┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views
diff options
context:
space:
mode:
Diffstat (limited to 'src/views')
-rw-r--r--src/views/dolphinremoteencoding.cpp5
-rw-r--r--src/views/dolphinview.cpp139
-rw-r--r--src/views/dolphinview.h35
-rw-r--r--src/views/dolphinviewactionhandler.cpp9
-rw-r--r--src/views/draganddrophelper.cpp16
-rw-r--r--src/views/draganddrophelper.h11
-rw-r--r--src/views/renamedialog.cpp16
-rw-r--r--src/views/versioncontrol/updateitemstatesthread.cpp26
-rw-r--r--src/views/versioncontrol/updateitemstatesthread.h9
-rw-r--r--src/views/versioncontrol/versioncontrolobserver.cpp34
10 files changed, 185 insertions, 115 deletions
diff --git a/src/views/dolphinremoteencoding.cpp b/src/views/dolphinremoteencoding.cpp
index 375b3fd46..04b350eda 100644
--- a/src/views/dolphinremoteencoding.cpp
+++ b/src/views/dolphinremoteencoding.cpp
@@ -38,7 +38,6 @@
#include <KMenu>
#include <KProtocolInfo>
#include <KProtocolManager>
-#include <KIO/SlaveConfig>
#include <KIO/Scheduler>
#include <KConfigGroup>
@@ -132,9 +131,7 @@ void DolphinRemoteEncoding::updateMenu()
m_menu->menu()->actions().at(i)->setChecked(false);
}
- QString charset = KGlobal::charsets()->descriptionForEncoding(KIO::SlaveConfig::self()->configData(m_currentURL.protocol(),
- m_currentURL.host(), DATA_KEY));
-
+ const QString charset = KGlobal::charsets()->descriptionForEncoding(KProtocolManager::charsetFor(m_currentURL));
if (!charset.isEmpty()) {
int id = 0;
bool isFound = false;
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index d69d664af..fa43656c1 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -33,6 +33,8 @@
#include <QTimer>
#include <QScrollBar>
+#include <KDesktopFile>
+#include <KProtocolManager>
#include <KActionCollection>
#include <KColorScheme>
#include <KDirModel>
@@ -102,6 +104,7 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) :
m_restoredContentsPosition(),
m_selectedUrls(),
m_clearSelectionBeforeSelectingNewItems(false),
+ m_markFirstNewlySelectedItemAsCurrent(false),
m_versionControlObserver(0)
{
m_topLayout = new QVBoxLayout(this);
@@ -175,7 +178,7 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) :
connect(m_view, SIGNAL(visibleRolesChanged(QList<QByteArray>,QList<QByteArray>)),
this, SLOT(slotVisibleRolesChangedByHeader(QList<QByteArray>,QList<QByteArray>)));
connect(m_view, SIGNAL(roleEditingCanceled(int,QByteArray,QVariant)),
- this, SLOT(slotRoleEditingCanceled(int,QByteArray,QVariant)));
+ this, SLOT(slotRoleEditingCanceled()));
connect(m_view->header(), SIGNAL(columnWidthChanged(QByteArray,qreal,qreal)),
this, SLOT(slotHeaderColumnWidthChanged(QByteArray,qreal,qreal)));
@@ -245,9 +248,12 @@ void DolphinView::setMode(Mode mode)
if (mode != m_mode) {
ViewProperties props(viewPropertiesUrl());
props.setViewMode(mode);
- props.save();
- applyViewProperties();
+ // We pass the new ViewProperties to applyViewProperties, rather than
+ // storing them on disk and letting applyViewProperties() read them
+ // from there, to prevent that changing the view mode fails if the
+ // .directory file is not writable (see bug 318534).
+ applyViewProperties(props);
}
}
@@ -815,9 +821,10 @@ void DolphinView::slotItemsActivated(const QSet<int>& indexes)
while (it.hasNext()) {
const int index = it.next();
KFileItem item = m_model->fileItem(index);
+ const KUrl& url = openItemAsFolderUrl(item);
- if (item.isDir()) { // Open folders in new tabs
- emit tabRequested(item.url());
+ if (!url.isEmpty()) { // Open folders in new tabs
+ emit tabRequested(url);
} else {
items.append(item);
}
@@ -832,14 +839,23 @@ void DolphinView::slotItemsActivated(const QSet<int>& indexes)
void DolphinView::slotItemMiddleClicked(int index)
{
- const KFileItem item = m_model->fileItem(index);
- if (item.isDir() || isTabsForFilesEnabled()) {
+ const KFileItem& item = m_model->fileItem(index);
+ const KUrl& url = openItemAsFolderUrl(item);
+ if (!url.isEmpty()) {
+ emit tabRequested(url);
+ } else if (isTabsForFilesEnabled()) {
emit tabRequested(item.url());
}
}
void DolphinView::slotItemContextMenuRequested(int index, const QPointF& pos)
{
+ // Force emit of a selection changed signal before we request the
+ // context menu, to update the edit-actions first. (See Bug 294013)
+ if (m_selectionChangedTimer->isActive()) {
+ emitSelectionChangedSignal();
+ }
+
const KFileItem item = m_model->fileItem(index);
emit requestContextMenu(pos.toPoint(), item, url(), QList<QAction*>());
}
@@ -1029,15 +1045,19 @@ void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even
event->buttons(),
event->modifiers());
- const QString error = DragAndDropHelper::dropUrls(destItem, destUrl, &dropEvent);
+ QString error;
+ KonqOperations* op = DragAndDropHelper::dropUrls(destItem, destUrl, &dropEvent, error);
if (!error.isEmpty()) {
emit infoMessage(error);
}
- if (destUrl == url()) {
+ if (op && destUrl == url()) {
// Mark the dropped urls as selected.
- markPastedUrlsAsSelected(event->mimeData());
+ m_clearSelectionBeforeSelectingNewItems = true;
+ connect(op, SIGNAL(urlPasted(KUrl)), this, SLOT(slotUrlPasted(KUrl)));
}
+
+ setActive(true);
}
void DolphinView::slotModelChanged(KItemModelBase* current, KItemModelBase* previous)
@@ -1072,6 +1092,17 @@ void DolphinView::slotMouseButtonPressed(int itemIndex, Qt::MouseButtons buttons
}
}
+void DolphinView::slotAboutToCreate(const KUrl::List& urls)
+{
+ if (!urls.isEmpty()) {
+ if (m_markFirstNewlySelectedItemAsCurrent) {
+ markUrlAsCurrent(urls.first());
+ m_markFirstNewlySelectedItemAsCurrent = false;
+ }
+ m_selectedUrls << urls;
+ }
+}
+
void DolphinView::slotSelectionChanged(const QSet<int>& current, const QSet<int>& previous)
{
const int currentCount = current.count();
@@ -1194,6 +1225,46 @@ QString DolphinView::viewPropertiesContext() const
return m_viewPropertiesContext;
}
+KUrl DolphinView::openItemAsFolderUrl(const KFileItem& item, const bool browseThroughArchives)
+{
+ if (item.isNull()) {
+ return KUrl();
+ }
+
+ KUrl url = item.targetUrl();
+
+ if (item.isDir()) {
+ return url;
+ }
+
+ if (item.isMimeTypeKnown()) {
+ const QString& mimetype = item.mimetype();
+
+ if (browseThroughArchives && item.isFile() && url.isLocalFile()) {
+ // Generic mechanism for redirecting to tar:/<path>/ when clicking on a tar file,
+ // zip:/<path>/ when clicking on a zip file, etc.
+ // The .protocol file specifies the mimetype that the kioslave handles.
+ // Note that we don't use mimetype inheritance since we don't want to
+ // open OpenDocument files as zip folders...
+ const QString& protocol = KProtocolManager::protocolForArchiveMimetype(mimetype);
+ if (!protocol.isEmpty()) {
+ url.setProtocol(protocol);
+ return url;
+ }
+ }
+
+ if (mimetype == QLatin1String("application/x-desktop")) {
+ // Redirect to the URL in Type=Link desktop files
+ KDesktopFile desktopFile(url.toLocalFile());
+ if (desktopFile.hasLinkType()) {
+ return desktopFile.readUrl();
+ }
+ }
+ }
+
+ return KUrl();
+}
+
void DolphinView::observeCreatedItem(const KUrl& url)
{
if (m_active) {
@@ -1224,10 +1295,11 @@ void DolphinView::updateViewState()
m_view->scrollToItem(currentIndex);
m_scrollToCurrentItem = false;
}
+
+ m_currentItemUrl = KUrl();
} else {
selectionManager->setCurrentItem(0);
}
- m_currentItemUrl = KUrl();
}
if (!m_restoredContentsPosition.isNull()) {
@@ -1306,6 +1378,16 @@ void DolphinView::slotDeleteFileFinished(KJob* job)
}
}
+void DolphinView::slotRenamingFailed(const KUrl& oldUrl, const KUrl& newUrl)
+{
+ const int index = m_model->index(newUrl);
+ if (index >= 0) {
+ QHash<QByteArray, QVariant> data;
+ data.insert("text", oldUrl.fileName());
+ m_model->setData(index, data);
+ }
+}
+
void DolphinView::slotDirectoryLoadingStarted()
{
// Disable the writestate temporary until it can be determined in a fast way
@@ -1372,7 +1454,7 @@ void DolphinView::slotVisibleRolesChangedByHeader(const QList<QByteArray>& curre
emit visibleRolesChanged(m_visibleRoles, previousVisibleRoles);
}
-void DolphinView::slotRoleEditingCanceled(int index, const QByteArray& role, const QVariant& value)
+void DolphinView::slotRoleEditingCanceled()
{
disconnect(m_view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
@@ -1406,7 +1488,10 @@ void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, con
m_model->setData(index, data);
}
- KonqOperations::rename(this, oldUrl, newName);
+ KonqOperations* op = KonqOperations::renameV2(this, oldUrl, newName);
+ if (op) {
+ connect(op, SIGNAL(renamingFailed(KUrl,KUrl)), SLOT(slotRenamingFailed(KUrl,KUrl)));
+ }
}
}
}
@@ -1432,9 +1517,13 @@ void DolphinView::loadDirectory(const KUrl& url, bool reload)
void DolphinView::applyViewProperties()
{
- m_view->beginTransaction();
-
const ViewProperties props(viewPropertiesUrl());
+ applyViewProperties(props);
+}
+
+void DolphinView::applyViewProperties(const ViewProperties& props)
+{
+ m_view->beginTransaction();
const Mode mode = props.viewMode();
if (m_mode != mode) {
@@ -1538,8 +1627,12 @@ void DolphinView::applyModeToView()
void DolphinView::pasteToUrl(const KUrl& url)
{
- markPastedUrlsAsSelected(QApplication::clipboard()->mimeData());
- KonqOperations::doPaste(this, url);
+ KonqOperations* op = KonqOperations::doPasteV2(this, url);
+ if (op) {
+ m_clearSelectionBeforeSelectingNewItems = true;
+ m_markFirstNewlySelectedItemAsCurrent = true;
+ connect(op, SIGNAL(aboutToCreate(KUrl::List)), this, SLOT(slotAboutToCreate(KUrl::List)));
+ }
}
KUrl::List DolphinView::simplifiedSelectedUrls() const
@@ -1567,18 +1660,6 @@ QMimeData* DolphinView::selectionMimeData() const
return m_model->createMimeData(selectedIndexes);
}
-void DolphinView::markPastedUrlsAsSelected(const QMimeData* mimeData)
-{
- const KUrl::List sourceUrls = KUrl::List::fromMimeData(mimeData);
- KUrl::List destUrls;
- foreach (const KUrl& source, sourceUrls) {
- KUrl destination(url().url() + '/' + source.fileName());
- destUrls << destination;
- }
- markUrlsAsSelected(destUrls);
- m_clearSelectionBeforeSelectingNewItems = true;
-}
-
void DolphinView::updateWritableState()
{
const bool wasFolderWritable = m_isFolderWritable;
diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h
index 62b5df7c7..86bc5c159 100644
--- a/src/views/dolphinview.h
+++ b/src/views/dolphinview.h
@@ -304,6 +304,14 @@ public:
void setViewPropertiesContext(const QString& context);
QString viewPropertiesContext() const;
+ /**
+ * Checks if the given \a item can be opened as folder (e.g. archives).
+ * This function will also adjust the \a url (e.g. change the protocol).
+ * @return a valid and adjusted url if the item can be opened as folder,
+ * otherwise return an empty url.
+ */
+ static KUrl openItemAsFolderUrl(const KFileItem& item, const bool browseThroughArchives = true);
+
public slots:
/**
* Changes the directory to \a url. If the current directory is equal to
@@ -566,6 +574,11 @@ private slots:
void slotModelChanged(KItemModelBase* current, KItemModelBase* previous);
void slotMouseButtonPressed(int itemIndex, Qt::MouseButtons buttons);
+ /*
+ * Is called when new items get pasted or dropped.
+ */
+ void slotAboutToCreate(const KUrl::List& urls);
+
/**
* Emits the signal \a selectionChanged() with a small delay. This is
* because getting all file items for the selection can be an expensive
@@ -619,6 +632,8 @@ private slots:
*/
void slotDeleteFileFinished(KJob* job);
+ void slotRenamingFailed(const KUrl& oldUrl, const KUrl& newUrl);
+
/**
* Invoked when the file item model has started the loading
* of the directory specified by DolphinView::url().
@@ -655,7 +670,7 @@ private slots:
void slotVisibleRolesChangedByHeader(const QList<QByteArray>& current,
const QList<QByteArray>& previous);
- void slotRoleEditingCanceled(int index, const QByteArray& role, const QVariant& value);
+ void slotRoleEditingCanceled();
void slotRoleEditingFinished(int index, const QByteArray& role, const QVariant& value);
/**
@@ -694,11 +709,18 @@ private:
/**
* Applies the view properties which are defined by the current URL
- * to the DolphinView properties.
+ * to the DolphinView properties. The view properties are read from a
+ * .directory file either in the current directory, or in the
+ * share/apps/dolphin/view_properties/ subfolder of the user's .kde folder.
*/
void applyViewProperties();
/**
+ * Applies the given view properties to the DolphinView.
+ */
+ void applyViewProperties(const ViewProperties& props);
+
+ /**
* Applies the m_mode property to the corresponding
* itemlayout-property of the KItemListView.
*/
@@ -723,14 +745,6 @@ private:
QMimeData* selectionMimeData() const;
/**
- * Is invoked after a paste operation or a drag & drop
- * operation and URLs from \a mimeData as selected.
- * This allows to select all newly pasted
- * items in restoreViewState().
- */
- void markPastedUrlsAsSelected(const QMimeData* mimeData);
-
- /**
* Updates m_isFolderWritable dependent on whether the folder represented by
* the current URL is writable. If the state has changed, the signal
* writeableStateChanged() will be emitted.
@@ -773,6 +787,7 @@ private:
QList<KUrl> m_selectedUrls; // Used for making the view to remember selections after F5
bool m_clearSelectionBeforeSelectingNewItems;
+ bool m_markFirstNewlySelectedItemAsCurrent;
VersionControlObserver* m_versionControlObserver;
diff --git a/src/views/dolphinviewactionhandler.cpp b/src/views/dolphinviewactionhandler.cpp
index 730723785..9a9718c33 100644
--- a/src/views/dolphinviewactionhandler.cpp
+++ b/src/views/dolphinviewactionhandler.cpp
@@ -314,14 +314,7 @@ void DolphinViewActionHandler::slotRename()
void DolphinViewActionHandler::slotTrashActivated(Qt::MouseButtons, Qt::KeyboardModifiers modifiers)
{
emit actionBeingHandled();
- // Note: kde3's konq_mainwindow.cpp used to check
- // reason == KAction::PopupMenuActivation && ...
- // but this isn't supported anymore
- if (modifiers & Qt::ShiftModifier) {
- m_currentView->deleteSelectedItems();
- } else {
- m_currentView->trashSelectedItems();
- }
+ m_currentView->trashSelectedItems();
}
void DolphinViewActionHandler::slotDeleteItems()
diff --git a/src/views/draganddrophelper.cpp b/src/views/draganddrophelper.cpp
index f81d4d0bf..f8ae0ad03 100644
--- a/src/views/draganddrophelper.cpp
+++ b/src/views/draganddrophelper.cpp
@@ -28,10 +28,13 @@
#include <QtDBus>
#include <QDropEvent>
-QString DragAndDropHelper::dropUrls(const KFileItem& destItem, const KUrl& destUrl, QDropEvent* event)
+KonqOperations* DragAndDropHelper::dropUrls(const KFileItem& destItem, const KUrl& destUrl, QDropEvent* event, QString& error)
{
+ error.clear();
+
if (!destItem.isNull() && !destItem.isWritable()) {
- return i18nc("@info:status", "Access denied. Could not write to <filename>%1</filename>", destUrl.pathOrUrl());
+ error = i18nc("@info:status", "Access denied. Could not write to <filename>%1</filename>", destUrl.pathOrUrl());
+ return 0;
}
const QMimeData* mimeData = event->mimeData();
@@ -49,15 +52,16 @@ QString DragAndDropHelper::dropUrls(const KFileItem& destItem, const KUrl& destU
const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
foreach (const KUrl& url, urls) {
if (url == destUrl) {
- return i18nc("@info:status", "A folder cannot be dropped into itself");
+ error = i18nc("@info:status", "A folder cannot be dropped into itself");
+ return 0;
}
}
- KonqOperations::doDrop(destItem, destUrl, event, QApplication::activeWindow());
+ return KonqOperations::doDrop(destItem, destUrl, event, QApplication::activeWindow(), QList<QAction*>());
} else {
- KonqOperations::doDrop(KFileItem(), destUrl, event, QApplication::activeWindow());
+ return KonqOperations::doDrop(KFileItem(), destUrl, event, QApplication::activeWindow(), QList<QAction*>());
}
- return QString();
+ return 0;
}
diff --git a/src/views/draganddrophelper.h b/src/views/draganddrophelper.h
index ac16f7cf2..eda5fc5c2 100644
--- a/src/views/draganddrophelper.h
+++ b/src/views/draganddrophelper.h
@@ -29,6 +29,7 @@ class KFileItem;
class KUrl;
class QDropEvent;
class QWidget;
+class KonqOperations;
class LIBDOLPHINPRIVATE_EXPORT DragAndDropHelper
{
@@ -46,13 +47,15 @@ public:
* @param destUrl URL of the item destination. Is used only if destItem::isNull()
* is true.
* @param event Drop event.
- * @return Error message intended to be shown for users if dropping is not
+ * @param error Error message intended to be shown for users if dropping is not
* possible. If an empty string is returned, the dropping has been
* successful.
+ * @return KonqOperations pointer
*/
- static QString dropUrls(const KFileItem& destItem,
- const KUrl& destUrl,
- QDropEvent* event);
+ static KonqOperations* dropUrls(const KFileItem& destItem,
+ const KUrl& destUrl,
+ QDropEvent* event,
+ QString& error);
};
#endif
diff --git a/src/views/renamedialog.cpp b/src/views/renamedialog.cpp
index abb37b897..d8dbd7749 100644
--- a/src/views/renamedialog.cpp
+++ b/src/views/renamedialog.cpp
@@ -146,7 +146,13 @@ void RenameDialog::slotButtonClicked(int button)
const KUrl oldUrl = m_items.first().url();
KUrl newUrl = oldUrl;
newUrl.setFileName(KIO::encodeFileName(m_newName));
- KonqOperations::rename(this, oldUrl, newUrl);
+
+ QWidget* widget = parentWidget();
+ if (!widget) {
+ widget = this;
+ }
+
+ KonqOperations::rename(widget, oldUrl, newUrl);
} else {
renameItems();
}
@@ -191,7 +197,13 @@ void RenameDialog::renameItems()
if (oldUrl.fileName() != newName) {
KUrl newUrl = oldUrl;
newUrl.setFileName(KIO::encodeFileName(newName));
- KonqOperations::rename(this, oldUrl, newUrl);
+
+ QWidget* widget = parentWidget();
+ if (!widget) {
+ widget = this;
+ }
+
+ KonqOperations::rename(widget, oldUrl, newUrl);
}
}
}
diff --git a/src/views/versioncontrol/updateitemstatesthread.cpp b/src/views/versioncontrol/updateitemstatesthread.cpp
index e07d72c76..fa005f8f1 100644
--- a/src/views/versioncontrol/updateitemstatesthread.cpp
+++ b/src/views/versioncontrol/updateitemstatesthread.cpp
@@ -23,13 +23,13 @@
#include <QMutexLocker>
-UpdateItemStatesThread::UpdateItemStatesThread() :
+UpdateItemStatesThread::UpdateItemStatesThread(KVersionControlPlugin* plugin,
+ const QList<VersionControlObserver::ItemState>& itemStates) :
QThread(),
m_globalPluginMutex(0),
- m_plugin(0),
- m_itemMutex(),
+ m_plugin(plugin),
m_retrievedItems(false),
- m_itemStates()
+ m_itemStates(itemStates)
{
// Several threads may share one instance of a plugin. A global
// mutex is required to serialize the retrieval of version control
@@ -42,32 +42,16 @@ UpdateItemStatesThread::~UpdateItemStatesThread()
{
}
-void UpdateItemStatesThread::setData(KVersionControlPlugin* plugin,
- const QList<VersionControlObserver::ItemState>& itemStates)
-{
- // The locks are taken in the same order as in run()
- // to avoid potential deadlock.
- QMutexLocker pluginLocker(m_globalPluginMutex);
- QMutexLocker itemLocker(&m_itemMutex);
-
- m_itemStates = itemStates;
- m_plugin = plugin;
-}
-
void UpdateItemStatesThread::run()
{
Q_ASSERT(!m_itemStates.isEmpty());
Q_ASSERT(m_plugin);
- QMutexLocker itemLocker(&m_itemMutex);
-
const QString directory = m_itemStates.first().item.url().directory(KUrl::AppendTrailingSlash);
m_retrievedItems = false;
- itemLocker.unlock();
QMutexLocker pluginLocker(m_globalPluginMutex);
if (m_plugin->beginRetrieval(directory)) {
- itemLocker.relock();
const int count = m_itemStates.count();
KVersionControlPlugin2* pluginV2 = qobject_cast<KVersionControlPlugin2*>(m_plugin);
@@ -99,13 +83,11 @@ void UpdateItemStatesThread::unlockPlugin()
QList<VersionControlObserver::ItemState> UpdateItemStatesThread::itemStates() const
{
- QMutexLocker locker(&m_itemMutex);
return m_itemStates;
}
bool UpdateItemStatesThread::retrievedItems() const
{
- QMutexLocker locker(&m_itemMutex);
return m_retrievedItems;
}
diff --git a/src/views/versioncontrol/updateitemstatesthread.h b/src/views/versioncontrol/updateitemstatesthread.h
index f0f91d7d2..a28169755 100644
--- a/src/views/versioncontrol/updateitemstatesthread.h
+++ b/src/views/versioncontrol/updateitemstatesthread.h
@@ -38,9 +38,6 @@ class LIBDOLPHINPRIVATE_EXPORT UpdateItemStatesThread : public QThread
Q_OBJECT
public:
- UpdateItemStatesThread();
- virtual ~UpdateItemStatesThread();
-
/**
* @param plugin Version control plugin that is used to update the
* state of the items. Whenever the plugin is accessed
@@ -49,8 +46,9 @@ public:
* UpdateItemStatesThread::unlockPlugin() must be used.
* @param itemStates List of items, where the states get updated.
*/
- void setData(KVersionControlPlugin* plugin,
- const QList<VersionControlObserver::ItemState>& itemStates);
+ UpdateItemStatesThread(KVersionControlPlugin* plugin,
+ const QList<VersionControlObserver::ItemState>& itemStates);
+ virtual ~UpdateItemStatesThread();
/**
* Whenever the plugin is accessed by the thread creator, lockPlugin() must
@@ -76,7 +74,6 @@ private:
QMutex* m_globalPluginMutex; // Protects the m_plugin globally
KVersionControlPlugin* m_plugin;
- mutable QMutex m_itemMutex; // Protects m_retrievedItems and m_itemStates
bool m_retrievedItems;
QList<VersionControlObserver::ItemState> m_itemStates;
};
diff --git a/src/views/versioncontrol/versioncontrolobserver.cpp b/src/views/versioncontrol/versioncontrolobserver.cpp
index 64bc26867..402a2de54 100644
--- a/src/views/versioncontrol/versioncontrolobserver.cpp
+++ b/src/views/versioncontrol/versioncontrolobserver.cpp
@@ -108,12 +108,7 @@ QList<QAction*> VersionControlObserver::actions(const KFileItemList& items) cons
if (pluginV2) {
// Use version 2 of the KVersionControlPlugin which allows providing actions
// also for non-versioned directories.
- if (m_updateItemStatesThread && m_updateItemStatesThread->lockPlugin()) {
- actions = pluginV2->actions(items);
- m_updateItemStatesThread->unlockPlugin();
- } else {
- actions = pluginV2->actions(items);
- }
+ actions = pluginV2->actions(items);
} else if (isVersioned()) {
// Support deprecated interfaces from KVersionControlPlugin version 1.
// Context menu actions where only available for versioned directories.
@@ -125,14 +120,8 @@ QList<QAction*> VersionControlObserver::actions(const KFileItemList& items) cons
}
}
- if (m_updateItemStatesThread && m_updateItemStatesThread->lockPlugin()) {
- actions = directory.isEmpty() ? m_plugin->contextMenuActions(items)
- : m_plugin->contextMenuActions(directory);
- m_updateItemStatesThread->unlockPlugin();
- } else {
- actions = directory.isEmpty() ? m_plugin->contextMenuActions(items)
- : m_plugin->contextMenuActions(directory);
- }
+ actions = directory.isEmpty() ? m_plugin->contextMenuActions(items)
+ : m_plugin->contextMenuActions(directory);
}
return actions;
@@ -238,20 +227,12 @@ void VersionControlObserver::slotThreadFinished()
void VersionControlObserver::updateItemStates()
{
Q_ASSERT(m_plugin);
- if (!m_updateItemStatesThread) {
- m_updateItemStatesThread = new UpdateItemStatesThread();
- connect(m_updateItemStatesThread, SIGNAL(finished()),
- this, SLOT(slotThreadFinished()));
- connect(m_updateItemStatesThread, SIGNAL(finished()),
- m_updateItemStatesThread, SLOT(deleteLater()));
- }
- else {
+ if (m_updateItemStatesThread) {
// An update is currently ongoing. Wait until the thread has finished
// the update (see slotThreadFinished()).
m_pendingItemStatesUpdate = true;
return;
}
-
QList<ItemState> itemStates;
const int itemCount = m_model->count();
itemStates.reserve(itemCount);
@@ -269,7 +250,12 @@ void VersionControlObserver::updateItemStates()
if (!m_silentUpdate) {
emit infoMessage(i18nc("@info:status", "Updating version information..."));
}
- m_updateItemStatesThread->setData(m_plugin, itemStates);
+ m_updateItemStatesThread = new UpdateItemStatesThread(m_plugin, itemStates);
+ connect(m_updateItemStatesThread, SIGNAL(finished()),
+ this, SLOT(slotThreadFinished()));
+ connect(m_updateItemStatesThread, SIGNAL(finished()),
+ m_updateItemStatesThread, SLOT(deleteLater()));
+
m_updateItemStatesThread->start(); // slotThreadFinished() is called when finished
}
}