[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kate] part/swapfile: remove swap file, if file status changes to unmodified
From: Dominik Haumann <dhdev () gmx ! de>
Date: 2012-06-30 13:27:04
Message-ID: 20120630132704.34D65A60A6 () git ! kde ! org
[Download RAW message or body]
Git commit b12aacc3de06027614e6e2e268719d94323e3aee by Dominik Haumann.
Committed on 30/06/2012 at 15:23.
Pushed by dhaumann into branch 'master'.
remove swap file, if file status changes to unmodified
+ swap files are as small as possible
- undo/redo history is lost as it is reduced to the last unmodified state
M +11 -0 part/swapfile/kateswapfile.cpp
M +1 -0 part/swapfile/kateswapfile.h
http://commits.kde.org/kate/b12aacc3de06027614e6e2e268719d94323e3aee
diff --git a/part/swapfile/kateswapfile.cpp b/part/swapfile/kateswapfile.cpp
index 3da2560..9d96fba 100644
--- a/part/swapfile/kateswapfile.cpp
+++ b/part/swapfile/kateswapfile.cpp
@@ -90,6 +90,7 @@ void SwapFile::setTrackingEnabled(bool enable)
if (m_trackingEnabled) {
connect(&buffer, SIGNAL(editingStarted()), this, SLOT(startEditing()));
connect(&buffer, SIGNAL(editingFinished()), this, SLOT(finishEditing()));
+ connect(m_document, SIGNAL(modifiedChanged(KTextEditor::Document*)), this, \
SLOT(modifiedChanged()));
connect(&buffer, SIGNAL(lineWrapped(KTextEditor::Cursor)), this, \
SLOT(wrapLine(KTextEditor::Cursor)));
connect(&buffer, SIGNAL(lineUnwrapped(int)), this, SLOT(unwrapLine(int)));
@@ -98,6 +99,7 @@ void SwapFile::setTrackingEnabled(bool enable)
} else {
disconnect(&buffer, SIGNAL(editingStarted()), this, SLOT(startEditing()));
disconnect(&buffer, SIGNAL(editingFinished()), this, SLOT(finishEditing()));
+ disconnect(m_document, SIGNAL(modifiedChanged(KTextEditor::Document*)), this, \
SLOT(modifiedChanged()));
disconnect(&buffer, SIGNAL(lineWrapped(KTextEditor::Cursor)), this, \
SLOT(wrapLine(KTextEditor::Cursor)));
disconnect(&buffer, SIGNAL(lineUnwrapped(int)), this, SLOT(unwrapLine(int)));
@@ -138,6 +140,15 @@ void SwapFile::fileLoaded(const QString&)
emit swapFileFound();
}
+void SwapFile::modifiedChanged()
+{
+ if (!m_document->isModified() && !shouldRecover()) {
+ m_needSync = false;
+ // the file is not modified and we are not in recover mode
+ removeSwapFile();
+ }
+}
+
void SwapFile::recover()
{
m_document->setReadWrite(true);
diff --git a/part/swapfile/kateswapfile.h b/part/swapfile/kateswapfile.h
index 2a10af4..a6e0744 100644
--- a/part/swapfile/kateswapfile.h
+++ b/part/swapfile/kateswapfile.h
@@ -65,6 +65,7 @@ class KATEPART_TESTS_EXPORT SwapFile : public QObject
protected Q_SLOTS:
void fileSaved(const QString& filename);
void fileLoaded(const QString &filename);
+ void modifiedChanged();
void startEditing ();
void finishEditing ();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic