[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE_3_2_BRANCH: kdelibs/kate/part
From: Christoph Cullmann <crossfire () babylon2k ! de>
Date: 2004-03-14 17:20:59
Message-ID: 20040314172059.C449A99A8 () office ! kde ! org
[Download RAW message or body]
CVS commit by cullmann:
backport fix for #75559
M +48 -9 katedocument.cpp 1.681.2.5
M +24 -13 katedocument.h 1.264.2.3
--- kdelibs/kate/part/katedocument.cpp #1.681.2.4:1.681.2.5
@@ -72,4 +72,5 @@
#include <kencodingfiledialog.h>
#include <ktempfile.h>
+#include <kmdcodec.h>
#include <qtimer.h>
@@ -2384,5 +2385,4 @@ bool KateDocument::openFile(KIO::Job * j
}
-
// update file type
updateFileType (KateFactory::self()->fileTypeManager()->fileType (this));
@@ -2390,4 +2390,7 @@ bool KateDocument::openFile(KIO::Job * j
// read vars
readVariables();
+
+ // update the md5 digest
+ createDigest( m_digest );
}
@@ -2507,4 +2510,7 @@ bool KateDocument::saveFile()
success = buffer->saveFile (m_file);
+ // update the md5 digest
+ createDigest( m_digest );
+
// add file
activateDirWatch ();
@@ -4003,6 +4009,14 @@ void KateDocument::guiActivateEvent( KPa
}
-void KateDocument::setDocName (QString )
+void KateDocument::setDocName (QString name )
{
+ if ( !name.isEmpty() )
+ {
+ // TODO check for similarly named documents
+ m_docName = name;
+ emit nameChanged((Kate::Document *) this);
+ return;
+ }
+
int count = -1;
@@ -4813,6 +4827,13 @@ bool KateDocument::checkColorValue( QStr
void KateDocument::slotModOnHdDirty (const QString &path)
{
- if ((path == m_file) && (!m_modOnHd || m_modOnHdReason != 1))
+ if ((path == m_dirWatchFile) && (!m_modOnHd || m_modOnHdReason != 1))
+ {
+ // compare md5 with the one we have (if we have one)
+ if ( ! m_digest.isEmpty() )
{
+ QCString tmp;
+ if ( createDigest( tmp ) && tmp == m_digest )
+ return;
+ }
m_modOnHd = true;
m_modOnHdReason = 1;
@@ -4823,5 +4844,5 @@ void KateDocument::slotModOnHdDirty (con
void KateDocument::slotModOnHdCreated (const QString &path)
{
- if ((path == m_file) && (!m_modOnHd || m_modOnHdReason != 2))
+ if ((path == m_dirWatchFile) && (!m_modOnHd || m_modOnHdReason != 2))
{
m_modOnHd = true;
@@ -4833,5 +4854,5 @@ void KateDocument::slotModOnHdCreated (c
void KateDocument::slotModOnHdDeleted (const QString &path)
{
- if ((path == m_file) && (!m_modOnHd || m_modOnHdReason != 3))
+ if ((path == m_dirWatchFile) && (!m_modOnHd || m_modOnHdReason != 3))
{
m_modOnHd = true;
@@ -4841,4 +4862,22 @@ void KateDocument::slotModOnHdDeleted (c
}
+bool KateDocument::createDigest( QCString &result )
+{
+ bool ret = false;
+ result = "";
+ if ( url().isLocalFile() )
+ {
+ QFile f ( url().path() );
+ if ( f.open( IO_ReadOnly) )
+ {
+ KMD5 md5;
+ ret = md5.update( f );
+ md5.hexDigest( result );
+ f.close();
+ }
+ }
+ return ret;
+}
+
bool KateDocument::wrapCursor ()
{
--- kdelibs/kate/part/katedocument.h #1.264.2.2:1.264.2.3
@@ -714,4 +714,14 @@ class KateDocument : public Kate::Docume
void slotModOnHdDeleted (const QString &path);
+ private:
+ /**
+ * create a MD5 digest of the file, if it is a local file,
+ * and fill it into the string @p result.
+ * This is using KMD5::hexDigest().
+ *
+ * @return wheather the operation was attempted and succeded.
+ */
+ bool createDigest( QCString &result );
+
public:
// should cursor be wrapped ? take config + blockselection state in account
@@ -740,4 +750,5 @@ class KateDocument : public Kate::Docume
bool m_modOnHd;
unsigned char m_modOnHdReason;
+ QCString m_digest; // MD5 digest, updated on load/save
QString m_docName;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic