Generate list of actions

wilder-work
Laurent Montel 8 years ago
parent 2f6d2a4728
commit 0e9cd54aa0
  1. 52
      src/editor/plugininterface/kmailplugineditorconverttextmanagerinterface.cpp
  2. 10
      src/editor/plugininterface/kmailplugineditorconverttextmanagerinterface.h

@ -23,6 +23,7 @@
#include <MessageComposer/PluginEditorConvertText>
#include <MessageComposer/PluginEditorConvertTextManager>
#include <MessageComposer/PluginEditorConvertTextInterface>
#include <QAction>
KMailPluginEditorConvertTextManagerInterface::KMailPluginEditorConvertTextManagerInterface(QObject *parent)
: QObject(parent)
@ -89,3 +90,54 @@ void KMailPluginEditorConvertTextManagerInterface::setRichTextEditor(KPIMTextEdi
{
mRichTextEditor = richTextEditor;
}
QHash<MessageComposer::PluginActionType::Type, QList<QAction *> > KMailPluginEditorConvertTextManagerInterface::actionsType()
{
if (mActionHash.isEmpty()) {
for (MessageComposer::PluginEditorConvertTextInterface *interface : qAsConst(mListPluginInterface)) {
const MessageComposer::PluginActionType actionType = interface->actionType();
MessageComposer::PluginActionType::Type type = actionType.type();
QList<QAction *> lst = mActionHash.value(type);
if (!lst.isEmpty()) {
QAction *act = new QAction(this);
act->setSeparator(true);
lst << act << actionType.action();
mActionHash.insert(type, lst);
} else {
mActionHash.insert(type, QList<QAction *>() << actionType.action());
}
/*
if (interface->plugin()->hasPopupMenuSupport()) {
type = MessageComposer::PluginActionType::PopupMenu;
QList<QAction *> lst = mActionHash.value(type);
if (!lst.isEmpty()) {
QAction *act = new QAction(this);
act->setSeparator(true);
lst << act << actionType.action();
mActionHash.insert(type, lst);
} else {
mActionHash.insert(type, QList<QAction *>() << actionType.action());
}
}
if (interface->plugin()->hasToolBarSupport()) {
type = MessageComposer::PluginActionType::ToolBar;
QList<QAction *> lst = mActionHash.value(type);
if (!lst.isEmpty()) {
QAction *act = new QAction(this);
act->setSeparator(true);
lst << act << actionType.action();
mActionHash.insert(type, lst);
} else {
mActionHash.insert(type, QList<QAction *>() << actionType.action());
}
}
*/
}
}
return mActionHash;
}
QList<QAction *> KMailPluginEditorConvertTextManagerInterface::actionsType(MessageComposer::PluginActionType::Type type)
{
return mActionHash.value(type);
}

@ -21,10 +21,9 @@
#define KMAILPLUGINEDITORCONVERTTEXTMANAGERINTERFACE_H
#include <QObject>
#include <MessageComposer/PluginEditorConvertTextInterface>
#include <QHash>
class QWidget;
namespace MessageComposer {
class PluginEditorConvertTextInterface;
}
namespace KPIMTextEdit {
class RichTextComposer;
}
@ -46,9 +45,14 @@ public:
KPIMTextEdit::RichTextComposer *richTextEditor() const;
void setRichTextEditor(KPIMTextEdit::RichTextComposer *richTextEditor);
QHash<MessageComposer::PluginActionType::Type, QList<QAction *> > actionsType();
QList<QAction *> actionsType(MessageComposer::PluginActionType::Type type);
private:
Q_DISABLE_COPY(KMailPluginEditorConvertTextManagerInterface)
QList<MessageComposer::PluginEditorConvertTextInterface *> mListPluginInterface;
QHash<MessageComposer::PluginActionType::Type, QList<QAction *> > mActionHash;
KPIMTextEdit::RichTextComposer *mRichTextEditor = nullptr;
QWidget *mParentWidget = nullptr;
KActionCollection *mActionCollection = nullptr;

Loading…
Cancel
Save