mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
InformationPanel: Allow to refresh the panel when its displayed content changes
BUG: 430095 BUG: 412902 FIXED-IN: 21.08
This commit is contained in:
parent
020ba2c3fc
commit
6cec386192
|
@ -24,7 +24,6 @@
|
||||||
#include "panels/folders/folderspanel.h"
|
#include "panels/folders/folderspanel.h"
|
||||||
#include "panels/places/placesitemmodel.h"
|
#include "panels/places/placesitemmodel.h"
|
||||||
#include "panels/places/placespanel.h"
|
#include "panels/places/placespanel.h"
|
||||||
#include "panels/information/informationpanel.h"
|
|
||||||
#include "panels/terminal/terminalpanel.h"
|
#include "panels/terminal/terminalpanel.h"
|
||||||
#include "settings/dolphinsettingsdialog.h"
|
#include "settings/dolphinsettingsdialog.h"
|
||||||
#include "statusbar/dolphinstatusbar.h"
|
#include "statusbar/dolphinstatusbar.h"
|
||||||
|
@ -1788,6 +1787,8 @@ void DolphinMainWindow::setupDockWidgets()
|
||||||
infoPanel, &InformationPanel::setSelection);
|
infoPanel, &InformationPanel::setSelection);
|
||||||
connect(this, &DolphinMainWindow::requestItemInfo,
|
connect(this, &DolphinMainWindow::requestItemInfo,
|
||||||
infoPanel, &InformationPanel::requestDelayedItemInfo);
|
infoPanel, &InformationPanel::requestDelayedItemInfo);
|
||||||
|
connect(this, &DolphinMainWindow::fileItemsChanged,
|
||||||
|
infoPanel, &InformationPanel::slotFilesItemChanged);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// i18n: This is the last paragraph for the "What's This"-texts of all four panels.
|
// i18n: This is the last paragraph for the "What's This"-texts of all four panels.
|
||||||
|
@ -2173,6 +2174,8 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container)
|
||||||
this, &DolphinMainWindow::slotSelectionChanged);
|
this, &DolphinMainWindow::slotSelectionChanged);
|
||||||
connect(view, &DolphinView::requestItemInfo,
|
connect(view, &DolphinView::requestItemInfo,
|
||||||
this, &DolphinMainWindow::requestItemInfo);
|
this, &DolphinMainWindow::requestItemInfo);
|
||||||
|
connect(view, &DolphinView::fileItemsChanged,
|
||||||
|
this, &DolphinMainWindow::fileItemsChanged);
|
||||||
connect(view, &DolphinView::tabRequested,
|
connect(view, &DolphinView::tabRequested,
|
||||||
this, &DolphinMainWindow::openNewTab);
|
this, &DolphinMainWindow::openNewTab);
|
||||||
connect(view, &DolphinView::requestContextMenu,
|
connect(view, &DolphinView::requestContextMenu,
|
||||||
|
|
|
@ -15,6 +15,10 @@
|
||||||
#include <KSortableList>
|
#include <KSortableList>
|
||||||
#include <kxmlguiwindow.h>
|
#include <kxmlguiwindow.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_BALOO
|
||||||
|
#include "panels/information/informationpanel.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
@ -192,6 +196,12 @@ Q_SIGNALS:
|
||||||
*/
|
*/
|
||||||
void requestItemInfo(const KFileItem& item);
|
void requestItemInfo(const KFileItem& item);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It is emitted when in the current view, files are changed,
|
||||||
|
* or dirs have files/removed from them.
|
||||||
|
*/
|
||||||
|
void fileItemsChanged(const KFileItemList &changedFileItems);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is emitted if the settings have been changed.
|
* Is emitted if the settings have been changed.
|
||||||
*/
|
*/
|
||||||
|
@ -656,7 +666,6 @@ private:
|
||||||
QMetaObject::Connection m_updateHistoryConnection;
|
QMetaObject::Connection m_updateHistoryConnection;
|
||||||
|
|
||||||
QMenu m_searchTools;
|
QMenu m_searchTools;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline DolphinViewContainer* DolphinMainWindow::activeViewContainer() const
|
inline DolphinViewContainer* DolphinMainWindow::activeViewContainer() const
|
||||||
|
|
|
@ -1015,6 +1015,8 @@ void KFileItemModel::slotItemsAdded(const QUrl &directoryUrl, const KFileItemLis
|
||||||
// emitted during the maximum update interval.
|
// emitted during the maximum update interval.
|
||||||
m_maximumUpdateIntervalTimer->start();
|
m_maximumUpdateIntervalTimer->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Q_EMIT fileItemsChanged({KFileItem(directoryUrl)});
|
||||||
}
|
}
|
||||||
|
|
||||||
void KFileItemModel::slotItemsDeleted(const KFileItemList& items)
|
void KFileItemModel::slotItemsDeleted(const KFileItemList& items)
|
||||||
|
@ -1023,6 +1025,7 @@ void KFileItemModel::slotItemsDeleted(const KFileItemList& items)
|
||||||
|
|
||||||
QVector<int> indexesToRemove;
|
QVector<int> indexesToRemove;
|
||||||
indexesToRemove.reserve(items.count());
|
indexesToRemove.reserve(items.count());
|
||||||
|
KFileItemList dirsChanged;
|
||||||
|
|
||||||
for (const KFileItem& item : items) {
|
for (const KFileItem& item : items) {
|
||||||
const int indexForItem = index(item);
|
const int indexForItem = index(item);
|
||||||
|
@ -1036,6 +1039,11 @@ void KFileItemModel::slotItemsDeleted(const KFileItemList& items)
|
||||||
m_filteredItems.erase(it);
|
m_filteredItems.erase(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QUrl parentUrl = item.url().adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash);
|
||||||
|
if (dirsChanged.findByUrl(parentUrl).isNull()) {
|
||||||
|
dirsChanged << KFileItem(parentUrl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::sort(indexesToRemove.begin(), indexesToRemove.end());
|
std::sort(indexesToRemove.begin(), indexesToRemove.end());
|
||||||
|
@ -1063,6 +1071,8 @@ void KFileItemModel::slotItemsDeleted(const KFileItemList& items)
|
||||||
const KItemRangeList itemRanges = KItemRangeList::fromSortedContainer(indexesToRemove);
|
const KItemRangeList itemRanges = KItemRangeList::fromSortedContainer(indexesToRemove);
|
||||||
removeFilteredChildren(itemRanges);
|
removeFilteredChildren(itemRanges);
|
||||||
removeItems(itemRanges, DeleteItemData);
|
removeItems(itemRanges, DeleteItemData);
|
||||||
|
|
||||||
|
Q_EMIT fileItemsChanged(dirsChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KFileItemModel::slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >& items)
|
void KFileItemModel::slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >& items)
|
||||||
|
@ -1077,6 +1087,7 @@ void KFileItemModel::slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >&
|
||||||
indexes.reserve(items.count());
|
indexes.reserve(items.count());
|
||||||
|
|
||||||
QSet<QByteArray> changedRoles;
|
QSet<QByteArray> changedRoles;
|
||||||
|
KFileItemList changedFiles;
|
||||||
|
|
||||||
QListIterator<QPair<KFileItem, KFileItem> > it(items);
|
QListIterator<QPair<KFileItem, KFileItem> > it(items);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
|
@ -1102,6 +1113,7 @@ void KFileItemModel::slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >&
|
||||||
|
|
||||||
m_items.remove(oldItem.url());
|
m_items.remove(oldItem.url());
|
||||||
m_items.insert(newItem.url(), indexForItem);
|
m_items.insert(newItem.url(), indexForItem);
|
||||||
|
changedFiles.append(newItem);
|
||||||
indexes.append(indexForItem);
|
indexes.append(indexForItem);
|
||||||
} else {
|
} else {
|
||||||
// Check if 'oldItem' is one of the filtered items.
|
// Check if 'oldItem' is one of the filtered items.
|
||||||
|
@ -1130,6 +1142,8 @@ void KFileItemModel::slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >&
|
||||||
std::sort(indexes.begin(), indexes.end());
|
std::sort(indexes.begin(), indexes.end());
|
||||||
const KItemRangeList itemRangeList = KItemRangeList::fromSortedContainer(indexes);
|
const KItemRangeList itemRangeList = KItemRangeList::fromSortedContainer(indexes);
|
||||||
emitItemsChangedAndTriggerResorting(itemRangeList, changedRoles);
|
emitItemsChangedAndTriggerResorting(itemRangeList, changedRoles);
|
||||||
|
|
||||||
|
Q_EMIT fileItemsChanged(changedFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KFileItemModel::slotClear()
|
void KFileItemModel::slotClear()
|
||||||
|
|
|
@ -245,6 +245,12 @@ Q_SIGNALS:
|
||||||
*/
|
*/
|
||||||
void urlIsFileError(const QUrl& url);
|
void urlIsFileError(const QUrl& url);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It is emitted for files when they change and
|
||||||
|
* for dirs when files are added or removed.
|
||||||
|
*/
|
||||||
|
void fileItemsChanged(const KFileItemList &changedFileItems);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onGroupedSortingChanged(bool current) override;
|
void onGroupedSortingChanged(bool current) override;
|
||||||
void onSortRoleChanged(const QByteArray& current, const QByteArray& previous, bool resortItems = true) override;
|
void onSortRoleChanged(const QByteArray& current, const QByteArray& previous, bool resortItems = true) override;
|
||||||
|
|
|
@ -242,6 +242,7 @@ void InformationPanel::showItemInfo()
|
||||||
connect(m_folderStatJob, &KIO::Job::result,
|
connect(m_folderStatJob, &KIO::Job::result,
|
||||||
this, &InformationPanel::slotFolderStatFinished);
|
this, &InformationPanel::slotFolderStatFinished);
|
||||||
} else {
|
} else {
|
||||||
|
m_shownUrl = item.url();
|
||||||
m_content->showItem(item);
|
m_content->showItem(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -303,6 +304,15 @@ void InformationPanel::slotFilesAdded(const QString& directory)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InformationPanel::slotFilesItemChanged(const KFileItemList &changedFileItems)
|
||||||
|
{
|
||||||
|
const auto item = changedFileItems.findByUrl(m_shownUrl);
|
||||||
|
if (!item.isNull()) {
|
||||||
|
m_fileItem = item;
|
||||||
|
showItemInfo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void InformationPanel::slotFilesChanged(const QStringList& files)
|
void InformationPanel::slotFilesChanged(const QStringList& files)
|
||||||
{
|
{
|
||||||
for (const QString& fileName : files) {
|
for (const QString& fileName : files) {
|
||||||
|
|
|
@ -46,6 +46,8 @@ public Q_SLOTS:
|
||||||
*/
|
*/
|
||||||
void requestDelayedItemInfo(const KFileItem& item);
|
void requestDelayedItemInfo(const KFileItem& item);
|
||||||
|
|
||||||
|
void slotFilesItemChanged(const KFileItemList &changedFileItems);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** @see Panel::urlChanged() */
|
/** @see Panel::urlChanged() */
|
||||||
bool urlChanged() override;
|
bool urlChanged() override;
|
||||||
|
|
|
@ -179,6 +179,7 @@ DolphinView::DolphinView(const QUrl& url, QWidget* parent) :
|
||||||
connect(m_model, &KFileItemModel::errorMessage, this, &DolphinView::errorMessage);
|
connect(m_model, &KFileItemModel::errorMessage, this, &DolphinView::errorMessage);
|
||||||
connect(m_model, &KFileItemModel::directoryRedirection, this, &DolphinView::slotDirectoryRedirection);
|
connect(m_model, &KFileItemModel::directoryRedirection, this, &DolphinView::slotDirectoryRedirection);
|
||||||
connect(m_model, &KFileItemModel::urlIsFileError, this, &DolphinView::urlIsFileError);
|
connect(m_model, &KFileItemModel::urlIsFileError, this, &DolphinView::urlIsFileError);
|
||||||
|
connect(m_model, &KFileItemModel::fileItemsChanged, this, &DolphinView::fileItemsChanged);
|
||||||
|
|
||||||
connect(this, &DolphinView::itemCountChanged,
|
connect(this, &DolphinView::itemCountChanged,
|
||||||
this, &DolphinView::updatePlaceholderLabel);
|
this, &DolphinView::updatePlaceholderLabel);
|
||||||
|
|
|
@ -593,6 +593,8 @@ Q_SIGNALS:
|
||||||
|
|
||||||
void goUpRequested();
|
void goUpRequested();
|
||||||
|
|
||||||
|
void fileItemsChanged(const KFileItemList &changedFileItems);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** Changes the zoom level if Control is pressed during a wheel event. */
|
/** Changes the zoom level if Control is pressed during a wheel event. */
|
||||||
void wheelEvent(QWheelEvent* event) override;
|
void wheelEvent(QWheelEvent* event) override;
|
||||||
|
|
Loading…
Reference in a new issue