mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
Merge branch 'Applications/18.12'
This commit is contained in:
commit
fb4b4465f9
|
@ -182,6 +182,7 @@ DolphinView::DolphinView(const QUrl& url, QWidget* parent) :
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_versionControlObserver = new VersionControlObserver(this);
|
m_versionControlObserver = new VersionControlObserver(this);
|
||||||
|
m_versionControlObserver->setView(this);
|
||||||
m_versionControlObserver->setModel(m_model);
|
m_versionControlObserver->setModel(m_model);
|
||||||
connect(m_versionControlObserver, &VersionControlObserver::infoMessage, this, &DolphinView::infoMessage);
|
connect(m_versionControlObserver, &VersionControlObserver::infoMessage, this, &DolphinView::infoMessage);
|
||||||
connect(m_versionControlObserver, &VersionControlObserver::errorMessage, this, &DolphinView::errorMessage);
|
connect(m_versionControlObserver, &VersionControlObserver::errorMessage, this, &DolphinView::errorMessage);
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
#include "dolphin_versioncontrolsettings.h"
|
#include "dolphin_versioncontrolsettings.h"
|
||||||
#include "dolphindebug.h"
|
#include "dolphindebug.h"
|
||||||
|
#include "views/dolphinview.h"
|
||||||
#include "kitemviews/kfileitemmodel.h"
|
#include "kitemviews/kfileitemmodel.h"
|
||||||
#include "updateitemstatesthread.h"
|
#include "updateitemstatesthread.h"
|
||||||
|
|
||||||
|
@ -35,8 +36,10 @@ VersionControlObserver::VersionControlObserver(QObject* parent) :
|
||||||
m_pendingItemStatesUpdate(false),
|
m_pendingItemStatesUpdate(false),
|
||||||
m_versionedDirectory(false),
|
m_versionedDirectory(false),
|
||||||
m_silentUpdate(false),
|
m_silentUpdate(false),
|
||||||
|
m_view(nullptr),
|
||||||
m_model(nullptr),
|
m_model(nullptr),
|
||||||
m_dirVerificationTimer(nullptr),
|
m_dirVerificationTimer(nullptr),
|
||||||
|
m_pluginsInitialized(false),
|
||||||
m_plugin(nullptr),
|
m_plugin(nullptr),
|
||||||
m_updateItemStatesThread(nullptr)
|
m_updateItemStatesThread(nullptr)
|
||||||
{
|
{
|
||||||
|
@ -84,6 +87,26 @@ KFileItemModel* VersionControlObserver::model() const
|
||||||
return m_model;
|
return m_model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VersionControlObserver::setView(DolphinView* view)
|
||||||
|
{
|
||||||
|
if (m_view) {
|
||||||
|
disconnect(m_view, &DolphinView::activated,
|
||||||
|
this, &VersionControlObserver::delayedDirectoryVerification);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_view = view;
|
||||||
|
|
||||||
|
if (m_view) {
|
||||||
|
connect(m_view, &DolphinView::activated,
|
||||||
|
this, &VersionControlObserver::delayedDirectoryVerification);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DolphinView* VersionControlObserver::view() const
|
||||||
|
{
|
||||||
|
return m_view;
|
||||||
|
}
|
||||||
|
|
||||||
QList<QAction*> VersionControlObserver::actions(const KFileItemList& items) const
|
QList<QAction*> VersionControlObserver::actions(const KFileItemList& items) const
|
||||||
{
|
{
|
||||||
bool hasNullItems = false;
|
bool hasNullItems = false;
|
||||||
|
@ -256,18 +279,9 @@ int VersionControlObserver::createItemStatesList(QMap<QString, QVector<ItemState
|
||||||
return index - firstIndex; // number of processed items
|
return index - firstIndex; // number of processed items
|
||||||
}
|
}
|
||||||
|
|
||||||
KVersionControlPlugin* VersionControlObserver::searchPlugin(const QUrl& directory) const
|
KVersionControlPlugin* VersionControlObserver::searchPlugin(const QUrl& directory)
|
||||||
{
|
{
|
||||||
static bool pluginsAvailable = true;
|
if (!m_pluginsInitialized) {
|
||||||
static QList<KVersionControlPlugin*> plugins;
|
|
||||||
|
|
||||||
if (!pluginsAvailable) {
|
|
||||||
// A searching for plugins has already been done, but no
|
|
||||||
// plugins are installed
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (plugins.isEmpty()) {
|
|
||||||
// No searching for plugins has been done yet. Query the KServiceTypeTrader for
|
// No searching for plugins has been done yet. Query the KServiceTypeTrader for
|
||||||
// all fileview version control plugins and remember them in 'plugins'.
|
// all fileview version control plugins and remember them in 'plugins'.
|
||||||
const QStringList enabledPlugins = VersionControlSettings::enabledPlugins();
|
const QStringList enabledPlugins = VersionControlSettings::enabledPlugins();
|
||||||
|
@ -275,16 +289,19 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const QUrl& director
|
||||||
const KService::List pluginServices = KServiceTypeTrader::self()->query(QStringLiteral("FileViewVersionControlPlugin"));
|
const KService::List pluginServices = KServiceTypeTrader::self()->query(QStringLiteral("FileViewVersionControlPlugin"));
|
||||||
for (KService::List::ConstIterator it = pluginServices.constBegin(); it != pluginServices.constEnd(); ++it) {
|
for (KService::List::ConstIterator it = pluginServices.constBegin(); it != pluginServices.constEnd(); ++it) {
|
||||||
if (enabledPlugins.contains((*it)->name())) {
|
if (enabledPlugins.contains((*it)->name())) {
|
||||||
KVersionControlPlugin* plugin = (*it)->createInstance<KVersionControlPlugin>();
|
KVersionControlPlugin* plugin = (*it)->createInstance<KVersionControlPlugin>(this);
|
||||||
if (plugin) {
|
if (plugin) {
|
||||||
plugins.append(plugin);
|
m_plugins.append(plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (plugins.isEmpty()) {
|
m_pluginsInitialized = true;
|
||||||
pluginsAvailable = false;
|
}
|
||||||
return nullptr;
|
|
||||||
}
|
if (m_plugins.empty()) {
|
||||||
|
// A searching for plugins has already been done, but no
|
||||||
|
// plugins are installed
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We use the number of upUrl() calls to find the best matching plugin
|
// We use the number of upUrl() calls to find the best matching plugin
|
||||||
|
@ -294,7 +311,7 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const QUrl& director
|
||||||
|
|
||||||
// Verify whether the current directory contains revision information
|
// Verify whether the current directory contains revision information
|
||||||
// like .svn, .git, ...
|
// like .svn, .git, ...
|
||||||
foreach (KVersionControlPlugin* plugin, plugins) {
|
foreach (KVersionControlPlugin* plugin, m_plugins) {
|
||||||
const QString fileName = directory.path() + '/' + plugin->fileName();
|
const QString fileName = directory.path() + '/' + plugin->fileName();
|
||||||
if (QFile::exists(fileName)) {
|
if (QFile::exists(fileName)) {
|
||||||
// The score of this plugin is 0 (best), so we can just return this plugin,
|
// The score of this plugin is 0 (best), so we can just return this plugin,
|
||||||
|
|
|
@ -37,6 +37,8 @@ class QAction;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
class UpdateItemStatesThread;
|
class UpdateItemStatesThread;
|
||||||
|
|
||||||
|
class DolphinView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Observes all version control plugins.
|
* @brief Observes all version control plugins.
|
||||||
*
|
*
|
||||||
|
@ -55,6 +57,8 @@ public:
|
||||||
|
|
||||||
void setModel(KFileItemModel* model);
|
void setModel(KFileItemModel* model);
|
||||||
KFileItemModel* model() const;
|
KFileItemModel* model() const;
|
||||||
|
void setView(DolphinView* view);
|
||||||
|
DolphinView* view() const;
|
||||||
|
|
||||||
QList<QAction*> actions(const KFileItemList& items) const;
|
QList<QAction*> actions(const KFileItemList& items) const;
|
||||||
|
|
||||||
|
@ -126,7 +130,7 @@ private:
|
||||||
* Returns a matching plugin for the given directory.
|
* Returns a matching plugin for the given directory.
|
||||||
* 0 is returned, if no matching plugin has been found.
|
* 0 is returned, if no matching plugin has been found.
|
||||||
*/
|
*/
|
||||||
KVersionControlPlugin* searchPlugin(const QUrl& directory) const;
|
KVersionControlPlugin* searchPlugin(const QUrl& directory);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true, if the directory contains a version control information.
|
* Returns true, if the directory contains a version control information.
|
||||||
|
@ -139,11 +143,14 @@ private:
|
||||||
bool m_silentUpdate; // if true, no messages will be send during the update
|
bool m_silentUpdate; // if true, no messages will be send during the update
|
||||||
// of version states
|
// of version states
|
||||||
|
|
||||||
|
DolphinView* m_view;
|
||||||
KFileItemModel* m_model;
|
KFileItemModel* m_model;
|
||||||
|
|
||||||
QTimer* m_dirVerificationTimer;
|
QTimer* m_dirVerificationTimer;
|
||||||
|
|
||||||
|
bool m_pluginsInitialized;
|
||||||
KVersionControlPlugin* m_plugin;
|
KVersionControlPlugin* m_plugin;
|
||||||
|
QList<KVersionControlPlugin*> m_plugins;
|
||||||
UpdateItemStatesThread* m_updateItemStatesThread;
|
UpdateItemStatesThread* m_updateItemStatesThread;
|
||||||
|
|
||||||
friend class UpdateItemStatesThread;
|
friend class UpdateItemStatesThread;
|
||||||
|
|
Loading…
Reference in a new issue