summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/confedit/mainwindow.cpp1
1 files changed, 0 insertions, 1 deletions
diff --git a/noncore/apps/confedit/mainwindow.cpp b/noncore/apps/confedit/mainwindow.cpp
index 45dbcb4..3b8042f 100644
--- a/noncore/apps/confedit/mainwindow.cpp
+++ b/noncore/apps/confedit/mainwindow.cpp
@@ -1,204 +1,203 @@
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#include <stdlib.h>
37 36
38MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : 37MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
39 QDialog( parent, name, f ), _currentItem(0), _fileItem(0) 38 QDialog( parent, name, f ), _currentItem(0), _fileItem(0)
40 { 39 {
41 setCaption( tr("Conf File Editor") ); 40 setCaption( tr("Conf File Editor") );
42 41
43 //setBaseSize( qApp->globalStrut() ); 42 //setBaseSize( qApp->globalStrut() );
44 setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) ); 43 setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) );
45 44
46 mainLayout = new QVBoxLayout( this ); 45 mainLayout = new QVBoxLayout( this );
47 mainLayout->setSpacing( 0 ); 46 mainLayout->setSpacing( 0 );
48 mainLayout->setMargin( 0 ); 47 mainLayout->setMargin( 0 );
49 48
50 49
51 qDebug("creating settingList"); 50 qDebug("creating settingList");
52 settingList = new ListViewConfDir( QDir::homeDirPath() + "/Settings", this, "settingslist"); 51 settingList = new ListViewConfDir( QDir::homeDirPath() + "/Settings", this, "settingslist");
53 settingList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) ); 52 settingList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) );
54 mainLayout->addWidget( settingList, 0); 53 mainLayout->addWidget( settingList, 0);
55 54
56 qDebug("creating editor"); 55 qDebug("creating editor");
57 editor = new EditWidget(this); 56 editor = new EditWidget(this);
58 editor->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Maximum));//, sizePolicy().hasHeightForWidth() ) ); 57 editor->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Maximum));//, sizePolicy().hasHeightForWidth() ) );
59 mainLayout->addWidget( editor, 1 ); 58 mainLayout->addWidget( editor, 1 );
60 editor->layoutType( ListViewItemConf::File ); 59 editor->layoutType( ListViewItemConf::File );
61 60
62 makeMenu(); 61 makeMenu();
63 62
64 connect(settingList, SIGNAL( pressed(QListViewItem*) ), 63 connect(settingList, SIGNAL( pressed(QListViewItem*) ),
65 this, SLOT(setCurrent(QListViewItem*))); 64 this, SLOT(setCurrent(QListViewItem*)));
66 connect( settingList, SIGNAL( clicked( QListViewItem* ) ), 65 connect( settingList, SIGNAL( clicked( QListViewItem* ) ),
67 this, SLOT( stopTimer( QListViewItem* ) ) ); 66 this, SLOT( stopTimer( QListViewItem* ) ) );
68 67
69 connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ), 68 connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ),
70 SLOT( groupChanged(const QString&) ) ); 69 SLOT( groupChanged(const QString&) ) );
71 connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ), 70 connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ),
72 SLOT( keyChanged(const QString&) ) ); 71 SLOT( keyChanged(const QString&) ) );
73 connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ), 72 connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ),
74 SLOT( valueChanged(const QString&) ) ); 73 SLOT( valueChanged(const QString&) ) );
75 74
76 setCurrent(0); 75 setCurrent(0);
77 editor->layoutType(EditWidget::File); 76 editor->layoutType(EditWidget::File);
78} 77}
79 78
80void MainWindow::makeMenu() 79void MainWindow::makeMenu()
81{ 80{
82 popupTimer = new QTimer(this); 81 popupTimer = new QTimer(this);
83 popupMenuFile = new QPopupMenu(this); 82 popupMenuFile = new QPopupMenu(this);
84 popupMenuEntry = new QPopupMenu(this); 83 popupMenuEntry = new QPopupMenu(this);
85 84
86 popupActionSave = new QAction( tr("Save"),QString::null, 0, this, 0 ); 85 popupActionSave = new QAction( tr("Save"),QString::null, 0, this, 0 );
87 popupActionSave->addTo( popupMenuFile ); 86 popupActionSave->addTo( popupMenuFile );
88 // popupActionSave->addTo( popupMenuEntry ); 87 // popupActionSave->addTo( popupMenuEntry );
89 connect( popupActionSave, SIGNAL( activated() ), 88 connect( popupActionSave, SIGNAL( activated() ),
90 this , SLOT( saveConfFile() ) ); 89 this , SLOT( saveConfFile() ) );
91 90
92 popupActionRevert = new QAction( tr("Revert"),QString::null, 0, this, 0 ); 91 popupActionRevert = new QAction( tr("Revert"),QString::null, 0, this, 0 );
93 popupActionRevert->addTo( popupMenuFile ); 92 popupActionRevert->addTo( popupMenuFile );
94 popupActionRevert->addTo( popupMenuEntry ); 93 popupActionRevert->addTo( popupMenuEntry );
95 connect( popupActionRevert, SIGNAL( activated() ), 94 connect( popupActionRevert, SIGNAL( activated() ),
96 this , SLOT( revertConfFile() ) ); 95 this , SLOT( revertConfFile() ) );
97 96
98 popupActionDelete = new QAction( tr("Delete"),QString::null, 0, this, 0 ); 97 popupActionDelete = new QAction( tr("Delete"),QString::null, 0, this, 0 );
99 popupActionDelete->addTo( popupMenuFile ); 98 popupActionDelete->addTo( popupMenuFile );
100 popupActionDelete->addTo( popupMenuEntry ); 99 popupActionDelete->addTo( popupMenuEntry );
101 connect( popupActionDelete, SIGNAL( activated() ), 100 connect( popupActionDelete, SIGNAL( activated() ),
102 this , SLOT( removeConfFile() ) ); 101 this , SLOT( removeConfFile() ) );
103 102
104 connect( popupTimer, SIGNAL(timeout()), 103 connect( popupTimer, SIGNAL(timeout()),
105 this, SLOT(showPopup()) ); 104 this, SLOT(showPopup()) );
106} 105}
107 106
108MainWindow::~MainWindow() 107MainWindow::~MainWindow()
109{ 108{
110} 109}
111 110
112 111
113 112
114void MainWindow::setCurrent(QListViewItem *item) 113void MainWindow::setCurrent(QListViewItem *item)
115{ 114{
116 //qDebug("MainWindow::setCurrent"); 115 //qDebug("MainWindow::setCurrent");
117 if (!item) return; 116 if (!item) return;
118 _item = (ListViewItemConf*) item; 117 _item = (ListViewItemConf*) item;
119 if (!_item) return; 118 if (!_item) return;
120 popupTimer->start( 750, true ); 119 popupTimer->start( 750, true );
121 if (_item->getType() == ListViewItemConf::File) 120 if (_item->getType() == ListViewItemConf::File)
122 { 121 {
123 editor->layoutType(EditWidget::File); 122 editor->layoutType(EditWidget::File);
124 _currentItem=0; 123 _currentItem=0;
125 _fileItem = (ListViewItemConfFile*)item; 124 _fileItem = (ListViewItemConfFile*)item;
126 return; 125 return;
127 } 126 }
128 _fileItem = 0; 127 _fileItem = 0;
129 _currentItem = (ListViewItemConfigEntry*)item; 128 _currentItem = (ListViewItemConfigEntry*)item;
130 if (!_currentItem) return; 129 if (!_currentItem) return;
131 QString file = _currentItem->getFile(); 130 QString file = _currentItem->getFile();
132 QString group = _currentItem->getGroup(); 131 QString group = _currentItem->getGroup();
133 QString key = _currentItem->getKey(); 132 QString key = _currentItem->getKey();
134 QString val = _currentItem->getValue(); 133 QString val = _currentItem->getValue();
135 editor->TextFileName->setText(file); 134 editor->TextFileName->setText(file);
136 editor->LineEditGroup->setText(group); 135 editor->LineEditGroup->setText(group);
137 if (!key.isEmpty()) 136 if (!key.isEmpty())
138 { 137 {
139 editor->layoutType(EditWidget::Entry); 138 editor->layoutType(EditWidget::Entry);
140 editor->LineEditKey->setText(key); 139 editor->LineEditKey->setText(key);
141 editor->LineEditValue->setText(val); 140 editor->LineEditValue->setText(val);
142 }else{ 141 }else{
143 editor->layoutType(EditWidget::Group); 142 editor->layoutType(EditWidget::Group);
144 } 143 }
145} 144}
146 145
147 146
148void MainWindow::groupChanged(const QString &g) 147void MainWindow::groupChanged(const QString &g)
149{ 148{
150 if (!_currentItem) return; 149 if (!_currentItem) return;
151 _currentItem->setGroup(g); 150 _currentItem->setGroup(g);
152} 151}
153 152
154void MainWindow::keyChanged(const QString &k) 153void MainWindow::keyChanged(const QString &k)
155{ 154{
156 if (!_currentItem) return; 155 if (!_currentItem) return;
157 _currentItem->keyChanged(k); 156 _currentItem->keyChanged(k);
158} 157}
159 158
160void MainWindow::valueChanged(const QString &v) 159void MainWindow::valueChanged(const QString &v)
161{ 160{
162 if (!_currentItem) return; 161 if (!_currentItem) return;
163 _currentItem->valueChanged(v); 162 _currentItem->valueChanged(v);
164} 163}
165 164
166 165
167void MainWindow::stopTimer( QListViewItem* ) 166void MainWindow::stopTimer( QListViewItem* )
168{ 167{
169 popupTimer->stop(); 168 popupTimer->stop();
170} 169}
171 170
172void MainWindow::saveConfFile() 171void MainWindow::saveConfFile()
173{ 172{
174 if (!_fileItem) return; 173 if (!_fileItem) return;
175 _fileItem->save(); 174 _fileItem->save();
176} 175}
177 176
178void MainWindow::revertConfFile() 177void MainWindow::revertConfFile()
179{ 178{
180 if (!_item) return; 179 if (!_item) return;
181 _item->revert(); 180 _item->revert();
182} 181}
183 182
184void MainWindow::removeConfFile() 183void MainWindow::removeConfFile()
185{ 184{
186 if (!_item) return; 185 if (!_item) return;
187 _item->remove(); 186 _item->remove();
188} 187}
189 188
190void MainWindow::showPopup() 189void MainWindow::showPopup()
191{ 190{
192qDebug("showPopup"); 191qDebug("showPopup");
193 if (!_item) return; 192 if (!_item) return;
194 popupActionRevert->setEnabled(_item->revertable()); 193 popupActionRevert->setEnabled(_item->revertable());
195 popupActionSave->setEnabled(_item->isChanged()); 194 popupActionSave->setEnabled(_item->isChanged());
196 if (_fileItem) 195 if (_fileItem)
197 { 196 {
198 popupActionSave->setEnabled(_fileItem->isChanged()); 197 popupActionSave->setEnabled(_fileItem->isChanged());
199 popupMenuFile->popup( QCursor::pos() ); 198 popupMenuFile->popup( QCursor::pos() );
200 }else if(_currentItem) 199 }else if(_currentItem)
201 { 200 {
202 popupMenuEntry->popup( QCursor::pos() ); 201 popupMenuEntry->popup( QCursor::pos() );
203 } 202 }
204} 203}