From 82f79e1df065b59b8c17017d676206be30397bc6 Mon Sep 17 00:00:00 2001 From: tpearson Date: Sun, 17 Jan 2010 18:57:42 +0000 Subject: 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 --- libkipi/libkipi/plugin.cpp | 91 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 libkipi/libkipi/plugin.cpp (limited to 'libkipi/libkipi/plugin.cpp') 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 + +// KDE includes. + +#include +#include +#include + +// Local includes. + +#include "plugin.h" + + +struct KIPI::Plugin::Private { + QMap m_actionCollection; + KInstance* m_instance; + QMap 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 ) ); +} + + + -- cgit v1.2.3