This repository has been archived by the owner on Jun 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
alterrunswindow.cpp
61 lines (57 loc) · 2.13 KB
/
alterrunswindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "alterrunswindow.h"
#include "ui_alterrunswindow.h"
AlterRunsWindow::AlterRunsWindow(QWidget *parent) :
QDialog(parent),
ui(new Ui::AlterRunsWindow)
{
ui->setupUi(this);
}
AlterRunsWindow::~AlterRunsWindow()
{
delete ui;
}
void AlterRunsWindow::on_buttonBox_accepted()
{
QString runs = ui->runsLineEdit->text();
QString time = ui->departTimeLineEdit->text();
QString startStation = ui->startStationLineEdit->text();
QString endStation = ui->endStationLineEdit->text();
QString tripTime = ui->tripTimeLineEdit->text();
QString capacity = ui->capacityLineEdit->text();
QString ticketSold = ui->ticketSoldLineEdit->text();
if(runs.isEmpty() || time.isEmpty() || startStation.isEmpty() ||
endStation.isEmpty() || tripTime.isEmpty() || capacity.isEmpty() ||
ticketSold.isEmpty())
{
QMessageBox::warning(this, "错误", "请填完整");
}
else
{
QRegExp intRegex(QString("\\d+"));
QRegExp floatRegex(QString("\\d*(\\.\\d*)?\\d$"));
QRegExp timeRegex(QString("^(([0-1]?\\d)|(2[0-4])):(([0-5]?\\d)|60)$"));
if(floatRegex.exactMatch(tripTime) && timeRegex.exactMatch(time) &&
intRegex.exactMatch(capacity) && intRegex.exactMatch(ticketSold))
{
emit sendInformation(this->index, runs, time, startStation, endStation, tripTime, capacity, ticketSold);
hide();
}
else
{
QMessageBox::warning(this, "格式错误", "请检查各值格式");
}
}
}
void AlterRunsWindow::getInformation(int index, QString runs, QString departTime,
QString startStation, QString endStation, QString tripTime,
QString capacity, QString ticketSold)
{
this->index = index;
ui->runsLineEdit->setText(runs);
ui->departTimeLineEdit->setText(departTime);
ui->startStationLineEdit->setText(startStation);
ui->endStationLineEdit->setText(endStation);
ui->tripTimeLineEdit->setText(tripTime);
ui->capacityLineEdit->setText(capacity);
ui->ticketSoldLineEdit->setText(ticketSold);
}