From e9ae80694875f869892f13f4fcaf1170a00dea41 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdewebdev@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- quanta/utility/tagactionset.h | 161 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 quanta/utility/tagactionset.h (limited to 'quanta/utility/tagactionset.h') diff --git a/quanta/utility/tagactionset.h b/quanta/utility/tagactionset.h new file mode 100644 index 00000000..6bb2448f --- /dev/null +++ b/quanta/utility/tagactionset.h @@ -0,0 +1,161 @@ +/*************************************************************************** + tagactionset.h + ------------------- + + copyright : (C) 2004 - Paulo Moura Guedes + email : moura@kdewebdev.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef TAGACTIONSET_H +#define TAGACTIONSET_H + +namespace DOM +{ +class Node; +} +class KActionSeparator; + +#include +class QWidget; +class KActionSet; +class KActionMenu; + +class Node; +class NodeModifsSet; + +/** +@author Paulo Moura Guedes +*/ +class TagActionSetAbstract : public QObject +{ + Q_OBJECT +public: + TagActionSetAbstract(QObject *parent = 0, const char *name = 0); + virtual ~TagActionSetAbstract(); + + DOM::Node const& currentDomNode() const {return m_currentDomNode;} + + static Node* parentTag(Node* node, QString const& tagName); + static Node* firstChildTag(Node* node, QString const& tagName); + + virtual bool isInTagContext(/*DOM::Node const& node*/) const = 0; + virtual void initActions(QWidget* parent) = 0; + virtual bool fillWithTagActions(QWidget* widget, DOM::Node const& node); + virtual void unplugAllActions(QWidget* widget) const = 0; + +protected: + virtual void initActionMenus(QWidget* widget) = 0; + +protected: + Node* m_currentNode; + +private: + DOM::Node m_currentDomNode; +}; + + +class TagActionSet : public TagActionSetAbstract +{ + Q_OBJECT +public: + TagActionSet(QObject *parent = 0, const char *name = 0); + virtual ~TagActionSet() {} + + virtual bool isInTagContext() const; + virtual void initActions(QWidget* parent); + virtual bool fillWithTagActions(QWidget* widget, DOM::Node const& node); + virtual void unplugAllActions(QWidget* widget) const; + +public slots: + void slotApplySourceIndentation(); + void slotCopyDivElement(); + void slotCutDivElement(); + +protected: + virtual void initActionMenus(QWidget* widget); + +private: + bool isInDivArea() const; + +private: + KActionSeparator* m_separator; +}; + + +class TableTagActionSet : public TagActionSetAbstract +{ + Q_OBJECT +public: + TableTagActionSet(QObject *parent = 0, const char *name = 0); + virtual ~TableTagActionSet() + {} + + virtual bool isInTagContext(/*DOM::Node const& node*/) const; + virtual void initActions(QWidget* parent); + virtual bool fillWithTagActions(QWidget* widget, DOM::Node const& node); + virtual void unplugAllActions(QWidget* widget) const; + +public slots: + // Insert + void slotInsertTable(); + void slotInsertRowAbove(); + void slotInsertRowBelow(); + void slotInsertColumnLeft(); + void slotInsertColumnRight(); + // Remove + void slotRemoveTable(); + void slotRemoveRows(); + void slotRemoveColumns(); + void slotRemoveCells(); + void slotRemoveCellsContent(); + // Merge + void slotMergeSelectedCells(); + +protected: + virtual void initActionMenus(QWidget* widget); + +private: + // Insert + bool canInsertTable() const; + bool canInsertRowAbove() const; + bool canInsertRowBelow() const; + bool canInsertColumnLeft() const; + bool canInsertColumnRight() const; + // Remove + bool canRemoveTable() const; + bool canRemoveRows() const; + bool canRemoveColumns() const; + bool canRemoveCells() const; + bool canRemoveCellsContent() const; + // Merge + bool canMergeSelectedCells() const; + + Node* tableStart() const; + int numberOfColumns() const; + int currentColumnIndex() const; + int columnIndex(Node* node) const; + Node* buildEmptyRowSubtree() const; + Node* buildEmptyTBodyCellSubtree() const; + Node* buildEmptyTHeadCellSubtree() const; + + void removeColumn(int index, NodeModifsSet* modifs); + void clearCellContents(Node* tdNode, NodeModifsSet* modifs); + +private: + KActionSeparator* m_separator; + + KActionMenu* m_tableActionMenu_0; + KActionMenu* m_insertActionMenu_1; + KActionMenu* m_removeActionMenu_1; +}; + +#endif -- cgit v1.2.1