summaryrefslogtreecommitdiff
path: root/noncore/apps/confedit/listviewitemconfigentry.cpp
Unidiff
Diffstat (limited to 'noncore/apps/confedit/listviewitemconfigentry.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/confedit/listviewitemconfigentry.cpp107
1 files changed, 107 insertions, 0 deletions
diff --git a/noncore/apps/confedit/listviewitemconfigentry.cpp b/noncore/apps/confedit/listviewitemconfigentry.cpp
new file mode 100644
index 0000000..16be46e
--- a/dev/null
+++ b/noncore/apps/confedit/listviewitemconfigentry.cpp
@@ -0,0 +1,107 @@
1/***************************************************************************
2 * *
3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. *
7 * *
8 ***************************************************************************/
9 // (c) 2002 Patrick S. Vogtp <tille@handhelds.org>
10
11#include "listviewitemconfigentry.h"
12#include "listviewitemconffile.h"
13
14ListViewItemConfigEntry::ListViewItemConfigEntry(ListViewItemConfFile *parent, QString group, QString key)
15 : ListViewItemConf(parent)
16{
17 _fileItem = parent;
18 _file = parent->fileName();
19 _group = group;
20 setKey(key);
21 _fileItem->unchanged();
22}
23
24ListViewItemConfigEntry::~ListViewItemConfigEntry()
25{
26}
27
28bool ListViewItemConfigEntry::isGroup()
29{
30 return _key.isEmpty();
31}
32
33bool ListViewItemConfigEntry::isKey()
34{
35 return !_key.isEmpty();
36}
37
38QString ListViewItemConfigEntry::getFile()
39{
40 return _file;
41}
42
43void ListViewItemConfigEntry::setGroup(QString g)
44{
45 if (g==_group) return;
46 _group = g;
47 changed();
48}
49
50QString ListViewItemConfigEntry::getGroup()
51{
52 return _group;
53}
54
55void ListViewItemConfigEntry::setKey(QString key)
56{
57 int pos = key.find("=");
58 _key = key.left(pos).stripWhiteSpace();
59 _value = key.right(key.length() - pos - 1).stripWhiteSpace();
60 displayText();
61}
62
63QString ListViewItemConfigEntry::getKey()
64{
65 return _key;
66}
67
68QString ListViewItemConfigEntry::getValue()
69{
70 return _value;
71}
72
73void ListViewItemConfigEntry::keyChanged(QString k)
74{
75 if (k==_key) return;
76 _key = k;
77 changed();
78}
79
80void ListViewItemConfigEntry::valueChanged(QString v)
81{
82 if (v==_value) return;
83 _value = v;
84 changed();
85}
86
87void ListViewItemConfigEntry::displayText()
88{
89 QString s;
90 if (_changed) s="*";
91 if (isGroup())
92 {
93 s += "["+_group+"]";
94 _type = Group;
95 }else{
96 s += _key+" = "+_value;
97 _type = Key;
98 }
99 setText(0,s);
100}
101
102void ListViewItemConfigEntry::changed()
103{
104 _changed=true;
105 displayText();
106 _fileItem->changed();
107} \ No newline at end of file