|
|
|
/*
|
|
|
|
* File : snippetitem.cpp
|
|
|
|
*
|
|
|
|
* Author: Robert Gruber <rgruber@users.sourceforge.net>
|
|
|
|
*
|
|
|
|
* Copyright: See COPYING file that comes with this distribution
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <tqstring.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "snippetitem.h"
|
|
|
|
|
|
|
|
SnippetItem::SnippetItem(TQListView * parent, TQString name, TQString text )
|
|
|
|
: TQListViewItem( parent, name )
|
|
|
|
{
|
|
|
|
strName = name;
|
|
|
|
strText = text;
|
|
|
|
iParent = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
SnippetItem::SnippetItem(TQListViewItem * parent, TQString name, TQString text)
|
|
|
|
: TQListViewItem( parent, name )
|
|
|
|
{
|
|
|
|
strName = name;
|
|
|
|
strText = text;
|
|
|
|
iParent = ((SnippetGroup *)parent)->getId();
|
|
|
|
}
|
|
|
|
|
|
|
|
SnippetItem::~SnippetItem()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn SnippetItem::getName()
|
|
|
|
*/
|
|
|
|
TQString SnippetItem::getName()
|
|
|
|
{
|
|
|
|
return strName;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn SnippetItem::getText
|
|
|
|
*/
|
|
|
|
TQString SnippetItem::getText()
|
|
|
|
{
|
|
|
|
return strText;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn SnippetItem::setText(TQString text)
|
|
|
|
*/
|
|
|
|
void SnippetItem::setText(TQString text)
|
|
|
|
{
|
|
|
|
strText = text;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn SnippetItem::setName(TQString name)
|
|
|
|
*/
|
|
|
|
void SnippetItem::setName(TQString name)
|
|
|
|
{
|
|
|
|
strName = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SnippetItem::resetParent()
|
|
|
|
{
|
|
|
|
SnippetGroup * group = dynamic_cast<SnippetGroup*>(parent());
|
|
|
|
if (group)
|
|
|
|
iParent = group->getId();
|
|
|
|
}
|
|
|
|
|
|
|
|
SnippetItem * SnippetItem::findItemByName(TQString name, TQPtrList<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, TQPtrList<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(TQListView * parent, TQString name, int id, TQString 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;
|
|
|
|
}
|