kpilot
DOC-converter.hGo to the documentation of this file.00001 #ifndef _DOC_CONVERTER_H
00002 #define _DOC_CONVERTER_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #define DOC_UNCOMPRESSED 1
00033 #define DOC_COMPRESSED 2
00034
00035
00036 #define BMK_SUFFIX ".bmk"
00037 #define PDBBMK_SUFFIX ".bm"
00038
00039 #include <qptrlist.h>
00040 #include <qobject.h>
00041
00042 class PilotDatabase;
00043
00044
00045
00046
00047
00048
00049
00050
00051 class docBookmark;
00052 #define bmkList QPtrList<docBookmark>
00053 #define bmkSortedList QSortedList<docBookmark>
00054
00055 class docBookmark {
00056 public:
00057 static bool compare_pos;
00058 docBookmark():bmkName(), position(0) { };
00059 docBookmark(QString name, long int pos):bmkName(name), position(pos) { };
00060 docBookmark(const docBookmark &bmk):bmkName(bmk.bmkName),position(bmk.position){};
00061 virtual ~ docBookmark() { };
00062 virtual int findMatches(QString, bmkList &fBookmarks) {
00063 FUNCTIONSETUP;
00064 fBookmarks.append(new docBookmark(*this));
00065 return 1;
00066 };
00067
00068 QString bmkName;
00069 long int position;
00070 };
00071
00072 class docMatchBookmark:public docBookmark {
00073 public:
00074 docMatchBookmark():docBookmark() { from=0; to=100;};
00075 docMatchBookmark(QString pattrn, int options=0):docBookmark(),
00076 pattern(pattrn), opts(options) { from=0; to=100; };
00077 docMatchBookmark(QString pattrn, QString bmkname,
00078 int options=0):docBookmark(bmkname, 0), pattern(pattrn),
00079 opts(options) { from=0; to=100; };
00080 virtual ~ docMatchBookmark() { };
00081
00082 virtual int findMatches(QString, bmkList &fBookmarks);
00083 QString pattern;
00084 int opts;
00085 int from, to;
00086 };
00087
00088 class docRegExpBookmark:public docMatchBookmark {
00089 public:
00090 docRegExpBookmark():docMatchBookmark() { capSubexpression=-1;};
00091 docRegExpBookmark(QString regexp, int cap=0,
00092 int options=0):docMatchBookmark(regexp, options) {capSubexpression=cap; };
00093 docRegExpBookmark(QString pattrn, QString bmkname,
00094 int options=0):docMatchBookmark(pattrn, bmkname, options) { capSubexpression=-1; };
00095 virtual ~ docRegExpBookmark() { };
00096
00097 virtual int findMatches(QString, bmkList &fBookmarks);
00098 int capSubexpression;
00099 };
00100
00101
00102
00103
00104
00105
00106 class DOCConverter:public QObject {
00107 Q_OBJECT
00108 private:
00109 PilotDatabase * docdb;
00110 QString txtfilename;
00111 QString bmkfilename;
00112 bool compress;
00113
00114 bmkList fBookmarks;
00115 public:
00116 enum eSortBookmarksEnum
00117 {
00118 eSortNone,
00119 eSortPos,
00120 eSortName
00121 } eSortBookmarks;
00122
00123 public:
00124 DOCConverter(QObject *parent=0L, const char *name=0L);
00125 virtual ~ DOCConverter();
00126
00127 QString readText();
00128 void setTXTpath(QString path, QString file);
00129 void setTXTpath(QString filename);
00130 void setPDB(PilotDatabase * dbi);
00131 QString txtFilename() const {return txtfilename;}
00132 QString bmkFilename() const {return bmkfilename;}
00133 void setBmkFilename(QString bmkf) { bmkfilename=bmkf;}
00134
00135 bool getCompress() const { return compress; };
00136 void setCompress(bool newcomp) {compress=newcomp;};
00137
00138 bool convertTXTtoPDB();
00139 bool convertPDBtoTXT();
00140
00141 int setBookmarks(bmkList bookmarks) {
00142 fBookmarks = bookmarks;
00143 return fBookmarks.count();
00144 };
00145 int clearBookmarks() {
00146 fBookmarks.clear();
00147 return fBookmarks.count();
00148 };
00149 int addBookmark(docBookmark*bookmark) {
00150 fBookmarks.append(bookmark);
00151 return fBookmarks.count();
00152 };
00153
00154 int findBmkEndtags(QString &, bmkList&);
00155 int findBmkInline(QString &, bmkList&);
00156 int findBmkFile(QString &, bmkList&);
00157
00158
00159 void setSort(enum eSortBookmarksEnum sort) {eSortBookmarks=sort;}
00160 enum eSortBookmarksEnum getSort() {return eSortBookmarks;}
00161
00162 enum eBmkTypesEnum {
00163 eBmkNone = 0,
00164 eBmkFile = 1,
00165 eBmkInline = 2,
00166 eBmkEndtags = 4,
00167 eBmkDefaultBmkFile = 8
00168 } fBmkTypes;
00169 void setBookmarkTypes(int types) {
00170 fBmkTypes = (eBmkTypesEnum) types;
00171 };
00172
00173 protected:
00174 int findBookmarks();
00175
00176 private:
00177 void readConfig();
00178 signals:
00179 void logMessage(const QString &);
00180 void logError(const QString &);
00181 };
00182
00183 #endif
|