summaryrefslogtreecommitdiff
path: root/noncore/apps/confedit/mainwindow.cpp
Side-by-side diff
Diffstat (limited to 'noncore/apps/confedit/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/confedit/mainwindow.cpp65
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
@@ -37,74 +37,97 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
QMainWindow( 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 );
+ 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*)));
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&) ) );
- 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()
{
}
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();
updateGeometry();
_currentItem=0;
_fileItem = (ListViewItemConfFile*)item;
return;
}else editor->show();
@@ -123,12 +146,14 @@ void MainWindow::setCurrent(QListViewItem *item)
editor->LineEditKey->setText(key);
editor->LineEditValue->setText(val);
}else{
editor->isKey(false);
}
updateGeometry();
+ editor->updateGeometry();
+ settingList->updateGeometry();
}
void MainWindow::groupChanged(const QString &g)
{
if (!_currentItem) return;
@@ -147,35 +172,41 @@ void MainWindow::valueChanged(const QString &v)
_currentItem->valueChanged(v);
}
void MainWindow::stopTimer( QListViewItem* )
{
- qDebug("stopTimer");
popupTimer->stop();
}
void MainWindow::saveConfFile()
{
if (!_fileItem) return;
_fileItem->save();
}
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)
{
popupActionSave->setEnabled(_fileItem->isChanged());
- popupActionRevert->setEnabled(_fileItem->revertable());
popupMenuFile->popup( QCursor::pos() );
- }else if(_currentItem->isChanged())
+ }else if(_currentItem)
{
-
+ popupMenuEntry->popup( QCursor::pos() );
}
}