Sun, 08 Sep 2013 19:56:11 +0300
Added a version data editor
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 | if (!confirm (fmt (tr ("Really remove version %1?"), name))) |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
87 | return; |
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 | vers->removeRow (vers->currentRow()); |
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 | |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | // ============================================================================= |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
93 | // ----------------------------------------------------------------------------- |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
94 | void VersionEditor::clear() { |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
95 | if (!confirm (tr ("Really remove all versions?"))) |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
96 | return; |
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 | m_ui->m_versions->clear(); |
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 | // ============================================================================= |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
102 | // ----------------------------------------------------------------------------- |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
103 | void VersionEditor::addVersion (str name, str path, bool isRelease) { |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
104 | QTableWidget* const vers = m_ui->m_versions; |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
105 | |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
106 | int row = vers->rowCount(); |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
107 | vers->insertRow (row); |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
108 | vers->setItem (row, NameColumn, new QTableWidgetItem); |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
109 | vers->setItem (row, PathColumn, new QTableWidgetItem); |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
110 | vers->item (row, NameColumn)->setText (name); |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
111 | vers->item (row, PathColumn)->setText (path); |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
112 | |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
113 | QCheckBox* cb = new QCheckBox; |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
114 | cb->setChecked (isRelease); |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
115 | vers->setCellWidget (row, ReleaseColumn, cb); |
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 | // ============================================================================= |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
119 | // ----------------------------------------------------------------------------- |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
120 | void VersionEditor::saveChanges() { |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
121 | QTableWidget* const vers = m_ui->m_versions; |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
122 | |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
123 | cfg::devBuildNames.clear(); |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
124 | cfg::releaseNames.clear(); |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
125 | cfg::binaryPaths.clear(); |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
126 | |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
127 | for (int i = 0; i < vers->rowCount(); ++i) { |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
128 | const QCheckBox* cb = getReleaseCheckbox (i); |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
129 | bool isRelease = cb->isChecked(); |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
130 | const str name = vers->item (i, NameColumn)->text(), |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
131 | path = vers->item (i, PathColumn)->text(); |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
132 | |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
133 | if (isRelease) |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
134 | cfg::releaseNames << QVariant (name); |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
135 | else |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
136 | cfg::devBuildNames << QVariant (name); |
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 | cfg::binaryPaths[name] = path; |
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 | cfg::save(); |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
142 | } |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
143 | |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
144 | // ============================================================================= |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
145 | // ----------------------------------------------------------------------------- |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
146 | void VersionEditor::selectionChanged (int row) { |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
147 | bool ok = (row != -1); |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
148 | m_ui->m_edit->setEnabled (ok); |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
149 | m_ui->m_remove->setEnabled (ok); |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
150 | } |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
151 | |
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 | QCheckBox* VersionEditor::getReleaseCheckbox (int i) { |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
155 | 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
|
156 | } |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
157 | |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
158 | // ============================================================================= |
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 | AddVersionPrompt::AddVersionPrompt (QWidget* parent, Qt::WindowFlags f) : |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
161 | QDialog (parent, f), |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
162 | m_ui (new Ui_AddVersion) |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
163 | { |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
164 | m_ui->setupUi (this); |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
165 | 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
|
166 | 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
|
167 | 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
|
168 | } |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
169 | |
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 | AddVersionPrompt::~AddVersionPrompt() { |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
173 | delete m_ui; |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
174 | } |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
175 | |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
176 | // ============================================================================= |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
177 | // ----------------------------------------------------------------------------- |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
178 | void AddVersionPrompt::findPath() { |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
179 | str path = ConfigBox::getBinaryPath (this); |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
180 | if (!path.isEmpty()) |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
181 | m_ui->m_binaryPath->setText (path); |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
182 | } |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
183 | |
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 | str AddVersionPrompt::name() { |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
187 | return m_ui->m_binaryName->text(); |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
188 | } |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
189 | |
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 | str AddVersionPrompt::path() { |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
193 | return m_ui->m_binaryPath->text(); |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
194 | } |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
195 | |
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 | bool AddVersionPrompt::release() { |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
199 | return m_ui->m_release->isChecked(); |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
200 | } |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
201 | |
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 | void AddVersionPrompt::setName (const str& a) { |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
205 | m_ui->m_binaryName->setText (a); |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
206 | } |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
207 | |
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 | void AddVersionPrompt::setPath (const str& a) { |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
211 | m_ui->m_binaryPath->setText (a); |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
212 | } |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
213 | |
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 | void AddVersionPrompt::setRelease (bool a) { |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
217 | m_ui->m_release->setChecked (a); |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
218 | } |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
219 | |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
220 | // ============================================================================= |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
221 | // ----------------------------------------------------------------------------- |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
222 | void AddVersionPrompt::fieldsChanged() { |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
223 | 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
|
224 | m_ui->buttonBox->button (QDialogButtonBox::Ok)->setEnabled (ok); |
256bb5c6b77f
Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
225 | } |