forked from ElvishArtisan/rivendell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist_svcs.cpp
140 lines (116 loc) · 3.57 KB
/
list_svcs.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// list_svcs.cpp
//
// List Rivendell Services and Report Ages
//
// (C) Copyright 2002-2021 Fred Gleason <[email protected]>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <rdescape_string.h>
#include "globals.h"
#include "list_svcs.h"
#include "svc_rec_dialog.h"
#include "pick_report_dates.h"
ListSvcs::ListSvcs(QWidget *parent)
: RDDialog(parent)
{
setWindowTitle("RDLogManager - "+tr("Rivendell Services"));
//
// Fix the Window Size
//
setMinimumSize(sizeHint());
//
// Log List
//
list_log_view=new RDTableView(this);
list_log_model=new RDServiceListModel(false,false,this);
list_log_model->setFont(font());
list_log_model->setPalette(palette());
list_log_view->setModel(list_log_model);
for(int i=2;i<list_log_model->columnCount();i++) {
list_log_view->hideColumn(i);
}
connect(list_log_view,SIGNAL(doubleClicked(const QModelIndex &)),
this,SLOT(listDoubleClickedData(const QModelIndex &)));
connect(list_log_model,SIGNAL(modelReset()),
list_log_view,SLOT(resizeColumnsToContents()));
list_log_view->resizeColumnsToContents();
//
// Generate Report Button
//
list_generate_button=new QPushButton(this);
list_generate_button->setFont(buttonFont());
list_generate_button->setText(tr("Generate\nReports"));
connect(list_generate_button,SIGNAL(clicked()),this,SLOT(generateData()));
//
// Purge Button
//
list_purge_button=new QPushButton(this);
list_purge_button->setFont(buttonFont());
list_purge_button->setText(tr("Purge\nData"));
connect(list_purge_button,SIGNAL(clicked()),this,SLOT(purgeData()));
//
// Close Button
//
list_close_button=new QPushButton(this);
list_close_button->setDefault(true);
list_close_button->setFont(buttonFont());
list_close_button->setText(tr("Close"));
connect(list_close_button,SIGNAL(clicked()),this,SLOT(closeData()));
}
QSize ListSvcs::sizeHint() const
{
return QSize(400,300);
}
QSizePolicy ListSvcs::sizePolicy() const
{
return QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
}
void ListSvcs::generateData()
{
QModelIndexList rows=list_log_view->selectionModel()->selectedRows();
if(rows.size()!=1) {
return;
}
PickReportDates *d=
new PickReportDates(list_log_model->serviceName(rows.first()),this);
d->exec();
delete d;
}
void ListSvcs::purgeData()
{
QModelIndexList rows=list_log_view->selectionModel()->selectedRows();
if(rows.size()!=1) {
return;
}
SvcRecDialog *d=
new SvcRecDialog(list_log_model->serviceName(rows.first()),this);
d->exec();
delete d;
}
void ListSvcs::listDoubleClickedData(const QModelIndex &index)
{
generateData();
}
void ListSvcs::closeData()
{
done(0);
}
void ListSvcs::resizeEvent(QResizeEvent *e)
{
list_log_view->setGeometry(10,10,size().width()-20,size().height()-80);
list_generate_button->setGeometry(10,size().height()-60,80,50);
list_purge_button->setGeometry(100,size().height()-60,80,50);
list_close_button->setGeometry(size().width()-90,size().height()-60,80,50);
}