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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
|
/***************************************************************************
copyright : (C) 2001-2006 by Robby Stephenson
email : robby@periapsis.org
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of version 2 of the GNU General Public License as *
* published by the Free Software Foundation; *
* *
***************************************************************************/
#ifndef TELLICO_MAINWINDOW_H
#define TELLICO_MAINWINDOW_H
#include <config.h>
#include "core/dcopinterface.h"
#include "translators/translators.h"
#include "datavectors.h"
#include <tdemainwindow.h>
class TDEToolBar;
class KURL;
class TDEAction;
class TDESelectAction;
class TDEToggleAction;
class TDERecentFilesAction;
class TDEActionMenu;
class KDialogBase;
class TQCloseEvent;
class TQSplitter;
class TQListViewItem;
namespace Tellico {
// forward declarations
namespace GUI {
class LineEdit;
class TabControl;
}
class Controller;
class ViewStack;
class DetailedListView;
class FilterDialog;
class EntryEditDialog;
class GroupView;
class FilterView;
class LoanView;
class ConfigDialog;
class CollectionFieldsDialog;
class StringMapDialog;
class EntryItem;
class FetchDialog;
class ReportDialog;
class StatusBar;
class DropHandler;
/**
* The base class for Tellico application windows. It sets up the main
* window and reads the config file as well as providing a menubar, toolbar
* and statusbar. Tellico reimplements the methods that TDEMainWindow provides
* for main window handling and supports full session management as well as
* using TDEActions.
* @see TDEMainWindow
* @see TDEApplication
* @see TDEConfig
*
* @author Robby Stephenson
*/
class MainWindow : public TDEMainWindow, public ApplicationInterface {
Q_OBJECT
friend class Controller;
friend class DropHandler;
public:
/**
* The main window constructor, calls all init functions to create the application.
*/
MainWindow(TQWidget* parent=0, const char* name=0);
/**
* Opens the initial file.
*
* @param nofile If true, even if the config option to reopen last file is set, no file is opened
*/
void initFileOpen(bool nofile);
/**
* Saves the document
*
* @return Returns @p true if successful
*/
bool fileSave();
/**
* Saves a document by a new filename
*
* @return Returns @p true if successful
*/
bool fileSaveAs();
/**
* @return Returns whether the current collection is still the non-saved default one
*/
bool isNewDocument() const { return m_newDocument; }
/**
* Used by main() and DCOP to import file.
*
* @param format The file format
* @param url The url
*/
virtual bool importFile(Import::Format format, const KURL& url, Import::Action action);
/**
* Used by DCOP to export to a file.
*/
virtual bool exportCollection(Export::Format format, const KURL& url);
/**
* Used by DCOP
*/
virtual void openFile(const TQString& file);
virtual void setFilter(const TQString& text);
virtual bool showEntry(long id);
bool eventFilter(TQObject* watched, TQEvent* event);
public slots:
/**
* Initializes some stuff after the object is created.
*/
void slotInit();
/**
* Cleans up everything and then opens a new document.
*
* @param type Type of collection to add
*/
void slotFileNew(int type);
/**
* Opens a file and loads it into the document
*/
void slotFileOpen();
/**
* Opens a file by URL and loads it into the document
*
* @param url The url to open
*/
void slotFileOpen(const KURL& url);
/**
* Opens a file from the recent files menu
*
* @param url The url sent by the RecentFilesAction
*/
void slotFileOpenRecent(const KURL& url);
/**
* Saves the document
*/
void slotFileSave();
/**
* Saves a document by a new filename
*/
void slotFileSaveAs();
/**
* Prints the current document.
*/
void slotFilePrint();
/**
* Quits the application.
*/
void slotFileQuit();
/**
* Puts the marked text/object into the clipboard and removes it from the document.
*/
void slotEditCut();
/*
* Puts the marked text/object into the clipboard.
*/
void slotEditCopy();
/**
* Pastes the clipboard into the document.
*/
void slotEditPaste();
/**
* Selects all the entries in the collection.
*/
void slotEditSelectAll();
/**
* Deselects all the entries in the collection.
*/
void slotEditDeselect();
/**
* Toggles the group widget.
*/
void slotToggleGroupWidget();
/**
* Toggles the edit widget.
*/
void slotToggleEntryEditor();
/**
* Toggles the edit widget.
*/
void slotToggleEntryView();
/**
* Shows the configuration dialog for the application.
*/
void slotShowConfigDialog();
/**
* Hides the configuration dialog for the application.
*/
void slotHideConfigDialog();
/**
* Shows the fetch dialog.
*/
void slotShowFetchDialog();
/**
* Hides the fetch dialog.
*/
void slotHideFetchDialog();
/**
* Changes the statusbar contents for the standard label permanently,
* used to indicate current actions being made.
*
* @param text The text that is displayed in the statusbar
*/
void slotStatusMsg(const TQString& text);
void slotClearStatus();
/**
* Shows the configuration window for the toolbars.
*/
void slotConfigToolbar();
/**
* Updates the toolbars;
*/
void slotNewToolbarConfig();
/**
* Shows the configuration window for the key bindgins.
*/
void slotConfigKeys();
/**
* Updates the entry count in the status bar.
*/
void slotEntryCount();
/**
* Handles updating everything when the configuration is changed
* via the configuration dialog. This slot is called when the OK or Apply
* button is clicked in the dialog
*/
void slotHandleConfigChange();
/**
* Changes the grouping of the entries in the @ref GroupView. The current value
* of the combobox in the toolbar is used.
*/
void slotChangeGrouping();
/**
* Imports data.
*
* @param format The import format
*/
void slotFileImport(int format);
/**
* Exports the current document.
*
* @param format The export format
*/
void slotFileExport(int format);
/**
* Shows the filter dialog for the application.
*/
void slotShowFilterDialog();
/**
* Hides the filter dialog for the application.
*/
void slotHideFilterDialog();
/**
* Shows the collection properties dialog for the application.
*/
void slotShowCollectionFieldsDialog();
/**
* Hides the collection properties dialog for the application.
*/
void slotHideCollectionFieldsDialog();
/**
* Shows the "Tip of the Day" dialog.
*
* @param force Whether the configuration setting should be ignored
*/
void slotShowTipOfDay(bool force=true);
/**
* Shows the string macro editor dialog for the application.
*/
void slotShowStringMacroDialog();
/**
* Hides the string macro editor dialog for the application.
*/
void slotHideStringMacroDialog();
/**
* Handle a url that indicates some actino should be taken
*/
void slotURLAction(const KURL& url);
private:
/**
* Saves the general options like all toolbar positions and status as well as the
* geometry and the recent file list to the configuration file.
*/
void saveOptions();
/**
* Reads the specific options.
*/
void readOptions();
/**
* Initializes the TDEActions of the application
*/
void initActions();
/**
* Sets up the statusbar for the main window by initializing a status label
* and inserting a progress bar and entry counter.
*/
void initStatusBar();
/**
* Initiates the view, setting up all the dock windows and so on.
*/
void initView();
/**
* Initiates the document.
*/
void initDocument();
/**
* Initiates all the signal and slot connections between major objects in the view.
*/
void initConnections();
/**
* Initiates shutdown
*/
// void closeEvent(TQCloseEvent *e);
/**
* Saves the window properties for each open window during session end to the
* session config file, including saving the currently opened file by a temporary
* filename provided by TDEApplication.
* @see TDEMainWindow::saveProperties
*
* @param cfg The config class with the properties to restore
*/
void saveProperties(TDEConfig* cfg);
/**
* Reads the session config file and restores the application's state including
* the last opened files and documents by reading the temporary files saved by
* @ref saveProperties().
* @see TDEMainWindow::readProperties
*
* @param cfg The config class with the properties to restore
*/
void readProperties(TDEConfig* cfg);
/**
* Called before the window is closed, either by the user or indirectely by the
* session manager.
*
* The purpose of this function is to prepare the window in a way that it is safe to close it,
* i.e. without the user losing some data.
* @see TDEMainWindow::queryClose
*/
bool queryClose();
/**
* Called before the very last window is closed, either by the user
* or indirectly by the session manager.
* @see TDEMainWindow::queryExit
*/
bool queryExit();
/**
* Actual method used when opening a URL. Updating for the list views is turned off
* as well as sorting, in order to more quickly load the document.
*
* @param url The url to open
*/
bool openURL(const KURL& url);
/*
* Helper method to handle the printing duties.
*
* @param html The HTML string representing the doc to print
*/
void doPrint(const TQString& html);
void XSLTError();
/**
* Helper function to activate a slot in the edit widget.
* Primarily used for copy, cut, and paste.
*
* @param slot The slot name
*/
void activateEditSlot(const char* slot);
void addFilterView();
void addLoanView();
void updateCaption(bool modified);
void updateCollectionActions();
void updateEntrySources();
private slots:
/**
* Updates the actions when a file is opened.
*/
void slotEnableOpenedActions();
/**
* Updates the save action and the caption when the document is modified.
*/
void slotEnableModifiedActions(bool modified = true);
/**
* Read the options specific to a collection
*
* @param coll The collection pointer
*/
void readCollectionOptions(Tellico::Data::CollPtr coll);
/**
* Saves the options relevant for a collection. I was having problems with the collection
* being destructed before I could save info.
*
* @param coll A pointer to the collection
*/
void saveCollectionOptions(Tellico::Data::CollPtr coll);
/**
* Queue a filter update. The timer adds a 200 millisecond delay before actually
* updating the filter.
*/
void slotQueueFilter();
/**
* Update the filter to match any field with text. If a non-word character appears, the
* text is interpreted as a regexp.
*/
void slotUpdateFilter();
/**
* Updates the collection toolbar.
*/
void slotUpdateCollectionToolBar(Tellico::Data::CollPtr coll);
/**
* Make sure the edit dialog is visible and start a new entry.
*/
void slotNewEntry();
/**
* Handle the entry editor dialog being closed.
*/
void slotEditDialogFinished();
/**
* Handle the Ok button being clicked in the string macros dialog.
*/
void slotStringMacroDialogOk();
/**
* Since I use an application icon in the toolbar, I need to change its size whenever
* the toolbar changes mode
*/
void slotUpdateToolbarIcons();
/**
* Convert current collection to a bibliography.
*/
void slotConvertToBibliography();
/**
* Send a citation for the selected entries
*/
void slotCiteEntry(int action);
/**
* Show the entry editor and update menu item.
*/
void slotShowEntryEditor();
/**
* Show the report window.
*/
void slotShowReportDialog();
void slotGroupLabelActivated();
/**
* Show the report window.
*/
void slotHideReportDialog();
/**
* Focus the filter
*/
void slotFilterLabelActivated();
void slotClearFilter();
void slotRenameCollection();
private:
void importFile(Import::Format format, const KURL::List& kurls);
bool importCollection(Data::CollPtr coll, Import::Action action);
// the reason that I have to keep pointers to all these
// is because they get plugged into menus later in Controller
TDERecentFilesAction* m_fileOpenRecent;
TDEAction* m_fileSave;
TDEAction* m_newEntry;
TDEAction* m_editEntry;
TDEAction* m_copyEntry;
TDEAction* m_deleteEntry;
TDEAction* m_mergeEntry;
TDEActionMenu* m_updateEntryMenu;
TDEAction* m_updateAll;
TDEAction* m_checkInEntry;
TDEAction* m_checkOutEntry;
TDEToggleAction* m_toggleGroupWidget;
TDEToggleAction* m_toggleEntryEditor;
TDEToggleAction* m_toggleEntryView;
TDESelectAction* m_entryGrouping;
GUI::LineEdit* m_quickFilter;
// m_split is used between the stuff on the left and stuff on the right
TQSplitter* m_split;
// m_leftSplit is used between detailed view and entry view
TQSplitter* m_rightSplit;
Tellico::StatusBar* m_statusBar;
DetailedListView* m_detailedView;
EntryEditDialog* m_editDialog;
GUI::TabControl* m_viewTabs;
GroupView* m_groupView;
FilterView* m_filterView;
LoanView* m_loanView;
ViewStack* m_viewStack;
ConfigDialog* m_configDlg;
FilterDialog* m_filterDlg;
CollectionFieldsDialog* m_collFieldsDlg;
StringMapDialog* m_stringMacroDlg;
FetchDialog* m_fetchDlg;
ReportDialog* m_reportDlg;
TQPtrList<TDEAction> m_fetchActions;
CollectionInterface m_collInterface;
// keep track of the number of queued filter updates
uint m_queuedFilters;
// keep track whether everything gets initialized
bool m_initialized : 1;
// need to keep track of whether the current collection has never been saved
bool m_newDocument : 1;
};
} // end namespace
#endif // TELLICO_MAINWINDOW_H
|