-rw-r--r-- | noncore/apps/confedit/mainwindow.cpp | 12 | ||||
-rw-r--r-- | noncore/apps/confedit/mainwindow.h | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/noncore/apps/confedit/mainwindow.cpp b/noncore/apps/confedit/mainwindow.cpp index 3b8042f..8e36980 100644 --- a/noncore/apps/confedit/mainwindow.cpp +++ b/noncore/apps/confedit/mainwindow.cpp | |||
@@ -1,114 +1,114 @@ | |||
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 | 9 | ||
10 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> | 10 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> |
11 | 11 | ||
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 <qpe/qpeapplication.h> |
21 | #include <qaction.h> | 21 | #include <qaction.h> |
22 | #include <qmessagebox.h> | 22 | #include <qmessagebox.h> |
23 | #include <qpopupmenu.h> | 23 | #include <qpopupmenu.h> |
24 | #include <qtoolbutton.h> | 24 | #include <qtoolbutton.h> |
25 | #include <qstring.h> | 25 | #include <qstring.h> |
26 | #include <qlabel.h> | 26 | #include <qlabel.h> |
27 | #include <qfile.h> | 27 | #include <qfile.h> |
28 | #include <qpushbutton.h> | 28 | #include <qpushbutton.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qlineedit.h> | 30 | #include <qlineedit.h> |
31 | 31 | ||
32 | #include "listviewconfdir.h" | 32 | #include "listviewconfdir.h" |
33 | #include "listviewitemconf.h" | 33 | #include "listviewitemconf.h" |
34 | #include "listviewitemconfigentry.h" | 34 | #include "listviewitemconfigentry.h" |
35 | 35 | ||
36 | 36 | ||
37 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | 37 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : |
38 | QDialog( parent, name, f ), _currentItem(0), _fileItem(0) | 38 | QMainWindow( parent, name, f ), _currentItem(0), _fileItem(0) |
39 | { | 39 | { |
40 | setCaption( tr("Conf File Editor") ); | 40 | setCaption( tr("Conf File Editor") ); |
41 | 41 | ||
42 | //setBaseSize( qApp->globalStrut() ); | 42 | //setBaseSize( qApp->globalStrut() ); |
43 | setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) ); | 43 | setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) ); |
44 | 44 | ||
45 | mainLayout = new QVBoxLayout( this ); | 45 | mainLayout = new QVBoxLayout( this ); |
46 | mainLayout->setSpacing( 0 ); | 46 | mainLayout->setSpacing( 0 ); |
47 | mainLayout->setMargin( 0 ); | 47 | mainLayout->setMargin( 0 ); |
48 | 48 | ||
49 | 49 | ||
50 | qDebug("creating settingList"); | 50 | qDebug("creating settingList"); |
51 | settingList = new ListViewConfDir( QDir::homeDirPath() + "/Settings", this, "settingslist"); | 51 | settingList = new ListViewConfDir( QDir::homeDirPath() + "/Settings", this, "settingslist"); |
52 | settingList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) ); | 52 | settingList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) ); |
53 | mainLayout->addWidget( settingList, 0); | 53 | mainLayout->addWidget( settingList, 0); |
54 | 54 | ||
55 | qDebug("creating editor"); | 55 | qDebug("creating editor"); |
56 | editor = new EditWidget(this); | 56 | editor = new EditWidget(this); |
57 | editor->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Maximum));//, sizePolicy().hasHeightForWidth() ) ); | 57 | editor->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Maximum));//, sizePolicy().hasHeightForWidth() ) ); |
58 | mainLayout->addWidget( editor, 1 ); | 58 | mainLayout->addWidget( editor, 1 ); |
59 | editor->layoutType( ListViewItemConf::File ); | 59 | editor->layoutType( ListViewItemConf::File ); |
60 | 60 | ||
61 | makeMenu(); | 61 | makeMenu(); |
62 | 62 | ||
63 | connect(settingList, SIGNAL( pressed(QListViewItem*) ), | 63 | connect(settingList, SIGNAL( pressed(QListViewItem*) ), |
64 | this, SLOT(setCurrent(QListViewItem*))); | 64 | this, SLOT(setCurrent(QListViewItem*))); |
65 | connect( settingList, SIGNAL( clicked( QListViewItem* ) ), | 65 | connect( settingList, SIGNAL( clicked( QListViewItem* ) ), |
66 | this, SLOT( stopTimer( QListViewItem* ) ) ); | 66 | this, SLOT( stopTimer( QListViewItem* ) ) ); |
67 | 67 | ||
68 | connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ), | 68 | connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ), |
69 | SLOT( groupChanged(const QString&) ) ); | 69 | SLOT( groupChanged(const QString&) ) ); |
70 | connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ), | 70 | connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ), |
71 | SLOT( keyChanged(const QString&) ) ); | 71 | SLOT( keyChanged(const QString&) ) ); |
72 | connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ), | 72 | connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ), |
73 | SLOT( valueChanged(const QString&) ) ); | 73 | SLOT( valueChanged(const QString&) ) ); |
74 | 74 | ||
75 | setCurrent(0); | 75 | setCurrent(0); |
76 | editor->layoutType(EditWidget::File); | 76 | editor->layoutType(EditWidget::File); |
77 | } | 77 | } |
78 | 78 | ||
79 | void MainWindow::makeMenu() | 79 | void MainWindow::makeMenu() |
80 | { | 80 | { |
81 | popupTimer = new QTimer(this); | 81 | popupTimer = new QTimer(this); |
82 | popupMenuFile = new QPopupMenu(this); | 82 | popupMenuFile = new QPopupMenu(this); |
83 | popupMenuEntry = new QPopupMenu(this); | 83 | popupMenuEntry = new QPopupMenu(this); |
84 | 84 | ||
85 | popupActionSave = new QAction( tr("Save"),QString::null, 0, this, 0 ); | 85 | popupActionSave = new QAction( tr("Save"),QString::null, 0, this, 0 ); |
86 | popupActionSave->addTo( popupMenuFile ); | 86 | popupActionSave->addTo( popupMenuFile ); |
87 | // popupActionSave->addTo( popupMenuEntry ); | 87 | // popupActionSave->addTo( popupMenuEntry ); |
88 | connect( popupActionSave, SIGNAL( activated() ), | 88 | connect( popupActionSave, SIGNAL( activated() ), |
89 | this , SLOT( saveConfFile() ) ); | 89 | this , SLOT( saveConfFile() ) ); |
90 | 90 | ||
91 | popupActionRevert = new QAction( tr("Revert"),QString::null, 0, this, 0 ); | 91 | popupActionRevert = new QAction( tr("Revert"),QString::null, 0, this, 0 ); |
92 | popupActionRevert->addTo( popupMenuFile ); | 92 | popupActionRevert->addTo( popupMenuFile ); |
93 | popupActionRevert->addTo( popupMenuEntry ); | 93 | popupActionRevert->addTo( popupMenuEntry ); |
94 | connect( popupActionRevert, SIGNAL( activated() ), | 94 | connect( popupActionRevert, SIGNAL( activated() ), |
95 | this , SLOT( revertConfFile() ) ); | 95 | this , SLOT( revertConfFile() ) ); |
96 | 96 | ||
97 | popupActionDelete = new QAction( tr("Delete"),QString::null, 0, this, 0 ); | 97 | popupActionDelete = new QAction( tr("Delete"),QString::null, 0, this, 0 ); |
98 | popupActionDelete->addTo( popupMenuFile ); | 98 | popupActionDelete->addTo( popupMenuFile ); |
99 | popupActionDelete->addTo( popupMenuEntry ); | 99 | popupActionDelete->addTo( popupMenuEntry ); |
100 | connect( popupActionDelete, SIGNAL( activated() ), | 100 | connect( popupActionDelete, SIGNAL( activated() ), |
101 | this , SLOT( removeConfFile() ) ); | 101 | this , SLOT( removeConfFile() ) ); |
102 | 102 | ||
103 | connect( popupTimer, SIGNAL(timeout()), | 103 | connect( popupTimer, SIGNAL(timeout()), |
104 | this, SLOT(showPopup()) ); | 104 | this, SLOT(showPopup()) ); |
105 | } | 105 | } |
106 | 106 | ||
107 | MainWindow::~MainWindow() | 107 | MainWindow::~MainWindow() |
108 | { | 108 | { |
109 | } | 109 | } |
110 | 110 | ||
111 | 111 | ||
112 | 112 | ||
113 | void MainWindow::setCurrent(QListViewItem *item) | 113 | void MainWindow::setCurrent(QListViewItem *item) |
114 | { | 114 | { |
@@ -125,79 +125,79 @@ void MainWindow::setCurrent(QListViewItem *item) | |||
125 | return; | 125 | return; |
126 | } | 126 | } |
127 | _fileItem = 0; | 127 | _fileItem = 0; |
128 | _currentItem = (ListViewItemConfigEntry*)item; | 128 | _currentItem = (ListViewItemConfigEntry*)item; |
129 | if (!_currentItem) return; | 129 | if (!_currentItem) return; |
130 | QString file = _currentItem->getFile(); | 130 | QString file = _currentItem->getFile(); |
131 | QString group = _currentItem->getGroup(); | 131 | QString group = _currentItem->getGroup(); |
132 | QString key = _currentItem->getKey(); | 132 | QString key = _currentItem->getKey(); |
133 | QString val = _currentItem->getValue(); | 133 | QString val = _currentItem->getValue(); |
134 | editor->TextFileName->setText(file); | 134 | editor->TextFileName->setText(file); |
135 | editor->LineEditGroup->setText(group); | 135 | editor->LineEditGroup->setText(group); |
136 | if (!key.isEmpty()) | 136 | if (!key.isEmpty()) |
137 | { | 137 | { |
138 | editor->layoutType(EditWidget::Entry); | 138 | editor->layoutType(EditWidget::Entry); |
139 | editor->LineEditKey->setText(key); | 139 | editor->LineEditKey->setText(key); |
140 | editor->LineEditValue->setText(val); | 140 | editor->LineEditValue->setText(val); |
141 | }else{ | 141 | }else{ |
142 | editor->layoutType(EditWidget::Group); | 142 | editor->layoutType(EditWidget::Group); |
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
147 | void MainWindow::groupChanged(const QString &g) | 147 | void MainWindow::groupChanged(const QString &g) |
148 | { | 148 | { |
149 | if (!_currentItem) return; | 149 | if (!_currentItem) return; |
150 | _currentItem->setGroup(g); | 150 | _currentItem->setGroup(g); |
151 | } | 151 | } |
152 | 152 | ||
153 | void MainWindow::keyChanged(const QString &k) | 153 | void MainWindow::keyChanged(const QString &k) |
154 | { | 154 | { |
155 | if (!_currentItem) return; | 155 | if (!_currentItem) return; |
156 | _currentItem->keyChanged(k); | 156 | _currentItem->keyChanged(k); |
157 | } | 157 | } |
158 | 158 | ||
159 | void MainWindow::valueChanged(const QString &v) | 159 | void MainWindow::valueChanged(const QString &v) |
160 | { | 160 | { |
161 | if (!_currentItem) return; | 161 | if (!_currentItem) return; |
162 | _currentItem->valueChanged(v); | 162 | _currentItem->valueChanged(v); |
163 | } | 163 | } |
164 | 164 | ||
165 | 165 | ||
166 | void MainWindow::stopTimer( QListViewItem* ) | 166 | void MainWindow::stopTimer( QListViewItem* ) |
167 | { | 167 | { |
168 | popupTimer->stop(); | 168 | popupTimer->stop(); |
169 | } | 169 | } |
170 | 170 | ||
171 | void MainWindow::saveConfFile() | 171 | void MainWindow::saveConfFile() |
172 | { | 172 | { |
173 | if (!_fileItem) return; | 173 | if (!_fileItem) return; |
174 | _fileItem->save(); | 174 | _fileItem->save(); |
175 | } | 175 | } |
176 | 176 | ||
177 | void MainWindow::revertConfFile() | 177 | void MainWindow::revertConfFile() |
178 | { | 178 | { |
179 | if (!_item) return; | 179 | if (!_item) return; |
180 | _item->revert(); | 180 | _item->revert(); |
181 | } | 181 | } |
182 | 182 | ||
183 | void MainWindow::removeConfFile() | 183 | void MainWindow::removeConfFile() |
184 | { | 184 | { |
185 | if (!_item) return; | 185 | if (!_item) return; |
186 | _item->remove(); | 186 | _item->remove(); |
187 | } | 187 | } |
188 | 188 | ||
189 | void MainWindow::showPopup() | 189 | void MainWindow::showPopup() |
190 | { | 190 | { |
191 | qDebug("showPopup"); | 191 | qDebug("showPopup"); |
192 | if (!_item) return; | 192 | if (!_item) return; |
193 | popupActionRevert->setEnabled(_item->revertable()); | 193 | popupActionRevert->setEnabled(_item->revertable()); |
194 | popupActionSave->setEnabled(_item->isChanged()); | 194 | popupActionSave->setEnabled(_item->isChanged()); |
195 | if (_fileItem) | 195 | if (_fileItem) |
196 | { | 196 | { |
197 | popupActionSave->setEnabled(_fileItem->isChanged()); | 197 | popupActionSave->setEnabled(_fileItem->isChanged()); |
198 | popupMenuFile->popup( QCursor::pos() ); | 198 | popupMenuFile->popup( QCursor::pos() ); |
199 | }else if(_currentItem) | 199 | }else if(_currentItem) |
200 | { | 200 | { |
201 | popupMenuEntry->popup( QCursor::pos() ); | 201 | popupMenuEntry->popup( QCursor::pos() ); |
202 | } | 202 | } |
203 | } | 203 | } |
diff --git a/noncore/apps/confedit/mainwindow.h b/noncore/apps/confedit/mainwindow.h index 5be4a86..878558a 100644 --- a/noncore/apps/confedit/mainwindow.h +++ b/noncore/apps/confedit/mainwindow.h | |||
@@ -1,68 +1,68 @@ | |||
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 | 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 <qdialog.h> |
17 | #include <qaction.h> | 17 | #include <qaction.h> |
18 | #include <qtimer.h> | 18 | #include <qtimer.h> |
19 | #include <qpopupmenu.h> | 19 | #include <qpopupmenu.h> |
20 | #include "editwidget.h" | 20 | #include "editwidget.h" |
21 | 21 | ||
22 | class QPEToolBar; | 22 | class QPEToolBar; |
23 | class ListViewItemConfFile; | 23 | class ListViewItemConfFile; |
24 | class ListViewConfDir; | 24 | class ListViewConfDir; |
25 | class ListViewItemConf; | 25 | class ListViewItemConf; |
26 | 26 | ||
27 | class MainWindow : public QDialog//QMainWindow | 27 | class MainWindow : public QMainWindow |
28 | { | 28 | { |
29 | Q_OBJECT | 29 | Q_OBJECT |
30 | 30 | ||
31 | 31 | ||
32 | public: | 32 | public: |
33 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 33 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
34 | ~MainWindow(); | 34 | ~MainWindow(); |
35 | 35 | ||
36 | 36 | ||
37 | public slots: | 37 | public slots: |
38 | void setCurrent(QListViewItem*); | 38 | void setCurrent(QListViewItem*); |
39 | void groupChanged(const QString&); | 39 | void groupChanged(const QString&); |
40 | void keyChanged(const QString&); | 40 | void keyChanged(const QString&); |
41 | void valueChanged(const QString&); | 41 | void valueChanged(const QString&); |
42 | void showPopup(); | 42 | void showPopup(); |
43 | void stopTimer( QListViewItem* ); | 43 | void stopTimer( QListViewItem* ); |
44 | void saveConfFile(); | 44 | void saveConfFile(); |
45 | void revertConfFile(); | 45 | void revertConfFile(); |
46 | void removeConfFile(); | 46 | void removeConfFile(); |
47 | 47 | ||
48 | private: | 48 | private: |
49 | ListViewConfDir *settingList; | 49 | ListViewConfDir *settingList; |
50 | EditWidget *editor; | 50 | EditWidget *editor; |
51 | QVBoxLayout *mainLayout; | 51 | QVBoxLayout *mainLayout; |
52 | ListViewItemConf *_item; | 52 | ListViewItemConf *_item; |
53 | ListViewItemConfigEntry *_currentItem; | 53 | ListViewItemConfigEntry *_currentItem; |
54 | ListViewItemConfFile *_fileItem; | 54 | ListViewItemConfFile *_fileItem; |
55 | QTimer *popupTimer; | 55 | QTimer *popupTimer; |
56 | QPopupMenu *popupMenuFile; | 56 | QPopupMenu *popupMenuFile; |
57 | QPopupMenu *popupMenuEntry; | 57 | QPopupMenu *popupMenuEntry; |
58 | QAction *popupActionSave; | 58 | QAction *popupActionSave; |
59 | QAction *popupActionRevert; | 59 | QAction *popupActionRevert; |
60 | QAction *popupActionDelete; | 60 | QAction *popupActionDelete; |
61 | QAction *popupActionNew; | 61 | QAction *popupActionNew; |
62 | //QAction *popupAction; | 62 | //QAction *popupAction; |
63 | //QAction *popupAction; | 63 | //QAction *popupAction; |
64 | 64 | ||
65 | void makeMenu(); | 65 | void makeMenu(); |
66 | }; | 66 | }; |
67 | 67 | ||
68 | #endif | 68 | #endif |