kmail

snippetitem.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 
00014 #ifndef SNIPPETITEM_H
00015 #define SNIPPETITEM_H
00016 
00017 #include <tdelistview.h>
00018 #include <tdelocale.h>
00019 
00020 #include <tqobject.h>
00021 
00022 class TQString;
00023 class TDEAction;
00024 class SnippetGroup;
00025 
00026 
00032 class SnippetItem : public TQObject, public TQListViewItem {
00033 friend class SnippetGroup;
00034 
00035     Q_OBJECT
00036   
00037 public:
00038     SnippetItem(TQListViewItem * parent, TQString name, TQString text);
00039 
00040     ~SnippetItem();
00041     TQString getName();
00042     TQString getText();
00043     using TQListViewItem::parent;
00044     int getParent() { return iParent; }
00045     void resetParent();
00046     void setText(TQString text);
00047     void setName(TQString name);
00048     void setAction( TDEAction* );
00049     TDEAction* getAction();
00050     static SnippetItem * findItemByName(TQString name, TQPtrList<SnippetItem> &list);
00051     static SnippetGroup * findGroupById(int id, TQPtrList<SnippetItem> &list);
00052 signals:
00053     void execute( TQListViewItem * );
00054 public slots:
00055     void slotExecute();
00056     
00057 private:
00058   SnippetItem(TQListView * parent, TQString name, TQString text);
00059   TQString strName;
00060   TQString strText;
00061   int iParent;
00062   TDEAction *action;
00063 };
00064 
00071 class SnippetGroup : public SnippetItem {
00072 public:
00073     SnippetGroup(TQListView * parent, TQString name, int id);
00074     ~SnippetGroup();
00075 
00076     int getId() { return iId; }
00077     static int getMaxId() { return iMaxId; }
00078     
00079     void setId(int id);
00080 
00081 private:
00082     static int iMaxId;
00083     int iId;
00084 };
00085 
00086 #endif