You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tdewebdev/quanta/utility/tagactionset.h

165 lines
4.5 KiB

/***************************************************************************
tagactionset.h
-------------------
copyright : (C) 2004 - Paulo Moura Guedes
email : moura@tdewebdev.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 TDEActionSeparator;
#include <tqobject.h>
class TQWidget;
class TDEActionSet;
class TDEActionMenu;
class Node;
class NodeModifsSet;
/**
@author Paulo Moura Guedes
*/
class TagActionSetAbstract : public TQObject
{
Q_OBJECT
public:
TagActionSetAbstract(TQObject *parent = 0, const char *name = 0);
virtual ~TagActionSetAbstract();
DOM::Node const& currentDomNode() const {return m_currentDomNode;}
static Node* parentTag(Node* node, TQString const& tagName);
static Node* firstChildTag(Node* node, TQString const& tagName);
virtual bool isInTagContext(/*DOM::Node const& node*/) const = 0;
virtual void initActions(TQWidget* parent) = 0;
virtual bool fillWithTagActions(TQWidget* widget, DOM::Node const& node);
virtual void unplugAllActions(TQWidget* widget) const = 0;
protected:
virtual void initActionMenus(TQWidget* widget) = 0;
protected:
Node* m_currentNode;
private:
DOM::Node m_currentDomNode;
};
class TagActionSet : public TagActionSetAbstract
{
Q_OBJECT
public:
TagActionSet(TQObject *parent = 0, const char *name = 0);
virtual ~TagActionSet() {}
virtual bool isInTagContext() const;
virtual void initActions(TQWidget* parent);
virtual bool fillWithTagActions(TQWidget* widget, DOM::Node const& node);
virtual void unplugAllActions(TQWidget* widget) const;
public slots:
void slotApplySourceIndentation();
void slotCopyDivElement();
void slotCutDivElement();
protected:
virtual void initActionMenus(TQWidget* widget);
private:
bool isInDivArea() const;
private:
TDEActionSeparator* m_separator;
};
class TableTagActionSet : public TagActionSetAbstract
{
Q_OBJECT
public:
TableTagActionSet(TQObject *parent = 0, const char *name = 0);
virtual ~TableTagActionSet()
{}
virtual bool isInTagContext(/*DOM::Node const& node*/) const;
virtual void initActions(TQWidget* parent);
virtual bool fillWithTagActions(TQWidget* widget, DOM::Node const& node);
virtual void unplugAllActions(TQWidget* 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(TQWidget* 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:
TDEActionSeparator* m_separator;
TDEActionMenu* m_tableActionMenu_0;
TDEActionMenu* m_insertActionMenu_1;
TDEActionMenu* m_removeActionMenu_1;
};
#endif