diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch) | |
tree | 67208f7c145782a7e90b123b982ca78d88cc2c87 /kmail/snippetitem.cpp | |
download | tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kmail/snippetitem.cpp')
-rw-r--r-- | kmail/snippetitem.cpp | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/kmail/snippetitem.cpp b/kmail/snippetitem.cpp new file mode 100644 index 000000000..46d28c941 --- /dev/null +++ b/kmail/snippetitem.cpp @@ -0,0 +1,154 @@ +/*************************************************************************** + * snippet feature from kdevelop/plugins/snippet/ * + * * + * Copyright (C) 2007 by Robert Gruber * + * rgruber@users.sourceforge.net * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "snippetitem.h" + +#include <kaction.h> + +#include <qstring.h> + +SnippetItem::SnippetItem(QListView * parent, QString name, QString text ) + : QListViewItem( parent, name ), action(0) +{ + strName = name; + strText = text; + iParent = -1; +} + +SnippetItem::SnippetItem(QListViewItem * parent, QString name, QString text) + : QListViewItem( parent, name ), action(0) +{ + strName = name; + strText = text; + iParent = ((SnippetGroup *)parent)->getId(); +} + +SnippetItem::~SnippetItem() +{ + if ( action ) { + action->unplugAll(); + delete action; + } +} + + +/*! + \fn SnippetItem::getName() + */ +QString SnippetItem::getName() +{ + return strName; +} + + +/*! + \fn SnippetItem::getText + */ +QString SnippetItem::getText() +{ + return strText; +} + + +/*! + \fn SnippetItem::setText(QString text) + */ +void SnippetItem::setText(QString text) +{ + strText = text; +} + + +/*! + \fn SnippetItem::setName(QString name) + */ +void SnippetItem::setName(QString name) +{ + strName = name; +} + +void SnippetItem::resetParent() +{ + SnippetGroup * group = dynamic_cast<SnippetGroup*>(parent()); + if (group) + iParent = group->getId(); +} + + +KAction* SnippetItem::getAction() +{ + return action; +} + +void SnippetItem::setAction(KAction * anAction) +{ + action = anAction; +} + +void SnippetItem::slotExecute() +{ + emit execute( this ); +} + + +SnippetItem * SnippetItem::findItemByName(QString name, QPtrList<SnippetItem> &list) +{ + for ( SnippetItem * item = list.first(); item; item = list.next() ) { //write the snippet-list + if (item->getName() == name) + return item; + } + return NULL; +} + +SnippetGroup * SnippetItem::findGroupById(int id, QPtrList<SnippetItem> &list) +{ + for ( SnippetItem * item = list.first(); item; item = list.next() ) { //write the snippet-list + SnippetGroup * group = dynamic_cast<SnippetGroup*>(item); + if (group && group->getId() == id) + return group; + } + return NULL; +} + + +/* * * * * * * * * * * * * * * * * * * * +Deklaration for class SnippetGroup +* * * * * * * * * * * * * * * * * * * */ + +int SnippetGroup::iMaxId = 1; + +SnippetGroup::SnippetGroup(QListView * parent, QString name, int id) + : SnippetItem(parent, name, "GROUP") +{ + if (id > 0) { + iId = id; + if (id >= iMaxId) + iMaxId = id+1; + } else { + iId = iMaxId; + iMaxId++; + } +} + +SnippetGroup::~SnippetGroup() +{ +} + +void SnippetGroup::setId(int id) +{ + iId = id; + if (iId >= iMaxId) + iMaxId = iId+1; +} + +#include "snippetitem.moc" |