-
Notifications
You must be signed in to change notification settings - Fork 0
/
breaksdialog.cpp
82 lines (64 loc) · 2.94 KB
/
breaksdialog.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
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Firebird database editor *
* Copyright (C) 2016 Łukasz "Kuszki" Dróżdż lukasz.kuszki@gmail.com *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* 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, see http://www.gnu.org/licenses/. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "breaksdialog.hpp"
#include "ui_breaksdialog.h"
BreaksDialog::BreaksDialog(QWidget* Parent)
: QDialog(Parent), ui(new Ui::BreaksDialog)
{
ui->setupUi(this); static const QStringList Flags =
{
tr("On point objects"),
tr("On common breakpoints")
};
auto Model = new QStandardItemModel(0, 1, this);
auto Item = new QStandardItem(tr("Remove breakpoints"));
int i(0); for (const auto& Text : Flags)
{
auto Item = new QStandardItem(Text);
Item->setData(i);
Item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
Item->setCheckState(Qt::Unchecked);
Model->insertRow(i++, Item);
}
Item->setFlags(Qt::ItemIsEnabled);
Model->insertRow(0, Item);
ui->flagsCombo->setModel(Model);
dialogParamsChanged();
}
BreaksDialog::~BreaksDialog(void)
{
delete ui;
}
void BreaksDialog::accept(void)
{
const auto M = dynamic_cast<QStandardItemModel*>(ui->flagsCombo->model());
int Flags(0); QDialog::accept(); const bool Job = ui->modeCombo->currentIndex();
if (M->item(1)->checkState() == Qt::Checked) Flags = Flags | 0x01;
if (M->item(2)->checkState() == Qt::Checked) Flags = Flags | 0x02;
emit onReduceRequest(Flags, ui->angleSpin->value(), ui->lengthSpin->value(), Job);
}
void BreaksDialog::dialogParamsChanged(void)
{
const bool Job = ui->modeCombo->currentIndex();
const bool Angle = ui->angleSpin->value() != 0.0;
const bool Length = ui->lengthSpin->value() != 0.0;
const bool OK = (Job == 0 && Length) || (Job == 1 && Angle);
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(OK);
}