利用widget重构parkinglot

This commit is contained in:
wmj committed 2017-12-14 16:34:48 +08:00
1 parent 998cffecaf
commit ac082afd00
11 files changed
+80 -336

No files matched your search

+17 -2
View File
@@ -29,13 +29,28 @@ SOURCES += \
mainwindow.cpp \
monitor.cpp \
cars.cpp \
parkinglot.cpp
parkinglot.cpp \
cars.cpp \
main.cpp \
mainwindow.cpp \
monitor.cpp \
parkinglot.cpp \
ParkingLotWidget.cpp \
ParkingSpaceInfo.cpp \
Road.cpp
HEADERS += \
mainwindow.h \
monitor.h \
cars.h \
parkinglot.h
parkinglot.h \
cars.h \
mainwindow.h \
monitor.h \
parkinglot.h \
ParkingLotWidget.h \
ParkingSpaceInfo.h \
Road.h
FORMS += \
mainwindow.ui
+3 -250
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.4.1, 2017-12-13T20:49:28. -->
<!-- Written by QtCreator 4.4.1, 2017-12-14T16:03:40. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
@@ -58,253 +58,6 @@
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.9.3 MinGW 32bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.9.3 MinGW 32bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.593.win32_mingw53_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">D:/wming/Documents/build-DataStructureProject-Desktop_Qt_5_9_3_MinGW_32bit-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.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></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.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<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>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></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.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<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>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清理</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></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.DefaultDisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:/wming/Documents/build-DataStructureProject-Desktop_Qt_5_9_3_MinGW_32bit-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.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></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">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.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<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>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></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.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<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>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清理</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></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.DefaultDisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:/wming/Documents/build-DataStructureProject-Desktop_Qt_5_9_3_MinGW_32bit-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.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></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">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.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<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>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></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.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<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>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清理</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></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.DefaultDisplayName">Profile</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</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">部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></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.DefaultDisplayName">在本地部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></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="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="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.ProjectConfiguration.DefaultDisplayName">DataStructureProject</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:D:/wming/Documents/DataStructureProject/DataStructureProject.pro</value>
<value type="bool" key="QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath">true</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">DataStructureProject.pro</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">D:/wming/Documents/build-DataStructureProject-Desktop_Qt_5_9_3_MinGW_32bit-Debug</value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</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>
</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.9.3 MSVC2017 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.9.3 MSVC2017 64bit</value>
@@ -539,7 +292,7 @@
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">DataStructureProject.pro</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">D:/wming/Documents/build-DataStructureProject-Desktop_Qt_5_9_3_MinGW_32bit-Debug</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">D:/wming/Documents/build-DataStructureProject-Desktop_Qt_5_9_3_MSVC2017_64bit-Debug</value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
@@ -552,7 +305,7 @@
</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>
+5 -24
View File
@@ -12,11 +12,7 @@ ParkingLotWidget::ParkingLotWidget(QWidget *parent, const QString& xml) : QWidge
{
resize(1000, 1000);
parse_xml(xml);
if (rootLayoutDirection == horizontal)
setLayout(hBoxLayout);
else
setLayout(vBoxLayout);
setLayout(layout);
}
@@ -48,30 +44,15 @@ void ParkingLotWidget::parse_xml(const QString & xml)
}
QDomElement element = doc.documentElement().firstChild().toElement();
QString name = element.tagName();
if (element.tagName() == "vLayout")
if (element.tagName().contains("Layout"))
{
rootLayoutDirection = vertical;
vBoxLayout = parseVbox(element);
} else if (element.tagName() == "hLayout")
{
rootLayoutDirection = horizontal;
hBoxLayout = parseHbox(element);
layout = parseLayout(element);
} else
{
qDebug() << this -> objectName() << "布局文件错误";
}
}
inline QHBoxLayout * ParkingLotWidget::parseHbox(const QDomElement & element)
{
return static_cast<QHBoxLayout*>(parseLayout(element));
}
inline QVBoxLayout * ParkingLotWidget::parseVbox(const QDomElement & element)
{
return static_cast<QVBoxLayout*>(parseLayout(element));;
}
QBoxLayout * ParkingLotWidget::parseLayout(const QDomElement & element)
{
QBoxLayout* layout;
@@ -99,13 +80,13 @@ QBoxLayout * ParkingLotWidget::parseLayout(const QDomElement & element)
this, child.attribute("direction"), n, child.attribute("expendDirection")));
}
else if ((name.at(0) == 'v' || name.at(0) == 'h' )&& name.contains("Layout"))
layout->addLayout(parseHbox(child));
layout->addLayout(parseLayout(child));
else
qDebug() << this->objectName() << "错误的xml标签";
child = child.nextSiblingElement();
}
layout->addStretch(); // 添加伸缩,实现居上或居左对齐
layout->setMargin(0);
layout->setSpacing(0);
layout->setContentsMargins(0, 0, 0, 0);
return layout;
}
+1 -6
View File
@@ -1,7 +1,6 @@
#pragma once
#include <QWidget>
#include <QString>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QDomDocument>
class ParkingLotWidget: public QWidget
@@ -13,11 +12,7 @@ public:
~ParkingLotWidget();
private:
void parse_xml(const QString& xml);
inline QHBoxLayout* parseHbox(const QDomElement& element);
inline QVBoxLayout* parseVbox(const QDomElement& element);
enum {horizontal, vertical} rootLayoutDirection;
QBoxLayout *parseLayout(const QDomElement& element);
QHBoxLayout *hBoxLayout = nullptr;
QVBoxLayout *vBoxLayout = nullptr;
QBoxLayout *layout = nullptr;
};
+18 -21
View File
@@ -2,10 +2,20 @@
#include <QPainter>
#include <QDebug>
ParkingSpaceInfo::ParkingSpaceInfo(QWidget* parent, const direction dir) : QWidget(parent)
ParkingSpaceInfo::ParkingSpaceInfo(QWidget* parent, const QString &dir)
{
this->dir = dir;
switch (dir)
direction d = {};
const char c = dir.at(0).unicode();
switch (c)
{
case 'N':d = N; break;
case 'E':d = E; break;
case 'W':d = W; break;
case 'S':d = S; break;
default: qDebug() << this->objectName() << "错误的方向";
}
this->dir = d;
switch (this->dir)
{
case N:
case S:
@@ -21,20 +31,6 @@ ParkingSpaceInfo::ParkingSpaceInfo(QWidget* parent, const direction dir) : QWidg
break;
}
}
ParkingSpaceInfo::ParkingSpaceInfo(QWidget* parent, const QString &dir)
{
direction d = {};
const char c = dir.at(0).unicode();
switch (c)
{
case 'N':d = N; break;
case 'E':d = E; break;
case 'W':d = W; break;
case 'S':d = S; break;
default: qDebug() << this->objectName() << "´íÎóµÄ·½Ïò";
}
this->ParkingSpaceInfo::ParkingSpaceInfo(parent, d);
}
QBoxLayout *ParkingSpaceInfo::makeParkingSapceGroup(QWidget* parent, const QString& dir, int n, const QString & expend)
{
@@ -48,18 +44,16 @@ QBoxLayout *ParkingSpaceInfo::makeParkingSapceGroup(QWidget* parent, const QStri
ParkingSpaceInfo *pk = new ParkingSpaceInfo(parent, dir);
layout->addWidget(pk);
}
layout->addStretch(); // 居上或居左对齐
layout->setMargin(0);
layout->setSpacing(0);
layout->setContentsMargins(0, 0, 0, 0);
return layout;
}
void ParkingSpaceInfo::paintEvent(QPaintEvent * event)
{
QPainter painter(this);
painter.setPen(Qt::blue);
// painter.drawRect(0, 0, this->width(), this->height());
painter.setPen(Qt::red);
painter.setPen(Qt::white);
painter.setBrush(Qt::white);
painter.translate(30, 20);
switch (dir) {
@@ -79,6 +73,9 @@ void ParkingSpaceInfo::paintEvent(QPaintEvent * event)
painter.drawRect(0, 0, 60, 5);
painter.drawRect(0, 5, 10, 35);
painter.drawRect(10, 35, 50, 5);
/*painter.setPen(Qt::blue);
painter.setBrush(Qt::NoBrush);
painter.drawRect(0, 0, this->width() - 1, this->height() - 1);*/
painter.end();
}
-1
View File
@@ -6,7 +6,6 @@ class ParkingSpaceInfo: public QWidget
Q_OBJECT
public:
enum direction{N, S, E, W};
ParkingSpaceInfo(QWidget* parent, direction dir);
ParkingSpaceInfo(QWidget* parent, const QString &dir);
static QBoxLayout* makeParkingSapceGroup(QWidget* parent, const QString& dir, int n, const QString &expend);
void paintEvent(QPaintEvent* event) override;
+3
View File
@@ -17,11 +17,14 @@ Road::Road(QWidget* parent, const int length, const direction dir)
setMaximumSize(50, length);
break;
}
// setContentsMargins(0, 0, 0, 0);
}
void Road::paintEvent(QPaintEvent * event)
{
QPainter painter(this);
/*painter.setPen(Qt::blue);
painter.drawRect(0, 0, width() - 1, height() - 1);*/
painter.setBrush(Qt::white);
painter.setPen(Qt::white);
auto x = 0, y = 0;
+9 -6
View File
@@ -5,6 +5,7 @@
#include <QLabel>
#include <QScrollArea>
#include "parkinglot.h"
#include "ParkingLotWidget.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
@@ -15,21 +16,23 @@ MainWindow::MainWindow(QWidget *parent) :
QScrollArea* scrollArea = new QScrollArea(this);
scrollArea->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
scrollArea->setWidgetResizable(true);
scrollArea->resize(1800, 800);
// scrollArea->resize(1800, 800);
// monitor = new Monitor(this);
// Cars *car = new Cars(this);
ParkingLot *pk = new ParkingLot("D:\\wming\\Documents\\DataStructureProject\\parkinglot_f1.xml", this);
ParkingLotWidget *pk = new ParkingLotWidget(this, "D:\\wming\\Documents\\DataStructureProject\\parkinglot_f1.xml");
// pk->show();
// pk->creatMap();
QLabel *label = new QLabel(this);
/*QLabel *label = new QLabel(this);
label->resize(1000, 1000);
label->setPixmap(pk->creatMap2());
scrollArea->setWidget(label);
label->setPixmap(pk->creatMap2());*/
scrollArea->resize(pk->width(), this->height());
scrollArea->setWidget(pk);
}
MainWindow::~MainWindow()
{
delete ui;
delete monitor;
// delete monitor;
}
void MainWindow::open(void) {
+18 -18
View File
@@ -28,7 +28,7 @@ ParkingLot::ParkingLot(const QString &fname, QWidget* parent)
}
}
QPixmap ParkingLot::creatMap2()
QPixmap ParkingLot::creatMap2() const
{
QDomElement root =doc -> documentElement();
if (root.tagName() != "parkinglot") {
@@ -93,24 +93,24 @@ QPixmap drawRoom(const QDomElement& roomXML) {
}
QPixmap temp(60, 40);
result.fill(QColor(200, 200, 200));
QPainter painter(&result), tPainter(&temp);
QPainter painter(&result), t_painter(&temp);
painter.setPen(Qt::white);
painter.setBrush(Qt::white);
tPainter.setPen(Qt::white);
tPainter.setBrush(Qt::white);
t_painter.setPen(Qt::white);
t_painter.setBrush(Qt::white);
ushort direction = roomXML.attribute("direction").at(0).unicode();
int n = roomXML.attribute("number").toInt();
int x = 0, y = 0;
const auto direction = roomXML.attribute("direction").at(0).unicode();
const auto n = roomXML.attribute("number").toInt();
auto x = 0, y = 0;
enum {down, right} expendDirection;
if (roomXML.attribute("expendDirection") == "down")
expendDirection = down;
else
expendDirection = right;
tPainter.drawRect(0, 0, 60, 5);
tPainter.drawRect(0, 5, 10, 35);
tPainter.drawRect(10, 35, 50, 5);
tPainter.end();
t_painter.drawRect(0, 0, 60, 5);
t_painter.drawRect(0, 5, 10, 35);
t_painter.drawRect(10, 35, 50, 5);
t_painter.end();
switch(direction) {
case 'E':
// temp = temp;
@@ -129,7 +129,7 @@ QPixmap drawRoom(const QDomElement& roomXML) {
break;
}
// tPainter.begin(&temp);
for (int i = 0; i < n; i++) {
for (auto i = 0; i < n; i++) {
painter.drawPixmap(x, y, temp.width(), temp.height(), temp);
if (expendDirection == down)
y += temp.height();
@@ -148,7 +148,7 @@ QPixmap ParkingLot::parseLayout(const QDomElement& layout) const
result.fill(QColor(200, 200, 200));
QPainter painter(&result);
painter.setPen(Qt::black);
int x = 0, y = 0, maxX = 0, maxY = 0;
auto x = 0, y = 0, max_x = 0, max_y = 0;
enum {vertical, horizontal} direction;
if (layout.tagName() == "vLayout")
direction = vertical;
@@ -161,7 +161,7 @@ QPixmap ParkingLot::parseLayout(const QDomElement& layout) const
QDomElement child = layout.firstChild().toElement();
while(!child.isNull()) {
QString name = child.tagName();
const QString name = child.tagName();
if (name == "road") {
temp = drawRoad(child);
} else if (name == "room") {
@@ -171,16 +171,16 @@ QPixmap ParkingLot::parseLayout(const QDomElement& layout) const
painter.drawPixmap(x, y, temp.width(), temp.height(), temp);
if (direction == horizontal) {
x += temp.width();
maxY = std::max(maxY, temp.height());
max_y = std::max(max_y, temp.height());
} else {
y += temp.height();
maxX = std::max(maxX, temp.width());
max_x = std::max(max_x, temp.width());
}
child = child.nextSibling().toElement();
}
if (direction == horizontal) {
return result.copy(0, 0, x, maxY);
return result.copy(0, 0, x, max_y);
} else {
return result.copy(0, 0, maxX, y);
return result.copy(0, 0, max_x, y);
}
}
+2 -4
View File
@@ -1,20 +1,18 @@
#ifndef PARKINGLOT_H
#define PARKINGLOT_H
#include <QWidget>
#include <QString>
#include <QPainter>
#include <QBitmap>
#include <QDomDocument>
class ParkingLot
{
public:
explicit ParkingLot(const QString& fname, QWidget *parent = nullptr);
void creatMap();
QPixmap creatMap2();
QPixmap creatMap2() const;
QPixmap* getPixmap() const;
~ParkingLot();
private:
bool vertical;
// bool vertical;
QPixmap* map;
QDomDocument* doc;
QWidget* parent;
+4 -4
View File
@@ -2,16 +2,16 @@
<vLayout>
<road length="700" direction="horizontal" />
<hLayout>
<road length="900" direction="vertical" />
<road length="600" direction="vertical" />
<room number="15" direction="W" expendDirection="down"/>
<room number="15" direction="E" expendDirection="down"/>
<road length="900" direction="vertical" />
<road length="600" direction="vertical" />
<room number="15" direction="W" expendDirection="down"/>
<room number="15" direction="E" expendDirection="down"/>
<road length="900" direction="vertical" />
<road length="600" direction="vertical" />
<room number="15" direction="W" expendDirection="down"/>
<room number="15" direction="E" expendDirection="down"/>
<road length="900" direction="vertical" />
<road length="600" direction="vertical" />
<room number="15" direction="W" expendDirection="down"/>
<room number="15" direction="E" expendDirection="down"/>
</hLayout>