summaryrefslogtreecommitdiff
authortille <tille>2002-06-29 23:23:09 (UTC)
committer tille <tille>2002-06-29 23:23:09 (UTC)
commit0f179c0cc471b659b30dec4762c9c36678063f31 (patch) (unidiff)
tree5350dc3b1c05991953011d01ad19cb12414abc1a
parenteb02223de534d315bfdcb0d521719c2d2e9a7235 (diff)
downloadopie-0f179c0cc471b659b30dec4762c9c36678063f31.zip
opie-0f179c0cc471b659b30dec4762c9c36678063f31.tar.gz
opie-0f179c0cc471b659b30dec4762c9c36678063f31.tar.bz2
revert
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/confedit/listviewitemconf.h1
-rw-r--r--noncore/apps/confedit/listviewitemconffile.cpp30
-rw-r--r--noncore/apps/confedit/listviewitemconffile.h2
-rw-r--r--noncore/apps/confedit/mainwindow.cpp47
-rw-r--r--noncore/apps/confedit/mainwindow.h10
5 files changed, 71 insertions, 19 deletions
diff --git a/noncore/apps/confedit/listviewitemconf.h b/noncore/apps/confedit/listviewitemconf.h
index 5837625..c6e60ba 100644
--- a/noncore/apps/confedit/listviewitemconf.h
+++ b/noncore/apps/confedit/listviewitemconf.h
@@ -27,2 +27,3 @@ public:
27 virtual void changed(); 27 virtual void changed();
28 bool isChanged() {return _changed;};
28 virtual void unchanged(); 29 virtual void unchanged();
diff --git a/noncore/apps/confedit/listviewitemconffile.cpp b/noncore/apps/confedit/listviewitemconffile.cpp
index 858726d..b075063 100644
--- a/noncore/apps/confedit/listviewitemconffile.cpp
+++ b/noncore/apps/confedit/listviewitemconffile.cpp
@@ -75,2 +75,3 @@ void ListViewItemConfFile::parseFile()
75 confFile.close(); 75 confFile.close();
76 unchanged();
76 setExpandable( _valid ); 77 setExpandable( _valid );
@@ -78,2 +79,24 @@ void ListViewItemConfFile::parseFile()
78 79
80
81void ListViewItemConfFile::revert()
82{
83 if (_changed)
84 {
85 parseFile();
86 }else{
87 QString backup = confFileInfo->absFilePath()+"~";
88 QFile conf(confFileInfo->absFilePath());
89 QFile back(backup);
90
91 if (!back.open(IO_ReadOnly)) return;
92 if (!conf.open(IO_WriteOnly)) return;
93
94 #define SIZE 124
95 char buf[SIZE];
96 while (int c = back.readBlock(buf, SIZE) ) conf.writeBlock(buf,c);
97 conf.close();
98 back.close();
99 }
100}
101
79void ListViewItemConfFile::save() 102void ListViewItemConfFile::save()
@@ -103,4 +126,9 @@ void ListViewItemConfFile::save()
103 conf.close(); 126 conf.close();
104 qDebug("no saveing yet...");
105 unchanged(); 127 unchanged();
106} 128}
129
130
131bool ListViewItemConfFile::revertable()
132{
133 return _changed || QFile(confFileInfo->absFilePath()+"~").exists();
134} \ No newline at end of file
diff --git a/noncore/apps/confedit/listviewitemconffile.h b/noncore/apps/confedit/listviewitemconffile.h
index d89b19c..ae23eab 100644
--- a/noncore/apps/confedit/listviewitemconffile.h
+++ b/noncore/apps/confedit/listviewitemconffile.h
@@ -27,3 +27,5 @@ public:
27 virtual void displayText(); 27 virtual void displayText();
28 bool revertable();
28 void save(); 29 void save();
30 void revert();
29protected: 31protected:
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
@@ -40,5 +40,2 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
40 40
41 popupTimer = new QTimer(this);
42 popupMenu = new QPopupMenu(this);
43
44 QWidget *mainWidget = new QWidget(this); 41 QWidget *mainWidget = new QWidget(this);
@@ -60,6 +57,2 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
60 57
61 connect( popupTimer, SIGNAL(timeout()),
62 this, SLOT(showPopup()) );
63 connect( settingList, SIGNAL( clicked( QListViewItem* ) ),
64 this, SLOT( stopTimer( QListViewItem* ) ) );
65 58
@@ -78,2 +71,18 @@ void MainWindow::makeMenu()
78 71
72 popupTimer = new QTimer(this);
73 popupMenuFile = new QPopupMenu(this);
74
75 popupActionSave = new QAction( tr("Save"),QString::null, 0, this, 0 );
76 popupActionSave->addTo( popupMenuFile );
77 connect( popupActionSave, SIGNAL( activated() ),
78 this , SLOT( saveConfFile() ) );
79 popupActionRevert = new QAction( tr("Revert"),QString::null, 0, this, 0 );
80 popupActionRevert->addTo( popupMenuFile );
81 connect( popupActionRevert, SIGNAL( activated() ),
82 this , SLOT( revertConfFile() ) );
83
84 connect( popupTimer, SIGNAL(timeout()),
85 this, SLOT(showPopup()) );
86 connect( settingList, SIGNAL( clicked( QListViewItem* ) ),
87 this, SLOT( stopTimer( QListViewItem* ) ) );
79} 88}
@@ -153,2 +162,8 @@ void MainWindow::saveConfFile()
153 162
163void MainWindow::revertConfFile()
164{
165 if (!_fileItem) return;
166 _fileItem->revert();
167}
168
154void MainWindow::showPopup() 169void MainWindow::showPopup()
@@ -156,13 +171,11 @@ void MainWindow::showPopup()
156 qDebug("showPopup"); 171 qDebug("showPopup");
157 if (!_fileItem) return; 172 if (_fileItem)
158 popupMenu->clear(); 173 {
159 174 popupActionSave->setEnabled(_fileItem->isChanged());
160 QAction *popupAction; 175 popupActionRevert->setEnabled(_fileItem->revertable());
161 popupAction = new QAction( tr("Save"),QString::null, 0, this, 0 ); 176 popupMenuFile->popup( QCursor::pos() );
162 popupAction->addTo( popupMenu ); 177 }else if(_currentItem->isChanged())
163 connect( popupAction, SIGNAL( activated() ), 178 {
164 this , SLOT( saveConfFile() ) );
165
166 179
167 popupMenu->popup( QCursor::pos() ); 180 }
168} 181}
diff --git a/noncore/apps/confedit/mainwindow.h b/noncore/apps/confedit/mainwindow.h
index b015dac..e0dc0b0 100644
--- a/noncore/apps/confedit/mainwindow.h
+++ b/noncore/apps/confedit/mainwindow.h
@@ -43,2 +43,3 @@ public slots:
43 void saveConfFile(); 43 void saveConfFile();
44 void revertConfFile();
44 45
@@ -50,3 +51,10 @@ private:
50 QTimer *popupTimer; 51 QTimer *popupTimer;
51 QPopupMenu *popupMenu; 52 QPopupMenu *popupMenuFile;
53 QPopupMenu *popupMenuEntry;
54 QAction *popupActionSave;
55 QAction *popupActionRevert;
56 QAction *popupActionDelete;
57 QAction *popupActionNew;
58 //QAction *popupAction;
59 //QAction *popupAction;
52 60