1 /***************************************************************************
2 * Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at> *
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. *
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. *
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 ***************************************************************************/
20 #ifndef REVISIONCONTROLOBSERVER_H
21 #define REVISIONCONTROLOBSERVER_H
23 #include <libdolphin_export.h>
25 #include <kfileitem.h>
26 #include <revisioncontrolplugin.h>
30 #include <QPersistentModelIndex>
36 class QAbstractItemView
;
39 class UpdateItemStatesThread
;
42 * @brief Observes all revision control plugins.
44 * The item view gets updated automatically if the currently shown
45 * directory is under revision control.
47 * @see RevisionControlPlugin
49 class LIBDOLPHINPRIVATE_EXPORT RevisionControlObserver
: public QObject
54 RevisionControlObserver(QAbstractItemView
* view
);
55 virtual ~RevisionControlObserver();
57 QList
<QAction
*> contextMenuActions(const KFileItemList
& items
) const;
58 QList
<QAction
*> contextMenuActions(const QString
& directory
) const;
62 * Is emitted if an information message with the content \a msg
65 void infoMessage(const QString
& msg
);
68 * Is emitted if an error message with the content \a msg
71 void errorMessage(const QString
& msg
);
74 * Is emitted if an "operation completed" message with the content \a msg
77 void operationCompletedMessage(const QString
& msg
);
81 * Invokes verifyDirectory() with a small delay. If delayedDirectoryVerification()
82 * is invoked before the delay has been exceeded, the delay will be reset. This
83 * assures that a lot of short requests for directory verification only result
84 * in one (expensive) call.
86 void delayedDirectoryVerification();
89 * Invokes verifyDirectory() with a small delay. In opposite to
90 * delayedDirectoryVerification() it and assures that the verification of
91 * the directory is done silently without information messages.
93 void silentDirectoryVerification();
95 void verifyDirectory();
96 void applyUpdatedItemStates();
101 QPersistentModelIndex index
;
103 RevisionControlPlugin::RevisionState revision
;
106 void updateItemStates();
109 * Adds recursively all items from the directory \p parentIndex into
110 * the list \p itemStates.
112 void addDirectory(const QModelIndex
& parentIndex
, QList
<ItemState
>& itemStates
);
115 bool m_pendingItemStatesUpdate
;
116 bool m_revisionedDirectory
;
117 bool m_silentUpdate
; // if true, no messages will be send during the update
118 // of revision states
120 QAbstractItemView
* m_view
;
121 KDirLister
* m_dirLister
;
122 DolphinModel
* m_dolphinModel
;
124 QTimer
* m_dirVerificationTimer
;
126 mutable QMutex m_pluginMutex
;
127 RevisionControlPlugin
* m_plugin
;
128 UpdateItemStatesThread
* m_updateItemStatesThread
;
130 friend class UpdateItemStatesThread
;
133 #endif // REVISIONCONTROLOBSERVER_H