-rw-r--r-- | noncore/apps/confedit/listviewitemconffile.cpp | 9 | ||||
-rw-r--r-- | noncore/apps/confedit/listviewitemconfigentry.cpp | 21 | ||||
-rw-r--r-- | noncore/apps/confedit/listviewitemconfigentry.h | 3 | ||||
-rw-r--r-- | noncore/apps/confedit/mainwindow.cpp | 24 |
4 files changed, 44 insertions, 13 deletions
diff --git a/noncore/apps/confedit/listviewitemconffile.cpp b/noncore/apps/confedit/listviewitemconffile.cpp index a8fd770..858726d 100644 --- a/noncore/apps/confedit/listviewitemconffile.cpp +++ b/noncore/apps/confedit/listviewitemconffile.cpp | |||
@@ -79,21 +79,28 @@ void ListViewItemConfFile::parseFile() | |||
79 | void ListViewItemConfFile::save() | 79 | void ListViewItemConfFile::save() |
80 | { | 80 | { |
81 | if (!_changed) return; | 81 | if (!_changed) return; |
82 | QString backup = confFileInfo->absFilePath()+"~"; | 82 | QString backup = confFileInfo->absFilePath()+"~"; |
83 | qDebug("make backup to "+backup); | 83 | qDebug("make backup to "+backup); |
84 | QFile conf(confFileInfo->absFilePath()); | 84 | QFile conf(confFileInfo->absFilePath()); |
85 | QFile back(backup); | 85 | QFile back(backup); |
86 | 86 | ||
87 | if (!conf.open(IO_ReadOnly)) return; | 87 | if (!conf.open(IO_ReadOnly)) return; |
88 | if (!back.open(IO_WriteOnly)) return; | 88 | if (!back.open(IO_WriteOnly)) return; |
89 | 89 | ||
90 | #define SIZE 124 | 90 | #define SIZE 124 |
91 | char buf[SIZE]; | 91 | char buf[SIZE]; |
92 | while (int c = conf.readBlock(buf, SIZE) ) back.writeBlock(buf,c); | 92 | while (int c = conf.readBlock(buf, SIZE) ) back.writeBlock(buf,c); |
93 | conf.close(); | 93 | conf.close(); |
94 | back.close(); | 94 | back.close(); |
95 | |||
96 | 95 | ||
96 | |||
97 | if (!conf.open(IO_WriteOnly)) return; | ||
98 | QTextStream *t = new QTextStream( &conf ); | ||
99 | for (QListViewItem *it = firstChild(); it!=0;it = it->nextSibling()) | ||
100 | { | ||
101 | ((ListViewItemConfigEntry*)it)->save(t); | ||
102 | } | ||
103 | conf.close(); | ||
97 | qDebug("no saveing yet..."); | 104 | qDebug("no saveing yet..."); |
98 | unchanged(); | 105 | unchanged(); |
99 | } | 106 | } |
diff --git a/noncore/apps/confedit/listviewitemconfigentry.cpp b/noncore/apps/confedit/listviewitemconfigentry.cpp index 16be46e..77ce17d 100644 --- a/noncore/apps/confedit/listviewitemconfigentry.cpp +++ b/noncore/apps/confedit/listviewitemconfigentry.cpp | |||
@@ -1,28 +1,29 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 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 * | 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 * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | // (c) 2002 Patrick S. Vogtp <tille@handhelds.org> | 9 | // (c) 2002 Patrick S. Vogtp <tille@handhelds.org> |
10 | 10 | ||
11 | #include "listviewitemconfigentry.h" | 11 | #include "listviewitemconfigentry.h" |
12 | #include "listviewitemconffile.h" | 12 | #include "listviewitemconffile.h" |
13 | #include <qtextstream.h> | ||
13 | 14 | ||
14 | ListViewItemConfigEntry::ListViewItemConfigEntry(ListViewItemConfFile *parent, QString group, QString key) | 15 | ListViewItemConfigEntry::ListViewItemConfigEntry(ListViewItemConfFile *parent, QString group, QString key) |
15 | : ListViewItemConf(parent) | 16 | : ListViewItemConf(parent) |
16 | { | 17 | { |
17 | _fileItem = parent; | 18 | _fileItem = parent; |
18 | _file = parent->fileName(); | 19 | _file = parent->fileName(); |
19 | _group = group; | 20 | _group = group; |
20 | setKey(key); | 21 | setKey(key); |
21 | _fileItem->unchanged(); | 22 | _fileItem->unchanged(); |
22 | } | 23 | } |
23 | 24 | ||
24 | ListViewItemConfigEntry::~ListViewItemConfigEntry() | 25 | ListViewItemConfigEntry::~ListViewItemConfigEntry() |
25 | { | 26 | { |
26 | } | 27 | } |
27 | 28 | ||
28 | bool ListViewItemConfigEntry::isGroup() | 29 | bool ListViewItemConfigEntry::isGroup() |
@@ -91,17 +92,37 @@ void ListViewItemConfigEntry::displayText() | |||
91 | if (isGroup()) | 92 | if (isGroup()) |
92 | { | 93 | { |
93 | s += "["+_group+"]"; | 94 | s += "["+_group+"]"; |
94 | _type = Group; | 95 | _type = Group; |
95 | }else{ | 96 | }else{ |
96 | s += _key+" = "+_value; | 97 | s += _key+" = "+_value; |
97 | _type = Key; | 98 | _type = Key; |
98 | } | 99 | } |
99 | setText(0,s); | 100 | setText(0,s); |
100 | } | 101 | } |
101 | 102 | ||
102 | void ListViewItemConfigEntry::changed() | 103 | void ListViewItemConfigEntry::changed() |
103 | { | 104 | { |
104 | _changed=true; | 105 | _changed=true; |
105 | displayText(); | 106 | displayText(); |
106 | _fileItem->changed(); | 107 | _fileItem->changed(); |
108 | } | ||
109 | |||
110 | void ListViewItemConfigEntry::save(QTextStream *t) | ||
111 | { | ||
112 | QString s; | ||
113 | if (isGroup()) | ||
114 | { | ||
115 | s += "["+_group+"]"; | ||
116 | _type = Group; | ||
117 | }else{ | ||
118 | s += _key+" = "+_value; | ||
119 | _type = Key; | ||
120 | } | ||
121 | s += "\n"; | ||
122 | (*t) << s; | ||
123 | _changed = false; | ||
124 | for (QListViewItem *it = firstChild(); it!=0;it = it->nextSibling()) | ||
125 | { | ||
126 | ((ListViewItemConfigEntry*)it)->save(t); | ||
127 | } | ||
107 | } \ No newline at end of file | 128 | } \ No newline at end of file |
diff --git a/noncore/apps/confedit/listviewitemconfigentry.h b/noncore/apps/confedit/listviewitemconfigentry.h index d2b331f..1ff0491 100644 --- a/noncore/apps/confedit/listviewitemconfigentry.h +++ b/noncore/apps/confedit/listviewitemconfigentry.h | |||
@@ -3,41 +3,44 @@ | |||
3 | * This program is free software; you can redistribute it and/or modify * | 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 * | 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 * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | // (c) 2002 Patrick S. Vogtp <tille@handhelds.org> | 9 | // (c) 2002 Patrick S. Vogtp <tille@handhelds.org> |
10 | 10 | ||
11 | #ifndef LISTVIEWITEMCONFIGENTRY_H | 11 | #ifndef LISTVIEWITEMCONFIGENTRY_H |
12 | #define LISTVIEWITEMCONFIGENTRY_H | 12 | #define LISTVIEWITEMCONFIGENTRY_H |
13 | 13 | ||
14 | #include <qwidget.h> | 14 | #include <qwidget.h> |
15 | #include <qlistview.h> | 15 | #include <qlistview.h> |
16 | #include "listviewitemconffile.h" | 16 | #include "listviewitemconffile.h" |
17 | #include "listviewitemconf.h" | 17 | #include "listviewitemconf.h" |
18 | 18 | ||
19 | class QTextStream; | ||
20 | |||
19 | class ListViewItemConfigEntry : public ListViewItemConf { | 21 | class ListViewItemConfigEntry : public ListViewItemConf { |
20 | public: | 22 | public: |
21 | ListViewItemConfigEntry(ListViewItemConfFile *parent, QString group, QString key=""); | 23 | ListViewItemConfigEntry(ListViewItemConfFile *parent, QString group, QString key=""); |
22 | ~ListViewItemConfigEntry(); | 24 | ~ListViewItemConfigEntry(); |
23 | bool isGroup(); | 25 | bool isGroup(); |
24 | bool isKey(); | 26 | bool isKey(); |
25 | QString getFile(); | 27 | QString getFile(); |
26 | void setGroup(QString); | 28 | void setGroup(QString); |
27 | QString getGroup(); | 29 | QString getGroup(); |
28 | void setKey(QString); | 30 | void setKey(QString); |
29 | QString getKey(); | 31 | QString getKey(); |
30 | QString getValue(); | 32 | QString getValue(); |
31 | void keyChanged(QString); | 33 | void keyChanged(QString); |
32 | void valueChanged(QString); | 34 | void valueChanged(QString); |
33 | virtual void displayText(); | 35 | virtual void displayText(); |
34 | virtual void changed(); | 36 | virtual void changed(); |
37 | void save(QTextStream*); | ||
35 | private: | 38 | private: |
36 | QString _file; | 39 | QString _file; |
37 | QString _group; | 40 | QString _group; |
38 | QString _key; | 41 | QString _key; |
39 | QString _value; | 42 | QString _value; |
40 | ListViewItemConfFile *_fileItem; | 43 | ListViewItemConfFile *_fileItem; |
41 | }; | 44 | }; |
42 | 45 | ||
43 | #endif | 46 | #endif |
diff --git a/noncore/apps/confedit/mainwindow.cpp b/noncore/apps/confedit/mainwindow.cpp index 30dfdf7..47d9518 100644 --- a/noncore/apps/confedit/mainwindow.cpp +++ b/noncore/apps/confedit/mainwindow.cpp | |||
@@ -42,46 +42,46 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | |||
42 | popupMenu = new QPopupMenu(this); | 42 | popupMenu = new QPopupMenu(this); |
43 | 43 | ||
44 | QWidget *mainWidget = new QWidget(this); | 44 | QWidget *mainWidget = new QWidget(this); |
45 | setCentralWidget( mainWidget); | 45 | setCentralWidget( mainWidget); |
46 | 46 | ||
47 | QGridLayout *mainLayout = new QGridLayout( mainWidget ); | 47 | QGridLayout *mainLayout = new QGridLayout( mainWidget ); |
48 | mainLayout->setSpacing( 3 ); | 48 | mainLayout->setSpacing( 3 ); |
49 | mainLayout->setMargin( 3 ); | 49 | mainLayout->setMargin( 3 ); |
50 | 50 | ||
51 | 51 | ||
52 | settingList = new ListViewConfDir( "/root/Settings/", this, "settingslist"); | 52 | settingList = new ListViewConfDir( "/root/Settings/", this, "settingslist"); |
53 | mainLayout->addWidget( settingList, 0, 0 ); | 53 | mainLayout->addWidget( settingList, 0, 0 ); |
54 | 54 | ||
55 | editor = new EditWidget(this); | 55 | editor = new EditWidget(this); |
56 | mainLayout->addWidget( editor, 1, 0 ); | 56 | mainLayout->addWidget( editor, 1, 0 ); |
57 | 57 | ||
58 | connect (settingList, SIGNAL( currentChanged(QListViewItem*) ), | 58 | connect(settingList, SIGNAL( pressed(QListViewItem*) ), |
59 | this, SLOT(setCurrent(QListViewItem*))); | 59 | this, SLOT(setCurrent(QListViewItem*))); |
60 | 60 | ||
61 | connect( popupTimer, SIGNAL(timeout()), | 61 | connect( popupTimer, SIGNAL(timeout()), |
62 | this, SLOT(showPopup()) ); | 62 | this, SLOT(showPopup()) ); |
63 | connect( this, SIGNAL( clicked( QListViewItem* ) ), | 63 | connect( settingList, SIGNAL( clicked( QListViewItem* ) ), |
64 | this, SLOT( stopTimer( QListViewItem* ) ) ); | 64 | this, SLOT( stopTimer( QListViewItem* ) ) ); |
65 | 65 | ||
66 | connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ), | 66 | connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ), |
67 | SLOT( groupChanged(const QString&) ) ); | 67 | SLOT( groupChanged(const QString&) ) ); |
68 | connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ), | 68 | connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ), |
69 | SLOT( keyChanged(const QString&) ) ); | 69 | SLOT( keyChanged(const QString&) ) ); |
70 | connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ), | 70 | connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ), |
71 | SLOT( valueChanged(const QString&) ) ); | 71 | SLOT( valueChanged(const QString&) ) ); |
72 | makeMenu(); | 72 | makeMenu(); |
73 | } | 73 | } |
74 | 74 | ||
75 | void MainWindow::makeMenu() | 75 | void MainWindow::makeMenu() |
76 | { | 76 | { |
77 | 77 | ||
78 | 78 | ||
79 | } | 79 | } |
80 | 80 | ||
81 | MainWindow::~MainWindow() | 81 | MainWindow::~MainWindow() |
82 | { | 82 | { |
83 | } | 83 | } |
84 | 84 | ||
85 | 85 | ||
86 | 86 | ||
87 | void MainWindow::setCurrent(QListViewItem *item) | 87 | void MainWindow::setCurrent(QListViewItem *item) |