首页美化框架已完成

master
LKeynes 4 years ago
parent 0df11545dc
commit 7b8c88a16b

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.11.1, 2021-07-07T08:43:09. -->
<!-- Written by QtCreator 4.11.1, 2021-01-06T09:35:14. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{4109ff11-a646-43d1-9619-aeb32783df6e}</value>
<value type="QByteArray">{0c4c8ccc-c524-4850-ba23-7e124d5915df}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
@ -71,7 +71,7 @@
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">E:/ChangShaTour/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">F:/QtDemo/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -119,7 +119,7 @@
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">E:/ChangShaTour/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">F:/QtDemo/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -167,7 +167,7 @@
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">E:/ChangShaTour/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Profile</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">F:/QtDemo/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -287,8 +287,8 @@
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/Users/13648/Desktop/Trip-in-Chang-sha-042a8abb0ff29b210015c9bef1bad274bdb5d3d5/ChangShaTour/ChangShaTour.pro</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">C:/Users/13648/Desktop/Trip-in-Chang-sha-042a8abb0ff29b210015c9bef1bad274bdb5d3d5/ChangShaTour/ChangShaTour.pro</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:F:/QtDemo/ChangShaTour/ChangShaTour.pro</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">F:/QtDemo/ChangShaTour/ChangShaTour.pro</value>
<value type="QString" key="RunConfiguration.Arguments"></value>
<value type="bool" key="RunConfiguration.Arguments.multi">false</value>
<value type="QString" key="RunConfiguration.OverrideDebuggerStartup"></value>
@ -299,257 +299,14 @@
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">E:/ChangShaTour/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Release</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.1</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.14.2 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.14.2 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.5142.win64_mingw73_kit</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">E:/ChangShaTour/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MinGW_64_bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">E:/ChangShaTour/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MinGW_64_bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">E:/ChangShaTour/Trip-in-Chang-sha/build-ChangShaTour-Desktop_Qt_5_14_2_MinGW_64_bit-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">true</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="QString" key="Analyzer.Perf.CallgraphMode">dwarf</value>
<valuelist type="QVariantList" key="Analyzer.Perf.Events">
<value type="QString">cpu-cycles</value>
</valuelist>
<valuelist type="QVariantList" key="Analyzer.Perf.ExtraArguments"/>
<value type="int" key="Analyzer.Perf.Frequency">250</value>
<valuelist type="QVariantList" key="Analyzer.Perf.RecordArguments">
<value type="QString">-e</value>
<value type="QString">cpu-cycles</value>
<value type="QString">--call-graph</value>
<value type="QString">dwarf,4096</value>
<value type="QString">-F</value>
<value type="QString">250</value>
</valuelist>
<value type="QString" key="Analyzer.Perf.SampleMode">-F</value>
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
<value type="int" key="Analyzer.Perf.StackSize">4096</value>
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="QString" key="Analyzer.Valgrind.KCachegrindExecutable">kcachegrind</value>
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="QString" key="RunConfiguration.Arguments"></value>
<value type="bool" key="RunConfiguration.Arguments.multi">false</value>
<value type="QString" key="RunConfiguration.OverrideDebuggerStartup"></value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default"></value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">F:/QtDemo/build-ChangShaTour-Desktop_Qt_5_14_2_MSVC2017_64bit-Release</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="int">2</value>
<value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -1,22 +1,22 @@
#include <QMetaType>
#include <QString>
#include <QDateTime>
#ifndef ROUTEITEM_H
#define ROUTEITEM_H
struct routeItem{
QString placeName;
QString url;
QString cateId;
QDateTime startTime;
QDateTime endTime;
QString traffic;
double distance;
double timeCost;
QString description;
struct routeItem * next;
};
typedef struct routeItem RouteItem;
#endif // ROUTEITEM_H
#include <QMetaType>
#include <QString>
#include <QDateTime>
#ifndef ROUTEITEM_H
#define ROUTEITEM_H
struct routeItem{
QString placeName;
QString url;
QString cateId;
QDateTime startTime;
QDateTime endTime;
QString traffic;
double distance;
double timeCost;
QString description;
struct routeItem * next;
};
typedef struct routeItem RouteItem;
#endif // ROUTEITEM_H

@ -1,47 +1,47 @@
#include "addhistory.h"
//将店铺的链接加入history数据库
AddHistory::AddHistory()
{
}
void AddHistory::add(QString url)
{
QSqlQuery query(userDb);
query.prepare("select historyId from history where url=?");
query.addBindValue(url);
query.exec();
query.next();
if(query.isValid())
{
query.prepare("update history set createdtime = now() where url=?");
query.addBindValue(url);
query.exec();
return ;
}
query.prepare("select count(*) from history where id = ?");
query.addBindValue(Id);
query.exec();
query.next();
int count=query.value(0).toInt();
if(count>=limit)
{
query.prepare("select historyId from history where id = ? order by createdtime");
query.addBindValue(Id);
query.exec();
query.next();
int historyId=query.value("historyId").toInt();
query.prepare("update history set url = ?, createdtime = now() where historyId=?");
query.addBindValue(url);
query.addBindValue(historyId);
query.exec();
}
else
{
query.prepare("insert into history (id,url)values(?,?)");
query.addBindValue(Id);
query.addBindValue(url);
query.exec();
}
}
#include "addhistory.h"
//将店铺的链接加入history数据库
AddHistory::AddHistory()
{
}
void AddHistory::add(QString url)
{
QSqlQuery query(userDb);
query.prepare("select historyId from history where url=?");
query.addBindValue(url);
query.exec();
query.next();
if(query.isValid())
{
query.prepare("update history set createdtime = now() where url=?");
query.addBindValue(url);
query.exec();
return ;
}
query.prepare("select count(*) from history where id = ?");
query.addBindValue(Id);
query.exec();
query.next();
int count=query.value(0).toInt();
if(count>=limit)
{
query.prepare("select historyId from history where id = ? order by createdtime");
query.addBindValue(Id);
query.exec();
query.next();
int historyId=query.value("historyId").toInt();
query.prepare("update history set url = ?, createdtime = now() where historyId=?");
query.addBindValue(url);
query.addBindValue(historyId);
query.exec();
}
else
{
query.prepare("insert into history (id,url)values(?,?)");
query.addBindValue(Id);
query.addBindValue(url);
query.exec();
}
}

@ -1,16 +1,16 @@
#ifndef ADDHISTORY_H
#define ADDHISTORY_H
#include <QString>
#include <QSqlQuery>
#include "cglobal.h"
class AddHistory
{
public:
AddHistory();
void add(QString id);
private:
int limit;
};
#endif // ADDHISTORY_H
#ifndef ADDHISTORY_H
#define ADDHISTORY_H
#include <QString>
#include <QSqlQuery>
#include "cglobal.h"
class AddHistory
{
public:
AddHistory();
void add(QString id);
private:
int limit;
};
#endif // ADDHISTORY_H

