summaryrefslogtreecommitdiff
path: root/utils/regtools
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2014-09-27 13:28:44 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2014-12-15 22:52:35 +0100
commit3b4e63173d5f762a368d159e21f76e2df3fcf8ab (patch)
tree286fcb801ec69ae20e67a00229403310e7de886b /utils/regtools
parentfe1fed88732ac84f5a4196c5936c99e9750a6525 (diff)
downloadrockbox-3b4e63173d5f762a368d159e21f76e2df3fcf8ab.tar.gz
rockbox-3b4e63173d5f762a368d159e21f76e2df3fcf8ab.zip
qeditor: rework mainwindow tab names handling
With the previous code, tab names would be ignored if tab is detached which can happen early on. Change-Id: I9eac4202850f3e79a04590a4ba1444850ec6a583 Reviewed-on: http://gerrit.rockbox.org/986 Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
Diffstat (limited to 'utils/regtools')
-rw-r--r--utils/regtools/qeditor/mainwindow.cpp15
-rw-r--r--utils/regtools/qeditor/mainwindow.h5
-rw-r--r--utils/regtools/qeditor/regedit.cpp6
-rw-r--r--utils/regtools/qeditor/regtab.cpp1
4 files changed, 20 insertions, 7 deletions
diff --git a/utils/regtools/qeditor/mainwindow.cpp b/utils/regtools/qeditor/mainwindow.cpp
index 07adc71368..9cea728d6e 100644
--- a/utils/regtools/qeditor/mainwindow.cpp
+++ b/utils/regtools/qeditor/mainwindow.cpp
@@ -43,8 +43,15 @@ 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)
47{
48 m_tab = tab;
49 SetTabName(m_tabname);
50}
51
46void DocumentTab::SetTabName(const QString& name) 52void DocumentTab::SetTabName(const QString& name)
47{ 53{
54 m_tabname = name;
48 if(m_tab) 55 if(m_tab)
49 m_tab->SetTabName(this, name); 56 m_tab->SetTabName(this, name);
50} 57}
@@ -201,20 +208,20 @@ void MainWindow::OnLoadDesc()
201 } 208 }
202} 209}
203 210
204void MainWindow::AddTab(DocumentTab *doc, const QString& title) 211void MainWindow::AddTab(DocumentTab *doc)
205{ 212{
206 m_tab->setCurrentIndex(m_tab->addTab(doc->GetWidget(), title)); 213 m_tab->setCurrentIndex(m_tab->addTab(doc->GetWidget(), ""));
207 doc->SetTabWidget(m_tab); 214 doc->SetTabWidget(m_tab);
208} 215}
209 216
210void MainWindow::OnNewRegTab() 217void MainWindow::OnNewRegTab()
211{ 218{
212 AddTab(new RegTab(m_backend, this), "Register Tab"); 219 AddTab(new RegTab(m_backend, this));
213} 220}
214 221
215void MainWindow::OnNewRegEdit() 222void MainWindow::OnNewRegEdit()
216{ 223{
217 AddTab(new RegEdit(m_backend, this), "Register Editor"); 224 AddTab(new RegEdit(m_backend, this));
218} 225}
219 226
220bool MainWindow::Quit() 227bool MainWindow::Quit()
diff --git a/utils/regtools/qeditor/mainwindow.h b/utils/regtools/qeditor/mainwindow.h
index 67d33244ba..c5da66758e 100644
--- a/utils/regtools/qeditor/mainwindow.h
+++ b/utils/regtools/qeditor/mainwindow.h
@@ -35,12 +35,13 @@ public:
35 DocumentTab() { m_tab = 0; } 35 DocumentTab() { m_tab = 0; }
36 virtual bool Quit() = 0; 36 virtual bool Quit() = 0;
37 virtual QWidget *GetWidget() = 0; 37 virtual QWidget *GetWidget() = 0;
38 void SetTabWidget(MyTabWidget *tab) { m_tab = tab; } 38 void SetTabWidget(MyTabWidget *tab);
39 39
40protected: 40protected:
41 void OnModified(bool modified); 41 void OnModified(bool modified);
42 void SetTabName(const QString& name); 42 void SetTabName(const QString& name);
43 MyTabWidget *m_tab; 43 MyTabWidget *m_tab;
44 QString m_tabname;
44}; 45};
45 46
46class MyTabWidget : public QTabWidget 47class MyTabWidget : public QTabWidget
@@ -70,7 +71,7 @@ private:
70 void closeEvent(QCloseEvent *event); 71 void closeEvent(QCloseEvent *event);
71 72
72protected: 73protected:
73 void AddTab(DocumentTab *tab, const QString& title); 74 void AddTab(DocumentTab *tab);
74 bool Quit(); 75 bool Quit();
75 76
76private slots: 77private slots:
diff --git a/utils/regtools/qeditor/regedit.cpp b/utils/regtools/qeditor/regedit.cpp
index b1f9afd45c..5a32defb58 100644
--- a/utils/regtools/qeditor/regedit.cpp
+++ b/utils/regtools/qeditor/regedit.cpp
@@ -961,6 +961,7 @@ RegEdit::RegEdit(Backend *backend, QWidget *parent)
961 SetModified(false, false); 961 SetModified(false, false);
962 m_right_panel = 0; 962 m_right_panel = 0;
963 SetPanel(new EmptyEditPanel(this)); 963 SetPanel(new EmptyEditPanel(this));
964 UpdateTabName();
964 965
965 connect(m_file_open, SIGNAL(clicked()), this, SLOT(OnOpen())); 966 connect(m_file_open, SIGNAL(clicked()), this, SLOT(OnOpen()));
966 connect(m_file_save, SIGNAL(clicked()), this, SLOT(OnSave())); 967 connect(m_file_save, SIGNAL(clicked()), this, SLOT(OnSave()));
@@ -1080,7 +1081,10 @@ bool RegEdit::SaveSocFile(const QString& filename)
1080void RegEdit::UpdateTabName() 1081void RegEdit::UpdateTabName()
1081{ 1082{
1082 QFileInfo info(m_cur_socfile.GetFilename()); 1083 QFileInfo info(m_cur_socfile.GetFilename());
1083 SetTabName(info.fileName()); 1084 if(info.exists())
1085 SetTabName(info.fileName());
1086 else
1087 SetTabName("Register Editor");
1084} 1088}
1085 1089
1086void RegEdit::LoadSocFile(const QString& filename) 1090void RegEdit::LoadSocFile(const QString& filename)
diff --git a/utils/regtools/qeditor/regtab.cpp b/utils/regtools/qeditor/regtab.cpp
index e7621322d7..c92dad49d5 100644
--- a/utils/regtools/qeditor/regtab.cpp
+++ b/utils/regtools/qeditor/regtab.cpp
@@ -178,6 +178,7 @@ RegTab::RegTab(Backend *backend, QWidget *parent)
178 178
179 OnSocListChanged(); 179 OnSocListChanged();
180 SetDataSocName(""); 180 SetDataSocName("");
181 UpdateTabName();
181} 182}
182 183
183QWidget *RegTab::GetWidget() 184QWidget *RegTab::GetWidget()