Commit 0023ed78 authored by Tobias Hunger's avatar Tobias Hunger

Qt: Add button to remove all invalid Qt versions

Add a button to remove all invalid Qt versions.

Task-number: QTCREATORBUG-3969
parent a3593b03
......@@ -60,6 +60,7 @@
#include <QtGui/QHelpEvent>
#include <QtGui/QToolTip>
#include <QtGui/QMenu>
#include <QtGui/QMessageBox>
enum ModelRoles { VersionIdRole = Qt::UserRole, BuildLogRole, BuildRunningRole};
......@@ -214,6 +215,7 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<QtVersion *> ver
connect(m_debuggingHelperUi->showLogButton, SIGNAL(clicked()),
this, SLOT(slotShowDebuggingBuildLog()));
connect(m_ui->cleanUpButton, SIGNAL(clicked()), this, SLOT(cleanUpQtVersions()));
showEnvironmentPage(0);
updateState();
}
......@@ -300,6 +302,36 @@ void QtOptionsPageWidget::debuggingHelperBuildFinished(int qtVersionId, Debuggin
showDebuggingBuildLog(item);
}
void QtOptionsPageWidget::cleanUpQtVersions()
{
QStringList toRemove;
foreach (const QtVersion *v, m_versions) {
if (!v->isValid())
toRemove.append(v->displayName());
}
if (toRemove.isEmpty())
return;
if (QMessageBox::warning(0, tr("Remove invalid Qt Versions"),
tr("Do you want to remove all invalid Qt Versions?<br>"
"<ul><li>%1</li></ul><br>"
"will be removed.").arg(toRemove.join(QLatin1String("</li><li>"))),
QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
return;
for (int i = m_versions.count() - 1; i >= 0; --i) {
if (!m_versions.at(i)->isValid()) {
QTreeWidgetItem *item = treeItemForIndex(i);
delete item;
delete m_versions.at(i);
m_versions.removeAt(i);
}
}
updateState();
}
void QtOptionsPageWidget::buildDebuggingHelper(DebuggingHelperBuildTask::Tools tools)
{
const int index = currentIndex();
......@@ -592,11 +624,13 @@ void QtOptionsPageWidget::updateDebuggingHelperUi()
void QtOptionsPageWidget::updateState()
{
bool hasInvalidVersion = false;
for (int i = 0; i < m_versions.count(); ++i) {
QTreeWidgetItem *item = treeItemForIndex(i);
if (!m_versions.at(i)->isValid()) {
if (item)
item->setIcon(0, m_invalidVersionIcon);
hasInvalidVersion = true;
} else {
if (item)
item->setIcon(0, m_validVersionIcon);
......@@ -607,6 +641,7 @@ void QtOptionsPageWidget::updateState()
const bool enabled = version != 0;
const bool isAutodetected = enabled && version->isAutodetected();
m_ui->delButton->setEnabled(enabled && !isAutodetected);
m_ui->cleanUpButton->setEnabled(hasInvalidVersion);
m_versionUi->nameEdit->setEnabled(enabled && !isAutodetected);
m_versionUi->qmakePath->setEnabled(enabled && !isAutodetected);
bool s60SDKPathEnabled = enabled &&
......
......@@ -110,6 +110,7 @@ private slots:
void buildQmlObserver();
void slotShowDebuggingBuildLog();
void debuggingHelperBuildFinished(int qtVersionId, DebuggingHelperBuildTask::Tools tools, const QString &output);
void cleanUpQtVersions();
private:
void updateDescriptionLabel();
......
......@@ -80,6 +80,13 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="cleanUpButton">
<property name="text">
<string>Clean up</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment