summaryrefslogtreecommitdiff
path: root/utils/regtools/qeditor/mainwindow.cpp
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2016-02-06 15:08:43 +0000
committerAmaury Pouly <amaury.pouly@gmail.com>2016-02-06 15:20:48 +0000
commit6b9610fb908b27d1e0383c8d9bde3a88f35ed30c (patch)
tree1b0f5e2821b44d20f3704c584e309f5911357040 /utils/regtools/qeditor/mainwindow.cpp
parent0f701a64bee43e79f95970ae9c0ec43ea7fcdf17 (diff)
downloadrockbox-6b9610fb908b27d1e0383c8d9bde3a88f35ed30c.tar.gz
rockbox-6b9610fb908b27d1e0383c8d9bde3a88f35ed30c.zip
regtoosl/qeditor: port to the new description format
This big commit port qeditor from v1 to v2 register file format. Although the display code was much simplified, the edit code had to be rewritten. The new code also brings many improvement to the register display widget. The new code also compiles with both Qt4 and Qt5, although it is recommended to use Qt5 to get some improvements, especially in the layout of editor. Change-Id: I24633ac37a144f25d9e705b565654269ec9cfbd3
Diffstat (limited to 'utils/regtools/qeditor/mainwindow.cpp')
-rw-r--r--utils/regtools/qeditor/mainwindow.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/utils/regtools/qeditor/mainwindow.cpp b/utils/regtools/qeditor/mainwindow.cpp
index b44306d701..8b83be6bae 100644
--- a/utils/regtools/qeditor/mainwindow.cpp
+++ b/utils/regtools/qeditor/mainwindow.cpp
@@ -43,7 +43,7 @@ void DocumentTab::OnModified(bool modified)
43 m_tab->SetTabModified(this, modified); 43 m_tab->SetTabModified(this, modified);
44} 44}
45 45
46void DocumentTab::SetTabWidget(MyTabWidget *tab) 46void DocumentTab::SetTabWidget(DocumentTabWidget *tab)
47{ 47{
48 m_tab = tab; 48 m_tab = tab;
49 SetTabName(m_tabname); 49 SetTabName(m_tabname);
@@ -57,17 +57,17 @@ void DocumentTab::SetTabName(const QString& name)
57} 57}
58 58
59/** 59/**
60 * MyTabWidget 60 * DocumentTabWidget
61 */ 61 */
62 62
63MyTabWidget::MyTabWidget() 63DocumentTabWidget::DocumentTabWidget()
64{ 64{
65 setMovable(true); 65 setMovable(true);
66 setTabsClosable(true); 66 setTabsClosable(true);
67 connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(OnCloseTab(int))); 67 connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(OnCloseTab(int)));
68} 68}
69 69
70void MyTabWidget::SetTabModified(DocumentTab *doc, bool modified) 70void DocumentTabWidget::SetTabModified(DocumentTab *doc, bool modified)
71{ 71{
72 int index = indexOf(doc->GetWidget()); 72 int index = indexOf(doc->GetWidget());
73 if(modified) 73 if(modified)
@@ -76,12 +76,12 @@ void MyTabWidget::SetTabModified(DocumentTab *doc, bool modified)
76 setTabIcon(index, QIcon()); 76 setTabIcon(index, QIcon());
77} 77}
78 78
79void MyTabWidget::SetTabName(DocumentTab *doc, const QString& name) 79void DocumentTabWidget::SetTabName(DocumentTab *doc, const QString& name)
80{ 80{
81 setTabText(indexOf(doc->GetWidget()), name); 81 setTabText(indexOf(doc->GetWidget()), name);
82} 82}
83 83
84bool MyTabWidget::CloseTab(int index) 84bool DocumentTabWidget::CloseTab(int index)
85{ 85{
86 QWidget *w = this->widget(index); 86 QWidget *w = this->widget(index);
87 DocumentTab *doc = dynamic_cast< DocumentTab* >(w); 87 DocumentTab *doc = dynamic_cast< DocumentTab* >(w);
@@ -95,7 +95,7 @@ bool MyTabWidget::CloseTab(int index)
95 return false; 95 return false;
96} 96}
97 97
98void MyTabWidget::OnCloseTab(int index) 98void DocumentTabWidget::OnCloseTab(int index)
99{ 99{
100 CloseTab(index); 100 CloseTab(index);
101} 101}
@@ -135,7 +135,9 @@ MainWindow::MainWindow(Backend *backend)
135 about_menu->addAction(about_act); 135 about_menu->addAction(about_act);
136 about_menu->addAction(about_qt_act); 136 about_menu->addAction(about_qt_act);
137 137
138 m_tab = new MyTabWidget(); 138 m_tab = new DocumentTabWidget();
139 m_tab->setTabOpenable(true);
140 m_tab->setTabOpenMenu(new_submenu);
139 141
140 setCentralWidget(m_tab); 142 setCentralWidget(m_tab);
141 143
@@ -161,8 +163,8 @@ void MainWindow::OnQuit()
161 163
162void MainWindow::OnAbout() 164void MainWindow::OnAbout()
163{ 165{
164 QString soc_desc_ver = QString("%1.%2.%3").arg(MAJOR_VERSION) 166 QString soc_desc_ver = QString("%1.%2.%3").arg(soc_desc::MAJOR_VERSION)
165 .arg(MINOR_VERSION).arg(REVISION_VERSION); 167 .arg(soc_desc::MINOR_VERSION).arg(soc_desc::REVISION_VERSION);
166 QMessageBox::about(this, "About", 168 QMessageBox::about(this, "About",
167 "<h1>QEditor</h1>" 169 "<h1>QEditor</h1>"
168 "<h2>Version "APP_VERSION"</h2>" 170 "<h2>Version "APP_VERSION"</h2>"
@@ -193,7 +195,10 @@ void MainWindow::closeEvent(QCloseEvent *event)
193void MainWindow::OnLoadDesc() 195void MainWindow::OnLoadDesc()
194{ 196{
195 QFileDialog *fd = new QFileDialog(this); 197 QFileDialog *fd = new QFileDialog(this);
196 fd->setFilter("XML files (*.xml);;All files (*)"); 198 QStringList filters;
199 filters << "XML files (*.xml)";
200 filters << "All files (*)";
201 fd->setNameFilters(filters);
197 fd->setFileMode(QFileDialog::ExistingFiles); 202 fd->setFileMode(QFileDialog::ExistingFiles);
198 fd->setDirectory(Settings::Get()->value("loaddescdir", QDir::currentPath()).toString()); 203 fd->setDirectory(Settings::Get()->value("loaddescdir", QDir::currentPath()).toString());
199 if(fd->exec()) 204 if(fd->exec())