@ -1,101 +1,101 @@
#include "cglobal.h"
qint64 Id;
QSqlDatabase meituanDb;
QSqlDatabase userDb;
QSqlDatabase listDb;
QMap<QString,QString> labelToDb;
QStringList recommendlabel;
cglobal::cglobal()
{
}
void cglobal::labelmap()
{
//food
labelToDb[QStringLiteral("代金券")]="food";
labelToDb[QStringLiteral("蛋糕甜点")]="food";
labelToDb[QStringLiteral("自助餐")]="food";
labelToDb[QStringLiteral("小吃快餐")]="food";
labelToDb[QStringLiteral("火锅")]="food";
labelToDb[QStringLiteral("日韩料理")]="food";
labelToDb[QStringLiteral("西餐")]="food";
labelToDb[QStringLiteral("烧烤烤肉")]="food";
labelToDb[QStringLiteral("川湘菜")]="food";
labelToDb[QStringLiteral("东北菜")]="food";
labelToDb[QStringLiteral("江浙菜")]="food";
labelToDb[QStringLiteral("中式烧烤/烤串")]="food";
labelToDb[QStringLiteral("香锅烤鱼")]="food";
labelToDb[QStringLiteral("粤菜")]="food";
labelToDb[QStringLiteral("西北菜")]="food";
labelToDb[QStringLiteral("咖啡酒吧")]="food";
labelToDb[QStringLiteral("京菜鲁菜")]="food";
labelToDb[QStringLiteral("云贵菜")]="food";
labelToDb[QStringLiteral("东南亚菜")]="food";
labelToDb[QStringLiteral("海鲜")]="food";
labelToDb[QStringLiteral("素食")]="food";
labelToDb[QStringLiteral("台湾/客家菜")]="food";
labelToDb[QStringLiteral("创意菜")]="food";
labelToDb[QStringLiteral("汤/洲/炖菜")]="food";
labelToDb[QStringLiteral("蒙餐")]="food";
labelToDb[QStringLiteral("新疆菜")]="food";
labelToDb[QStringLiteral("其他美食")]="food";
labelToDb[QStringLiteral("聚餐宴请")]="food";
//attractions
labelToDb[QStringLiteral("景点")]="attractions";
//entertainment
labelToDb[QStringLiteral("新奇体验")]="entertainment";
labelToDb[QStringLiteral("团建拓展")]="entertainment";
labelToDb[QStringLiteral("足疗/按摩")]="entertainment";
labelToDb[QStringLiteral("洗浴/汗蒸")]="entertainment";
labelToDb[QStringLiteral("KTV")]="entertainment";
labelToDb[QStringLiteral("酒吧")]="entertainment";
labelToDb[QStringLiteral("电玩/游戏厅")]="entertainment";
labelToDb[QStringLiteral("运动健身")]="entertainment";
labelToDb[QStringLiteral("私人影院")]="entertainment";
labelToDb[QStringLiteral("DIY手工坊")]="entertainment";
labelToDb[QStringLiteral("密室逃脱")]="entertainment";
labelToDb[QStringLiteral("网吧网咖")]="entertainment";
labelToDb[QStringLiteral("茶馆")]="entertainment";
labelToDb[QStringLiteral("轰趴馆")]="entertainment";
labelToDb[QStringLiteral("棋牌室")]="entertainment";
labelToDb[QStringLiteral("桌游")]="entertainment";
labelToDb[QStringLiteral("真人CS")]="entertainment";
labelToDb[QStringLiteral("采摘/农家乐")]="entertainment";
labelToDb[QStringLiteral("VR")]="entertainment";
//hotel
labelToDb[QStringLiteral("经济型酒店")]="hotel";
labelToDb[QStringLiteral("主题酒店")]="hotel";
labelToDb[QStringLiteral("商务酒店")]="hotel";
labelToDb[QStringLiteral("公寓")]="hotel";
labelToDb[QStringLiteral("豪华酒店")]="hotel";
labelToDb[QStringLiteral("客栈")]="hotel";
labelToDb[QStringLiteral("青年旅社")]="hotel";
labelToDb[QStringLiteral("度假酒店")]="hotel";
labelToDb[QStringLiteral("别墅")]="hotel";
labelToDb[QStringLiteral("民宿")]="hotel";
//sport
labelToDb[QStringLiteral("滑翔伞")]="sport";
labelToDb[QStringLiteral("赛车")]="sport";
labelToDb[QStringLiteral("游泳")]="sport";
labelToDb[QStringLiteral("健身中心")]="sport";
labelToDb[QStringLiteral("羽毛球")]="sport";
labelToDb[QStringLiteral("台球")]="sport";
labelToDb[QStringLiteral("武术")]="sport";
labelToDb[QStringLiteral("保龄球")]="sport";
labelToDb[QStringLiteral("高尔夫")]="sport";
labelToDb[QStringLiteral("篮球")]="sport";
labelToDb[QStringLiteral("滑冰")]="sport";
labelToDb[QStringLiteral("射击射箭")]="sport";
labelToDb[QStringLiteral("网球")]="sport";
labelToDb[QStringLiteral("骑马")]="sport";
labelToDb[QStringLiteral("乒乓球")]="sport";
labelToDb[QStringLiteral("体育球馆")]="sport";
recommendlabel<<QStringLiteral("川湘菜")<<QStringLiteral("景点")<<QStringLiteral("运动健身")<<QStringLiteral("民宿")<<QStringLiteral("蛋糕甜点")<<QStringLiteral("自助餐")<<QStringLiteral("小吃快餐")<<QStringLiteral("火锅")<<QStringLiteral("日韩料理")<<QStringLiteral("西餐")<<QStringLiteral("烧烤烤肉")<<QStringLiteral("东北菜")<<QStringLiteral("江浙菜")<<QStringLiteral("中式烧烤/烤串")<<QStringLiteral("香锅烤鱼")<<QStringLiteral("粤菜")<<QStringLiteral("西北菜")<<QStringLiteral("咖啡酒吧")<<QStringLiteral("云贵菜")<<QStringLiteral("京菜鲁菜")<<QStringLiteral("东南亚菜")<<QStringLiteral("海鲜")<<QStringLiteral("素食")<<QStringLiteral("台湾/客家菜")<<QStringLiteral("创意菜")<<QStringLiteral("汤/洲/炖菜")<<QStringLiteral("蒙餐")<<QStringLiteral("新疆菜")<<QStringLiteral("其他美食")<<QStringLiteral("聚餐宴请");
recommendlabel<<QStringLiteral("经济型酒店")<<QStringLiteral("主题酒店")<<QStringLiteral("商务酒店")<<QStringLiteral("公寓")<<QStringLiteral("豪华酒店")<<QStringLiteral("客栈")<<QStringLiteral("青年旅社")<<QStringLiteral("度假酒店")<<QStringLiteral("别墅");
recommendlabel<<QStringLiteral("代金券")<<QStringLiteral("新奇体验")<<QStringLiteral("团建扩展")<<QStringLiteral("足疗/按摩")<<QStringLiteral("洗浴/汗蒸")<<QStringLiteral("KTV")<<QStringLiteral("酒吧")<<QStringLiteral("电玩/游戏厅")<<QStringLiteral("私人影院")<<QStringLiteral("DIY手工坊")<<QStringLiteral("密室逃脱")<<QStringLiteral("网吧网咖")<<QStringLiteral("茶馆")<<QStringLiteral("棋牌室")<<QStringLiteral("轰趴馆")<<QStringLiteral("桌游")<<QStringLiteral("真人CS")<<QStringLiteral("采摘/农家乐")<<QStringLiteral("VR");
recommendlabel<<QStringLiteral("滑翔伞")<<QStringLiteral("赛车")<<QStringLiteral("游泳")<<QStringLiteral("健身中心")<<QStringLiteral("羽毛球")<<QStringLiteral("台球")<<QStringLiteral("武术")<<QStringLiteral("保龄球")<<QStringLiteral("高尔夫")<<QStringLiteral("篮球")<<QStringLiteral("滑冰")<<QStringLiteral("射击射箭")<<QStringLiteral("网球")<<QStringLiteral("骑马")<<QStringLiteral("乒乓球")<<QStringLiteral("体育场馆");
}
#include "cglobal.h"
qint64 Id;
QSqlDatabase meituanDb;
QSqlDatabase userDb;
QSqlDatabase listDb;
QMap<QString,QString> labelToDb;
QStringList recommendlabel;
cglobal::cglobal()
{
}
void cglobal::labelmap()
{
//food
labelToDb[QStringLiteral("代金券")]="food";
labelToDb[QStringLiteral("蛋糕甜点")]="food";
labelToDb[QStringLiteral("自助餐")]="food";
labelToDb[QStringLiteral("小吃快餐")]="food";
labelToDb[QStringLiteral("火锅")]="food";
labelToDb[QStringLiteral("日韩料理")]="food";
labelToDb[QStringLiteral("西餐")]="food";
labelToDb[QStringLiteral("烧烤烤肉")]="food";
labelToDb[QStringLiteral("川湘菜")]="food";
labelToDb[QStringLiteral("东北菜")]="food";
labelToDb[QStringLiteral("江浙菜")]="food";
labelToDb[QStringLiteral("中式烧烤/烤串")]="food";
labelToDb[QStringLiteral("香锅烤鱼")]="food";
labelToDb[QStringLiteral("粤菜")]="food";
labelToDb[QStringLiteral("西北菜")]="food";
labelToDb[QStringLiteral("咖啡酒吧")]="food";
labelToDb[QStringLiteral("京菜鲁菜")]="food";
labelToDb[QStringLiteral("云贵菜")]="food";
labelToDb[QStringLiteral("东南亚菜")]="food";
labelToDb[QStringLiteral("海鲜")]="food";
labelToDb[QStringLiteral("素食")]="food";
labelToDb[QStringLiteral("台湾/客家菜")]="food";
labelToDb[QStringLiteral("创意菜")]="food";
labelToDb[QStringLiteral("汤/洲/炖菜")]="food";
labelToDb[QStringLiteral("蒙餐")]="food";
labelToDb[QStringLiteral("新疆菜")]="food";
labelToDb[QStringLiteral("其他美食")]="food";
labelToDb[QStringLiteral("聚餐宴请")]="food";
//attractions
labelToDb[QStringLiteral("景点")]="attractions";
//entertainment
labelToDb[QStringLiteral("新奇体验")]="entertainment";
labelToDb[QStringLiteral("团建拓展")]="entertainment";
labelToDb[QStringLiteral("足疗/按摩")]="entertainment";
labelToDb[QStringLiteral("洗浴/汗蒸")]="entertainment";
labelToDb[QStringLiteral("KTV")]="entertainment";
labelToDb[QStringLiteral("酒吧")]="entertainment";
labelToDb[QStringLiteral("电玩/游戏厅")]="entertainment";
labelToDb[QStringLiteral("运动健身")]="entertainment";
labelToDb[QStringLiteral("私人影院")]="entertainment";
labelToDb[QStringLiteral("DIY手工坊")]="entertainment";
labelToDb[QStringLiteral("密室逃脱")]="entertainment";
labelToDb[QStringLiteral("网吧网咖")]="entertainment";
labelToDb[QStringLiteral("茶馆")]="entertainment";
labelToDb[QStringLiteral("轰趴馆")]="entertainment";
labelToDb[QStringLiteral("棋牌室")]="entertainment";
labelToDb[QStringLiteral("桌游")]="entertainment";
labelToDb[QStringLiteral("真人CS")]="entertainment";
labelToDb[QStringLiteral("采摘/农家乐")]="entertainment";
labelToDb[QStringLiteral("VR")]="entertainment";
//hotel
labelToDb[QStringLiteral("经济型酒店")]="hotel";
labelToDb[QStringLiteral("主题酒店")]="hotel";
labelToDb[QStringLiteral("商务酒店")]="hotel";
labelToDb[QStringLiteral("公寓")]="hotel";
labelToDb[QStringLiteral("豪华酒店")]="hotel";
labelToDb[QStringLiteral("客栈")]="hotel";
labelToDb[QStringLiteral("青年旅社")]="hotel";
labelToDb[QStringLiteral("度假酒店")]="hotel";
labelToDb[QStringLiteral("别墅")]="hotel";
labelToDb[QStringLiteral("民宿")]="hotel";
//sport
labelToDb[QStringLiteral("滑翔伞")]="sport";
labelToDb[QStringLiteral("赛车")]="sport";
labelToDb[QStringLiteral("游泳")]="sport";
labelToDb[QStringLiteral("健身中心")]="sport";
labelToDb[QStringLiteral("羽毛球")]="sport";
labelToDb[QStringLiteral("台球")]="sport";
labelToDb[QStringLiteral("武术")]="sport";
labelToDb[QStringLiteral("保龄球")]="sport";
labelToDb[QStringLiteral("高尔夫")]="sport";
labelToDb[QStringLiteral("篮球")]="sport";
labelToDb[QStringLiteral("滑冰")]="sport";
labelToDb[QStringLiteral("射击射箭")]="sport";
labelToDb[QStringLiteral("网球")]="sport";
labelToDb[QStringLiteral("骑马")]="sport";
labelToDb[QStringLiteral("乒乓球")]="sport";
labelToDb[QStringLiteral("体育球馆")]="sport";
recommendlabel<<QStringLiteral("川湘菜")<<QStringLiteral("景点")<<QStringLiteral("运动健身")<<QStringLiteral("民宿")<<QStringLiteral("蛋糕甜点")<<QStringLiteral("自助餐")<<QStringLiteral("小吃快餐")<<QStringLiteral("火锅")<<QStringLiteral("日韩料理")<<QStringLiteral("西餐")<<QStringLiteral("烧烤烤肉")<<QStringLiteral("东北菜")<<QStringLiteral("江浙菜")<<QStringLiteral("中式烧烤/烤串")<<QStringLiteral("香锅烤鱼")<<QStringLiteral("粤菜")<<QStringLiteral("西北菜")<<QStringLiteral("咖啡酒吧")<<QStringLiteral("云贵菜")<<QStringLiteral("京菜鲁菜")<<QStringLiteral("东南亚菜")<<QStringLiteral("海鲜")<<QStringLiteral("素食")<<QStringLiteral("台湾/客家菜")<<QStringLiteral("创意菜")<<QStringLiteral("汤/洲/炖菜")<<QStringLiteral("蒙餐")<<QStringLiteral("新疆菜")<<QStringLiteral("其他美食")<<QStringLiteral("聚餐宴请");
recommendlabel<<QStringLiteral("经济型酒店")<<QStringLiteral("主题酒店")<<QStringLiteral("商务酒店")<<QStringLiteral("公寓")<<QStringLiteral("豪华酒店")<<QStringLiteral("客栈")<<QStringLiteral("青年旅社")<<QStringLiteral("度假酒店")<<QStringLiteral("别墅");
recommendlabel<<QStringLiteral("代金券")<<QStringLiteral("新奇体验")<<QStringLiteral("团建扩展")<<QStringLiteral("足疗/按摩")<<QStringLiteral("洗浴/汗蒸")<<QStringLiteral("KTV")<<QStringLiteral("酒吧")<<QStringLiteral("电玩/游戏厅")<<QStringLiteral("私人影院")<<QStringLiteral("DIY手工坊")<<QStringLiteral("密室逃脱")<<QStringLiteral("网吧网咖")<<QStringLiteral("茶馆")<<QStringLiteral("棋牌室")<<QStringLiteral("轰趴馆")<<QStringLiteral("桌游")<<QStringLiteral("真人CS")<<QStringLiteral("采摘/农家乐")<<QStringLiteral("VR");
recommendlabel<<QStringLiteral("滑翔伞")<<QStringLiteral("赛车")<<QStringLiteral("游泳")<<QStringLiteral("健身中心")<<QStringLiteral("羽毛球")<<QStringLiteral("台球")<<QStringLiteral("武术")<<QStringLiteral("保龄球")<<QStringLiteral("高尔夫")<<QStringLiteral("篮球")<<QStringLiteral("滑冰")<<QStringLiteral("射击射箭")<<QStringLiteral("网球")<<QStringLiteral("骑马")<<QStringLiteral("乒乓球")<<QStringLiteral("体育场馆");
}

@ -1,23 +1,23 @@
#ifndef CGLOBAL_H
#define CGLOBAL_H
#include <QVariant>
#include <QMap>
#include <QObject>
#include <QSqlDatabase>
//全局变量定义文件include该文件即可获得用户Id
extern qint64 Id;
extern QSqlDatabase meituanDb;
extern QSqlDatabase userDb;
extern QSqlDatabase listDb;
extern QMap<QString,QString> labelToDb;
extern QStringList recommendlabel;
class cglobal
{
public:
cglobal();
void labelmap();
};
#endif // CGLOBAL_H
#ifndef CGLOBAL_H
#define CGLOBAL_H
#include <QVariant>
#include <QMap>
#include <QObject>
#include <QSqlDatabase>
//全局变量定义文件include该文件即可获得用户Id
extern qint64 Id;
extern QSqlDatabase meituanDb;
extern QSqlDatabase userDb;
extern QSqlDatabase listDb;
extern QMap<QString,QString> labelToDb;
extern QStringList recommendlabel;
class cglobal
{
public:
cglobal();
void labelmap();
};
#endif // CGLOBAL_H

@ -8,7 +8,7 @@ CustomizeWidget::CustomizeWidget(QWidget *parent) :
ui->setupUi(this);
num = 1;
limit = 15;
limit = 12;
startTimeList = (QDateTime *)malloc(sizeof(QDateTime) * limit);
endTimeList = (QDateTime *)malloc(sizeof(QDateTime) * limit);
for(int i = 0; i < limit; i++)
@ -54,8 +54,8 @@ CustomizeWidget::CustomizeWidget(QWidget *parent) :
labelList[i] = new QLabel(QString::number(i+1));
labelList[i]->setAlignment(Qt::AlignCenter);
placeBtnList[i] = new QPushButton("");
startEditList[i] = new QDateTimeEdit();
endEditList[i] = new QDateTimeEdit();
startEditList[i] = new QDateTimeEdit(QDateTime::currentDateTime());
endEditList[i] = new QDateTimeEdit(QDateTime::currentDateTime());
addBtnList[i] = new QPushButton("add");
delBtnList[i] = new QPushButton("del");
@ -120,10 +120,18 @@ void CustomizeWidget::addAt(int index)
for (int i = num - 1; i > index + 1; i--)
{
nameList[i] = nameList[i - 1];
urlList[i] = urlList[i - 1];
cateIdList[i] = urlList[i - 1];
//后期还要加上修改两个时间List的语句
placeBtnList[i]->setText(nameList[i]);
//后期还要加上修改两个时间Edit的语句
}
nameList[index + 1] = "";
urlList[index + 1] = "";
cateIdList[index + 1] = "";
//后期还要加上修改两个时间List的语句
placeBtnList[index + 1]->setText(nameList[index + 1]);
//后期还要加上修改两个时间Edit的语句
}
}
@ -139,10 +147,18 @@ void CustomizeWidget::delAt(int index)
for (int i = index; i < num ; i++)
{
nameList[i] = nameList[i + 1];
urlList[i] = urlList[i + 1];
cateIdList[i] = cateIdList[i + 1];
//后期还要加上修改两个时间List的语句
placeBtnList[i]->setText(nameList[i]);
//后期还要加上修改两个时间Edit的语句
}
nameList[num] = "";
urlList[num] = "";
cateIdList[num] = "";
//后期还要加上修改两个时间List的语句
placeBtnList[num]->setText(nameList[index + 1]);
//后期还要加上修改两个时间Edit的语句
}
}
@ -150,7 +166,16 @@ void CustomizeWidget::setBtn(int index)
{
PopWidget * w = new PopWidget();
w->show();
connect(w->getConfirmBtn(), &QPushButton::clicked, this, [=](){w->close();});
connect(w->getConfirmBtn(), &QPushButton::clicked, this, [=](){getResult(index, w->getChosen()); w->close();});
connect(w->getCancelBtn(), &QPushButton::clicked, this, [=](){w->close();});
qDebug() << "Set Btn" << QString::number(index);
}
void CustomizeWidget::getResult(int index, QStringList chosen)
{
nameList[index] = chosen[0];
urlList[index] = chosen[1];
cateIdList[index] = chosen[2];
placeBtnList[index]->setText(nameList[index]);
}

@ -35,6 +35,7 @@ public:
void delAt(int index);
void setBtn(int index);
QString getBtn(int index);
void getResult(int index, QStringList chosen);
private:
Ui::CustomizeWidget *ui;

