summaryrefslogtreecommitdiffstats
path: root/kmail/snippetitem.h
blob: f15fb07d676a1ca0be9cdedfbb57c421e0d9aee0 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/***************************************************************************
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef SNIPPETITEM_H
#define SNIPPETITEM_H

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

#include <tqobject.h>

class TQString;
class KAction;
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 TQObject, public TQListViewItem {
friend class SnippetGroup;

    Q_OBJECT
  TQ_OBJECT
public:
    SnippetItem(TQListViewItem * parent, TQString name, TQString text);

    ~SnippetItem();
    TQString getName();
    TQString getText();
    using TQListViewItem::parent;
    int getParent() { return iParent; }
    void resetParent();
    void setText(TQString text);
    void setName(TQString name);
    void setAction( KAction* );
    KAction* getAction();
    static SnippetItem * findItemByName(TQString name, TQPtrList<SnippetItem> &list);
    static SnippetGroup * findGroupById(int id, TQPtrList<SnippetItem> &list);
signals:
    void execute( TQListViewItem * );
public slots:
    void slotExecute();
    
private:
  SnippetItem(TQListView * parent, TQString name, TQString text);
  TQString strName;
  TQString strText;
  int iParent;
  KAction *action;
};

/**
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 * parent, TQString name, int id);
    ~SnippetGroup();

    int getId() { return iId; }
    static int getMaxId() { return iMaxId; }
    
    void setId(int id);

private:
    static int iMaxId;
    int iId;
};

#endif