]> cloud.milkyroute.net Git - dolphin.git/blob - src/revisioncontrolplugin.cpp
remove revision-information entries when items got deleted in the model
[dolphin.git] / src / revisioncontrolplugin.cpp
1 /***************************************************************************
2 * Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #include "revisioncontrolplugin.h"
21
22 #include <kfileitem.h>
23 #include <QDir>
24 #include <QString>
25 #include <QTextStream>
26
27 RevisionControlPlugin::RevisionControlPlugin()
28 {
29 }
30
31 RevisionControlPlugin::~RevisionControlPlugin()
32 {
33 }
34
35 // ----------------------------------------------------------------------------
36
37 SubversionPlugin::SubversionPlugin() :
38 m_directory(),
39 m_revisionInfoHash()
40 {
41 }
42
43 SubversionPlugin::~SubversionPlugin()
44 {
45 }
46
47 QString SubversionPlugin::fileName() const
48 {
49 return ".svn";
50 }
51
52 bool SubversionPlugin::beginRetrieval(const QString& directory)
53 {
54 Q_ASSERT(directory.endsWith('/'));
55 m_directory = directory;
56
57 QFile file(directory + ".svn/entries");
58 if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
59 return false;
60 }
61
62 QTextStream in(&file);
63 QString fileName;
64 QString line;
65 while (!in.atEnd()) {
66 fileName = line;
67 line = in.readLine();
68 const bool isRevisioned = !line.isEmpty() &&
69 ((line == QLatin1String("dir")) ||
70 (line == QLatin1String("file")));
71 if (isRevisioned) {
72 RevisionInfo info; // TODO
73 m_revisionInfoHash.insert(fileName, info);
74 }
75 }
76 return true;
77 }
78
79 void SubversionPlugin::endRetrieval()
80 {
81 }
82
83 RevisionControlPlugin::RevisionState SubversionPlugin::revisionState(const KFileItem& item)
84 {
85 const QString name = item.name();
86 if (m_revisionInfoHash.contains(name)) {
87 // TODO...
88 return RevisionControlPlugin::LatestRevision;
89 }
90
91 return RevisionControlPlugin::LocalRevision;
92 }