author | tille <tille> | 2002-06-30 01:05:42 (UTC) |
---|---|---|
committer | tille <tille> | 2002-06-30 01:05:42 (UTC) |
commit | 064b3d7b91a526a64c22facba228e3c2fec8fdc8 (patch) (side-by-side diff) | |
tree | 98221da79a27bc13b8214b92c8c936c529312e24 /noncore/apps/confedit/mainwindow.cpp | |
parent | 1f9e13bb2d287a2495e2cbb0f8be0f53c883eae2 (diff) | |
download | opie-064b3d7b91a526a64c22facba228e3c2fec8fdc8.zip opie-064b3d7b91a526a64c22facba228e3c2fec8fdc8.tar.gz opie-064b3d7b91a526a64c22facba228e3c2fec8fdc8.tar.bz2 |
late night
Diffstat (limited to 'noncore/apps/confedit/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/confedit/mainwindow.cpp | 63 |
1 files changed, 47 insertions, 16 deletions
diff --git a/noncore/apps/confedit/mainwindow.cpp b/noncore/apps/confedit/mainwindow.cpp index 77b91f6..17a5058 100644 --- a/noncore/apps/confedit/mainwindow.cpp +++ b/noncore/apps/confedit/mainwindow.cpp @@ -40,18 +40,25 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : QWidget *mainWidget = new QWidget(this); setCentralWidget( mainWidget); - QGridLayout *mainLayout = new QGridLayout( mainWidget ); mainLayout->setSpacing( 3 ); mainLayout->setMargin( 3 ); + qDebug("settingList"); settingList = new ListViewConfDir( "/root/Settings/", this, "settingslist"); + settingList->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding));//, sizePolicy().hasHeightForWidth() ) ); mainLayout->addWidget( settingList, 0, 0 ); + qDebug("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 ); + makeMenu(); + + qDebug("connect"); connect(settingList, SIGNAL( pressed(QListViewItem*) ), this, SLOT(setCurrent(QListViewItem*))); @@ -62,29 +69,46 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : SLOT( keyChanged(const QString&) ) ); connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ), SLOT( valueChanged(const QString&) ) ); - makeMenu(); +// qDebug("editor->hide()"); +// editor->hide(); + qDebug("connect"); + connect( settingList, SIGNAL( clicked( QListViewItem* ) ), + this, SLOT( stopTimer( QListViewItem* ) ) ); } 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()) ); - connect( settingList, SIGNAL( clicked( QListViewItem* ) ), - this, SLOT( stopTimer( QListViewItem* ) ) ); + qDebug("connect"); } MainWindow::~MainWindow() @@ -96,12 +120,11 @@ MainWindow::~MainWindow() void MainWindow::setCurrent(QListViewItem *item) { if (!item) return; - ListViewItemConf *i = (ListViewItemConf*) item; - if (!i) return; - if (i->getType() == ListViewItemConf::File) - { - qDebug("start timer"); + _item = (ListViewItemConf*) item; + if (!_item) return; popupTimer->start( 750, true ); + if (_item->getType() == ListViewItemConf::File) + { editor->hide(); updateGeometry(); _currentItem=0; @@ -126,6 +149,8 @@ void MainWindow::setCurrent(QListViewItem *item) editor->isKey(false); } updateGeometry(); + editor->updateGeometry(); + settingList->updateGeometry(); } @@ -150,7 +175,6 @@ void MainWindow::valueChanged(const QString &v) void MainWindow::stopTimer( QListViewItem* ) { - qDebug("stopTimer"); popupTimer->stop(); } @@ -162,20 +186,27 @@ void MainWindow::saveConfFile() void MainWindow::revertConfFile() { - if (!_fileItem) return; - _fileItem->revert(); + if (!_item) return; + _item->revert(); } +void MainWindow::removeConfFile() +{ + if (!_item) return; + _item->remove(); +} void MainWindow::showPopup() { qDebug("showPopup"); + if (!_item) return; + popupActionRevert->setEnabled(_item->revertable()); + popupActionSave->setEnabled(_item->isChanged()); if (_fileItem) { popupActionSave->setEnabled(_fileItem->isChanged()); - popupActionRevert->setEnabled(_fileItem->revertable()); popupMenuFile->popup( QCursor::pos() ); - }else if(_currentItem->isChanged()) + }else if(_currentItem) { - + popupMenuEntry->popup( QCursor::pos() ); } } |