Commit 2a101e53 authored by con's avatar con

Different sections for auto-detected and manual Qt versions.

parent c427858b
......@@ -87,9 +87,18 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<QtVersion *> ver
new Core::Utils::TreeWidgetColumnStretcher(m_ui->qtdirList, 1);
// setup parent items for auto-detected and manual versions
m_ui->qtdirList->header()->setResizeMode(QHeaderView::ResizeToContents);
QTreeWidgetItem *autoItem = new QTreeWidgetItem(m_ui->qtdirList);
autoItem->setText(0, tr("Auto-detected"));
autoItem->setFirstColumnSpanned(true);
QTreeWidgetItem *manualItem = new QTreeWidgetItem(m_ui->qtdirList);
manualItem->setText(0, tr("Manual"));
manualItem->setFirstColumnSpanned(true);
for (int i = 0; i < m_versions.count(); ++i) {
const QtVersion * const version = m_versions.at(i);
QTreeWidgetItem *item = new QTreeWidgetItem(m_ui->qtdirList);
QTreeWidgetItem *item = new QTreeWidgetItem(version->isSystemVersion()? autoItem : manualItem);
item->setText(0, version->name());
item->setText(1, QDir::toNativeSeparators(version->path()));
item->setData(0, Qt::UserRole, version->uniqueId());
......@@ -107,6 +116,7 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<QtVersion *> ver
if (i == m_defaultVersion)
m_ui->defaultCombo->setCurrentIndex(i);
}
m_ui->qtdirList->expandAll();
connect(m_ui->nameEdit, SIGNAL(textEdited(const QString &)),
this, SLOT(updateCurrentQtName()));
......@@ -148,10 +158,10 @@ void QtOptionsPageWidget::buildDebuggingHelper()
{
// Find the qt version for this button..
QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem();
if (!currentItem)
int currentItemIndex = indexForTreeItem(currentItem);
if (currentItemIndex < 0)
return;
int currentItemIndex = m_ui->qtdirList->indexOfTopLevelItem(currentItem);
QtVersion *version = m_versions[currentItemIndex];
QString result = m_versions.at(currentItemIndex)->buildDebuggingHelperLibrary();
......@@ -170,14 +180,14 @@ void QtOptionsPageWidget::buildDebuggingHelper()
void QtOptionsPageWidget::showDebuggingBuildLog()
{
QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem();
if (!currentItem)
return;
int currentItemIndex = m_ui->qtdirList->indexOfTopLevelItem(currentItem);
int currentItemIndex = indexForTreeItem(currentItem);
if (currentItemIndex < 0)
return;
QDialog dlg;
Ui_ShowBuildLog ui;
ui.setupUi(&dlg);
ui.log->setPlainText(m_ui->qtdirList->topLevelItem(currentItemIndex)->data(2, Qt::UserRole).toString());
ui.log->setPlainText(currentItem->data(2, Qt::UserRole).toString());
dlg.exec();
}
......@@ -192,7 +202,7 @@ void QtOptionsPageWidget::addQtDir()
QtVersion *newVersion = new QtVersion(m_specifyNameString, m_specifyPathString);
m_versions.append(newVersion);
QTreeWidgetItem *item = new QTreeWidgetItem(m_ui->qtdirList);
QTreeWidgetItem *item = new QTreeWidgetItem(m_ui->qtdirList->topLevelItem(1));
item->setText(0, newVersion->name());
item->setText(1, QDir::toNativeSeparators(newVersion->path()));
item->setData(0, Qt::UserRole, newVersion->uniqueId());
......@@ -210,7 +220,7 @@ void QtOptionsPageWidget::addQtDir()
void QtOptionsPageWidget::removeQtDir()
{
QTreeWidgetItem *item = m_ui->qtdirList->currentItem();
int index = m_ui->qtdirList->indexOfTopLevelItem(item);
int index = indexForTreeItem(item);
if (index < 0)
return;
......@@ -229,9 +239,10 @@ void QtOptionsPageWidget::removeQtDir()
void QtOptionsPageWidget::updateState()
{
bool enabled = (m_ui->qtdirList->currentItem() != 0);
int currentIndex = indexForTreeItem(m_ui->qtdirList->currentItem());
bool enabled = (currentIndex >= 0);
bool isSystemVersion = (enabled
&& m_versions.at(m_ui->qtdirList->indexOfTopLevelItem(m_ui->qtdirList->currentItem()))->isSystemVersion());
&& m_versions.at(currentIndex)->isSystemVersion());
m_ui->delButton->setEnabled(enabled && !isSystemVersion);
m_ui->nameEdit->setEnabled(enabled && !isSystemVersion);
m_ui->qtPath->setEnabled(enabled && !isSystemVersion);
......@@ -242,7 +253,7 @@ void QtOptionsPageWidget::updateState()
QtVersion *version = 0;
if (enabled)
version = m_versions.at(m_ui->qtdirList->indexOfTopLevelItem(m_ui->qtdirList->currentItem()));
version = m_versions.at(currentIndex);
if (version) {
m_ui->rebuildButton->setEnabled(version->isValid());
if (version->hasDebuggingHelper())
......@@ -270,7 +281,12 @@ void QtOptionsPageWidget::makeMSVCVisible(bool visible)
void QtOptionsPageWidget::showEnvironmentPage(QTreeWidgetItem *item)
{
if (item) {
int index = m_ui->qtdirList->indexOfTopLevelItem(item);
int index = indexForTreeItem(item);
if (index < 0) {
makeMSVCVisible(false);
makeMingwVisible(false);
return;
}
m_ui->errorLabel->setText("");
ProjectExplorer::ToolChain::ToolChainType t = m_versions.at(index)->toolchainType();
if (t == ProjectExplorer::ToolChain::MinGW) {
......@@ -317,12 +333,25 @@ void QtOptionsPageWidget::showEnvironmentPage(QTreeWidgetItem *item)
}
}
int QtOptionsPageWidget::indexForTreeItem(QTreeWidgetItem *item) const
{
if (!item || !item->parent())
return -1;
int uniqueId = item->data(0, Qt::UserRole).toInt();
for (int index = 0; index < m_versions.size(); ++index) {
if (m_versions.at(index)->uniqueId() == uniqueId)
return index;
}
return -1;
}
void QtOptionsPageWidget::versionChanged(QTreeWidgetItem *item, QTreeWidgetItem *old)
{
if (old) {
fixQtVersionName(m_ui->qtdirList->indexOfTopLevelItem(old));
fixQtVersionName(indexForTreeItem(old));
}
if (item) {
int itemIndex = indexForTreeItem(item);
if (itemIndex >= 0) {
m_ui->nameEdit->setText(item->text(0));
m_ui->qtPath->setPath(item->text(1));
} else {
......@@ -375,7 +404,9 @@ void QtOptionsPageWidget::updateCurrentQtName()
{
QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem();
Q_ASSERT(currentItem);
int currentItemIndex = m_ui->qtdirList->indexOfTopLevelItem(currentItem);
int currentItemIndex = indexForTreeItem(currentItem);
if (currentItemIndex < 0)
return;
m_versions[currentItemIndex]->setName(m_ui->nameEdit->text());
currentItem->setText(0, m_versions[currentItemIndex]->name());
......@@ -386,7 +417,7 @@ void QtOptionsPageWidget::updateCurrentQtName()
void QtOptionsPageWidget::finish()
{
if (QTreeWidgetItem *item = m_ui->qtdirList->currentItem())
fixQtVersionName(m_ui->qtdirList->indexOfTopLevelItem(item));
fixQtVersionName(indexForTreeItem(item));
}
/* Checks that the qt version name is unique
......@@ -395,6 +426,8 @@ void QtOptionsPageWidget::finish()
*/
void QtOptionsPageWidget::fixQtVersionName(int index)
{
if (index < 0)
return;
int count = m_versions.count();
for (int i = 0; i < count; ++i) {
if (i != index) {
......@@ -424,7 +457,9 @@ void QtOptionsPageWidget::updateCurrentQtPath()
{
QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem();
Q_ASSERT(currentItem);
int currentItemIndex = m_ui->qtdirList->indexOfTopLevelItem(currentItem);
int currentItemIndex = indexForTreeItem(currentItem);
if (currentItemIndex < 0)
return;
if (m_versions[currentItemIndex]->path() == m_ui->qtPath->path())
return;
m_versions[currentItemIndex]->setPath(m_ui->qtPath->path());
......@@ -455,7 +490,9 @@ void QtOptionsPageWidget::updateCurrentMingwDirectory()
{
QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem();
Q_ASSERT(currentItem);
int currentItemIndex = m_ui->qtdirList->indexOfTopLevelItem(currentItem);
int currentItemIndex = indexForTreeItem(currentItem);
if (currentItemIndex < 0)
return;
m_versions[currentItemIndex]->setMingwDirectory(m_ui->mingwPath->path());
}
......@@ -464,7 +501,9 @@ void QtOptionsPageWidget::msvcVersionChanged()
const QString &msvcVersion = m_ui->msvcComboBox->currentText();
QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem();
Q_ASSERT(currentItem);
int currentItemIndex = m_ui->qtdirList->indexOfTopLevelItem(currentItem);
int currentItemIndex = indexForTreeItem(currentItem);
if (currentItemIndex < 0)
return;
m_versions[currentItemIndex]->setMsvcVersion(msvcVersion);
}
......
......@@ -60,6 +60,8 @@ private:
void showEnvironmentPage(QTreeWidgetItem * item);
void fixQtVersionName(int index);
int indexForWidget(QWidget *debuggingHelperWidget) const;
int indexForTreeItem(QTreeWidgetItem *item) const;
Internal::Ui::QtVersionManager *m_ui;
QList<QtVersion *> m_versions;
int m_defaultVersion;
......
......@@ -285,13 +285,13 @@ void QtVersionManager::updateSystemVersion()
foreach (QtVersion *version, m_versions) {
if (version->isSystemVersion()) {
version->setPath(systemQtPath);
version->setName(tr("Auto-detected Qt"));
version->setName(tr("Qt in PATH"));
haveSystemVersion = true;
}
}
if (haveSystemVersion)
return;
QtVersion *version = new QtVersion(tr("Auto-detected Qt"),
QtVersion *version = new QtVersion(tr("Qt in PATH"),
systemQtPath,
getUniqueId(),
true);
......
......@@ -22,9 +22,6 @@
<property name="uniformRowHeights">
<bool>true</bool>
</property>
<property name="itemsExpandable">
<bool>false</bool>
</property>
<property name="columnCount">
<number>3</number>
</property>
......
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