diff --git a/src/ChangShaTour/ChangShaTour.pro b/src/ChangShaTour/ChangShaTour.pro index f9154a7..0e76c6c 100755 --- a/src/ChangShaTour/ChangShaTour.pro +++ b/src/ChangShaTour/ChangShaTour.pro @@ -36,6 +36,7 @@ SOURCES += \ popwidget.cpp \ preferencewidget.cpp \ recommendwidget.cpp \ + recroutemanager.cpp \ registermanager.cpp \ registerwidget.cpp \ route.cpp \ @@ -71,6 +72,7 @@ HEADERS += \ popwidget.h \ preferencewidget.h \ recommendwidget.h \ + recroutemanager.h \ registermanager.h \ registerwidget.h \ route.h \ diff --git a/src/ChangShaTour/ChangShaTour.pro.user b/src/ChangShaTour/ChangShaTour.pro.user index 7476665..526ee50 100755 --- a/src/ChangShaTour/ChangShaTour.pro.user +++ b/src/ChangShaTour/ChangShaTour.pro.user @@ -1,10 +1,10 @@ - + EnvironmentId - {61ba832e-6c30-4ab6-b0b8-ace44f46ca0c} + {4109ff11-a646-43d1-9619-aeb32783df6e} ProjectExplorer.Project.ActiveTarget @@ -44,8 +44,8 @@ true 0 8 - false - 0 + true + 1 true true true @@ -67,11 +67,11 @@ Desktop Qt 5.14.2 MSVC2017 64bit Desktop Qt 5.14.2 MSVC2017 64bit qt.qt5.5142.win64_msvc2017_64_kit - 1 + 0 0 0 - D:/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Debug + E:/ChangShaTour/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Debug true @@ -119,7 +119,7 @@ 2 - D:/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Release + E:/ChangShaTour/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Release true @@ -167,7 +167,7 @@ 0 - D:/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Profile + E:/ChangShaTour/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Profile true @@ -288,8 +288,8 @@ 2 ChangShaTour2 - Qt4ProjectManager.Qt4RunConfiguration:D:/gitRepositories/TourInChangSha/src/ChangShaTour/ChangShaTour.pro - D:/gitRepositories/TourInChangSha/src/ChangShaTour/ChangShaTour.pro + Qt4ProjectManager.Qt4RunConfiguration:C:/Users/13648/Desktop/Trip-in-Chang-sha-af8bc36c519e12df61b843ed226798781f589b26/ChangShaTour/ChangShaTour.pro + C:/Users/13648/Desktop/Trip-in-Chang-sha-af8bc36c519e12df61b843ed226798781f589b26/ChangShaTour/ChangShaTour.pro false @@ -300,256 +300,13 @@ false true - D:/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Release + E:/ChangShaTour/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Debug 1 ProjectExplorer.Project.Target.1 - - Desktop Qt 5.14.2 MinGW 32-bit - Desktop Qt 5.14.2 MinGW 32-bit - qt.qt5.5142.win32_mingw73_kit - 0 - 0 - 0 - - D:/build-ChangShaTour-Desktop_Qt_5_14_2_MinGW_32_bit-Debug - - - true - QtProjectManager.QMakeBuildStep - true - - false - false - false - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - Qt4ProjectManager.Qt4BuildConfiguration - 2 - - - D:/build-ChangShaTour-Desktop_Qt_5_14_2_MinGW_32_bit-Release - - - true - QtProjectManager.QMakeBuildStep - false - - false - false - true - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - Qt4ProjectManager.Qt4BuildConfiguration - 0 - - - D:/build-ChangShaTour-Desktop_Qt_5_14_2_MinGW_32_bit-Profile - - - true - QtProjectManager.QMakeBuildStep - true - - false - true - true - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Profile - Qt4ProjectManager.Qt4BuildConfiguration - 0 - - 3 - - - 0 - Deploy - Deploy - ProjectExplorer.BuildSteps.Deploy - - 1 - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - - ProjectExplorer.CustomExecutableRunConfiguration - - - false - - false - true - false - false - true - - - - 1 - - - - ProjectExplorer.Project.Target.2 Desktop Qt 5.14.2 MinGW 64-bit Desktop Qt 5.14.2 MinGW 64-bit @@ -558,7 +315,7 @@ 0 0 - D:/build-ChangShaTour-Desktop_Qt_5_14_2_MinGW_64_bit-Debug + E:/ChangShaTour/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MinGW_64_bit-Debug true @@ -606,7 +363,7 @@ 2 - D:/build-ChangShaTour-Desktop_Qt_5_14_2_MinGW_64_bit-Release + E:/ChangShaTour/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MinGW_64_bit-Release true @@ -654,7 +411,7 @@ 0 - D:/build-ChangShaTour-Desktop_Qt_5_14_2_MinGW_64_bit-Profile + E:/ChangShaTour/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MinGW_64_bit-Profile true @@ -793,7 +550,7 @@ ProjectExplorer.Project.TargetCount - 3 + 2 ProjectExplorer.Project.Updater.FileVersion diff --git a/src/ChangShaTour/ChangShaTour.pro.user.0c4c8cc b/src/ChangShaTour/ChangShaTour.pro.user.0c4c8cc new file mode 100644 index 0000000..08f2061 --- /dev/null +++ b/src/ChangShaTour/ChangShaTour.pro.user.0c4c8cc @@ -0,0 +1,319 @@ + + + + + + EnvironmentId + {0c4c8ccc-c524-4850-ba23-7e124d5915df} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + -fno-delayed-template-parsing + + true + + + + ProjectExplorer.Project.Target.0 + + Desktop Qt 5.14.2 MSVC2017 64bit + Desktop Qt 5.14.2 MSVC2017 64bit + qt.qt5.5142.win64_msvc2017_64_kit + 0 + 0 + 0 + + F:/QtDemo/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Debug + + + true + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + F:/QtDemo/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Release + + + true + QtProjectManager.QMakeBuildStep + false + + false + false + true + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + + F:/QtDemo/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Profile + + + true + QtProjectManager.QMakeBuildStep + true + + false + true + true + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + Qt4ProjectManager.Qt4RunConfiguration:F:/QtDemo/ChangShaTour/ChangShaTour.pro + F:/QtDemo/ChangShaTour/ChangShaTour.pro + + false + + false + true + true + false + false + true + + F:/QtDemo/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Debug + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/src/ChangShaTour/ChangShaTour.pro.user.4109ff1 b/src/ChangShaTour/ChangShaTour.pro.user.4109ff1 new file mode 100644 index 0000000..54b70f7 --- /dev/null +++ b/src/ChangShaTour/ChangShaTour.pro.user.4109ff1 @@ -0,0 +1,562 @@ + + + + + + EnvironmentId + {4109ff11-a646-43d1-9619-aeb32783df6e} + + + ProjectExplorer.Project.ActiveTarget + 1 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + -fno-delayed-template-parsing + + true + + + + ProjectExplorer.Project.Target.0 + + Desktop Qt 5.14.2 MinGW 64-bit + Desktop Qt 5.14.2 MinGW 64-bit + qt.qt5.5142.win64_mingw73_kit + 0 + 0 + 0 + + E:/ChangShaTour/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MinGW_64_bit-Debug + + + true + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + E:/ChangShaTour/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MinGW_64_bit-Release + + + true + QtProjectManager.QMakeBuildStep + false + + false + false + true + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + + E:/ChangShaTour/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MinGW_64_bit-Profile + + + true + QtProjectManager.QMakeBuildStep + true + + false + true + true + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + + ProjectExplorer.CustomExecutableRunConfiguration + + + false + + false + true + false + false + true + + + + 1 + + + + ProjectExplorer.Project.Target.1 + + Desktop Qt 5.14.2 MSVC2017 64bit + Desktop Qt 5.14.2 MSVC2017 64bit + qt.qt5.5142.win64_msvc2017_64_kit + 0 + 0 + 0 + + E:/ChangShaTour/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Debug + + + true + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + E:/ChangShaTour/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Release + + + true + QtProjectManager.QMakeBuildStep + false + + false + false + true + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + + E:/ChangShaTour/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Profile + + + true + QtProjectManager.QMakeBuildStep + true + + false + true + true + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + Qt4ProjectManager.Qt4RunConfiguration:E:/ChangShaTour/Trip-in-Chang-sha/ChangShaTour/ChangShaTour.pro + E:/ChangShaTour/Trip-in-Chang-sha/ChangShaTour/ChangShaTour.pro + + false + + false + true + true + false + false + true + + E:/ChangShaTour/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Debug + + 1 + + + + ProjectExplorer.Project.TargetCount + 2 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/src/ChangShaTour/ChangShaTour.pro.user.61ba832 b/src/ChangShaTour/ChangShaTour.pro.user.61ba832 new file mode 100644 index 0000000..e2c9e33 --- /dev/null +++ b/src/ChangShaTour/ChangShaTour.pro.user.61ba832 @@ -0,0 +1,805 @@ + + + + + + EnvironmentId + {61ba832e-6c30-4ab6-b0b8-ace44f46ca0c} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + false + 0 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + -fno-delayed-template-parsing + + true + + + + ProjectExplorer.Project.Target.0 + + Desktop Qt 5.14.2 MSVC2017 64bit + Desktop Qt 5.14.2 MSVC2017 64bit + qt.qt5.5142.win64_msvc2017_64_kit + 0 + 0 + 0 + + D:/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Debug + + + true + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + D:/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Release + + + true + QtProjectManager.QMakeBuildStep + false + + false + false + true + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + + D:/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Profile + + + true + QtProjectManager.QMakeBuildStep + true + + false + true + true + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + Qt4ProjectManager.Qt4RunConfiguration:D:/ChangShaTour/ChangShaTour.pro + D:/ChangShaTour/ChangShaTour.pro + + false + + false + true + true + false + false + true + + D:/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Debug + + 1 + + + + ProjectExplorer.Project.Target.1 + + Desktop Qt 5.14.2 MinGW 32-bit + Desktop Qt 5.14.2 MinGW 32-bit + qt.qt5.5142.win32_mingw73_kit + 0 + 0 + 0 + + D:/build-ChangShaTour-Desktop_Qt_5_14_2_MinGW_32_bit-Debug + + + true + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + D:/build-ChangShaTour-Desktop_Qt_5_14_2_MinGW_32_bit-Release + + + true + QtProjectManager.QMakeBuildStep + false + + false + false + true + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + + D:/build-ChangShaTour-Desktop_Qt_5_14_2_MinGW_32_bit-Profile + + + true + QtProjectManager.QMakeBuildStep + true + + false + true + true + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + + ProjectExplorer.CustomExecutableRunConfiguration + + + false + + false + true + false + false + true + + + + 1 + + + + ProjectExplorer.Project.Target.2 + + Desktop Qt 5.14.2 MinGW 64-bit + Desktop Qt 5.14.2 MinGW 64-bit + qt.qt5.5142.win64_mingw73_kit + 0 + 0 + 0 + + D:/build-ChangShaTour-Desktop_Qt_5_14_2_MinGW_64_bit-Debug + + + true + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + D:/build-ChangShaTour-Desktop_Qt_5_14_2_MinGW_64_bit-Release + + + true + QtProjectManager.QMakeBuildStep + false + + false + false + true + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + + D:/build-ChangShaTour-Desktop_Qt_5_14_2_MinGW_64_bit-Profile + + + true + QtProjectManager.QMakeBuildStep + true + + false + true + true + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + + ProjectExplorer.CustomExecutableRunConfiguration + + + false + + false + true + false + false + true + + + + 1 + + + + ProjectExplorer.Project.TargetCount + 3 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/src/ChangShaTour/ChangShaTour.pro.user.c9f9416 b/src/ChangShaTour/ChangShaTour.pro.user.c9f9416 new file mode 100644 index 0000000..57a164a --- /dev/null +++ b/src/ChangShaTour/ChangShaTour.pro.user.c9f9416 @@ -0,0 +1,562 @@ + + + + + + EnvironmentId + {c9f94164-08c8-4e3c-b552-0ae5039b502e} + + + ProjectExplorer.Project.ActiveTarget + 1 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + -fno-delayed-template-parsing + + true + + + + ProjectExplorer.Project.Target.0 + + Desktop Qt 5.14.2 MSVC2017 32bit + Desktop Qt 5.14.2 MSVC2017 32bit + qt.qt5.5142.win32_msvc2017_kit + 0 + 0 + 0 + + D:/kunlin/OneDrive/QT project/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_32bit-Debug + + + true + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + D:/kunlin/OneDrive/QT project/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_32bit-Release + + + true + QtProjectManager.QMakeBuildStep + false + + false + false + true + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + + D:/kunlin/OneDrive/QT project/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_32bit-Profile + + + true + QtProjectManager.QMakeBuildStep + true + + false + true + true + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + Qt4ProjectManager.Qt4RunConfiguration:D:/kunlin/OneDrive/QT project/ChangShaTour/ChangShaTour.pro + D:/kunlin/OneDrive/QT project/ChangShaTour/ChangShaTour.pro + + false + + false + true + true + false + false + true + + D:/kunlin/OneDrive/QT project/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_32bit-Debug + + 1 + + + + ProjectExplorer.Project.Target.1 + + Desktop Qt 5.14.2 MSVC2017 64bit + Desktop Qt 5.14.2 MSVC2017 64bit + qt.qt5.5142.win64_msvc2017_64_kit + 1 + 0 + 0 + + D:/kunlin/OneDrive/QT project/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Debug + + + true + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + D:/kunlin/OneDrive/QT project/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Release + + + true + QtProjectManager.QMakeBuildStep + false + + false + false + true + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + + D:/kunlin/OneDrive/QT project/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Profile + + + true + QtProjectManager.QMakeBuildStep + true + + false + true + true + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + Qt4ProjectManager.Qt4RunConfiguration:D:/kunlin/OneDrive/QT project/ChangShaTour/ChangShaTour.pro + D:/kunlin/OneDrive/QT project/ChangShaTour/ChangShaTour.pro + + false + + false + true + true + false + false + true + + D:/kunlin/OneDrive/QT project/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Release + + 1 + + + + ProjectExplorer.Project.TargetCount + 2 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/src/ChangShaTour/RouteItem.h b/src/ChangShaTour/RouteItem.h index 5afefeb..7f450bd 100755 --- a/src/ChangShaTour/RouteItem.h +++ b/src/ChangShaTour/RouteItem.h @@ -1,22 +1,22 @@ -#include -#include -#include -#ifndef ROUTEITEM_H -#define ROUTEITEM_H -struct routeItem{ - QString placeName; - QString url; - QString cateId; - QDateTime startTime; - QDateTime endTime; - QString traffic; - double distance; - double timeCost; - QString description; - struct routeItem * next; -}; -typedef struct routeItem RouteItem; - - - -#endif // ROUTEITEM_H +#include +#include +#include +#ifndef ROUTEITEM_H +#define ROUTEITEM_H +struct routeItem{ + QString placeName; + QString url; + QString cateId; + QDateTime startTime; + QDateTime endTime; + QString traffic; + double distance; + double timeCost; + QString description; + struct routeItem * next; +}; +typedef struct routeItem RouteItem; + + + +#endif // ROUTEITEM_H diff --git a/src/ChangShaTour/addhistory.cpp b/src/ChangShaTour/addhistory.cpp index 7460ae6..152be19 100755 --- a/src/ChangShaTour/addhistory.cpp +++ b/src/ChangShaTour/addhistory.cpp @@ -1,47 +1,47 @@ -#include "addhistory.h" -//将店铺的链接加入history数据库 -AddHistory::AddHistory() -{ - -} -void AddHistory::add(QString url) -{ - QSqlQuery query(userDb); - query.prepare("select historyId from history where url=?"); - query.addBindValue(url); - query.exec(); - query.next(); - if(query.isValid()) - { - query.prepare("update history set createdtime = now() where url=?"); - query.addBindValue(url); - query.exec(); - return ; - } - query.prepare("select count(*) from history where id = ?"); - query.addBindValue(Id); - query.exec(); - query.next(); - int count=query.value(0).toInt(); - if(count>=limit) - { - query.prepare("select historyId from history where id = ? order by createdtime"); - query.addBindValue(Id); - query.exec(); - query.next(); - int historyId=query.value("historyId").toInt(); - query.prepare("update history set url = ?, createdtime = now() where historyId=?"); - query.addBindValue(url); - query.addBindValue(historyId); - query.exec(); - } - else - { - - query.prepare("insert into history (id,url)values(?,?)"); - query.addBindValue(Id); - query.addBindValue(url); - query.exec(); - } - -} +#include "addhistory.h" +//将店铺的链接加入history数据库 +AddHistory::AddHistory() +{ + +} +void AddHistory::add(QString url) +{ + QSqlQuery query(userDb); + query.prepare("select historyId from history where url=?"); + query.addBindValue(url); + query.exec(); + query.next(); + if(query.isValid()) + { + query.prepare("update history set createdtime = now() where url=?"); + query.addBindValue(url); + query.exec(); + return ; + } + query.prepare("select count(*) from history where id = ?"); + query.addBindValue(Id); + query.exec(); + query.next(); + int count=query.value(0).toInt(); + if(count>=limit) + { + query.prepare("select historyId from history where id = ? order by createdtime"); + query.addBindValue(Id); + query.exec(); + query.next(); + int historyId=query.value("historyId").toInt(); + query.prepare("update history set url = ?, createdtime = now() where historyId=?"); + query.addBindValue(url); + query.addBindValue(historyId); + query.exec(); + } + else + { + + query.prepare("insert into history (id,url)values(?,?)"); + query.addBindValue(Id); + query.addBindValue(url); + query.exec(); + } + +} diff --git a/src/ChangShaTour/addhistory.h b/src/ChangShaTour/addhistory.h index e2f1b9a..507e9a6 100755 --- a/src/ChangShaTour/addhistory.h +++ b/src/ChangShaTour/addhistory.h @@ -1,16 +1,16 @@ -#ifndef ADDHISTORY_H -#define ADDHISTORY_H -#include -#include -#include "cglobal.h" - -class AddHistory -{ -public: - AddHistory(); - void add(QString id); -private: - int limit; -}; - -#endif // ADDHISTORY_H +#ifndef ADDHISTORY_H +#define ADDHISTORY_H +#include +#include +#include "cglobal.h" + +class AddHistory +{ +public: + AddHistory(); + void add(QString id); +private: + int limit; +}; + +#endif // ADDHISTORY_H diff --git a/src/ChangShaTour/cglobal.cpp b/src/ChangShaTour/cglobal.cpp index 525caed..ac03d70 100755 --- a/src/ChangShaTour/cglobal.cpp +++ b/src/ChangShaTour/cglobal.cpp @@ -1,101 +1,102 @@ -#include "cglobal.h" -qint64 Id; - -QSqlDatabase meituanDb; -QSqlDatabase userDb; -QSqlDatabase listDb; -QMap labelToDb; -QStringList recommendlabel; - - -cglobal::cglobal() -{ - -} -void cglobal::labelmap() -{ - //food - labelToDb[QStringLiteral("代金券")]="food"; - labelToDb[QStringLiteral("蛋糕甜点")]="food"; - labelToDb[QStringLiteral("自助餐")]="food"; - labelToDb[QStringLiteral("小吃快餐")]="food"; - labelToDb[QStringLiteral("火锅")]="food"; - labelToDb[QStringLiteral("日韩料理")]="food"; - labelToDb[QStringLiteral("西餐")]="food"; - labelToDb[QStringLiteral("烧烤烤肉")]="food"; - labelToDb[QStringLiteral("川湘菜")]="food"; - labelToDb[QStringLiteral("东北菜")]="food"; - labelToDb[QStringLiteral("江浙菜")]="food"; - labelToDb[QStringLiteral("中式烧烤/烤串")]="food"; - labelToDb[QStringLiteral("香锅烤鱼")]="food"; - labelToDb[QStringLiteral("粤菜")]="food"; - labelToDb[QStringLiteral("西北菜")]="food"; - labelToDb[QStringLiteral("咖啡酒吧")]="food"; - labelToDb[QStringLiteral("京菜鲁菜")]="food"; - labelToDb[QStringLiteral("云贵菜")]="food"; - labelToDb[QStringLiteral("东南亚菜")]="food"; - labelToDb[QStringLiteral("海鲜")]="food"; - labelToDb[QStringLiteral("素食")]="food"; - labelToDb[QStringLiteral("台湾/客家菜")]="food"; - labelToDb[QStringLiteral("创意菜")]="food"; - labelToDb[QStringLiteral("汤/洲/炖菜")]="food"; - labelToDb[QStringLiteral("蒙餐")]="food"; - labelToDb[QStringLiteral("新疆菜")]="food"; - labelToDb[QStringLiteral("其他美食")]="food"; - labelToDb[QStringLiteral("聚餐宴请")]="food"; - //attractions - labelToDb[QStringLiteral("景点")]="attractions"; - //entertainment - labelToDb[QStringLiteral("新奇体验")]="entertainment"; - labelToDb[QStringLiteral("团建拓展")]="entertainment"; - labelToDb[QStringLiteral("足疗/按摩")]="entertainment"; - labelToDb[QStringLiteral("洗浴/汗蒸")]="entertainment"; - labelToDb[QStringLiteral("KTV")]="entertainment"; - labelToDb[QStringLiteral("酒吧")]="entertainment"; - labelToDb[QStringLiteral("电玩/游戏厅")]="entertainment"; - labelToDb[QStringLiteral("运动健身")]="entertainment"; - labelToDb[QStringLiteral("私人影院")]="entertainment"; - labelToDb[QStringLiteral("DIY手工坊")]="entertainment"; - labelToDb[QStringLiteral("密室逃脱")]="entertainment"; - labelToDb[QStringLiteral("网吧网咖")]="entertainment"; - labelToDb[QStringLiteral("茶馆")]="entertainment"; - labelToDb[QStringLiteral("轰趴馆")]="entertainment"; - labelToDb[QStringLiteral("棋牌室")]="entertainment"; - labelToDb[QStringLiteral("桌游")]="entertainment"; - labelToDb[QStringLiteral("真人CS")]="entertainment"; - labelToDb[QStringLiteral("采摘/农家乐")]="entertainment"; - labelToDb[QStringLiteral("VR")]="entertainment"; - //hotel - labelToDb[QStringLiteral("经济型酒店")]="hotel"; - labelToDb[QStringLiteral("主题酒店")]="hotel"; - labelToDb[QStringLiteral("商务酒店")]="hotel"; - labelToDb[QStringLiteral("公寓")]="hotel"; - labelToDb[QStringLiteral("豪华酒店")]="hotel"; - labelToDb[QStringLiteral("客栈")]="hotel"; - labelToDb[QStringLiteral("青年旅社")]="hotel"; - labelToDb[QStringLiteral("度假酒店")]="hotel"; - labelToDb[QStringLiteral("别墅")]="hotel"; - labelToDb[QStringLiteral("民宿")]="hotel"; - //sport - labelToDb[QStringLiteral("滑翔伞")]="sport"; - labelToDb[QStringLiteral("赛车")]="sport"; - labelToDb[QStringLiteral("游泳")]="sport"; - labelToDb[QStringLiteral("健身中心")]="sport"; - labelToDb[QStringLiteral("羽毛球")]="sport"; - labelToDb[QStringLiteral("台球")]="sport"; - labelToDb[QStringLiteral("武术")]="sport"; - labelToDb[QStringLiteral("保龄球")]="sport"; - labelToDb[QStringLiteral("高尔夫")]="sport"; - labelToDb[QStringLiteral("篮球")]="sport"; - labelToDb[QStringLiteral("滑冰")]="sport"; - labelToDb[QStringLiteral("射击射箭")]="sport"; - labelToDb[QStringLiteral("网球")]="sport"; - labelToDb[QStringLiteral("骑马")]="sport"; - labelToDb[QStringLiteral("乒乓球")]="sport"; - labelToDb[QStringLiteral("体育球馆")]="sport"; - - recommendlabel< labelToDb; +QStringList recommendlabel; + + +cglobal::cglobal() +{ + +} +void cglobal::labelmap() +{ + //food + labelToDb[QStringLiteral("代金券")]="food"; + labelToDb[QStringLiteral("蛋糕甜点")]="food"; + labelToDb[QStringLiteral("自助餐")]="food"; + labelToDb[QStringLiteral("小吃快餐")]="food"; + labelToDb[QStringLiteral("火锅")]="food"; + labelToDb[QStringLiteral("日韩料理")]="food"; + labelToDb[QStringLiteral("西餐")]="food"; + labelToDb[QStringLiteral("烧烤烤肉")]="food"; + labelToDb[QStringLiteral("川湘菜")]="food"; + labelToDb[QStringLiteral("东北菜")]="food"; + labelToDb[QStringLiteral("江浙菜")]="food"; + labelToDb[QStringLiteral("中式烧烤/烤串")]="food"; + labelToDb[QStringLiteral("香锅烤鱼")]="food"; + labelToDb[QStringLiteral("粤菜")]="food"; + labelToDb[QStringLiteral("西北菜")]="food"; + labelToDb[QStringLiteral("咖啡酒吧")]="food"; + labelToDb[QStringLiteral("京菜鲁菜")]="food"; + labelToDb[QStringLiteral("云贵菜")]="food"; + labelToDb[QStringLiteral("东南亚菜")]="food"; + labelToDb[QStringLiteral("海鲜")]="food"; + labelToDb[QStringLiteral("素食")]="food"; + labelToDb[QStringLiteral("台湾/客家菜")]="food"; + labelToDb[QStringLiteral("创意菜")]="food"; + labelToDb[QStringLiteral("汤/洲/炖菜")]="food"; + labelToDb[QStringLiteral("蒙餐")]="food"; + labelToDb[QStringLiteral("新疆菜")]="food"; + labelToDb[QStringLiteral("其他美食")]="food"; + labelToDb[QStringLiteral("聚餐宴请")]="food"; + //attractions + labelToDb[QStringLiteral("景点")]="attractions"; + //entertainment + labelToDb[QStringLiteral("新奇体验")]="entertainment"; + labelToDb[QStringLiteral("团建拓展")]="entertainment"; + labelToDb[QStringLiteral("足疗/按摩")]="entertainment"; + labelToDb[QStringLiteral("洗浴/汗蒸")]="entertainment"; + labelToDb[QStringLiteral("KTV")]="entertainment"; + labelToDb[QStringLiteral("酒吧")]="entertainment"; + labelToDb[QStringLiteral("电玩/游戏厅")]="entertainment"; + labelToDb[QStringLiteral("运动健身")]="entertainment"; + labelToDb[QStringLiteral("私人影院")]="entertainment"; + labelToDb[QStringLiteral("DIY手工坊")]="entertainment"; + labelToDb[QStringLiteral("密室逃脱")]="entertainment"; + labelToDb[QStringLiteral("网吧网咖")]="entertainment"; + labelToDb[QStringLiteral("茶馆")]="entertainment"; + labelToDb[QStringLiteral("轰趴馆")]="entertainment"; + labelToDb[QStringLiteral("棋牌室")]="entertainment"; + labelToDb[QStringLiteral("桌游")]="entertainment"; + labelToDb[QStringLiteral("真人CS")]="entertainment"; + labelToDb[QStringLiteral("采摘/农家乐")]="entertainment"; + labelToDb[QStringLiteral("VR")]="entertainment"; + //hotel + labelToDb[QStringLiteral("经济型酒店")]="hotel"; + labelToDb[QStringLiteral("主题酒店")]="hotel"; + labelToDb[QStringLiteral("商务酒店")]="hotel"; + labelToDb[QStringLiteral("公寓")]="hotel"; + labelToDb[QStringLiteral("豪华酒店")]="hotel"; + labelToDb[QStringLiteral("客栈")]="hotel"; + labelToDb[QStringLiteral("青年旅社")]="hotel"; + labelToDb[QStringLiteral("度假酒店")]="hotel"; + labelToDb[QStringLiteral("别墅")]="hotel"; + labelToDb[QStringLiteral("民宿")]="hotel"; + //sport + labelToDb[QStringLiteral("滑翔伞")]="sport"; + labelToDb[QStringLiteral("赛车")]="sport"; + labelToDb[QStringLiteral("游泳")]="sport"; + labelToDb[QStringLiteral("健身中心")]="sport"; + labelToDb[QStringLiteral("羽毛球")]="sport"; + labelToDb[QStringLiteral("台球")]="sport"; + labelToDb[QStringLiteral("武术")]="sport"; + labelToDb[QStringLiteral("保龄球")]="sport"; + labelToDb[QStringLiteral("高尔夫")]="sport"; + labelToDb[QStringLiteral("篮球")]="sport"; + labelToDb[QStringLiteral("滑冰")]="sport"; + labelToDb[QStringLiteral("射击射箭")]="sport"; + labelToDb[QStringLiteral("网球")]="sport"; + labelToDb[QStringLiteral("骑马")]="sport"; + labelToDb[QStringLiteral("乒乓球")]="sport"; + labelToDb[QStringLiteral("体育球馆")]="sport"; + + recommendlabel< -#include -#include -#include -//全局变量定义文件,include该文件即可获得用户Id -extern qint64 Id; - -extern QSqlDatabase meituanDb; -extern QSqlDatabase userDb; -extern QSqlDatabase listDb; -extern QMap labelToDb; -extern QStringList recommendlabel; - -class cglobal -{ -public: - cglobal(); - void labelmap(); -}; - -#endif // CGLOBAL_H +#ifndef CGLOBAL_H +#define CGLOBAL_H +#include +#include +#include +#include +//全局变量定义文件,include该文件即可获得用户Id +extern qint64 Id; + +extern QSqlDatabase meituanDb; +extern QSqlDatabase userDb; +extern QSqlDatabase listDb; +extern QSqlDatabase routeDb; +extern QMap labelToDb; +extern QStringList recommendlabel; + +class cglobal +{ +public: + cglobal(); + void labelmap(); +}; + +#endif // CGLOBAL_H diff --git a/src/ChangShaTour/conditionwidget.cpp b/src/ChangShaTour/conditionwidget.cpp index 360f8df..aa9fa32 100755 --- a/src/ChangShaTour/conditionwidget.cpp +++ b/src/ChangShaTour/conditionwidget.cpp @@ -7,13 +7,19 @@ ConditionWidget::ConditionWidget(QWidget *parent) : { ui->setupUi(this); + initConditionWidget(); +} + +void ConditionWidget::initConditionWidget() +{ QVBoxLayout * verticalLayout = new QVBoxLayout(); - QHBoxLayout * dateTimeHorizontalLayout = new QHBoxLayout(); - QHBoxLayout * placeHorizontalLayout = new QHBoxLayout(); + /*QHBoxLayout * dateTimeHorizontalLayout = new QHBoxLayout(); + QHBoxLayout * placeHorizontalLayout = new QHBoxLayout();*/ + QHBoxLayout * dayHorizontalLayout = new QHBoxLayout(); QHBoxLayout * numberHorizontalLayout = new QHBoxLayout(); QHBoxLayout * budgetHorizontalLayout = new QHBoxLayout(); - QLabel * startDateTimeLabel = new QLabel("start time"); + /*QLabel * startDateTimeLabel = new QLabel("start time"); startDateTime = new QDateTimeEdit(); QLabel * endDateTimeLabel = new QLabel("结束时间"); endDateTime = new QDateTimeEdit(); @@ -29,30 +35,53 @@ ConditionWidget::ConditionWidget(QWidget *parent) : placeHorizontalLayout->addWidget(startPlaceLabel); placeHorizontalLayout->addWidget(startPlace); placeHorizontalLayout->addWidget(endPlaceLabel); - placeHorizontalLayout->addWidget(endPlace); + placeHorizontalLayout->addWidget(endPlace);*/ + + QLabel * dayLabel = new QLabel("天数"); + dayLine = new QLineEdit(); + dayLine->setPlaceholderText("请输入一个1~10之间的整数"); + dayLine->setValidator(new QIntValidator(dayLine)); + dayHorizontalLayout->addWidget(dayLabel); + dayHorizontalLayout->addWidget(dayLine); QLabel * numberLabel = new QLabel("人数"); numberLine = new QLineEdit(); - numberLine->setPlaceholderText("enter an integer between 0 and 8"); + numberLine->setPlaceholderText("请输入一个1~8之间的整数"); numberLine->setValidator(new QIntValidator(numberLine)); numberHorizontalLayout->addWidget(numberLabel); numberHorizontalLayout->addWidget(numberLine); QLabel * budgetLabel = new QLabel("预算"); budgetLine = new QLineEdit(); - budgetLine->setPlaceholderText("enter an integer"); + budgetLine->setPlaceholderText("请输入一个50000以内的整数"); budgetLine->setValidator(new QIntValidator(budgetLine)); budgetHorizontalLayout->addWidget(budgetLabel); budgetHorizontalLayout->addWidget(budgetLine); - verticalLayout->addLayout(dateTimeHorizontalLayout); - verticalLayout->addLayout(placeHorizontalLayout); + /*verticalLayout->addLayout(dateTimeHorizontalLayout); + verticalLayout->addLayout(placeHorizontalLayout);*/ + verticalLayout->addLayout(dayHorizontalLayout); verticalLayout->addLayout(numberHorizontalLayout); verticalLayout->addLayout(budgetHorizontalLayout); this->setLayout(verticalLayout); } +int ConditionWidget::getDay() +{ + return (dayLine->text()).toInt(); +} + +int ConditionWidget::getNumber() +{ + return (numberLine->text()).toInt(); +} + +int ConditionWidget::getBudget() +{ + return (budgetLine->text()).toInt(); +} + ConditionWidget::~ConditionWidget() { delete ui; diff --git a/src/ChangShaTour/conditionwidget.h b/src/ChangShaTour/conditionwidget.h index 8e8cb27..2512dc4 100755 --- a/src/ChangShaTour/conditionwidget.h +++ b/src/ChangShaTour/conditionwidget.h @@ -24,6 +24,11 @@ public: explicit ConditionWidget(QWidget *parent = nullptr); ~ConditionWidget(); + void initConditionWidget(); + int getDay(); + int getNumber(); + int getBudget(); + private: Ui::ConditionWidget *ui; @@ -31,6 +36,7 @@ private: QDateTimeEdit * endDateTime; QLineEdit * startPlace; QLineEdit * endPlace; + QLineEdit * dayLine; QLineEdit * numberLine; QLineEdit * budgetLine; }; diff --git a/src/ChangShaTour/customizewidget.cpp b/src/ChangShaTour/customizewidget.cpp index 33a4b6d..2b6fbb9 100755 --- a/src/ChangShaTour/customizewidget.cpp +++ b/src/ChangShaTour/customizewidget.cpp @@ -10,9 +10,12 @@ CustomizeWidget::CustomizeWidget(QWidget *parent) : qDebug("Creating CustomizeWidget..."); num = 1; - limit = 12; + limit = 16; + dayLimit = 3; + r = new Route(); startTimeList = new QDateTime[limit]; endTimeList = new QDateTime[limit]; + for(int i = 0; i < limit; i++) { nameList.append(""); @@ -24,7 +27,7 @@ CustomizeWidget::CustomizeWidget(QWidget *parent) : mainLayout = new QVBoxLayout(); - title = new QLabel("现在开始定制您的路线\n点击空白按钮就可以向路线中添加场所"); + title = new QLabel("现在开始定制您的路线\n点击空白按钮就可以向路线中添加场所\n场所的起始/结束时间表示了您想在该场所游玩的时间段"); title->setAlignment(Qt::AlignCenter); format = new QHBoxLayout(); @@ -203,11 +206,10 @@ void CustomizeWidget::getResult(int index, QStringList chosen) placeBtnList[index]->setText(nameList[index]); } -Route * CustomizeWidget::genRoute() +bool CustomizeWidget::genRoute() { int length = 0; int *position = (int *)malloc(sizeof(int) * limit); - Route *r = new Route(); QStringList title; QStringList url; @@ -218,6 +220,11 @@ Route * CustomizeWidget::genRoute() double * distanceList = (double *)malloc(sizeof(double) * limit); double * timeCostList = (double *)malloc(sizeof(double) * limit); QStringList descriptionList; + + uint eTime = 4294967295; + uint lTime = 0; + + //检查路线是否合法 for (int i = 0; i < num; i++) { if (nameList[i] != "") @@ -226,9 +233,27 @@ Route * CustomizeWidget::genRoute() length++; startTimeList[i] = startEditList[i]->dateTime(); endTimeList[i] = endEditList[i]->dateTime(); + uint start = startTimeList[i].toTime_t(); + uint end = endTimeList[i].toTime_t(); + if (end <= start) + { + QMessageBox::warning(this, "Warning", "场所的终止时间要晚于起始时间!"); + return false; + } + if (start < eTime) + eTime = start; + if (end > lTime) + lTime = end; } } + if ((lTime - eTime) > ((uint)dayLimit*(24*3600))) + { + QMessageBox::warning(this, "Warning", "整条行程的时间跨度不可超过" + QString::number(dayLimit) + "天!"); + return false; + } + + //合法后进行路线生成 qDebug() << "CustomizeWidget Route length:" << length; for (int j = 0; j < length; j++) { @@ -244,6 +269,10 @@ Route * CustomizeWidget::genRoute() } r->setAllItems(title, url, cateId, startTime, endTime, trafficList, distanceList, timeCostList, descriptionList); + return true; +} +Route * CustomizeWidget::getRoute() +{ return r; } diff --git a/src/ChangShaTour/customizewidget.h b/src/ChangShaTour/customizewidget.h index ff0ab1d..dc3455f 100755 --- a/src/ChangShaTour/customizewidget.h +++ b/src/ChangShaTour/customizewidget.h @@ -12,6 +12,7 @@ #include #include #include +#include #include "popwidget.h" #include "route.h" @@ -37,13 +38,16 @@ public: void setBtn(int index); QString getBtn(int index); void getResult(int index, QStringList chosen); - Route *genRoute(); + bool genRoute(); + Route *getRoute(); private: Ui::CustomizeWidget *ui; int num; int limit; + int dayLimit; + Route *r; QStringList nameList; QStringList urlList; QStringList cateIdList; diff --git a/src/ChangShaTour/favoritewidget.cpp b/src/ChangShaTour/favoritewidget.cpp index 6534136..ff9778f 100755 --- a/src/ChangShaTour/favoritewidget.cpp +++ b/src/ChangShaTour/favoritewidget.cpp @@ -13,7 +13,7 @@ FavoriteWidget::FavoriteWidget(QWidget *parent) : verLayout = new QVBoxLayout(); setLayout(verLayout); - screenWidget = new QWidget(); +// screenWidget = new QWidget(); QHBoxLayout *screenLayout=new QHBoxLayout(); favoRoutesBtn=new QPushButton("路线收藏夹"); @@ -21,7 +21,7 @@ FavoriteWidget::FavoriteWidget(QWidget *parent) : screenLayout->addWidget(favoRoutesBtn); screenLayout->addWidget(favoPlacesBtn); - screenWidget->setLayout(screenLayout); +// screenWidget->setLayout(screenLayout); web = new WebWidget(); web->setVisible(false); @@ -32,7 +32,7 @@ FavoriteWidget::FavoriteWidget(QWidget *parent) : queryDatabase(); size = (size < limit? size: limit); - verLayout->addWidget(screenWidget); + verLayout->addLayout(screenLayout); verLayout->addWidget(web); setFavPlaceScreen(); setFavRouteScreen(); @@ -78,21 +78,24 @@ void FavoriteWidget::queryDatabase() void FavoriteWidget::webReturn() { invisibleAllScreens(); - screenWidget->setVisible(true); + favoRoutesBtn->setVisible(true); + favoPlacesBtn->setVisible(true); favoPlacesWidget->setVisible(true); } void FavoriteWidget::switchToPlace() { invisibleAllScreens(); - screenWidget->setVisible(true); + favoRoutesBtn->setVisible(true); + favoPlacesBtn->setVisible(true); favoPlacesWidget->setVisible(true); } void FavoriteWidget::switchToRoute() { invisibleAllScreens(); - screenWidget->setVisible(true); + favoRoutesBtn->setVisible(true); + favoPlacesBtn->setVisible(true); favoRoutesWidget->setVisible(true); } @@ -344,7 +347,8 @@ void FavoriteWidget::invisibleAllScreens() web->setVisible(false); favoPlacesWidget->setVisible(false); favoRoutesWidget->setVisible(false); - screenWidget->setVisible(false); + favoRoutesBtn->setVisible(false); + favoPlacesBtn->setVisible(false); } FavoriteWidget::~FavoriteWidget() diff --git a/src/ChangShaTour/homewidget.cpp b/src/ChangShaTour/homewidget.cpp index 6d0ae0d..ddb65c7 100755 --- a/src/ChangShaTour/homewidget.cpp +++ b/src/ChangShaTour/homewidget.cpp @@ -89,10 +89,11 @@ void HomeWidget::InitHomeWidget() { background = new QLabel(this); SetBackground("./softImages/homeWidget/homeWidgetBrownHalf.png"); + background->setMargin(30); QVBoxLayout * verLayout = new QVBoxLayout(); setLayout(verLayout); - verLayout->setMargin(0); + verLayout->setMargin(35); verLayout->setSpacing(0); subWidget = new QWidget(); diff --git a/src/ChangShaTour/imgdownloader.cpp b/src/ChangShaTour/imgdownloader.cpp index 58a6f03..5e89eb6 100755 --- a/src/ChangShaTour/imgdownloader.cpp +++ b/src/ChangShaTour/imgdownloader.cpp @@ -2,7 +2,9 @@ imgDownloader::imgDownloader() { - + QDir *root = new QDir(); + if (!root->exists("./images")) + root->mkdir("./images"); } void imgDownloader::downloadFileFromUrl(QString strUrl, QString strFilePath) @@ -10,14 +12,15 @@ void imgDownloader::downloadFileFromUrl(QString strUrl, QString strFilePath) // qDebug() << strUrl << " " << strFilePath; QFile file; file.setFileName(strFilePath); - if (!file.exists()) + QFileInfo fileInfo; + fileInfo.setFile(file); + if (file.exists() && (fileInfo.size() != 0)) + return; + if(file.open(QIODevice::WriteOnly)) { - if(file.open(QIODevice::WriteOnly)) - { - QByteArray byte = imgDownloader::InitGetRequest(strUrl, "downImgFromUrl"); - file.write(byte); - file.close(); - } + QByteArray byte = imgDownloader::InitGetRequest(strUrl, "downImgFromUrl"); + file.write(byte); + file.close(); } } diff --git a/src/ChangShaTour/imgdownloader.h b/src/ChangShaTour/imgdownloader.h index 7140aa5..b39e42c 100755 --- a/src/ChangShaTour/imgdownloader.h +++ b/src/ChangShaTour/imgdownloader.h @@ -11,6 +11,8 @@ #include #include #include +#include +#include #if _MSC_VER >= 1600 diff --git a/src/ChangShaTour/journywidget.h b/src/ChangShaTour/journywidget.h index a65f481..88c3dd2 100755 --- a/src/ChangShaTour/journywidget.h +++ b/src/ChangShaTour/journywidget.h @@ -32,7 +32,7 @@ public: private: Ui::JournyWidget *ui; - int numOfJourney = 0; + int numOfJourney; int * routeIdList; Route * journeyList; QVBoxLayout * verticalLayout; diff --git a/src/ChangShaTour/listwidget.cpp b/src/ChangShaTour/listwidget.cpp index 27e2a41..e31ccbc 100755 --- a/src/ChangShaTour/listwidget.cpp +++ b/src/ChangShaTour/listwidget.cpp @@ -9,82 +9,8 @@ ListWidget::ListWidget(QWidget *parent) : ui(new Ui::ListWidget) { ui->setupUi(this); - qDebug("Creating ListWidget..."); -// QSqlQuery queryList(listDb); -// QSqlQuery queryMeituan(meituanDb); - - listLen = 10; - mainLayout = new QVBoxLayout(); - - subWidget = new QWidget(); - listLayout = new QHBoxLayout(); - layout_1 = new QVBoxLayout(); - layout_2 = new QVBoxLayout(); - layout_3 = new QVBoxLayout(); - title_1 = new QLabel(); - title_2 = new QLabel(); - title_3 = new QLabel(); - - //lineList第一行是标题行,其余listLen个是按钮行 - lineList_1 = (QHBoxLayout **)malloc(sizeof(QHBoxLayout *) * (listLen + 1)); - lineList_2 = (QHBoxLayout **)malloc(sizeof(QHBoxLayout *) * (listLen + 1)); - lineList_3 = (QHBoxLayout **)malloc(sizeof(QHBoxLayout *) * (listLen + 1)); - rankList_1 = (QLabel **)malloc(sizeof(QLabel *) * listLen); - rankList_2 = (QLabel **)malloc(sizeof(QLabel *) * listLen); - rankList_3 = (QLabel **)malloc(sizeof(QLabel *) * listLen); - btnList_1 = (QToolButton **)malloc(sizeof(QToolButton *) * listLen); - btnList_2 = (QToolButton **)malloc(sizeof(QToolButton *) * listLen); - btnList_3 = (QToolButton **)malloc(sizeof(QToolButton *) * listLen); - - web = new WebWidget(); - - title_1->setText("热门榜单"); - title_1->setAlignment(Qt::AlignCenter); - title_1->setFont(QFont( "Timers", 15, QFont::Bold) ); - title_2->setText("小众榜单"); - title_2->setAlignment(Qt::AlignCenter); - title_2->setFont(QFont( "Timers", 15, QFont::Bold) ); - title_3->setText("好评榜单"); - title_3->setAlignment(Qt::AlignCenter); - title_3->setFont(QFont( "Timers", 15, QFont::Bold) ); - - QHBoxLayout *line_1 = new QHBoxLayout(); - QHBoxLayout *line_2 = new QHBoxLayout(); - QHBoxLayout *line_3 = new QHBoxLayout(); - - line_1->addWidget(title_1); - line_2->addWidget(title_2); - line_3->addWidget(title_3); - - lineList_1[0] = line_1; - lineList_2[0] = line_2; - lineList_3[0] = line_3; - setHotList(); - setMinorityList(); - setFavorableList(); - - //设置总体布局 - this->setLayout(mainLayout); - - mainLayout->addWidget(subWidget); - mainLayout->addWidget(web); - web->setVisible(false); - subWidget->setLayout(listLayout); - listLayout->addLayout(layout_1, 1); - listLayout->addLayout(layout_2, 1); - listLayout->addLayout(layout_3, 1); - - for (int i = 0; i < (listLen + 1); i++) - { - layout_1->addLayout(lineList_1[i]); - layout_2->addLayout(lineList_2[i]); - layout_3->addLayout(lineList_3[i]); - } - - connect(web->getReturnBtn(), &QPushButton::clicked, this, &ListWidget::returnWeb); - - qDebug("LisWidget Completed"); + InitListWidget(); } ListWidget::~ListWidget() @@ -341,3 +267,96 @@ void ListWidget::setFavorableList() } } +void ListWidget::SetBackground(QString url) +{ + background->setPixmap(url); + background->setScaledContents(true); +} + +void ListWidget::InitListWidget() +{ + background = new QLabel(this); + SetBackground("./softImages/listWidget/blueHalf.png"); + + qDebug("Creating ListWidget..."); +// QSqlQuery queryList(listDb); +// QSqlQuery queryMeituan(meituanDb); + + listLen = 10; + mainLayout = new QVBoxLayout(); + + subWidget = new QWidget(); + listLayout = new QHBoxLayout(); + layout_1 = new QVBoxLayout(); + layout_2 = new QVBoxLayout(); + layout_3 = new QVBoxLayout(); + title_1 = new QLabel(); + title_2 = new QLabel(); + title_3 = new QLabel(); + + //lineList第一行是标题行,其余listLen个是按钮行 + lineList_1 = (QHBoxLayout **)malloc(sizeof(QHBoxLayout *) * (listLen + 1)); + lineList_2 = (QHBoxLayout **)malloc(sizeof(QHBoxLayout *) * (listLen + 1)); + lineList_3 = (QHBoxLayout **)malloc(sizeof(QHBoxLayout *) * (listLen + 1)); + rankList_1 = (QLabel **)malloc(sizeof(QLabel *) * listLen); + rankList_2 = (QLabel **)malloc(sizeof(QLabel *) * listLen); + rankList_3 = (QLabel **)malloc(sizeof(QLabel *) * listLen); + btnList_1 = (QToolButton **)malloc(sizeof(QToolButton *) * listLen); + btnList_2 = (QToolButton **)malloc(sizeof(QToolButton *) * listLen); + btnList_3 = (QToolButton **)malloc(sizeof(QToolButton *) * listLen); + + web = new WebWidget(); + + title_1->setText("热门榜单"); + title_1->setAlignment(Qt::AlignCenter); + title_1->setFont(QFont( "Timers", 15, QFont::Bold) ); + title_2->setText("小众榜单"); + title_2->setAlignment(Qt::AlignCenter); + title_2->setFont(QFont( "Timers", 15, QFont::Bold) ); + title_3->setText("好评榜单"); + title_3->setAlignment(Qt::AlignCenter); + title_3->setFont(QFont( "Timers", 15, QFont::Bold) ); + + QHBoxLayout *line_1 = new QHBoxLayout(); + QHBoxLayout *line_2 = new QHBoxLayout(); + QHBoxLayout *line_3 = new QHBoxLayout(); + + line_1->addWidget(title_1); + line_2->addWidget(title_2); + line_3->addWidget(title_3); + + lineList_1[0] = line_1; + lineList_2[0] = line_2; + lineList_3[0] = line_3; + setHotList(); + setMinorityList(); + setFavorableList(); + + //设置总体布局 + this->setLayout(mainLayout); + + mainLayout->addWidget(subWidget); + mainLayout->addWidget(web); + web->setVisible(false); + + subWidget->setLayout(listLayout); + listLayout->addLayout(layout_1, 1); + listLayout->addLayout(layout_2, 1); + listLayout->addLayout(layout_3, 1); + + for (int i = 0; i < (listLen + 1); i++) + { + layout_1->addLayout(lineList_1[i]); + layout_2->addLayout(lineList_2[i]); + layout_3->addLayout(lineList_3[i]); + } + + connect(web->getReturnBtn(), &QPushButton::clicked, this, &ListWidget::returnWeb); + + qDebug("LisWidget Completed"); +} + +void ListWidget::resizeEvent(QResizeEvent *event) +{ + background->resize(this->size()); +} diff --git a/src/ChangShaTour/listwidget.h b/src/ChangShaTour/listwidget.h index f7ed920..f0f6cd4 100755 --- a/src/ChangShaTour/listwidget.h +++ b/src/ChangShaTour/listwidget.h @@ -35,10 +35,15 @@ public: void setMinorityList(); void setFavorableList(); + void SetBackground(QString); + void InitListWidget(); + void resizeEvent(QResizeEvent *event); private: Ui::ListWidget *ui; + QLabel * background; + int listLen; QVBoxLayout *mainLayout; diff --git a/src/ChangShaTour/loginmanager.cpp b/src/ChangShaTour/loginmanager.cpp index 436b5ae..e0f2631 100755 --- a/src/ChangShaTour/loginmanager.cpp +++ b/src/ChangShaTour/loginmanager.cpp @@ -1,26 +1,26 @@ -#include "loginmanager.h" - -LoginManager::LoginManager() -{ - -} -bool LoginManager::loginVerify(QString account,QString password) -{ - QSqlQuery query(userDb); - query.prepare("select id,password from account where email=?"); - query.addBindValue(account); - query.exec(); - query.next(); - QString passwordget=query.value("password").toString(); - Id=query.value("id").toInt(); - qDebug()<< "userId:" < -#include -#include - - -class LoginManager -{ -public: - LoginManager(); - bool loginVerify(QString account,QString password); -private: - -}; - -#endif // LOGINMANAGER_H +#ifndef LOGINMANAGER_H +#define LOGINMANAGER_H + +#include "cglobal.h" +#include +#include +#include + + +class LoginManager +{ +public: + LoginManager(); + bool loginVerify(QString account,QString password); +private: + +}; + +#endif // LOGINMANAGER_H diff --git a/src/ChangShaTour/main.cpp b/src/ChangShaTour/main.cpp index 8f53939..b2afca3 100755 --- a/src/ChangShaTour/main.cpp +++ b/src/ChangShaTour/main.cpp @@ -60,6 +60,15 @@ int main(int argc, char *argv[]) listDb.setUserName("mkl"); //用户名 listDb.setPassword("010512"); //密码 listDb.open(); + + routeDb = QSqlDatabase::addDatabase("QMYSQL", "routeConnection"); //连接的MYSQL的数据库驱动 + routeDb.setHostName("121.36.100.63"); //主机名 + routeDb.setPort(3306); //端口 + routeDb.setDatabaseName("route"); //数据库名 + routeDb.setUserName("mkl"); //用户名 + routeDb.setPassword("010512"); //密码 + routeDb.open(); + cglobal *glb=new cglobal(); glb->labelmap(); diff --git a/src/ChangShaTour/mainwidget.cpp b/src/ChangShaTour/mainwidget.cpp index d41a637..b5cf80c 100755 --- a/src/ChangShaTour/mainwidget.cpp +++ b/src/ChangShaTour/mainwidget.cpp @@ -158,6 +158,7 @@ void MainWidget::InitMainWidget() firstSubWidget = new QWidget(); InitFirstSubWidget(); + firstSubWidget->setFixedSize(1440, 100); verLayout->addWidget(firstSubWidget); homeWidget = new HomeWidget(); diff --git a/src/ChangShaTour/planwidget.cpp b/src/ChangShaTour/planwidget.cpp index f953150..ce59a6a 100755 --- a/src/ChangShaTour/planwidget.cpp +++ b/src/ChangShaTour/planwidget.cpp @@ -7,62 +7,30 @@ PlanWidget::PlanWidget(QWidget *parent) : { ui->setupUi(this); - verLayout = new QVBoxLayout(); - - pageIndex = 0; - route = new Route(); - - horLayout = new QHBoxLayout(); - returnBtn = new QPushButton("返回"); - favoriteBtn = new QPushButton("收藏"); - confirmBtn = new QPushButton("确认"); - returnBtn->setVisible(false); - favoriteBtn->setVisible(false); - confirmBtn->setVisible(false); - - rcmdPlanBtn = new QPushButton("推荐路线"); - cstmPlanBtn = new QPushButton("定制路线"); - conditionWidget = new ConditionWidget(); - preferenceWidget = new PreferenceWidget(); - routeChoiceWidget = new RouteChoiceWidget(); - customizeWidget = new CustomizeWidget(); - confirmWidget = new ConfirmWidget(); - rcmdPlanBtn->setVisible(true); - cstmPlanBtn->setVisible(true); - conditionWidget->setVisible(false); - preferenceWidget->setVisible(false); - routeChoiceWidget->setVisible(false); - customizeWidget->setVisible(false); - confirmWidget->setVisible(false); - - setLayout(verLayout); - verLayout->addLayout(horLayout); - verLayout->addWidget(rcmdPlanBtn); - verLayout->addWidget(cstmPlanBtn); - verLayout->addWidget(conditionWidget); - verLayout->addWidget(preferenceWidget); - verLayout->addWidget(routeChoiceWidget); - verLayout->addWidget(customizeWidget); - verLayout->addWidget(confirmWidget); - - horLayout->addWidget(returnBtn); - horLayout->addStretch(5); - horLayout->addWidget(favoriteBtn); - horLayout->addWidget(confirmBtn); - - connect(rcmdPlanBtn, &QPushButton::clicked, this, &PlanWidget::switchToConditionWidget); - connect(cstmPlanBtn, &QPushButton::clicked, this, &PlanWidget::switchToCustomizeWidget); + InitPlanWidget(); } void PlanWidget::switchToPlanChoice() { + if (pageIndex == 1) + { + conditionWidget->deleteLater(); + conditionWidget = new ConditionWidget(); + verLayout->addWidget(conditionWidget); + } + if (pageIndex == 4) + { + customizeWidget->deleteLater(); + customizeWidget = new CustomizeWidget(); + verLayout->addWidget(customizeWidget); + } pageIndex = 0; + functionWidget->setVisible(false); returnBtn->setVisible(false); favoriteBtn->setVisible(false); confirmBtn->setVisible(false); - rcmdPlanBtn->setVisible(true); - cstmPlanBtn->setVisible(true); + choiceWidget->setVisible(true); conditionWidget->setVisible(false); preferenceWidget->setVisible(false); routeChoiceWidget->setVisible(false); @@ -78,13 +46,19 @@ void PlanWidget::switchToConditionWidget() preferenceWidget = new PreferenceWidget(); verLayout->addWidget(preferenceWidget); } + + if(pageIndex == 0) + { + recRouteManager = new RecRouteManager(); + } + pageIndex = 1; + functionWidget->setVisible(true); returnBtn->setVisible(true); favoriteBtn->setVisible(false); confirmBtn->setVisible(true); - rcmdPlanBtn->setVisible(false); - cstmPlanBtn->setVisible(false); + choiceWidget->setVisible(false); conditionWidget->setVisible(true); preferenceWidget->setVisible(false); routeChoiceWidget->setVisible(false); @@ -107,13 +81,39 @@ void PlanWidget::switchToPreferenceWidget() routeChoiceWidget = new RouteChoiceWidget(); verLayout->addWidget(routeChoiceWidget); } + + if (pageIndex == 1) + { + int day = conditionWidget->getDay(); + int number = conditionWidget->getNumber(); + int budget = conditionWidget->getBudget(); + if(day == 0 || day > 10) + { + QMessageBox::warning(NULL, "警告", "请输入合法的天数!", QMessageBox::Yes); + return; + } + if(number == 0 || number > 8) + { + QMessageBox::warning(NULL, "警告", "请输入合法的人数!", QMessageBox::Yes); + return; + } + if(budget == 0 || budget > 50000) + { + QMessageBox::warning(NULL, "警告", "请输入合法的预算!", QMessageBox::Yes); + return; + } + recRouteManager->setDay(day); + recRouteManager->setNumber(number); + recRouteManager->setBudget(budget); + } + pageIndex = 2; + functionWidget->setVisible(true); returnBtn->setVisible(true); favoriteBtn->setVisible(false); confirmBtn->setVisible(true); - rcmdPlanBtn->setVisible(false); - cstmPlanBtn->setVisible(false); + choiceWidget->setVisible(false); conditionWidget->setVisible(false); preferenceWidget->setVisible(true); routeChoiceWidget->setVisible(false); @@ -136,19 +136,34 @@ void PlanWidget::switchToRouteChoiceWidget() confirmWidget = new ConfirmWidget(); verLayout->addWidget(confirmWidget); } + + if (pageIndex == 2) + { + int preference = preferenceWidget->getPreference(); + if(preference == 0) + { + QMessageBox::warning(NULL, "警告", "请选择一个偏好!", QMessageBox::Yes); + return; + } + recRouteManager->setPreference(preference); + recRouteManager->genRecRoutes(); + } + pageIndex = 3; + functionWidget->setVisible(true); returnBtn->setVisible(true); favoriteBtn->setVisible(false); confirmBtn->setVisible(true); - rcmdPlanBtn->setVisible(false); - cstmPlanBtn->setVisible(false); + choiceWidget->setVisible(false); conditionWidget->setVisible(false); preferenceWidget->setVisible(false); routeChoiceWidget->setVisible(true); customizeWidget->setVisible(false); confirmWidget->setVisible(false); + routeChoiceWidget->setBtns(recRouteManager->getRecRoutes(), recRouteManager->getNumOfRecRoutes()); + disconnect(returnBtn, 0, 0, 0); disconnect(confirmBtn, 0, 0, 0); @@ -167,11 +182,11 @@ void PlanWidget::switchToCustomizeWidget() } pageIndex = 4; + functionWidget->setVisible(true); returnBtn->setVisible(true); favoriteBtn->setVisible(false); confirmBtn->setVisible(true); - rcmdPlanBtn->setVisible(false); - cstmPlanBtn->setVisible(false); + choiceWidget->setVisible(false); conditionWidget->setVisible(false); preferenceWidget->setVisible(false); routeChoiceWidget->setVisible(false); @@ -189,37 +204,56 @@ void PlanWidget::switchToCustomizeWidget() void PlanWidget::switchToConfirmWidget() { int originalIndex = pageIndex; - pageIndex = 5; - returnBtn->setVisible(true); - favoriteBtn->setVisible(true); - confirmBtn->setVisible(true); - rcmdPlanBtn->setVisible(false); - cstmPlanBtn->setVisible(false); - conditionWidget->setVisible(false); - preferenceWidget->setVisible(false); - routeChoiceWidget->setVisible(false); - customizeWidget->setVisible(false); - confirmWidget->setVisible(true); - - disconnect(returnBtn, 0, 0, 0); - disconnect(confirmBtn, 0, 0, 0); if (originalIndex == 3) { + pageIndex = 5; + + functionWidget->setVisible(true); + returnBtn->setVisible(true); + favoriteBtn->setVisible(true); + confirmBtn->setVisible(true); + choiceWidget->setVisible(false); + conditionWidget->setVisible(false); + preferenceWidget->setVisible(false); + routeChoiceWidget->setVisible(false); + customizeWidget->setVisible(false); + confirmWidget->setVisible(true); + + disconnect(returnBtn, 0, 0, 0); + disconnect(confirmBtn, 0, 0, 0); connect(returnBtn, &QPushButton::clicked, this, &PlanWidget::switchToRouteChoiceWidget); } if (originalIndex == 4) { - connect(returnBtn, &QPushButton::clicked, this, &PlanWidget::switchToCustomizeWidget); - route = customizeWidget->genRoute(); - qDebug() << "generate customize route:"; - struct routeItem * p= route->getAllItems()->next; - while (p) + if (customizeWidget->genRoute()) { - qDebug() << p->placeName; - p = p->next; - } + pageIndex = 5; + functionWidget->setVisible(true); + returnBtn->setVisible(true); + favoriteBtn->setVisible(true); + confirmBtn->setVisible(true); + choiceWidget->setVisible(false); + conditionWidget->setVisible(false); + preferenceWidget->setVisible(false); + routeChoiceWidget->setVisible(false); + customizeWidget->setVisible(false); + confirmWidget->setVisible(true); + + disconnect(returnBtn, 0, 0, 0); + disconnect(confirmBtn, 0, 0, 0); + connect(returnBtn, &QPushButton::clicked, this, &PlanWidget::switchToCustomizeWidget); + + Route *route = customizeWidget->getRoute(); + qDebug() << "generate customize route:"; + struct routeItem * p= route->getAllItems()->next; + while (p) + { + qDebug() << p->placeName; + p = p->next; + } + } } // connect(confirmBtn, &QPushButton::clicked, this, &PlanWidget::switchToPreferenceWidget); @@ -229,3 +263,190 @@ PlanWidget::~PlanWidget() { delete ui; } + +void PlanWidget::SetBackground(QString url) +{ + background->setPixmap(url); + background->setScaledContents(true); +} + +void PlanWidget::InitPlanWidget() +{ + background = new QLabel(this); + SetBackground("./softImages/planWidget/blueHalf.png"); + background->setMargin(20); + + pageIndex = 0; + + verLayout = new QVBoxLayout(); + setLayout(verLayout); + verLayout->setMargin(30); + + functionWidget = new QWidget(); + InitFunctionWidget(); + verLayout->addWidget(functionWidget); + functionWidget->setVisible(false); + returnBtn->setVisible(false); + favoriteBtn->setVisible(false); + confirmBtn->setVisible(false); + + choiceWidget = new QWidget(); + InitChoiceWidget(); + verLayout->addWidget(choiceWidget); + choiceWidget->setVisible(true); + + conditionWidget = new ConditionWidget(); + preferenceWidget = new PreferenceWidget(); + routeChoiceWidget = new RouteChoiceWidget(); + customizeWidget = new CustomizeWidget(); + confirmWidget = new ConfirmWidget(); + conditionWidget->setVisible(false); + preferenceWidget->setVisible(false); + routeChoiceWidget->setVisible(false); + customizeWidget->setVisible(false); + confirmWidget->setVisible(false); + + verLayout->addWidget(conditionWidget); + verLayout->addWidget(preferenceWidget); + verLayout->addWidget(routeChoiceWidget); + verLayout->addWidget(customizeWidget); + verLayout->addWidget(confirmWidget); +} + +void PlanWidget::InitChoiceWidget() +{ + QVBoxLayout * verLayout = new QVBoxLayout(); + choiceWidget->setLayout(verLayout); + + QWidget * firstSubWidget = new QWidget(); + verLayout->addWidget(firstSubWidget); + + QHBoxLayout * firstHoriLayout = new QHBoxLayout(); + firstSubWidget->setLayout(firstHoriLayout); + firstSubWidget->setFixedSize(1440, 300); + + rcmdPlanBtn = new QPushButton(); + InitPlanButton(rcmdPlanBtn, "recommendRoute"); + firstHoriLayout->addWidget(rcmdPlanBtn); + + cstmPlanBtn = new QPushButton(); + InitPlanButton(cstmPlanBtn, "customizeRoute"); + firstHoriLayout->addWidget(cstmPlanBtn); + + QWidget * secondSubWidget = new QWidget(); + verLayout->addWidget(secondSubWidget); + + QHBoxLayout * secondHoriLayout = new QHBoxLayout(); + secondSubWidget->setLayout(secondHoriLayout); + + QLabel * rcmdText = new QLabel("推荐路线"); + InitLabel(rcmdText); + secondHoriLayout->addWidget(rcmdText); + + QLabel * cstmText = new QLabel("定制路线"); + InitLabel(cstmText); + secondHoriLayout->addWidget(cstmText); + + connect(rcmdPlanBtn, &QPushButton::clicked, this, &PlanWidget::switchToConditionWidget); + connect(cstmPlanBtn, &QPushButton::clicked, this, &PlanWidget::switchToCustomizeWidget); +} + +void PlanWidget::InitFunctionWidget() +{ + QHBoxLayout * horiLayout = new QHBoxLayout(); + functionWidget->setLayout(horiLayout); + + returnBtn = new QPushButton("返回"); + InitButton(returnBtn); + horiLayout->addWidget(returnBtn); + + favoriteBtn = new QPushButton("收藏"); + InitButton(favoriteBtn); + horiLayout->addWidget(favoriteBtn); + + horiLayout->addStretch(5); + + confirmBtn = new QPushButton("确认"); + InitButton(confirmBtn); + horiLayout->addWidget(confirmBtn); +} + +void PlanWidget::InitLabel(QLabel * label) +{ + QFont lbl_font("Microsoft YaHei"); + lbl_font.setPointSize(24); + lbl_font.setBold(true); + label->setFont(lbl_font); + label->setStyleSheet("color:#FFFFFF"); + label->setAlignment(Qt::AlignCenter); +} + +void PlanWidget::InitButton(QPushButton * button) +{ + button->setStyleSheet("QPushButton {" + "color:#ffffff;" + "background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #E1B37C, stop: 1 #E1B37C);" + "border-style:outset;" + "border-radius:10px;" + "font:bold 20px;" + "font-family: Microsoft YaHei;" + "min-width:100px;" + "min-height:20px;" + "padding:4px;" + "} " + "QPushButton:hover {" + "background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #D2AD90, stop: 1 #D2AD90);" + "border-style:outset;" + "border-radius:10px;" + "font:bold 20px;" + "font-family: Microsoft YaHei;" + "min-width:100px;" + "min-height:20px;" + "padding:4px;" + "} " + "QPushButton:pressed {" + "background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #D2AD90, stop: 1 #D2AD90);" + "border-style:outset;" + "border-radius:10px;" + "font:bold 20px;" + "font-family: Microsoft YaHei;" + "min-width:100px;" + "min-height:20px;" + "padding:4px;" + "}"); + button->setFixedSize(120, 40); +} + +void PlanWidget::InitPlanButton(QPushButton * button, QString url) +{ + button->setStyleSheet("QPushButton {" + "border-image: url(./softImages/planWidget/" + url + "Blur.jpg);" + "border-style:outset;" + "border-radius:10px;" + "min-width:100px;" + "min-height:20px;" + "padding:4px;" + "} " + "QPushButton:hover {" + "border-image: url(./softImages/planWidget/" + url + ".jpg);" + "border-style:outset;" + "border-radius:10px;" + "min-width:100px;" + "min-height:20px;" + "padding:4px;" + "} " + "QPushButton:pressed {" + "border-image: url(./softImages/planWidget/" + url + ".jpg);" + "border-style:outset;" + "border-radius:10px;" + "min-width:100px;" + "min-height:20px;" + "padding:4px;" + "}"); + button->setFixedSize(500, 300); +} + +void PlanWidget::resizeEvent(QResizeEvent *event) +{ + background->resize(this->size()); +} diff --git a/src/ChangShaTour/planwidget.h b/src/ChangShaTour/planwidget.h index c2bd843..eda72e3 100755 --- a/src/ChangShaTour/planwidget.h +++ b/src/ChangShaTour/planwidget.h @@ -5,12 +5,14 @@ #include #include #include +#include #include "conditionwidget.h" #include "preferencewidget.h" #include "routechoicewidget.h" #include "customizewidget.h" #include "confirmwidget.h" #include "route.h" +#include "recroutemanager.h" #if _MSC_VER >= 1600 #pragma execution_character_set("utf-8") @@ -28,27 +30,43 @@ public: explicit PlanWidget(QWidget *parent = nullptr); ~PlanWidget(); + void SetBackground(QString); + + void InitPlanWidget(); + void InitChoiceWidget(); + void InitFunctionWidget(); + + void InitLabel(QLabel *); + void InitPlanButton(QPushButton *, QString); + void InitButton(QPushButton *); + + void resizeEvent(QResizeEvent *event); + private: Ui::PlanWidget *ui; + QLabel * background; + int pageIndex; - Route *route; QVBoxLayout *verLayout; - QHBoxLayout *horLayout; QPushButton *returnBtn; QPushButton *favoriteBtn; QPushButton *confirmBtn; QPushButton *rcmdPlanBtn; QPushButton *cstmPlanBtn; + QWidget * choiceWidget; + QWidget * functionWidget; ConditionWidget *conditionWidget; PreferenceWidget *preferenceWidget; RouteChoiceWidget *routeChoiceWidget; CustomizeWidget *customizeWidget; ConfirmWidget *confirmWidget; + RecRouteManager * recRouteManager; + public slots: void switchToPlanChoice(); void switchToConditionWidget(); diff --git a/src/ChangShaTour/popwidget.cpp b/src/ChangShaTour/popwidget.cpp index 9f88b5a..5adab23 100755 --- a/src/ChangShaTour/popwidget.cpp +++ b/src/ChangShaTour/popwidget.cpp @@ -1,257 +1,257 @@ -#include "popwidget.h" -#include "ui_popwidget.h" - -PopWidget::PopWidget(QWidget *parent) : - QWidget(parent), - ui(new Ui::PopWidget) -{ - ui->setupUi(this); - - this->setWindowModality(Qt::ApplicationModal); - this->setFixedSize(QSize(400,810)); - this->setWindowTitle("请选择..."); - - chosen.append(""); - chosen.append(""); - chosen.append(""); - showLimit = 15; - currentPage = 1; - offset = 0; - btnList = (QToolButton **)malloc(sizeof(QToolButton *) * showLimit); - idList = (int *)malloc(sizeof(int) * showLimit); - - mainLayout = new QVBoxLayout(); - - notify = new QLabel("请从您的收藏夹中选择场所添加到路线中"); - notify->setAlignment(Qt::AlignCenter); - - searchLine = new QHBoxLayout(); - searchBar = new QLineEdit(); - searchBtn = new QPushButton("搜索"); - returnSearchBtn = new QPushButton("退出搜索"); - - scroll = new QScrollArea(); - scrollWidget = new QWidget; - scrollLayout = new QVBoxLayout(); - - pageLine = new QHBoxLayout(); - up = new QPushButton("上一页"); - down = new QPushButton("下一页"); - - chosenLabel = new QLabel("您还未选择场所..."); - chosenLabel->setAlignment(Qt::AlignLeft); - - closeLine = new QHBoxLayout(); - confirm = new QPushButton("确认"); - cancel = new QPushButton("取消"); - - this->setLayout(mainLayout); - - mainLayout->addWidget(notify); - mainLayout->addLayout(searchLine); - mainLayout->addWidget(scroll); - mainLayout->addLayout(pageLine); - mainLayout->addWidget(chosenLabel); - mainLayout->addLayout(closeLine); - - searchLine->addWidget(searchBar, 6); - searchLine->addWidget(searchBtn, 1); - -// scrollWidget->setLayout(scrollLayout); -// //查询数据库,进行按钮布局 -// scroll->setWidget(scrollWidget); - getTotalNum(); - setScreen(); - - pageLine->addWidget(up); - pageLine->addWidget(down); - - closeLine->addWidget(confirm); - closeLine->addWidget(cancel); - - connect(up, &QPushButton::clicked, this, &PopWidget::pageUp); - connect(down, &QPushButton::clicked, this, &PopWidget::pageDown); -} - -PopWidget::~PopWidget() -{ - delete ui; -} - -QPushButton * PopWidget::getConfirmBtn() -{ - return confirm; -} - -QPushButton * PopWidget::getCancelBtn() -{ - return cancel; -} - -//从店铺收藏夹获取店铺 -void PopWidget::getTotalNum() -{ - //查询条目数 - QSqlQuery query(userDb); - - query.prepare("select count(*) as num from favPlaces where userId = :id"); - query.bindValue(":id", Id); - query.exec(); - query.next(); - qDebug() << " popWidget totalNum:" << query.value("num"); - totalNum = query.value("num").value(); - - pageNum = (totalNum + showLimit - 1)/showLimit; - -} - -void PopWidget::queryDatabase() -{ - QSqlQuery query(userDb); - - query.prepare("select * from favPlaces where userId = :id limit :offset, :limit"); - query.bindValue(":id", Id); - query.bindValue(":offset", offset); - query.bindValue(":limit", showLimit); - query.exec(); - int i = 0; - while(query.next()==true) - { - QVariant favPlaceId = query.value("favPlaceId"); - QVariant title = query.value("title"); - QVariant detail = query.value("detail"); - QVariant frontimg = query.value("frontimg"); - QVariant cateId = query.value("cateId"); - - idList[i] = (int)favPlaceId.value(); - nameList.append(title.value()); - urlList.append(detail.value()); - imgList.append(frontimg.value()); - cateList.append(cateId.value()); - i++; - } - currentNum = i; - qDebug() << "popWidget currentNum:" << currentNum; - -} - -QToolButton * PopWidget::setBtn(QToolButton *btn, QString text, QString img) -{ - if(img != "") - btn->setIcon(QIcon(img)); - btn->setText(text); - btn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - btn->setIconSize(QSize(100,200)); - btn->setFixedSize(300,100); - - return btn; -} - -void PopWidget::setBtns() -{ - int i = 0; - for (i; i < currentNum; i++) - { - int index = i; - //下载图片到本地 - QString imgPath = "./images/fav" + QString::number(Id) + "_" + QString::number(idList[index]) + ".png"; - imgDownloader *download = new imgDownloader(); - download->downloadFileFromUrl(imgList[index], imgPath); - btnList[index] = setBtn(btnList[index], nameList[index], imgPath); - disconnect(btnList[index], 0, 0, 0); - connect(btnList[index], &QToolButton::clicked, this, [=](){setChosen(index);}); - } -} - -void PopWidget::setChosen(int index) -{ - if (urlList[index] != chosen[1]) - { - chosen[0] = nameList[index]; - chosen[1] = urlList[index]; - chosen[2] = cateList[index]; - chosenLabel->setText("您选择了" + chosen[0]); - } - else - { - chosen[0] = ""; - chosen[1] = ""; - chosen[2] = ""; - chosenLabel->setText("您还未选择场所..."); - } -} - -void PopWidget::setScreen() -{ - qDebug() << "popWidget currentPage:" << currentPage; - qDebug() << "popWidget offset:" << offset; - urlList.clear(); - imgList.clear(); - nameList.clear(); - cateList.clear(); - for (int i = 0; i < showLimit; i++) - btnList[i] = new QToolButton(); - - queryDatabase(); - qDebug("query success"); - setBtns(); - qDebug("setBtns success"); - - scroll->takeWidget(); - scrollWidget->deleteLater(); - scrollWidget = new QWidget(); - scrollLayout->deleteLater(); - scrollLayout = new QVBoxLayout(); - scrollWidget->setLayout(scrollLayout); - - for (int i = 0; i < currentNum; i++) - { - scrollLayout->addWidget(btnList[i]); - } - - scroll->setWidget(scrollWidget); - -} - -void PopWidget::pageUp() -{ - currentPage--; - if (currentPage < 1) - { - currentPage = 1; - qDebug("这是第一页"); - } - else - { - offset -= showLimit; - rollTop(); - setScreen(); - } -} - -void PopWidget::pageDown() -{ - currentPage++; - if (currentPage > pageNum) - { - currentPage = pageNum; - qDebug("已经是最后一页了!"); - } - else - { - offset += showLimit; - rollTop(); - setScreen(); - } -} - -void PopWidget::rollTop() -{ - QScrollBar *scrollBar = scroll->verticalScrollBar(); - scrollBar->setValue(scrollBar->minimum()); -} - -QStringList PopWidget::getChosen() -{ - return chosen; -} +#include "popwidget.h" +#include "ui_popwidget.h" + +PopWidget::PopWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::PopWidget) +{ + ui->setupUi(this); + + this->setWindowModality(Qt::ApplicationModal); + this->setFixedSize(QSize(400,810)); + this->setWindowTitle("请选择..."); + + chosen.append(""); + chosen.append(""); + chosen.append(""); + showLimit = 15; + currentPage = 1; + offset = 0; + btnList = (QToolButton **)malloc(sizeof(QToolButton *) * showLimit); + idList = (int *)malloc(sizeof(int) * showLimit); + + mainLayout = new QVBoxLayout(); + + notify = new QLabel("请从您的收藏夹中选择场所添加到路线中"); + notify->setAlignment(Qt::AlignCenter); + + searchLine = new QHBoxLayout(); + searchBar = new QLineEdit(); + searchBtn = new QPushButton("搜索"); + returnSearchBtn = new QPushButton("退出搜索"); + + scroll = new QScrollArea(); + scrollWidget = new QWidget; + scrollLayout = new QVBoxLayout(); + + pageLine = new QHBoxLayout(); + up = new QPushButton("上一页"); + down = new QPushButton("下一页"); + + chosenLabel = new QLabel("您还未选择场所..."); + chosenLabel->setAlignment(Qt::AlignLeft); + + closeLine = new QHBoxLayout(); + confirm = new QPushButton("确认"); + cancel = new QPushButton("取消"); + + this->setLayout(mainLayout); + + mainLayout->addWidget(notify); + mainLayout->addLayout(searchLine); + mainLayout->addWidget(scroll); + mainLayout->addLayout(pageLine); + mainLayout->addWidget(chosenLabel); + mainLayout->addLayout(closeLine); + + searchLine->addWidget(searchBar, 6); + searchLine->addWidget(searchBtn, 1); + +// scrollWidget->setLayout(scrollLayout); +// //查询数据库,进行按钮布局 +// scroll->setWidget(scrollWidget); + getTotalNum(); + setScreen(); + + pageLine->addWidget(up); + pageLine->addWidget(down); + + closeLine->addWidget(confirm); + closeLine->addWidget(cancel); + + connect(up, &QPushButton::clicked, this, &PopWidget::pageUp); + connect(down, &QPushButton::clicked, this, &PopWidget::pageDown); +} + +PopWidget::~PopWidget() +{ + delete ui; +} + +QPushButton * PopWidget::getConfirmBtn() +{ + return confirm; +} + +QPushButton * PopWidget::getCancelBtn() +{ + return cancel; +} + +//从店铺收藏夹获取店铺 +void PopWidget::getTotalNum() +{ + //查询条目数 + QSqlQuery query(userDb); + + query.prepare("select count(*) as num from favPlaces where userId = :id"); + query.bindValue(":id", Id); + query.exec(); + query.next(); + qDebug() << "popWidget totalNum:" << query.value("num"); + totalNum = query.value("num").value(); + + pageNum = (totalNum + showLimit - 1)/showLimit; + +} + +void PopWidget::queryDatabase() +{ + QSqlQuery query(userDb); + + query.prepare("select * from favPlaces where userId = :id limit :offset, :limit"); + query.bindValue(":id", Id); + query.bindValue(":offset", offset); + query.bindValue(":limit", showLimit); + query.exec(); + int i = 0; + while(query.next()==true) + { + QVariant favPlaceId = query.value("favPlaceId"); + QVariant title = query.value("title"); + QVariant detail = query.value("detail"); + QVariant frontimg = query.value("frontimg"); + QVariant cateId = query.value("cateId"); + + idList[i] = (int)favPlaceId.value(); + nameList.append(title.value()); + urlList.append(detail.value()); + imgList.append(frontimg.value()); + cateList.append(cateId.value()); + i++; + } + currentNum = i; + qDebug() << "popWidget currentNum:" << currentNum; + +} + +QToolButton * PopWidget::setBtn(QToolButton *btn, QString text, QString img) +{ + if(img != "") + btn->setIcon(QIcon(img)); + btn->setText(text); + btn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + btn->setIconSize(QSize(100,200)); + btn->setFixedSize(300,100); + + return btn; +} + +void PopWidget::setBtns() +{ + int i = 0; + for (i; i < currentNum; i++) + { + int index = i; + //下载图片到本地 + QString imgPath = "./images/fav" + QString::number(Id) + "_" + QString::number(idList[index]) + ".png"; + imgDownloader *download = new imgDownloader(); + download->downloadFileFromUrl(imgList[index], imgPath); + btnList[index] = setBtn(btnList[index], nameList[index], imgPath); + disconnect(btnList[index], 0, 0, 0); + connect(btnList[index], &QToolButton::clicked, this, [=](){setChosen(index);}); + } +} + +void PopWidget::setChosen(int index) +{ + if (urlList[index] != chosen[1]) + { + chosen[0] = nameList[index]; + chosen[1] = urlList[index]; + chosen[2] = cateList[index]; + chosenLabel->setText("您选择了" + chosen[0]); + } + else + { + chosen[0] = ""; + chosen[1] = ""; + chosen[2] = ""; + chosenLabel->setText("您还未选择场所..."); + } +} + +void PopWidget::setScreen() +{ + qDebug() << "popWidget currentPage:" << currentPage; + qDebug() << "popWidget offset:" << offset; + urlList.clear(); + imgList.clear(); + nameList.clear(); + cateList.clear(); + for (int i = 0; i < showLimit; i++) + btnList[i] = new QToolButton(); + + queryDatabase(); + qDebug("popWidget query success"); + setBtns(); + qDebug("popWidget setBtns success"); + + scroll->takeWidget(); + scrollWidget->deleteLater(); + scrollWidget = new QWidget(); + scrollLayout->deleteLater(); + scrollLayout = new QVBoxLayout(); + scrollWidget->setLayout(scrollLayout); + + for (int i = 0; i < currentNum; i++) + { + scrollLayout->addWidget(btnList[i]); + } + + scroll->setWidget(scrollWidget); + +} + +void PopWidget::pageUp() +{ + currentPage--; + if (currentPage < 1) + { + currentPage = 1; + qDebug("这是第一页"); + } + else + { + offset -= showLimit; + rollTop(); + setScreen(); + } +} + +void PopWidget::pageDown() +{ + currentPage++; + if (currentPage > pageNum) + { + currentPage = pageNum; + qDebug("已经是最后一页了!"); + } + else + { + offset += showLimit; + rollTop(); + setScreen(); + } +} + +void PopWidget::rollTop() +{ + QScrollBar *scrollBar = scroll->verticalScrollBar(); + scrollBar->setValue(scrollBar->minimum()); +} + +QStringList PopWidget::getChosen() +{ + return chosen; +} diff --git a/src/ChangShaTour/popwidget.h b/src/ChangShaTour/popwidget.h index 5766367..79951f8 100755 --- a/src/ChangShaTour/popwidget.h +++ b/src/ChangShaTour/popwidget.h @@ -1,90 +1,90 @@ -#ifndef POPWIDGET_H -#define POPWIDGET_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "cglobal.h" -#include "imgdownloader.h" - -#if _MSC_VER >= 1600 -#pragma execution_character_set("utf-8") -#endif - -namespace Ui { -class PopWidget; -} - -class PopWidget : public QWidget -{ - Q_OBJECT - -public: - explicit PopWidget(QWidget *parent = nullptr); - ~PopWidget(); - - QPushButton * getConfirmBtn(); - QPushButton * getCancelBtn(); - void getTotalNum(); - void queryDatabase(); - void pageUp(); - void pageDown(); - void setScreen(); - void setBtns(); - QToolButton * setBtn(QToolButton *btn, QString text, QString img); - void setChosen(int index); - void rollTop(); - QStringList getChosen(); - -private: - Ui::PopWidget *ui; - - bool inSearch; - QStringList chosen;//被选中的场所在当,有三个值name,url,cateId - int totalNum;//收藏夹总共有多少条 - int showLimit;//一页中最多显示条数 - int pageNum;//总页数 - int currentPage;//当前所在页数 - int currentNum;//当前页中条目数量 - int offset;//query语句中的偏移量 - QStringList nameList; - QStringList urlList; - QStringList imgList; - QToolButton **btnList; - int *idList; - QStringList cateList; - - QVBoxLayout *mainLayout; - - QLabel *notify; - - QHBoxLayout *searchLine; - QLineEdit *searchBar; - QPushButton *searchBtn; - QPushButton *returnSearchBtn; - - QScrollArea *scroll; - QWidget *scrollWidget; - QVBoxLayout *scrollLayout; - - QHBoxLayout *pageLine; - QPushButton *up; - QPushButton *down; - - QLabel *chosenLabel; - - QHBoxLayout *closeLine; - QPushButton *confirm; - QPushButton *cancel; -}; - -#endif // POPWIDGET_H +#ifndef POPWIDGET_H +#define POPWIDGET_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "cglobal.h" +#include "imgdownloader.h" + +#if _MSC_VER >= 1600 +#pragma execution_character_set("utf-8") +#endif + +namespace Ui { +class PopWidget; +} + +class PopWidget : public QWidget +{ + Q_OBJECT + +public: + explicit PopWidget(QWidget *parent = nullptr); + ~PopWidget(); + + QPushButton * getConfirmBtn(); + QPushButton * getCancelBtn(); + void getTotalNum(); + void queryDatabase(); + void pageUp(); + void pageDown(); + void setScreen(); + void setBtns(); + QToolButton * setBtn(QToolButton *btn, QString text, QString img); + void setChosen(int index); + void rollTop(); + QStringList getChosen(); + +private: + Ui::PopWidget *ui; + + bool inSearch; + QStringList chosen;//被选中的场所在当,有三个值name,url,cateId + int totalNum;//收藏夹总共有多少条 + int showLimit;//一页中最多显示条数 + int pageNum;//总页数 + int currentPage;//当前所在页数 + int currentNum;//当前页中条目数量 + int offset;//query语句中的偏移量 + QStringList nameList; + QStringList urlList; + QStringList imgList; + QToolButton **btnList; + int *idList; + QStringList cateList; + + QVBoxLayout *mainLayout; + + QLabel *notify; + + QHBoxLayout *searchLine; + QLineEdit *searchBar; + QPushButton *searchBtn; + QPushButton *returnSearchBtn; + + QScrollArea *scroll; + QWidget *scrollWidget; + QVBoxLayout *scrollLayout; + + QHBoxLayout *pageLine; + QPushButton *up; + QPushButton *down; + + QLabel *chosenLabel; + + QHBoxLayout *closeLine; + QPushButton *confirm; + QPushButton *cancel; +}; + +#endif // POPWIDGET_H diff --git a/src/ChangShaTour/popwidget.ui b/src/ChangShaTour/popwidget.ui index c09c006..c79c892 100755 --- a/src/ChangShaTour/popwidget.ui +++ b/src/ChangShaTour/popwidget.ui @@ -1,21 +1,21 @@ - - - - - PopWidget - - - - 0 - 0 - 400 - 300 - - - - Form - - - - - + + + + + PopWidget + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + diff --git a/src/ChangShaTour/preferencewidget.cpp b/src/ChangShaTour/preferencewidget.cpp index 1e2505f..d6a3dca 100755 --- a/src/ChangShaTour/preferencewidget.cpp +++ b/src/ChangShaTour/preferencewidget.cpp @@ -7,6 +7,8 @@ PreferenceWidget::PreferenceWidget(QWidget *parent) : { ui->setupUi(this); + preference = 0; + gridLayout = new QGridLayout(); QVBoxLayout * landscapeVerticalLayout = new QVBoxLayout(); QVBoxLayout * customVerticalLayout = new QVBoxLayout(); @@ -68,6 +70,7 @@ PreferenceWidget::PreferenceWidget(QWidget *parent) : void PreferenceWidget::ChooseLandscape() { + preference = 1; landscapeButton->setStyleSheet("QPushButton{background-color: rgb(20, 62, 134);color:rgb(255, 255, 255);}"); customButton->setStyleSheet("QPushButton{color:rgb(255, 255, 255);}""QPushButton:hover{background-color: rgb(20, 62, 134);border:none;color:rgb(255, 255, 255);}"); foodButton->setStyleSheet("QPushButton{color:rgb(255, 255, 255);}""QPushButton:hover{background-color: rgb(20, 62, 134);border:none;color:rgb(255, 255, 255);}"); @@ -78,6 +81,7 @@ void PreferenceWidget::ChooseLandscape() void PreferenceWidget::ChooseCustom() { + preference = 2; customButton->setStyleSheet("QPushButton{background-color: rgb(20, 62, 134);color:rgb(255, 255, 255);}"); landscapeButton->setStyleSheet("QPushButton{color:rgb(255, 255, 255);}""QPushButton:hover{background-color: rgb(20, 62, 134);border:none;color:rgb(255, 255, 255);}"); foodButton->setStyleSheet("QPushButton{color:rgb(255, 255, 255);}""QPushButton:hover{background-color: rgb(20, 62, 134);border:none;color:rgb(255, 255, 255);}"); @@ -88,6 +92,7 @@ void PreferenceWidget::ChooseCustom() void PreferenceWidget::ChooseFood() { + preference = 3; foodButton->setStyleSheet("QPushButton{background-color: rgb(20, 62, 134);color:rgb(255, 255, 255);}"); customButton->setStyleSheet("QPushButton{color:rgb(255, 255, 255);}""QPushButton:hover{background-color: rgb(20, 62, 134);border:none;color:rgb(255, 255, 255);}"); landscapeButton->setStyleSheet("QPushButton{color:rgb(255, 255, 255);}""QPushButton:hover{background-color: rgb(20, 62, 134);border:none;color:rgb(255, 255, 255);}"); @@ -98,6 +103,7 @@ void PreferenceWidget::ChooseFood() void PreferenceWidget::ChooseNight() { + preference = 4; nightButton->setStyleSheet("QPushButton{background-color: rgb(20, 62, 134);color:rgb(255, 255, 255);}"); customButton->setStyleSheet("QPushButton{color:rgb(255, 255, 255);}""QPushButton:hover{background-color: rgb(20, 62, 134);border:none;color:rgb(255, 255, 255);}"); foodButton->setStyleSheet("QPushButton{color:rgb(255, 255, 255);}""QPushButton:hover{background-color: rgb(20, 62, 134);border:none;color:rgb(255, 255, 255);}"); @@ -108,6 +114,7 @@ void PreferenceWidget::ChooseNight() void PreferenceWidget::ChooseAnime() { + preference = 5; animeButton->setStyleSheet("QPushButton{background-color: rgb(20, 62, 134);color:rgb(255, 255, 255);}"); customButton->setStyleSheet("QPushButton{color:rgb(255, 255, 255);}""QPushButton:hover{background-color: rgb(20, 62, 134);border:none;color:rgb(255, 255, 255);}"); foodButton->setStyleSheet("QPushButton{color:rgb(255, 255, 255);}""QPushButton:hover{background-color: rgb(20, 62, 134);border:none;color:rgb(255, 255, 255);}"); @@ -118,6 +125,7 @@ void PreferenceWidget::ChooseAnime() void PreferenceWidget::ChooseLove() { + preference = 6; loveButton->setStyleSheet("QPushButton{background-color: rgb(20, 62, 134);color:rgb(255, 255, 255);}"); customButton->setStyleSheet("QPushButton{color:rgb(255, 255, 255);}""QPushButton:hover{background-color: rgb(20, 62, 134);border:none;color:rgb(255, 255, 255);}"); foodButton->setStyleSheet("QPushButton{color:rgb(255, 255, 255);}""QPushButton:hover{background-color: rgb(20, 62, 134);border:none;color:rgb(255, 255, 255);}"); @@ -126,6 +134,11 @@ void PreferenceWidget::ChooseLove() landscapeButton->setStyleSheet("QPushButton{color:rgb(255, 255, 255);}""QPushButton:hover{background-color: rgb(20, 62, 134);border:none;color:rgb(255, 255, 255);}"); } +int PreferenceWidget::getPreference() +{ + return this->preference; +} + PreferenceWidget::~PreferenceWidget() { delete ui; diff --git a/src/ChangShaTour/preferencewidget.h b/src/ChangShaTour/preferencewidget.h index 93ca8a4..ea10c63 100755 --- a/src/ChangShaTour/preferencewidget.h +++ b/src/ChangShaTour/preferencewidget.h @@ -23,6 +23,8 @@ public: explicit PreferenceWidget(QWidget *parent = nullptr); ~PreferenceWidget(); + int getPreference(); + private: Ui::PreferenceWidget *ui; @@ -42,6 +44,8 @@ private: QTextEdit * animeLine; QTextEdit * loveLine; + int preference; + private slots: void ChooseLandscape(); void ChooseCustom(); diff --git a/src/ChangShaTour/recommendwidget.cpp b/src/ChangShaTour/recommendwidget.cpp index 81d119c..e49241e 100755 --- a/src/ChangShaTour/recommendwidget.cpp +++ b/src/ChangShaTour/recommendwidget.cpp @@ -7,81 +7,26 @@ RecommendWidget::RecommendWidget(QWidget *parent) : { ui->setupUi(this); - row = 8; - column = 3; - page = 0; - displaynumber=row*column;//显示的数量 - labellimit = 4; - web = new WebWidget(); - idList = (int *)malloc(sizeof(int) * row * column); - algorithm(); - verLayout = new QVBoxLayout(); - - scroll = new QScrollArea(); - - subWidget = new QWidget(); - subVerLayout = new QVBoxLayout(); - - funcLine = new QHBoxLayout(); - lineList = (QHBoxLayout **)malloc(sizeof(QHBoxLayout *) * row); - - refreshBtn = new QPushButton("刷新"); - btnList = (QToolButton **)malloc(sizeof(QToolButton *) * row * column); - - //初始化按钮 - for (int i = 0; i < row; i++) - { - for (int j = 0; j addLayout(funcLine); - verLayout->addWidget(scroll); - verLayout->addWidget(web); - web->setVisible(false); - - subWidget->setLayout(subVerLayout); - for (int i = 0; i < row; i++) - { - lineList[i] = new QHBoxLayout(); - subVerLayout->addLayout(lineList[i]); - } - - //funcLine->addWidget(refreshBtn); - for (int i = 0; i < row; i++) - { - for (int j = 0; j addWidget(btnList[index]); - } - } - - //必须要在setWidget方法调用之前把subWidget中的layout设置好,否则显示不出来 - scroll->setWidget(subWidget); - - connect(web->getReturnBtn(), &QPushButton::clicked, this, &RecommendWidget::webReturn); - connect(refreshBtn, &QPushButton::clicked, this, &RecommendWidget::refresh); + InitRecommendWidget(); } QToolButton *RecommendWidget::setBtn(QToolButton *btn, const QString iconPath, const QString text) { - btn->setIcon(QIcon(iconPath)); - btn->setText(text); - btn->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); - btn->setIconSize(QSize(100,200)); - btn->setFixedSize(400,250); + //btn->setIcon(QIcon(iconPath)); + //btn->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); + //btn->setIconSize(QSize(200,300)); + + QLabel * btnBackground = new QLabel(btn); + btnBackground->setPixmap(iconPath); + btnBackground->setScaledContents(true); + + QLabel * textLabel = new QLabel(btn); + textLabel->setText(text); + InitLabel(textLabel); + + btn->setFixedSize(442,190); + btnBackground->resize(btn->size()); + textLabel->resize(btn->size()); return btn; } @@ -158,7 +103,7 @@ void RecommendWidget::setBtns() qDebug()<loadPage(nameList[index], imgList[index], urlList[index],cateIdList[index]); scroll->setVisible(false); web->setVisible(true); refreshBtn->setVisible(false);}); + connect(btnList[index], &QToolButton::clicked, this, [=](){web->loadPage(nameList[index], imgList[index], urlList[index],cateIdList[index]); subWidget->setVisible(false); web->setVisible(true); refreshBtn->setVisible(false);}); } } } @@ -200,7 +145,8 @@ void RecommendWidget::algorithm() void RecommendWidget::webReturn() { - scroll->setVisible(true); + //scroll->setVisible(true); + subWidget->setVisible(true); web->setVisible(false); refreshBtn->setVisible(true); disconnect(web->getAddBtn(), 0, 0, 0); @@ -208,7 +154,7 @@ void RecommendWidget::webReturn() void RecommendWidget::refresh() { - rollTop(); + //rollTop(); nameList.clear(); urlList.clear(); @@ -216,20 +162,145 @@ void RecommendWidget::refresh() textList.clear(); cateIdList.clear(); + for (int i = 0; i < row; i++) + { + for (int j = 0; j deleteLater(); + btnList[index] = new QToolButton(); + } + } + // query.exec("select * from csmeishi limit 2"); page+=1; queryDatabase(page); setBtns(); - //qDebug()<<"refreshed"; + + for (int i = 0; i < row; i++) + { + for (int j = 0; j addWidget(btnList[index]); + } + } + qDebug()<<"refreshed"; } void RecommendWidget::rollTop() { - QScrollBar *scrollBar = scroll->verticalScrollBar(); + QScrollBar * scrollBar = scroll->verticalScrollBar(); scrollBar->setValue(scrollBar->minimum()); } +void RecommendWidget::SetBackground(QString url) +{ + background->setPixmap(url); + background->setScaledContents(true); +} + +void RecommendWidget::InitRecommendWidget() +{ + background = new QLabel(this); + SetBackground("./softImages/recommendWidget/brownHalf.png"); + background->setMargin(20); + + row = 2; + column = 3; + page = 0; + displaynumber = row*column;//显示的数量 + labellimit = 4; + + verLayout = new QVBoxLayout(); + + web = new WebWidget(); + idList = (int *)malloc(sizeof(int) * row * column); + algorithm(); + + //scroll = new QScrollArea(); + + subWidget = new QWidget(); + subVerLayout = new QVBoxLayout(); + + funcLine = new QHBoxLayout(); + lineList = (QHBoxLayout **)malloc(sizeof(QHBoxLayout *) * row); + + refreshBtn = new QPushButton(); + refreshBtn->setFocus(); + refreshBtn->setDefault(true); + refreshBtn->setShortcut(QKeySequence::InsertParagraphSeparator); + refreshBtn->setShortcut(Qt::Key_F5); + + btnList = (QToolButton **)malloc(sizeof(QToolButton *) * row * column); + //初始化按钮 + for (int i = 0; i < row; i++) + { + for (int j = 0; j setMargin(30); + + verLayout->addLayout(funcLine); + verLayout->addWidget(refreshBtn); + refreshBtn->setStyleSheet("border: none; background-color: rgb(225, 179, 124, 0.8);"); + //verLayout->addWidget(scroll); + verLayout->addWidget(subWidget); + verLayout->addWidget(web); + web->setVisible(false); + + subWidget->setLayout(subVerLayout); + subWidget->setStyleSheet("background-color: rgb(76, 42, 26, 0.6);"); + for (int i = 0; i < row; i++) + { + lineList[i] = new QHBoxLayout(); + subVerLayout->addLayout(lineList[i]); + } + + for (int i = 0; i < row; i++) + { + for (int j = 0; j addWidget(btnList[index]); + } + } + + //必须要在setWidget方法调用之前把subWidget中的layout设置好,否则显示不出来 + //scroll->setWidget(subWidget); + + connect(web->getReturnBtn(), &QPushButton::clicked, this, &RecommendWidget::webReturn); + connect(refreshBtn, &QPushButton::clicked, this, &RecommendWidget::refresh); +} + +void RecommendWidget::InitLabel(QLabel * label) +{ + QFont lbl_font("Microsoft YaHei"); + lbl_font.setPointSize(10); + lbl_font.setBold(true); + label->setFont(lbl_font); + label->setStyleSheet("color:#FFFFFF; background-color: rgb(0, 0, 0, 0.1);"); + //label->setAttribute(Qt::WA_TranslucentBackground, true); + label->setAlignment(Qt::AlignCenter); +} + +void RecommendWidget::resizeEvent(QResizeEvent *event) +{ + background->resize(this->size()); +} + RecommendWidget::~RecommendWidget() { delete ui; diff --git a/src/ChangShaTour/recommendwidget.h b/src/ChangShaTour/recommendwidget.h index f81c3f8..def30cf 100755 --- a/src/ChangShaTour/recommendwidget.h +++ b/src/ChangShaTour/recommendwidget.h @@ -14,6 +14,7 @@ #include #include #include +#include #include "webwidget.h" #include "cglobal.h" #include "imgdownloader.h" @@ -45,9 +46,18 @@ public: void rollTop(); void algorithm(); + void SetBackground(QString); + + void InitRecommendWidget(); + + void InitLabel(QLabel *); + void resizeEvent(QResizeEvent *event); + private: Ui::RecommendWidget *ui; + QLabel * background; + int row; int column; int labellimit; diff --git a/src/ChangShaTour/recroutemanager.cpp b/src/ChangShaTour/recroutemanager.cpp new file mode 100644 index 0000000..71306d9 --- /dev/null +++ b/src/ChangShaTour/recroutemanager.cpp @@ -0,0 +1,133 @@ +#include "recroutemanager.h" + +RecRouteManager::RecRouteManager() +{ + +} + +int RecRouteManager::getDay() +{ + return this->day; +} + +int RecRouteManager::getNumber() +{ + return this->number; +} + +int RecRouteManager::getBudget() +{ + return this->budget; +} + +void RecRouteManager::setDay(int day) +{ + this->day = day; +} + +void RecRouteManager::setNumber(int number) +{ + this->number = number; +} + +void RecRouteManager::setBudget(int budget) +{ + this->budget = budget; +} + +int RecRouteManager::getPreference() +{ + return this->preference; +} + +void RecRouteManager::setPreference(int preference) +{ + this->preference = preference; +} + +void RecRouteManager::genRecRoutes() +{ + recRouteList = new Route[5]; + routeIdList = new int[5]; + numOfRecRoutes = 0; + QSqlQuery query(routeDb); + query.prepare("select distinct routeId from recRoutes where day = ? and minNumber >= ? and maxNumber <= ? and minBudget >= ? and maxBudget <= ? and preference = ? limit 5"); + query.addBindValue(day); + query.addBindValue(number - 2); + query.addBindValue(number + 2); + query.addBindValue(budget * (1 - 0.5)); + query.addBindValue(budget * (1 + 0.5)); + query.addBindValue(preference); + query.exec(); + + while(query.next()) + { + routeIdList[numOfRecRoutes] = query.value("routeId").toInt(); + numOfRecRoutes += 1; + } + + for(int i = 0; i < numOfRecRoutes; i++) + { + QDateTime * startTimeList = new QDateTime[16]; + QDateTime * endTimeList = new QDateTime[16]; + QStringList placeNameList; + QStringList urlList; + QStringList cateIdList; + QStringList trafficList; + double * distanceList = new double[16]; + double * timeCostList = new double[16]; + QStringList descriptionList; + + query.prepare("select * from recRoutes where routeId = ? order by placeNo"); + query.addBindValue(routeIdList[i]); + query.exec(); + int j = 0; + while(query.next()) + { + int routeId = query.value("routeId").toInt(); + QString routeName = query.value("routeName").toString(); + QDateTime startTime = query.value("startTime").toDateTime(); + QDateTime endTime = query.value("endTime").toDateTime(); + QString placeName = query.value("placeName").toString(); + QString url = query.value("url").toString(); + QString cateId = query.value("cateId").toString(); + QString traffic = query.value("traffic").toString(); + double distance = query.value("distance").toInt() / 1000.0; + double timeCost = query.value("timeCost").toInt() / 60.0; + QString description = query.value("description").toString(); + + recRouteList[i].setRouteId(routeId); + recRouteList[i].setRouteName(routeName); + startTimeList[j] = startTime; + endTimeList[j] = endTime; + placeNameList.append(placeName); + urlList.append(url); + cateIdList.append(cateId); + trafficList.append(traffic); + distanceList[j] = distance; + timeCostList[j] = timeCost; + descriptionList.append(description); + j++; + } + recRouteList[i].setAllItems(placeNameList, urlList, cateIdList, startTimeList, endTimeList, trafficList, distanceList, timeCostList, descriptionList); + } + qDebug() << "success"; + qDebug() << day; + qDebug() << number; + qDebug() << budget; + qDebug() << preference; + qDebug() << numOfRecRoutes; + qDebug() << recRouteList[0].getRouteName(); +} + +Route * RecRouteManager::getRecRoutes() +{ + return recRouteList; +} + +int RecRouteManager::getNumOfRecRoutes() +{ + return numOfRecRoutes; +} + + diff --git a/src/ChangShaTour/recroutemanager.h b/src/ChangShaTour/recroutemanager.h new file mode 100644 index 0000000..ae74320 --- /dev/null +++ b/src/ChangShaTour/recroutemanager.h @@ -0,0 +1,40 @@ +#ifndef RECROUTEMANAGER_H +#define RECROUTEMANAGER_H + +#include +#include +#include "cglobal.h" +#include "route.h" + +class RecRouteManager +{ +public: + RecRouteManager(); + + int getDay(); + int getNumber(); + int getBudget(); + void setDay(int day); + void setNumber(int number); + void setBudget(int budget); + + int getPreference(); + void setPreference(int preference); + + void genRecRoutes(); + Route * getRecRoutes(); + int getNumOfRecRoutes(); + +private: + Route * recRouteList; + int * routeIdList; + int numOfRecRoutes; + + int day; + int number; + int budget; + + int preference; +}; + +#endif // RECROUTEMANAGER_H diff --git a/src/ChangShaTour/registerwidget.cpp b/src/ChangShaTour/registerwidget.cpp index eda9e9f..c02d6b8 100755 --- a/src/ChangShaTour/registerwidget.cpp +++ b/src/ChangShaTour/registerwidget.cpp @@ -1,202 +1,202 @@ -#include "registerwidget.h" -#include "ui_registerwidget.h" -#include - -RegisterWidget::RegisterWidget(QWidget *parent) : - QWidget(parent), - ui(new Ui::RegisterWidget) -{ - ui->setupUi(this); - - background = new QLabel(this); - subWidget = new QWidget(this); - - InitRegisterWidget(); -} - -QPushButton * RegisterWidget::getGetVerificationCodeButton() -{ - return getVerificationCodeButon; -} - -QPushButton * RegisterWidget::getConfirmButton() -{ - return confirmButton; -} - -QPushButton * RegisterWidget::getCancelButton() -{ - return cancelButton; -} - -QString RegisterWidget::getEmailAddress() -{ - return emailAddressLineEdit->text(); -} - -QString RegisterWidget::getPassword() -{ - return passwordLineEdit->text(); -} - -QString RegisterWidget::getConfirmPassword() -{ - return confirmPasswordLineEdit->text(); -} - -QString RegisterWidget::getVerificationCode() -{ - return verificationCodeLineEdit->text(); -} - -void RegisterWidget::setEmailAddressNotEditable() -{ - emailAddressLineEdit->setEnabled(false); -} - -RegisterWidget::~RegisterWidget() -{ - delete ui; -} - -void RegisterWidget::SetBackground(QString url) -{ - background->setPixmap(url); - background->setScaledContents(true); -} - -void RegisterWidget::InitRegisterWidget() -{ - SetBackground("./softImages/RegisterImage.jpg"); - InitSubWidget(); -} - -void RegisterWidget::SetSubWidgetBackground(QString url) -{ - subBackGround->setPixmap(url); - subBackGround->setScaledContents(true); -} - -void RegisterWidget::InitSubWidget() -{ - QGridLayout * gridLayout = new QGridLayout(); - subWidget->setLayout(gridLayout); - - subBackGround = new QLabel(subWidget); - SetSubWidgetBackground("F:/QtDemo/StylesheetExercise/images/blackHalf.png"); - - QLabel * emailLabel = new QLabel("用户邮箱: "); - QLabel * passwordLabel = new QLabel("用户密码: "); - QLabel * confirmLabel = new QLabel("确认密码: "); - QLabel * verifyLabel = new QLabel("验证码: "); - InitLabel(emailLabel); - InitLabel(passwordLabel); - InitLabel(confirmLabel); - InitLabel(verifyLabel); - gridLayout->addWidget(emailLabel, 0, 0, 1, 1); - gridLayout->addWidget(passwordLabel, 1, 0, 1, 1); - gridLayout->addWidget(confirmLabel, 2, 0, 1, 1); - gridLayout->addWidget(verifyLabel, 3, 0, 1, 1); - - emailAddressLineEdit = new QLineEdit(); - passwordLineEdit = new QLineEdit(); - confirmPasswordLineEdit = new QLineEdit(); - verificationCodeLineEdit = new QLineEdit(); - InitLineEdit(emailAddressLineEdit); - emailAddressLineEdit->setPlaceholderText("请输入qq邮箱地址或163邮箱地址"); - InitLineEdit(passwordLineEdit); - passwordLineEdit->setPlaceholderText("请输入长度为6~12位的密码"); - passwordLineEdit->setEchoMode(QLineEdit::Password); - InitLineEdit(confirmPasswordLineEdit); - confirmPasswordLineEdit->setEchoMode(QLineEdit::Password); - InitLineEdit(verificationCodeLineEdit); - gridLayout->addWidget(emailAddressLineEdit, 0, 1, 1, 1); - gridLayout->addWidget(passwordLineEdit, 1, 1, 1, 1); - gridLayout->addWidget(confirmPasswordLineEdit, 2, 1, 1, 1); - gridLayout->addWidget(verificationCodeLineEdit, 3, 1, 1, 1); - - getVerificationCodeButon = new QPushButton("获取验证码"); - InitButton(getVerificationCodeButon); - gridLayout->addWidget(getVerificationCodeButon, 3, 2, 1, 1); - - QHBoxLayout * horiLayout = new QHBoxLayout(); - gridLayout->addLayout(horiLayout, 4, 1, 1, 1); - - confirmButton = new QPushButton("确认"); - InitButton(confirmButton); - horiLayout->addWidget(confirmButton); - - cancelButton = new QPushButton("取消"); - InitButton(cancelButton); - horiLayout->addWidget(cancelButton); -} - -void RegisterWidget::InitLabel(QLabel * label) -{ - QFont lbl_font("Microsoft YaHei"); - lbl_font.setPointSize(20); - lbl_font.setBold(true); - label->setFont(lbl_font); - label->setStyleSheet("color:#FFFFFF"); - label->setAlignment(Qt::AlignRight); -} - -void RegisterWidget::InitButton(QPushButton * button) -{ - button->setStyleSheet("QPushButton {" - "color:#ffffff;" - "background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #8CA8CC, stop: 1 #8CA8CC);" - "border-style:outset;" - "border-radius:10px;" - "font:bold 20px;" - "font-family: Microsoft YaHei;" - "min-width:100px;" - "min-height:20px;" - "padding:4px;" - "} " - "QPushButton:hover {" - "background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #6E8AB2, stop: 1 #6E8AB2);" - "border-style:outset;" - "border-radius:10px;" - "font:bold 20px;" - "font-family: Microsoft YaHei;" - "min-width:100px;" - "min-height:20px;" - "padding:4px;" - "} " - "QPushButton:pressed {" - "background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #6783AB, stop: 1 #6783AB);" - "border-style:outset;" - "border-radius:10px;" - "font:bold 20px;" - "font-family: Microsoft YaHei;" - "min-width:100px;" - "min-height:20px;" - "padding:4px;" - "}"); -} - -void RegisterWidget::InitLineEdit(QLineEdit * lineEdit) -{ - lineEdit->setStyleSheet("QLineEdit {" - " border-radius: 4px; " - " color:rgb(0, 0, 0); " - " background-color: rgb(255, 255, 255);" - "} " - " QLineEdit:focus { " - " border-style:outset; " - //" border-width:4px; " - " border-radius: 4px; " - //" border-color: #C1D7F1; " - " color:#ffffff; " - " background-color: #C1D7F1;" - "} "); - lineEdit->setFont(QFont("Microsoft YaHei" , 14, QFont::Bold)); -} - -void RegisterWidget::resizeEvent(QResizeEvent *event) -{ - background->resize(this->size()); - subWidget->resize(this->size()); - subBackGround->resize(subWidget->size()); -} +#include "registerwidget.h" +#include "ui_registerwidget.h" +#include + +RegisterWidget::RegisterWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::RegisterWidget) +{ + ui->setupUi(this); + + background = new QLabel(this); + subWidget = new QWidget(this); + + InitRegisterWidget(); +} + +QPushButton * RegisterWidget::getGetVerificationCodeButton() +{ + return getVerificationCodeButon; +} + +QPushButton * RegisterWidget::getConfirmButton() +{ + return confirmButton; +} + +QPushButton * RegisterWidget::getCancelButton() +{ + return cancelButton; +} + +QString RegisterWidget::getEmailAddress() +{ + return emailAddressLineEdit->text(); +} + +QString RegisterWidget::getPassword() +{ + return passwordLineEdit->text(); +} + +QString RegisterWidget::getConfirmPassword() +{ + return confirmPasswordLineEdit->text(); +} + +QString RegisterWidget::getVerificationCode() +{ + return verificationCodeLineEdit->text(); +} + +void RegisterWidget::setEmailAddressNotEditable() +{ + emailAddressLineEdit->setEnabled(false); +} + +RegisterWidget::~RegisterWidget() +{ + delete ui; +} + +void RegisterWidget::SetBackground(QString url) +{ + background->setPixmap(url); + background->setScaledContents(true); +} + +void RegisterWidget::InitRegisterWidget() +{ + SetBackground("./softImages/RegisterImage.jpg"); + InitSubWidget(); +} + +void RegisterWidget::SetSubWidgetBackground(QString url) +{ + subBackGround->setPixmap(url); + subBackGround->setScaledContents(true); +} + +void RegisterWidget::InitSubWidget() +{ + QGridLayout * gridLayout = new QGridLayout(); + subWidget->setLayout(gridLayout); + + subBackGround = new QLabel(subWidget); + SetSubWidgetBackground("F:/QtDemo/StylesheetExercise/images/blackHalf.png"); + + QLabel * emailLabel = new QLabel("用户邮箱: "); + QLabel * passwordLabel = new QLabel("用户密码: "); + QLabel * confirmLabel = new QLabel("确认密码: "); + QLabel * verifyLabel = new QLabel("验证码: "); + InitLabel(emailLabel); + InitLabel(passwordLabel); + InitLabel(confirmLabel); + InitLabel(verifyLabel); + gridLayout->addWidget(emailLabel, 0, 0, 1, 1); + gridLayout->addWidget(passwordLabel, 1, 0, 1, 1); + gridLayout->addWidget(confirmLabel, 2, 0, 1, 1); + gridLayout->addWidget(verifyLabel, 3, 0, 1, 1); + + emailAddressLineEdit = new QLineEdit(); + passwordLineEdit = new QLineEdit(); + confirmPasswordLineEdit = new QLineEdit(); + verificationCodeLineEdit = new QLineEdit(); + InitLineEdit(emailAddressLineEdit); + emailAddressLineEdit->setPlaceholderText("请输入qq邮箱地址或163邮箱地址"); + InitLineEdit(passwordLineEdit); + passwordLineEdit->setPlaceholderText("请输入长度为6~12位的密码"); + passwordLineEdit->setEchoMode(QLineEdit::Password); + InitLineEdit(confirmPasswordLineEdit); + confirmPasswordLineEdit->setEchoMode(QLineEdit::Password); + InitLineEdit(verificationCodeLineEdit); + gridLayout->addWidget(emailAddressLineEdit, 0, 1, 1, 1); + gridLayout->addWidget(passwordLineEdit, 1, 1, 1, 1); + gridLayout->addWidget(confirmPasswordLineEdit, 2, 1, 1, 1); + gridLayout->addWidget(verificationCodeLineEdit, 3, 1, 1, 1); + + getVerificationCodeButon = new QPushButton("获取验证码"); + InitButton(getVerificationCodeButon); + gridLayout->addWidget(getVerificationCodeButon, 3, 2, 1, 1); + + QHBoxLayout * horiLayout = new QHBoxLayout(); + gridLayout->addLayout(horiLayout, 4, 1, 1, 1); + + confirmButton = new QPushButton("确认"); + InitButton(confirmButton); + horiLayout->addWidget(confirmButton); + + cancelButton = new QPushButton("取消"); + InitButton(cancelButton); + horiLayout->addWidget(cancelButton); +} + +void RegisterWidget::InitLabel(QLabel * label) +{ + QFont lbl_font("Microsoft YaHei"); + lbl_font.setPointSize(20); + lbl_font.setBold(true); + label->setFont(lbl_font); + label->setStyleSheet("color:#FFFFFF"); + label->setAlignment(Qt::AlignRight); +} + +void RegisterWidget::InitButton(QPushButton * button) +{ + button->setStyleSheet("QPushButton {" + "color:#ffffff;" + "background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #8CA8CC, stop: 1 #8CA8CC);" + "border-style:outset;" + "border-radius:10px;" + "font:bold 20px;" + "font-family: Microsoft YaHei;" + "min-width:100px;" + "min-height:20px;" + "padding:4px;" + "} " + "QPushButton:hover {" + "background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #6E8AB2, stop: 1 #6E8AB2);" + "border-style:outset;" + "border-radius:10px;" + "font:bold 20px;" + "font-family: Microsoft YaHei;" + "min-width:100px;" + "min-height:20px;" + "padding:4px;" + "} " + "QPushButton:pressed {" + "background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #6783AB, stop: 1 #6783AB);" + "border-style:outset;" + "border-radius:10px;" + "font:bold 20px;" + "font-family: Microsoft YaHei;" + "min-width:100px;" + "min-height:20px;" + "padding:4px;" + "}"); +} + +void RegisterWidget::InitLineEdit(QLineEdit * lineEdit) +{ + lineEdit->setStyleSheet("QLineEdit {" + " border-radius: 4px; " + " color:rgb(0, 0, 0); " + " background-color: rgb(255, 255, 255);" + "} " + " QLineEdit:focus { " + " border-style:outset; " + //" border-width:4px; " + " border-radius: 4px; " + //" border-color: #C1D7F1; " + " color:#ffffff; " + " background-color: #C1D7F1;" + "} "); + lineEdit->setFont(QFont("Microsoft YaHei" , 14, QFont::Bold)); +} + +void RegisterWidget::resizeEvent(QResizeEvent *event) +{ + background->resize(this->size()); + subWidget->resize(this->size()); + subBackGround->resize(subWidget->size()); +} diff --git a/src/ChangShaTour/registerwidget.h b/src/ChangShaTour/registerwidget.h index 1fe2887..7fcadee 100755 --- a/src/ChangShaTour/registerwidget.h +++ b/src/ChangShaTour/registerwidget.h @@ -1,68 +1,68 @@ -#ifndef REGISTERWIDGET_H -#define REGISTERWIDGET_H - -#include -#include -#include -#include -#include -#include -#include "registermanager.h" - -#if _MSC_VER >= 1600 -#pragma execution_character_set("utf-8") -#endif - -namespace Ui { -class RegisterWidget; -} - -class RegisterWidget : public QWidget -{ - Q_OBJECT - -public: - explicit RegisterWidget(QWidget *parent = nullptr); - ~RegisterWidget(); - - void SetBackground(QString); - void InitRegisterWidget(); - void SetSubWidgetBackground(QString); - void InitSubWidget(); - void InitLabel(QLabel *); - void InitButton(QPushButton *); - void InitLineEdit(QLineEdit *); - void resizeEvent(QResizeEvent * event); - - QPushButton * getGetVerificationCodeButton(); - QPushButton * getConfirmButton(); - QPushButton * getCancelButton(); - - QString getEmailAddress(); - QString getPassword(); - QString getConfirmPassword(); - QString getVerificationCode(); - - void setEmailAddressNotEditable(); - - -private: - Ui::RegisterWidget *ui; - - QLabel * background; - QLabel * subBackGround; - - QWidget * subWidget; - - QLineEdit * emailAddressLineEdit; - QLineEdit * passwordLineEdit; - QLineEdit * confirmPasswordLineEdit; - QLineEdit * verificationCodeLineEdit; - - QPushButton * getVerificationCodeButon; - QPushButton * confirmButton; - QPushButton * cancelButton; - -}; - -#endif // REGISTERWIDGET_H +#ifndef REGISTERWIDGET_H +#define REGISTERWIDGET_H + +#include +#include +#include +#include +#include +#include +#include "registermanager.h" + +#if _MSC_VER >= 1600 +#pragma execution_character_set("utf-8") +#endif + +namespace Ui { +class RegisterWidget; +} + +class RegisterWidget : public QWidget +{ + Q_OBJECT + +public: + explicit RegisterWidget(QWidget *parent = nullptr); + ~RegisterWidget(); + + void SetBackground(QString); + void InitRegisterWidget(); + void SetSubWidgetBackground(QString); + void InitSubWidget(); + void InitLabel(QLabel *); + void InitButton(QPushButton *); + void InitLineEdit(QLineEdit *); + void resizeEvent(QResizeEvent * event); + + QPushButton * getGetVerificationCodeButton(); + QPushButton * getConfirmButton(); + QPushButton * getCancelButton(); + + QString getEmailAddress(); + QString getPassword(); + QString getConfirmPassword(); + QString getVerificationCode(); + + void setEmailAddressNotEditable(); + + +private: + Ui::RegisterWidget *ui; + + QLabel * background; + QLabel * subBackGround; + + QWidget * subWidget; + + QLineEdit * emailAddressLineEdit; + QLineEdit * passwordLineEdit; + QLineEdit * confirmPasswordLineEdit; + QLineEdit * verificationCodeLineEdit; + + QPushButton * getVerificationCodeButon; + QPushButton * confirmButton; + QPushButton * cancelButton; + +}; + +#endif // REGISTERWIDGET_H diff --git a/src/ChangShaTour/registerwidget.ui b/src/ChangShaTour/registerwidget.ui index 52a5988..96058f2 100755 --- a/src/ChangShaTour/registerwidget.ui +++ b/src/ChangShaTour/registerwidget.ui @@ -1,21 +1,21 @@ - - - - - RegisterWidget - - - - 0 - 0 - 400 - 300 - - - - Form - - - - - + + + + + RegisterWidget + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + diff --git a/src/ChangShaTour/route.cpp b/src/ChangShaTour/route.cpp index 832371b..e5bca0b 100755 --- a/src/ChangShaTour/route.cpp +++ b/src/ChangShaTour/route.cpp @@ -1,97 +1,97 @@ -#include "route.h" -#include - -Route::Route() -{ - routeItems=new RouteItem; - routeItems->next=NULL; -} -//route结构体使用方式和query类似 -//Route * oneRoute = getAllItems(); -//while (oneRoute->next!=NULL) -//{ -// oneRoute=oneRoute->next; -// url=oneRoute->url; -//} -RouteItem * Route::getAllItems() -{ - return this->routeItems; -} -int Route::getRouteId() -{ - return this->routeId; -} -QString Route::getRouteName() -{ - return this->routeName; -} -int Route::getUserId() -{ - return this->userId; -} -void Route::setRouteName(QString name) -{ - this->routeName = name; - return; -} -void Route::setUserId(int id) -{ - this->userId=id; -} -void Route::setRouteId(int id) -{ - this->routeId=id; -} -void Route::setAllItems(QStringList titleList,QStringList urlList,QStringList cateIdList,QDateTime * startTimeList,QDateTime * endTimeList,QStringList trafficList,double * distanceList,double * timeCostList,QStringList descriptionList) -{ - RouteItem * head= routeItems; - RouteItem * p; - int totalSize=titleList.size(); - int i; - for(i=0;iplaceName = titleList[i]; - p->url = urlList[i]; - p->cateId = cateIdList[i]; - p->startTime = startTimeList[i]; - p->endTime = endTimeList[i]; - p->traffic = trafficList[i]; - p->distance = distanceList[i]; - p->timeCost = timeCostList[i]; - p->description = descriptionList[i]; - p->next = NULL; - head->next = p; - head=head->next; - } -} -//删除和添加都是根据位置,位置从1开始计数 -RouteItem * Route::addItem(RouteItem * oneItem,int locate) -{ - RouteItem * p = routeItems; - int i = 0; - while(p->next != NULL&&inext; - i++; - } - oneItem->next = p->next; - p->next=oneItem; - return routeItems; -} -RouteItem * Route::deleteItem(int locate) -{ - RouteItem * p = routeItems; - RouteItem * pre = routeItems; - int i = 0; - while(p->next != NULL&&inext; - i++; - } - pre->next = p->next; - free(p); - return routeItems; - -} +#include "route.h" +#include + +Route::Route() +{ + routeItems=new RouteItem; + routeItems->next=NULL; +} +//route结构体使用方式和query类似 +//Route * oneRoute = getAllItems(); +//while (oneRoute->next!=NULL) +//{ +// oneRoute=oneRoute->next; +// url=oneRoute->url; +//} +RouteItem * Route::getAllItems() +{ + return this->routeItems; +} +int Route::getRouteId() +{ + return this->routeId; +} +QString Route::getRouteName() +{ + return this->routeName; +} +int Route::getUserId() +{ + return this->userId; +} +void Route::setRouteName(QString name) +{ + this->routeName = name; + return; +} +void Route::setUserId(int id) +{ + this->userId=id; +} +void Route::setRouteId(int id) +{ + this->routeId=id; +} +void Route::setAllItems(QStringList titleList,QStringList urlList,QStringList cateIdList,QDateTime * startTimeList,QDateTime * endTimeList,QStringList trafficList,double * distanceList,double * timeCostList,QStringList descriptionList) +{ + RouteItem * head= routeItems; + RouteItem * p; + int totalSize=titleList.size(); + int i; + for(i=0;iplaceName = titleList[i]; + p->url = urlList[i]; + p->cateId = cateIdList[i]; + p->startTime = startTimeList[i]; + p->endTime = endTimeList[i]; + p->traffic = trafficList[i]; + p->distance = distanceList[i]; + p->timeCost = timeCostList[i]; + p->description = descriptionList[i]; + p->next = NULL; + head->next = p; + head=head->next; + } +} +//删除和添加都是根据位置,位置从1开始计数 +RouteItem * Route::addItem(RouteItem * oneItem,int locate) +{ + RouteItem * p = routeItems; + int i = 0; + while(p->next != NULL&&inext; + i++; + } + oneItem->next = p->next; + p->next=oneItem; + return routeItems; +} +RouteItem * Route::deleteItem(int locate) +{ + RouteItem * p = routeItems; + RouteItem * pre = routeItems; + int i = 0; + while(p->next != NULL&&inext; + i++; + } + pre->next = p->next; + free(p); + return routeItems; + +} diff --git a/src/ChangShaTour/route.h b/src/ChangShaTour/route.h index d83a2f7..4b9c2bb 100755 --- a/src/ChangShaTour/route.h +++ b/src/ChangShaTour/route.h @@ -1,28 +1,28 @@ -#ifndef ROUTE_H -#define ROUTE_H -#include "RouteItem.h" -#include - -class Route -{ -public: - Route(); - struct routeItem * getAllItems(); - //距离和时间都用int表示,单位m/km,时间s/min,统一一下 - void setAllItems(QStringList titleList,QStringList urlList,QStringList cateIdList,QDateTime * startTimeList,QDateTime * endTimeList,QStringList trafficList,double *distanceList,double *timeCostList,QStringList descriptionList); - int getRouteId(); - int getUserId(); - QString getRouteName(); - void setRouteName(QString name); - void setRouteId(int id); - void setUserId(int id); - RouteItem * addItem(RouteItem * oneItem,int locate); - RouteItem * deleteItem(int locate); -private: - QString routeName; - int userId=0;//路线没有用户时默认为0 - int routeId=0;//路线编号默认为0 - struct routeItem *routeItems; -}; - -#endif // ROUTE_H +#ifndef ROUTE_H +#define ROUTE_H +#include "RouteItem.h" +#include + +class Route +{ +public: + Route(); + struct routeItem * getAllItems(); + //距离和时间都用int表示,单位m/km,时间s/min,统一一下 + void setAllItems(QStringList titleList,QStringList urlList,QStringList cateIdList,QDateTime * startTimeList,QDateTime * endTimeList,QStringList trafficList,double *distanceList,double *timeCostList,QStringList descriptionList); + int getRouteId(); + int getUserId(); + QString getRouteName(); + void setRouteName(QString name); + void setRouteId(int id); + void setUserId(int id); + RouteItem * addItem(RouteItem * oneItem,int locate); + RouteItem * deleteItem(int locate); +private: + QString routeName; + int userId=0;//路线没有用户时默认为0 + int routeId=0;//路线编号默认为0 + struct routeItem *routeItems; +}; + +#endif // ROUTE_H diff --git a/src/ChangShaTour/routechoicewidget.cpp b/src/ChangShaTour/routechoicewidget.cpp index a357180..48d423e 100755 --- a/src/ChangShaTour/routechoicewidget.cpp +++ b/src/ChangShaTour/routechoicewidget.cpp @@ -8,6 +8,32 @@ RouteChoiceWidget::RouteChoiceWidget(QWidget *parent) : ui->setupUi(this); } +void RouteChoiceWidget::setBtns(Route * routeList, int len) +{ + verticalLayout = new QVBoxLayout(); + this->setLayout(verticalLayout); + for(int i = 0; i < len; i++) + { + Route recRoute = routeList[i]; + QString routeName = recRoute.getRouteName(); + RouteItem * head = recRoute.getAllItems(); + head = head->next; + QString text; + text += routeName; + text += "\r\n"; + text += head->placeName; + while(head->next) + { + head = head->next; + text += "--->"; + text += head->placeName; + } + QPushButton * recRouteButton = new QPushButton(text); + recRouteButton->setStyleSheet("QPushButton{text-align : left;}"); + verticalLayout->addWidget(recRouteButton); + } +} + RouteChoiceWidget::~RouteChoiceWidget() { delete ui; diff --git a/src/ChangShaTour/routechoicewidget.h b/src/ChangShaTour/routechoicewidget.h index f85f172..78b4627 100755 --- a/src/ChangShaTour/routechoicewidget.h +++ b/src/ChangShaTour/routechoicewidget.h @@ -2,6 +2,9 @@ #define ROUTECHOICEWIDGET_H #include +#include +#include +#include "route.h" #if _MSC_VER >= 1600 #pragma execution_character_set("utf-8") @@ -19,8 +22,12 @@ public: explicit RouteChoiceWidget(QWidget *parent = nullptr); ~RouteChoiceWidget(); + void setBtns(Route * routeList, int len); + private: Ui::RouteChoiceWidget *ui; + + QVBoxLayout * verticalLayout; }; #endif // ROUTECHOICEWIDGET_H diff --git a/src/ChangShaTour/routeplanning.cpp b/src/ChangShaTour/routeplanning.cpp new file mode 100644 index 0000000..515bfe8 --- /dev/null +++ b/src/ChangShaTour/routeplanning.cpp @@ -0,0 +1,298 @@ +#include "routeplanning.h" + +RoutePlanning::RoutePlanning() +{ + trafficNum = 4; +} + + +QStringList RoutePlanning::getWalkingRoute(QString origin, QString destination) +{ + QStringList walkingInfo; + + QNetworkAccessManager *netManager = new QNetworkAccessManager(); + QString url = "https://restapi.amap.com/v3/direction/walking?origin=" + origin + "&destination=" + destination + "&key=6248dbf9cf7275be36d27841a6d7300b"; + qDebug() << "Url=" << url; + + QEventLoop loop; + + QNetworkRequest request; + request.setUrl(url); + QNetworkReply *reply = netManager->get(request); + qDebug("Request Sent!"); + QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit())); + + //add timeout deal + QTimer *tmpTimer = new QTimer(); + QObject::connect(tmpTimer,SIGNAL(timeout()),&loop, SLOT(quit())); + tmpTimer->setSingleShot(true); + tmpTimer->start(60000); + loop.exec(); + tmpTimer->stop(); + + if(reply->error()==QNetworkReply::NoError) + { + QByteArray resBytes = reply->readAll(); +// qDebug()<<"resBytes="<setSingleShot(true); + tmpTimer->start(60000); + loop.exec(); + tmpTimer->stop(); + if(reply->error()==QNetworkReply::NoError) + { + QByteArray resBytes = reply->readAll(); + + QJsonDocument doc = QJsonDocument::fromJson(resBytes); + QJsonObject json = doc.object(); + + QString statusCode = json.value("status").toString(); + qDebug()<<"Transit status:"<setSingleShot(true); + tmpTimer->start(60000); + loop.exec(); + tmpTimer->stop(); + + if(reply->error()==QNetworkReply::NoError) + { + QByteArray resBytes = reply->readAll(); +// qDebug()<<"resBytes="<setSingleShot(true); + tmpTimer->start(60000); + loop.exec(); + tmpTimer->stop(); + + if(reply->error()==QNetworkReply::NoError) + { + QByteArray resBytes = reply->readAll(); +// qDebug()<<"resBytes="< +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if _MSC_VER >= 1600 +#pragma execution_character_set("utf-8") +#endif + +class RoutePlanning +{ +public: + RoutePlanning(); + + QStringList * getAllInfo(QString origin, QString destination); + +private: + int trafficNum; + + QStringList getWalkingRoute(QString origin, QString destination); + QStringList getTransitRoute(QString origin, QString destination); + QStringList getDrivingRoute(QString origin, QString destination); + QStringList getBicyclingRoute(QString origin, QString destination); + +}; + +#endif // ROUTEPLANNING_H diff --git a/src/ChangShaTour/searchwidget.cpp b/src/ChangShaTour/searchwidget.cpp index 94e3f95..25eab72 100755 --- a/src/ChangShaTour/searchwidget.cpp +++ b/src/ChangShaTour/searchwidget.cpp @@ -1,322 +1,322 @@ -#include "searchwidget.h" -#include "ui_searchwidget.h" - -SearchWidget::SearchWidget(QWidget *parent) : - QWidget(parent), - ui(new Ui::SearchWidget) -{ - ui->setupUi(this); - - showLimit = 15; - cateList.append("food"); - cateList.append("entertainment"); - cateList.append("hotel"); - cateList.append("attractions"); - cateList.append("sport"); - lengthList = (int *)malloc(sizeof(int) * cateList.length()); - idList = (int *)malloc(sizeof(int) * showLimit); - - mainLayout = new QVBoxLayout(); - - subWidget = new QWidget(); - web = new WebWidget(); - nullWidget = new QLabel("抱歉,未找到您要的结果。"); - - subLayout = new QVBoxLayout(); - - rtn = new QPushButton("返回"); - scroll = new QScrollArea(); - - scrollWidget = new QWidget(); - scrollLayout = new QVBoxLayout(); - - btnList = (QToolButton **)malloc(sizeof(QToolButton *) * showLimit); - - switchLine = new QHBoxLayout(); - up = new QPushButton("上一页"); - down = new QPushButton("下一页"); - - //设置布局 - this->setLayout(mainLayout); - - mainLayout->addWidget(subWidget); - mainLayout->addWidget(web); - mainLayout->addWidget(nullWidget); - web->setVisible(false); - nullWidget->setVisible(false); - - subWidget->setLayout(subLayout); - - subLayout->addWidget(rtn); - subLayout->addWidget(scroll); - subLayout->addLayout(switchLine); - - switchLine->addWidget(up); - switchLine->addWidget(down); - - connect(web->getReturnBtn(), &QPushButton::clicked, this, &SearchWidget::returnWeb); - connect(up, &QPushButton::clicked, this, &SearchWidget::pageUp); - connect(down, &QPushButton::clicked, this, &SearchWidget::pageDown); -} - -SearchWidget::~SearchWidget() -{ - delete ui; -} - -QPushButton *SearchWidget::getReturnBtn() -{ - return rtn; -} - -void SearchWidget::sendInput(QString input) -{ - this->segment = input; - qDebug() << "segment:" <(); - totalNum += query.value("num").value(); - } - - pageNum = (totalNum + showLimit - 1)/showLimit; - page2cate = (int *)malloc(sizeof(int) * pageNum); - page2offset = (int *)malloc(sizeof(int) * pageNum); - -} - -void SearchWidget::queryDatabase(QSqlQuery query) -{ - query.exec(); - int i = currentHead; - while(query.next()==true && i < showLimit) - { - QVariant id = query.value("id"); - - QVariant detail = query.value("detail"); - - QVariant frontimg = query.value("frontimg"); - - QVariant title = query.value("title"); - QVariant avgscore = query.value("avgscore"); - QVariant comments = query.value("comments"); - QVariant address = query.value("address"); - QVariant cateId = query.value("cateId"); -// QVariant avgprice = query.value("avgprice"); - - QString name = title.value(); - QString score = QString::number(avgscore.value()); - QString commentNum = QString::number(comments.value()); - QString addr = address.value(); -// QString price = QString::number(avgprice.value()); - QString text = name + "\n" + score + "分 " + commentNum + "条评论\n" + addr + "\n";// + "人均" + price + "元"; - QString cateid = cateId.value(); - - idList[i] = id.value(); - nameList.append(name); - urlList.append(detail.value()); - imgList.append(frontimg.value()); - textList.append(text); - cateIdList.append(cateid); - i++; - } - currentQueryLength = i - currentHead; -} - -QToolButton *SearchWidget::setBtn(QToolButton *btn, const QString iconPath, const QString text) -{ - if(iconPath != "") - btn->setIcon(QIcon(iconPath)); - btn->setText(text); - btn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - btn->setIconSize(QSize(100,200)); - btn->setFixedSize(1230,200); - - return btn; -} - -void SearchWidget::setBtns() -{ - int i = currentHead; -// qDebug() << "currentHead:" << currentHead; -// qDebug() << "currentQueryLength:" << currentQueryLength; - for (i; i < currentHead + currentQueryLength; i++) - { - int index = i; - //下载图片到本地 - QString imgPath = "./images/" + cateList[currentCate] + QString::number(idList[index]) + ".png"; - imgDownloader *download = new imgDownloader(); - download->downloadFileFromUrl(imgList[index], imgPath); - btnList[index] = setBtn(btnList[index], imgPath, textList[index]); - qDebug() << "info:" << cateList[currentCate] << idList[index] << urlList[index] << imgList[index]; -// btnList[index]->setVisible(true); - disconnect(btnList[index], 0, 0, 0); - connect(btnList[index], &QToolButton::clicked, this, [=](){web->loadPage(nameList[index], imgList[index], urlList[index], cateIdList[index]); subWidget->setVisible(false); web->setVisible(true); nullWidget->setVisible(false);}); - } - for (i; i < showLimit; i++) - { - int index = i; - btnList[index] = setBtn(btnList[index], "./images/transparent.png", ""); -// btnList[index]->setVisible(false); - disconnect(btnList[index], 0, 0, 0); - } -// offset += currentQueryLength; -// currentHead += currentQueryLength; -} - -void SearchWidget::querySet() -{ - rollTop(); - - //重置存储查询信息的列表 - nameList.clear(); - urlList.clear(); - imgList.clear(); - textList.clear(); - cateIdList.clear(); - currentHead = 0; - currentQueryLength = 0; - currentCate = page2cate[currentPage - 1]; - currentOffset = page2offset[currentPage - 1]; - for (int i = 0; i removeWidget(scroll); - scroll->takeWidget(); - scrollWidget->deleteLater(); - scrollWidget = new QWidget(); - scrollLayout->deleteLater(); - scrollLayout = new QVBoxLayout(); - scrollWidget->setLayout(scrollLayout); - - qDebug() << "currentPage:" << currentPage; - - QSqlQuery query(meituanDb); - - while (currentHead < showLimit) - { - //判断是否换表 - if (currentOffset >= lengthList[currentCate]) - { - currentCate += 1; - currentOffset = 0; - if (currentCate >= cateList.length()) - break; - } - //查询数据 - query.prepare("select * from " + cateList[currentCate] + " where title like :segment limit :offset , :showLimit"); - query.bindValue(":segment", "%" + segment + "%"); - query.bindValue(":offset", currentOffset); - qDebug() << "currentCate:" << currentCate; -// qDebug() << "offset:" << offset; - query.bindValue(":showLimit", showLimit); - queryDatabase(query); -// qDebug() << "query success"; - //设置按钮 - setBtns(); -// qDebug() << "set buttons success"; - - - //设置滚动界面布局 - for (int i = currentHead; i < currentHead + currentQueryLength; i++) - { - scrollLayout->addWidget(btnList[i]); - } - - currentOffset += currentQueryLength; - currentHead += currentQueryLength; - } - page2cate[currentPage] = currentCate; - page2offset[currentPage] = currentOffset; - - scroll->setWidget(scrollWidget); - -} - -void SearchWidget::showResult() -{ - - totalNum = 0; - pageNum = 0; - getTotalNum(); - qDebug() << "totalNum:" << totalNum; - qDebug() << "pageNum:" << pageNum; - currentPage = 1; - currentCate = 0; - currentOffset = 0; - page2cate[0] = currentCate; - page2offset[0] = currentOffset; - if (totalNum) - { - querySet(); - subWidget->setVisible(true); - nullWidget->setVisible(false); - } - else - { - subWidget->setVisible(false); - nullWidget->setVisible(true); - } - web->setVisible(false); - -} - -void SearchWidget::returnWeb() -{ - subWidget->setVisible(true); - web->setVisible(false); - nullWidget->setVisible(false); -} - -void SearchWidget::pageUp() -{ - currentPage--; - if (currentPage < 1) - { - currentPage = 1; - qDebug("这是第一页"); - } - else - { - rollTop(); - querySet(); - } -} - -void SearchWidget::pageDown() -{ - currentPage++; - if (currentPage > pageNum) - { - currentPage = pageNum; - qDebug("已经是最后一页了!"); - } - else - { - rollTop(); - querySet(); - } -} - -void SearchWidget::rollTop() -{ - QScrollBar *scrollBar = scroll->verticalScrollBar(); - scrollBar->setValue(scrollBar->minimum()); -} - +#include "searchwidget.h" +#include "ui_searchwidget.h" + +SearchWidget::SearchWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::SearchWidget) +{ + ui->setupUi(this); + + showLimit = 15; + cateList.append("food"); + cateList.append("entertainment"); + cateList.append("hotel"); + cateList.append("attractions"); + cateList.append("sport"); + lengthList = (int *)malloc(sizeof(int) * cateList.length()); + idList = (int *)malloc(sizeof(int) * showLimit); + + mainLayout = new QVBoxLayout(); + + subWidget = new QWidget(); + web = new WebWidget(); + nullWidget = new QLabel("抱歉,未找到您要的结果。"); + + subLayout = new QVBoxLayout(); + + rtn = new QPushButton("返回"); + scroll = new QScrollArea(); + + scrollWidget = new QWidget(); + scrollLayout = new QVBoxLayout(); + + btnList = (QToolButton **)malloc(sizeof(QToolButton *) * showLimit); + + switchLine = new QHBoxLayout(); + up = new QPushButton("上一页"); + down = new QPushButton("下一页"); + + //设置布局 + this->setLayout(mainLayout); + + mainLayout->addWidget(subWidget); + mainLayout->addWidget(web); + mainLayout->addWidget(nullWidget); + web->setVisible(false); + nullWidget->setVisible(false); + + subWidget->setLayout(subLayout); + + subLayout->addWidget(rtn); + subLayout->addWidget(scroll); + subLayout->addLayout(switchLine); + + switchLine->addWidget(up); + switchLine->addWidget(down); + + connect(web->getReturnBtn(), &QPushButton::clicked, this, &SearchWidget::returnWeb); + connect(up, &QPushButton::clicked, this, &SearchWidget::pageUp); + connect(down, &QPushButton::clicked, this, &SearchWidget::pageDown); +} + +SearchWidget::~SearchWidget() +{ + delete ui; +} + +QPushButton *SearchWidget::getReturnBtn() +{ + return rtn; +} + +void SearchWidget::sendInput(QString input) +{ + this->segment = input; + qDebug() << "segment:" <(); + totalNum += query.value("num").value(); + } + + pageNum = (totalNum + showLimit - 1)/showLimit; + page2cate = (int *)malloc(sizeof(int) * pageNum); + page2offset = (int *)malloc(sizeof(int) * pageNum); + +} + +void SearchWidget::queryDatabase(QSqlQuery query) +{ + query.exec(); + int i = currentHead; + while(query.next()==true && i < showLimit) + { + QVariant id = query.value("id"); + + QVariant detail = query.value("detail"); + + QVariant frontimg = query.value("frontimg"); + + QVariant title = query.value("title"); + QVariant avgscore = query.value("avgscore"); + QVariant comments = query.value("comments"); + QVariant address = query.value("address"); + QVariant cateId = query.value("cateId"); +// QVariant avgprice = query.value("avgprice"); + + QString name = title.value(); + QString score = QString::number(avgscore.value()); + QString commentNum = QString::number(comments.value()); + QString addr = address.value(); +// QString price = QString::number(avgprice.value()); + QString text = name + "\n" + score + "分 " + commentNum + "条评论\n" + addr + "\n";// + "人均" + price + "元"; + QString cateid = cateId.value(); + + idList[i] = id.value(); + nameList.append(name); + urlList.append(detail.value()); + imgList.append(frontimg.value()); + textList.append(text); + cateIdList.append(cateid); + i++; + } + currentQueryLength = i - currentHead; +} + +QToolButton *SearchWidget::setBtn(QToolButton *btn, const QString iconPath, const QString text) +{ + if(iconPath != "") + btn->setIcon(QIcon(iconPath)); + btn->setText(text); + btn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + btn->setIconSize(QSize(100,200)); + btn->setFixedSize(1230,200); + + return btn; +} + +void SearchWidget::setBtns() +{ + int i = currentHead; +// qDebug() << "currentHead:" << currentHead; +// qDebug() << "currentQueryLength:" << currentQueryLength; + for (i; i < currentHead + currentQueryLength; i++) + { + int index = i; + //下载图片到本地 + QString imgPath = "./images/" + cateList[currentCate] + QString::number(idList[index]) + ".png"; + imgDownloader *download = new imgDownloader(); + download->downloadFileFromUrl(imgList[index], imgPath); + btnList[index] = setBtn(btnList[index], imgPath, textList[index]); + qDebug() << "info:" << cateList[currentCate] << idList[index] << urlList[index] << imgList[index]; +// btnList[index]->setVisible(true); + disconnect(btnList[index], 0, 0, 0); + connect(btnList[index], &QToolButton::clicked, this, [=](){web->loadPage(nameList[index], imgList[index], urlList[index], cateIdList[index]); subWidget->setVisible(false); web->setVisible(true); nullWidget->setVisible(false);}); + } + for (i; i < showLimit; i++) + { + int index = i; + btnList[index] = setBtn(btnList[index], "./images/transparent.png", ""); +// btnList[index]->setVisible(false); + disconnect(btnList[index], 0, 0, 0); + } +// offset += currentQueryLength; +// currentHead += currentQueryLength; +} + +void SearchWidget::querySet() +{ + rollTop(); + + //重置存储查询信息的列表 + nameList.clear(); + urlList.clear(); + imgList.clear(); + textList.clear(); + cateIdList.clear(); + currentHead = 0; + currentQueryLength = 0; + currentCate = page2cate[currentPage - 1]; + currentOffset = page2offset[currentPage - 1]; + for (int i = 0; i removeWidget(scroll); + scroll->takeWidget(); + scrollWidget->deleteLater(); + scrollWidget = new QWidget(); + scrollLayout->deleteLater(); + scrollLayout = new QVBoxLayout(); + scrollWidget->setLayout(scrollLayout); + + qDebug() << "currentPage:" << currentPage; + + QSqlQuery query(meituanDb); + + while (currentHead < showLimit) + { + //判断是否换表 + if (currentOffset >= lengthList[currentCate]) + { + currentCate += 1; + currentOffset = 0; + if (currentCate >= cateList.length()) + break; + } + //查询数据 + query.prepare("select * from " + cateList[currentCate] + " where title like :segment limit :offset , :showLimit"); + query.bindValue(":segment", "%" + segment + "%"); + query.bindValue(":offset", currentOffset); + qDebug() << "currentCate:" << currentCate; +// qDebug() << "offset:" << offset; + query.bindValue(":showLimit", showLimit); + queryDatabase(query); +// qDebug() << "query success"; + //设置按钮 + setBtns(); +// qDebug() << "set buttons success"; + + + //设置滚动界面布局 + for (int i = currentHead; i < currentHead + currentQueryLength; i++) + { + scrollLayout->addWidget(btnList[i]); + } + + currentOffset += currentQueryLength; + currentHead += currentQueryLength; + } + page2cate[currentPage] = currentCate; + page2offset[currentPage] = currentOffset; + + scroll->setWidget(scrollWidget); + +} + +void SearchWidget::showResult() +{ + + totalNum = 0; + pageNum = 0; + getTotalNum(); + qDebug() << "totalNum:" << totalNum; + qDebug() << "pageNum:" << pageNum; + currentPage = 1; + currentCate = 0; + currentOffset = 0; + page2cate[0] = currentCate; + page2offset[0] = currentOffset; + if (totalNum) + { + querySet(); + subWidget->setVisible(true); + nullWidget->setVisible(false); + } + else + { + subWidget->setVisible(false); + nullWidget->setVisible(true); + } + web->setVisible(false); + +} + +void SearchWidget::returnWeb() +{ + subWidget->setVisible(true); + web->setVisible(false); + nullWidget->setVisible(false); +} + +void SearchWidget::pageUp() +{ + currentPage--; + if (currentPage < 1) + { + currentPage = 1; + QMessageBox::warning(this, "Warning", "当前页面已是第一页!"); + } + else + { + rollTop(); + querySet(); + } +} + +void SearchWidget::pageDown() +{ + currentPage++; + if (currentPage > pageNum) + { + currentPage = pageNum; + QMessageBox::warning(this, "Warning", "已经到了最后一页!"); + } + else + { + rollTop(); + querySet(); + } +} + +void SearchWidget::rollTop() +{ + QScrollBar *scrollBar = scroll->verticalScrollBar(); + scrollBar->setValue(scrollBar->minimum()); +} + diff --git a/src/ChangShaTour/searchwidget.h b/src/ChangShaTour/searchwidget.h index b3bb070..46db7e6 100755 --- a/src/ChangShaTour/searchwidget.h +++ b/src/ChangShaTour/searchwidget.h @@ -1,95 +1,96 @@ -#ifndef SEARCHWIDGET_H -#define SEARCHWIDGET_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "databaseconnector.h" -#include "webwidget.h" -#include "imgdownloader.h" - -#if _MSC_VER >= 1600 -#pragma execution_character_set("utf-8") -#endif - -namespace Ui { -class SearchWidget; -} - -class SearchWidget : public QWidget -{ - Q_OBJECT - -public: - explicit SearchWidget(QWidget *parent = nullptr); - ~SearchWidget(); - - void sendInput(QString input); - void queryDatabase(QSqlQuery query); - void getTotalNum(); - void showResult(); - QPushButton *getReturnBtn(); - QToolButton *setBtn(QToolButton *btn, const QString iconPath, const QString text); - void querySet(); - void setBtns(); - void pageUp(); - void pageDown(); - void returnWeb(); - void rollTop(); - -private: - Ui::SearchWidget *ui; - - QString segment; - - QStringList nameList; - QStringList urlList; - QStringList imgList; - QStringList textList; - int *idList; - QStringList cateIdList; - QStringList cateList; - - int totalNum; - int *lengthList; - int pageNum; - int showLimit; - int currentPage; - int currentHead; - int currentQueryLength; - int currentCate; - int currentOffset; - int *page2cate; - int *page2offset; - - - QVBoxLayout *mainLayout; - - QWidget *subWidget; - WebWidget *web; - QLabel *nullWidget; - - QVBoxLayout *subLayout; - QPushButton *rtn; - QScrollArea *scroll; - - QWidget *scrollWidget; - QVBoxLayout *scrollLayout; - - QToolButton **btnList; - - QHBoxLayout *switchLine; - QPushButton *up; - QPushButton *down; - -}; - -#endif // SEARCHWIDGET_H +#ifndef SEARCHWIDGET_H +#define SEARCHWIDGET_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "databaseconnector.h" +#include "webwidget.h" +#include "imgdownloader.h" + +#if _MSC_VER >= 1600 +#pragma execution_character_set("utf-8") +#endif + +namespace Ui { +class SearchWidget; +} + +class SearchWidget : public QWidget +{ + Q_OBJECT + +public: + explicit SearchWidget(QWidget *parent = nullptr); + ~SearchWidget(); + + void sendInput(QString input); + void queryDatabase(QSqlQuery query); + void getTotalNum(); + void showResult(); + QPushButton *getReturnBtn(); + QToolButton *setBtn(QToolButton *btn, const QString iconPath, const QString text); + void querySet(); + void setBtns(); + void pageUp(); + void pageDown(); + void returnWeb(); + void rollTop(); + +private: + Ui::SearchWidget *ui; + + QString segment; + + QStringList nameList; + QStringList urlList; + QStringList imgList; + QStringList textList; + int *idList; + QStringList cateIdList; + QStringList cateList; + + int totalNum; + int *lengthList; + int pageNum; + int showLimit; + int currentPage; + int currentHead; + int currentQueryLength; + int currentCate; + int currentOffset; + int *page2cate; + int *page2offset; + + + QVBoxLayout *mainLayout; + + QWidget *subWidget; + WebWidget *web; + QLabel *nullWidget; + + QVBoxLayout *subLayout; + QPushButton *rtn; + QScrollArea *scroll; + + QWidget *scrollWidget; + QVBoxLayout *scrollLayout; + + QToolButton **btnList; + + QHBoxLayout *switchLine; + QPushButton *up; + QPushButton *down; + +}; + +#endif // SEARCHWIDGET_H diff --git a/src/ChangShaTour/searchwidget.ui b/src/ChangShaTour/searchwidget.ui index 83afa88..b116dd1 100755 --- a/src/ChangShaTour/searchwidget.ui +++ b/src/ChangShaTour/searchwidget.ui @@ -1,21 +1,21 @@ - - - - - SearchWidget - - - - 0 - 0 - 400 - 300 - - - - Form - - - - - + + + + + SearchWidget + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + diff --git a/src/ChangShaTour/waitwidget.cpp b/src/ChangShaTour/waitwidget.cpp index 453608c..bcb08d0 100755 --- a/src/ChangShaTour/waitwidget.cpp +++ b/src/ChangShaTour/waitwidget.cpp @@ -1,38 +1,38 @@ -#include "waitwidget.h" -#include "ui_waitwidget.h" - -WaitWidget::WaitWidget(QWidget *parent) : - QWidget(parent), - ui(new Ui::WaitWidget) -{ - ui->setupUi(this); - - background = new QLabel(this); - - this->setWindowOpacity(0.8); - setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);//设置为对话框风格,并且去掉边框 - setWindowModality(Qt::WindowModal);//设置为模式对话框,同时在构造该对话框时要设置父窗口 - SetBackground("./softImages/waitGirl.gif"); -} - -WaitWidget::~WaitWidget() -{ - delete ui; -} - -void WaitWidget::SetBackground(QString url) -{ - background->setStyleSheet("background-color: transparent;"); - //新建QMovie对象并用资源文件初始化 - QMovie * mov = new QMovie(url); - //setMoive - background->setMovie(mov); - background->setScaledContents(true); - //播放动画 - mov->start(); -} - -void WaitWidget::resizeEvent(QResizeEvent *event) -{ - background->resize(this->size()); -} +#include "waitwidget.h" +#include "ui_waitwidget.h" + +WaitWidget::WaitWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::WaitWidget) +{ + ui->setupUi(this); + + background = new QLabel(this); + + this->setWindowOpacity(0.8); + setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);//设置为对话框风格,并且去掉边框 + setWindowModality(Qt::WindowModal);//设置为模式对话框,同时在构造该对话框时要设置父窗口 + SetBackground("./softImages/waitGirl.gif"); +} + +WaitWidget::~WaitWidget() +{ + delete ui; +} + +void WaitWidget::SetBackground(QString url) +{ + background->setStyleSheet("background-color: transparent;"); + //新建QMovie对象并用资源文件初始化 + QMovie * mov = new QMovie(url); + //setMoive + background->setMovie(mov); + background->setScaledContents(true); + //播放动画 + mov->start(); +} + +void WaitWidget::resizeEvent(QResizeEvent *event) +{ + background->resize(this->size()); +} diff --git a/src/ChangShaTour/waitwidget.h b/src/ChangShaTour/waitwidget.h index dcc2c84..a6c6f0e 100755 --- a/src/ChangShaTour/waitwidget.h +++ b/src/ChangShaTour/waitwidget.h @@ -1,29 +1,29 @@ -#ifndef WAITWIDGET_H -#define WAITWIDGET_H - -#include -#include -#include - -namespace Ui { -class WaitWidget; -} - -class WaitWidget : public QWidget -{ - Q_OBJECT - -public: - explicit WaitWidget(QWidget *parent = nullptr); - ~WaitWidget(); - - void SetBackground(QString); - void resizeEvent(QResizeEvent *event); - -private: - Ui::WaitWidget *ui; - - QLabel * background; -}; - -#endif // WAITWIDGET_H +#ifndef WAITWIDGET_H +#define WAITWIDGET_H + +#include +#include +#include + +namespace Ui { +class WaitWidget; +} + +class WaitWidget : public QWidget +{ + Q_OBJECT + +public: + explicit WaitWidget(QWidget *parent = nullptr); + ~WaitWidget(); + + void SetBackground(QString); + void resizeEvent(QResizeEvent *event); + +private: + Ui::WaitWidget *ui; + + QLabel * background; +}; + +#endif // WAITWIDGET_H diff --git a/src/ChangShaTour/waitwidget.ui b/src/ChangShaTour/waitwidget.ui index 9ae91d8..30e5791 100755 --- a/src/ChangShaTour/waitwidget.ui +++ b/src/ChangShaTour/waitwidget.ui @@ -1,21 +1,21 @@ - - - - - WaitWidget - - - - 0 - 0 - 400 - 300 - - - - Form - - - - - + + + + + WaitWidget + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + diff --git a/src/ChangShaTour/webwidget.cpp b/src/ChangShaTour/webwidget.cpp index f939aaa..360dd32 100755 --- a/src/ChangShaTour/webwidget.cpp +++ b/src/ChangShaTour/webwidget.cpp @@ -6,25 +6,8 @@ WebWidget::WebWidget(QWidget *parent) : ui(new Ui::WebWidget) { ui->setupUi(this); - hisLimit=10; - - verLayout = new QVBoxLayout(); - - horLayout = new QHBoxLayout(); - view = new QWebEngineView(); - QNetworkProxyFactory::setUseSystemConfiguration(false); - - add = new QPushButton("添加到收藏夹"); - rtn = new QPushButton("返回"); - - setLayout(verLayout); - - verLayout->addLayout(horLayout); - verLayout->addWidget(view); - horLayout->addWidget(add); - horLayout->addWidget(rtn); - add->setVisible(true); + InitWebWidget(); } @@ -173,3 +156,77 @@ void WebWidget::loadPage(QString name, QString img, QString url,QString cateId) view->page()->load(QUrl(url)); } + +void WebWidget::SetBackground(QString url) +{ + background->setPixmap(url); + background->setScaledContents(true); +} + +void WebWidget::InitWebWidget() +{ + background = new QLabel(this); + SetBackground("./softImages/webWidget/glueHalf.png"); + + hisLimit=10; + + verLayout = new QVBoxLayout(); + + horLayout = new QHBoxLayout(); + view = new QWebEngineView(); + QNetworkProxyFactory::setUseSystemConfiguration(false); + + add = new QPushButton("收藏"); + InitButton(add); + rtn = new QPushButton("返回"); + InitButton(rtn); + + setLayout(verLayout); + + verLayout->addLayout(horLayout); + verLayout->addWidget(view); + + horLayout->addWidget(add); + horLayout->addWidget(rtn); + add->setVisible(true); +} + +void WebWidget::InitButton(QPushButton * button) +{ + button->setStyleSheet("QPushButton {" + "color:#ffffff;" + "background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #DB261D, stop: 1 #FFC300);" + "border-style:outset;" + "border-radius:10px;" + "font:bold 20px;" + "font-family: Microsoft YaHei;" + "min-width:100px;" + "min-height:20px;" + "padding:4px;" + "} " + "QPushButton:hover {" + "background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #6E8AB2, stop: 1 #FFF2CC);" + "border-style:outset;" + "border-radius:10px;" + "font:bold 20px;" + "font-family: Microsoft YaHei;" + "min-width:100px;" + "min-height:20px;" + "padding:4px;" + "} " + "QPushButton:pressed {" + "background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #6783AB, stop: 1 #FFF2CC);" + "border-style:outset;" + "border-radius:10px;" + "font:bold 20px;" + "font-family: Microsoft YaHei;" + "min-width:100px;" + "min-height:20px;" + "padding:4px;" + "}"); +} + +void WebWidget::resizeEvent(QResizeEvent *event) +{ + background->resize(this->size()); +} diff --git a/src/ChangShaTour/webwidget.h b/src/ChangShaTour/webwidget.h index 7039652..3b939d8 100755 --- a/src/ChangShaTour/webwidget.h +++ b/src/ChangShaTour/webwidget.h @@ -11,6 +11,7 @@ #include #include #include +#include #if _MSC_VER >= 1600 #pragma execution_character_set("utf-8") @@ -35,9 +36,16 @@ public: void addToRecommend(QString cateId); void addToFavPlaces(QString name, QString img, QString url,QString cateId); + void SetBackground(QString); + void InitWebWidget(); + void InitButton(QPushButton *); + void resizeEvent(QResizeEvent *event); + private: Ui::WebWidget *ui; + QLabel * background; + QVBoxLayout *verLayout; int hisLimit;