author | tille <tille> | 2002-07-07 17:18:50 (UTC) |
---|---|---|
committer | tille <tille> | 2002-07-07 17:18:50 (UTC) |
commit | 04f29267e391eb4ad7ff9fc86468f6ccd1bd8f6d (patch) (unidiff) | |
tree | 91ed01ce29ec4dfd478f75239f874a22d1672a14 /noncore | |
parent | a72877e867e70784e3c865fa2948ac40f72b5c39 (diff) | |
download | opie-04f29267e391eb4ad7ff9fc86468f6ccd1bd8f6d.zip opie-04f29267e391eb4ad7ff9fc86468f6ccd1bd8f6d.tar.gz opie-04f29267e391eb4ad7ff9fc86468f6ccd1bd8f6d.tar.bz2 |
better layout
-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 | |||
@@ -16,18 +16,19 @@ 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 ); |
@@ -43,31 +44,54 @@ EditWidget::EditWidget( QWidget* parent, const char* name, WFlags fl ) | |||
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 | |||
@@ -17,18 +17,22 @@ 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: |
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 | |||
@@ -23,8 +23,10 @@ ListViewConfDir::ListViewConfDir(QString settingsPath, QWidget *parent, const ch | |||
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() |
@@ -46,8 +48,14 @@ void ListViewConfDir::readConfFiles() | |||
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 | |||
@@ -22,9 +22,10 @@ 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(); |
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 | |||
@@ -26,8 +26,9 @@ public: | |||
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(); |
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 | |||
@@ -19,9 +19,9 @@ | |||
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() |
@@ -40,8 +40,9 @@ QString ListViewItemConfFile::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 ); |
@@ -51,9 +52,9 @@ void ListViewItemConfFile::parseFile() | |||
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; |
@@ -61,21 +62,23 @@ void ListViewItemConfFile::parseFile() | |||
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() |
@@ -139,4 +142,10 @@ bool ListViewItemConfFile::revertable() | |||
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 | |||
@@ -21,16 +21,17 @@ | |||
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; |
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 | |||
@@ -21,9 +21,8 @@ ListViewItemConfigEntry::ListViewItemConfigEntry(ListViewItemConfFile *parent, Q | |||
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 | { |
@@ -142,5 +141,11 @@ void ListViewItemConfigEntry::revert() | |||
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 | |||
@@ -34,8 +34,9 @@ public: | |||
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; |
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 | |||
@@ -16,8 +16,9 @@ | |||
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> |
@@ -33,84 +34,74 @@ | |||
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 | { |
@@ -119,21 +110,20 @@ MainWindow::~MainWindow() | |||
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(); |
@@ -143,17 +133,14 @@ void MainWindow::setCurrent(QListViewItem *item) | |||
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) |
@@ -196,8 +183,9 @@ 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; |
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 | |||
@@ -12,8 +12,9 @@ | |||
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" |
@@ -22,9 +23,9 @@ 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 | ||
@@ -46,8 +47,9 @@ public slots: | |||
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; |