summaryrefslogtreecommitdiffstats
path: root/kded/kctimefactory.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch)
tree5ac38a06f3dde268dc7927dc155896926aaf7012 /kded/kctimefactory.cpp
downloadtdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz
tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kded/kctimefactory.cpp')
-rw-r--r--kded/kctimefactory.cpp99
1 files changed, 99 insertions, 0 deletions
diff --git a/kded/kctimefactory.cpp b/kded/kctimefactory.cpp
new file mode 100644
index 000000000..bfc69af2c
--- /dev/null
+++ b/kded/kctimefactory.cpp
@@ -0,0 +1,99 @@
+/* This file is part of the KDE libraries
+ * Copyright (C) 2000 Waldo Bastian <bastian@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation;
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ **/
+
+#include "kctimefactory.h"
+#include "ksycoca.h"
+#include "ksycocatype.h"
+
+#include <assert.h>
+
+KCTimeInfo::KCTimeInfo()
+ : KSycocaFactory( KST_CTimeInfo ), ctimeDict(977)
+{
+ ctimeDict.setAutoDelete(true);
+ if (m_str)
+ {
+ (*m_str) >> m_dictOffset;
+ }
+ else
+ {
+ m_dictOffset = 0;
+ }
+}
+
+KCTimeInfo::~KCTimeInfo()
+{
+}
+
+void
+KCTimeInfo::saveHeader(QDataStream &str)
+{
+ KSycocaFactory::saveHeader(str);
+
+ str << m_dictOffset;
+}
+
+void
+KCTimeInfo::save(QDataStream &str)
+{
+ KSycocaFactory::save(str);
+
+ m_dictOffset = str.device()->at();
+ QDictIterator<Q_UINT32> it(ctimeDict);
+ while( it.current())
+ {
+ str << it.currentKey() << *(it.current());
+ ++it;
+ }
+ str << QString::null << (Q_UINT32) 0;
+
+ int endOfFactoryData = str.device()->at();
+
+ saveHeader(str);
+ str.device()->at(endOfFactoryData);
+}
+
+void
+KCTimeInfo::addCTime(const QString &path, Q_UINT32 ctime)
+{
+ assert(!path.isEmpty());
+ ctimeDict.replace(path, new Q_UINT32(ctime));
+}
+
+Q_UINT32
+KCTimeInfo::ctime(const QString &path)
+{
+ Q_UINT32 *ctimeP = ctimeDict[path];
+ return ctimeP ? *ctimeP : 0;
+}
+
+void
+KCTimeInfo::fillCTimeDict(QDict<Q_UINT32> &dict)
+{
+ assert(m_str);
+ m_str->device()->at(m_dictOffset);
+ QString path;
+ Q_UINT32 ctime;
+ while(true)
+ {
+ KSycocaEntry::read(*m_str, path);
+ (*m_str) >> ctime;
+ if (path.isEmpty()) break;
+ dict.replace(path, new Q_UINT32(ctime));
+ }
+}