diff options
Diffstat (limited to 'utils/regtools/qeditor')
-rw-r--r-- | utils/regtools/qeditor/main.cpp | 1 | ||||
-rw-r--r-- | utils/regtools/qeditor/mainwindow.cpp | 13 | ||||
-rw-r--r-- | utils/regtools/qeditor/qeditor.pro | 4 | ||||
-rw-r--r-- | utils/regtools/qeditor/regedit.cpp | 82 | ||||
-rw-r--r-- | utils/regtools/qeditor/regedit.h | 1 |
5 files changed, 94 insertions, 7 deletions
diff --git a/utils/regtools/qeditor/main.cpp b/utils/regtools/qeditor/main.cpp index 576d3a16fc..c1f8df66d6 100644 --- a/utils/regtools/qeditor/main.cpp +++ b/utils/regtools/qeditor/main.cpp | |||
@@ -5,6 +5,7 @@ | |||
5 | int main(int argc, char *argv[]) | 5 | int main(int argc, char *argv[]) |
6 | { | 6 | { |
7 | QApplication app(argc, argv); | 7 | QApplication app(argc, argv); |
8 | app.setApplicationVersion(APP_VERSION); | ||
8 | 9 | ||
9 | Backend backend;; | 10 | Backend backend;; |
10 | QDir dir(QCoreApplication::applicationDirPath()); | 11 | QDir dir(QCoreApplication::applicationDirPath()); |
diff --git a/utils/regtools/qeditor/mainwindow.cpp b/utils/regtools/qeditor/mainwindow.cpp index cd0926851c..1a88ebb47e 100644 --- a/utils/regtools/qeditor/mainwindow.cpp +++ b/utils/regtools/qeditor/mainwindow.cpp | |||
@@ -97,7 +97,18 @@ void MainWindow::OnQuit() | |||
97 | 97 | ||
98 | void MainWindow::OnAbout() | 98 | void MainWindow::OnAbout() |
99 | { | 99 | { |
100 | QMessageBox::about(this, "About", "Written by Amaury Pouly for Rockbox"); | 100 | QMessageBox::about(this, "About", |
101 | "<h1>QEditor</h1>" | ||
102 | "<h2>Version "APP_VERSION"</h2>" | ||
103 | "<p>Written by Amaury Pouly</p>" | ||
104 | "<p>Libraries:</p>" | ||
105 | "<ul><li>soc_desc: "SOCDESC_VERSION"</li>" | ||
106 | #ifdef HAVE_HWSTUB | ||
107 | "<li>hwstub: "HWSTUB_VERSION"</li>" | ||
108 | #else | ||
109 | "<li>hwstub: not compiled in</li>" | ||
110 | #endif | ||
111 | "</ul>"); | ||
101 | } | 112 | } |
102 | 113 | ||
103 | void MainWindow::OnAboutQt() | 114 | void MainWindow::OnAboutQt() |
diff --git a/utils/regtools/qeditor/qeditor.pro b/utils/regtools/qeditor/qeditor.pro index 38d7c987bf..279b3532c0 100644 --- a/utils/regtools/qeditor/qeditor.pro +++ b/utils/regtools/qeditor/qeditor.pro | |||
@@ -7,6 +7,10 @@ SOURCES += main.cpp mainwindow.cpp regtab.cpp backend.cpp analyser.cpp \ | |||
7 | LIBS += -L../lib/ -lsocdesc -lxml2 | 7 | LIBS += -L../lib/ -lsocdesc -lxml2 |
8 | INCLUDEPATH += ../lib/ ../../hwstub/lib | 8 | INCLUDEPATH += ../lib/ ../../hwstub/lib |
9 | 9 | ||
10 | VERSION = 2.0.1 | ||
11 | |||
12 | DEFINES += APP_VERSION=\\\"$$VERSION\\\" | ||
13 | |||
10 | unix { | 14 | unix { |
11 | !nohwstub { | 15 | !nohwstub { |
12 | message("Use 'qmake -config nohwstub' if you want to disable hwstub support") | 16 | message("Use 'qmake -config nohwstub' if you want to disable hwstub support") |
diff --git a/utils/regtools/qeditor/regedit.cpp b/utils/regtools/qeditor/regedit.cpp index 5e498ce496..bb1abc0825 100644 --- a/utils/regtools/qeditor/regedit.cpp +++ b/utils/regtools/qeditor/regedit.cpp | |||
@@ -206,6 +206,7 @@ void DevEditPanel::OnInstActivated(int row, int column) | |||
206 | { | 206 | { |
207 | m_ref.GetDev().addr.erase(m_ref.GetDev().addr.begin() + row); | 207 | m_ref.GetDev().addr.erase(m_ref.GetDev().addr.begin() + row); |
208 | m_instances_table->removeRow(row); | 208 | m_instances_table->removeRow(row); |
209 | emit OnModified(true); | ||
209 | } | 210 | } |
210 | else if(type == DevInstNewType) | 211 | else if(type == DevInstNewType) |
211 | { | 212 | { |
@@ -526,6 +527,7 @@ void RegEditPanel::OnInstActivated(int row, int column) | |||
526 | { | 527 | { |
527 | m_ref.GetReg().addr.erase(m_ref.GetReg().addr.begin() + row); | 528 | m_ref.GetReg().addr.erase(m_ref.GetReg().addr.begin() + row); |
528 | m_instances_table->removeRow(row); | 529 | m_instances_table->removeRow(row); |
530 | emit OnModified(true); | ||
529 | } | 531 | } |
530 | else if(type == RegInstNewType) | 532 | else if(type == RegInstNewType) |
531 | { | 533 | { |
@@ -729,6 +731,7 @@ void FieldEditPanel::OnValueActivated(int row, int column) | |||
729 | { | 731 | { |
730 | m_ref.GetField().value.erase(m_ref.GetField().value.begin() + row); | 732 | m_ref.GetField().value.erase(m_ref.GetField().value.begin() + row); |
731 | m_value_table->removeRow(row); | 733 | m_value_table->removeRow(row); |
734 | emit OnModified(true); | ||
732 | } | 735 | } |
733 | else if(type == FieldValueNewType) | 736 | else if(type == FieldValueNewType) |
734 | { | 737 | { |
@@ -921,6 +924,11 @@ RegEdit::RegEdit(Backend *backend, QWidget *parent) | |||
921 | m_soc_tree = new QTreeWidget(this); | 924 | m_soc_tree = new QTreeWidget(this); |
922 | m_soc_tree->setColumnCount(1); | 925 | m_soc_tree->setColumnCount(1); |
923 | m_soc_tree->setHeaderLabel(QString("Name")); | 926 | m_soc_tree->setHeaderLabel(QString("Name")); |
927 | m_soc_tree->setContextMenuPolicy(Qt::ActionsContextMenu); | ||
928 | QAction *soc_tree_delete_action = new QAction("&Delete", this); | ||
929 | soc_tree_delete_action->setIcon(QIcon::fromTheme("list-remove")); | ||
930 | connect(soc_tree_delete_action, SIGNAL(triggered()), this, SLOT(OnSocItemDelete())); | ||
931 | m_soc_tree->addAction(soc_tree_delete_action); | ||
924 | m_splitter->addWidget(m_soc_tree); | 932 | m_splitter->addWidget(m_soc_tree); |
925 | m_splitter->setStretchFactor(0, 0); | 933 | m_splitter->setStretchFactor(0, 0); |
926 | 934 | ||
@@ -962,12 +970,11 @@ bool RegEdit::CloseSoc() | |||
962 | { | 970 | { |
963 | if(!m_modified) | 971 | if(!m_modified) |
964 | return true; | 972 | return true; |
965 | QMessageBox msgBox; | 973 | QMessageBox msgbox(QMessageBox::Question, "Save changes ?", |
966 | msgBox.setText("The description has been modified."); | 974 | "The description has been modified. Do you want to save your changes ?", |
967 | msgBox.setInformativeText("Do you want to save your changes?"); | 975 | QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, this); |
968 | msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); | 976 | msgbox.setDefaultButton(QMessageBox::Cancel); |
969 | msgBox.setDefaultButton(QMessageBox::Save); | 977 | int ret = msgbox.exec(); |
970 | int ret = msgBox.exec(); | ||
971 | if(ret == QMessageBox::Discard) | 978 | if(ret == QMessageBox::Discard) |
972 | return true; | 979 | return true; |
973 | if(ret == QMessageBox::Cancel) | 980 | if(ret == QMessageBox::Cancel) |
@@ -1188,6 +1195,66 @@ void RegEdit::SetModified(bool add, bool mod) | |||
1188 | emit OnModified(mod); | 1195 | emit OnModified(mod); |
1189 | } | 1196 | } |
1190 | 1197 | ||
1198 | namespace | ||
1199 | { | ||
1200 | |||
1201 | template< typename T > | ||
1202 | void my_remove_at(std::vector< T >& v, size_t at) | ||
1203 | { | ||
1204 | v.erase(v.begin() + at); | ||
1205 | } | ||
1206 | |||
1207 | } | ||
1208 | |||
1209 | void RegEdit::OnSocItemDelete() | ||
1210 | { | ||
1211 | QTreeWidgetItem *current = m_soc_tree->currentItem(); | ||
1212 | if(current == 0) | ||
1213 | return; | ||
1214 | QMessageBox msgbox(QMessageBox::Question, "Delete item ?", | ||
1215 | "Are you sure you want to delete this item ?", | ||
1216 | QMessageBox::Yes | QMessageBox::No, this); | ||
1217 | msgbox.setDefaultButton(QMessageBox::No); | ||
1218 | int ret = msgbox.exec(); | ||
1219 | if(ret != QMessageBox::Yes) | ||
1220 | return; | ||
1221 | if(current->type() == SocTreeSocType) | ||
1222 | { | ||
1223 | SocTreeItem *item = dynamic_cast< SocTreeItem * >(current); | ||
1224 | item->GetRef().GetSoc().dev.clear(); | ||
1225 | item->takeChildren(); | ||
1226 | FillSocTreeItem(item); | ||
1227 | m_soc_tree->expandItem(item); | ||
1228 | } | ||
1229 | else if(current->type() == SocTreeDevType) | ||
1230 | { | ||
1231 | DevTreeItem *item = dynamic_cast< DevTreeItem * >(current); | ||
1232 | my_remove_at(item->GetRef().GetSoc().dev, item->GetRef().GetDevIndex()); | ||
1233 | QTreeWidgetItem *parent = item->parent(); | ||
1234 | parent->takeChildren(); | ||
1235 | FillSocTreeItem(parent); | ||
1236 | m_soc_tree->expandItem(parent); | ||
1237 | } | ||
1238 | else if(current->type() == SocTreeRegType) | ||
1239 | { | ||
1240 | RegTreeItem *item = dynamic_cast< RegTreeItem * >(current); | ||
1241 | my_remove_at(item->GetRef().GetDev().reg, item->GetRef().GetRegIndex()); | ||
1242 | QTreeWidgetItem *parent = item->parent(); | ||
1243 | parent->takeChildren(); | ||
1244 | FillDevTreeItem(parent); | ||
1245 | m_soc_tree->expandItem(parent); | ||
1246 | } | ||
1247 | else if(current->type() == SocTreeFieldType) | ||
1248 | { | ||
1249 | FieldTreeItem *item = dynamic_cast< FieldTreeItem * >(current); | ||
1250 | my_remove_at(item->GetRef().GetReg().field, item->GetRef().GetFieldIndex()); | ||
1251 | QTreeWidgetItem *parent = item->parent(); | ||
1252 | parent->takeChildren(); | ||
1253 | FillRegTreeItem(parent); | ||
1254 | m_soc_tree->expandItem(parent); | ||
1255 | } | ||
1256 | } | ||
1257 | |||
1191 | void RegEdit::OnSocModified(bool modified) | 1258 | void RegEdit::OnSocModified(bool modified) |
1192 | { | 1259 | { |
1193 | // we might need to update the name in the tree | 1260 | // we might need to update the name in the tree |
@@ -1293,6 +1360,7 @@ void RegEdit::AddDevice(QTreeWidgetItem *_item) | |||
1293 | item->parent()->insertChild(item->parent()->indexOfChild(item), dev_item); | 1360 | item->parent()->insertChild(item->parent()->indexOfChild(item), dev_item); |
1294 | CreateNewRegisterItem(dev_item); | 1361 | CreateNewRegisterItem(dev_item); |
1295 | m_soc_tree->setCurrentItem(dev_item); | 1362 | m_soc_tree->setCurrentItem(dev_item); |
1363 | emit OnModified(true); | ||
1296 | } | 1364 | } |
1297 | 1365 | ||
1298 | void RegEdit::AddRegister(QTreeWidgetItem *_item) | 1366 | void RegEdit::AddRegister(QTreeWidgetItem *_item) |
@@ -1305,6 +1373,7 @@ void RegEdit::AddRegister(QTreeWidgetItem *_item) | |||
1305 | item->parent()->insertChild(item->parent()->indexOfChild(item), reg_item); | 1373 | item->parent()->insertChild(item->parent()->indexOfChild(item), reg_item); |
1306 | CreateNewFieldItem(reg_item); | 1374 | CreateNewFieldItem(reg_item); |
1307 | m_soc_tree->setCurrentItem(reg_item); | 1375 | m_soc_tree->setCurrentItem(reg_item); |
1376 | emit OnModified(true); | ||
1308 | } | 1377 | } |
1309 | 1378 | ||
1310 | void RegEdit::AddField(QTreeWidgetItem *_item) | 1379 | void RegEdit::AddField(QTreeWidgetItem *_item) |
@@ -1316,6 +1385,7 @@ void RegEdit::AddField(QTreeWidgetItem *_item) | |||
1316 | FixupEmptyItem(field_item); | 1385 | FixupEmptyItem(field_item); |
1317 | item->parent()->insertChild(item->parent()->indexOfChild(item), field_item); | 1386 | item->parent()->insertChild(item->parent()->indexOfChild(item), field_item); |
1318 | m_soc_tree->setCurrentItem(field_item); | 1387 | m_soc_tree->setCurrentItem(field_item); |
1388 | emit OnModified(true); | ||
1319 | } | 1389 | } |
1320 | 1390 | ||
1321 | bool RegEdit::Quit() | 1391 | bool RegEdit::Quit() |
diff --git a/utils/regtools/qeditor/regedit.h b/utils/regtools/qeditor/regedit.h index 8615816783..b5ccd249fa 100644 --- a/utils/regtools/qeditor/regedit.h +++ b/utils/regtools/qeditor/regedit.h | |||
@@ -238,6 +238,7 @@ protected slots: | |||
238 | void OnSaveAs(); | 238 | void OnSaveAs(); |
239 | void OnSocModified(bool modified); | 239 | void OnSocModified(bool modified); |
240 | void OnNew(); | 240 | void OnNew(); |
241 | void OnSocItemDelete(); | ||
241 | 242 | ||
242 | protected: | 243 | protected: |
243 | void LoadSocFile(const QString& filename); | 244 | void LoadSocFile(const QString& filename); |