Diffstat (limited to 'noncore/apps/confedit/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/confedit/mainwindow.cpp | 65 |
1 files changed, 48 insertions, 17 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 @@ -42,3 +42,2 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : setCentralWidget( mainWidget); - QGridLayout *mainLayout = new QGridLayout( mainWidget ); @@ -48,8 +47,16 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : + 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*) ), @@ -64,3 +71,7 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : SLOT( valueChanged(const QString&) ) ); - makeMenu(); +// qDebug("editor->hide()"); +// editor->hide(); + qDebug("connect"); + connect( settingList, SIGNAL( clicked( QListViewItem* ) ), + this, SLOT( stopTimer( QListViewItem* ) ) ); } @@ -69,3 +80,3 @@ void MainWindow::makeMenu() { - + qDebug("MainWindow::makeMenu()"); @@ -73,9 +84,15 @@ void MainWindow::makeMenu() 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() ), @@ -83,6 +100,13 @@ void MainWindow::makeMenu() + 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"); } @@ -98,8 +122,7 @@ void MainWindow::setCurrent(QListViewItem *item) if (!item) return; - ListViewItemConf *i = (ListViewItemConf*) item; - if (!i) return; - if (i->getType() == ListViewItemConf::File) + _item = (ListViewItemConf*) item; + if (!_item) return; + popupTimer->start( 750, true ); + if (_item->getType() == ListViewItemConf::File) { - qDebug("start timer"); - popupTimer->start( 750, true ); editor->hide(); @@ -128,2 +151,4 @@ void MainWindow::setCurrent(QListViewItem *item) updateGeometry(); + editor->updateGeometry(); + settingList->updateGeometry(); } @@ -152,3 +177,2 @@ void MainWindow::stopTimer( QListViewItem* ) { - qDebug("stopTimer"); popupTimer->stop(); @@ -164,9 +188,17 @@ 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"); +qDebug("showPopup"); + if (!_item) return; + popupActionRevert->setEnabled(_item->revertable()); + popupActionSave->setEnabled(_item->isChanged()); if (_fileItem) @@ -174,7 +206,6 @@ void MainWindow::showPopup() popupActionSave->setEnabled(_fileItem->isChanged()); - popupActionRevert->setEnabled(_fileItem->revertable()); popupMenuFile->popup( QCursor::pos() ); - }else if(_currentItem->isChanged()) + }else if(_currentItem) { - + popupMenuEntry->popup( QCursor::pos() ); } |