autobookmarker.h
00001 /* 00002 This library is free software you can redistribute it and/or 00003 modify it under the terms of the GNU Library General Public 00004 License. 00005 00006 This library is distributed in the hope that it will be useful, 00007 but WITHOUT ANY WARRANTY; without even the implied warranty of 00008 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00009 Library General Public License for more details. 00010 00011 You should have received a copy of the GNU Library General Public License 00012 along with this library; see the file COPYING.LIB. If not, write to 00013 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00014 Boston, MA 02110-1301, USA. 00015 00016 --- 00017 file: autobookmarker.h 00018 00019 KTextEditor plugin to add bookmarks to documents. 00020 Copyright Anders Lund <anders.lund@lund.tdcadsl.dk>, 2003 00021 */ 00022 00023 #ifndef _AUTOBOOKMARKER_H_ 00024 #define _AUTOBOOKMARKER_H_ 00025 00026 #include <ktexteditor/plugin.h> 00027 #include <ktexteditor/configinterfaceextension.h> 00028 00029 #include <kdialogbase.h> 00030 00031 #include <tqptrlist.h> 00032 #include <tqvbox.h> 00033 00034 class AutoBookmarkEnt 00035 { 00036 public: 00037 enum REFlags { CaseSensitive=1, MinimalMatching=2 }; 00038 AutoBookmarkEnt(const TQString &p=TQString::null, 00039 const TQStringList &f=TQStringList(), 00040 const TQStringList &m=TQStringList(), 00041 int flags=1 ); 00042 ~AutoBookmarkEnt(){}; 00043 TQString pattern; 00044 TQStringList filemask; 00045 TQStringList mimemask; 00046 int flags; 00047 }; 00048 00049 class AutoBookmarker 00050 : public KTextEditor::Plugin, public KTextEditor::PluginViewInterface, 00051 public KTextEditor::ConfigInterfaceExtension 00052 { 00053 Q_OBJECT 00054 public: 00055 AutoBookmarker( TQObject *parent = 0, 00056 const char* name = 0, 00057 const TQStringList &args = TQStringList() ); 00058 virtual ~AutoBookmarker() {}; 00059 00060 void addView (KTextEditor::View *view); 00061 void removeView (KTextEditor::View *view); 00062 00063 // ConfigInterfaceExtention 00064 uint configPages() const { return 1; }; 00065 KTextEditor::ConfigPage * configPage( uint number, TQWidget *parent, const char *name ); 00066 TQString configPageName( uint ) const; 00067 TQString configPageFullName( uint ) const; 00068 TQPixmap configPagePixmap( uint, int ) const; 00069 bool abDone; 00070 00071 private slots: 00072 void slotCompleted(); 00073 void applyEntity( AutoBookmarkEnt *e ); 00074 }; 00075 00076 typedef TQPtrList<AutoBookmarkEnt> ABEntityList; 00077 typedef TQPtrListIterator<AutoBookmarkEnt> ABEntityListIterator; 00078 00079 /* singleton to keep the data */ 00080 class ABGlobal 00081 { 00082 public: 00083 ABGlobal(); 00084 ~ABGlobal(); 00085 00086 static ABGlobal* self(); 00087 00088 ABEntityList* entities() { return m_ents; }; 00089 void readConfig(); 00090 void writeConfig(); 00091 00092 private: 00093 ABEntityList *m_ents; 00094 static ABGlobal *s_self; 00095 }; 00096 00097 class AutoBookmarkerConfigPage : public KTextEditor::ConfigPage 00098 { 00099 Q_OBJECT 00100 public: 00101 AutoBookmarkerConfigPage( TQWidget *parent, const char *name ); 00102 virtual ~AutoBookmarkerConfigPage() {}; 00103 00104 virtual void apply(); 00105 virtual void reset(); 00106 virtual void defaults(); 00107 00108 private slots: 00109 void slotNew(); 00110 void slotDel(); 00111 void slotEdit(); 00112 00113 private: 00114 class KListView *lvPatterns; 00115 class TQPushButton *btnNew, *btnDel, *btnEdit; 00116 ABEntityList *m_ents; 00117 }; 00118 00119 class AutoBookmarkerEntEditor : public KDialogBase 00120 { 00121 Q_OBJECT 00122 public: 00123 AutoBookmarkerEntEditor( TQWidget *parent, AutoBookmarkEnt *e ); 00124 ~AutoBookmarkerEntEditor(){}; 00125 00126 void apply(); 00127 00128 private slots: 00129 void showMTDlg(); 00130 void slotPatternChanged( const TQString& ); 00131 private: 00132 class TQLineEdit *lePattern, *leMimeTypes, *leFileMask; 00133 class TQCheckBox *cbCS, *cbMM; 00134 AutoBookmarkEnt *e; 00135 }; 00136 00137 #endif //_AUTOBOOKMARKER_H_