forked from qt-creator/qt-creator
ProjectExplorer: Use more Ids instead of Kit in KitModel
The idea is to slowly move towards a uniform approach to handle the Kits/Qt Version/Debugger/Toolchain/... managers/settings. Change-Id: I6ddba968a51d9468bb0dfec74b2fb8b902d11294 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -176,7 +176,6 @@ public:
|
|||||||
|
|
||||||
Kit *kit(const QModelIndex &);
|
Kit *kit(const QModelIndex &);
|
||||||
KitNode *kitNode(const QModelIndex &);
|
KitNode *kitNode(const QModelIndex &);
|
||||||
QModelIndex indexOf(Kit *k) const;
|
|
||||||
QModelIndex indexOf(Id kitId) const;
|
QModelIndex indexOf(Id kitId) const;
|
||||||
|
|
||||||
void setDefaultKit(const QModelIndex &index);
|
void setDefaultKit(const QModelIndex &index);
|
||||||
@@ -187,7 +186,7 @@ public:
|
|||||||
void apply();
|
void apply();
|
||||||
|
|
||||||
void markForRemoval(Kit *k);
|
void markForRemoval(Kit *k);
|
||||||
Kit *markForAddition(Kit *baseKit);
|
Id markForAddition(Kit *baseKit);
|
||||||
|
|
||||||
void updateVisibility();
|
void updateVisibility();
|
||||||
|
|
||||||
@@ -264,12 +263,6 @@ QModelIndex KitModel::indexOf(Id kitId) const
|
|||||||
return n ? indexForItem(n) : QModelIndex();
|
return n ? indexForItem(n) : QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex KitModel::indexOf(Kit *k) const
|
|
||||||
{
|
|
||||||
KitNode *n = findWorkingCopy(k);
|
|
||||||
return n ? indexForItem(n) : QModelIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
void KitModel::setDefaultKit(const QModelIndex &index)
|
void KitModel::setDefaultKit(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
if (KitNode *n = kitNode(index))
|
if (KitNode *n = kitNode(index))
|
||||||
@@ -348,7 +341,7 @@ void KitModel::markForRemoval(Kit *k)
|
|||||||
validateKitNames();
|
validateKitNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
Kit *KitModel::markForAddition(Kit *baseKit)
|
Id KitModel::markForAddition(Kit *baseKit)
|
||||||
{
|
{
|
||||||
const QString newName = newKitName(baseKit ? baseKit->unexpandedDisplayName() : QString());
|
const QString newName = newKitName(baseKit ? baseKit->unexpandedDisplayName() : QString());
|
||||||
KitNode *node = createNode(nullptr);
|
KitNode *node = createNode(nullptr);
|
||||||
@@ -367,7 +360,7 @@ Kit *KitModel::markForAddition(Kit *baseKit)
|
|||||||
if (!m_defaultNode)
|
if (!m_defaultNode)
|
||||||
setDefaultNode(node);
|
setDefaultNode(node);
|
||||||
|
|
||||||
return k;
|
return k->id();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KitModel::updateVisibility()
|
void KitModel::updateVisibility()
|
||||||
@@ -625,9 +618,9 @@ void KitOptionsPageWidget::kitSelectionChanged()
|
|||||||
|
|
||||||
void KitOptionsPageWidget::addNewKit()
|
void KitOptionsPageWidget::addNewKit()
|
||||||
{
|
{
|
||||||
Kit *k = m_model->markForAddition(nullptr);
|
Id kitId = m_model->markForAddition(nullptr);
|
||||||
|
|
||||||
QModelIndex newIdx = m_sortModel->mapFromSource(m_model->indexOf(k));
|
QModelIndex newIdx = m_sortModel->mapFromSource(m_model->indexOf(kitId));
|
||||||
m_selectionModel->select(newIdx,
|
m_selectionModel->select(newIdx,
|
||||||
QItemSelectionModel::Clear
|
QItemSelectionModel::Clear
|
||||||
| QItemSelectionModel::SelectCurrent
|
| QItemSelectionModel::SelectCurrent
|
||||||
@@ -648,8 +641,8 @@ void KitOptionsPageWidget::cloneKit()
|
|||||||
if (!current)
|
if (!current)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Kit *k = m_model->markForAddition(current);
|
Id kitId = m_model->markForAddition(current);
|
||||||
QModelIndex newIdx = m_sortModel->mapFromSource(m_model->indexOf(k));
|
QModelIndex newIdx = m_sortModel->mapFromSource(m_model->indexOf(kitId));
|
||||||
m_kitsView->scrollTo(newIdx);
|
m_kitsView->scrollTo(newIdx);
|
||||||
m_selectionModel->select(newIdx,
|
m_selectionModel->select(newIdx,
|
||||||
QItemSelectionModel::Clear
|
QItemSelectionModel::Clear
|
||||||
|
Reference in New Issue
Block a user