@ -7,46 +7,7 @@ HomeWidget::HomeWidget(QWidget *parent) :
{
ui->setupUi(this);
verLayout = new QVBoxLayout();
horLayout = new QHBoxLayout();
rcmdBtn = new QPushButton("猜你喜欢");
listBtn = new QPushButton("热门榜单");
sortBtn = new QPushButton("分类筛选");
planBtn = new QPushButton("方案定制");
//默认选择显示“猜你喜欢”界面
pageIndex = 0;
//rcmdBtn->setStyleSheet("QPushButton{background-color: rgb(20, 62, 134);color:rgb(255, 255, 255);}");
//listBtn->setStyleSheet("QPushButton{color:rgb(255, 255, 255);}""QPushButton:hover{background-color: rgb(20, 62, 134);border:none;color:rgb(255, 255, 255);}");
//sortBtn->setStyleSheet("QPushButton{color:rgb(255, 255, 255);}""QPushButton:hover{background-color: rgb(20, 62, 134);border:none;color:rgb(255, 255, 255);}");
//planBtn->setStyleSheet("QPushButton{color:rgb(255, 255, 255);}""QPushButton:hover{background-color: rgb(20, 62, 134);border:none;color:rgb(255, 255, 255);}");
rcmdWidget = new RecommendWidget(this);
listWidget = new ListWidget(this);
sortWidget = new SortWidget(this);
planWidget = new PlanWidget(this);
rcmdWidget->setVisible(true);
listWidget->setVisible(false);
sortWidget->setVisible(false);
planWidget->setVisible(false);
setLayout(verLayout);
verLayout->addLayout(horLayout);
verLayout->addWidget(rcmdWidget);
verLayout->addWidget(listWidget);
verLayout->addWidget(sortWidget);
verLayout->addWidget(planWidget);
horLayout->addWidget(rcmdBtn);
horLayout->addWidget(listBtn);
horLayout->addWidget(sortBtn);
horLayout->addWidget(planBtn);
connect(rcmdBtn, &QPushButton::clicked, this, &HomeWidget::switchToRcmdWidget);
connect(listBtn, &QPushButton::clicked, this, &HomeWidget::switchToListWidget);
connect(sortBtn, &QPushButton::clicked, this, &HomeWidget::switchToSortWidget);
connect(planBtn, &QPushButton::clicked, this, &HomeWidget::switchToPlanWidget);
InitHomeWidget();
}
void HomeWidget::switchToRcmdWidget()
@ -117,3 +78,116 @@ HomeWidget::~HomeWidget()
{
delete ui;
}
void HomeWidget::SetBackground(QString url)
{
background->setPixmap(url);
background->setScaledContents(true);
}
void HomeWidget::InitHomeWidget()
{
background = new QLabel(this);
SetBackground("./softImages/homeWidget/homeWidgetBrownHalf.png");
QVBoxLayout * verLayout = new QVBoxLayout();
setLayout(verLayout);
verLayout->setMargin(0);
verLayout->setSpacing(0);
subWidget = new QWidget();
InitSubWidget();
subWidget->setFixedSize(1440, 140);
verLayout->addWidget(subWidget);
//默认选择显示“猜你喜欢”界面
pageIndex = 0;
rcmdWidget = new RecommendWidget(this);
verLayout->addWidget(rcmdWidget);
listWidget = new ListWidget(this);
verLayout->addWidget(listWidget);
sortWidget = new SortWidget(this);
verLayout->addWidget(sortWidget);
planWidget = new PlanWidget(this);
verLayout->addWidget(planWidget);
rcmdWidget->setVisible(true);
listWidget->setVisible(false);
sortWidget->setVisible(false);
planWidget->setVisible(false);
}
void HomeWidget::InitSubWidget()
{
QHBoxLayout * horiLayout = new QHBoxLayout();
subWidget->setLayout(horiLayout);
rcmdBtn = new QPushButton();
InitButton(rcmdBtn, "recommendBtn.jpg", "recommendBtnBlur.jpg");
horiLayout->addWidget(rcmdBtn);
listBtn = new QPushButton();
InitButton(listBtn, "listBtn.jpg", "listBtnBlur.jpg");
horiLayout->addWidget(listBtn);
sortBtn = new QPushButton();
InitButton(sortBtn, "sortBtn.jpg", "sortBtnBlur.jpg");
horiLayout->addWidget(sortBtn);
planBtn = new QPushButton();
InitButton(planBtn, "planBtn.jpg", "planBtnBlur.jpg");
horiLayout->addWidget(planBtn);
connect(rcmdBtn, &QPushButton::clicked, this, &HomeWidget::switchToRcmdWidget);
connect(listBtn, &QPushButton::clicked, this, &HomeWidget::switchToListWidget);
connect(sortBtn, &QPushButton::clicked, this, &HomeWidget::switchToSortWidget);
connect(planBtn, &QPushButton::clicked, this, &HomeWidget::switchToPlanWidget);
}
void HomeWidget::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 HomeWidget::InitButton(QPushButton * button, QString url, QString blurUrl)
{
button->setStyleSheet("QPushButton {"
"border-image: url(./softImages/homeWidget/" + blurUrl + ");"
"border-style:outset;"
"border-radius:10px;"
"min-width:100px;"
"min-height:20px;"
"padding:4px;"
"} "
"QPushButton:hover {"
"border-image: url(./softImages/homeWidget/" + url + ");"
"border-style:outset;"
"border-radius:10px;"
"min-width:100px;"
"min-height:20px;"
"padding:4px;"
"} "
"QPushButton:pressed {"
"border-image: url(./softImages/homeWidget/" + url + ");"
"border-style:outset;"
"border-radius:10px;"
"min-width:100px;"
"min-height:20px;"
"padding:4px;"
"}");
button->setFixedSize(260, 120);
}
void HomeWidget::resizeEvent(QResizeEvent *event)
{
background->resize(this->size());
}

@ -26,20 +26,30 @@ public:
explicit HomeWidget(QWidget *parent = nullptr);
~HomeWidget();
void SetBackground(QString);
void InitHomeWidget();
void InitSubWidget();
void InitLabel(QLabel *);
void InitButton(QPushButton *, QString, QString);
void resizeEvent(QResizeEvent *event);
private:
Ui::HomeWidget *ui;
QLabel * background;
//表示现在homeWidget处在哪个界面
int pageIndex;
QVBoxLayout *verLayout;
QHBoxLayout *horLayout;
QPushButton *rcmdBtn;
QPushButton *listBtn;
QPushButton *sortBtn;
QPushButton *planBtn;
QWidget * subWidget;
RecommendWidget *rcmdWidget;
ListWidget *listWidget;
SortWidget *sortWidget;

@ -60,8 +60,8 @@ ListWidget::ListWidget(QWidget *parent) :
lineList_2[0] = line_2;
lineList_3[0] = line_3;
setHotList();
//setMinorityList();
//setFavorableList();
setMinorityList();
setFavorableList();
//设置总体布局
this->setLayout(mainLayout);
@ -78,8 +78,8 @@ ListWidget::ListWidget(QWidget *parent) :
for (int i = 0; i < (listLen + 1); i++)
{
layout_1->addLayout(lineList_1[i]);
//layout_2->addLayout(lineList_2[i]);
//layout_3->addLayout(lineList_3[i]);
layout_2->addLayout(lineList_2[i]);
layout_3->addLayout(lineList_3[i]);
}
connect(web->getReturnBtn(), &QPushButton::clicked, this, &ListWidget::returnWeb);
@ -188,7 +188,7 @@ void ListWidget::setHotList()
}
void ListWidget::setMinorityList()
{
/*
QSqlQuery queryList(listDb);
QSqlQuery queryMeituan(meituanDb);
int index = 1;
@ -225,11 +225,48 @@ void ListWidget::setMinorityList()
index++;
}
*/
QSqlQuery queryList(listDb);
QSqlQuery queryMeituan(meituanDb);
int index = 1;
queryList.prepare("select * from minoritylist order by score desc");
//queryList.bindValue(":limit", listLen);
queryList.exec();
while (queryList.next() == true && index < (listLen + 1))
{
QHBoxLayout *line = new QHBoxLayout();
QLabel *rank = new QLabel(QString::number(index));
rank->setAlignment(Qt::AlignCenter);
QToolButton *btn = new QToolButton();
int id = queryList.value("id").value<int>();
QString name = queryList.value("title").value<QString>();
QString img = queryList.value("frontimg").value<QString>();
QString url = queryList.value("detail").value<QString>();
QString cate = queryList.value("cateId").value<QString>();
/*queryMeituan.prepare("select * from " + labelToDb[cate] + " where detail = :url");
// qDebug() << "类名:" << cate;
// qDebug() << "所属表名:" << labelToDb[cate];
queryMeituan.bindValue(":url", url);
QStringList list = queryMeituanDatabase(queryMeituan);//获得图片链接和店铺名和id*/
imgDownloader *imgDownload = new imgDownloader();
QString imgPath = "./images/minoritylist" + QString::number(id) + ".png";
imgDownload->downloadFileFromUrl(img, imgPath);
btn = setBtn(btn, imgPath, name);
connect(btn, &QToolButton::clicked, this, [=](){web->loadPage(name, img, url, cate); subWidget->setVisible(false); web->setVisible(true);});
line->addWidget(rank, 1);
line->addWidget(btn, 10);
lineList_2[index] = line;
index++;
}
}
void ListWidget::setFavorableList()
{
/*
QSqlQuery queryList(listDb);
QSqlQuery queryMeituan(meituanDb);
int index = 1;
@ -264,6 +301,43 @@ void ListWidget::setFavorableList()
index++;
}
*/
QSqlQuery queryList(listDb);
QSqlQuery queryMeituan(meituanDb);
int index = 1;
queryList.prepare("select * from favorablelist order by score desc");
//queryList.bindValue(":limit", listLen);
queryList.exec();
while (queryList.next() == true && index < (listLen + 1))
{
QHBoxLayout *line = new QHBoxLayout();
QLabel *rank = new QLabel(QString::number(index));
rank->setAlignment(Qt::AlignCenter);
QToolButton *btn = new QToolButton();
int id = queryList.value("id").value<int>();
QString name = queryList.value("title").value<QString>();
QString img = queryList.value("frontimg").value<QString>();
QString url = queryList.value("detail").value<QString>();
QString cate = queryList.value("cateId").value<QString>();
/*queryMeituan.prepare("select * from " + labelToDb[cate] + " where detail = :url");
// qDebug() << "类名:" << cate;
// qDebug() << "所属表名:" << labelToDb[cate];
queryMeituan.bindValue(":url", url);
QStringList list = queryMeituanDatabase(queryMeituan);//获得图片链接和店铺名和id*/
imgDownloader *imgDownload = new imgDownloader();
QString imgPath = "./images/favorablelist" + QString::number(id) + ".png";
imgDownload->downloadFileFromUrl(img, imgPath);
btn = setBtn(btn, imgPath, name);
connect(btn, &QToolButton::clicked, this, [=](){web->loadPage(name, img, url, cate); subWidget->setVisible(false); web->setVisible(true);});
line->addWidget(rank, 1);
line->addWidget(btn, 10);
lineList_3[index] = line;
index++;
}
}

@ -1,26 +1,26 @@
#include "loginmanager.h"
LoginManager::LoginManager()
{
}
bool LoginManager::loginVerify(QString account,QString password)
{
QSqlQuery query(userDb);
query.prepare("select id,password from account where email=?");
query.addBindValue(account);
query.exec();
query.next();
QString passwordget=query.value("password").toString();
Id=query.value("id").toInt();
qDebug()<< "userId:" <<Id;
if(passwordget==password)
{
return true;
}
else
{
return false;
}
}
#include "loginmanager.h"
LoginManager::LoginManager()
{
}
bool LoginManager::loginVerify(QString account,QString password)
{
QSqlQuery query(userDb);
query.prepare("select id,password from account where email=?");
query.addBindValue(account);
query.exec();
query.next();
QString passwordget=query.value("password").toString();
Id=query.value("id").toInt();
qDebug()<< "userId:" <<Id;
if(passwordget==password)
{
return true;
}
else
{
return false;
}
}

@ -1,19 +1,19 @@
#ifndef LOGINMANAGER_H
#define LOGINMANAGER_H
#include "cglobal.h"
#include <QSqlQuery>
#include <QVariant>
#include <QDebug>
class LoginManager
{
public:
LoginManager();
bool loginVerify(QString account,QString password);
private:
};
#endif // LOGINMANAGER_H
#ifndef LOGINMANAGER_H
#define LOGINMANAGER_H
#include "cglobal.h"
#include <QSqlQuery>
#include <QVariant>
#include <QDebug>
class LoginManager
{
public:
LoginManager();
bool loginVerify(QString account,QString password);
private:
};
#endif // LOGINMANAGER_H

@ -7,47 +7,7 @@ MainWidget::MainWidget(QWidget *parent) :
{
ui->setupUi(this);
verLayout = new QVBoxLayout();
horLayout = new QHBoxLayout();
homeBtn = new QPushButton("首页");
userBtn = new QPushButton("个人主页");
searchBar = new QLineEdit();
searchBtn = new QPushButton("搜索");
//首页按钮默认选中
index = 0;
//homeBtn->setStyleSheet("QPushButton{background-color: rgb(20, 62, 134);color:rgb(255, 255, 255);}");
//userBtn->setStyleSheet("QPushButton{color:rgb(255, 255, 255);}""QPushButton:hover{background-color: rgb(20, 62, 134);border:none;color:rgb(255, 255, 255);}");
homeWidget = new HomeWidget(this);
userWidget = new UserWidget(this);
searchWidget = new SearchWidget(this);
// home2user = new QPropertyAnimation(homeWidget, "geometry");
// user2home = new QPropertyAnimation(userWidget, "geometry");
this->setLayout(verLayout);
verLayout->addLayout(horLayout);
verLayout->addWidget(homeWidget);
verLayout->addWidget(userWidget);
verLayout->addWidget(searchWidget);
horLayout->addWidget(homeBtn);
horLayout->addWidget(userBtn);
horLayout->addWidget(searchBar);
horLayout->addWidget(searchBtn);
// homeWidget->setGeometry(11, 45, 1418, 727);
// userWidget->setGeometry(1440, 45, 1418, 727);
// searchWidget->setGeometry();
userWidget->setVisible(false);
searchWidget->setVisible(false);
connect(homeBtn, &QPushButton::clicked, this, &MainWidget::switchToHome);
connect(userBtn, &QPushButton::clicked, this, &MainWidget::switchToUser);
connect(searchBtn, &QPushButton::clicked, this, &MainWidget::actSearch);
connect(searchWidget->getReturnBtn(), &QPushButton::clicked, this, &MainWidget::returnSearch);
InitMainWidget();
}
void MainWidget::switchToHome()
@ -56,9 +16,9 @@ void MainWidget::switchToHome()
{
//homeBtn->setStyleSheet("QPushButton{background-color: rgb(20, 62, 134);color:rgb(255, 255, 255);}");
//userBtn->setStyleSheet("QPushButton{color:rgb(255, 255, 255);}""QPushButton:hover{background-color: rgb(20, 62, 134);border:none;color:rgb(255, 255, 255);}");
// homeWidget->setVisible(true);
// userWidget->setVisible(false);
user2homeAnimation();
homeWidget->setVisible(true);
userWidget->setVisible(false);
//user2homeAnimation();
homeWidget->setVisible(true);
userWidget->setVisible(false);
searchWidget->setVisible(false);
@ -75,11 +35,9 @@ void MainWidget::switchToUser()
{
//homeBtn->setStyleSheet("QPushButton{color:rgb(255, 255, 255);}""QPushButton:hover{background-color: rgb(20, 62, 134);border:none;color:rgb(255, 255, 255);}");
//userBtn->setStyleSheet("QPushButton{background-color: rgb(20, 62, 134);color:rgb(255, 255, 255);}");
// homeWidget->setVisible(false);
// userWidget->setVisible(true);
home2userAnimation();
// homeWidget->setVisible(false);
// userWidget->setVisible(true);
//home2userAnimation();
homeWidget->setVisible(false);
userWidget->setVisible(true);
searchWidget->setVisible(false);
searchBar->clear();
index = 1;
@ -181,3 +139,138 @@ MainWidget::~MainWidget()
{
delete ui;
}
void MainWidget::SetBackground(QString url)
{
background->setPixmap(url);
background->setScaledContents(true);
}
void MainWidget::InitMainWidget()
{
background = new QLabel(this);
SetBackground("./softImages/MainImage.jpg");
QVBoxLayout * verLayout = new QVBoxLayout();
setLayout(verLayout);
verLayout->setMargin(0);
verLayout->setSpacing(0);
firstSubWidget = new QWidget();
InitFirstSubWidget();
verLayout->addWidget(firstSubWidget);
homeWidget = new HomeWidget();
verLayout->addWidget(homeWidget);
userWidget = new UserWidget();
verLayout->addWidget(userWidget);
searchWidget = new SearchWidget();
verLayout->addWidget(searchWidget);
//首页按钮默认选中
index = 0;
userWidget->setVisible(false);
searchWidget->setVisible(false);
connect(searchWidget->getReturnBtn(), &QPushButton::clicked, this, &MainWidget::returnSearch);
}
void MainWidget::InitFirstSubWidget()
{
QHBoxLayout * horiLayout = new QHBoxLayout();
firstSubWidget->setLayout(horiLayout);
homeBtn = new QPushButton("首页");
InitButton(homeBtn);
horiLayout->addWidget(homeBtn);
userBtn = new QPushButton("个人主页");
InitButton(userBtn);
horiLayout->addWidget(userBtn);
searchBar = new QLineEdit();
InitLineEdit(searchBar);
horiLayout->addWidget(searchBar);
searchBtn = new QPushButton("搜索");
InitButton(searchBtn);
horiLayout->addWidget(searchBtn);
connect(homeBtn, &QPushButton::clicked, this, &MainWidget::switchToHome);
connect(userBtn, &QPushButton::clicked, this, &MainWidget::switchToUser);
connect(searchBtn, &QPushButton::clicked, this, &MainWidget::actSearch);
}
void MainWidget::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 MainWidget::InitButton(QPushButton * button)
{
button->setStyleSheet("QPushButton {"
"color:#ffffff;"
"background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #E1B37C, stop: 1 #E1B37C);"
"border-style:outset;"
"border-radius:10px;"
"font:bold 32px;"
"font-family: Microsoft YaHei;"
"min-width:100px;"
"min-height:20px;"
"padding:4px;"
"} "
"QPushButton:hover {"
"background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #D2AD90, stop: 1 #D2AD90);"
"border-style:outset;"
"border-radius:10px;"
"font:bold 32px;"
"font-family: Microsoft YaHei;"
"min-width:100px;"
"min-height:20px;"
"padding:4px;"
"} "
"QPushButton:pressed {"
"background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #D2AD90, stop: 1 #D2AD90);"
"border-style:outset;"
"border-radius:10px;"
"font:bold 32px;"
"font-family: Microsoft YaHei;"
"min-width:100px;"
"min-height:20px;"
"padding:4px;"
"}");
button->setFixedSize(195, 65);
}
void MainWidget::InitLineEdit(QLineEdit * lineEdit)
{
lineEdit->setStyleSheet("QLineEdit {"
" border-style:outset; "
//" border-width:4px; "
" border-radius: 4px; "
//" border-color: #C1D7F1; "
" color:#ffffff; "
" background-color: rgb(88, 128, 77, 0.4);"
"} "
" QLineEdit:focus { "
" border-style:outset; "
//" border-width:4px; "
" border-radius: 4px; "
//" border-color: #C1D7F1; "
" color:#ffffff; "
" background-color: rgb(88, 128, 77, 0.6);"
"} ");
lineEdit->setFont(QFont("Microsoft YaHei" , 24, QFont::Bold));
lineEdit->setFixedSize(640, 60);
}
void MainWidget::resizeEvent(QResizeEvent *event)
{
background->resize(this->size());
}

@ -30,22 +30,33 @@ public:
explicit MainWidget(QWidget *parent = nullptr);
~MainWidget();
void SetBackground(QString);
void InitMainWidget();
void InitFirstSubWidget();
void InitLabel(QLabel *);
void InitButton(QPushButton *);
void InitLineEdit(QLineEdit *);
void resizeEvent(QResizeEvent *event);
void home2userAnimation();
void user2homeAnimation();
private:
Ui::MainWidget *ui;
int index;
QLabel * background;
QVBoxLayout *verLayout;
int index;
QHBoxLayout *horLayout;
QPushButton *homeBtn;
QPushButton *userBtn;
QLineEdit *searchBar;
QPushButton *searchBtn;
QWidget * firstSubWidget;
HomeWidget *homeWidget;
UserWidget *userWidget;
SearchWidget *searchWidget;

@ -1,243 +1,258 @@
#include "popwidget.h"
#include "ui_popwidget.h"
PopWidget::PopWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::PopWidget)
{
ui->setupUi(this);
this->setWindowModality(Qt::ApplicationModal);
this->setFixedSize(QSize(400,810));
this->setWindowTitle("请选择...");
chosen.append("");
chosen.append("");
chosen.append("");
showLimit = 15;
currentPage = 1;
offset = 0;
btnList = (QToolButton **)malloc(sizeof(QToolButton *) * showLimit);
mainLayout = new QVBoxLayout();
notify = new QLabel("请从您的收藏夹中选择场所添加到路线中");
notify->setAlignment(Qt::AlignCenter);
searchLine = new QHBoxLayout();
searchBar = new QLineEdit();
searchBtn = new QPushButton("搜索");
returnSearchBtn = new QPushButton("退出搜索");
scroll = new QScrollArea();
scrollWidget = new QWidget;
scrollLayout = new QVBoxLayout();
pageLine = new QHBoxLayout();
up = new QPushButton("上一页");
down = new QPushButton("下一页");
chosenLabel = new QLabel("您还未选择场所...");
chosenLabel->setAlignment(Qt::AlignLeft);
closeLine = new QHBoxLayout();
confirm = new QPushButton("确认");
cancel = new QPushButton("取消");
this->setLayout(mainLayout);
mainLayout->addWidget(notify);
mainLayout->addLayout(searchLine);
mainLayout->addWidget(scroll);
mainLayout->addLayout(pageLine);
mainLayout->addWidget(chosenLabel);
mainLayout->addLayout(closeLine);
searchLine->addWidget(searchBar, 6);
searchLine->addWidget(searchBtn, 1);
// scrollWidget->setLayout(scrollLayout);
// //查询数据库,进行按钮布局
// scroll->setWidget(scrollWidget);
getTotalNum();
setScreen();
pageLine->addWidget(up);
pageLine->addWidget(down);
closeLine->addWidget(confirm);
closeLine->addWidget(cancel);
connect(up, &QPushButton::clicked, this, &PopWidget::pageUp);
connect(down, &QPushButton::clicked, this, &PopWidget::pageDown);
}
PopWidget::~PopWidget()
{
delete ui;
}
QPushButton * PopWidget::getConfirmBtn()
{
return confirm;
}
QPushButton * PopWidget::getCancelBtn()
{
return cancel;
}
//从店铺收藏夹获取店铺
void PopWidget::getTotalNum()
{
//查询条目数
QSqlQuery query(userDb);
query.prepare("select count(*) as num from favPlaces where userId = :id");
query.bindValue(":id", Id);
query.exec();
query.next();
qDebug() << " popWidget totalNum:" << query.value("num");
totalNum = query.value("num").value<qlonglong>();
pageNum = (totalNum + showLimit - 1)/showLimit;
}
void PopWidget::queryDatabase()
{
QSqlQuery query(userDb);
query.prepare("select * from favPlaces where userId = :id limit :offset, :limit");
query.bindValue(":id", Id);
query.bindValue(":offset", offset);
query.bindValue(":limit", showLimit);
query.exec();
int i = 0;
while(query.next()==true)
{
QVariant detail = query.value("url");
urlList.append(detail.value<QString>());
i++;
}
currentNum = i;
qDebug() << "popWidget currentNum:" << currentNum;
}
QToolButton * PopWidget::setBtn(QToolButton *btn, QString text, QString img)
{
if(img != "")
btn->setIcon(QIcon(img));
btn->setText(text);
btn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
btn->setIconSize(QSize(100,200));
btn->setFixedSize(300,100);
return btn;
}
void PopWidget::setBtns()
{
int i = 0;
for (i; i < currentNum; i++)
{
int index = i;
//下载图片到本地
// QString imgPath = "D:/Study/SE/project/images/" + cateList[currentCate] + QString::number(idList[index]) + ".png";
// imgDownloader *download = new imgDownloader();
// download->downloadFileFromUrl(imgList[index], imgPath);
btnList[index] = setBtn(btnList[index], urlList[index], "D:/Study/SE/project/images/transparent.png");
disconnect(btnList[index], 0, 0, 0);
connect(btnList[index], &QToolButton::clicked, this, [=](){setChosen(index);});
}
}
void PopWidget::setChosen(int index)
{
if (urlList[index] != chosen[1])
{
// chosen[0] = nameList[index];
chosen[1] = urlList[index];
// chosen[2] = imgList[index];
qDebug() << "popWidget chosen:" + chosen[0] + chosen[1] + chosen[2];
chosenLabel->setText("您选择了" + chosen[1]);
}
else
{
chosen[0] = "";
chosen[1] = "";
chosen[2] = "";
chosenLabel->setText("您还未选择场所...");
}
}
void PopWidget::setScreen()
{
qDebug() << "popWidget currentPage:" << currentPage;
qDebug() << "popWidget offset:" << offset;
urlList.clear();
imgList.clear();
nameList.clear();
for (int i = 0; i < showLimit; i++)
btnList[i] = new QToolButton();
queryDatabase();
qDebug("query success");
setBtns();
qDebug("setBtns success");
scroll->takeWidget();
scrollWidget->deleteLater();
scrollWidget = new QWidget();
scrollLayout->deleteLater();
scrollLayout = new QVBoxLayout();
scrollWidget->setLayout(scrollLayout);
for (int i = 0; i < currentNum; i++)
{
scrollLayout->addWidget(btnList[i]);
}
scroll->setWidget(scrollWidget);
}
void PopWidget::pageUp()
{
currentPage--;
if (currentPage < 1)
{
currentPage = 1;
qDebug("这是第一页");
}
else
{
offset -= showLimit;
rollTop();
setScreen();
}
}
void PopWidget::pageDown()
{
currentPage++;
if (currentPage > pageNum)
{
currentPage = pageNum;
qDebug("已经是最后一页了!");
}
else
{
offset += showLimit;
rollTop();
setScreen();
}
}
void PopWidget::rollTop()
{
QScrollBar *scrollBar = scroll->verticalScrollBar();
scrollBar->setValue(scrollBar->minimum());
}
#include "popwidget.h"
#include "ui_popwidget.h"
PopWidget::PopWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::PopWidget)
{
ui->setupUi(this);
this->setWindowModality(Qt::ApplicationModal);
this->setFixedSize(QSize(400,810));
this->setWindowTitle("请选择...");
chosen.append("");
chosen.append("");
chosen.append("");
showLimit = 15;
currentPage = 1;
offset = 0;
btnList = (QToolButton **)malloc(sizeof(QToolButton *) * showLimit);
idList = (int *)malloc(sizeof(int) * showLimit);
mainLayout = new QVBoxLayout();
notify = new QLabel("请从您的收藏夹中选择场所添加到路线中");
notify->setAlignment(Qt::AlignCenter);
searchLine = new QHBoxLayout();
searchBar = new QLineEdit();
searchBtn = new QPushButton("搜索");
returnSearchBtn = new QPushButton("退出搜索");
scroll = new QScrollArea();
scrollWidget = new QWidget;
scrollLayout = new QVBoxLayout();
pageLine = new QHBoxLayout();
up = new QPushButton("上一页");
down = new QPushButton("下一页");
chosenLabel = new QLabel("您还未选择场所...");
chosenLabel->setAlignment(Qt::AlignLeft);
closeLine = new QHBoxLayout();
confirm = new QPushButton("确认");
cancel = new QPushButton("取消");
this->setLayout(mainLayout);
mainLayout->addWidget(notify);
mainLayout->addLayout(searchLine);
mainLayout->addWidget(scroll);
mainLayout->addLayout(pageLine);
mainLayout->addWidget(chosenLabel);
mainLayout->addLayout(closeLine);
searchLine->addWidget(searchBar, 6);
searchLine->addWidget(searchBtn, 1);
// scrollWidget->setLayout(scrollLayout);
// //查询数据库,进行按钮布局
// scroll->setWidget(scrollWidget);
getTotalNum();
setScreen();
pageLine->addWidget(up);
pageLine->addWidget(down);
closeLine->addWidget(confirm);
closeLine->addWidget(cancel);
connect(up, &QPushButton::clicked, this, &PopWidget::pageUp);
connect(down, &QPushButton::clicked, this, &PopWidget::pageDown);
}
PopWidget::~PopWidget()
{
delete ui;
}
QPushButton * PopWidget::getConfirmBtn()
{
return confirm;
}
QPushButton * PopWidget::getCancelBtn()
{
return cancel;
}
//从店铺收藏夹获取店铺
void PopWidget::getTotalNum()
{
//查询条目数
QSqlQuery query(userDb);
query.prepare("select count(*) as num from favPlaces where userId = :id");
query.bindValue(":id", Id);
query.exec();
query.next();
qDebug() << " popWidget totalNum:" << query.value("num");
totalNum = query.value("num").value<qlonglong>();
pageNum = (totalNum + showLimit - 1)/showLimit;
}
void PopWidget::queryDatabase()
{
QSqlQuery query(userDb);
query.prepare("select * from favPlaces where userId = :id limit :offset, :limit");
query.bindValue(":id", Id);
query.bindValue(":offset", offset);
query.bindValue(":limit", showLimit);
query.exec();
int i = 0;
while(query.next()==true)
{
QVariant favPlaceId = query.value("favPlaceId");
QVariant title = query.value("title");
QVariant detail = query.value("detail");
QVariant frontimg = query.value("frontimg");
QVariant cateId = query.value("cateId");
idList[i] = (int)favPlaceId.value<qlonglong>();
nameList.append(title.value<QString>());
urlList.append(detail.value<QString>());
imgList.append(frontimg.value<QString>());
cateList.append(cateId.value<QString>());
i++;
}
currentNum = i;
qDebug() << "popWidget currentNum:" << currentNum;
}
QToolButton * PopWidget::setBtn(QToolButton *btn, QString text, QString img)
{
if(img != "")
btn->setIcon(QIcon(img));
btn->setText(text);
btn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
btn->setIconSize(QSize(100,200));
btn->setFixedSize(300,100);
return btn;
}
void PopWidget::setBtns()
{
int i = 0;
for (i; i < currentNum; i++)
{
int index = i;
//下载图片到本地
QString imgPath = "./images/fav" + QString::number(Id) + "_" + QString::number(idList[index]) + ".png";
imgDownloader *download = new imgDownloader();
download->downloadFileFromUrl(imgList[index], imgPath);
btnList[index] = setBtn(btnList[index], nameList[index], imgPath);
disconnect(btnList[index], 0, 0, 0);
connect(btnList[index], &QToolButton::clicked, this, [=](){setChosen(index);});
}
}
void PopWidget::setChosen(int index)
{
if (urlList[index] != chosen[1])
{
chosen[0] = nameList[index];
chosen[1] = urlList[index];
chosen[2] = cateList[index];
qDebug() << "popWidget chosen:" + chosen[0] + chosen[1] + chosen[2];
chosenLabel->setText("您选择了" + chosen[0]);
}
else
{
chosen[0] = "";
chosen[1] = "";
chosen[2] = "";
chosenLabel->setText("您还未选择场所...");
}
}
void PopWidget::setScreen()
{
qDebug() << "popWidget currentPage:" << currentPage;
qDebug() << "popWidget offset:" << offset;
urlList.clear();
imgList.clear();
nameList.clear();
cateList.clear();
for (int i = 0; i < showLimit; i++)
btnList[i] = new QToolButton();
queryDatabase();
qDebug("query success");
setBtns();
qDebug("setBtns success");
scroll->takeWidget();
scrollWidget->deleteLater();
scrollWidget = new QWidget();
scrollLayout->deleteLater();
scrollLayout = new QVBoxLayout();
scrollWidget->setLayout(scrollLayout);
for (int i = 0; i < currentNum; i++)
{
scrollLayout->addWidget(btnList[i]);
}
scroll->setWidget(scrollWidget);
}
void PopWidget::pageUp()
{
currentPage--;
if (currentPage < 1)
{
currentPage = 1;
qDebug("这是第一页");
}
else
{
offset -= showLimit;
rollTop();
setScreen();
}
}
void PopWidget::pageDown()
{
currentPage++;
if (currentPage > pageNum)
{
currentPage = pageNum;
qDebug("已经是最后一页了!");
}
else
{
offset += showLimit;
rollTop();
setScreen();
}
}
void PopWidget::rollTop()
{
QScrollBar *scrollBar = scroll->verticalScrollBar();
scrollBar->setValue(scrollBar->minimum());
}
QStringList PopWidget::getChosen()
{
return chosen;
}

