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 | 114a878c64ce6f8223cfd22d76a20eb16d177e5e (patch) | |
tree | acaf47eb0fa12142d3896416a69e74cbf5a72242 /parts/snippet/snippetitem.cpp | |
download | tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.tar.gz tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.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/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'parts/snippet/snippetitem.cpp')
-rw-r--r-- | parts/snippet/snippetitem.cpp | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/parts/snippet/snippetitem.cpp b/parts/snippet/snippetitem.cpp new file mode 100644 index 00000000..7548ad16 --- /dev/null +++ b/parts/snippet/snippetitem.cpp @@ -0,0 +1,127 @@ +/* + * File : snippetitem.cpp + * + * Author: Robert Gruber <rgruber@users.sourceforge.net> + * + * Copyright: See COPYING file that comes with this distribution + */ + +#include <qstring.h> + + +#include "snippetitem.h" + +SnippetItem::SnippetItem(QListView * parent, QString name, QString text ) + : QListViewItem( parent, name ) +{ + strName = name; + strText = text; + iParent = -1; +} + +SnippetItem::SnippetItem(QListViewItem * parent, QString name, QString text) + : QListViewItem( parent, name ) +{ + strName = name; + strText = text; + iParent = ((SnippetGroup *)parent)->getId(); +} + +SnippetItem::~SnippetItem() +{ +} + + +/*! + \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(); +} + +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, QString lang) + : SnippetItem(parent, name, "GROUP") +{ + if (id > 0) { + iId = id; + if (id >= iMaxId) + iMaxId = id+1; + } else { + iId = iMaxId; + iMaxId++; + } + + strLanguage = lang; +} + +SnippetGroup::~SnippetGroup() +{ +} + +void SnippetGroup::setId(int id) +{ + iId = id; + if (iId >= iMaxId) + iMaxId = iId+1; +} |