Commit 000c1779 authored by Laurent Montel's avatar Laurent Montel 😁

Allow to add several actions type

parent 2310dab0
cmake_minimum_required(VERSION 3.0)
set(PIM_VERSION "5.7.40")
set(PIM_VERSION "5.7.41")
project(pimcommon VERSION ${PIM_VERSION})
......
......@@ -26,7 +26,7 @@ public:
{
}
ActionType actionType;
QVector<ActionType> actionTypes;
};
GenericPluginInterface::GenericPluginInterface(QObject *parent)
......@@ -40,14 +40,20 @@ GenericPluginInterface::~GenericPluginInterface()
delete d;
}
void GenericPluginInterface::setActionType(const ActionType &type)
void GenericPluginInterface::setActionTypes(const QVector<ActionType> &type)
{
d->actionType = type;
d->actionTypes = type;
}
ActionType GenericPluginInterface::actionType() const
void GenericPluginInterface::addActionType(const ActionType &type)
{
return d->actionType;
//TODO check already existance ?
d->actionTypes.append(type);
}
QVector<ActionType> GenericPluginInterface::actionTypes() const
{
return d->actionTypes;
}
void GenericPluginInterface::updateActions(int numberOfSelectedItems, int numberOfSelectedCollections)
......
......@@ -41,8 +41,9 @@ public:
Q_ENUMS(RequireType)
Q_DECLARE_FLAGS(RequireTypes, RequireType)
void setActionType(const ActionType &type);
ActionType actionType() const;
void setActionTypes(const QVector<ActionType> &type);
void addActionType(const ActionType &type);
QVector<ActionType> actionTypes() const;
virtual void setCurrentItems(const Akonadi::Item::List &items);
virtual void setItems(const Akonadi::Item::List &items);
......
......@@ -163,19 +163,8 @@ QHash<PimCommon::ActionType::Type, QList<QAction *> > PluginInterface::actionsTy
{
QHash<PimCommon::ActionType::Type, QList<QAction *> > listType;
for (PimCommon::GenericPluginInterface *interface : qAsConst(d->mListGenericInterface)) {
PimCommon::ActionType actionType = interface->actionType();
PimCommon::ActionType::Type type = actionType.type();
QList<QAction *> lst = listType.value(type);
if (!lst.isEmpty()) {
QAction *act = new QAction(this);
act->setSeparator(true);
lst << act << actionType.action();
listType.insert(type, lst);
} else {
listType.insert(type, QList<QAction *>() << actionType.action());
}
if (interface->plugin()->hasPopupMenuSupport()) {
type = PimCommon::ActionType::PopupMenu;
for (const PimCommon::ActionType &actionType : interface->actionTypes()) {
PimCommon::ActionType::Type type = actionType.type();
QList<QAction *> lst = listType.value(type);
if (!lst.isEmpty()) {
QAction *act = new QAction(this);
......@@ -185,17 +174,29 @@ QHash<PimCommon::ActionType::Type, QList<QAction *> > PluginInterface::actionsTy
} else {
listType.insert(type, QList<QAction *>() << actionType.action());
}
}
if (interface->plugin()->hasToolBarSupport()) {
type = PimCommon::ActionType::ToolBar;
QList<QAction *> lst = listType.value(type);
if (!lst.isEmpty()) {
QAction *act = new QAction(this);
act->setSeparator(true);
lst << act << actionType.action();
listType.insert(type, lst);
} else {
listType.insert(type, QList<QAction *>() << actionType.action());
if (interface->plugin()->hasPopupMenuSupport()) {
type = PimCommon::ActionType::PopupMenu;
QList<QAction *> lst = listType.value(type);
if (!lst.isEmpty()) {
QAction *act = new QAction(this);
act->setSeparator(true);
lst << act << actionType.action();
listType.insert(type, lst);
} else {
listType.insert(type, QList<QAction *>() << actionType.action());
}
}
if (interface->plugin()->hasToolBarSupport()) {
type = PimCommon::ActionType::ToolBar;
QList<QAction *> lst = listType.value(type);
if (!lst.isEmpty()) {
QAction *act = new QAction(this);
act->setSeparator(true);
lst << act << actionType.action();
listType.insert(type, lst);
} else {
listType.insert(type, QList<QAction *>() << actionType.action());
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment