kjots
kjotsentry.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __KJOTSENTRY_H
00025 #define __KJOTSENTRY_H
00026
00027
00028 #include <QTreeWidgetItem>
00029 #include <QTextDocument>
00030 #include <QTextCursor>
00031 #include <QSet>
00032
00033
00034
00035
00036
00037 class KJotsPage;
00038 class QDomDocument;
00039 class QDomElement;
00040 class KJotsBook;
00041
00042 class KJotsEntry : public QObject, public QTreeWidgetItem
00043 {
00044 Q_OBJECT
00045 public:
00046 KJotsEntry();
00047
00048 public:
00049 virtual void setTitle(const QString&);
00050 QString title() { return text(0); }
00051 virtual void rename() = 0;
00052 virtual void generateXml( QDomDocument&, QDomElement& );
00053 virtual void parseXml( QDomElement&, bool );
00054 virtual void generateHtml( KJotsEntry*, bool, QTextCursor* ) = 0;
00055 virtual QString generateText( void ) = 0;
00056 virtual void generatePrintData ( QTextCursor * ) = 0;
00057
00058 quint64 id() const { return m_id; }
00059
00060 KJotsBook *parentBook();
00061 KJotsBook *topLevelBook();
00062
00063 bool isBook() const { return m_isBook; }
00064 bool isPage() const { return !m_isBook; }
00065
00066 protected:
00067 void setId(quint64);
00068 bool m_isBook;
00069
00070 private:
00071 quint64 m_id;
00072 static QSet<quint64> all_ids;
00073 };
00074
00075
00076
00077
00078
00079 class KJotsBook : public KJotsEntry
00080 {
00081 friend class KJotsEntry;
00082
00083 Q_OBJECT
00084 public:
00085 KJotsBook ();
00086 ~KJotsBook();
00087
00088 bool openBook(const QString&);
00089 void saveBook();
00090 void deleteBook();
00091 void rename();
00092 KJotsPage* addPage(void);
00093 void generateXml( QDomDocument&, QDomElement& );
00094 void parseXml( QDomElement&, bool );
00095 void generateHtml( KJotsEntry*, bool, QTextCursor* );
00096 QString generateText( void );
00097 void generatePrintData ( QTextCursor * );
00098
00099 bool shouldBeOpened ( void ) const { return m_shouldBeOpened; }
00100
00101 void setDirty(bool);
00102 bool dirty();
00103 QString fileName() const { return m_fileName; }
00104
00105 QList<KJotsEntry*> contents ( void );
00106 QList<KJotsEntry*> children ( void );
00107
00108 static KJotsBook *createNewBook( void );
00109
00110 private:
00111 QString getToc();
00112
00113 bool m_open, m_shouldBeOpened;
00114 QString m_fileName;
00115 bool m_dirty;
00116 };
00117
00118
00119
00120
00121 class KJotsPage : public KJotsEntry
00122 {
00123 Q_OBJECT
00124 public:
00125 KJotsPage();
00126 ~KJotsPage();
00127
00128 public:
00129 QTextDocument *body ( void ) { return &document; }
00130 void setCursor ( const QTextCursor &c ) { cursor = c; }
00131 QTextCursor& getCursor ( void ) { return cursor; }
00132 void rename();
00133
00134 void generateXml( QDomDocument&, QDomElement& );
00135 void parseXml( QDomElement&, bool );
00136 void generateHtml( KJotsEntry*, bool, QTextCursor* );
00137 QString generateText( void );
00138 void generatePrintData ( QTextCursor * );
00139
00140 static KJotsPage *createNewPage( int );
00141
00142 protected slots:
00143 void documentModified(bool);
00144
00145 private:
00146 QTextDocument document;
00147 QTextCursor cursor;
00148 };
00149
00150 #endif // __KJOTSENTRY_H
00151
00152