summaryrefslogtreecommitdiffstats
path: root/parts/snippet/snippetitem.h
blob: d96ecd5be49a7101d6227b885a8dba4137388af3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 *  File : snippetitem.h
 *
 *  Author: Robert Gruber <rgruber@users.sourceforge.net>
 *
 *  Copyright: See COPYING file that comes with this distribution
 */

#ifndef SNIPPETITEM_H
#define SNIPPETITEM_H

#include <klistview.h>
#include <klocale.h>

class TQString;

class SnippetGroup;

/**
This class represents one CodeSnippet-Item in the listview.
It also holds the needed data for one snippet.
@author Robert Gruber
*/
class SnippetItem : public TQListViewItem {
friend class SnippetGroup;
public:
    SnippetItem(TQListViewItem * tqparent, TQString name, TQString text);

    ~SnippetItem();
    TQString getName();
    TQString getText();
    int getParent() { return iParent; }
    void resetParent();
    void setText(TQString text);
    void setName(TQString name);
    static SnippetItem * findItemByName(TQString name, TQPtrList<SnippetItem> &list);
    static SnippetGroup * findGroupById(int id, TQPtrList<SnippetItem> &list);
    
private:
  SnippetItem(TQListView * tqparent, TQString name, TQString text);
  TQString strName;
  TQString strText;
  int iParent;
};

/**
This class represents one group in the listview.
It is derived from SnippetItem in order to allow storing 
it in the main TQPtrList<SnippetItem>.
@author Robert Gruber
*/
class SnippetGroup : public SnippetItem {
public:
    SnippetGroup(TQListView * tqparent, TQString name, int id, TQString lang=i18n("All"));
    ~SnippetGroup();

    int getId() { return iId; }
    static int getMaxId() { return iMaxId; }
    TQString getLanguage() { return strLanguage; }
    
    void setId(int id);
    void setLanguage(TQString lang) { strLanguage = lang; }

private:
    static int iMaxId;
    int iId;
    TQString strLanguage;
};

#endif