forked from qt-creator/qt-creator
Wizard: Replace QMap with QSet
It looks like both key and value are the same pointers. Change-Id: I38d006ada777d61df242dd0b82e9b622c0907cad Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -137,9 +137,9 @@ LinearProgressWidget::LinearProgressWidget(WizardProgress *progress, QWidget *pa
|
|||||||
connect(m_wizardProgress, &WizardProgress::currentItemChanged,
|
connect(m_wizardProgress, &WizardProgress::currentItemChanged,
|
||||||
this, &LinearProgressWidget::slotCurrentItemChanged);
|
this, &LinearProgressWidget::slotCurrentItemChanged);
|
||||||
|
|
||||||
QList<WizardProgressItem *> items = m_wizardProgress->items();
|
const QSet<WizardProgressItem *> items = m_wizardProgress->items();
|
||||||
for (int i = 0; i < items.count(); i++)
|
for (WizardProgressItem *item : items)
|
||||||
slotItemAdded(items.at(i));
|
slotItemAdded(item);
|
||||||
recreateLayout();
|
recreateLayout();
|
||||||
|
|
||||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
@@ -539,7 +539,7 @@ public:
|
|||||||
void updateReachableItems();
|
void updateReachableItems();
|
||||||
|
|
||||||
QMap<int, WizardProgressItem *> m_pageToItem;
|
QMap<int, WizardProgressItem *> m_pageToItem;
|
||||||
QMap<WizardProgressItem *, WizardProgressItem *> m_itemToItem;
|
QSet<WizardProgressItem *> m_items;
|
||||||
|
|
||||||
QList<WizardProgressItem *> m_visitedItems;
|
QList<WizardProgressItem *> m_visitedItems;
|
||||||
QList<WizardProgressItem *> m_reachableItems;
|
QList<WizardProgressItem *> m_reachableItems;
|
||||||
@@ -550,7 +550,7 @@ public:
|
|||||||
|
|
||||||
inline QDebug &operator<<(QDebug &debug, const WizardProgressPrivate &progress)
|
inline QDebug &operator<<(QDebug &debug, const WizardProgressPrivate &progress)
|
||||||
{
|
{
|
||||||
debug << "items:" << progress.m_itemToItem.size()
|
debug << "items:" << progress.m_items.size()
|
||||||
<< "; visited:" << progress.m_visitedItems.size()
|
<< "; visited:" << progress.m_visitedItems.size()
|
||||||
<< "; reachable:" << progress.m_reachableItems.size();
|
<< "; reachable:" << progress.m_reachableItems.size();
|
||||||
|
|
||||||
@@ -689,12 +689,8 @@ WizardProgress::~WizardProgress()
|
|||||||
{
|
{
|
||||||
Q_D(WizardProgress);
|
Q_D(WizardProgress);
|
||||||
|
|
||||||
auto it = d->m_itemToItem.constBegin();
|
for (WizardProgressItem *item : std::as_const(d->m_items))
|
||||||
const auto itEnd = d->m_itemToItem.constEnd();
|
delete item;
|
||||||
while (it != itEnd) {
|
|
||||||
delete it.key();
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
delete d_ptr;
|
delete d_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -703,7 +699,7 @@ WizardProgressItem *WizardProgress::addItem(const QString &title)
|
|||||||
Q_D(WizardProgress);
|
Q_D(WizardProgress);
|
||||||
|
|
||||||
auto item = new WizardProgressItem(this, title);
|
auto item = new WizardProgressItem(this, title);
|
||||||
d->m_itemToItem.insert(item, item);
|
d->m_items.insert(item);
|
||||||
emit itemAdded(item);
|
emit itemAdded(item);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
@@ -712,8 +708,8 @@ void WizardProgress::removeItem(WizardProgressItem *item)
|
|||||||
{
|
{
|
||||||
Q_D(WizardProgress);
|
Q_D(WizardProgress);
|
||||||
|
|
||||||
const auto it = d->m_itemToItem.constFind(item);
|
const auto it = d->m_items.constFind(item);
|
||||||
if (it == d->m_itemToItem.constEnd()) {
|
if (it == d->m_items.constEnd()) {
|
||||||
qWarning("WizardProgress::removePage: Item is not a part of the wizard");
|
qWarning("WizardProgress::removePage: Item is not a part of the wizard");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -745,7 +741,7 @@ void WizardProgress::removeItem(WizardProgressItem *item)
|
|||||||
QList<int> pages = item->pages();
|
QList<int> pages = item->pages();
|
||||||
for (int i = 0; i < pages.count(); i++)
|
for (int i = 0; i < pages.count(); i++)
|
||||||
d->m_pageToItem.remove(pages.at(i));
|
d->m_pageToItem.remove(pages.at(i));
|
||||||
d->m_itemToItem.erase(it);
|
d->m_items.erase(it);
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -782,11 +778,11 @@ WizardProgressItem *WizardProgress::currentItem() const
|
|||||||
return d->m_currentItem;
|
return d->m_currentItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<WizardProgressItem *> WizardProgress::items() const
|
QSet<WizardProgressItem *> WizardProgress::items() const
|
||||||
{
|
{
|
||||||
Q_D(const WizardProgress);
|
Q_D(const WizardProgress);
|
||||||
|
|
||||||
return d->m_itemToItem.keys();
|
return d->m_items;
|
||||||
}
|
}
|
||||||
|
|
||||||
WizardProgressItem *WizardProgress::startItem() const
|
WizardProgressItem *WizardProgress::startItem() const
|
||||||
|
@@ -85,7 +85,7 @@ public:
|
|||||||
|
|
||||||
WizardProgressItem *currentItem() const;
|
WizardProgressItem *currentItem() const;
|
||||||
|
|
||||||
QList<WizardProgressItem *> items() const;
|
QSet<WizardProgressItem *> items() const;
|
||||||
|
|
||||||
WizardProgressItem *startItem() const;
|
WizardProgressItem *startItem() const;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user