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.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/apps/confedit/mainwindow.cpp b/noncore/apps/confedit/mainwindow.cpp
index 5f7ad50..6ef1043 100644
--- a/noncore/apps/confedit/mainwindow.cpp
+++ b/noncore/apps/confedit/mainwindow.cpp
@@ -1,148 +1,148 @@
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 <qlabel.h> 15#include <qlabel.h>
16#include <qlayout.h> 16#include <qlayout.h>
17#include <qlineedit.h> 17#include <qlineedit.h>
18 18
19#include "listviewconfdir.h" 19#include "listviewconfdir.h"
20#include "listviewitemconfigentry.h" 20#include "listviewitemconfigentry.h"
21 21
22 22
23MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : 23MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
24 QMainWindow( parent, name, f ), _currentItem(0), _fileItem(0) 24 QMainWindow( parent, name, f ), _currentItem(0), _fileItem(0)
25{ 25{
26 setCaption( tr("Conf File Editor") ); 26 setCaption( tr("Conf File Editor") );
27 27
28 //setBaseSize( qApp->globalStrut() ); 28 //setBaseSize( qApp->globalStrut() );
29 setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) ); 29 setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) );
30 30
31 mainLayout = new QVBoxLayout( this ); 31 mainLayout = new QVBoxLayout( this );
32 mainLayout->setSpacing( 0 ); 32 mainLayout->setSpacing( 0 );
33 mainLayout->setMargin( 0 ); 33 mainLayout->setMargin( 0 );
34 34
35 35
36 qDebug("creating settingList"); 36 qDebug("creating settingList");
37 settingList = new ListViewConfDir( QDir::homeDirPath() + "/Settings", this, "settingslist"); 37 settingList = new ListViewConfDir( QDir::homeDirPath() + "/Settings", this, "settingslist");
38 settingList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) ); 38 settingList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) );
39 mainLayout->addWidget( settingList, 0); 39 mainLayout->addWidget( settingList, 0);
40 40
41 qDebug("creating editor"); 41 qDebug("creating editor");
42 editor = new EditWidget(this); 42 editor = new EditWidget(this);
43 editor->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Maximum));//, sizePolicy().hasHeightForWidth() ) ); 43 editor->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Maximum));//, sizePolicy().hasHeightForWidth() ) );
44 mainLayout->addWidget( editor, 1 ); 44 mainLayout->addWidget( editor, 1 );
45 editor->layoutType( ListViewItemConf::File ); 45 editor->layoutType( ListViewItemConf::File );
46 46
47 makeMenu(); 47 makeMenu();
48 48
49 connect(settingList, SIGNAL( pressed(QListViewItem*) ), 49 connect(settingList, SIGNAL( pressed(QListViewItem*) ),
50 this, SLOT(setCurrent(QListViewItem*))); 50 this, SLOT(setCurrent(QListViewItem*)));
51 connect( settingList, SIGNAL( clicked( QListViewItem* ) ), 51 connect( settingList, SIGNAL( clicked(QListViewItem*) ),
52 this, SLOT( stopTimer( QListViewItem* ) ) ); 52 this, SLOT( stopTimer(QListViewItem*) ) );
53 53
54 connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ), 54 connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ),
55 SLOT( groupChanged(const QString&) ) ); 55 SLOT( groupChanged(const QString&) ) );
56 connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ), 56 connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ),
57 SLOT( keyChanged(const QString&) ) ); 57 SLOT( keyChanged(const QString&) ) );
58 connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ), 58 connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ),
59 SLOT( valueChanged(const QString&) ) ); 59 SLOT( valueChanged(const QString&) ) );
60 60
61 setCurrent(0); 61 setCurrent(0);
62 editor->layoutType(EditWidget::File); 62 editor->layoutType(EditWidget::File);
63} 63}
64 64
65void MainWindow::makeMenu() 65void MainWindow::makeMenu()
66{ 66{
67 popupTimer = new QTimer(this); 67 popupTimer = new QTimer(this);
68 popupMenuFile = new QPopupMenu(this); 68 popupMenuFile = new QPopupMenu(this);
69 popupMenuEntry = new QPopupMenu(this); 69 popupMenuEntry = new QPopupMenu(this);
70 70
71 popupActionSave = new QAction( tr("Save"),QString::null, 0, this, 0 ); 71 popupActionSave = new QAction( tr("Save"),QString::null, 0, this, 0 );
72 popupActionSave->addTo( popupMenuFile ); 72 popupActionSave->addTo( popupMenuFile );
73 // popupActionSave->addTo( popupMenuEntry ); 73 // popupActionSave->addTo( popupMenuEntry );
74 connect( popupActionSave, SIGNAL( activated() ), 74 connect( popupActionSave, SIGNAL( activated() ),
75 this , SLOT( saveConfFile() ) ); 75 this , SLOT( saveConfFile() ) );
76 76
77 popupActionRevert = new QAction( tr("Revert"),QString::null, 0, this, 0 ); 77 popupActionRevert = new QAction( tr("Revert"),QString::null, 0, this, 0 );
78 popupActionRevert->addTo( popupMenuFile ); 78 popupActionRevert->addTo( popupMenuFile );
79 popupActionRevert->addTo( popupMenuEntry ); 79 popupActionRevert->addTo( popupMenuEntry );
80 connect( popupActionRevert, SIGNAL( activated() ), 80 connect( popupActionRevert, SIGNAL( activated() ),
81 this , SLOT( revertConfFile() ) ); 81 this , SLOT( revertConfFile() ) );
82 82
83 popupActionDelete = new QAction( tr("Delete"),QString::null, 0, this, 0 ); 83 popupActionDelete = new QAction( tr("Delete"),QString::null, 0, this, 0 );
84 popupActionDelete->addTo( popupMenuFile ); 84 popupActionDelete->addTo( popupMenuFile );
85 popupActionDelete->addTo( popupMenuEntry ); 85 popupActionDelete->addTo( popupMenuEntry );
86 connect( popupActionDelete, SIGNAL( activated() ), 86 connect( popupActionDelete, SIGNAL( activated() ),
87 this , SLOT( removeConfFile() ) ); 87 this , SLOT( removeConfFile() ) );
88 88
89 connect( popupTimer, SIGNAL(timeout()), 89 connect( popupTimer, SIGNAL(timeout()),
90 this, SLOT(showPopup()) ); 90 this, SLOT(showPopup()) );
91} 91}
92 92
93MainWindow::~MainWindow() 93MainWindow::~MainWindow()
94{ 94{
95} 95}
96 96
97 97
98 98
99void MainWindow::setCurrent(QListViewItem *item) 99void MainWindow::setCurrent(QListViewItem *item)
100{ 100{
101 //qDebug("MainWindow::setCurrent"); 101 //qDebug("MainWindow::setCurrent");
102 if (!item) return; 102 if (!item) return;
103 _item = (ListViewItemConf*) item; 103 _item = (ListViewItemConf*) item;
104 if (!_item) return; 104 if (!_item) return;
105 popupTimer->start( 750, true ); 105 popupTimer->start( 750, true );
106 if (_item->getType() == ListViewItemConf::File) 106 if (_item->getType() == ListViewItemConf::File)
107 { 107 {
108 editor->layoutType(EditWidget::File); 108 editor->layoutType(EditWidget::File);
109 _currentItem=0; 109 _currentItem=0;
110 _fileItem = (ListViewItemConfFile*)item; 110 _fileItem = (ListViewItemConfFile*)item;
111 return; 111 return;
112 } 112 }
113 _fileItem = 0; 113 _fileItem = 0;
114 _currentItem = (ListViewItemConfigEntry*)item; 114 _currentItem = (ListViewItemConfigEntry*)item;
115 if (!_currentItem) return; 115 if (!_currentItem) return;
116 QString file = _currentItem->getFile(); 116 QString file = _currentItem->getFile();
117 QString group = _currentItem->getGroup(); 117 QString group = _currentItem->getGroup();
118 QString key = _currentItem->getKey(); 118 QString key = _currentItem->getKey();
119 QString val = _currentItem->getValue(); 119 QString val = _currentItem->getValue();
120 editor->TextFileName->setText(file); 120 editor->TextFileName->setText(file);
121 editor->LineEditGroup->setText(group); 121 editor->LineEditGroup->setText(group);
122 if (!key.isEmpty()) 122 if (!key.isEmpty())
123 { 123 {
124 editor->layoutType(EditWidget::Entry); 124 editor->layoutType(EditWidget::Entry);
125 editor->LineEditKey->setText(key); 125 editor->LineEditKey->setText(key);
126 editor->LineEditValue->setText(val); 126 editor->LineEditValue->setText(val);
127 }else{ 127 }else{
128 editor->layoutType(EditWidget::Group); 128 editor->layoutType(EditWidget::Group);
129 } 129 }
130} 130}
131 131
132 132
133void MainWindow::groupChanged(const QString &g) 133void MainWindow::groupChanged(const QString &g)
134{ 134{
135 if (!_currentItem) return; 135 if (!_currentItem) return;
136 _currentItem->setGroup(g); 136 _currentItem->setGroup(g);
137} 137}
138 138
139void MainWindow::keyChanged(const QString &k) 139void MainWindow::keyChanged(const QString &k)
140{ 140{
141 if (!_currentItem) return; 141 if (!_currentItem) return;
142 _currentItem->keyChanged(k); 142 _currentItem->keyChanged(k);
143} 143}
144 144
145void MainWindow::valueChanged(const QString &v) 145void MainWindow::valueChanged(const QString &v)
146{ 146{
147 if (!_currentItem) return; 147 if (!_currentItem) return;
148 _currentItem->valueChanged(v); 148 _currentItem->valueChanged(v);