summaryrefslogtreecommitdiffstats
path: root/libkipi/libkipi/plugin.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-17 18:57:42 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-17 18:57:42 +0000
commit82f79e1df065b59b8c17017d676206be30397bc6 (patch)
treea7d5680cbb2341001d69b66b502ef4cd9664abdc /libkipi/libkipi/plugin.cpp
downloadlibkipi-82f79e1df065b59b8c17017d676206be30397bc6.tar.gz
libkipi-82f79e1df065b59b8c17017d676206be30397bc6.zip
Added old KDE3 version of libkipi
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/libraries/libkipi@1076200 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'libkipi/libkipi/plugin.cpp')
-rw-r--r--libkipi/libkipi/plugin.cpp91
1 files changed, 91 insertions, 0 deletions
diff --git a/libkipi/libkipi/plugin.cpp b/libkipi/libkipi/plugin.cpp
new file mode 100644
index 0000000..920a31e
--- /dev/null
+++ b/libkipi/libkipi/plugin.cpp
@@ -0,0 +1,91 @@
+/* ============================================================
+ * File : plugin.cpp
+ * Authors: KIPI team developers (see AUTHORS files for details)
+ *
+ * Date : 2004-02
+ * Description :
+ *
+ * Copyright 2004 by the KIPI team
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU Library General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * ============================================================ */
+
+// Qt includes.
+
+#include <qwidget.h>
+
+// KDE includes.
+
+#include <kaction.h>
+#include <kinstance.h>
+#include <kdebug.h>
+
+// Local includes.
+
+#include "plugin.h"
+
+
+struct KIPI::Plugin::Private {
+ QMap<QWidget*, KActionCollection*> m_actionCollection;
+ KInstance* m_instance;
+ QMap<QWidget*, KActionPtrList> m_actions;
+ QWidget* m_defaultWidget;
+};
+
+
+KIPI::Plugin::Plugin( KInstance* instance, QObject *parent, const char* name)
+ : QObject( parent, name)
+{
+ d=new Private;
+ d->m_instance=instance;
+}
+
+KIPI::Plugin::~Plugin()
+{
+ delete d;
+}
+
+KActionCollection* KIPI::Plugin::actionCollection( QWidget* widget )
+{
+ if ( widget == 0 )
+ widget = d->m_defaultWidget;
+
+ if (!d->m_actionCollection.contains( widget ))
+ kdWarning( 51000 ) << "Error in the plugin. The plugin needs to call Plugin::setup( QWidget* ) "
+ << "as the very first line when overriding the setup method." << endl;
+ return d->m_actionCollection[widget];
+}
+
+void KIPI::Plugin::addAction( KAction* action )
+{
+ d->m_actions[d->m_defaultWidget].append( action );
+}
+
+KActionPtrList KIPI::Plugin::actions( QWidget* widget )
+{
+ if ( widget == 0 )
+ widget = d->m_defaultWidget;
+
+ return d->m_actions[widget];
+}
+
+void KIPI::Plugin::setup( QWidget* widget )
+{
+ d->m_defaultWidget = widget;
+ d->m_actions.insert( widget, KActionPtrList() );
+ QString name = QString( "action collection for %1" ).arg( widget->name() );
+ d->m_actionCollection.insert( widget, new KActionCollection( widget, widget, name.latin1(), d->m_instance ) );
+}
+
+
+