summaryrefslogtreecommitdiffstats
path: root/src/knowit.h
blob: 095f6f66b11da421842dd93edd7493387bfe786f (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
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
/***************************************************************************
                          knowit.h  -  description
                             -------------------
    begin                : czw wrz 26 08:27:40 CEST 2002
    copyright            : (C) 2002-2004 by Micha� Rudolf
    email                : [email protected]
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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 KNOWIT_H
#define KNOWIT_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <tqurloperator.h>

#include <keditcl.h>
#include <klocale.h>
#include <kmainwindow.h>
#include <kurl.h>
#include "knowitpref.h"
#include "knowitchooser.h"
#include "knowitedit.h"
#include "knowitlink.h"
#include "notes.h"

class TQSplitter;
class TQTimer;
class KAction;
class KConfig;
class KListBox;
class KToggleAction;
class KRecentFilesAction;

class KnowitTray;
class KnowitEdit;
class KnowitTree;
   

/** Knowit is the base class of the project */
class Knowit : public KMainWindow
{
  Q_OBJECT
  TQ_OBJECT
  private:
    static const TQString Untitled;
    KConfig *config;
    TQSplitter* Layout;
    KnowitTree* Items;
    KListBox* Links;
    KnowitEdit* Edit;
    KURL filename;
    TQPixmap pixmapFolder, pixmapFolderText, pixmapText, pixmapEmpty;
    KEdFind FindDlg;
    KnowitOptions Options;
    KnowitPreferences PrefDlg;
    KnowitChooser ChooserDlg;
    KnowitLinkDialog LinkDlg;
    KnowitTray* systray;
    /* data items */
    TNotesCollection Notes;
    bool runMinimized;
    TQListViewItem* lastSought;
    TQString soughtText;
    TQTimer* AutosaveTimer;
    /* for saving backups */
    TQUrlOperator URLOperator;
    /* false by default, set to true on queryClose() */
    bool shuttingDown;
    /* actions */
    KRecentFilesAction *actionRecent;
    KToggleAction *actionBold, *actionItalic, *actionUnderline,
       *actionEditAlignLeft, *actionEditAlignRight, *actionEditAlignCenter,
       *actionEditAlignJustify, *actionRawTextMode;
    KAction *actionCut, *actionCopy, *actionUndo, *actionRedo;

    /** Insert/Overwrite status */
    enum {StatusText = 1, StatusOvr = 2};    
  public:
    /** Constructor of main window */
    Knowit(TQWidget* tqparent=0, const char *name=0);
    /** Standard destructor */
    ~Knowit();
    /** Opens document */
    bool open(const KURL& fname);
    /** Saves document */
    bool save(const KURL& fname);
    /** Removes all data, creante new document */
    void reset();
    /** Checks if file was changed since last save, if so,
       user is prompted to save changes */
    virtual bool queryClose();
    /** Saves options and exits */
    virtual bool queryExit();
    /** Reads configuration from disk */
    void readOptions();
    /** Saves configuration to disk */
    void saveOptions();

    /** Finds and shows next occurence of currently sought text
       - or show message that it couldn't be found */
    void tqfind(TQListViewItem* start = 0);
    /** Returns true if notes or current text were modified */
    bool modified();
    /** Reimplemented from TQWidget to prevent from closing when docked */
    virtual void closeEvent(TQCloseEvent* e);
    /** Apply current configuration */
    void applyOptions(const KnowitOptions& O, bool store = true);
    /** Returns current note */
    TNote* currentNote() const;

 public slots:
    /** tqStatus bar text has changed - displays it */
    void slotStatusMsg(const TQString& text);
    /** Shows requested popup menu for notes */
    void slotContextMenu(KListView*, TQListViewItem*, const TQPoint&);
    /** Shows given note */
    void slotNoteChanged(TQListViewItem* item);
    /** Add same-level note */
    void slotNoteAdd();
    /** Adds subnote */
    void slotNoteAddChild();
    /** Changes note's name */
    void slotNoteRename();
    /** Removes current note */
    void slotNoteRemove();
    /** Sort subnotes */
    void slotNoteSort();

    /** Move note up */
    void slotNoteMoveUp();
    /** Move note down */
    void slotNoteMoveDown();
    /** Move note at the beginning of current list */
    void slotNoteMoveBegin();
    /** Move note at the end of current list */
    void slotNoteMoveEnd();
    /** Move note level up */
    void slotNoteMoveLeft();
    /** Move note level down */
    void slotNoteMoveRight();

    /** Current item has changed - updates associated text and shows next */
    void slotItemChanged(TQListViewItem*);
    /** Resets to a new file */
    void slotFileNew();
    /** Prompts for a file to open and opens it */
    void slotFileOpen();
    /** Opens selected of recent files */
    void slotFileRecent(const KURL&);
    /** Saves file using previous name */
    void slotFileSave();
    /** Autosaves file using previous name */
    void slotFileAutosave();
    /** Prompts for filename and saves file */
    void slotFileSaveAs();
    /** Exports all notes to HTML */
    void slotFileExport();
    /** Prints current note */
    void slotFilePrint();
    /** Shows basic file statistics */
    void slotFileInfo();
    /** Quits KnowIt */
    void slotFileQuit();
    /** Turns bold in edit window on/off */
    void slotEditBold();
    /** Turns italic in edit window on/off */
    void slotEditItalic();
    /** Turns underlining in edit window on/off */
    void slotEditUnderline();
    /** Changes color of selected/current text */
    void slotEditColor();
    /** Changes vertical tqalignment to superscript */
    void slotEditSuperscript();
    /** Changes vertical tqalignment to subscript */
    void slotEditSubscript();
    /** Restores normal vertical tqalignment */
    void slotEditNormal();
    /** Prompts for text and shows note containing it */
    void slotEditFind();
    /** Shows next note with sought text */
    void slotEditFindNext();
    /** Shows note with given title */
    void slotEditGoTo();
    /** Aligns text to the left */
    void slotEditAlignLeft();
    /** Aligns text to the right */
    void slotEditAlignRight();
    /** Justifies text */
    void slotEditAlignJustify();
    /** Centers text */
    void slotEditAlignCenter();
    /** Change selected paragraphs to list. Warning: uses obsolete TQt function */
    void slotEditListBullet();
    void slotEditListNumber();
    void slotEditListUpper();
    void slotEditListLower();
    void slotEditListNone();
    /** Inserts current date */
    void slotEditInsertDate();
    /** Inserts file into editor */
    void slotEditInsertFile();
    /** Switches active window (notes/editor) */
    void slotEditSwitch();
    /** Edited text has changed - update bold/italic/... status */
    void slotEditChanged();
    /** Cursor position has changed - update bold/italic/... status */
    void slotEditCursorChanged(int para, int pos);
    /** Shows options dialog */
    void slotOptions();
    /** Shows shortcut configuration dialog */
    void slotOptionsKeys();
    /** Shows toolbar configuration dialog */
    void slotOptionsToolbar();
    /** Removes KnowIt from Applet Tray */
    void slotUndock();
    /** Shows tip of the day */
    void slotHelpTip();
    /** Updates available commands */
    void slotActionUpdate();
    /** Text Insert mode changed, called from statusbar */
    void slotOverwriteModeChange(int);
    /** Text Insert mode changed, called from Shortcut Key */
    void slotOverwriteModeChange();
    /** Toggles raw text/rich text edit mode */
    void slotRawTextMode();
    
    /** Shows requested popup menu for links */
    void slotContextLinksMenu(TQListBoxItem* item, const TQPoint&);
    /** show current attachment **/
    void slotShowAttachment(TQListBoxItem* i);
    /** Add link **/
    void slotLinkAdd();
    /** Handle dropped link **/
    void slotLinkDropped(const TQString& s, int flags);
    /** Remove link **/
    void slotLinkRemove();
    /** Open link **/
    void slotLinkOpen();
    /** Open link with selected application **/
    void slotLinkOpenWith();
    /** Modify link **/
    void slotLinkModify();
    /** Copy link location **/
    void slotLinkCopy();
};

#endif