-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathActivityTimetableWindow.cpp
69 lines (59 loc) · 2.1 KB
/
ActivityTimetableWindow.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
62
63
64
65
66
67
68
69
/* This file is part of TSRE5.
*
* TSRE5 - train sim game engine and MSTS/OR Editors.
* Copyright (C) 2016 Piotr Gadecki <[email protected]>
*
* Licensed under GNU General Public License 3.0 or later.
*
* See LICENSE.md or https://www.gnu.org/licenses/gpl.html
*/
#include "ActivityTimetableWindow.h"
#include "ActivityTimetableProperties.h"
#include "Activity.h"
ActivityTimetableWindow::ActivityTimetableWindow(QWidget* parent) : QWidget(parent) {
setWindowFlags(Qt::WindowType::Tool);
setWindowTitle(tr("Timetable"));
timetableProperties = new ActivityTimetableProperties(this);
QVBoxLayout *actionListLayout = new QVBoxLayout;
actionListLayout->setContentsMargins(0,0,0,0);
actionListLayout->setSpacing(0);
actionListLayout->addWidget(&list);
list.setFixedWidth(170);
QHBoxLayout *v = new QHBoxLayout;
v->setSpacing(2);
v->setContentsMargins(1,1,1,1);
v->addItem(actionListLayout);
v->addWidget(timetableProperties);
this->setLayout(v);
QObject::connect(&list, SIGNAL(itemClicked(QListWidgetItem*)),
this, SLOT(listSelected(QListWidgetItem*)));
}
ActivityTimetableWindow::~ActivityTimetableWindow() {
}
void ActivityTimetableWindow::showTimetable(Activity *a){
if(this->isHidden())
return;
if(a == NULL)
return;
activity = a;
services = a->getServiceList();
//serviceProperties->setPaths(route->path);
//activity = r->s
list.clear();
//QList<QTreeWidgetItem *> items;
//QStringList list;
for(int i = 0; i < services.size(); i++ ){
if(services[i] == NULL)
continue;
QListWidgetItem *item = new QListWidgetItem ( services[i]->name, &list, i );
if(services[i]->player)
item->setCheckState(Qt::Checked);
else
item->setCheckState(Qt::Unchecked);
}
}
void ActivityTimetableWindow::listSelected(QListWidgetItem *item){
//if(route == NULL)
// return;
timetableProperties->showTimetable(services[item->type()]);
}