diff options
Diffstat (limited to 'utils/regtools/qeditor/regedit.cpp')
-rw-r--r-- | utils/regtools/qeditor/regedit.cpp | 82 |
1 files changed, 76 insertions, 6 deletions
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() |