@ -1,86 +1,90 @@
#ifndef POPWIDGET_H
#define POPWIDGET_H
#include <QWidget>
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLineEdit>
#include <QLabel>
#include <QScrollArea>
#include <QSqlQuery>
#include <QDebug>
#include <QToolButton>
#include <QIcon>
#include <QScrollBar>
#include "cglobal.h"
#if _MSC_VER >= 1600
#pragma execution_character_set("utf-8")
#endif
namespace Ui {
class PopWidget;
}
class PopWidget : public QWidget
{
Q_OBJECT
public:
explicit PopWidget(QWidget *parent = nullptr);
~PopWidget();
QPushButton * getConfirmBtn();
QPushButton * getCancelBtn();
void getTotalNum();
void queryDatabase();
void pageUp();
void pageDown();
void setScreen();
void setBtns();
QToolButton * setBtn(QToolButton *btn, QString text, QString img);
void setChosen(int index);
void rollTop();
private:
Ui::PopWidget *ui;
bool inSearch;
QStringList chosen;//被选中的场所在当,有三个值name,url,img
int totalNum;//收藏夹总共有多少条
int showLimit;//一页中最多显示条数
int pageNum;//总页数
int currentPage;//当前所在页数
int currentNum;//当前页中条目数量
int offset;//query语句中的偏移量
QStringList nameList;
QStringList urlList;
QStringList imgList;
QToolButton **btnList;
QVBoxLayout *mainLayout;
QLabel *notify;
QHBoxLayout *searchLine;
QLineEdit *searchBar;
QPushButton *searchBtn;
QPushButton *returnSearchBtn;
QScrollArea *scroll;
QWidget *scrollWidget;
QVBoxLayout *scrollLayout;
QHBoxLayout *pageLine;
QPushButton *up;
QPushButton *down;
QLabel *chosenLabel;
QHBoxLayout *closeLine;
QPushButton *confirm;
QPushButton *cancel;
};
#endif // POPWIDGET_H
#ifndef POPWIDGET_H
#define POPWIDGET_H
#include <QWidget>
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLineEdit>
#include <QLabel>
#include <QScrollArea>
#include <QSqlQuery>
#include <QDebug>
#include <QToolButton>
#include <QIcon>
#include <QScrollBar>
#include "cglobal.h"
#include "imgdownloader.h"
#if _MSC_VER >= 1600
#pragma execution_character_set("utf-8")
#endif
namespace Ui {
class PopWidget;
}
class PopWidget : public QWidget
{
Q_OBJECT
public:
explicit PopWidget(QWidget *parent = nullptr);
~PopWidget();
QPushButton * getConfirmBtn();
QPushButton * getCancelBtn();
void getTotalNum();
void queryDatabase();
void pageUp();
void pageDown();
void setScreen();
void setBtns();
QToolButton * setBtn(QToolButton *btn, QString text, QString img);
void setChosen(int index);
void rollTop();
QStringList getChosen();
private:
Ui::PopWidget *ui;
bool inSearch;
QStringList chosen;//被选中的场所在当,有三个值name,url,cateId
int totalNum;//收藏夹总共有多少条
int showLimit;//一页中最多显示条数
int pageNum;//总页数
int currentPage;//当前所在页数
int currentNum;//当前页中条目数量
int offset;//query语句中的偏移量
QStringList nameList;
QStringList urlList;
QStringList imgList;
QToolButton **btnList;
int *idList;
QStringList cateList;
QVBoxLayout *mainLayout;
QLabel *notify;
QHBoxLayout *searchLine;
QLineEdit *searchBar;
QPushButton *searchBtn;
QPushButton *returnSearchBtn;
QScrollArea *scroll;
QWidget *scrollWidget;
QVBoxLayout *scrollLayout;
QHBoxLayout *pageLine;
QPushButton *up;
QPushButton *down;
QLabel *chosenLabel;
QHBoxLayout *closeLine;
QPushButton *confirm;
QPushButton *cancel;
};
#endif // POPWIDGET_H

@ -1,21 +1,21 @@
<ui version="4.0">
<author/>
<comment/>
<exportmacro/>
<class>PopWidget</class>
<widget class="QWidget" name="PopWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
</widget>
<pixmapfunction/>
<connections/>
</ui>
<ui version="4.0">
<author/>
<comment/>
<exportmacro/>
<class>PopWidget</class>
<widget class="QWidget" name="PopWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
</widget>
<pixmapfunction/>
<connections/>
</ui>

Before

Width:  |  Height:  |  Size: 182 B

After

Width:  |  Height:  |  Size: 182 B

Before

Width:  |  Height:  |  Size: 222 B

After

Width:  |  Height:  |  Size: 222 B

Before

Width:  |  Height:  |  Size: 221 B

After

Width:  |  Height:  |  Size: 221 B

Before

Width:  |  Height:  |  Size: 178 B

After

Width:  |  Height:  |  Size: 178 B

Before

Width:  |  Height:  |  Size: 169 B

After

Width:  |  Height:  |  Size: 169 B

Before

Width:  |  Height:  |  Size: 274 B

After

Width:  |  Height:  |  Size: 274 B

Before

Width:  |  Height:  |  Size: 386 B

After

Width:  |  Height:  |  Size: 386 B

Before

Width:  |  Height:  |  Size: 355 B

After

Width:  |  Height:  |  Size: 355 B

Before

Width:  |  Height:  |  Size: 304 B

After

Width:  |  Height:  |  Size: 304 B

Before

Width:  |  Height:  |  Size: 316 B

After

Width:  |  Height:  |  Size: 316 B

Before

Width:  |  Height:  |  Size: 187 B

After

Width:  |  Height:  |  Size: 187 B

Before

Width:  |  Height:  |  Size: 219 B

After

Width:  |  Height:  |  Size: 219 B

Before

Width:  |  Height:  |  Size: 135 B

After

Width:  |  Height:  |  Size: 135 B

Before

Width:  |  Height:  |  Size: 137 B

After

Width:  |  Height:  |  Size: 137 B

Before

Width:  |  Height:  |  Size: 680 B

After

Width:  |  Height:  |  Size: 680 B

Before

Width:  |  Height:  |  Size: 843 B

After

Width:  |  Height:  |  Size: 843 B

Before

Width:  |  Height:  |  Size: 520 B

After

Width:  |  Height:  |  Size: 520 B

Before

Width:  |  Height:  |  Size: 615 B

After

Width:  |  Height:  |  Size: 615 B

