GH-1445 update page list when version and log pages need it

This commit is contained in:
Petr Mrázek 2016-11-07 00:18:27 +01:00
parent 1276ecdbb7
commit 7cff5ba2e1
7 changed files with 20 additions and 3 deletions

View File

@ -132,7 +132,7 @@ void InstanceWindow::on_InstanceLaunchTask_changed(std::shared_ptr<LaunchTask> p
void InstanceWindow::on_RunningState_changed(bool running) void InstanceWindow::on_RunningState_changed(bool running)
{ {
setKillButton(running); setKillButton(running);
m_container->refresh(); m_container->refreshContainer();
} }
void InstanceWindow::on_closeButton_clicked() void InstanceWindow::on_closeButton_clicked()
@ -195,6 +195,11 @@ bool InstanceWindow::selectPage(QString pageId)
return m_container->selectPage(pageId); return m_container->selectPage(pageId);
} }
void InstanceWindow::refreshContainer()
{
m_container->refreshContainer();
}
InstanceWindow::~InstanceWindow() InstanceWindow::~InstanceWindow()
{ {
} }

View File

@ -33,6 +33,7 @@ public:
virtual ~InstanceWindow(); virtual ~InstanceWindow();
bool selectPage(QString pageId) override; bool selectPage(QString pageId) override;
void refreshContainer() override;
QString instanceId(); QString instanceId();

View File

@ -5,4 +5,5 @@ class BasePageContainer
public: public:
virtual ~BasePageContainer(){}; virtual ~BasePageContainer(){};
virtual bool selectPage(QString pageId) = 0; virtual bool selectPage(QString pageId) = 0;
virtual void refreshContainer() = 0;
}; };

View File

@ -231,6 +231,7 @@ void LogPage::on_btnClear_clicked()
if(!m_model) if(!m_model)
return; return;
m_model->clear(); m_model->clear();
m_parentContainer->refreshContainer();
} }
void LogPage::on_btnBottom_clicked() void LogPage::on_btnBottom_clicked()

View File

@ -225,6 +225,7 @@ bool VersionPage::reloadMinecraftProfile()
void VersionPage::on_reloadBtn_clicked() void VersionPage::on_reloadBtn_clicked()
{ {
reloadMinecraftProfile(); reloadMinecraftProfile();
m_container->refreshContainer();
} }
void VersionPage::on_removeBtn_clicked() void VersionPage::on_removeBtn_clicked()
@ -238,6 +239,8 @@ void VersionPage::on_removeBtn_clicked()
} }
} }
updateButtons(); updateButtons();
reloadMinecraftProfile();
m_container->refreshContainer();
} }
void VersionPage::on_modBtn_clicked() void VersionPage::on_modBtn_clicked()
@ -354,6 +357,7 @@ void VersionPage::on_changeVersionBtn_clicked()
} }
m_inst->setIntendedVersionId(vselect.selectedVersion()->descriptor()); m_inst->setIntendedVersionId(vselect.selectedVersion()->descriptor());
doUpdate(); doUpdate();
m_container->refreshContainer();
} }
int VersionPage::doUpdate() int VersionPage::doUpdate()
@ -367,6 +371,7 @@ int VersionPage::doUpdate()
connect(updateTask.get(), SIGNAL(failed(QString)), SLOT(onGameUpdateError(QString))); connect(updateTask.get(), SIGNAL(failed(QString)), SLOT(onGameUpdateError(QString)));
int ret = tDialog.execWithTask(updateTask.get()); int ret = tDialog.execWithTask(updateTask.get());
updateButtons(); updateButtons();
m_container->refreshContainer();
return ret; return ret;
} }
@ -383,6 +388,7 @@ void VersionPage::on_forgeBtn_clicked()
dialog.execWithTask( dialog.execWithTask(
ForgeInstaller().createInstallTask(m_inst, vselect.selectedVersion(), this)); ForgeInstaller().createInstallTask(m_inst, vselect.selectedVersion(), this));
preselect(m_profile->rowCount(QModelIndex())-1); preselect(m_profile->rowCount(QModelIndex())-1);
m_container->refreshContainer();
} }
} }
@ -400,6 +406,7 @@ void VersionPage::on_liteloaderBtn_clicked()
dialog.execWithTask( dialog.execWithTask(
LiteLoaderInstaller().createInstallTask(m_inst, vselect.selectedVersion(), this)); LiteLoaderInstaller().createInstallTask(m_inst, vselect.selectedVersion(), this));
preselect(m_profile->rowCount(QModelIndex())-1); preselect(m_profile->rowCount(QModelIndex())-1);
m_container->refreshContainer();
} }
} }
@ -543,6 +550,7 @@ void VersionPage::on_revertBtn_clicked()
} }
updateButtons(); updateButtons();
preselect(currentIdx); preselect(currentIdx);
m_container->refreshContainer();
} }
#include "VersionPage.moc" #include "VersionPage.moc"

View File

@ -77,6 +77,7 @@ PageContainer::PageContainer(BasePageProviderPtr pageProvider, QString defaultId
m_pageList->setIconSize(QSize(pageIconSize, pageIconSize)); m_pageList->setIconSize(QSize(pageIconSize, pageIconSize));
m_pageList->setSelectionMode(QAbstractItemView::SingleSelection); m_pageList->setSelectionMode(QAbstractItemView::SingleSelection);
m_pageList->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); m_pageList->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
m_pageList->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
m_pageList->setModel(m_proxyModel); m_pageList->setModel(m_proxyModel);
connect(m_pageList->selectionModel(), SIGNAL(currentRowChanged(QModelIndex, QModelIndex)), connect(m_pageList->selectionModel(), SIGNAL(currentRowChanged(QModelIndex, QModelIndex)),
this, SLOT(currentChanged(QModelIndex))); this, SLOT(currentChanged(QModelIndex)));
@ -106,7 +107,7 @@ bool PageContainer::selectPage(QString pageId)
return false; return false;
} }
void PageContainer::refresh() void PageContainer::refreshContainer()
{ {
m_proxyModel->invalidate(); m_proxyModel->invalidate();
if(!m_currentPage->shouldDisplay()) if(!m_currentPage->shouldDisplay())

View File

@ -49,7 +49,7 @@ public:
virtual bool selectPage(QString pageId) override; virtual bool selectPage(QString pageId) override;
void refresh(); void refreshContainer() override;
private: private:
void createUI(); void createUI();