summaryrefslogtreecommitdiff
path: root/noncore/apps/confedit/mainwindow.cpp
authortille <tille>2002-07-07 17:18:50 (UTC)
committer tille <tille>2002-07-07 17:18:50 (UTC)
commit04f29267e391eb4ad7ff9fc86468f6ccd1bd8f6d (patch) (unidiff)
tree91ed01ce29ec4dfd478f75239f874a22d1672a14 /noncore/apps/confedit/mainwindow.cpp
parenta72877e867e70784e3c865fa2948ac40f72b5c39 (diff)
downloadopie-04f29267e391eb4ad7ff9fc86468f6ccd1bd8f6d.zip
opie-04f29267e391eb4ad7ff9fc86468f6ccd1bd8f6d.tar.gz
opie-04f29267e391eb4ad7ff9fc86468f6ccd1bd8f6d.tar.bz2
better layout
Diffstat (limited to 'noncore/apps/confedit/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/confedit/mainwindow.cpp58
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
@@ -17,6 +17,7 @@
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>
@@ -34,34 +35,35 @@
34 35
35 36
36MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : 37MainWindow::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&) ) );
@@ -69,47 +71,36 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
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
80void MainWindow::makeMenu() 78void 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
115MainWindow::~MainWindow() 106MainWindow::~MainWindow()
@@ -120,19 +111,18 @@ MainWindow::~MainWindow()
120 111
121void MainWindow::setCurrent(QListViewItem *item) 112void 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;
@@ -144,15 +134,12 @@ void MainWindow::setCurrent(QListViewItem *item)
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
@@ -197,6 +184,7 @@ void MainWindow::removeConfFile()
197 if (!_item) return; 184 if (!_item) return;
198 _item->remove(); 185 _item->remove();
199} 186}
187
200void MainWindow::showPopup() 188void MainWindow::showPopup()
201{ 189{
202qDebug("showPopup"); 190qDebug("showPopup");