┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views
diff options
context:
space:
mode:
Diffstat (limited to 'src/views')
-rw-r--r--src/views/dolphinview.cpp38
-rw-r--r--src/views/dolphinview.h2
-rw-r--r--src/views/versioncontrol/fileviewversioncontrolplugin.desktop1
-rw-r--r--src/views/versioncontrol/kversioncontrolplugin.h23
-rw-r--r--src/views/versioncontrol/versioncontrolobserver.cpp50
5 files changed, 84 insertions, 30 deletions
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index f0f67c9d0..ce77dd325 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -18,6 +18,7 @@
#include "kitemviews/kitemlistcontroller.h"
#include "kitemviews/kitemlistheader.h"
#include "kitemviews/kitemlistselectionmanager.h"
+#include "kitemviews/private/kitemlistroleeditor.h"
#include "versioncontrol/versioncontrolobserver.h"
#include "viewproperties.h"
#include "views/tooltips/tooltipmanager.h"
@@ -178,6 +179,7 @@ DolphinView::DolphinView(const QUrl& url, QWidget* parent) :
connect(m_model, &KFileItemModel::errorMessage, this, &DolphinView::errorMessage);
connect(m_model, &KFileItemModel::directoryRedirection, this, &DolphinView::slotDirectoryRedirection);
connect(m_model, &KFileItemModel::urlIsFileError, this, &DolphinView::urlIsFileError);
+ connect(m_model, &KFileItemModel::fileItemsChanged, this, &DolphinView::fileItemsChanged);
connect(this, &DolphinView::itemCountChanged,
this, &DolphinView::updatePlaceholderLabel);
@@ -674,12 +676,21 @@ void DolphinView::renameSelectedItems()
if (items.count() == 1 && GeneralSettings::renameInline()) {
const int index = m_model->index(items.first());
- m_view->editRole(index, "text");
- hideToolTip();
+ QMetaObject::Connection * const connection = new QMetaObject::Connection;
+ *connection = connect(m_view, &KItemListView::scrollingStopped, this, [=](){
+ QObject::disconnect(*connection);
+ delete connection;
+
+ m_view->editRole(index, "text");
+
+ hideToolTip();
+
+ connect(m_view, &DolphinItemListView::roleEditingFinished,
+ this, &DolphinView::slotRoleEditingFinished);
+ });
+ m_view->scrollToItem(index);
- connect(m_view, &DolphinItemListView::roleEditingFinished,
- this, &DolphinView::slotRoleEditingFinished);
} else {
KIO::RenameFileDialog* dialog = new KIO::RenameFileDialog(items, this);
connect(dialog, &KIO::RenameFileDialog::renamingFinished,
@@ -1736,13 +1747,15 @@ void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, con
disconnect(m_view, &DolphinItemListView::roleEditingFinished,
this, &DolphinView::slotRoleEditingFinished);
- if (index < 0 || index >= m_model->count()) {
+ const KFileItemList items = selectedItems();
+ if (items.count() != 1) {
return;
}
if (role == "text") {
- const KFileItem oldItem = m_model->fileItem(index);
- const QString newName = value.toString();
+ const KFileItem oldItem = items.first();
+ const EditResult retVal = value.value<EditResult>();
+ const QString newName = retVal.newName;
if (!newName.isEmpty() && newName != oldItem.text() && newName != QLatin1Char('.') && newName != QLatin1String("..")) {
const QUrl oldUrl = oldItem.url();
@@ -1773,14 +1786,14 @@ void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, con
#endif
const bool newNameExistsAlready = (m_model->index(newUrl) >= 0);
- if (!newNameExistsAlready) {
+ if (!newNameExistsAlready && m_model->index(oldUrl) == index) {
// Only change the data in the model if no item with the new name
// is in the model yet. If there is an item with the new name
// already, calling KIO::CopyJob will open a dialog
// asking for a new name, and KFileItemModel will update the
// data when the dir lister signals that the file name has changed.
QHash<QByteArray, QVariant> data;
- data.insert(role, value);
+ data.insert(role, retVal.newName);
m_model->setData(index, data);
}
@@ -1797,6 +1810,13 @@ void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, con
connect(job, &KJob::result, this, &DolphinView::slotRenamingResult);
}
}
+ if (retVal.direction != EditDone) {
+ const short indexShift = retVal.direction == EditNext ? 1 : -1;
+ m_container->controller()->selectionManager()->setSelected(index, 1, KItemListSelectionManager::Deselect);
+ m_container->controller()->selectionManager()->setSelected(index + indexShift, 1,
+ KItemListSelectionManager::Select);
+ renameSelectedItems();
+ }
}
}
diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h
index be8263917..bb093774f 100644
--- a/src/views/dolphinview.h
+++ b/src/views/dolphinview.h
@@ -593,6 +593,8 @@ Q_SIGNALS:
void goUpRequested();
+ void fileItemsChanged(const KFileItemList &changedFileItems);
+
protected:
/** Changes the zoom level if Control is pressed during a wheel event. */
void wheelEvent(QWheelEvent* event) override;
diff --git a/src/views/versioncontrol/fileviewversioncontrolplugin.desktop b/src/views/versioncontrol/fileviewversioncontrolplugin.desktop
index 4c33b3b2c..5cffe9aac 100644
--- a/src/views/versioncontrol/fileviewversioncontrolplugin.desktop
+++ b/src/views/versioncontrol/fileviewversioncontrolplugin.desktop
@@ -43,6 +43,7 @@ Comment[sr@ijekavian]=Прикључак управљања верзијама �
Comment[sr@ijekavianlatin]=Priključak upravljanja verzijama za fajl prikaze
Comment[sr@latin]=Priključak upravljanja verzijama za fajl prikaze
Comment[sv]=Insticksprogram för versionskontroll i filvyer
+Comment[ta]=கோப்புக் காட்சிகளுக்கான பதிப்புக் கட்டுப்பாட்டு (version control) செருகுநிரல்
Comment[tr]=Dosya Görünümleri için Sürüm Kontrol Eklentisi
Comment[uk]=Додаток керування версіями для панелей перегляду файлів
Comment[vi]=Phần cài cắm "Quản lí phiên bản" cho khung xem tệp
diff --git a/src/views/versioncontrol/kversioncontrolplugin.h b/src/views/versioncontrol/kversioncontrolplugin.h
index aeac5ad29..c908be247 100644
--- a/src/views/versioncontrol/kversioncontrolplugin.h
+++ b/src/views/versioncontrol/kversioncontrolplugin.h
@@ -23,14 +23,15 @@ class KFileItem;
* steps are required (in the example below it is assumed that a plugin for
* Subversion will be written):
*
- * - Create a fileviewsvnplugin.desktop file with the following content:
+ * - Create a fileviewsvnplugin.json file with the following content:
* <code>
- * [Desktop Entry]
- * Type=Service
- * Name=Subversion
- * X-KDE-ServiceTypes=FileViewVersionControlPlugin
- * MimeType=text/plain;
- * X-KDE-Library=fileviewsvnplugin
+ * {
+ * "KPlugin": {
+ * "Description": "The svn plugin",
+ * "Name": "Svn"
+ * }
+ * }
+
* </code>
*
* - Create a class FileViewSvnPlugin derived from KVersionControlPlugin and
@@ -45,15 +46,13 @@ class KFileItem;
* <code>
* #include <KPluginFactory>
* #include <KPluginLoader>
- * K_PLUGIN_FACTORY(FileViewSvnPluginFactory, registerPlugin<FileViewSvnPlugin>();)
- * K_EXPORT_PLUGIN(FileViewSvnPluginFactory("fileviewsvnplugin"))
+ * K_PLUGIN_CLASS_WITH_JSON(FileViewSvnPlugin, "fileviewsvnplugin.json")
* </code>
*
* - Add the following lines to your CMakeLists.txt file:
* <code>
- * kde4_add_plugin(fileviewsvnplugin fileviewsvnplugin.cpp)
- * target_link_libraries(fileviewsvnplugin konq)
- * install(FILES fileviewsvnplugin.desktop DESTINATION ${SERVICES_INSTALL_DIR})
+ * kcoreaddons_add_plugin(fileviewsvnplugin SOURCES fileviewsvnplugin.cpp INSTALL_NAMESPACE "dolphin/vcs")
+ * target_link_libraries(fileviewsvnplugin DolphinVcs)
* </code>
*
* General implementation notes:
diff --git a/src/views/versioncontrol/versioncontrolobserver.cpp b/src/views/versioncontrol/versioncontrolobserver.cpp
index cf5be3c91..175d362bc 100644
--- a/src/views/versioncontrol/versioncontrolobserver.cpp
+++ b/src/views/versioncontrol/versioncontrolobserver.cpp
@@ -15,6 +15,8 @@
#include <KLocalizedString>
#include <KService>
#include <KServiceTypeTrader>
+#include <KPluginLoader>
+#include <KPluginMetaData>
#include <QTimer>
@@ -279,24 +281,54 @@ void VersionControlObserver::initPlugins()
// all fileview version control plugins and remember them in 'plugins'.
const QStringList enabledPlugins = VersionControlSettings::enabledPlugins();
+ const QVector<KPluginMetaData> plugins = KPluginLoader::findPlugins(QStringLiteral("dolphin/vcs"));
+
+ QSet<QString> loadedPlugins;
+
+ for (const auto &p : plugins) {
+ if (enabledPlugins.contains(p.name())) {
+ KPluginLoader loader(p.fileName());
+ KPluginFactory *factory = loader.factory();
+ KVersionControlPlugin *plugin = factory->create<KVersionControlPlugin>();
+ if (plugin) {
+ m_plugins.append(plugin);
+ loadedPlugins += p.name();
+ }
+ }
+ }
+
+ // Deprecated: load plugins using KService. This mechanism will be removed with KF6
const KService::List pluginServices = KServiceTypeTrader::self()->query(QStringLiteral("FileViewVersionControlPlugin"));
for (KService::List::ConstIterator it = pluginServices.constBegin(); it != pluginServices.constEnd(); ++it) {
+ if (loadedPlugins.contains((*it)->property("Name", QVariant::String).toString())) {
+ continue;
+ }
if (enabledPlugins.contains((*it)->name())) {
+ KPluginLoader pluginLoader(*(*it));
+ // Need to cast to int, because pluginVersion() returns -1 as
+ // an unsigned int for plugins without versions.
+ if (int(pluginLoader.pluginVersion()) < 2) {
+ qCWarning(DolphinDebug) << "Can't load old plugin" << (*it)->name();
+ continue;
+ }
KVersionControlPlugin* plugin = (*it)->createInstance<KVersionControlPlugin>(this);
if (plugin) {
- connect(plugin, &KVersionControlPlugin::itemVersionsChanged,
- this, &VersionControlObserver::silentDirectoryVerification);
- connect(plugin, &KVersionControlPlugin::infoMessage,
- this, &VersionControlObserver::infoMessage);
- connect(plugin, &KVersionControlPlugin::errorMessage,
- this, &VersionControlObserver::errorMessage);
- connect(plugin, &KVersionControlPlugin::operationCompletedMessage,
- this, &VersionControlObserver::operationCompletedMessage);
-
m_plugins.append(plugin);
}
}
}
+
+ for (auto &plugin : qAsConst(m_plugins)) {
+ connect(plugin, &KVersionControlPlugin::itemVersionsChanged,
+ this, &VersionControlObserver::silentDirectoryVerification);
+ connect(plugin, &KVersionControlPlugin::infoMessage,
+ this, &VersionControlObserver::infoMessage);
+ connect(plugin, &KVersionControlPlugin::errorMessage,
+ this, &VersionControlObserver::errorMessage);
+ connect(plugin, &KVersionControlPlugin::operationCompletedMessage,
+ this, &VersionControlObserver::operationCompletedMessage);
+ }
+
m_pluginsInitialized = true;
}
}