forked from qt-creator/qt-creator
QmlDesigner: Allow priorities for resource handlers
Change-Id: If9e9ad3ebc57ba2d80f3b1e89d0643223a00fe72 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
committed by
Alessandro Portale
parent
7282e05554
commit
0e6bed71cf
@@ -49,16 +49,19 @@ struct AddResourceHandler
|
||||
public:
|
||||
AddResourceHandler( const QString &_category,
|
||||
const QString &_filter,
|
||||
AddResourceOperation _operation)
|
||||
AddResourceOperation _operation,
|
||||
int _priority = 0)
|
||||
: category(_category)
|
||||
,filter(_filter)
|
||||
,operation(_operation)
|
||||
,piority(_priority)
|
||||
{
|
||||
}
|
||||
|
||||
QString category;
|
||||
QString filter;
|
||||
AddResourceOperation operation;
|
||||
int piority;
|
||||
};
|
||||
|
||||
class DesignerActionToolBar : public Utils::StyledBar
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <rewritingexception.h>
|
||||
#include <qmldesignerplugin.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/flowlayout.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/stylehelper.h>
|
||||
@@ -395,14 +396,26 @@ void ItemLibraryWidget::addResources()
|
||||
QTC_ASSERT(document, return);
|
||||
|
||||
QList<AddResourceHandler> handlers = QmlDesignerPlugin::instance()->viewManager().designerActionManager().addResourceHandler();
|
||||
|
||||
QMultiMap<QString, QString> map;
|
||||
for (const AddResourceHandler &handler : handlers) {
|
||||
map.insert(handler.category, handler.filter);
|
||||
}
|
||||
|
||||
QMap<QString, int> priorities;
|
||||
for (const AddResourceHandler &handler : handlers) {
|
||||
priorities.insert(handler.category, handler.piority);
|
||||
}
|
||||
|
||||
QStringList sortedKeys = map.uniqueKeys();
|
||||
Utils::sort(sortedKeys, [&priorities](const QString &first,
|
||||
const QString &second){
|
||||
return priorities.value(first) < priorities.value(second);
|
||||
});
|
||||
|
||||
QStringList filters;
|
||||
|
||||
for (const QString &key : map.uniqueKeys()) {
|
||||
for (const QString &key : sortedKeys) {
|
||||
QString str = key + " (";
|
||||
str.append(map.values(key).join(" "));
|
||||
str.append(")");
|
||||
|
||||
Reference in New Issue
Block a user