@ -58,7 +58,7 @@ RecommendWidget::RecommendWidget(QWidget *parent) :
subVerLayout->addLayout(lineList[i]);
}
funcLine->addWidget(refreshBtn);
//funcLine->addWidget(refreshBtn);
for (int i = 0; i < row; i++)
{
for (int j = 0; j <column; j++)

@ -1,203 +1,202 @@
#include "registerwidget.h"
#include "ui_registerwidget.h"
#include <QDir>
RegisterWidget::RegisterWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::RegisterWidget)
{
ui->setupUi(this);
background = new QLabel(this);
subWidget = new QWidget(this);
qDebug() << QDir::currentPath();
InitRegisterWidget();
}
QPushButton * RegisterWidget::getGetVerificationCodeButton()
{
return getVerificationCodeButon;
}
QPushButton * RegisterWidget::getConfirmButton()
{
return confirmButton;
}
QPushButton * RegisterWidget::getCancelButton()
{
return cancelButton;
}
QString RegisterWidget::getEmailAddress()
{
return emailAddressLineEdit->text();
}
QString RegisterWidget::getPassword()
{
return passwordLineEdit->text();
}
QString RegisterWidget::getConfirmPassword()
{
return confirmPasswordLineEdit->text();
}
QString RegisterWidget::getVerificationCode()
{
return verificationCodeLineEdit->text();
}
void RegisterWidget::setEmailAddressNotEditable()
{
emailAddressLineEdit->setEnabled(false);
}
RegisterWidget::~RegisterWidget()
{
delete ui;
}
void RegisterWidget::SetBackground(QString url)
{
background->setPixmap(url);
background->setScaledContents(true);
}
void RegisterWidget::InitRegisterWidget()
{
SetBackground("./softImages/RegisterImage.jpg");
InitSubWidget();
}
void RegisterWidget::SetSubWidgetBackground(QString url)
{
subBackGround->setPixmap(url);
subBackGround->setScaledContents(true);
}
void RegisterWidget::InitSubWidget()
{
QGridLayout * gridLayout = new QGridLayout();
subWidget->setLayout(gridLayout);
subBackGround = new QLabel(subWidget);
SetSubWidgetBackground("F:/QtDemo/StylesheetExercise/images/blackHalf.png");
QLabel * emailLabel = new QLabel("用户邮箱: ");
QLabel * passwordLabel = new QLabel("用户密码: ");
QLabel * confirmLabel = new QLabel("确认密码: ");
QLabel * verifyLabel = new QLabel("验证码: ");
InitLabel(emailLabel);
InitLabel(passwordLabel);
InitLabel(confirmLabel);
InitLabel(verifyLabel);
gridLayout->addWidget(emailLabel, 0, 0, 1, 1);
gridLayout->addWidget(passwordLabel, 1, 0, 1, 1);
gridLayout->addWidget(confirmLabel, 2, 0, 1, 1);
gridLayout->addWidget(verifyLabel, 3, 0, 1, 1);
emailAddressLineEdit = new QLineEdit();
passwordLineEdit = new QLineEdit();
confirmPasswordLineEdit = new QLineEdit();
verificationCodeLineEdit = new QLineEdit();
InitLineEdit(emailAddressLineEdit);
emailAddressLineEdit->setPlaceholderText("请输入qq邮箱地址或163邮箱地址");
InitLineEdit(passwordLineEdit);
passwordLineEdit->setPlaceholderText("请输入长度为6~12位的密码");
passwordLineEdit->setEchoMode(QLineEdit::Password);
InitLineEdit(confirmPasswordLineEdit);
confirmPasswordLineEdit->setEchoMode(QLineEdit::Password);
InitLineEdit(verificationCodeLineEdit);
gridLayout->addWidget(emailAddressLineEdit, 0, 1, 1, 1);
gridLayout->addWidget(passwordLineEdit, 1, 1, 1, 1);
gridLayout->addWidget(confirmPasswordLineEdit, 2, 1, 1, 1);
gridLayout->addWidget(verificationCodeLineEdit, 3, 1, 1, 1);
getVerificationCodeButon = new QPushButton("获取验证码");
InitButton(getVerificationCodeButon);
gridLayout->addWidget(getVerificationCodeButon, 3, 2, 1, 1);
QHBoxLayout * horiLayout = new QHBoxLayout();
gridLayout->addLayout(horiLayout, 4, 1, 1, 1);
confirmButton = new QPushButton("确认");
InitButton(confirmButton);
horiLayout->addWidget(confirmButton);
cancelButton = new QPushButton("取消");
InitButton(cancelButton);
horiLayout->addWidget(cancelButton);
}
void RegisterWidget::InitLabel(QLabel * label)
{
QFont lbl_font("Microsoft YaHei");
lbl_font.setPointSize(20);
lbl_font.setBold(true);
label->setFont(lbl_font);
label->setStyleSheet("color:#FFFFFF");
label->setAlignment(Qt::AlignRight);
}
void RegisterWidget::InitButton(QPushButton * button)
{
button->setStyleSheet("QPushButton {"
"color:#ffffff;"
"background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #8CA8CC, stop: 1 #8CA8CC);"
"border-style:outset;"
"border-radius:10px;"
"font:bold 20px;"
"font-family: Microsoft YaHei;"
"min-width:100px;"
"min-height:20px;"
"padding:4px;"
"} "
"QPushButton:hover {"
"background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #6E8AB2, stop: 1 #6E8AB2);"
"border-style:outset;"
"border-radius:10px;"
"font:bold 20px;"
"font-family: Microsoft YaHei;"
"min-width:100px;"
"min-height:20px;"
"padding:4px;"
"} "
"QPushButton:pressed {"
"background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #6783AB, stop: 1 #6783AB);"
"border-style:outset;"
"border-radius:10px;"
"font:bold 20px;"
"font-family: Microsoft YaHei;"
"min-width:100px;"
"min-height:20px;"
"padding:4px;"
"}");
}
void RegisterWidget::InitLineEdit(QLineEdit * lineEdit)
{
lineEdit->setStyleSheet("QLineEdit {"
" border-radius: 4px; "
" color:rgb(0, 0, 0); "
" background-color: rgb(255, 255, 255);"
"} "
" QLineEdit:focus { "
" border-style:outset; "
//" border-width:4px; "
" border-radius: 4px; "
//" border-color: #C1D7F1; "
" color:#ffffff; "
" background-color: #C1D7F1;"
"} ");
lineEdit->setFont(QFont("Microsoft YaHei" , 14, QFont::Bold));
}
void RegisterWidget::resizeEvent(QResizeEvent *event)
{
background->resize(this->size());
subWidget->resize(this->size());
subBackGround->resize(subWidget->size());
}
#include "registerwidget.h"
#include "ui_registerwidget.h"
#include <QDir>
RegisterWidget::RegisterWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::RegisterWidget)
{
ui->setupUi(this);
background = new QLabel(this);
subWidget = new QWidget(this);
InitRegisterWidget();
}
QPushButton * RegisterWidget::getGetVerificationCodeButton()
{
return getVerificationCodeButon;
}
QPushButton * RegisterWidget::getConfirmButton()
{
return confirmButton;
}
QPushButton * RegisterWidget::getCancelButton()
{
return cancelButton;
}
QString RegisterWidget::getEmailAddress()
{
return emailAddressLineEdit->text();
}
QString RegisterWidget::getPassword()
{
return passwordLineEdit->text();
}
QString RegisterWidget::getConfirmPassword()
{
return confirmPasswordLineEdit->text();
}
QString RegisterWidget::getVerificationCode()
{
return verificationCodeLineEdit->text();
}
void RegisterWidget::setEmailAddressNotEditable()
{
emailAddressLineEdit->setEnabled(false);
}
RegisterWidget::~RegisterWidget()
{
delete ui;
}
void RegisterWidget::SetBackground(QString url)
{
background->setPixmap(url);
background->setScaledContents(true);
}
void RegisterWidget::InitRegisterWidget()
{
SetBackground("./softImages/RegisterImage.jpg");
InitSubWidget();
}
void RegisterWidget::SetSubWidgetBackground(QString url)
{
subBackGround->setPixmap(url);
subBackGround->setScaledContents(true);
}
void RegisterWidget::InitSubWidget()
{
QGridLayout * gridLayout = new QGridLayout();
subWidget->setLayout(gridLayout);
subBackGround = new QLabel(subWidget);
SetSubWidgetBackground("F:/QtDemo/StylesheetExercise/images/blackHalf.png");
QLabel * emailLabel = new QLabel("用户邮箱: ");
QLabel * passwordLabel = new QLabel("用户密码: ");
QLabel * confirmLabel = new QLabel("确认密码: ");
QLabel * verifyLabel = new QLabel("验证码: ");
InitLabel(emailLabel);
InitLabel(passwordLabel);
InitLabel(confirmLabel);
InitLabel(verifyLabel);
gridLayout->addWidget(emailLabel, 0, 0, 1, 1);
gridLayout->addWidget(passwordLabel, 1, 0, 1, 1);
gridLayout->addWidget(confirmLabel, 2, 0, 1, 1);
gridLayout->addWidget(verifyLabel, 3, 0, 1, 1);
emailAddressLineEdit = new QLineEdit();
passwordLineEdit = new QLineEdit();
confirmPasswordLineEdit = new QLineEdit();
verificationCodeLineEdit = new QLineEdit();
InitLineEdit(emailAddressLineEdit);
emailAddressLineEdit->setPlaceholderText("请输入qq邮箱地址或163邮箱地址");
InitLineEdit(passwordLineEdit);
passwordLineEdit->setPlaceholderText("请输入长度为6~12位的密码");
passwordLineEdit->setEchoMode(QLineEdit::Password);
InitLineEdit(confirmPasswordLineEdit);
confirmPasswordLineEdit->setEchoMode(QLineEdit::Password);
InitLineEdit(verificationCodeLineEdit);
gridLayout->addWidget(emailAddressLineEdit, 0, 1, 1, 1);
gridLayout->addWidget(passwordLineEdit, 1, 1, 1, 1);
gridLayout->addWidget(confirmPasswordLineEdit, 2, 1, 1, 1);
gridLayout->addWidget(verificationCodeLineEdit, 3, 1, 1, 1);
getVerificationCodeButon = new QPushButton("获取验证码");
InitButton(getVerificationCodeButon);
gridLayout->addWidget(getVerificationCodeButon, 3, 2, 1, 1);
QHBoxLayout * horiLayout = new QHBoxLayout();
gridLayout->addLayout(horiLayout, 4, 1, 1, 1);
confirmButton = new QPushButton("确认");
InitButton(confirmButton);
horiLayout->addWidget(confirmButton);
cancelButton = new QPushButton("取消");
InitButton(cancelButton);
horiLayout->addWidget(cancelButton);
}
void RegisterWidget::InitLabel(QLabel * label)
{
QFont lbl_font("Microsoft YaHei");
lbl_font.setPointSize(20);
lbl_font.setBold(true);
label->setFont(lbl_font);
label->setStyleSheet("color:#FFFFFF");
label->setAlignment(Qt::AlignRight);
}
void RegisterWidget::InitButton(QPushButton * button)
{
button->setStyleSheet("QPushButton {"
"color:#ffffff;"
"background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #8CA8CC, stop: 1 #8CA8CC);"
"border-style:outset;"
"border-radius:10px;"
"font:bold 20px;"
"font-family: Microsoft YaHei;"
"min-width:100px;"
"min-height:20px;"
"padding:4px;"
"} "
"QPushButton:hover {"
"background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #6E8AB2, stop: 1 #6E8AB2);"
"border-style:outset;"
"border-radius:10px;"
"font:bold 20px;"
"font-family: Microsoft YaHei;"
"min-width:100px;"
"min-height:20px;"
"padding:4px;"
"} "
"QPushButton:pressed {"
"background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #6783AB, stop: 1 #6783AB);"
"border-style:outset;"
"border-radius:10px;"
"font:bold 20px;"
"font-family: Microsoft YaHei;"
"min-width:100px;"
"min-height:20px;"
"padding:4px;"
"}");
}
void RegisterWidget::InitLineEdit(QLineEdit * lineEdit)
{
lineEdit->setStyleSheet("QLineEdit {"
" border-radius: 4px; "
" color:rgb(0, 0, 0); "
" background-color: rgb(255, 255, 255);"
"} "
" QLineEdit:focus { "
" border-style:outset; "
//" border-width:4px; "
" border-radius: 4px; "
//" border-color: #C1D7F1; "
" color:#ffffff; "
" background-color: #C1D7F1;"
"} ");
lineEdit->setFont(QFont("Microsoft YaHei" , 14, QFont::Bold));
}
void RegisterWidget::resizeEvent(QResizeEvent *event)
{
background->resize(this->size());
subWidget->resize(this->size());
subBackGround->resize(subWidget->size());
}

@ -1,68 +1,68 @@
#ifndef REGISTERWIDGET_H
#define REGISTERWIDGET_H
#include <QWidget>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include "registermanager.h"
#if _MSC_VER >= 1600
#pragma execution_character_set("utf-8")
#endif
namespace Ui {
class RegisterWidget;
}
class RegisterWidget : public QWidget
{
Q_OBJECT
public:
explicit RegisterWidget(QWidget *parent = nullptr);
~RegisterWidget();
void SetBackground(QString);
void InitRegisterWidget();
void SetSubWidgetBackground(QString);
void InitSubWidget();
void InitLabel(QLabel *);
void InitButton(QPushButton *);
void InitLineEdit(QLineEdit *);
void resizeEvent(QResizeEvent * event);
QPushButton * getGetVerificationCodeButton();
QPushButton * getConfirmButton();
QPushButton * getCancelButton();
QString getEmailAddress();
QString getPassword();
QString getConfirmPassword();
QString getVerificationCode();
void setEmailAddressNotEditable();
private:
Ui::RegisterWidget *ui;
QLabel * background;
QLabel * subBackGround;
QWidget * subWidget;
QLineEdit * emailAddressLineEdit;
QLineEdit * passwordLineEdit;
QLineEdit * confirmPasswordLineEdit;
QLineEdit * verificationCodeLineEdit;
QPushButton * getVerificationCodeButon;
QPushButton * confirmButton;
QPushButton * cancelButton;
};
#endif // REGISTERWIDGET_H
#ifndef REGISTERWIDGET_H
#define REGISTERWIDGET_H
#include <QWidget>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include "registermanager.h"
#if _MSC_VER >= 1600
#pragma execution_character_set("utf-8")
#endif
namespace Ui {
class RegisterWidget;
}
class RegisterWidget : public QWidget
{
Q_OBJECT
public:
explicit RegisterWidget(QWidget *parent = nullptr);
~RegisterWidget();
void SetBackground(QString);
void InitRegisterWidget();
void SetSubWidgetBackground(QString);
void InitSubWidget();
void InitLabel(QLabel *);
void InitButton(QPushButton *);
void InitLineEdit(QLineEdit *);
void resizeEvent(QResizeEvent * event);
QPushButton * getGetVerificationCodeButton();
QPushButton * getConfirmButton();
QPushButton * getCancelButton();
QString getEmailAddress();
QString getPassword();
QString getConfirmPassword();
QString getVerificationCode();
void setEmailAddressNotEditable();
private:
Ui::RegisterWidget *ui;
QLabel * background;
QLabel * subBackGround;
QWidget * subWidget;
QLineEdit * emailAddressLineEdit;
QLineEdit * passwordLineEdit;
QLineEdit * confirmPasswordLineEdit;
QLineEdit * verificationCodeLineEdit;
QPushButton * getVerificationCodeButon;
QPushButton * confirmButton;
QPushButton * cancelButton;
};
#endif // REGISTERWIDGET_H

@ -1,21 +1,21 @@
<ui version="4.0">
<author/>
<comment/>
<exportmacro/>
<class>RegisterWidget</class>
<widget name="RegisterWidget" class="QWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
</widget>
<pixmapfunction/>
<connections/>
</ui>
<ui version="4.0">
<author/>
<comment/>
<exportmacro/>
<class>RegisterWidget</class>
<widget name="RegisterWidget" class="QWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
</widget>
<pixmapfunction/>
<connections/>
</ui>

