forked from qt-creator/qt-creator
ProjectNodes: Support different priorities for LocationInfo
Allow to have different priorities for LocationInfo in the FileNodes. Use this to group the different LocationInfo items in the context menu. Change-Id: I13369d996841891ba7165684fe7bfb7687f9d523 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -3399,7 +3399,13 @@ void ProjectExplorerPluginPrivate::updateLocationSubMenus()
|
||||
if (!isVisible)
|
||||
return;
|
||||
|
||||
unsigned int lastPriority = 0;
|
||||
for (const FolderNode::LocationInfo &li : locations) {
|
||||
if (li.priority != lastPriority) {
|
||||
projectMenu->addSeparator();
|
||||
folderMenu->addSeparator();
|
||||
lastPriority = li.priority;
|
||||
}
|
||||
const int line = li.line;
|
||||
const Utils::FilePath path = li.path;
|
||||
auto *action = new QAction(li.displayName, nullptr);
|
||||
|
@@ -673,6 +673,7 @@ void FolderNode::setIcon(const QIcon &icon)
|
||||
void FolderNode::setLocationInfo(const QList<FolderNode::LocationInfo> &info)
|
||||
{
|
||||
m_locations = info;
|
||||
Utils::sort(m_locations, &LocationInfo::priority);
|
||||
}
|
||||
|
||||
const QList<FolderNode::LocationInfo> FolderNode::locationInfo() const
|
||||
|
@@ -246,13 +246,22 @@ public:
|
||||
void setDisplayName(const QString &name);
|
||||
void setIcon(const QIcon &icon);
|
||||
|
||||
class LocationInfo {
|
||||
class LocationInfo
|
||||
{
|
||||
public:
|
||||
LocationInfo(const QString &dn, const Utils::FilePath &p, const int l = -1) :
|
||||
path(p), line(l), displayName(dn) { }
|
||||
LocationInfo(const QString &dn,
|
||||
const Utils::FilePath &p,
|
||||
const int l = 0,
|
||||
const unsigned int prio = 0)
|
||||
: path(p)
|
||||
, line(l)
|
||||
, priority(prio)
|
||||
, displayName(dn)
|
||||
{}
|
||||
|
||||
Utils::FilePath path;
|
||||
int line = -1;
|
||||
unsigned int priority = 0;
|
||||
QString displayName;
|
||||
};
|
||||
void setLocationInfo(const QList<LocationInfo> &info);
|
||||
|
Reference in New Issue
Block a user