forked from qt-creator/qt-creator
ProjectExplorer: Simplify some kit aspect models
Change-Id: Ic494056102613f7a534b8da78540d4c951410cbe Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -43,18 +43,6 @@ public:
|
||||
, m_kit(kit)
|
||||
{}
|
||||
|
||||
QModelIndex indexForId(const QVariant &id) const
|
||||
{
|
||||
// The "None" item always comes last
|
||||
const auto noneIndex = [this] { return index(rowCount() - 1, 0); };
|
||||
|
||||
if (id.isNull())
|
||||
return noneIndex();
|
||||
const TreeItem *const item = findItemAtLevel<1>(
|
||||
[id](TreeItem *item) { return item->data(0, DebuggerTreeItem::IdRole) == id; });
|
||||
return item ? indexForItem(item) : noneIndex();
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
clear();
|
||||
@@ -83,12 +71,6 @@ class DebuggerItemSortModel : public SortModel
|
||||
public:
|
||||
DebuggerItemSortModel(QObject *parent) : SortModel(parent) {}
|
||||
|
||||
QModelIndex indexForId(const QVariant &id) const
|
||||
{
|
||||
return mapFromSource(
|
||||
static_cast<DebuggerItemListModel *>(sourceModel())->indexForId(id));
|
||||
}
|
||||
|
||||
void reset() { static_cast<DebuggerItemListModel *>(sourceModel())->reset(); }
|
||||
|
||||
private:
|
||||
@@ -177,7 +159,8 @@ private:
|
||||
sortModel->reset();
|
||||
sortModel->sort(0);
|
||||
const DebuggerItem * const item = DebuggerKitAspect::debugger(m_kit);
|
||||
m_comboBox->setCurrentIndex(sortModel->indexForId(item ? item->id() : QVariant()).row());
|
||||
m_comboBox->setCurrentIndex(
|
||||
m_comboBox->findData(item ? item->id() : QVariant(), DebuggerTreeItem::IdRole));
|
||||
}
|
||||
|
||||
QVariant currentId() const
|
||||
|
@@ -36,18 +36,6 @@ public:
|
||||
reset();
|
||||
}
|
||||
|
||||
QModelIndex indexForBundleId(Id bundleId) const
|
||||
{
|
||||
if (!bundleId.isValid())
|
||||
return index(rowCount() - 1, 0); // The "none" item always comes last
|
||||
const TreeItem *const item = findItemAtLevel<1>(
|
||||
[bundleId](TreeItem *item) {
|
||||
const auto tcItem = static_cast<ToolchainTreeItem *>(item);
|
||||
return tcItem->bundle && tcItem->bundle->bundleId() == bundleId;
|
||||
});
|
||||
return item ? indexForItem(item) : QModelIndex();
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
clear();
|
||||
@@ -77,12 +65,6 @@ class ToolchainSortModel : public SortModel
|
||||
public:
|
||||
ToolchainSortModel(QObject *parent) : SortModel(parent) {}
|
||||
|
||||
QModelIndex indexForBundleId(Id bundleId) const
|
||||
{
|
||||
return mapFromSource(
|
||||
static_cast<ToolchainListModel *>(sourceModel())->indexForBundleId(bundleId));
|
||||
}
|
||||
|
||||
void reset() { static_cast<ToolchainListModel *>(sourceModel())->reset(); }
|
||||
|
||||
private:
|
||||
@@ -222,7 +204,7 @@ private:
|
||||
|
||||
int indexOf(QComboBox *cb, Id bundleId)
|
||||
{
|
||||
return static_cast<ToolchainSortModel *>(cb->model())->indexForBundleId(bundleId).row();
|
||||
return cb->findData(bundleId.toSetting(), ToolchainTreeItem::BundleIdRole);
|
||||
}
|
||||
|
||||
QWidget *m_mainWidget = nullptr;
|
||||
|
@@ -39,15 +39,6 @@ public:
|
||||
, m_kit(kit)
|
||||
{}
|
||||
|
||||
QModelIndex indexForQtId(int id) const
|
||||
{
|
||||
if (id == -1)
|
||||
return index(rowCount() - 1, 0); // The "No Qt" item always comes last
|
||||
const TreeItem *const item = findItemAtLevel<1>(
|
||||
[id](TreeItem *item) { return static_cast<QtVersionItem *>(item)->uniqueId() == id; });
|
||||
return item ? indexForItem(item) : QModelIndex();
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
clear();
|
||||
@@ -71,12 +62,6 @@ class QtVersionSortModel : public SortModel
|
||||
public:
|
||||
QtVersionSortModel(QObject *parent) : SortModel(parent) {}
|
||||
|
||||
QModelIndex indexForId(int id) const
|
||||
{
|
||||
return mapFromSource(
|
||||
static_cast<QtVersionListModel *>(sourceModel())->indexForQtId(id));
|
||||
}
|
||||
|
||||
void reset() { static_cast<QtVersionListModel *>(sourceModel())->reset(); }
|
||||
|
||||
private:
|
||||
@@ -154,7 +139,8 @@ private:
|
||||
const auto sortModel = static_cast<QtVersionSortModel *>(m_combo->model());
|
||||
sortModel->reset();
|
||||
sortModel->sort(0);
|
||||
m_combo->setCurrentIndex(sortModel->indexForId(QtKitAspect::qtVersionId(m_kit)).row());
|
||||
m_combo->setCurrentIndex(
|
||||
m_combo->findData(QtKitAspect::qtVersionId(m_kit), QtVersionItem::IdRole));
|
||||
}
|
||||
|
||||
private:
|
||||
|
Reference in New Issue
Block a user