@ -1,97 +1,97 @@
#include "route.h"
#include <QDebug>
Route::Route()
{
routeItems=new RouteItem;
routeItems->next=NULL;
}
//route结构体使用方式和query类似
//Route * oneRoute = getAllItems();
//while (oneRoute->next!=NULL)
//{
// oneRoute=oneRoute->next;
// url=oneRoute->url;
//}
RouteItem * Route::getAllItems()
{
return this->routeItems;
}
int Route::getRouteId()
{
return this->routeId;
}
QString Route::getRouteName()
{
return this->routeName;
}
int Route::getUserId()
{
return this->userId;
}
void Route::setRouteName(QString name)
{
this->routeName = name;
return;
}
void Route::setUserId(int id)
{
this->userId=id;
}
void Route::setRouteId(int id)
{
this->routeId=id;
}
void Route::setAllItems(QStringList titleList,QStringList urlList,QStringList cateIdList,QDateTime * startTimeList,QDateTime * endTimeList,QStringList trafficList,double * distanceList,double * timeCostList,QStringList descriptionList)
{
RouteItem * head= routeItems;
RouteItem * p;
int totalSize=titleList.size();
int i;
for(i=0;i<totalSize;i++)
{
p=new RouteItem;
p->placeName = titleList[i];
p->url = urlList[i];
p->cateId = cateIdList[i];
p->startTime = startTimeList[i];
p->endTime = endTimeList[i];
p->traffic = trafficList[i];
p->distance = distanceList[i];
p->timeCost = timeCostList[i];
p->description = descriptionList[i];
p->next = NULL;
head->next = p;
head=head->next;
}
}
//删除和添加都是根据位置位置从1开始计数
RouteItem * Route::addItem(RouteItem * oneItem,int locate)
{
RouteItem * p = routeItems;
int i = 0;
while(p->next != NULL&&i<locate)
{
p = p->next;
i++;
}
oneItem->next = p->next;
p->next=oneItem;
return routeItems;
}
RouteItem * Route::deleteItem(int locate)
{
RouteItem * p = routeItems;
RouteItem * pre = routeItems;
int i = 0;
while(p->next != NULL&&i<locate)
{
pre = p;
p = p->next;
i++;
}
pre->next = p->next;
free(p);
return routeItems;
}
#include "route.h"
#include <QDebug>
Route::Route()
{
routeItems=new RouteItem;
routeItems->next=NULL;
}
//route结构体使用方式和query类似
//Route * oneRoute = getAllItems();
//while (oneRoute->next!=NULL)
//{
// oneRoute=oneRoute->next;
// url=oneRoute->url;
//}
RouteItem * Route::getAllItems()
{
return this->routeItems;
}
int Route::getRouteId()
{
return this->routeId;
}
QString Route::getRouteName()
{
return this->routeName;
}
int Route::getUserId()
{
return this->userId;
}
void Route::setRouteName(QString name)
{
this->routeName = name;
return;
}
void Route::setUserId(int id)
{
this->userId=id;
}
void Route::setRouteId(int id)
{
this->routeId=id;
}
void Route::setAllItems(QStringList titleList,QStringList urlList,QStringList cateIdList,QDateTime * startTimeList,QDateTime * endTimeList,QStringList trafficList,double * distanceList,double * timeCostList,QStringList descriptionList)
{
RouteItem * head= routeItems;
RouteItem * p;
int totalSize=titleList.size();
int i;
for(i=0;i<totalSize;i++)
{
p=new RouteItem;
p->placeName = titleList[i];
p->url = urlList[i];
p->cateId = cateIdList[i];
p->startTime = startTimeList[i];
p->endTime = endTimeList[i];
p->traffic = trafficList[i];
p->distance = distanceList[i];
p->timeCost = timeCostList[i];
p->description = descriptionList[i];
p->next = NULL;
head->next = p;
head=head->next;
}
}
//删除和添加都是根据位置位置从1开始计数
RouteItem * Route::addItem(RouteItem * oneItem,int locate)
{
RouteItem * p = routeItems;
int i = 0;
while(p->next != NULL&&i<locate)
{
p = p->next;
i++;
}
oneItem->next = p->next;
p->next=oneItem;
return routeItems;
}
RouteItem * Route::deleteItem(int locate)
{
RouteItem * p = routeItems;
RouteItem * pre = routeItems;
int i = 0;
while(p->next != NULL&&i<locate)
{
pre = p;
p = p->next;
i++;
}
pre->next = p->next;
free(p);
return routeItems;
}

@ -1,28 +1,28 @@
#ifndef ROUTE_H
#define ROUTE_H
#include "RouteItem.h"
#include <QStringList>
class Route
{
public:
Route();
struct routeItem * getAllItems();
//距离和时间都用int表示单位m/km时间s/min统一一下
void setAllItems(QStringList titleList,QStringList urlList,QStringList cateIdList,QDateTime * startTimeList,QDateTime * endTimeList,QStringList trafficList,double *distanceList,double *timeCostList,QStringList descriptionList);
int getRouteId();
int getUserId();
QString getRouteName();
void setRouteName(QString name);
void setRouteId(int id);
void setUserId(int id);
RouteItem * addItem(RouteItem * oneItem,int locate);
RouteItem * deleteItem(int locate);
private:
QString routeName;
int userId=0;//路线没有用户时默认为0
int routeId=0;//路线编号默认为0
struct routeItem *routeItems;
};
#endif // ROUTE_H
#ifndef ROUTE_H
#define ROUTE_H
#include "RouteItem.h"
#include <QStringList>
class Route
{
public:
Route();
struct routeItem * getAllItems();
//距离和时间都用int表示单位m/km时间s/min统一一下
void setAllItems(QStringList titleList,QStringList urlList,QStringList cateIdList,QDateTime * startTimeList,QDateTime * endTimeList,QStringList trafficList,double *distanceList,double *timeCostList,QStringList descriptionList);
int getRouteId();
int getUserId();
QString getRouteName();
void setRouteName(QString name);
void setRouteId(int id);
void setUserId(int id);
RouteItem * addItem(RouteItem * oneItem,int locate);
RouteItem * deleteItem(int locate);
private:
QString routeName;
int userId=0;//路线没有用户时默认为0
int routeId=0;//路线编号默认为0
struct routeItem *routeItems;
};
#endif // ROUTE_H

