author | tille <tille> | 2002-06-29 23:23:09 (UTC) |
---|---|---|
committer | tille <tille> | 2002-06-29 23:23:09 (UTC) |
commit | 0f179c0cc471b659b30dec4762c9c36678063f31 (patch) (side-by-side diff) | |
tree | 5350dc3b1c05991953011d01ad19cb12414abc1a /noncore/apps/confedit/mainwindow.cpp | |
parent | eb02223de534d315bfdcb0d521719c2d2e9a7235 (diff) | |
download | opie-0f179c0cc471b659b30dec4762c9c36678063f31.zip opie-0f179c0cc471b659b30dec4762c9c36678063f31.tar.gz opie-0f179c0cc471b659b30dec4762c9c36678063f31.tar.bz2 |
revert
Diffstat (limited to 'noncore/apps/confedit/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/confedit/mainwindow.cpp | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/noncore/apps/confedit/mainwindow.cpp b/noncore/apps/confedit/mainwindow.cpp index 47d9518..77b91f6 100644 --- a/noncore/apps/confedit/mainwindow.cpp +++ b/noncore/apps/confedit/mainwindow.cpp @@ -38,9 +38,6 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : { setCaption( tr("Conf File Editor") ); - popupTimer = new QTimer(this); - popupMenu = new QPopupMenu(this); - QWidget *mainWidget = new QWidget(this); setCentralWidget( mainWidget); @@ -58,10 +55,6 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : connect(settingList, SIGNAL( pressed(QListViewItem*) ), this, SLOT(setCurrent(QListViewItem*))); - connect( popupTimer, SIGNAL(timeout()), - this, SLOT(showPopup()) ); - connect( settingList, SIGNAL( clicked( QListViewItem* ) ), - this, SLOT( stopTimer( QListViewItem* ) ) ); connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ), SLOT( groupChanged(const QString&) ) ); @@ -76,6 +69,22 @@ void MainWindow::makeMenu() { + popupTimer = new QTimer(this); + popupMenuFile = new QPopupMenu(this); + + popupActionSave = new QAction( tr("Save"),QString::null, 0, this, 0 ); + popupActionSave->addTo( popupMenuFile ); + connect( popupActionSave, SIGNAL( activated() ), + this , SLOT( saveConfFile() ) ); + popupActionRevert = new QAction( tr("Revert"),QString::null, 0, this, 0 ); + popupActionRevert->addTo( popupMenuFile ); + connect( popupActionRevert, SIGNAL( activated() ), + this , SLOT( revertConfFile() ) ); + + connect( popupTimer, SIGNAL(timeout()), + this, SLOT(showPopup()) ); + connect( settingList, SIGNAL( clicked( QListViewItem* ) ), + this, SLOT( stopTimer( QListViewItem* ) ) ); } MainWindow::~MainWindow() @@ -151,18 +160,22 @@ void MainWindow::saveConfFile() _fileItem->save(); } +void MainWindow::revertConfFile() +{ + if (!_fileItem) return; + _fileItem->revert(); +} + void MainWindow::showPopup() { qDebug("showPopup"); - if (!_fileItem) return; - popupMenu->clear(); - - QAction *popupAction; - popupAction = new QAction( tr("Save"),QString::null, 0, this, 0 ); - popupAction->addTo( popupMenu ); - connect( popupAction, SIGNAL( activated() ), - this , SLOT( saveConfFile() ) ); - + if (_fileItem) + { + popupActionSave->setEnabled(_fileItem->isChanged()); + popupActionRevert->setEnabled(_fileItem->revertable()); + popupMenuFile->popup( QCursor::pos() ); + }else if(_currentItem->isChanged()) + { - popupMenu->popup( QCursor::pos() ); + } } |