mirror of
https://invent.kde.org/system/dolphin
synced 2024-07-07 10:51:45 +00:00
Add clang-format and format code as in Frameworks
This commit is contained in:
parent
ffff8af851
commit
38c34eeca3
|
@ -219,3 +219,10 @@ install(FILES completions/dolphin.zsh RENAME _dolphin DESTINATION ${KDE_INSTALL_
|
||||||
|
|
||||||
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
||||||
|
|
||||||
|
include(KDEClangFormat)
|
||||||
|
# add clang-format target
|
||||||
|
file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h *.c)
|
||||||
|
kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})
|
||||||
|
|
||||||
|
include(KDEGitCommitHooks)
|
||||||
|
kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "dbusinterface.h"
|
#include "dbusinterface.h"
|
||||||
#include "global.h"
|
|
||||||
#include "dolphin_generalsettings.h"
|
#include "dolphin_generalsettings.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
#include <KPropertiesDialog>
|
#include <KPropertiesDialog>
|
||||||
#include <KWindowSystem>
|
#include <KWindowSystem>
|
||||||
|
@ -14,10 +14,11 @@
|
||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
#include <QDBusConnectionInterface>
|
#include <QDBusConnectionInterface>
|
||||||
|
|
||||||
DBusInterface::DBusInterface() :
|
DBusInterface::DBusInterface()
|
||||||
QObject()
|
: QObject()
|
||||||
{
|
{
|
||||||
QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/freedesktop/FileManager1"), this,
|
QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/freedesktop/FileManager1"),
|
||||||
|
this,
|
||||||
QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors);
|
QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors);
|
||||||
QDBusConnectionInterface *sessionInterface = QDBusConnection::sessionBus().interface();
|
QDBusConnectionInterface *sessionInterface = QDBusConnection::sessionBus().interface();
|
||||||
if (sessionInterface) {
|
if (sessionInterface) {
|
||||||
|
|
|
@ -14,15 +14,11 @@
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
DolphinBookmarkHandler::DolphinBookmarkHandler(DolphinMainWindow *mainWindow,
|
DolphinBookmarkHandler::DolphinBookmarkHandler(DolphinMainWindow *mainWindow, KActionCollection *collection, QMenu *menu, QObject *parent)
|
||||||
KActionCollection* collection,
|
: QObject(parent)
|
||||||
QMenu* menu,
|
, m_mainWindow(mainWindow)
|
||||||
QObject* parent) :
|
|
||||||
QObject(parent),
|
|
||||||
m_mainWindow(mainWindow)
|
|
||||||
{
|
{
|
||||||
QString bookmarksFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
|
QString bookmarksFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kfile/bookmarks.xml"));
|
||||||
QStringLiteral("kfile/bookmarks.xml"));
|
|
||||||
if (bookmarksFile.isEmpty()) {
|
if (bookmarksFile.isEmpty()) {
|
||||||
QString genericDataLocation = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
|
QString genericDataLocation = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
|
||||||
if (genericDataLocation.isEmpty()) {
|
if (genericDataLocation.isEmpty()) {
|
||||||
|
@ -79,8 +75,10 @@ QList<KBookmarkOwner::FutureBookmark> DolphinBookmarkHandler::currentBookmarkLis
|
||||||
bool DolphinBookmarkHandler::enableOption(KBookmarkOwner::BookmarkOption option) const
|
bool DolphinBookmarkHandler::enableOption(KBookmarkOwner::BookmarkOption option) const
|
||||||
{
|
{
|
||||||
switch (option) {
|
switch (option) {
|
||||||
case BookmarkOption::ShowAddBookmark: return true;
|
case BookmarkOption::ShowAddBookmark:
|
||||||
case BookmarkOption::ShowEditBookmark: return true;
|
return true;
|
||||||
|
case BookmarkOption::ShowEditBookmark:
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ private:
|
||||||
static QString title(DolphinViewContainer *viewContainer);
|
static QString title(DolphinViewContainer *viewContainer);
|
||||||
static QUrl url(DolphinViewContainer *viewContainer);
|
static QUrl url(DolphinViewContainer *viewContainer);
|
||||||
static QString icon(DolphinViewContainer *viewContainer);
|
static QString icon(DolphinViewContainer *viewContainer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DolphinMainWindow *m_mainWindow;
|
DolphinMainWindow *m_mainWindow;
|
||||||
KBookmarkManager *m_bookmarkManager;
|
KBookmarkManager *m_bookmarkManager;
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
|
|
||||||
#include "dolphincontextmenu.h"
|
#include "dolphincontextmenu.h"
|
||||||
|
|
||||||
#include "dolphin_generalsettings.h"
|
|
||||||
#include "dolphin_contextmenusettings.h"
|
#include "dolphin_contextmenusettings.h"
|
||||||
|
#include "dolphin_generalsettings.h"
|
||||||
#include "dolphinmainwindow.h"
|
#include "dolphinmainwindow.h"
|
||||||
#include "dolphinnewfilemenu.h"
|
#include "dolphinnewfilemenu.h"
|
||||||
#include "dolphinplacesmodelsingleton.h"
|
#include "dolphinplacesmodelsingleton.h"
|
||||||
|
@ -39,18 +39,18 @@ DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent,
|
||||||
const KFileItem &fileInfo,
|
const KFileItem &fileInfo,
|
||||||
const KFileItemList &selectedItems,
|
const KFileItemList &selectedItems,
|
||||||
const QUrl &baseUrl,
|
const QUrl &baseUrl,
|
||||||
KFileItemActions *fileItemActions) :
|
KFileItemActions *fileItemActions)
|
||||||
QMenu(parent),
|
: QMenu(parent)
|
||||||
m_mainWindow(parent),
|
, m_mainWindow(parent)
|
||||||
m_fileInfo(fileInfo),
|
, m_fileInfo(fileInfo)
|
||||||
m_baseUrl(baseUrl),
|
, m_baseUrl(baseUrl)
|
||||||
m_baseFileItem(nullptr),
|
, m_baseFileItem(nullptr)
|
||||||
m_selectedItems(selectedItems),
|
, m_selectedItems(selectedItems)
|
||||||
m_selectedItemsProperties(nullptr),
|
, m_selectedItemsProperties(nullptr)
|
||||||
m_context(NoContext),
|
, m_context(NoContext)
|
||||||
m_copyToMenu(parent),
|
, m_copyToMenu(parent)
|
||||||
m_removeAction(nullptr),
|
, m_removeAction(nullptr)
|
||||||
m_fileItemActions(fileItemActions)
|
, m_fileItemActions(fileItemActions)
|
||||||
{
|
{
|
||||||
QApplication::instance()->installEventFilter(this);
|
QApplication::instance()->installEventFilter(this);
|
||||||
|
|
||||||
|
@ -67,8 +67,7 @@ DolphinContextMenu::~DolphinContextMenu()
|
||||||
|
|
||||||
void DolphinContextMenu::addAllActions()
|
void DolphinContextMenu::addAllActions()
|
||||||
{
|
{
|
||||||
static_cast<KHamburgerMenu *>(m_mainWindow->actionCollection()->
|
static_cast<KHamburgerMenu *>(m_mainWindow->actionCollection()->action(QStringLiteral("hamburger_menu")))->addToMenu(this);
|
||||||
action(QStringLiteral("hamburger_menu")))->addToMenu(this);
|
|
||||||
|
|
||||||
// get the context information
|
// get the context information
|
||||||
const auto scheme = m_baseUrl.scheme();
|
const auto scheme = m_baseUrl.scheme();
|
||||||
|
@ -204,26 +203,17 @@ void DolphinContextMenu::addItemContextMenu()
|
||||||
} else if (m_context & TimelineContext || m_context & SearchContext) {
|
} else if (m_context & TimelineContext || m_context & SearchContext) {
|
||||||
addOpenWithActions();
|
addOpenWithActions();
|
||||||
|
|
||||||
addAction(QIcon::fromTheme(QStringLiteral("document-open-folder")),
|
addAction(QIcon::fromTheme(QStringLiteral("document-open-folder")), i18nc("@action:inmenu", "Open Path"), [this]() {
|
||||||
i18nc("@action:inmenu",
|
|
||||||
"Open Path"),
|
|
||||||
[this](){
|
|
||||||
m_mainWindow->changeUrl(KIO::upUrl(m_fileInfo.url()));
|
m_mainWindow->changeUrl(KIO::upUrl(m_fileInfo.url()));
|
||||||
m_mainWindow->activeViewContainer()->view()->markUrlsAsSelected({m_fileInfo.url()});
|
m_mainWindow->activeViewContainer()->view()->markUrlsAsSelected({m_fileInfo.url()});
|
||||||
m_mainWindow->activeViewContainer()->view()->markUrlAsCurrent(m_fileInfo.url());
|
m_mainWindow->activeViewContainer()->view()->markUrlAsCurrent(m_fileInfo.url());
|
||||||
});
|
});
|
||||||
|
|
||||||
addAction(QIcon::fromTheme(QStringLiteral("window-new")),
|
addAction(QIcon::fromTheme(QStringLiteral("window-new")), i18nc("@action:inmenu", "Open Path in New Window"), [this]() {
|
||||||
i18nc("@action:inmenu",
|
|
||||||
"Open Path in New Window"),
|
|
||||||
[this](){
|
|
||||||
Dolphin::openNewWindow({m_fileInfo.url()}, m_mainWindow, Dolphin::OpenNewWindowFlag::Select);
|
Dolphin::openNewWindow({m_fileInfo.url()}, m_mainWindow, Dolphin::OpenNewWindowFlag::Select);
|
||||||
});
|
});
|
||||||
|
|
||||||
addAction(QIcon::fromTheme(QStringLiteral("tab-new")),
|
addAction(QIcon::fromTheme(QStringLiteral("tab-new")), i18nc("@action:inmenu", "Open Path in New Tab"), [this]() {
|
||||||
i18nc("@action:inmenu",
|
|
||||||
"Open Path in New Tab"),
|
|
||||||
[this](){
|
|
||||||
m_mainWindow->openNewTab(KIO::upUrl(m_fileInfo.url()));
|
m_mainWindow->openNewTab(KIO::upUrl(m_fileInfo.url()));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -298,8 +288,7 @@ void DolphinContextMenu::addViewportContextMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert 'Add to Places' entry if it's not already in the places panel
|
// Insert 'Add to Places' entry if it's not already in the places panel
|
||||||
if (ContextMenuSettings::showAddToPlaces() &&
|
if (ContextMenuSettings::showAddToPlaces() && !placeExists(m_mainWindow->activeViewContainer()->url())) {
|
||||||
!placeExists(m_mainWindow->activeViewContainer()->url())) {
|
|
||||||
addAction(m_mainWindow->actionCollection()->action(QStringLiteral("add_to_places")));
|
addAction(m_mainWindow->actionCollection()->action(QStringLiteral("add_to_places")));
|
||||||
}
|
}
|
||||||
addSeparator();
|
addSeparator();
|
||||||
|
@ -349,20 +338,15 @@ void DolphinContextMenu::insertDefaultItemActions(const KFileItemListProperties&
|
||||||
addAction(collection->action(KStandardAction::name(KStandardAction::RenameFile)));
|
addAction(collection->action(KStandardAction::name(KStandardAction::RenameFile)));
|
||||||
|
|
||||||
// Insert 'Add to Places' entry if appropriate
|
// Insert 'Add to Places' entry if appropriate
|
||||||
if (ContextMenuSettings::showAddToPlaces() &&
|
if (ContextMenuSettings::showAddToPlaces() && m_selectedItems.count() == 1 && m_fileInfo.isDir() && !placeExists(m_fileInfo.url())) {
|
||||||
m_selectedItems.count() == 1 &&
|
|
||||||
m_fileInfo.isDir() &&
|
|
||||||
!placeExists(m_fileInfo.url())) {
|
|
||||||
addAction(m_mainWindow->actionCollection()->action(QStringLiteral("add_to_places")));
|
addAction(m_mainWindow->actionCollection()->action(QStringLiteral("add_to_places")));
|
||||||
}
|
}
|
||||||
|
|
||||||
addSeparator();
|
addSeparator();
|
||||||
|
|
||||||
// Insert 'Move to Trash' and/or 'Delete'
|
// Insert 'Move to Trash' and/or 'Delete'
|
||||||
const bool showDeleteAction = (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) ||
|
const bool showDeleteAction = (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) || !properties.isLocal());
|
||||||
!properties.isLocal());
|
const bool showMoveToTrashAction = (properties.isLocal() && properties.supportsMoving());
|
||||||
const bool showMoveToTrashAction = (properties.isLocal() &&
|
|
||||||
properties.supportsMoving());
|
|
||||||
|
|
||||||
if (showDeleteAction && showMoveToTrashAction) {
|
if (showDeleteAction && showMoveToTrashAction) {
|
||||||
delete m_removeAction;
|
delete m_removeAction;
|
||||||
|
@ -462,4 +446,3 @@ void DolphinContextMenu::addAdditionalActions(const KFileItemListProperties &pro
|
||||||
addSeparator();
|
addSeparator();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,8 +95,7 @@ private:
|
||||||
void addAdditionalActions(const KFileItemListProperties &props);
|
void addAdditionalActions(const KFileItemListProperties &props);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Entry
|
struct Entry {
|
||||||
{
|
|
||||||
int type;
|
int type;
|
||||||
QString name;
|
QString name;
|
||||||
QString filePath; // empty for separator
|
QString filePath; // empty for separator
|
||||||
|
@ -105,8 +104,7 @@ private:
|
||||||
QString comment;
|
QString comment;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ContextType
|
enum ContextType {
|
||||||
{
|
|
||||||
NoContext = 0,
|
NoContext = 0,
|
||||||
ItemContext = 1,
|
ItemContext = 1,
|
||||||
TrashContext = 2,
|
TrashContext = 2,
|
||||||
|
@ -130,7 +128,6 @@ private:
|
||||||
DolphinRemoveAction *m_removeAction; // Action that represents either 'Move To Trash' or 'Delete'
|
DolphinRemoveAction *m_removeAction; // Action that represents either 'Move To Trash' or 'Delete'
|
||||||
void addDirectoryItemContextMenu();
|
void addDirectoryItemContextMenu();
|
||||||
KFileItemActions *m_fileItemActions;
|
KFileItemActions *m_fileItemActions;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
|
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
|
|
||||||
namespace {
|
namespace
|
||||||
|
{
|
||||||
// Disable the 'Floatable' feature, i.e., the possibility to drag the
|
// Disable the 'Floatable' feature, i.e., the possibility to drag the
|
||||||
// dock widget out of the main window. This works around problems like
|
// dock widget out of the main window. This works around problems like
|
||||||
// https://bugs.kde.org/show_bug.cgi?id=288629
|
// https://bugs.kde.org/show_bug.cgi?id=288629
|
||||||
|
@ -22,8 +23,13 @@ class DolphinDockTitleBar : public QWidget
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DolphinDockTitleBar(QWidget* parent = nullptr) : QWidget(parent) {}
|
explicit DolphinDockTitleBar(QWidget *parent = nullptr)
|
||||||
~DolphinDockTitleBar() override {}
|
: QWidget(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
~DolphinDockTitleBar() override
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
QSize minimumSizeHint() const override
|
QSize minimumSizeHint() const override
|
||||||
{
|
{
|
||||||
|
@ -37,10 +43,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
DolphinDockWidget::DolphinDockWidget(const QString& title, QWidget* parent, Qt::WindowFlags flags) :
|
DolphinDockWidget::DolphinDockWidget(const QString &title, QWidget *parent, Qt::WindowFlags flags)
|
||||||
QDockWidget(title, parent, flags),
|
: QDockWidget(title, parent, flags)
|
||||||
m_locked(false),
|
, m_locked(false)
|
||||||
m_dockTitleBar(nullptr)
|
, m_dockTitleBar(nullptr)
|
||||||
{
|
{
|
||||||
setFeatures(DefaultDockWidgetFeatures);
|
setFeatures(DefaultDockWidgetFeatures);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -9,9 +9,9 @@
|
||||||
#ifndef DOLPHIN_MAINWINDOW_H
|
#ifndef DOLPHIN_MAINWINDOW_H
|
||||||
#define DOLPHIN_MAINWINDOW_H
|
#define DOLPHIN_MAINWINDOW_H
|
||||||
|
|
||||||
|
#include "config-dolphin.h"
|
||||||
#include "dolphintabwidget.h"
|
#include "dolphintabwidget.h"
|
||||||
#include "selectionmode/bottombar.h"
|
#include "selectionmode/bottombar.h"
|
||||||
#include "config-dolphin.h"
|
|
||||||
#include <KFileItemActions>
|
#include <KFileItemActions>
|
||||||
#include <kio/fileundomanager.h>
|
#include <kio/fileundomanager.h>
|
||||||
#include <kxmlguiwindow.h>
|
#include <kxmlguiwindow.h>
|
||||||
|
@ -44,10 +44,12 @@ class QToolButton;
|
||||||
class PlacesPanel;
|
class PlacesPanel;
|
||||||
class TerminalPanel;
|
class TerminalPanel;
|
||||||
|
|
||||||
namespace KIO {
|
namespace KIO
|
||||||
|
{
|
||||||
class OpenUrlJob;
|
class OpenUrlJob;
|
||||||
}
|
}
|
||||||
namespace SelectionMode {
|
namespace SelectionMode
|
||||||
|
{
|
||||||
class ActionTextHelper;
|
class ActionTextHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +161,6 @@ public Q_SLOTS:
|
||||||
*/
|
*/
|
||||||
bool isItemVisibleInAnyView(const QString &urlOfItem);
|
bool isItemVisibleInAnyView(const QString &urlOfItem);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pastes the clipboard data into the currently selected folder
|
* Pastes the clipboard data into the currently selected folder
|
||||||
* of the active view. If not exactly one folder is selected,
|
* of the active view. If not exactly one folder is selected,
|
||||||
|
@ -653,10 +654,7 @@ private:
|
||||||
* as the action for toggling the dock visibility is done by Qt which
|
* as the action for toggling the dock visibility is done by Qt which
|
||||||
* is no KAction instance.
|
* is no KAction instance.
|
||||||
*/
|
*/
|
||||||
void createPanelAction(const QIcon &icon,
|
void createPanelAction(const QIcon &icon, const QKeySequence &shortcut, QAction *dockAction, const QString &actionName);
|
||||||
const QKeySequence& shortcut,
|
|
||||||
QAction* dockAction,
|
|
||||||
const QString& actionName);
|
|
||||||
|
|
||||||
/** Adds "What's This?" texts to many widgets and StandardActions. */
|
/** Adds "What's This?" texts to many widgets and StandardActions. */
|
||||||
void setupWhatsThis();
|
void setupWhatsThis();
|
||||||
|
@ -727,4 +725,3 @@ inline KNewFileMenu* DolphinMainWindow::newFileMenu() const
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // DOLPHIN_MAINWINDOW_H
|
#endif // DOLPHIN_MAINWINDOW_H
|
||||||
|
|
||||||
|
|
|
@ -22,11 +22,11 @@
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
DolphinNavigatorsWidgetAction::DolphinNavigatorsWidgetAction(QWidget *parent) :
|
DolphinNavigatorsWidgetAction::DolphinNavigatorsWidgetAction(QWidget *parent)
|
||||||
QWidgetAction{parent},
|
: QWidgetAction{parent}
|
||||||
m_splitter{new QSplitter(Qt::Horizontal)},
|
, m_splitter{new QSplitter(Qt::Horizontal)}
|
||||||
m_adjustSpacingTimer{new QTimer(this)},
|
, m_adjustSpacingTimer{new QTimer(this)}
|
||||||
m_viewGeometriesHelper{m_splitter.get(), this}
|
, m_viewGeometriesHelper{m_splitter.get(), this}
|
||||||
{
|
{
|
||||||
updateText();
|
updateText();
|
||||||
setIcon(QIcon::fromTheme(QStringLiteral("dialog-scripts")));
|
setIcon(QIcon::fromTheme(QStringLiteral("dialog-scripts")));
|
||||||
|
@ -37,8 +37,7 @@ DolphinNavigatorsWidgetAction::DolphinNavigatorsWidgetAction(QWidget *parent) :
|
||||||
|
|
||||||
m_adjustSpacingTimer->setInterval(100);
|
m_adjustSpacingTimer->setInterval(100);
|
||||||
m_adjustSpacingTimer->setSingleShot(true);
|
m_adjustSpacingTimer->setSingleShot(true);
|
||||||
connect(m_adjustSpacingTimer.get(), &QTimer::timeout,
|
connect(m_adjustSpacingTimer.get(), &QTimer::timeout, this, &DolphinNavigatorsWidgetAction::adjustSpacing);
|
||||||
this, &DolphinNavigatorsWidgetAction::adjustSpacing);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinNavigatorsWidgetAction::adjustSpacing()
|
void DolphinNavigatorsWidgetAction::adjustSpacing()
|
||||||
|
@ -46,8 +45,7 @@ void DolphinNavigatorsWidgetAction::adjustSpacing()
|
||||||
m_previousWindowWidth = parentWidget()->window()->width();
|
m_previousWindowWidth = parentWidget()->window()->width();
|
||||||
auto viewGeometries = m_viewGeometriesHelper.viewGeometries();
|
auto viewGeometries = m_viewGeometriesHelper.viewGeometries();
|
||||||
const int widthOfSplitterPrimary = viewGeometries.globalXOfPrimary + viewGeometries.widthOfPrimary - viewGeometries.globalXOfNavigatorsWidget;
|
const int widthOfSplitterPrimary = viewGeometries.globalXOfPrimary + viewGeometries.widthOfPrimary - viewGeometries.globalXOfNavigatorsWidget;
|
||||||
const QList<int> splitterSizes = {widthOfSplitterPrimary,
|
const QList<int> splitterSizes = {widthOfSplitterPrimary, m_splitter->width() - widthOfSplitterPrimary};
|
||||||
m_splitter->width() - widthOfSplitterPrimary};
|
|
||||||
m_splitter->setSizes(splitterSizes);
|
m_splitter->setSizes(splitterSizes);
|
||||||
|
|
||||||
// primary side of m_splitter
|
// primary side of m_splitter
|
||||||
|
@ -55,11 +53,8 @@ void DolphinNavigatorsWidgetAction::adjustSpacing()
|
||||||
if (leadingSpacing < 0) {
|
if (leadingSpacing < 0) {
|
||||||
leadingSpacing = 0;
|
leadingSpacing = 0;
|
||||||
}
|
}
|
||||||
int trailingSpacing = (viewGeometries.globalXOfNavigatorsWidget + m_splitter->width())
|
int trailingSpacing = (viewGeometries.globalXOfNavigatorsWidget + m_splitter->width()) - (viewGeometries.globalXOfPrimary + viewGeometries.widthOfPrimary);
|
||||||
- (viewGeometries.globalXOfPrimary + viewGeometries.widthOfPrimary);
|
if (trailingSpacing < 0 || emptyTrashButton(Primary)->isVisible() || networkFolderButton(Primary)->isVisible()) {
|
||||||
if (trailingSpacing < 0 || emptyTrashButton(Primary)->isVisible()
|
|
||||||
|| networkFolderButton(Primary)->isVisible()
|
|
||||||
) {
|
|
||||||
trailingSpacing = 0;
|
trailingSpacing = 0;
|
||||||
}
|
}
|
||||||
const int widthLeftForUrlNavigator = m_splitter->widget(0)->width() - leadingSpacing - trailingSpacing;
|
const int widthLeftForUrlNavigator = m_splitter->widget(0)->width() - leadingSpacing - trailingSpacing;
|
||||||
|
@ -84,11 +79,8 @@ void DolphinNavigatorsWidgetAction::adjustSpacing()
|
||||||
}
|
}
|
||||||
spacing(Primary, Trailing)->setFixedWidth(0);
|
spacing(Primary, Trailing)->setFixedWidth(0);
|
||||||
|
|
||||||
trailingSpacing = (viewGeometries.globalXOfNavigatorsWidget + m_splitter->width())
|
trailingSpacing = (viewGeometries.globalXOfNavigatorsWidget + m_splitter->width()) - (viewGeometries.globalXOfSecondary + viewGeometries.widthOfSecondary);
|
||||||
- (viewGeometries.globalXOfSecondary + viewGeometries.widthOfSecondary);
|
if (trailingSpacing < 0 || emptyTrashButton(Secondary)->isVisible() || networkFolderButton(Secondary)->isVisible()) {
|
||||||
if (trailingSpacing < 0 || emptyTrashButton(Secondary)->isVisible()
|
|
||||||
|| networkFolderButton(Secondary)->isVisible()
|
|
||||||
) {
|
|
||||||
trailingSpacing = 0;
|
trailingSpacing = 0;
|
||||||
} else {
|
} else {
|
||||||
const int widthLeftForUrlNavigator2 = m_splitter->widget(1)->width() - trailingSpacing;
|
const int widthLeftForUrlNavigator2 = m_splitter->widget(1)->width() - trailingSpacing;
|
||||||
|
@ -111,8 +103,7 @@ void DolphinNavigatorsWidgetAction::createSecondaryUrlNavigator()
|
||||||
updateText();
|
updateText();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinNavigatorsWidgetAction::followViewContainersGeometry(QWidget *primaryViewContainer,
|
void DolphinNavigatorsWidgetAction::followViewContainersGeometry(QWidget *primaryViewContainer, QWidget *secondaryViewContainer)
|
||||||
QWidget *secondaryViewContainer)
|
|
||||||
{
|
{
|
||||||
m_viewGeometriesHelper.setViewContainers(primaryViewContainer, secondaryViewContainer);
|
m_viewGeometriesHelper.setViewContainers(primaryViewContainer, secondaryViewContainer);
|
||||||
adjustSpacing();
|
adjustSpacing();
|
||||||
|
@ -193,7 +184,11 @@ QWidget *DolphinNavigatorsWidgetAction::createNavigatorWidget(Side side) const
|
||||||
auto networkFolderButton = newNetworkFolderButton(urlNavigator, navigatorWidget);
|
auto networkFolderButton = newNetworkFolderButton(urlNavigator, navigatorWidget);
|
||||||
layout->addWidget(networkFolderButton);
|
layout->addWidget(networkFolderButton);
|
||||||
|
|
||||||
connect(urlNavigator, &KUrlNavigator::urlChanged, this, [urlNavigator, this]() {
|
connect(
|
||||||
|
urlNavigator,
|
||||||
|
&KUrlNavigator::urlChanged,
|
||||||
|
this,
|
||||||
|
[urlNavigator, this]() {
|
||||||
// Update URL navigator to show a server URL entry placeholder text if we
|
// Update URL navigator to show a server URL entry placeholder text if we
|
||||||
// just loaded the remote:/ page, to make it easier for users to figure out
|
// just loaded the remote:/ page, to make it easier for users to figure out
|
||||||
// that they can enter arbitrary remote URLs. See bug 414670
|
// that they can enter arbitrary remote URLs. See bug 414670
|
||||||
|
@ -210,7 +205,8 @@ QWidget *DolphinNavigatorsWidgetAction::createNavigatorWidget(Side side) const
|
||||||
// We have to wait for DolphinUrlNavigator::sizeHint() to update which
|
// We have to wait for DolphinUrlNavigator::sizeHint() to update which
|
||||||
// happens a little bit later than when urlChanged is emitted.
|
// happens a little bit later than when urlChanged is emitted.
|
||||||
this->m_adjustSpacingTimer->start();
|
this->m_adjustSpacingTimer->start();
|
||||||
}, Qt::QueuedConnection);
|
},
|
||||||
|
Qt::QueuedConnection);
|
||||||
|
|
||||||
auto trailingSpacing = new QWidget{navigatorWidget};
|
auto trailingSpacing = new QWidget{navigatorWidget};
|
||||||
layout->addWidget(trailingSpacing);
|
layout->addWidget(trailingSpacing);
|
||||||
|
@ -228,15 +224,14 @@ QPushButton * DolphinNavigatorsWidgetAction::emptyTrashButton(DolphinNavigatorsW
|
||||||
|
|
||||||
QPushButton *DolphinNavigatorsWidgetAction::newEmptyTrashButton(const DolphinUrlNavigator *urlNavigator, QWidget *parent) const
|
QPushButton *DolphinNavigatorsWidgetAction::newEmptyTrashButton(const DolphinUrlNavigator *urlNavigator, QWidget *parent) const
|
||||||
{
|
{
|
||||||
auto emptyTrashButton = new QPushButton(QIcon::fromTheme(QStringLiteral("user-trash")),
|
auto emptyTrashButton = new QPushButton(QIcon::fromTheme(QStringLiteral("user-trash")), i18nc("@action:button", "Empty Trash"), parent);
|
||||||
i18nc("@action:button", "Empty Trash"), parent);
|
|
||||||
emptyTrashButton->setToolTip(i18n("Empties Trash to create free space"));
|
emptyTrashButton->setToolTip(i18n("Empties Trash to create free space"));
|
||||||
|
|
||||||
emptyTrashButton->setFlat(true);
|
emptyTrashButton->setFlat(true);
|
||||||
connect(emptyTrashButton, &QPushButton::clicked,
|
connect(emptyTrashButton, &QPushButton::clicked, this, [parent]() {
|
||||||
this, [parent]() { Trash::empty(parent); });
|
Trash::empty(parent);
|
||||||
connect(&Trash::instance(), &Trash::emptinessChanged,
|
});
|
||||||
emptyTrashButton, &QPushButton::setDisabled);
|
connect(&Trash::instance(), &Trash::emptinessChanged, emptyTrashButton, &QPushButton::setDisabled);
|
||||||
emptyTrashButton->hide();
|
emptyTrashButton->hide();
|
||||||
connect(urlNavigator, &KUrlNavigator::urlChanged, this, [emptyTrashButton, urlNavigator]() {
|
connect(urlNavigator, &KUrlNavigator::urlChanged, this, [emptyTrashButton, urlNavigator]() {
|
||||||
emptyTrashButton->setVisible(urlNavigator->locationUrl().scheme() == QLatin1String("trash"));
|
emptyTrashButton->setVisible(urlNavigator->locationUrl().scheme() == QLatin1String("trash"));
|
||||||
|
@ -256,12 +251,10 @@ QPushButton *DolphinNavigatorsWidgetAction::networkFolderButton(DolphinNavigator
|
||||||
|
|
||||||
QPushButton *DolphinNavigatorsWidgetAction::newNetworkFolderButton(const DolphinUrlNavigator *urlNavigator, QWidget *parent) const
|
QPushButton *DolphinNavigatorsWidgetAction::newNetworkFolderButton(const DolphinUrlNavigator *urlNavigator, QWidget *parent) const
|
||||||
{
|
{
|
||||||
auto networkFolderButton = new QPushButton(QIcon::fromTheme(QStringLiteral("folder-add")),
|
auto networkFolderButton = new QPushButton(QIcon::fromTheme(QStringLiteral("folder-add")), i18nc("@action:button", "Add Network Folder"), parent);
|
||||||
i18nc("@action:button", "Add Network Folder"), parent);
|
|
||||||
networkFolderButton->setFlat(true);
|
networkFolderButton->setFlat(true);
|
||||||
KService::Ptr service = KService::serviceByDesktopName(QStringLiteral("org.kde.knetattach"));
|
KService::Ptr service = KService::serviceByDesktopName(QStringLiteral("org.kde.knetattach"));
|
||||||
connect(networkFolderButton, &QPushButton::clicked,
|
connect(networkFolderButton, &QPushButton::clicked, this, [networkFolderButton, service]() {
|
||||||
this, [networkFolderButton, service]() {
|
|
||||||
auto *job = new KIO::ApplicationLauncherJob(service, networkFolderButton);
|
auto *job = new KIO::ApplicationLauncherJob(service, networkFolderButton);
|
||||||
auto *delegate = new KNotificationJobUiDelegate;
|
auto *delegate = new KNotificationJobUiDelegate;
|
||||||
delegate->setAutoErrorHandlingEnabled(true);
|
delegate->setAutoErrorHandlingEnabled(true);
|
||||||
|
@ -290,15 +283,13 @@ QWidget *DolphinNavigatorsWidgetAction::spacing(Side side, Position position) co
|
||||||
|
|
||||||
void DolphinNavigatorsWidgetAction::updateText()
|
void DolphinNavigatorsWidgetAction::updateText()
|
||||||
{
|
{
|
||||||
const int urlNavigatorsAmount = m_splitter->count() > 1 && m_splitter->widget(1)->isVisible() ?
|
const int urlNavigatorsAmount = m_splitter->count() > 1 && m_splitter->widget(1)->isVisible() ? 2 : 1;
|
||||||
2 : 1;
|
|
||||||
setText(i18ncp("@action:inmenu", "Location Bar", "Location Bars", urlNavigatorsAmount));
|
setText(i18ncp("@action:inmenu", "Location Bar", "Location Bars", urlNavigatorsAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
DolphinNavigatorsWidgetAction::ViewGeometriesHelper::ViewGeometriesHelper
|
DolphinNavigatorsWidgetAction::ViewGeometriesHelper::ViewGeometriesHelper(QWidget *navigatorsWidget, DolphinNavigatorsWidgetAction *navigatorsWidgetAction)
|
||||||
(QWidget *navigatorsWidget, DolphinNavigatorsWidgetAction *navigatorsWidgetAction) :
|
: m_navigatorsWidget{navigatorsWidget}
|
||||||
m_navigatorsWidget{navigatorsWidget},
|
, m_navigatorsWidgetAction{navigatorsWidgetAction}
|
||||||
m_navigatorsWidgetAction{navigatorsWidgetAction}
|
|
||||||
{
|
{
|
||||||
Q_CHECK_PTR(navigatorsWidget);
|
Q_CHECK_PTR(navigatorsWidget);
|
||||||
Q_CHECK_PTR(navigatorsWidgetAction);
|
Q_CHECK_PTR(navigatorsWidgetAction);
|
||||||
|
@ -323,8 +314,7 @@ bool DolphinNavigatorsWidgetAction::ViewGeometriesHelper::eventFilter(QObject *w
|
||||||
return QObject::eventFilter(watched, event);
|
return QObject::eventFilter(watched, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinNavigatorsWidgetAction::ViewGeometriesHelper::setViewContainers(QWidget *primaryViewContainer,
|
void DolphinNavigatorsWidgetAction::ViewGeometriesHelper::setViewContainers(QWidget *primaryViewContainer, QWidget *secondaryViewContainer)
|
||||||
QWidget *secondaryViewContainer)
|
|
||||||
{
|
{
|
||||||
Q_CHECK_PTR(primaryViewContainer);
|
Q_CHECK_PTR(primaryViewContainer);
|
||||||
if (m_primaryViewContainer) {
|
if (m_primaryViewContainer) {
|
||||||
|
@ -338,8 +328,7 @@ void DolphinNavigatorsWidgetAction::ViewGeometriesHelper::setViewContainers(QWid
|
||||||
m_secondaryViewContainer = secondaryViewContainer;
|
m_secondaryViewContainer = secondaryViewContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
DolphinNavigatorsWidgetAction::ViewGeometriesHelper::Geometries
|
DolphinNavigatorsWidgetAction::ViewGeometriesHelper::Geometries DolphinNavigatorsWidgetAction::ViewGeometriesHelper::viewGeometries()
|
||||||
DolphinNavigatorsWidgetAction::ViewGeometriesHelper::viewGeometries()
|
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_primaryViewContainer);
|
Q_ASSERT(m_primaryViewContainer);
|
||||||
Geometries geometries;
|
Geometries geometries;
|
||||||
|
@ -356,18 +345,15 @@ DolphinNavigatorsWidgetAction::ViewGeometriesHelper::Geometries
|
||||||
if (QApplication::layoutDirection() == Qt::LeftToRight) {
|
if (QApplication::layoutDirection() == Qt::LeftToRight) {
|
||||||
geometries.globalXOfNavigatorsWidget = m_navigatorsWidget->mapToGlobal(QPoint(0, 0)).x();
|
geometries.globalXOfNavigatorsWidget = m_navigatorsWidget->mapToGlobal(QPoint(0, 0)).x();
|
||||||
geometries.globalXOfPrimary = m_primaryViewContainer->mapToGlobal(QPoint(0, 0)).x();
|
geometries.globalXOfPrimary = m_primaryViewContainer->mapToGlobal(QPoint(0, 0)).x();
|
||||||
geometries.globalXOfSecondary = !m_secondaryViewContainer ? INT_MIN :
|
geometries.globalXOfSecondary = !m_secondaryViewContainer ? INT_MIN : m_secondaryViewContainer->mapToGlobal(QPoint(0, 0)).x();
|
||||||
m_secondaryViewContainer->mapToGlobal(QPoint(0,0)).x();
|
|
||||||
} else {
|
} else {
|
||||||
// When the direction is reversed, globalX does not change.
|
// When the direction is reversed, globalX does not change.
|
||||||
// For the adjustSpacing() code to work we need globalX to measure from right to left
|
// For the adjustSpacing() code to work we need globalX to measure from right to left
|
||||||
// and to measure up to the rightmost point of a widget instead of the leftmost.
|
// and to measure up to the rightmost point of a widget instead of the leftmost.
|
||||||
geometries.globalXOfNavigatorsWidget =
|
geometries.globalXOfNavigatorsWidget = (-1) * (m_navigatorsWidget->mapToGlobal(QPoint(0, 0)).x() + m_navigatorsWidget->width());
|
||||||
(-1) * (m_navigatorsWidget->mapToGlobal(QPoint(0,0)).x() + m_navigatorsWidget->width());
|
geometries.globalXOfPrimary = (-1) * (m_primaryViewContainer->mapToGlobal(QPoint(0, 0)).x() + geometries.widthOfPrimary);
|
||||||
geometries.globalXOfPrimary =
|
geometries.globalXOfSecondary =
|
||||||
(-1) * (m_primaryViewContainer->mapToGlobal(QPoint(0,0)).x() + geometries.widthOfPrimary);
|
!m_secondaryViewContainer ? INT_MIN : (-1) * (m_secondaryViewContainer->mapToGlobal(QPoint(0, 0)).x() + geometries.widthOfSecondary);
|
||||||
geometries.globalXOfSecondary = !m_secondaryViewContainer ? INT_MIN :
|
|
||||||
(-1) * (m_secondaryViewContainer->mapToGlobal(QPoint(0,0)).x() + geometries.widthOfSecondary);
|
|
||||||
}
|
}
|
||||||
return geometries;
|
return geometries;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,8 +65,7 @@ public:
|
||||||
* Notify this widget of changes in geometry of the ViewContainers it tries to be
|
* Notify this widget of changes in geometry of the ViewContainers it tries to be
|
||||||
* aligned with.
|
* aligned with.
|
||||||
*/
|
*/
|
||||||
void followViewContainersGeometry(QWidget *primaryViewContainer,
|
void followViewContainersGeometry(QWidget *primaryViewContainer, QWidget *secondaryViewContainer = nullptr);
|
||||||
QWidget *secondaryViewContainer = nullptr);
|
|
||||||
|
|
||||||
bool isInToolbar() const;
|
bool isInToolbar() const;
|
||||||
|
|
||||||
|
@ -104,10 +103,7 @@ private:
|
||||||
/**
|
/**
|
||||||
* In Left-to-right languages the Primary side will be the left one.
|
* In Left-to-right languages the Primary side will be the left one.
|
||||||
*/
|
*/
|
||||||
enum Side {
|
enum Side { Primary, Secondary };
|
||||||
Primary,
|
|
||||||
Secondary
|
|
||||||
};
|
|
||||||
/**
|
/**
|
||||||
* Used to create the navigatorWidgets for both sides of the QSplitter.
|
* Used to create the navigatorWidgets for both sides of the QSplitter.
|
||||||
*/
|
*/
|
||||||
|
@ -142,10 +138,7 @@ private:
|
||||||
*/
|
*/
|
||||||
QPushButton *newNetworkFolderButton(const DolphinUrlNavigator *urlNavigator, QWidget *parent) const;
|
QPushButton *newNetworkFolderButton(const DolphinUrlNavigator *urlNavigator, QWidget *parent) const;
|
||||||
|
|
||||||
enum Position {
|
enum Position { Leading, Trailing };
|
||||||
Leading,
|
|
||||||
Trailing
|
|
||||||
};
|
|
||||||
/**
|
/**
|
||||||
* Used to retrieve both the leading and trailing spacing for the navigatorWidgets
|
* Used to retrieve both the leading and trailing spacing for the navigatorWidgets
|
||||||
* on both sides. A secondary leading spacing does not exist.
|
* on both sides. A secondary leading spacing does not exist.
|
||||||
|
@ -191,8 +184,7 @@ private:
|
||||||
/**
|
/**
|
||||||
* Sets the ViewContainers whose geometry is obtained when viewGeometries() is called.
|
* Sets the ViewContainers whose geometry is obtained when viewGeometries() is called.
|
||||||
*/
|
*/
|
||||||
void setViewContainers(QWidget *primaryViewContainer,
|
void setViewContainers(QWidget *primaryViewContainer, QWidget *secondaryViewContainer = nullptr);
|
||||||
QWidget *secondaryViewContainer = nullptr);
|
|
||||||
|
|
||||||
struct Geometries {
|
struct Geometries {
|
||||||
int globalXOfNavigatorsWidget;
|
int globalXOfNavigatorsWidget;
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
#include <KActionCollection>
|
#include <KActionCollection>
|
||||||
#include <KIO/Job>
|
#include <KIO/Job>
|
||||||
|
|
||||||
DolphinNewFileMenu::DolphinNewFileMenu(KActionCollection* collection, QObject* parent) :
|
DolphinNewFileMenu::DolphinNewFileMenu(KActionCollection *collection, QObject *parent)
|
||||||
KNewFileMenu(collection, QStringLiteral("new_menu"), parent)
|
: KNewFileMenu(collection, QStringLiteral("new_menu"), parent)
|
||||||
{
|
{
|
||||||
DolphinNewFileMenuObserver::instance().attach(this);
|
DolphinNewFileMenuObserver::instance().attach(this);
|
||||||
}
|
}
|
||||||
|
@ -30,4 +30,3 @@ void DolphinNewFileMenu::slotResult(KJob* job)
|
||||||
KNewFileMenu::slotResult(job);
|
KNewFileMenu::slotResult(job);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,8 +48,7 @@
|
||||||
|
|
||||||
K_PLUGIN_CLASS_WITH_JSON(DolphinPart, "dolphinpart.json")
|
K_PLUGIN_CLASS_WITH_JSON(DolphinPart, "dolphinpart.json")
|
||||||
|
|
||||||
DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent,
|
DolphinPart::DolphinPart(QWidget *parentWidget, QObject *parent, const KPluginMetaData &metaData, const QVariantList &args)
|
||||||
const KPluginMetaData& metaData, const QVariantList& args)
|
|
||||||
: KParts::ReadOnlyPart(parent)
|
: KParts::ReadOnlyPart(parent)
|
||||||
, m_openTerminalAction(nullptr)
|
, m_openTerminalAction(nullptr)
|
||||||
, m_removeAction(nullptr)
|
, m_removeAction(nullptr)
|
||||||
|
@ -66,8 +65,7 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent,
|
||||||
m_view->setTabsForFilesEnabled(true);
|
m_view->setTabsForFilesEnabled(true);
|
||||||
setWidget(m_view);
|
setWidget(m_view);
|
||||||
|
|
||||||
connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage,
|
connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage, this, &DolphinPart::slotErrorMessage);
|
||||||
this, &DolphinPart::slotErrorMessage);
|
|
||||||
|
|
||||||
connect(m_view, &DolphinView::directoryLoadingCompleted, this, &KParts::ReadOnlyPart::completed);
|
connect(m_view, &DolphinView::directoryLoadingCompleted, this, &KParts::ReadOnlyPart::completed);
|
||||||
connect(m_view, &DolphinView::directoryLoadingCompleted, this, &DolphinPart::updatePasteAction);
|
connect(m_view, &DolphinView::directoryLoadingCompleted, this, &DolphinPart::updatePasteAction);
|
||||||
|
@ -76,34 +74,22 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent,
|
||||||
|
|
||||||
setXMLFile(QStringLiteral("dolphinpart.rc"));
|
setXMLFile(QStringLiteral("dolphinpart.rc"));
|
||||||
|
|
||||||
connect(m_view, &DolphinView::infoMessage,
|
connect(m_view, &DolphinView::infoMessage, this, &DolphinPart::slotMessage);
|
||||||
this, &DolphinPart::slotMessage);
|
connect(m_view, &DolphinView::operationCompletedMessage, this, &DolphinPart::slotMessage);
|
||||||
connect(m_view, &DolphinView::operationCompletedMessage,
|
connect(m_view, &DolphinView::errorMessage, this, &DolphinPart::slotErrorMessage);
|
||||||
this, &DolphinPart::slotMessage);
|
connect(m_view, &DolphinView::itemActivated, this, &DolphinPart::slotItemActivated);
|
||||||
connect(m_view, &DolphinView::errorMessage,
|
connect(m_view, &DolphinView::itemsActivated, this, &DolphinPart::slotItemsActivated);
|
||||||
this, &DolphinPart::slotErrorMessage);
|
|
||||||
connect(m_view, &DolphinView::itemActivated,
|
|
||||||
this, &DolphinPart::slotItemActivated);
|
|
||||||
connect(m_view, &DolphinView::itemsActivated,
|
|
||||||
this, &DolphinPart::slotItemsActivated);
|
|
||||||
connect(m_view, &DolphinView::statusBarTextChanged, this, [this](const QString &text) {
|
connect(m_view, &DolphinView::statusBarTextChanged, this, [this](const QString &text) {
|
||||||
const QString escapedText = Qt::convertFromPlainText(text);
|
const QString escapedText = Qt::convertFromPlainText(text);
|
||||||
Q_EMIT ReadOnlyPart::setStatusBarText(QStringLiteral("<qt>%1</qt>").arg(escapedText));
|
Q_EMIT ReadOnlyPart::setStatusBarText(QStringLiteral("<qt>%1</qt>").arg(escapedText));
|
||||||
});
|
});
|
||||||
connect(m_view, &DolphinView::tabRequested,
|
connect(m_view, &DolphinView::tabRequested, this, &DolphinPart::createNewWindow);
|
||||||
this, &DolphinPart::createNewWindow);
|
connect(m_view, &DolphinView::requestContextMenu, this, &DolphinPart::slotOpenContextMenu);
|
||||||
connect(m_view, &DolphinView::requestContextMenu,
|
connect(m_view, &DolphinView::selectionChanged, m_extension, &KParts::BrowserExtension::selectionInfo);
|
||||||
this, &DolphinPart::slotOpenContextMenu);
|
connect(m_view, &DolphinView::selectionChanged, this, &DolphinPart::slotSelectionChanged);
|
||||||
connect(m_view, &DolphinView::selectionChanged,
|
connect(m_view, &DolphinView::requestItemInfo, this, &DolphinPart::slotRequestItemInfo);
|
||||||
m_extension, &KParts::BrowserExtension::selectionInfo);
|
connect(m_view, &DolphinView::modeChanged, this, &DolphinPart::viewModeChanged); // relay signal
|
||||||
connect(m_view, &DolphinView::selectionChanged,
|
connect(m_view, &DolphinView::redirection, this, &DolphinPart::slotDirectoryRedirection);
|
||||||
this, &DolphinPart::slotSelectionChanged);
|
|
||||||
connect(m_view, &DolphinView::requestItemInfo,
|
|
||||||
this, &DolphinPart::slotRequestItemInfo);
|
|
||||||
connect(m_view, &DolphinView::modeChanged,
|
|
||||||
this, &DolphinPart::viewModeChanged); // relay signal
|
|
||||||
connect(m_view, &DolphinView::redirection,
|
|
||||||
this, &DolphinPart::slotDirectoryRedirection);
|
|
||||||
|
|
||||||
// Watch for changes that should result in updates to the
|
// Watch for changes that should result in updates to the
|
||||||
// status bar text.
|
// status bar text.
|
||||||
|
@ -115,12 +101,10 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent,
|
||||||
connect(m_actionHandler, &DolphinViewActionHandler::createDirectoryTriggered, this, &DolphinPart::createDirectory);
|
connect(m_actionHandler, &DolphinViewActionHandler::createDirectoryTriggered, this, &DolphinPart::createDirectory);
|
||||||
|
|
||||||
m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler);
|
m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler);
|
||||||
connect(this, &DolphinPart::aboutToOpenURL,
|
connect(this, &DolphinPart::aboutToOpenURL, m_remoteEncoding, &DolphinRemoteEncoding::slotAboutToOpenUrl);
|
||||||
m_remoteEncoding, &DolphinRemoteEncoding::slotAboutToOpenUrl);
|
|
||||||
|
|
||||||
QClipboard *clipboard = QApplication::clipboard();
|
QClipboard *clipboard = QApplication::clipboard();
|
||||||
connect(clipboard, &QClipboard::dataChanged,
|
connect(clipboard, &QClipboard::dataChanged, this, &DolphinPart::updatePasteAction);
|
||||||
this, &DolphinPart::updatePasteAction);
|
|
||||||
|
|
||||||
// Create file info and listing filter extensions.
|
// Create file info and listing filter extensions.
|
||||||
// NOTE: Listing filter needs to be instantiated after the creation of the view.
|
// NOTE: Listing filter needs to be instantiated after the creation of the view.
|
||||||
|
@ -159,8 +143,7 @@ void DolphinPart::createActions()
|
||||||
|
|
||||||
m_newFileMenu = new DolphinNewFileMenu(actionCollection(), this);
|
m_newFileMenu = new DolphinNewFileMenu(actionCollection(), this);
|
||||||
m_newFileMenu->setParentWidget(widget());
|
m_newFileMenu->setParentWidget(widget());
|
||||||
connect(m_newFileMenu->menu(), &QMenu::aboutToShow,
|
connect(m_newFileMenu->menu(), &QMenu::aboutToShow, this, &DolphinPart::updateNewMenu);
|
||||||
this, &DolphinPart::updateNewMenu);
|
|
||||||
|
|
||||||
QAction *editMimeTypeAction = actionCollection()->addAction(QStringLiteral("editMimeType"));
|
QAction *editMimeTypeAction = actionCollection()->addAction(QStringLiteral("editMimeType"));
|
||||||
editMimeTypeAction->setText(i18nc("@action:inmenu Edit", "&Edit File Type..."));
|
editMimeTypeAction->setText(i18nc("@action:inmenu Edit", "&Edit File Type..."));
|
||||||
|
@ -191,20 +174,15 @@ void DolphinPart::createActions()
|
||||||
// Go menu
|
// Go menu
|
||||||
|
|
||||||
QActionGroup *goActionGroup = new QActionGroup(this);
|
QActionGroup *goActionGroup = new QActionGroup(this);
|
||||||
connect(goActionGroup, &QActionGroup::triggered,
|
connect(goActionGroup, &QActionGroup::triggered, this, &DolphinPart::slotGoTriggered);
|
||||||
this, &DolphinPart::slotGoTriggered);
|
|
||||||
|
|
||||||
createGoAction("go_applications", "start-here-kde",
|
createGoAction("go_applications", "start-here-kde", i18nc("@action:inmenu Go", "App&lications"), QStringLiteral("programs:/"), goActionGroup);
|
||||||
i18nc("@action:inmenu Go", "App&lications"), QStringLiteral("programs:/"),
|
createGoAction("go_network_folders", "folder-remote", i18nc("@action:inmenu Go", "&Network Folders"), QStringLiteral("remote:/"), goActionGroup);
|
||||||
goActionGroup);
|
createGoAction("go_trash", "user-trash", i18nc("@action:inmenu Go", "Trash"), QStringLiteral("trash:/"), goActionGroup);
|
||||||
createGoAction("go_network_folders", "folder-remote",
|
createGoAction("go_autostart",
|
||||||
i18nc("@action:inmenu Go", "&Network Folders"), QStringLiteral("remote:/"),
|
"",
|
||||||
goActionGroup);
|
i18nc("@action:inmenu Go", "Autostart"),
|
||||||
createGoAction("go_trash", "user-trash",
|
QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/autostart",
|
||||||
i18nc("@action:inmenu Go", "Trash"), QStringLiteral("trash:/"),
|
|
||||||
goActionGroup);
|
|
||||||
createGoAction("go_autostart", "",
|
|
||||||
i18nc("@action:inmenu Go", "Autostart"), QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/autostart",
|
|
||||||
goActionGroup);
|
goActionGroup);
|
||||||
|
|
||||||
// Tools menu
|
// Tools menu
|
||||||
|
@ -222,9 +200,7 @@ void DolphinPart::createActions()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinPart::createGoAction(const char* name, const char* iconName,
|
void DolphinPart::createGoAction(const char *name, const char *iconName, const QString &text, const QString &url, QActionGroup *actionGroup)
|
||||||
const QString& text, const QString& url,
|
|
||||||
QActionGroup* actionGroup)
|
|
||||||
{
|
{
|
||||||
QAction *action = actionCollection()->addAction(name);
|
QAction *action = actionCollection()->addAction(name);
|
||||||
action->setIcon(QIcon::fromTheme(iconName));
|
action->setIcon(QIcon::fromTheme(iconName));
|
||||||
|
@ -384,14 +360,10 @@ void DolphinPart::createNewWindow(const QUrl& url)
|
||||||
Q_EMIT m_extension->createNewWindow(url);
|
Q_EMIT m_extension->createNewWindow(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinPart::slotOpenContextMenu(const QPoint& pos,
|
void DolphinPart::slotOpenContextMenu(const QPoint &pos, const KFileItem &_item, const KFileItemList &selectedItems, const QUrl &)
|
||||||
const KFileItem& _item,
|
|
||||||
const KFileItemList &selectedItems,
|
|
||||||
const QUrl &)
|
|
||||||
{
|
{
|
||||||
KParts::BrowserExtension::PopupFlags popupFlags = KParts::BrowserExtension::DefaultPopupItems
|
KParts::BrowserExtension::PopupFlags popupFlags =
|
||||||
| KParts::BrowserExtension::ShowProperties
|
KParts::BrowserExtension::DefaultPopupItems | KParts::BrowserExtension::ShowProperties | KParts::BrowserExtension::ShowUrlOperations;
|
||||||
| KParts::BrowserExtension::ShowUrlOperations;
|
|
||||||
|
|
||||||
KFileItem item(_item);
|
KFileItem item(_item);
|
||||||
|
|
||||||
|
@ -420,8 +392,7 @@ void DolphinPart::slotOpenContextMenu(const QPoint& pos,
|
||||||
const bool supportsMoving = capabilities.supportsMoving();
|
const bool supportsMoving = capabilities.supportsMoving();
|
||||||
|
|
||||||
if (capabilities.supportsDeleting()) {
|
if (capabilities.supportsDeleting()) {
|
||||||
const bool showDeleteAction = (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) ||
|
const bool showDeleteAction = (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) || !item.isLocalFile());
|
||||||
!item.isLocalFile());
|
|
||||||
const bool showMoveToTrashAction = capabilities.isLocal() && supportsMoving;
|
const bool showMoveToTrashAction = capabilities.isLocal() && supportsMoving;
|
||||||
|
|
||||||
if (showDeleteAction && showMoveToTrashAction) {
|
if (showDeleteAction && showMoveToTrashAction) {
|
||||||
|
@ -450,17 +421,11 @@ void DolphinPart::slotOpenContextMenu(const QPoint& pos,
|
||||||
// But in treeview mode we should allow it.
|
// But in treeview mode we should allow it.
|
||||||
if (m_view->itemsExpandable())
|
if (m_view->itemsExpandable())
|
||||||
popupFlags |= KParts::BrowserExtension::ShowCreateDirectory;
|
popupFlags |= KParts::BrowserExtension::ShowCreateDirectory;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
actionGroups.insert(QStringLiteral("editactions"), editActions);
|
actionGroups.insert(QStringLiteral("editactions"), editActions);
|
||||||
|
|
||||||
Q_EMIT m_extension->popupMenu(pos,
|
Q_EMIT m_extension->popupMenu(pos, items, KParts::OpenUrlArguments(), KParts::BrowserArguments(), popupFlags, actionGroups);
|
||||||
items,
|
|
||||||
KParts::OpenUrlArguments(),
|
|
||||||
KParts::BrowserArguments(),
|
|
||||||
popupFlags,
|
|
||||||
actionGroups);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinPart::slotDirectoryRedirection(const QUrl &oldUrl, const QUrl &newUrl)
|
void DolphinPart::slotDirectoryRedirection(const QUrl &oldUrl, const QUrl &newUrl)
|
||||||
|
@ -473,7 +438,6 @@ void DolphinPart::slotDirectoryRedirection(const QUrl &oldUrl, const QUrl &newUr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DolphinPart::slotEditMimeType()
|
void DolphinPart::slotEditMimeType()
|
||||||
{
|
{
|
||||||
const KFileItemList items = m_view->selectedItems();
|
const KFileItemList items = m_view->selectedItems();
|
||||||
|
@ -484,16 +448,12 @@ void DolphinPart::slotEditMimeType()
|
||||||
|
|
||||||
void DolphinPart::slotSelectItemsMatchingPattern()
|
void DolphinPart::slotSelectItemsMatchingPattern()
|
||||||
{
|
{
|
||||||
openSelectionDialog(i18nc("@title:window", "Select"),
|
openSelectionDialog(i18nc("@title:window", "Select"), i18n("Select all items matching this pattern:"), true);
|
||||||
i18n("Select all items matching this pattern:"),
|
|
||||||
true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinPart::slotUnselectItemsMatchingPattern()
|
void DolphinPart::slotUnselectItemsMatchingPattern()
|
||||||
{
|
{
|
||||||
openSelectionDialog(i18nc("@title:window", "Unselect"),
|
openSelectionDialog(i18nc("@title:window", "Unselect"), i18n("Unselect all items matching this pattern:"), false);
|
||||||
i18n("Unselect all items matching this pattern:"),
|
|
||||||
false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinPart::openSelectionDialog(const QString &title, const QString &text, bool selectItems)
|
void DolphinPart::openSelectionDialog(const QString &title, const QString &text, bool selectItems)
|
||||||
|
@ -571,9 +531,7 @@ void DolphinPart::slotOpenTerminal()
|
||||||
void DolphinPart::slotFindFile()
|
void DolphinPart::slotFindFile()
|
||||||
{
|
{
|
||||||
QMenu searchTools;
|
QMenu searchTools;
|
||||||
KMoreToolsMenuFactory("dolphin/search-tools").fillMenuFromGroupingNames(
|
KMoreToolsMenuFactory("dolphin/search-tools").fillMenuFromGroupingNames(&searchTools, {"files-find"}, QUrl::fromLocalFile(localFilePathOrHome()));
|
||||||
&searchTools, { "files-find" }, QUrl::fromLocalFile(localFilePathOrHome())
|
|
||||||
);
|
|
||||||
QList<QAction *> actions = searchTools.actions();
|
QList<QAction *> actions = searchTools.actions();
|
||||||
if (!(actions.isEmpty())) {
|
if (!(actions.isEmpty())) {
|
||||||
actions.first()->trigger();
|
actions.first()->trigger();
|
||||||
|
|
|
@ -40,8 +40,7 @@ class DolphinPart : public KParts::ReadOnlyPart
|
||||||
Q_PROPERTY(QList<QUrl> filesToSelect READ filesToSelect WRITE setFilesToSelect)
|
Q_PROPERTY(QList<QUrl> filesToSelect READ filesToSelect WRITE setFilesToSelect)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DolphinPart(QWidget* parentWidget, QObject* parent,
|
explicit DolphinPart(QWidget *parentWidget, QObject *parent, const KPluginMetaData &metaData, const QVariantList &args);
|
||||||
const KPluginMetaData& metaData, const QVariantList& args);
|
|
||||||
~DolphinPart() override;
|
~DolphinPart() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,7 +50,10 @@ public:
|
||||||
bool openUrl(const QUrl &url) override;
|
bool openUrl(const QUrl &url) override;
|
||||||
|
|
||||||
/// see the supportsUndo property
|
/// see the supportsUndo property
|
||||||
bool supportsUndo() const { return true; }
|
bool supportsUndo() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by konqueror for setting the view mode
|
* Used by konqueror for setting the view mode
|
||||||
|
@ -68,7 +70,10 @@ public:
|
||||||
QString currentViewMode() const;
|
QString currentViewMode() const;
|
||||||
|
|
||||||
/// Returns the view owned by this part; used by DolphinPartBrowserExtension
|
/// Returns the view owned by this part; used by DolphinPartBrowserExtension
|
||||||
DolphinView* view() { return m_view; }
|
DolphinView *view()
|
||||||
|
{
|
||||||
|
return m_view;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a name filter, like *.diff
|
* Sets a name filter, like *.diff
|
||||||
|
@ -78,13 +83,19 @@ public:
|
||||||
/**
|
/**
|
||||||
* Returns the current name filter. Used by konqueror to show it in the URL.
|
* Returns the current name filter. Used by konqueror to show it in the URL.
|
||||||
*/
|
*/
|
||||||
QString nameFilter() const { return m_nameFilter; }
|
QString nameFilter() const
|
||||||
|
{
|
||||||
|
return m_nameFilter;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* We reimplement openUrl so no need to implement openFile.
|
* We reimplement openUrl so no need to implement openFile.
|
||||||
*/
|
*/
|
||||||
bool openFile() override { return true; }
|
bool openFile() override
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
/**
|
/**
|
||||||
|
@ -92,7 +103,6 @@ Q_SIGNALS:
|
||||||
*/
|
*/
|
||||||
void viewModeChanged();
|
void viewModeChanged();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emitted whenever the current URL is about to be changed.
|
* Emitted whenever the current URL is about to be changed.
|
||||||
*/
|
*/
|
||||||
|
@ -204,18 +214,18 @@ private Q_SLOTS:
|
||||||
* Called by konqueror --select
|
* Called by konqueror --select
|
||||||
*/
|
*/
|
||||||
void setFilesToSelect(const QList<QUrl> &files);
|
void setFilesToSelect(const QList<QUrl> &files);
|
||||||
QList<QUrl> filesToSelect() const { return QList<QUrl>(); } // silence moc
|
QList<QUrl> filesToSelect() const
|
||||||
|
{
|
||||||
|
return QList<QUrl>();
|
||||||
|
} // silence moc
|
||||||
|
|
||||||
bool eventFilter(QObject *, QEvent *) override;
|
bool eventFilter(QObject *, QEvent *) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createActions();
|
void createActions();
|
||||||
void createGoAction(const char* name, const char* iconName,
|
void createGoAction(const char *name, const char *iconName, const QString &text, const QString &url, QActionGroup *actionGroup);
|
||||||
const QString& text, const QString& url,
|
|
||||||
QActionGroup* actionGroup);
|
|
||||||
|
|
||||||
void openSelectionDialog(const QString& title, const QString& text,
|
void openSelectionDialog(const QString &title, const QString &text, bool selectItems);
|
||||||
bool selectItems);
|
|
||||||
QString urlToLocalFilePath(const QUrl &url);
|
QString urlToLocalFilePath(const QUrl &url);
|
||||||
QString localFilePathOrHome() const;
|
QString localFilePathOrHome() const;
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ DolphinPartBrowserExtension::DolphinPartBrowserExtension(DolphinPart* part)
|
||||||
: KParts::BrowserExtension(part)
|
: KParts::BrowserExtension(part)
|
||||||
, m_part(part)
|
, m_part(part)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinPartBrowserExtension::restoreState(QDataStream &stream)
|
void DolphinPartBrowserExtension::restoreState(QDataStream &stream)
|
||||||
|
@ -53,7 +52,6 @@ void DolphinPartBrowserExtension::reparseConfiguration()
|
||||||
m_part->view()->readSettings();
|
m_part->view()->readSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DolphinPartFileInfoExtension::DolphinPartFileInfoExtension(DolphinPart *part)
|
DolphinPartFileInfoExtension::DolphinPartFileInfoExtension(DolphinPart *part)
|
||||||
: KParts::FileInfoExtension(part)
|
: KParts::FileInfoExtension(part)
|
||||||
, m_part(part)
|
, m_part(part)
|
||||||
|
@ -102,9 +100,7 @@ DolphinPartListingFilterExtension::DolphinPartListingFilterExtension(DolphinPart
|
||||||
|
|
||||||
KParts::ListingFilterExtension::FilterModes DolphinPartListingFilterExtension::supportedFilterModes() const
|
KParts::ListingFilterExtension::FilterModes DolphinPartListingFilterExtension::supportedFilterModes() const
|
||||||
{
|
{
|
||||||
return (KParts::ListingFilterExtension::MimeType |
|
return (KParts::ListingFilterExtension::MimeType | KParts::ListingFilterExtension::SubString | KParts::ListingFilterExtension::WildCard);
|
||||||
KParts::ListingFilterExtension::SubString |
|
|
||||||
KParts::ListingFilterExtension::WildCard);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DolphinPartListingFilterExtension::supportsMultipleFilters(KParts::ListingFilterExtension::FilterMode mode) const
|
bool DolphinPartListingFilterExtension::supportsMultipleFilters(KParts::ListingFilterExtension::FilterMode mode) const
|
||||||
|
@ -158,8 +154,7 @@ DolphinPartListingNotificationExtension::DolphinPartListingNotificationExtension
|
||||||
|
|
||||||
KParts::ListingNotificationExtension::NotificationEventTypes DolphinPartListingNotificationExtension::supportedNotificationEventTypes() const
|
KParts::ListingNotificationExtension::NotificationEventTypes DolphinPartListingNotificationExtension::supportedNotificationEventTypes() const
|
||||||
{
|
{
|
||||||
return (KParts::ListingNotificationExtension::ItemsAdded |
|
return (KParts::ListingNotificationExtension::ItemsAdded | KParts::ListingNotificationExtension::ItemsDeleted);
|
||||||
KParts::ListingNotificationExtension::ItemsDeleted);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinPartListingNotificationExtension::slotNewItems(const KFileItemList &items)
|
void DolphinPartListingNotificationExtension::slotNewItems(const KFileItemList &items)
|
||||||
|
@ -171,4 +166,3 @@ void DolphinPartListingNotificationExtension::slotItemsDeleted(const KFileItemLi
|
||||||
{
|
{
|
||||||
Q_EMIT listingEvent(KParts::ListingNotificationExtension::ItemsDeleted, items);
|
Q_EMIT listingEvent(KParts::ListingNotificationExtension::ItemsDeleted, items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,8 +51,7 @@ void DolphinPlacesModel::setPanelsLocked(bool locked)
|
||||||
QStringList DolphinPlacesModel::mimeTypes() const
|
QStringList DolphinPlacesModel::mimeTypes() const
|
||||||
{
|
{
|
||||||
QStringList types = KFilePlacesModel::mimeTypes();
|
QStringList types = KFilePlacesModel::mimeTypes();
|
||||||
types << DragAndDropHelper::arkDndServiceMimeType()
|
types << DragAndDropHelper::arkDndServiceMimeType() << DragAndDropHelper::arkDndPathMimeType();
|
||||||
<< DragAndDropHelper::arkDndPathMimeType();
|
|
||||||
return types;
|
return types;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +120,6 @@ bool DolphinPlacesModel::isTrash(const QModelIndex &index) const
|
||||||
DolphinPlacesModelSingleton::DolphinPlacesModelSingleton()
|
DolphinPlacesModelSingleton::DolphinPlacesModelSingleton()
|
||||||
: m_placesModel(new DolphinPlacesModel(KAboutData::applicationData().componentName() + applicationNameSuffix()))
|
: m_placesModel(new DolphinPlacesModel(KAboutData::applicationData().componentName() + applicationNameSuffix()))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DolphinPlacesModelSingleton &DolphinPlacesModelSingleton::instance()
|
DolphinPlacesModelSingleton &DolphinPlacesModelSingleton::instance()
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
#ifndef DOLPHINPLACESMODELSINGLETON_H
|
#ifndef DOLPHINPLACESMODELSINGLETON_H
|
||||||
#define DOLPHINPLACESMODELSINGLETON_H
|
#define DOLPHINPLACESMODELSINGLETON_H
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
#include <KFilePlacesModel>
|
#include <KFilePlacesModel>
|
||||||
|
|
||||||
|
@ -50,7 +50,6 @@ private:
|
||||||
*/
|
*/
|
||||||
class DolphinPlacesModelSingleton
|
class DolphinPlacesModelSingleton
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static DolphinPlacesModelSingleton &instance();
|
static DolphinPlacesModelSingleton &instance();
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
DolphinRecentTabsMenu::DolphinRecentTabsMenu(QObject* parent) :
|
DolphinRecentTabsMenu::DolphinRecentTabsMenu(QObject *parent)
|
||||||
KActionMenu(QIcon::fromTheme(QStringLiteral("edit-undo")), i18n("Recently Closed Tabs"), parent)
|
: KActionMenu(QIcon::fromTheme(QStringLiteral("edit-undo")), i18n("Recently Closed Tabs"), parent)
|
||||||
{
|
{
|
||||||
setPopupMode(QToolButton::InstantPopup);
|
setPopupMode(QToolButton::InstantPopup);
|
||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
|
@ -24,8 +24,7 @@ DolphinRecentTabsMenu::DolphinRecentTabsMenu(QObject* parent) :
|
||||||
|
|
||||||
addSeparator();
|
addSeparator();
|
||||||
|
|
||||||
connect(menu(), &QMenu::triggered,
|
connect(menu(), &QMenu::triggered, this, &DolphinRecentTabsMenu::handleAction);
|
||||||
this, &DolphinRecentTabsMenu::handleAction);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinRecentTabsMenu::rememberClosedTab(const QUrl &url, const QByteArray &state)
|
void DolphinRecentTabsMenu::rememberClosedTab(const QUrl &url, const QByteArray &state)
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
DolphinRemoveAction::DolphinRemoveAction(QObject* parent, KActionCollection* collection) :
|
DolphinRemoveAction::DolphinRemoveAction(QObject *parent, KActionCollection *collection)
|
||||||
QAction(parent),
|
: QAction(parent)
|
||||||
m_collection(collection)
|
, m_collection(collection)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
connect(this, &DolphinRemoveAction::triggered, this, &DolphinRemoveAction::slotRemoveActionTriggered);
|
connect(this, &DolphinRemoveAction::triggered, this, &DolphinRemoveAction::slotRemoveActionTriggered);
|
||||||
|
|
|
@ -26,12 +26,7 @@ class DOLPHIN_EXPORT DolphinRemoveAction : public QAction
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
enum class ShiftState { Unknown, Pressed, Released };
|
||||||
enum class ShiftState {
|
|
||||||
Unknown,
|
|
||||||
Pressed,
|
|
||||||
Released
|
|
||||||
};
|
|
||||||
|
|
||||||
DolphinRemoveAction(QObject *parent, KActionCollection *collection);
|
DolphinRemoveAction(QObject *parent, KActionCollection *collection);
|
||||||
|
|
||||||
|
|
|
@ -13,10 +13,10 @@
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
DolphinTabBar::DolphinTabBar(QWidget* parent) :
|
DolphinTabBar::DolphinTabBar(QWidget *parent)
|
||||||
QTabBar(parent),
|
: QTabBar(parent)
|
||||||
m_autoActivationIndex(-1),
|
, m_autoActivationIndex(-1)
|
||||||
m_tabToBeClosedOnMiddleMouseButtonRelease(-1)
|
, m_tabToBeClosedOnMiddleMouseButtonRelease(-1)
|
||||||
{
|
{
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab);
|
setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab);
|
||||||
|
@ -26,8 +26,7 @@ DolphinTabBar::DolphinTabBar(QWidget* parent) :
|
||||||
m_autoActivationTimer = new QTimer(this);
|
m_autoActivationTimer = new QTimer(this);
|
||||||
m_autoActivationTimer->setSingleShot(true);
|
m_autoActivationTimer->setSingleShot(true);
|
||||||
m_autoActivationTimer->setInterval(800);
|
m_autoActivationTimer->setInterval(800);
|
||||||
connect(m_autoActivationTimer, &QTimer::timeout,
|
connect(m_autoActivationTimer, &QTimer::timeout, this, &DolphinTabBar::slotAutoActivationTimeout);
|
||||||
this, &DolphinTabBar::slotAutoActivationTimeout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinTabBar::dragEnterEvent(QDragEnterEvent *event)
|
void DolphinTabBar::dragEnterEvent(QDragEnterEvent *event)
|
||||||
|
@ -93,8 +92,7 @@ void DolphinTabBar::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
const int index = tabAt(event->pos());
|
const int index = tabAt(event->pos());
|
||||||
|
|
||||||
if (index >= 0 && index == m_tabToBeClosedOnMiddleMouseButtonRelease
|
if (index >= 0 && index == m_tabToBeClosedOnMiddleMouseButtonRelease && event->button() == Qt::MiddleButton) {
|
||||||
&& event->button() == Qt::MiddleButton) {
|
|
||||||
// Mouse middle click on a tab closes this tab.
|
// Mouse middle click on a tab closes this tab.
|
||||||
Q_EMIT tabCloseRequested(index);
|
Q_EMIT tabCloseRequested(index);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -14,12 +14,12 @@
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
#include <QVariantAnimation>
|
#include <QVariantAnimation>
|
||||||
|
|
||||||
DolphinTabPage::DolphinTabPage(const QUrl &primaryUrl, const QUrl &secondaryUrl, QWidget* parent) :
|
DolphinTabPage::DolphinTabPage(const QUrl &primaryUrl, const QUrl &secondaryUrl, QWidget *parent)
|
||||||
QWidget(parent),
|
: QWidget(parent)
|
||||||
m_expandingContainer{nullptr},
|
, m_expandingContainer{nullptr}
|
||||||
m_primaryViewActive(true),
|
, m_primaryViewActive(true)
|
||||||
m_splitViewEnabled(false),
|
, m_splitViewEnabled(false)
|
||||||
m_active(true)
|
, m_active(true)
|
||||||
{
|
{
|
||||||
QGridLayout *layout = new QGridLayout(this);
|
QGridLayout *layout = new QGridLayout(this);
|
||||||
layout->setSpacing(0);
|
layout->setSpacing(0);
|
||||||
|
@ -27,17 +27,14 @@ DolphinTabPage::DolphinTabPage(const QUrl &primaryUrl, const QUrl &secondaryUrl,
|
||||||
|
|
||||||
m_splitter = new DolphinTabPageSplitter(Qt::Horizontal, this);
|
m_splitter = new DolphinTabPageSplitter(Qt::Horizontal, this);
|
||||||
m_splitter->setChildrenCollapsible(false);
|
m_splitter->setChildrenCollapsible(false);
|
||||||
connect(m_splitter, &QSplitter::splitterMoved,
|
connect(m_splitter, &QSplitter::splitterMoved, this, &DolphinTabPage::splitterMoved);
|
||||||
this, &DolphinTabPage::splitterMoved);
|
|
||||||
layout->addWidget(m_splitter, 1, 0);
|
layout->addWidget(m_splitter, 1, 0);
|
||||||
layout->setRowStretch(1, 1);
|
layout->setRowStretch(1, 1);
|
||||||
|
|
||||||
// Create a new primary view
|
// Create a new primary view
|
||||||
m_primaryViewContainer = createViewContainer(primaryUrl);
|
m_primaryViewContainer = createViewContainer(primaryUrl);
|
||||||
connect(m_primaryViewContainer->view(), &DolphinView::urlChanged,
|
connect(m_primaryViewContainer->view(), &DolphinView::urlChanged, this, &DolphinTabPage::activeViewUrlChanged);
|
||||||
this, &DolphinTabPage::activeViewUrlChanged);
|
connect(m_primaryViewContainer->view(), &DolphinView::redirection, this, &DolphinTabPage::slotViewUrlRedirection);
|
||||||
connect(m_primaryViewContainer->view(), &DolphinView::redirection,
|
|
||||||
this, &DolphinTabPage::slotViewUrlRedirection);
|
|
||||||
|
|
||||||
m_splitter->addWidget(m_primaryViewContainer);
|
m_splitter->addWidget(m_primaryViewContainer);
|
||||||
m_primaryViewContainer->show();
|
m_primaryViewContainer->show();
|
||||||
|
@ -69,9 +66,8 @@ void DolphinTabPage::setSplitViewEnabled(bool enabled, Animated animated, const
|
||||||
{
|
{
|
||||||
if (m_splitViewEnabled != enabled) {
|
if (m_splitViewEnabled != enabled) {
|
||||||
m_splitViewEnabled = enabled;
|
m_splitViewEnabled = enabled;
|
||||||
if (animated == WithAnimation && (
|
if (animated == WithAnimation
|
||||||
style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, this) < 1 ||
|
&& (style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, this) < 1 || GlobalConfig::animationDurationFactor() <= 0.0)) {
|
||||||
GlobalConfig::animationDurationFactor() <= 0.0)) {
|
|
||||||
animated = WithoutAnimation;
|
animated = WithoutAnimation;
|
||||||
}
|
}
|
||||||
if (m_expandViewAnimation) {
|
if (m_expandViewAnimation) {
|
||||||
|
@ -93,8 +89,7 @@ void DolphinTabPage::setSplitViewEnabled(bool enabled, Animated animated, const
|
||||||
}
|
}
|
||||||
m_secondaryViewContainer->connectUrlNavigator(secondaryNavigator);
|
m_secondaryViewContainer->connectUrlNavigator(secondaryNavigator);
|
||||||
m_navigatorsWidget->setSecondaryNavigatorVisible(true);
|
m_navigatorsWidget->setSecondaryNavigatorVisible(true);
|
||||||
m_navigatorsWidget->followViewContainersGeometry(m_primaryViewContainer,
|
m_navigatorsWidget->followViewContainersGeometry(m_primaryViewContainer, m_secondaryViewContainer);
|
||||||
m_secondaryViewContainer);
|
|
||||||
|
|
||||||
m_splitter->addWidget(m_secondaryViewContainer);
|
m_splitter->addWidget(m_secondaryViewContainer);
|
||||||
m_secondaryViewContainer->setActive(true);
|
m_secondaryViewContainer->setActive(true);
|
||||||
|
@ -115,8 +110,7 @@ void DolphinTabPage::setSplitViewEnabled(bool enabled, Animated animated, const
|
||||||
view = activeViewContainer();
|
view = activeViewContainer();
|
||||||
if (m_primaryViewActive) {
|
if (m_primaryViewActive) {
|
||||||
m_primaryViewContainer->disconnectUrlNavigator();
|
m_primaryViewContainer->disconnectUrlNavigator();
|
||||||
m_secondaryViewContainer->connectUrlNavigator(
|
m_secondaryViewContainer->connectUrlNavigator(m_navigatorsWidget->primaryUrlNavigator());
|
||||||
m_navigatorsWidget->primaryUrlNavigator());
|
|
||||||
|
|
||||||
// If the primary view is active, we have to swap the pointers
|
// If the primary view is active, we have to swap the pointers
|
||||||
// because the secondary view will be the new primary view.
|
// because the secondary view will be the new primary view.
|
||||||
|
@ -127,8 +121,7 @@ void DolphinTabPage::setSplitViewEnabled(bool enabled, Animated animated, const
|
||||||
view = m_primaryViewActive ? m_secondaryViewContainer : m_primaryViewContainer;
|
view = m_primaryViewActive ? m_secondaryViewContainer : m_primaryViewContainer;
|
||||||
if (!m_primaryViewActive) {
|
if (!m_primaryViewActive) {
|
||||||
m_primaryViewContainer->disconnectUrlNavigator();
|
m_primaryViewContainer->disconnectUrlNavigator();
|
||||||
m_secondaryViewContainer->connectUrlNavigator(
|
m_secondaryViewContainer->connectUrlNavigator(m_navigatorsWidget->primaryUrlNavigator());
|
||||||
m_navigatorsWidget->primaryUrlNavigator());
|
|
||||||
|
|
||||||
// If the secondary view is active, we have to swap the pointers
|
// If the secondary view is active, we have to swap the pointers
|
||||||
// because the secondary view will be the new primary view.
|
// because the secondary view will be the new primary view.
|
||||||
|
@ -168,8 +161,7 @@ DolphinViewContainer* DolphinTabPage::secondaryViewContainer() const
|
||||||
|
|
||||||
DolphinViewContainer *DolphinTabPage::activeViewContainer() const
|
DolphinViewContainer *DolphinTabPage::activeViewContainer() const
|
||||||
{
|
{
|
||||||
return m_primaryViewActive ? m_primaryViewContainer :
|
return m_primaryViewActive ? m_primaryViewContainer : m_secondaryViewContainer;
|
||||||
m_secondaryViewContainer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KFileItemList DolphinTabPage::selectedItems() const
|
KFileItemList DolphinTabPage::selectedItems() const
|
||||||
|
@ -200,8 +192,7 @@ void DolphinTabPage::connectNavigators(DolphinNavigatorsWidgetAction *navigators
|
||||||
auto secondaryNavigator = navigatorsWidget->secondaryUrlNavigator();
|
auto secondaryNavigator = navigatorsWidget->secondaryUrlNavigator();
|
||||||
m_secondaryViewContainer->connectUrlNavigator(secondaryNavigator);
|
m_secondaryViewContainer->connectUrlNavigator(secondaryNavigator);
|
||||||
}
|
}
|
||||||
m_navigatorsWidget->followViewContainersGeometry(m_primaryViewContainer,
|
m_navigatorsWidget->followViewContainersGeometry(m_primaryViewContainer, m_secondaryViewContainer);
|
||||||
m_secondaryViewContainer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinTabPage::disconnectNavigators()
|
void DolphinTabPage::disconnectNavigators()
|
||||||
|
@ -343,8 +334,7 @@ void DolphinTabPage::slotAnimationFinished()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_splitter->count(); ++i) {
|
for (int i = 0; i < m_splitter->count(); ++i) {
|
||||||
QWidget *viewContainer = m_splitter->widget(i);
|
QWidget *viewContainer = m_splitter->widget(i);
|
||||||
if (viewContainer != m_primaryViewContainer &&
|
if (viewContainer != m_primaryViewContainer && viewContainer != m_secondaryViewContainer) {
|
||||||
viewContainer != m_secondaryViewContainer) {
|
|
||||||
viewContainer->close();
|
viewContainer->close();
|
||||||
viewContainer->deleteLater();
|
viewContainer->deleteLater();
|
||||||
}
|
}
|
||||||
|
@ -373,8 +363,7 @@ void DolphinTabPage::slotAnimationValueChanged(const QVariant& value)
|
||||||
|
|
||||||
// Reduce the size of the other widgets to make space for the expandingContainer.
|
// Reduce the size of the other widgets to make space for the expandingContainer.
|
||||||
for (int i = m_splitter->count() - 1; i >= 0; --i) {
|
for (int i = m_splitter->count() - 1; i >= 0; --i) {
|
||||||
if (m_splitter->widget(i) == m_primaryViewContainer ||
|
if (m_splitter->widget(i) == m_primaryViewContainer || m_splitter->widget(i) == m_secondaryViewContainer) {
|
||||||
m_splitter->widget(i) == m_secondaryViewContainer) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
newSplitterSizes[i] = oldSplitterSizes.at(i) - expansionWidthNeeded;
|
newSplitterSizes[i] = oldSplitterSizes.at(i) - expansionWidthNeeded;
|
||||||
|
@ -404,7 +393,6 @@ void DolphinTabPage::slotAnimationValueChanged(const QVariant& value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DolphinTabPage::slotViewActivated()
|
void DolphinTabPage::slotViewActivated()
|
||||||
{
|
{
|
||||||
const DolphinView *oldActiveView = activeViewContainer()->view();
|
const DolphinView *oldActiveView = activeViewContainer()->view();
|
||||||
|
@ -429,14 +417,10 @@ void DolphinTabPage::slotViewActivated()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect(oldActiveView, &DolphinView::urlChanged,
|
disconnect(oldActiveView, &DolphinView::urlChanged, this, &DolphinTabPage::activeViewUrlChanged);
|
||||||
this, &DolphinTabPage::activeViewUrlChanged);
|
disconnect(oldActiveView, &DolphinView::redirection, this, &DolphinTabPage::slotViewUrlRedirection);
|
||||||
disconnect(oldActiveView, &DolphinView::redirection,
|
connect(newActiveView, &DolphinView::urlChanged, this, &DolphinTabPage::activeViewUrlChanged);
|
||||||
this, &DolphinTabPage::slotViewUrlRedirection);
|
connect(newActiveView, &DolphinView::redirection, this, &DolphinTabPage::slotViewUrlRedirection);
|
||||||
connect(newActiveView, &DolphinView::urlChanged,
|
|
||||||
this, &DolphinTabPage::activeViewUrlChanged);
|
|
||||||
connect(newActiveView, &DolphinView::redirection,
|
|
||||||
this, &DolphinTabPage::slotViewUrlRedirection);
|
|
||||||
Q_EMIT activeViewChanged(activeViewContainer());
|
Q_EMIT activeViewChanged(activeViewContainer());
|
||||||
Q_EMIT activeViewUrlChanged(activeViewContainer()->url());
|
Q_EMIT activeViewUrlChanged(activeViewContainer()->url());
|
||||||
}
|
}
|
||||||
|
@ -466,11 +450,9 @@ DolphinViewContainer* DolphinTabPage::createViewContainer(const QUrl& url) const
|
||||||
container->setActive(false);
|
container->setActive(false);
|
||||||
|
|
||||||
const DolphinView *view = container->view();
|
const DolphinView *view = container->view();
|
||||||
connect(view, &DolphinView::activated,
|
connect(view, &DolphinView::activated, this, &DolphinTabPage::slotViewActivated);
|
||||||
this, &DolphinTabPage::slotViewActivated);
|
|
||||||
|
|
||||||
connect(view, &DolphinView::toggleActiveViewRequested,
|
connect(view, &DolphinView::toggleActiveViewRequested, this, &DolphinTabPage::switchActiveView);
|
||||||
this, &DolphinTabPage::switchActiveView);
|
|
||||||
|
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
@ -478,21 +460,16 @@ DolphinViewContainer* DolphinTabPage::createViewContainer(const QUrl& url) const
|
||||||
void DolphinTabPage::startExpandViewAnimation(DolphinViewContainer *expandingContainer)
|
void DolphinTabPage::startExpandViewAnimation(DolphinViewContainer *expandingContainer)
|
||||||
{
|
{
|
||||||
Q_CHECK_PTR(expandingContainer);
|
Q_CHECK_PTR(expandingContainer);
|
||||||
Q_ASSERT(expandingContainer == m_primaryViewContainer ||
|
Q_ASSERT(expandingContainer == m_primaryViewContainer || expandingContainer == m_secondaryViewContainer);
|
||||||
expandingContainer == m_secondaryViewContainer);
|
|
||||||
m_expandingContainer = expandingContainer;
|
m_expandingContainer = expandingContainer;
|
||||||
|
|
||||||
m_expandViewAnimation = new QVariantAnimation(m_splitter);
|
m_expandViewAnimation = new QVariantAnimation(m_splitter);
|
||||||
m_expandViewAnimation->setDuration(2 *
|
m_expandViewAnimation->setDuration(2 * style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, this) * GlobalConfig::animationDurationFactor());
|
||||||
style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, this) *
|
|
||||||
GlobalConfig::animationDurationFactor());
|
|
||||||
for (int i = 0; i < m_splitter->count(); ++i) {
|
for (int i = 0; i < m_splitter->count(); ++i) {
|
||||||
m_splitter->widget(i)->setMinimumWidth(1);
|
m_splitter->widget(i)->setMinimumWidth(1);
|
||||||
}
|
}
|
||||||
connect(m_expandViewAnimation, &QAbstractAnimation::finished,
|
connect(m_expandViewAnimation, &QAbstractAnimation::finished, this, &DolphinTabPage::slotAnimationFinished);
|
||||||
this, &DolphinTabPage::slotAnimationFinished);
|
connect(m_expandViewAnimation, &QVariantAnimation::valueChanged, this, &DolphinTabPage::slotAnimationValueChanged);
|
||||||
connect(m_expandViewAnimation, &QVariantAnimation::valueChanged,
|
|
||||||
this, &DolphinTabPage::slotAnimationValueChanged);
|
|
||||||
|
|
||||||
m_expandViewAnimation->setStartValue(expandingContainer->width());
|
m_expandViewAnimation->setStartValue(expandingContainer->width());
|
||||||
if (m_splitViewEnabled) { // A new viewContainer is being opened.
|
if (m_splitViewEnabled) { // A new viewContainer is being opened.
|
||||||
|
@ -508,7 +485,8 @@ void DolphinTabPage::startExpandViewAnimation(DolphinViewContainer *expandingCon
|
||||||
DolphinTabPageSplitterHandle::DolphinTabPageSplitterHandle(Qt::Orientation orientation, QSplitter *parent)
|
DolphinTabPageSplitterHandle::DolphinTabPageSplitterHandle(Qt::Orientation orientation, QSplitter *parent)
|
||||||
: QSplitterHandle(orientation, parent)
|
: QSplitterHandle(orientation, parent)
|
||||||
, m_mouseReleaseWasReceived(false)
|
, m_mouseReleaseWasReceived(false)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
bool DolphinTabPageSplitterHandle::event(QEvent *event)
|
bool DolphinTabPageSplitterHandle::event(QEvent *event)
|
||||||
{
|
{
|
||||||
|
@ -542,7 +520,8 @@ void DolphinTabPageSplitterHandle::resetSplitterSizes()
|
||||||
|
|
||||||
DolphinTabPageSplitter::DolphinTabPageSplitter(Qt::Orientation orientation, QWidget *parent)
|
DolphinTabPageSplitter::DolphinTabPageSplitter(Qt::Orientation orientation, QWidget *parent)
|
||||||
: QSplitter(orientation, parent)
|
: QSplitter(orientation, parent)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
QSplitterHandle *DolphinTabPageSplitter::createHandle()
|
QSplitterHandle *DolphinTabPageSplitter::createHandle()
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
#include <QSplitter>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QSplitter>
|
|
||||||
|
|
||||||
class DolphinNavigatorsWidgetAction;
|
class DolphinNavigatorsWidgetAction;
|
||||||
class DolphinViewContainer;
|
class DolphinViewContainer;
|
||||||
|
|
|
@ -10,35 +10,30 @@
|
||||||
#include "dolphintabbar.h"
|
#include "dolphintabbar.h"
|
||||||
#include "dolphinviewcontainer.h"
|
#include "dolphinviewcontainer.h"
|
||||||
|
|
||||||
|
#include <KAcceleratorManager>
|
||||||
#include <KConfigGroup>
|
#include <KConfigGroup>
|
||||||
|
#include <KIO/CommandLauncherJob>
|
||||||
|
#include <KLocalizedString>
|
||||||
#include <KShell>
|
#include <KShell>
|
||||||
#include <kio/global.h>
|
#include <kio/global.h>
|
||||||
#include <KIO/CommandLauncherJob>
|
|
||||||
#include <KAcceleratorManager>
|
|
||||||
#include <KLocalizedString>
|
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDropEvent>
|
#include <QDropEvent>
|
||||||
|
|
||||||
DolphinTabWidget::DolphinTabWidget(DolphinNavigatorsWidgetAction *navigatorsWidget, QWidget* parent) :
|
DolphinTabWidget::DolphinTabWidget(DolphinNavigatorsWidgetAction *navigatorsWidget, QWidget *parent)
|
||||||
QTabWidget(parent),
|
: QTabWidget(parent)
|
||||||
m_lastViewedTab(nullptr),
|
, m_lastViewedTab(nullptr)
|
||||||
m_navigatorsWidget{navigatorsWidget}
|
, m_navigatorsWidget{navigatorsWidget}
|
||||||
{
|
{
|
||||||
KAcceleratorManager::setNoAccel(this);
|
KAcceleratorManager::setNoAccel(this);
|
||||||
|
|
||||||
connect(this, &DolphinTabWidget::tabCloseRequested,
|
connect(this, &DolphinTabWidget::tabCloseRequested, this, QOverload<int>::of(&DolphinTabWidget::closeTab));
|
||||||
this, QOverload<int>::of(&DolphinTabWidget::closeTab));
|
connect(this, &DolphinTabWidget::currentChanged, this, &DolphinTabWidget::currentTabChanged);
|
||||||
connect(this, &DolphinTabWidget::currentChanged,
|
|
||||||
this, &DolphinTabWidget::currentTabChanged);
|
|
||||||
|
|
||||||
DolphinTabBar *tabBar = new DolphinTabBar(this);
|
DolphinTabBar *tabBar = new DolphinTabBar(this);
|
||||||
connect(tabBar, &DolphinTabBar::openNewActivatedTab,
|
connect(tabBar, &DolphinTabBar::openNewActivatedTab, this, QOverload<int>::of(&DolphinTabWidget::openNewActivatedTab));
|
||||||
this, QOverload<int>::of(&DolphinTabWidget::openNewActivatedTab));
|
connect(tabBar, &DolphinTabBar::tabDropEvent, this, &DolphinTabWidget::tabDropEvent);
|
||||||
connect(tabBar, &DolphinTabBar::tabDropEvent,
|
connect(tabBar, &DolphinTabBar::tabDetachRequested, this, &DolphinTabWidget::detachTab);
|
||||||
this, &DolphinTabWidget::tabDropEvent);
|
|
||||||
connect(tabBar, &DolphinTabBar::tabDetachRequested,
|
|
||||||
this, &DolphinTabWidget::detachTab);
|
|
||||||
tabBar->hide();
|
tabBar->hide();
|
||||||
|
|
||||||
setTabBar(tabBar);
|
setTabBar(tabBar);
|
||||||
|
@ -164,10 +159,8 @@ void DolphinTabWidget::openNewTab(const QUrl& primaryUrl, const QUrl& secondaryU
|
||||||
|
|
||||||
DolphinTabPage *tabPage = new DolphinTabPage(primaryUrl, secondaryUrl, this);
|
DolphinTabPage *tabPage = new DolphinTabPage(primaryUrl, secondaryUrl, this);
|
||||||
tabPage->setActive(false);
|
tabPage->setActive(false);
|
||||||
connect(tabPage, &DolphinTabPage::activeViewChanged,
|
connect(tabPage, &DolphinTabPage::activeViewChanged, this, &DolphinTabWidget::activeViewChanged);
|
||||||
this, &DolphinTabWidget::activeViewChanged);
|
connect(tabPage, &DolphinTabPage::activeViewUrlChanged, this, &DolphinTabWidget::tabUrlChanged);
|
||||||
connect(tabPage, &DolphinTabPage::activeViewUrlChanged,
|
|
||||||
this, &DolphinTabWidget::tabUrlChanged);
|
|
||||||
connect(tabPage->activeViewContainer(), &DolphinViewContainer::captionChanged, this, [this, tabPage]() {
|
connect(tabPage->activeViewContainer(), &DolphinViewContainer::captionChanged, this, [this, tabPage]() {
|
||||||
const int tabIndex = indexOf(tabPage);
|
const int tabIndex = indexOf(tabPage);
|
||||||
Q_ASSERT(tabIndex >= 0);
|
Q_ASSERT(tabIndex >= 0);
|
||||||
|
@ -497,7 +490,7 @@ QString DolphinTabWidget::tabName(DolphinTabPage* tabPage) const
|
||||||
if (!tabPage) {
|
if (!tabPage) {
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
// clang-format off
|
||||||
QString name;
|
QString name;
|
||||||
if (tabPage->splitViewEnabled()) {
|
if (tabPage->splitViewEnabled()) {
|
||||||
if (tabPage->primaryViewActive()) {
|
if (tabPage->primaryViewActive()) {
|
||||||
|
@ -512,6 +505,7 @@ QString DolphinTabWidget::tabName(DolphinTabPage* tabPage) const
|
||||||
} else {
|
} else {
|
||||||
name = tabPage->activeViewContainer()->caption();
|
name = tabPage->activeViewContainer()->caption();
|
||||||
}
|
}
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
// Make sure that a '&' inside the directory name is displayed correctly
|
// Make sure that a '&' inside the directory name is displayed correctly
|
||||||
// and not misinterpreted as a keyboard shortcut in QTabBar::setTabText()
|
// and not misinterpreted as a keyboard shortcut in QTabBar::setTabText()
|
||||||
|
@ -556,8 +550,7 @@ const std::optional<const DolphinTabWidget::ViewIndex> DolphinTabWidget::viewOpe
|
||||||
}
|
}
|
||||||
|
|
||||||
i = (i + 1) % count();
|
i = (i + 1) % count();
|
||||||
}
|
} while (i != currentIndex());
|
||||||
while (i != currentIndex());
|
|
||||||
|
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
@ -600,8 +593,7 @@ const std::optional<const DolphinTabWidget::ViewIndex> DolphinTabWidget::viewSho
|
||||||
}
|
}
|
||||||
|
|
||||||
i = (i + 1) % count();
|
i = (i + 1) % count();
|
||||||
}
|
} while (i != currentIndex());
|
||||||
while (i != currentIndex());
|
|
||||||
|
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ class DolphinTabWidget : public QTabWidget
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param navigatorsWidget The navigatorsWidget which is always going to be connected
|
* @param navigatorsWidget The navigatorsWidget which is always going to be connected
|
||||||
* to the active tabPage.
|
* to the active tabPage.
|
||||||
|
|
|
@ -12,19 +12,20 @@
|
||||||
#include "dolphinurlnavigatorscontroller.h"
|
#include "dolphinurlnavigatorscontroller.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
#include <KUrlComboBox>
|
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
|
#include <KUrlComboBox>
|
||||||
|
|
||||||
#include <QAbstractButton>
|
#include <QAbstractButton>
|
||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
|
||||||
DolphinUrlNavigator::DolphinUrlNavigator(QWidget *parent) :
|
DolphinUrlNavigator::DolphinUrlNavigator(QWidget *parent)
|
||||||
DolphinUrlNavigator(QUrl(), parent)
|
: DolphinUrlNavigator(QUrl(), parent)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
DolphinUrlNavigator::DolphinUrlNavigator(const QUrl &url, QWidget *parent) :
|
DolphinUrlNavigator::DolphinUrlNavigator(const QUrl &url, QWidget *parent)
|
||||||
KUrlNavigator(DolphinPlacesModelSingleton::instance().placesModel(), url, parent)
|
: KUrlNavigator(DolphinPlacesModelSingleton::instance().placesModel(), url, parent)
|
||||||
{
|
{
|
||||||
const GeneralSettings *settings = GeneralSettings::self();
|
const GeneralSettings *settings = GeneralSettings::self();
|
||||||
setUrlEditable(settings->editableUrl());
|
setUrlEditable(settings->editableUrl());
|
||||||
|
@ -47,8 +48,7 @@ DolphinUrlNavigator::DolphinUrlNavigator(const QUrl &url, QWidget *parent) :
|
||||||
|
|
||||||
DolphinUrlNavigatorsController::registerDolphinUrlNavigator(this);
|
DolphinUrlNavigatorsController::registerDolphinUrlNavigator(this);
|
||||||
|
|
||||||
connect(this, &KUrlNavigator::returnPressed,
|
connect(this, &KUrlNavigator::returnPressed, this, &DolphinUrlNavigator::slotReturnPressed);
|
||||||
this, &DolphinUrlNavigator::slotReturnPressed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DolphinUrlNavigator::~DolphinUrlNavigator()
|
DolphinUrlNavigator::~DolphinUrlNavigator()
|
||||||
|
|
|
@ -46,8 +46,7 @@ bool DolphinUrlNavigatorsController::placesSelectorVisible()
|
||||||
void DolphinUrlNavigatorsController::registerDolphinUrlNavigator(DolphinUrlNavigator *dolphinUrlNavigator)
|
void DolphinUrlNavigatorsController::registerDolphinUrlNavigator(DolphinUrlNavigator *dolphinUrlNavigator)
|
||||||
{
|
{
|
||||||
s_instances.push_front(dolphinUrlNavigator);
|
s_instances.push_front(dolphinUrlNavigator);
|
||||||
connect(dolphinUrlNavigator->editor(), &KUrlComboBox::completionModeChanged,
|
connect(dolphinUrlNavigator->editor(), &KUrlComboBox::completionModeChanged, DolphinUrlNavigatorsController::setCompletionMode);
|
||||||
DolphinUrlNavigatorsController::setCompletionMode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinUrlNavigatorsController::unregisterDolphinUrlNavigator(DolphinUrlNavigator *dolphinUrlNavigator)
|
void DolphinUrlNavigatorsController::unregisterDolphinUrlNavigator(DolphinUrlNavigator *dolphinUrlNavigator)
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "dolphinviewcontainer.h"
|
#include "dolphinviewcontainer.h"
|
||||||
|
|
||||||
|
#include "dolphin_detailsmodesettings.h"
|
||||||
#include "dolphin_generalsettings.h"
|
#include "dolphin_generalsettings.h"
|
||||||
#include "dolphindebug.h"
|
#include "dolphindebug.h"
|
||||||
#include "dolphinplacesmodelsingleton.h"
|
#include "dolphinplacesmodelsingleton.h"
|
||||||
|
@ -14,7 +15,6 @@
|
||||||
#include "search/dolphinsearchbox.h"
|
#include "search/dolphinsearchbox.h"
|
||||||
#include "selectionmode/topbar.h"
|
#include "selectionmode/topbar.h"
|
||||||
#include "statusbar/dolphinstatusbar.h"
|
#include "statusbar/dolphinstatusbar.h"
|
||||||
#include "dolphin_detailsmodesettings.h"
|
|
||||||
|
|
||||||
#include <KActionCollection>
|
#include <KActionCollection>
|
||||||
#if HAVE_KACTIVITIES
|
#if HAVE_KACTIVITIES
|
||||||
|
@ -38,9 +38,9 @@
|
||||||
#include <QDropEvent>
|
#include <QDropEvent>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
|
#include <QRegularExpression>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QRegularExpression>
|
|
||||||
|
|
||||||
// An overview of the widgets contained by this ViewContainer
|
// An overview of the widgets contained by this ViewContainer
|
||||||
struct LayoutStructure {
|
struct LayoutStructure {
|
||||||
|
@ -54,22 +54,22 @@ struct LayoutStructure {
|
||||||
};
|
};
|
||||||
constexpr LayoutStructure positionFor;
|
constexpr LayoutStructure positionFor;
|
||||||
|
|
||||||
DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) :
|
DolphinViewContainer::DolphinViewContainer(const QUrl &url, QWidget *parent)
|
||||||
QWidget(parent),
|
: QWidget(parent)
|
||||||
m_topLayout(nullptr),
|
, m_topLayout(nullptr)
|
||||||
m_urlNavigator{new DolphinUrlNavigator(url)},
|
, m_urlNavigator{new DolphinUrlNavigator(url)}
|
||||||
m_urlNavigatorConnected{nullptr},
|
, m_urlNavigatorConnected{nullptr}
|
||||||
m_searchBox(nullptr),
|
, m_searchBox(nullptr)
|
||||||
m_searchModeEnabled(false),
|
, m_searchModeEnabled(false)
|
||||||
m_messageWidget(nullptr),
|
, m_messageWidget(nullptr)
|
||||||
m_selectionModeTopBar{nullptr},
|
, m_selectionModeTopBar{nullptr}
|
||||||
m_view(nullptr),
|
, m_view(nullptr)
|
||||||
m_filterBar(nullptr),
|
, m_filterBar(nullptr)
|
||||||
m_selectionModeBottomBar{nullptr},
|
, m_selectionModeBottomBar{nullptr}
|
||||||
m_statusBar(nullptr),
|
, m_statusBar(nullptr)
|
||||||
m_statusBarTimer(nullptr),
|
, m_statusBarTimer(nullptr)
|
||||||
m_statusBarTimestamp(),
|
, m_statusBarTimestamp()
|
||||||
m_autoGrabFocus(true)
|
, m_autoGrabFocus(true)
|
||||||
#if HAVE_KACTIVITIES
|
#if HAVE_KACTIVITIES
|
||||||
, m_activityResourceInstance(nullptr)
|
, m_activityResourceInstance(nullptr)
|
||||||
#endif
|
#endif
|
||||||
|
@ -105,7 +105,6 @@ DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) :
|
||||||
|
|
||||||
#ifndef Q_OS_WIN
|
#ifndef Q_OS_WIN
|
||||||
if (getuid() == 0) {
|
if (getuid() == 0) {
|
||||||
|
|
||||||
// We must be logged in as the root user; show a big scary warning
|
// We must be logged in as the root user; show a big scary warning
|
||||||
showMessage(i18n("Running Dolphin as root can be dangerous. Please be careful."), Warning);
|
showMessage(i18n("Running Dolphin as root can be dangerous. Please be careful."), Warning);
|
||||||
}
|
}
|
||||||
|
@ -115,86 +114,51 @@ DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) :
|
||||||
m_filterBar = new FilterBar(this);
|
m_filterBar = new FilterBar(this);
|
||||||
m_filterBar->setVisible(GeneralSettings::filterBar());
|
m_filterBar->setVisible(GeneralSettings::filterBar());
|
||||||
|
|
||||||
connect(m_filterBar, &FilterBar::filterChanged,
|
connect(m_filterBar, &FilterBar::filterChanged, this, &DolphinViewContainer::setNameFilter);
|
||||||
this, &DolphinViewContainer::setNameFilter);
|
connect(m_filterBar, &FilterBar::closeRequest, this, &DolphinViewContainer::closeFilterBar);
|
||||||
connect(m_filterBar, &FilterBar::closeRequest,
|
connect(m_filterBar, &FilterBar::focusViewRequest, this, &DolphinViewContainer::requestFocus);
|
||||||
this, &DolphinViewContainer::closeFilterBar);
|
|
||||||
connect(m_filterBar, &FilterBar::focusViewRequest,
|
|
||||||
this, &DolphinViewContainer::requestFocus);
|
|
||||||
|
|
||||||
// Initialize the main view
|
// Initialize the main view
|
||||||
m_view = new DolphinView(url, this);
|
m_view = new DolphinView(url, this);
|
||||||
connect(m_view, &DolphinView::urlChanged,
|
connect(m_view, &DolphinView::urlChanged, m_filterBar, &FilterBar::clearIfUnlocked);
|
||||||
m_filterBar, &FilterBar::clearIfUnlocked);
|
connect(m_view, &DolphinView::urlChanged, m_messageWidget, &KMessageWidget::hide);
|
||||||
connect(m_view, &DolphinView::urlChanged,
|
|
||||||
m_messageWidget, &KMessageWidget::hide);
|
|
||||||
// m_urlNavigator stays in sync with m_view's location changes and
|
// m_urlNavigator stays in sync with m_view's location changes and
|
||||||
// keeps track of them so going back and forth in the history works.
|
// keeps track of them so going back and forth in the history works.
|
||||||
connect(m_view, &DolphinView::urlChanged,
|
connect(m_view, &DolphinView::urlChanged, m_urlNavigator.get(), &DolphinUrlNavigator::setLocationUrl);
|
||||||
m_urlNavigator.get(), &DolphinUrlNavigator::setLocationUrl);
|
connect(m_urlNavigator.get(), &DolphinUrlNavigator::urlChanged, this, &DolphinViewContainer::slotUrlNavigatorLocationChanged);
|
||||||
connect(m_urlNavigator.get(), &DolphinUrlNavigator::urlChanged,
|
connect(m_urlNavigator.get(), &DolphinUrlNavigator::urlAboutToBeChanged, this, &DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged);
|
||||||
this, &DolphinViewContainer::slotUrlNavigatorLocationChanged);
|
connect(m_urlNavigator.get(), &DolphinUrlNavigator::urlSelectionRequested, this, &DolphinViewContainer::slotUrlSelectionRequested);
|
||||||
connect(m_urlNavigator.get(), &DolphinUrlNavigator::urlAboutToBeChanged,
|
connect(m_view, &DolphinView::writeStateChanged, this, &DolphinViewContainer::writeStateChanged);
|
||||||
this, &DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged);
|
connect(m_view, &DolphinView::requestItemInfo, this, &DolphinViewContainer::showItemInfo);
|
||||||
connect(m_urlNavigator.get(), &DolphinUrlNavigator::urlSelectionRequested,
|
connect(m_view, &DolphinView::itemActivated, this, &DolphinViewContainer::slotItemActivated);
|
||||||
this, &DolphinViewContainer::slotUrlSelectionRequested);
|
connect(m_view, &DolphinView::itemsActivated, this, &DolphinViewContainer::slotItemsActivated);
|
||||||
connect(m_view, &DolphinView::writeStateChanged,
|
connect(m_view, &DolphinView::redirection, this, &DolphinViewContainer::redirect);
|
||||||
this, &DolphinViewContainer::writeStateChanged);
|
connect(m_view, &DolphinView::directoryLoadingStarted, this, &DolphinViewContainer::slotDirectoryLoadingStarted);
|
||||||
connect(m_view, &DolphinView::requestItemInfo,
|
connect(m_view, &DolphinView::directoryLoadingCompleted, this, &DolphinViewContainer::slotDirectoryLoadingCompleted);
|
||||||
this, &DolphinViewContainer::showItemInfo);
|
connect(m_view, &DolphinView::directoryLoadingCanceled, this, &DolphinViewContainer::slotDirectoryLoadingCanceled);
|
||||||
connect(m_view, &DolphinView::itemActivated,
|
connect(m_view, &DolphinView::itemCountChanged, this, &DolphinViewContainer::delayedStatusBarUpdate);
|
||||||
this, &DolphinViewContainer::slotItemActivated);
|
connect(m_view, &DolphinView::directoryLoadingProgress, this, &DolphinViewContainer::updateDirectoryLoadingProgress);
|
||||||
connect(m_view, &DolphinView::itemsActivated,
|
connect(m_view, &DolphinView::directorySortingProgress, this, &DolphinViewContainer::updateDirectorySortingProgress);
|
||||||
this, &DolphinViewContainer::slotItemsActivated);
|
connect(m_view, &DolphinView::selectionChanged, this, &DolphinViewContainer::delayedStatusBarUpdate);
|
||||||
connect(m_view, &DolphinView::redirection,
|
connect(m_view, &DolphinView::errorMessage, this, &DolphinViewContainer::showErrorMessage);
|
||||||
this, &DolphinViewContainer::redirect);
|
connect(m_view, &DolphinView::urlIsFileError, this, &DolphinViewContainer::slotUrlIsFileError);
|
||||||
connect(m_view, &DolphinView::directoryLoadingStarted,
|
connect(m_view, &DolphinView::activated, this, &DolphinViewContainer::activate);
|
||||||
this, &DolphinViewContainer::slotDirectoryLoadingStarted);
|
connect(m_view, &DolphinView::hiddenFilesShownChanged, this, &DolphinViewContainer::slotHiddenFilesShownChanged);
|
||||||
connect(m_view, &DolphinView::directoryLoadingCompleted,
|
connect(m_view, &DolphinView::sortHiddenLastChanged, this, &DolphinViewContainer::slotSortHiddenLastChanged);
|
||||||
this, &DolphinViewContainer::slotDirectoryLoadingCompleted);
|
connect(m_view, &DolphinView::currentDirectoryRemoved, this, &DolphinViewContainer::slotCurrentDirectoryRemoved);
|
||||||
connect(m_view, &DolphinView::directoryLoadingCanceled,
|
|
||||||
this, &DolphinViewContainer::slotDirectoryLoadingCanceled);
|
|
||||||
connect(m_view, &DolphinView::itemCountChanged,
|
|
||||||
this, &DolphinViewContainer::delayedStatusBarUpdate);
|
|
||||||
connect(m_view, &DolphinView::directoryLoadingProgress,
|
|
||||||
this, &DolphinViewContainer::updateDirectoryLoadingProgress);
|
|
||||||
connect(m_view, &DolphinView::directorySortingProgress,
|
|
||||||
this, &DolphinViewContainer::updateDirectorySortingProgress);
|
|
||||||
connect(m_view, &DolphinView::selectionChanged,
|
|
||||||
this, &DolphinViewContainer::delayedStatusBarUpdate);
|
|
||||||
connect(m_view, &DolphinView::errorMessage,
|
|
||||||
this, &DolphinViewContainer::showErrorMessage);
|
|
||||||
connect(m_view, &DolphinView::urlIsFileError,
|
|
||||||
this, &DolphinViewContainer::slotUrlIsFileError);
|
|
||||||
connect(m_view, &DolphinView::activated,
|
|
||||||
this, &DolphinViewContainer::activate);
|
|
||||||
connect(m_view, &DolphinView::hiddenFilesShownChanged,
|
|
||||||
this, &DolphinViewContainer::slotHiddenFilesShownChanged);
|
|
||||||
connect(m_view, &DolphinView::sortHiddenLastChanged,
|
|
||||||
this, &DolphinViewContainer::slotSortHiddenLastChanged);
|
|
||||||
connect(m_view, &DolphinView::currentDirectoryRemoved,
|
|
||||||
this, &DolphinViewContainer::slotCurrentDirectoryRemoved);
|
|
||||||
|
|
||||||
// Initialize status bar
|
// Initialize status bar
|
||||||
m_statusBar = new DolphinStatusBar(this);
|
m_statusBar = new DolphinStatusBar(this);
|
||||||
m_statusBar->setUrl(m_view->url());
|
m_statusBar->setUrl(m_view->url());
|
||||||
m_statusBar->setZoomLevel(m_view->zoomLevel());
|
m_statusBar->setZoomLevel(m_view->zoomLevel());
|
||||||
connect(m_view, &DolphinView::urlChanged,
|
connect(m_view, &DolphinView::urlChanged, m_statusBar, &DolphinStatusBar::setUrl);
|
||||||
m_statusBar, &DolphinStatusBar::setUrl);
|
connect(m_view, &DolphinView::zoomLevelChanged, m_statusBar, &DolphinStatusBar::setZoomLevel);
|
||||||
connect(m_view, &DolphinView::zoomLevelChanged,
|
connect(m_view, &DolphinView::infoMessage, m_statusBar, &DolphinStatusBar::setText);
|
||||||
m_statusBar, &DolphinStatusBar::setZoomLevel);
|
connect(m_view, &DolphinView::operationCompletedMessage, m_statusBar, &DolphinStatusBar::setText);
|
||||||
connect(m_view, &DolphinView::infoMessage,
|
connect(m_view, &DolphinView::statusBarTextChanged, m_statusBar, &DolphinStatusBar::setDefaultText);
|
||||||
m_statusBar, &DolphinStatusBar::setText);
|
connect(m_view, &DolphinView::statusBarTextChanged, m_statusBar, &DolphinStatusBar::resetToDefaultText);
|
||||||
connect(m_view, &DolphinView::operationCompletedMessage,
|
connect(m_statusBar, &DolphinStatusBar::stopPressed, this, &DolphinViewContainer::stopDirectoryLoading);
|
||||||
m_statusBar, &DolphinStatusBar::setText);
|
connect(m_statusBar, &DolphinStatusBar::zoomLevelChanged, this, &DolphinViewContainer::slotStatusBarZoomLevelChanged);
|
||||||
connect(m_view, &DolphinView::statusBarTextChanged,
|
|
||||||
m_statusBar, &DolphinStatusBar::setDefaultText);
|
|
||||||
connect(m_view, &DolphinView::statusBarTextChanged,
|
|
||||||
m_statusBar, &DolphinStatusBar::resetToDefaultText);
|
|
||||||
connect(m_statusBar, &DolphinStatusBar::stopPressed,
|
|
||||||
this, &DolphinViewContainer::stopDirectoryLoading);
|
|
||||||
connect(m_statusBar, &DolphinStatusBar::zoomLevelChanged,
|
|
||||||
this, &DolphinViewContainer::slotStatusBarZoomLevelChanged);
|
|
||||||
|
|
||||||
m_statusBarTimer = new QTimer(this);
|
m_statusBarTimer = new QTimer(this);
|
||||||
m_statusBarTimer->setSingleShot(true);
|
m_statusBarTimer->setSingleShot(true);
|
||||||
|
@ -202,8 +166,7 @@ DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) :
|
||||||
connect(m_statusBarTimer, &QTimer::timeout, this, &DolphinViewContainer::updateStatusBar);
|
connect(m_statusBarTimer, &QTimer::timeout, this, &DolphinViewContainer::updateStatusBar);
|
||||||
|
|
||||||
KIO::FileUndoManager *undoManager = KIO::FileUndoManager::self();
|
KIO::FileUndoManager *undoManager = KIO::FileUndoManager::self();
|
||||||
connect(undoManager, &KIO::FileUndoManager::jobRecordingFinished,
|
connect(undoManager, &KIO::FileUndoManager::jobRecordingFinished, this, &DolphinViewContainer::delayedStatusBarUpdate);
|
||||||
this, &DolphinViewContainer::delayedStatusBarUpdate);
|
|
||||||
|
|
||||||
m_topLayout->addWidget(m_searchBox, positionFor.searchBox, 0);
|
m_topLayout->addWidget(m_searchBox, positionFor.searchBox, 0);
|
||||||
m_topLayout->addWidget(m_messageWidget, positionFor.messageWidget, 0);
|
m_topLayout->addWidget(m_messageWidget, positionFor.messageWidget, 0);
|
||||||
|
@ -220,15 +183,11 @@ DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) :
|
||||||
});
|
});
|
||||||
|
|
||||||
KFilePlacesModel *placesModel = DolphinPlacesModelSingleton::instance().placesModel();
|
KFilePlacesModel *placesModel = DolphinPlacesModelSingleton::instance().placesModel();
|
||||||
connect(placesModel, &KFilePlacesModel::dataChanged,
|
connect(placesModel, &KFilePlacesModel::dataChanged, this, &DolphinViewContainer::slotPlacesModelChanged);
|
||||||
this, &DolphinViewContainer::slotPlacesModelChanged);
|
connect(placesModel, &KFilePlacesModel::rowsInserted, this, &DolphinViewContainer::slotPlacesModelChanged);
|
||||||
connect(placesModel, &KFilePlacesModel::rowsInserted,
|
connect(placesModel, &KFilePlacesModel::rowsRemoved, this, &DolphinViewContainer::slotPlacesModelChanged);
|
||||||
this, &DolphinViewContainer::slotPlacesModelChanged);
|
|
||||||
connect(placesModel, &KFilePlacesModel::rowsRemoved,
|
|
||||||
this, &DolphinViewContainer::slotPlacesModelChanged);
|
|
||||||
|
|
||||||
connect(this, &DolphinViewContainer::searchModeEnabledChanged,
|
connect(this, &DolphinViewContainer::searchModeEnabledChanged, this, &DolphinViewContainer::captionChanged);
|
||||||
this, &DolphinViewContainer::captionChanged);
|
|
||||||
|
|
||||||
// Initialize kactivities resource instance
|
// Initialize kactivities resource instance
|
||||||
|
|
||||||
|
@ -341,17 +300,13 @@ void DolphinViewContainer::connectUrlNavigator(DolphinUrlNavigator *urlNavigator
|
||||||
urlNavigator->setActive(isActive());
|
urlNavigator->setActive(isActive());
|
||||||
|
|
||||||
// Url changes are still done via m_urlNavigator.
|
// Url changes are still done via m_urlNavigator.
|
||||||
connect(urlNavigator, &DolphinUrlNavigator::urlChanged,
|
connect(urlNavigator, &DolphinUrlNavigator::urlChanged, m_urlNavigator.get(), &DolphinUrlNavigator::setLocationUrl);
|
||||||
m_urlNavigator.get(), &DolphinUrlNavigator::setLocationUrl);
|
connect(urlNavigator, &DolphinUrlNavigator::urlsDropped, this, [=](const QUrl &destination, QDropEvent *event) {
|
||||||
connect(urlNavigator, &DolphinUrlNavigator::urlsDropped,
|
|
||||||
this, [=](const QUrl &destination, QDropEvent *event) {
|
|
||||||
m_view->dropUrls(destination, event, urlNavigator->dropWidget());
|
m_view->dropUrls(destination, event, urlNavigator->dropWidget());
|
||||||
});
|
});
|
||||||
// Aside from these, only visual things need to be connected.
|
// Aside from these, only visual things need to be connected.
|
||||||
connect(m_view, &DolphinView::urlChanged,
|
connect(m_view, &DolphinView::urlChanged, urlNavigator, &DolphinUrlNavigator::setLocationUrl);
|
||||||
urlNavigator, &DolphinUrlNavigator::setLocationUrl);
|
connect(urlNavigator, &DolphinUrlNavigator::activated, this, &DolphinViewContainer::activate);
|
||||||
connect(urlNavigator, &DolphinUrlNavigator::activated,
|
|
||||||
this, &DolphinViewContainer::activate);
|
|
||||||
|
|
||||||
m_urlNavigatorConnected = urlNavigator;
|
m_urlNavigatorConnected = urlNavigator;
|
||||||
}
|
}
|
||||||
|
@ -362,14 +317,10 @@ void DolphinViewContainer::disconnectUrlNavigator()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect(m_urlNavigatorConnected, &DolphinUrlNavigator::urlChanged,
|
disconnect(m_urlNavigatorConnected, &DolphinUrlNavigator::urlChanged, m_urlNavigator.get(), &DolphinUrlNavigator::setLocationUrl);
|
||||||
m_urlNavigator.get(), &DolphinUrlNavigator::setLocationUrl);
|
disconnect(m_urlNavigatorConnected, &DolphinUrlNavigator::urlsDropped, this, nullptr);
|
||||||
disconnect(m_urlNavigatorConnected, &DolphinUrlNavigator::urlsDropped,
|
disconnect(m_view, &DolphinView::urlChanged, m_urlNavigatorConnected, &DolphinUrlNavigator::setLocationUrl);
|
||||||
this, nullptr);
|
disconnect(m_urlNavigatorConnected, &DolphinUrlNavigator::activated, this, &DolphinViewContainer::activate);
|
||||||
disconnect(m_view, &DolphinView::urlChanged,
|
|
||||||
m_urlNavigatorConnected, &DolphinUrlNavigator::setLocationUrl);
|
|
||||||
disconnect(m_urlNavigatorConnected, &DolphinUrlNavigator::activated,
|
|
||||||
this, &DolphinViewContainer::activate);
|
|
||||||
|
|
||||||
m_urlNavigatorVisualState = m_urlNavigatorConnected->visualState();
|
m_urlNavigatorVisualState = m_urlNavigatorConnected->visualState();
|
||||||
m_urlNavigatorConnected = nullptr;
|
m_urlNavigatorConnected = nullptr;
|
||||||
|
@ -435,10 +386,10 @@ bool DolphinViewContainer::isSelectionModeEnabled() const
|
||||||
const bool isEnabled = m_view->selectionMode();
|
const bool isEnabled = m_view->selectionMode();
|
||||||
Q_ASSERT((!isEnabled
|
Q_ASSERT((!isEnabled
|
||||||
// We can't assert that the bars are invisible only because the selection mode is disabled because the hide animation might still be playing.
|
// We can't assert that the bars are invisible only because the selection mode is disabled because the hide animation might still be playing.
|
||||||
&& (!m_selectionModeBottomBar || !m_selectionModeBottomBar->isEnabled() ||
|
&& (!m_selectionModeBottomBar || !m_selectionModeBottomBar->isEnabled() || !m_selectionModeBottomBar->isVisible()
|
||||||
!m_selectionModeBottomBar->isVisible() || m_selectionModeBottomBar->contents() == SelectionMode::BottomBar::PasteContents))
|
|| m_selectionModeBottomBar->contents() == SelectionMode::BottomBar::PasteContents))
|
||||||
|| ( isEnabled
|
|| (isEnabled && m_selectionModeTopBar
|
||||||
&& m_selectionModeTopBar && m_selectionModeTopBar->isVisible()
|
&& m_selectionModeTopBar->isVisible()
|
||||||
// The bottom bar is either visible or was hidden because it has nothing to show in GeneralContents mode e.g. because no items are selected.
|
// The bottom bar is either visible or was hidden because it has nothing to show in GeneralContents mode e.g. because no items are selected.
|
||||||
&& m_selectionModeBottomBar
|
&& m_selectionModeBottomBar
|
||||||
&& (m_selectionModeBottomBar->isVisible() || m_selectionModeBottomBar->contents() == SelectionMode::BottomBar::GeneralContents)));
|
&& (m_selectionModeBottomBar->isVisible() || m_selectionModeBottomBar->contents() == SelectionMode::BottomBar::GeneralContents)));
|
||||||
|
@ -452,7 +403,6 @@ void DolphinViewContainer::slotSplitTabDisabled()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DolphinViewContainer::showMessage(const QString &msg, MessageType type)
|
void DolphinViewContainer::showMessage(const QString &msg, MessageType type)
|
||||||
{
|
{
|
||||||
if (msg.isEmpty()) {
|
if (msg.isEmpty()) {
|
||||||
|
@ -466,9 +416,15 @@ void DolphinViewContainer::showMessage(const QString& msg, MessageType type)
|
||||||
m_messageWidget->setWordWrap(true);
|
m_messageWidget->setWordWrap(true);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Information: m_messageWidget->setMessageType(KMessageWidget::Information); break;
|
case Information:
|
||||||
case Warning: m_messageWidget->setMessageType(KMessageWidget::Warning); break;
|
m_messageWidget->setMessageType(KMessageWidget::Information);
|
||||||
case Error: m_messageWidget->setMessageType(KMessageWidget::Error); break;
|
break;
|
||||||
|
case Warning:
|
||||||
|
m_messageWidget->setMessageType(KMessageWidget::Warning);
|
||||||
|
break;
|
||||||
|
case Error:
|
||||||
|
m_messageWidget->setMessageType(KMessageWidget::Error);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Q_ASSERT(false);
|
Q_ASSERT(false);
|
||||||
break;
|
break;
|
||||||
|
@ -590,13 +546,13 @@ QString DolphinViewContainer::caption() const
|
||||||
|
|
||||||
KFilePlacesModel *placesModel = DolphinPlacesModelSingleton::instance().placesModel();
|
KFilePlacesModel *placesModel = DolphinPlacesModelSingleton::instance().placesModel();
|
||||||
const QString pattern = url().adjusted(QUrl::StripTrailingSlash).toString(QUrl::FullyEncoded).append("/?");
|
const QString pattern = url().adjusted(QUrl::StripTrailingSlash).toString(QUrl::FullyEncoded).append("/?");
|
||||||
const auto& matchedPlaces = placesModel->match(placesModel->index(0,0), KFilePlacesModel::UrlRole, QRegularExpression::anchoredPattern(pattern), 1, Qt::MatchRegularExpression);
|
const auto &matchedPlaces =
|
||||||
|
placesModel->match(placesModel->index(0, 0), KFilePlacesModel::UrlRole, QRegularExpression::anchoredPattern(pattern), 1, Qt::MatchRegularExpression);
|
||||||
|
|
||||||
if (!matchedPlaces.isEmpty()) {
|
if (!matchedPlaces.isEmpty()) {
|
||||||
return placesModel->text(matchedPlaces.first());
|
return placesModel->text(matchedPlaces.first());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!url().isLocalFile()) {
|
if (!url().isLocalFile()) {
|
||||||
QUrl adjustedUrl = url().adjusted(QUrl::StripTrailingSlash);
|
QUrl adjustedUrl = url().adjusted(QUrl::StripTrailingSlash);
|
||||||
QString caption;
|
QString caption;
|
||||||
|
@ -842,9 +798,7 @@ void DolphinViewContainer::slotUrlNavigatorLocationChanged(const QUrl& url)
|
||||||
"Dolphin does not support web pages, the web browser has been launched"),
|
"Dolphin does not support web pages, the web browser has been launched"),
|
||||||
Information);
|
Information);
|
||||||
} else {
|
} else {
|
||||||
showMessage(i18nc("@info:status",
|
showMessage(i18nc("@info:status", "Protocol not supported by Dolphin, default application has been launched"), Information);
|
||||||
"Protocol not supported by Dolphin, default application has been launched"),
|
|
||||||
Information);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QDesktopServices::openUrl(url);
|
QDesktopServices::openUrl(url);
|
||||||
|
@ -863,14 +817,12 @@ void DolphinViewContainer::slotUrlSelectionRequested(const QUrl& url)
|
||||||
|
|
||||||
void DolphinViewContainer::disableUrlNavigatorSelectionRequests()
|
void DolphinViewContainer::disableUrlNavigatorSelectionRequests()
|
||||||
{
|
{
|
||||||
disconnect(m_urlNavigator.get(), &KUrlNavigator::urlSelectionRequested,
|
disconnect(m_urlNavigator.get(), &KUrlNavigator::urlSelectionRequested, this, &DolphinViewContainer::slotUrlSelectionRequested);
|
||||||
this, &DolphinViewContainer::slotUrlSelectionRequested);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinViewContainer::enableUrlNavigatorSelectionRequests()
|
void DolphinViewContainer::enableUrlNavigatorSelectionRequests()
|
||||||
{
|
{
|
||||||
connect(m_urlNavigator.get(), &KUrlNavigator::urlSelectionRequested,
|
connect(m_urlNavigator.get(), &KUrlNavigator::urlSelectionRequested, this, &DolphinViewContainer::slotUrlSelectionRequested);
|
||||||
this, &DolphinViewContainer::slotUrlSelectionRequested);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinViewContainer::redirect(const QUrl &oldUrl, const QUrl &newUrl)
|
void DolphinViewContainer::redirect(const QUrl &oldUrl, const QUrl &newUrl)
|
||||||
|
@ -993,8 +945,7 @@ QString DolphinViewContainer::getNearestExistingAncestorOfPath(const QString& pa
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
do {
|
do {
|
||||||
dir.setPath(QDir::cleanPath(dir.filePath(QStringLiteral(".."))));
|
dir.setPath(QDir::cleanPath(dir.filePath(QStringLiteral(".."))));
|
||||||
}
|
} while (!dir.exists() && !dir.isRoot());
|
||||||
while (!dir.exists() && !dir.isRoot());
|
|
||||||
|
|
||||||
return dir.exists() ? dir.path() : QString{};
|
return dir.exists() ? dir.path() : QString{};
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,8 @@
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#if HAVE_KACTIVITIES
|
#if HAVE_KACTIVITIES
|
||||||
namespace KActivities {
|
namespace KActivities
|
||||||
|
{
|
||||||
class ResourceInstance;
|
class ResourceInstance;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -33,7 +34,8 @@ class QGridLayout;
|
||||||
class QUrl;
|
class QUrl;
|
||||||
class DolphinSearchBox;
|
class DolphinSearchBox;
|
||||||
class DolphinStatusBar;
|
class DolphinStatusBar;
|
||||||
namespace SelectionMode {
|
namespace SelectionMode
|
||||||
|
{
|
||||||
class TopBar;
|
class TopBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,12 +56,7 @@ class DolphinViewContainer : public QWidget
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum MessageType
|
enum MessageType { Information, Warning, Error };
|
||||||
{
|
|
||||||
Information,
|
|
||||||
Warning,
|
|
||||||
Error
|
|
||||||
};
|
|
||||||
|
|
||||||
DolphinViewContainer(const QUrl &url, QWidget *parent);
|
DolphinViewContainer(const QUrl &url, QWidget *parent);
|
||||||
~DolphinViewContainer() override;
|
~DolphinViewContainer() override;
|
||||||
|
@ -149,7 +146,9 @@ public:
|
||||||
* @param actionCollection The collection of actions from which the actions on the bottom bar are retrieved.
|
* @param actionCollection The collection of actions from which the actions on the bottom bar are retrieved.
|
||||||
* @param bottomBarContents The contents the bar is supposed to show after this call.
|
* @param bottomBarContents The contents the bar is supposed to show after this call.
|
||||||
*/
|
*/
|
||||||
void setSelectionModeEnabled(bool enabled, KActionCollection *actionCollection = nullptr, SelectionMode::BottomBar::Contents bottomBarContents = SelectionMode::BottomBar::Contents::GeneralContents);
|
void setSelectionModeEnabled(bool enabled,
|
||||||
|
KActionCollection *actionCollection = nullptr,
|
||||||
|
SelectionMode::BottomBar::Contents bottomBarContents = SelectionMode::BottomBar::Contents::GeneralContents);
|
||||||
/** @see setSelectionModeEnabled() */
|
/** @see setSelectionModeEnabled() */
|
||||||
bool isSelectionModeEnabled() const;
|
bool isSelectionModeEnabled() const;
|
||||||
|
|
||||||
|
@ -167,7 +166,6 @@ public:
|
||||||
/** Returns true, if the filter bar is visible. */
|
/** Returns true, if the filter bar is visible. */
|
||||||
bool isFilterBarVisible() const;
|
bool isFilterBarVisible() const;
|
||||||
|
|
||||||
|
|
||||||
/** Returns true if the search mode is enabled. */
|
/** Returns true if the search mode is enabled. */
|
||||||
bool isSearchModeEnabled() const;
|
bool isSearchModeEnabled() const;
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
|
||||||
FilterBar::FilterBar(QWidget* parent) :
|
FilterBar::FilterBar(QWidget *parent)
|
||||||
QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
// Create button to lock text when changing folders
|
// Create button to lock text when changing folders
|
||||||
m_lockButton = new QToolButton(this);
|
m_lockButton = new QToolButton(this);
|
||||||
|
@ -26,14 +26,12 @@ FilterBar::FilterBar(QWidget* parent) :
|
||||||
m_lockButton->setToolTip(i18nc("@info:tooltip", "Keep Filter When Changing Folders"));
|
m_lockButton->setToolTip(i18nc("@info:tooltip", "Keep Filter When Changing Folders"));
|
||||||
connect(m_lockButton, &QToolButton::toggled, this, &FilterBar::slotToggleLockButton);
|
connect(m_lockButton, &QToolButton::toggled, this, &FilterBar::slotToggleLockButton);
|
||||||
|
|
||||||
|
|
||||||
// Create filter editor
|
// Create filter editor
|
||||||
m_filterInput = new QLineEdit(this);
|
m_filterInput = new QLineEdit(this);
|
||||||
m_filterInput->setLayoutDirection(Qt::LeftToRight);
|
m_filterInput->setLayoutDirection(Qt::LeftToRight);
|
||||||
m_filterInput->setClearButtonEnabled(true);
|
m_filterInput->setClearButtonEnabled(true);
|
||||||
m_filterInput->setPlaceholderText(i18n("Filter..."));
|
m_filterInput->setPlaceholderText(i18n("Filter..."));
|
||||||
connect(m_filterInput, &QLineEdit::textChanged,
|
connect(m_filterInput, &QLineEdit::textChanged, this, &FilterBar::filterChanged);
|
||||||
this, &FilterBar::filterChanged);
|
|
||||||
setFocusProxy(m_filterInput);
|
setFocusProxy(m_filterInput);
|
||||||
|
|
||||||
// Create close button
|
// Create close button
|
||||||
|
@ -120,4 +118,3 @@ void FilterBar::keyReleaseEvent(QKeyEvent* event)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,11 @@ void Dolphin::openNewWindow(const QList<QUrl> &urls, QWidget *window, const Open
|
||||||
job->start();
|
job->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Dolphin::attachToExistingInstance(const QList<QUrl>& inputUrls, bool openFiles, bool splitView, const QString& preferredService, const QString &activationToken)
|
bool Dolphin::attachToExistingInstance(const QList<QUrl> &inputUrls,
|
||||||
|
bool openFiles,
|
||||||
|
bool splitView,
|
||||||
|
const QString &preferredService,
|
||||||
|
const QString &activationToken)
|
||||||
{
|
{
|
||||||
bool attached = false;
|
bool attached = false;
|
||||||
|
|
||||||
|
@ -101,8 +105,7 @@ bool Dolphin::attachToExistingInstance(const QList<QUrl>& inputUrls, bool openFi
|
||||||
}
|
}
|
||||||
|
|
||||||
i = (i + 1) % dolphinInterfaces.size();
|
i = (i + 1) % dolphinInterfaces.size();
|
||||||
}
|
} while (i != activeWindowIndex);
|
||||||
while (i != activeWindowIndex);
|
|
||||||
|
|
||||||
if (!urlFound) {
|
if (!urlFound) {
|
||||||
if (GeneralSettings::openExternallyCalledFolderInNewTab()) {
|
if (GeneralSettings::openExternallyCalledFolderInNewTab()) {
|
||||||
|
@ -117,9 +120,7 @@ bool Dolphin::attachToExistingInstance(const QList<QUrl>& inputUrls, bool openFi
|
||||||
if (interface.second.isEmpty()) {
|
if (interface.second.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto reply = openFiles ?
|
auto reply = openFiles ? interface.first->openFiles(interface.second, splitView) : interface.first->openDirectories(interface.second, splitView);
|
||||||
interface.first->openFiles(interface.second, splitView) :
|
|
||||||
interface.first->openDirectories(interface.second, splitView);
|
|
||||||
reply.waitForFinished();
|
reply.waitForFinished();
|
||||||
if (!reply.isError()) {
|
if (!reply.isError()) {
|
||||||
interface.first->activateWindow(activationToken);
|
interface.first->activateWindow(activationToken);
|
||||||
|
@ -142,9 +143,7 @@ QVector<QPair<QSharedPointer<OrgKdeDolphinMainWindowInterface>, QStringList>> Do
|
||||||
QVector<QPair<QSharedPointer<OrgKdeDolphinMainWindowInterface>, QStringList>> dolphinInterfaces;
|
QVector<QPair<QSharedPointer<OrgKdeDolphinMainWindowInterface>, QStringList>> dolphinInterfaces;
|
||||||
if (!preferredService.isEmpty()) {
|
if (!preferredService.isEmpty()) {
|
||||||
QSharedPointer<OrgKdeDolphinMainWindowInterface> preferredInterface(
|
QSharedPointer<OrgKdeDolphinMainWindowInterface> preferredInterface(
|
||||||
new OrgKdeDolphinMainWindowInterface(preferredService,
|
new OrgKdeDolphinMainWindowInterface(preferredService, QStringLiteral("/dolphin/Dolphin_1"), QDBusConnection::sessionBus()));
|
||||||
QStringLiteral("/dolphin/Dolphin_1"),
|
|
||||||
QDBusConnection::sessionBus()));
|
|
||||||
if (preferredInterface->isValid() && !preferredInterface->lastError().isValid()) {
|
if (preferredInterface->isValid() && !preferredInterface->lastError().isValid()) {
|
||||||
dolphinInterfaces.append(qMakePair(preferredInterface, QStringList()));
|
dolphinInterfaces.append(qMakePair(preferredInterface, QStringList()));
|
||||||
}
|
}
|
||||||
|
@ -161,9 +160,7 @@ QVector<QPair<QSharedPointer<OrgKdeDolphinMainWindowInterface>, QStringList>> Do
|
||||||
if (service.startsWith(pattern) && !service.endsWith(myPid)) {
|
if (service.startsWith(pattern) && !service.endsWith(myPid)) {
|
||||||
// Check if instance can handle our URLs
|
// Check if instance can handle our URLs
|
||||||
QSharedPointer<OrgKdeDolphinMainWindowInterface> interface(
|
QSharedPointer<OrgKdeDolphinMainWindowInterface> interface(
|
||||||
new OrgKdeDolphinMainWindowInterface(service,
|
new OrgKdeDolphinMainWindowInterface(service, QStringLiteral("/dolphin/Dolphin_1"), QDBusConnection::sessionBus()));
|
||||||
QStringLiteral("/dolphin/Dolphin_1"),
|
|
||||||
QDBusConnection::sessionBus()));
|
|
||||||
if (interface->isValid() && !interface->lastError().isValid()) {
|
if (interface->isValid() && !interface->lastError().isValid()) {
|
||||||
dolphinInterfaces.append(qMakePair(interface, QStringList()));
|
dolphinInterfaces.append(qMakePair(interface, QStringList()));
|
||||||
}
|
}
|
||||||
|
@ -189,17 +186,14 @@ double GlobalConfig::animationDurationFactor()
|
||||||
updateAnimationDurationFactor(kdeGlobalsConfig, {"AnimationDurationFactor"});
|
updateAnimationDurationFactor(kdeGlobalsConfig, {"AnimationDurationFactor"});
|
||||||
|
|
||||||
KConfigWatcher::Ptr configWatcher = KConfigWatcher::create(KSharedConfig::openConfig());
|
KConfigWatcher::Ptr configWatcher = KConfigWatcher::create(KSharedConfig::openConfig());
|
||||||
connect(configWatcher.data(), &KConfigWatcher::configChanged,
|
connect(configWatcher.data(), &KConfigWatcher::configChanged, &GlobalConfig::updateAnimationDurationFactor);
|
||||||
&GlobalConfig::updateAnimationDurationFactor);
|
|
||||||
return s_animationDurationFactor;
|
return s_animationDurationFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalConfig::updateAnimationDurationFactor(const KConfigGroup &group, const QByteArrayList &names)
|
void GlobalConfig::updateAnimationDurationFactor(const KConfigGroup &group, const QByteArrayList &names)
|
||||||
{
|
{
|
||||||
if (group.name() == QLatin1String("KDE") &&
|
if (group.name() == QLatin1String("KDE") && names.contains(QByteArrayLiteral("AnimationDurationFactor"))) {
|
||||||
names.contains(QByteArrayLiteral("AnimationDurationFactor"))) {
|
s_animationDurationFactor = std::max(0.0, group.readEntry("AnimationDurationFactor", 1.0));
|
||||||
s_animationDurationFactor = std::max(0.0,
|
|
||||||
group.readEntry("AnimationDurationFactor", 1.0));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
13
src/global.h
13
src/global.h
|
@ -14,7 +14,8 @@
|
||||||
class KConfigGroup;
|
class KConfigGroup;
|
||||||
class OrgKdeDolphinMainWindowInterface;
|
class OrgKdeDolphinMainWindowInterface;
|
||||||
|
|
||||||
namespace Dolphin {
|
namespace Dolphin
|
||||||
|
{
|
||||||
QList<QUrl> validateUris(const QStringList &uriList);
|
QList<QUrl> validateUris(const QStringList &uriList);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,10 +23,7 @@ namespace Dolphin {
|
||||||
*/
|
*/
|
||||||
QUrl homeUrl();
|
QUrl homeUrl();
|
||||||
|
|
||||||
enum class OpenNewWindowFlag {
|
enum class OpenNewWindowFlag { None = 0, Select = 1 << 1 };
|
||||||
None = 0,
|
|
||||||
Select = 1<<1
|
|
||||||
};
|
|
||||||
Q_DECLARE_FLAGS(OpenNewWindowFlags, OpenNewWindowFlag)
|
Q_DECLARE_FLAGS(OpenNewWindowFlags, OpenNewWindowFlag)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,10 +53,7 @@ namespace Dolphin {
|
||||||
const int LAYOUT_SPACING_SMALL = 2;
|
const int LAYOUT_SPACING_SMALL = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Animated {
|
enum Animated { WithAnimation, WithoutAnimation };
|
||||||
WithAnimation,
|
|
||||||
WithoutAnimation
|
|
||||||
};
|
|
||||||
|
|
||||||
class GlobalConfig : public QObject
|
class GlobalConfig : public QObject
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,27 +19,35 @@ QString fileItemListToString(KFileItemList items, int maximumTextWidth, const QF
|
||||||
QString text;
|
QString text;
|
||||||
switch (items.count()) {
|
switch (items.count()) {
|
||||||
case 1:
|
case 1:
|
||||||
text = i18nc("Textual representation of a file. %1 is the name of the file/folder.",
|
text = i18nc("Textual representation of a file. %1 is the name of the file/folder.", "\"%1\"", items.first().name());
|
||||||
"\"%1\"", items.first().name());
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
text = i18nc("Textual representation of two files. %1 and %2 are names of files/folders.",
|
text =
|
||||||
"\"%1\" and \"%2\"", items.first().name(), items.last().name());
|
i18nc("Textual representation of two files. %1 and %2 are names of files/folders.", "\"%1\" and \"%2\"", items.first().name(), items.last().name());
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
text = i18nc("Textual representation of three files. %1, %2 and %3 are names of files/folders.",
|
text = i18nc("Textual representation of three files. %1, %2 and %3 are names of files/folders.",
|
||||||
"\"%1\", \"%2\" and \"%3\"",
|
"\"%1\", \"%2\" and \"%3\"",
|
||||||
items.first().name(), items.at(1).name(), items.last().name());
|
items.first().name(),
|
||||||
|
items.at(1).name(),
|
||||||
|
items.last().name());
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
text = i18nc("Textual representation of four files. %1, %2, %3 and %4 are names of files/folders.",
|
text = i18nc("Textual representation of four files. %1, %2, %3 and %4 are names of files/folders.",
|
||||||
"\"%1\", \"%2\", \"%3\" and \"%4\"",
|
"\"%1\", \"%2\", \"%3\" and \"%4\"",
|
||||||
items.first().name(), items.at(1).name(), items.at(2).name(), items.last().name());
|
items.first().name(),
|
||||||
|
items.at(1).name(),
|
||||||
|
items.at(2).name(),
|
||||||
|
items.last().name());
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
text = i18nc("Textual representation of five files. %1, %2, %3, %4 and %5 are names of files/folders.",
|
text = i18nc("Textual representation of five files. %1, %2, %3, %4 and %5 are names of files/folders.",
|
||||||
"\"%1\", \"%2\", \"%3\", \"%4\" and \"%5\"",
|
"\"%1\", \"%2\", \"%3\", \"%4\" and \"%5\"",
|
||||||
items.first().name(), items.at(1).name(), items.at(2).name(), items.at(3).name(), items.last().name());
|
items.first().name(),
|
||||||
|
items.at(1).name(),
|
||||||
|
items.at(2).name(),
|
||||||
|
items.at(3).name(),
|
||||||
|
items.last().name());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
text = QString();
|
text = QString();
|
||||||
|
@ -54,14 +62,15 @@ QString fileItemListToString(KFileItemList items, int maximumTextWidth, const QF
|
||||||
const KFileItemListProperties properties(items);
|
const KFileItemListProperties properties(items);
|
||||||
if (itemsState == Selected) {
|
if (itemsState == Selected) {
|
||||||
if (properties.isFile()) {
|
if (properties.isFile()) {
|
||||||
text = i18ncp("Textual representation of selected files. %1 is the number of files.",
|
text = i18ncp("Textual representation of selected files. %1 is the number of files.", "One Selected File", "%1 Selected Files", items.count());
|
||||||
"One Selected File", "%1 Selected Files", items.count());
|
|
||||||
} else if (properties.isDirectory()) {
|
} else if (properties.isDirectory()) {
|
||||||
text = i18ncp("Textual representation of selected folders. %1 is the number of folders.",
|
text =
|
||||||
"One Selected Folder", "%1 Selected Folders", items.count());
|
i18ncp("Textual representation of selected folders. %1 is the number of folders.", "One Selected Folder", "%1 Selected Folders", items.count());
|
||||||
} else {
|
} else {
|
||||||
text = i18ncp("Textual representation of selected fileitems. %1 is the number of files/folders.",
|
text = i18ncp("Textual representation of selected fileitems. %1 is the number of files/folders.",
|
||||||
"One Selected Item", "%1 Selected Items", items.count());
|
"One Selected Item",
|
||||||
|
"%1 Selected Items",
|
||||||
|
items.count());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fontMetrics.horizontalAdvance(text) <= maximumTextWidth) {
|
if (fontMetrics.horizontalAdvance(text) <= maximumTextWidth) {
|
||||||
|
@ -70,13 +79,10 @@ QString fileItemListToString(KFileItemList items, int maximumTextWidth, const QF
|
||||||
}
|
}
|
||||||
|
|
||||||
if (properties.isFile()) {
|
if (properties.isFile()) {
|
||||||
return i18ncp("Textual representation of files. %1 is the number of files.",
|
return i18ncp("Textual representation of files. %1 is the number of files.", "One File", "%1 Files", items.count());
|
||||||
"One File", "%1 Files", items.count());
|
|
||||||
} else if (properties.isDirectory()) {
|
} else if (properties.isDirectory()) {
|
||||||
return i18ncp("Textual representation of folders. %1 is the number of folders.",
|
return i18ncp("Textual representation of folders. %1 is the number of folders.", "One Folder", "%1 Folders", items.count());
|
||||||
"One Folder", "%1 Folders", items.count());
|
|
||||||
} else {
|
} else {
|
||||||
return i18ncp("Textual representation of fileitems. %1 is the number of files/folders.",
|
return i18ncp("Textual representation of fileitems. %1 is the number of files/folders.", "One Item", "%1 Items", items.count());
|
||||||
"One Item", "%1 Items", items.count());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,10 +12,7 @@ class KFileItemList;
|
||||||
class QFontMetrics;
|
class QFontMetrics;
|
||||||
class QString;
|
class QString;
|
||||||
|
|
||||||
enum ItemsState {
|
enum ItemsState { None, Selected };
|
||||||
None,
|
|
||||||
Selected
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Generates a textual representation of the given list of KFileItems.
|
* @brief Generates a textual representation of the given list of KFileItems.
|
||||||
|
|
|
@ -15,14 +15,15 @@
|
||||||
|
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QPainter>
|
|
||||||
#include <QTimer>
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QMimeDatabase>
|
#include <QMimeDatabase>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
// #define KFILEITEMLISTVIEW_DEBUG
|
// #define KFILEITEMLISTVIEW_DEBUG
|
||||||
|
|
||||||
namespace {
|
namespace
|
||||||
|
{
|
||||||
// If the visible index range changes, KFileItemModelRolesUpdater is not
|
// If the visible index range changes, KFileItemModelRolesUpdater is not
|
||||||
// informed immediately, but with a short delay. This ensures that scrolling
|
// informed immediately, but with a short delay. This ensures that scrolling
|
||||||
// always feels smooth and is not interrupted by icon loading (which can be
|
// always feels smooth and is not interrupted by icon loading (which can be
|
||||||
|
@ -35,12 +36,12 @@ namespace {
|
||||||
const int LongInterval = 300;
|
const int LongInterval = 300;
|
||||||
}
|
}
|
||||||
|
|
||||||
KFileItemListView::KFileItemListView(QGraphicsWidget* parent) :
|
KFileItemListView::KFileItemListView(QGraphicsWidget *parent)
|
||||||
KStandardItemListView(parent),
|
: KStandardItemListView(parent)
|
||||||
m_modelRolesUpdater(nullptr),
|
, m_modelRolesUpdater(nullptr)
|
||||||
m_updateVisibleIndexRangeTimer(nullptr),
|
, m_updateVisibleIndexRangeTimer(nullptr)
|
||||||
m_updateIconSizeTimer(nullptr),
|
, m_updateIconSizeTimer(nullptr)
|
||||||
m_scanDirectories(true)
|
, m_scanDirectories(true)
|
||||||
{
|
{
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
|
||||||
|
@ -328,8 +329,7 @@ void KFileItemListView::onTransactionEnd()
|
||||||
// Only unpause the model-roles-updater if no timer is active. If one
|
// Only unpause the model-roles-updater if no timer is active. If one
|
||||||
// timer is still active the model-roles-updater will be unpaused later as
|
// timer is still active the model-roles-updater will be unpaused later as
|
||||||
// soon as the timer has been exceeded.
|
// soon as the timer has been exceeded.
|
||||||
const bool timerActive = m_updateVisibleIndexRangeTimer->isActive() ||
|
const bool timerActive = m_updateVisibleIndexRangeTimer->isActive() || m_updateIconSizeTimer->isActive();
|
||||||
m_updateIconSizeTimer->isActive();
|
|
||||||
if (!timerActive) {
|
if (!timerActive) {
|
||||||
m_modelRolesUpdater->setPaused(false);
|
m_modelRolesUpdater->setPaused(false);
|
||||||
}
|
}
|
||||||
|
@ -457,4 +457,3 @@ QSize KFileItemListView::availableIconSize() const
|
||||||
|
|
||||||
return QSize(iconSize, iconSize);
|
return QSize(iconSize, iconSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,5 +143,3 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QMimeDatabase>
|
#include <QMimeDatabase>
|
||||||
|
|
||||||
KFileItemListWidgetInformant::KFileItemListWidgetInformant() :
|
KFileItemListWidgetInformant::KFileItemListWidgetInformant()
|
||||||
KStandardItemListWidgetInformant()
|
: KStandardItemListWidgetInformant()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,8 +45,7 @@ bool KFileItemListWidgetInformant::itemIsLink(int index, const KItemListView* vi
|
||||||
return item.isLink();
|
return item.isLink();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString KFileItemListWidgetInformant::roleText(const QByteArray& role,
|
QString KFileItemListWidgetInformant::roleText(const QByteArray &role, const QHash<QByteArray, QVariant> &values) const
|
||||||
const QHash<QByteArray, QVariant>& values) const
|
|
||||||
{
|
{
|
||||||
QString text;
|
QString text;
|
||||||
const QVariant roleValue = values.value(role);
|
const QVariant roleValue = values.value(role);
|
||||||
|
@ -114,8 +113,8 @@ QFont KFileItemListWidgetInformant::customizedFontForLinks(const QFont& baseFont
|
||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
KFileItemListWidget::KFileItemListWidget(KItemListWidgetInformant* informant, QGraphicsItem* parent) :
|
KFileItemListWidget::KFileItemListWidget(KItemListWidgetInformant *informant, QGraphicsItem *parent)
|
||||||
KStandardItemListWidget(informant, parent)
|
: KStandardItemListWidget(informant, parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,4 +221,3 @@ KFileItemListView* KFileItemListWidget::listView()
|
||||||
{
|
{
|
||||||
return dynamic_cast<KFileItemListView *>(parentItem());
|
return dynamic_cast<KFileItemListView *>(parentItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
class KFileItemListView;
|
class KFileItemListView;
|
||||||
|
|
||||||
|
|
||||||
class DOLPHIN_EXPORT KFileItemListWidgetInformant : public KStandardItemListWidgetInformant
|
class DOLPHIN_EXPORT KFileItemListWidgetInformant : public KStandardItemListWidgetInformant
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -55,5 +54,3 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,24 +8,24 @@
|
||||||
|
|
||||||
#include "kfileitemmodel.h"
|
#include "kfileitemmodel.h"
|
||||||
|
|
||||||
#include "dolphin_generalsettings.h"
|
|
||||||
#include "dolphin_detailsmodesettings.h"
|
#include "dolphin_detailsmodesettings.h"
|
||||||
|
#include "dolphin_generalsettings.h"
|
||||||
#include "dolphindebug.h"
|
#include "dolphindebug.h"
|
||||||
#include "private/kfileitemmodelsortalgorithm.h"
|
#include "private/kfileitemmodelsortalgorithm.h"
|
||||||
|
|
||||||
#include <KDirLister>
|
#include <KDirLister>
|
||||||
#include <KIO/Job>
|
#include <KIO/Job>
|
||||||
#include <kio_version.h>
|
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
#include <KUrlMimeData>
|
#include <KUrlMimeData>
|
||||||
|
#include <kio_version.h>
|
||||||
|
|
||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
|
#include <QIcon>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QMimeDatabase>
|
#include <QMimeDatabase>
|
||||||
|
#include <QRecursiveMutex>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QRecursiveMutex>
|
|
||||||
#include <QIcon>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <klazylocalizedstring.h>
|
#include <klazylocalizedstring.h>
|
||||||
|
|
||||||
|
@ -33,25 +33,25 @@ Q_GLOBAL_STATIC(QRecursiveMutex, s_collatorMutex)
|
||||||
|
|
||||||
// #define KFILEITEMMODEL_DEBUG
|
// #define KFILEITEMMODEL_DEBUG
|
||||||
|
|
||||||
KFileItemModel::KFileItemModel(QObject* parent) :
|
KFileItemModel::KFileItemModel(QObject *parent)
|
||||||
KItemModelBase("text", parent),
|
: KItemModelBase("text", parent)
|
||||||
m_dirLister(nullptr),
|
, m_dirLister(nullptr)
|
||||||
m_sortDirsFirst(true),
|
, m_sortDirsFirst(true)
|
||||||
m_sortHiddenLast(false),
|
, m_sortHiddenLast(false)
|
||||||
m_sortRole(NameRole),
|
, m_sortRole(NameRole)
|
||||||
m_sortingProgressPercent(-1),
|
, m_sortingProgressPercent(-1)
|
||||||
m_roles(),
|
, m_roles()
|
||||||
m_itemData(),
|
, m_itemData()
|
||||||
m_items(),
|
, m_items()
|
||||||
m_filter(),
|
, m_filter()
|
||||||
m_filteredItems(),
|
, m_filteredItems()
|
||||||
m_requestRole(),
|
, m_requestRole()
|
||||||
m_maximumUpdateIntervalTimer(nullptr),
|
, m_maximumUpdateIntervalTimer(nullptr)
|
||||||
m_resortAllItemsTimer(nullptr),
|
, m_resortAllItemsTimer(nullptr)
|
||||||
m_pendingItemsToInsert(),
|
, m_pendingItemsToInsert()
|
||||||
m_groups(),
|
, m_groups()
|
||||||
m_expandedDirs(),
|
, m_expandedDirs()
|
||||||
m_urlsToExpand()
|
, m_urlsToExpand()
|
||||||
{
|
{
|
||||||
m_collator.setNumericMode(true);
|
m_collator.setNumericMode(true);
|
||||||
|
|
||||||
|
@ -353,8 +353,12 @@ QList<QPair<int, QVariant> > KFileItemModel::groups() const
|
||||||
timer.start();
|
timer.start();
|
||||||
#endif
|
#endif
|
||||||
switch (typeForRole(sortRole())) {
|
switch (typeForRole(sortRole())) {
|
||||||
case NameRole: m_groups = nameRoleGroups(); break;
|
case NameRole:
|
||||||
case SizeRole: m_groups = sizeRoleGroups(); break;
|
m_groups = nameRoleGroups();
|
||||||
|
break;
|
||||||
|
case SizeRole:
|
||||||
|
m_groups = sizeRoleGroups();
|
||||||
|
break;
|
||||||
case ModificationTimeRole:
|
case ModificationTimeRole:
|
||||||
m_groups = timeRoleGroups([](const ItemData *item) {
|
m_groups = timeRoleGroups([](const ItemData *item) {
|
||||||
return item->item.time(KFileItem::ModificationTime);
|
return item->item.time(KFileItem::ModificationTime);
|
||||||
|
@ -375,9 +379,15 @@ QList<QPair<int, QVariant> > KFileItemModel::groups() const
|
||||||
return item->values.value("deletiontime").toDateTime();
|
return item->values.value("deletiontime").toDateTime();
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case PermissionsRole: m_groups = permissionRoleGroups(); break;
|
case PermissionsRole:
|
||||||
case RatingRole: m_groups = ratingRoleGroups(); break;
|
m_groups = permissionRoleGroups();
|
||||||
default: m_groups = genericStringRoleGroups(sortRole()); break;
|
break;
|
||||||
|
case RatingRole:
|
||||||
|
m_groups = ratingRoleGroups();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
m_groups = genericStringRoleGroups(sortRole());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef KFILEITEMMODEL_DEBUG
|
#ifdef KFILEITEMMODEL_DEBUG
|
||||||
|
@ -662,7 +672,6 @@ void KFileItemModel::restoreExpandedDirectories(const QSet<QUrl> &urls)
|
||||||
|
|
||||||
void KFileItemModel::expandParentDirectories(const QUrl &url)
|
void KFileItemModel::expandParentDirectories(const QUrl &url)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Assure that each sub-path of the URL that should be
|
// Assure that each sub-path of the URL that should be
|
||||||
// expanded is added to m_urlsToExpand. KDirLister
|
// expanded is added to m_urlsToExpand. KDirLister
|
||||||
// does not care whether the parent-URL has already been
|
// does not care whether the parent-URL has already been
|
||||||
|
@ -740,8 +749,7 @@ void KFileItemModel::applyFilters()
|
||||||
for (int index = m_itemData.count() - 1; index >= 0; --index) {
|
for (int index = m_itemData.count() - 1; index >= 0; --index) {
|
||||||
ItemData *itemData = m_itemData.at(index);
|
ItemData *itemData = m_itemData.at(index);
|
||||||
|
|
||||||
if (m_filter.matches(itemData->item)
|
if (m_filter.matches(itemData->item) || (itemShownBelow && itemShownBelow->parent == itemData)) {
|
||||||
|| (itemShownBelow && itemShownBelow->parent == itemData)) {
|
|
||||||
// We could've entered here for two reasons:
|
// We could've entered here for two reasons:
|
||||||
// 1. This item passes the filter itself
|
// 1. This item passes the filter itself
|
||||||
// 2. This is an expanded folder that doesn't pass the filter but sees a filter-passing child just below
|
// 2. This is an expanded folder that doesn't pass the filter but sees a filter-passing child just below
|
||||||
|
@ -952,8 +960,7 @@ void KFileItemModel::resortAllItems()
|
||||||
|
|
||||||
// Determine the first index that has been moved.
|
// Determine the first index that has been moved.
|
||||||
int firstMovedIndex = 0;
|
int firstMovedIndex = 0;
|
||||||
while (firstMovedIndex < itemCount
|
while (firstMovedIndex < itemCount && firstMovedIndex == m_items.value(oldUrls.at(firstMovedIndex))) {
|
||||||
&& firstMovedIndex == m_items.value(oldUrls.at(firstMovedIndex))) {
|
|
||||||
++firstMovedIndex;
|
++firstMovedIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -962,8 +969,7 @@ void KFileItemModel::resortAllItems()
|
||||||
m_groups.clear();
|
m_groups.clear();
|
||||||
|
|
||||||
int lastMovedIndex = itemCount - 1;
|
int lastMovedIndex = itemCount - 1;
|
||||||
while (lastMovedIndex > firstMovedIndex
|
while (lastMovedIndex > firstMovedIndex && lastMovedIndex == m_items.value(oldUrls.at(lastMovedIndex))) {
|
||||||
&& lastMovedIndex == m_items.value(oldUrls.at(lastMovedIndex))) {
|
|
||||||
--lastMovedIndex;
|
--lastMovedIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1436,8 +1442,7 @@ void KFileItemModel::insertItems(QList<ItemData*>& newItems)
|
||||||
if (m_sortRole == NameRole) {
|
if (m_sortRole == NameRole) {
|
||||||
parallelMergeSort(newItems.begin(), newItems.end(), nameLessThan, QThread::idealThreadCount());
|
parallelMergeSort(newItems.begin(), newItems.end(), nameLessThan, QThread::idealThreadCount());
|
||||||
} else if (isRoleValueNatural(m_sortRole)) {
|
} else if (isRoleValueNatural(m_sortRole)) {
|
||||||
auto lambdaLessThan = [&] (const KFileItemModel::ItemData* a, const KFileItemModel::ItemData* b)
|
auto lambdaLessThan = [&](const KFileItemModel::ItemData *a, const KFileItemModel::ItemData *b) {
|
||||||
{
|
|
||||||
const QByteArray role = roleForType(m_sortRole);
|
const QByteArray role = roleForType(m_sortRole);
|
||||||
return a->values.value(role).toString() < b->values.value(role).toString();
|
return a->values.value(role).toString() < b->values.value(role).toString();
|
||||||
};
|
};
|
||||||
|
@ -1695,11 +1700,9 @@ void KFileItemModel::emitItemsChangedAndTriggerResorting(const KItemRangeList& i
|
||||||
// (a) The first item in the range is "lessThan" its predecessor,
|
// (a) The first item in the range is "lessThan" its predecessor,
|
||||||
// (b) the successor of the last item is "lessThan" the last item, or
|
// (b) the successor of the last item is "lessThan" the last item, or
|
||||||
// (c) the internal order of the items in the range is incorrect.
|
// (c) the internal order of the items in the range is incorrect.
|
||||||
if (first > 0
|
if (first > 0 && lessThan(m_itemData.at(first), m_itemData.at(first - 1), m_collator)) {
|
||||||
&& lessThan(m_itemData.at(first), m_itemData.at(first - 1), m_collator)) {
|
|
||||||
needsResorting = true;
|
needsResorting = true;
|
||||||
} else if (last < count() - 1
|
} else if (last < count() - 1 && lessThan(m_itemData.at(last + 1), m_itemData.at(last), m_collator)) {
|
||||||
&& lessThan(m_itemData.at(last + 1), m_itemData.at(last), m_collator)) {
|
|
||||||
needsResorting = true;
|
needsResorting = true;
|
||||||
} else {
|
} else {
|
||||||
for (int index = first; index < last; ++index) {
|
for (int index = first; index < last; ++index) {
|
||||||
|
@ -1991,11 +1994,9 @@ bool KFileItemModel::lessThan(const ItemData* a, const ItemData* b, const QColla
|
||||||
return (sortOrder() == Qt::AscendingOrder) ? result < 0 : result > 0;
|
return (sortOrder() == Qt::AscendingOrder) ? result < 0 : result > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KFileItemModel::sort(const QList<KFileItemModel::ItemData*>::iterator &begin,
|
void KFileItemModel::sort(const QList<KFileItemModel::ItemData *>::iterator &begin, const QList<KFileItemModel::ItemData *>::iterator &end) const
|
||||||
const QList<KFileItemModel::ItemData*>::iterator &end) const
|
|
||||||
{
|
|
||||||
auto lambdaLessThan = [&] (const KFileItemModel::ItemData* a, const KFileItemModel::ItemData* b)
|
|
||||||
{
|
{
|
||||||
|
auto lambdaLessThan = [&](const KFileItemModel::ItemData *a, const KFileItemModel::ItemData *b) {
|
||||||
return lessThan(a, b, m_collator);
|
return lessThan(a, b, m_collator);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2156,7 +2157,6 @@ int KFileItemModel::sortRoleCompare(const ItemData* a, const ItemData* b, const
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
|
@ -2226,7 +2226,6 @@ QList<QPair<int, QVariant> > KFileItemModel::nameRoleGroups() const
|
||||||
if (firstChar != newFirstChar) {
|
if (firstChar != newFirstChar) {
|
||||||
QString newGroupValue;
|
QString newGroupValue;
|
||||||
if (newFirstChar.isLetter()) {
|
if (newFirstChar.isLetter()) {
|
||||||
|
|
||||||
if (m_collator.compare(newFirstChar, QChar(QLatin1Char('A'))) >= 0 && m_collator.compare(newFirstChar, QChar(QLatin1Char('Z'))) <= 0) {
|
if (m_collator.compare(newFirstChar, QChar(QLatin1Char('A'))) >= 0 && m_collator.compare(newFirstChar, QChar(QLatin1Char('Z'))) <= 0) {
|
||||||
// WARNING! Symbols based on latin 'Z' like 'Z' with acute are treated wrong as non Latin and put in a new group.
|
// WARNING! Symbols based on latin 'Z' like 'Z' with acute are treated wrong as non Latin and put in a new group.
|
||||||
|
|
||||||
|
@ -2345,19 +2344,23 @@ QList<QPair<int, QVariant> > KFileItemModel::timeRoleGroups(const std::function<
|
||||||
const int daysDistance = fileDate.daysTo(currentDate);
|
const int daysDistance = fileDate.daysTo(currentDate);
|
||||||
|
|
||||||
QString newGroupValue;
|
QString newGroupValue;
|
||||||
if (currentDate.year() == fileDate.year() &&
|
if (currentDate.year() == fileDate.year() && currentDate.month() == fileDate.month()) {
|
||||||
currentDate.month() == fileDate.month()) {
|
|
||||||
|
|
||||||
switch (daysDistance / 7) {
|
switch (daysDistance / 7) {
|
||||||
case 0:
|
case 0:
|
||||||
switch (daysDistance) {
|
switch (daysDistance) {
|
||||||
case 0: newGroupValue = i18nc("@title:group Date", "Today"); break;
|
case 0:
|
||||||
case 1: newGroupValue = i18nc("@title:group Date", "Yesterday"); break;
|
newGroupValue = i18nc("@title:group Date", "Today");
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
newGroupValue = i18nc("@title:group Date", "Yesterday");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
newGroupValue = fileTime.toString(
|
newGroupValue = fileTime.toString(i18nc("@title:group Date: The week day name: dddd", "dddd"));
|
||||||
i18nc("@title:group Date: The week day name: dddd", "dddd"));
|
newGroupValue = i18nc(
|
||||||
newGroupValue = i18nc("Can be used to script translation of \"dddd\""
|
"Can be used to script translation of \"dddd\""
|
||||||
"with context @title:group Date", "%1", newGroupValue);
|
"with context @title:group Date",
|
||||||
|
"%1",
|
||||||
|
newGroupValue);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -2378,100 +2381,135 @@ QList<QPair<int, QVariant> > KFileItemModel::timeRoleGroups(const std::function<
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const QDate lastMonthDate = currentDate.addMonths(-1);
|
const QDate lastMonthDate = currentDate.addMonths(-1);
|
||||||
if (lastMonthDate.year() == fileDate.year() &&
|
if (lastMonthDate.year() == fileDate.year() && lastMonthDate.month() == fileDate.month()) {
|
||||||
lastMonthDate.month() == fileDate.month()) {
|
|
||||||
|
|
||||||
if (daysDistance == 1) {
|
if (daysDistance == 1) {
|
||||||
const KLocalizedString format = ki18nc("@title:group Date: "
|
const KLocalizedString format = ki18nc(
|
||||||
|
"@title:group Date: "
|
||||||
"MMMM is full month name in current locale, and yyyy is "
|
"MMMM is full month name in current locale, and yyyy is "
|
||||||
"full year number. You must keep the ' don't use any fancy \" or « or similar. The ' is not shown to the user, it's there to mark a part of the text that should not be formatted as a date", "'Yesterday' (MMMM, yyyy)");
|
"full year number. You must keep the ' don't use any fancy \" or « or similar. The ' is not shown to the user, it's there to mark a "
|
||||||
|
"part of the text that should not be formatted as a date",
|
||||||
|
"'Yesterday' (MMMM, yyyy)");
|
||||||
const QString translatedFormat = format.toString();
|
const QString translatedFormat = format.toString();
|
||||||
if (translatedFormat.count(QLatin1Char('\'')) == 2) {
|
if (translatedFormat.count(QLatin1Char('\'')) == 2) {
|
||||||
newGroupValue = fileTime.toString(translatedFormat);
|
newGroupValue = fileTime.toString(translatedFormat);
|
||||||
newGroupValue = i18nc("Can be used to script translation of "
|
newGroupValue = i18nc(
|
||||||
|
"Can be used to script translation of "
|
||||||
"\"'Yesterday' (MMMM, yyyy)\" with context @title:group Date",
|
"\"'Yesterday' (MMMM, yyyy)\" with context @title:group Date",
|
||||||
"%1", newGroupValue);
|
"%1",
|
||||||
|
newGroupValue);
|
||||||
} else {
|
} else {
|
||||||
qCWarning(DolphinDebug).nospace() << "A wrong translation was found: " << translatedFormat << ". Please file a bug report at bugs.kde.org";
|
qCWarning(DolphinDebug).nospace()
|
||||||
|
<< "A wrong translation was found: " << translatedFormat << ". Please file a bug report at bugs.kde.org";
|
||||||
const QString untranslatedFormat = format.toString({QLatin1String("en_US")});
|
const QString untranslatedFormat = format.toString({QLatin1String("en_US")});
|
||||||
newGroupValue = fileTime.toString(untranslatedFormat);
|
newGroupValue = fileTime.toString(untranslatedFormat);
|
||||||
}
|
}
|
||||||
} else if (daysDistance <= 7) {
|
} else if (daysDistance <= 7) {
|
||||||
newGroupValue = fileTime.toString(i18nc("@title:group Date: "
|
newGroupValue =
|
||||||
|
fileTime.toString(i18nc("@title:group Date: "
|
||||||
"The week day name: dddd, MMMM is full month name "
|
"The week day name: dddd, MMMM is full month name "
|
||||||
"in current locale, and yyyy is full year number.",
|
"in current locale, and yyyy is full year number.",
|
||||||
"dddd (MMMM, yyyy)"));
|
"dddd (MMMM, yyyy)"));
|
||||||
newGroupValue = i18nc("Can be used to script translation of "
|
newGroupValue = i18nc(
|
||||||
|
"Can be used to script translation of "
|
||||||
"\"dddd (MMMM, yyyy)\" with context @title:group Date",
|
"\"dddd (MMMM, yyyy)\" with context @title:group Date",
|
||||||
"%1", newGroupValue);
|
"%1",
|
||||||
|
newGroupValue);
|
||||||
} else if (daysDistance <= 7 * 2) {
|
} else if (daysDistance <= 7 * 2) {
|
||||||
const KLocalizedString format = ki18nc("@title:group Date: "
|
const KLocalizedString format = ki18nc(
|
||||||
|
"@title:group Date: "
|
||||||
"MMMM is full month name in current locale, and yyyy is "
|
"MMMM is full month name in current locale, and yyyy is "
|
||||||
"full year number. You must keep the ' don't use any fancy \" or « or similar. The ' is not shown to the user, it's there to mark a part of the text that should not be formatted as a date", "'One Week Ago' (MMMM, yyyy)");
|
"full year number. You must keep the ' don't use any fancy \" or « or similar. The ' is not shown to the user, it's there to mark a "
|
||||||
|
"part of the text that should not be formatted as a date",
|
||||||
|
"'One Week Ago' (MMMM, yyyy)");
|
||||||
const QString translatedFormat = format.toString();
|
const QString translatedFormat = format.toString();
|
||||||
if (translatedFormat.count(QLatin1Char('\'')) == 2) {
|
if (translatedFormat.count(QLatin1Char('\'')) == 2) {
|
||||||
newGroupValue = fileTime.toString(translatedFormat);
|
newGroupValue = fileTime.toString(translatedFormat);
|
||||||
newGroupValue = i18nc("Can be used to script translation of "
|
newGroupValue = i18nc(
|
||||||
|
"Can be used to script translation of "
|
||||||
"\"'One Week Ago' (MMMM, yyyy)\" with context @title:group Date",
|
"\"'One Week Ago' (MMMM, yyyy)\" with context @title:group Date",
|
||||||
"%1", newGroupValue);
|
"%1",
|
||||||
|
newGroupValue);
|
||||||
} else {
|
} else {
|
||||||
qCWarning(DolphinDebug).nospace() << "A wrong translation was found: " << translatedFormat << ". Please file a bug report at bugs.kde.org";
|
qCWarning(DolphinDebug).nospace()
|
||||||
|
<< "A wrong translation was found: " << translatedFormat << ". Please file a bug report at bugs.kde.org";
|
||||||
const QString untranslatedFormat = format.toString({QLatin1String("en_US")});
|
const QString untranslatedFormat = format.toString({QLatin1String("en_US")});
|
||||||
newGroupValue = fileTime.toString(untranslatedFormat);
|
newGroupValue = fileTime.toString(untranslatedFormat);
|
||||||
}
|
}
|
||||||
} else if (daysDistance <= 7 * 3) {
|
} else if (daysDistance <= 7 * 3) {
|
||||||
const KLocalizedString format = ki18nc("@title:group Date: "
|
const KLocalizedString format = ki18nc(
|
||||||
|
"@title:group Date: "
|
||||||
"MMMM is full month name in current locale, and yyyy is "
|
"MMMM is full month name in current locale, and yyyy is "
|
||||||
"full year number. You must keep the ' don't use any fancy \" or « or similar. The ' is not shown to the user, it's there to mark a part of the text that should not be formatted as a date", "'Two Weeks Ago' (MMMM, yyyy)");
|
"full year number. You must keep the ' don't use any fancy \" or « or similar. The ' is not shown to the user, it's there to mark a "
|
||||||
|
"part of the text that should not be formatted as a date",
|
||||||
|
"'Two Weeks Ago' (MMMM, yyyy)");
|
||||||
const QString translatedFormat = format.toString();
|
const QString translatedFormat = format.toString();
|
||||||
if (translatedFormat.count(QLatin1Char('\'')) == 2) {
|
if (translatedFormat.count(QLatin1Char('\'')) == 2) {
|
||||||
newGroupValue = fileTime.toString(translatedFormat);
|
newGroupValue = fileTime.toString(translatedFormat);
|
||||||
newGroupValue = i18nc("Can be used to script translation of "
|
newGroupValue = i18nc(
|
||||||
|
"Can be used to script translation of "
|
||||||
"\"'Two Weeks Ago' (MMMM, yyyy)\" with context @title:group Date",
|
"\"'Two Weeks Ago' (MMMM, yyyy)\" with context @title:group Date",
|
||||||
"%1", newGroupValue);
|
"%1",
|
||||||
|
newGroupValue);
|
||||||
} else {
|
} else {
|
||||||
qCWarning(DolphinDebug).nospace() << "A wrong translation was found: " << translatedFormat << ". Please file a bug report at bugs.kde.org";
|
qCWarning(DolphinDebug).nospace()
|
||||||
|
<< "A wrong translation was found: " << translatedFormat << ". Please file a bug report at bugs.kde.org";
|
||||||
const QString untranslatedFormat = format.toString({QLatin1String("en_US")});
|
const QString untranslatedFormat = format.toString({QLatin1String("en_US")});
|
||||||
newGroupValue = fileTime.toString(untranslatedFormat);
|
newGroupValue = fileTime.toString(untranslatedFormat);
|
||||||
}
|
}
|
||||||
} else if (daysDistance <= 7 * 4) {
|
} else if (daysDistance <= 7 * 4) {
|
||||||
const KLocalizedString format = ki18nc("@title:group Date: "
|
const KLocalizedString format = ki18nc(
|
||||||
|
"@title:group Date: "
|
||||||
"MMMM is full month name in current locale, and yyyy is "
|
"MMMM is full month name in current locale, and yyyy is "
|
||||||
"full year number. You must keep the ' don't use any fancy \" or « or similar. The ' is not shown to the user, it's there to mark a part of the text that should not be formatted as a date", "'Three Weeks Ago' (MMMM, yyyy)");
|
"full year number. You must keep the ' don't use any fancy \" or « or similar. The ' is not shown to the user, it's there to mark a "
|
||||||
|
"part of the text that should not be formatted as a date",
|
||||||
|
"'Three Weeks Ago' (MMMM, yyyy)");
|
||||||
const QString translatedFormat = format.toString();
|
const QString translatedFormat = format.toString();
|
||||||
if (translatedFormat.count(QLatin1Char('\'')) == 2) {
|
if (translatedFormat.count(QLatin1Char('\'')) == 2) {
|
||||||
newGroupValue = fileTime.toString(translatedFormat);
|
newGroupValue = fileTime.toString(translatedFormat);
|
||||||
newGroupValue = i18nc("Can be used to script translation of "
|
newGroupValue = i18nc(
|
||||||
|
"Can be used to script translation of "
|
||||||
"\"'Three Weeks Ago' (MMMM, yyyy)\" with context @title:group Date",
|
"\"'Three Weeks Ago' (MMMM, yyyy)\" with context @title:group Date",
|
||||||
"%1", newGroupValue);
|
"%1",
|
||||||
|
newGroupValue);
|
||||||
} else {
|
} else {
|
||||||
qCWarning(DolphinDebug).nospace() << "A wrong translation was found: " << translatedFormat << ". Please file a bug report at bugs.kde.org";
|
qCWarning(DolphinDebug).nospace()
|
||||||
|
<< "A wrong translation was found: " << translatedFormat << ". Please file a bug report at bugs.kde.org";
|
||||||
const QString untranslatedFormat = format.toString({QLatin1String("en_US")});
|
const QString untranslatedFormat = format.toString({QLatin1String("en_US")});
|
||||||
newGroupValue = fileTime.toString(untranslatedFormat);
|
newGroupValue = fileTime.toString(untranslatedFormat);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const KLocalizedString format = ki18nc("@title:group Date: "
|
const KLocalizedString format = ki18nc(
|
||||||
|
"@title:group Date: "
|
||||||
"MMMM is full month name in current locale, and yyyy is "
|
"MMMM is full month name in current locale, and yyyy is "
|
||||||
"full year number. You must keep the ' don't use any fancy \" or « or similar. The ' is not shown to the user, it's there to mark a part of the text that should not be formatted as a date", "'Earlier on' MMMM, yyyy");
|
"full year number. You must keep the ' don't use any fancy \" or « or similar. The ' is not shown to the user, it's there to mark a "
|
||||||
|
"part of the text that should not be formatted as a date",
|
||||||
|
"'Earlier on' MMMM, yyyy");
|
||||||
const QString translatedFormat = format.toString();
|
const QString translatedFormat = format.toString();
|
||||||
if (translatedFormat.count(QLatin1Char('\'')) == 2) {
|
if (translatedFormat.count(QLatin1Char('\'')) == 2) {
|
||||||
newGroupValue = fileTime.toString(translatedFormat);
|
newGroupValue = fileTime.toString(translatedFormat);
|
||||||
newGroupValue = i18nc("Can be used to script translation of "
|
newGroupValue = i18nc(
|
||||||
|
"Can be used to script translation of "
|
||||||
"\"'Earlier on' MMMM, yyyy\" with context @title:group Date",
|
"\"'Earlier on' MMMM, yyyy\" with context @title:group Date",
|
||||||
"%1", newGroupValue);
|
"%1",
|
||||||
|
newGroupValue);
|
||||||
} else {
|
} else {
|
||||||
qCWarning(DolphinDebug).nospace() << "A wrong translation was found: " << translatedFormat << ". Please file a bug report at bugs.kde.org";
|
qCWarning(DolphinDebug).nospace()
|
||||||
|
<< "A wrong translation was found: " << translatedFormat << ". Please file a bug report at bugs.kde.org";
|
||||||
const QString untranslatedFormat = format.toString({QLatin1String("en_US")});
|
const QString untranslatedFormat = format.toString({QLatin1String("en_US")});
|
||||||
newGroupValue = fileTime.toString(untranslatedFormat);
|
newGroupValue = fileTime.toString(untranslatedFormat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newGroupValue = fileTime.toString(i18nc("@title:group "
|
newGroupValue =
|
||||||
|
fileTime.toString(i18nc("@title:group "
|
||||||
"The month and year: MMMM is full month name in current locale, "
|
"The month and year: MMMM is full month name in current locale, "
|
||||||
"and yyyy is full year number", "MMMM, yyyy"));
|
"and yyyy is full year number",
|
||||||
newGroupValue = i18nc("Can be used to script translation of "
|
"MMMM, yyyy"));
|
||||||
|
newGroupValue = i18nc(
|
||||||
|
"Can be used to script translation of "
|
||||||
"\"MMMM, yyyy\" with context @title:group Date",
|
"\"MMMM, yyyy\" with context @title:group Date",
|
||||||
"%1", newGroupValue);
|
"%1",
|
||||||
|
newGroupValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2737,8 +2775,7 @@ bool KFileItemModel::isConsistent() const
|
||||||
|
|
||||||
// Check if the items are sorted correctly.
|
// Check if the items are sorted correctly.
|
||||||
if (i > 0 && !lessThan(m_itemData.at(i - 1), m_itemData.at(i), m_collator)) {
|
if (i > 0 && !lessThan(m_itemData.at(i - 1), m_itemData.at(i), m_collator)) {
|
||||||
qCWarning(DolphinDebug) << "The order of items" << i - 1 << "and" << i << "is wrong:"
|
qCWarning(DolphinDebug) << "The order of items" << i - 1 << "and" << i << "is wrong:" << fileItem(i - 1) << fileItem(i);
|
||||||
<< fileItem(i - 1) << fileItem(i);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2753,7 +2790,8 @@ bool KFileItemModel::isConsistent() const
|
||||||
|
|
||||||
const int parentIndex = index(parent->item);
|
const int parentIndex = index(parent->item);
|
||||||
if (parentIndex >= i) {
|
if (parentIndex >= i) {
|
||||||
qCWarning(DolphinDebug) << "Index" << parentIndex << "of parent" << parent->item << "is not smaller than index" << i << "of child" << data->item;
|
qCWarning(DolphinDebug) << "Index" << parentIndex << "of parent" << parent->item << "is not smaller than index" << i << "of child"
|
||||||
|
<< data->item;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,8 @@ class KDirLister;
|
||||||
|
|
||||||
class QTimer;
|
class QTimer;
|
||||||
|
|
||||||
namespace KIO {
|
namespace KIO
|
||||||
|
{
|
||||||
class Job;
|
class Job;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,8 +182,8 @@ public:
|
||||||
void setMimeTypeFilters(const QStringList &filters);
|
void setMimeTypeFilters(const QStringList &filters);
|
||||||
QStringList mimeTypeFilters() const;
|
QStringList mimeTypeFilters() const;
|
||||||
|
|
||||||
struct RoleInfo
|
struct RoleInfo {
|
||||||
{ QByteArray role;
|
QByteArray role;
|
||||||
QString translation;
|
QString translation;
|
||||||
QString group;
|
QString group;
|
||||||
bool requiresBaloo;
|
bool requiresBaloo;
|
||||||
|
@ -294,30 +295,63 @@ private Q_SLOTS:
|
||||||
private:
|
private:
|
||||||
enum RoleType {
|
enum RoleType {
|
||||||
// User visible roles:
|
// User visible roles:
|
||||||
NoRole, NameRole, SizeRole, ModificationTimeRole, CreationTimeRole, AccessTimeRole, PermissionsRole, OwnerRole,
|
NoRole,
|
||||||
GroupRole, TypeRole, ExtensionRole, DestinationRole, PathRole, DeletionTimeRole,
|
NameRole,
|
||||||
|
SizeRole,
|
||||||
|
ModificationTimeRole,
|
||||||
|
CreationTimeRole,
|
||||||
|
AccessTimeRole,
|
||||||
|
PermissionsRole,
|
||||||
|
OwnerRole,
|
||||||
|
GroupRole,
|
||||||
|
TypeRole,
|
||||||
|
ExtensionRole,
|
||||||
|
DestinationRole,
|
||||||
|
PathRole,
|
||||||
|
DeletionTimeRole,
|
||||||
// User visible roles available with Baloo:
|
// User visible roles available with Baloo:
|
||||||
CommentRole, TagsRole, RatingRole, DimensionsRole, WidthRole, HeightRole, ImageDateTimeRole, OrientationRole,
|
CommentRole,
|
||||||
PublisherRole, PageCountRole, WordCountRole, TitleRole, AuthorRole, LineCountRole, ArtistRole, GenreRole, AlbumRole, DurationRole, TrackRole, ReleaseYearRole,
|
TagsRole,
|
||||||
BitrateRole, OriginUrlRole, AspectRatioRole, FrameRateRole,
|
RatingRole,
|
||||||
|
DimensionsRole,
|
||||||
|
WidthRole,
|
||||||
|
HeightRole,
|
||||||
|
ImageDateTimeRole,
|
||||||
|
OrientationRole,
|
||||||
|
PublisherRole,
|
||||||
|
PageCountRole,
|
||||||
|
WordCountRole,
|
||||||
|
TitleRole,
|
||||||
|
AuthorRole,
|
||||||
|
LineCountRole,
|
||||||
|
ArtistRole,
|
||||||
|
GenreRole,
|
||||||
|
AlbumRole,
|
||||||
|
DurationRole,
|
||||||
|
TrackRole,
|
||||||
|
ReleaseYearRole,
|
||||||
|
BitrateRole,
|
||||||
|
OriginUrlRole,
|
||||||
|
AspectRatioRole,
|
||||||
|
FrameRateRole,
|
||||||
// Non-visible roles:
|
// Non-visible roles:
|
||||||
IsDirRole, IsLinkRole, IsHiddenRole, IsExpandedRole, IsExpandableRole, ExpandedParentsCountRole,
|
IsDirRole,
|
||||||
|
IsLinkRole,
|
||||||
|
IsHiddenRole,
|
||||||
|
IsExpandedRole,
|
||||||
|
IsExpandableRole,
|
||||||
|
ExpandedParentsCountRole,
|
||||||
// Mandatory last entry:
|
// Mandatory last entry:
|
||||||
RolesCount
|
RolesCount
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ItemData
|
struct ItemData {
|
||||||
{
|
|
||||||
KFileItem item;
|
KFileItem item;
|
||||||
QHash<QByteArray, QVariant> values;
|
QHash<QByteArray, QVariant> values;
|
||||||
ItemData *parent;
|
ItemData *parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum RemoveItemsBehavior {
|
enum RemoveItemsBehavior { KeepItemData, DeleteItemData, DeleteItemDataIfUnfiltered };
|
||||||
KeepItemData,
|
|
||||||
DeleteItemData,
|
|
||||||
DeleteItemDataIfUnfiltered
|
|
||||||
};
|
|
||||||
|
|
||||||
void insertItems(QList<ItemData *> &items);
|
void insertItems(QList<ItemData *> &items);
|
||||||
void removeItems(const KItemRangeList &itemRanges, RemoveItemsBehavior behavior);
|
void removeItems(const KItemRangeList &itemRanges, RemoveItemsBehavior behavior);
|
||||||
|
@ -442,8 +476,7 @@ private:
|
||||||
* Maps the QByteArray-roles to RoleTypes and provides translation- and
|
* Maps the QByteArray-roles to RoleTypes and provides translation- and
|
||||||
* group-contexts.
|
* group-contexts.
|
||||||
*/
|
*/
|
||||||
struct RoleInfoMap
|
struct RoleInfoMap {
|
||||||
{
|
|
||||||
const char *const role;
|
const char *const role;
|
||||||
const RoleType roleType;
|
const RoleType roleType;
|
||||||
const KLazyLocalizedString roleTranslation;
|
const KLazyLocalizedString roleTranslation;
|
||||||
|
@ -531,19 +564,9 @@ private:
|
||||||
|
|
||||||
inline bool KFileItemModel::isRoleValueNatural(RoleType roleType)
|
inline bool KFileItemModel::isRoleValueNatural(RoleType roleType)
|
||||||
{
|
{
|
||||||
return (roleType == TypeRole ||
|
return (roleType == TypeRole || roleType == ExtensionRole || roleType == TagsRole || roleType == CommentRole || roleType == TitleRole
|
||||||
roleType == ExtensionRole ||
|
|| roleType == ArtistRole || roleType == GenreRole || roleType == AlbumRole || roleType == PathRole || roleType == DestinationRole
|
||||||
roleType == TagsRole ||
|
|| roleType == OriginUrlRole || roleType == OwnerRole || roleType == GroupRole);
|
||||||
roleType == CommentRole ||
|
|
||||||
roleType == TitleRole ||
|
|
||||||
roleType == ArtistRole ||
|
|
||||||
roleType == GenreRole ||
|
|
||||||
roleType == AlbumRole ||
|
|
||||||
roleType == PathRole ||
|
|
||||||
roleType == DestinationRole ||
|
|
||||||
roleType == OriginUrlRole ||
|
|
||||||
roleType == OwnerRole ||
|
|
||||||
roleType == GroupRole);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool KFileItemModel::nameLessThan(const ItemData *a, const ItemData *b)
|
inline bool KFileItemModel::nameLessThan(const ItemData *a, const ItemData *b)
|
||||||
|
@ -561,5 +584,3 @@ inline bool KFileItemModel::isChildItem(int index) const
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,8 @@ using namespace std::chrono_literals;
|
||||||
|
|
||||||
// #define KFILEITEMMODELROLESUPDATER_DEBUG
|
// #define KFILEITEMMODELROLESUPDATER_DEBUG
|
||||||
|
|
||||||
namespace {
|
namespace
|
||||||
|
{
|
||||||
// Maximum time in ms that the KFileItemModelRolesUpdater
|
// Maximum time in ms that the KFileItemModelRolesUpdater
|
||||||
// may perform a blocking operation
|
// may perform a blocking operation
|
||||||
const int MaxBlockTimeout = 200;
|
const int MaxBlockTimeout = 200;
|
||||||
|
@ -52,38 +53,38 @@ namespace {
|
||||||
const int ReadAheadPages = 5;
|
const int ReadAheadPages = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel* model, QObject* parent) :
|
KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel *model, QObject *parent)
|
||||||
QObject(parent),
|
: QObject(parent)
|
||||||
m_state(Idle),
|
, m_state(Idle)
|
||||||
m_previewChangedDuringPausing(false),
|
, m_previewChangedDuringPausing(false)
|
||||||
m_iconSizeChangedDuringPausing(false),
|
, m_iconSizeChangedDuringPausing(false)
|
||||||
m_rolesChangedDuringPausing(false),
|
, m_rolesChangedDuringPausing(false)
|
||||||
m_previewShown(false),
|
, m_previewShown(false)
|
||||||
m_enlargeSmallPreviews(true),
|
, m_enlargeSmallPreviews(true)
|
||||||
m_clearPreviews(false),
|
, m_clearPreviews(false)
|
||||||
m_finishedItems(),
|
, m_finishedItems()
|
||||||
m_model(model),
|
, m_model(model)
|
||||||
m_iconSize(),
|
, m_iconSize()
|
||||||
m_firstVisibleIndex(0),
|
, m_firstVisibleIndex(0)
|
||||||
m_lastVisibleIndex(-1),
|
, m_lastVisibleIndex(-1)
|
||||||
m_maximumVisibleItems(50),
|
, m_maximumVisibleItems(50)
|
||||||
m_roles(),
|
, m_roles()
|
||||||
m_resolvableRoles(),
|
, m_resolvableRoles()
|
||||||
m_enabledPlugins(),
|
, m_enabledPlugins()
|
||||||
m_localFileSizePreviewLimit(0),
|
, m_localFileSizePreviewLimit(0)
|
||||||
m_scanDirectories(true),
|
, m_scanDirectories(true)
|
||||||
m_pendingSortRoleItems(),
|
, m_pendingSortRoleItems()
|
||||||
m_pendingIndexes(),
|
, m_pendingIndexes()
|
||||||
m_pendingPreviewItems(),
|
, m_pendingPreviewItems()
|
||||||
m_previewJob(),
|
, m_previewJob()
|
||||||
m_hoverSequenceItem(),
|
, m_hoverSequenceItem()
|
||||||
m_hoverSequenceIndex(0),
|
, m_hoverSequenceIndex(0)
|
||||||
m_hoverSequencePreviewJob(nullptr),
|
, m_hoverSequencePreviewJob(nullptr)
|
||||||
m_hoverSequenceNumSuccessiveFailures(0),
|
, m_hoverSequenceNumSuccessiveFailures(0)
|
||||||
m_recentlyChangedItemsTimer(nullptr),
|
, m_recentlyChangedItemsTimer(nullptr)
|
||||||
m_recentlyChangedItems(),
|
, m_recentlyChangedItems()
|
||||||
m_changedItems(),
|
, m_changedItems()
|
||||||
m_directoryContentsCounter(nullptr)
|
, m_directoryContentsCounter(nullptr)
|
||||||
#if HAVE_BALOO
|
#if HAVE_BALOO
|
||||||
, m_balooFileMonitor(nullptr)
|
, m_balooFileMonitor(nullptr)
|
||||||
#endif
|
#endif
|
||||||
|
@ -94,16 +95,11 @@ KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel* model, QO
|
||||||
m_enabledPlugins = globalConfig.readEntry("Plugins", KIO::PreviewJob::defaultPlugins());
|
m_enabledPlugins = globalConfig.readEntry("Plugins", KIO::PreviewJob::defaultPlugins());
|
||||||
m_localFileSizePreviewLimit = static_cast<qulonglong>(globalConfig.readEntry("MaximumSize", 0));
|
m_localFileSizePreviewLimit = static_cast<qulonglong>(globalConfig.readEntry("MaximumSize", 0));
|
||||||
|
|
||||||
connect(m_model, &KFileItemModel::itemsInserted,
|
connect(m_model, &KFileItemModel::itemsInserted, this, &KFileItemModelRolesUpdater::slotItemsInserted);
|
||||||
this, &KFileItemModelRolesUpdater::slotItemsInserted);
|
connect(m_model, &KFileItemModel::itemsRemoved, this, &KFileItemModelRolesUpdater::slotItemsRemoved);
|
||||||
connect(m_model, &KFileItemModel::itemsRemoved,
|
connect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
this, &KFileItemModelRolesUpdater::slotItemsRemoved);
|
connect(m_model, &KFileItemModel::itemsMoved, this, &KFileItemModelRolesUpdater::slotItemsMoved);
|
||||||
connect(m_model, &KFileItemModel::itemsChanged,
|
connect(m_model, &KFileItemModel::sortRoleChanged, this, &KFileItemModelRolesUpdater::slotSortRoleChanged);
|
||||||
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
|
||||||
connect(m_model, &KFileItemModel::itemsMoved,
|
|
||||||
this, &KFileItemModelRolesUpdater::slotItemsMoved);
|
|
||||||
connect(m_model, &KFileItemModel::sortRoleChanged,
|
|
||||||
this, &KFileItemModelRolesUpdater::slotSortRoleChanged);
|
|
||||||
|
|
||||||
// Use a timer to prevent that each call of slotItemsChanged() results in a synchronous
|
// Use a timer to prevent that each call of slotItemsChanged() results in a synchronous
|
||||||
// resolving of the roles. Postpone the resolving until no update has been done for 100 ms.
|
// resolving of the roles. Postpone the resolving until no update has been done for 100 ms.
|
||||||
|
@ -120,8 +116,7 @@ KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel* model, QO
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_directoryContentsCounter = new KDirectoryContentsCounter(m_model, this);
|
m_directoryContentsCounter = new KDirectoryContentsCounter(m_model, this);
|
||||||
connect(m_directoryContentsCounter, &KDirectoryContentsCounter::result,
|
connect(m_directoryContentsCounter, &KDirectoryContentsCounter::result, this, &KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived);
|
||||||
this, &KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived);
|
|
||||||
|
|
||||||
const auto plugins = KPluginMetaData::findPlugins(QStringLiteral("kf" QT_STRINGIFY(QT_VERSION_MAJOR)) + QStringLiteral("/overlayicon"));
|
const auto plugins = KPluginMetaData::findPlugins(QStringLiteral("kf" QT_STRINGIFY(QT_VERSION_MAJOR)) + QStringLiteral("/overlayicon"));
|
||||||
for (const KPluginMetaData &data : plugins) {
|
for (const KPluginMetaData &data : plugins) {
|
||||||
|
@ -241,8 +236,7 @@ void KFileItemModelRolesUpdater::setPaused(bool paused)
|
||||||
m_state = Paused;
|
m_state = Paused;
|
||||||
killPreviewJob();
|
killPreviewJob();
|
||||||
} else {
|
} else {
|
||||||
const bool updatePreviews = (m_iconSizeChangedDuringPausing && m_previewShown) ||
|
const bool updatePreviews = (m_iconSizeChangedDuringPausing && m_previewShown) || m_previewChangedDuringPausing;
|
||||||
m_previewChangedDuringPausing;
|
|
||||||
const bool resolveAll = updatePreviews || m_rolesChangedDuringPausing;
|
const bool resolveAll = updatePreviews || m_rolesChangedDuringPausing;
|
||||||
if (resolveAll) {
|
if (resolveAll) {
|
||||||
m_finishedItems.clear();
|
m_finishedItems.clear();
|
||||||
|
@ -286,8 +280,7 @@ void KFileItemModelRolesUpdater::setRoles(const QSet<QByteArray>& roles)
|
||||||
|
|
||||||
if (hasBalooRole && m_balooConfig.fileIndexingEnabled() && !m_balooFileMonitor) {
|
if (hasBalooRole && m_balooConfig.fileIndexingEnabled() && !m_balooFileMonitor) {
|
||||||
m_balooFileMonitor = new Baloo::FileMonitor(this);
|
m_balooFileMonitor = new Baloo::FileMonitor(this);
|
||||||
connect(m_balooFileMonitor, &Baloo::FileMonitor::fileMetaDataChanged,
|
connect(m_balooFileMonitor, &Baloo::FileMonitor::fileMetaDataChanged, this, &KFileItemModelRolesUpdater::applyChangedBalooRoles);
|
||||||
this, &KFileItemModelRolesUpdater::applyChangedBalooRoles);
|
|
||||||
} else if (!hasBalooRole && m_balooFileMonitor) {
|
} else if (!hasBalooRole && m_balooFileMonitor) {
|
||||||
delete m_balooFileMonitor;
|
delete m_balooFileMonitor;
|
||||||
m_balooFileMonitor = nullptr;
|
m_balooFileMonitor = nullptr;
|
||||||
|
@ -465,8 +458,7 @@ void KFileItemModelRolesUpdater::slotItemsMoved(KItemRange itemRange, const QLis
|
||||||
startUpdating();
|
startUpdating();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KFileItemModelRolesUpdater::slotItemsChanged(const KItemRangeList& itemRanges,
|
void KFileItemModelRolesUpdater::slotItemsChanged(const KItemRangeList &itemRanges, const QSet<QByteArray> &roles)
|
||||||
const QSet<QByteArray>& roles)
|
|
||||||
{
|
{
|
||||||
Q_UNUSED(roles)
|
Q_UNUSED(roles)
|
||||||
|
|
||||||
|
@ -493,8 +485,7 @@ void KFileItemModelRolesUpdater::slotItemsChanged(const KItemRangeList& itemRang
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KFileItemModelRolesUpdater::slotSortRoleChanged(const QByteArray& current,
|
void KFileItemModelRolesUpdater::slotSortRoleChanged(const QByteArray ¤t, const QByteArray &previous)
|
||||||
const QByteArray& previous)
|
|
||||||
{
|
{
|
||||||
Q_UNUSED(current)
|
Q_UNUSED(current)
|
||||||
Q_UNUSED(previous)
|
Q_UNUSED(previous)
|
||||||
|
@ -567,11 +558,9 @@ void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem& item, const QPi
|
||||||
|
|
||||||
data.insert("iconPixmap", scaledPixmap);
|
data.insert("iconPixmap", scaledPixmap);
|
||||||
|
|
||||||
disconnect(m_model, &KFileItemModel::itemsChanged,
|
disconnect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
|
||||||
m_model->setData(index, data);
|
m_model->setData(index, data);
|
||||||
connect(m_model, &KFileItemModel::itemsChanged,
|
connect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
|
||||||
|
|
||||||
m_finishedItems.insert(item);
|
m_finishedItems.insert(item);
|
||||||
}
|
}
|
||||||
|
@ -589,11 +578,9 @@ void KFileItemModelRolesUpdater::slotPreviewFailed(const KFileItem& item)
|
||||||
QHash<QByteArray, QVariant> data;
|
QHash<QByteArray, QVariant> data;
|
||||||
data.insert("iconPixmap", QPixmap());
|
data.insert("iconPixmap", QPixmap());
|
||||||
|
|
||||||
disconnect(m_model, &KFileItemModel::itemsChanged,
|
disconnect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
|
||||||
m_model->setData(index, data);
|
m_model->setData(index, data);
|
||||||
connect(m_model, &KFileItemModel::itemsChanged,
|
connect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
|
||||||
|
|
||||||
applyResolvedRoles(index, ResolveAll);
|
applyResolvedRoles(index, ResolveAll);
|
||||||
m_finishedItems.insert(item);
|
m_finishedItems.insert(item);
|
||||||
|
@ -653,8 +640,7 @@ void KFileItemModelRolesUpdater::slotHoverSequenceGotPreview(const KFileItem& it
|
||||||
|
|
||||||
m_model->setData(index, data);
|
m_model->setData(index, data);
|
||||||
|
|
||||||
const auto loadedIt = std::find(m_hoverSequenceLoadedItems.begin(),
|
const auto loadedIt = std::find(m_hoverSequenceLoadedItems.begin(), m_hoverSequenceLoadedItems.end(), item);
|
||||||
m_hoverSequenceLoadedItems.end(), item);
|
|
||||||
if (loadedIt == m_hoverSequenceLoadedItems.end()) {
|
if (loadedIt == m_hoverSequenceLoadedItems.end()) {
|
||||||
m_hoverSequenceLoadedItems.push_back(item);
|
m_hoverSequenceLoadedItems.push_back(item);
|
||||||
trimHoverSequenceLoadedItems();
|
trimHoverSequenceLoadedItems();
|
||||||
|
@ -676,11 +662,8 @@ void KFileItemModelRolesUpdater::slotHoverSequencePreviewFailed(const KFileItem&
|
||||||
QHash<QByteArray, QVariant> data = m_model->data(index);
|
QHash<QByteArray, QVariant> data = m_model->data(index);
|
||||||
QVector<QPixmap> pixmaps = data["hoverSequencePixmaps"].value<QVector<QPixmap>>();
|
QVector<QPixmap> pixmaps = data["hoverSequencePixmaps"].value<QVector<QPixmap>>();
|
||||||
|
|
||||||
qCDebug(DolphinDebug).nospace()
|
qCDebug(DolphinDebug).nospace() << "Failed to generate hover sequence preview #" << pixmaps.size() << " for file " << item.url().toString() << " (attempt "
|
||||||
<< "Failed to generate hover sequence preview #" << pixmaps.size()
|
<< (m_hoverSequenceNumSuccessiveFailures + 1) << "/" << (numRetries + 1) << ")";
|
||||||
<< " for file " << item.url().toString()
|
|
||||||
<< " (attempt " << (m_hoverSequenceNumSuccessiveFailures+1)
|
|
||||||
<< "/" << (numRetries+1) << ")";
|
|
||||||
|
|
||||||
if (m_hoverSequenceNumSuccessiveFailures >= numRetries) {
|
if (m_hoverSequenceNumSuccessiveFailures >= numRetries) {
|
||||||
// Give up and simply duplicate the previous sequence image (if any)
|
// Give up and simply duplicate the previous sequence image (if any)
|
||||||
|
@ -755,11 +738,9 @@ void KFileItemModelRolesUpdater::resolveNextSortRole()
|
||||||
m_state = Idle;
|
m_state = Idle;
|
||||||
|
|
||||||
// Prevent that we try to update the items twice.
|
// Prevent that we try to update the items twice.
|
||||||
disconnect(m_model, &KFileItemModel::itemsMoved,
|
disconnect(m_model, &KFileItemModel::itemsMoved, this, &KFileItemModelRolesUpdater::slotItemsMoved);
|
||||||
this, &KFileItemModelRolesUpdater::slotItemsMoved);
|
|
||||||
applySortProgressToModel();
|
applySortProgressToModel();
|
||||||
connect(m_model, &KFileItemModel::itemsMoved,
|
connect(m_model, &KFileItemModel::itemsMoved, this, &KFileItemModelRolesUpdater::slotItemsMoved);
|
||||||
this, &KFileItemModelRolesUpdater::slotItemsMoved);
|
|
||||||
startUpdating();
|
startUpdating();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -796,18 +777,13 @@ void KFileItemModelRolesUpdater::resolveNextPendingRoles()
|
||||||
data.insert("iconPixmap", QPixmap());
|
data.insert("iconPixmap", QPixmap());
|
||||||
data.insert("hoverSequencePixmaps", QVariant::fromValue(QVector<QPixmap>()));
|
data.insert("hoverSequencePixmaps", QVariant::fromValue(QVector<QPixmap>()));
|
||||||
|
|
||||||
disconnect(m_model, &KFileItemModel::itemsChanged,
|
disconnect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
|
||||||
for (int index = 0; index <= m_model->count(); ++index) {
|
for (int index = 0; index <= m_model->count(); ++index) {
|
||||||
if (m_model->data(index).contains("iconPixmap") ||
|
if (m_model->data(index).contains("iconPixmap") || m_model->data(index).contains("hoverSequencePixmaps")) {
|
||||||
m_model->data(index).contains("hoverSequencePixmaps"))
|
|
||||||
{
|
|
||||||
m_model->setData(index, data);
|
m_model->setData(index, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
connect(m_model, &KFileItemModel::itemsChanged,
|
connect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
m_clearPreviews = false;
|
m_clearPreviews = false;
|
||||||
}
|
}
|
||||||
|
@ -864,12 +840,10 @@ void KFileItemModelRolesUpdater::applyChangedBalooRolesForItem(const KFileItem &
|
||||||
data.insert(it.key(), it.value());
|
data.insert(it.key(), it.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect(m_model, &KFileItemModel::itemsChanged,
|
disconnect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
|
||||||
const int index = m_model->index(item);
|
const int index = m_model->index(item);
|
||||||
m_model->setData(index, data);
|
m_model->setData(index, data);
|
||||||
connect(m_model, &KFileItemModel::itemsChanged,
|
connect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
|
||||||
#else
|
#else
|
||||||
#ifndef Q_CC_MSVC
|
#ifndef Q_CC_MSVC
|
||||||
Q_UNUSED(item)
|
Q_UNUSED(item)
|
||||||
|
@ -895,11 +869,9 @@ void KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived(const QStrin
|
||||||
data.insert("isExpandable", count > 0);
|
data.insert("isExpandable", count > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect(m_model, &KFileItemModel::itemsChanged,
|
disconnect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
|
||||||
m_model->setData(index, data);
|
m_model->setData(index, data);
|
||||||
connect(m_model, &KFileItemModel::itemsChanged,
|
connect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -995,8 +967,7 @@ void KFileItemModelRolesUpdater::startPreviewJob()
|
||||||
// by PreviewJob if a smaller size is requested. For images KFileItemModelRolesUpdater must
|
// by PreviewJob if a smaller size is requested. For images KFileItemModelRolesUpdater must
|
||||||
// do a downscaling anyhow because of the frame, so in this case only the provided
|
// do a downscaling anyhow because of the frame, so in this case only the provided
|
||||||
// cache sizes are requested.
|
// cache sizes are requested.
|
||||||
const QSize cacheSize = (m_iconSize.width() > 128) || (m_iconSize.height() > 128)
|
const QSize cacheSize = (m_iconSize.width() > 128) || (m_iconSize.height() > 128) ? QSize(256, 256) : QSize(128, 128);
|
||||||
? QSize(256, 256) : QSize(128, 128);
|
|
||||||
|
|
||||||
// KIO::filePreview() will request the MIME-type of all passed items, which (in the
|
// KIO::filePreview() will request the MIME-type of all passed items, which (in the
|
||||||
// worst case) might block the application for several seconds. To prevent such
|
// worst case) might block the application for several seconds. To prevent such
|
||||||
|
@ -1033,12 +1004,9 @@ void KFileItemModelRolesUpdater::startPreviewJob()
|
||||||
KJobWidgets::setWindow(job, qApp->activeWindow());
|
KJobWidgets::setWindow(job, qApp->activeWindow());
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(job, &KIO::PreviewJob::gotPreview,
|
connect(job, &KIO::PreviewJob::gotPreview, this, &KFileItemModelRolesUpdater::slotGotPreview);
|
||||||
this, &KFileItemModelRolesUpdater::slotGotPreview);
|
connect(job, &KIO::PreviewJob::failed, this, &KFileItemModelRolesUpdater::slotPreviewFailed);
|
||||||
connect(job, &KIO::PreviewJob::failed,
|
connect(job, &KIO::PreviewJob::finished, this, &KFileItemModelRolesUpdater::slotPreviewJobFinished);
|
||||||
this, &KFileItemModelRolesUpdater::slotPreviewFailed);
|
|
||||||
connect(job, &KIO::PreviewJob::finished,
|
|
||||||
this, &KFileItemModelRolesUpdater::slotPreviewJobFinished);
|
|
||||||
|
|
||||||
m_previewJob = job;
|
m_previewJob = job;
|
||||||
}
|
}
|
||||||
|
@ -1047,17 +1015,14 @@ QPixmap KFileItemModelRolesUpdater::transformPreviewPixmap(const QPixmap& pixmap
|
||||||
{
|
{
|
||||||
QPixmap scaledPixmap = pixmap;
|
QPixmap scaledPixmap = pixmap;
|
||||||
|
|
||||||
if (!pixmap.hasAlpha() && !pixmap.isNull()
|
if (!pixmap.hasAlpha() && !pixmap.isNull() && m_iconSize.width() > KIconLoader::SizeSmallMedium && m_iconSize.height() > KIconLoader::SizeSmallMedium) {
|
||||||
&& m_iconSize.width() > KIconLoader::SizeSmallMedium
|
|
||||||
&& m_iconSize.height() > KIconLoader::SizeSmallMedium) {
|
|
||||||
if (m_enlargeSmallPreviews) {
|
if (m_enlargeSmallPreviews) {
|
||||||
KPixmapModifier::applyFrame(scaledPixmap, m_iconSize);
|
KPixmapModifier::applyFrame(scaledPixmap, m_iconSize);
|
||||||
} else {
|
} else {
|
||||||
// Assure that small previews don't get enlarged. Instead they
|
// Assure that small previews don't get enlarged. Instead they
|
||||||
// should be shown centered within the frame.
|
// should be shown centered within the frame.
|
||||||
const QSize contentSize = KPixmapModifier::sizeInsideFrame(m_iconSize);
|
const QSize contentSize = KPixmapModifier::sizeInsideFrame(m_iconSize);
|
||||||
const bool enlargingRequired = scaledPixmap.width() < contentSize.width() &&
|
const bool enlargingRequired = scaledPixmap.width() < contentSize.width() && scaledPixmap.height() < contentSize.height();
|
||||||
scaledPixmap.height() < contentSize.height();
|
|
||||||
if (enlargingRequired) {
|
if (enlargingRequired) {
|
||||||
QSize frameSize = scaledPixmap.size() / scaledPixmap.devicePixelRatio();
|
QSize frameSize = scaledPixmap.size() / scaledPixmap.devicePixelRatio();
|
||||||
frameSize.scale(m_iconSize, Qt::KeepAspectRatio);
|
frameSize.scale(m_iconSize, Qt::KeepAspectRatio);
|
||||||
|
@ -1131,8 +1096,7 @@ void KFileItemModelRolesUpdater::loadNextHoverSequencePreview()
|
||||||
// by PreviewJob if a smaller size is requested. For images KFileItemModelRolesUpdater must
|
// by PreviewJob if a smaller size is requested. For images KFileItemModelRolesUpdater must
|
||||||
// do a downscaling anyhow because of the frame, so in this case only the provided
|
// do a downscaling anyhow because of the frame, so in this case only the provided
|
||||||
// cache sizes are requested.
|
// cache sizes are requested.
|
||||||
const QSize cacheSize = (m_iconSize.width() > 128) || (m_iconSize.height() > 128)
|
const QSize cacheSize = (m_iconSize.width() > 128) || (m_iconSize.height() > 128) ? QSize(256, 256) : QSize(128, 128);
|
||||||
? QSize(256, 256) : QSize(128, 128);
|
|
||||||
|
|
||||||
KIO::PreviewJob *job = new KIO::PreviewJob({m_hoverSequenceItem}, cacheSize, &m_enabledPlugins);
|
KIO::PreviewJob *job = new KIO::PreviewJob({m_hoverSequenceItem}, cacheSize, &m_enabledPlugins);
|
||||||
|
|
||||||
|
@ -1142,12 +1106,9 @@ void KFileItemModelRolesUpdater::loadNextHoverSequencePreview()
|
||||||
KJobWidgets::setWindow(job, qApp->activeWindow());
|
KJobWidgets::setWindow(job, qApp->activeWindow());
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(job, &KIO::PreviewJob::gotPreview,
|
connect(job, &KIO::PreviewJob::gotPreview, this, &KFileItemModelRolesUpdater::slotHoverSequenceGotPreview);
|
||||||
this, &KFileItemModelRolesUpdater::slotHoverSequenceGotPreview);
|
connect(job, &KIO::PreviewJob::failed, this, &KFileItemModelRolesUpdater::slotHoverSequencePreviewFailed);
|
||||||
connect(job, &KIO::PreviewJob::failed,
|
connect(job, &KIO::PreviewJob::finished, this, &KFileItemModelRolesUpdater::slotHoverSequencePreviewJobFinished);
|
||||||
this, &KFileItemModelRolesUpdater::slotHoverSequencePreviewFailed);
|
|
||||||
connect(job, &KIO::PreviewJob::finished,
|
|
||||||
this, &KFileItemModelRolesUpdater::slotHoverSequencePreviewJobFinished);
|
|
||||||
|
|
||||||
m_hoverSequencePreviewJob = job;
|
m_hoverSequencePreviewJob = job;
|
||||||
}
|
}
|
||||||
|
@ -1155,12 +1116,9 @@ void KFileItemModelRolesUpdater::loadNextHoverSequencePreview()
|
||||||
void KFileItemModelRolesUpdater::killHoverSequencePreviewJob()
|
void KFileItemModelRolesUpdater::killHoverSequencePreviewJob()
|
||||||
{
|
{
|
||||||
if (m_hoverSequencePreviewJob) {
|
if (m_hoverSequencePreviewJob) {
|
||||||
disconnect(m_hoverSequencePreviewJob, &KIO::PreviewJob::gotPreview,
|
disconnect(m_hoverSequencePreviewJob, &KIO::PreviewJob::gotPreview, this, &KFileItemModelRolesUpdater::slotHoverSequenceGotPreview);
|
||||||
this, &KFileItemModelRolesUpdater::slotHoverSequenceGotPreview);
|
disconnect(m_hoverSequencePreviewJob, &KIO::PreviewJob::failed, this, &KFileItemModelRolesUpdater::slotHoverSequencePreviewFailed);
|
||||||
disconnect(m_hoverSequencePreviewJob, &KIO::PreviewJob::failed,
|
disconnect(m_hoverSequencePreviewJob, &KIO::PreviewJob::finished, this, &KFileItemModelRolesUpdater::slotHoverSequencePreviewJobFinished);
|
||||||
this, &KFileItemModelRolesUpdater::slotHoverSequencePreviewFailed);
|
|
||||||
disconnect(m_hoverSequencePreviewJob, &KIO::PreviewJob::finished,
|
|
||||||
this, &KFileItemModelRolesUpdater::slotHoverSequencePreviewJobFinished);
|
|
||||||
m_hoverSequencePreviewJob->kill();
|
m_hoverSequencePreviewJob->kill();
|
||||||
m_hoverSequencePreviewJob = nullptr;
|
m_hoverSequencePreviewJob = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -1261,11 +1219,9 @@ void KFileItemModelRolesUpdater::applySortRole(int index)
|
||||||
data = rolesData(item);
|
data = rolesData(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect(m_model, &KFileItemModel::itemsChanged,
|
disconnect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
|
||||||
m_model->setData(index, data);
|
m_model->setData(index, data);
|
||||||
connect(m_model, &KFileItemModel::itemsChanged,
|
connect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KFileItemModelRolesUpdater::applySortProgressToModel()
|
void KFileItemModelRolesUpdater::applySortProgressToModel()
|
||||||
|
@ -1308,11 +1264,9 @@ bool KFileItemModelRolesUpdater::applyResolvedRoles(int index, ResolveHint hint)
|
||||||
data.insert("hoverSequencePixmaps", QVariant::fromValue(QVector<QPixmap>()));
|
data.insert("hoverSequencePixmaps", QVariant::fromValue(QVector<QPixmap>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect(m_model, &KFileItemModel::itemsChanged,
|
disconnect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
|
||||||
m_model->setData(index, data);
|
m_model->setData(index, data);
|
||||||
connect(m_model, &KFileItemModel::itemsChanged,
|
connect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1393,12 +1347,9 @@ void KFileItemModelRolesUpdater::updateAllPreviews()
|
||||||
void KFileItemModelRolesUpdater::killPreviewJob()
|
void KFileItemModelRolesUpdater::killPreviewJob()
|
||||||
{
|
{
|
||||||
if (m_previewJob) {
|
if (m_previewJob) {
|
||||||
disconnect(m_previewJob, &KIO::PreviewJob::gotPreview,
|
disconnect(m_previewJob, &KIO::PreviewJob::gotPreview, this, &KFileItemModelRolesUpdater::slotGotPreview);
|
||||||
this, &KFileItemModelRolesUpdater::slotGotPreview);
|
disconnect(m_previewJob, &KIO::PreviewJob::failed, this, &KFileItemModelRolesUpdater::slotPreviewFailed);
|
||||||
disconnect(m_previewJob, &KIO::PreviewJob::failed,
|
disconnect(m_previewJob, &KIO::PreviewJob::finished, this, &KFileItemModelRolesUpdater::slotPreviewJobFinished);
|
||||||
this, &KFileItemModelRolesUpdater::slotPreviewFailed);
|
|
||||||
disconnect(m_previewJob, &KIO::PreviewJob::finished,
|
|
||||||
this, &KFileItemModelRolesUpdater::slotPreviewJobFinished);
|
|
||||||
m_previewJob->kill();
|
m_previewJob->kill();
|
||||||
m_previewJob = nullptr;
|
m_previewJob = nullptr;
|
||||||
m_pendingPreviewItems.clear();
|
m_pendingPreviewItems.clear();
|
||||||
|
@ -1410,9 +1361,7 @@ QList<int> KFileItemModelRolesUpdater::indexesToResolve() const
|
||||||
const int count = m_model->count();
|
const int count = m_model->count();
|
||||||
|
|
||||||
QList<int> result;
|
QList<int> result;
|
||||||
result.reserve(qMin(count, (m_lastVisibleIndex - m_firstVisibleIndex + 1) +
|
result.reserve(qMin(count, (m_lastVisibleIndex - m_firstVisibleIndex + 1) + ResolveAllItemsLimit + (2 * m_maximumVisibleItems)));
|
||||||
ResolveAllItemsLimit +
|
|
||||||
(2 * m_maximumVisibleItems)));
|
|
||||||
|
|
||||||
// Add visible items.
|
// Add visible items.
|
||||||
// Resolve files first, their previews are quicker.
|
// Resolve files first, their previews are quicker.
|
||||||
|
@ -1492,4 +1441,3 @@ void KFileItemModelRolesUpdater::trimHoverSequenceLoadedItems()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
#include <KFileItem>
|
|
||||||
#include "config-dolphin.h"
|
#include "config-dolphin.h"
|
||||||
|
#include <KFileItem>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
@ -26,7 +26,8 @@ class QPixmap;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
class KOverlayIconPlugin;
|
class KOverlayIconPlugin;
|
||||||
|
|
||||||
namespace KIO {
|
namespace KIO
|
||||||
|
{
|
||||||
class PreviewJob;
|
class PreviewJob;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,10 +179,8 @@ private Q_SLOTS:
|
||||||
void slotItemsInserted(const KItemRangeList &itemRanges);
|
void slotItemsInserted(const KItemRangeList &itemRanges);
|
||||||
void slotItemsRemoved(const KItemRangeList &itemRanges);
|
void slotItemsRemoved(const KItemRangeList &itemRanges);
|
||||||
void slotItemsMoved(KItemRange itemRange, const QList<int> &movedToIndexes);
|
void slotItemsMoved(KItemRange itemRange, const QList<int> &movedToIndexes);
|
||||||
void slotItemsChanged(const KItemRangeList& itemRanges,
|
void slotItemsChanged(const KItemRangeList &itemRanges, const QSet<QByteArray> &roles);
|
||||||
const QSet<QByteArray>& roles);
|
void slotSortRoleChanged(const QByteArray ¤t, const QByteArray &previous);
|
||||||
void slotSortRoleChanged(const QByteArray& current,
|
|
||||||
const QByteArray& previous);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is invoked after a preview has been received successfully.
|
* Is invoked after a preview has been received successfully.
|
||||||
|
@ -318,10 +317,7 @@ private:
|
||||||
|
|
||||||
void applySortProgressToModel();
|
void applySortProgressToModel();
|
||||||
|
|
||||||
enum ResolveHint {
|
enum ResolveHint { ResolveFast, ResolveAll };
|
||||||
ResolveFast,
|
|
||||||
ResolveAll
|
|
||||||
};
|
|
||||||
bool applyResolvedRoles(int index, ResolveHint hint);
|
bool applyResolvedRoles(int index, ResolveHint hint);
|
||||||
QHash<QByteArray, QVariant> rolesData(const KFileItem &item);
|
QHash<QByteArray, QVariant> rolesData(const KFileItem &item);
|
||||||
|
|
||||||
|
@ -338,13 +334,7 @@ private:
|
||||||
void trimHoverSequenceLoadedItems();
|
void trimHoverSequenceLoadedItems();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum State {
|
enum State { Idle, Paused, ResolvingSortRole, ResolvingAllRoles, PreviewJobRunning };
|
||||||
Idle,
|
|
||||||
Paused,
|
|
||||||
ResolvingSortRole,
|
|
||||||
ResolvingAllRoles,
|
|
||||||
PreviewJobRunning
|
|
||||||
};
|
|
||||||
|
|
||||||
State m_state;
|
State m_state;
|
||||||
|
|
||||||
|
|
|
@ -31,12 +31,13 @@ class KItemListContainerViewport : public QGraphicsView
|
||||||
|
|
||||||
public:
|
public:
|
||||||
KItemListContainerViewport(QGraphicsScene *scene, QWidget *parent);
|
KItemListContainerViewport(QGraphicsScene *scene, QWidget *parent);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void wheelEvent(QWheelEvent *event) override;
|
void wheelEvent(QWheelEvent *event) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
KItemListContainerViewport::KItemListContainerViewport(QGraphicsScene* scene, QWidget* parent) :
|
KItemListContainerViewport::KItemListContainerViewport(QGraphicsScene *scene, QWidget *parent)
|
||||||
QGraphicsView(scene, parent)
|
: QGraphicsView(scene, parent)
|
||||||
{
|
{
|
||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
@ -51,12 +52,12 @@ void KItemListContainerViewport::wheelEvent(QWheelEvent* event)
|
||||||
event->ignore();
|
event->ignore();
|
||||||
}
|
}
|
||||||
|
|
||||||
KItemListContainer::KItemListContainer(KItemListController* controller, QWidget* parent) :
|
KItemListContainer::KItemListContainer(KItemListController *controller, QWidget *parent)
|
||||||
QAbstractScrollArea(parent),
|
: QAbstractScrollArea(parent)
|
||||||
m_controller(controller),
|
, m_controller(controller)
|
||||||
m_horizontalSmoothScroller(nullptr),
|
, m_horizontalSmoothScroller(nullptr)
|
||||||
m_verticalSmoothScroller(nullptr),
|
, m_verticalSmoothScroller(nullptr)
|
||||||
m_scroller(nullptr)
|
, m_scroller(nullptr)
|
||||||
{
|
{
|
||||||
Q_ASSERT(controller);
|
Q_ASSERT(controller);
|
||||||
controller->setParent(this);
|
controller->setParent(this);
|
||||||
|
@ -74,17 +75,13 @@ KItemListContainer::KItemListContainer(KItemListController* controller, QWidget*
|
||||||
slotViewChanged(controller->view(), nullptr);
|
slotViewChanged(controller->view(), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(controller, &KItemListController::modelChanged,
|
connect(controller, &KItemListController::modelChanged, this, &KItemListContainer::slotModelChanged);
|
||||||
this, &KItemListContainer::slotModelChanged);
|
connect(controller, &KItemListController::viewChanged, this, &KItemListContainer::slotViewChanged);
|
||||||
connect(controller, &KItemListController::viewChanged,
|
|
||||||
this, &KItemListContainer::slotViewChanged);
|
|
||||||
|
|
||||||
m_scroller = QScroller::scroller(viewport());
|
m_scroller = QScroller::scroller(viewport());
|
||||||
m_scroller->grabGesture(viewport());
|
m_scroller->grabGesture(viewport());
|
||||||
connect(controller, &KItemListController::scrollerStop,
|
connect(controller, &KItemListController::scrollerStop, this, &KItemListContainer::stopScroller);
|
||||||
this, &KItemListContainer::stopScroller);
|
connect(m_scroller, &QScroller::stateChanged, controller, &KItemListController::slotStateChanged);
|
||||||
connect(m_scroller, &QScroller::stateChanged,
|
|
||||||
controller, &KItemListController::slotStateChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KItemListContainer::~KItemListContainer()
|
KItemListContainer::~KItemListContainer()
|
||||||
|
@ -172,10 +169,8 @@ void KItemListContainer::wheelEvent(QWheelEvent* event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool scrollHorizontally = (qAbs(event->angleDelta().y()) < qAbs(event->angleDelta().x())) ||
|
const bool scrollHorizontally = (qAbs(event->angleDelta().y()) < qAbs(event->angleDelta().x())) || (!verticalScrollBar()->isVisible());
|
||||||
(!verticalScrollBar()->isVisible());
|
KItemListSmoothScroller *smoothScroller = scrollHorizontally ? m_horizontalSmoothScroller : m_verticalSmoothScroller;
|
||||||
KItemListSmoothScroller* smoothScroller = scrollHorizontally ?
|
|
||||||
m_horizontalSmoothScroller : m_verticalSmoothScroller;
|
|
||||||
|
|
||||||
smoothScroller->handleWheelEvent(event);
|
smoothScroller->handleWheelEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -197,16 +192,11 @@ void KItemListContainer::slotViewChanged(KItemListView* current, KItemListView*
|
||||||
QGraphicsScene *scene = static_cast<QGraphicsView *>(viewport())->scene();
|
QGraphicsScene *scene = static_cast<QGraphicsView *>(viewport())->scene();
|
||||||
if (previous) {
|
if (previous) {
|
||||||
scene->removeItem(previous);
|
scene->removeItem(previous);
|
||||||
disconnect(previous, &KItemListView::scrollOrientationChanged,
|
disconnect(previous, &KItemListView::scrollOrientationChanged, this, &KItemListContainer::slotScrollOrientationChanged);
|
||||||
this, &KItemListContainer::slotScrollOrientationChanged);
|
disconnect(previous, &KItemListView::scrollOffsetChanged, this, &KItemListContainer::updateScrollOffsetScrollBar);
|
||||||
disconnect(previous, &KItemListView::scrollOffsetChanged,
|
disconnect(previous, &KItemListView::maximumScrollOffsetChanged, this, &KItemListContainer::updateScrollOffsetScrollBar);
|
||||||
this, &KItemListContainer::updateScrollOffsetScrollBar);
|
disconnect(previous, &KItemListView::itemOffsetChanged, this, &KItemListContainer::updateItemOffsetScrollBar);
|
||||||
disconnect(previous, &KItemListView::maximumScrollOffsetChanged,
|
disconnect(previous, &KItemListView::maximumItemOffsetChanged, this, &KItemListContainer::updateItemOffsetScrollBar);
|
||||||
this, &KItemListContainer::updateScrollOffsetScrollBar);
|
|
||||||
disconnect(previous, &KItemListView::itemOffsetChanged,
|
|
||||||
this, &KItemListContainer::updateItemOffsetScrollBar);
|
|
||||||
disconnect(previous, &KItemListView::maximumItemOffsetChanged,
|
|
||||||
this, &KItemListContainer::updateItemOffsetScrollBar);
|
|
||||||
disconnect(previous, &KItemListView::scrollTo, this, &KItemListContainer::scrollTo);
|
disconnect(previous, &KItemListView::scrollTo, this, &KItemListContainer::scrollTo);
|
||||||
disconnect(m_horizontalSmoothScroller, &KItemListSmoothScroller::scrollingStopped, previous, &KItemListView::scrollingStopped);
|
disconnect(m_horizontalSmoothScroller, &KItemListSmoothScroller::scrollingStopped, previous, &KItemListView::scrollingStopped);
|
||||||
disconnect(m_verticalSmoothScroller, &KItemListSmoothScroller::scrollingStopped, previous, &KItemListView::scrollingStopped);
|
disconnect(m_verticalSmoothScroller, &KItemListSmoothScroller::scrollingStopped, previous, &KItemListView::scrollingStopped);
|
||||||
|
@ -215,16 +205,11 @@ void KItemListContainer::slotViewChanged(KItemListView* current, KItemListView*
|
||||||
}
|
}
|
||||||
if (current) {
|
if (current) {
|
||||||
scene->addItem(current);
|
scene->addItem(current);
|
||||||
connect(current, &KItemListView::scrollOrientationChanged,
|
connect(current, &KItemListView::scrollOrientationChanged, this, &KItemListContainer::slotScrollOrientationChanged);
|
||||||
this, &KItemListContainer::slotScrollOrientationChanged);
|
connect(current, &KItemListView::scrollOffsetChanged, this, &KItemListContainer::updateScrollOffsetScrollBar);
|
||||||
connect(current, &KItemListView::scrollOffsetChanged,
|
connect(current, &KItemListView::maximumScrollOffsetChanged, this, &KItemListContainer::updateScrollOffsetScrollBar);
|
||||||
this, &KItemListContainer::updateScrollOffsetScrollBar);
|
connect(current, &KItemListView::itemOffsetChanged, this, &KItemListContainer::updateItemOffsetScrollBar);
|
||||||
connect(current, &KItemListView::maximumScrollOffsetChanged,
|
connect(current, &KItemListView::maximumItemOffsetChanged, this, &KItemListContainer::updateItemOffsetScrollBar);
|
||||||
this, &KItemListContainer::updateScrollOffsetScrollBar);
|
|
||||||
connect(current, &KItemListView::itemOffsetChanged,
|
|
||||||
this, &KItemListContainer::updateItemOffsetScrollBar);
|
|
||||||
connect(current, &KItemListView::maximumItemOffsetChanged,
|
|
||||||
this, &KItemListContainer::updateItemOffsetScrollBar);
|
|
||||||
connect(current, &KItemListView::scrollTo, this, &KItemListContainer::scrollTo);
|
connect(current, &KItemListView::scrollTo, this, &KItemListContainer::scrollTo);
|
||||||
connect(m_horizontalSmoothScroller, &KItemListSmoothScroller::scrollingStopped, current, &KItemListView::scrollingStopped);
|
connect(m_horizontalSmoothScroller, &KItemListSmoothScroller::scrollingStopped, current, &KItemListView::scrollingStopped);
|
||||||
connect(m_verticalSmoothScroller, &KItemListSmoothScroller::scrollingStopped, current, &KItemListView::scrollingStopped);
|
connect(m_verticalSmoothScroller, &KItemListSmoothScroller::scrollingStopped, current, &KItemListView::scrollingStopped);
|
||||||
|
@ -289,8 +274,7 @@ void KItemListContainer::updateScrollOffsetScrollBar()
|
||||||
|
|
||||||
const int value = view->scrollOffset();
|
const int value = view->scrollOffset();
|
||||||
if (smoothScroller->requestScrollBarUpdate(maximum)) {
|
if (smoothScroller->requestScrollBarUpdate(maximum)) {
|
||||||
const bool updatePolicy = (scrollOffsetScrollBar->maximum() > 0 && maximum == 0)
|
const bool updatePolicy = (scrollOffsetScrollBar->maximum() > 0 && maximum == 0) || horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOn;
|
||||||
|| horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOn;
|
|
||||||
|
|
||||||
scrollOffsetScrollBar->setSingleStep(singleStep);
|
scrollOffsetScrollBar->setSingleStep(singleStep);
|
||||||
scrollOffsetScrollBar->setPageStep(pageStep);
|
scrollOffsetScrollBar->setPageStep(pageStep);
|
||||||
|
@ -356,16 +340,12 @@ void KItemListContainer::updateGeometries()
|
||||||
scrollbarSpacing = style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarSpacing, &option, this);
|
scrollbarSpacing = style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarSpacing, &option, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
const int widthDec = verticalScrollBar()->isVisible()
|
const int widthDec = verticalScrollBar()->isVisible() ? extra + scrollbarSpacing + style()->pixelMetric(QStyle::PM_ScrollBarExtent, &option, this) : extra;
|
||||||
? extra + scrollbarSpacing + style()->pixelMetric(QStyle::PM_ScrollBarExtent, &option, this)
|
|
||||||
: extra;
|
|
||||||
|
|
||||||
const int heightDec = horizontalScrollBar()->isVisible()
|
const int heightDec =
|
||||||
? extra + scrollbarSpacing + style()->pixelMetric(QStyle::PM_ScrollBarExtent, &option, this)
|
horizontalScrollBar()->isVisible() ? extra + scrollbarSpacing + style()->pixelMetric(QStyle::PM_ScrollBarExtent, &option, this) : extra;
|
||||||
: extra;
|
|
||||||
|
|
||||||
const QRectF newGeometry(0, 0, rect.width() - widthDec,
|
const QRectF newGeometry(0, 0, rect.width() - widthDec, rect.height() - heightDec);
|
||||||
rect.height() - heightDec);
|
|
||||||
if (m_controller->view()->geometry() != newGeometry) {
|
if (m_controller->view()->geometry() != newGeometry) {
|
||||||
m_controller->view()->setGeometry(newGeometry);
|
m_controller->view()->setGeometry(newGeometry);
|
||||||
|
|
||||||
|
@ -407,8 +387,7 @@ void KItemListContainer::updateScrollOffsetScrollBarPolicy()
|
||||||
newViewSize.rheight() += scrollBarInc;
|
newViewSize.rheight() += scrollBarInc;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Qt::ScrollBarPolicy policy = view->scrollBarRequired(newViewSize)
|
const Qt::ScrollBarPolicy policy = view->scrollBarRequired(newViewSize) ? Qt::ScrollBarAlwaysOn : Qt::ScrollBarAsNeeded;
|
||||||
? Qt::ScrollBarAlwaysOn : Qt::ScrollBarAsNeeded;
|
|
||||||
if (vertical) {
|
if (vertical) {
|
||||||
setVerticalScrollBarPolicy(policy);
|
setVerticalScrollBarPolicy(policy);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -80,5 +80,3 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,40 +30,37 @@
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QTouchEvent>
|
#include <QTouchEvent>
|
||||||
|
|
||||||
KItemListController::KItemListController(KItemModelBase* model, KItemListView* view, QObject* parent) :
|
KItemListController::KItemListController(KItemModelBase *model, KItemListView *view, QObject *parent)
|
||||||
QObject(parent),
|
: QObject(parent)
|
||||||
m_singleClickActivationEnforced(false),
|
, m_singleClickActivationEnforced(false)
|
||||||
m_selectionMode(false),
|
, m_selectionMode(false)
|
||||||
m_selectionTogglePressed(false),
|
, m_selectionTogglePressed(false)
|
||||||
m_clearSelectionIfItemsAreNotDragged(false),
|
, m_clearSelectionIfItemsAreNotDragged(false)
|
||||||
m_isSwipeGesture(false),
|
, m_isSwipeGesture(false)
|
||||||
m_dragActionOrRightClick(false),
|
, m_dragActionOrRightClick(false)
|
||||||
m_scrollerIsScrolling(false),
|
, m_scrollerIsScrolling(false)
|
||||||
m_pinchGestureInProgress(false),
|
, m_pinchGestureInProgress(false)
|
||||||
m_mousePress(false),
|
, m_mousePress(false)
|
||||||
m_isTouchEvent(false),
|
, m_isTouchEvent(false)
|
||||||
m_selectionBehavior(NoSelection),
|
, m_selectionBehavior(NoSelection)
|
||||||
m_autoActivationBehavior(ActivationAndExpansion),
|
, m_autoActivationBehavior(ActivationAndExpansion)
|
||||||
m_mouseDoubleClickAction(ActivateItemOnly),
|
, m_mouseDoubleClickAction(ActivateItemOnly)
|
||||||
m_model(nullptr),
|
, m_model(nullptr)
|
||||||
m_view(nullptr),
|
, m_view(nullptr)
|
||||||
m_selectionManager(new KItemListSelectionManager(this)),
|
, m_selectionManager(new KItemListSelectionManager(this))
|
||||||
m_keyboardManager(new KItemListKeyboardSearchManager(this)),
|
, m_keyboardManager(new KItemListKeyboardSearchManager(this))
|
||||||
m_pressedIndex(std::nullopt),
|
, m_pressedIndex(std::nullopt)
|
||||||
m_pressedMousePos(),
|
, m_pressedMousePos()
|
||||||
m_autoActivationTimer(nullptr),
|
, m_autoActivationTimer(nullptr)
|
||||||
m_swipeGesture(Qt::CustomGesture),
|
, m_swipeGesture(Qt::CustomGesture)
|
||||||
m_twoFingerTapGesture(Qt::CustomGesture),
|
, m_twoFingerTapGesture(Qt::CustomGesture)
|
||||||
m_oldSelection(),
|
, m_oldSelection()
|
||||||
m_keyboardAnchorIndex(-1),
|
, m_keyboardAnchorIndex(-1)
|
||||||
m_keyboardAnchorPos(0)
|
, m_keyboardAnchorPos(0)
|
||||||
{
|
{
|
||||||
connect(m_keyboardManager, &KItemListKeyboardSearchManager::changeCurrentItem,
|
connect(m_keyboardManager, &KItemListKeyboardSearchManager::changeCurrentItem, this, &KItemListController::slotChangeCurrentItem);
|
||||||
this, &KItemListController::slotChangeCurrentItem);
|
connect(m_selectionManager, &KItemListSelectionManager::currentChanged, m_keyboardManager, &KItemListKeyboardSearchManager::slotCurrentChanged);
|
||||||
connect(m_selectionManager, &KItemListSelectionManager::currentChanged,
|
connect(m_selectionManager, &KItemListSelectionManager::selectionChanged, m_keyboardManager, &KItemListKeyboardSearchManager::slotSelectionChanged);
|
||||||
m_keyboardManager, &KItemListKeyboardSearchManager::slotCurrentChanged);
|
|
||||||
connect(m_selectionManager, &KItemListSelectionManager::selectionChanged,
|
|
||||||
m_keyboardManager, &KItemListKeyboardSearchManager::slotSelectionChanged);
|
|
||||||
|
|
||||||
m_autoActivationTimer = new QTimer(this);
|
m_autoActivationTimer = new QTimer(this);
|
||||||
m_autoActivationTimer->setSingleShot(true);
|
m_autoActivationTimer->setSingleShot(true);
|
||||||
|
@ -252,10 +249,8 @@ bool KItemListController::keyPressEvent(QKeyEvent* event)
|
||||||
const bool shiftPressed = event->modifiers() & Qt::ShiftModifier;
|
const bool shiftPressed = event->modifiers() & Qt::ShiftModifier;
|
||||||
const bool controlPressed = event->modifiers() & Qt::ControlModifier;
|
const bool controlPressed = event->modifiers() & Qt::ControlModifier;
|
||||||
const bool shiftOrControlPressed = shiftPressed || controlPressed;
|
const bool shiftOrControlPressed = shiftPressed || controlPressed;
|
||||||
const bool navigationPressed = key == Qt::Key_Home || key == Qt::Key_End ||
|
const bool navigationPressed = key == Qt::Key_Home || key == Qt::Key_End || key == Qt::Key_PageUp || key == Qt::Key_PageDown || key == Qt::Key_Up
|
||||||
key == Qt::Key_PageUp || key == Qt::Key_PageDown ||
|
|| key == Qt::Key_Down || key == Qt::Key_Left || key == Qt::Key_Right;
|
||||||
key == Qt::Key_Up || key == Qt::Key_Down ||
|
|
||||||
key == Qt::Key_Left || key == Qt::Key_Right;
|
|
||||||
|
|
||||||
const int itemCount = m_model->count();
|
const int itemCount = m_model->count();
|
||||||
|
|
||||||
|
@ -263,11 +258,20 @@ bool KItemListController::keyPressEvent(QKeyEvent* event)
|
||||||
// the arrow keys to simplify the event handling.
|
// the arrow keys to simplify the event handling.
|
||||||
if (m_view->scrollOrientation() == Qt::Horizontal) {
|
if (m_view->scrollOrientation() == Qt::Horizontal) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case Qt::Key_Up: key = Qt::Key_Left; break;
|
case Qt::Key_Up:
|
||||||
case Qt::Key_Down: key = Qt::Key_Right; break;
|
key = Qt::Key_Left;
|
||||||
case Qt::Key_Left: key = Qt::Key_Up; break;
|
break;
|
||||||
case Qt::Key_Right: key = Qt::Key_Down; break;
|
case Qt::Key_Down:
|
||||||
default: break;
|
key = Qt::Key_Right;
|
||||||
|
break;
|
||||||
|
case Qt::Key_Left:
|
||||||
|
key = Qt::Key_Up;
|
||||||
|
break;
|
||||||
|
case Qt::Key_Right:
|
||||||
|
key = Qt::Key_Down;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,8 +406,7 @@ bool KItemListController::keyPressEvent(QKeyEvent* event)
|
||||||
int index = -1;
|
int index = -1;
|
||||||
if (selectedItems.count() >= 2) {
|
if (selectedItems.count() >= 2) {
|
||||||
const int currentItemIndex = m_selectionManager->currentItem();
|
const int currentItemIndex = m_selectionManager->currentItem();
|
||||||
index = selectedItems.contains(currentItemIndex)
|
index = selectedItems.contains(currentItemIndex) ? currentItemIndex : selectedItems.first();
|
||||||
? currentItemIndex : selectedItems.first();
|
|
||||||
} else if (selectedItems.count() == 1) {
|
} else if (selectedItems.count() == 1) {
|
||||||
index = selectedItems.first();
|
index = selectedItems.first();
|
||||||
}
|
}
|
||||||
|
@ -689,9 +692,8 @@ bool KItemListController::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool emitItemActivated = !(m_view->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) || m_singleClickActivationEnforced) &&
|
bool emitItemActivated = !(m_view->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) || m_singleClickActivationEnforced)
|
||||||
(event->button() & Qt::LeftButton) &&
|
&& (event->button() & Qt::LeftButton) && index.has_value() && index.value() < m_model->count();
|
||||||
index.has_value() && index.value() < m_model->count();
|
|
||||||
if (emitItemActivated) {
|
if (emitItemActivated) {
|
||||||
Q_EMIT itemActivated(index.value());
|
Q_EMIT itemActivated(index.value());
|
||||||
}
|
}
|
||||||
|
@ -731,7 +733,6 @@ bool KItemListController::dragMoveEvent(QGraphicsSceneDragDropEvent* event, cons
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QUrl hoveredDir = m_model->directory();
|
QUrl hoveredDir = m_model->directory();
|
||||||
KItemListWidget *oldHoveredWidget = hoveredWidget();
|
KItemListWidget *oldHoveredWidget = hoveredWidget();
|
||||||
|
|
||||||
|
@ -853,8 +854,8 @@ bool KItemListController::hoverMoveEvent(QGraphicsSceneHoverEvent* event, const
|
||||||
const auto oldHoveredExpansionWidgetIterator = std::find_if(visibleItemListWidgets.begin(), visibleItemListWidgets.end(), [](auto &widget) {
|
const auto oldHoveredExpansionWidgetIterator = std::find_if(visibleItemListWidgets.begin(), visibleItemListWidgets.end(), [](auto &widget) {
|
||||||
return widget->expansionAreaHovered();
|
return widget->expansionAreaHovered();
|
||||||
});
|
});
|
||||||
const auto oldHoveredExpansionWidget = oldHoveredExpansionWidgetIterator == visibleItemListWidgets.end() ?
|
const auto oldHoveredExpansionWidget =
|
||||||
std::nullopt : std::make_optional(*oldHoveredExpansionWidgetIterator);
|
oldHoveredExpansionWidgetIterator == visibleItemListWidgets.end() ? std::nullopt : std::make_optional(*oldHoveredExpansionWidgetIterator);
|
||||||
|
|
||||||
const auto unhoverOldHoveredWidget = [&]() {
|
const auto unhoverOldHoveredWidget = [&]() {
|
||||||
if (auto oldHoveredWidget = hoveredWidget(); oldHoveredWidget) {
|
if (auto oldHoveredWidget = hoveredWidget(); oldHoveredWidget) {
|
||||||
|
@ -885,7 +886,6 @@ bool KItemListController::hoverMoveEvent(QGraphicsSceneHoverEvent* event, const
|
||||||
// we also unhover any old icon+text hovers, in case the mouse movement from icon+text to expansion toggle is too fast (i.e. newHoveredWidget is never null between the transition)
|
// we also unhover any old icon+text hovers, in case the mouse movement from icon+text to expansion toggle is too fast (i.e. newHoveredWidget is never null between the transition)
|
||||||
unhoverOldHoveredWidget();
|
unhoverOldHoveredWidget();
|
||||||
|
|
||||||
|
|
||||||
newHoveredWidget->setExpansionAreaHovered(true);
|
newHoveredWidget->setExpansionAreaHovered(true);
|
||||||
} else {
|
} else {
|
||||||
// make sure we unhover the old one first if old!=new
|
// make sure we unhover the old one first if old!=new
|
||||||
|
@ -1040,8 +1040,7 @@ void KItemListController::tapTriggered(QTapGesture* tap, const QTransform& trans
|
||||||
|
|
||||||
if (m_dragActionOrRightClick) {
|
if (m_dragActionOrRightClick) {
|
||||||
m_dragActionOrRightClick = false;
|
m_dragActionOrRightClick = false;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
onPress(tap->hotSpot().toPoint(), tap->position().toPoint(), Qt::NoModifier, Qt::LeftButton);
|
onPress(tap->hotSpot().toPoint(), tap->position().toPoint(), Qt::NoModifier, Qt::LeftButton);
|
||||||
onRelease(transform.map(tap->position()), Qt::NoModifier, Qt::LeftButton, true);
|
onRelease(transform.map(tap->position()), Qt::NoModifier, Qt::LeftButton, true);
|
||||||
}
|
}
|
||||||
|
@ -1051,7 +1050,6 @@ void KItemListController::tapTriggered(QTapGesture* tap, const QTransform& trans
|
||||||
|
|
||||||
void KItemListController::tapAndHoldTriggered(QGestureEvent *event, const QTransform &transform)
|
void KItemListController::tapAndHoldTriggered(QGestureEvent *event, const QTransform &transform)
|
||||||
{
|
{
|
||||||
|
|
||||||
//the Qt TabAndHold gesture is triggerable with a mouse click, we don't want this
|
//the Qt TabAndHold gesture is triggerable with a mouse click, we don't want this
|
||||||
if (!m_isTouchEvent) {
|
if (!m_isTouchEvent) {
|
||||||
return;
|
return;
|
||||||
|
@ -1160,7 +1158,6 @@ void KItemListController::twoFingerTapTriggered(QGestureEvent* event, const QTra
|
||||||
onPress(twoTap->screenPos().toPoint(), twoTap->pos().toPoint(), Qt::ControlModifier, Qt::LeftButton);
|
onPress(twoTap->screenPos().toPoint(), twoTap->pos().toPoint(), Qt::ControlModifier, Qt::LeftButton);
|
||||||
onRelease(transform.map(twoTap->pos()), Qt::ControlModifier, Qt::LeftButton, false);
|
onRelease(transform.map(twoTap->pos()), Qt::ControlModifier, Qt::LeftButton, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1257,8 +1254,7 @@ void KItemListController::slotRubberBandChanged()
|
||||||
if (!m_oldSelection.isEmpty()) {
|
if (!m_oldSelection.isEmpty()) {
|
||||||
// Clear the old selection that was available before the rubberband has
|
// Clear the old selection that was available before the rubberband has
|
||||||
// been activated in case if no Shift- or Control-key are pressed
|
// been activated in case if no Shift- or Control-key are pressed
|
||||||
const bool shiftOrControlPressed = QApplication::keyboardModifiers() & Qt::ShiftModifier ||
|
const bool shiftOrControlPressed = QApplication::keyboardModifiers() & Qt::ShiftModifier || QApplication::keyboardModifiers() & Qt::ControlModifier;
|
||||||
QApplication::keyboardModifiers() & Qt::ControlModifier;
|
|
||||||
if (!shiftOrControlPressed && !m_selectionMode) {
|
if (!shiftOrControlPressed && !m_selectionMode) {
|
||||||
m_oldSelection.clear();
|
m_oldSelection.clear();
|
||||||
}
|
}
|
||||||
|
@ -1284,8 +1280,7 @@ void KItemListController::slotRubberBandChanged()
|
||||||
// Select all invisible items that intersect with the rubberband. Instead of
|
// Select all invisible items that intersect with the rubberband. Instead of
|
||||||
// iterating all items only the area which might be touched by the rubberband
|
// iterating all items only the area which might be touched by the rubberband
|
||||||
// will be checked.
|
// will be checked.
|
||||||
const bool increaseIndex = scrollVertical ?
|
const bool increaseIndex = scrollVertical ? startPos.y() > endPos.y() : startPos.x() > endPos.x();
|
||||||
startPos.y() > endPos.y(): startPos.x() > endPos.x();
|
|
||||||
|
|
||||||
int index = increaseIndex ? m_view->lastVisibleIndex() + 1 : m_view->firstVisibleIndex() - 1;
|
int index = increaseIndex ? m_view->lastVisibleIndex() + 1 : m_view->firstVisibleIndex() - 1;
|
||||||
bool selectionFinished = false;
|
bool selectionFinished = false;
|
||||||
|
@ -1297,14 +1292,12 @@ void KItemListController::slotRubberBandChanged()
|
||||||
|
|
||||||
if (increaseIndex) {
|
if (increaseIndex) {
|
||||||
++index;
|
++index;
|
||||||
selectionFinished = (index >= m_model->count()) ||
|
selectionFinished = (index >= m_model->count()) || (scrollVertical && widgetRect.top() > rubberBandRect.bottom())
|
||||||
( scrollVertical && widgetRect.top() > rubberBandRect.bottom()) ||
|
|| (!scrollVertical && widgetRect.left() > rubberBandRect.right());
|
||||||
(!scrollVertical && widgetRect.left() > rubberBandRect.right());
|
|
||||||
} else {
|
} else {
|
||||||
--index;
|
--index;
|
||||||
selectionFinished = (index < 0) ||
|
selectionFinished = (index < 0) || (scrollVertical && widgetRect.bottom() < rubberBandRect.top())
|
||||||
( scrollVertical && widgetRect.bottom() < rubberBandRect.top()) ||
|
|| (!scrollVertical && widgetRect.right() < rubberBandRect.left());
|
||||||
(!scrollVertical && widgetRect.right() < rubberBandRect.left());
|
|
||||||
}
|
}
|
||||||
} while (!selectionFinished);
|
} while (!selectionFinished);
|
||||||
|
|
||||||
|
@ -1314,8 +1307,7 @@ void KItemListController::slotRubberBandChanged()
|
||||||
// 1. All previously selected items which are not inside the rubberband, and
|
// 1. All previously selected items which are not inside the rubberband, and
|
||||||
// 2. all items inside the rubberband which have not been selected previously.
|
// 2. all items inside the rubberband which have not been selected previously.
|
||||||
m_selectionManager->setSelectedItems(m_oldSelection ^ selectedItems);
|
m_selectionManager->setSelectedItems(m_oldSelection ^ selectedItems);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
m_selectionManager->setSelectedItems(selectedItems + m_oldSelection);
|
m_selectionManager->setSelectedItems(selectedItems + m_oldSelection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1400,9 +1392,8 @@ KItemListWidget* KItemListController::widgetForDropPos(const QPointF& pos) const
|
||||||
|
|
||||||
void KItemListController::updateKeyboardAnchor()
|
void KItemListController::updateKeyboardAnchor()
|
||||||
{
|
{
|
||||||
const bool validAnchor = m_keyboardAnchorIndex >= 0 &&
|
const bool validAnchor =
|
||||||
m_keyboardAnchorIndex < m_model->count() &&
|
m_keyboardAnchorIndex >= 0 && m_keyboardAnchorIndex < m_model->count() && keyboardAnchorPos(m_keyboardAnchorIndex) == m_keyboardAnchorPos;
|
||||||
keyboardAnchorPos(m_keyboardAnchorIndex) == m_keyboardAnchorPos;
|
|
||||||
if (!validAnchor) {
|
if (!validAnchor) {
|
||||||
const int index = m_selectionManager->currentItem();
|
const int index = m_selectionManager->currentItem();
|
||||||
m_keyboardAnchorIndex = index;
|
m_keyboardAnchorIndex = index;
|
||||||
|
@ -1544,9 +1535,7 @@ bool KItemListController::onPress(const QPoint& screenPos, const QPointF& pos, c
|
||||||
// - open the context menu and perform an action for all selected items.
|
// - open the context menu and perform an action for all selected items.
|
||||||
const bool shiftOrControlPressed = shiftPressed || controlPressed;
|
const bool shiftOrControlPressed = shiftPressed || controlPressed;
|
||||||
const bool pressedItemAlreadySelected = m_pressedIndex.has_value() && m_selectionManager->isSelected(m_pressedIndex.value());
|
const bool pressedItemAlreadySelected = m_pressedIndex.has_value() && m_selectionManager->isSelected(m_pressedIndex.value());
|
||||||
const bool clearSelection = m_selectionBehavior == SingleSelection ||
|
const bool clearSelection = m_selectionBehavior == SingleSelection || (!shiftOrControlPressed && !pressedItemAlreadySelected);
|
||||||
(!shiftOrControlPressed && !pressedItemAlreadySelected);
|
|
||||||
|
|
||||||
|
|
||||||
// When this method returns false, a rubberBand selection is created using KItemListController::startRubberBand via the caller.
|
// When this method returns false, a rubberBand selection is created using KItemListController::startRubberBand via the caller.
|
||||||
if (clearSelection) {
|
if (clearSelection) {
|
||||||
|
@ -1597,7 +1586,6 @@ bool KItemListController::onPress(const QPoint& screenPos, const QPointF& pos, c
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rightClick) {
|
if (rightClick) {
|
||||||
|
|
||||||
// Do header hit check and short circuit before commencing any state changing effects
|
// Do header hit check and short circuit before commencing any state changing effects
|
||||||
if (m_view->headerBoundaries().contains(pos)) {
|
if (m_view->headerBoundaries().contains(pos)) {
|
||||||
Q_EMIT headerContextMenuRequested(screenPos);
|
Q_EMIT headerContextMenuRequested(screenPos);
|
||||||
|
@ -1702,8 +1690,7 @@ bool KItemListController::onRelease(const QPointF& pos, const Qt::KeyboardModifi
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool controlPressed = modifiers & Qt::ControlModifier;
|
const bool controlPressed = modifiers & Qt::ControlModifier;
|
||||||
const bool shiftOrControlPressed = modifiers & Qt::ShiftModifier ||
|
const bool shiftOrControlPressed = modifiers & Qt::ShiftModifier || controlPressed;
|
||||||
controlPressed;
|
|
||||||
|
|
||||||
const std::optional<int> index = m_view->itemAt(pos);
|
const std::optional<int> index = m_view->itemAt(pos);
|
||||||
|
|
||||||
|
|
|
@ -56,22 +56,12 @@ class DOLPHIN_EXPORT KItemListController : public QObject
|
||||||
Q_PROPERTY(MouseDoubleClickAction mouseDoubleClickAction READ mouseDoubleClickAction WRITE setMouseDoubleClickAction)
|
Q_PROPERTY(MouseDoubleClickAction mouseDoubleClickAction READ mouseDoubleClickAction WRITE setMouseDoubleClickAction)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum SelectionBehavior {
|
enum SelectionBehavior { NoSelection, SingleSelection, MultiSelection };
|
||||||
NoSelection,
|
|
||||||
SingleSelection,
|
|
||||||
MultiSelection
|
|
||||||
};
|
|
||||||
Q_ENUM(SelectionBehavior)
|
Q_ENUM(SelectionBehavior)
|
||||||
|
|
||||||
enum AutoActivationBehavior {
|
enum AutoActivationBehavior { ActivationAndExpansion, ExpansionOnly };
|
||||||
ActivationAndExpansion,
|
|
||||||
ExpansionOnly
|
|
||||||
};
|
|
||||||
|
|
||||||
enum MouseDoubleClickAction {
|
enum MouseDoubleClickAction { ActivateAndExpandItem, ActivateItemOnly };
|
||||||
ActivateAndExpandItem,
|
|
||||||
ActivateItemOnly
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param model Model of the controller. The ownership is passed to the controller.
|
* @param model Model of the controller. The ownership is passed to the controller.
|
||||||
|
@ -394,5 +384,3 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,17 +14,17 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QStyleOptionGraphicsItem>
|
#include <QStyleOptionGraphicsItem>
|
||||||
|
|
||||||
KItemListGroupHeader::KItemListGroupHeader(QGraphicsWidget* parent) :
|
KItemListGroupHeader::KItemListGroupHeader(QGraphicsWidget *parent)
|
||||||
QGraphicsWidget(parent),
|
: QGraphicsWidget(parent)
|
||||||
m_dirtyCache(true),
|
, m_dirtyCache(true)
|
||||||
m_role(),
|
, m_role()
|
||||||
m_data(),
|
, m_data()
|
||||||
m_styleOption(),
|
, m_styleOption()
|
||||||
m_scrollOrientation(Qt::Vertical),
|
, m_scrollOrientation(Qt::Vertical)
|
||||||
m_itemIndex(-1),
|
, m_itemIndex(-1)
|
||||||
m_separatorColor(),
|
, m_separatorColor()
|
||||||
m_roleColor(),
|
, m_roleColor()
|
||||||
m_roleBounds()
|
, m_roleBounds()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,10 +190,7 @@ void KItemListGroupHeader::updateSize()
|
||||||
|
|
||||||
const int y = (m_scrollOrientation == Qt::Vertical) ? padding : horizontalMargin;
|
const int y = (m_scrollOrientation == Qt::Vertical) ? padding : horizontalMargin;
|
||||||
|
|
||||||
m_roleBounds = QRectF(horizontalMargin + padding,
|
m_roleBounds = QRectF(horizontalMargin + padding, y, size().width() - 2 * padding - horizontalMargin, roleHeight);
|
||||||
y,
|
|
||||||
size().width() - 2 * padding - horizontalMargin,
|
|
||||||
roleHeight);
|
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
@ -229,4 +226,3 @@ QColor KItemListGroupHeader::baseColor() const
|
||||||
const QPalette::ColorGroup group = isActiveWindow() ? QPalette::Active : QPalette::Inactive;
|
const QPalette::ColorGroup group = isActiveWindow() ? QPalette::Active : QPalette::Inactive;
|
||||||
return styleOption().palette.color(group, normalBaseColorRole());
|
return styleOption().palette.color(group, normalBaseColorRole());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,5 +114,3 @@ private:
|
||||||
QRectF m_roleBounds;
|
QRectF m_roleBounds;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,8 @@ qreal KItemListHeader::preferredColumnWidth(const QByteArray& role) const
|
||||||
return m_headerWidget->preferredColumnWidth(role);
|
return m_headerWidget->preferredColumnWidth(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KItemListHeader::setSidePadding(qreal width){
|
void KItemListHeader::setSidePadding(qreal width)
|
||||||
|
{
|
||||||
if (m_headerWidget->sidePadding() != width) {
|
if (m_headerWidget->sidePadding() != width) {
|
||||||
m_headerWidget->setSidePadding(width);
|
m_headerWidget->setSidePadding(width);
|
||||||
if (m_headerWidget->automaticColumnResizing()) {
|
if (m_headerWidget->automaticColumnResizing()) {
|
||||||
|
@ -71,22 +72,19 @@ void KItemListHeader::setSidePadding(qreal width){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal KItemListHeader::sidePadding() const{
|
qreal KItemListHeader::sidePadding() const
|
||||||
|
{
|
||||||
return m_headerWidget->sidePadding();
|
return m_headerWidget->sidePadding();
|
||||||
}
|
}
|
||||||
|
|
||||||
KItemListHeader::KItemListHeader(KItemListView* listView) :
|
KItemListHeader::KItemListHeader(KItemListView *listView)
|
||||||
QObject(listView),
|
: QObject(listView)
|
||||||
m_view(listView)
|
, m_view(listView)
|
||||||
{
|
{
|
||||||
m_headerWidget = m_view->m_headerWidget;
|
m_headerWidget = m_view->m_headerWidget;
|
||||||
Q_ASSERT(m_headerWidget);
|
Q_ASSERT(m_headerWidget);
|
||||||
|
|
||||||
connect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged,
|
connect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged, this, &KItemListHeader::columnWidthChanged);
|
||||||
this, &KItemListHeader::columnWidthChanged);
|
connect(m_headerWidget, &KItemListHeaderWidget::columnWidthChangeFinished, this, &KItemListHeader::columnWidthChangeFinished);
|
||||||
connect(m_headerWidget, &KItemListHeaderWidget::columnWidthChangeFinished,
|
connect(m_headerWidget, &KItemListHeaderWidget::sidePaddingChanged, this, &KItemListHeader::sidePaddingChanged);
|
||||||
this, &KItemListHeader::columnWidthChangeFinished);
|
|
||||||
connect(m_headerWidget, &KItemListHeaderWidget::sidePaddingChanged,
|
|
||||||
this, &KItemListHeader::sidePaddingChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,16 +72,13 @@ Q_SIGNALS:
|
||||||
* Is emitted if the width of a column has been adjusted by the user with the mouse
|
* Is emitted if the width of a column has been adjusted by the user with the mouse
|
||||||
* (no signal is emitted if KItemListHeader::setColumnWidth() is invoked).
|
* (no signal is emitted if KItemListHeader::setColumnWidth() is invoked).
|
||||||
*/
|
*/
|
||||||
void columnWidthChanged(const QByteArray& role,
|
void columnWidthChanged(const QByteArray &role, qreal currentWidth, qreal previousWidth);
|
||||||
qreal currentWidth,
|
|
||||||
qreal previousWidth);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is emitted if the user has released the mouse button after adjusting the
|
* Is emitted if the user has released the mouse button after adjusting the
|
||||||
* width of a visible role.
|
* width of a visible role.
|
||||||
*/
|
*/
|
||||||
void columnWidthChangeFinished(const QByteArray& role,
|
void columnWidthChangeFinished(const QByteArray &role, qreal currentWidth);
|
||||||
qreal currentWidth);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit KItemListHeader(KItemListView *listView);
|
explicit KItemListHeader(KItemListView *listView);
|
||||||
|
@ -94,5 +91,3 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,13 @@
|
||||||
|
|
||||||
#include "kitemlistselectionmanager.h"
|
#include "kitemlistselectionmanager.h"
|
||||||
|
|
||||||
KItemListSelectionManager::KItemListSelectionManager(QObject* parent) :
|
KItemListSelectionManager::KItemListSelectionManager(QObject *parent)
|
||||||
QObject(parent),
|
: QObject(parent)
|
||||||
m_currentItem(-1),
|
, m_currentItem(-1)
|
||||||
m_anchorItem(-1),
|
, m_anchorItem(-1)
|
||||||
m_selectedItems(),
|
, m_selectedItems()
|
||||||
m_isAnchoredSelectionActive(false),
|
, m_isAnchoredSelectionActive(false)
|
||||||
m_model(nullptr)
|
, m_model(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,8 +359,7 @@ void KItemListSelectionManager::itemsMoved(const KItemRange& itemRange, const QL
|
||||||
for (int index : previous) {
|
for (int index : previous) {
|
||||||
if (index >= itemRange.index && index < itemRange.index + itemRange.count) {
|
if (index >= itemRange.index && index < itemRange.index + itemRange.count) {
|
||||||
m_selectedItems.insert(movedToIndexes.at(index - itemRange.index));
|
m_selectedItems.insert(movedToIndexes.at(index - itemRange.index));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
m_selectedItems.insert(index);
|
m_selectedItems.insert(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -372,8 +371,7 @@ void KItemListSelectionManager::itemsMoved(const KItemRange& itemRange, const QL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int KItemListSelectionManager::indexAfterRangesRemoving(int index, const KItemRangeList& itemRanges,
|
int KItemListSelectionManager::indexAfterRangesRemoving(int index, const KItemRangeList &itemRanges, const RangesRemovingBehaviour behaviour) const
|
||||||
const RangesRemovingBehaviour behaviour) const
|
|
||||||
{
|
{
|
||||||
int dec = 0;
|
int dec = 0;
|
||||||
for (const KItemRange &itemRange : itemRanges) {
|
for (const KItemRange &itemRange : itemRanges) {
|
||||||
|
@ -397,4 +395,3 @@ int KItemListSelectionManager::indexAfterRangesRemoving(int index, const KItemRa
|
||||||
}
|
}
|
||||||
return qBound(-1, index - dec, m_model->count() - 1);
|
return qBound(-1, index - dec, m_model->count() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,17 +24,10 @@ class DOLPHIN_EXPORT KItemListSelectionManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
enum RangesRemovingBehaviour {
|
enum RangesRemovingBehaviour { DiscardRemovedIndex, AdjustRemovedIndex };
|
||||||
DiscardRemovedIndex,
|
|
||||||
AdjustRemovedIndex
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum SelectionMode {
|
enum SelectionMode { Select, Deselect, Toggle };
|
||||||
Select,
|
|
||||||
Deselect,
|
|
||||||
Toggle
|
|
||||||
};
|
|
||||||
|
|
||||||
explicit KItemListSelectionManager(QObject *parent = nullptr);
|
explicit KItemListSelectionManager(QObject *parent = nullptr);
|
||||||
~KItemListSelectionManager() override;
|
~KItemListSelectionManager() override;
|
||||||
|
@ -73,7 +66,6 @@ private:
|
||||||
void itemsRemoved(const KItemRangeList &itemRanges);
|
void itemsRemoved(const KItemRangeList &itemRanges);
|
||||||
void itemsMoved(const KItemRange &itemRange, const QList<int> &movedToIndexes);
|
void itemsMoved(const KItemRange &itemRange, const QList<int> &movedToIndexes);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method for itemsRemoved. Returns the changed index after removing
|
* Helper method for itemsRemoved. Returns the changed index after removing
|
||||||
* the given range. If the index is part of the range, -1 will be returned.
|
* the given range. If the index is part of the range, -1 will be returned.
|
||||||
|
|
|
@ -6,19 +6,18 @@
|
||||||
|
|
||||||
#include "kitemliststyleoption.h"
|
#include "kitemliststyleoption.h"
|
||||||
|
|
||||||
|
KItemListStyleOption::KItemListStyleOption()
|
||||||
KItemListStyleOption::KItemListStyleOption() :
|
: rect()
|
||||||
rect(),
|
, font()
|
||||||
font(),
|
, fontMetrics(QFont())
|
||||||
fontMetrics(QFont()),
|
, palette()
|
||||||
palette(),
|
, padding(-1)
|
||||||
padding(-1),
|
, horizontalMargin(-1)
|
||||||
horizontalMargin(-1),
|
, verticalMargin(-1)
|
||||||
verticalMargin(-1),
|
, iconSize(-1)
|
||||||
iconSize(-1),
|
, extendedSelectionRegion(false)
|
||||||
extendedSelectionRegion(false),
|
, maxTextLines(0)
|
||||||
maxTextLines(0),
|
, maxTextWidth(0)
|
||||||
maxTextWidth(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,17 +27,9 @@ KItemListStyleOption::~KItemListStyleOption()
|
||||||
|
|
||||||
bool KItemListStyleOption::operator==(const KItemListStyleOption &other) const
|
bool KItemListStyleOption::operator==(const KItemListStyleOption &other) const
|
||||||
{
|
{
|
||||||
return rect == other.rect
|
return rect == other.rect && font == other.font && fontMetrics == other.fontMetrics && palette == other.palette && padding == other.padding
|
||||||
&& font == other.font
|
&& horizontalMargin == other.horizontalMargin && verticalMargin == other.verticalMargin && iconSize == other.iconSize
|
||||||
&& fontMetrics == other.fontMetrics
|
&& extendedSelectionRegion == other.extendedSelectionRegion && maxTextLines == other.maxTextLines && maxTextWidth == other.maxTextWidth;
|
||||||
&& palette == other.palette
|
|
||||||
&& padding == other.padding
|
|
||||||
&& horizontalMargin == other.horizontalMargin
|
|
||||||
&& verticalMargin == other.verticalMargin
|
|
||||||
&& iconSize == other.iconSize
|
|
||||||
&& extendedSelectionRegion == other.extendedSelectionRegion
|
|
||||||
&& maxTextLines == other.maxTextLines
|
|
||||||
&& maxTextWidth == other.maxTextWidth;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KItemListStyleOption::operator!=(const KItemListStyleOption &other) const
|
bool KItemListStyleOption::operator!=(const KItemListStyleOption &other) const
|
||||||
|
|
|
@ -36,5 +36,3 @@ public:
|
||||||
bool operator!=(const KItemListStyleOption &other) const;
|
bool operator!=(const KItemListStyleOption &other) const;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,8 @@
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QVariantAnimation>
|
#include <QVariantAnimation>
|
||||||
|
|
||||||
|
namespace
|
||||||
namespace {
|
{
|
||||||
// Time in ms until reaching the autoscroll margin triggers
|
// Time in ms until reaching the autoscroll margin triggers
|
||||||
// an initial autoscrolling
|
// an initial autoscrolling
|
||||||
const int InitialAutoScrollDelay = 700;
|
const int InitialAutoScrollDelay = 700;
|
||||||
|
@ -59,44 +59,44 @@ QAccessibleInterface* accessibleInterfaceFactory(const QString& key, QObject* ob
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
KItemListView::KItemListView(QGraphicsWidget* parent) :
|
KItemListView::KItemListView(QGraphicsWidget *parent)
|
||||||
QGraphicsWidget(parent),
|
: QGraphicsWidget(parent)
|
||||||
m_enabledSelectionToggles(false),
|
, m_enabledSelectionToggles(false)
|
||||||
m_grouped(false),
|
, m_grouped(false)
|
||||||
m_highlightEntireRow(false),
|
, m_highlightEntireRow(false)
|
||||||
m_alternateBackgrounds(false),
|
, m_alternateBackgrounds(false)
|
||||||
m_supportsItemExpanding(false),
|
, m_supportsItemExpanding(false)
|
||||||
m_editingRole(false),
|
, m_editingRole(false)
|
||||||
m_activeTransactions(0),
|
, m_activeTransactions(0)
|
||||||
m_endTransactionAnimationHint(Animation),
|
, m_endTransactionAnimationHint(Animation)
|
||||||
m_itemSize(),
|
, m_itemSize()
|
||||||
m_controller(nullptr),
|
, m_controller(nullptr)
|
||||||
m_model(nullptr),
|
, m_model(nullptr)
|
||||||
m_visibleRoles(),
|
, m_visibleRoles()
|
||||||
m_widgetCreator(nullptr),
|
, m_widgetCreator(nullptr)
|
||||||
m_groupHeaderCreator(nullptr),
|
, m_groupHeaderCreator(nullptr)
|
||||||
m_styleOption(),
|
, m_styleOption()
|
||||||
m_visibleItems(),
|
, m_visibleItems()
|
||||||
m_visibleGroups(),
|
, m_visibleGroups()
|
||||||
m_visibleCells(),
|
, m_visibleCells()
|
||||||
m_scrollBarExtent(0),
|
, m_scrollBarExtent(0)
|
||||||
m_layouter(nullptr),
|
, m_layouter(nullptr)
|
||||||
m_animation(nullptr),
|
, m_animation(nullptr)
|
||||||
m_oldScrollOffset(0),
|
, m_oldScrollOffset(0)
|
||||||
m_oldMaximumScrollOffset(0),
|
, m_oldMaximumScrollOffset(0)
|
||||||
m_oldItemOffset(0),
|
, m_oldItemOffset(0)
|
||||||
m_oldMaximumItemOffset(0),
|
, m_oldMaximumItemOffset(0)
|
||||||
m_skipAutoScrollForRubberBand(false),
|
, m_skipAutoScrollForRubberBand(false)
|
||||||
m_rubberBand(nullptr),
|
, m_rubberBand(nullptr)
|
||||||
m_tapAndHoldIndicator(nullptr),
|
, m_tapAndHoldIndicator(nullptr)
|
||||||
m_mousePos(),
|
, m_mousePos()
|
||||||
m_autoScrollIncrement(0),
|
, m_autoScrollIncrement(0)
|
||||||
m_autoScrollTimer(nullptr),
|
, m_autoScrollTimer(nullptr)
|
||||||
m_header(nullptr),
|
, m_header(nullptr)
|
||||||
m_headerWidget(nullptr),
|
, m_headerWidget(nullptr)
|
||||||
m_indicatorAnimation(nullptr),
|
, m_indicatorAnimation(nullptr)
|
||||||
m_dropIndicator(),
|
, m_dropIndicator()
|
||||||
m_sizeHintResolver(nullptr)
|
, m_sizeHintResolver(nullptr)
|
||||||
{
|
{
|
||||||
setAcceptHoverEvents(true);
|
setAcceptHoverEvents(true);
|
||||||
setAcceptTouchEvents(true);
|
setAcceptTouchEvents(true);
|
||||||
|
@ -106,8 +106,7 @@ KItemListView::KItemListView(QGraphicsWidget* parent) :
|
||||||
m_layouter = new KItemListViewLayouter(m_sizeHintResolver, this);
|
m_layouter = new KItemListViewLayouter(m_sizeHintResolver, this);
|
||||||
|
|
||||||
m_animation = new KItemListViewAnimation(this);
|
m_animation = new KItemListViewAnimation(this);
|
||||||
connect(m_animation, &KItemListViewAnimation::finished,
|
connect(m_animation, &KItemListViewAnimation::finished, this, &KItemListView::slotAnimationFinished);
|
||||||
this, &KItemListView::slotAnimationFinished);
|
|
||||||
|
|
||||||
m_rubberBand = new KItemListRubberBand(this);
|
m_rubberBand = new KItemListRubberBand(this);
|
||||||
connect(m_rubberBand, &KItemListRubberBand::activationChanged, this, &KItemListView::slotRubberBandActivationChanged);
|
connect(m_rubberBand, &KItemListRubberBand::activationChanged, this, &KItemListView::slotRubberBandActivationChanged);
|
||||||
|
@ -137,7 +136,6 @@ KItemListView::KItemListView(QGraphicsWidget* parent) :
|
||||||
#ifndef QT_NO_ACCESSIBILITY
|
#ifndef QT_NO_ACCESSIBILITY
|
||||||
QAccessible::installFactory(accessibleInterfaceFactory);
|
QAccessible::installFactory(accessibleInterfaceFactory);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KItemListView::~KItemListView()
|
KItemListView::~KItemListView()
|
||||||
|
@ -244,9 +242,8 @@ void KItemListView::setVisibleRoles(const QList<QByteArray>& roles)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool alternateBackgroundsChanged = m_itemSize.isEmpty() &&
|
const bool alternateBackgroundsChanged =
|
||||||
((roles.count() > 1 && previousRoles.count() <= 1) ||
|
m_itemSize.isEmpty() && ((roles.count() > 1 && previousRoles.count() <= 1) || (roles.count() <= 1 && previousRoles.count() > 1));
|
||||||
(roles.count() <= 1 && previousRoles.count() > 1));
|
|
||||||
|
|
||||||
QHashIterator<int, KItemListWidget *> it(m_visibleItems);
|
QHashIterator<int, KItemListWidget *> it(m_visibleItems);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
|
@ -365,8 +362,7 @@ void KItemListView::setGeometry(const QRectF& rect)
|
||||||
applyAutomaticColumnWidths();
|
applyAutomaticColumnWidths();
|
||||||
} else {
|
} else {
|
||||||
const qreal requiredWidth = columnWidthsSum();
|
const qreal requiredWidth = columnWidthsSum();
|
||||||
const QSizeF dynamicItemSize(qMax(newSize.width(), requiredWidth),
|
const QSizeF dynamicItemSize(qMax(newSize.width(), requiredWidth), m_itemSize.height());
|
||||||
m_itemSize.height());
|
|
||||||
m_layouter->setItemSize(dynamicItemSize);
|
m_layouter->setItemSize(dynamicItemSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -533,8 +529,7 @@ void KItemListView::scrollToItem(int index)
|
||||||
QRectF currentRect = itemRect(index);
|
QRectF currentRect = itemRect(index);
|
||||||
|
|
||||||
// Fix for Bug 311099 - View the underscore when using Ctrl + PagDown
|
// Fix for Bug 311099 - View the underscore when using Ctrl + PagDown
|
||||||
currentRect.adjust(-m_styleOption.horizontalMargin, -m_styleOption.verticalMargin,
|
currentRect.adjust(-m_styleOption.horizontalMargin, -m_styleOption.verticalMargin, m_styleOption.horizontalMargin, m_styleOption.verticalMargin);
|
||||||
m_styleOption.horizontalMargin, m_styleOption.verticalMargin);
|
|
||||||
|
|
||||||
if (!viewGeometry.contains(currentRect)) {
|
if (!viewGeometry.contains(currentRect)) {
|
||||||
qreal newOffset = scrollOffset();
|
qreal newOffset = scrollOffset();
|
||||||
|
@ -593,8 +588,7 @@ void KItemListView::setHeaderVisible(bool visible)
|
||||||
{
|
{
|
||||||
if (visible && !m_headerWidget->isVisible()) {
|
if (visible && !m_headerWidget->isVisible()) {
|
||||||
QStyleOptionHeader option;
|
QStyleOptionHeader option;
|
||||||
const QSize headerSize = style()->sizeFromContents(QStyle::CT_HeaderSection,
|
const QSize headerSize = style()->sizeFromContents(QStyle::CT_HeaderSection, &option, QSize());
|
||||||
&option, QSize());
|
|
||||||
|
|
||||||
m_headerWidget->setPos(0, 0);
|
m_headerWidget->setPos(0, 0);
|
||||||
m_headerWidget->resize(size().width(), headerSize.height());
|
m_headerWidget->resize(size().width(), headerSize.height());
|
||||||
|
@ -602,30 +596,20 @@ void KItemListView::setHeaderVisible(bool visible)
|
||||||
m_headerWidget->setColumns(m_visibleRoles);
|
m_headerWidget->setColumns(m_visibleRoles);
|
||||||
m_headerWidget->setZValue(1);
|
m_headerWidget->setZValue(1);
|
||||||
|
|
||||||
connect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged,
|
connect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged, this, &KItemListView::slotHeaderColumnWidthChanged);
|
||||||
this, &KItemListView::slotHeaderColumnWidthChanged);
|
connect(m_headerWidget, &KItemListHeaderWidget::sidePaddingChanged, this, &KItemListView::slotSidePaddingChanged);
|
||||||
connect(m_headerWidget, &KItemListHeaderWidget::sidePaddingChanged,
|
connect(m_headerWidget, &KItemListHeaderWidget::columnMoved, this, &KItemListView::slotHeaderColumnMoved);
|
||||||
this, &KItemListView::slotSidePaddingChanged);
|
connect(m_headerWidget, &KItemListHeaderWidget::sortOrderChanged, this, &KItemListView::sortOrderChanged);
|
||||||
connect(m_headerWidget, &KItemListHeaderWidget::columnMoved,
|
connect(m_headerWidget, &KItemListHeaderWidget::sortRoleChanged, this, &KItemListView::sortRoleChanged);
|
||||||
this, &KItemListView::slotHeaderColumnMoved);
|
|
||||||
connect(m_headerWidget, &KItemListHeaderWidget::sortOrderChanged,
|
|
||||||
this, &KItemListView::sortOrderChanged);
|
|
||||||
connect(m_headerWidget, &KItemListHeaderWidget::sortRoleChanged,
|
|
||||||
this, &KItemListView::sortRoleChanged);
|
|
||||||
|
|
||||||
m_layouter->setHeaderHeight(headerSize.height());
|
m_layouter->setHeaderHeight(headerSize.height());
|
||||||
m_headerWidget->setVisible(true);
|
m_headerWidget->setVisible(true);
|
||||||
} else if (!visible && m_headerWidget->isVisible()) {
|
} else if (!visible && m_headerWidget->isVisible()) {
|
||||||
disconnect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged,
|
disconnect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged, this, &KItemListView::slotHeaderColumnWidthChanged);
|
||||||
this, &KItemListView::slotHeaderColumnWidthChanged);
|
disconnect(m_headerWidget, &KItemListHeaderWidget::sidePaddingChanged, this, &KItemListView::slotSidePaddingChanged);
|
||||||
disconnect(m_headerWidget, &KItemListHeaderWidget::sidePaddingChanged,
|
disconnect(m_headerWidget, &KItemListHeaderWidget::columnMoved, this, &KItemListView::slotHeaderColumnMoved);
|
||||||
this, &KItemListView::slotSidePaddingChanged);
|
disconnect(m_headerWidget, &KItemListHeaderWidget::sortOrderChanged, this, &KItemListView::sortOrderChanged);
|
||||||
disconnect(m_headerWidget, &KItemListHeaderWidget::columnMoved,
|
disconnect(m_headerWidget, &KItemListHeaderWidget::sortRoleChanged, this, &KItemListView::sortRoleChanged);
|
||||||
this, &KItemListView::slotHeaderColumnMoved);
|
|
||||||
disconnect(m_headerWidget, &KItemListHeaderWidget::sortOrderChanged,
|
|
||||||
this, &KItemListView::sortOrderChanged);
|
|
||||||
disconnect(m_headerWidget, &KItemListHeaderWidget::sortRoleChanged,
|
|
||||||
this, &KItemListView::sortRoleChanged);
|
|
||||||
|
|
||||||
m_layouter->setHeaderHeight(0);
|
m_layouter->setHeaderHeight(0);
|
||||||
m_headerWidget->setVisible(false);
|
m_headerWidget->setVisible(false);
|
||||||
|
@ -671,13 +655,10 @@ void KItemListView::editRole(int index, const QByteArray& role)
|
||||||
m_editingRole = true;
|
m_editingRole = true;
|
||||||
widget->setEditedRole(role);
|
widget->setEditedRole(role);
|
||||||
|
|
||||||
connect(widget, &KItemListWidget::roleEditingCanceled,
|
connect(widget, &KItemListWidget::roleEditingCanceled, this, &KItemListView::slotRoleEditingCanceled);
|
||||||
this, &KItemListView::slotRoleEditingCanceled);
|
connect(widget, &KItemListWidget::roleEditingFinished, this, &KItemListView::slotRoleEditingFinished);
|
||||||
connect(widget, &KItemListWidget::roleEditingFinished,
|
|
||||||
this, &KItemListView::slotRoleEditingFinished);
|
|
||||||
|
|
||||||
connect(this, &KItemListView::scrollOffsetChanged,
|
connect(this, &KItemListView::scrollOffsetChanged, widget, &KStandardItemListWidget::finishRoleEditing);
|
||||||
widget, &KStandardItemListWidget::finishRoleEditing);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KItemListView::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void KItemListView::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
|
@ -709,8 +690,7 @@ void KItemListView::paint(QPainter* painter, const QStyleOptionGraphicsItem* opt
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_rubberBand->isActive()) {
|
if (m_rubberBand->isActive()) {
|
||||||
QRectF rubberBandRect = QRectF(m_rubberBand->startPosition(),
|
QRectF rubberBandRect = QRectF(m_rubberBand->startPosition(), m_rubberBand->endPosition()).normalized();
|
||||||
m_rubberBand->endPosition()).normalized();
|
|
||||||
|
|
||||||
const QPointF topLeft = rubberBandRect.topLeft();
|
const QPointF topLeft = rubberBandRect.topLeft();
|
||||||
if (scrollOrientation() == Qt::Vertical) {
|
if (scrollOrientation() == Qt::Vertical) {
|
||||||
|
@ -729,8 +709,8 @@ void KItemListView::paint(QPainter* painter, const QStyleOptionGraphicsItem* opt
|
||||||
|
|
||||||
if (m_tapAndHoldIndicator->isActive()) {
|
if (m_tapAndHoldIndicator->isActive()) {
|
||||||
const QPointF indicatorSize = m_tapAndHoldIndicator->endPosition();
|
const QPointF indicatorSize = m_tapAndHoldIndicator->endPosition();
|
||||||
const QRectF rubberBandRect = QRectF(m_tapAndHoldIndicator->startPosition() - indicatorSize,
|
const QRectF rubberBandRect =
|
||||||
(m_tapAndHoldIndicator->startPosition()) + indicatorSize).normalized();
|
QRectF(m_tapAndHoldIndicator->startPosition() - indicatorSize, (m_tapAndHoldIndicator->startPosition()) + indicatorSize).normalized();
|
||||||
QStyleOptionRubberBand opt;
|
QStyleOptionRubberBand opt;
|
||||||
initStyleOption(&opt);
|
initStyleOption(&opt);
|
||||||
opt.shape = QRubberBand::Rectangle;
|
opt.shape = QRubberBand::Rectangle;
|
||||||
|
@ -776,13 +756,9 @@ void KItemListView::setItemSize(const QSizeF& size)
|
||||||
// Skip animations when the number of rows or columns
|
// Skip animations when the number of rows or columns
|
||||||
// are changed in the grid layout. Although the animation
|
// are changed in the grid layout. Although the animation
|
||||||
// engine can handle this usecase, it looks obtrusive.
|
// engine can handle this usecase, it looks obtrusive.
|
||||||
const bool animate = !changesItemGridLayout(m_layouter->size(),
|
const bool animate = !changesItemGridLayout(m_layouter->size(), size, m_layouter->itemMargin());
|
||||||
size,
|
|
||||||
m_layouter->itemMargin());
|
|
||||||
|
|
||||||
const bool alternateBackgroundsChanged = m_alternateBackgrounds &&
|
const bool alternateBackgroundsChanged = m_alternateBackgrounds && ((m_itemSize.isEmpty() && !size.isEmpty()) || (!m_itemSize.isEmpty() && size.isEmpty()));
|
||||||
(( m_itemSize.isEmpty() && !size.isEmpty()) ||
|
|
||||||
(!m_itemSize.isEmpty() && size.isEmpty()));
|
|
||||||
|
|
||||||
m_itemSize = size;
|
m_itemSize = size;
|
||||||
|
|
||||||
|
@ -827,9 +803,7 @@ void KItemListView::setStyleOption(const KItemListStyleOption& option)
|
||||||
// Skip animations when the number of rows or columns
|
// Skip animations when the number of rows or columns
|
||||||
// are changed in the grid layout. Although the animation
|
// are changed in the grid layout. Although the animation
|
||||||
// engine can handle this usecase, it looks obtrusive.
|
// engine can handle this usecase, it looks obtrusive.
|
||||||
animate = !changesItemGridLayout(m_layouter->size(),
|
animate = !changesItemGridLayout(m_layouter->size(), m_layouter->itemSize(), margin);
|
||||||
m_layouter->itemSize(),
|
|
||||||
margin);
|
|
||||||
m_layouter->setItemMargin(margin);
|
m_layouter->setItemMargin(margin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -837,8 +811,7 @@ void KItemListView::setStyleOption(const KItemListStyleOption& option)
|
||||||
updateGroupHeaderHeight();
|
updateGroupHeaderHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (animate &&
|
if (animate && (previousOption.maxTextLines != option.maxTextLines || previousOption.maxTextWidth != option.maxTextWidth)) {
|
||||||
(previousOption.maxTextLines != option.maxTextLines || previousOption.maxTextWidth != option.maxTextWidth)) {
|
|
||||||
// Animating a change of the maximum text size just results in expensive
|
// Animating a change of the maximum text size just results in expensive
|
||||||
// temporary eliding and clipping operations and does not look good visually.
|
// temporary eliding and clipping operations and does not look good visually.
|
||||||
animate = false;
|
animate = false;
|
||||||
|
@ -879,7 +852,6 @@ void KItemListView::setScrollOrientation(Qt::Orientation orientation)
|
||||||
it.value()->setScrollOrientation(orientation);
|
it.value()->setScrollOrientation(orientation);
|
||||||
}
|
}
|
||||||
updateGroupHeaderHeight();
|
updateGroupHeaderHeight();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
doLayout(NoAnimation);
|
doLayout(NoAnimation);
|
||||||
|
@ -1126,8 +1098,8 @@ void KItemListView::slotItemsInserted(const KItemRangeList& itemRanges)
|
||||||
// the size of the layouter will be decreased before calling doLayout(): This prevents
|
// the size of the layouter will be decreased before calling doLayout(): This prevents
|
||||||
// an unnecessary temporary animation due to the geometry change of the inserted scrollbar.
|
// an unnecessary temporary animation due to the geometry change of the inserted scrollbar.
|
||||||
const bool verticalScrollOrientation = (scrollOrientation() == Qt::Vertical);
|
const bool verticalScrollOrientation = (scrollOrientation() == Qt::Vertical);
|
||||||
const bool decreaseLayouterSize = ( verticalScrollOrientation && maximumScrollOffset() > size().height()) ||
|
const bool decreaseLayouterSize = (verticalScrollOrientation && maximumScrollOffset() > size().height())
|
||||||
(!verticalScrollOrientation && maximumScrollOffset() > size().width());
|
|| (!verticalScrollOrientation && maximumScrollOffset() > size().width());
|
||||||
if (decreaseLayouterSize) {
|
if (decreaseLayouterSize) {
|
||||||
const int scrollBarExtent = style()->pixelMetric(QStyle::PM_ScrollBarExtent);
|
const int scrollBarExtent = style()->pixelMetric(QStyle::PM_ScrollBarExtent);
|
||||||
|
|
||||||
|
@ -1317,8 +1289,7 @@ void KItemListView::slotItemsMoved(const KItemRange& itemRange, const QList<int>
|
||||||
updateSiblingsInformation();
|
updateSiblingsInformation();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KItemListView::slotItemsChanged(const KItemRangeList& itemRanges,
|
void KItemListView::slotItemsChanged(const KItemRangeList &itemRanges, const QSet<QByteArray> &roles)
|
||||||
const QSet<QByteArray>& roles)
|
|
||||||
{
|
{
|
||||||
const bool updateSizeHints = itemSizeHintUpdateRequired(roles);
|
const bool updateSizeHints = itemSizeHintUpdateRequired(roles);
|
||||||
if (updateSizeHints && m_itemSize.isEmpty()) {
|
if (updateSizeHints && m_itemSize.isEmpty()) {
|
||||||
|
@ -1451,8 +1422,7 @@ void KItemListView::slotSelectionChanged(const KItemSet& current, const KItemSet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KItemListView::slotAnimationFinished(QGraphicsWidget* widget,
|
void KItemListView::slotAnimationFinished(QGraphicsWidget *widget, KItemListViewAnimation::AnimationType type)
|
||||||
KItemListViewAnimation::AnimationType type)
|
|
||||||
{
|
{
|
||||||
KItemListWidget *itemListWidget = qobject_cast<KItemListWidget *>(widget);
|
KItemListWidget *itemListWidget = qobject_cast<KItemListWidget *>(widget);
|
||||||
Q_ASSERT(itemListWidget);
|
Q_ASSERT(itemListWidget);
|
||||||
|
@ -1470,8 +1440,7 @@ void KItemListView::slotAnimationFinished(QGraphicsWidget* widget,
|
||||||
widgetCreator()->recycle(itemListWidget);
|
widgetCreator()->recycle(itemListWidget);
|
||||||
} else {
|
} else {
|
||||||
const int index = itemListWidget->index();
|
const int index = itemListWidget->index();
|
||||||
const bool invisible = (index < m_layouter->firstVisibleIndex()) ||
|
const bool invisible = (index < m_layouter->firstVisibleIndex()) || (index > m_layouter->lastVisibleIndex());
|
||||||
(index > m_layouter->lastVisibleIndex());
|
|
||||||
if (invisible && !m_animation->isStarted(itemListWidget)) {
|
if (invisible && !m_animation->isStarted(itemListWidget)) {
|
||||||
recycleWidget(itemListWidget);
|
recycleWidget(itemListWidget);
|
||||||
}
|
}
|
||||||
|
@ -1490,8 +1459,7 @@ void KItemListView::slotRubberBandActivationChanged(bool active)
|
||||||
connect(m_rubberBand, &KItemListRubberBand::endPositionChanged, this, &KItemListView::slotRubberBandPosChanged);
|
connect(m_rubberBand, &KItemListRubberBand::endPositionChanged, this, &KItemListView::slotRubberBandPosChanged);
|
||||||
m_skipAutoScrollForRubberBand = true;
|
m_skipAutoScrollForRubberBand = true;
|
||||||
} else {
|
} else {
|
||||||
QRectF rubberBandRect = QRectF(m_rubberBand->startPosition(),
|
QRectF rubberBandRect = QRectF(m_rubberBand->startPosition(), m_rubberBand->endPosition()).normalized();
|
||||||
m_rubberBand->endPosition()).normalized();
|
|
||||||
|
|
||||||
auto animation = new QVariantAnimation(this);
|
auto animation = new QVariantAnimation(this);
|
||||||
animation->setStartValue(1.0);
|
animation->setStartValue(1.0);
|
||||||
|
@ -1522,9 +1490,7 @@ void KItemListView::slotRubberBandActivationChanged(bool active)
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KItemListView::slotHeaderColumnWidthChanged(const QByteArray& role,
|
void KItemListView::slotHeaderColumnWidthChanged(const QByteArray &role, qreal currentWidth, qreal previousWidth)
|
||||||
qreal currentWidth,
|
|
||||||
qreal previousWidth)
|
|
||||||
{
|
{
|
||||||
Q_UNUSED(role)
|
Q_UNUSED(role)
|
||||||
Q_UNUSED(currentWidth)
|
Q_UNUSED(currentWidth)
|
||||||
|
@ -1545,9 +1511,7 @@ void KItemListView::slotSidePaddingChanged(qreal width)
|
||||||
doLayout(NoAnimation);
|
doLayout(NoAnimation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KItemListView::slotHeaderColumnMoved(const QByteArray& role,
|
void KItemListView::slotHeaderColumnMoved(const QByteArray &role, int currentIndex, int previousIndex)
|
||||||
int currentIndex,
|
|
||||||
int previousIndex)
|
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_visibleRoles[previousIndex] == role);
|
Q_ASSERT(m_visibleRoles[previousIndex] == role);
|
||||||
|
|
||||||
|
@ -1597,8 +1561,7 @@ void KItemListView::triggerAutoScrolling()
|
||||||
// an autoscrolling.
|
// an autoscrolling.
|
||||||
|
|
||||||
const qreal minDiff = 4; // Ignore any autoscrolling if the rubberband is very small
|
const qreal minDiff = 4; // Ignore any autoscrolling if the rubberband is very small
|
||||||
const qreal diff = (scrollOrientation() == Qt::Vertical)
|
const qreal diff = (scrollOrientation() == Qt::Vertical) ? m_rubberBand->endPosition().y() - m_rubberBand->startPosition().y()
|
||||||
? m_rubberBand->endPosition().y() - m_rubberBand->startPosition().y()
|
|
||||||
: m_rubberBand->endPosition().x() - m_rubberBand->startPosition().x();
|
: m_rubberBand->endPosition().x() - m_rubberBand->startPosition().x();
|
||||||
if (qAbs(diff) < minDiff || (m_autoScrollIncrement < 0 && diff > 0) || (m_autoScrollIncrement > 0 && diff < 0)) {
|
if (qAbs(diff) < minDiff || (m_autoScrollIncrement < 0 && diff > 0) || (m_autoScrollIncrement > 0 && diff < 0)) {
|
||||||
// The rubberband direction is different from the scroll direction (e.g. the rubberband has
|
// The rubberband direction is different from the scroll direction (e.g. the rubberband has
|
||||||
|
@ -1677,22 +1640,14 @@ void KItemListView::setModel(KItemModelBase* model)
|
||||||
KItemModelBase *previous = m_model;
|
KItemModelBase *previous = m_model;
|
||||||
|
|
||||||
if (m_model) {
|
if (m_model) {
|
||||||
disconnect(m_model, &KItemModelBase::itemsChanged,
|
disconnect(m_model, &KItemModelBase::itemsChanged, this, &KItemListView::slotItemsChanged);
|
||||||
this, &KItemListView::slotItemsChanged);
|
disconnect(m_model, &KItemModelBase::itemsInserted, this, &KItemListView::slotItemsInserted);
|
||||||
disconnect(m_model, &KItemModelBase::itemsInserted,
|
disconnect(m_model, &KItemModelBase::itemsRemoved, this, &KItemListView::slotItemsRemoved);
|
||||||
this, &KItemListView::slotItemsInserted);
|
disconnect(m_model, &KItemModelBase::itemsMoved, this, &KItemListView::slotItemsMoved);
|
||||||
disconnect(m_model, &KItemModelBase::itemsRemoved,
|
disconnect(m_model, &KItemModelBase::groupsChanged, this, &KItemListView::slotGroupsChanged);
|
||||||
this, &KItemListView::slotItemsRemoved);
|
disconnect(m_model, &KItemModelBase::groupedSortingChanged, this, &KItemListView::slotGroupedSortingChanged);
|
||||||
disconnect(m_model, &KItemModelBase::itemsMoved,
|
disconnect(m_model, &KItemModelBase::sortOrderChanged, this, &KItemListView::slotSortOrderChanged);
|
||||||
this, &KItemListView::slotItemsMoved);
|
disconnect(m_model, &KItemModelBase::sortRoleChanged, this, &KItemListView::slotSortRoleChanged);
|
||||||
disconnect(m_model, &KItemModelBase::groupsChanged,
|
|
||||||
this, &KItemListView::slotGroupsChanged);
|
|
||||||
disconnect(m_model, &KItemModelBase::groupedSortingChanged,
|
|
||||||
this, &KItemListView::slotGroupedSortingChanged);
|
|
||||||
disconnect(m_model, &KItemModelBase::sortOrderChanged,
|
|
||||||
this, &KItemListView::slotSortOrderChanged);
|
|
||||||
disconnect(m_model, &KItemModelBase::sortRoleChanged,
|
|
||||||
this, &KItemListView::slotSortRoleChanged);
|
|
||||||
|
|
||||||
m_sizeHintResolver->itemsRemoved(KItemRangeList() << KItemRange(0, m_model->count()));
|
m_sizeHintResolver->itemsRemoved(KItemRangeList() << KItemRange(0, m_model->count()));
|
||||||
}
|
}
|
||||||
|
@ -1702,22 +1657,14 @@ void KItemListView::setModel(KItemModelBase* model)
|
||||||
m_grouped = model->groupedSorting();
|
m_grouped = model->groupedSorting();
|
||||||
|
|
||||||
if (m_model) {
|
if (m_model) {
|
||||||
connect(m_model, &KItemModelBase::itemsChanged,
|
connect(m_model, &KItemModelBase::itemsChanged, this, &KItemListView::slotItemsChanged);
|
||||||
this, &KItemListView::slotItemsChanged);
|
connect(m_model, &KItemModelBase::itemsInserted, this, &KItemListView::slotItemsInserted);
|
||||||
connect(m_model, &KItemModelBase::itemsInserted,
|
connect(m_model, &KItemModelBase::itemsRemoved, this, &KItemListView::slotItemsRemoved);
|
||||||
this, &KItemListView::slotItemsInserted);
|
connect(m_model, &KItemModelBase::itemsMoved, this, &KItemListView::slotItemsMoved);
|
||||||
connect(m_model, &KItemModelBase::itemsRemoved,
|
connect(m_model, &KItemModelBase::groupsChanged, this, &KItemListView::slotGroupsChanged);
|
||||||
this, &KItemListView::slotItemsRemoved);
|
connect(m_model, &KItemModelBase::groupedSortingChanged, this, &KItemListView::slotGroupedSortingChanged);
|
||||||
connect(m_model, &KItemModelBase::itemsMoved,
|
connect(m_model, &KItemModelBase::sortOrderChanged, this, &KItemListView::slotSortOrderChanged);
|
||||||
this, &KItemListView::slotItemsMoved);
|
connect(m_model, &KItemModelBase::sortRoleChanged, this, &KItemListView::slotSortRoleChanged);
|
||||||
connect(m_model, &KItemModelBase::groupsChanged,
|
|
||||||
this, &KItemListView::slotGroupsChanged);
|
|
||||||
connect(m_model, &KItemModelBase::groupedSortingChanged,
|
|
||||||
this, &KItemListView::slotGroupedSortingChanged);
|
|
||||||
connect(m_model, &KItemModelBase::sortOrderChanged,
|
|
||||||
this, &KItemListView::slotSortOrderChanged);
|
|
||||||
connect(m_model, &KItemModelBase::sortRoleChanged,
|
|
||||||
this, &KItemListView::slotSortRoleChanged);
|
|
||||||
|
|
||||||
const int itemCount = m_model->count();
|
const int itemCount = m_model->count();
|
||||||
if (itemCount > 0) {
|
if (itemCount > 0) {
|
||||||
|
@ -1805,8 +1752,7 @@ void KItemListView::doLayout(LayoutAnimationHint hint, int changedIndex, int cha
|
||||||
const int previousIndex = i - changedCount;
|
const int previousIndex = i - changedCount;
|
||||||
const QRectF itemRect = m_layouter->itemRect(previousIndex);
|
const QRectF itemRect = m_layouter->itemRect(previousIndex);
|
||||||
if (itemRect.isEmpty()) {
|
if (itemRect.isEmpty()) {
|
||||||
const QPointF invisibleOldPos = (scrollOrientation() == Qt::Vertical)
|
const QPointF invisibleOldPos = (scrollOrientation() == Qt::Vertical) ? QPointF(0, size().height()) : QPointF(size().width(), 0);
|
||||||
? QPointF(0, size().height()) : QPointF(size().width(), 0);
|
|
||||||
widget->setPos(invisibleOldPos);
|
widget->setPos(invisibleOldPos);
|
||||||
} else {
|
} else {
|
||||||
widget->setPos(itemRect.topLeft());
|
widget->setPos(itemRect.topLeft());
|
||||||
|
@ -1920,9 +1866,7 @@ void KItemListView::doLayout(LayoutAnimationHint hint, int changedIndex, int cha
|
||||||
emitOffsetChanges();
|
emitOffsetChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<int> KItemListView::recycleInvisibleItems(int firstVisibleIndex,
|
QList<int> KItemListView::recycleInvisibleItems(int firstVisibleIndex, int lastVisibleIndex, LayoutAnimationHint hint)
|
||||||
int lastVisibleIndex,
|
|
||||||
LayoutAnimationHint hint)
|
|
||||||
{
|
{
|
||||||
// Determine all items that are completely invisible and might be
|
// Determine all items that are completely invisible and might be
|
||||||
// reused for items that just got (at least partly) visible. If the
|
// reused for items that just got (at least partly) visible. If the
|
||||||
|
@ -2071,8 +2015,7 @@ void KItemListView::moveWidgetToIndex(KItemListWidget* widget, int index)
|
||||||
|
|
||||||
const Cell newCell(m_layouter->itemColumn(index), m_layouter->itemRow(index));
|
const Cell newCell(m_layouter->itemColumn(index), m_layouter->itemRow(index));
|
||||||
const bool vertical = (scrollOrientation() == Qt::Vertical);
|
const bool vertical = (scrollOrientation() == Qt::Vertical);
|
||||||
const bool updateCell = (vertical && oldCell.row == newCell.row) ||
|
const bool updateCell = (vertical && oldCell.row == newCell.row) || (!vertical && oldCell.column == newCell.column);
|
||||||
(!vertical && oldCell.column == newCell.column);
|
|
||||||
if (updateCell) {
|
if (updateCell) {
|
||||||
m_visibleCells.insert(index, newCell);
|
m_visibleCells.insert(index, newCell);
|
||||||
}
|
}
|
||||||
|
@ -2081,9 +2024,14 @@ void KItemListView::moveWidgetToIndex(KItemListWidget* widget, int index)
|
||||||
void KItemListView::setLayouterSize(const QSizeF &size, SizeType sizeType)
|
void KItemListView::setLayouterSize(const QSizeF &size, SizeType sizeType)
|
||||||
{
|
{
|
||||||
switch (sizeType) {
|
switch (sizeType) {
|
||||||
case LayouterSize: m_layouter->setSize(size); break;
|
case LayouterSize:
|
||||||
case ItemSize: m_layouter->setItemSize(size); break;
|
m_layouter->setSize(size);
|
||||||
default: break;
|
break;
|
||||||
|
case ItemSize:
|
||||||
|
m_layouter->setItemSize(size);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2317,8 +2265,7 @@ void KItemListView::applyColumnWidthsFromHeader()
|
||||||
{
|
{
|
||||||
// Apply the new size to the layouter
|
// Apply the new size to the layouter
|
||||||
const qreal requiredWidth = columnWidthsSum() + m_headerWidget->sidePadding();
|
const qreal requiredWidth = columnWidthsSum() + m_headerWidget->sidePadding();
|
||||||
const QSizeF dynamicItemSize(qMax(size().width(), requiredWidth),
|
const QSizeF dynamicItemSize(qMax(size().width(), requiredWidth), m_itemSize.height());
|
||||||
m_itemSize.height());
|
|
||||||
m_layouter->setItemSize(dynamicItemSize);
|
m_layouter->setItemSize(dynamicItemSize);
|
||||||
|
|
||||||
// Update the role sizes for all visible widgets
|
// Update the role sizes for all visible widgets
|
||||||
|
@ -2463,9 +2410,7 @@ QRectF KItemListView::headerBoundaries() const
|
||||||
return m_headerWidget->isVisible() ? m_headerWidget->geometry() : QRectF();
|
return m_headerWidget->isVisible() ? m_headerWidget->geometry() : QRectF();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KItemListView::changesItemGridLayout(const QSizeF& newGridSize,
|
bool KItemListView::changesItemGridLayout(const QSizeF &newGridSize, const QSizeF &newItemSize, const QSizeF &newItemMargin) const
|
||||||
const QSizeF& newItemSize,
|
|
||||||
const QSizeF& newItemMargin) const
|
|
||||||
{
|
{
|
||||||
if (newItemSize.isEmpty() || newGridSize.isEmpty()) {
|
if (newItemSize.isEmpty() || newGridSize.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -2474,26 +2419,18 @@ bool KItemListView::changesItemGridLayout(const QSizeF& newGridSize,
|
||||||
if (m_layouter->scrollOrientation() == Qt::Vertical) {
|
if (m_layouter->scrollOrientation() == Qt::Vertical) {
|
||||||
const qreal itemWidth = m_layouter->itemSize().width();
|
const qreal itemWidth = m_layouter->itemSize().width();
|
||||||
if (itemWidth > 0) {
|
if (itemWidth > 0) {
|
||||||
const int newColumnCount = itemsPerSize(newGridSize.width(),
|
const int newColumnCount = itemsPerSize(newGridSize.width(), newItemSize.width(), newItemMargin.width());
|
||||||
newItemSize.width(),
|
|
||||||
newItemMargin.width());
|
|
||||||
if (m_model->count() > newColumnCount) {
|
if (m_model->count() > newColumnCount) {
|
||||||
const int oldColumnCount = itemsPerSize(m_layouter->size().width(),
|
const int oldColumnCount = itemsPerSize(m_layouter->size().width(), itemWidth, m_layouter->itemMargin().width());
|
||||||
itemWidth,
|
|
||||||
m_layouter->itemMargin().width());
|
|
||||||
return oldColumnCount != newColumnCount;
|
return oldColumnCount != newColumnCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const qreal itemHeight = m_layouter->itemSize().height();
|
const qreal itemHeight = m_layouter->itemSize().height();
|
||||||
if (itemHeight > 0) {
|
if (itemHeight > 0) {
|
||||||
const int newRowCount = itemsPerSize(newGridSize.height(),
|
const int newRowCount = itemsPerSize(newGridSize.height(), newItemSize.height(), newItemMargin.height());
|
||||||
newItemSize.height(),
|
|
||||||
newItemMargin.height());
|
|
||||||
if (m_model->count() > newRowCount) {
|
if (m_model->count() > newRowCount) {
|
||||||
const int oldRowCount = itemsPerSize(m_layouter->size().height(),
|
const int oldRowCount = itemsPerSize(m_layouter->size().height(), itemHeight, m_layouter->itemMargin().height());
|
||||||
itemHeight,
|
|
||||||
m_layouter->itemMargin().height());
|
|
||||||
return oldRowCount != newRowCount;
|
return oldRowCount != newRowCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2514,14 +2451,12 @@ bool KItemListView::animateChangedItemCount(int changedItemCount) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int maximum = (scrollOrientation() == Qt::Vertical)
|
const int maximum = (scrollOrientation() == Qt::Vertical) ? m_layouter->size().width() / m_layouter->itemSize().width()
|
||||||
? m_layouter->size().width() / m_layouter->itemSize().width()
|
|
||||||
: m_layouter->size().height() / m_layouter->itemSize().height();
|
: m_layouter->size().height() / m_layouter->itemSize().height();
|
||||||
// Only animate if up to 2/3 of a row or column are inserted or removed
|
// Only animate if up to 2/3 of a row or column are inserted or removed
|
||||||
return changedItemCount <= maximum * 2 / 3;
|
return changedItemCount <= maximum * 2 / 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool KItemListView::scrollBarRequired(const QSizeF &size) const
|
bool KItemListView::scrollBarRequired(const QSizeF &size) const
|
||||||
{
|
{
|
||||||
const QSizeF oldSize = m_layouter->size();
|
const QSizeF oldSize = m_layouter->size();
|
||||||
|
@ -2530,8 +2465,7 @@ bool KItemListView::scrollBarRequired(const QSizeF& size) const
|
||||||
const qreal maxOffset = m_layouter->maximumScrollOffset();
|
const qreal maxOffset = m_layouter->maximumScrollOffset();
|
||||||
m_layouter->setSize(oldSize);
|
m_layouter->setSize(oldSize);
|
||||||
|
|
||||||
return m_layouter->scrollOrientation() == Qt::Vertical ? maxOffset > size.height()
|
return m_layouter->scrollOrientation() == Qt::Vertical ? maxOffset > size.height() : maxOffset > size.width();
|
||||||
: maxOffset > size.width();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int KItemListView::showDropIndicator(const QPointF &pos)
|
int KItemListView::showDropIndicator(const QPointF &pos)
|
||||||
|
@ -2615,8 +2549,7 @@ void KItemListView::updateSiblingsInformation(int firstIndex, int lastIndex)
|
||||||
firstIndex = m_layouter->firstVisibleIndex();
|
firstIndex = m_layouter->firstVisibleIndex();
|
||||||
lastIndex = m_layouter->lastVisibleIndex();
|
lastIndex = m_layouter->lastVisibleIndex();
|
||||||
} else {
|
} else {
|
||||||
const bool isRangeVisible = (firstIndex <= m_layouter->lastVisibleIndex() &&
|
const bool isRangeVisible = (firstIndex <= m_layouter->lastVisibleIndex() && lastIndex >= m_layouter->firstVisibleIndex());
|
||||||
lastIndex >= m_layouter->firstVisibleIndex());
|
|
||||||
if (!isRangeVisible) {
|
if (!isRangeVisible) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2777,8 +2710,6 @@ int KItemListView::itemsPerSize(qreal size, qreal itemSize, qreal itemMargin)
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
KItemListCreatorBase::~KItemListCreatorBase()
|
KItemListCreatorBase::~KItemListCreatorBase()
|
||||||
{
|
{
|
||||||
qDeleteAll(m_recycleableWidgets);
|
qDeleteAll(m_recycleableWidgets);
|
||||||
|
@ -2834,4 +2765,3 @@ void KItemListGroupHeaderCreatorBase::recycle(KItemListGroupHeader* header)
|
||||||
header->setOpacity(1.0);
|
header->setOpacity(1.0);
|
||||||
pushRecycleableWidget(header);
|
pushRecycleableWidget(header);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -403,8 +403,7 @@ protected Q_SLOTS:
|
||||||
virtual void slotItemsInserted(const KItemRangeList &itemRanges);
|
virtual void slotItemsInserted(const KItemRangeList &itemRanges);
|
||||||
virtual void slotItemsRemoved(const KItemRangeList &itemRanges);
|
virtual void slotItemsRemoved(const KItemRangeList &itemRanges);
|
||||||
virtual void slotItemsMoved(const KItemRange &itemRange, const QList<int> &movedToIndexes);
|
virtual void slotItemsMoved(const KItemRange &itemRange, const QList<int> &movedToIndexes);
|
||||||
virtual void slotItemsChanged(const KItemRangeList& itemRanges,
|
virtual void slotItemsChanged(const KItemRangeList &itemRanges, const QSet<QByteArray> &roles);
|
||||||
const QSet<QByteArray>& roles);
|
|
||||||
virtual void slotGroupsChanged();
|
virtual void slotGroupsChanged();
|
||||||
|
|
||||||
virtual void slotGroupedSortingChanged(bool current);
|
virtual void slotGroupedSortingChanged(bool current);
|
||||||
|
@ -414,8 +413,7 @@ protected Q_SLOTS:
|
||||||
virtual void slotSelectionChanged(const KItemSet ¤t, const KItemSet &previous);
|
virtual void slotSelectionChanged(const KItemSet ¤t, const KItemSet &previous);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void slotAnimationFinished(QGraphicsWidget* widget,
|
void slotAnimationFinished(QGraphicsWidget *widget, KItemListViewAnimation::AnimationType type);
|
||||||
KItemListViewAnimation::AnimationType type);
|
|
||||||
|
|
||||||
void slotRubberBandPosChanged();
|
void slotRubberBandPosChanged();
|
||||||
void slotRubberBandActivationChanged(bool active);
|
void slotRubberBandActivationChanged(bool active);
|
||||||
|
@ -426,9 +424,7 @@ private Q_SLOTS:
|
||||||
* will be turned off as soon as this method has been called at
|
* will be turned off as soon as this method has been called at
|
||||||
* least once.
|
* least once.
|
||||||
*/
|
*/
|
||||||
void slotHeaderColumnWidthChanged(const QByteArray& role,
|
void slotHeaderColumnWidthChanged(const QByteArray &role, qreal currentWidth, qreal previousWidth);
|
||||||
qreal currentWidth,
|
|
||||||
qreal previousWidth);
|
|
||||||
|
|
||||||
void slotSidePaddingChanged(qreal width);
|
void slotSidePaddingChanged(qreal width);
|
||||||
|
|
||||||
|
@ -436,9 +432,7 @@ private Q_SLOTS:
|
||||||
* Is invoked if a column has been moved by the user. Applies
|
* Is invoked if a column has been moved by the user. Applies
|
||||||
* the moved role to the view.
|
* the moved role to the view.
|
||||||
*/
|
*/
|
||||||
void slotHeaderColumnMoved(const QByteArray& role,
|
void slotHeaderColumnMoved(const QByteArray &role, int currentIndex, int previousIndex);
|
||||||
int currentIndex,
|
|
||||||
int previousIndex);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggers the autoscrolling if autoScroll() is enabled by checking the
|
* Triggers the autoscrolling if autoScroll() is enabled by checking the
|
||||||
|
@ -459,17 +453,9 @@ private Q_SLOTS:
|
||||||
void slotRoleEditingFinished(int index, const QByteArray &role, const QVariant &value);
|
void slotRoleEditingFinished(int index, const QByteArray &role, const QVariant &value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum LayoutAnimationHint
|
enum LayoutAnimationHint { NoAnimation, Animation };
|
||||||
{
|
|
||||||
NoAnimation,
|
|
||||||
Animation
|
|
||||||
};
|
|
||||||
|
|
||||||
enum SizeType
|
enum SizeType { LayouterSize, ItemSize };
|
||||||
{
|
|
||||||
LayouterSize,
|
|
||||||
ItemSize
|
|
||||||
};
|
|
||||||
|
|
||||||
void setController(KItemListController *controller);
|
void setController(KItemListController *controller);
|
||||||
void setModel(KItemModelBase *model);
|
void setModel(KItemModelBase *model);
|
||||||
|
@ -485,9 +471,7 @@ private:
|
||||||
* won't be reused. Reusing items is faster in comparison to deleting invisible
|
* won't be reused. Reusing items is faster in comparison to deleting invisible
|
||||||
* items and creating a new instance for visible items.
|
* items and creating a new instance for visible items.
|
||||||
*/
|
*/
|
||||||
QList<int> recycleInvisibleItems(int firstVisibleIndex,
|
QList<int> recycleInvisibleItems(int firstVisibleIndex, int lastVisibleIndex, LayoutAnimationHint hint);
|
||||||
int lastVisibleIndex,
|
|
||||||
LayoutAnimationHint hint);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method for doLayout: Starts a moving-animation for the widget to the given
|
* Helper method for doLayout: Starts a moving-animation for the widget to the given
|
||||||
|
@ -633,9 +617,7 @@ private:
|
||||||
* the new grid- and item-size. Used to determine whether an animation
|
* the new grid- and item-size. Used to determine whether an animation
|
||||||
* should be done when applying the new layout.
|
* should be done when applying the new layout.
|
||||||
*/
|
*/
|
||||||
bool changesItemGridLayout(const QSizeF& newGridSize,
|
bool changesItemGridLayout(const QSizeF &newGridSize, const QSizeF &newItemSize, const QSizeF &newItemMargin) const;
|
||||||
const QSizeF& newItemSize,
|
|
||||||
const QSizeF& newItemMargin) const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param changedItemCount Number of inserted or removed items.
|
* @param changedItemCount Number of inserted or removed items.
|
||||||
|
@ -731,10 +713,17 @@ private:
|
||||||
QHash<int, KItemListWidget *> m_visibleItems;
|
QHash<int, KItemListWidget *> m_visibleItems;
|
||||||
QHash<KItemListWidget *, KItemListGroupHeader *> m_visibleGroups;
|
QHash<KItemListWidget *, KItemListGroupHeader *> m_visibleGroups;
|
||||||
|
|
||||||
struct Cell
|
struct Cell {
|
||||||
|
Cell()
|
||||||
|
: column(-1)
|
||||||
|
, row(-1)
|
||||||
{
|
{
|
||||||
Cell() : column(-1), row(-1) {}
|
}
|
||||||
Cell(int c, int r) : column(c), row(r) {}
|
Cell(int c, int r)
|
||||||
|
: column(c)
|
||||||
|
, row(r)
|
||||||
|
{
|
||||||
|
}
|
||||||
int column;
|
int column;
|
||||||
int row;
|
int row;
|
||||||
};
|
};
|
||||||
|
@ -823,9 +812,7 @@ public:
|
||||||
|
|
||||||
virtual void calculateItemSizeHints(QVector<std::pair<qreal, bool>> &logicalHeightHints, qreal &logicalWidthHint, const KItemListView *view) const = 0;
|
virtual void calculateItemSizeHints(QVector<std::pair<qreal, bool>> &logicalHeightHints, qreal &logicalWidthHint, const KItemListView *view) const = 0;
|
||||||
|
|
||||||
virtual qreal preferredRoleColumnWidth(const QByteArray& role,
|
virtual qreal preferredRoleColumnWidth(const QByteArray &role, int index, const KItemListView *view) const = 0;
|
||||||
int index,
|
|
||||||
const KItemListView* view) const = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -842,16 +829,15 @@ public:
|
||||||
|
|
||||||
void calculateItemSizeHints(QVector<std::pair<qreal, bool>> &logicalHeightHints, qreal &logicalWidthHint, const KItemListView *view) const override;
|
void calculateItemSizeHints(QVector<std::pair<qreal, bool>> &logicalHeightHints, qreal &logicalWidthHint, const KItemListView *view) const override;
|
||||||
|
|
||||||
qreal preferredRoleColumnWidth(const QByteArray& role,
|
qreal preferredRoleColumnWidth(const QByteArray &role, int index, const KItemListView *view) const override;
|
||||||
int index,
|
|
||||||
const KItemListView* view) const override;
|
|
||||||
private:
|
private:
|
||||||
KItemListWidgetInformant *m_informant;
|
KItemListWidgetInformant *m_informant;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
KItemListWidgetCreator<T>::KItemListWidgetCreator() :
|
KItemListWidgetCreator<T>::KItemListWidgetCreator()
|
||||||
m_informant(T::createInformant())
|
: m_informant(T::createInformant())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -874,15 +860,15 @@ KItemListWidget* KItemListWidgetCreator<T>::create(KItemListView* view)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void KItemListWidgetCreator<T>::calculateItemSizeHints(QVector<std::pair<qreal, bool>>& logicalHeightHints, qreal& logicalWidthHint, const KItemListView* view) const
|
void KItemListWidgetCreator<T>::calculateItemSizeHints(QVector<std::pair<qreal, bool>> &logicalHeightHints,
|
||||||
|
qreal &logicalWidthHint,
|
||||||
|
const KItemListView *view) const
|
||||||
{
|
{
|
||||||
return m_informant->calculateItemSizeHints(logicalHeightHints, logicalWidthHint, view);
|
return m_informant->calculateItemSizeHints(logicalHeightHints, logicalWidthHint, view);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
qreal KItemListWidgetCreator<T>::preferredRoleColumnWidth(const QByteArray& role,
|
qreal KItemListWidgetCreator<T>::preferredRoleColumnWidth(const QByteArray &role, int index, const KItemListView *view) const
|
||||||
int index,
|
|
||||||
const KItemListView* view) const
|
|
||||||
{
|
{
|
||||||
return m_informant->preferredRoleColumnWidth(role, index, view);
|
return m_informant->preferredRoleColumnWidth(role, index, view);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,8 @@ KItemListView* KItemListViewAccessible::view() const
|
||||||
return qobject_cast<KItemListView *>(object());
|
return qobject_cast<KItemListView *>(object());
|
||||||
}
|
}
|
||||||
|
|
||||||
KItemListViewAccessible::KItemListViewAccessible(KItemListView* view_) :
|
KItemListViewAccessible::KItemListViewAccessible(KItemListView *view_)
|
||||||
QAccessibleObject(view_)
|
: QAccessibleObject(view_)
|
||||||
{
|
{
|
||||||
Q_ASSERT(view());
|
Q_ASSERT(view());
|
||||||
m_cells.resize(childCount());
|
m_cells.resize(childCount());
|
||||||
|
@ -185,7 +185,8 @@ bool KItemListViewAccessible::unselectColumn(int)
|
||||||
}
|
}
|
||||||
|
|
||||||
void KItemListViewAccessible::modelChange(QAccessibleTableModelChangeEvent * /*event*/)
|
void KItemListViewAccessible::modelChange(QAccessibleTableModelChangeEvent * /*event*/)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
QAccessible::Role KItemListViewAccessible::role() const
|
QAccessible::Role KItemListViewAccessible::role() const
|
||||||
{
|
{
|
||||||
|
@ -251,17 +252,17 @@ QAccessibleInterface* KItemListViewAccessible::child(int index) const
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
KItemListViewAccessible::AccessibleIdWrapper::AccessibleIdWrapper() :
|
KItemListViewAccessible::AccessibleIdWrapper::AccessibleIdWrapper()
|
||||||
isValid(false),
|
: isValid(false)
|
||||||
id(0)
|
, id(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Table Cell
|
// Table Cell
|
||||||
|
|
||||||
KItemListAccessibleCell::KItemListAccessibleCell(KItemListView* view, int index) :
|
KItemListAccessibleCell::KItemListAccessibleCell(KItemListView *view, int index)
|
||||||
m_view(view),
|
: m_view(view)
|
||||||
m_index(index)
|
, m_index(index)
|
||||||
{
|
{
|
||||||
Q_ASSERT(index >= 0 && index < view->model()->count());
|
Q_ASSERT(index >= 0 && index < view->model()->count());
|
||||||
}
|
}
|
||||||
|
@ -427,8 +428,8 @@ QObject* KItemListAccessibleCell::object() const
|
||||||
}
|
}
|
||||||
|
|
||||||
// Container Interface
|
// Container Interface
|
||||||
KItemListContainerAccessible::KItemListContainerAccessible(KItemListContainer* container) :
|
KItemListContainerAccessible::KItemListContainerAccessible(KItemListContainer *container)
|
||||||
QAccessibleWidget(container)
|
: QAccessibleWidget(container)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,8 @@ protected:
|
||||||
inline QAccessibleInterface *cell(int index) const;
|
inline QAccessibleInterface *cell(int index) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class AccessibleIdWrapper {
|
class AccessibleIdWrapper
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
AccessibleIdWrapper();
|
AccessibleIdWrapper();
|
||||||
bool isValid;
|
bool isValid;
|
||||||
|
|
|
@ -27,28 +27,28 @@ KItemListWidgetInformant::~KItemListWidgetInformant()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
KItemListWidget::KItemListWidget(KItemListWidgetInformant* informant, QGraphicsItem* parent) :
|
KItemListWidget::KItemListWidget(KItemListWidgetInformant *informant, QGraphicsItem *parent)
|
||||||
QGraphicsWidget(parent),
|
: QGraphicsWidget(parent)
|
||||||
m_informant(informant),
|
, m_informant(informant)
|
||||||
m_index(-1),
|
, m_index(-1)
|
||||||
m_selected(false),
|
, m_selected(false)
|
||||||
m_current(false),
|
, m_current(false)
|
||||||
m_hovered(false),
|
, m_hovered(false)
|
||||||
m_expansionAreaHovered(false),
|
, m_expansionAreaHovered(false)
|
||||||
m_alternateBackground(false),
|
, m_alternateBackground(false)
|
||||||
m_enabledSelectionToggle(false),
|
, m_enabledSelectionToggle(false)
|
||||||
m_data(),
|
, m_data()
|
||||||
m_visibleRoles(),
|
, m_visibleRoles()
|
||||||
m_columnWidths(),
|
, m_columnWidths()
|
||||||
m_styleOption(),
|
, m_styleOption()
|
||||||
m_siblingsInfo(),
|
, m_siblingsInfo()
|
||||||
m_hoverOpacity(0),
|
, m_hoverOpacity(0)
|
||||||
m_hoverCache(nullptr),
|
, m_hoverCache(nullptr)
|
||||||
m_hoverAnimation(nullptr),
|
, m_hoverAnimation(nullptr)
|
||||||
m_hoverSequenceIndex(0),
|
, m_hoverSequenceIndex(0)
|
||||||
m_selectionToggle(nullptr),
|
, m_selectionToggle(nullptr)
|
||||||
m_editedRole(),
|
, m_editedRole()
|
||||||
m_iconSize(-1)
|
, m_iconSize(-1)
|
||||||
{
|
{
|
||||||
connect(&m_hoverSequenceTimer, &QTimer::timeout, this, &KItemListWidget::slotHoverSequenceTimerTimeout);
|
connect(&m_hoverSequenceTimer, &QTimer::timeout, this, &KItemListWidget::slotHoverSequenceTimerTimeout);
|
||||||
}
|
}
|
||||||
|
@ -79,8 +79,7 @@ int KItemListWidget::index() const
|
||||||
return m_index;
|
return m_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KItemListWidget::setData(const QHash<QByteArray, QVariant>& data,
|
void KItemListWidget::setData(const QHash<QByteArray, QVariant> &data, const QSet<QByteArray> &roles)
|
||||||
const QSet<QByteArray>& roles)
|
|
||||||
{
|
{
|
||||||
clearHoverCache();
|
clearHoverCache();
|
||||||
if (roles.isEmpty()) {
|
if (roles.isEmpty()) {
|
||||||
|
@ -112,10 +111,7 @@ void KItemListWidget::paint(QPainter* painter, const QStyleOptionGraphicsItem* o
|
||||||
|
|
||||||
if (m_selected && m_editedRole.isEmpty()) {
|
if (m_selected && m_editedRole.isEmpty()) {
|
||||||
const QStyle::State activeState(isActiveWindow() ? QStyle::State_Active : 0);
|
const QStyle::State activeState(isActiveWindow() ? QStyle::State_Active : 0);
|
||||||
drawItemStyleOption(painter, widget, activeState |
|
drawItemStyleOption(painter, widget, activeState | QStyle::State_Enabled | QStyle::State_Selected | QStyle::State_Item);
|
||||||
QStyle::State_Enabled |
|
|
||||||
QStyle::State_Selected |
|
|
||||||
QStyle::State_Item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_current && m_editedRole.isEmpty()) {
|
if (m_current && m_editedRole.isEmpty()) {
|
||||||
|
@ -139,10 +135,7 @@ void KItemListWidget::paint(QPainter* painter, const QStyleOptionGraphicsItem* o
|
||||||
|
|
||||||
QPainter pixmapPainter(m_hoverCache);
|
QPainter pixmapPainter(m_hoverCache);
|
||||||
const QStyle::State activeState(isActiveWindow() ? QStyle::State_Active : 0);
|
const QStyle::State activeState(isActiveWindow() ? QStyle::State_Active : 0);
|
||||||
drawItemStyleOption(&pixmapPainter, widget, activeState |
|
drawItemStyleOption(&pixmapPainter, widget, activeState | QStyle::State_Enabled | QStyle::State_MouseOver | QStyle::State_Item);
|
||||||
QStyle::State_Enabled |
|
|
||||||
QStyle::State_MouseOver |
|
|
||||||
QStyle::State_Item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const qreal opacity = painter->opacity();
|
const qreal opacity = painter->opacity();
|
||||||
|
@ -166,7 +159,6 @@ QList<QByteArray> KItemListWidget::visibleRoles() const
|
||||||
return m_visibleRoles;
|
return m_visibleRoles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void KItemListWidget::setColumnWidth(const QByteArray &role, qreal width)
|
void KItemListWidget::setColumnWidth(const QByteArray &role, qreal width)
|
||||||
{
|
{
|
||||||
const qreal previousWidth = m_columnWidths.value(role);
|
const qreal previousWidth = m_columnWidths.value(role);
|
||||||
|
@ -182,11 +174,13 @@ qreal KItemListWidget::columnWidth(const QByteArray& role) const
|
||||||
return m_columnWidths.value(role);
|
return m_columnWidths.value(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal KItemListWidget::sidePadding() const {
|
qreal KItemListWidget::sidePadding() const
|
||||||
|
{
|
||||||
return m_sidePadding;
|
return m_sidePadding;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KItemListWidget::setSidePadding(qreal width) {
|
void KItemListWidget::setSidePadding(qreal width)
|
||||||
|
{
|
||||||
if (m_sidePadding != width) {
|
if (m_sidePadding != width) {
|
||||||
m_sidePadding = width;
|
m_sidePadding = width;
|
||||||
sidePaddingChanged(width);
|
sidePaddingChanged(width);
|
||||||
|
@ -400,10 +394,7 @@ bool KItemListWidget::contains(const QPointF& point) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return iconRect().contains(point) ||
|
return iconRect().contains(point) || textRect().contains(point) || expansionToggleRect().contains(point) || selectionToggleRect().contains(point);
|
||||||
textRect().contains(point) ||
|
|
||||||
expansionToggleRect().contains(point) ||
|
|
||||||
selectionToggleRect().contains(point);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF KItemListWidget::textFocusRect() const
|
QRectF KItemListWidget::textFocusRect() const
|
||||||
|
@ -421,8 +412,7 @@ QRectF KItemListWidget::expansionToggleRect() const
|
||||||
return QRectF();
|
return QRectF();
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap KItemListWidget::createDragPixmap(const QStyleOptionGraphicsItem* option,
|
QPixmap KItemListWidget::createDragPixmap(const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
QWidget* widget)
|
|
||||||
{
|
{
|
||||||
QPixmap pixmap(size().toSize() * widget->devicePixelRatio());
|
QPixmap pixmap(size().toSize() * widget->devicePixelRatio());
|
||||||
pixmap.setDevicePixelRatio(widget->devicePixelRatio());
|
pixmap.setDevicePixelRatio(widget->devicePixelRatio());
|
||||||
|
@ -446,23 +436,19 @@ QPixmap KItemListWidget::createDragPixmap(const QStyleOptionGraphicsItem* option
|
||||||
return pixmap;
|
return pixmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KItemListWidget::dataChanged(const QHash<QByteArray, QVariant>& current,
|
void KItemListWidget::dataChanged(const QHash<QByteArray, QVariant> ¤t, const QSet<QByteArray> &roles)
|
||||||
const QSet<QByteArray>& roles)
|
|
||||||
{
|
{
|
||||||
Q_UNUSED(current)
|
Q_UNUSED(current)
|
||||||
Q_UNUSED(roles)
|
Q_UNUSED(roles)
|
||||||
}
|
}
|
||||||
|
|
||||||
void KItemListWidget::visibleRolesChanged(const QList<QByteArray>& current,
|
void KItemListWidget::visibleRolesChanged(const QList<QByteArray> ¤t, const QList<QByteArray> &previous)
|
||||||
const QList<QByteArray>& previous)
|
|
||||||
{
|
{
|
||||||
Q_UNUSED(current)
|
Q_UNUSED(current)
|
||||||
Q_UNUSED(previous)
|
Q_UNUSED(previous)
|
||||||
}
|
}
|
||||||
|
|
||||||
void KItemListWidget::columnWidthChanged(const QByteArray& role,
|
void KItemListWidget::columnWidthChanged(const QByteArray &role, qreal current, qreal previous)
|
||||||
qreal current,
|
|
||||||
qreal previous)
|
|
||||||
{
|
{
|
||||||
Q_UNUSED(role)
|
Q_UNUSED(role)
|
||||||
Q_UNUSED(current)
|
Q_UNUSED(current)
|
||||||
|
@ -474,8 +460,7 @@ void KItemListWidget::sidePaddingChanged(qreal width)
|
||||||
Q_UNUSED(width)
|
Q_UNUSED(width)
|
||||||
}
|
}
|
||||||
|
|
||||||
void KItemListWidget::styleOptionChanged(const KItemListStyleOption& current,
|
void KItemListWidget::styleOptionChanged(const KItemListStyleOption ¤t, const KItemListStyleOption &previous)
|
||||||
const KItemListStyleOption& previous)
|
|
||||||
{
|
{
|
||||||
Q_UNUSED(previous)
|
Q_UNUSED(previous)
|
||||||
|
|
||||||
|
@ -618,4 +603,3 @@ void KItemListWidget::drawItemStyleOption(QPainter* painter, QWidget* widget, QS
|
||||||
viewItemOption.rect = selectionRect().toRect();
|
viewItemOption.rect = selectionRect().toRect();
|
||||||
style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &viewItemOption, painter, widget);
|
style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &viewItemOption, painter, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,9 +37,7 @@ public:
|
||||||
|
|
||||||
virtual void calculateItemSizeHints(QVector<std::pair<qreal, bool>> &logicalHeightHints, qreal &logicalWidthHint, const KItemListView *view) const = 0;
|
virtual void calculateItemSizeHints(QVector<std::pair<qreal, bool>> &logicalHeightHints, qreal &logicalWidthHint, const KItemListView *view) const = 0;
|
||||||
|
|
||||||
virtual qreal preferredRoleColumnWidth(const QByteArray& role,
|
virtual qreal preferredRoleColumnWidth(const QByteArray &role, int index, const KItemListView *view) const = 0;
|
||||||
int index,
|
|
||||||
const KItemListView* view) const = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -282,5 +280,3 @@ inline const KItemListWidgetInformant* KItemListWidget::informant() const
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,19 +8,19 @@
|
||||||
|
|
||||||
#include "kitemmodelbase.h"
|
#include "kitemmodelbase.h"
|
||||||
|
|
||||||
KItemModelBase::KItemModelBase(QObject* parent) :
|
KItemModelBase::KItemModelBase(QObject *parent)
|
||||||
QObject(parent),
|
: QObject(parent)
|
||||||
m_groupedSorting(false),
|
, m_groupedSorting(false)
|
||||||
m_sortRole(),
|
, m_sortRole()
|
||||||
m_sortOrder(Qt::AscendingOrder)
|
, m_sortOrder(Qt::AscendingOrder)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
KItemModelBase::KItemModelBase(const QByteArray& sortRole, QObject* parent) :
|
KItemModelBase::KItemModelBase(const QByteArray &sortRole, QObject *parent)
|
||||||
QObject(parent),
|
: QObject(parent)
|
||||||
m_groupedSorting(false),
|
, m_groupedSorting(false)
|
||||||
m_sortRole(sortRole),
|
, m_sortRole(sortRole)
|
||||||
m_sortOrder(Qt::AscendingOrder)
|
, m_sortOrder(Qt::AscendingOrder)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -279,5 +279,3 @@ inline Qt::SortOrder KItemModelBase::sortOrder() const
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,7 @@
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
struct KItemRange
|
struct KItemRange {
|
||||||
{
|
|
||||||
KItemRange(int index = 0, int count = 0);
|
KItemRange(int index = 0, int count = 0);
|
||||||
int index;
|
int index;
|
||||||
int count;
|
int count;
|
||||||
|
@ -21,9 +20,9 @@ struct KItemRange
|
||||||
bool operator==(const KItemRange &other) const;
|
bool operator==(const KItemRange &other) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline KItemRange::KItemRange(int index, int count) :
|
inline KItemRange::KItemRange(int index, int count)
|
||||||
index(index),
|
: index(index)
|
||||||
count(count)
|
, count(count)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,12 +31,17 @@ inline bool KItemRange::operator == (const KItemRange& other) const
|
||||||
return index == other.index && count == other.count;
|
return index == other.index && count == other.count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class KItemRangeList : public QList<KItemRange>
|
class KItemRangeList : public QList<KItemRange>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KItemRangeList() : QList<KItemRange>() {}
|
KItemRangeList()
|
||||||
explicit KItemRangeList(const QList<KItemRange>& list) : QList<KItemRange>(list) {}
|
: QList<KItemRange>()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
explicit KItemRangeList(const QList<KItemRange> &list)
|
||||||
|
: QList<KItemRange>(list)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
template<class Container>
|
template<class Container>
|
||||||
static KItemRangeList fromSortedContainer(const Container &container);
|
static KItemRangeList fromSortedContainer(const Container &container);
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#include "kitemset.h"
|
#include "kitemset.h"
|
||||||
|
|
||||||
|
|
||||||
KItemSet::iterator KItemSet::insert(int i)
|
KItemSet::iterator KItemSet::insert(int i)
|
||||||
{
|
{
|
||||||
if (m_itemRanges.empty()) {
|
if (m_itemRanges.empty()) {
|
||||||
|
@ -170,8 +169,7 @@ KItemSet KItemSet::operator+(const KItemSet& other) const
|
||||||
count = qMax(count, it2->index + it2->count - index);
|
count = qMax(count, it2->index + it2->count - index);
|
||||||
++it2;
|
++it2;
|
||||||
}
|
}
|
||||||
} while ((it1 != end1 && it1->index <= index + count)
|
} while ((it1 != end1 && it1->index <= index + count) || (it2 != end2 && it2->index <= index + count));
|
||||||
|| (it2 != end2 && it2->index <= index + count));
|
|
||||||
|
|
||||||
sum.m_itemRanges.append(KItemRange(index, count));
|
sum.m_itemRanges.append(KItemRange(index, count));
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef KITEMSET_H
|
#ifndef KITEMSET_H
|
||||||
#define KITEMSET_H
|
#define KITEMSET_H
|
||||||
|
|
||||||
|
@ -51,16 +50,16 @@ public:
|
||||||
|
|
||||||
class iterator
|
class iterator
|
||||||
{
|
{
|
||||||
iterator(const KItemRangeList::iterator& rangeIt, int offset) :
|
iterator(const KItemRangeList::iterator &rangeIt, int offset)
|
||||||
m_rangeIt(rangeIt),
|
: m_rangeIt(rangeIt)
|
||||||
m_offset(offset)
|
, m_offset(offset)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
iterator(const iterator& other) :
|
iterator(const iterator &other)
|
||||||
m_rangeIt(other.m_rangeIt),
|
: m_rangeIt(other.m_rangeIt)
|
||||||
m_offset(other.m_offset)
|
, m_offset(other.m_offset)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,25 +133,24 @@ public:
|
||||||
friend class KItemSet;
|
friend class KItemSet;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class const_iterator
|
class const_iterator
|
||||||
{
|
{
|
||||||
const_iterator(KItemRangeList::const_iterator rangeIt, int offset) :
|
const_iterator(KItemRangeList::const_iterator rangeIt, int offset)
|
||||||
m_rangeIt(rangeIt),
|
: m_rangeIt(rangeIt)
|
||||||
m_offset(offset)
|
, m_offset(offset)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const_iterator(const const_iterator& other) :
|
const_iterator(const const_iterator &other)
|
||||||
m_rangeIt(other.m_rangeIt),
|
: m_rangeIt(other.m_rangeIt)
|
||||||
m_offset(other.m_offset)
|
, m_offset(other.m_offset)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit const_iterator(const iterator& other) :
|
explicit const_iterator(const iterator &other)
|
||||||
m_rangeIt(other.m_rangeIt),
|
: m_rangeIt(other.m_rangeIt)
|
||||||
m_offset(other.m_offset)
|
, m_offset(other.m_offset)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,13 +280,13 @@ private:
|
||||||
friend class KItemSetTest;
|
friend class KItemSetTest;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline KItemSet::KItemSet() :
|
inline KItemSet::KItemSet()
|
||||||
m_itemRanges()
|
: m_itemRanges()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
inline KItemSet::KItemSet(const KItemSet& other) :
|
inline KItemSet::KItemSet(const KItemSet &other)
|
||||||
m_itemRanges(other.m_itemRanges)
|
: m_itemRanges(other.m_itemRanges)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,13 +11,12 @@
|
||||||
#include <KRatingPainter>
|
#include <KRatingPainter>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
KStandardItemListGroupHeader::KStandardItemListGroupHeader(QGraphicsWidget* parent) :
|
KStandardItemListGroupHeader::KStandardItemListGroupHeader(QGraphicsWidget *parent)
|
||||||
KItemListGroupHeader(parent),
|
: KItemListGroupHeader(parent)
|
||||||
m_dirtyCache(true),
|
, m_dirtyCache(true)
|
||||||
m_text(),
|
, m_text()
|
||||||
m_pixmap()
|
, m_pixmap()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KStandardItemListGroupHeader::~KStandardItemListGroupHeader()
|
KStandardItemListGroupHeader::~KStandardItemListGroupHeader()
|
||||||
|
@ -110,4 +109,3 @@ void KStandardItemListGroupHeader::updateCache()
|
||||||
m_text = text;
|
m_text = text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,5 +38,3 @@ private:
|
||||||
QPixmap m_pixmap;
|
QPixmap m_pixmap;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
|
|
||||||
#include <KIconLoader>
|
#include <KIconLoader>
|
||||||
|
|
||||||
KStandardItemListView::KStandardItemListView(QGraphicsWidget* parent) :
|
KStandardItemListView::KStandardItemListView(QGraphicsWidget *parent)
|
||||||
KItemListView(parent),
|
: KItemListView(parent)
|
||||||
m_itemLayout(DetailsLayout)
|
, m_itemLayout(DetailsLayout)
|
||||||
{
|
{
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
setScrollOrientation(Qt::Vertical);
|
setScrollOrientation(Qt::Vertical);
|
||||||
|
@ -66,17 +66,24 @@ void KStandardItemListView::initializeItemListWidget(KItemListWidget* item)
|
||||||
Q_ASSERT(standardItemListWidget);
|
Q_ASSERT(standardItemListWidget);
|
||||||
|
|
||||||
switch (itemLayout()) {
|
switch (itemLayout()) {
|
||||||
case IconsLayout: standardItemListWidget->setLayout(KStandardItemListWidget::IconsLayout); break;
|
case IconsLayout:
|
||||||
case CompactLayout: standardItemListWidget->setLayout(KStandardItemListWidget::CompactLayout); break;
|
standardItemListWidget->setLayout(KStandardItemListWidget::IconsLayout);
|
||||||
case DetailsLayout: standardItemListWidget->setLayout(KStandardItemListWidget::DetailsLayout); break;
|
break;
|
||||||
default: Q_ASSERT(false); break;
|
case CompactLayout:
|
||||||
|
standardItemListWidget->setLayout(KStandardItemListWidget::CompactLayout);
|
||||||
|
break;
|
||||||
|
case DetailsLayout:
|
||||||
|
standardItemListWidget->setLayout(KStandardItemListWidget::DetailsLayout);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Q_ASSERT(false);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
standardItemListWidget->setHighlightEntireRow(highlightEntireRow());
|
standardItemListWidget->setHighlightEntireRow(highlightEntireRow());
|
||||||
standardItemListWidget->setSupportsItemExpanding(supportsItemExpanding());
|
standardItemListWidget->setSupportsItemExpanding(supportsItemExpanding());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool KStandardItemListView::itemSizeHintUpdateRequired(const QSet<QByteArray> &changedRoles) const
|
bool KStandardItemListView::itemSizeHintUpdateRequired(const QSet<QByteArray> &changedRoles) const
|
||||||
{
|
{
|
||||||
// The only thing that can modify the item's size hint is the amount of space
|
// The only thing that can modify the item's size hint is the amount of space
|
||||||
|
@ -123,23 +130,27 @@ void KStandardItemListView::onSupportsItemExpandingChanged(bool supportsExpandin
|
||||||
updateLayoutOfVisibleItems();
|
updateLayoutOfVisibleItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void KStandardItemListView::polishEvent()
|
void KStandardItemListView::polishEvent()
|
||||||
{
|
{
|
||||||
switch (m_itemLayout) {
|
switch (m_itemLayout) {
|
||||||
case IconsLayout: applyDefaultStyleOption(style()->pixelMetric(QStyle::PM_LargeIconSize), 2, 4, 8); break;
|
case IconsLayout:
|
||||||
case CompactLayout: applyDefaultStyleOption(style()->pixelMetric(QStyle::PM_SmallIconSize), 2, 8, 0); break;
|
applyDefaultStyleOption(style()->pixelMetric(QStyle::PM_LargeIconSize), 2, 4, 8);
|
||||||
case DetailsLayout: applyDefaultStyleOption(style()->pixelMetric(QStyle::PM_SmallIconSize), 2, 0, 0); break;
|
break;
|
||||||
default: Q_ASSERT(false); break;
|
case CompactLayout:
|
||||||
|
applyDefaultStyleOption(style()->pixelMetric(QStyle::PM_SmallIconSize), 2, 8, 0);
|
||||||
|
break;
|
||||||
|
case DetailsLayout:
|
||||||
|
applyDefaultStyleOption(style()->pixelMetric(QStyle::PM_SmallIconSize), 2, 0, 0);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Q_ASSERT(false);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
QGraphicsWidget::polishEvent();
|
QGraphicsWidget::polishEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KStandardItemListView::applyDefaultStyleOption(int iconSize,
|
void KStandardItemListView::applyDefaultStyleOption(int iconSize, int padding, int horizontalMargin, int verticalMargin)
|
||||||
int padding,
|
|
||||||
int horizontalMargin,
|
|
||||||
int verticalMargin)
|
|
||||||
{
|
{
|
||||||
KItemListStyleOption option = styleOption();
|
KItemListStyleOption option = styleOption();
|
||||||
|
|
||||||
|
@ -168,4 +179,3 @@ void KStandardItemListView::updateLayoutOfVisibleItems()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,12 +31,7 @@ class DOLPHIN_EXPORT KStandardItemListView : public KItemListView
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum ItemLayout
|
enum ItemLayout { IconsLayout, CompactLayout, DetailsLayout };
|
||||||
{
|
|
||||||
IconsLayout,
|
|
||||||
CompactLayout,
|
|
||||||
DetailsLayout
|
|
||||||
};
|
|
||||||
|
|
||||||
explicit KStandardItemListView(QGraphicsWidget *parent = nullptr);
|
explicit KStandardItemListView(QGraphicsWidget *parent = nullptr);
|
||||||
~KStandardItemListView() override;
|
~KStandardItemListView() override;
|
||||||
|
@ -66,5 +61,3 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,8 @@
|
||||||
|
|
||||||
// #define KSTANDARDITEMLISTWIDGET_DEBUG
|
// #define KSTANDARDITEMLISTWIDGET_DEBUG
|
||||||
|
|
||||||
KStandardItemListWidgetInformant::KStandardItemListWidgetInformant() :
|
KStandardItemListWidgetInformant::KStandardItemListWidgetInformant()
|
||||||
KItemListWidgetInformant()
|
: KItemListWidgetInformant()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,9 @@ KStandardItemListWidgetInformant::~KStandardItemListWidgetInformant()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void KStandardItemListWidgetInformant::calculateItemSizeHints(QVector<std::pair<qreal, bool>>& logicalHeightHints, qreal& logicalWidthHint, const KItemListView* view) const
|
void KStandardItemListWidgetInformant::calculateItemSizeHints(QVector<std::pair<qreal, bool>> &logicalHeightHints,
|
||||||
|
qreal &logicalWidthHint,
|
||||||
|
const KItemListView *view) const
|
||||||
{
|
{
|
||||||
switch (static_cast<const KStandardItemListView *>(view)->itemLayout()) {
|
switch (static_cast<const KStandardItemListView *>(view)->itemLayout()) {
|
||||||
case KStandardItemListView::IconsLayout:
|
case KStandardItemListView::IconsLayout:
|
||||||
|
@ -56,9 +58,7 @@ void KStandardItemListWidgetInformant::calculateItemSizeHints(QVector<std::pair<
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal KStandardItemListWidgetInformant::preferredRoleColumnWidth(const QByteArray& role,
|
qreal KStandardItemListWidgetInformant::preferredRoleColumnWidth(const QByteArray &role, int index, const KItemListView *view) const
|
||||||
int index,
|
|
||||||
const KItemListView* view) const
|
|
||||||
{
|
{
|
||||||
const QHash<QByteArray, QVariant> values = view->model()->data(index);
|
const QHash<QByteArray, QVariant> values = view->model()->data(index);
|
||||||
const KItemListStyleOption &option = view->styleOption();
|
const KItemListStyleOption &option = view->styleOption();
|
||||||
|
@ -105,8 +105,7 @@ bool KStandardItemListWidgetInformant::itemIsLink(int index, const KItemListView
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString KStandardItemListWidgetInformant::roleText(const QByteArray& role,
|
QString KStandardItemListWidgetInformant::roleText(const QByteArray &role, const QHash<QByteArray, QVariant> &values) const
|
||||||
const QHash<QByteArray, QVariant>& values) const
|
|
||||||
{
|
{
|
||||||
if (role == "rating") {
|
if (role == "rating") {
|
||||||
// Always use an empty text, as the rating is shown by the image m_rating.
|
// Always use an empty text, as the rating is shown by the image m_rating.
|
||||||
|
@ -120,7 +119,9 @@ QFont KStandardItemListWidgetInformant::customizedFontForLinks(const QFont& base
|
||||||
return baseFont;
|
return baseFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KStandardItemListWidgetInformant::calculateIconsLayoutItemSizeHints(QVector<std::pair<qreal, bool>>& logicalHeightHints, qreal& logicalWidthHint, const KItemListView* view) const
|
void KStandardItemListWidgetInformant::calculateIconsLayoutItemSizeHints(QVector<std::pair<qreal, bool>> &logicalHeightHints,
|
||||||
|
qreal &logicalWidthHint,
|
||||||
|
const KItemListView *view) const
|
||||||
{
|
{
|
||||||
const KItemListStyleOption &option = view->styleOption();
|
const KItemListStyleOption &option = view->styleOption();
|
||||||
const QFont &normalFont = option.font;
|
const QFont &normalFont = option.font;
|
||||||
|
@ -177,7 +178,9 @@ void KStandardItemListWidgetInformant::calculateIconsLayoutItemSizeHints(QVector
|
||||||
logicalWidthHint = itemWidth;
|
logicalWidthHint = itemWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KStandardItemListWidgetInformant::calculateCompactLayoutItemSizeHints(QVector<std::pair<qreal, bool>>& logicalHeightHints, qreal& logicalWidthHint, const KItemListView* view) const
|
void KStandardItemListWidgetInformant::calculateCompactLayoutItemSizeHints(QVector<std::pair<qreal, bool>> &logicalHeightHints,
|
||||||
|
qreal &logicalWidthHint,
|
||||||
|
const KItemListView *view) const
|
||||||
{
|
{
|
||||||
const KItemListStyleOption &option = view->styleOption();
|
const KItemListStyleOption &option = view->styleOption();
|
||||||
const QFontMetrics &normalFontMetrics = option.fontMetrics;
|
const QFontMetrics &normalFontMetrics = option.fontMetrics;
|
||||||
|
@ -225,7 +228,9 @@ void KStandardItemListWidgetInformant::calculateCompactLayoutItemSizeHints(QVect
|
||||||
logicalWidthHint = height;
|
logicalWidthHint = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KStandardItemListWidgetInformant::calculateDetailsLayoutItemSizeHints(QVector<std::pair<qreal, bool>>& logicalHeightHints, qreal& logicalWidthHint, const KItemListView* view) const
|
void KStandardItemListWidgetInformant::calculateDetailsLayoutItemSizeHints(QVector<std::pair<qreal, bool>> &logicalHeightHints,
|
||||||
|
qreal &logicalWidthHint,
|
||||||
|
const KItemListView *view) const
|
||||||
{
|
{
|
||||||
const KItemListStyleOption &option = view->styleOption();
|
const KItemListStyleOption &option = view->styleOption();
|
||||||
const qreal height = option.padding * 2 + qMax(option.iconSize, option.fontMetrics.height());
|
const qreal height = option.padding * 2 + qMax(option.iconSize, option.fontMetrics.height());
|
||||||
|
@ -233,35 +238,35 @@ void KStandardItemListWidgetInformant::calculateDetailsLayoutItemSizeHints(QVect
|
||||||
logicalWidthHint = -1.0;
|
logicalWidthHint = -1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
KStandardItemListWidget::KStandardItemListWidget(KItemListWidgetInformant* informant, QGraphicsItem* parent) :
|
KStandardItemListWidget::KStandardItemListWidget(KItemListWidgetInformant *informant, QGraphicsItem *parent)
|
||||||
KItemListWidget(informant, parent),
|
: KItemListWidget(informant, parent)
|
||||||
m_textInfo(),
|
, m_textInfo()
|
||||||
m_isCut(false),
|
, m_isCut(false)
|
||||||
m_isHidden(false),
|
, m_isHidden(false)
|
||||||
m_customizedFont(),
|
, m_customizedFont()
|
||||||
m_customizedFontMetrics(m_customizedFont),
|
, m_customizedFontMetrics(m_customizedFont)
|
||||||
m_isExpandable(false),
|
, m_isExpandable(false)
|
||||||
m_highlightEntireRow(false),
|
, m_highlightEntireRow(false)
|
||||||
m_supportsItemExpanding(false),
|
, m_supportsItemExpanding(false)
|
||||||
m_dirtyLayout(true),
|
, m_dirtyLayout(true)
|
||||||
m_dirtyContent(true),
|
, m_dirtyContent(true)
|
||||||
m_dirtyContentRoles(),
|
, m_dirtyContentRoles()
|
||||||
m_layout(IconsLayout),
|
, m_layout(IconsLayout)
|
||||||
m_pixmapPos(),
|
, m_pixmapPos()
|
||||||
m_pixmap(),
|
, m_pixmap()
|
||||||
m_scaledPixmapSize(),
|
, m_scaledPixmapSize()
|
||||||
m_columnWidthSum(),
|
, m_columnWidthSum()
|
||||||
m_iconRect(),
|
, m_iconRect()
|
||||||
m_hoverPixmap(),
|
, m_hoverPixmap()
|
||||||
m_textRect(),
|
, m_textRect()
|
||||||
m_sortedVisibleRoles(),
|
, m_sortedVisibleRoles()
|
||||||
m_expansionArea(),
|
, m_expansionArea()
|
||||||
m_customTextColor(),
|
, m_customTextColor()
|
||||||
m_additionalInfoTextColor(),
|
, m_additionalInfoTextColor()
|
||||||
m_overlay(),
|
, m_overlay()
|
||||||
m_rating(),
|
, m_rating()
|
||||||
m_roleEditor(nullptr),
|
, m_roleEditor(nullptr)
|
||||||
m_oldRoleEditor(nullptr)
|
, m_oldRoleEditor(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,7 +299,8 @@ KStandardItemListWidget::Layout KStandardItemListWidget::layout() const
|
||||||
return m_layout;
|
return m_layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KStandardItemListWidget::setHighlightEntireRow(bool highlightEntireRow) {
|
void KStandardItemListWidget::setHighlightEntireRow(bool highlightEntireRow)
|
||||||
|
{
|
||||||
if (m_highlightEntireRow != highlightEntireRow) {
|
if (m_highlightEntireRow != highlightEntireRow) {
|
||||||
m_highlightEntireRow = highlightEntireRow;
|
m_highlightEntireRow = highlightEntireRow;
|
||||||
m_dirtyLayout = true;
|
m_dirtyLayout = true;
|
||||||
|
@ -302,7 +308,8 @@ void KStandardItemListWidget::setHighlightEntireRow(bool highlightEntireRow) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KStandardItemListWidget::highlightEntireRow() const {
|
bool KStandardItemListWidget::highlightEntireRow() const
|
||||||
|
{
|
||||||
return m_highlightEntireRow;
|
return m_highlightEntireRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -564,8 +571,7 @@ QRectF KStandardItemListWidget::selectionToggleRect() const
|
||||||
return QRectF(pos, QSizeF(toggleSize, toggleSize));
|
return QRectF(pos, QSizeF(toggleSize, toggleSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap KStandardItemListWidget::createDragPixmap(const QStyleOptionGraphicsItem* option,
|
QPixmap KStandardItemListWidget::createDragPixmap(const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
QWidget* widget)
|
|
||||||
{
|
{
|
||||||
QPixmap pixmap = KItemListWidget::createDragPixmap(option, widget);
|
QPixmap pixmap = KItemListWidget::createDragPixmap(option, widget);
|
||||||
if (m_layout != DetailsLayout) {
|
if (m_layout != DetailsLayout) {
|
||||||
|
@ -576,9 +582,7 @@ QPixmap KStandardItemListWidget::createDragPixmap(const QStyleOptionGraphicsItem
|
||||||
const int leftClip = m_pixmapPos.x();
|
const int leftClip = m_pixmapPos.x();
|
||||||
|
|
||||||
const TextInfo *textInfo = m_textInfo.value("text");
|
const TextInfo *textInfo = m_textInfo.value("text");
|
||||||
const int rightClip = textInfo->pos.x() +
|
const int rightClip = textInfo->pos.x() + textInfo->staticText.size().width() + 2 * styleOption().padding;
|
||||||
textInfo->staticText.size().width() +
|
|
||||||
2 * styleOption().padding;
|
|
||||||
|
|
||||||
QPixmap clippedPixmap(rightClip - leftClip + 1, pixmap.height());
|
QPixmap clippedPixmap(rightClip - leftClip + 1, pixmap.height());
|
||||||
clippedPixmap.fill(Qt::transparent);
|
clippedPixmap.fill(Qt::transparent);
|
||||||
|
@ -589,7 +593,6 @@ QPixmap KStandardItemListWidget::createDragPixmap(const QStyleOptionGraphicsItem
|
||||||
return clippedPixmap;
|
return clippedPixmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
KItemListWidgetInformant *KStandardItemListWidget::createInformant()
|
KItemListWidgetInformant *KStandardItemListWidget::createInformant()
|
||||||
{
|
{
|
||||||
return new KStandardItemListWidgetInformant();
|
return new KStandardItemListWidgetInformant();
|
||||||
|
@ -669,15 +672,12 @@ QPixmap KStandardItemListWidget::overlay() const
|
||||||
return m_overlay;
|
return m_overlay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString KStandardItemListWidget::roleText(const QByteArray &role, const QHash<QByteArray, QVariant> &values) const
|
||||||
QString KStandardItemListWidget::roleText(const QByteArray& role,
|
|
||||||
const QHash<QByteArray, QVariant>& values) const
|
|
||||||
{
|
{
|
||||||
return static_cast<const KStandardItemListWidgetInformant *>(informant())->roleText(role, values);
|
return static_cast<const KStandardItemListWidgetInformant *>(informant())->roleText(role, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KStandardItemListWidget::dataChanged(const QHash<QByteArray, QVariant>& current,
|
void KStandardItemListWidget::dataChanged(const QHash<QByteArray, QVariant> ¤t, const QSet<QByteArray> &roles)
|
||||||
const QSet<QByteArray>& roles)
|
|
||||||
{
|
{
|
||||||
Q_UNUSED(current)
|
Q_UNUSED(current)
|
||||||
|
|
||||||
|
@ -709,17 +709,14 @@ void KStandardItemListWidget::dataChanged(const QHash<QByteArray, QVariant>& cur
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KStandardItemListWidget::visibleRolesChanged(const QList<QByteArray>& current,
|
void KStandardItemListWidget::visibleRolesChanged(const QList<QByteArray> ¤t, const QList<QByteArray> &previous)
|
||||||
const QList<QByteArray>& previous)
|
|
||||||
{
|
{
|
||||||
Q_UNUSED(previous)
|
Q_UNUSED(previous)
|
||||||
m_sortedVisibleRoles = current;
|
m_sortedVisibleRoles = current;
|
||||||
m_dirtyLayout = true;
|
m_dirtyLayout = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KStandardItemListWidget::columnWidthChanged(const QByteArray& role,
|
void KStandardItemListWidget::columnWidthChanged(const QByteArray &role, qreal current, qreal previous)
|
||||||
qreal current,
|
|
||||||
qreal previous)
|
|
||||||
{
|
{
|
||||||
Q_UNUSED(role)
|
Q_UNUSED(role)
|
||||||
Q_UNUSED(current)
|
Q_UNUSED(current)
|
||||||
|
@ -727,13 +724,13 @@ void KStandardItemListWidget::columnWidthChanged(const QByteArray& role,
|
||||||
m_dirtyLayout = true;
|
m_dirtyLayout = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KStandardItemListWidget::sidePaddingChanged(qreal padding) {
|
void KStandardItemListWidget::sidePaddingChanged(qreal padding)
|
||||||
|
{
|
||||||
Q_UNUSED(padding)
|
Q_UNUSED(padding)
|
||||||
m_dirtyLayout = true;
|
m_dirtyLayout = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KStandardItemListWidget::styleOptionChanged(const KItemListStyleOption& current,
|
void KStandardItemListWidget::styleOptionChanged(const KItemListStyleOption ¤t, const KItemListStyleOption &previous)
|
||||||
const KItemListStyleOption& previous)
|
|
||||||
{
|
{
|
||||||
KItemListWidget::styleOptionChanged(current, previous);
|
KItemListWidget::styleOptionChanged(current, previous);
|
||||||
|
|
||||||
|
@ -775,10 +772,8 @@ void KStandardItemListWidget::editedRoleChanged(const QByteArray& current, const
|
||||||
if (m_roleEditor) {
|
if (m_roleEditor) {
|
||||||
Q_EMIT roleEditingCanceled(index(), current, data().value(current));
|
Q_EMIT roleEditingCanceled(index(), current, data().value(current));
|
||||||
|
|
||||||
disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled,
|
disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled, this, &KStandardItemListWidget::slotRoleEditingCanceled);
|
||||||
this, &KStandardItemListWidget::slotRoleEditingCanceled);
|
disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished, this, &KStandardItemListWidget::slotRoleEditingFinished);
|
||||||
disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished,
|
|
||||||
this, &KStandardItemListWidget::slotRoleEditingFinished);
|
|
||||||
|
|
||||||
if (m_oldRoleEditor) {
|
if (m_oldRoleEditor) {
|
||||||
m_oldRoleEditor->deleteLater();
|
m_oldRoleEditor->deleteLater();
|
||||||
|
@ -814,10 +809,8 @@ void KStandardItemListWidget::editedRoleChanged(const QByteArray& current, const
|
||||||
m_roleEditor->setTextCursor(cursor);
|
m_roleEditor->setTextCursor(cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled,
|
connect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled, this, &KStandardItemListWidget::slotRoleEditingCanceled);
|
||||||
this, &KStandardItemListWidget::slotRoleEditingCanceled);
|
connect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished, this, &KStandardItemListWidget::slotRoleEditingFinished);
|
||||||
connect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished,
|
|
||||||
this, &KStandardItemListWidget::slotRoleEditingFinished);
|
|
||||||
|
|
||||||
// Adjust the geometry of the editor
|
// Adjust the geometry of the editor
|
||||||
QRectF rect = roleEditingRect(current);
|
QRectF rect = roleEditingRect(current);
|
||||||
|
@ -863,22 +856,19 @@ void KStandardItemListWidget::showEvent(QShowEvent* event)
|
||||||
const QUrl itemUrl = data().value("url").toUrl();
|
const QUrl itemUrl = data().value("url").toUrl();
|
||||||
m_isCut = clipboard->isCut(itemUrl);
|
m_isCut = clipboard->isCut(itemUrl);
|
||||||
|
|
||||||
connect(clipboard, &KFileItemClipboard::cutItemsChanged,
|
connect(clipboard, &KFileItemClipboard::cutItemsChanged, this, &KStandardItemListWidget::slotCutItemsChanged);
|
||||||
this, &KStandardItemListWidget::slotCutItemsChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KStandardItemListWidget::hideEvent(QHideEvent *event)
|
void KStandardItemListWidget::hideEvent(QHideEvent *event)
|
||||||
{
|
{
|
||||||
disconnect(KFileItemClipboard::instance(), &KFileItemClipboard::cutItemsChanged,
|
disconnect(KFileItemClipboard::instance(), &KFileItemClipboard::cutItemsChanged, this, &KStandardItemListWidget::slotCutItemsChanged);
|
||||||
this, &KStandardItemListWidget::slotCutItemsChanged);
|
|
||||||
|
|
||||||
KItemListWidget::hideEvent(event);
|
KItemListWidget::hideEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KStandardItemListWidget::event(QEvent *event)
|
bool KStandardItemListWidget::event(QEvent *event)
|
||||||
{
|
{
|
||||||
if (event->type() == QEvent::WindowDeactivate || event->type() == QEvent::WindowActivate
|
if (event->type() == QEvent::WindowDeactivate || event->type() == QEvent::WindowActivate || event->type() == QEvent::PaletteChange) {
|
||||||
|| event->type() == QEvent::PaletteChange) {
|
|
||||||
m_dirtyContent = true;
|
m_dirtyContent = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -904,16 +894,14 @@ void KStandardItemListWidget::slotCutItemsChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KStandardItemListWidget::slotRoleEditingCanceled(const QByteArray& role,
|
void KStandardItemListWidget::slotRoleEditingCanceled(const QByteArray &role, const QVariant &value)
|
||||||
const QVariant& value)
|
|
||||||
{
|
{
|
||||||
closeRoleEditor();
|
closeRoleEditor();
|
||||||
Q_EMIT roleEditingCanceled(index(), role, value);
|
Q_EMIT roleEditingCanceled(index(), role, value);
|
||||||
setEditedRole(QByteArray());
|
setEditedRole(QByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
void KStandardItemListWidget::slotRoleEditingFinished(const QByteArray& role,
|
void KStandardItemListWidget::slotRoleEditingFinished(const QByteArray &role, const QVariant &value)
|
||||||
const QVariant& value)
|
|
||||||
{
|
{
|
||||||
closeRoleEditor();
|
closeRoleEditor();
|
||||||
Q_EMIT roleEditingFinished(index(), role, value);
|
Q_EMIT roleEditingFinished(index(), role, value);
|
||||||
|
@ -933,8 +921,9 @@ void KStandardItemListWidget::triggerCacheRefreshing()
|
||||||
m_isHidden = isHidden();
|
m_isHidden = isHidden();
|
||||||
m_customizedFont = customizedFont(styleOption().font);
|
m_customizedFont = customizedFont(styleOption().font);
|
||||||
m_customizedFontMetrics = QFontMetrics(m_customizedFont);
|
m_customizedFontMetrics = QFontMetrics(m_customizedFont);
|
||||||
m_columnWidthSum = std::accumulate(m_sortedVisibleRoles.begin(), m_sortedVisibleRoles.end(),
|
m_columnWidthSum = std::accumulate(m_sortedVisibleRoles.begin(), m_sortedVisibleRoles.end(), qreal(), [this](qreal sum, const auto &role) {
|
||||||
qreal(), [this](qreal sum, const auto &role){ return sum + columnWidth(role); });
|
return sum + columnWidth(role);
|
||||||
|
});
|
||||||
|
|
||||||
updateExpansionArea();
|
updateExpansionArea();
|
||||||
updateTextsCache();
|
updateTextsCache();
|
||||||
|
@ -984,9 +973,7 @@ void KStandardItemListWidget::updatePixmapCache()
|
||||||
|
|
||||||
bool updatePixmap = (m_pixmap.width() != maxIconWidth || m_pixmap.height() != maxIconHeight);
|
bool updatePixmap = (m_pixmap.width() != maxIconWidth || m_pixmap.height() != maxIconHeight);
|
||||||
if (!updatePixmap && m_dirtyContent) {
|
if (!updatePixmap && m_dirtyContent) {
|
||||||
updatePixmap = m_dirtyContentRoles.isEmpty()
|
updatePixmap = m_dirtyContentRoles.isEmpty() || m_dirtyContentRoles.contains("iconPixmap") || m_dirtyContentRoles.contains("iconName")
|
||||||
|| m_dirtyContentRoles.contains("iconPixmap")
|
|
||||||
|| m_dirtyContentRoles.contains("iconName")
|
|
||||||
|| m_dirtyContentRoles.contains("iconOverlays");
|
|| m_dirtyContentRoles.contains("iconOverlays");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1028,7 +1015,8 @@ void KStandardItemListWidget::updatePixmapCache()
|
||||||
iconName = QStringLiteral("unknown");
|
iconName = QStringLiteral("unknown");
|
||||||
}
|
}
|
||||||
const QStringList overlays = values["iconOverlays"].toStringList();
|
const QStringList overlays = values["iconOverlays"].toStringList();
|
||||||
m_pixmap = pixmapForIcon(iconName, overlays, maxIconHeight, m_layout != IconsLayout && isActiveWindow() && isSelected() ? QIcon::Selected : QIcon::Normal);
|
m_pixmap =
|
||||||
|
pixmapForIcon(iconName, overlays, maxIconHeight, m_layout != IconsLayout && isActiveWindow() && isSelected() ? QIcon::Selected : QIcon::Normal);
|
||||||
|
|
||||||
} else if (m_pixmap.width() / m_pixmap.devicePixelRatio() != maxIconWidth || m_pixmap.height() / m_pixmap.devicePixelRatio() != maxIconHeight) {
|
} else if (m_pixmap.width() / m_pixmap.devicePixelRatio() != maxIconWidth || m_pixmap.height() / m_pixmap.devicePixelRatio() != maxIconHeight) {
|
||||||
// A custom pixmap has been applied. Assure that the pixmap
|
// A custom pixmap has been applied. Assure that the pixmap
|
||||||
|
@ -1074,8 +1062,7 @@ void KStandardItemListWidget::updatePixmapCache()
|
||||||
} else {
|
} else {
|
||||||
const int textRowsCount = (m_layout == CompactLayout) ? visibleRoles().count() : 1;
|
const int textRowsCount = (m_layout == CompactLayout) ? visibleRoles().count() : 1;
|
||||||
const qreal requiredTextHeight = textRowsCount * m_customizedFontMetrics.height();
|
const qreal requiredTextHeight = textRowsCount * m_customizedFontMetrics.height();
|
||||||
scaledIconSize = (requiredTextHeight < maxIconHeight) ?
|
scaledIconSize = (requiredTextHeight < maxIconHeight) ? widgetSize.height() - 2 * padding : maxIconHeight;
|
||||||
widgetSize.height() - 2 * padding : maxIconHeight;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const int maxScaledIconWidth = iconOnTop ? widgetSize.width() - 2 * padding : scaledIconSize;
|
const int maxScaledIconWidth = iconOnTop ? widgetSize.width() - 2 * padding : scaledIconSize;
|
||||||
|
@ -1092,16 +1079,12 @@ void KStandardItemListWidget::updatePixmapCache()
|
||||||
} else {
|
} else {
|
||||||
// Center horizontally and vertically within the icon-area
|
// Center horizontally and vertically within the icon-area
|
||||||
const TextInfo *textInfo = m_textInfo.value("text");
|
const TextInfo *textInfo = m_textInfo.value("text");
|
||||||
m_pixmapPos.setX(textInfo->pos.x() - 2.0 * padding
|
m_pixmapPos.setX(textInfo->pos.x() - 2.0 * padding - (scaledIconSize + m_scaledPixmapSize.width()) / 2.0);
|
||||||
- (scaledIconSize + m_scaledPixmapSize.width()) / 2.0);
|
|
||||||
|
|
||||||
// Derive icon's vertical center from the center of the text frame, including
|
// Derive icon's vertical center from the center of the text frame, including
|
||||||
// any necessary adjustment if the font's midline is offset from the frame center
|
// any necessary adjustment if the font's midline is offset from the frame center
|
||||||
const qreal midlineShift = m_customizedFontMetrics.height() / 2.0
|
const qreal midlineShift = m_customizedFontMetrics.height() / 2.0 - m_customizedFontMetrics.descent() - m_customizedFontMetrics.capHeight() / 2.0;
|
||||||
- m_customizedFontMetrics.descent()
|
|
||||||
- m_customizedFontMetrics.capHeight() / 2.0;
|
|
||||||
m_pixmapPos.setY(m_textRect.center().y() + midlineShift - m_scaledPixmapSize.height() / 2.0);
|
m_pixmapPos.setY(m_textRect.center().y() + midlineShift - m_scaledPixmapSize.height() / 2.0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_layout == IconsLayout) {
|
if (m_layout == IconsLayout) {
|
||||||
|
@ -1109,8 +1092,7 @@ void KStandardItemListWidget::updatePixmapCache()
|
||||||
} else {
|
} else {
|
||||||
const qreal widthOffset = widgetIconSize - m_scaledPixmapSize.width();
|
const qreal widthOffset = widgetIconSize - m_scaledPixmapSize.width();
|
||||||
const qreal heightOffset = widgetIconSize - m_scaledPixmapSize.height();
|
const qreal heightOffset = widgetIconSize - m_scaledPixmapSize.height();
|
||||||
const QPointF squareIconPos(m_pixmapPos.x() - 0.5 * widthOffset,
|
const QPointF squareIconPos(m_pixmapPos.x() - 0.5 * widthOffset, m_pixmapPos.y() - 0.5 * heightOffset);
|
||||||
m_pixmapPos.y() - 0.5 * heightOffset);
|
|
||||||
const QSizeF squareIconSize(widgetIconSize, widgetIconSize);
|
const QSizeF squareIconSize(widgetIconSize, widgetIconSize);
|
||||||
m_iconRect = QRectF(squareIconPos, squareIconSize);
|
m_iconRect = QRectF(squareIconPos, squareIconSize);
|
||||||
}
|
}
|
||||||
|
@ -1160,10 +1142,18 @@ void KStandardItemListWidget::updateTextsCache()
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (m_layout) {
|
switch (m_layout) {
|
||||||
case IconsLayout: updateIconsLayoutTextCache(); break;
|
case IconsLayout:
|
||||||
case CompactLayout: updateCompactLayoutTextCache(); break;
|
updateIconsLayoutTextCache();
|
||||||
case DetailsLayout: updateDetailsLayoutTextCache(); break;
|
break;
|
||||||
default: Q_ASSERT(false); break;
|
case CompactLayout:
|
||||||
|
updateCompactLayoutTextCache();
|
||||||
|
break;
|
||||||
|
case DetailsLayout:
|
||||||
|
updateDetailsLayoutTextCache();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Q_ASSERT(false);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TextInfo *ratingTextInfo = m_textInfo.value("rating");
|
const TextInfo *ratingTextInfo = m_textInfo.value("rating");
|
||||||
|
@ -1173,9 +1163,7 @@ void KStandardItemListWidget::updateTextsCache()
|
||||||
const KItemListStyleOption &option = styleOption();
|
const KItemListStyleOption &option = styleOption();
|
||||||
QSizeF ratingSize = preferredRatingSize(option);
|
QSizeF ratingSize = preferredRatingSize(option);
|
||||||
|
|
||||||
const qreal availableWidth = (m_layout == DetailsLayout)
|
const qreal availableWidth = (m_layout == DetailsLayout) ? columnWidth("rating") - columnPadding(option) : size().width();
|
||||||
? columnWidth("rating") - columnPadding(option)
|
|
||||||
: size().width();
|
|
||||||
if (ratingSize.width() > availableWidth) {
|
if (ratingSize.width() > availableWidth) {
|
||||||
ratingSize.rwidth() = availableWidth;
|
ratingSize.rwidth() = availableWidth;
|
||||||
}
|
}
|
||||||
|
@ -1202,9 +1190,7 @@ QString KStandardItemListWidget::elideRightKeepExtension(const QString &text, in
|
||||||
const auto extensionWidth = m_customizedFontMetrics.horizontalAdvance(text.right(extensionLength));
|
const auto extensionWidth = m_customizedFontMetrics.horizontalAdvance(text.right(extensionLength));
|
||||||
if (elidingWidth > extensionWidth && extensionLength < 6 && (float(extensionWidth) / float(elidingWidth)) < 0.3) {
|
if (elidingWidth > extensionWidth && extensionLength < 6 && (float(extensionWidth) / float(elidingWidth)) < 0.3) {
|
||||||
// if we have room to display the file extension and the extension is not too long
|
// if we have room to display the file extension and the extension is not too long
|
||||||
QString ret = m_customizedFontMetrics.elidedText(text.chopped(extensionLength),
|
QString ret = m_customizedFontMetrics.elidedText(text.chopped(extensionLength), Qt::ElideRight, elidingWidth - extensionWidth);
|
||||||
Qt::ElideRight,
|
|
||||||
elidingWidth - extensionWidth);
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
ret.append(text.rightRef(extensionLength));
|
ret.append(text.rightRef(extensionLength));
|
||||||
#else
|
#else
|
||||||
|
@ -1213,8 +1199,7 @@ QString KStandardItemListWidget::elideRightKeepExtension(const QString &text, in
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return m_customizedFontMetrics.elidedText(text,Qt::ElideRight,
|
return m_customizedFontMetrics.elidedText(text, Qt::ElideRight, elidingWidth);
|
||||||
elidingWidth);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KStandardItemListWidget::updateIconsLayoutTextCache()
|
void KStandardItemListWidget::updateIconsLayoutTextCache()
|
||||||
|
@ -1289,10 +1274,7 @@ void KStandardItemListWidget::updateIconsLayoutTextCache()
|
||||||
// Use one line for each additional information
|
// Use one line for each additional information
|
||||||
nameTextInfo->staticText.setTextWidth(maxWidth);
|
nameTextInfo->staticText.setTextWidth(maxWidth);
|
||||||
nameTextInfo->pos = QPointF(padding, iconSize() + 2 * padding);
|
nameTextInfo->pos = QPointF(padding, iconSize() + 2 * padding);
|
||||||
m_textRect = QRectF(padding + (maxWidth - nameWidth) / 2,
|
m_textRect = QRectF(padding + (maxWidth - nameWidth) / 2, nameTextInfo->pos.y(), nameWidth, nameHeight);
|
||||||
nameTextInfo->pos.y(),
|
|
||||||
nameWidth,
|
|
||||||
nameHeight);
|
|
||||||
|
|
||||||
// Calculate the position for each additional information
|
// Calculate the position for each additional information
|
||||||
qreal y = nameTextInfo->pos.y() + nameHeight;
|
qreal y = nameTextInfo->pos.y() + nameHeight;
|
||||||
|
@ -1436,11 +1418,8 @@ void KStandardItemListWidget::updateDetailsLayoutTextCache()
|
||||||
x += roleWidth;
|
x += roleWidth;
|
||||||
|
|
||||||
if (isTextRole) {
|
if (isTextRole) {
|
||||||
const qreal textWidth = option.extendedSelectionRegion
|
const qreal textWidth = option.extendedSelectionRegion ? size().width() - textInfo->pos.x() : requiredWidth + 2 * option.padding;
|
||||||
? size().width() - textInfo->pos.x()
|
m_textRect = QRectF(textInfo->pos.x() - option.padding, 0, textWidth, size().height());
|
||||||
: requiredWidth + 2 * option.padding;
|
|
||||||
m_textRect = QRectF(textInfo->pos.x() - option.padding, 0,
|
|
||||||
textWidth, size().height());
|
|
||||||
|
|
||||||
// The column after the name should always be aligned on the same x-position independent
|
// The column after the name should always be aligned on the same x-position independent
|
||||||
// from the expansion-level shown in the name column
|
// from the expansion-level shown in the name column
|
||||||
|
@ -1471,9 +1450,8 @@ void KStandardItemListWidget::updateAdditionalInfoTextColor()
|
||||||
const QColor c2 = styleOption().palette.base().color();
|
const QColor c2 = styleOption().palette.base().color();
|
||||||
const int p1 = 70;
|
const int p1 = 70;
|
||||||
const int p2 = 100 - p1;
|
const int p2 = 100 - p1;
|
||||||
m_additionalInfoTextColor = QColor((c1.red() * p1 + c2.red() * p2) / 100,
|
m_additionalInfoTextColor =
|
||||||
(c1.green() * p1 + c2.green() * p2) / 100,
|
QColor((c1.red() * p1 + c2.red() * p2) / 100, (c1.green() * p1 + c2.green() * p2) / 100, (c1.blue() * p1 + c2.blue() * p2) / 100);
|
||||||
(c1.blue() * p1 + c2.blue() * p2) / 100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KStandardItemListWidget::drawPixmap(QPainter *painter, const QPixmap &pixmap)
|
void KStandardItemListWidget::drawPixmap(QPainter *painter, const QPixmap &pixmap)
|
||||||
|
@ -1545,10 +1523,8 @@ QRectF KStandardItemListWidget::roleEditingRect(const QByteArray& role) const
|
||||||
|
|
||||||
void KStandardItemListWidget::closeRoleEditor()
|
void KStandardItemListWidget::closeRoleEditor()
|
||||||
{
|
{
|
||||||
disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled,
|
disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled, this, &KStandardItemListWidget::slotRoleEditingCanceled);
|
||||||
this, &KStandardItemListWidget::slotRoleEditingCanceled);
|
disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished, this, &KStandardItemListWidget::slotRoleEditingFinished);
|
||||||
disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished,
|
|
||||||
this, &KStandardItemListWidget::slotRoleEditingFinished);
|
|
||||||
|
|
||||||
if (m_roleEditor->hasFocus()) {
|
if (m_roleEditor->hasFocus()) {
|
||||||
// If the editing was not ended by a FocusOut event, we have
|
// If the editing was not ended by a FocusOut event, we have
|
||||||
|
@ -1578,8 +1554,7 @@ QPixmap KStandardItemListWidget::pixmapForIcon(const QString& name, const QStrin
|
||||||
if (icon.isNull()) {
|
if (icon.isNull()) {
|
||||||
icon = QIcon(name);
|
icon = QIcon(name);
|
||||||
}
|
}
|
||||||
if (icon.isNull()
|
if (icon.isNull() || icon.pixmap(size / qApp->devicePixelRatio(), size / qApp->devicePixelRatio(), mode).isNull()) {
|
||||||
|| icon.pixmap(size / qApp->devicePixelRatio(), size / qApp->devicePixelRatio(), mode).isNull()) {
|
|
||||||
icon = fallbackIcon;
|
icon = fallbackIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1635,4 +1610,3 @@ qreal KStandardItemListWidget::columnPadding(const KItemListStyleOption& option)
|
||||||
{
|
{
|
||||||
return option.padding * 6;
|
return option.padding * 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,12 +24,12 @@ public:
|
||||||
KStandardItemListWidgetInformant();
|
KStandardItemListWidgetInformant();
|
||||||
~KStandardItemListWidgetInformant() override;
|
~KStandardItemListWidgetInformant() override;
|
||||||
|
|
||||||
void calculateItemSizeHints(QVector<std::pair<qreal /* height */, bool /* isElided */>>& logicalHeightHints, qreal& logicalWidthHint, const KItemListView* view) const override;
|
void calculateItemSizeHints(QVector<std::pair<qreal /* height */, bool /* isElided */>> &logicalHeightHints,
|
||||||
|
qreal &logicalWidthHint,
|
||||||
qreal preferredRoleColumnWidth(const QByteArray& role,
|
|
||||||
int index,
|
|
||||||
const KItemListView *view) const override;
|
const KItemListView *view) const override;
|
||||||
|
|
||||||
|
qreal preferredRoleColumnWidth(const QByteArray &role, int index, const KItemListView *view) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* @return The value of the "text" role. The default implementation returns
|
* @return The value of the "text" role. The default implementation returns
|
||||||
|
@ -52,8 +52,7 @@ protected:
|
||||||
* a role might depend on other roles, so the values of all roles
|
* a role might depend on other roles, so the values of all roles
|
||||||
* are passed as parameter.
|
* are passed as parameter.
|
||||||
*/
|
*/
|
||||||
virtual QString roleText(const QByteArray& role,
|
virtual QString roleText(const QByteArray &role, const QHash<QByteArray, QVariant> &values) const;
|
||||||
const QHash<QByteArray, QVariant>& values) const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return A font based on baseFont which is customized for symlinks.
|
* @return A font based on baseFont which is customized for symlinks.
|
||||||
|
@ -75,12 +74,7 @@ class DOLPHIN_EXPORT KStandardItemListWidget : public KItemListWidget
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Layout
|
enum Layout { IconsLayout, CompactLayout, DetailsLayout };
|
||||||
{
|
|
||||||
IconsLayout,
|
|
||||||
CompactLayout,
|
|
||||||
DetailsLayout
|
|
||||||
};
|
|
||||||
|
|
||||||
KStandardItemListWidget(KItemListWidgetInformant *informant, QGraphicsItem *parent);
|
KStandardItemListWidget(KItemListWidgetInformant *informant, QGraphicsItem *parent);
|
||||||
~KStandardItemListWidget() override;
|
~KStandardItemListWidget() override;
|
||||||
|
@ -183,8 +177,7 @@ protected:
|
||||||
void hideEvent(QHideEvent *event) override;
|
void hideEvent(QHideEvent *event) override;
|
||||||
bool event(QEvent *event) override;
|
bool event(QEvent *event) override;
|
||||||
|
|
||||||
struct TextInfo
|
struct TextInfo {
|
||||||
{
|
|
||||||
QPointF pos;
|
QPointF pos;
|
||||||
QStaticText staticText;
|
QStaticText staticText;
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
#include <QCollator>
|
#include <QCollator>
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
|
|
||||||
namespace {
|
namespace
|
||||||
|
{
|
||||||
QString tagsFromValues(const QStringList &values)
|
QString tagsFromValues(const QStringList &values)
|
||||||
{
|
{
|
||||||
if (values.size() == 1) {
|
if (values.size() == 1) {
|
||||||
|
@ -24,7 +25,9 @@ namespace {
|
||||||
QStringList alphabeticalOrderTags = values;
|
QStringList alphabeticalOrderTags = values;
|
||||||
QCollator coll;
|
QCollator coll;
|
||||||
coll.setNumericMode(true);
|
coll.setNumericMode(true);
|
||||||
std::sort(alphabeticalOrderTags.begin(), alphabeticalOrderTags.end(), [&](const QString& s1, const QString& s2){ return coll.compare(s1, s2) < 0; });
|
std::sort(alphabeticalOrderTags.begin(), alphabeticalOrderTags.end(), [&](const QString &s1, const QString &s2) {
|
||||||
|
return coll.compare(s1, s2) < 0;
|
||||||
|
});
|
||||||
return alphabeticalOrderTags.join(QLatin1String(", "));
|
return alphabeticalOrderTags.join(QLatin1String(", "));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,13 +61,11 @@ namespace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct KBalooRolesProviderSingleton
|
struct KBalooRolesProviderSingleton {
|
||||||
{
|
|
||||||
KBalooRolesProvider instance;
|
KBalooRolesProvider instance;
|
||||||
};
|
};
|
||||||
Q_GLOBAL_STATIC(KBalooRolesProviderSingleton, s_balooRolesProvider)
|
Q_GLOBAL_STATIC(KBalooRolesProviderSingleton, s_balooRolesProvider)
|
||||||
|
|
||||||
|
|
||||||
KBalooRolesProvider &KBalooRolesProvider::instance()
|
KBalooRolesProvider &KBalooRolesProvider::instance()
|
||||||
{
|
{
|
||||||
return s_balooRolesProvider->instance;
|
return s_balooRolesProvider->instance;
|
||||||
|
@ -79,8 +80,7 @@ QSet<QByteArray> KBalooRolesProvider::roles() const
|
||||||
return m_roles;
|
return m_roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<QByteArray, QVariant> KBalooRolesProvider::roleValues(const Baloo::File& file,
|
QHash<QByteArray, QVariant> KBalooRolesProvider::roleValues(const Baloo::File &file, const QSet<QByteArray> &roles) const
|
||||||
const QSet<QByteArray>& roles) const
|
|
||||||
{
|
{
|
||||||
QHash<QByteArray, QVariant> values;
|
QHash<QByteArray, QVariant> values;
|
||||||
|
|
||||||
|
@ -92,8 +92,9 @@ QHash<QByteArray, QVariant> KBalooRolesProvider::roleValues(const Baloo::File& f
|
||||||
while (rangeBegin != propMap.constKeyValueEnd()) {
|
while (rangeBegin != propMap.constKeyValueEnd()) {
|
||||||
auto key = (*rangeBegin).first;
|
auto key = (*rangeBegin).first;
|
||||||
|
|
||||||
auto rangeEnd = std::find_if(rangeBegin, propMap.constKeyValueEnd(),
|
auto rangeEnd = std::find_if(rangeBegin, propMap.constKeyValueEnd(), [key](const entry &e) {
|
||||||
[key](const entry& e) { return e.first != key; });
|
return e.first != key;
|
||||||
|
});
|
||||||
|
|
||||||
const QByteArray role = propertyRoleMap().value(key);
|
const QByteArray role = propertyRoleMap().value(key);
|
||||||
if (role.isEmpty() || !roles.contains(role)) {
|
if (role.isEmpty() || !roles.contains(role)) {
|
||||||
|
@ -106,7 +107,9 @@ QHash<QByteArray, QVariant> KBalooRolesProvider::roleValues(const Baloo::File& f
|
||||||
if (distance > 1) {
|
if (distance > 1) {
|
||||||
QVariantList list;
|
QVariantList list;
|
||||||
list.reserve(static_cast<int>(distance));
|
list.reserve(static_cast<int>(distance));
|
||||||
std::for_each(rangeBegin, rangeEnd, [&list](const entry& s) { list.append(s.second); });
|
std::for_each(rangeBegin, rangeEnd, [&list](const entry &s) {
|
||||||
|
list.append(s.second);
|
||||||
|
});
|
||||||
values.insert(role, propertyInfo.formatAsDisplayString(list));
|
values.insert(role, propertyInfo.formatAsDisplayString(list));
|
||||||
} else {
|
} else {
|
||||||
if (propertyInfo.valueType() == QVariant::DateTime) {
|
if (propertyInfo.valueType() == QVariant::DateTime) {
|
||||||
|
@ -182,4 +185,3 @@ KBalooRolesProvider::KBalooRolesProvider()
|
||||||
m_roles.insert(QByteArrayLiteral("comment"));
|
m_roles.insert(QByteArrayLiteral("comment"));
|
||||||
m_roles.insert(QByteArrayLiteral("originUrl"));
|
m_roles.insert(QByteArrayLiteral("originUrl"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
namespace Baloo {
|
namespace Baloo
|
||||||
|
{
|
||||||
class File;
|
class File;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,8 +40,7 @@ public:
|
||||||
* @return Values for the roles \a roles that can be determined from the file
|
* @return Values for the roles \a roles that can be determined from the file
|
||||||
* with the URL \a url.
|
* with the URL \a url.
|
||||||
*/
|
*/
|
||||||
QHash<QByteArray, QVariant> roleValues(const Baloo::File& file,
|
QHash<QByteArray, QVariant> roleValues(const Baloo::File &file, const QSet<QByteArray> &roles) const;
|
||||||
const QSet<QByteArray>& roles) const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
KBalooRolesProvider();
|
KBalooRolesProvider();
|
||||||
|
@ -52,4 +52,3 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -10,26 +10,26 @@
|
||||||
|
|
||||||
#include <KDirWatch>
|
#include <KDirWatch>
|
||||||
|
|
||||||
#include <QFileInfo>
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QFileInfo>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
namespace {
|
namespace
|
||||||
|
{
|
||||||
/// cache of directory counting result
|
/// cache of directory counting result
|
||||||
static QHash<QString, QPair<int, long>> *s_cache;
|
static QHash<QString, QPair<int, long>> *s_cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
KDirectoryContentsCounter::KDirectoryContentsCounter(KFileItemModel* model, QObject* parent) :
|
KDirectoryContentsCounter::KDirectoryContentsCounter(KFileItemModel *model, QObject *parent)
|
||||||
QObject(parent),
|
: QObject(parent)
|
||||||
m_model(model),
|
, m_model(model)
|
||||||
m_queue(),
|
, m_queue()
|
||||||
m_worker(nullptr),
|
, m_worker(nullptr)
|
||||||
m_workerIsBusy(false),
|
, m_workerIsBusy(false)
|
||||||
m_dirWatcher(nullptr),
|
, m_dirWatcher(nullptr)
|
||||||
m_watchedDirs()
|
, m_watchedDirs()
|
||||||
{
|
{
|
||||||
connect(m_model, &KFileItemModel::itemsRemoved,
|
connect(m_model, &KFileItemModel::itemsRemoved, this, &KDirectoryContentsCounter::slotItemsRemoved);
|
||||||
this, &KDirectoryContentsCounter::slotItemsRemoved);
|
|
||||||
|
|
||||||
if (!m_workerThread) {
|
if (!m_workerThread) {
|
||||||
m_workerThread = new QThread();
|
m_workerThread = new QThread();
|
||||||
|
@ -43,10 +43,8 @@ KDirectoryContentsCounter::KDirectoryContentsCounter(KFileItemModel* model, QObj
|
||||||
m_worker = new KDirectoryContentsCounterWorker();
|
m_worker = new KDirectoryContentsCounterWorker();
|
||||||
m_worker->moveToThread(m_workerThread);
|
m_worker->moveToThread(m_workerThread);
|
||||||
|
|
||||||
connect(this, &KDirectoryContentsCounter::requestDirectoryContentsCount,
|
connect(this, &KDirectoryContentsCounter::requestDirectoryContentsCount, m_worker, &KDirectoryContentsCounterWorker::countDirectoryContents);
|
||||||
m_worker, &KDirectoryContentsCounterWorker::countDirectoryContents);
|
connect(m_worker, &KDirectoryContentsCounterWorker::result, this, &KDirectoryContentsCounter::slotResult);
|
||||||
connect(m_worker, &KDirectoryContentsCounterWorker::result,
|
|
||||||
this, &KDirectoryContentsCounter::slotResult);
|
|
||||||
|
|
||||||
m_dirWatcher = new KDirWatch(this);
|
m_dirWatcher = new KDirWatch(this);
|
||||||
connect(m_dirWatcher, &KDirWatch::dirty, this, &KDirectoryContentsCounter::slotDirWatchDirty);
|
connect(m_dirWatcher, &KDirWatch::dirty, this, &KDirectoryContentsCounter::slotDirWatchDirty);
|
||||||
|
@ -170,8 +168,8 @@ void KDirectoryContentsCounter::startWorker(const QString& path)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_workerIsBusy) {
|
if (m_workerIsBusy) {
|
||||||
if (std::find(m_queue.begin(), m_queue.end(), path) == m_queue.end() &&
|
if (std::find(m_queue.begin(), m_queue.end(), path) == m_queue.end()
|
||||||
std::find(m_priorityQueue.begin(), m_priorityQueue.end(), path) == m_priorityQueue.end()) {
|
&& std::find(m_priorityQueue.begin(), m_priorityQueue.end(), path) == m_priorityQueue.end()) {
|
||||||
if (alreadyInCache) {
|
if (alreadyInCache) {
|
||||||
m_queue.push_back(path);
|
m_queue.push_back(path);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -17,17 +17,15 @@
|
||||||
|
|
||||||
#include "dolphin_detailsmodesettings.h"
|
#include "dolphin_detailsmodesettings.h"
|
||||||
|
|
||||||
KDirectoryContentsCounterWorker::KDirectoryContentsCounterWorker(QObject* parent) :
|
KDirectoryContentsCounterWorker::KDirectoryContentsCounterWorker(QObject *parent)
|
||||||
QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
qRegisterMetaType<KDirectoryContentsCounterWorker::Options>();
|
qRegisterMetaType<KDirectoryContentsCounterWorker::Options>();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef Q_OS_WIN
|
#ifndef Q_OS_WIN
|
||||||
KDirectoryContentsCounterWorker::CountResult walkDir(const QString &dirPath,
|
KDirectoryContentsCounterWorker::CountResult
|
||||||
const bool countHiddenFiles,
|
walkDir(const QString &dirPath, const bool countHiddenFiles, const bool countDirectoriesOnly, const uint allowedRecursiveLevel)
|
||||||
const bool countDirectoriesOnly,
|
|
||||||
const uint allowedRecursiveLevel)
|
|
||||||
{
|
{
|
||||||
int count = -1;
|
int count = -1;
|
||||||
long size = -1;
|
long size = -1;
|
||||||
|
@ -53,10 +51,7 @@ KDirectoryContentsCounterWorker::CountResult walkDir(const QString &dirPath,
|
||||||
// If only directories are counted, consider an unknown file type and links also
|
// If only directories are counted, consider an unknown file type and links also
|
||||||
// as directory instead of trying to do an expensive stat()
|
// as directory instead of trying to do an expensive stat()
|
||||||
// (see bugs 292642 and 299997).
|
// (see bugs 292642 and 299997).
|
||||||
const bool countEntry = !countDirectoriesOnly ||
|
const bool countEntry = !countDirectoriesOnly || dirEntry->d_type == DT_DIR || dirEntry->d_type == DT_LNK || dirEntry->d_type == DT_UNKNOWN;
|
||||||
dirEntry->d_type == DT_DIR ||
|
|
||||||
dirEntry->d_type == DT_LNK ||
|
|
||||||
dirEntry->d_type == DT_UNKNOWN;
|
|
||||||
if (countEntry) {
|
if (countEntry) {
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,11 +17,7 @@ class KDirectoryContentsCounterWorker : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Option {
|
enum Option { NoOptions = 0x0, CountHiddenFiles = 0x1, CountDirectoriesOnly = 0x2 };
|
||||||
NoOptions = 0x0,
|
|
||||||
CountHiddenFiles = 0x1,
|
|
||||||
CountDirectoriesOnly = 0x2
|
|
||||||
};
|
|
||||||
Q_DECLARE_FLAGS(Options, Option)
|
Q_DECLARE_FLAGS(Options, Option)
|
||||||
|
|
||||||
struct CountResult {
|
struct CountResult {
|
||||||
|
|
|
@ -19,8 +19,6 @@ public:
|
||||||
};
|
};
|
||||||
Q_GLOBAL_STATIC(KFileItemClipboardSingleton, s_KFileItemClipboard)
|
Q_GLOBAL_STATIC(KFileItemClipboardSingleton, s_KFileItemClipboard)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
KFileItemClipboard *KFileItemClipboard::instance()
|
KFileItemClipboard *KFileItemClipboard::instance()
|
||||||
{
|
{
|
||||||
return &s_KFileItemClipboard->instance;
|
return &s_KFileItemClipboard->instance;
|
||||||
|
@ -62,12 +60,11 @@ void KFileItemClipboard::updateCutItems()
|
||||||
Q_EMIT cutItemsChanged();
|
Q_EMIT cutItemsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
KFileItemClipboard::KFileItemClipboard() :
|
KFileItemClipboard::KFileItemClipboard()
|
||||||
QObject(nullptr),
|
: QObject(nullptr)
|
||||||
m_cutItems()
|
, m_cutItems()
|
||||||
{
|
{
|
||||||
updateCutItems();
|
updateCutItems();
|
||||||
|
|
||||||
connect(QApplication::clipboard(), &QClipboard::dataChanged,
|
connect(QApplication::clipboard(), &QClipboard::dataChanged, this, &KFileItemClipboard::updateCutItems);
|
||||||
this, &KFileItemClipboard::updateCutItems);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,11 @@
|
||||||
|
|
||||||
#include <KFileItem>
|
#include <KFileItem>
|
||||||
|
|
||||||
KFileItemModelFilter::KFileItemModelFilter() :
|
KFileItemModelFilter::KFileItemModelFilter()
|
||||||
m_useRegExp(false),
|
: m_useRegExp(false)
|
||||||
m_regExp(nullptr),
|
, m_regExp(nullptr)
|
||||||
m_lowerCasePattern(),
|
, m_lowerCasePattern()
|
||||||
m_pattern()
|
, m_pattern()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,6 @@ bool KFileItemModelFilter::hasSetFilters() const
|
||||||
return (!m_pattern.isEmpty() || !m_mimeTypes.isEmpty());
|
return (!m_pattern.isEmpty() || !m_mimeTypes.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool KFileItemModelFilter::matches(const KFileItem &item) const
|
bool KFileItemModelFilter::matches(const KFileItem &item) const
|
||||||
{
|
{
|
||||||
const bool hasPatternFilter = !m_pattern.isEmpty();
|
const bool hasPatternFilter = !m_pattern.isEmpty();
|
||||||
|
|
|
@ -24,7 +24,6 @@ class QRegularExpression;
|
||||||
*/
|
*/
|
||||||
class DOLPHIN_EXPORT KFileItemModelFilter
|
class DOLPHIN_EXPORT KFileItemModelFilter
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
KFileItemModelFilter();
|
KFileItemModelFilter();
|
||||||
virtual ~KFileItemModelFilter();
|
virtual ~KFileItemModelFilter();
|
||||||
|
@ -76,5 +75,3 @@ private:
|
||||||
QStringList m_mimeTypes; // Property set by setMimeTypes()
|
QStringList m_mimeTypes; // Property set by setMimeTypes()
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template<typename RandomAccessIterator, typename LessThan>
|
template<typename RandomAccessIterator, typename LessThan>
|
||||||
static void mergeSort(RandomAccessIterator begin,
|
static void mergeSort(RandomAccessIterator begin, RandomAccessIterator end, const LessThan &lessThan)
|
||||||
RandomAccessIterator end,
|
|
||||||
const LessThan& lessThan)
|
|
||||||
{
|
{
|
||||||
// The implementation is based on qStableSortHelper() from qalgorithms.h
|
// The implementation is based on qStableSortHelper() from qalgorithms.h
|
||||||
// SPDX-FileCopyrightText: 2011 Nokia Corporation and/or its subsidiary(-ies).
|
// SPDX-FileCopyrightText: 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
@ -50,11 +48,8 @@ static void mergeSort(RandomAccessIterator begin,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template<typename RandomAccessIterator, typename LessThan>
|
template<typename RandomAccessIterator, typename LessThan>
|
||||||
static void parallelMergeSort(RandomAccessIterator begin,
|
static void
|
||||||
RandomAccessIterator end,
|
parallelMergeSort(RandomAccessIterator begin, RandomAccessIterator end, LessThan lessThan, int numberOfThreads, int parallelMergeSortingThreshold = 100)
|
||||||
LessThan lessThan,
|
|
||||||
int numberOfThreads,
|
|
||||||
int parallelMergeSortingThreshold = 100)
|
|
||||||
{
|
{
|
||||||
const int span = end - begin;
|
const int span = end - begin;
|
||||||
|
|
||||||
|
@ -62,7 +57,8 @@ static void parallelMergeSort(RandomAccessIterator begin,
|
||||||
const int newNumberOfThreads = numberOfThreads / 2;
|
const int newNumberOfThreads = numberOfThreads / 2;
|
||||||
const RandomAccessIterator middle = begin + span / 2;
|
const RandomAccessIterator middle = begin + span / 2;
|
||||||
|
|
||||||
QFuture<void> future = QtConcurrent::run(parallelMergeSort<RandomAccessIterator, LessThan>, begin, middle, lessThan, newNumberOfThreads, parallelMergeSortingThreshold);
|
QFuture<void> future =
|
||||||
|
QtConcurrent::run(parallelMergeSort<RandomAccessIterator, LessThan>, begin, middle, lessThan, newNumberOfThreads, parallelMergeSortingThreshold);
|
||||||
parallelMergeSort(middle, end, lessThan, newNumberOfThreads, parallelMergeSortingThreshold);
|
parallelMergeSort(middle, end, lessThan, newNumberOfThreads, parallelMergeSortingThreshold);
|
||||||
|
|
||||||
future.waitForFinished();
|
future.waitForFinished();
|
||||||
|
@ -83,10 +79,7 @@ static void parallelMergeSort(RandomAccessIterator begin,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template<typename RandomAccessIterator, typename LessThan>
|
template<typename RandomAccessIterator, typename LessThan>
|
||||||
static void merge(RandomAccessIterator begin,
|
static void merge(RandomAccessIterator begin, RandomAccessIterator pivot, RandomAccessIterator end, const LessThan &lessThan)
|
||||||
RandomAccessIterator pivot,
|
|
||||||
RandomAccessIterator end,
|
|
||||||
const LessThan& lessThan)
|
|
||||||
{
|
{
|
||||||
// The implementation is based on qMerge() from qalgorithms.h
|
// The implementation is based on qMerge() from qalgorithms.h
|
||||||
// SPDX-FileCopyrightText: 2011 Nokia Corporation and/or its subsidiary(-ies).
|
// SPDX-FileCopyrightText: 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
@ -111,14 +104,12 @@ static void merge(RandomAccessIterator begin,
|
||||||
if (len1 > len2) {
|
if (len1 > len2) {
|
||||||
const int len1Half = len1 / 2;
|
const int len1Half = len1 / 2;
|
||||||
firstCut = begin + len1Half;
|
firstCut = begin + len1Half;
|
||||||
secondCut = std::lower_bound<RandomAccessIterator,
|
secondCut = std::lower_bound<RandomAccessIterator, decltype(*firstCut), const LessThan &>(pivot, end, *firstCut, lessThan);
|
||||||
decltype(*firstCut), const LessThan&>(pivot, end, *firstCut, lessThan);
|
|
||||||
len2Half = secondCut - pivot;
|
len2Half = secondCut - pivot;
|
||||||
} else {
|
} else {
|
||||||
len2Half = len2 / 2;
|
len2Half = len2 / 2;
|
||||||
secondCut = pivot + len2Half;
|
secondCut = pivot + len2Half;
|
||||||
firstCut = std::upper_bound<RandomAccessIterator,
|
firstCut = std::upper_bound<RandomAccessIterator, decltype(*secondCut), const LessThan &>(begin, pivot, *secondCut, lessThan);
|
||||||
decltype(*secondCut), const LessThan&>(begin, pivot, *secondCut, lessThan);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::rotate(firstCut, pivot, secondCut);
|
std::rotate(firstCut, pivot, secondCut);
|
||||||
|
@ -129,4 +120,3 @@ static void merge(RandomAccessIterator begin,
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -12,21 +12,20 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QStyleOptionHeader>
|
#include <QStyleOptionHeader>
|
||||||
|
|
||||||
|
KItemListHeaderWidget::KItemListHeaderWidget(QGraphicsWidget *parent)
|
||||||
KItemListHeaderWidget::KItemListHeaderWidget(QGraphicsWidget* parent) :
|
: QGraphicsWidget(parent)
|
||||||
QGraphicsWidget(parent),
|
, m_automaticColumnResizing(true)
|
||||||
m_automaticColumnResizing(true),
|
, m_model(nullptr)
|
||||||
m_model(nullptr),
|
, m_offset(0)
|
||||||
m_offset(0),
|
, m_sidePadding(0)
|
||||||
m_sidePadding(0),
|
, m_columns()
|
||||||
m_columns(),
|
, m_columnWidths()
|
||||||
m_columnWidths(),
|
, m_preferredColumnWidths()
|
||||||
m_preferredColumnWidths(),
|
, m_hoveredRoleIndex(-1)
|
||||||
m_hoveredRoleIndex(-1),
|
, m_pressedRoleIndex(-1)
|
||||||
m_pressedRoleIndex(-1),
|
, m_roleOperation(NoRoleOperation)
|
||||||
m_roleOperation(NoRoleOperation),
|
, m_pressedMousePos()
|
||||||
m_pressedMousePos(),
|
, m_movingRole()
|
||||||
m_movingRole()
|
|
||||||
{
|
{
|
||||||
m_movingRole.x = 0;
|
m_movingRole.x = 0;
|
||||||
m_movingRole.xDec = 0;
|
m_movingRole.xDec = 0;
|
||||||
|
@ -48,19 +47,15 @@ void KItemListHeaderWidget::setModel(KItemModelBase* model)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_model) {
|
if (m_model) {
|
||||||
disconnect(m_model, &KItemModelBase::sortRoleChanged,
|
disconnect(m_model, &KItemModelBase::sortRoleChanged, this, &KItemListHeaderWidget::slotSortRoleChanged);
|
||||||
this, &KItemListHeaderWidget::slotSortRoleChanged);
|
disconnect(m_model, &KItemModelBase::sortOrderChanged, this, &KItemListHeaderWidget::slotSortOrderChanged);
|
||||||
disconnect(m_model, &KItemModelBase::sortOrderChanged,
|
|
||||||
this, &KItemListHeaderWidget::slotSortOrderChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_model = model;
|
m_model = model;
|
||||||
|
|
||||||
if (m_model) {
|
if (m_model) {
|
||||||
connect(m_model, &KItemModelBase::sortRoleChanged,
|
connect(m_model, &KItemModelBase::sortRoleChanged, this, &KItemListHeaderWidget::slotSortRoleChanged);
|
||||||
this, &KItemListHeaderWidget::slotSortRoleChanged);
|
connect(m_model, &KItemModelBase::sortOrderChanged, this, &KItemListHeaderWidget::slotSortOrderChanged);
|
||||||
connect(m_model, &KItemModelBase::sortOrderChanged,
|
|
||||||
this, &KItemListHeaderWidget::slotSortOrderChanged);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,8 +189,7 @@ void KItemListHeaderWidget::mousePressEvent(QGraphicsSceneMouseEvent* event)
|
||||||
m_roleOperation = ResizePaddingColumnOperation;
|
m_roleOperation = ResizePaddingColumnOperation;
|
||||||
} else {
|
} else {
|
||||||
updatePressedRoleIndex(event->pos());
|
updatePressedRoleIndex(event->pos());
|
||||||
m_roleOperation = isAboveRoleGrip(m_pressedMousePos, m_pressedRoleIndex) ?
|
m_roleOperation = isAboveRoleGrip(m_pressedMousePos, m_pressedRoleIndex) ? ResizeRoleOperation : NoRoleOperation;
|
||||||
ResizeRoleOperation : NoRoleOperation;
|
|
||||||
}
|
}
|
||||||
event->accept();
|
event->accept();
|
||||||
} else {
|
} else {
|
||||||
|
@ -219,8 +213,7 @@ void KItemListHeaderWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
|
||||||
if (m_pressedRoleIndex == sortRoleIndex) {
|
if (m_pressedRoleIndex == sortRoleIndex) {
|
||||||
// Toggle the sort order
|
// Toggle the sort order
|
||||||
const Qt::SortOrder previous = m_model->sortOrder();
|
const Qt::SortOrder previous = m_model->sortOrder();
|
||||||
const Qt::SortOrder current = (m_model->sortOrder() == Qt::AscendingOrder) ?
|
const Qt::SortOrder current = (m_model->sortOrder() == Qt::AscendingOrder) ? Qt::DescendingOrder : Qt::AscendingOrder;
|
||||||
Qt::DescendingOrder : Qt::AscendingOrder;
|
|
||||||
m_model->setSortOrder(current);
|
m_model->setSortOrder(current);
|
||||||
Q_EMIT sortOrderChanged(current, previous);
|
Q_EMIT sortOrderChanged(current, previous);
|
||||||
} else {
|
} else {
|
||||||
|
@ -390,9 +383,8 @@ void KItemListHeaderWidget::hoverMoveEvent(QGraphicsSceneHoverEvent* event)
|
||||||
|
|
||||||
const QPointF &pos = event->pos();
|
const QPointF &pos = event->pos();
|
||||||
updateHoveredRoleIndex(pos);
|
updateHoveredRoleIndex(pos);
|
||||||
if ((m_hoveredRoleIndex >= 0 && isAboveRoleGrip(pos, m_hoveredRoleIndex)) ||
|
if ((m_hoveredRoleIndex >= 0 && isAboveRoleGrip(pos, m_hoveredRoleIndex)) || isAbovePaddingGrip(pos, PaddingGrip::Leading)
|
||||||
isAbovePaddingGrip(pos, PaddingGrip::Leading) ||
|
|| isAbovePaddingGrip(pos, PaddingGrip::Trailing)) {
|
||||||
isAbovePaddingGrip(pos, PaddingGrip::Trailing)) {
|
|
||||||
setCursor(Qt::SplitHCursor);
|
setCursor(Qt::SplitHCursor);
|
||||||
} else {
|
} else {
|
||||||
unsetCursor();
|
unsetCursor();
|
||||||
|
@ -413,11 +405,7 @@ void KItemListHeaderWidget::slotSortOrderChanged(Qt::SortOrder current, Qt::Sort
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KItemListHeaderWidget::paintRole(QPainter* painter,
|
void KItemListHeaderWidget::paintRole(QPainter *painter, const QByteArray &role, const QRectF &rect, int orderIndex, QWidget *widget) const
|
||||||
const QByteArray& role,
|
|
||||||
const QRectF& rect,
|
|
||||||
int orderIndex,
|
|
||||||
QWidget* widget) const
|
|
||||||
{
|
{
|
||||||
const auto direction = widget ? widget->layoutDirection() : qApp->layoutDirection();
|
const auto direction = widget ? widget->layoutDirection() : qApp->layoutDirection();
|
||||||
|
|
||||||
|
@ -425,10 +413,7 @@ void KItemListHeaderWidget::paintRole(QPainter* painter,
|
||||||
// SPDX-FileCopyrightText: 2011 Nokia Corporation and/or its subsidiary(-ies).
|
// SPDX-FileCopyrightText: 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
QStyleOptionHeader option;
|
QStyleOptionHeader option;
|
||||||
option.direction = direction;
|
option.direction = direction;
|
||||||
option.textAlignment =
|
option.textAlignment = direction == Qt::LeftToRight ? Qt::AlignLeft : Qt::AlignRight;
|
||||||
direction == Qt::LeftToRight
|
|
||||||
? Qt::AlignLeft
|
|
||||||
: Qt::AlignRight;
|
|
||||||
|
|
||||||
option.section = orderIndex;
|
option.section = orderIndex;
|
||||||
option.state = QStyle::State_None | QStyle::State_Raised | QStyle::State_Horizontal;
|
option.state = QStyle::State_None | QStyle::State_Raised | QStyle::State_Horizontal;
|
||||||
|
@ -445,8 +430,7 @@ void KItemListHeaderWidget::paintRole(QPainter* painter,
|
||||||
option.state |= QStyle::State_Sunken;
|
option.state |= QStyle::State_Sunken;
|
||||||
}
|
}
|
||||||
if (m_model->sortRole() == role) {
|
if (m_model->sortRole() == role) {
|
||||||
option.sortIndicator = (m_model->sortOrder() == Qt::AscendingOrder) ?
|
option.sortIndicator = (m_model->sortOrder() == Qt::AscendingOrder) ? QStyleOptionHeader::SortDown : QStyleOptionHeader::SortUp;
|
||||||
QStyleOptionHeader::SortDown : QStyleOptionHeader::SortUp;
|
|
||||||
}
|
}
|
||||||
option.rect = rect.toRect();
|
option.rect = rect.toRect();
|
||||||
option.orientation = Qt::Horizontal;
|
option.orientation = Qt::Horizontal;
|
||||||
|
@ -546,8 +530,7 @@ bool KItemListHeaderWidget::isAbovePaddingGrip(const QPointF& pos, PaddingGrip p
|
||||||
switch (paddingGrip) {
|
switch (paddingGrip) {
|
||||||
case Leading:
|
case Leading:
|
||||||
return pos.x() >= (lx - grip) && pos.x() <= lx;
|
return pos.x() >= (lx - grip) && pos.x() <= lx;
|
||||||
case Trailing:
|
case Trailing: {
|
||||||
{
|
|
||||||
qreal rx = lx;
|
qreal rx = lx;
|
||||||
for (const QByteArray &role : qAsConst(m_columns)) {
|
for (const QByteArray &role : qAsConst(m_columns)) {
|
||||||
rx += m_columnWidths.value(role);
|
rx += m_columnWidths.value(role);
|
||||||
|
@ -596,12 +579,8 @@ int KItemListHeaderWidget::targetOfMovingRole() const
|
||||||
const qreal targetWidth = m_columnWidths.value(role);
|
const qreal targetWidth = m_columnWidths.value(role);
|
||||||
const qreal targetRight = targetLeft + targetWidth - 1;
|
const qreal targetRight = targetLeft + targetWidth - 1;
|
||||||
|
|
||||||
const bool isInTarget = (targetWidth >= movingWidth &&
|
const bool isInTarget = (targetWidth >= movingWidth && movingLeft >= targetLeft && movingRight <= targetRight)
|
||||||
movingLeft >= targetLeft &&
|
|| (targetWidth < movingWidth && movingLeft <= targetLeft && movingRight >= targetRight);
|
||||||
movingRight <= targetRight) ||
|
|
||||||
(targetWidth < movingWidth &&
|
|
||||||
movingLeft <= targetLeft &&
|
|
||||||
movingRight >= targetRight);
|
|
||||||
|
|
||||||
if (isInTarget) {
|
if (isInTarget) {
|
||||||
return targetIndex;
|
return targetIndex;
|
||||||
|
@ -627,4 +606,3 @@ qreal KItemListHeaderWidget::roleXPosition(const QByteArray& role) const
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,9 +62,7 @@ Q_SIGNALS:
|
||||||
* Is emitted if the width of a visible role has been adjusted by the user with the mouse
|
* Is emitted if the width of a visible role has been adjusted by the user with the mouse
|
||||||
* (no signal is emitted if KItemListHeader::setVisibleRoleWidth() is invoked).
|
* (no signal is emitted if KItemListHeader::setVisibleRoleWidth() is invoked).
|
||||||
*/
|
*/
|
||||||
void columnWidthChanged(const QByteArray& role,
|
void columnWidthChanged(const QByteArray &role, qreal currentWidth, qreal previousWidth);
|
||||||
qreal currentWidth,
|
|
||||||
qreal previousWidth);
|
|
||||||
|
|
||||||
void sidePaddingChanged(qreal width);
|
void sidePaddingChanged(qreal width);
|
||||||
|
|
||||||
|
@ -72,8 +70,7 @@ Q_SIGNALS:
|
||||||
* Is emitted if the user has released the mouse button after adjusting the
|
* Is emitted if the user has released the mouse button after adjusting the
|
||||||
* width of a visible role.
|
* width of a visible role.
|
||||||
*/
|
*/
|
||||||
void columnWidthChangeFinished(const QByteArray& role,
|
void columnWidthChangeFinished(const QByteArray &role, qreal currentWidth);
|
||||||
qreal currentWidth);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is emitted if the position of the column has been changed.
|
* Is emitted if the position of the column has been changed.
|
||||||
|
@ -110,18 +107,12 @@ private Q_SLOTS:
|
||||||
void slotSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous);
|
void slotSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
enum PaddingGrip {
|
||||||
enum PaddingGrip
|
|
||||||
{
|
|
||||||
Leading,
|
Leading,
|
||||||
Trailing,
|
Trailing,
|
||||||
};
|
};
|
||||||
|
|
||||||
void paintRole(QPainter* painter,
|
void paintRole(QPainter *painter, const QByteArray &role, const QRectF &rect, int orderIndex, QWidget *widget = nullptr) const;
|
||||||
const QByteArray& role,
|
|
||||||
const QRectF& rect,
|
|
||||||
int orderIndex,
|
|
||||||
QWidget* widget = nullptr) const;
|
|
||||||
|
|
||||||
void updatePressedRoleIndex(const QPointF &pos);
|
void updatePressedRoleIndex(const QPointF &pos);
|
||||||
void updateHoveredRoleIndex(const QPointF &pos);
|
void updateHoveredRoleIndex(const QPointF &pos);
|
||||||
|
@ -147,13 +138,7 @@ private:
|
||||||
qreal roleXPosition(const QByteArray &role) const;
|
qreal roleXPosition(const QByteArray &role) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum RoleOperation
|
enum RoleOperation { NoRoleOperation, ResizeRoleOperation, ResizePaddingColumnOperation, MoveRoleOperation };
|
||||||
{
|
|
||||||
NoRoleOperation,
|
|
||||||
ResizeRoleOperation,
|
|
||||||
ResizePaddingColumnOperation,
|
|
||||||
MoveRoleOperation
|
|
||||||
};
|
|
||||||
|
|
||||||
bool m_automaticColumnResizing;
|
bool m_automaticColumnResizing;
|
||||||
KItemModelBase *m_model;
|
KItemModelBase *m_model;
|
||||||
|
@ -168,8 +153,7 @@ private:
|
||||||
RoleOperation m_roleOperation;
|
RoleOperation m_roleOperation;
|
||||||
QPointF m_pressedMousePos;
|
QPointF m_pressedMousePos;
|
||||||
|
|
||||||
struct MovingRole
|
struct MovingRole {
|
||||||
{
|
|
||||||
QPixmap pixmap;
|
QPixmap pixmap;
|
||||||
int x;
|
int x;
|
||||||
int xDec;
|
int xDec;
|
||||||
|
@ -178,5 +162,3 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
|
|
||||||
#include "kitemlistkeyboardsearchmanager.h"
|
#include "kitemlistkeyboardsearchmanager.h"
|
||||||
|
|
||||||
KItemListKeyboardSearchManager::KItemListKeyboardSearchManager(QObject* parent) :
|
KItemListKeyboardSearchManager::KItemListKeyboardSearchManager(QObject *parent)
|
||||||
QObject(parent),
|
: QObject(parent)
|
||||||
m_isSearchRestarted(false),
|
, m_isSearchRestarted(false)
|
||||||
m_timeout(1000)
|
, m_timeout(1000)
|
||||||
{
|
{
|
||||||
m_keyboardInputTime.invalidate();
|
m_keyboardInputTime.invalidate();
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ class DOLPHIN_EXPORT KItemListKeyboardSearchManager : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit KItemListKeyboardSearchManager(QObject *parent = nullptr);
|
explicit KItemListKeyboardSearchManager(QObject *parent = nullptr);
|
||||||
~KItemListKeyboardSearchManager() override;
|
~KItemListKeyboardSearchManager() override;
|
||||||
|
|
||||||
|
@ -82,5 +81,3 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
|
|
||||||
#include <KIO/Global>
|
#include <KIO/Global>
|
||||||
|
|
||||||
KItemListRoleEditor::KItemListRoleEditor(QWidget *parent) :
|
KItemListRoleEditor::KItemListRoleEditor(QWidget *parent)
|
||||||
KTextEdit(parent),
|
: KTextEdit(parent)
|
||||||
m_role(),
|
, m_role()
|
||||||
m_blockFinishedSignal(false)
|
, m_blockFinishedSignal(false)
|
||||||
{
|
{
|
||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
@ -118,12 +118,8 @@ void KItemListRoleEditor::keyPressEvent(QKeyEvent* event)
|
||||||
case Qt::Key_Home:
|
case Qt::Key_Home:
|
||||||
case Qt::Key_End: {
|
case Qt::Key_End: {
|
||||||
if (event->modifiers() == Qt::NoModifier || event->modifiers() == Qt::ShiftModifier) {
|
if (event->modifiers() == Qt::NoModifier || event->modifiers() == Qt::ShiftModifier) {
|
||||||
const QTextCursor::MoveOperation op = event->key() == Qt::Key_Home
|
const QTextCursor::MoveOperation op = event->key() == Qt::Key_Home ? QTextCursor::Start : QTextCursor::End;
|
||||||
? QTextCursor::Start
|
const QTextCursor::MoveMode mode = event->modifiers() == Qt::NoModifier ? QTextCursor::MoveAnchor : QTextCursor::KeepAnchor;
|
||||||
: QTextCursor::End;
|
|
||||||
const QTextCursor::MoveMode mode = event->modifiers() == Qt::NoModifier
|
|
||||||
? QTextCursor::MoveAnchor
|
|
||||||
: QTextCursor::KeepAnchor;
|
|
||||||
QTextCursor cursor = textCursor();
|
QTextCursor cursor = textCursor();
|
||||||
cursor.movePosition(op, mode);
|
cursor.movePosition(op, mode);
|
||||||
setTextCursor(cursor);
|
setTextCursor(cursor);
|
||||||
|
@ -173,4 +169,3 @@ void KItemListRoleEditor::emitRoleEditingFinished(EditResultDirection direction)
|
||||||
Q_EMIT roleEditingFinished(m_role, ret);
|
Q_EMIT roleEditingFinished(m_role, ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,7 @@ enum EditResultDirection{
|
||||||
};
|
};
|
||||||
Q_DECLARE_METATYPE(EditResultDirection)
|
Q_DECLARE_METATYPE(EditResultDirection)
|
||||||
|
|
||||||
struct EditResult
|
struct EditResult {
|
||||||
{
|
|
||||||
QString newName;
|
QString newName;
|
||||||
EditResultDirection direction;
|
EditResultDirection direction;
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,11 +6,11 @@
|
||||||
|
|
||||||
#include "kitemlistrubberband.h"
|
#include "kitemlistrubberband.h"
|
||||||
|
|
||||||
KItemListRubberBand::KItemListRubberBand(QObject* parent) :
|
KItemListRubberBand::KItemListRubberBand(QObject *parent)
|
||||||
QObject(parent),
|
: QObject(parent)
|
||||||
m_active(false),
|
, m_active(false)
|
||||||
m_startPos(),
|
, m_startPos()
|
||||||
m_endPos()
|
, m_endPos()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,4 +74,3 @@ bool KItemListRubberBand::isActive() const
|
||||||
{
|
{
|
||||||
return m_active;
|
return m_active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,5 +45,3 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,10 @@
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
KItemListSelectionToggle::KItemListSelectionToggle(QGraphicsItem* parent) :
|
KItemListSelectionToggle::KItemListSelectionToggle(QGraphicsItem *parent)
|
||||||
QGraphicsWidget(parent),
|
: QGraphicsWidget(parent)
|
||||||
m_checked(false),
|
, m_checked(false)
|
||||||
m_hovered(false)
|
, m_hovered(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,4 +99,3 @@ int KItemListSelectionToggle::iconSize() const
|
||||||
|
|
||||||
return iconSize;
|
return iconSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
#include <QGraphicsWidget>
|
#include <QGraphicsWidget>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Allows to toggle between the selected and unselected state of an item.
|
* @brief Allows to toggle between the selected and unselected state of an item.
|
||||||
*/
|
*/
|
||||||
|
@ -44,5 +43,3 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,12 @@
|
||||||
#include "kitemlistsizehintresolver.h"
|
#include "kitemlistsizehintresolver.h"
|
||||||
#include "kitemviews/kitemlistview.h"
|
#include "kitemviews/kitemlistview.h"
|
||||||
|
|
||||||
KItemListSizeHintResolver::KItemListSizeHintResolver(const KItemListView* itemListView) :
|
KItemListSizeHintResolver::KItemListSizeHintResolver(const KItemListView *itemListView)
|
||||||
m_itemListView(itemListView),
|
: m_itemListView(itemListView)
|
||||||
m_logicalHeightHintCache(),
|
, m_logicalHeightHintCache()
|
||||||
m_logicalWidthHint(0.0),
|
, m_logicalWidthHint(0.0)
|
||||||
m_minHeightHint(0.0),
|
, m_minHeightHint(0.0)
|
||||||
m_needsResolving(false)
|
, m_needsResolving(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,20 +12,18 @@
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
#include <QWheelEvent>
|
#include <QWheelEvent>
|
||||||
|
|
||||||
KItemListSmoothScroller::KItemListSmoothScroller(QScrollBar* scrollBar,
|
KItemListSmoothScroller::KItemListSmoothScroller(QScrollBar *scrollBar, QObject *parent)
|
||||||
QObject* parent) :
|
: QObject(parent)
|
||||||
QObject(parent),
|
, m_scrollBarPressed(false)
|
||||||
m_scrollBarPressed(false),
|
, m_smoothScrolling(true)
|
||||||
m_smoothScrolling(true),
|
, m_scrollBar(scrollBar)
|
||||||
m_scrollBar(scrollBar),
|
, m_animation(nullptr)
|
||||||
m_animation(nullptr)
|
|
||||||
{
|
{
|
||||||
m_animation = new QPropertyAnimation(this);
|
m_animation = new QPropertyAnimation(this);
|
||||||
const int animationDuration = m_scrollBar->style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, m_scrollBar);
|
const int animationDuration = m_scrollBar->style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, m_scrollBar);
|
||||||
const bool animationEnabled = (animationDuration > 0);
|
const bool animationEnabled = (animationDuration > 0);
|
||||||
m_animation->setDuration(animationEnabled ? animationDuration : 1);
|
m_animation->setDuration(animationEnabled ? animationDuration : 1);
|
||||||
connect(m_animation, &QPropertyAnimation::stateChanged,
|
connect(m_animation, &QPropertyAnimation::stateChanged, this, &KItemListSmoothScroller::slotAnimationStateChanged);
|
||||||
this, &KItemListSmoothScroller::slotAnimationStateChanged);
|
|
||||||
|
|
||||||
m_scrollBar->installEventFilter(this);
|
m_scrollBar->installEventFilter(this);
|
||||||
}
|
}
|
||||||
|
@ -168,8 +166,7 @@ bool KItemListSmoothScroller::eventFilter(QObject* obj, QEvent* event)
|
||||||
return QObject::eventFilter(obj, event);
|
return QObject::eventFilter(obj, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KItemListSmoothScroller::slotAnimationStateChanged(QAbstractAnimation::State newState,
|
void KItemListSmoothScroller::slotAnimationStateChanged(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
|
||||||
QAbstractAnimation::State oldState)
|
|
||||||
{
|
{
|
||||||
Q_UNUSED(oldState)
|
Q_UNUSED(oldState)
|
||||||
if (newState == QAbstractAnimation::Stopped && m_smoothScrolling && !m_scrollBarPressed) {
|
if (newState == QAbstractAnimation::Stopped && m_smoothScrolling && !m_scrollBarPressed) {
|
||||||
|
@ -198,4 +195,3 @@ void KItemListSmoothScroller::handleWheelEvent(QWheelEvent* event)
|
||||||
|
|
||||||
m_smoothScrolling = previous;
|
m_smoothScrolling = previous;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,7 @@ class DOLPHIN_EXPORT KItemListSmoothScroller : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit KItemListSmoothScroller(QScrollBar* scrollBar,
|
explicit KItemListSmoothScroller(QScrollBar *scrollBar, QObject *parent = nullptr);
|
||||||
QObject* parent = nullptr);
|
|
||||||
~KItemListSmoothScroller() override;
|
~KItemListSmoothScroller() override;
|
||||||
|
|
||||||
void setScrollBar(QScrollBar *scrollBar);
|
void setScrollBar(QScrollBar *scrollBar);
|
||||||
|
@ -74,12 +73,12 @@ Q_SIGNALS:
|
||||||
* Emitted when the scrolling animation has finished
|
* Emitted when the scrolling animation has finished
|
||||||
*/
|
*/
|
||||||
void scrollingStopped();
|
void scrollingStopped();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void slotAnimationStateChanged(QAbstractAnimation::State newState,
|
void slotAnimationStateChanged(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
|
||||||
QAbstractAnimation::State oldState);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_scrollBarPressed;
|
bool m_scrollBarPressed;
|
||||||
|
@ -89,5 +88,3 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,11 @@
|
||||||
|
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
|
|
||||||
KItemListViewAnimation::KItemListViewAnimation(QObject* parent) :
|
KItemListViewAnimation::KItemListViewAnimation(QObject *parent)
|
||||||
QObject(parent),
|
: QObject(parent)
|
||||||
m_scrollOrientation(Qt::Vertical),
|
, m_scrollOrientation(Qt::Vertical)
|
||||||
m_scrollOffset(0),
|
, m_scrollOffset(0)
|
||||||
m_animation()
|
, m_animation()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,8 +65,7 @@ void KItemListViewAnimation::setScrollOffset(qreal offset)
|
||||||
if (type == MovingAnimation) {
|
if (type == MovingAnimation) {
|
||||||
// Stop the animation, calculate the moved start- and end-value
|
// Stop the animation, calculate the moved start- and end-value
|
||||||
// and restart the animation for the remaining duration.
|
// and restart the animation for the remaining duration.
|
||||||
const int remainingDuration = propertyAnim->duration()
|
const int remainingDuration = propertyAnim->duration() - propertyAnim->currentTime();
|
||||||
- propertyAnim->currentTime();
|
|
||||||
|
|
||||||
const bool block = propertyAnim->signalsBlocked();
|
const bool block = propertyAnim->signalsBlocked();
|
||||||
propertyAnim->blockSignals(true);
|
propertyAnim->blockSignals(true);
|
||||||
|
@ -172,11 +171,18 @@ void KItemListViewAnimation::stop(QGraphicsWidget* widget, AnimationType type)
|
||||||
propertyAnim->stop();
|
propertyAnim->stop();
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case MovingAnimation: break;
|
case MovingAnimation:
|
||||||
case CreateAnimation: widget->setOpacity(1.0); break;
|
break;
|
||||||
case DeleteAnimation: widget->setOpacity(0.0); break;
|
case CreateAnimation:
|
||||||
case ResizeAnimation: break;
|
widget->setOpacity(1.0);
|
||||||
default: break;
|
break;
|
||||||
|
case DeleteAnimation:
|
||||||
|
widget->setOpacity(0.0);
|
||||||
|
break;
|
||||||
|
case ResizeAnimation:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_animation[type].remove(widget);
|
m_animation[type].remove(widget);
|
||||||
|
@ -228,4 +234,3 @@ void KItemListViewAnimation::slotFinished()
|
||||||
}
|
}
|
||||||
Q_ASSERT(false);
|
Q_ASSERT(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,14 +28,7 @@ class DOLPHIN_EXPORT KItemListViewAnimation : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum AnimationType {
|
enum AnimationType { MovingAnimation, CreateAnimation, DeleteAnimation, ResizeAnimation, IconResizeAnimation, AnimationTypeCount };
|
||||||
MovingAnimation,
|
|
||||||
CreateAnimation,
|
|
||||||
DeleteAnimation,
|
|
||||||
ResizeAnimation,
|
|
||||||
IconResizeAnimation,
|
|
||||||
AnimationTypeCount
|
|
||||||
};
|
|
||||||
|
|
||||||
explicit KItemListViewAnimation(QObject *parent = nullptr);
|
explicit KItemListViewAnimation(QObject *parent = nullptr);
|
||||||
~KItemListViewAnimation() override;
|
~KItemListViewAnimation() override;
|
||||||
|
@ -87,5 +80,3 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,32 +14,32 @@
|
||||||
|
|
||||||
// #define KITEMLISTVIEWLAYOUTER_DEBUG
|
// #define KITEMLISTVIEWLAYOUTER_DEBUG
|
||||||
|
|
||||||
KItemListViewLayouter::KItemListViewLayouter(KItemListSizeHintResolver* sizeHintResolver, QObject* parent) :
|
KItemListViewLayouter::KItemListViewLayouter(KItemListSizeHintResolver *sizeHintResolver, QObject *parent)
|
||||||
QObject(parent),
|
: QObject(parent)
|
||||||
m_dirty(true),
|
, m_dirty(true)
|
||||||
m_visibleIndexesDirty(true),
|
, m_visibleIndexesDirty(true)
|
||||||
m_scrollOrientation(Qt::Vertical),
|
, m_scrollOrientation(Qt::Vertical)
|
||||||
m_size(),
|
, m_size()
|
||||||
m_itemSize(128, 128),
|
, m_itemSize(128, 128)
|
||||||
m_itemMargin(),
|
, m_itemMargin()
|
||||||
m_headerHeight(0),
|
, m_headerHeight(0)
|
||||||
m_model(nullptr),
|
, m_model(nullptr)
|
||||||
m_sizeHintResolver(sizeHintResolver),
|
, m_sizeHintResolver(sizeHintResolver)
|
||||||
m_scrollOffset(0),
|
, m_scrollOffset(0)
|
||||||
m_maximumScrollOffset(0),
|
, m_maximumScrollOffset(0)
|
||||||
m_itemOffset(0),
|
, m_itemOffset(0)
|
||||||
m_maximumItemOffset(0),
|
, m_maximumItemOffset(0)
|
||||||
m_firstVisibleIndex(-1),
|
, m_firstVisibleIndex(-1)
|
||||||
m_lastVisibleIndex(-1),
|
, m_lastVisibleIndex(-1)
|
||||||
m_columnWidth(0),
|
, m_columnWidth(0)
|
||||||
m_xPosInc(0),
|
, m_xPosInc(0)
|
||||||
m_columnCount(0),
|
, m_columnCount(0)
|
||||||
m_rowOffsets(),
|
, m_rowOffsets()
|
||||||
m_columnOffsets(),
|
, m_columnOffsets()
|
||||||
m_groupItemIndexes(),
|
, m_groupItemIndexes()
|
||||||
m_groupHeaderHeight(0),
|
, m_groupHeaderHeight(0)
|
||||||
m_groupHeaderMargin(0),
|
, m_groupHeaderMargin(0)
|
||||||
m_itemInfos()
|
, m_itemInfos()
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_sizeHintResolver);
|
Q_ASSERT(m_sizeHintResolver);
|
||||||
}
|
}
|
||||||
|
@ -271,9 +271,8 @@ QRectF KItemListViewLayouter::groupHeaderRect(int index) const
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const qreal itemWidth = (m_scrollOrientation == Qt::Vertical)
|
const qreal itemWidth =
|
||||||
? m_sizeHintResolver->sizeHint(index).width()
|
(m_scrollOrientation == Qt::Vertical) ? m_sizeHintResolver->sizeHint(index).width() : m_sizeHintResolver->sizeHint(index).height();
|
||||||
: m_sizeHintResolver->sizeHint(index).height();
|
|
||||||
|
|
||||||
if (itemWidth > headerWidth) {
|
if (itemWidth > headerWidth) {
|
||||||
headerWidth = itemWidth;
|
headerWidth = itemWidth;
|
||||||
|
@ -294,9 +293,7 @@ int KItemListViewLayouter::itemColumn(int index) const
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (m_scrollOrientation == Qt::Vertical)
|
return (m_scrollOrientation == Qt::Vertical) ? m_itemInfos[index].column : m_itemInfos[index].row;
|
||||||
? m_itemInfos[index].column
|
|
||||||
: m_itemInfos[index].row;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int KItemListViewLayouter::itemRow(int index) const
|
int KItemListViewLayouter::itemRow(int index) const
|
||||||
|
@ -306,9 +303,7 @@ int KItemListViewLayouter::itemRow(int index) const
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (m_scrollOrientation == Qt::Vertical)
|
return (m_scrollOrientation == Qt::Vertical) ? m_itemInfos[index].row : m_itemInfos[index].column;
|
||||||
? m_itemInfos[index].row
|
|
||||||
: m_itemInfos[index].column;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int KItemListViewLayouter::maximumVisibleItems() const
|
int KItemListViewLayouter::maximumVisibleItems() const
|
||||||
|
@ -336,7 +331,6 @@ void KItemListViewLayouter::markAsDirty()
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef QT_NO_DEBUG
|
#ifndef QT_NO_DEBUG
|
||||||
bool KItemListViewLayouter::isDirty()
|
bool KItemListViewLayouter::isDirty()
|
||||||
{
|
{
|
||||||
|
@ -347,7 +341,9 @@ void KItemListViewLayouter::markAsDirty()
|
||||||
void KItemListViewLayouter::doLayout()
|
void KItemListViewLayouter::doLayout()
|
||||||
{
|
{
|
||||||
// we always want to update visible indexes after performing a layout
|
// we always want to update visible indexes after performing a layout
|
||||||
auto qsg = qScopeGuard([this] { updateVisibleIndexes(); });
|
auto qsg = qScopeGuard([this] {
|
||||||
|
updateVisibleIndexes();
|
||||||
|
});
|
||||||
|
|
||||||
if (!m_dirty) {
|
if (!m_dirty) {
|
||||||
return;
|
return;
|
||||||
|
@ -409,11 +405,13 @@ void KItemListViewLayouter::doLayout()
|
||||||
currentOffset += m_groupHeaderHeight;
|
currentOffset += m_groupHeaderHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QGuiApplication::isLeftToRight()) for (int column = 0; column < m_columnCount; ++column) {
|
if (QGuiApplication::isLeftToRight())
|
||||||
|
for (int column = 0; column < m_columnCount; ++column) {
|
||||||
m_columnOffsets[column] = currentOffset;
|
m_columnOffsets[column] = currentOffset;
|
||||||
currentOffset += m_columnWidth;
|
currentOffset += m_columnWidth;
|
||||||
}
|
}
|
||||||
else for (int column = 0; column < m_columnCount; ++column) {
|
else
|
||||||
|
for (int column = 0; column < m_columnCount; ++column) {
|
||||||
m_columnOffsets[column] = currentOffset - m_columnWidth;
|
m_columnOffsets[column] = currentOffset - m_columnWidth;
|
||||||
currentOffset -= m_columnWidth;
|
currentOffset -= m_columnWidth;
|
||||||
}
|
}
|
||||||
|
@ -615,4 +613,3 @@ qreal KItemListViewLayouter::minimumGroupHeaderWidth() const
|
||||||
{
|
{
|
||||||
return 100;
|
return 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -223,5 +223,3 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,45 +19,25 @@
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
static const quint32 stackBlur8Mul[255] =
|
static const quint32 stackBlur8Mul[255] = {
|
||||||
{
|
512, 512, 456, 512, 328, 456, 335, 512, 405, 328, 271, 456, 388, 335, 292, 512, 454, 405, 364, 328, 298, 271, 496, 456, 420, 388, 360, 335, 312,
|
||||||
512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,
|
292, 273, 512, 482, 454, 428, 405, 383, 364, 345, 328, 312, 298, 284, 271, 259, 496, 475, 456, 437, 420, 404, 388, 374, 360, 347, 335, 323, 312,
|
||||||
454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,
|
302, 292, 282, 273, 265, 512, 497, 482, 468, 454, 441, 428, 417, 405, 394, 383, 373, 364, 354, 345, 337, 328, 320, 312, 305, 298, 291, 284, 278,
|
||||||
482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,
|
271, 265, 259, 507, 496, 485, 475, 465, 456, 446, 437, 428, 420, 412, 404, 396, 388, 381, 374, 367, 360, 354, 347, 341, 335, 329, 323, 318, 312,
|
||||||
437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,
|
307, 302, 297, 292, 287, 282, 278, 273, 269, 265, 261, 512, 505, 497, 489, 482, 475, 468, 461, 454, 447, 441, 435, 428, 422, 417, 411, 405, 399,
|
||||||
497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,
|
394, 389, 383, 378, 373, 368, 364, 359, 354, 350, 345, 341, 337, 332, 328, 324, 320, 316, 312, 309, 305, 301, 298, 294, 291, 287, 284, 281, 278,
|
||||||
320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,
|
274, 271, 268, 265, 262, 259, 257, 507, 501, 496, 491, 485, 480, 475, 470, 465, 460, 456, 451, 446, 442, 437, 433, 428, 424, 420, 416, 412, 408,
|
||||||
446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,
|
404, 400, 396, 392, 388, 385, 381, 377, 374, 370, 367, 363, 360, 357, 354, 350, 347, 344, 341, 338, 335, 332, 329, 326, 323, 320, 318, 315, 312,
|
||||||
329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,
|
310, 307, 304, 302, 299, 297, 294, 292, 289, 287, 285, 282, 280, 278, 275, 273, 271, 269, 267, 265, 263, 261, 259};
|
||||||
505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,
|
|
||||||
399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,
|
|
||||||
324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,
|
|
||||||
268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,
|
|
||||||
451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,
|
|
||||||
385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,
|
|
||||||
332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,
|
|
||||||
289,287,285,282,280,278,275,273,271,269,267,265,263,261,259
|
|
||||||
};
|
|
||||||
|
|
||||||
static const quint32 stackBlur8Shr[255] =
|
static const quint32 stackBlur8Shr[255] = {
|
||||||
{
|
9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19,
|
||||||
9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17,
|
19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
|
||||||
17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19,
|
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
|
||||||
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20,
|
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
|
||||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21,
|
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24,
|
||||||
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
|
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||||
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22,
|
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24};
|
||||||
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
|
|
||||||
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23,
|
|
||||||
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
|
|
||||||
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
|
|
||||||
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
|
|
||||||
23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
|
||||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
|
||||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
|
||||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
|
||||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24
|
|
||||||
};
|
|
||||||
|
|
||||||
static void blurHorizontal(QImage &image, unsigned int *stack, int div, int radius)
|
static void blurHorizontal(QImage &image, unsigned int *stack, int div, int radius)
|
||||||
{
|
{
|
||||||
|
@ -236,16 +216,15 @@ static void shadowBlur(QImage& image, float radius, const QColor& color)
|
||||||
p.fillRect(image.rect(), color);
|
p.fillRect(image.rect(), color);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace
|
||||||
|
{
|
||||||
/** Helper class for drawing frames for KPixmapModifier::applyFrame(). */
|
/** Helper class for drawing frames for KPixmapModifier::applyFrame(). */
|
||||||
class TileSet
|
class TileSet
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum { LeftMargin = 3, TopMargin = 2, RightMargin = 3, BottomMargin = 4 };
|
enum { LeftMargin = 3, TopMargin = 2, RightMargin = 3, BottomMargin = 4 };
|
||||||
|
|
||||||
enum Tile { TopLeftCorner = 0, TopSide, TopRightCorner, LeftSide,
|
enum Tile { TopLeftCorner = 0, TopSide, TopRightCorner, LeftSide, RightSide, BottomLeftCorner, BottomSide, BottomRightCorner, NumTiles };
|
||||||
RightSide, BottomLeftCorner, BottomSide, BottomRightCorner,
|
|
||||||
NumTiles };
|
|
||||||
|
|
||||||
TileSet()
|
TileSet()
|
||||||
{
|
{
|
||||||
|
@ -287,8 +266,7 @@ namespace {
|
||||||
}
|
}
|
||||||
p->drawPixmap(r.right() - 8 + 1, r.bottom() - 8 + 1, m_tiles[BottomRightCorner]);
|
p->drawPixmap(r.right() - 8 + 1, r.bottom() - 8 + 1, m_tiles[BottomRightCorner]);
|
||||||
|
|
||||||
const QRect contentRect = r.adjusted(LeftMargin + 1, TopMargin + 1,
|
const QRect contentRect = r.adjusted(LeftMargin + 1, TopMargin + 1, -(RightMargin + 1), -(BottomMargin + 1));
|
||||||
-(RightMargin + 1), -(BottomMargin + 1));
|
|
||||||
p->fillRect(contentRect, Qt::transparent);
|
p->fillRect(contentRect, Qt::transparent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,8 +297,7 @@ void KPixmapModifier::applyFrame(QPixmap& icon, const QSize& scaledSize)
|
||||||
qreal dpr = qApp->devicePixelRatio();
|
qreal dpr = qApp->devicePixelRatio();
|
||||||
|
|
||||||
// Resize the icon to the maximum size minus the space required for the frame
|
// Resize the icon to the maximum size minus the space required for the frame
|
||||||
const QSize size(scaledSize.width() - TileSet::LeftMargin - TileSet::RightMargin,
|
const QSize size(scaledSize.width() - TileSet::LeftMargin - TileSet::RightMargin, scaledSize.height() - TileSet::TopMargin - TileSet::BottomMargin);
|
||||||
scaledSize.height() - TileSet::TopMargin - TileSet::BottomMargin);
|
|
||||||
scale(icon, size * dpr);
|
scale(icon, size * dpr);
|
||||||
icon.setDevicePixelRatio(dpr);
|
icon.setDevicePixelRatio(dpr);
|
||||||
|
|
||||||
|
@ -341,7 +318,5 @@ void KPixmapModifier::applyFrame(QPixmap& icon, const QSize& scaledSize)
|
||||||
|
|
||||||
QSize KPixmapModifier::sizeInsideFrame(const QSize &frameSize)
|
QSize KPixmapModifier::sizeInsideFrame(const QSize &frameSize)
|
||||||
{
|
{
|
||||||
return QSize(frameSize.width() - TileSet::LeftMargin - TileSet::RightMargin,
|
return QSize(frameSize.width() - TileSet::LeftMargin - TileSet::RightMargin, frameSize.height() - TileSet::TopMargin - TileSet::BottomMargin);
|
||||||
frameSize.height() - TileSet::TopMargin - TileSet::BottomMargin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,5 +39,3 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
61
src/main.cpp
61
src/main.cpp
|
@ -6,23 +6,23 @@
|
||||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config-dolphin.h"
|
||||||
#include "dbusinterface.h"
|
#include "dbusinterface.h"
|
||||||
#include "dolphin_generalsettings.h"
|
#include "dolphin_generalsettings.h"
|
||||||
#include "dolphin_version.h"
|
#include "dolphin_version.h"
|
||||||
#include "dolphindebug.h"
|
#include "dolphindebug.h"
|
||||||
#include "dolphinmainwindow.h"
|
#include "dolphinmainwindow.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "config-dolphin.h"
|
|
||||||
#if HAVE_KUSERFEEDBACK
|
#if HAVE_KUSERFEEDBACK
|
||||||
#include "userfeedback/dolphinfeedbackprovider.h"
|
#include "userfeedback/dolphinfeedbackprovider.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <KAboutData>
|
#include <KAboutData>
|
||||||
|
#include <KConfigGui>
|
||||||
#include <KCrash>
|
#include <KCrash>
|
||||||
#include <KDBusService>
|
#include <KDBusService>
|
||||||
#include <KLocalizedString>
|
|
||||||
#include <KConfigGui>
|
|
||||||
#include <KIO/PreviewJob>
|
#include <KIO/PreviewJob>
|
||||||
|
#include <KLocalizedString>
|
||||||
#include <KWindowSystem>
|
#include <KWindowSystem>
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
@ -54,12 +54,10 @@ int main(int argc, char **argv)
|
||||||
// Prohibit using sudo or kdesu (but allow using the root user directly)
|
// Prohibit using sudo or kdesu (but allow using the root user directly)
|
||||||
if (getuid() == 0) {
|
if (getuid() == 0) {
|
||||||
if (!qEnvironmentVariableIsEmpty("SUDO_USER")) {
|
if (!qEnvironmentVariableIsEmpty("SUDO_USER")) {
|
||||||
std::cout << "Running Dolphin with sudo can cause bugs and expose you to security vulnerabilities."
|
std::cout << "Running Dolphin with sudo can cause bugs and expose you to security vulnerabilities." << std::endl;
|
||||||
<< std::endl;
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
} else if (!qEnvironmentVariableIsEmpty("KDESU_USER")) {
|
} else if (!qEnvironmentVariableIsEmpty("KDESU_USER")) {
|
||||||
std::cout << "Running Dolphin with kdesu can cause bugs and expose you to security vulnerabilities."
|
std::cout << "Running Dolphin with kdesu can cause bugs and expose you to security vulnerabilities." << std::endl;
|
||||||
<< std::endl;
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,7 +86,9 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
KLocalizedString::setApplicationDomain("dolphin");
|
KLocalizedString::setApplicationDomain("dolphin");
|
||||||
|
|
||||||
KAboutData aboutData(QStringLiteral("dolphin"), i18n("Dolphin"), QStringLiteral(DOLPHIN_VERSION_STRING),
|
KAboutData aboutData(QStringLiteral("dolphin"),
|
||||||
|
i18n("Dolphin"),
|
||||||
|
QStringLiteral(DOLPHIN_VERSION_STRING),
|
||||||
i18nc("@title", "File Manager"),
|
i18nc("@title", "File Manager"),
|
||||||
KAboutLicense::GPL,
|
KAboutLicense::GPL,
|
||||||
i18nc("@info:credit", "(C) 2006-2022 The Dolphin Developers"));
|
i18nc("@info:credit", "(C) 2006-2022 The Dolphin Developers"));
|
||||||
|
@ -111,30 +111,14 @@ int main(int argc, char **argv)
|
||||||
aboutData.addAuthor(i18nc("@info:credit", "Peter Penz"),
|
aboutData.addAuthor(i18nc("@info:credit", "Peter Penz"),
|
||||||
i18nc("@info:credit", "Maintainer and developer (2006-2012)"),
|
i18nc("@info:credit", "Maintainer and developer (2006-2012)"),
|
||||||
QStringLiteral("peter.penz19@gmail.com"));
|
QStringLiteral("peter.penz19@gmail.com"));
|
||||||
aboutData.addAuthor(i18nc("@info:credit", "Sebastian Trüg"),
|
aboutData.addAuthor(i18nc("@info:credit", "Sebastian Trüg"), i18nc("@info:credit", "Developer"), QStringLiteral("trueg@kde.org"));
|
||||||
i18nc("@info:credit", "Developer"),
|
aboutData.addAuthor(i18nc("@info:credit", "David Faure"), i18nc("@info:credit", "Developer"), QStringLiteral("faure@kde.org"));
|
||||||
QStringLiteral("trueg@kde.org"));
|
aboutData.addAuthor(i18nc("@info:credit", "Aaron J. Seigo"), i18nc("@info:credit", "Developer"), QStringLiteral("aseigo@kde.org"));
|
||||||
aboutData.addAuthor(i18nc("@info:credit", "David Faure"),
|
aboutData.addAuthor(i18nc("@info:credit", "Rafael Fernández López"), i18nc("@info:credit", "Developer"), QStringLiteral("ereslibre@kde.org"));
|
||||||
i18nc("@info:credit", "Developer"),
|
aboutData.addAuthor(i18nc("@info:credit", "Kevin Ottens"), i18nc("@info:credit", "Developer"), QStringLiteral("ervin@kde.org"));
|
||||||
QStringLiteral("faure@kde.org"));
|
aboutData.addAuthor(i18nc("@info:credit", "Holger Freyther"), i18nc("@info:credit", "Developer"), QStringLiteral("freyther@gmx.net"));
|
||||||
aboutData.addAuthor(i18nc("@info:credit", "Aaron J. Seigo"),
|
aboutData.addAuthor(i18nc("@info:credit", "Max Blazejak"), i18nc("@info:credit", "Developer"), QStringLiteral("m43ksrocks@gmail.com"));
|
||||||
i18nc("@info:credit", "Developer"),
|
aboutData.addAuthor(i18nc("@info:credit", "Michael Austin"), i18nc("@info:credit", "Documentation"), QStringLiteral("tuxedup@users.sourceforge.net"));
|
||||||
QStringLiteral("aseigo@kde.org"));
|
|
||||||
aboutData.addAuthor(i18nc("@info:credit", "Rafael Fernández López"),
|
|
||||||
i18nc("@info:credit", "Developer"),
|
|
||||||
QStringLiteral("ereslibre@kde.org"));
|
|
||||||
aboutData.addAuthor(i18nc("@info:credit", "Kevin Ottens"),
|
|
||||||
i18nc("@info:credit", "Developer"),
|
|
||||||
QStringLiteral("ervin@kde.org"));
|
|
||||||
aboutData.addAuthor(i18nc("@info:credit", "Holger Freyther"),
|
|
||||||
i18nc("@info:credit", "Developer"),
|
|
||||||
QStringLiteral("freyther@gmx.net"));
|
|
||||||
aboutData.addAuthor(i18nc("@info:credit", "Max Blazejak"),
|
|
||||||
i18nc("@info:credit", "Developer"),
|
|
||||||
QStringLiteral("m43ksrocks@gmail.com"));
|
|
||||||
aboutData.addAuthor(i18nc("@info:credit", "Michael Austin"),
|
|
||||||
i18nc("@info:credit", "Documentation"),
|
|
||||||
QStringLiteral("tuxedup@users.sourceforge.net"));
|
|
||||||
|
|
||||||
KAboutData::setApplicationData(aboutData);
|
KAboutData::setApplicationData(aboutData);
|
||||||
|
|
||||||
|
@ -142,11 +126,14 @@ int main(int argc, char **argv)
|
||||||
aboutData.setupCommandLine(&parser);
|
aboutData.setupCommandLine(&parser);
|
||||||
|
|
||||||
// command line options
|
// command line options
|
||||||
parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("select"), i18nc("@info:shell", "The files and folders passed as arguments "
|
parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("select"),
|
||||||
|
i18nc("@info:shell",
|
||||||
|
"The files and folders passed as arguments "
|
||||||
"will be selected.")));
|
"will be selected.")));
|
||||||
parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("split"), i18nc("@info:shell", "Dolphin will get started with a split view.")));
|
parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("split"), i18nc("@info:shell", "Dolphin will get started with a split view.")));
|
||||||
parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("new-window"), i18nc("@info:shell", "Dolphin will explicitly open in a new window.")));
|
parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("new-window"), i18nc("@info:shell", "Dolphin will explicitly open in a new window.")));
|
||||||
parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("daemon"), i18nc("@info:shell", "Start Dolphin Daemon (only required for DBus Interface).")));
|
parser.addOption(
|
||||||
|
QCommandLineOption(QStringList() << QStringLiteral("daemon"), i18nc("@info:shell", "Start Dolphin Daemon (only required for DBus Interface).")));
|
||||||
parser.addPositionalArgument(QStringLiteral("+[Url]"), i18nc("@info:shell", "Document to open"));
|
parser.addPositionalArgument(QStringLiteral("+[Url]"), i18nc("@info:shell", "Document to open"));
|
||||||
|
|
||||||
parser.process(app);
|
parser.process(app);
|
||||||
|
@ -159,7 +146,6 @@ int main(int argc, char **argv)
|
||||||
// We later mutate urls, so we need to store if it was empty originally
|
// We later mutate urls, so we need to store if it was empty originally
|
||||||
const bool startedWithURLs = !urls.isEmpty();
|
const bool startedWithURLs = !urls.isEmpty();
|
||||||
|
|
||||||
|
|
||||||
if (parser.isSet(QStringLiteral("daemon"))) {
|
if (parser.isSet(QStringLiteral("daemon"))) {
|
||||||
// Disable session management for the daemonized version
|
// Disable session management for the daemonized version
|
||||||
// See https://bugs.kde.org/show_bug.cgi?id=417219
|
// See https://bugs.kde.org/show_bug.cgi?id=417219
|
||||||
|
@ -180,7 +166,6 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!parser.isSet(QStringLiteral("new-window"))) {
|
if (!parser.isSet(QStringLiteral("new-window"))) {
|
||||||
|
|
||||||
QString token;
|
QString token;
|
||||||
if (KWindowSystem::isPlatformWayland()) {
|
if (KWindowSystem::isPlatformWayland()) {
|
||||||
token = qEnvironmentVariable("XDG_ACTIVATION_TOKEN");
|
token = qEnvironmentVariable("XDG_ACTIVATION_TOKEN");
|
||||||
|
@ -234,9 +219,7 @@ int main(int argc, char **argv)
|
||||||
// 2. The "remember state" setting is enabled or session restoration after
|
// 2. The "remember state" setting is enabled or session restoration after
|
||||||
// reboot is in use
|
// reboot is in use
|
||||||
// 3. There is a session available to restore
|
// 3. There is a session available to restore
|
||||||
if (!parser.isSet(QStringLiteral("new-window"))
|
if (!parser.isSet(QStringLiteral("new-window")) && (app.isSessionRestored() || GeneralSettings::rememberOpenedTabs())) {
|
||||||
&& (app.isSessionRestored() || GeneralSettings::rememberOpenedTabs())
|
|
||||||
) {
|
|
||||||
// Get saved state data for the last-closed Dolphin instance
|
// Get saved state data for the last-closed Dolphin instance
|
||||||
const QString serviceName = QStringLiteral("org.kde.dolphin-%1").arg(QCoreApplication::applicationPid());
|
const QString serviceName = QStringLiteral("org.kde.dolphin-%1").arg(QCoreApplication::applicationPid());
|
||||||
if (Dolphin::dolphinGuiInstances(serviceName).size() > 0) {
|
if (Dolphin::dolphinGuiInstances(serviceName).size() > 0) {
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user