diff options
| author | Amaury Pouly <amaury.pouly@gmail.com> | 2014-09-18 21:36:17 +0200 |
|---|---|---|
| committer | Amaury Pouly <amaury.pouly@gmail.com> | 2014-09-19 10:58:33 +0200 |
| commit | 970c2482dd22a84a5973b73621d0dd06e6f45a25 (patch) | |
| tree | 3131c033b3f3e385eceed7beb16e8b143ff0caf1 /utils/regtools/qeditor/mainwindow.cpp | |
| parent | dbb59291e745c7cc640a35fc40faa083648793bf (diff) | |
| download | rockbox-970c2482dd22a84a5973b73621d0dd06e6f45a25.zip rockbox-970c2482dd22a84a5973b73621d0dd06e6f45a25.tar.gz rockbox-970c2482dd22a84a5973b73621d0dd06e6f45a25.tar.bz2 rockbox-970c2482dd22a84a5973b73621d0dd06e6f45a25.tar.xz | |
qeditor: rework modified indicator, register tab names depend on content
Because Qt doesn't support QObject multiple inherance, it is a bit tricky
to have a base class which interact with the UI. The register tab name
now display:
- file dump name (for dumps)
- hwstub device path (for hwstub)
And the register editor display the filename
Change-Id: If2579992098c02627c67d560c824f1668e73bc45
Reviewed-on: http://gerrit.rockbox.org/979
Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
Diffstat (limited to 'utils/regtools/qeditor/mainwindow.cpp')
| -rw-r--r-- | utils/regtools/qeditor/mainwindow.cpp | 53 |
1 files changed, 40 insertions, 13 deletions
diff --git a/utils/regtools/qeditor/mainwindow.cpp b/utils/regtools/qeditor/mainwindow.cpp index 1a88ebb..58f9766 100644 --- a/utils/regtools/qeditor/mainwindow.cpp +++ b/utils/regtools/qeditor/mainwindow.cpp @@ -14,6 +14,25 @@ #include "regtab.h" #include "regedit.h" +/** + * DocumentTab + */ +void DocumentTab::OnModified(bool modified) +{ + if(m_tab) + m_tab->SetTabModified(this, modified); +} + +void DocumentTab::SetTabName(const QString& name) +{ + if(m_tab) + m_tab->SetTabName(this, name); +} + +/** + * MyTabWidget + */ + MyTabWidget::MyTabWidget() { setMovable(true); @@ -21,6 +40,20 @@ MyTabWidget::MyTabWidget() connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(OnCloseTab(int))); } +void MyTabWidget::SetTabModified(DocumentTab *doc, bool modified) +{ + int index = indexOf(doc->GetWidget()); + if(modified) + setTabIcon(index, QIcon::fromTheme("document-save")); + else + setTabIcon(index, QIcon()); +} + +void MyTabWidget::SetTabName(DocumentTab *doc, const QString& name) +{ + setTabText(indexOf(doc->GetWidget()), name); +} + bool MyTabWidget::CloseTab(int index) { QWidget *w = this->widget(index); @@ -40,6 +73,10 @@ void MyTabWidget::OnCloseTab(int index) CloseTab(index); } +/** + * MainWindow + */ + MainWindow::MainWindow(Backend *backend) :m_backend(backend) { @@ -144,20 +181,10 @@ void MainWindow::OnLoadDesc() } } -void MainWindow::OnTabModified(bool modified) -{ - QWidget *sender = qobject_cast< QWidget* >(QObject::sender()); - int index = m_tab->indexOf(sender); - if(modified) - m_tab->setTabIcon(index, QIcon::fromTheme("document-save")); - else - m_tab->setTabIcon(index, QIcon()); -} - -void MainWindow::AddTab(QWidget *tab, const QString& title) +void MainWindow::AddTab(DocumentTab *doc, const QString& title) { - connect(tab, SIGNAL(OnModified(bool)), this, SLOT(OnTabModified(bool))); - m_tab->setCurrentIndex(m_tab->addTab(tab, title)); + m_tab->setCurrentIndex(m_tab->addTab(doc->GetWidget(), title)); + doc->SetTabWidget(m_tab); } void MainWindow::OnNewRegTab() |