summaryrefslogtreecommitdiffstats
path: root/gui/pagedialog
diff options
context:
space:
mode:
Diffstat (limited to 'gui/pagedialog')
-rw-r--r--gui/pagedialog/PageDialog.cpp27
-rw-r--r--gui/pagedialog/PageDialog.h7
-rw-r--r--gui/pagedialog/PageDialog_p.h2
3 files changed, 28 insertions, 8 deletions
diff --git a/gui/pagedialog/PageDialog.cpp b/gui/pagedialog/PageDialog.cpp
index 1169af2c..450f2b08 100644
--- a/gui/pagedialog/PageDialog.cpp
+++ b/gui/pagedialog/PageDialog.cpp
@@ -50,7 +50,7 @@ protected:
}
};
-PageDialog::PageDialog(BasePageProviderPtr pageProvider, QWidget *parent) : QDialog(parent)
+PageDialog::PageDialog(BasePageProviderPtr pageProvider, QString defaultId, QWidget *parent) : QDialog(parent)
{
MultiMCPlatform::fixWM_CLASS(this);
createUI();
@@ -60,13 +60,16 @@ PageDialog::PageDialog(BasePageProviderPtr pageProvider, QWidget *parent) : QDia
m_model = new PageModel(this);
m_proxyModel = new PageEntryFilterModel(this);
int firstIndex = -1;
+ int counter = 0;
auto pages = pageProvider->getPages();
for(auto page: pages)
{
- page->index = m_pageStack->addWidget(dynamic_cast<QWidget *>(page));
+ page->stackIndex = m_pageStack->addWidget(dynamic_cast<QWidget *>(page));
+ page->listIndex = counter;
+ counter++;
if(firstIndex == -1)
{
- firstIndex = page->index;
+ firstIndex = page->stackIndex;
}
}
m_model->setPages(pages);
@@ -80,9 +83,21 @@ PageDialog::PageDialog(BasePageProviderPtr pageProvider, QWidget *parent) : QDia
m_pageList->setModel(m_proxyModel);
connect(m_pageList->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
this, SLOT(currentChanged(QModelIndex)));
-
m_pageStack->setStackingMode(QStackedLayout::StackOne);
m_pageList->setFocus();
+ // now find what we want to have selected...
+ auto page = m_model->findPageEntryById(defaultId);
+ QModelIndex index;
+ if(page)
+ {
+ index = m_proxyModel->mapFromSource(m_model->index(page->listIndex));
+ }
+ else
+ {
+ index = m_proxyModel->index(0,0);
+ }
+ if(index.isValid())
+ m_pageList->setCurrentIndex(index);
}
void PageDialog::createUI()
@@ -112,6 +127,7 @@ void PageDialog::createUI()
m_pageStack->setMargin(0);
m_pageStack->addWidget(new QWidget(this));
+ /*
QDialogButtonBox *buttons =
new QDialogButtonBox(QDialogButtonBox::Help | QDialogButtonBox::Ok |
QDialogButtonBox::Apply | QDialogButtonBox::Cancel);
@@ -119,6 +135,7 @@ void PageDialog::createUI()
connect(buttons->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply()));
connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
+ */
QGridLayout *mainGridLayout = new QGridLayout;
mainGridLayout->addLayout(headerHLayout, 0, 1, 1, 1);
@@ -132,7 +149,7 @@ void PageDialog::createUI()
void PageDialog::showPage(int row)
{
auto page = m_model->pages().at(row);
- m_pageStack->setCurrentIndex(page->index);
+ m_pageStack->setCurrentIndex(page->stackIndex);
m_header->setText(page->displayName());
m_iconHeader->setIcon(page->icon());
}
diff --git a/gui/pagedialog/PageDialog.h b/gui/pagedialog/PageDialog.h
index fd97fc3b..bb31a607 100644
--- a/gui/pagedialog/PageDialog.h
+++ b/gui/pagedialog/PageDialog.h
@@ -30,11 +30,14 @@ class PageDialog : public QDialog
{
Q_OBJECT
public:
- explicit PageDialog(BasePageProviderPtr pageProvider, QWidget *parent = 0);
+ explicit PageDialog(BasePageProviderPtr pageProvider, QString defaultId = QString(),
+ QWidget *parent = 0);
virtual ~PageDialog() {};
+
private:
void createUI();
-private slots:
+private
+slots:
void apply();
virtual void reject();
virtual void accept();
diff --git a/gui/pagedialog/PageDialog_p.h b/gui/pagedialog/PageDialog_p.h
index 36e641e3..f10e8f2c 100644
--- a/gui/pagedialog/PageDialog_p.h
+++ b/gui/pagedialog/PageDialog_p.h
@@ -4,6 +4,7 @@
#include <QEvent>
#include <QScrollBar>
+class BasePage;
const int pageIconSize = 24;
class PageViewDelegate : public QStyledItemDelegate
@@ -63,7 +64,6 @@ public:
return m_pages;
}
-private:
BasePage * findPageEntryById(QString id)
{
for(auto page: m_pages)