Diffstat (limited to 'noncore/apps/confedit/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/confedit/mainwindow.cpp | 58 |
1 files changed, 23 insertions, 35 deletions
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 | |||
@@ -14,12 +14,13 @@ | |||
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> |
@@ -31,131 +32,117 @@ | |||
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; |
@@ -194,12 +181,13 @@ void MainWindow::revertConfFile() | |||
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()); |