Changed: Changed sizes with signals (fix Qt warnings)

This commit is contained in:
kervala 2016-06-04 19:58:50 +02:00
parent 8ef9e92dd9
commit 5c0d7c2f92
2 changed files with 33 additions and 12 deletions

View file

@ -85,15 +85,16 @@ CUninstallWizardDialog::CUninstallWizardDialog(QWidget *parent):QDialog(parent),
componentsTreeView->setModel(model); componentsTreeView->setModel(model);
componentsTreeView->resizeColumnToContents(0); componentsTreeView->resizeColumnToContents(0);
adjustSize();
// click signals
connect(uninstallButton, SIGNAL(clicked()), SLOT(accept())); connect(uninstallButton, SIGNAL(clicked()), SLOT(accept()));
connect(quitButton, SIGNAL(clicked()), SLOT(reject())); connect(quitButton, SIGNAL(clicked()), SLOT(reject()));
connect(model, SIGNAL(itemChanged(QStandardItem *)), SLOT(onItemChanged(QStandardItem *))); connect(model, SIGNAL(itemChanged(QStandardItem *)), SLOT(onItemChanged(QStandardItem *)));
adjustSize(); // semi-hack to not update UI on another thread
connect(this, SIGNAL(updateSize(int, QString)), SLOT(onUpdateSize(int, QString)));
QtConcurrent::run(this, &CUninstallWizardDialog::updateSizes); connect(this, SIGNAL(updateLayout()), SLOT(onUpdateLayout()));
updateButtons();
} }
CUninstallWizardDialog::~CUninstallWizardDialog() CUninstallWizardDialog::~CUninstallWizardDialog()
@ -193,10 +194,26 @@ void CUninstallWizardDialog::onItemChanged(QStandardItem * /* item */)
updateButtons(); updateButtons();
} }
void CUninstallWizardDialog::updateSizes() void CUninstallWizardDialog::onUpdateSize(int row, const QString &text)
{ {
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(componentsTreeView->model()); QStandardItemModel *model = qobject_cast<QStandardItemModel*>(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(); CConfigFile *config = CConfigFile::getInstance();
// clients // clients
@ -208,8 +225,7 @@ void CUninstallWizardDialog::updateSizes()
qint64 bytes = getDirectorySize(config->getInstallationDirectory() + "/" + server.id); qint64 bytes = getDirectorySize(config->getInstallationDirectory() + "/" + server.id);
QStandardItem *item = new QStandardItem(qBytesToHumanReadable(bytes)); emit updateSize(it.value(), qBytesToHumanReadable(bytes));
model->setItem(it.value(), 1, item);
++it; ++it;
} }
@ -223,13 +239,12 @@ void CUninstallWizardDialog::updateSizes()
qint64 bytes = getDirectorySize(config->getProfileDirectory() + "/" + profile.id); qint64 bytes = getDirectorySize(config->getProfileDirectory() + "/" + profile.id);
QStandardItem *item = new QStandardItem(qBytesToHumanReadable(bytes)); emit updateSize(it.value(), qBytesToHumanReadable(bytes));
model->setItem(it.value(), 1, item);
++it; ++it;
} }
componentsTreeView->resizeColumnToContents(1); emit updateLayout();
} }
void CUninstallWizardDialog::updateButtons() void CUninstallWizardDialog::updateButtons()

View file

@ -37,13 +37,19 @@ public:
void setSelectedComponents(const SUninstallComponents &components); void setSelectedComponents(const SUninstallComponents &components);
SUninstallComponents getSelectedCompenents() const; SUninstallComponents getSelectedCompenents() const;
bool isInstallerSelected() const; signals:
void updateSize(int row, const QString &text);
void updateLayout();
private slots: private slots:
void accept(); void accept();
void onItemChanged(QStandardItem *item); void onItemChanged(QStandardItem *item);
void onUpdateSize(int row, const QString &text);
void onUpdateLayout();
private: private:
void showEvent(QShowEvent *event);
void updateSizes(); void updateSizes();
void updateButtons(); void updateButtons();