diff --git a/src/ChangShaTour/ChangShaTour.pro.user b/src/ChangShaTour/ChangShaTour.pro.user index 6c456ec..7d51893 100644 --- a/src/ChangShaTour/ChangShaTour.pro.user +++ b/src/ChangShaTour/ChangShaTour.pro.user @@ -1,10 +1,10 @@ - + EnvironmentId - {4109ff11-a646-43d1-9619-aeb32783df6e} + {d82e82d4-1ed7-46a6-9098-5e0a8f0d7fa3} ProjectExplorer.Project.ActiveTarget @@ -64,14 +64,14 @@ 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 - 1 + Desktop Qt 5.14.2 MSVC2017 32bit + Desktop Qt 5.14.2 MSVC2017 32bit + qt.qt5.5142.win32_msvc2017_kit + 0 0 0 - E:/ChangShaTour/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Debug + D:/大三下/软件体系结构/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_32bit-Debug true @@ -119,7 +119,7 @@ 2 - E:/ChangShaTour/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Release + D:/大三下/软件体系结构/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_32bit-Release true @@ -167,7 +167,7 @@ 0 - E:/ChangShaTour/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Profile + D:/大三下/软件体系结构/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_32bit-Profile true @@ -287,9 +287,8 @@ 2 - ChangShaTour2 - Qt4ProjectManager.Qt4RunConfiguration:C:/Users/13648/Desktop/Trip-in-Chang-sha-8a043ecb0a246aecbb035065accda093da77fdf0/ChangShaTour/ChangShaTour.pro - C:/Users/13648/Desktop/Trip-in-Chang-sha-8a043ecb0a246aecbb035065accda093da77fdf0/ChangShaTour/ChangShaTour.pro + Qt4ProjectManager.Qt4RunConfiguration:D:/大三下/软件体系结构/Trip-in-Chang-sha/ChangShaTour/ChangShaTour.pro + D:/大三下/软件体系结构/Trip-in-Chang-sha/ChangShaTour/ChangShaTour.pro false @@ -300,7 +299,7 @@ false true - E:/ChangShaTour/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Release + D:/大三下/软件体系结构/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_32bit-Debug 1 @@ -308,14 +307,14 @@ ProjectExplorer.Project.Target.1 - Desktop Qt 5.14.2 MinGW 64-bit - Desktop Qt 5.14.2 MinGW 64-bit - qt.qt5.5142.win64_mingw73_kit + 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_MinGW_64_bit-Debug + D:/大三下/软件体系结构/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Debug true @@ -363,7 +362,7 @@ 2 - E:/ChangShaTour/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MinGW_64_bit-Release + D:/大三下/软件体系结构/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Release true @@ -411,7 +410,7 @@ 0 - E:/ChangShaTour/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MinGW_64_bit-Profile + D:/大三下/软件体系结构/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Profile true diff --git a/src/ChangShaTour/confirmwidget.cpp b/src/ChangShaTour/confirmwidget.cpp index 7c37c20..3aabb64 100644 --- a/src/ChangShaTour/confirmwidget.cpp +++ b/src/ChangShaTour/confirmwidget.cpp @@ -1,8 +1,6 @@ #include "confirmwidget.h" #include "ui_confirmwidget.h" - - ConfirmWidget::ConfirmWidget(QWidget *parent) : QWidget(parent), ui(new Ui::ConfirmWidget) @@ -56,6 +54,7 @@ void ConfirmWidget::initInfoWidget() RouteItem * routeItems = routeToConfirm->getAllItems(); int i = 0; routeNameLabel = new QLabel("路线名称:"); + InitLabel(routeNameLabel, true, false, "#FFFFFF"); routeNameLineEdit->setText(routeToConfirm->getRouteName()); nameLine = new QHBoxLayout(); nameLine->addWidget(routeNameLabel); @@ -66,32 +65,41 @@ void ConfirmWidget::initInfoWidget() routeItems=routeItems->next; qDebug()<placeName<startTime<endTime; placeLabelList[i] = new QLabel(routeItems->placeName); + InitLabel(placeLabelList[i], true, false, "#E1B37C"); startTimeLabelList[i] = new QLabel(routeItems->startTime.toString()); + InitLabel(startTimeLabelList[i], true, true, "#FFFFFF"); endTimeLabelList[i] = new QLabel(routeItems->endTime.toString()); + InitLabel(endTimeLabelList[i], true, true, "#FFFFFF"); double * tt =getLatAndLng(routeItems->placeName,routeItems->cateId); lats[i] = tt[0]; lngs[i] = tt[1]; i++; } + allInfo = new QStringList *[size-1]; //需要根据接口返回的数据调整顺序 trafficLabels<<"步行"<<"公交地铁"<<"驾车"<<"骑行"; qDebug()<addItems(trafficLabels); QString location1 = QString::number(lngs[i]) + "," + QString::number(lats[i]); qDebug()<getAllInfo(location1,location2); + allInfo[i] = routePlan->getAllInfo(location1,location2); int k = trafficCBoxList[i]->currentIndex(); - descriptionLabelList[i]=new QLabel(allInfo[k][2]); - distanceLabelList[i]=new QLabel("距离:"+allInfo[k][0]); - timeCostLabelList[i]=new QLabel("时间:"+allInfo[k][1]); + descriptionLabelList[i]=new QLabel(allInfo[i][k][2]); + InitLabel(descriptionLabelList[i], false, true, "#FFFFFF"); + distanceLabelList[i]=new QLabel("距离:"+QString::number(allInfo[i][k][0].toInt()*1.0/1000)+"公里"); + InitLabel(distanceLabelList[i], false, true, "#FFFFFF"); + timeCostLabelList[i]=new QLabel("时间:"+QString::number(allInfo[i][k][1].toInt()*1.0/60)+"分钟"); + InitLabel(timeCostLabelList[i], false, true, "#FFFFFF"); void(QComboBox::*fp)(int)=&QComboBox:: currentIndexChanged; - connect(trafficCBoxList[i],fp,this,[=](){descriptionLabelList[i]->setText(allInfo[trafficCBoxList[i]->currentIndex()][2]);distanceLabelList[i]->setText("距离:"+allInfo[trafficCBoxList[i]->currentIndex()][0]);timeCostLabelList[i]->setText("时间:"+allInfo[trafficCBoxList[i]->currentIndex()][1]);}); + connect(trafficCBoxList[i],fp,this,[=](){descriptionLabelList[i]->setText(allInfo[i][trafficCBoxList[i]->currentIndex()][2]);distanceLabelList[i]->setText("距离:"+QString::number(allInfo[i][trafficCBoxList[i]->currentIndex()][0].toInt()*1.0/1000)+"公里");timeCostLabelList[i]->setText("时间:"+QString::number(allInfo[i][trafficCBoxList[i]->currentIndex()][1].toInt()*1.0/60)+"分钟");}); } } @@ -99,6 +107,7 @@ void ConfirmWidget::initInfo() { size = routeToConfirm->getLength(); routeNameLineEdit = new QLineEdit(); + InitLineEdit(routeNameLineEdit); placeLabelList = (QLabel **)malloc(sizeof(QLabel *) * size); startTimeLabelList = (QLabel **)malloc(sizeof(QLabel *) * size); endTimeLabelList = (QLabel **)malloc(sizeof(QLabel *) * size); @@ -140,12 +149,13 @@ Route * ConfirmWidget::genRoute() { routeItems = routeItems->next; routeItems->traffic = trafficCBoxList[i]->currentText(); - routeItems->description = descriptionLabelList[i]->text(); - routeItems->distance = distanceLabelList[i]->text().split(":")[1].toInt(); - routeItems->timeCost = timeCostLabelList[i]->text().split(":")[1].toInt(); + routeItems->description = allInfo[i][trafficCBoxList[i]->currentIndex()][2]; + routeItems->distance = allInfo[i][trafficCBoxList[i]->currentIndex()][0].toInt(); + routeItems->timeCost = allInfo[i][trafficCBoxList[i]->currentIndex()][1].toInt(); if((routeItems->next->startTime.toTime_t()) - (routeItems->endTime.toTime_t()) < routeItems->timeCost) { QMessageBox::warning(this,"警告","当前交通方式无法按时到达目的地!",QMessageBox::Yes); + return NULL; } } return routeToConfirm; @@ -161,3 +171,50 @@ ConfirmWidget::~ConfirmWidget() { delete ui; } + +void ConfirmWidget::InitLabel(QLabel * label, bool isBold, bool isItalic, QString color) +{ + QFont lbl_font("Microsoft YaHei"); + lbl_font.setPointSize(12); + lbl_font.setBold(isBold); + lbl_font.setItalic(isItalic); + label->setFont(lbl_font); + label->setStyleSheet("color:" + color); + //label->setAlignment(Qt::AlignRight); +} + +void ConfirmWidget::InitComboBox(QComboBox * comboBox) +{ + comboBox->setStyleSheet("QComboBox {" + " border-radius: 4px; " + " color:rgb(0, 0, 0); " + " background-color: rgb(255, 255, 255);" + "} " + " QComboBox:focus { " + " border-style:outset; " + //" border-width:4px; " + " border-radius: 4px; " + //" border-color: #C1D7F1; " + " color:#ffffff; " + " background-color: #C1D7F1;" + "} "); + comboBox->setFont(QFont("Microsoft YaHei" , 12, QFont::Bold)); +} + +void ConfirmWidget::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" , 12, QFont::Bold)); +} diff --git a/src/ChangShaTour/confirmwidget.h b/src/ChangShaTour/confirmwidget.h index ecefe2f..ae05e3e 100644 --- a/src/ChangShaTour/confirmwidget.h +++ b/src/ChangShaTour/confirmwidget.h @@ -42,6 +42,10 @@ public: void trafficInfoChanged(const QString &); Route * genRoute(); + void InitLabel(QLabel * label, bool isBold, bool isItalic, QString color); + void InitComboBox(QComboBox *); + void InitLineEdit(QLineEdit *); + private: int size; QLineEdit * routeNameLineEdit; @@ -57,6 +61,7 @@ private: QLabel ** startTimeLabelList; QLabel ** descriptionLabelList; QLabel ** distanceLabelList; + QStringList ** allInfo; QLabel ** timeCostLabelList; QLabel ** endTimeLabelList; QLabel ** labelList;//显示序号 diff --git a/src/ChangShaTour/customizewidget.cpp b/src/ChangShaTour/customizewidget.cpp index e086e0f..526b04d 100644 --- a/src/ChangShaTour/customizewidget.cpp +++ b/src/ChangShaTour/customizewidget.cpp @@ -15,11 +15,20 @@ CustomizeWidget::CustomizeWidget(QWidget *parent) : title = new QLabel("现在开始定制您的路线\n点击空白按钮就可以向路线中添加场所\n场所的起始/结束时间表示了您想在该场所游玩的时间段"); title->setAlignment(Qt::AlignCenter); + QLabel * numberLabel = new QLabel("序号"); + InitLabel(numberLabel); + QLabel * placeLabel = new QLabel("场所"); + InitLabel(placeLabel); + QLabel * startTimeLabel = new QLabel("起始时间"); + InitLabel(startTimeLabel); + QLabel * endTimeLabel = new QLabel("结束时间"); + InitLabel(endTimeLabel); + format = new QHBoxLayout(); - format->addWidget(new QLabel("序号"),1); - format->addWidget(new QLabel("场所"),12); - format->addWidget(new QLabel("起始时间"),3); - format->addWidget(new QLabel("结束时间"),3); + format->addWidget(numberLabel,1); + format->addWidget(placeLabel,12); + format->addWidget(startTimeLabel,3); + format->addWidget(endTimeLabel,3); format->addWidget(new QLabel(""),2); format->addWidget(new QLabel(""),2); @@ -45,12 +54,17 @@ CustomizeWidget::CustomizeWidget(QWidget *parent) : { lineList[i] = new QHBoxLayout(); labelList[i] = new QLabel(QString::number(i+1)); - labelList[i]->setAlignment(Qt::AlignCenter); + InitLabel(labelList[i]); placeBtnList[i] = new QPushButton(); + InitButton(placeBtnList[i]); startEditList[i] = new QDateTimeEdit(); + InitDateTimeEdit(startEditList[i]); endEditList[i] = new QDateTimeEdit(); + InitDateTimeEdit(endEditList[i]); addBtnList[i] = new QPushButton("+"); + InitButton(addBtnList[i]); delBtnList[i] = new QPushButton("-"); + InitButton(delBtnList[i]); mainLayout->addLayout(lineList[i]); @@ -327,5 +341,58 @@ void CustomizeWidget::initInterface(Route *route) // } qDebug("CustomizeWidget Completed"); +} + +void CustomizeWidget::InitLabel(QLabel * label) +{ + QFont lbl_font("Microsoft YaHei"); + lbl_font.setPointSize(12); + lbl_font.setBold(true); + label->setFont(lbl_font); + label->setStyleSheet("color:#FFFFFF"); + label->setAlignment(Qt::AlignCenter); +} +void CustomizeWidget::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 14px;" + "font-family: Microsoft YaHei;" + "} " + "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 14px;" + "font-family: Microsoft YaHei;" + "} " + "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 14px;" + "font-family: Microsoft YaHei;" + "}"); +} + +void CustomizeWidget::InitDateTimeEdit(QDateTimeEdit * lineEdit) +{ + lineEdit->setStyleSheet("QDateTimeEdit {" + " border-radius: 4px; " + " color:rgb(0, 0, 0); " + " background-color: rgb(255, 255, 255);" + "} " + " QDateTimeEdit:focus { " + " border-style:outset; " + //" border-width:4px; " + " border-radius: 4px; " + //" border-color: #C1D7F1; " + " color:#ffffff; " + " background-color: #C1D7F1;" + "} "); + lineEdit->setFont(QFont("Microsoft YaHei" , 10, QFont::Bold)); } diff --git a/src/ChangShaTour/customizewidget.h b/src/ChangShaTour/customizewidget.h index 708f446..70e7599 100644 --- a/src/ChangShaTour/customizewidget.h +++ b/src/ChangShaTour/customizewidget.h @@ -43,6 +43,10 @@ public: Route *getRoute(); void initInterface(Route *r); + void InitLabel(QLabel *); + void InitButton(QPushButton *); + void InitDateTimeEdit(QDateTimeEdit *); + private: Ui::CustomizeWidget *ui; diff --git a/src/ChangShaTour/favoritewidget.cpp b/src/ChangShaTour/favoritewidget.cpp index ce58bc5..965801c 100644 --- a/src/ChangShaTour/favoritewidget.cpp +++ b/src/ChangShaTour/favoritewidget.cpp @@ -253,7 +253,7 @@ void FavoriteWidget::getFavRoutesList() void FavoriteWidget::setFavRoutesBtns() { - QPushButton ** favRoutesBtnList = (QPushButton **)malloc(sizeof(QPushButton *) * 5); + QPushButton ** favRoutesBtnList = (QPushButton **)malloc(sizeof(QPushButton *) * numOfFavRoutes); for(int i = numOfFavRoutes - 1; i >= 0; i--) { Route *favRoute = favRoutesList[i]; @@ -271,9 +271,8 @@ void FavoriteWidget::setFavRoutesBtns() text += head->placeName; } favRoutesBtnList[i] = new QPushButton(text); + InitRouteButton(favRoutesBtnList[i]); connect(favRoutesBtnList[i],&QPushButton::clicked,this,[=](){switchToShowRouteInfo(favRoutesList[i]);}); - favRoutesBtnList[i]->setStyleSheet("text-align : left;"); - InitButton(favRoutesBtnList[i]); verticalLayout->addWidget(favRoutesBtnList[i]); } } @@ -372,12 +371,14 @@ void FavoriteWidget::InitFavoriteWidget() verLayout = new QVBoxLayout(); verLayout->setMargin(35); + verLayout->setAlignment(Qt::AlignTop); setLayout(verLayout); //QHBoxLayout * refreshLayout = new QHBoxLayout(); refreshButton = new QPushButton("刷新"); + connect(refreshButton, &QPushButton::clicked, this, &FavoriteWidget::refreshe); - verLayout->addWidget(refreshButton); + //verLayout->addWidget(refreshButton); //verLayout->addLayout(refreshLayout); QHBoxLayout *screenLayout=new QHBoxLayout(); @@ -386,12 +387,17 @@ void FavoriteWidget::InitFavoriteWidget() InitButton(favoRoutesBtn); screenLayout->addWidget(favoRoutesBtn); + InitButton(refreshButton); + screenLayout->addWidget(refreshButton); + favoPlacesBtn=new QPushButton("场所收藏夹"); - screenLayout->addWidget(favoPlacesBtn); InitButton(favoPlacesBtn); + screenLayout->addWidget(favoPlacesBtn); initFunctionWidget(); + qDebug() << "initFunctionWidget over"; initShowRouteInfoWidget(); + qDebug() << "initShowRouteInfoWidget over"; web = new WebWidget(); web->setVisible(false); @@ -509,6 +515,13 @@ void FavoriteWidget::refreshe() { favoPlacesWidget->deleteLater(); favoRoutesWidget->deleteLater(); + urlList.clear(); + cateIdList.clear(); + nameList.clear(); + cateIdList.clear(); + queryDatabase(); + + size = (size < limit? size: limit); setFavPlaceScreen(); setFavRouteScreen(); setPageBtns(); @@ -584,9 +597,9 @@ void FavoriteWidget::InitButton(QPushButton * button) "border-radius:10px;" "font:bold 20px;" "font-family: Microsoft YaHei;" - "min-width:100px;" - "min-height:20px;" - "padding:4px;" + //"min-width:100px;" + //"min-height:20px;" + //"padding:4px;" //"text-align: left;" "} " "QPushButton:hover {" @@ -596,9 +609,9 @@ void FavoriteWidget::InitButton(QPushButton * button) "border-radius:10px;" "font:bold 20px;" "font-family: Microsoft YaHei;" - "min-width:100px;" - "min-height:20px;" - "padding:4px;" + //"min-width:100px;" + //"min-height:20px;" + //"padding:4px;" //"text-align: left;" "} " "QPushButton:pressed {" @@ -608,9 +621,9 @@ void FavoriteWidget::InitButton(QPushButton * button) "border-radius:10px;" "font:bold 20px;" "font-family: Microsoft YaHei;" - "min-width:100px;" - "min-height:20px;" - "padding:4px;" + //"min-width:100px;" + //"min-height:20px;" + //"padding:4px;" //"text-align: left;" "}"); } @@ -626,7 +639,7 @@ void FavoriteWidget::InitItemButton(QToolButton * button) //"min-width:100px;" //"min-height:20px;" //"padding:4px;" - //"text-align: left;" + "text-align: left;" "} " "QToolButton:hover {" "color: #66441F;" @@ -638,7 +651,7 @@ void FavoriteWidget::InitItemButton(QToolButton * button) //"min-width:100px;" //"min-height:20px;" //"padding:4px;" - //"text-align: left;" + "text-align: left;" "} " "QToolButton:pressed {" "color: #66441F;" @@ -650,7 +663,46 @@ void FavoriteWidget::InitItemButton(QToolButton * button) //"min-width:100px;" //"min-height:20px;" //"padding:4px;" - //"text-align: left;" + "text-align: left;" + "}"); +} + +void FavoriteWidget::InitRouteButton(QPushButton * button) +{ + button->setStyleSheet("QPushButton {" + "color:#ffffff;" + "background-color: rgba(0, 0, 0, 0);" + "border:none;" + "font:bold 16px;" + "font-family: Microsoft YaHei;" + //"min-width:100px;" + //"min-height:20px;" + //"padding:4px;" + "text-align: left;" + "} " + "QPushButton:hover {" + "color: #66441F;" + "background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #A9201A, stop: 1 #FFFFFF);" + "border-style:outset;" + "border-radius:10px;" + "font:bold 16px;" + "font-family: Microsoft YaHei;" + //"min-width:100px;" + //"min-height:20px;" + //"padding:4px;" + "text-align: left;" + "} " + "QPushButton:pressed {" + "color: #66441F;" + "background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #A9201A, stop: 1 #FFFFFF);" + "border-style:outset;" + "border-radius:10px;" + "font:bold 16px;" + "font-family: Microsoft YaHei;" + //"min-width:100px;" + //"min-height:20px;" + //"padding:4px;" + "text-align: left;" "}"); } diff --git a/src/ChangShaTour/favoritewidget.h b/src/ChangShaTour/favoritewidget.h index 0d11d19..9b41038 100644 --- a/src/ChangShaTour/favoritewidget.h +++ b/src/ChangShaTour/favoritewidget.h @@ -55,6 +55,7 @@ public: void InitButton(QPushButton *); void InitItemButton(QToolButton *); + void InitRouteButton(QPushButton *); void resizeEvent(QResizeEvent *event); diff --git a/src/ChangShaTour/feedbackwidget.cpp b/src/ChangShaTour/feedbackwidget.cpp index 3ea5b97..4ea4f97 100644 --- a/src/ChangShaTour/feedbackwidget.cpp +++ b/src/ChangShaTour/feedbackwidget.cpp @@ -13,11 +13,14 @@ FeedBackWidget::FeedBackWidget(QWidget *parent) : QHBoxLayout * scoreHintLayout = new QHBoxLayout(); QLabel * scoreHintLabel = new QLabel("(必填部分)\n请给这条路线打个分吧~"); + InitLabel(scoreHintLabel, true, true, "#000000"); scoreHintLayout->addWidget(scoreHintLabel); QHBoxLayout * scoreLayout = new QHBoxLayout(); QLabel * scoreLable = new QLabel("分数"); + InitLabel(scoreLable, true, false, "#000000"); scoreLineEdit = new QLineEdit(); + InitLineEdit(scoreLineEdit); scoreLineEdit->setPlaceholderText("请输入一个1~5之间的整数"); scoreLineEdit->setValidator(new QIntValidator(scoreLineEdit)); scoreLayout->addWidget(scoreLable); @@ -25,11 +28,14 @@ FeedBackWidget::FeedBackWidget(QWidget *parent) : QHBoxLayout * shareHintLayout = new QHBoxLayout(); QLabel * shareHintLabel = new QLabel("(选填部分)\n填写下面的信息即可将你的行程分享给其他人哦~"); + InitLabel(shareHintLabel, true, true, "#000000"); shareHintLayout->addWidget(shareHintLabel); QHBoxLayout * dayLayout = new QHBoxLayout(); QLabel * dayLabel = new QLabel("旅游天数"); + InitLabel(dayLabel, true, false, "#000000"); dayLineEdit = new QLineEdit(); + InitLineEdit(dayLineEdit); dayLineEdit->setPlaceholderText("请输入一个1~10之间的整数"); dayLineEdit->setValidator(new QIntValidator(dayLineEdit)); dayLayout->addWidget(dayLabel); @@ -37,7 +43,9 @@ FeedBackWidget::FeedBackWidget(QWidget *parent) : QHBoxLayout * numberLayout = new QHBoxLayout(); QLabel * numberLabel = new QLabel("旅游人数"); + InitLabel(numberLabel, true, false, "#000000"); numberLineEdit = new QLineEdit(); + InitLineEdit(numberLineEdit); numberLineEdit->setPlaceholderText("请输入一个1~8之间的整数"); numberLineEdit->setValidator(new QIntValidator(numberLineEdit)); numberLayout->addWidget(numberLabel); @@ -45,7 +53,9 @@ FeedBackWidget::FeedBackWidget(QWidget *parent) : QHBoxLayout * budgetLayout = new QHBoxLayout(); QLabel * budgetLabel = new QLabel("旅游花费"); + InitLabel(budgetLabel, true, false, "#000000"); budgetLineEdit = new QLineEdit(); + InitLineEdit(budgetLineEdit); budgetLineEdit->setPlaceholderText("请输入一个1~50000之间的整数"); budgetLineEdit->setValidator(new QIntValidator(budgetLineEdit)); budgetLayout->addWidget(budgetLabel); @@ -53,20 +63,26 @@ FeedBackWidget::FeedBackWidget(QWidget *parent) : QHBoxLayout * preferenceLayout = new QHBoxLayout(); QLabel * preferenceLabel = new QLabel("路线重心"); + InitLabel(preferenceLabel, true, false, "#000000"); preferenceLineEdit = new QLineEdit(); + InitLineEdit(preferenceLineEdit); preferenceLineEdit->setPlaceholderText("请输入一个1~6之间的整数,数字的含义如下"); preferenceLineEdit->setValidator(new QIntValidator(preferenceLineEdit)); preferenceLayout->addWidget(preferenceLabel); preferenceLayout->addWidget(preferenceLineEdit); QHBoxLayout * preferenceHintLayout = new QHBoxLayout(); - QLabel * preferenceHintLabel = new QLabel("1:偏重自然风光 2:偏重人文风俗 3:偏重特色美食\n4:night life 5:偏重二次元 6:偏重恋人出游"); + QLabel * preferenceHintLabel = new QLabel("1:偏重自然风光 2:偏重人文风俗 3:偏重特色美食\n4:偏重城市夜景 5:偏重休闲娱乐 6:偏重浪漫出游"); + InitLabel(preferenceHintLabel, true, true, "#000000"); preferenceHintLayout->addWidget(preferenceHintLabel); QHBoxLayout * functionButtonLayout = new QHBoxLayout(); confirmButton = new QPushButton("确认"); + InitButton(confirmButton); cancelButton = new QPushButton("取消"); + InitButton(cancelButton); functionButtonLayout->addWidget(confirmButton); + functionButtonLayout->addStretch(); functionButtonLayout->addWidget(cancelButton); verticalLayout = new QVBoxLayout(); @@ -122,3 +138,67 @@ QPushButton * FeedBackWidget::getCancleButton() { return cancelButton; } + +void FeedBackWidget::InitLabel(QLabel * label, bool isBold, bool isItalic, QString color) +{ + QFont lbl_font("Microsoft YaHei"); + lbl_font.setPointSize(9); + lbl_font.setBold(isBold); + lbl_font.setItalic(isItalic); + label->setFont(lbl_font); + label->setStyleSheet("color:" + color); + //label->setAlignment(Qt::AlignRight); +} + +void FeedBackWidget::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 16px;" + "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 16px;" + "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 16px;" + "font-family: Microsoft YaHei;" + //"min-width:100px;" + //"min-height:20px;" + //"padding:4px;" + "}"); +} + +void FeedBackWidget::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" , 9, QFont::Bold)); +} diff --git a/src/ChangShaTour/feedbackwidget.h b/src/ChangShaTour/feedbackwidget.h index 2dbd787..95809ac 100644 --- a/src/ChangShaTour/feedbackwidget.h +++ b/src/ChangShaTour/feedbackwidget.h @@ -32,6 +32,10 @@ public: QPushButton * getConfirmButton(); QPushButton * getCancleButton(); + void InitLabel(QLabel * label, bool isBold, bool isItalic, QString color); + void InitButton(QPushButton *); + void InitLineEdit(QLineEdit *); + private: Ui::FeedBackWidget *ui; diff --git a/src/ChangShaTour/historywidget.cpp b/src/ChangShaTour/historywidget.cpp index 1c4e809..6e18818 100644 --- a/src/ChangShaTour/historywidget.cpp +++ b/src/ChangShaTour/historywidget.cpp @@ -80,6 +80,7 @@ void HistoryWidget::InitHistoryWidget() mainLayout = new QVBoxLayout(); mainLayout->setMargin(35); + mainLayout->setAlignment(Qt::AlignTop); subWidget = new QWidget(); web = new WebWidget(); diff --git a/src/ChangShaTour/journywidget.cpp b/src/ChangShaTour/journywidget.cpp index 0e12594..cb3d962 100644 --- a/src/ChangShaTour/journywidget.cpp +++ b/src/ChangShaTour/journywidget.cpp @@ -7,20 +7,16 @@ JournyWidget::JournyWidget(QWidget *parent) : { ui->setupUi(this); verLayout = new QVBoxLayout(); + verLayout->setAlignment(Qt::AlignTop); setLayout(verLayout); - - - functionWidget = new QWidget(); initFunctionWidget(); functionWidget->setVisible(true); - journeyChoiceWidget = new QWidget(); journeyChoiceWidget->setVisible(true); - routeIdList = new int[5]; tagList = new int[5]; journeyList = new Route *[5]; @@ -175,14 +171,17 @@ void JournyWidget::setBtns() QHBoxLayout * horizontalLayout = new QHBoxLayout(); journeyBtnList[i] = new QPushButton(text); - journeyBtnList[i]->setStyleSheet("QPushButton{text-align : left;}"); + InitItemButton(journeyBtnList[i]); + //journeyBtnList[i]->setStyleSheet("QPushButton{text-align : left;}"); journeyBtnList[i]->setFixedSize(1000, 50); modifyBtnList[i] = new QPushButton("修改"); + InitButton(modifyBtnList[i]); modifyBtnList[i]->setFixedSize(200, 50); connect(modifyBtnList[i],&QPushButton::clicked,this,[=](){switchToModify(journeyList[i],tagList[i]);}); feedBackBtnList[i] = new QPushButton("反馈"); + InitButton(feedBackBtnList[i]); feedBackBtnList[i]->setFixedSize(200, 50); connect(journeyBtnList[i],&QPushButton::clicked,this,[=](){journeyRoute = journeyList[i]; switchToShowRouteInfo();}); @@ -220,8 +219,8 @@ void JournyWidget::switchToModify(Route *routeToModofy,int journeyTag) { modifyWidget = new ModifyWidget(); modifyWidget->show(); - modifyWidget->setWindowModality(Qt::ApplicationModal); modifyWidget->InitModify(routeToModofy,journeyTag); + } void JournyWidget::initFunctionWidget() { @@ -251,6 +250,7 @@ void JournyWidget::initFunctionWidget() //传入修改完毕的route和该route的Id(tagList[i]) void JournyWidget::addRoute(Route *routeToAdd,int tag) { + qDebug() << "routeName:" << routeToAdd->getRouteName(); RouteItem * routeItemsFav = routeToAdd->getAllItems(); QSqlQuery query(userDb); //QString sql_count = "select count(distinct routeId) from journey where userId = ?;"; @@ -419,35 +419,71 @@ void JournyWidget::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);" + "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:bold 16px;" "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);" + "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:bold 16px;" "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);" + "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:bold 16px;" "font-family: Microsoft YaHei;" "min-width:100px;" "min-height:20px;" "padding:4px;" "}"); - button->setFixedSize(120, 40); +} + +void JournyWidget::InitItemButton(QPushButton * button) +{ + button->setStyleSheet("QPushButton {" + "color:#ffffff;" + "background-color: rgba(0, 0, 0, 0);" + "border:none;" + "font:bold 16px;" + "font-family: Microsoft YaHei;" + //"min-width:100px;" + //"min-height:20px;" + //"padding:4px;" + "text-align : left;" + "} " + "QPushButton:hover {" + "background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #5F7896, stop: 1 #5F7896);" + "border-style:outset;" + "border-radius:10px;" + "font:bold 16px;" + "font-family: Microsoft YaHei;" + //"min-width:100px;" + //"min-height:20px;" + //"padding:4px;" + "text-align : left;" + "} " + "QPushButton:pressed {" + "background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #5F7896, stop: 1 #5F7896);" + "border-style:outset;" + "border-radius:10px;" + "font:bold 16px;" + "font-family: Microsoft YaHei;" + //"min-width:100px;" + //"min-height:20px;" + //"padding:4px;" + "text-align : left;" + "}"); } diff --git a/src/ChangShaTour/journywidget.h b/src/ChangShaTour/journywidget.h index 47dfa67..a7c00fb 100644 --- a/src/ChangShaTour/journywidget.h +++ b/src/ChangShaTour/journywidget.h @@ -38,11 +38,13 @@ public: void switchToJourneyChoiceWidget(); void confirmButtonProcessor(int index); void initFunctionWidget(); - void InitButton(QPushButton * button); void switchToModify(Route * routeToModofy, int journeyTag); void resetWidget(); void addRoute(Route *routeToAdd,int tag); + void InitButton(QPushButton *); + void InitItemButton(QPushButton *); + private: Ui::JournyWidget *ui; diff --git a/src/ChangShaTour/mainwidget.cpp b/src/ChangShaTour/mainwidget.cpp index 6daa377..5bcd4ca 100644 --- a/src/ChangShaTour/mainwidget.cpp +++ b/src/ChangShaTour/mainwidget.cpp @@ -162,10 +162,13 @@ void MainWidget::InitMainWidget() verLayout->addWidget(firstSubWidget); homeWidget = new HomeWidget(); + qDebug() << "homeWidget over"; verLayout->addWidget(homeWidget); userWidget = new UserWidget(); + qDebug() << "userWidget over"; verLayout->addWidget(userWidget); searchWidget = new SearchWidget(); + qDebug() << "searchWidget over"; verLayout->addWidget(searchWidget); //首页按钮默认选中 diff --git a/src/ChangShaTour/modifywidget.cpp b/src/ChangShaTour/modifywidget.cpp index 3014855..78e64bf 100644 --- a/src/ChangShaTour/modifywidget.cpp +++ b/src/ChangShaTour/modifywidget.cpp @@ -9,22 +9,30 @@ ModifyWidget::ModifyWidget(QWidget *parent) : pageIndex = 0; + this->setWindowModality(Qt::ApplicationModal); + this->setFixedSize(QSize(1000,810)); + this->setWindowTitle("请修改..."); + this->setWindowFlags(windowFlags()& ~Qt::WindowMaximizeButtonHint); + this->setWindowFlags(windowFlags()& ~Qt::WindowCloseButtonHint); + mainLayout = new QVBoxLayout(); funcLine = new QHBoxLayout(); rtn = new QPushButton("返回"); + InitButton(rtn); next = new QPushButton("下一步"); + InitButton(next); -// modifyPlace = new CustomizeWidget(); -// modifyTraffic = new ConfirmWidget(); -// showInfo = new ShowRouteInfoWidget(); + modifyPlace = new CustomizeWidget(); + modifyTraffic = new ConfirmWidget(); + showInfo = new ShowRouteInfoWidget(); this->setLayout(mainLayout); mainLayout->addLayout(funcLine); -// mainLayout->addWidget(modifyPlace); -// mainLayout->addWidget(modifyTraffic); -// mainLayout->addWidget(showInfo); + mainLayout->addWidget(modifyPlace); + mainLayout->addWidget(modifyTraffic); + mainLayout->addWidget(showInfo); funcLine->addWidget(rtn); funcLine->addStretch(5); @@ -46,19 +54,21 @@ void ModifyWidget::invisibleAll() void ModifyWidget::InitModify(Route *route, int t) { + oRoute = new Route; r = route; + oRoute->setAllInfo(r); pageIndex = 0; tag = t; - modifyPlace->deleteLater(); - modifyTraffic->deleteLater(); - showInfo->deleteLater(); - modifyPlace = new CustomizeWidget(); - modifyTraffic = new ConfirmWidget(); - showInfo = new ShowRouteInfoWidget(); - mainLayout->addWidget(modifyPlace); - mainLayout->addWidget(modifyTraffic); - mainLayout->addWidget(showInfo); +// modifyPlace->deleteLater(); +// modifyTraffic->deleteLater(); +// showInfo->deleteLater(); +// modifyPlace = new CustomizeWidget(); +// modifyTraffic = new ConfirmWidget(); +// showInfo = new ShowRouteInfoWidget(); +// mainLayout->addWidget(modifyPlace); +// mainLayout->addWidget(modifyTraffic); +// mainLayout->addWidget(showInfo); modifyPlace->initInterface(r); @@ -67,7 +77,7 @@ void ModifyWidget::InitModify(Route *route, int t) disconnect(rtn, 0, 0, 0); disconnect(next, 0, 0, 0); - connect(rtn, &QPushButton::clicked, this, [=](){this->setVisible(false);}); + connect(rtn, &QPushButton::clicked, this, [=](){r->setAllInfo(oRoute); this->close();}); connect(next, &QPushButton::clicked, this, &ModifyWidget::switchToModifyTraffic); } @@ -76,6 +86,7 @@ void ModifyWidget::switchToModifyPlace() { if (pageIndex == 1) { + qDebug("switch to place"); modifyTraffic->deleteLater(); modifyTraffic = new ConfirmWidget(); mainLayout->addWidget(modifyTraffic); @@ -87,7 +98,7 @@ void ModifyWidget::switchToModifyPlace() disconnect(rtn, 0, 0, 0); disconnect(next, 0, 0, 0); - connect(rtn, &QPushButton::clicked, this, [=](){this->deleteLater();}); + connect(rtn, &QPushButton::clicked, this, [=](){r->setAllInfo(oRoute); this->close();}); connect(next, &QPushButton::clicked, this, &ModifyWidget::switchToModifyTraffic); } @@ -98,6 +109,7 @@ void ModifyWidget::switchToModifyTraffic() { if (pageIndex == 2) { + qDebug("switch to traffic"); showInfo->deleteLater(); showInfo = new ShowRouteInfoWidget(); mainLayout->addWidget(showInfo); @@ -113,23 +125,26 @@ void ModifyWidget::switchToModifyTraffic() connect(next, &QPushButton::clicked, this, &ModifyWidget::switchToShowInfo); } - - if (modifyPlace->genRoute()) + else { - pageIndex = 1; - r = modifyPlace->getRoute(); + if (modifyPlace->genRoute()) + { + qDebug("switch to traffic"); + pageIndex = 1; + r = modifyPlace->getRoute(); - modifyTraffic->setRouteToConfirm(r); - modifyTraffic->initWidget(); + modifyTraffic->setRouteToConfirm(r); + modifyTraffic->initWidget(); - invisibleAll(); - modifyTraffic->setVisible(true); + invisibleAll(); + modifyTraffic->setVisible(true); - disconnect(rtn, 0, 0, 0); - disconnect(next, 0, 0, 0); - connect(rtn, &QPushButton::clicked, this, &ModifyWidget::switchToModifyPlace); - connect(next, &QPushButton::clicked, this, &ModifyWidget::switchToShowInfo); + disconnect(rtn, 0, 0, 0); + disconnect(next, 0, 0, 0); + connect(rtn, &QPushButton::clicked, this, &ModifyWidget::switchToModifyPlace); + connect(next, &QPushButton::clicked, this, &ModifyWidget::switchToShowInfo); + } } } @@ -138,13 +153,16 @@ void ModifyWidget::switchToShowInfo() if (pageIndex == 1) { - r = modifyTraffic->genRoute(); - if(r == NULL) + Route *route = modifyTraffic->genRoute(); + if(route == NULL) { + qDebug() << "traffic send NULL"; return ; } else { + r = route; + qDebug("switch to Info"); pageIndex = 2; showInfo->setRouteToShow(r); showInfo->initWidget(); @@ -155,13 +173,107 @@ void ModifyWidget::switchToShowInfo() p = p->next; } + invisibleAll(); + showInfo->setVisible(true); + disconnect(rtn, 0, 0, 0); disconnect(next, 0, 0, 0); connect(rtn, &QPushButton::clicked, this, &ModifyWidget::switchToModifyTraffic); - connect(next, &QPushButton::clicked, this, [=](){this->setVisible(false);}); + connect(next, &QPushButton::clicked, this, [=](){addRoute(r, tag); this->close();}); } } } + +QPushButton *ModifyWidget::getNext() +{ + return next; +} + +int ModifyWidget::getIndex() +{ + return pageIndex; +} + +void ModifyWidget::addRoute(Route *routeToAdd,int tag) +{ + qDebug() << "routeName:" << routeToAdd->getRouteName(); + RouteItem * routeItemsFav = routeToAdd->getAllItems(); + QSqlQuery query(userDb); + //QString sql_count = "select count(distinct routeId) from journey where userId = ?;"; + //query.prepare(sql_count); + //query.addBindValue(Id); + //query.exec(sql_count); + //query.next(); + int routeId = routeToAdd->getRouteId(); + + QString sql_delete = "delete from journey where routeId = ? and userId = ?"; + query.prepare(sql_delete); + query.addBindValue(routeId); + query.addBindValue(Id); + query.exec(); + QString sql = "insert into journey (userId,routeId,routeName,placeNo,startTime,endTime,placeName,url,cateId,traffic,distance,timeCost,description,tag) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?);"; + int i = 1; + //int size = routeFav->getPlaceSize(); + while(routeItemsFav->next != NULL) + { + routeItemsFav = routeItemsFav->next; + query.prepare(sql); + query.addBindValue(Id); + query.addBindValue(routeId); + //query.addBindValue(routeFav->getRouteId()); + query.addBindValue(routeToAdd->getRouteName()); + //query.addBindValue(routeFav->getRouteName()); + query.addBindValue(i); + query.addBindValue(routeItemsFav->startTime.toString("yyyy-MM-dd HH:mm:ss")); + query.addBindValue(routeItemsFav->endTime.toString("yyyy-MM-dd HH:mm:ss")); + query.addBindValue(routeItemsFav->placeName); + query.addBindValue(routeItemsFav->url); + query.addBindValue(routeItemsFav->cateId); + query.addBindValue(routeItemsFav->traffic); + query.addBindValue(routeItemsFav->distance); + query.addBindValue(routeItemsFav->timeCost); + query.addBindValue(routeItemsFav->description); + query.addBindValue(tag); + query.exec(); + i++; + } + +} + +void ModifyWidget::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 16px;" + "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 16px;" + "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 16px;" + "font-family: Microsoft YaHei;" + //"min-width:100px;" + //"min-height:20px;" + //"padding:4px;" + "}"); +} diff --git a/src/ChangShaTour/modifywidget.h b/src/ChangShaTour/modifywidget.h index 70ca0b6..a78a4f2 100644 --- a/src/ChangShaTour/modifywidget.h +++ b/src/ChangShaTour/modifywidget.h @@ -31,12 +31,18 @@ public: void switchToModifyTraffic(); void switchToShowInfo(); void InitModify(Route *route, int t); + QPushButton *getNext(); + int getIndex(); + void addRoute(Route *routeToAdd,int tag); + + void InitButton(QPushButton *); private: Ui::ModifyWidget *ui; int pageIndex; Route *r; + Route *oRoute; int tag; QVBoxLayout *mainLayout; diff --git a/src/ChangShaTour/planwidget.cpp b/src/ChangShaTour/planwidget.cpp index f575979..79ac15d 100644 --- a/src/ChangShaTour/planwidget.cpp +++ b/src/ChangShaTour/planwidget.cpp @@ -345,8 +345,6 @@ void PlanWidget::switchToShowRouteInfo() connect(confirmBtn, &QPushButton::clicked, this, &PlanWidget::switchToPlanChoice); connect(favoriteBtn,&QPushButton::clicked, this, &PlanWidget::addFavRoute); - - showRouteInfoWidget->setRouteToShow(route); showRouteInfoWidget->initWidget(); struct routeItem * p= route->getAllItems()->next; @@ -357,7 +355,6 @@ void PlanWidget::switchToShowRouteInfo() } } - } } @@ -457,11 +454,8 @@ void PlanWidget::switchToConfirmWidget() connect(confirmBtn, &QPushButton::clicked, this, &PlanWidget::switchToShowRouteInfo); } - } - - } PlanWidget::~PlanWidget() @@ -648,7 +642,7 @@ void PlanWidget::addRoute() query.prepare(sql_delete); query.addBindValue(routeId_selected); query.addBindValue(Id); - query.exec(sql_delete); + query.exec(); } QString sql = "insert into journey (userId,routeId,routeName,placeNo,startTime,endTime,placeName,url,cateId,traffic,distance,timeCost,description,tag) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?);"; int i = 1; diff --git a/src/ChangShaTour/popwidget.cpp b/src/ChangShaTour/popwidget.cpp index 5adab23..0b7722e 100644 --- a/src/ChangShaTour/popwidget.cpp +++ b/src/ChangShaTour/popwidget.cpp @@ -23,27 +23,36 @@ PopWidget::PopWidget(QWidget *parent) : mainLayout = new QVBoxLayout(); notify = new QLabel("请从您的收藏夹中选择场所添加到路线中"); + InitLabel(notify); notify->setAlignment(Qt::AlignCenter); searchLine = new QHBoxLayout(); searchBar = new QLineEdit(); + InitLineEdit(searchBar); searchBtn = new QPushButton("搜索"); + InitButton(searchBtn); returnSearchBtn = new QPushButton("退出搜索"); + InitButton(returnSearchBtn); scroll = new QScrollArea(); scrollWidget = new QWidget; scrollLayout = new QVBoxLayout(); pageLine = new QHBoxLayout(); - up = new QPushButton("上一页"); - down = new QPushButton("下一页"); + up = new QPushButton("上页"); + InitButton(up); + down = new QPushButton("下页"); + InitButton(down); chosenLabel = new QLabel("您还未选择场所..."); + InitLabel(chosenLabel); chosenLabel->setAlignment(Qt::AlignLeft); closeLine = new QHBoxLayout(); confirm = new QPushButton("确认"); + InitButton(confirm); cancel = new QPushButton("取消"); + InitButton(cancel); this->setLayout(mainLayout); @@ -190,7 +199,10 @@ void PopWidget::setScreen() nameList.clear(); cateList.clear(); for (int i = 0; i < showLimit; i++) + { btnList[i] = new QToolButton(); + InitItemButton(btnList[i]); + } queryDatabase(); qDebug("popWidget query success"); @@ -255,3 +267,102 @@ QStringList PopWidget::getChosen() { return chosen; } + +void PopWidget::InitLabel(QLabel * label) +{ + QFont lbl_font("Microsoft YaHei"); + lbl_font.setPointSize(10); + //lbl_font.setBold(true); + label->setFont(lbl_font); + label->setStyleSheet("color: rgb(0, 0, 0)"); + label->setAlignment(Qt::AlignRight); +} + +void PopWidget::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 16px;" + "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 16px;" + "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 16px;" + "font-family: Microsoft YaHei;" + "min-width:100px;" + "min-height:20px;" + "padding:4px;" + "}"); +} + +void PopWidget::InitItemButton(QToolButton * button) +{ + button->setStyleSheet("QToolButton {" + "color: rgb(0, 0, 0);" + "background-color: rgba(0, 0, 0, 0);" + "border:none;" + "font:bold 16px;" + "font-family: Microsoft YaHei;" + //"min-width:100px;" + //"min-height:20px;" + //"padding:4px;" + "} " + "QToolButton:hover {" + "color: rgb(255, 255, 255);" + "background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #5F7896, stop: 1 #5F7896);" + "border-style:outset;" + "border-radius:10px;" + "font:bold 16px;" + "font-family: Microsoft YaHei;" + //"min-width:100px;" + //"min-height:20px;" + //"padding:4px;" + "} " + "QToolButton:pressed {" + "color: rgb(255, 255, 255);" + "background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #5F7896, stop: 1 #5F7896);" + "border-style:outset;" + "border-radius:10px;" + "font:bold 16px;" + "font-family: Microsoft YaHei;" + //"min-width:100px;" + //"min-height:20px;" + //"padding:4px;" + "}"); +} + +void PopWidget::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)); +} diff --git a/src/ChangShaTour/popwidget.h b/src/ChangShaTour/popwidget.h index 79951f8..b166c6e 100644 --- a/src/ChangShaTour/popwidget.h +++ b/src/ChangShaTour/popwidget.h @@ -45,6 +45,11 @@ public: void rollTop(); QStringList getChosen(); + void InitLabel(QLabel *); + void InitButton(QPushButton *); + void InitItemButton(QToolButton *); + void InitLineEdit(QLineEdit *); + private: Ui::PopWidget *ui; diff --git a/src/ChangShaTour/route.cpp b/src/ChangShaTour/route.cpp index b03dcad..e58106f 100644 --- a/src/ChangShaTour/route.cpp +++ b/src/ChangShaTour/route.cpp @@ -100,3 +100,33 @@ int Route::getLength() { return this->placeSize; } + +void Route::setAllInfo(Route *otherRoute) +{ + this->setRouteName(otherRoute->routeName); + this->setUserId(otherRoute->routeId); + this->setUserId(otherRoute->userId); + RouteItem * routeItemtemp = this->routeItems; + RouteItem * OtherRouteItem = otherRoute->getAllItems()->next; + while(OtherRouteItem) + { + RouteItem * p; + p = new RouteItem; +// routeItemtemp = NULL; + p->url = OtherRouteItem->url; + p->cateId = OtherRouteItem->cateId; + p->next = OtherRouteItem->next; + p->endTime = OtherRouteItem->endTime; + p->traffic = OtherRouteItem->traffic; + p->distance = OtherRouteItem->distance; + p->timeCost = OtherRouteItem->timeCost; + p->placeName = OtherRouteItem->placeName; + p->startTime = OtherRouteItem->startTime; + p->description = OtherRouteItem->description; + routeItemtemp -> next = p; + + routeItemtemp = routeItemtemp->next; + routeItemtemp->next = NULL; + OtherRouteItem = OtherRouteItem->next; + } +} diff --git a/src/ChangShaTour/route.h b/src/ChangShaTour/route.h index 21ea1c0..44453ef 100644 --- a/src/ChangShaTour/route.h +++ b/src/ChangShaTour/route.h @@ -19,6 +19,7 @@ public: RouteItem * addItem(RouteItem * oneItem,int locate); RouteItem * deleteItem(int locate); int getLength(); + void setAllInfo(Route *otherRoute); private: QString routeName; int placeSize = 0; diff --git a/src/ChangShaTour/showrouteinfowidget.cpp b/src/ChangShaTour/showrouteinfowidget.cpp index 3111c1b..238413d 100644 --- a/src/ChangShaTour/showrouteinfowidget.cpp +++ b/src/ChangShaTour/showrouteinfowidget.cpp @@ -19,7 +19,9 @@ void ShowRouteInfoWidget::initWidget() initInfoWidget(); int i; routeNameLabel = new QLabel("路线名称:"); + InitLabel(routeNameLabel, true, false, "#FFFFFF"); nameLabel = new QLabel(routeToShow->getRouteName()); + InitLabel(nameLabel, true, true, "#FFFFFF"); nameLine = new QHBoxLayout(); nameLine->addWidget(routeNameLabel); nameLine->addWidget(nameLabel); @@ -54,14 +56,21 @@ void ShowRouteInfoWidget::initInfoWidget() routeItems=routeItems->next; placeLabelList[i] = new QLabel(routeItems->placeName); + InitLabel(placeLabelList[i], true, false, "#E1B37C"); startTimeLabelList[i] = new QLabel(routeItems->startTime.toString()); + InitLabel(startTimeLabelList[i], true, true, "#FFFFFF"); endTimeLabelList[i] = new QLabel(routeItems->endTime.toString()); + InitLabel(endTimeLabelList[i], true, true, "#FFFFFF"); if(i != size-1) { trafficLabelList[i] = new QLabel(routeItems->traffic); + InitLabel(trafficLabelList[i], true, true, "#FFFFFF"); descriptionLabelList[i] = new QLabel(routeItems->description); - distanceLabelList[i] = new QLabel("距离:"+QString::number(routeItems->distance)); - timeCostLabelList[i] = new QLabel("时间:"+QString::number(routeItems->timeCost)); + InitLabel(descriptionLabelList[i], false, true, "#FFFFFF"); + distanceLabelList[i] = new QLabel("距离:"+QString::number((routeItems->distance)*1.0/1000)+"公里"); + InitLabel(distanceLabelList[i], false, true, "#FFFFFF"); + timeCostLabelList[i] = new QLabel("时间:"+QString::number((routeItems->timeCost)*1.0/60)+"分钟"); + InitLabel(timeCostLabelList[i], false, true, "#FFFFFF"); } i++; } @@ -84,13 +93,24 @@ void ShowRouteInfoWidget::setRouteToShow(Route *route) { this->routeToShow = route; } + Route * ShowRouteInfoWidget::getRouteToShow() { return this->routeToShow; } - ShowRouteInfoWidget::~ShowRouteInfoWidget() { delete ui; } + +void ShowRouteInfoWidget::InitLabel(QLabel * label, bool isBold, bool isItalic, QString color) +{ + QFont lbl_font("Microsoft YaHei"); + lbl_font.setPointSize(12); + lbl_font.setBold(isBold); + lbl_font.setItalic(isItalic); + label->setFont(lbl_font); + label->setStyleSheet("color:" + color); + //label->setAlignment(Qt::AlignRight); +} diff --git a/src/ChangShaTour/showrouteinfowidget.h b/src/ChangShaTour/showrouteinfowidget.h index 7da131a..879d0cf 100644 --- a/src/ChangShaTour/showrouteinfowidget.h +++ b/src/ChangShaTour/showrouteinfowidget.h @@ -32,6 +32,7 @@ public: void initInfoWidget(); void setRouteToShow(Route * route); Route * getRouteToShow(); + void InitLabel(QLabel * label, bool isBold, bool isItalic, QString color); private: Ui::ShowRouteInfoWidget *ui; diff --git a/src/ChangShaTour/userwidget.cpp b/src/ChangShaTour/userwidget.cpp index ae6d0c6..366acec 100644 --- a/src/ChangShaTour/userwidget.cpp +++ b/src/ChangShaTour/userwidget.cpp @@ -137,9 +137,13 @@ void UserWidget::InitUserWidget() //historyBtn->setStyleSheet("QPushButton{color:rgb(255, 255, 255);}""QPushButton:hover{background-color: rgb(20, 62, 134);border:none;color:rgb(255, 255, 255);}"); userInfoWidget = new UserInfoWidget(this); + qDebug() << "userInfoWidget over"; journyWidget = new JournyWidget(this); + qDebug() << "journyWidget over"; favoriteWidget = new FavoriteWidget(this); + qDebug() << "favoriteWidget over"; historyWidget = new HistoryWidget(this); + qDebug() << "historyWidget over"; journyWidget->setVisible(false); favoriteWidget->setVisible(false); historyWidget->setVisible(false);