summaryrefslogtreecommitdiffstats
path: root/src/notes.h
blob: f5d69f1e29f96c4bb7035bf698e396f0fa233d57 (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
/***************************************************************************
                          notes.h  -  description
                             -------------------
    begin                : sob lis 16 2002
    copyright            : (C) 2002-2004 by Micha³ Rudolf
    email                : mrudolf@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 KNOWIT_NOTES_H
#define KNOWIT_NOTES_H

#include <tqstring.h>
#include <tqpixmap.h>
#include <tqvaluelist.h>
#include <tqvaluevector.h>
#include <tqptrdict.h>
class TQTextStream;
class TQListViewItem;
class KURL;

class TNote;

class TNoteLink
{
public:
   enum {DescriptionLink, LinkDescription, LinkOnly, DescriptionOnly};
   TQString link;
   TQString description;
   TNoteLink()   {}
   TNoteLink(const TQString& s)   {link = s;}
   TNoteLink(const TQString& s1, const TQString& s2) {link = s1; description = s2;}
   int operator==(const TNoteLink& N) const   {return link == N.link &&
      description == N.description;}
   int operator!=(const TNoteLink& N) const   {return link != N.link ||
      description != N.description;}
   void save(TQTextStream& ts) const;
   void open() const;
   void openWith() const;
   TQString text(int fmt = DescriptionLink) const;
   TQPixmap icon() const;
   bool isLocalReference() const;
};


class TNotesCollection : public TQPtrDict<TNote> {
public:
   TQPixmap Pixmaps[4];
   TNotesCollection();
   ~TNotesCollection();
   void addNote(TQListViewItem* item);
   void addNote(TQListViewItem* item, const TQString& s);
   void removeNote(TQListViewItem* item);
   bool changeNote(TQListViewItem* item, const TQString& s);
   void clearNotes();
   void updateNotesView();
   bool modified;
   bool autoUpdate;
   const TQString& text(TQListViewItem* item);
};


class TNote {
private:
   TQValueList<TNoteLink> links;
   TNotesCollection* collection;
   bool saveHTMLBuf(TQTextStream& ts, TQValueVector<int>& depths,
      int flags = SaveAll);
   bool saveHTMLTocEntry(TQTextStream& ts, TQValueVector<int>& depths, int flags);
public:
   typedef enum {Empty, Text, EmptyParent, TextParent} State;
   enum {SaveCurrent = 0, SaveSubnotes = 0x0001, SaveAll = 0x0002, UseUTF8 = 0x0040,
         Enumerate = 0x0080, AddRule = 0x0100, Style = 0x0200, TOC = 0x0400};
   TQListViewItem* item;
   TQString text;
   bool isEmpty();
   bool contains(const TQString& sought, bool case_sensitive = false);
   bool change(const TQString& s);
   void destroy();
   void updateView();
   State state();
   void open(TQTextStream& ts);
   void save(TQTextStream& ts, bool current = false);
   bool saveHTML(const KURL& fname, const TQString& origname, const TQString& style,
      int flags = SaveAll);
   void addLink(const TQString& s);
   void addLink(const TNoteLink& l);
   int linkCount() const;
   const TNoteLink& link(int i) const;
   void removeLink(int i);
   void modifyLink(int i, const TQString& s);
   void modifyLink(int i, TNoteLink& l);
   void modifyLinkDescription(int i, const TQString& s);
   TNote(TQListViewItem* i, TNotesCollection* coll);
   TNote(TQListViewItem* i, TNotesCollection* coll, const TQString& s);
   ~TNote();
};
#endif