kmail
snippetitem.h
Go to the documentation of this file.00001 /*************************************************************************** 00002 * snippet feature from kdevelop/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 <klistview.h> 00018 #include <klocale.h> 00019 00020 #include <qobject.h> 00021 00022 class QString; 00023 class KAction; 00024 class SnippetGroup; 00025 00026 00032 class SnippetItem : public QObject, public QListViewItem { 00033 friend class SnippetGroup; 00034 00035 Q_OBJECT 00036 public: 00037 SnippetItem(QListViewItem * parent, QString name, QString text); 00038 00039 ~SnippetItem(); 00040 QString getName(); 00041 QString getText(); 00042 using QListViewItem::parent; 00043 int getParent() { return iParent; } 00044 void resetParent(); 00045 void setText(QString text); 00046 void setName(QString name); 00047 void setAction( KAction* ); 00048 KAction* getAction(); 00049 static SnippetItem * findItemByName(QString name, QPtrList<SnippetItem> &list); 00050 static SnippetGroup * findGroupById(int id, QPtrList<SnippetItem> &list); 00051 signals: 00052 void execute( QListViewItem * ); 00053 public slots: 00054 void slotExecute(); 00055 00056 private: 00057 SnippetItem(QListView * parent, QString name, QString text); 00058 QString strName; 00059 QString strText; 00060 int iParent; 00061 KAction *action; 00062 }; 00063 00070 class SnippetGroup : public SnippetItem { 00071 public: 00072 SnippetGroup(QListView * parent, QString name, int id); 00073 ~SnippetGroup(); 00074 00075 int getId() { return iId; } 00076 static int getMaxId() { return iMaxId; } 00077 00078 void setId(int id); 00079 00080 private: 00081 static int iMaxId; 00082 int iId; 00083 }; 00084 00085 #endif