@ -1,322 +1,322 @@
#include "searchwidget.h"
#include "ui_searchwidget.h"
SearchWidget::SearchWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::SearchWidget)
{
ui->setupUi(this);
showLimit = 15;
cateList.append("food");
cateList.append("entertainment");
cateList.append("hotel");
cateList.append("attractions");
cateList.append("sport");
lengthList = (int *)malloc(sizeof(int) * cateList.length());
idList = (int *)malloc(sizeof(int) * showLimit);
mainLayout = new QVBoxLayout();
subWidget = new QWidget();
web = new WebWidget();
nullWidget = new QLabel("抱歉,未找到您要的结果。");
subLayout = new QVBoxLayout();
rtn = new QPushButton("返回");
scroll = new QScrollArea();
scrollWidget = new QWidget();
scrollLayout = new QVBoxLayout();
btnList = (QToolButton **)malloc(sizeof(QToolButton *) * showLimit);
switchLine = new QHBoxLayout();
up = new QPushButton("上一页");
down = new QPushButton("下一页");
//设置布局
this->setLayout(mainLayout);
mainLayout->addWidget(subWidget);
mainLayout->addWidget(web);
mainLayout->addWidget(nullWidget);
web->setVisible(false);
nullWidget->setVisible(false);
subWidget->setLayout(subLayout);
subLayout->addWidget(rtn);
subLayout->addWidget(scroll);
subLayout->addLayout(switchLine);
switchLine->addWidget(up);
switchLine->addWidget(down);
connect(web->getReturnBtn(), &QPushButton::clicked, this, &SearchWidget::returnWeb);
connect(up, &QPushButton::clicked, this, &SearchWidget::pageUp);
connect(down, &QPushButton::clicked, this, &SearchWidget::pageDown);
}
SearchWidget::~SearchWidget()
{
delete ui;
}
QPushButton *SearchWidget::getReturnBtn()
{
return rtn;
}
void SearchWidget::sendInput(QString input)
{
this->segment = input;
qDebug() << "segment:" <<segment;
}
void SearchWidget::getTotalNum()
{
//查询条目数
QSqlQuery query(meituanDb);
int length = cateList.length();
for (int i = 0; i < length; i++)
{
query.prepare("select count(*) as num from " + cateList[i] + " where title like :segment");
query.bindValue(":segment", "%" + segment + "%");
query.exec();
query.next();
qDebug() << cateList[i] + " totalNum:" << query.value("num");
lengthList[i] = query.value("num").value<qlonglong>();
totalNum += query.value("num").value<qlonglong>();
}
pageNum = (totalNum + showLimit - 1)/showLimit;
page2cate = (int *)malloc(sizeof(int) * pageNum);
page2offset = (int *)malloc(sizeof(int) * pageNum);
}
void SearchWidget::queryDatabase(QSqlQuery query)
{
query.exec();
int i = currentHead;
while(query.next()==true && i < showLimit)
{
QVariant id = query.value("id");
QVariant detail = query.value("detail");
QVariant frontimg = query.value("frontimg");
QVariant title = query.value("title");
QVariant avgscore = query.value("avgscore");
QVariant comments = query.value("comments");
QVariant address = query.value("address");
QVariant cateId = query.value("cateId");
// QVariant avgprice = query.value("avgprice");
QString name = title.value<QString>();
QString score = QString::number(avgscore.value<double>());
QString commentNum = QString::number(comments.value<qlonglong>());
QString addr = address.value<QString>();
// QString price = QString::number(avgprice.value<qlonglong>());
QString text = name + "\n" + score + "" + commentNum + "条评论\n" + addr + "\n";// + "人均" + price + "元";
QString cateid = cateId.value<QString>();
idList[i] = id.value<qlonglong>();
nameList.append(name);
urlList.append(detail.value<QString>());
imgList.append(frontimg.value<QString>());
textList.append(text);
cateIdList.append(cateid);
i++;
}
currentQueryLength = i - currentHead;
}
QToolButton *SearchWidget::setBtn(QToolButton *btn, const QString iconPath, const QString text)
{
if(iconPath != "")
btn->setIcon(QIcon(iconPath));
btn->setText(text);
btn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
btn->setIconSize(QSize(100,200));
btn->setFixedSize(1230,200);
return btn;
}
void SearchWidget::setBtns()
{
int i = currentHead;
// qDebug() << "currentHead:" << currentHead;
// qDebug() << "currentQueryLength:" << currentQueryLength;
for (i; i < currentHead + currentQueryLength; i++)
{
int index = i;
//下载图片到本地
QString imgPath = "./images/" + cateList[currentCate] + QString::number(idList[index]) + ".png";
imgDownloader *download = new imgDownloader();
download->downloadFileFromUrl(imgList[index], imgPath);
btnList[index] = setBtn(btnList[index], imgPath, textList[index]);
qDebug() << "info:" << cateList[currentCate] << idList[index] << urlList[index] << imgList[index];
// btnList[index]->setVisible(true);
disconnect(btnList[index], 0, 0, 0);
connect(btnList[index], &QToolButton::clicked, this, [=](){web->loadPage(nameList[index], imgList[index], urlList[index], cateIdList[index]); subWidget->setVisible(false); web->setVisible(true); nullWidget->setVisible(false);});
}
for (i; i < showLimit; i++)
{
int index = i;
btnList[index] = setBtn(btnList[index], "./images/transparent.png", "");
// btnList[index]->setVisible(false);
disconnect(btnList[index], 0, 0, 0);
}
// offset += currentQueryLength;
// currentHead += currentQueryLength;
}
void SearchWidget::querySet()
{
rollTop();
//重置存储查询信息的列表
nameList.clear();
urlList.clear();
imgList.clear();
textList.clear();
cateIdList.clear();
currentHead = 0;
currentQueryLength = 0;
currentCate = page2cate[currentPage - 1];
currentOffset = page2offset[currentPage - 1];
for (int i = 0; i <showLimit; i++)
{
int index = i;
btnList[index] = new QToolButton();
}
// subLayout->removeWidget(scroll);
scroll->takeWidget();
scrollWidget->deleteLater();
scrollWidget = new QWidget();
scrollLayout->deleteLater();
scrollLayout = new QVBoxLayout();
scrollWidget->setLayout(scrollLayout);
qDebug() << "currentPage:" << currentPage;
QSqlQuery query(meituanDb);
while (currentHead < showLimit)
{
//判断是否换表
if (currentOffset >= lengthList[currentCate])
{
currentCate += 1;
currentOffset = 0;
if (currentCate >= cateList.length())
break;
}
//查询数据
query.prepare("select * from " + cateList[currentCate] + " where title like :segment limit :offset , :showLimit");
query.bindValue(":segment", "%" + segment + "%");
query.bindValue(":offset", currentOffset);
qDebug() << "currentCate:" << currentCate;
// qDebug() << "offset:" << offset;
query.bindValue(":showLimit", showLimit);
queryDatabase(query);
// qDebug() << "query success";
//设置按钮
setBtns();
// qDebug() << "set buttons success";
//设置滚动界面布局
for (int i = currentHead; i < currentHead + currentQueryLength; i++)
{
scrollLayout->addWidget(btnList[i]);
}
currentOffset += currentQueryLength;
currentHead += currentQueryLength;
}
page2cate[currentPage] = currentCate;
page2offset[currentPage] = currentOffset;
scroll->setWidget(scrollWidget);
}
void SearchWidget::showResult()
{
totalNum = 0;
pageNum = 0;
getTotalNum();
qDebug() << "totalNum:" << totalNum;
qDebug() << "pageNum:" << pageNum;
currentPage = 1;
currentCate = 0;
currentOffset = 0;
page2cate[0] = currentCate;
page2offset[0] = currentOffset;
if (totalNum)
{
querySet();
subWidget->setVisible(true);
nullWidget->setVisible(false);
}
else
{
subWidget->setVisible(false);
nullWidget->setVisible(true);
}
web->setVisible(false);
}
void SearchWidget::returnWeb()
{
subWidget->setVisible(true);
web->setVisible(false);
nullWidget->setVisible(false);
}
void SearchWidget::pageUp()
{
currentPage--;
if (currentPage < 1)
{
currentPage = 1;
qDebug("这是第一页");
}
else
{
rollTop();
querySet();
}
}
void SearchWidget::pageDown()
{
currentPage++;
if (currentPage > pageNum)
{
currentPage = pageNum;
qDebug("已经是最后一页了!");
}
else
{
rollTop();
querySet();
}
}
void SearchWidget::rollTop()
{
QScrollBar *scrollBar = scroll->verticalScrollBar();
scrollBar->setValue(scrollBar->minimum());
}
#include "searchwidget.h"
#include "ui_searchwidget.h"
SearchWidget::SearchWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::SearchWidget)
{
ui->setupUi(this);
showLimit = 15;
cateList.append("food");
cateList.append("entertainment");
cateList.append("hotel");
cateList.append("attractions");
cateList.append("sport");
lengthList = (int *)malloc(sizeof(int) * cateList.length());
idList = (int *)malloc(sizeof(int) * showLimit);
mainLayout = new QVBoxLayout();
subWidget = new QWidget();
web = new WebWidget();
nullWidget = new QLabel("抱歉,未找到您要的结果。");
subLayout = new QVBoxLayout();
rtn = new QPushButton("返回");
scroll = new QScrollArea();
scrollWidget = new QWidget();
scrollLayout = new QVBoxLayout();
btnList = (QToolButton **)malloc(sizeof(QToolButton *) * showLimit);
switchLine = new QHBoxLayout();
up = new QPushButton("上一页");
down = new QPushButton("下一页");
//设置布局
this->setLayout(mainLayout);
mainLayout->addWidget(subWidget);
mainLayout->addWidget(web);
mainLayout->addWidget(nullWidget);
web->setVisible(false);
nullWidget->setVisible(false);
subWidget->setLayout(subLayout);
subLayout->addWidget(rtn);
subLayout->addWidget(scroll);
subLayout->addLayout(switchLine);
switchLine->addWidget(up);
switchLine->addWidget(down);
connect(web->getReturnBtn(), &QPushButton::clicked, this, &SearchWidget::returnWeb);
connect(up, &QPushButton::clicked, this, &SearchWidget::pageUp);
connect(down, &QPushButton::clicked, this, &SearchWidget::pageDown);
}
SearchWidget::~SearchWidget()
{
delete ui;
}
QPushButton *SearchWidget::getReturnBtn()
{
return rtn;
}
void SearchWidget::sendInput(QString input)
{
this->segment = input;
qDebug() << "segment:" <<segment;
}
void SearchWidget::getTotalNum()
{
//查询条目数
QSqlQuery query(meituanDb);
int length = cateList.length();
for (int i = 0; i < length; i++)
{
query.prepare("select count(*) as num from " + cateList[i] + " where title like :segment");
query.bindValue(":segment", "%" + segment + "%");
query.exec();
query.next();
qDebug() << cateList[i] + " totalNum:" << query.value("num");
lengthList[i] = query.value("num").value<qlonglong>();
totalNum += query.value("num").value<qlonglong>();
}
pageNum = (totalNum + showLimit - 1)/showLimit;
page2cate = (int *)malloc(sizeof(int) * pageNum);
page2offset = (int *)malloc(sizeof(int) * pageNum);
}
void SearchWidget::queryDatabase(QSqlQuery query)
{
query.exec();
int i = currentHead;
while(query.next()==true && i < showLimit)
{
QVariant id = query.value("id");
QVariant detail = query.value("detail");
QVariant frontimg = query.value("frontimg");
QVariant title = query.value("title");
QVariant avgscore = query.value("avgscore");
QVariant comments = query.value("comments");
QVariant address = query.value("address");
QVariant cateId = query.value("cateId");
// QVariant avgprice = query.value("avgprice");
QString name = title.value<QString>();
QString score = QString::number(avgscore.value<double>());
QString commentNum = QString::number(comments.value<qlonglong>());
QString addr = address.value<QString>();
// QString price = QString::number(avgprice.value<qlonglong>());
QString text = name + "\n" + score + "" + commentNum + "条评论\n" + addr + "\n";// + "人均" + price + "元";
QString cateid = cateId.value<QString>();
idList[i] = id.value<qlonglong>();
nameList.append(name);
urlList.append(detail.value<QString>());
imgList.append(frontimg.value<QString>());
textList.append(text);
cateIdList.append(cateid);
i++;
}
currentQueryLength = i - currentHead;
}
QToolButton *SearchWidget::setBtn(QToolButton *btn, const QString iconPath, const QString text)
{
if(iconPath != "")
btn->setIcon(QIcon(iconPath));
btn->setText(text);
btn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
btn->setIconSize(QSize(100,200));
btn->setFixedSize(1230,200);
return btn;
}
void SearchWidget::setBtns()
{
int i = currentHead;
// qDebug() << "currentHead:" << currentHead;
// qDebug() << "currentQueryLength:" << currentQueryLength;
for (i; i < currentHead + currentQueryLength; i++)
{
int index = i;
//下载图片到本地
QString imgPath = "./images/" + cateList[currentCate] + QString::number(idList[index]) + ".png";
imgDownloader *download = new imgDownloader();
download->downloadFileFromUrl(imgList[index], imgPath);
btnList[index] = setBtn(btnList[index], imgPath, textList[index]);
qDebug() << "info:" << cateList[currentCate] << idList[index] << urlList[index] << imgList[index];
// btnList[index]->setVisible(true);
disconnect(btnList[index], 0, 0, 0);
connect(btnList[index], &QToolButton::clicked, this, [=](){web->loadPage(nameList[index], imgList[index], urlList[index], cateIdList[index]); subWidget->setVisible(false); web->setVisible(true); nullWidget->setVisible(false);});
}
for (i; i < showLimit; i++)
{
int index = i;
btnList[index] = setBtn(btnList[index], "./images/transparent.png", "");
// btnList[index]->setVisible(false);
disconnect(btnList[index], 0, 0, 0);
}
// offset += currentQueryLength;
// currentHead += currentQueryLength;
}
void SearchWidget::querySet()
{
rollTop();
//重置存储查询信息的列表
nameList.clear();
urlList.clear();
imgList.clear();
textList.clear();
cateIdList.clear();
currentHead = 0;
currentQueryLength = 0;
currentCate = page2cate[currentPage - 1];
currentOffset = page2offset[currentPage - 1];
for (int i = 0; i <showLimit; i++)
{
int index = i;
btnList[index] = new QToolButton();
}
// subLayout->removeWidget(scroll);
scroll->takeWidget();
scrollWidget->deleteLater();
scrollWidget = new QWidget();
scrollLayout->deleteLater();
scrollLayout = new QVBoxLayout();
scrollWidget->setLayout(scrollLayout);
qDebug() << "currentPage:" << currentPage;
QSqlQuery query(meituanDb);
while (currentHead < showLimit)
{
//判断是否换表
if (currentOffset >= lengthList[currentCate])
{
currentCate += 1;
currentOffset = 0;
if (currentCate >= cateList.length())
break;
}
//查询数据
query.prepare("select * from " + cateList[currentCate] + " where title like :segment limit :offset , :showLimit");
query.bindValue(":segment", "%" + segment + "%");
query.bindValue(":offset", currentOffset);
qDebug() << "currentCate:" << currentCate;
// qDebug() << "offset:" << offset;
query.bindValue(":showLimit", showLimit);
queryDatabase(query);
// qDebug() << "query success";
//设置按钮
setBtns();
// qDebug() << "set buttons success";
//设置滚动界面布局
for (int i = currentHead; i < currentHead + currentQueryLength; i++)
{
scrollLayout->addWidget(btnList[i]);
}
currentOffset += currentQueryLength;
currentHead += currentQueryLength;
}
page2cate[currentPage] = currentCate;
page2offset[currentPage] = currentOffset;
scroll->setWidget(scrollWidget);
}
void SearchWidget::showResult()
{
totalNum = 0;
pageNum = 0;
getTotalNum();
qDebug() << "totalNum:" << totalNum;
qDebug() << "pageNum:" << pageNum;
currentPage = 1;
currentCate = 0;
currentOffset = 0;
page2cate[0] = currentCate;
page2offset[0] = currentOffset;
if (totalNum)
{
querySet();
subWidget->setVisible(true);
nullWidget->setVisible(false);
}
else
{
subWidget->setVisible(false);
nullWidget->setVisible(true);
}
web->setVisible(false);
}
void SearchWidget::returnWeb()
{
subWidget->setVisible(true);
web->setVisible(false);
nullWidget->setVisible(false);
}
void SearchWidget::pageUp()
{
currentPage--;
if (currentPage < 1)
{
currentPage = 1;
qDebug("这是第一页");
}
else
{
rollTop();
querySet();
}
}
void SearchWidget::pageDown()
{
currentPage++;
if (currentPage > pageNum)
{
currentPage = pageNum;
qDebug("已经是最后一页了!");
}
else
{
rollTop();
querySet();
}
}
void SearchWidget::rollTop()
{
QScrollBar *scrollBar = scroll->verticalScrollBar();
scrollBar->setValue(scrollBar->minimum());
}

@ -1,95 +1,95 @@
#ifndef SEARCHWIDGET_H
#define SEARCHWIDGET_H
#include <QWidget>
#include <QPushButton>
#include <QToolButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QSqlQuery>
#include <QVariant>
#include <QDebug>
#include <QScrollArea>
#include <QScrollBar>
#include <QLabel>
#include "databaseconnector.h"
#include "webwidget.h"
#include "imgdownloader.h"
#if _MSC_VER >= 1600
#pragma execution_character_set("utf-8")
#endif
namespace Ui {
class SearchWidget;
}
class SearchWidget : public QWidget
{
Q_OBJECT
public:
explicit SearchWidget(QWidget *parent = nullptr);
~SearchWidget();
void sendInput(QString input);
void queryDatabase(QSqlQuery query);
void getTotalNum();
void showResult();
QPushButton *getReturnBtn();
QToolButton *setBtn(QToolButton *btn, const QString iconPath, const QString text);
void querySet();
void setBtns();
void pageUp();
void pageDown();
void returnWeb();
void rollTop();
private:
Ui::SearchWidget *ui;
QString segment;
QStringList nameList;
QStringList urlList;
QStringList imgList;
QStringList textList;
int *idList;
QStringList cateIdList;
QStringList cateList;
int totalNum;
int *lengthList;
int pageNum;
int showLimit;
int currentPage;
int currentHead;
int currentQueryLength;
int currentCate;
int currentOffset;
int *page2cate;
int *page2offset;
QVBoxLayout *mainLayout;
QWidget *subWidget;
WebWidget *web;
QLabel *nullWidget;
QVBoxLayout *subLayout;
QPushButton *rtn;
QScrollArea *scroll;
QWidget *scrollWidget;
QVBoxLayout *scrollLayout;
QToolButton **btnList;
QHBoxLayout *switchLine;
QPushButton *up;
QPushButton *down;
};
#endif // SEARCHWIDGET_H
#ifndef SEARCHWIDGET_H
#define SEARCHWIDGET_H
#include <QWidget>
#include <QPushButton>
#include <QToolButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QSqlQuery>
#include <QVariant>
#include <QDebug>
#include <QScrollArea>
#include <QScrollBar>
#include <QLabel>
#include "databaseconnector.h"
#include "webwidget.h"
#include "imgdownloader.h"
#if _MSC_VER >= 1600
#pragma execution_character_set("utf-8")
#endif
namespace Ui {
class SearchWidget;
}
class SearchWidget : public QWidget
{
Q_OBJECT
public:
explicit SearchWidget(QWidget *parent = nullptr);
~SearchWidget();
void sendInput(QString input);
void queryDatabase(QSqlQuery query);
void getTotalNum();
void showResult();
QPushButton *getReturnBtn();
QToolButton *setBtn(QToolButton *btn, const QString iconPath, const QString text);
void querySet();
void setBtns();
void pageUp();
void pageDown();
void returnWeb();
void rollTop();
private:
Ui::SearchWidget *ui;
QString segment;
QStringList nameList;
QStringList urlList;
QStringList imgList;
QStringList textList;
int *idList;
QStringList cateIdList;
QStringList cateList;
int totalNum;
int *lengthList;
int pageNum;
int showLimit;
int currentPage;
int currentHead;
int currentQueryLength;
int currentCate;
int currentOffset;
int *page2cate;
int *page2offset;
QVBoxLayout *mainLayout;
QWidget *subWidget;
WebWidget *web;
QLabel *nullWidget;
QVBoxLayout *subLayout;
QPushButton *rtn;
QScrollArea *scroll;
QWidget *scrollWidget;
QVBoxLayout *scrollLayout;
QToolButton **btnList;
QHBoxLayout *switchLine;
QPushButton *up;
QPushButton *down;
};
#endif // SEARCHWIDGET_H

@ -1,21 +1,21 @@
<ui version="4.0">
<author/>
<comment/>
<exportmacro/>
<class>SearchWidget</class>
<widget name="SearchWidget" class="QWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
</widget>
<pixmapfunction/>
<connections/>
</ui>
<ui version="4.0">
<author/>
<comment/>
<exportmacro/>
<class>SearchWidget</class>
<widget name="SearchWidget" class="QWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
</widget>
<pixmapfunction/>
<connections/>
</ui>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save