src/versionEditor.cpp

Sun, 08 Sep 2013 21:58:44 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Sun, 08 Sep 2013 21:58:44 +0300
changeset 28
dc076175ebdc
parent 27
b9307871cf10
child 30
6b82f6a3ad53
permissions
-rw-r--r--

don't ask to confirm when removing one version

25
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 #include "versionEditor.h"
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 #include "ui_versionEditor.h"
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 #include "ui_addversion.h"
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 #include "config.h"
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 #include "misc.h"
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 #include "build/moc_versionEditor.cpp"
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 EXTERN_CONFIG (Map, binaryPaths)
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 EXTERN_CONFIG (List, devBuildNames)
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 EXTERN_CONFIG (List, releaseNames)
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 // =============================================================================
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 // -----------------------------------------------------------------------------
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 VersionEditor::VersionEditor (QWidget* parent, Qt::WindowFlags f) :
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 QDialog (parent, f),
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 m_ui (new Ui_VersionEditor)
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 {
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18 m_ui->setupUi (this);
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 connect (m_ui->m_versions, SIGNAL (currentCellChanged (int, int, int, int)),
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 this, SLOT (selectionChanged (int)));
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 connect (m_ui->m_add, SIGNAL (clicked (bool)), this, SLOT (add()));
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 connect (m_ui->m_edit, SIGNAL (clicked (bool)), this, SLOT (edit()));
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 connect (m_ui->m_remove, SIGNAL (clicked (bool)), this, SLOT (remove()));
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 connect (m_ui->m_clear, SIGNAL (clicked (bool)), this, SLOT (clear()));
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 initVersions();
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 }
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31 // =============================================================================
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 // -----------------------------------------------------------------------------
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 VersionEditor::~VersionEditor() {
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 delete m_ui;
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 }
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37 // =============================================================================
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38 // -----------------------------------------------------------------------------
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 void VersionEditor::initVersions() {
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40 int i = 0;
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42 for (const QVariant& ver : (cfg::releaseNames + cfg::devBuildNames)) {
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43 bool isRelease = (i < cfg::releaseNames.size());
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 addVersion (ver.toString(), cfg::binaryPaths[ver.toString()].toString(), isRelease);
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46 ++i;
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
47 }
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48 }
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
49
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50 // =============================================================================
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51 // -----------------------------------------------------------------------------
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52 void VersionEditor::add() {
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53 AddVersionPrompt* dlg = new AddVersionPrompt (this);
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54 if (!dlg->exec())
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55 return;
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57 addVersion (dlg->name(), dlg->path(), dlg->release());
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58 }
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60 // =============================================================================
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
61 // -----------------------------------------------------------------------------
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
62 void VersionEditor::edit() {
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
63 QTableWidget* const vers = m_ui->m_versions;
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
64 int row = vers->currentRow();
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66 if (row < 0)
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
67 return;
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
69 AddVersionPrompt* dlg = new AddVersionPrompt (this);
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
70 dlg->setName (vers->item (row, NameColumn)->text());
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
71 dlg->setPath (vers->item (row, PathColumn)->text());
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
72 dlg->setRelease (getReleaseCheckbox(row)->isChecked());
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
73
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
74 if (!dlg->exec())
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
75 return;
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
76
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
77 addVersion (dlg->name(), dlg->path(), dlg->release());
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
78 }
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
79
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
80 // =============================================================================
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
81 // -----------------------------------------------------------------------------
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
82 void VersionEditor::remove() {
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
83 QTableWidget* const vers = m_ui->m_versions;
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
84
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
85 str name = vers->item (vers->currentRow(), NameColumn)->text();
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
86 vers->removeRow (vers->currentRow());
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
87 }
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
88
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
89 // =============================================================================
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
90 // -----------------------------------------------------------------------------
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
91 void VersionEditor::clear() {
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
92 if (!confirm (tr ("Really remove all versions?")))
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
93 return;
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
94
27
b9307871cf10 clear the rows of the version editor properly when clearing versions; don't save the config when closing the version editor since then changes will apply even if user presses cancel in the main config box
Teemu Piippo <crimsondusk64@gmail.com>
parents: 25
diff changeset
95 for (int i = m_ui->m_versions->rowCount() - 1; i >= 0; --i)
b9307871cf10 clear the rows of the version editor properly when clearing versions; don't save the config when closing the version editor since then changes will apply even if user presses cancel in the main config box
Teemu Piippo <crimsondusk64@gmail.com>
parents: 25
diff changeset
96 m_ui->m_versions->removeRow (i);
25
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
97 }
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
98
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
99 // =============================================================================
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
100 // -----------------------------------------------------------------------------
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
101 void VersionEditor::addVersion (str name, str path, bool isRelease) {
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
102 QTableWidget* const vers = m_ui->m_versions;
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
103
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
104 int row = vers->rowCount();
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
105 vers->insertRow (row);
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
106 vers->setItem (row, NameColumn, new QTableWidgetItem);
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
107 vers->setItem (row, PathColumn, new QTableWidgetItem);
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
108 vers->item (row, NameColumn)->setText (name);
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
109 vers->item (row, PathColumn)->setText (path);
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
110
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
111 QCheckBox* cb = new QCheckBox;
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
112 cb->setChecked (isRelease);
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
113 vers->setCellWidget (row, ReleaseColumn, cb);
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
114 }
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
115
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
116 // =============================================================================
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
117 // -----------------------------------------------------------------------------
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
118 void VersionEditor::saveChanges() {
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
119 QTableWidget* const vers = m_ui->m_versions;
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
120
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
121 cfg::devBuildNames.clear();
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
122 cfg::releaseNames.clear();
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
123 cfg::binaryPaths.clear();
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
124
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
125 for (int i = 0; i < vers->rowCount(); ++i) {
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
126 const QCheckBox* cb = getReleaseCheckbox (i);
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
127 bool isRelease = cb->isChecked();
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
128 const str name = vers->item (i, NameColumn)->text(),
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
129 path = vers->item (i, PathColumn)->text();
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
130
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
131 if (isRelease)
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
132 cfg::releaseNames << QVariant (name);
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
133 else
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
134 cfg::devBuildNames << QVariant (name);
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
135
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
136 cfg::binaryPaths[name] = path;
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
137 }
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
138 }
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
139
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
140 // =============================================================================
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
141 // -----------------------------------------------------------------------------
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
142 void VersionEditor::selectionChanged (int row) {
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
143 bool ok = (row != -1);
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
144 m_ui->m_edit->setEnabled (ok);
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
145 m_ui->m_remove->setEnabled (ok);
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
146 }
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
147
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
148 // =============================================================================
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
149 // -----------------------------------------------------------------------------
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
150 QCheckBox* VersionEditor::getReleaseCheckbox (int i) {
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
151 return static_cast<QCheckBox*> (m_ui->m_versions->cellWidget (i, ReleaseColumn));
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
152 }
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
153
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
154 // =============================================================================
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
155 // -----------------------------------------------------------------------------
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
156 AddVersionPrompt::AddVersionPrompt (QWidget* parent, Qt::WindowFlags f) :
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
157 QDialog (parent, f),
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
158 m_ui (new Ui_AddVersion)
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
159 {
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
160 m_ui->setupUi (this);
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
161 connect (m_ui->m_binaryName, SIGNAL (textChanged (QString)), this, SLOT (fieldsChanged()));
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
162 connect (m_ui->m_binaryPath, SIGNAL (textChanged (QString)), this, SLOT (fieldsChanged()));
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
163 connect (m_ui->m_findBinary, SIGNAL (clicked (bool)), this, SLOT (findPath()));
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
164 }
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
165
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
166 // =============================================================================
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
167 // -----------------------------------------------------------------------------
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
168 AddVersionPrompt::~AddVersionPrompt() {
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
169 delete m_ui;
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
170 }
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
171
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
172 // =============================================================================
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
173 // -----------------------------------------------------------------------------
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
174 void AddVersionPrompt::findPath() {
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
175 str path = ConfigBox::getBinaryPath (this);
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
176 if (!path.isEmpty())
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
177 m_ui->m_binaryPath->setText (path);
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
178 }
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
179
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
180 // =============================================================================
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
181 // -----------------------------------------------------------------------------
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
182 str AddVersionPrompt::name() {
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
183 return m_ui->m_binaryName->text();
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
184 }
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
185
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
186 // =============================================================================
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
187 // -----------------------------------------------------------------------------
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
188 str AddVersionPrompt::path() {
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
189 return m_ui->m_binaryPath->text();
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
190 }
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
191
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
192 // =============================================================================
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
193 // -----------------------------------------------------------------------------
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
194 bool AddVersionPrompt::release() {
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
195 return m_ui->m_release->isChecked();
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
196 }
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
197
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
198 // =============================================================================
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
199 // -----------------------------------------------------------------------------
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
200 void AddVersionPrompt::setName (const str& a) {
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
201 m_ui->m_binaryName->setText (a);
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
202 }
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
203
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
204 // =============================================================================
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
205 // -----------------------------------------------------------------------------
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
206 void AddVersionPrompt::setPath (const str& a) {
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
207 m_ui->m_binaryPath->setText (a);
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
208 }
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
209
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
210 // =============================================================================
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
211 // -----------------------------------------------------------------------------
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
212 void AddVersionPrompt::setRelease (bool a) {
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
213 m_ui->m_release->setChecked (a);
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
214 }
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
215
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
216 // =============================================================================
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
217 // -----------------------------------------------------------------------------
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
218 void AddVersionPrompt::fieldsChanged() {
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
219 bool ok = (!m_ui->m_binaryName->text().isEmpty()) && (!m_ui->m_binaryPath->text().isEmpty());
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
220 m_ui->buttonBox->button (QDialogButtonBox::Ok)->setEnabled (ok);
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
221 }

mercurial