diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 01:29:50 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 01:29:50 +0000 |
commit | 8362bf63dea22bbf6736609b0f49c152f975eb63 (patch) | |
tree | 0eea3928e39e50fae91d4e68b21b1e6cbae25604 /kivio/kiviopart/tools | |
download | koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip |
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kivio/kiviopart/tools')
-rw-r--r-- | kivio/kiviopart/tools/Makefile.am | 15 | ||||
-rw-r--r-- | kivio/kiviopart/tools/kivio_mousetool.cpp | 34 | ||||
-rw-r--r-- | kivio/kiviopart/tools/kivio_mousetool.h | 55 | ||||
-rw-r--r-- | kivio/kiviopart/tools/kivio_plugin.cpp | 34 | ||||
-rw-r--r-- | kivio/kiviopart/tools/kivio_plugin.h | 41 | ||||
-rw-r--r-- | kivio/kiviopart/tools/kivio_pluginmanager.cpp | 102 | ||||
-rw-r--r-- | kivio/kiviopart/tools/kivio_pluginmanager.h | 65 | ||||
-rw-r--r-- | kivio/kiviopart/tools/kivio_tool.rc | 4 | ||||
-rw-r--r-- | kivio/kiviopart/tools/mousetoolaction.cpp | 98 | ||||
-rw-r--r-- | kivio/kiviopart/tools/mousetoolaction.h | 126 |
10 files changed, 574 insertions, 0 deletions
diff --git a/kivio/kiviopart/tools/Makefile.am b/kivio/kiviopart/tools/Makefile.am new file mode 100644 index 00000000..89fe8298 --- /dev/null +++ b/kivio/kiviopart/tools/Makefile.am @@ -0,0 +1,15 @@ +noinst_LTLIBRARIES =libtools.la + +INCLUDES = -I$(top_srcdir)/kivio/kiviopart\ + -I$(top_srcdir)/kivio/kiviopart/kiviosdk\ + $(KOFFICE_INCLUDES) $(all_includes) +libtools_la_METASOURCES = AUTO +libtools_la_SOURCES = kivio_plugin.cpp kivio_pluginmanager.cpp \ + kivio_mousetool.cpp mousetoolaction.cpp +EXTRA_DIST = \ + kivio_tool.rc + +rcdir = $(kde_datadir)/kivio +rc_DATA = kivio_tool.rc +noinst_HEADERS = kivio_plugin.h kivio_pluginmanager.h kivio_mousetool.h \ + mousetoolaction.h diff --git a/kivio/kiviopart/tools/kivio_mousetool.cpp b/kivio/kiviopart/tools/kivio_mousetool.cpp new file mode 100644 index 00000000..cc84c799 --- /dev/null +++ b/kivio/kiviopart/tools/kivio_mousetool.cpp @@ -0,0 +1,34 @@ +/* + * Kivio - Visual Modelling and Flowcharting + * Copyright (C) 2003 Peter Simonsson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include "kivio_mousetool.h" + +#include "kivio_pluginmanager.h" + +namespace Kivio { + MouseTool::MouseTool(KivioView* parent, const char* name) : Kivio::Plugin(parent, name) + { + connect(this, SIGNAL(activated(Kivio::MouseTool*)), view()->pluginManager(), SLOT(activate(Kivio::MouseTool*))); + } + + MouseTool::~MouseTool() + { + } +} + +#include "kivio_mousetool.moc" diff --git a/kivio/kiviopart/tools/kivio_mousetool.h b/kivio/kiviopart/tools/kivio_mousetool.h new file mode 100644 index 00000000..3b5a3539 --- /dev/null +++ b/kivio/kiviopart/tools/kivio_mousetool.h @@ -0,0 +1,55 @@ +/* + * Kivio - Visual Modelling and Flowcharting + * Copyright (C) 2003 Peter Simonsson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#ifndef KIVIOMOUSETOOL_H +#define KIVIOMOUSETOOL_H + +#include "kivio_plugin.h" + +#include <qptrlist.h> +#include <koffice_export.h> +class KivioStencil; +class KoPoint; + +namespace Kivio { + /** + Baseclass for mouse tools (like eg the select tool)*/ + class KIVIO_EXPORT MouseTool : public Kivio::Plugin + { + Q_OBJECT + public: + MouseTool(KivioView* parent = 0, const char* name = 0); + ~MouseTool(); + + virtual bool processEvent(QEvent* e) = 0; + + public slots: + virtual void setActivated(bool) = 0; + /** This function should apply a change to @p stencils + * done by the tool. + */ + virtual void applyToolAction(QPtrList<KivioStencil>* stencils) { Q_UNUSED(stencils); }; + virtual void applyToolAction(KivioStencil* /*stencil*/, const KoPoint& /*pos*/) {}; + + signals: + /** this should be emited when the tool wants to be active */ + void activated(Kivio::MouseTool*); + }; +} + +#endif diff --git a/kivio/kiviopart/tools/kivio_plugin.cpp b/kivio/kiviopart/tools/kivio_plugin.cpp new file mode 100644 index 00000000..01e06906 --- /dev/null +++ b/kivio/kiviopart/tools/kivio_plugin.cpp @@ -0,0 +1,34 @@ +/* + * Kivio - Visual Modelling and Flowcharting + * Copyright (C) 2003 Peter Simonsson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include "kivio_plugin.h" + +#include "kivio_factory.h" + +namespace Kivio { + Plugin::Plugin(KivioView* parent, const char* name) : KParts::Plugin(parent, name) + { + setInstance(KivioFactory::global()); + } + + Plugin::~Plugin() + { + } +} + +#include "kivio_plugin.moc" diff --git a/kivio/kiviopart/tools/kivio_plugin.h b/kivio/kiviopart/tools/kivio_plugin.h new file mode 100644 index 00000000..8db99552 --- /dev/null +++ b/kivio/kiviopart/tools/kivio_plugin.h @@ -0,0 +1,41 @@ +/* + * Kivio - Visual Modelling and Flowcharting + * Copyright (C) 2003 Peter Simonsson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#ifndef KIVIO_PLUGIN_H +#define KIVIO_PLUGIN_H + +#include <kparts/plugin.h> +#include <kivio_view.h> +#include <koffice_export.h> + +namespace Kivio { + /** + This class provides the base for all plugins in Kivio + */ + class KIVIO_EXPORT Plugin : public KParts::Plugin + { + Q_OBJECT + public: + Plugin(KivioView* parent = 0, const char* name = 0); + ~Plugin(); + + KivioView* view() { return static_cast<KivioView*>(parent()); } + }; +} + +#endif diff --git a/kivio/kiviopart/tools/kivio_pluginmanager.cpp b/kivio/kiviopart/tools/kivio_pluginmanager.cpp new file mode 100644 index 00000000..a718a9ee --- /dev/null +++ b/kivio/kiviopart/tools/kivio_pluginmanager.cpp @@ -0,0 +1,102 @@ +/* + * Kivio - Visual Modelling and Flowcharting + * Copyright (C) 2003 Peter Simonsson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include "kivio_pluginmanager.h" + +#include <kdebug.h> +#include <kparts/plugin.h> + +#include "kivio_plugin.h" + +namespace Kivio { + PluginManager::PluginManager(KivioView* parent, const char* name) : QObject(parent, name) + { + m_activeTool = 0; + m_defaultTool = 0; + m_delegateEvents = true; + } + + PluginManager::~PluginManager() + { + } + + bool PluginManager::delegateEvent(QEvent* e) + { + if(activeTool() && m_delegateEvents) { + return activeTool()->processEvent(e); + } + + return false; + } + + Kivio::MouseTool* PluginManager::activeTool() + { + return m_activeTool; + } + + Kivio::MouseTool* PluginManager::defaultTool() + { + return m_defaultTool; + } + + void PluginManager::activateDefaultTool() + { + if(defaultTool()) { + kdDebug(43000) << "Default tool activated! " << defaultTool()->name() << endl; + defaultTool()->setActivated(true); + } + } + + void PluginManager::activate(Kivio::MouseTool* tool) + { + if(tool != m_activeTool) { + if(m_activeTool) { + kdDebug(43000) << "Deactivate tool: " << m_activeTool->name() << endl; + m_activeTool->setActivated(false); + } + + kdDebug(43000) << "Activate new tool: " << tool->name() << endl; + m_activeTool = tool; + } + } + + void PluginManager::setDefaultTool(Kivio::MouseTool* tool) + { + m_defaultTool = tool; + kdDebug(43000) << "New default tool: " << tool->name() << endl; + } + + Kivio::Plugin* PluginManager::findPlugin(const QString& name) + { + QPtrList<KParts::Plugin> plugins = KParts::Plugin::pluginObjects(parent()); + KParts::Plugin* p = plugins.first(); + bool found = false; + + while(p && !found) { + if(p->name() == name) { + found = true; + } else { + p = plugins.next(); + } + } + + return static_cast<Kivio::Plugin*>(p); + } +} + +#include "kivio_pluginmanager.moc" diff --git a/kivio/kiviopart/tools/kivio_pluginmanager.h b/kivio/kiviopart/tools/kivio_pluginmanager.h new file mode 100644 index 00000000..d8914b50 --- /dev/null +++ b/kivio/kiviopart/tools/kivio_pluginmanager.h @@ -0,0 +1,65 @@ +/* + * Kivio - Visual Modelling and Flowcharting + * Copyright (C) 2003 Peter Simonsson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#ifndef KIVIO_PLUGINMANAGER_H +#define KIVIO_PLUGINMANAGER_H + +#include <qobject.h> +#include "kivio_mousetool.h" +#include <koffice_export.h> + +namespace Kivio { + class Plugin; + + /** + This class manages the plugins*/ + class KIVIO_EXPORT PluginManager : public QObject { + Q_OBJECT + public: + PluginManager(KivioView* parent, const char* name = 0); + ~PluginManager(); + + bool delegateEvent(QEvent* e); + + void setEventDelegationEnabled(bool enabled) { m_delegateEvents = enabled; } + bool eventDelegationEnabled() const { return m_delegateEvents; } + + /** Returns the tool that is in use. */ + Kivio::MouseTool* activeTool(); + /** Returns the default tool. */ + Kivio::MouseTool* defaultTool(); + + Kivio::Plugin* findPlugin(const QString& name); + + public slots: + /** Makes the default tool active. */ + void activateDefaultTool(); + /** Makes @param tool active. */ + void activate(Kivio::MouseTool* tool); + /** Make @param tool the default. */ + void setDefaultTool(Kivio::MouseTool* tool); + + private: + Kivio::MouseTool* m_activeTool; + Kivio::MouseTool* m_defaultTool; + + bool m_delegateEvents; + }; +} + +#endif diff --git a/kivio/kiviopart/tools/kivio_tool.rc b/kivio/kiviopart/tools/kivio_tool.rc new file mode 100644 index 00000000..9e602d1c --- /dev/null +++ b/kivio/kiviopart/tools/kivio_tool.rc @@ -0,0 +1,4 @@ +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd" ><kpartgui name="kivio" version="2"> +<ToolBar name="ToolsToolBar" fullWidth="false" position="left" > +</ToolBar> +</kpartgui> diff --git a/kivio/kiviopart/tools/mousetoolaction.cpp b/kivio/kiviopart/tools/mousetoolaction.cpp new file mode 100644 index 00000000..546c5634 --- /dev/null +++ b/kivio/kiviopart/tools/mousetoolaction.cpp @@ -0,0 +1,98 @@ +/* + * Kivio - Visual Modelling and Flowcharting + * Copyright (C) 2005 Peter Simonsson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include "mousetoolaction.h" + +#include <ktoolbar.h> +#include <ktoolbarbutton.h> +#include <kdebug.h> + +namespace Kivio { + +MouseToolAction::MouseToolAction(const QString& text, const KShortcut& cut, + QObject* parent, const char* name) + : KRadioAction(text, cut, parent, name) +{ +} + +MouseToolAction::MouseToolAction(const QString& text, const KShortcut& cut, + const QObject* receiver, const char* slot, + QObject* parent, const char* name) + : KRadioAction(text, cut, receiver, slot, parent, name) +{ +} + +MouseToolAction::MouseToolAction(const QString& text, const QIconSet& pix, + const KShortcut& cut, + QObject* parent, const char* name) + : KRadioAction(text, pix, cut, parent, name) +{ +} + +MouseToolAction::MouseToolAction(const QString& text, const QString& pix, + const KShortcut& cut, + QObject* parent, const char* name) + : KRadioAction(text, pix, cut, parent, name) +{ +} + +MouseToolAction::MouseToolAction(const QString& text, const QIconSet& pix, + const KShortcut& cut, + const QObject* receiver, const char* slot, + QObject* parent, const char* name) + : KRadioAction(text, pix, cut, receiver, slot, parent, name) +{ +} + +MouseToolAction::MouseToolAction(const QString& text, const QString& pix, + const KShortcut& cut, + const QObject* receiver, const char* slot, + QObject* parent, const char* name) + : KRadioAction(text, pix, cut, receiver, slot, parent, name) +{ +} + +MouseToolAction::MouseToolAction(QObject* parent, const char* name) + : KRadioAction(parent, name) +{ +} + +MouseToolAction::~MouseToolAction() +{ +} + +int MouseToolAction::plug(QWidget* widget, int index) +{ + int usedIndex = KRadioAction::plug(widget, index); + + if(usedIndex == -1) { + return usedIndex; + } + + if(::qt_cast<KToolBar*>(widget)) { + KToolBar* toolBar = static_cast<KToolBar*>(widget); + KToolBarButton* button = toolBar->getButton(itemId(usedIndex)); + connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL(doubleClicked())); + } + + return usedIndex; +} + +} + +#include "mousetoolaction.moc" diff --git a/kivio/kiviopart/tools/mousetoolaction.h b/kivio/kiviopart/tools/mousetoolaction.h new file mode 100644 index 00000000..fd172f68 --- /dev/null +++ b/kivio/kiviopart/tools/mousetoolaction.h @@ -0,0 +1,126 @@ +/* + * Kivio - Visual Modelling and Flowcharting + * Copyright (C) 2005 Peter Simonsson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#ifndef KIVIOMOUSETOOLACTION_H +#define KIVIOMOUSETOOLACTION_H + +#include <kactionclasses.h> +#include <koffice_export.h> + +namespace Kivio { + +class KIVIO_EXPORT MouseToolAction : public KRadioAction +{ + Q_OBJECT + public: + /** + * Constructs a mouse tool action with text and potential keyboard + * accelerator but nothing else. Use this only if you really + * know what you are doing. + * + * @param text The text that will be displayed. + * @param cut The corresponding keyboard accelerator (shortcut). + * @param parent This action's parent. + * @param name An internal name for this action. + */ + MouseToolAction(const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0, const char* name = 0); + + /** + * @param text The text that will be displayed. + * @param cut The corresponding keyboard accelerator (shortcut). + * @param receiver The SLOT's parent. + * @param slot The SLOT to invoke to execute this action. + * @param parent This action's parent. + * @param name An internal name for this action. + */ + MouseToolAction(const QString& text, const KShortcut& cut, + const QObject* receiver, const char* slot, QObject* parent, const char* name = 0); + + /** + * @param text The text that will be displayed. + * @param pix The icons that go with this action. + * @param cut The corresponding keyboard accelerator (shortcut). + * @param parent This action's parent. + * @param name An internal name for this action. + */ + MouseToolAction(const QString& text, const QIconSet& pix, const KShortcut& cut = KShortcut(), + QObject* parent = 0, const char* name = 0); + + /** + * @param text The text that will be displayed. + * @param pix The dynamically loaded icon that goes with this action. + * @param cut The corresponding keyboard accelerator (shortcut). + * @param parent This action's parent. + * @param name An internal name for this action. + */ + MouseToolAction(const QString& text, const QString& pix, const KShortcut& cut = KShortcut(), + QObject* parent = 0, const char* name = 0); + + /** + * @param text The text that will be displayed. + * @param pix The icons that go with this action. + * @param cut The corresponding keyboard accelerator (shortcut). + * @param receiver The SLOT's parent. + * @param slot The SLOT to invoke to execute this action. + * @param parent This action's parent. + * @param name An internal name for this action. + */ + MouseToolAction(const QString& text, const QIconSet& pix, const KShortcut& cut, + const QObject* receiver, const char* slot, QObject* parent, const char* name = 0); + + /** + * @param text The text that will be displayed. + * @param pix The dynamically loaded icon that goes with this action. + * @param cut The corresponding keyboard accelerator (shortcut). + * @param receiver The SLOT's parent. + * @param slot The SLOT to invoke to execute this action. + * @param parent This action's parent. + * @param name An internal name for this action. + */ + MouseToolAction(const QString& text, const QString& pix, const KShortcut& cut, + const QObject* receiver, const char* slot, + QObject* parent, const char* name = 0); + + /** + * @param parent This action's parent. + * @param name An internal name for this action. + */ + MouseToolAction(QObject* parent = 0, const char* name = 0); + + ~MouseToolAction(); + + /** + * "Plug" or insert this action into a given widget. + * + * This will typically be a menu or a toolbar. From this point + * on, you will never need to directly manipulate the item in the + * menu or toolbar. You do all enabling/disabling/manipulation + * directly with your MouseToolAction object. + * + * @param widget The GUI element to display this action. + * @param index The index of the item. + */ + virtual int plug(QWidget* widget, int index = -1); + + signals: + void doubleClicked(); +}; + +} + +#endif |