summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/confedit/listviewitemconf.cpp5
-rw-r--r--noncore/apps/confedit/listviewitemconf.h4
-rw-r--r--noncore/apps/confedit/listviewitemconffile.cpp24
-rw-r--r--noncore/apps/confedit/listviewitemconffile.h8
-rw-r--r--noncore/apps/confedit/listviewitemconfigentry.cpp18
-rw-r--r--noncore/apps/confedit/listviewitemconfigentry.h5
-rw-r--r--noncore/apps/confedit/mainwindow.cpp65
-rw-r--r--noncore/apps/confedit/mainwindow.h4
8 files changed, 104 insertions, 29 deletions
diff --git a/noncore/apps/confedit/listviewitemconf.cpp b/noncore/apps/confedit/listviewitemconf.cpp
index 55f8422..91edca2 100644
--- a/noncore/apps/confedit/listviewitemconf.cpp
+++ b/noncore/apps/confedit/listviewitemconf.cpp
@@ -45,2 +45,7 @@ void ListViewItemConf::unchanged()
displayText();
+}
+
+bool ListViewItemConf::revertable()
+{
+ return _changed;
} \ No newline at end of file
diff --git a/noncore/apps/confedit/listviewitemconf.h b/noncore/apps/confedit/listviewitemconf.h
index c6e60ba..3c504ed 100644
--- a/noncore/apps/confedit/listviewitemconf.h
+++ b/noncore/apps/confedit/listviewitemconf.h
@@ -25,2 +25,5 @@ public:
int getType();
+ void save();
+ virtual void revert() = 0;
+ virtual void remove() = 0;
virtual void displayText() = 0;
@@ -29,2 +32,3 @@ public:
virtual void unchanged();
+ virtual bool revertable();
diff --git a/noncore/apps/confedit/listviewitemconffile.cpp b/noncore/apps/confedit/listviewitemconffile.cpp
index b075063..228421b 100644
--- a/noncore/apps/confedit/listviewitemconffile.cpp
+++ b/noncore/apps/confedit/listviewitemconffile.cpp
@@ -80,2 +80,9 @@ void ListViewItemConfFile::parseFile()
+void ListViewItemConfFile::remove()
+{
+ QFile::remove(confFileInfo->absFilePath());
+ QFile::remove(backupFileName());
+ delete this;
+}
+
void ListViewItemConfFile::revert()
@@ -86,5 +93,4 @@ void ListViewItemConfFile::revert()
}else{
- QString backup = confFileInfo->absFilePath()+"~";
QFile conf(confFileInfo->absFilePath());
- QFile back(backup);
+ QFile back(backupFileName());
@@ -104,6 +110,4 @@ void ListViewItemConfFile::save()
if (!_changed) return;
- QString backup = confFileInfo->absFilePath()+"~";
- qDebug("make backup to "+backup);
QFile conf(confFileInfo->absFilePath());
- QFile back(backup);
+ QFile back(backupFileName());
@@ -112,3 +116,2 @@ void ListViewItemConfFile::save()
- #define SIZE 124
char buf[SIZE];
@@ -132,3 +135,8 @@ bool ListViewItemConfFile::revertable()
{
- return _changed || QFile(confFileInfo->absFilePath()+"~").exists();
-} \ No newline at end of file
+ return _changed || QFile(backupFileName()).exists();
+}
+
+QString ListViewItemConfFile::backupFileName()
+{
+ return confFileInfo->absFilePath()+"~";
+}
diff --git a/noncore/apps/confedit/listviewitemconffile.h b/noncore/apps/confedit/listviewitemconffile.h
index ae23eab..679a2ed 100644
--- a/noncore/apps/confedit/listviewitemconffile.h
+++ b/noncore/apps/confedit/listviewitemconffile.h
@@ -26,6 +26,8 @@ public:
QString fileName();
- virtual void displayText();
- bool revertable();
void save();
- void revert();
+ virtual void displayText();
+ virtual bool revertable();
+ virtual void revert();
+ virtual void remove();
+ QString backupFileName();
protected:
diff --git a/noncore/apps/confedit/listviewitemconfigentry.cpp b/noncore/apps/confedit/listviewitemconfigentry.cpp
index 77ce17d..b947514 100644
--- a/noncore/apps/confedit/listviewitemconfigentry.cpp
+++ b/noncore/apps/confedit/listviewitemconfigentry.cpp
@@ -21,2 +21,5 @@ ListViewItemConfigEntry::ListViewItemConfigEntry(ListViewItemConfFile *parent, Q
setKey(key);
+ _groupOrig = group;
+ _keyOrig = _key;
+ _valueOrig = _value;
_fileItem->unchanged();
@@ -109,2 +112,8 @@ void ListViewItemConfigEntry::changed()
+
+void ListViewItemConfigEntry::remove()
+{
+ delete this;
+}
+
void ListViewItemConfigEntry::save(QTextStream *t)
@@ -127,2 +136,11 @@ void ListViewItemConfigEntry::save(QTextStream *t)
}
+}
+
+void ListViewItemConfigEntry::revert()
+{
+ _group = _groupOrig;
+ _key = _keyOrig;
+ _value = _valueOrig;
+ _changed=false;
+ displayText();
} \ No newline at end of file
diff --git a/noncore/apps/confedit/listviewitemconfigentry.h b/noncore/apps/confedit/listviewitemconfigentry.h
index 1ff0491..6b651a6 100644
--- a/noncore/apps/confedit/listviewitemconfigentry.h
+++ b/noncore/apps/confedit/listviewitemconfigentry.h
@@ -36,3 +36,5 @@ public:
virtual void changed();
+ virtual void remove();
void save(QTextStream*);
+ virtual void revert();
private:
@@ -42,2 +44,5 @@ private:
QString _value;
+ QString _groupOrig;
+ QString _keyOrig;
+ QString _valueOrig;
ListViewItemConfFile *_fileItem;
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() );
}
diff --git a/noncore/apps/confedit/mainwindow.h b/noncore/apps/confedit/mainwindow.h
index e0dc0b0..886b829 100644
--- a/noncore/apps/confedit/mainwindow.h
+++ b/noncore/apps/confedit/mainwindow.h
@@ -23,3 +23,3 @@ class ListViewItemConfFile;
class ListViewConfDir;
-
+class ListViewItemConf;
@@ -44,2 +44,3 @@ public slots:
void revertConfFile();
+ void removeConfFile();
@@ -48,2 +49,3 @@ private:
EditWidget *editor;
+ ListViewItemConf *_item;
ListViewItemConfigEntry *_currentItem;