forked from qt-creator/qt-creator
ClassView: Dissolve the internal 'Utils' class
It's regularly getting in my way, and it's rather a namespace anyway. Also, move the functions that are only used once closer to their place of use. Change-Id: I97951aae1b69c04f391afbdd1b491a8a9173a977 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -29,6 +29,8 @@
|
||||
#include "classviewconstants.h"
|
||||
#include "classviewutils.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
#include <QHash>
|
||||
#include <QPair>
|
||||
#include <QIcon>
|
||||
@@ -276,6 +278,22 @@ void ParserTreeItem::add(const ParserTreeItem::ConstPtr &target)
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Converts internal location container to QVariant compatible.
|
||||
\a locations specifies a set of symbol locations.
|
||||
Returns a list of variant locations that can be added to the data of an
|
||||
item.
|
||||
*/
|
||||
|
||||
static QList<QVariant> locationsToRole(const QSet<SymbolLocation> &locations)
|
||||
{
|
||||
QList<QVariant> locationsVar;
|
||||
for (const SymbolLocation &loc : locations)
|
||||
locationsVar.append(QVariant::fromValue(loc));
|
||||
|
||||
return locationsVar;
|
||||
}
|
||||
|
||||
/*!
|
||||
Appends this item to the QStandardIten item \a item.
|
||||
*/
|
||||
@@ -304,7 +322,10 @@ void ParserTreeItem::convertTo(QStandardItem *item) const
|
||||
ParserTreeItem::Ptr ptr = cur.value();
|
||||
|
||||
auto add = new QStandardItem;
|
||||
Utils::setSymbolInformationToItem(inf, add);
|
||||
add->setData(inf.name(), Constants::SymbolNameRole);
|
||||
add->setData(inf.type(), Constants::SymbolTypeRole);
|
||||
add->setData(inf.iconType(), Constants::IconTypeRole);
|
||||
|
||||
if (!ptr.isNull()) {
|
||||
// icon
|
||||
add->setIcon(ptr->icon());
|
||||
@@ -314,8 +335,7 @@ void ParserTreeItem::convertTo(QStandardItem *item) const
|
||||
add->setFlags(add->flags() | Qt::ItemIsDragEnabled);
|
||||
|
||||
// locations
|
||||
add->setData(Utils::locationsToRole(ptr->symbolLocations()),
|
||||
Constants::SymbolLocationsRole);
|
||||
add->setData(locationsToRole(ptr->symbolLocations()), Constants::SymbolLocationsRole);
|
||||
}
|
||||
item->appendRow(add);
|
||||
++cur;
|
||||
|
||||
Reference in New Issue
Block a user