kmail

snippetwidget.h
1 /***************************************************************************
2  * snippet feature from tdevelop/plugins/snippet/ *
3  * *
4  * Copyright (C) 2007 by Robert Gruber *
5  * rgruber@users.sourceforge.net *
6  * *
7  * This program is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  ***************************************************************************/
13 #ifndef __SNIPPET_WIDGET_H__
14 #define __SNIPPET_WIDGET_H__
15 
16 #include <tqwidget.h>
17 #include <tqstring.h>
18 #include <tdelistview.h>
19 #include <tqtooltip.h>
20 #include <tqrect.h>
21 
22 #include <tdetexteditor/editinterface.h>
23 #include <tdetexteditor/view.h>
24 #include "snippetconfig.h"
25 
26 class KDevProject;
27 class SnippetPart;
28 class TQPushButton;
29 class TDEListView;
30 class TQListViewItem;
31 class TQPoint;
32 class SnippetDlg;
33 class SnippetItem;
34 class KTextEdit;
35 class TDEConfig;
36 class KMEdit;
37 class TDEActionCollection;
38 
45 class SnippetWidget : public TDEListView, public TQToolTip
46 {
47  TQ_OBJECT
48 
49 
50 public:
51  SnippetWidget(KMEdit* editor, TDEActionCollection* actionCollection, TQWidget* parent = 0);
52  ~SnippetWidget();
53  TQPtrList<SnippetItem> * getList() { return (&_list); }
54  void writeConfig();
55  SnippetConfig * getSnippetConfig() { return (&_SnippetConfig); }
56 
57 
58 private slots:
59  void initConfig();
60 
61 protected:
62  void maybeTip( const TQPoint & );
63  bool acceptDrag (TQDropEvent *event) const;
64 
65 private:
66  void insertIntoActiveView( const TQString &text );
67  TQString parseText(TQString text, TQString del="$");
68  bool showMultiVarDialog(TQMap<TQString, TQString> * map, TQMap<TQString, TQString> * mapSave,
69  int & iWidth, int & iBasicHeight, int & iOneHeight);
70  TQString showSingleVarDialog(TQString var, TQMap<TQString, TQString> * mapSave, TQRect & dlgSize);
71  SnippetItem* makeItem( SnippetItem* parent, const TQString& name, const TQString& text, const TDEShortcut& shortcut );
72 
73  TQPtrList<SnippetItem> _list;
74  TQMap<TQString, TQString> _mapSaved;
75  TDEConfig * _cfg;
76  SnippetConfig _SnippetConfig;
77  KMEdit* mEditor;
78  TDEActionCollection* mActionCollection;
79 
80 public slots:
81  void slotRemove();
82  void slotEdit( TQListViewItem* item_ = 0 );
83  void slotEditGroup();
84  void slotAdd();
85  void slotAddGroup();
86  void slotExecute();
87 
88 protected slots:
89  void showPopupMenu( TQListViewItem * item, const TQPoint & p, int );
90  void slotExecuted(TQListViewItem * item = 0);
91  void slotDropped(TQDropEvent *e, TQListViewItem *after);
92  void startDrag();
93 };
94 
95 
96 #endif
This class stores the values that can be configured via the KDevelop settings dialog.
Definition: snippetconfig.h:26
This class represents one CodeSnippet-Item in the listview.
Definition: snippetitem.h:32
This is the widget which gets added to the right TreeToolView.
Definition: snippetwidget.h:46
void slotDropped(TQDropEvent *e, TQListViewItem *after)
void showPopupMenu(TQListViewItem *item, const TQPoint &p, int)
void maybeTip(const TQPoint &)
bool acceptDrag(TQDropEvent *event) const
void slotEdit(TQListViewItem *item_=0)