blob: bd0f2f34272b0679c5f0abd066b19b02c36fb4e2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
//
// C++ Interface: %{MODULE}
//
// Description:
//
//
// Author: %{AUTHOR} <%{EMAIL}>, (C) %{YEAR}
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef CONTEXTMENUHANDLER_H
#define CONTEXTMENUHANDLER_H
// TQt includes
#include <tqobject.h>
#include <tqstring.h>
#include <tqxml.h>
// KDE includes
#include <kaction.h>
#include <kpopupmenu.h>
//forward declarations
class ContextMenuHandler;
class ListViewInterface;
/**
@author Robert Vogl
*/
class ContextActionHandler : public TQXmlDefaultHandler
{
public:
ContextActionHandler(ContextMenuHandler *menuhandler = 0);
~ContextActionHandler();
// Reimplementations from base class
bool startElement( const TQString &namespaceURI,
const TQString &localName,
const TQString &qName,
const TQXmlAttributes &atts );
// Reimplementations from base class
bool endElement( const TQString &namespaceURI,
const TQString &localName,
const TQString &qName );
// Reimplementations from base class
bool characters( const TQString &ch );
void setSearchID( const TQString xmlID );
private:
ContextMenuHandler *m_menuhandler;
TQString m_subName;
TQString m_actionName;
TQString m_qty;
TDEPopupMenu *m_popup;
bool m_hit;
TQString m_searchID;
};
/**
@author Robert Vogl
*/
class ContextMenuHandler : public TQObject
{
Q_OBJECT
public:
ContextMenuHandler(TQObject *parent = 0, const char *name = 0);
~ContextMenuHandler();
/**
* \param item The selected TreeView item.
* \returns A pointer to the popup-menu.
*/
TDEPopupMenu* getPopupMenu(ListViewInterface *item);
/**
* \returns A pointer to the Submenu as a child of the parent
* \p parent.
*/
TDEPopupMenu* SubMenuFactory(TDEPopupMenu *parent);
/**
* Creates an action sufficiant to the given name.
* It checks if the action is allowed or not and returns
* a disabled or enabled action.
* \param actionName The name of the action as defined in the
* namespace \p ContextMenu.xml.
* \param qty The maximum allowed quantity of the same action for the
* given element.
* \returns A Pointer to the action.
*/
TDEAction* ActionFactory( const TQString &actionName, const TQString &qty );
/**
* Creates a Popup context menu for the given item and stores a
* pointer to it in \p m_MenuList.
*/
void registerPopupMenu(ListViewInterface *item);
/**
* Sets wether the content of the item is editable or not.
*/
void setItemEditable( bool editable );
/**
* Sets the number of lines a editable item can hold.
* -1 = unlimited.
*/
void setItemMaxlines( const TQString &maxlines );
private: // Methods
void initActions();
bool parseXmlFile(const TQString &xmlID);
public: // Attributes
TDEPopupMenu* m_popupmenu;
private:
// Basic actions
TDEAction* renameItem;
TDEAction* deleteItem;
// Actions to create new items
TDEAction* newBookInfo;
TDEAction* newChapter;
TDEAction* newKeywordSet;
TDEAction* newKeyword;
TDEAction* newAbstract;
TDEAction* newAuthorGroup;
TDEAction* newAuthor;
TDEAction* newDate;
TDEAction* newReleaseInfo;
TDEAction* newTitle;
TDEAction* newParagraph;
TDEAction* newSection_1;
TDEAction* newSection_2;
TDEAction* newSection_3;
TDEAction* newSection_4;
TDEAction* newSection_5;
// mixed stuff
TQString m_XmlFilePath;
ListViewInterface* m_item;
TQObject* m_DocTreeView;
};
#endif
|