Commit ddc216ac authored by dt_'s avatar dt_ Committed by Tobias Hunger

Readd editing of paths

The path can only be changed to a version that is of the same type.
That should prevent a few interesting problems

Change-Id: Ib9ddf4cfbeea7ac408ff7d177726005b90cf0205
Reviewed-on: http://codereview.qt.nokia.com/244Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@nokia.com>
parent 218205bb
......@@ -70,6 +70,8 @@ private:
bool checkVersionString(const QString &version) const;
};
namespace Internal { class QtOptionsPageWidget; }
class QTSUPPORT_EXPORT QtConfigWidget : public QWidget
{
Q_OBJECT
......@@ -83,6 +85,7 @@ class QTSUPPORT_EXPORT BaseQtVersion
{
friend class QtVersionFactory;
friend class QtVersionManager;
friend class QtSupport::Internal::QtOptionsPageWidget;
public:
virtual ~BaseQtVersion();
......@@ -219,6 +222,7 @@ private:
QString findQtBinary(const QStringList &possibleName) const;
void updateMkspec() const;
void setId(int id); // used by the qtversionmanager for legacy restore
// and by the qtoptionspage to replace qt versions
QString m_displayName;
int m_id;
bool m_isAutodetected;
......
......@@ -174,6 +174,9 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<BaseQtVersion *>
connect(m_versionUi->nameEdit, SIGNAL(textEdited(const QString &)),
this, SLOT(updateCurrentQtName()));
connect(m_versionUi->editPathPushButton, SIGNAL(clicked()),
this, SLOT(editPath()));
connect(m_ui->addButton, SIGNAL(clicked()),
this, SLOT(addQtDir()));
connect(m_ui->delButton, SIGNAL(clicked()),
......@@ -434,16 +437,21 @@ QtOptionsPageWidget::~QtOptionsPageWidget()
qDeleteAll(m_versions);
}
void QtOptionsPageWidget::addQtDir()
static QString filterForQmakeFileDialog()
{
QString filter("qmake (");
foreach (const QString &s, Utils::BuildableHelperLibrary::possibleQMakeCommands()) {
filter += s + " ";
}
filter += ")";
return filter;
}
void QtOptionsPageWidget::addQtDir()
{
QString qtVersion = QFileDialog::getOpenFileName(this,
tr("Select a qmake executable"), QString(), filter);
tr("Select a qmake executable"),
QString(), filterForQmakeFileDialog());
if (qtVersion.isNull())
return;
if (QtVersionManager::instance()->qtVersionForQMakeBinary(qtVersion)) {
......@@ -481,6 +489,39 @@ void QtOptionsPageWidget::removeQtDir()
updateCleanUpButton();
}
void QtOptionsPageWidget::editPath()
{
// TODO Here be dragons
QString qtVersion = QFileDialog::getOpenFileName(this,
tr("Select a qmake executable"),
QString(), filterForQmakeFileDialog());
if (qtVersion.isNull())
return;
BaseQtVersion *version = QtVersionFactory::createQtVersionFromQMakePath(qtVersion);
BaseQtVersion *current = currentVersion();
// Same type? then replace!
if (current->type() != version->type()) {
// not the same type, error out
QMessageBox::critical(this, tr("Qt versions incompatible"),
tr("The qt version selected must be for the same target."),
QMessageBox::Ok);
delete version;
return;
}
// same type, replace
version->setId(current->uniqueId());
m_versions.replace(m_versions.indexOf(current), version);
delete current;
// Update ui
userChangedCurrentVersion();
QTreeWidgetItem *item = m_ui->qtdirList->currentItem();
item->setText(0, version->displayName());
item->setText(1, QDir::toNativeSeparators(version->qmakeCommand()));
item->setData(0, VersionIdRole, version->uniqueId());
item->setIcon(0, version->isValid()? m_validVersionIcon : m_invalidVersionIcon);
}
void QtOptionsPageWidget::updateDebuggingHelperUi()
{
BaseQtVersion *version = currentVersion();
......@@ -748,6 +789,7 @@ void QtOptionsPageWidget::updateWidgets()
const bool isAutodetected = enabled && version->isAutodetected();
m_ui->delButton->setEnabled(enabled && !isAutodetected);
m_versionUi->nameEdit->setEnabled(enabled && !isAutodetected);
m_versionUi->editPathPushButton->setEnabled(enabled && !isAutodetected);
}
void QtOptionsPageWidget::updateCurrentQtName()
......
......@@ -96,6 +96,7 @@ private slots:
void versionChanged(QTreeWidgetItem *item, QTreeWidgetItem *old);
void addQtDir();
void removeQtDir();
void editPath();
void updateCleanUpButton();
void updateCurrentQtName();
void buildDebuggingHelper(DebuggingHelperBuildTask::Tools tools
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>222</width>
<height>70</height>
<width>392</width>
<height>87</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
......@@ -29,16 +29,33 @@
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="qmakePath">
<property name="text">
<string/>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="qmakePath">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="editPathPushButton">
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0" colspan="2">
<item row="2" column="0">
<widget class="QLabel" name="errorLabel">
<property name="text">
<string/>
......
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