Proof of concept for having the context actions statically defined in the module.
Needs work for correctly placing the items in menu and on toolbar. Old system still needs to be removed left in place to keep app useable.
This commit is contained in:
parent
7f09d5fe07
commit
601d071d0f
21 changed files with 303 additions and 70 deletions
|
|
@ -1,5 +1,8 @@
|
|||
#include "plugin_support/PluginModule.h"
|
||||
#include "PluginContentWidget.h"
|
||||
#include <QDebug>
|
||||
#include <typeinfo>
|
||||
#include <typeindex>
|
||||
|
||||
PluginModule::PluginModule(QString name, QString ident)
|
||||
: m_name(std::move(name))
|
||||
|
|
@ -14,7 +17,6 @@ void PluginModule::setDisplayCategory(QString category)
|
|||
|
||||
void PluginModule::registerStaticAction(StaticAction action)
|
||||
{
|
||||
qDebug() << "registerMenuAction " << action.text();
|
||||
m_menuActions.emplace_back(std::move(action));
|
||||
}
|
||||
|
||||
|
|
@ -39,3 +41,28 @@ const PluginModule::ModuleAction* PluginModule::findModuleAction(const QString &
|
|||
return &res->second;
|
||||
}
|
||||
|
||||
void PluginModule::registerContextAction(std::shared_ptr<ContextBaseAction> action)
|
||||
{
|
||||
auto find_result_iter = m_contextMap.find(action->contextTypeIndex());
|
||||
if (find_result_iter != m_contextMap.end())
|
||||
find_result_iter->second.push_back(action);
|
||||
else
|
||||
m_contextMap.emplace(action->contextTypeIndex(), ContextActionContainer({ action }));
|
||||
}
|
||||
|
||||
const PluginModule::ContextActionContainer &PluginModule::actionsForContext(std::type_index ti)
|
||||
{
|
||||
static const ContextActionContainer empty_result;
|
||||
|
||||
auto find_result_iter = m_contextMap.find(ti);
|
||||
if (find_result_iter != m_contextMap.end())
|
||||
return find_result_iter->second;
|
||||
|
||||
return empty_result;
|
||||
}
|
||||
|
||||
const PluginModule::ContextActionContainer& PluginModule::actionsForContext(PluginContentWidget *widget)
|
||||
{
|
||||
return actionsForContext(std::type_index(typeid(*widget)));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue