summaryrefslogtreecommitdiffstats
path: root/bibletime/frontend/mainindex/cmainindex.h
blob: 0719e64cda880b83d8926f0fe82c5cc2d3602006 (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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/*********
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
* Copyright 1999-2006 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/



#ifndef CMAININDEX_H
#define CMAININDEX_H

//BibleTime includes
#include "cindexitem.h"

#include "backend/cswordmoduleinfo.h"
#include "frontend/displaywindow/cdisplaywindow.h"

#include "util/cpointers.h"

//TQt includes
#include <tqwidget.h>
#include <tqtimer.h>
#include <tqtooltip.h>

//KDE includes
#include <tdeaction.h>
#include <tdelistview.h>

class CSearchDialog;

/** The class which manages all bookmarks and modules. The modules are put into own, fixed subfolders sorted by language.
  * @author The BibleTime team
  */
class CMainIndex : public TDEListView {
	Q_OBJECT
  

	class ToolTip : public TQToolTip {
	public:
		ToolTip(CMainIndex* parent);
		virtual ~ToolTip() {}
		/**
		* Displays a tooltip for position p using the getToolTip() function of CGroupManagerItem
		*/
		virtual void maybeTip( const TQPoint &pos);

	private:
		CMainIndex* m_mainIndex;
	};

public:
	CMainIndex(TQWidget *parent);
	virtual ~CMainIndex();
	
	void initTree();
	/**
	* Opens the searchdialog using the given modules using the given search text.
	*/
	void emitModulesChosen( ListCSwordModuleInfo modules, TQString key );
	/**
	* Saves the bookmarks to disk
	*/
	void saveBookmarks();
	/**
	* Reloads the main index's Sword dependend things like modules
	*/
	void reloadSword();

public slots:
	/**
	 * Opens the searchdialog for the selected modules.
	 */
	void searchInModules();

protected: // Protected methods
	/**
	* Reimplementation. Adds the given group to the tree.
	*/
	virtual void addGroup( const CItemBase::Type type, const TQString language);
	/**
	* Initialize the SIGNAL<->TQT_SLOT connections
	*/
	void initConnections();
	/**
	* Reimplementation. Returns the drag object for the current selection.
	*/
	virtual TQDragObject* dragObject();
	/**
	* Reimplementation from TDEListView. Returns true if the drag is acceptable for the listview.
	*/
	virtual bool acceptDrag( TQDropEvent* event ) const;
	/**
	* Returns the correct TDEAction object for the given type of action.
	*/
	TDEAction* const action( const CItemBase::MenuAction type ) const;
	/**
	* Reimplementation. Takes care of movable items.
	*/
	virtual void startDrag();
	/**
	* Reimplementation to support the items dragEnter and dragLeave functions.
	*/
	virtual void contentsDragMoveEvent( TQDragMoveEvent* event );
	/**
	 * Reimplementation.
	 */
	virtual void contentsDragLeaveEvent( TQDragLeaveEvent* e );
	TQRect drawItemHighlighter(TQPainter* painter, TQListViewItem * item );
	/** Read settings like open groups or scrollbar position and restore them
	*/
	void readSettings();
	/** Save settings like roups close/open status to the settings file.
	*/
	void saveSettings();
	/** Reimplementation.
	 */
	virtual void polish();

protected slots: // Protected slots
	/**
	* Is called when an item was clicked/double clicked.
	*/
	void slotExecuted( TQListViewItem* );
	void dropped( TQDropEvent*, TQListViewItem*, TQListViewItem*);
	/**
	* Shows the context menu at the given position.
	*/
	void contextMenu(TDEListView*, TQListViewItem*, const TQPoint&);
	/**
	* Adds a new subfolder to the current item.
	*/
	void createNewFolder();
	/**
	* Opens a dialog to change the current folder.
	*/
	void changeFolder();
	/**
	* Exports the bookmarks being in the selected folder.
	*/
	void exportBookmarks();
	/**
	* Changes the current bookmark.
	*/
	void changeBookmark();
	/**
	* Import bookmarks from a file and add them to the selected folder.
	*/
	void importBookmarks();
	/**
	* Deletes the selected entries.
	*/
	void deleteEntries();
	/**
	* Prints the selected bookmarks.
	*/
	void printBookmarks();
	/**
	* Shows information about the current module.
	*/
	void aboutModule();
	/**
	* Unlocks the current module.
	*/
	void unlockModule();
	void autoOpenTimeout();
	/**
	* Is called when items should be moved.
	*/
	void moved( TQPtrList<TQListViewItem>& items, TQPtrList<TQListViewItem>& afterFirst, TQPtrList<TQListViewItem>& afterNow);
	/**
	* Opens a plain text editor window to edit the modules content.
	*/
	void editModulePlain();
	/**
	* Opens an HTML editor window to edit the modules content.
	*/
	void editModuleHTML();

private:
	CSearchDialog* m_searchDialog;
	ToolTip* m_toolTip;
	bool m_itemsMovable;
	TQListViewItem* m_autoOpenFolder;
	TQTimer m_autoOpenTimer;

	/**
	* Initializes the view.
	*/
	void initView();
	/**
	* Returns true if more than one netry is supported by this action type.
	* Returns false for actions which support only one entry, e.g. about module etc.
	*/
	const bool isMultiAction( const CItemBase::MenuAction type ) const;

	struct Actions {
		TDEAction* newFolder;
		TDEAction* changeFolder;

		TDEAction* changeBookmark;
		TDEAction* importBookmarks;
		TDEAction* exportBookmarks;
		TDEAction* printBookmarks;

		TDEAction* deleteEntries;

		TDEActionMenu* editModuleMenu;
		TDEAction* editModulePlain;
		TDEAction* editModuleHTML;

		TDEAction* searchInModules;
		TDEAction* unlockModule;
		TDEAction* aboutModule;
	}
	m_actions;
	TDEPopupMenu* m_popup;

signals:
	/**
	* Is emitted when a module should be opened,
	*/
	void createReadDisplayWindow( ListCSwordModuleInfo, const TQString& );
	/**
	 * Is emitted when a write window should be created.
	 */
	void createWriteDisplayWindow( CSwordModuleInfo*, const TQString&, const CDisplayWindow::WriteWindowType& );
	void signalSwordSetupChanged();
};

#endif