snippetwidget.h
00001 /*************************************************************************** 00002 * snippet feature from tdevelop/plugins/snippet/ * 00003 * * 00004 * Copyright (C) 2007 by Robert Gruber * 00005 * rgruber@users.sourceforge.net * 00006 * * 00007 * This program is free software; you can redistribute it and/or modify * 00008 * it under the terms of the GNU General Public License as published by * 00009 * the Free Software Foundation; either version 2 of the License, or * 00010 * (at your option) any later version. * 00011 * * 00012 ***************************************************************************/ 00013 #ifndef __SNIPPET_WIDGET_H__ 00014 #define __SNIPPET_WIDGET_H__ 00015 00016 #include <tqwidget.h> 00017 #include <tqstring.h> 00018 #include <tdelistview.h> 00019 #include <tqtooltip.h> 00020 #include <tqrect.h> 00021 00022 #include <tdetexteditor/editinterface.h> 00023 #include <tdetexteditor/view.h> 00024 #include "snippetconfig.h" 00025 00026 class KDevProject; 00027 class SnippetPart; 00028 class TQPushButton; 00029 class TDEListView; 00030 class TQListViewItem; 00031 class TQPoint; 00032 class SnippetDlg; 00033 class SnippetItem; 00034 class KTextEdit; 00035 class TDEConfig; 00036 class KMEdit; 00037 class TDEActionCollection; 00038 00045 class SnippetWidget : public TDEListView, public TQToolTip 00046 { 00047 Q_OBJECT 00048 00049 00050 public: 00051 SnippetWidget(KMEdit* editor, TDEActionCollection* actionCollection, TQWidget* parent = 0); 00052 ~SnippetWidget(); 00053 TQPtrList<SnippetItem> * getList() { return (&_list); } 00054 void writeConfig(); 00055 SnippetConfig * getSnippetConfig() { return (&_SnippetConfig); } 00056 00057 00058 private slots: 00059 void initConfig(); 00060 00061 protected: 00062 void maybeTip( const TQPoint & ); 00063 bool acceptDrag (TQDropEvent *event) const; 00064 00065 private: 00066 void insertIntoActiveView( const TQString &text ); 00067 TQString parseText(TQString text, TQString del="$"); 00068 bool showMultiVarDialog(TQMap<TQString, TQString> * map, TQMap<TQString, TQString> * mapSave, 00069 int & iWidth, int & iBasicHeight, int & iOneHeight); 00070 TQString showSingleVarDialog(TQString var, TQMap<TQString, TQString> * mapSave, TQRect & dlgSize); 00071 SnippetItem* makeItem( SnippetItem* parent, const TQString& name, const TQString& text, const TDEShortcut& shortcut ); 00072 00073 TQPtrList<SnippetItem> _list; 00074 TQMap<TQString, TQString> _mapSaved; 00075 TDEConfig * _cfg; 00076 SnippetConfig _SnippetConfig; 00077 KMEdit* mEditor; 00078 TDEActionCollection* mActionCollection; 00079 00080 public slots: 00081 void slotRemove(); 00082 void slotEdit( TQListViewItem* item_ = 0 ); 00083 void slotEditGroup(); 00084 void slotAdd(); 00085 void slotAddGroup(); 00086 void slotExecute(); 00087 00088 protected slots: 00089 void showPopupMenu( TQListViewItem * item, const TQPoint & p, int ); 00090 void slotExecuted(TQListViewItem * item = 0); 00091 void slotDropped(TQDropEvent *e, TQListViewItem *after); 00092 void startDrag(); 00093 }; 00094 00095 00096 #endif