-rw-r--r-- | noncore/apps/confedit/editwidget.cpp | 60 | ||||
-rw-r--r-- | noncore/apps/confedit/editwidget.h | 6 | ||||
-rw-r--r-- | noncore/apps/confedit/listviewconfdir.cpp | 12 | ||||
-rw-r--r-- | noncore/apps/confedit/listviewconfdir.h | 3 | ||||
-rw-r--r-- | noncore/apps/confedit/listviewitemconf.h | 1 | ||||
-rw-r--r-- | noncore/apps/confedit/listviewitemconffile.cpp | 17 | ||||
-rw-r--r-- | noncore/apps/confedit/listviewitemconffile.h | 3 | ||||
-rw-r--r-- | noncore/apps/confedit/listviewitemconfigentry.cpp | 7 | ||||
-rw-r--r-- | noncore/apps/confedit/listviewitemconfigentry.h | 1 | ||||
-rw-r--r-- | noncore/apps/confedit/mainwindow.cpp | 58 | ||||
-rw-r--r-- | noncore/apps/confedit/mainwindow.h | 4 |
11 files changed, 108 insertions, 64 deletions
diff --git a/noncore/apps/confedit/editwidget.cpp b/noncore/apps/confedit/editwidget.cpp index 64f968a..f7dc408 100644 --- a/noncore/apps/confedit/editwidget.cpp +++ b/noncore/apps/confedit/editwidget.cpp | |||
@@ -12,26 +12,27 @@ | |||
12 | #include <qaction.h> | 12 | #include <qaction.h> |
13 | #include "listviewitemconfigentry.h" | 13 | #include "listviewitemconfigentry.h" |
14 | 14 | ||
15 | EditWidget::EditWidget( QWidget* parent, const char* name, WFlags fl ) | 15 | EditWidget::EditWidget( QWidget* parent, const char* name, WFlags fl ) |
16 | : QWidget( parent, name, fl ) | 16 | : QWidget( parent, name, fl ) |
17 | { | 17 | { |
18 | 18 | ||
19 | EditWidgetLayout = new QGridLayout( this ); | 19 | EditWidgetLayout = new QGridLayout( this ); |
20 | EditWidgetLayout->setSpacing( 3 ); | 20 | EditWidgetLayout->setSpacing( 0 ); |
21 | EditWidgetLayout->setMargin( 3 ); | 21 | EditWidgetLayout->setMargin( 0 ); |
22 | // setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Maximum));//, sizePolicy().hasHeightForWidth() ) ); | ||
22 | 23 | ||
23 | QLabel *TextLabelFileName = new QLabel( this, "TextLabelFileName" ); | 24 | TextLabelFileName = new QLabel( this, "TextLabelFileName" ); |
24 | TextLabelFileName->setText( tr( "File Name:" ) ); | 25 | TextLabelFileName->setText( tr( "File Name:" ) ); |
25 | EditWidgetLayout->addWidget( TextLabelFileName, 0, 0 ); | 26 | EditWidgetLayout->addWidget( TextLabelFileName, 0, 0 ); |
26 | TextFileName = new QLabel( this, "TextFileName" ); | 27 | TextFileName = new QLabel( this, "TextFileName" ); |
27 | EditWidgetLayout->addWidget( TextFileName, 0, 1 ); | 28 | EditWidgetLayout->addWidget( TextFileName, 0, 1 ); |
28 | 29 | ||
29 | QLabel *TextLabelGroup = new QLabel( this, "TextLabelGroup" ); | 30 | TextLabelGroup = new QLabel( this, "TextLabelGroup" ); |
30 | TextLabelGroup->setText( tr( "Group:" ) ); | 31 | TextLabelGroup->setText( tr( "Group:" ) ); |
31 | EditWidgetLayout->addWidget( TextLabelGroup, 1, 0 ); | 32 | EditWidgetLayout->addWidget( TextLabelGroup, 1, 0 ); |
32 | LineEditGroup = new QLineEdit( this, "LineEditGroup" ); | 33 | LineEditGroup = new QLineEdit( this, "LineEditGroup" ); |
33 | EditWidgetLayout->addWidget( LineEditGroup, 1, 1 ); | 34 | EditWidgetLayout->addWidget( LineEditGroup, 1, 1 ); |
34 | 35 | ||
35 | TextLabelKey = new QLabel( this, "TextLabelKey" ); | 36 | TextLabelKey = new QLabel( this, "TextLabelKey" ); |
36 | TextLabelKey->setText( tr( "Key:" ) ); | 37 | TextLabelKey->setText( tr( "Key:" ) ); |
37 | EditWidgetLayout->addWidget( TextLabelKey, 2, 0 ); | 38 | EditWidgetLayout->addWidget( TextLabelKey, 2, 0 ); |
@@ -39,35 +40,58 @@ EditWidget::EditWidget( QWidget* parent, const char* name, WFlags fl ) | |||
39 | EditWidgetLayout->addWidget( LineEditKey, 2, 1 ); | 40 | EditWidgetLayout->addWidget( LineEditKey, 2, 1 ); |
40 | 41 | ||
41 | TextLabelValue = new QLabel( this, "TextLabelValue" ); | 42 | TextLabelValue = new QLabel( this, "TextLabelValue" ); |
42 | TextLabelValue->setText( tr( "Value:" ) ); | 43 | TextLabelValue->setText( tr( "Value:" ) ); |
43 | EditWidgetLayout->addWidget( TextLabelValue, 3, 0 ); | 44 | EditWidgetLayout->addWidget( TextLabelValue, 3, 0 ); |
44 | LineEditValue = new QLineEdit( this, "LineEditValue" ); | 45 | LineEditValue = new QLineEdit( this, "LineEditValue" ); |
45 | EditWidgetLayout->addWidget( LineEditValue, 3, 1 ); | 46 | EditWidgetLayout->addWidget( LineEditValue, 3, 1 ); |
46 | 47 | ||
48 | // layoutType(Nothing); | ||
47 | } | 49 | } |
48 | 50 | ||
49 | 51 | ||
50 | EditWidget::~EditWidget() | 52 | EditWidget::~EditWidget() |
51 | { | 53 | { |
52 | } | 54 | } |
53 | 55 | ||
54 | 56 | ||
55 | void EditWidget::isKey(bool h) | 57 | void EditWidget::layoutType(int t) |
56 | { | 58 | { |
57 | if (h) | 59 | switch (t) |
58 | { | 60 | { |
59 | LineEditGroup->setEnabled(false); | 61 | case Entry: |
60 | TextLabelKey->show(); | 62 | LineEditGroup->setEnabled(false); |
61 | LineEditKey->show(); | 63 | TextLabelKey->show(); |
62 | TextLabelValue->show(); | 64 | LineEditKey->show(); |
63 | LineEditValue->show(); | 65 | TextLabelValue->show(); |
64 | }else{ | 66 | LineEditValue->show(); |
65 | LineEditGroup->setEnabled(true); | 67 | TextLabelGroup->show(); |
66 | TextLabelKey->hide(); | 68 | LineEditGroup->show(); |
67 | LineEditKey->hide(); | 69 | TextLabelFileName->show(); |
68 | TextLabelValue->hide(); | 70 | TextFileName->show(); |
69 | LineEditValue->hide(); | 71 | break; |
72 | case Group: | ||
73 | LineEditGroup->setEnabled(true); | ||
74 | TextLabelKey->hide(); | ||
75 | LineEditKey->hide(); | ||
76 | TextLabelValue->hide(); | ||
77 | LineEditValue->hide(); | ||
78 | TextLabelGroup->show(); | ||
79 | LineEditGroup->show(); | ||
80 | TextLabelFileName->show(); | ||
81 | TextFileName->show(); | ||
82 | break; | ||
83 | default: | ||
84 | TextLabelKey->hide(); | ||
85 | LineEditKey->hide(); | ||
86 | TextLabelValue->hide(); | ||
87 | LineEditValue->hide(); | ||
88 | TextLabelGroup->hide(); | ||
89 | LineEditGroup->hide(); | ||
90 | TextLabelFileName->hide(); | ||
91 | TextFileName->hide(); | ||
70 | } | 92 | } |
71 | update(); | 93 | // update(); |
94 | // updateGeometry(); | ||
95 | // adjustSize(); | ||
72 | } | 96 | } |
73 | 97 | ||
diff --git a/noncore/apps/confedit/editwidget.h b/noncore/apps/confedit/editwidget.h index 673166f..8261c85 100644 --- a/noncore/apps/confedit/editwidget.h +++ b/noncore/apps/confedit/editwidget.h | |||
@@ -13,25 +13,29 @@ class ListViewItemConfigEntry; | |||
13 | class QTimer; | 13 | class QTimer; |
14 | class QPopupMenu; | 14 | class QPopupMenu; |
15 | 15 | ||
16 | class EditWidget : public QWidget | 16 | class EditWidget : public QWidget |
17 | { | 17 | { |
18 | Q_OBJECT | 18 | Q_OBJECT |
19 | 19 | ||
20 | public: | 20 | public: |
21 | enum{ Entry, Group, File, Nothing}; | ||
22 | |||
21 | EditWidget( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 23 | EditWidget( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
22 | ~EditWidget(); | 24 | ~EditWidget(); |
23 | 25 | ||
24 | QLabel *TextLabelKey; | 26 | QLabel *TextLabelKey; |
25 | QLabel *TextLabelValue; | 27 | QLabel *TextLabelValue; |
28 | QLabel *TextLabelGroup; | ||
29 | QLabel *TextLabelFileName; | ||
26 | QLabel *TextFileName; | 30 | QLabel *TextFileName; |
27 | QLineEdit *LineEditGroup; | 31 | QLineEdit *LineEditGroup; |
28 | QLineEdit *LineEditKey; | 32 | QLineEdit *LineEditKey; |
29 | QLineEdit *LineEditValue; | 33 | QLineEdit *LineEditValue; |
30 | void isKey(bool h); | 34 | void layoutType(int t); |
31 | protected: | 35 | protected: |
32 | QGridLayout* EditWidgetLayout; | 36 | QGridLayout* EditWidgetLayout; |
33 | 37 | ||
34 | private: | 38 | private: |
35 | }; | 39 | }; |
36 | 40 | ||
37 | #endif // EDITWIDGET_H | 41 | #endif // EDITWIDGET_H |
diff --git a/noncore/apps/confedit/listviewconfdir.cpp b/noncore/apps/confedit/listviewconfdir.cpp index f466f06..0c2feeb 100644 --- a/noncore/apps/confedit/listviewconfdir.cpp +++ b/noncore/apps/confedit/listviewconfdir.cpp | |||
@@ -19,16 +19,18 @@ ListViewConfDir::ListViewConfDir(QString settingsPath, QWidget *parent, const ch | |||
19 | { | 19 | { |
20 | 20 | ||
21 | setRootIsDecorated( true ); | 21 | setRootIsDecorated( true ); |
22 | addColumn(tr("Files")); | 22 | addColumn(tr("Files")); |
23 | 23 | ||
24 | if (!confDir.isReadable()) | 24 | if (!confDir.isReadable()) |
25 | QMessageBox::critical(this,tr("Could not open"),tr("The directory ")+settingsPath+tr(" could not be opened."),1,0); | 25 | QMessageBox::critical(this,tr("Could not open"),tr("The directory ")+settingsPath+tr(" could not be opened."),1,0); |
26 | readConfFiles(); | 26 | readConfFiles(); |
27 | |||
28 | connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*))); | ||
27 | } | 29 | } |
28 | 30 | ||
29 | 31 | ||
30 | ListViewConfDir::~ListViewConfDir() | 32 | ListViewConfDir::~ListViewConfDir() |
31 | { | 33 | { |
32 | } | 34 | } |
33 | 35 | ||
34 | void ListViewConfDir::readConfFiles() | 36 | void ListViewConfDir::readConfFiles() |
@@ -42,12 +44,18 @@ void ListViewConfDir::readConfFiles() | |||
42 | QFileInfo *fi; | 44 | QFileInfo *fi; |
43 | 45 | ||
44 | ListViewItemConfFile *fileEntry; | 46 | ListViewItemConfFile *fileEntry; |
45 | 47 | ||
46 | while ( (fi=it.current()) ) | 48 | while ( (fi=it.current()) ) |
47 | { | 49 | { |
48 | qDebug( "opening: >%s<", fi->fileName().data() ); | 50 | qDebug( "opening: >%s<", fi->fileName().data() ); |
49 | fileEntry = new ListViewItemConfFile( fi, this ); | 51 | fileEntry = new ListViewItemConfFile( fi, this ); |
50 | 52 | QListViewItem *dummy = new QListViewItem(fileEntry, "dummy"); | |
51 | ++it; | 53 | ++it; |
52 | } | 54 | } |
53 | } \ No newline at end of file | 55 | } |
56 | |||
57 | void ListViewConfDir::expand(QListViewItem *item) | ||
58 | { | ||
59 | ((ListViewItemConf*)item)->expand(); | ||
60 | } | ||
61 | |||
diff --git a/noncore/apps/confedit/listviewconfdir.h b/noncore/apps/confedit/listviewconfdir.h index 3131972..978007b 100644 --- a/noncore/apps/confedit/listviewconfdir.h +++ b/noncore/apps/confedit/listviewconfdir.h | |||
@@ -18,16 +18,17 @@ | |||
18 | 18 | ||
19 | class QDir; | 19 | class QDir; |
20 | 20 | ||
21 | class ListViewConfDir : public QListView { | 21 | class ListViewConfDir : public QListView { |
22 | Q_OBJECT | 22 | Q_OBJECT |
23 | public: | 23 | public: |
24 | ListViewConfDir(QString settingsPath, QWidget *parent=0, const char *name=0); | 24 | ListViewConfDir(QString settingsPath, QWidget *parent=0, const char *name=0); |
25 | ~ListViewConfDir(); | 25 | ~ListViewConfDir(); |
26 | 26 | protected slots: | |
27 | void expand(QListViewItem*); | ||
27 | private: | 28 | private: |
28 | QDir confDir; | 29 | QDir confDir; |
29 | 30 | ||
30 | void readConfFiles(); | 31 | void readConfFiles(); |
31 | }; | 32 | }; |
32 | 33 | ||
33 | #endif | 34 | #endif |
diff --git a/noncore/apps/confedit/listviewitemconf.h b/noncore/apps/confedit/listviewitemconf.h index 3c504ed..c005475 100644 --- a/noncore/apps/confedit/listviewitemconf.h +++ b/noncore/apps/confedit/listviewitemconf.h | |||
@@ -22,16 +22,17 @@ public: | |||
22 | ListViewItemConf(QListView *parent); | 22 | ListViewItemConf(QListView *parent); |
23 | ~ListViewItemConf(); | 23 | ~ListViewItemConf(); |
24 | 24 | ||
25 | int getType(); | 25 | int getType(); |
26 | void save(); | 26 | void save(); |
27 | virtual void revert() = 0; | 27 | virtual void revert() = 0; |
28 | virtual void remove() = 0; | 28 | virtual void remove() = 0; |
29 | virtual void displayText() = 0; | 29 | virtual void displayText() = 0; |
30 | virtual void expand() = 0; | ||
30 | virtual void changed(); | 31 | virtual void changed(); |
31 | bool isChanged() {return _changed;}; | 32 | bool isChanged() {return _changed;}; |
32 | virtual void unchanged(); | 33 | virtual void unchanged(); |
33 | virtual bool revertable(); | 34 | virtual bool revertable(); |
34 | 35 | ||
35 | protected: | 36 | protected: |
36 | int _type; | 37 | int _type; |
37 | bool _changed; | 38 | bool _changed; |
diff --git a/noncore/apps/confedit/listviewitemconffile.cpp b/noncore/apps/confedit/listviewitemconffile.cpp index 228421b..1f85095 100644 --- a/noncore/apps/confedit/listviewitemconffile.cpp +++ b/noncore/apps/confedit/listviewitemconffile.cpp | |||
@@ -15,17 +15,17 @@ | |||
15 | #include "listviewitemconfigentry.h" | 15 | #include "listviewitemconfigentry.h" |
16 | 16 | ||
17 | #define tr QObject::tr | 17 | #define tr QObject::tr |
18 | 18 | ||
19 | ListViewItemConfFile::ListViewItemConfFile(QFileInfo *file, QListView *parent) | 19 | ListViewItemConfFile::ListViewItemConfFile(QFileInfo *file, QListView *parent) |
20 | : ListViewItemConf(parent), _valid(false) | 20 | : ListViewItemConf(parent), _valid(false) |
21 | { | 21 | { |
22 | confFileInfo = file; | 22 | confFileInfo = file; |
23 | parseFile(); | 23 | // parseFile(); |
24 | displayText(); | 24 | displayText(); |
25 | } | 25 | } |
26 | 26 | ||
27 | ListViewItemConfFile::~ListViewItemConfFile() | 27 | ListViewItemConfFile::~ListViewItemConfFile() |
28 | { | 28 | { |
29 | } | 29 | } |
30 | 30 | ||
31 | 31 | ||
@@ -36,50 +36,53 @@ void ListViewItemConfFile::displayText() | |||
36 | 36 | ||
37 | QString ListViewItemConfFile::fileName() | 37 | QString ListViewItemConfFile::fileName() |
38 | { | 38 | { |
39 | return confFileInfo->fileName(); | 39 | return confFileInfo->fileName(); |
40 | } | 40 | } |
41 | 41 | ||
42 | void ListViewItemConfFile::parseFile() | 42 | void ListViewItemConfFile::parseFile() |
43 | { | 43 | { |
44 | //qDebug("ListViewItemConfFile::parseFile BEGIN"); | ||
44 | QFile confFile(confFileInfo->absFilePath()); | 45 | QFile confFile(confFileInfo->absFilePath()); |
45 | if(! confFile.open(IO_ReadOnly)) | 46 | if(! confFile.open(IO_ReadOnly)) |
46 | QMessageBox::critical(0,tr("Could not open"),tr("The file ")+confFileInfo->fileName()+tr(" could not be opened."),1,0); | 47 | QMessageBox::critical(0,tr("Could not open"),tr("The file ")+confFileInfo->fileName()+tr(" could not be opened."),1,0); |
47 | QTextStream t( &confFile ); | 48 | QTextStream t( &confFile ); |
48 | QString s; | 49 | QString s; |
49 | QString group; | 50 | QString group; |
50 | ListViewItemConfigEntry *groupItem; | 51 | ListViewItemConfigEntry *groupItem; |
51 | ListViewItemConfigEntry *item; | 52 | ListViewItemConfigEntry *item; |
52 | while ( !t.atEnd() ) | 53 | while ( !t.atEnd() ) |
53 | { | 54 | { |
54 | s = t.readLine().stripWhiteSpace(); | 55 | s = t.readLine().stripWhiteSpace(); |
55 | //qDebug( "line: >%s<\n", s.latin1() ); | 56 | //qDebug( "line: >%s<\n", s.latin1() ); |
56 | if (s.contains("<?xml")) | 57 | if (s.contains("<?xml")) |
57 | { | 58 | { |
58 | _valid = false; | 59 | _valid = false; |
59 | break; | 60 | break; |
60 | }else | 61 | }else |
61 | if ( s[0] == '[' && s[s.length()-1] == ']' ) | 62 | if ( s[0] == '[' && s[s.length()-1] == ']' ) |
62 | { | 63 | { |
63 | // qDebug("got group"+s); | 64 | // qDebug("got group"+s); |
64 | group = s.mid(1,s.length()-2); | 65 | group = s.mid(1,s.length()-2); |
66 | if (!groupItem) groupItem = new ListViewItemConfigEntry(this, tr("no group") ); | ||
65 | groupItem = new ListViewItemConfigEntry(this, group ); | 67 | groupItem = new ListViewItemConfigEntry(this, group ); |
66 | insertItem( groupItem ); | 68 | insertItem( groupItem ); |
67 | } else | 69 | } else |
68 | if ( int pos = s.find('=') ) | 70 | if ( int pos = s.find('=') ) |
69 | { | 71 | { |
70 | // qDebug("got key"+s); | 72 | // qDebug("got key"+s); |
73 | if (!groupItem) qDebug("PANIK NO GROUP! >%s<",group.latin1()); | ||
71 | item = new ListViewItemConfigEntry(this, group, s ); | 74 | item = new ListViewItemConfigEntry(this, group, s ); |
72 | groupItem->insertItem( item ); | 75 | groupItem->insertItem( item ); |
73 | } | 76 | } |
74 | } | 77 | } |
75 | confFile.close(); | 78 | confFile.close(); |
76 | unchanged(); | ||
77 | setExpandable( _valid ); | 79 | setExpandable( _valid ); |
80 | //qDebug("ListViewItemConfFile::parseFile END"); | ||
78 | } | 81 | } |
79 | 82 | ||
80 | 83 | ||
81 | void ListViewItemConfFile::remove() | 84 | void ListViewItemConfFile::remove() |
82 | { | 85 | { |
83 | QFile::remove(confFileInfo->absFilePath()); | 86 | QFile::remove(confFileInfo->absFilePath()); |
84 | QFile::remove(backupFileName()); | 87 | QFile::remove(backupFileName()); |
85 | delete this; | 88 | delete this; |
@@ -135,8 +138,14 @@ bool ListViewItemConfFile::revertable() | |||
135 | { | 138 | { |
136 | return _changed || QFile(backupFileName()).exists(); | 139 | return _changed || QFile(backupFileName()).exists(); |
137 | } | 140 | } |
138 | 141 | ||
139 | QString ListViewItemConfFile::backupFileName() | 142 | QString ListViewItemConfFile::backupFileName() |
140 | { | 143 | { |
141 | return confFileInfo->absFilePath()+"~"; | 144 | return confFileInfo->absFilePath()+"~"; |
142 | } | 145 | } |
146 | |||
147 | |||
148 | void ListViewItemConfFile::expand() | ||
149 | { | ||
150 | parseFile(); | ||
151 | } | ||
diff --git a/noncore/apps/confedit/listviewitemconffile.h b/noncore/apps/confedit/listviewitemconffile.h index 679a2ed..18937af 100644 --- a/noncore/apps/confedit/listviewitemconffile.h +++ b/noncore/apps/confedit/listviewitemconffile.h | |||
@@ -17,23 +17,24 @@ | |||
17 | #include <qfileinfo.h> | 17 | #include <qfileinfo.h> |
18 | #include "listviewitemconf.h" | 18 | #include "listviewitemconf.h" |
19 | 19 | ||
20 | 20 | ||
21 | class ListViewItemConfFile : public ListViewItemConf { | 21 | class ListViewItemConfFile : public ListViewItemConf { |
22 | public: | 22 | public: |
23 | ListViewItemConfFile(QFileInfo *file, QListView *parent=0); | 23 | ListViewItemConfFile(QFileInfo *file, QListView *parent=0); |
24 | ~ListViewItemConfFile(); | 24 | ~ListViewItemConfFile(); |
25 | void parseFile(); | ||
26 | QString fileName(); | 25 | QString fileName(); |
27 | void save(); | 26 | void save(); |
28 | virtual void displayText(); | 27 | virtual void displayText(); |
29 | virtual bool revertable(); | 28 | virtual bool revertable(); |
30 | virtual void revert(); | 29 | virtual void revert(); |
31 | virtual void remove(); | 30 | virtual void remove(); |
31 | virtual void expand(); | ||
32 | QString backupFileName(); | 32 | QString backupFileName(); |
33 | void parseFile(); | ||
33 | protected: | 34 | protected: |
34 | private: | 35 | private: |
35 | bool _valid; | 36 | bool _valid; |
36 | QFileInfo *confFileInfo; | 37 | QFileInfo *confFileInfo; |
37 | }; | 38 | }; |
38 | 39 | ||
39 | #endif | 40 | #endif |
diff --git a/noncore/apps/confedit/listviewitemconfigentry.cpp b/noncore/apps/confedit/listviewitemconfigentry.cpp index b947514..5ef9f61 100644 --- a/noncore/apps/confedit/listviewitemconfigentry.cpp +++ b/noncore/apps/confedit/listviewitemconfigentry.cpp | |||
@@ -17,17 +17,16 @@ ListViewItemConfigEntry::ListViewItemConfigEntry(ListViewItemConfFile *parent, Q | |||
17 | { | 17 | { |
18 | _fileItem = parent; | 18 | _fileItem = parent; |
19 | _file = parent->fileName(); | 19 | _file = parent->fileName(); |
20 | _group = group; | 20 | _group = group; |
21 | setKey(key); | 21 | setKey(key); |
22 | _groupOrig = group; | 22 | _groupOrig = group; |
23 | _keyOrig = _key; | 23 | _keyOrig = _key; |
24 | _valueOrig = _value; | 24 | _valueOrig = _value; |
25 | _fileItem->unchanged(); | ||
26 | } | 25 | } |
27 | 26 | ||
28 | ListViewItemConfigEntry::~ListViewItemConfigEntry() | 27 | ListViewItemConfigEntry::~ListViewItemConfigEntry() |
29 | { | 28 | { |
30 | } | 29 | } |
31 | 30 | ||
32 | bool ListViewItemConfigEntry::isGroup() | 31 | bool ListViewItemConfigEntry::isGroup() |
33 | { | 32 | { |
@@ -138,9 +137,15 @@ void ListViewItemConfigEntry::save(QTextStream *t) | |||
138 | 137 | ||
139 | void ListViewItemConfigEntry::revert() | 138 | void ListViewItemConfigEntry::revert() |
140 | { | 139 | { |
141 | _group = _groupOrig; | 140 | _group = _groupOrig; |
142 | _key = _keyOrig; | 141 | _key = _keyOrig; |
143 | _value = _valueOrig; | 142 | _value = _valueOrig; |
144 | _changed=false; | 143 | _changed=false; |
145 | displayText(); | 144 | displayText(); |
145 | } | ||
146 | |||
147 | |||
148 | void ListViewItemConfigEntry::expand() | ||
149 | { | ||
150 | |||
146 | } \ No newline at end of file | 151 | } \ No newline at end of file |
diff --git a/noncore/apps/confedit/listviewitemconfigentry.h b/noncore/apps/confedit/listviewitemconfigentry.h index 6b651a6..c5f8737 100644 --- a/noncore/apps/confedit/listviewitemconfigentry.h +++ b/noncore/apps/confedit/listviewitemconfigentry.h | |||
@@ -30,16 +30,17 @@ public: | |||
30 | void setKey(QString); | 30 | void setKey(QString); |
31 | QString getKey(); | 31 | QString getKey(); |
32 | QString getValue(); | 32 | QString getValue(); |
33 | void keyChanged(QString); | 33 | void keyChanged(QString); |
34 | void valueChanged(QString); | 34 | void valueChanged(QString); |
35 | virtual void displayText(); | 35 | virtual void displayText(); |
36 | virtual void changed(); | 36 | virtual void changed(); |
37 | virtual void remove(); | 37 | virtual void remove(); |
38 | virtual void expand(); | ||
38 | void save(QTextStream*); | 39 | void save(QTextStream*); |
39 | virtual void revert(); | 40 | virtual void revert(); |
40 | private: | 41 | private: |
41 | QString _file; | 42 | QString _file; |
42 | QString _group; | 43 | QString _group; |
43 | QString _key; | 44 | QString _key; |
44 | QString _value; | 45 | QString _value; |
45 | QString _groupOrig; | 46 | QString _groupOrig; |
diff --git a/noncore/apps/confedit/mainwindow.cpp b/noncore/apps/confedit/mainwindow.cpp index fc403d2..6de8741 100644 --- a/noncore/apps/confedit/mainwindow.cpp +++ b/noncore/apps/confedit/mainwindow.cpp | |||
@@ -12,16 +12,17 @@ | |||
12 | 12 | ||
13 | #include "mainwindow.h" | 13 | #include "mainwindow.h" |
14 | 14 | ||
15 | #include <qpe/qpemenubar.h> | 15 | #include <qpe/qpemenubar.h> |
16 | #include <qpe/qpemessagebox.h> | 16 | #include <qpe/qpemessagebox.h> |
17 | #include <qpe/resource.h> | 17 | #include <qpe/resource.h> |
18 | #include <qpe/config.h> | 18 | #include <qpe/config.h> |
19 | #include <qpe/qpetoolbar.h> | 19 | #include <qpe/qpetoolbar.h> |
20 | #include <qpe/qpeapplication.h> | ||
20 | #include <qaction.h> | 21 | #include <qaction.h> |
21 | #include <qmessagebox.h> | 22 | #include <qmessagebox.h> |
22 | #include <qpopupmenu.h> | 23 | #include <qpopupmenu.h> |
23 | #include <qtoolbutton.h> | 24 | #include <qtoolbutton.h> |
24 | #include <qstring.h> | 25 | #include <qstring.h> |
25 | #include <qlabel.h> | 26 | #include <qlabel.h> |
26 | #include <qfile.h> | 27 | #include <qfile.h> |
27 | #include <qpushbutton.h> | 28 | #include <qpushbutton.h> |
@@ -29,135 +30,121 @@ | |||
29 | #include <qlineedit.h> | 30 | #include <qlineedit.h> |
30 | 31 | ||
31 | #include "listviewconfdir.h" | 32 | #include "listviewconfdir.h" |
32 | #include "listviewitemconf.h" | 33 | #include "listviewitemconf.h" |
33 | #include "listviewitemconfigentry.h" | 34 | #include "listviewitemconfigentry.h" |
34 | 35 | ||
35 | 36 | ||
36 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | 37 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : |
37 | QMainWindow( parent, name, f ), _currentItem(0), _fileItem(0) | 38 | QDialog( parent, name, f ), _currentItem(0), _fileItem(0) |
38 | { | 39 | { |
39 | setCaption( tr("Conf File Editor") ); | 40 | setCaption( tr("Conf File Editor") ); |
40 | 41 | ||
41 | QWidget *mainWidget = new QWidget(this); | 42 | //setBaseSize( qApp->globalStrut() ); |
42 | setCentralWidget( mainWidget); | 43 | setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) ); |
43 | QGridLayout *mainLayout = new QGridLayout( mainWidget ); | ||
44 | mainLayout->setSpacing( 3 ); | ||
45 | mainLayout->setMargin( 3 ); | ||
46 | 44 | ||
45 | mainLayout = new QVBoxLayout( this ); | ||
46 | mainLayout->setSpacing( 0 ); | ||
47 | mainLayout->setMargin( 0 ); | ||
47 | 48 | ||
48 | qDebug("settingList"); | 49 | |
50 | qDebug("creating settingList"); | ||
49 | settingList = new ListViewConfDir( "/root/Settings/", this, "settingslist"); | 51 | settingList = new ListViewConfDir( "/root/Settings/", this, "settingslist"); |
50 | settingList->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding));//, sizePolicy().hasHeightForWidth() ) ); | 52 | settingList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) ); |
51 | mainLayout->addWidget( settingList, 0, 0 ); | 53 | mainLayout->addWidget( settingList, 0); |
52 | 54 | ||
53 | qDebug("editor"); | 55 | qDebug("creating editor"); |
54 | editor = new EditWidget(this); | 56 | editor = new EditWidget(this); |
55 | editor->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum));//, sizePolicy().hasHeightForWidth() ) ); | 57 | editor->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Maximum));//, sizePolicy().hasHeightForWidth() ) ); |
56 | // editor->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)3));//, sizePolicy().hasHeightForWidth() ) ); | 58 | mainLayout->addWidget( editor, 1 ); |
57 | mainLayout->addWidget( editor, 1, 0 ); | 59 | editor->layoutType( ListViewItemConf::File ); |
58 | 60 | ||
59 | makeMenu(); | 61 | makeMenu(); |
60 | 62 | ||
61 | qDebug("connect"); | ||
62 | connect(settingList, SIGNAL( pressed(QListViewItem*) ), | 63 | connect(settingList, SIGNAL( pressed(QListViewItem*) ), |
63 | this, SLOT(setCurrent(QListViewItem*))); | 64 | this, SLOT(setCurrent(QListViewItem*))); |
64 | 65 | connect( settingList, SIGNAL( clicked( QListViewItem* ) ), | |
66 | this, SLOT( stopTimer( QListViewItem* ) ) ); | ||
65 | 67 | ||
66 | connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ), | 68 | connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ), |
67 | SLOT( groupChanged(const QString&) ) ); | 69 | SLOT( groupChanged(const QString&) ) ); |
68 | connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ), | 70 | connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ), |
69 | SLOT( keyChanged(const QString&) ) ); | 71 | SLOT( keyChanged(const QString&) ) ); |
70 | connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ), | 72 | connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ), |
71 | SLOT( valueChanged(const QString&) ) ); | 73 | SLOT( valueChanged(const QString&) ) ); |
72 | // qDebug("editor->hide()"); | 74 | |
73 | // editor->hide(); | ||
74 | qDebug("connect"); | ||
75 | connect( settingList, SIGNAL( clicked( QListViewItem* ) ), | ||
76 | this, SLOT( stopTimer( QListViewItem* ) ) ); | ||
77 | setCurrent(0); | 75 | setCurrent(0); |
78 | } | 76 | } |
79 | 77 | ||
80 | void MainWindow::makeMenu() | 78 | void MainWindow::makeMenu() |
81 | { | 79 | { |
82 | qDebug("MainWindow::makeMenu()"); | ||
83 | |||
84 | popupTimer = new QTimer(this); | 80 | popupTimer = new QTimer(this); |
85 | popupMenuFile = new QPopupMenu(this); | 81 | popupMenuFile = new QPopupMenu(this); |
86 | popupMenuEntry = new QPopupMenu(this); | 82 | popupMenuEntry = new QPopupMenu(this); |
87 | 83 | ||
88 | qDebug("Save"); | ||
89 | popupActionSave = new QAction( tr("Save"),QString::null, 0, this, 0 ); | 84 | popupActionSave = new QAction( tr("Save"),QString::null, 0, this, 0 ); |
90 | popupActionSave->addTo( popupMenuFile ); | 85 | popupActionSave->addTo( popupMenuFile ); |
91 | // popupActionSave->addTo( popupMenuEntry ); | 86 | // popupActionSave->addTo( popupMenuEntry ); |
92 | connect( popupActionSave, SIGNAL( activated() ), | 87 | connect( popupActionSave, SIGNAL( activated() ), |
93 | this , SLOT( saveConfFile() ) ); | 88 | this , SLOT( saveConfFile() ) ); |
94 | 89 | ||
95 | qDebug("Revert"); | ||
96 | popupActionRevert = new QAction( tr("Revert"),QString::null, 0, this, 0 ); | 90 | popupActionRevert = new QAction( tr("Revert"),QString::null, 0, this, 0 ); |
97 | popupActionRevert->addTo( popupMenuFile ); | 91 | popupActionRevert->addTo( popupMenuFile ); |
98 | popupActionRevert->addTo( popupMenuEntry ); | 92 | popupActionRevert->addTo( popupMenuEntry ); |
99 | connect( popupActionRevert, SIGNAL( activated() ), | 93 | connect( popupActionRevert, SIGNAL( activated() ), |
100 | this , SLOT( revertConfFile() ) ); | 94 | this , SLOT( revertConfFile() ) ); |
101 | 95 | ||
102 | qDebug("Delete"); | ||
103 | popupActionDelete = new QAction( tr("Delete"),QString::null, 0, this, 0 ); | 96 | popupActionDelete = new QAction( tr("Delete"),QString::null, 0, this, 0 ); |
104 | popupActionDelete->addTo( popupMenuFile ); | 97 | popupActionDelete->addTo( popupMenuFile ); |
105 | popupActionDelete->addTo( popupMenuEntry ); | 98 | popupActionDelete->addTo( popupMenuEntry ); |
106 | connect( popupActionDelete, SIGNAL( activated() ), | 99 | connect( popupActionDelete, SIGNAL( activated() ), |
107 | this , SLOT( removeConfFile() ) ); | 100 | this , SLOT( removeConfFile() ) ); |
108 | 101 | ||
109 | qDebug("connect"); | ||
110 | connect( popupTimer, SIGNAL(timeout()), | 102 | connect( popupTimer, SIGNAL(timeout()), |
111 | this, SLOT(showPopup()) ); | 103 | this, SLOT(showPopup()) ); |
112 | qDebug("connect"); | ||
113 | } | 104 | } |
114 | 105 | ||
115 | MainWindow::~MainWindow() | 106 | MainWindow::~MainWindow() |
116 | { | 107 | { |
117 | } | 108 | } |
118 | 109 | ||
119 | 110 | ||
120 | 111 | ||
121 | void MainWindow::setCurrent(QListViewItem *item) | 112 | void MainWindow::setCurrent(QListViewItem *item) |
122 | { | 113 | { |
123 | editor->hide(); | 114 | //qDebug("MainWindow::setCurrent"); |
124 | if (!item) return; | 115 | if (!item) return; |
125 | _item = (ListViewItemConf*) item; | 116 | _item = (ListViewItemConf*) item; |
126 | if (!_item) return; | 117 | if (!_item) return; |
127 | popupTimer->start( 750, true ); | 118 | popupTimer->start( 750, true ); |
128 | if (_item->getType() == ListViewItemConf::File) | 119 | if (_item->getType() == ListViewItemConf::File) |
129 | { | 120 | { |
130 | updateGeometry(); | 121 | editor->layoutType(EditWidget::File); |
131 | _currentItem=0; | 122 | _currentItem=0; |
132 | _fileItem = (ListViewItemConfFile*)item; | 123 | _fileItem = (ListViewItemConfFile*)item; |
133 | return; | 124 | return; |
134 | } | 125 | } |
135 | editor->show(); | ||
136 | _fileItem = 0; | 126 | _fileItem = 0; |
137 | _currentItem = (ListViewItemConfigEntry*)item; | 127 | _currentItem = (ListViewItemConfigEntry*)item; |
138 | if (!_currentItem) return; | 128 | if (!_currentItem) return; |
139 | QString file = _currentItem->getFile(); | 129 | QString file = _currentItem->getFile(); |
140 | QString group = _currentItem->getGroup(); | 130 | QString group = _currentItem->getGroup(); |
141 | QString key = _currentItem->getKey(); | 131 | QString key = _currentItem->getKey(); |
142 | QString val = _currentItem->getValue(); | 132 | QString val = _currentItem->getValue(); |
143 | editor->TextFileName->setText(file); | 133 | editor->TextFileName->setText(file); |
144 | editor->LineEditGroup->setText(group); | 134 | editor->LineEditGroup->setText(group); |
145 | if (!key.isEmpty()) | 135 | if (!key.isEmpty()) |
146 | { | 136 | { |
147 | editor->isKey(true); | 137 | editor->layoutType(EditWidget::Entry); |
148 | editor->LineEditKey->setText(key); | 138 | editor->LineEditKey->setText(key); |
149 | editor->LineEditValue->setText(val); | 139 | editor->LineEditValue->setText(val); |
150 | }else{ | 140 | }else{ |
151 | editor->isKey(false); | 141 | editor->layoutType(EditWidget::Group); |
152 | } | 142 | } |
153 | updateGeometry(); | ||
154 | editor->updateGeometry(); | ||
155 | settingList->updateGeometry(); | ||
156 | } | 143 | } |
157 | 144 | ||
158 | 145 | ||
159 | void MainWindow::groupChanged(const QString &g) | 146 | void MainWindow::groupChanged(const QString &g) |
160 | { | 147 | { |
161 | if (!_currentItem) return; | 148 | if (!_currentItem) return; |
162 | _currentItem->setGroup(g); | 149 | _currentItem->setGroup(g); |
163 | } | 150 | } |
@@ -192,16 +179,17 @@ void MainWindow::revertConfFile() | |||
192 | _item->revert(); | 179 | _item->revert(); |
193 | } | 180 | } |
194 | 181 | ||
195 | void MainWindow::removeConfFile() | 182 | void MainWindow::removeConfFile() |
196 | { | 183 | { |
197 | if (!_item) return; | 184 | if (!_item) return; |
198 | _item->remove(); | 185 | _item->remove(); |
199 | } | 186 | } |
187 | |||
200 | void MainWindow::showPopup() | 188 | void MainWindow::showPopup() |
201 | { | 189 | { |
202 | qDebug("showPopup"); | 190 | qDebug("showPopup"); |
203 | if (!_item) return; | 191 | if (!_item) return; |
204 | popupActionRevert->setEnabled(_item->revertable()); | 192 | popupActionRevert->setEnabled(_item->revertable()); |
205 | popupActionSave->setEnabled(_item->isChanged()); | 193 | popupActionSave->setEnabled(_item->isChanged()); |
206 | if (_fileItem) | 194 | if (_fileItem) |
207 | { | 195 | { |
diff --git a/noncore/apps/confedit/mainwindow.h b/noncore/apps/confedit/mainwindow.h index 886b829..5be4a86 100644 --- a/noncore/apps/confedit/mainwindow.h +++ b/noncore/apps/confedit/mainwindow.h | |||
@@ -8,27 +8,28 @@ | |||
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | 9 | ||
10 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> | 10 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> |
11 | 11 | ||
12 | #ifndef MAINWINDOW_H | 12 | #ifndef MAINWINDOW_H |
13 | #define MAINWINDOW_H | 13 | #define MAINWINDOW_H |
14 | 14 | ||
15 | #include <qmainwindow.h> | 15 | #include <qmainwindow.h> |
16 | #include <qdialog.h> | ||
16 | #include <qaction.h> | 17 | #include <qaction.h> |
17 | #include <qtimer.h> | 18 | #include <qtimer.h> |
18 | #include <qpopupmenu.h> | 19 | #include <qpopupmenu.h> |
19 | #include "editwidget.h" | 20 | #include "editwidget.h" |
20 | 21 | ||
21 | class QPEToolBar; | 22 | class QPEToolBar; |
22 | class ListViewItemConfFile; | 23 | class ListViewItemConfFile; |
23 | class ListViewConfDir; | 24 | class ListViewConfDir; |
24 | class ListViewItemConf; | 25 | class ListViewItemConf; |
25 | 26 | ||
26 | class MainWindow : public QMainWindow | 27 | class MainWindow : public QDialog//QMainWindow |
27 | { | 28 | { |
28 | Q_OBJECT | 29 | Q_OBJECT |
29 | 30 | ||
30 | 31 | ||
31 | public: | 32 | public: |
32 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 33 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
33 | ~MainWindow(); | 34 | ~MainWindow(); |
34 | 35 | ||
@@ -42,16 +43,17 @@ public slots: | |||
42 | void stopTimer( QListViewItem* ); | 43 | void stopTimer( QListViewItem* ); |
43 | void saveConfFile(); | 44 | void saveConfFile(); |
44 | void revertConfFile(); | 45 | void revertConfFile(); |
45 | void removeConfFile(); | 46 | void removeConfFile(); |
46 | 47 | ||
47 | private: | 48 | private: |
48 | ListViewConfDir *settingList; | 49 | ListViewConfDir *settingList; |
49 | EditWidget *editor; | 50 | EditWidget *editor; |
51 | QVBoxLayout *mainLayout; | ||
50 | ListViewItemConf *_item; | 52 | ListViewItemConf *_item; |
51 | ListViewItemConfigEntry *_currentItem; | 53 | ListViewItemConfigEntry *_currentItem; |
52 | ListViewItemConfFile *_fileItem; | 54 | ListViewItemConfFile *_fileItem; |
53 | QTimer *popupTimer; | 55 | QTimer *popupTimer; |
54 | QPopupMenu *popupMenuFile; | 56 | QPopupMenu *popupMenuFile; |
55 | QPopupMenu *popupMenuEntry; | 57 | QPopupMenu *popupMenuEntry; |
56 | QAction *popupActionSave; | 58 | QAction *popupActionSave; |
57 | QAction *popupActionRevert; | 59 | QAction *popupActionRevert; |