kpilot Library API Documentation

DOC-converter.h

00001 #ifndef _DOC_CONVERTER_H 00002 #define _DOC_CONVERTER_H 00003 /* DOC-converter.h KPilot 00004 ** 00005 ** Copyright (C) 2002-2003 by Reinhold Kainhofer 00006 ** 00007 */ 00008 00009 /* 00010 ** This program is free software; you can redistribute it and/or modify 00011 ** it under the terms of the GNU General Public License as published by 00012 ** the Free Software Foundation; either version 2 of the License, or 00013 ** (at your option) any later version. 00014 ** 00015 ** This program is distributed in the hope that it will be useful, 00016 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 ** GNU General Public License for more details. 00019 ** 00020 ** You should have received a copy of the GNU General Public License 00021 ** along with this program in a file called COPYING; if not, write to 00022 ** the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 00023 ** MA 02111-1307, USA. 00024 */ 00025 00026 /* 00027 ** Bug reports and questions can be sent to kde-pim@kde.org 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 #include "options.h" 00042 00043 00044 class PilotDatabase; 00045 00046 00047 /**************************************************************************************************** 00048 * various bookmark classes. Most important is the bmkList findMatches(QString, bmkList &) function, 00049 * which needs to return a list of all bookmarks found for the given bookmark expression. 00050 * A bookmark usually consists of a bookmark text and an offset into the text document. 00051 ****************************************************************************************************/ 00052 00053 class docBookmark; 00054 #define bmkList QPtrList<docBookmark> 00055 #define bmkSortedList QSortedList<docBookmark> 00056 00057 class docBookmark { 00058 public: 00059 static bool compare_pos; 00060 docBookmark():bmkName(), position(0) { }; 00061 docBookmark(QString name, long int pos):bmkName(name), position(pos) { }; 00062 docBookmark(const docBookmark &bmk):bmkName(bmk.bmkName),position(bmk.position){}; 00063 virtual ~ docBookmark() { }; 00064 virtual int findMatches(QString, bmkList &fBookmarks) { 00065 FUNCTIONSETUP; 00066 fBookmarks.append(new docBookmark(*this)); 00067 return 1; 00068 }; 00069 00070 QString bmkName; 00071 long int position; 00072 }; 00073 00074 class docMatchBookmark:public docBookmark { 00075 public: 00076 docMatchBookmark():docBookmark() { from=0; to=100;}; 00077 docMatchBookmark(QString pattrn, int options=0):docBookmark(), 00078 pattern(pattrn), opts(options) { from=0; to=100; }; 00079 docMatchBookmark(QString pattrn, QString bmkname, 00080 int options=0):docBookmark(bmkname, 0), pattern(pattrn), 00081 opts(options) { from=0; to=100; }; 00082 virtual ~ docMatchBookmark() { }; 00083 00084 virtual int findMatches(QString, bmkList &fBookmarks); 00085 QString pattern; 00086 int opts; 00087 int from, to; 00088 }; 00089 00090 class docRegExpBookmark:public docMatchBookmark { 00091 public: 00092 docRegExpBookmark():docMatchBookmark() { capSubexpression=-1;}; 00093 docRegExpBookmark(QString regexp, int cap=0, 00094 int options=0):docMatchBookmark(regexp, options) {capSubexpression=cap; }; 00095 docRegExpBookmark(QString pattrn, QString bmkname, 00096 int options=0):docMatchBookmark(pattrn, bmkname, options) { capSubexpression=-1; }; 00097 virtual ~ docRegExpBookmark() { }; 00098 00099 virtual int findMatches(QString, bmkList &fBookmarks); 00100 int capSubexpression; 00101 }; 00102 00103 00104 /************************************************************************************************************* 00105 * The converter class that does the real work for us. 00106 *************************************************************************************************************/ 00107 00108 class DOCConverter:public QObject { 00109 Q_OBJECT 00110 private: 00111 PilotDatabase * docdb; 00112 QString txtfilename; 00113 QString bmkfilename; 00114 bool compress; 00115 00116 bmkList fBookmarks; 00117 public: 00118 enum eSortBookmarksEnum 00119 { 00120 eSortNone, 00121 eSortPos, 00122 eSortName 00123 } eSortBookmarks; 00124 00125 public: 00126 DOCConverter(QObject *parent=0L, const char *name=0L); 00127 virtual ~ DOCConverter(); 00128 00129 QString readText(); 00130 void setTXTpath(QString path, QString file); 00131 void setTXTpath(QString filename); 00132 void setPDB(PilotDatabase * dbi); 00133 QString txtFilename() const {return txtfilename;} 00134 QString bmkFilename() const {return bmkfilename;} 00135 void setBmkFilename(QString bmkf) { bmkfilename=bmkf;} 00136 00137 bool getCompress() const { return compress; }; 00138 void setCompress(bool newcomp) {compress=newcomp;}; 00139 00140 bool convertTXTtoPDB(); 00141 bool convertPDBtoTXT(); 00142 00143 int setBookmarks(bmkList bookmarks) { 00144 fBookmarks = bookmarks; 00145 return fBookmarks.count(); 00146 }; 00147 int clearBookmarks() { 00148 fBookmarks.clear(); 00149 return fBookmarks.count(); 00150 }; 00151 int addBookmark(docBookmark*bookmark) { 00152 fBookmarks.append(bookmark); 00153 return fBookmarks.count(); 00154 }; 00155 00156 int findBmkEndtags(QString &, bmkList&); 00157 int findBmkInline(QString &, bmkList&); 00158 int findBmkFile(QString &, bmkList&); 00159 00160 00161 void setSort(enum eSortBookmarksEnum sort) {eSortBookmarks=sort;} 00162 enum eSortBookmarksEnum getSort() {return eSortBookmarks;} 00163 00164 enum eBmkTypesEnum { 00165 eBmkNone = 0, 00166 eBmkFile = 1, 00167 eBmkInline = 2, 00168 eBmkEndtags = 4, 00169 eBmkDefaultBmkFile = 8 00170 } fBmkTypes; 00171 void setBookmarkTypes(int types) { 00172 fBmkTypes = (eBmkTypesEnum) types; 00173 }; 00174 00175 protected: 00176 int findBookmarks(); 00177 00178 private: 00179 void readConfig(); 00180 signals: 00181 void logMessage(const QString &); 00182 void logError(const QString &); 00183 }; 00184 00185 #endif
KDE Logo
This file is part of the documentation for kpilot Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 28 23:57:48 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003