diff --git a/src/ChangShaTour/ChangShaTour.pro.user b/src/ChangShaTour/ChangShaTour.pro.user
index 41345dd..4f9bd9d 100644
--- a/src/ChangShaTour/ChangShaTour.pro.user
+++ b/src/ChangShaTour/ChangShaTour.pro.user
@@ -1,805 +1,317 @@
-
-
-
-
-
- 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:/Study/SE/project/code/Trip-in-Chang-sha-main-4/Trip-in-Chang-sha-main/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:/Study/SE/project/code/Trip-in-Chang-sha-main-4/Trip-in-Chang-sha-main/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:/Study/SE/project/code/Trip-in-Chang-sha-main-4/Trip-in-Chang-sha-main/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:/gitRepositories/TourInChangSha/src/ChangShaTour/ChangShaTour.pro
- D:/gitRepositories/TourInChangSha/src/ChangShaTour/ChangShaTour.pro
-
- false
-
- false
- true
- true
- false
- false
- true
-
- D:/Study/SE/project/code/Trip-in-Chang-sha-main-4/Trip-in-Chang-sha-main/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:/Study/SE/project/code/Trip-in-Chang-sha-main-4/Trip-in-Chang-sha-main/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:/Study/SE/project/code/Trip-in-Chang-sha-main-4/Trip-in-Chang-sha-main/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:/Study/SE/project/code/Trip-in-Chang-sha-main-4/Trip-in-Chang-sha-main/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:/Study/SE/project/code/Trip-in-Chang-sha-main-4/Trip-in-Chang-sha-main/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:/Study/SE/project/code/Trip-in-Chang-sha-main-4/Trip-in-Chang-sha-main/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:/Study/SE/project/code/Trip-in-Chang-sha-main-4/Trip-in-Chang-sha-main/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
-
-
+
+
+
+
+
+ EnvironmentId
+ {5009ac75-b61d-4c91-8540-bc9e10b6e582}
+
+
+ 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
+
+
+ true
+
+
+
+ ProjectExplorer.Project.Target.0
+
+ Desktop Qt 5.14.2 GCC 64bit
+ Desktop Qt 5.14.2 GCC 64bit
+ qt.qt5.5142.gcc_64_kit
+ 0
+ 0
+ 0
+
+ /home/extra/Study/2021SpringTerm/Architecture/TourInChangSha/src/build-ChangShaTour-Desktop_Qt_5_14_2_GCC_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
+
+
+ /home/extra/Study/2021SpringTerm/Architecture/TourInChangSha/src/build-ChangShaTour-Desktop_Qt_5_14_2_GCC_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
+
+
+ /home/extra/Study/2021SpringTerm/Architecture/TourInChangSha/src/build-ChangShaTour-Desktop_Qt_5_14_2_GCC_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:/home/extra/Study/2021SpringTerm/Architecture/TourInChangSha/src/ChangShaTour/ChangShaTour.pro
+ /home/extra/Study/2021SpringTerm/Architecture/TourInChangSha/src/ChangShaTour/ChangShaTour.pro
+
+ false
+
+ false
+ true
+ true
+ false
+ false
+ true
+
+ /home/extra/Study/2021SpringTerm/Architecture/TourInChangSha/src/build-ChangShaTour-Desktop_Qt_5_14_2_GCC_64bit-Debug
+
+ 1
+
+
+
+ ProjectExplorer.Project.TargetCount
+ 1
+
+
+ ProjectExplorer.Project.Updater.FileVersion
+ 22
+
+
+ Version
+ 22
+
+
diff --git a/src/ChangShaTour/favoritewidget.cpp b/src/ChangShaTour/favoritewidget.cpp
index f4eab10..69eee61 100644
--- a/src/ChangShaTour/favoritewidget.cpp
+++ b/src/ChangShaTour/favoritewidget.cpp
@@ -10,12 +10,248 @@ FavoriteWidget::FavoriteWidget(QWidget *parent) :
{
ui->setupUi(this);
+ verLayout = new QVBoxLayout();
+ setLayout(verLayout);
+
+ screenWidget = new QWidget();
+ QHBoxLayout *screenLayout=new QHBoxLayout();
+ favoRoutesBtn=new QPushButton("路线收藏夹");
+
+ favoPlacesBtn=new QPushButton("场所收藏夹");
+
+ screenLayout->addWidget(favoRoutesBtn);
+ screenLayout->addWidget(favoPlacesBtn);
+ screenWidget->setLayout(screenLayout);
+
+ web = new WebWidget();
+ web->setVisible(false);
+ qDebug()<<"no error";
+ setPageMaxNumber();
+
+ //获取当前页信息
+ queryDatabase();
+ size = (size < limit? size: limit);
+
+ verLayout->addWidget(screenWidget);
+ verLayout->addWidget(web);
+ setFavPlaceScreen();
+ setFavRouteScreen();
+ setPageBtns();
+ favoRoutesWidget->setVisible(false);
+
+
+
+
+
+
+ connect(favoPlacesBtn, &QPushButton::clicked, this, &FavoriteWidget::switchToPlace);
+ connect(favoRoutesBtn, &QPushButton::clicked, this, &FavoriteWidget::switchToRoute);
+ connect(web->getReturnBtn(), &QPushButton::clicked, this, &FavoriteWidget::webReturn);
+
+}
+//从店铺收藏夹获取店铺
+void FavoriteWidget::queryDatabase()
+{
+ QSqlQuery queryUser(userDb);
+ queryUser.exec("select * from favPlaces where userId=? limit ?,?");
+ queryUser.addBindValue(Id);
+ queryUser.addBindValue(pageNumber*limit);
+ queryUser.addBindValue((pageNumber+1)*limit);
+ queryUser.exec();
+ size = 0;
+ while(queryUser.next())
+ {
+ QString url = queryUser.value("url").toString();
+ QString cateId = queryUser.value("cateId").toString();
+ queryMeituanDatabase(url, cateId);
+ urlList.append(url);
+ cateIdList.append(cateId);
+ size++;
+ }
+
+}
+
+void FavoriteWidget::webReturn()
+{
+ invisibleAllScreens();
+ screenWidget->setVisible(true);
+ favoPlacesWidget->setVisible(true);
+
+}
+void FavoriteWidget::switchToPlace()
+{
+ invisibleAllScreens();
+ screenWidget->setVisible(true);
+ favoPlacesWidget->setVisible(true);
+
+}
+void FavoriteWidget::switchToRoute()
+{
+ invisibleAllScreens();
+ screenWidget->setVisible(true);
+ favoRoutesWidget->setVisible(true);
+
+}
+//从美团数据库获取详情页,暂只获取名字和图片链接
+void FavoriteWidget::queryMeituanDatabase(QString url,QString cateId)
+{
+ QSqlQuery queryMeituan(meituanDb);
+ queryMeituan.prepare("select * from " + labelToDb[cateId] + " where detail = ?");
+ queryMeituan.addBindValue(url);
+ queryMeituan.exec();
+ queryMeituan.next();
+ QString title = queryMeituan.value("title").toString();
+ QString img = queryMeituan.value("frontimg").toString();
+ titleList.append(title);//获取名字
+ imgList.append(img);//获取图片链接
+}
+//设置场所收藏夹界面
+void FavoriteWidget::setFavPlaceScreen()
+{
+ favoPlacesWidget = new QWidget();
+ favoPlacesLayout=new QVBoxLayout();
+ scroll = new QScrollArea();
+ placesWidget = new QWidget();
+ placesLayout = new QVBoxLayout();
+ favoPlacesLayout->addWidget(scroll);
+ btnList = (QToolButton **)malloc(sizeof(QToolButton *) * size);
+ for (int i = 0; i < size; i++)
+ btnList[i] = new QToolButton();
+ setBtns();
+ for (int i = 0; i < size; i++)
+ placesLayout->addWidget(btnList[i]);
+ placesWidget->setLayout(placesLayout);
+ scroll->setWidget(placesWidget);
+ pageWidget = new QWidget();
+ pageLayout = new QHBoxLayout();
+ nextPageBtn = new QPushButton("下一页");
+ backPageBtn = new QPushButton("上一页");
+ pageLayout->addWidget(backPageBtn);
+ pageLayout->addWidget(nextPageBtn);
+ pageWidget->setLayout(pageLayout);
+
+ favoPlacesLayout->addWidget(pageWidget);
+ favoPlacesWidget->setLayout(favoPlacesLayout);
+ verLayout->addWidget(favoPlacesWidget);
+ setPageBtns();
+
+ connect(nextPageBtn, &QPushButton::clicked, this, &FavoriteWidget::nextPage);
+ connect(backPageBtn, &QPushButton::clicked, this, &FavoriteWidget::backPage);
+}
+void FavoriteWidget::nextPage()
+{
+ cateIdList.clear();
+ urlList.clear();
+ imgList.clear();
+ titleList.clear();
+ deleteWidgetsInLayout();
+ pageNumber++;
+ queryDatabase();
+ size = (size < limit? size: limit);
+ setFavPlaceScreen();
+
+}
+
+void FavoriteWidget::backPage()
+{
+ cateIdList.clear();
+ urlList.clear();
+ imgList.clear();
+ titleList.clear();
+ deleteWidgetsInLayout();
+ pageNumber--;
+ queryDatabase();
+ size = (size < limit? size: limit);
+ setFavPlaceScreen();
+}
+//设置路线收藏夹界面
+void FavoriteWidget::setFavRouteScreen()
+{
+
+ favoRoutesWidget = new QWidget();
QVBoxLayout *layout = new QVBoxLayout();
- setLayout(layout);
+ favoRoutesWidget->setLayout(layout);
layout->addWidget(new QLabel("FavoriteWidget"));
+ verLayout->addWidget(favoRoutesWidget);
+
+}
+
+QToolButton * FavoriteWidget::setBtn(QToolButton *btn, const QString text)
+{
+ btn->setText(text);
+ btn->setToolButtonStyle(Qt::ToolButtonTextOnly);
+
+ return btn;
}
+//初始化所有按钮
+void FavoriteWidget::setBtns()
+{
+ for (int i = 0; i < size; i++)
+ {
+ int index = i;
+ btnList[index] = setBtn(btnList[index], titleList[index]);
+ //btnList[index]->setText(titleList[index]);
+ //btnList[index]->setToolButtonStyle(Qt::ToolButtonTextOnly);
+ connect(btnList[index], &QToolButton::clicked, this, [=](){web->loadPage((const QString)urlList[index],cateIdList[index]); invisibleAllScreens(); web->setVisible(true);});
+ }
+}
+
+void FavoriteWidget::setPageBtns()
+{
+ if ( pageNumber == 0 )
+ backPageBtn->setVisible(false);
+ else
+ backPageBtn->setVisible(true);
+ if ( pageNumber + 1 == pageMaxNumber )
+ nextPageBtn->setVisible(false);
+ else
+ nextPageBtn->setVisible(true);
+}
+
+void FavoriteWidget::setPageMaxNumber()
+{
+ QSqlQuery query(userDb);
+ //读取数据库,获取按钮信息,初始化各List
+
+ query.exec("select count(*) from favPlaces where userId = ?");
+ query.addBindValue(Id);
+ query.exec();
+ query.next();
+ pageMaxNumber = query.value(0).toInt() / limit + 1;
+ pageNumber = 0;
+}
+
+void FavoriteWidget::deleteWidgetsInLayout()
+{
+ //scroll->takeWidget();
+ favoPlacesWidget->deleteLater();
+ //favoPlacesLayout->deleteLater();
+ //placesWidget->deleteLater();
+ //nextPageBtn->deleteLater();
+ //backPageBtn->deleteLater();
+ //pageLayout->deleteLater();
+ //pageWidget->deleteLater();
+ //placesLayout->deleteLater();
+
+ //QLayoutItem * child;
+ //while ((child = placesLayout->takeAt(0)) != 0)
+ //{
+ // placesLayout->removeWidget(child->widget());
+ // child->widget()->setParent(0);
+ // delete child;
+ //}
+}
+//将所有除web界面全都隐藏
+void FavoriteWidget::invisibleAllScreens()
+{
+ web->setVisible(false);
+ favoPlacesWidget->setVisible(false);
+ favoRoutesWidget->setVisible(false);
+ screenWidget->setVisible(false);
+
+}
FavoriteWidget::~FavoriteWidget()
{
delete ui;
diff --git a/src/ChangShaTour/favoritewidget.h b/src/ChangShaTour/favoritewidget.h
index cea83bb..6abfc64 100644
--- a/src/ChangShaTour/favoritewidget.h
+++ b/src/ChangShaTour/favoritewidget.h
@@ -2,6 +2,13 @@
#define FAVORITEWIDGET_H
#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
#if _MSC_VER >= 1600
#pragma execution_character_set("utf-8")
@@ -17,10 +24,55 @@ class FavoriteWidget : public QWidget
public:
explicit FavoriteWidget(QWidget *parent = nullptr);
+ void queryDatabase();
+ void queryMeituanDatabase(QString url, QString cateId);
+ void setFavPlaceScreen();
+ void setFavRouteScreen();
+ QToolButton * setBtn(QToolButton *btn, const QString text);
+ void webReturn();
+ void initScreen();
+ void setBtns();
+ void switchToPlace();
+ void switchToRoute();
+ void setPageBtns();
+ void setPageMaxNumber();
+ void invisibleAllScreens();
+ void deleteWidgetsInLayout();
~FavoriteWidget();
private:
+ int limit=30;//每一页店铺的数量
+ int size;//实际每页的数量
+ int pageNumber;
+ int pageMaxNumber;
+
+ QStringList urlList;
+ QStringList imgList;
+ QStringList titleList;
+ QStringList cateIdList;
+
+ WebWidget * web;
+ QWidget * pageWidget;
+ QWidget * placesWidget;
+ QVBoxLayout * placesLayout;
+ QPushButton * nextPageBtn;
+ QPushButton * backPageBtn;
+ QHBoxLayout * pageLayout;
+ QWidget * screenWidget;
+ QScrollArea *scroll;
+ QVBoxLayout * verLayout;
+ QVBoxLayout * favoPlacesLayout;
+ QSignalMapper *signalMapper;
+ QToolButton ** btnList;
+ QWidget *favoRoutesWidget;
+ QWidget *favoPlacesWidget;
+ QPushButton *favoRoutesBtn;
+ QPushButton *favoPlacesBtn;
Ui::FavoriteWidget *ui;
+
+public slots:
+ void nextPage();
+ void backPage();
};
#endif // FAVORITEWIDGET_H
diff --git a/src/ChangShaTour/loginwidget.cpp b/src/ChangShaTour/loginwidget.cpp
index 3fc15da..f15872f 100644
--- a/src/ChangShaTour/loginwidget.cpp
+++ b/src/ChangShaTour/loginwidget.cpp
@@ -8,32 +8,135 @@ LoginWidget::LoginWidget(QWidget *parent) :
{
ui->setupUi(this);
- QVBoxLayout * verticalLayout = new QVBoxLayout();
- QHBoxLayout * accountHorizontalLayout = new QHBoxLayout();
- QHBoxLayout * passwordHorizontalLayout = new QHBoxLayout();
- QHBoxLayout * buttonHorizontalLayout = new QHBoxLayout();
+ verLayout = new QVBoxLayout();
+ background = new QLabel(this);
+ subWidget = new QWidget();
- QLabel * accountLabel = new QLabel("账号");
- accountLine = new QLineEdit();
- accountHorizontalLayout->addWidget(accountLabel);
- accountHorizontalLayout->addWidget(accountLine);
+ InitLoginWidget();
+}
+
+void LoginWidget::SetBackground(QString url)
+{
+ background->setPixmap(url);
+ background->setScaledContents(true);
+}
+
+void LoginWidget::InitLoginWidget()
+{
+ SetBackground("./softImages/LoginImage.jpg");
+ InitSubWidget();
+
+ verLayout->addStretch();
+ verLayout->addWidget(subWidget);
+ setLayout(verLayout);
+}
+
+void LoginWidget::SetSubWidgetBackground(QString url)
+{
+ subBackGround->setPixmap(url);
+ subBackGround->setScaledContents(true);
+}
+
+void LoginWidget::InitSubWidget()
+{
+ QGridLayout * gridLayout = new QGridLayout();
+ subWidget->setLayout(gridLayout);
+
+ subBackGround = new QLabel(subWidget);
+ SetSubWidgetBackground("./softImages/blackHalf.png");
- QLabel * passwordLabel = new QLabel("密码");
+ gridLayout->setContentsMargins(150, 10, 150, 10);
+
+ QLabel * accountLabel = new QLabel("账户: ");
+ QLabel * passwordLabel = new QLabel("密码: ");
+ InitLabel(accountLabel);
+ InitLabel(passwordLabel);
+ gridLayout->addWidget(accountLabel, 0, 0, 1, 1);
+ gridLayout->addWidget(passwordLabel, 1, 0, 1, 1);
+
+ accountLine = new QLineEdit();
passwordLine = new QLineEdit();
+ InitLineEdit(accountLine);
+ InitLineEdit(passwordLine);
passwordLine->setEchoMode(QLineEdit::Password);
- passwordHorizontalLayout->addWidget(passwordLabel);
- passwordHorizontalLayout->addWidget(passwordLine);
+ gridLayout->addWidget(accountLine, 0, 1, 1, 1);
+ gridLayout->addWidget(passwordLine, 1, 1, 1, 1);
- loginButton = new QPushButton("登陆");
registerButton = new QPushButton("注册");
- buttonHorizontalLayout->addWidget(loginButton);
- buttonHorizontalLayout->addWidget(registerButton);
+ loginButton = new QPushButton("登陆");
+ gridLayout->addWidget(registerButton, 0, 3, 1, 1);
+ gridLayout->addWidget(loginButton, 1, 3, 1, 1);
+ InitButton(registerButton);
+ InitButton(loginButton);
+}
- verticalLayout->addLayout(accountHorizontalLayout);
- verticalLayout->addLayout(passwordHorizontalLayout);
- verticalLayout->addLayout(buttonHorizontalLayout);
+void LoginWidget::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);
+}
- this->setLayout(verticalLayout);
+void LoginWidget::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 LoginWidget::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 LoginWidget::resizeEvent(QResizeEvent *event)
+{
+ background->resize(this->size());
+ subBackGround->resize(subWidget->size());
}
QPushButton * LoginWidget::getLoginButton()
diff --git a/src/ChangShaTour/loginwidget.h b/src/ChangShaTour/loginwidget.h
index 7f42464..2be0e79 100644
--- a/src/ChangShaTour/loginwidget.h
+++ b/src/ChangShaTour/loginwidget.h
@@ -24,6 +24,15 @@ public:
explicit LoginWidget(QWidget *parent = nullptr);
~LoginWidget();
+ void SetBackground(QString);
+ void InitLoginWidget();
+ void SetSubWidgetBackground(QString);
+ void InitSubWidget();
+ void InitLabel(QLabel *);
+ void InitButton(QPushButton *);
+ void InitLineEdit(QLineEdit *);
+ void resizeEvent(QResizeEvent *event);
+
QPushButton * getLoginButton();
QString getAccount();
QString getPassword();
@@ -32,6 +41,13 @@ public:
private:
Ui::LoginWidget *ui;
+ QLabel * background;
+ QLabel * subBackGround;
+
+ QVBoxLayout * verLayout;
+
+ QWidget * subWidget;
+
QLineEdit * accountLine;
QLineEdit * passwordLine;
QPushButton * loginButton;
diff --git a/src/ChangShaTour/mainwindow.cpp b/src/ChangShaTour/mainwindow.cpp
index 783091a..39cd93a 100644
--- a/src/ChangShaTour/mainwindow.cpp
+++ b/src/ChangShaTour/mainwindow.cpp
@@ -7,10 +7,12 @@ MainWindow::MainWindow(QWidget *parent)
{
ui->setupUi(this);
- resize(400,300);
+ resize(800,450);
+ setWindowFlags(windowFlags()&~Qt::WindowMaximizeButtonHint); // 禁止最大化按钮
+ //setFixedSize(this->width(),this->height()); // 禁止拖动窗口大小
loginWidget = new LoginWidget();
- setWindowTitle("登录");
+ setWindowTitle("长沙游");
this->setCentralWidget(loginWidget);
connect(loginWidget->getLoginButton(), &QPushButton::clicked, this, &MainWindow::switchToMain);
connect(loginWidget->getRegisterButton(), &QPushButton::clicked, this, &MainWindow::switchToRegister);
@@ -33,13 +35,11 @@ void MainWindow::switchToMain()
}
else if(loginmanage->loginVerify(accountLogin,passwordLogin))
{
-
- resize(1330, 1000);
- setMaximumSize(QSize(1330,1000));
+ //setMaximumSize(QSize(1330,1000));
// showMaximized();
loginWidget->deleteLater();
mainWidget = new MainWidget();
- setWindowTitle("长沙游");
+ resize(1600, 900);
setCentralWidget(mainWidget);
}
else
@@ -55,7 +55,6 @@ void MainWindow::switchToRegister()
connect(registerWidget->getConfirmButton(), &QPushButton::clicked, this, &MainWindow::registerConfirmSwitch);
connect(registerWidget->getCancelButton(), &QPushButton::clicked, this, &MainWindow::switchToLogin);
connect(registerWidget->getGetVerificationCodeButton(), &QPushButton::clicked, this, &MainWindow::clickGetVerificationCodeButton);
- setWindowTitle("注册");
setCentralWidget(registerWidget);
}
@@ -89,7 +88,6 @@ void MainWindow::switchToLogin()
loginWidget = new LoginWidget();
connect(loginWidget->getLoginButton(), &QPushButton::clicked, this, &MainWindow::switchToMain);
connect(loginWidget->getRegisterButton(), &QPushButton::clicked, this, &MainWindow::switchToRegister);
- setWindowTitle("登陆");
setCentralWidget(loginWidget);
}
diff --git a/src/ChangShaTour/recommendwidget.cpp b/src/ChangShaTour/recommendwidget.cpp
index 0446fbf..0623c95 100644
--- a/src/ChangShaTour/recommendwidget.cpp
+++ b/src/ChangShaTour/recommendwidget.cpp
@@ -152,7 +152,7 @@ void RecommendWidget::setBtns()
int index = i * column + j;
//下载图片到本地
// QString imgPath = ":/images" + idList[index] + ".jpg";
- QString imgPath = "D:/kunlin/OneDrive/QT project/images/"+labelToDb[cateIdList[index]] + QString::number(idList[index]) + ".png";
+ QString imgPath = "C:/Users/13648/Desktop/Trip-in-Chang-sha/ChangShaTour/images/"+labelToDb[cateIdList[index]] + QString::number(idList[index]) + ".png";
// qDebug() << QDir::currentPath();
// QString imgPath = "D:/Study/SE/project/images/" + labelToDb[cateIdList[index]] + QString::number(idList[index]) + ".png";
imgDownloader *download = new imgDownloader();
@@ -205,6 +205,7 @@ void RecommendWidget::webReturn()
scroll->setVisible(true);
web->setVisible(false);
refreshBtn->setVisible(true);
+ disconnect(web->getAddBtn(), 0, 0, 0);
}
void RecommendWidget::refresh()
diff --git a/src/ChangShaTour/registerwidget.cpp b/src/ChangShaTour/registerwidget.cpp
index 306f0ef..1799c55 100644
--- a/src/ChangShaTour/registerwidget.cpp
+++ b/src/ChangShaTour/registerwidget.cpp
@@ -1,5 +1,6 @@
#include "registerwidget.h"
#include "ui_registerwidget.h"
+#include
RegisterWidget::RegisterWidget(QWidget *parent) :
QWidget(parent),
@@ -7,52 +8,11 @@ RegisterWidget::RegisterWidget(QWidget *parent) :
{
ui->setupUi(this);
- vertiacalLayout = new QVBoxLayout();
- emailAddressHorizontalLayout = new QHBoxLayout();
- passwordHorizontalLayout = new QHBoxLayout();
- confirmPasswordHorizontalLayout = new QHBoxLayout();
- verificationCodeHorizontalLayout = new QHBoxLayout();
- optionHorizontalLayout = new QHBoxLayout();
-
- emailAddressLabel = new QLabel("邮箱地址");
- emailAddressLineEdit = new QLineEdit();
- emailAddressLineEdit->setPlaceholderText("请输入qq邮箱地址或163邮箱地址");
- emailAddressHorizontalLayout->addWidget(emailAddressLabel);
- emailAddressHorizontalLayout->addWidget(emailAddressLineEdit);
-
- passwordLabel = new QLabel("密码");
- passwordLineEdit = new QLineEdit();
- passwordLineEdit->setPlaceholderText("请输入长度为6~12位的密码");
- passwordLineEdit->setEchoMode(QLineEdit::Password);
- passwordHorizontalLayout->addWidget(passwordLabel);
- passwordHorizontalLayout->addWidget(passwordLineEdit);
-
- confirmPasswordLabel = new QLabel("确认密码");
- confirmPasswordLineEdit = new QLineEdit();
- confirmPasswordLineEdit->setEchoMode(QLineEdit::Password);
- confirmPasswordHorizontalLayout->addWidget(confirmPasswordLabel);
- confirmPasswordHorizontalLayout->addWidget(confirmPasswordLineEdit);
-
- verificationCodeLabel = new QLabel("验证码");
- verificationCodeLineEdit = new QLineEdit();
- getVerificationCodeButon = new QPushButton("点击获取验证码");
- verificationCodeHorizontalLayout->addWidget(verificationCodeLabel);
- verificationCodeHorizontalLayout->addWidget(verificationCodeLineEdit);
- verificationCodeHorizontalLayout->addWidget(getVerificationCodeButon);
-
- confirmButton = new QPushButton("确认");
- cancelButton = new QPushButton("取消");
- optionHorizontalLayout->addWidget(confirmButton);
- optionHorizontalLayout->addWidget(cancelButton);
-
- vertiacalLayout->addLayout(emailAddressHorizontalLayout);
- vertiacalLayout->addLayout(passwordHorizontalLayout);
- vertiacalLayout->addLayout(confirmPasswordHorizontalLayout);
- vertiacalLayout->addLayout(verificationCodeHorizontalLayout);
- vertiacalLayout->addLayout(optionHorizontalLayout);
-
- this->setLayout(vertiacalLayout);
+ background = new QLabel(this);
+ subWidget = new QWidget(this);
+ qDebug() << QDir::currentPath();
+ InitRegisterWidget();
}
QPushButton * RegisterWidget::getGetVerificationCodeButton()
@@ -99,3 +59,145 @@ 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 3f83c06..7fcadee 100644
--- a/src/ChangShaTour/registerwidget.h
+++ b/src/ChangShaTour/registerwidget.h
@@ -25,6 +25,15 @@ 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();
@@ -40,17 +49,10 @@ public:
private:
Ui::RegisterWidget *ui;
- QVBoxLayout * vertiacalLayout;
- QHBoxLayout * emailAddressHorizontalLayout;
- QHBoxLayout * passwordHorizontalLayout;
- QHBoxLayout * confirmPasswordHorizontalLayout;
- QHBoxLayout * optionHorizontalLayout;
- QHBoxLayout * verificationCodeHorizontalLayout;
-
- QLabel * emailAddressLabel;
- QLabel * passwordLabel;
- QLabel * confirmPasswordLabel;
- QLabel * verificationCodeLabel;
+ QLabel * background;
+ QLabel * subBackGround;
+
+ QWidget * subWidget;
QLineEdit * emailAddressLineEdit;
QLineEdit * passwordLineEdit;
diff --git a/src/ChangShaTour/smtp.cpp b/src/ChangShaTour/smtp.cpp
index 8d789b1..bdb6a9d 100644
--- a/src/ChangShaTour/smtp.cpp
+++ b/src/ChangShaTour/smtp.cpp
@@ -1,75 +1,75 @@
-#include "smtp.h"
-#include
-Smtp::Smtp(QByteArray senderAddress,QByteArray senderPassword)
-{
- this->senderAddress = senderAddress;
- this->senderPassword = senderPassword;
-}
-
-void Smtp::send(QByteArray reciverAddress,QString subject,QString content)
-{
- QByteArray reciveData;
- QByteArray senderAddress = this->senderAddress;
- QByteArray senderPassword = this->senderPassword;
-
- QTcpSocket * clientSocket = new QTcpSocket();
- clientSocket->connectToHost("smtp.163.com", 25, QTcpSocket::ReadWrite);
- clientSocket->waitForConnected(1000);
- clientSocket->waitForReadyRead(1000);
- reciveData = clientSocket->readAll();
- qDebug() << reciveData;
-
- clientSocket->write("HELO smtp.163.com\r\n");
- clientSocket->waitForReadyRead(1000);
- reciveData = clientSocket->readAll();
- qDebug() << reciveData;
-
- clientSocket->write("AUTH LOGIN\r\n");
- clientSocket->waitForReadyRead(1000);
- reciveData = clientSocket->readAll();
- qDebug() << reciveData;
-
- qDebug() << "senderAddress:"<< senderAddress;
- clientSocket->write(senderAddress.toBase64().append("\r\n"));
- clientSocket->waitForReadyRead(1000);
- reciveData = clientSocket->readAll();
- qDebug() << reciveData;
-
- qDebug() << "password:" << senderPassword;
- clientSocket->write(senderPassword.toBase64().append("\r\n"));
- clientSocket->waitForReadyRead(1000);
- reciveData = clientSocket->readAll();
- qDebug() << reciveData;
-
- clientSocket->write("mail from:<" + senderAddress + ">\r\n");
- clientSocket->waitForReadyRead(1000);
- reciveData = clientSocket->readAll();
- qDebug() << reciveData;
-
- clientSocket->write("rcpt to:<" + reciverAddress + ">\r\n");
- clientSocket->waitForReadyRead(1000);
- reciveData = clientSocket->readAll();
- qDebug() << reciveData;
-
- clientSocket->write("data\r\n");
- clientSocket->waitForReadyRead(1000);
- reciveData = clientSocket->readAll();
- qDebug() << reciveData;
-
- clientSocket->write("from:" + senderAddress + "\r\n");
- clientSocket->write("to:" + reciverAddress + "\r\n");
- clientSocket->write("subject:" + subject.toLocal8Bit() + "\r\n");
- clientSocket->write("\r\n");
- clientSocket->write(content.toLocal8Bit() + "\r\n");
- clientSocket->write(".\r\n");
- clientSocket->waitForReadyRead(1000);
- reciveData = clientSocket->readAll();
- qDebug() << reciveData;
-
- clientSocket->write("quit\r\n");
- clientSocket->waitForReadyRead(1000);
- reciveData = clientSocket->readAll();
- qDebug() << reciveData;
-
- delete clientSocket;
-}
+#include "smtp.h"
+#include
+Smtp::Smtp(QByteArray senderAddress,QByteArray senderPassword)
+{
+ this->senderAddress = senderAddress;
+ this->senderPassword = senderPassword;
+}
+
+void Smtp::send(QByteArray reciverAddress,QString subject,QString content)
+{
+ QByteArray reciveData;
+ QByteArray senderAddress = this->senderAddress;
+ QByteArray senderPassword = this->senderPassword;
+
+ QTcpSocket * clientSocket = new QTcpSocket();
+ clientSocket->connectToHost("smtp.163.com", 25, QTcpSocket::ReadWrite);
+ clientSocket->waitForConnected(1000);
+ clientSocket->waitForReadyRead(1000);
+ reciveData = clientSocket->readAll();
+ qDebug() << reciveData;
+
+ clientSocket->write("HELO smtp.163.com\r\n");
+ clientSocket->waitForReadyRead(1000);
+ reciveData = clientSocket->readAll();
+ qDebug() << reciveData;
+
+ clientSocket->write("AUTH LOGIN\r\n");
+ clientSocket->waitForReadyRead(1000);
+ reciveData = clientSocket->readAll();
+ qDebug() << reciveData;
+
+ qDebug() << "senderAddress:"<< senderAddress;
+ clientSocket->write(senderAddress.toBase64().append("\r\n"));
+ clientSocket->waitForReadyRead(1000);
+ reciveData = clientSocket->readAll();
+ qDebug() << reciveData;
+
+ qDebug() << "password:" << senderPassword;
+ clientSocket->write(senderPassword.toBase64().append("\r\n"));
+ clientSocket->waitForReadyRead(1000);
+ reciveData = clientSocket->readAll();
+ qDebug() << reciveData;
+
+ clientSocket->write("mail from:<" + senderAddress + ">\r\n");
+ clientSocket->waitForReadyRead(1000);
+ reciveData = clientSocket->readAll();
+ qDebug() << reciveData;
+
+ clientSocket->write("rcpt to:<" + reciverAddress + ">\r\n");
+ clientSocket->waitForReadyRead(1000);
+ reciveData = clientSocket->readAll();
+ qDebug() << reciveData;
+
+ clientSocket->write("data\r\n");
+ clientSocket->waitForReadyRead(1000);
+ reciveData = clientSocket->readAll();
+ qDebug() << reciveData;
+
+ clientSocket->write("from:" + senderAddress + "\r\n");
+ clientSocket->write("to:" + reciverAddress + "\r\n");
+ clientSocket->write("subject:" + subject.toLocal8Bit() + "\r\n");
+ clientSocket->write("\r\n");
+ clientSocket->write(content.toLocal8Bit() + "\r\n");
+ clientSocket->write(".\r\n");
+ clientSocket->waitForReadyRead(1000);
+ reciveData = clientSocket->readAll();
+ qDebug() << reciveData;
+
+ clientSocket->write("quit\r\n");
+ clientSocket->waitForReadyRead(1000);
+ reciveData = clientSocket->readAll();
+ qDebug() << reciveData;
+
+ delete clientSocket;
+}
diff --git a/src/ChangShaTour/smtp.h b/src/ChangShaTour/smtp.h
index 592b679..5562224 100644
--- a/src/ChangShaTour/smtp.h
+++ b/src/ChangShaTour/smtp.h
@@ -1,24 +1,24 @@
-#ifndef SMTH_H
-#define SMTH_H
-
-#include
-#include
-#include
-
-#if _MSC_VER >= 1600
-#pragma execution_character_set("utf-8")
-#endif
-
-class Smtp
-{
-public:
- Smtp(QByteArray senderAddress, QByteArray senderPassword);
-
- void send(QByteArray reciverAddress, QString subject, QString content);
-
-private:
- QTcpSocket * clientSocket;
- QByteArray senderAddress;
- QByteArray senderPassword;
-};
-#endif // SMTH_H
+#ifndef SMTH_H
+#define SMTH_H
+
+#include
+#include
+#include
+
+#if _MSC_VER >= 1600
+#pragma execution_character_set("utf-8")
+#endif
+
+class Smtp
+{
+public:
+ Smtp(QByteArray senderAddress, QByteArray senderPassword);
+
+ void send(QByteArray reciverAddress, QString subject, QString content);
+
+private:
+ QTcpSocket * clientSocket;
+ QByteArray senderAddress;
+ QByteArray senderPassword;
+};
+#endif // SMTH_H
diff --git a/src/ChangShaTour/sortwidget.cpp b/src/ChangShaTour/sortwidget.cpp
index e2291a5..6d36c02 100644
--- a/src/ChangShaTour/sortwidget.cpp
+++ b/src/ChangShaTour/sortwidget.cpp
@@ -140,7 +140,6 @@ void SortWidget::setScreenBtns()
QString str = "美食 酒店 休闲娱乐/KTV 运动健身/健身中心 景点";
QStringList strList = str.split(" ");
QHBoxLayout * funcLine = new QHBoxLayout();
- int nColCnt = 0;
foreach(QString itor, strList)
{
QPushButton *pBtn = new QPushButton(this);
@@ -262,7 +261,7 @@ void SortWidget::Screen(QString str)
queryDatabase(query, "select * from " + screenCode + " limit " + QString::number(row));
else
queryDatabase(query, "select * from " + screenCode + " where cateId=\"" + str + "\" limit " + QString::number(row));
- size = fmin(size, row);
+ size = size < row? size: row;
scroll->takeWidget();
subWidget->deleteLater();
@@ -321,7 +320,7 @@ void SortWidget::nextPage()
queryDatabase(query, "select * from " + screenCode + " limit " + QString::number(row * (pageNumber + 1)) + "," + QString::number(row));
else
queryDatabase(query, "select * from " + screenCode + " where cateId=\"" + screenStr + "\" limit " + QString::number(row * (pageNumber + 1)) + "," + QString::number(row));
- size = fmin(size, row);
+ size = size < row? size: row;
scroll->takeWidget();
subWidget->deleteLater();
@@ -355,7 +354,7 @@ void SortWidget::backPage()
queryDatabase(query, "select * from " + screenCode + " limit " + QString::number(row * (pageNumber - 1)) + "," + QString::number(row));
else
queryDatabase(query, "select * from " + screenCode + " where cateId=\"" + screenStr + "\" limit " + QString::number(row * (pageNumber - 1)) + "," + QString::number(row));
- size = fmin(size, row);
+ size = size < row? size: row;
scroll->takeWidget();
subWidget->deleteLater();
diff --git a/src/ChangShaTour/webwidget.cpp b/src/ChangShaTour/webwidget.cpp
index 08459f1..a21ed15 100644
--- a/src/ChangShaTour/webwidget.cpp
+++ b/src/ChangShaTour/webwidget.cpp
@@ -13,7 +13,7 @@ WebWidget::WebWidget(QWidget *parent) :
horLayout = new QHBoxLayout();
view = new QWebEngineView();
- add = new QPushButton("添加");
+ add = new QPushButton("添加到收藏夹");
rtn = new QPushButton("返回");
setLayout(verLayout);
@@ -23,7 +23,7 @@ WebWidget::WebWidget(QWidget *parent) :
horLayout->addWidget(add);
horLayout->addWidget(rtn);
- add->setVisible(false);
+ add->setVisible(true);
}
@@ -65,8 +65,9 @@ void WebWidget::addToHis(QString url,QString cateId)
query.exec();
query.next();
int historyId=query.value("historyId").toInt();
- query.prepare("update history set url = ?, createdtime = now() where historyId=?");
+ query.prepare("update history set url = ?, cateId = ?, createdtime = now() where historyId=?");
query.addBindValue(url);
+ query.addBindValue(cateId);
query.addBindValue(historyId);
query.exec();
}
@@ -127,6 +128,27 @@ void WebWidget::addToRecommend(QString cateId)
query.exec();
}
+void WebWidget::addToFavPlaces()
+{
+ QSqlQuery query(userDb);
+ query.prepare("select * from favPlaces where userId = ? and url = ?");
+ query.addBindValue(Id);
+ query.addBindValue(this->url);
+ query.exec();
+ if(query.next())
+ {
+ QMessageBox::warning(this,"警告","该场所已在收藏夹中,请不要重复添加!", QMessageBox::Yes);
+ return;
+ }
+ query.prepare("insert into favPlaces (userId, url, cateId)values(?, ?, ?)");
+ query.addBindValue(Id);
+ query.addBindValue(this->url);
+ query.addBindValue(this->cateId);
+ query.exec();
+ QMessageBox::information(this,"提示","添加成功!");
+ return;
+}
+
QPushButton *WebWidget::getReturnBtn()
{
return rtn;
@@ -134,9 +156,14 @@ QPushButton *WebWidget::getReturnBtn()
void WebWidget::loadPage(QString url,QString cateId)
{
+ this->url = url;
+ this->cateId = cateId;
+
addToHis(url,cateId);
addToHot(url,cateId);
addToRecommend(cateId);
+ connect(add, &QPushButton::clicked, this, &WebWidget::addToFavPlaces);
+
view->load(QUrl(url));
}
diff --git a/src/ChangShaTour/webwidget.h b/src/ChangShaTour/webwidget.h
index f3e0d19..8b035db 100644
--- a/src/ChangShaTour/webwidget.h
+++ b/src/ChangShaTour/webwidget.h
@@ -9,6 +9,7 @@
#include
#include
#include
+#include
#if _MSC_VER >= 1600
#pragma execution_character_set("utf-8")
@@ -31,6 +32,7 @@ public:
void addToHis(QString url,QString cateId);
void addToHot(QString url,QString cateId);
void addToRecommend(QString cateId);
+ void addToFavPlaces();
private:
Ui::WebWidget *ui;
@@ -44,6 +46,9 @@ private:
QWebEngineView *view;
+ QString url;
+ QString cateId;
+
};
#endif // WEBWIDGET_H
diff --git a/src/RefreshList/favorablelist.py b/src/RefreshList/favorablelist.py
new file mode 100644
index 0000000..1ec2b95
--- /dev/null
+++ b/src/RefreshList/favorablelist.py
@@ -0,0 +1,76 @@
+import pymysql
+
+# 打开数据库连接
+meituanDb = pymysql.connect("121.36.100.63","mkl","010512", "meituan" )
+
+# 使用 cursor() 方法创建一个游标对象 cursor
+cursor = meituanDb.cursor()
+
+lists = [ "attractions", "entertainment", "food", "hotel", "sport" ]
+
+try:
+ results = []
+ for string in lists:
+ # 执行SQL语句
+ cursor.execute("SELECT * FROM %s"%string)
+ # 获取所有记录列表
+ results.append(cursor.fetchall())
+ print (string + " loading over")
+ meituanDb.close()
+
+ listDb = pymysql.connect("121.36.100.63","mkl","010512", "list" )
+ cursor = listDb.cursor()
+ cursor.execute("DELETE FROM favorablelist")
+ listDb.commit()
+ items = []
+ maxSize = 10
+ n = 0
+
+ k = 0
+ while ( k < 5 ):
+ for row in results[k]:
+ if ( k == 0 ):
+ item = [ row[0], row[1], row[8], row[4], row[5], row[2] ]
+ elif ( k == 1 ):
+ item = [ row[0], row[1], row[9], row[4], row[6], row[2] ]
+ elif ( k == 2 ):
+ item = [ row[0], row[1], row[8], row[4], row[5], row[2] ]
+ elif ( k == 3 ):
+ item = [ row[0], row[1], row[8], row[3], row[5], row[2] ]
+ elif ( k == 4 ):
+ item = [ row[0], row[1], row[9], row[4], row[6], row[2] ]
+ i = 0
+ isIn = False
+ while ( i < n ):
+ if ( items[i][5] == item[5] ):
+ isIn = True
+ i += 1
+ if (isIn):
+ continue
+ if ( n < maxSize ):
+ items.append(item)
+ n += 1
+ else:
+ i = 0
+ while ( i < n ):
+ if ( float(item[3]) * float(item[4]) > float(items[i][3]) * float(items[i][4]) ):
+ items[i] = item
+ break
+ i += 1
+ k += 1
+ print ("add over")
+
+ cursor = listDb.cursor()
+ i = 0
+ while (i < n):
+ listSql = """INSERT INTO favorablelist(id,
+ url, cateId, score, title) """
+ cursor.execute(listSql + "VALUES(%d, '%s', '%s', %f, '%s')"%(items[i][0], items[i][1], items[i][2], float(items[i][3]) * float(items[i][4]), items[i][5]))
+ listDb.commit()
+ i += 1
+ print ("insert over")
+
+except:
+ listDb.rollback()
+
+listDb.close()
diff --git a/src/RefreshList/minoritylist.py b/src/RefreshList/minoritylist.py
new file mode 100644
index 0000000..ff0e175
--- /dev/null
+++ b/src/RefreshList/minoritylist.py
@@ -0,0 +1,76 @@
+import pymysql
+
+# 打开数据库连接
+meituanDb = pymysql.connect("121.36.100.63","mkl","010512", "meituan" )
+
+# 使用 cursor() 方法创建一个游标对象 cursor
+cursor = meituanDb.cursor()
+
+lists = [ "attractions", "entertainment", "food", "hotel", "sport" ]
+
+try:
+ results = []
+ for string in lists:
+ # 执行SQL语句
+ cursor.execute("SELECT * FROM %s WHERE comments < 500"%string)
+ # 获取所有记录列表
+ results.append(cursor.fetchall())
+ print (string + " loading over")
+ meituanDb.close()
+
+ listDb = pymysql.connect("121.36.100.63","mkl","010512", "list" )
+ cursor = listDb.cursor()
+ cursor.execute("DELETE FROM minoritylist")
+ listDb.commit()
+ items = []
+ maxSize = 10
+ n = 0
+
+ k = 0
+ while ( k < 5 ):
+ for row in results[k]:
+ if ( k == 0 ):
+ item = [ row[0], row[1], row[8], row[4], row[5], row[2] ]
+ elif ( k == 1 ):
+ item = [ row[0], row[1], row[9], row[4], row[6], row[2] ]
+ elif ( k == 2 ):
+ item = [ row[0], row[1], row[8], row[4], row[5], row[2] ]
+ elif ( k == 3 ):
+ item = [ row[0], row[1], row[8], row[3], row[5], row[2] ]
+ elif ( k == 4 ):
+ item = [ row[0], row[1], row[9], row[4], row[6], row[2] ]
+ i = 0
+ isIn = False
+ while ( i < n ):
+ if ( items[i][5] == item[5] ):
+ isIn = True
+ i += 1
+ if (isIn):
+ continue
+ if ( n < maxSize ):
+ items.append(item)
+ n += 1
+ else:
+ i = 0
+ while ( i < n ):
+ if ( float(item[3]) * float(item[4]) > float(items[i][3]) * float(items[i][4]) ):
+ items[i] = item
+ break
+ i += 1
+ k += 1
+ print ("add over")
+
+ cursor = listDb.cursor()
+ i = 0
+ while (i < n):
+ listSql = """INSERT INTO minoritylist(id,
+ url, cateId, score, title) """
+ cursor.execute(listSql + "VALUES(%d, '%s', '%s', %f, '%s')"%(items[i][0], items[i][1], items[i][2], float(items[i][3]) * float(items[i][4]), items[i][5]))
+ listDb.commit()
+ i += 1
+ print ("insert over")
+
+except:
+ listDb.rollback()
+
+listDb.close()
diff --git a/src/softImages/LoginImage.jpg b/src/softImages/LoginImage.jpg
new file mode 100644
index 0000000..9b05d29
Binary files /dev/null and b/src/softImages/LoginImage.jpg differ
diff --git a/src/softImages/RegisterImage.jpg b/src/softImages/RegisterImage.jpg
new file mode 100644
index 0000000..06cdf53
Binary files /dev/null and b/src/softImages/RegisterImage.jpg differ
diff --git a/src/softImages/blackHalf.png b/src/softImages/blackHalf.png
new file mode 100644
index 0000000..1e3b11f
Binary files /dev/null and b/src/softImages/blackHalf.png differ
diff --git a/src/softImages/waitGirl.gif b/src/softImages/waitGirl.gif
new file mode 100644
index 0000000..828d757
Binary files /dev/null and b/src/softImages/waitGirl.gif differ