Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

QTReaderApp.h

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2000 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of Qt Palmtop Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 #ifndef __QTREADERAPP_H
00021 #define __QTREADERAPP_H
00022 
00023 //#define _SCROLLPIPE
00024 //#define __ISEARCH
00025 
00026 //#define MAX_ENCODING 6
00027 #define MAX_ACTIONS 5
00028 
00029 #include <sys/timeb.h>
00030 #include <qmainwindow.h>
00031 #include "CExpander.h"
00032 #include "CEncoding.h"
00033 #include <qlist.h>
00034 //#include <qpe/filemanager.h>
00035 #include <qmap.h>
00036 #include <qlineedit.h>
00037 #include <qstack.h>
00038 #include <qlistbox.h>
00039 #ifdef USEQPE
00040 #include <qpe/qpeapplication.h>
00041 #endif
00042 #include "orkey.h"
00043 //#include "Queue.h"
00044 #include "BGType.h"
00045 
00046 class QBoxLayout;
00047 class QWidgetStack;
00048 class QToolButton;
00049 class QPopupMenu;
00050 class QToolBar;
00051 #ifdef USEQPE
00052 class QPEToolBar;
00053 class QPEMenuBar;
00054 #endif
00055 class QScrollBar;
00056 class CBkmkSelector;
00057 class QProgressBar;
00058 class QAction;
00059 class CAnnoEdit;
00060 class QFloatBar;
00061 class CDrawBuffer;
00062 class QTReader;
00063 class QImage;
00064 class Config;
00065 class CButtonPrefs;
00066 
00067 #ifdef USEQPE
00068 enum ToolbarPolicy
00069 {
00070     cesSingle = 0,
00071     cesMenuTool,
00072     cesMultiple
00073 };
00074 #else
00075 enum ToolbarPolicy
00076 {
00077     cesMenuTool = 0,
00078     cesMultiple
00079 };
00080 #endif
00081 
00082 enum regedit_type
00083 {
00084     cAutoGen,
00085     cAddBkmk,
00086     cJump,
00087     cMonoSpace,
00088     cSetTarget,
00089 #ifdef _SCROLLPIPE
00090     cSetPipeTarget,
00091 #endif
00092     cSetConfigName,
00093     cMargin,
00094     cExtraSpace,
00095     cExtraLead,
00096     cRepara
00097 };
00098 
00099 enum bkmk_action
00100 {
00101     cOpenFile,
00102     cGotoBkmk,
00103     cDelBkmk,
00104     cRmBkmkFile,
00105     cLdConfig,
00106     cRmConfig,
00107     cExportLinks,
00108     cLdTheme
00109 };
00110 
00111 enum fontselector_action
00112 {
00113     cChooseFont,
00114     cChooseEncoding
00115 };
00116 
00117 #ifdef __ISEARCH
00118 struct searchrecord
00119 {
00120   QString s;
00121   size_t pos;
00122   searchrecord(const QString& _s, size_t _pos) : s(_s), pos(_pos) {}
00123 };
00124 #endif
00125 
00126 class infowin;
00127 class GraphicWin;
00128 
00129 class QTReaderApp : public QMainWindow
00130 {
00131     Q_OBJECT
00132 
00133       QColor getcolour(int c);
00134 
00135       QMap<orKey, int> kmap;
00136     unsigned long m_savedpos;
00137     int m_debounce;
00138     bool m_kmapchanged;
00139     bground m_bgtype;
00140     timeb m_lastkeytime;
00141     QScrollBar* m_scrollbar;
00142     QScrollBar* scrollbar;
00143     int m_qtscroll, m_localscroll;
00144     bool m_hidebars, m_scrollishidden, m_statusishidden;
00145     QBoxLayout *m_layout;
00146     QLabel* m_prog;
00147     bool m_annoIsEditing;
00148     bool m_propogatefontchange, m_bFloatingDialog;
00149     bool m_url_clipboard, m_url_localfile, m_url_globalfile;
00150     CButtonPrefs* m_buttonprefs;
00151     fontselector_action m_fontAction;
00152     void doAction(QKeyEvent* e);
00153 
00154         public:
00155     QTReaderApp( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
00156     ~QTReaderApp();
00157 
00158     void hideEvent(QHideEvent*)
00159         {
00160 #ifdef USEQPE
00161         if (m_grabkeyboard)
00162           {
00163             ((QPEApplication*)qApp)->ungrabKeyboard();
00164           }
00165 #endif
00166             suspend();
00167         }
00168 #ifdef USEQPE
00169     void showEvent(QShowEvent*)
00170       {
00171         if (m_grabkeyboard)
00172           {
00173             ((QPEApplication*)qApp)->grabKeyboard();
00174           }
00175       }
00176 #endif
00177     void suspend();
00178     void openFile( const QString &, unsigned int loc = 0 );
00179 
00180 
00181  protected:
00182     void setfontHelper(const QString& lcn, int size = 0);
00183     QAction* m_bkmkAvail, *m_actFullscreen;
00184     CAnnoEdit* m_annoWin;
00185     Bkmk* m_anno;
00186     int m_scrollcolor, m_scrollbarcolor, m_background, m_foreground;
00187 //    void resizeEvent(QResizeEvent* e);
00188     void closeEvent( QCloseEvent *e );
00189 #if defined(USEQPE) && defined(USENEWFULLSCREEN)
00190     bool m_usenewfullscreen;
00191     void resizeEvent(QResizeEvent *);
00192     void focusInEvent(QFocusEvent*);
00193 #endif
00194         void readbkmks();
00195         void do_mono(const QString&);
00196         void do_jump(const QString&);
00197         void do_reparastring(const QString&);
00198         void do_settarget(const QString&);
00199 #ifdef _SCROLLPIPE
00200 //      void do_setpipetarget(const QString&);
00201 #endif
00202         void do_saveconfig(const QString&, bool);
00203         bool readconfig(const QString&, const QString&, bool);
00204         bool PopulateConfig(const char*, bool usedirs = false);
00205         ActionTypes ActNameToInt(const QString&);
00206 #ifdef USEQPE
00207         bool m_grabkeyboard;
00208 #endif
00209     bool m_doAnnotation;
00210     bool m_doDictionary;
00211     bool m_doOutput;
00212     bool m_doClipboard;
00213     bool m_fullscreen;
00214     bool m_loadedconfig;
00215  public:
00216         void saveprefs();
00217 public slots:
00218       void setBackgroundBitmap();
00219   void UpdateStatus();
00220     void setScrollState(bool _b);
00221     void handlekey(QKeyEvent* e);
00222       void forceopen(const QString& filename);
00223     void setDocument(const QString&);
00224 private slots:
00225 #ifdef _SCRIPT
00226 //    void RunScript();
00227 #endif
00228   void actionscroll(int v);
00229     void SaveConfig();
00230  void LoadTheme();
00231  void LoadConfig();
00232  void TidyConfig();
00233  void ExportLinks();
00234     void zoomin();
00235     void zoomout();
00236     void chooseencoding();
00237     void setfullscreen(bool sfs);
00238     void setrotated(bool sfs);
00239     void setinverted(bool sfs);
00240     void setgrab(bool sfs);
00241 //    void setcontinuous(bool sfs);
00242     void setTwoTouch(bool _b);
00243  void restoreFocus();
00244  void OnAnnotation(bool _b)
00245         {
00246             m_doAnnotation = _b;
00247         }
00248     void OnDictionary(bool _b)
00249         {
00250             m_doDictionary = _b;
00251         }
00252     void OnClipboard(bool _b)
00253         {
00254             m_doClipboard = _b;
00255         }
00256     void OnWordSelected(const QString&, size_t, size_t, const QString&);
00257     void OnURLSelected(const QString& href, const size_t tgt);
00258     void showgraphic(QImage&);
00259     void addAnno(const QString&, const QString&, size_t, size_t);
00260     void addAnno(const QString&, const QString&);
00261     void addanno();
00262     void showAnnotation();
00263     void do_setencoding(int i);
00264         void do_setfont(const QString&);
00265         //      void buttonActionSelected(QAction*);
00266         void msgHandler(const QCString&, const QByteArray&);
00267         void monospace(bool);
00268         void jump();
00269         void reparastring();
00270         void settarget();
00271 #ifdef _SCROLLPIPE
00272 //      void setpipetarget();
00273 //      void setpause(bool);
00274 #endif
00275 //      void setspacing();
00276         void setfont();
00277         void clearBkmkList();
00278         void listBkmkFiles();
00279         void editMark();
00280         void autoScroll(bool);
00281         void addbkmk();
00282         void savebkmks();
00283 //      void importFiles();
00284         void showprefs();
00285         void showtoolbarprefs();
00286         void showbuttonprefs();
00287         void infoClose();
00288         //    void oldFile();
00289         void showinfo();
00290 
00291 //    void indentplus();
00292 //    void indentminus();
00293 
00294     void fileOpen();
00295     void fileClose();
00296 
00297     void editCopy();
00298     void editFind();
00299 
00300     void gotoStart();
00301     void gotoEnd();
00302 
00303     void pageup();
00304     void pagedn();
00305 
00306     void findNext();
00307     void findClose();
00308 
00309     void regClose();
00310 
00311 #ifdef __ISEARCH
00312 //  void search( const QString& );
00313 #else
00314     void search();
00315 #endif
00316 
00317     void showEditTools();
00318 
00319 //    void stripcr(bool);
00320 //    void setfulljust(bool);
00321 //    void onespace(bool);
00322 //    void repalm(bool);
00323 //    void peanut(bool _b);
00324 //    void remap(bool);
00325 //    void embolden(bool);
00326 //    void autofmt(bool);
00327 //    void textfmt(bool);
00328 //    void striphtml(bool);
00329 //    void dehyphen(bool);
00330 //    void depluck(bool);
00331 //    void dejpluck(bool);
00332 //    void unindent(bool);
00333 //    void repara(bool);
00334 //    void dblspce(bool);
00335     void pagemode(bool);
00336     //  void gotobkmk(const QString& bm);
00337     void gotobkmk(int);
00338     void cancelbkmk();
00339     void do_gotomark();
00340     void do_delmark();
00341     void do_autogen();
00342     void do_regaction();
00343     void OnRedraw();
00344 
00345  private:
00346     void setscrollcolour();
00347     void setscrollbarcolour();
00348     void writeUrl(const QString& file, const QString& href);
00349     QAction *m_preferences_action, *m_open_action, *m_close_action;
00350     QAction *m_info_action, *m_touch_action, *m_find_action, *m_start_action;
00351     QAction *m_end_action, *m_jump_action, *m_pageline_action;
00352     QAction *m_pageup_action, *m_pagedn_action, *m_back_action;
00353     QAction *m_home_action, *m_forward_action, *m_zoomin_action;
00354     QAction *m_zoomout_action, *m_setfont_action, *m_mark_action;
00355     QAction *m_annotate_action, *m_goto_action, *m_delete_action;
00356     QAction *m_autogen_action, *m_clear_action, *m_save_action;
00357     QAction *m_tidy_action, *m_startBlock_action, *m_endBlock_action;
00358     QAction *m_setenc_action, *m_setmono_action, *m_saveconfig_action;
00359     QAction *m_loadconfig_action, *m_loadtheme_action, *m_toolbarprefs_action, *m_tidyconfig_action;
00360     QAction *m_exportlinks_action, *m_rotate_action, *m_buttonprefs_action, *m_inverse_action;
00361     QAction *m_repara_action;
00362 #ifdef USEQPE
00363     QAction *m_grab_action;
00364 #endif
00365     void addtoolbars(Config* config);
00366     ToolbarPolicy m_tbpol, m_tbpolsave;
00367     ToolBarDock m_tbposition;
00368     bool m_tbmove, m_tbmovesave;
00369     QToolBar* filebar();
00370     QToolBar* viewbar();
00371     QToolBar* navbar();
00372     QToolBar* markbar();
00373     void hidetoolbars();
00374     void addfilebar(Config* _config, const QString& key, QAction* a);
00375     void addviewbar(Config* _config, const QString& key, QAction* a);
00376     void addnavbar(Config* _config, const QString& key, QAction* a);
00377     void addmarkbar(Config* _config, const QString& key, QAction* a);
00378     bool checkbar(Config* _config, const QString& key);
00379 #ifdef _SCRIPT
00380     void SaveScript(const char* sname);
00381 #endif
00382 /*
00383     void setstate(unsigned char* _sd, unsigned short _sdlen);
00384     void getstate(unsigned char*& data, unsigned short& len);
00385 */
00386     void fileOpen2();
00387     void readfilelist();
00388     void savefilelist();
00389     void updatefileinfo();
00390     bool openfrombkmk(Bkmk*);
00391   QString m_targetapp, m_targetmsg, m_statusstring, m_themename;
00392     bool listbkmk(CList<Bkmk>*, const QString& _lab = QString::null, bool presel=false);
00393     QString usefilebrowser();
00394     void do_regedit();
00395     void colorChanged( const QColor &c );
00396     void clear();
00397     void updateCaption();
00398     void do_autogen(const QString&);
00399     void do_addbkmk(const QString&);
00400     bool findNextBookmark(size_t start);
00401 
00402  private:
00403 
00404     QAction* m_scrollButton;
00405 
00406     QAction* m_buttonAction[MAX_ACTIONS];
00407 
00408     CBkmkSelector* bkmkselector;
00409 
00410     //    ActionTypes m_spaceTarget, m_escapeTarget, m_returnTarget, m_leftTarget, m_rightTarget,
00411     //m_upTarget, m_downTarget;
00412     //bool m_leftScroll, m_rightScroll, m_upScroll, m_downScroll;
00413     bool m_bcloseDisabled, m_disableesckey;
00414     size_t searchStart;
00415 #ifdef __ISEARCH
00416     QStack<searchrecord>* searchStack;
00417     bool dosearch(size_t start, CDrawBuffer& test, const QString& arg);
00418 #else
00419     bool dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg);
00420 #endif
00421     QWidgetStack *editorStack;
00422     QTReader* reader;
00423     QComboBox* m_fontSelector;
00424 //    QPEToolBar /* *menu,*/ *fileBar;
00425 #if defined(USEQPE)
00426     QToolBar *menubar;
00427 #endif
00428     QToolBar *fileBar, *navBar, *viewBar, *markBar;
00429 #if defined(USEQPE)
00430     QPEMenuBar *mb;
00431 #else
00432     QMenuBar *mb;
00433 #endif
00434     QFloatBar *searchBar, *regBar/*, *m_fontBar*/;
00435     QToolBar /* *searchBar, *regBar,*/ *m_fontBar;
00436     QLineEdit *searchEdit, *regEdit;
00437     bool searchVisible;
00438     bool regVisible;
00439     bool m_fontVisible, m_twoTouch;
00440     static unsigned long m_uid;
00441     long unsigned get_unique_id() { return m_uid++; }
00442     /*
00443       void resizeEvent( QResizeEvent * r)
00444       {
00445 //      qDebug("resize:(%u,%u)", r->oldSize().width(), r->oldSize().height());
00446 //      qDebug("resize:(%u,%u)", r->size().width(), r->size().height());
00447       //    bgroup->move( width()-bgroup->width(), 0 );
00448       }
00449     */
00450     CList<Bkmk>* pBkmklist;
00451     CList<Bkmk>* pOpenlist;
00452     infowin*  m_infoWin;
00453     GraphicWin* m_graphicwin;
00454     QProgressBar* pbar;
00455     bool m_fBkmksChanged;
00456 //    int m_nRegAction;
00457     regedit_type m_nRegAction;
00458     bkmk_action m_nBkmkAction;
00459     QString m_autogenstr;
00460     bool m_dontSave;
00461 };
00462 
00463 //const int cAutoGen = 0;
00464 //const int cAddBkmk = 1;
00465 //const int cDelBkmk = 2;
00466 //const int cGotoBkmk = 3;
00467 //const int cRmBkmkFile = 4;
00468 //const int cJump = 5;
00469 //const int cMonoSpace = 6;
00470 //const int cOverlap = 7;
00471 //const int cSetTarget = 8;
00472 //const int cOpenFile = 9;
00473 //const int cSetPipeTarget = 10;
00474 //const int cSetConfigName = 11;
00475 //const int cMargin = 12;
00476 //const int cExtraSpace = 14;
00477 //const int cExtraLead = 15;
00478 //const int cGfxSize = 16;
00479 //const int cChooseFont = 2;
00480 //const int cChooseEncoding = 1;
00481 
00482 #endif
00483 
00484 
00485 

Generated on Sat Nov 5 16:16:58 2005 for OPIE by  doxygen 1.4.2