2 * Copyright (C) 2011, Jamie Thompson
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License as published by the Free Software Foundation; either
7 * version 3 of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public
15 * License along with this program; If not, see
16 * <http://www.gnu.org/licenses/>.
19 #include "TypesWindow.h"
20 #include "DirectoryWindow.h"
24 using namespace Windows;
26 TypesWindow::TypesWindow(Settings& settings, QWidget *parent) :
27 BaseWindow(settings, parent)
32 void TypesWindow::CreateContents()
34 switch(CurrentSettings().AppMode())
36 case Settings::APPMODE_GUI:
38 QWidget *layoutWidget = new QWidget(centralWidget());
39 layoutWidget->setGeometry(QRect(0, 0, 801, 251));
41 QGridLayout *layout = new QGridLayout(layoutWidget);
43 layout->setSizeConstraint(QLayout::SetMaximumSize);
44 layout->setContentsMargins(0, 0, 0, 0);
50 new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding),
55 new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding),
60 new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum),
65 new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum),
70 layout->setColumnStretch(0, 3);
71 layout->setColumnStretch(1, 1);
72 layout->setColumnStretch(2, 1);
73 layout->setColumnStretch(3, 1);
74 layout->setColumnStretch(4, 4);
80 QLabel *lblSent = new QLabel();
81 lblSent->setText(tr("Sent"));
82 lblSent->setAlignment(Qt::AlignCenter);
83 layout->addWidget(lblSent, row, 2, 1, 1);
86 QLabel *lblReceived = new QLabel();
87 lblReceived->setText(tr("Recieved"));
88 lblReceived->setAlignment(Qt::AlignCenter);
89 layout->addWidget(lblReceived, row, 3, 1, 1);
94 QSizePolicy sizePolicyForCheckBoxes(QSizePolicy::Minimum, QSizePolicy::Minimum);
95 sizePolicyForCheckBoxes.setHorizontalStretch(0);
96 sizePolicyForCheckBoxes.setVerticalStretch(0);
97 sizePolicyForCheckBoxes.setHeightForWidth(false);
101 QLabel *lblCalls = new QLabel();
102 lblCalls->setText(tr("Calls"));
103 lblCalls->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
104 layout->addWidget(lblCalls, row, 1, 1, 1);
107 cbMadeCalls = new QCheckBox();
108 //cbMadeCalls->setEnabled(false);
109 cbMadeCalls->setSizePolicy(sizePolicyForCheckBoxes);
110 cbMadeCalls->setMaximumSize(QSize(70, 64));
111 layout->addWidget(cbMadeCalls, row, 2, 1, 1);
114 cbRecvCalls = new QCheckBox();
115 //cbRecvCalls->setEnabled(false);
116 cbRecvCalls->setSizePolicy(sizePolicyForCheckBoxes);
117 cbRecvCalls->setMaximumSize(QSize(70, 64));
118 layout->addWidget(cbRecvCalls, row, 3, 1, 1);
125 QLabel *lblSMS = new QLabel();
126 lblSMS->setText(tr("SMS"));
127 lblSMS->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
128 layout->addWidget(lblSMS, row, 1, 1, 1);
131 cbSentSMS = new QCheckBox();
132 cbSentSMS->setSizePolicy(sizePolicyForCheckBoxes);
133 cbSentSMS->setMaximumSize(QSize(70, 64));
134 layout->addWidget(cbSentSMS, row, 2, 1, 1);
137 cbRecvSMS = new QCheckBox();
138 cbRecvSMS->setSizePolicy(sizePolicyForCheckBoxes);
139 cbRecvSMS->setMaximumSize(QSize(70, 64));
140 layout->addWidget(cbRecvSMS, row, 3, 1, 1);
147 QLabel *lblMMS = new QLabel();
148 lblMMS->setText(tr("MMS"));
149 lblMMS->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
150 layout->addWidget(lblMMS, row, 1, 1, 1);
153 cbSentMMS = new QCheckBox();
154 cbSentMMS->setEnabled(false);
155 cbSentMMS->setSizePolicy(sizePolicyForCheckBoxes);
156 cbSentMMS->setMaximumSize(QSize(70, 64));
157 layout->addWidget(cbSentMMS, row, 2, 1, 1);
160 cbRecvMMS = new QCheckBox();
161 cbRecvMMS->setEnabled(false);
162 cbRecvMMS->setSizePolicy(sizePolicyForCheckBoxes);
163 cbRecvMMS->setMaximumSize(QSize(70, 64));
164 layout->addWidget(cbRecvMMS, row, 3, 1, 1);
171 QLabel *lblChat = new QLabel();
172 lblChat->setText(tr("Chat"));
173 lblChat->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
174 layout->addWidget(lblChat, row, 1, 1, 1);
177 cbSentChat = new QCheckBox();
178 cbSentChat->setEnabled(false);
179 cbSentChat->setSizePolicy(sizePolicyForCheckBoxes);
180 cbSentChat->setMaximumSize(QSize(70, 64));
181 layout->addWidget(cbSentChat, row, 2, 1, 1);
184 cbRecvChat = new QCheckBox();
185 cbRecvChat->setEnabled(false);
186 cbRecvChat->setSizePolicy(sizePolicyForCheckBoxes);
187 cbRecvChat->setMaximumSize(QSize(70, 64));
188 layout->addWidget(cbRecvChat, row, 3, 1, 1);
195 btnContinue = new QPushButton(centralWidget());
196 btnContinue->setText(tr("Continue..."));
198 QSizePolicy sizePolicyForContinueButton(QSizePolicy::Fixed, QSizePolicy::Fixed);
199 sizePolicyForContinueButton.setHorizontalStretch(0);
200 sizePolicyForContinueButton.setVerticalStretch(0);
201 sizePolicyForContinueButton.setHeightForWidth(true);
202 btnContinue->setSizePolicy(sizePolicyForContinueButton);
204 QObject::connect(btnContinue, SIGNAL(clicked()), this, SLOT(Continue()));
207 connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(OrientationChanged()));
208 OrientationChanged();
210 centralWidget()->setLayout(layout);
216 case Settings::APPMODE_CONSOLE:
226 void TypesWindow::OrientationChanged()
228 QRect screenGeometry = QApplication::desktop()->screenGeometry();
230 if (screenGeometry.width() > screenGeometry.height())
231 btnContinue->setGeometry(QRect(610, 340, 184, 80));
234 btnContinue->setGeometry(QRect(290, 655, 184, 80));
237 void TypesWindow::Continue()
239 CurrentSettings().setShouldProcess(Settings::OUTGOING, EventTypes::EVENT_TYPE_CALL, cbMadeCalls->checkState() == Qt::Checked);
240 CurrentSettings().setShouldProcess(Settings::OUTGOING, EventTypes::EVENT_TYPE_SMS, cbSentSMS->checkState() == Qt::Checked);
241 CurrentSettings().setShouldProcess(Settings::OUTGOING, EventTypes::EVENT_TYPE_MMS, cbSentMMS->checkState() == Qt::Checked);
242 CurrentSettings().setShouldProcess(Settings::OUTGOING, EventTypes::EVENT_TYPE_CHAT, cbSentChat->checkState() == Qt::Checked);
243 CurrentSettings().setShouldProcess(Settings::INCOMING, EventTypes::EVENT_TYPE_CALL, cbRecvCalls->checkState() == Qt::Checked);
244 CurrentSettings().setShouldProcess(Settings::INCOMING, EventTypes::EVENT_TYPE_SMS, cbRecvSMS->checkState() == Qt::Checked);
245 CurrentSettings().setShouldProcess(Settings::INCOMING, EventTypes::EVENT_TYPE_MMS, cbRecvMMS->checkState() == Qt::Checked);
246 CurrentSettings().setShouldProcess(Settings::INCOMING, EventTypes::EVENT_TYPE_CHAT, cbRecvChat->checkState() == Qt::Checked);
248 if(CurrentSettings().anyToProcess())
251 QMessageBox::critical(this, tr("Excuse me"), tr("You must select at least one type of data to process."));
254 void TypesWindow::Advance()
256 QWidget* next = new DirectoryWindow(CurrentSettings(), this);