美化了登录,注册界面;新增图片文件夹

master
LKeynes 4 years ago
parent 0d2d9f2225
commit 181d116b38

File diff suppressed because it is too large Load Diff

@ -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;

@ -2,6 +2,13 @@
#define FAVORITEWIDGET_H
#include <QWidget>
#include <QPushButton>
#include <QSqlQuery>
#include <cglobal.h>
#include <webwidget.h>
#include <QToolButton>
#include <QSignalMapper>
#include <QScrollArea>
#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

@ -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()

@ -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;

@ -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);
}

@ -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()

@ -1,5 +1,6 @@
#include "registerwidget.h"
#include "ui_registerwidget.h"
#include <QDir>
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());
}

@ -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;

@ -1,75 +1,75 @@
#include "smtp.h"
#include<QDebug>
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<QDebug>
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;
}

@ -1,24 +1,24 @@
#ifndef SMTH_H
#define SMTH_H
#include<QByteArray>
#include<QString>
#include<QTcpSocket>
#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<QByteArray>
#include<QString>
#include<QTcpSocket>
#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

@ -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();

@ -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));
}

@ -9,6 +9,7 @@
#include <QUrl>
#include <QSqlQuery>
#include <cglobal.h>
#include <QMessageBox>
#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

@ -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()

@ -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()

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 929 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 KiB

Loading…
Cancel
Save