From fffb4962138ea02735a3c6e740f72b69a18048fd Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 4 Jun 2016 19:58:50 +0200 Subject: [PATCH] Changed: Changed sizes with signals (fix Qt warnings) --- .../src/uninstallwizarddialog.cpp | 37 +++++++++++++------ .../src/uninstallwizarddialog.h | 8 +++- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/uninstallwizarddialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/uninstallwizarddialog.cpp index fbaf44853..4b3745f1b 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/uninstallwizarddialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/uninstallwizarddialog.cpp @@ -85,15 +85,16 @@ CUninstallWizardDialog::CUninstallWizardDialog(QWidget *parent):QDialog(parent), componentsTreeView->setModel(model); componentsTreeView->resizeColumnToContents(0); + adjustSize(); + + // click signals connect(uninstallButton, SIGNAL(clicked()), SLOT(accept())); connect(quitButton, SIGNAL(clicked()), SLOT(reject())); connect(model, SIGNAL(itemChanged(QStandardItem *)), SLOT(onItemChanged(QStandardItem *))); - adjustSize(); - - QtConcurrent::run(this, &CUninstallWizardDialog::updateSizes); - - updateButtons(); + // semi-hack to not update UI on another thread + connect(this, SIGNAL(updateSize(int, QString)), SLOT(onUpdateSize(int, QString))); + connect(this, SIGNAL(updateLayout()), SLOT(onUpdateLayout())); } CUninstallWizardDialog::~CUninstallWizardDialog() @@ -193,10 +194,26 @@ void CUninstallWizardDialog::onItemChanged(QStandardItem * /* item */) updateButtons(); } -void CUninstallWizardDialog::updateSizes() +void CUninstallWizardDialog::onUpdateSize(int row, const QString &text) { QStandardItemModel *model = qobject_cast(componentsTreeView->model()); + if (model == NULL) return; + QStandardItem *item = new QStandardItem(text); + model->setItem(row, 1, item); +} + +void CUninstallWizardDialog::onUpdateLayout() +{ + componentsTreeView->resizeColumnToContents(1); + + updateButtons(); + + adjustSize(); +} + +void CUninstallWizardDialog::updateSizes() +{ CConfigFile *config = CConfigFile::getInstance(); // clients @@ -208,8 +225,7 @@ void CUninstallWizardDialog::updateSizes() qint64 bytes = getDirectorySize(config->getInstallationDirectory() + "/" + server.id); - QStandardItem *item = new QStandardItem(qBytesToHumanReadable(bytes)); - model->setItem(it.value(), 1, item); + emit updateSize(it.value(), qBytesToHumanReadable(bytes)); ++it; } @@ -223,13 +239,12 @@ void CUninstallWizardDialog::updateSizes() qint64 bytes = getDirectorySize(config->getProfileDirectory() + "/" + profile.id); - QStandardItem *item = new QStandardItem(qBytesToHumanReadable(bytes)); - model->setItem(it.value(), 1, item); + emit updateSize(it.value(), qBytesToHumanReadable(bytes)); ++it; } - componentsTreeView->resizeColumnToContents(1); + emit updateLayout(); } void CUninstallWizardDialog::updateButtons() diff --git a/code/ryzom/tools/client/ryzom_installer/src/uninstallwizarddialog.h b/code/ryzom/tools/client/ryzom_installer/src/uninstallwizarddialog.h index a65598f1e..286ba4085 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/uninstallwizarddialog.h +++ b/code/ryzom/tools/client/ryzom_installer/src/uninstallwizarddialog.h @@ -37,13 +37,19 @@ public: void setSelectedComponents(const SUninstallComponents &components); SUninstallComponents getSelectedCompenents() const; - bool isInstallerSelected() const; +signals: + void updateSize(int row, const QString &text); + void updateLayout(); private slots: void accept(); void onItemChanged(QStandardItem *item); + void onUpdateSize(int row, const QString &text); + void onUpdateLayout(); private: + void showEvent(QShowEvent *event); + void updateSizes(); void updateButtons();