author | tille <tille> | 2002-07-07 17:18:50 (UTC) |
---|---|---|
committer | tille <tille> | 2002-07-07 17:18:50 (UTC) |
commit | 04f29267e391eb4ad7ff9fc86468f6ccd1bd8f6d (patch) (side-by-side diff) | |
tree | 91ed01ce29ec4dfd478f75239f874a22d1672a14 /noncore/apps/confedit/mainwindow.cpp | |
parent | a72877e867e70784e3c865fa2948ac40f72b5c39 (diff) | |
download | opie-04f29267e391eb4ad7ff9fc86468f6ccd1bd8f6d.zip opie-04f29267e391eb4ad7ff9fc86468f6ccd1bd8f6d.tar.gz opie-04f29267e391eb4ad7ff9fc86468f6ccd1bd8f6d.tar.bz2 |
better layout
Diffstat (limited to 'noncore/apps/confedit/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/confedit/mainwindow.cpp | 58 |
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 @@ -14,12 +14,13 @@ #include <qpe/qpemenubar.h> #include <qpe/qpemessagebox.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qpe/qpetoolbar.h> +#include <qpe/qpeapplication.h> #include <qaction.h> #include <qmessagebox.h> #include <qpopupmenu.h> #include <qtoolbutton.h> #include <qstring.h> #include <qlabel.h> @@ -31,131 +32,117 @@ #include "listviewconfdir.h" #include "listviewitemconf.h" #include "listviewitemconfigentry.h" MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : - QMainWindow( parent, name, f ), _currentItem(0), _fileItem(0) + QDialog( parent, name, f ), _currentItem(0), _fileItem(0) { setCaption( tr("Conf File Editor") ); - QWidget *mainWidget = new QWidget(this); - setCentralWidget( mainWidget); - QGridLayout *mainLayout = new QGridLayout( mainWidget ); - mainLayout->setSpacing( 3 ); - mainLayout->setMargin( 3 ); +// setBaseSize( qApp->globalStrut() ); + setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) ); + mainLayout = new QVBoxLayout( this ); + mainLayout->setSpacing( 0 ); + mainLayout->setMargin( 0 ); - qDebug("settingList"); + + qDebug("creating settingList"); settingList = new ListViewConfDir( "/root/Settings/", this, "settingslist"); - settingList->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding));//, sizePolicy().hasHeightForWidth() ) ); - mainLayout->addWidget( settingList, 0, 0 ); + settingList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) ); + mainLayout->addWidget( settingList, 0); - qDebug("editor"); + qDebug("creating editor"); editor = new EditWidget(this); - editor->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum));//, sizePolicy().hasHeightForWidth() ) ); -// editor->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)3));//, sizePolicy().hasHeightForWidth() ) ); - mainLayout->addWidget( editor, 1, 0 ); + editor->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Maximum));//, sizePolicy().hasHeightForWidth() ) ); + mainLayout->addWidget( editor, 1 ); + editor->layoutType( ListViewItemConf::File ); makeMenu(); - qDebug("connect"); connect(settingList, SIGNAL( pressed(QListViewItem*) ), this, SLOT(setCurrent(QListViewItem*))); - + connect( settingList, SIGNAL( clicked( QListViewItem* ) ), + this, SLOT( stopTimer( QListViewItem* ) ) ); connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ), SLOT( groupChanged(const QString&) ) ); connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ), SLOT( keyChanged(const QString&) ) ); connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ), SLOT( valueChanged(const QString&) ) ); -// qDebug("editor->hide()"); -// editor->hide(); - qDebug("connect"); - connect( settingList, SIGNAL( clicked( QListViewItem* ) ), - this, SLOT( stopTimer( QListViewItem* ) ) ); + setCurrent(0); } void MainWindow::makeMenu() { - qDebug("MainWindow::makeMenu()"); - popupTimer = new QTimer(this); popupMenuFile = new QPopupMenu(this); popupMenuEntry = new QPopupMenu(this); - qDebug("Save"); popupActionSave = new QAction( tr("Save"),QString::null, 0, this, 0 ); popupActionSave->addTo( popupMenuFile ); // popupActionSave->addTo( popupMenuEntry ); connect( popupActionSave, SIGNAL( activated() ), this , SLOT( saveConfFile() ) ); - qDebug("Revert"); popupActionRevert = new QAction( tr("Revert"),QString::null, 0, this, 0 ); popupActionRevert->addTo( popupMenuFile ); popupActionRevert->addTo( popupMenuEntry ); connect( popupActionRevert, SIGNAL( activated() ), this , SLOT( revertConfFile() ) ); - qDebug("Delete"); popupActionDelete = new QAction( tr("Delete"),QString::null, 0, this, 0 ); popupActionDelete->addTo( popupMenuFile ); popupActionDelete->addTo( popupMenuEntry ); connect( popupActionDelete, SIGNAL( activated() ), this , SLOT( removeConfFile() ) ); - qDebug("connect"); connect( popupTimer, SIGNAL(timeout()), this, SLOT(showPopup()) ); - qDebug("connect"); } MainWindow::~MainWindow() { } void MainWindow::setCurrent(QListViewItem *item) { - editor->hide(); +// qDebug("MainWindow::setCurrent"); if (!item) return; _item = (ListViewItemConf*) item; if (!_item) return; popupTimer->start( 750, true ); if (_item->getType() == ListViewItemConf::File) { - updateGeometry(); + editor->layoutType(EditWidget::File); _currentItem=0; _fileItem = (ListViewItemConfFile*)item; return; } - editor->show(); _fileItem = 0; _currentItem = (ListViewItemConfigEntry*)item; if (!_currentItem) return; QString file = _currentItem->getFile(); QString group = _currentItem->getGroup(); QString key = _currentItem->getKey(); QString val = _currentItem->getValue(); editor->TextFileName->setText(file); editor->LineEditGroup->setText(group); if (!key.isEmpty()) { - editor->isKey(true); + editor->layoutType(EditWidget::Entry); editor->LineEditKey->setText(key); editor->LineEditValue->setText(val); }else{ - editor->isKey(false); + editor->layoutType(EditWidget::Group); } - updateGeometry(); - editor->updateGeometry(); - settingList->updateGeometry(); } void MainWindow::groupChanged(const QString &g) { if (!_currentItem) return; @@ -194,12 +181,13 @@ void MainWindow::revertConfFile() void MainWindow::removeConfFile() { if (!_item) return; _item->remove(); } + void MainWindow::showPopup() { qDebug("showPopup"); if (!_item) return; popupActionRevert->setEnabled(_item->revertable()); popupActionSave->setEnabled(_item->isChanged()); |