summaryrefslogtreecommitdiff
path: root/noncore/apps/confedit/mainwindow.cpp
Unidiff
Diffstat (limited to 'noncore/apps/confedit/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/confedit/mainwindow.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/noncore/apps/confedit/mainwindow.cpp b/noncore/apps/confedit/mainwindow.cpp
index 6ef1043..4b04c97 100644
--- a/noncore/apps/confedit/mainwindow.cpp
+++ b/noncore/apps/confedit/mainwindow.cpp
@@ -1,65 +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 12
13#include "mainwindow.h" 13#include "mainwindow.h"
14#include "listviewconfdir.h"
15#include "listviewitemconfigentry.h"
14 16
17/* OPIE */
18#include <opie2/odebug.h>
19using namespace Opie::Core;
20
21/* QT */
15#include <qlabel.h> 22#include <qlabel.h>
16#include <qlayout.h> 23#include <qlayout.h>
17#include <qlineedit.h> 24#include <qlineedit.h>
18 25
19#include "listviewconfdir.h"
20#include "listviewitemconfigentry.h"
21
22
23MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : 26MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
24 QMainWindow( parent, name, f ), _currentItem(0), _fileItem(0) 27 QMainWindow( parent, name, f ), _currentItem(0), _fileItem(0)
25{ 28{
26 setCaption( tr("Conf File Editor") ); 29 setCaption( tr("Conf File Editor") );
27 30
28 //setBaseSize( qApp->globalStrut() ); 31 //setBaseSize( qApp->globalStrut() );
29 setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) ); 32 setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) );
30 33
31 mainLayout = new QVBoxLayout( this ); 34 mainLayout = new QVBoxLayout( this );
32 mainLayout->setSpacing( 0 ); 35 mainLayout->setSpacing( 0 );
33 mainLayout->setMargin( 0 ); 36 mainLayout->setMargin( 0 );
34 37
35 38
36 qDebug("creating settingList"); 39 odebug << "creating settingList" << oendl;
37 settingList = new ListViewConfDir( QDir::homeDirPath() + "/Settings", this, "settingslist"); 40 settingList = new ListViewConfDir( QDir::homeDirPath() + "/Settings", this, "settingslist");
38 settingList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) ); 41 settingList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) );
39 mainLayout->addWidget( settingList, 0); 42 mainLayout->addWidget( settingList, 0);
40 43
41 qDebug("creating editor"); 44 odebug << "creating editor" << oendl;
42 editor = new EditWidget(this); 45 editor = new EditWidget(this);
43 editor->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Maximum));//, sizePolicy().hasHeightForWidth() ) ); 46 editor->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Maximum));//, sizePolicy().hasHeightForWidth() ) );
44 mainLayout->addWidget( editor, 1 ); 47 mainLayout->addWidget( editor, 1 );
45 editor->layoutType( ListViewItemConf::File ); 48 editor->layoutType( ListViewItemConf::File );
46 49
47 makeMenu(); 50 makeMenu();
48 51
49 connect(settingList, SIGNAL( pressed(QListViewItem*) ), 52 connect(settingList, SIGNAL( pressed(QListViewItem*) ),
50 this, SLOT(setCurrent(QListViewItem*))); 53 this, SLOT(setCurrent(QListViewItem*)));
51 connect( settingList, SIGNAL( clicked(QListViewItem*) ), 54 connect( settingList, SIGNAL( clicked(QListViewItem*) ),
52 this, SLOT( stopTimer(QListViewItem*) ) ); 55 this, SLOT( stopTimer(QListViewItem*) ) );
53 56
54 connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ), 57 connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ),
55 SLOT( groupChanged(const QString&) ) ); 58 SLOT( groupChanged(const QString&) ) );
56 connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ), 59 connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ),
57 SLOT( keyChanged(const QString&) ) ); 60 SLOT( keyChanged(const QString&) ) );
58 connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ), 61 connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ),
59 SLOT( valueChanged(const QString&) ) ); 62 SLOT( valueChanged(const QString&) ) );
60 63
61 setCurrent(0); 64 setCurrent(0);
62 editor->layoutType(EditWidget::File); 65 editor->layoutType(EditWidget::File);
63} 66}
64 67
65void MainWindow::makeMenu() 68void MainWindow::makeMenu()
@@ -77,49 +80,49 @@ void MainWindow::makeMenu()
77 popupActionRevert = new QAction( tr("Revert"),QString::null, 0, this, 0 ); 80 popupActionRevert = new QAction( tr("Revert"),QString::null, 0, this, 0 );
78 popupActionRevert->addTo( popupMenuFile ); 81 popupActionRevert->addTo( popupMenuFile );
79 popupActionRevert->addTo( popupMenuEntry ); 82 popupActionRevert->addTo( popupMenuEntry );
80 connect( popupActionRevert, SIGNAL( activated() ), 83 connect( popupActionRevert, SIGNAL( activated() ),
81 this , SLOT( revertConfFile() ) ); 84 this , SLOT( revertConfFile() ) );
82 85
83 popupActionDelete = new QAction( tr("Delete"),QString::null, 0, this, 0 ); 86 popupActionDelete = new QAction( tr("Delete"),QString::null, 0, this, 0 );
84 popupActionDelete->addTo( popupMenuFile ); 87 popupActionDelete->addTo( popupMenuFile );
85 popupActionDelete->addTo( popupMenuEntry ); 88 popupActionDelete->addTo( popupMenuEntry );
86 connect( popupActionDelete, SIGNAL( activated() ), 89 connect( popupActionDelete, SIGNAL( activated() ),
87 this , SLOT( removeConfFile() ) ); 90 this , SLOT( removeConfFile() ) );
88 91
89 connect( popupTimer, SIGNAL(timeout()), 92 connect( popupTimer, SIGNAL(timeout()),
90 this, SLOT(showPopup()) ); 93 this, SLOT(showPopup()) );
91} 94}
92 95
93MainWindow::~MainWindow() 96MainWindow::~MainWindow()
94{ 97{
95} 98}
96 99
97 100
98 101
99void MainWindow::setCurrent(QListViewItem *item) 102void MainWindow::setCurrent(QListViewItem *item)
100{ 103{
101 //qDebug("MainWindow::setCurrent"); 104 //odebug << "MainWindow::setCurrent" << oendl;
102 if (!item) return; 105 if (!item) return;
103 _item = (ListViewItemConf*) item; 106 _item = (ListViewItemConf*) item;
104 if (!_item) return; 107 if (!_item) return;
105 popupTimer->start( 750, true ); 108 popupTimer->start( 750, true );
106 if (_item->getType() == ListViewItemConf::File) 109 if (_item->getType() == ListViewItemConf::File)
107 { 110 {
108 editor->layoutType(EditWidget::File); 111 editor->layoutType(EditWidget::File);
109 _currentItem=0; 112 _currentItem=0;
110 _fileItem = (ListViewItemConfFile*)item; 113 _fileItem = (ListViewItemConfFile*)item;
111 return; 114 return;
112 } 115 }
113 _fileItem = 0; 116 _fileItem = 0;
114 _currentItem = (ListViewItemConfigEntry*)item; 117 _currentItem = (ListViewItemConfigEntry*)item;
115 if (!_currentItem) return; 118 if (!_currentItem) return;
116 QString file = _currentItem->getFile(); 119 QString file = _currentItem->getFile();
117 QString group = _currentItem->getGroup(); 120 QString group = _currentItem->getGroup();
118 QString key = _currentItem->getKey(); 121 QString key = _currentItem->getKey();
119 QString val = _currentItem->getValue(); 122 QString val = _currentItem->getValue();
120 editor->TextFileName->setText(file); 123 editor->TextFileName->setText(file);
121 editor->LineEditGroup->setText(group); 124 editor->LineEditGroup->setText(group);
122 if (!key.isEmpty()) 125 if (!key.isEmpty())
123 { 126 {
124 editor->layoutType(EditWidget::Entry); 127 editor->layoutType(EditWidget::Entry);
125 editor->LineEditKey->setText(key); 128 editor->LineEditKey->setText(key);
@@ -153,37 +156,37 @@ void MainWindow::stopTimer( QListViewItem* )
153{ 156{
154 popupTimer->stop(); 157 popupTimer->stop();
155} 158}
156 159
157void MainWindow::saveConfFile() 160void MainWindow::saveConfFile()
158{ 161{
159 if (!_fileItem) return; 162 if (!_fileItem) return;
160 _fileItem->save(); 163 _fileItem->save();
161} 164}
162 165
163void MainWindow::revertConfFile() 166void MainWindow::revertConfFile()
164{ 167{
165 if (!_item) return; 168 if (!_item) return;
166 _item->revert(); 169 _item->revert();
167} 170}
168 171
169void MainWindow::removeConfFile() 172void MainWindow::removeConfFile()
170{ 173{
171 if (!_item) return; 174 if (!_item) return;
172 _item->remove(); 175 _item->remove();
173} 176}
174 177
175void MainWindow::showPopup() 178void MainWindow::showPopup()
176{ 179{
177qDebug("showPopup"); 180odebug << "showPopup" << oendl;
178 if (!_item) return; 181 if (!_item) return;
179 popupActionRevert->setEnabled(_item->revertable()); 182 popupActionRevert->setEnabled(_item->revertable());
180 popupActionSave->setEnabled(_item->isChanged()); 183 popupActionSave->setEnabled(_item->isChanged());
181 if (_fileItem) 184 if (_fileItem)
182 { 185 {
183 popupActionSave->setEnabled(_fileItem->isChanged()); 186 popupActionSave->setEnabled(_fileItem->isChanged());
184 popupMenuFile->popup( QCursor::pos() ); 187 popupMenuFile->popup( QCursor::pos() );
185 }else if(_currentItem) 188 }else if(_currentItem)
186 { 189 {
187 popupMenuEntry->popup( QCursor::pos() ); 190 popupMenuEntry->popup( QCursor::pos() );
188 } 191 }
189} 192}