1
0
mirror of https://invent.kde.org/system/dolphin synced 2024-07-04 17:30:55 +00:00

Add clang-format and format code as in Frameworks

This commit is contained in:
Serg Podtynnyi 2023-02-04 00:14:53 +07:00
parent ffff8af851
commit 38c34eeca3
260 changed files with 7209 additions and 7699 deletions

View File

@ -219,3 +219,10 @@ install(FILES completions/dolphin.zsh RENAME _dolphin DESTINATION ${KDE_INSTALL_
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)

View File

@ -5,8 +5,8 @@
*/
#include "dbusinterface.h"
#include "global.h"
#include "dolphin_generalsettings.h"
#include "global.h"
#include <KPropertiesDialog>
#include <KWindowSystem>
@ -14,10 +14,11 @@
#include <QDBusConnection>
#include <QDBusConnectionInterface>
DBusInterface::DBusInterface() :
QObject()
DBusInterface::DBusInterface()
: QObject()
{
QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/freedesktop/FileManager1"), this,
QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/freedesktop/FileManager1"),
this,
QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors);
QDBusConnectionInterface *sessionInterface = QDBusConnection::sessionBus().interface();
if (sessionInterface) {

View File

@ -14,15 +14,11 @@
#include <QDir>
#include <QStandardPaths>
DolphinBookmarkHandler::DolphinBookmarkHandler(DolphinMainWindow *mainWindow,
KActionCollection* collection,
QMenu* menu,
QObject* parent) :
QObject(parent),
m_mainWindow(mainWindow)
DolphinBookmarkHandler::DolphinBookmarkHandler(DolphinMainWindow *mainWindow, KActionCollection *collection, QMenu *menu, QObject *parent)
: QObject(parent)
, m_mainWindow(mainWindow)
{
QString bookmarksFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
QStringLiteral("kfile/bookmarks.xml"));
QString bookmarksFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kfile/bookmarks.xml"));
if (bookmarksFile.isEmpty()) {
QString genericDataLocation = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
if (genericDataLocation.isEmpty()) {
@ -79,8 +75,10 @@ QList<KBookmarkOwner::FutureBookmark> DolphinBookmarkHandler::currentBookmarkLis
bool DolphinBookmarkHandler::enableOption(KBookmarkOwner::BookmarkOption option) const
{
switch (option) {
case BookmarkOption::ShowAddBookmark: return true;
case BookmarkOption::ShowEditBookmark: return true;
case BookmarkOption::ShowAddBookmark:
return true;
case BookmarkOption::ShowEditBookmark:
return true;
}
return false;
}

View File

@ -38,6 +38,7 @@ private:
static QString title(DolphinViewContainer *viewContainer);
static QUrl url(DolphinViewContainer *viewContainer);
static QString icon(DolphinViewContainer *viewContainer);
private:
DolphinMainWindow *m_mainWindow;
KBookmarkManager *m_bookmarkManager;

View File

@ -6,8 +6,8 @@
#include "dolphincontextmenu.h"
#include "dolphin_generalsettings.h"
#include "dolphin_contextmenusettings.h"
#include "dolphin_generalsettings.h"
#include "dolphinmainwindow.h"
#include "dolphinnewfilemenu.h"
#include "dolphinplacesmodelsingleton.h"
@ -39,18 +39,18 @@ DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent,
const KFileItem &fileInfo,
const KFileItemList &selectedItems,
const QUrl &baseUrl,
KFileItemActions *fileItemActions) :
QMenu(parent),
m_mainWindow(parent),
m_fileInfo(fileInfo),
m_baseUrl(baseUrl),
m_baseFileItem(nullptr),
m_selectedItems(selectedItems),
m_selectedItemsProperties(nullptr),
m_context(NoContext),
m_copyToMenu(parent),
m_removeAction(nullptr),
m_fileItemActions(fileItemActions)
KFileItemActions *fileItemActions)
: QMenu(parent)
, m_mainWindow(parent)
, m_fileInfo(fileInfo)
, m_baseUrl(baseUrl)
, m_baseFileItem(nullptr)
, m_selectedItems(selectedItems)
, m_selectedItemsProperties(nullptr)
, m_context(NoContext)
, m_copyToMenu(parent)
, m_removeAction(nullptr)
, m_fileItemActions(fileItemActions)
{
QApplication::instance()->installEventFilter(this);
@ -67,8 +67,7 @@ DolphinContextMenu::~DolphinContextMenu()
void DolphinContextMenu::addAllActions()
{
static_cast<KHamburgerMenu *>(m_mainWindow->actionCollection()->
action(QStringLiteral("hamburger_menu")))->addToMenu(this);
static_cast<KHamburgerMenu *>(m_mainWindow->actionCollection()->action(QStringLiteral("hamburger_menu")))->addToMenu(this);
// get the context information
const auto scheme = m_baseUrl.scheme();
@ -204,26 +203,17 @@ void DolphinContextMenu::addItemContextMenu()
} else if (m_context & TimelineContext || m_context & SearchContext) {
addOpenWithActions();
addAction(QIcon::fromTheme(QStringLiteral("document-open-folder")),
i18nc("@action:inmenu",
"Open Path"),
[this](){
addAction(QIcon::fromTheme(QStringLiteral("document-open-folder")), i18nc("@action:inmenu", "Open Path"), [this]() {
m_mainWindow->changeUrl(KIO::upUrl(m_fileInfo.url()));
m_mainWindow->activeViewContainer()->view()->markUrlsAsSelected({m_fileInfo.url()});
m_mainWindow->activeViewContainer()->view()->markUrlAsCurrent(m_fileInfo.url());
});
addAction(QIcon::fromTheme(QStringLiteral("window-new")),
i18nc("@action:inmenu",
"Open Path in New Window"),
[this](){
addAction(QIcon::fromTheme(QStringLiteral("window-new")), i18nc("@action:inmenu", "Open Path in New Window"), [this]() {
Dolphin::openNewWindow({m_fileInfo.url()}, m_mainWindow, Dolphin::OpenNewWindowFlag::Select);
});
addAction(QIcon::fromTheme(QStringLiteral("tab-new")),
i18nc("@action:inmenu",
"Open Path in New Tab"),
[this](){
addAction(QIcon::fromTheme(QStringLiteral("tab-new")), i18nc("@action:inmenu", "Open Path in New Tab"), [this]() {
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
if (ContextMenuSettings::showAddToPlaces() &&
!placeExists(m_mainWindow->activeViewContainer()->url())) {
if (ContextMenuSettings::showAddToPlaces() && !placeExists(m_mainWindow->activeViewContainer()->url())) {
addAction(m_mainWindow->actionCollection()->action(QStringLiteral("add_to_places")));
}
addSeparator();
@ -349,20 +338,15 @@ void DolphinContextMenu::insertDefaultItemActions(const KFileItemListProperties&
addAction(collection->action(KStandardAction::name(KStandardAction::RenameFile)));
// Insert 'Add to Places' entry if appropriate
if (ContextMenuSettings::showAddToPlaces() &&
m_selectedItems.count() == 1 &&
m_fileInfo.isDir() &&
!placeExists(m_fileInfo.url())) {
if (ContextMenuSettings::showAddToPlaces() && m_selectedItems.count() == 1 && m_fileInfo.isDir() && !placeExists(m_fileInfo.url())) {
addAction(m_mainWindow->actionCollection()->action(QStringLiteral("add_to_places")));
}
addSeparator();
// Insert 'Move to Trash' and/or 'Delete'
const bool showDeleteAction = (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) ||
!properties.isLocal());
const bool showMoveToTrashAction = (properties.isLocal() &&
properties.supportsMoving());
const bool showDeleteAction = (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) || !properties.isLocal());
const bool showMoveToTrashAction = (properties.isLocal() && properties.supportsMoving());
if (showDeleteAction && showMoveToTrashAction) {
delete m_removeAction;
@ -462,4 +446,3 @@ void DolphinContextMenu::addAdditionalActions(const KFileItemListProperties &pro
addSeparator();
}
}

View File

@ -95,8 +95,7 @@ private:
void addAdditionalActions(const KFileItemListProperties &props);
private:
struct Entry
{
struct Entry {
int type;
QString name;
QString filePath; // empty for separator
@ -105,8 +104,7 @@ private:
QString comment;
};
enum ContextType
{
enum ContextType {
NoContext = 0,
ItemContext = 1,
TrashContext = 2,
@ -130,7 +128,6 @@ private:
DolphinRemoveAction *m_removeAction; // Action that represents either 'Move To Trash' or 'Delete'
void addDirectoryItemContextMenu();
KFileItemActions *m_fileItemActions;
};
#endif

View File

@ -8,7 +8,8 @@
#include <QStyle>
namespace {
namespace
{
// Disable the 'Floatable' feature, i.e., the possibility to drag the
// dock widget out of the main window. This works around problems like
// https://bugs.kde.org/show_bug.cgi?id=288629
@ -22,8 +23,13 @@ class DolphinDockTitleBar : public QWidget
Q_OBJECT
public:
explicit DolphinDockTitleBar(QWidget* parent = nullptr) : QWidget(parent) {}
~DolphinDockTitleBar() override {}
explicit DolphinDockTitleBar(QWidget *parent = nullptr)
: QWidget(parent)
{
}
~DolphinDockTitleBar() override
{
}
QSize minimumSizeHint() const override
{
@ -37,10 +43,10 @@ public:
}
};
DolphinDockWidget::DolphinDockWidget(const QString& title, QWidget* parent, Qt::WindowFlags flags) :
QDockWidget(title, parent, flags),
m_locked(false),
m_dockTitleBar(nullptr)
DolphinDockWidget::DolphinDockWidget(const QString &title, QWidget *parent, Qt::WindowFlags flags)
: QDockWidget(title, parent, flags)
, m_locked(false)
, m_dockTitleBar(nullptr)
{
setFeatures(DefaultDockWidgetFeatures);
}

File diff suppressed because it is too large Load Diff

View File

@ -9,9 +9,9 @@
#ifndef DOLPHIN_MAINWINDOW_H
#define DOLPHIN_MAINWINDOW_H
#include "config-dolphin.h"
#include "dolphintabwidget.h"
#include "selectionmode/bottombar.h"
#include "config-dolphin.h"
#include <KFileItemActions>
#include <kio/fileundomanager.h>
#include <kxmlguiwindow.h>
@ -44,10 +44,12 @@ class QToolButton;
class PlacesPanel;
class TerminalPanel;
namespace KIO {
namespace KIO
{
class OpenUrlJob;
}
namespace SelectionMode {
namespace SelectionMode
{
class ActionTextHelper;
}
@ -159,7 +161,6 @@ public Q_SLOTS:
*/
bool isItemVisibleInAnyView(const QString &urlOfItem);
/**
* Pastes the clipboard data into the currently selected folder
* 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
* is no KAction instance.
*/
void createPanelAction(const QIcon &icon,
const QKeySequence& shortcut,
QAction* dockAction,
const QString& actionName);
void createPanelAction(const QIcon &icon, const QKeySequence &shortcut, QAction *dockAction, const QString &actionName);
/** Adds "What's This?" texts to many widgets and StandardActions. */
void setupWhatsThis();
@ -727,4 +725,3 @@ inline KNewFileMenu* DolphinMainWindow::newFileMenu() const
}
#endif // DOLPHIN_MAINWINDOW_H

View File

@ -22,11 +22,11 @@
#include <limits>
DolphinNavigatorsWidgetAction::DolphinNavigatorsWidgetAction(QWidget *parent) :
QWidgetAction{parent},
m_splitter{new QSplitter(Qt::Horizontal)},
m_adjustSpacingTimer{new QTimer(this)},
m_viewGeometriesHelper{m_splitter.get(), this}
DolphinNavigatorsWidgetAction::DolphinNavigatorsWidgetAction(QWidget *parent)
: QWidgetAction{parent}
, m_splitter{new QSplitter(Qt::Horizontal)}
, m_adjustSpacingTimer{new QTimer(this)}
, m_viewGeometriesHelper{m_splitter.get(), this}
{
updateText();
setIcon(QIcon::fromTheme(QStringLiteral("dialog-scripts")));
@ -37,8 +37,7 @@ DolphinNavigatorsWidgetAction::DolphinNavigatorsWidgetAction(QWidget *parent) :
m_adjustSpacingTimer->setInterval(100);
m_adjustSpacingTimer->setSingleShot(true);
connect(m_adjustSpacingTimer.get(), &QTimer::timeout,
this, &DolphinNavigatorsWidgetAction::adjustSpacing);
connect(m_adjustSpacingTimer.get(), &QTimer::timeout, this, &DolphinNavigatorsWidgetAction::adjustSpacing);
}
void DolphinNavigatorsWidgetAction::adjustSpacing()
@ -46,8 +45,7 @@ void DolphinNavigatorsWidgetAction::adjustSpacing()
m_previousWindowWidth = parentWidget()->window()->width();
auto viewGeometries = m_viewGeometriesHelper.viewGeometries();
const int widthOfSplitterPrimary = viewGeometries.globalXOfPrimary + viewGeometries.widthOfPrimary - viewGeometries.globalXOfNavigatorsWidget;
const QList<int> splitterSizes = {widthOfSplitterPrimary,
m_splitter->width() - widthOfSplitterPrimary};
const QList<int> splitterSizes = {widthOfSplitterPrimary, m_splitter->width() - widthOfSplitterPrimary};
m_splitter->setSizes(splitterSizes);
// primary side of m_splitter
@ -55,11 +53,8 @@ void DolphinNavigatorsWidgetAction::adjustSpacing()
if (leadingSpacing < 0) {
leadingSpacing = 0;
}
int trailingSpacing = (viewGeometries.globalXOfNavigatorsWidget + m_splitter->width())
- (viewGeometries.globalXOfPrimary + viewGeometries.widthOfPrimary);
if (trailingSpacing < 0 || emptyTrashButton(Primary)->isVisible()
|| networkFolderButton(Primary)->isVisible()
) {
int trailingSpacing = (viewGeometries.globalXOfNavigatorsWidget + m_splitter->width()) - (viewGeometries.globalXOfPrimary + viewGeometries.widthOfPrimary);
if (trailingSpacing < 0 || emptyTrashButton(Primary)->isVisible() || networkFolderButton(Primary)->isVisible()) {
trailingSpacing = 0;
}
const int widthLeftForUrlNavigator = m_splitter->widget(0)->width() - leadingSpacing - trailingSpacing;
@ -84,11 +79,8 @@ void DolphinNavigatorsWidgetAction::adjustSpacing()
}
spacing(Primary, Trailing)->setFixedWidth(0);
trailingSpacing = (viewGeometries.globalXOfNavigatorsWidget + m_splitter->width())
- (viewGeometries.globalXOfSecondary + viewGeometries.widthOfSecondary);
if (trailingSpacing < 0 || emptyTrashButton(Secondary)->isVisible()
|| networkFolderButton(Secondary)->isVisible()
) {
trailingSpacing = (viewGeometries.globalXOfNavigatorsWidget + m_splitter->width()) - (viewGeometries.globalXOfSecondary + viewGeometries.widthOfSecondary);
if (trailingSpacing < 0 || emptyTrashButton(Secondary)->isVisible() || networkFolderButton(Secondary)->isVisible()) {
trailingSpacing = 0;
} else {
const int widthLeftForUrlNavigator2 = m_splitter->widget(1)->width() - trailingSpacing;
@ -111,8 +103,7 @@ void DolphinNavigatorsWidgetAction::createSecondaryUrlNavigator()
updateText();
}
void DolphinNavigatorsWidgetAction::followViewContainersGeometry(QWidget *primaryViewContainer,
QWidget *secondaryViewContainer)
void DolphinNavigatorsWidgetAction::followViewContainersGeometry(QWidget *primaryViewContainer, QWidget *secondaryViewContainer)
{
m_viewGeometriesHelper.setViewContainers(primaryViewContainer, secondaryViewContainer);
adjustSpacing();
@ -193,7 +184,11 @@ QWidget *DolphinNavigatorsWidgetAction::createNavigatorWidget(Side side) const
auto networkFolderButton = newNetworkFolderButton(urlNavigator, navigatorWidget);
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
// just loaded the remote:/ page, to make it easier for users to figure out
// 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
// happens a little bit later than when urlChanged is emitted.
this->m_adjustSpacingTimer->start();
}, Qt::QueuedConnection);
},
Qt::QueuedConnection);
auto trailingSpacing = new QWidget{navigatorWidget};
layout->addWidget(trailingSpacing);
@ -228,15 +224,14 @@ QPushButton * DolphinNavigatorsWidgetAction::emptyTrashButton(DolphinNavigatorsW
QPushButton *DolphinNavigatorsWidgetAction::newEmptyTrashButton(const DolphinUrlNavigator *urlNavigator, QWidget *parent) const
{
auto emptyTrashButton = new QPushButton(QIcon::fromTheme(QStringLiteral("user-trash")),
i18nc("@action:button", "Empty Trash"), parent);
auto emptyTrashButton = new QPushButton(QIcon::fromTheme(QStringLiteral("user-trash")), i18nc("@action:button", "Empty Trash"), parent);
emptyTrashButton->setToolTip(i18n("Empties Trash to create free space"));
emptyTrashButton->setFlat(true);
connect(emptyTrashButton, &QPushButton::clicked,
this, [parent]() { Trash::empty(parent); });
connect(&Trash::instance(), &Trash::emptinessChanged,
emptyTrashButton, &QPushButton::setDisabled);
connect(emptyTrashButton, &QPushButton::clicked, this, [parent]() {
Trash::empty(parent);
});
connect(&Trash::instance(), &Trash::emptinessChanged, emptyTrashButton, &QPushButton::setDisabled);
emptyTrashButton->hide();
connect(urlNavigator, &KUrlNavigator::urlChanged, this, [emptyTrashButton, urlNavigator]() {
emptyTrashButton->setVisible(urlNavigator->locationUrl().scheme() == QLatin1String("trash"));
@ -256,12 +251,10 @@ QPushButton *DolphinNavigatorsWidgetAction::networkFolderButton(DolphinNavigator
QPushButton *DolphinNavigatorsWidgetAction::newNetworkFolderButton(const DolphinUrlNavigator *urlNavigator, QWidget *parent) const
{
auto networkFolderButton = new QPushButton(QIcon::fromTheme(QStringLiteral("folder-add")),
i18nc("@action:button", "Add Network Folder"), parent);
auto networkFolderButton = new QPushButton(QIcon::fromTheme(QStringLiteral("folder-add")), i18nc("@action:button", "Add Network Folder"), parent);
networkFolderButton->setFlat(true);
KService::Ptr service = KService::serviceByDesktopName(QStringLiteral("org.kde.knetattach"));
connect(networkFolderButton, &QPushButton::clicked,
this, [networkFolderButton, service]() {
connect(networkFolderButton, &QPushButton::clicked, this, [networkFolderButton, service]() {
auto *job = new KIO::ApplicationLauncherJob(service, networkFolderButton);
auto *delegate = new KNotificationJobUiDelegate;
delegate->setAutoErrorHandlingEnabled(true);
@ -290,15 +283,13 @@ QWidget *DolphinNavigatorsWidgetAction::spacing(Side side, Position position) co
void DolphinNavigatorsWidgetAction::updateText()
{
const int urlNavigatorsAmount = m_splitter->count() > 1 && m_splitter->widget(1)->isVisible() ?
2 : 1;
const int urlNavigatorsAmount = m_splitter->count() > 1 && m_splitter->widget(1)->isVisible() ? 2 : 1;
setText(i18ncp("@action:inmenu", "Location Bar", "Location Bars", urlNavigatorsAmount));
}
DolphinNavigatorsWidgetAction::ViewGeometriesHelper::ViewGeometriesHelper
(QWidget *navigatorsWidget, DolphinNavigatorsWidgetAction *navigatorsWidgetAction) :
m_navigatorsWidget{navigatorsWidget},
m_navigatorsWidgetAction{navigatorsWidgetAction}
DolphinNavigatorsWidgetAction::ViewGeometriesHelper::ViewGeometriesHelper(QWidget *navigatorsWidget, DolphinNavigatorsWidgetAction *navigatorsWidgetAction)
: m_navigatorsWidget{navigatorsWidget}
, m_navigatorsWidgetAction{navigatorsWidgetAction}
{
Q_CHECK_PTR(navigatorsWidget);
Q_CHECK_PTR(navigatorsWidgetAction);
@ -323,8 +314,7 @@ bool DolphinNavigatorsWidgetAction::ViewGeometriesHelper::eventFilter(QObject *w
return QObject::eventFilter(watched, event);
}
void DolphinNavigatorsWidgetAction::ViewGeometriesHelper::setViewContainers(QWidget *primaryViewContainer,
QWidget *secondaryViewContainer)
void DolphinNavigatorsWidgetAction::ViewGeometriesHelper::setViewContainers(QWidget *primaryViewContainer, QWidget *secondaryViewContainer)
{
Q_CHECK_PTR(primaryViewContainer);
if (m_primaryViewContainer) {
@ -338,8 +328,7 @@ void DolphinNavigatorsWidgetAction::ViewGeometriesHelper::setViewContainers(QWid
m_secondaryViewContainer = secondaryViewContainer;
}
DolphinNavigatorsWidgetAction::ViewGeometriesHelper::Geometries
DolphinNavigatorsWidgetAction::ViewGeometriesHelper::viewGeometries()
DolphinNavigatorsWidgetAction::ViewGeometriesHelper::Geometries DolphinNavigatorsWidgetAction::ViewGeometriesHelper::viewGeometries()
{
Q_ASSERT(m_primaryViewContainer);
Geometries geometries;
@ -356,18 +345,15 @@ DolphinNavigatorsWidgetAction::ViewGeometriesHelper::Geometries
if (QApplication::layoutDirection() == Qt::LeftToRight) {
geometries.globalXOfNavigatorsWidget = m_navigatorsWidget->mapToGlobal(QPoint(0, 0)).x();
geometries.globalXOfPrimary = m_primaryViewContainer->mapToGlobal(QPoint(0, 0)).x();
geometries.globalXOfSecondary = !m_secondaryViewContainer ? INT_MIN :
m_secondaryViewContainer->mapToGlobal(QPoint(0,0)).x();
geometries.globalXOfSecondary = !m_secondaryViewContainer ? INT_MIN : m_secondaryViewContainer->mapToGlobal(QPoint(0, 0)).x();
} else {
// When the direction is reversed, globalX does not change.
// 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.
geometries.globalXOfNavigatorsWidget =
(-1) * (m_navigatorsWidget->mapToGlobal(QPoint(0,0)).x() + m_navigatorsWidget->width());
geometries.globalXOfPrimary =
(-1) * (m_primaryViewContainer->mapToGlobal(QPoint(0,0)).x() + geometries.widthOfPrimary);
geometries.globalXOfSecondary = !m_secondaryViewContainer ? INT_MIN :
(-1) * (m_secondaryViewContainer->mapToGlobal(QPoint(0,0)).x() + geometries.widthOfSecondary);
geometries.globalXOfNavigatorsWidget = (-1) * (m_navigatorsWidget->mapToGlobal(QPoint(0, 0)).x() + m_navigatorsWidget->width());
geometries.globalXOfPrimary = (-1) * (m_primaryViewContainer->mapToGlobal(QPoint(0, 0)).x() + geometries.widthOfPrimary);
geometries.globalXOfSecondary =
!m_secondaryViewContainer ? INT_MIN : (-1) * (m_secondaryViewContainer->mapToGlobal(QPoint(0, 0)).x() + geometries.widthOfSecondary);
}
return geometries;
}

View File

@ -65,8 +65,7 @@ public:
* Notify this widget of changes in geometry of the ViewContainers it tries to be
* aligned with.
*/
void followViewContainersGeometry(QWidget *primaryViewContainer,
QWidget *secondaryViewContainer = nullptr);
void followViewContainersGeometry(QWidget *primaryViewContainer, QWidget *secondaryViewContainer = nullptr);
bool isInToolbar() const;
@ -104,10 +103,7 @@ private:
/**
* In Left-to-right languages the Primary side will be the left one.
*/
enum Side {
Primary,
Secondary
};
enum Side { Primary, Secondary };
/**
* Used to create the navigatorWidgets for both sides of the QSplitter.
*/
@ -142,10 +138,7 @@ private:
*/
QPushButton *newNetworkFolderButton(const DolphinUrlNavigator *urlNavigator, QWidget *parent) const;
enum Position {
Leading,
Trailing
};
enum Position { Leading, Trailing };
/**
* Used to retrieve both the leading and trailing spacing for the navigatorWidgets
* 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.
*/
void setViewContainers(QWidget *primaryViewContainer,
QWidget *secondaryViewContainer = nullptr);
void setViewContainers(QWidget *primaryViewContainer, QWidget *secondaryViewContainer = nullptr);
struct Geometries {
int globalXOfNavigatorsWidget;

View File

@ -11,8 +11,8 @@
#include <KActionCollection>
#include <KIO/Job>
DolphinNewFileMenu::DolphinNewFileMenu(KActionCollection* collection, QObject* parent) :
KNewFileMenu(collection, QStringLiteral("new_menu"), parent)
DolphinNewFileMenu::DolphinNewFileMenu(KActionCollection *collection, QObject *parent)
: KNewFileMenu(collection, QStringLiteral("new_menu"), parent)
{
DolphinNewFileMenuObserver::instance().attach(this);
}
@ -30,4 +30,3 @@ void DolphinNewFileMenu::slotResult(KJob* job)
KNewFileMenu::slotResult(job);
}
}

View File

@ -48,8 +48,7 @@
K_PLUGIN_CLASS_WITH_JSON(DolphinPart, "dolphinpart.json")
DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent,
const KPluginMetaData& metaData, const QVariantList& args)
DolphinPart::DolphinPart(QWidget *parentWidget, QObject *parent, const KPluginMetaData &metaData, const QVariantList &args)
: KParts::ReadOnlyPart(parent)
, m_openTerminalAction(nullptr)
, m_removeAction(nullptr)
@ -66,8 +65,7 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent,
m_view->setTabsForFilesEnabled(true);
setWidget(m_view);
connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage,
this, &DolphinPart::slotErrorMessage);
connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage, this, &DolphinPart::slotErrorMessage);
connect(m_view, &DolphinView::directoryLoadingCompleted, this, &KParts::ReadOnlyPart::completed);
connect(m_view, &DolphinView::directoryLoadingCompleted, this, &DolphinPart::updatePasteAction);
@ -76,34 +74,22 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent,
setXMLFile(QStringLiteral("dolphinpart.rc"));
connect(m_view, &DolphinView::infoMessage,
this, &DolphinPart::slotMessage);
connect(m_view, &DolphinView::operationCompletedMessage,
this, &DolphinPart::slotMessage);
connect(m_view, &DolphinView::errorMessage,
this, &DolphinPart::slotErrorMessage);
connect(m_view, &DolphinView::itemActivated,
this, &DolphinPart::slotItemActivated);
connect(m_view, &DolphinView::itemsActivated,
this, &DolphinPart::slotItemsActivated);
connect(m_view, &DolphinView::infoMessage, this, &DolphinPart::slotMessage);
connect(m_view, &DolphinView::operationCompletedMessage, this, &DolphinPart::slotMessage);
connect(m_view, &DolphinView::errorMessage, 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) {
const QString escapedText = Qt::convertFromPlainText(text);
Q_EMIT ReadOnlyPart::setStatusBarText(QStringLiteral("<qt>%1</qt>").arg(escapedText));
});
connect(m_view, &DolphinView::tabRequested,
this, &DolphinPart::createNewWindow);
connect(m_view, &DolphinView::requestContextMenu,
this, &DolphinPart::slotOpenContextMenu);
connect(m_view, &DolphinView::selectionChanged,
m_extension, &KParts::BrowserExtension::selectionInfo);
connect(m_view, &DolphinView::selectionChanged,
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);
connect(m_view, &DolphinView::tabRequested, this, &DolphinPart::createNewWindow);
connect(m_view, &DolphinView::requestContextMenu, this, &DolphinPart::slotOpenContextMenu);
connect(m_view, &DolphinView::selectionChanged, m_extension, &KParts::BrowserExtension::selectionInfo);
connect(m_view, &DolphinView::selectionChanged, 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
// status bar text.
@ -115,12 +101,10 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent,
connect(m_actionHandler, &DolphinViewActionHandler::createDirectoryTriggered, this, &DolphinPart::createDirectory);
m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler);
connect(this, &DolphinPart::aboutToOpenURL,
m_remoteEncoding, &DolphinRemoteEncoding::slotAboutToOpenUrl);
connect(this, &DolphinPart::aboutToOpenURL, m_remoteEncoding, &DolphinRemoteEncoding::slotAboutToOpenUrl);
QClipboard *clipboard = QApplication::clipboard();
connect(clipboard, &QClipboard::dataChanged,
this, &DolphinPart::updatePasteAction);
connect(clipboard, &QClipboard::dataChanged, this, &DolphinPart::updatePasteAction);
// Create file info and listing filter extensions.
// 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->setParentWidget(widget());
connect(m_newFileMenu->menu(), &QMenu::aboutToShow,
this, &DolphinPart::updateNewMenu);
connect(m_newFileMenu->menu(), &QMenu::aboutToShow, this, &DolphinPart::updateNewMenu);
QAction *editMimeTypeAction = actionCollection()->addAction(QStringLiteral("editMimeType"));
editMimeTypeAction->setText(i18nc("@action:inmenu Edit", "&Edit File Type..."));
@ -191,20 +174,15 @@ void DolphinPart::createActions()
// Go menu
QActionGroup *goActionGroup = new QActionGroup(this);
connect(goActionGroup, &QActionGroup::triggered,
this, &DolphinPart::slotGoTriggered);
connect(goActionGroup, &QActionGroup::triggered, this, &DolphinPart::slotGoTriggered);
createGoAction("go_applications", "start-here-kde",
i18nc("@action:inmenu Go", "App&lications"), QStringLiteral("programs:/"),
goActionGroup);
createGoAction("go_network_folders", "folder-remote",
i18nc("@action:inmenu Go", "&Network Folders"), QStringLiteral("remote:/"),
goActionGroup);
createGoAction("go_trash", "user-trash",
i18nc("@action:inmenu Go", "Trash"), QStringLiteral("trash:/"),
goActionGroup);
createGoAction("go_autostart", "",
i18nc("@action:inmenu Go", "Autostart"), QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/autostart",
createGoAction("go_applications", "start-here-kde", i18nc("@action:inmenu Go", "App&lications"), QStringLiteral("programs:/"), goActionGroup);
createGoAction("go_network_folders", "folder-remote", i18nc("@action:inmenu Go", "&Network Folders"), QStringLiteral("remote:/"), goActionGroup);
createGoAction("go_trash", "user-trash", i18nc("@action:inmenu Go", "Trash"), QStringLiteral("trash:/"), goActionGroup);
createGoAction("go_autostart",
"",
i18nc("@action:inmenu Go", "Autostart"),
QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/autostart",
goActionGroup);
// Tools menu
@ -222,9 +200,7 @@ void DolphinPart::createActions()
#endif
}
void DolphinPart::createGoAction(const char* name, const char* iconName,
const QString& text, const QString& url,
QActionGroup* actionGroup)
void DolphinPart::createGoAction(const char *name, const char *iconName, const QString &text, const QString &url, QActionGroup *actionGroup)
{
QAction *action = actionCollection()->addAction(name);
action->setIcon(QIcon::fromTheme(iconName));
@ -384,14 +360,10 @@ void DolphinPart::createNewWindow(const QUrl& url)
Q_EMIT m_extension->createNewWindow(url);
}
void DolphinPart::slotOpenContextMenu(const QPoint& pos,
const KFileItem& _item,
const KFileItemList &selectedItems,
const QUrl &)
void DolphinPart::slotOpenContextMenu(const QPoint &pos, const KFileItem &_item, const KFileItemList &selectedItems, const QUrl &)
{
KParts::BrowserExtension::PopupFlags popupFlags = KParts::BrowserExtension::DefaultPopupItems
| KParts::BrowserExtension::ShowProperties
| KParts::BrowserExtension::ShowUrlOperations;
KParts::BrowserExtension::PopupFlags popupFlags =
KParts::BrowserExtension::DefaultPopupItems | KParts::BrowserExtension::ShowProperties | KParts::BrowserExtension::ShowUrlOperations;
KFileItem item(_item);
@ -420,8 +392,7 @@ void DolphinPart::slotOpenContextMenu(const QPoint& pos,
const bool supportsMoving = capabilities.supportsMoving();
if (capabilities.supportsDeleting()) {
const bool showDeleteAction = (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) ||
!item.isLocalFile());
const bool showDeleteAction = (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) || !item.isLocalFile());
const bool showMoveToTrashAction = capabilities.isLocal() && supportsMoving;
if (showDeleteAction && showMoveToTrashAction) {
@ -450,17 +421,11 @@ void DolphinPart::slotOpenContextMenu(const QPoint& pos,
// But in treeview mode we should allow it.
if (m_view->itemsExpandable())
popupFlags |= KParts::BrowserExtension::ShowCreateDirectory;
}
actionGroups.insert(QStringLiteral("editactions"), editActions);
Q_EMIT m_extension->popupMenu(pos,
items,
KParts::OpenUrlArguments(),
KParts::BrowserArguments(),
popupFlags,
actionGroups);
Q_EMIT m_extension->popupMenu(pos, items, KParts::OpenUrlArguments(), KParts::BrowserArguments(), popupFlags, actionGroups);
}
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()
{
const KFileItemList items = m_view->selectedItems();
@ -484,16 +448,12 @@ void DolphinPart::slotEditMimeType()
void DolphinPart::slotSelectItemsMatchingPattern()
{
openSelectionDialog(i18nc("@title:window", "Select"),
i18n("Select all items matching this pattern:"),
true);
openSelectionDialog(i18nc("@title:window", "Select"), i18n("Select all items matching this pattern:"), true);
}
void DolphinPart::slotUnselectItemsMatchingPattern()
{
openSelectionDialog(i18nc("@title:window", "Unselect"),
i18n("Unselect all items matching this pattern:"),
false);
openSelectionDialog(i18nc("@title:window", "Unselect"), i18n("Unselect all items matching this pattern:"), false);
}
void DolphinPart::openSelectionDialog(const QString &title, const QString &text, bool selectItems)
@ -571,9 +531,7 @@ void DolphinPart::slotOpenTerminal()
void DolphinPart::slotFindFile()
{
QMenu searchTools;
KMoreToolsMenuFactory("dolphin/search-tools").fillMenuFromGroupingNames(
&searchTools, { "files-find" }, QUrl::fromLocalFile(localFilePathOrHome())
);
KMoreToolsMenuFactory("dolphin/search-tools").fillMenuFromGroupingNames(&searchTools, {"files-find"}, QUrl::fromLocalFile(localFilePathOrHome()));
QList<QAction *> actions = searchTools.actions();
if (!(actions.isEmpty())) {
actions.first()->trigger();

View File

@ -40,8 +40,7 @@ class DolphinPart : public KParts::ReadOnlyPart
Q_PROPERTY(QList<QUrl> filesToSelect READ filesToSelect WRITE setFilesToSelect)
public:
explicit DolphinPart(QWidget* parentWidget, QObject* parent,
const KPluginMetaData& metaData, const QVariantList& args);
explicit DolphinPart(QWidget *parentWidget, QObject *parent, const KPluginMetaData &metaData, const QVariantList &args);
~DolphinPart() override;
/**
@ -51,7 +50,10 @@ public:
bool openUrl(const QUrl &url) override;
/// see the supportsUndo property
bool supportsUndo() const { return true; }
bool supportsUndo() const
{
return true;
}
/**
* Used by konqueror for setting the view mode
@ -68,7 +70,10 @@ public:
QString currentViewMode() const;
/// 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
@ -78,13 +83,19 @@ public:
/**
* 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:
/**
* We reimplement openUrl so no need to implement openFile.
*/
bool openFile() override { return true; }
bool openFile() override
{
return true;
}
Q_SIGNALS:
/**
@ -92,7 +103,6 @@ Q_SIGNALS:
*/
void viewModeChanged();
/**
* Emitted whenever the current URL is about to be changed.
*/
@ -204,18 +214,18 @@ private Q_SLOTS:
* Called by konqueror --select
*/
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;
private:
void createActions();
void createGoAction(const char* name, const char* iconName,
const QString& text, const QString& url,
QActionGroup* actionGroup);
void createGoAction(const char *name, const char *iconName, const QString &text, const QString &url, QActionGroup *actionGroup);
void openSelectionDialog(const QString& title, const QString& text,
bool selectItems);
void openSelectionDialog(const QString &title, const QString &text, bool selectItems);
QString urlToLocalFilePath(const QUrl &url);
QString localFilePathOrHome() const;

View File

@ -13,7 +13,6 @@ DolphinPartBrowserExtension::DolphinPartBrowserExtension(DolphinPart* part)
: KParts::BrowserExtension(part)
, m_part(part)
{
}
void DolphinPartBrowserExtension::restoreState(QDataStream &stream)
@ -53,7 +52,6 @@ void DolphinPartBrowserExtension::reparseConfiguration()
m_part->view()->readSettings();
}
DolphinPartFileInfoExtension::DolphinPartFileInfoExtension(DolphinPart *part)
: KParts::FileInfoExtension(part)
, m_part(part)
@ -102,9 +100,7 @@ DolphinPartListingFilterExtension::DolphinPartListingFilterExtension(DolphinPart
KParts::ListingFilterExtension::FilterModes DolphinPartListingFilterExtension::supportedFilterModes() const
{
return (KParts::ListingFilterExtension::MimeType |
KParts::ListingFilterExtension::SubString |
KParts::ListingFilterExtension::WildCard);
return (KParts::ListingFilterExtension::MimeType | KParts::ListingFilterExtension::SubString | KParts::ListingFilterExtension::WildCard);
}
bool DolphinPartListingFilterExtension::supportsMultipleFilters(KParts::ListingFilterExtension::FilterMode mode) const
@ -158,8 +154,7 @@ DolphinPartListingNotificationExtension::DolphinPartListingNotificationExtension
KParts::ListingNotificationExtension::NotificationEventTypes DolphinPartListingNotificationExtension::supportedNotificationEventTypes() const
{
return (KParts::ListingNotificationExtension::ItemsAdded |
KParts::ListingNotificationExtension::ItemsDeleted);
return (KParts::ListingNotificationExtension::ItemsAdded | KParts::ListingNotificationExtension::ItemsDeleted);
}
void DolphinPartListingNotificationExtension::slotNewItems(const KFileItemList &items)
@ -171,4 +166,3 @@ void DolphinPartListingNotificationExtension::slotItemsDeleted(const KFileItemLi
{
Q_EMIT listingEvent(KParts::ListingNotificationExtension::ItemsDeleted, items);
}

View File

@ -51,8 +51,7 @@ void DolphinPlacesModel::setPanelsLocked(bool locked)
QStringList DolphinPlacesModel::mimeTypes() const
{
QStringList types = KFilePlacesModel::mimeTypes();
types << DragAndDropHelper::arkDndServiceMimeType()
<< DragAndDropHelper::arkDndPathMimeType();
types << DragAndDropHelper::arkDndServiceMimeType() << DragAndDropHelper::arkDndPathMimeType();
return types;
}
@ -121,7 +120,6 @@ bool DolphinPlacesModel::isTrash(const QModelIndex &index) const
DolphinPlacesModelSingleton::DolphinPlacesModelSingleton()
: m_placesModel(new DolphinPlacesModel(KAboutData::applicationData().componentName() + applicationNameSuffix()))
{
}
DolphinPlacesModelSingleton &DolphinPlacesModelSingleton::instance()

View File

@ -7,8 +7,8 @@
#ifndef DOLPHINPLACESMODELSINGLETON_H
#define DOLPHINPLACESMODELSINGLETON_H
#include <QString>
#include <QScopedPointer>
#include <QString>
#include <KFilePlacesModel>
@ -50,7 +50,6 @@ private:
*/
class DolphinPlacesModelSingleton
{
public:
static DolphinPlacesModelSingleton &instance();

View File

@ -12,8 +12,8 @@
#include <QMenu>
DolphinRecentTabsMenu::DolphinRecentTabsMenu(QObject* parent) :
KActionMenu(QIcon::fromTheme(QStringLiteral("edit-undo")), i18n("Recently Closed Tabs"), parent)
DolphinRecentTabsMenu::DolphinRecentTabsMenu(QObject *parent)
: KActionMenu(QIcon::fromTheme(QStringLiteral("edit-undo")), i18n("Recently Closed Tabs"), parent)
{
setPopupMode(QToolButton::InstantPopup);
setEnabled(false);
@ -24,8 +24,7 @@ DolphinRecentTabsMenu::DolphinRecentTabsMenu(QObject* parent) :
addSeparator();
connect(menu(), &QMenu::triggered,
this, &DolphinRecentTabsMenu::handleAction);
connect(menu(), &QMenu::triggered, this, &DolphinRecentTabsMenu::handleAction);
}
void DolphinRecentTabsMenu::rememberClosedTab(const QUrl &url, const QByteArray &state)

View File

@ -9,9 +9,9 @@
#include <QApplication>
DolphinRemoveAction::DolphinRemoveAction(QObject* parent, KActionCollection* collection) :
QAction(parent),
m_collection(collection)
DolphinRemoveAction::DolphinRemoveAction(QObject *parent, KActionCollection *collection)
: QAction(parent)
, m_collection(collection)
{
update();
connect(this, &DolphinRemoveAction::triggered, this, &DolphinRemoveAction::slotRemoveActionTriggered);

View File

@ -26,12 +26,7 @@ class DOLPHIN_EXPORT DolphinRemoveAction : public QAction
{
Q_OBJECT
public:
enum class ShiftState {
Unknown,
Pressed,
Released
};
enum class ShiftState { Unknown, Pressed, Released };
DolphinRemoveAction(QObject *parent, KActionCollection *collection);

View File

@ -13,10 +13,10 @@
#include <QMimeData>
#include <QTimer>
DolphinTabBar::DolphinTabBar(QWidget* parent) :
QTabBar(parent),
m_autoActivationIndex(-1),
m_tabToBeClosedOnMiddleMouseButtonRelease(-1)
DolphinTabBar::DolphinTabBar(QWidget *parent)
: QTabBar(parent)
, m_autoActivationIndex(-1)
, m_tabToBeClosedOnMiddleMouseButtonRelease(-1)
{
setAcceptDrops(true);
setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab);
@ -26,8 +26,7 @@ DolphinTabBar::DolphinTabBar(QWidget* parent) :
m_autoActivationTimer = new QTimer(this);
m_autoActivationTimer->setSingleShot(true);
m_autoActivationTimer->setInterval(800);
connect(m_autoActivationTimer, &QTimer::timeout,
this, &DolphinTabBar::slotAutoActivationTimeout);
connect(m_autoActivationTimer, &QTimer::timeout, this, &DolphinTabBar::slotAutoActivationTimeout);
}
void DolphinTabBar::dragEnterEvent(QDragEnterEvent *event)
@ -93,8 +92,7 @@ void DolphinTabBar::mouseReleaseEvent(QMouseEvent *event)
{
const int index = tabAt(event->pos());
if (index >= 0 && index == m_tabToBeClosedOnMiddleMouseButtonRelease
&& event->button() == Qt::MiddleButton) {
if (index >= 0 && index == m_tabToBeClosedOnMiddleMouseButtonRelease && event->button() == Qt::MiddleButton) {
// Mouse middle click on a tab closes this tab.
Q_EMIT tabCloseRequested(index);
return;

View File

@ -14,12 +14,12 @@
#include <QStyle>
#include <QVariantAnimation>
DolphinTabPage::DolphinTabPage(const QUrl &primaryUrl, const QUrl &secondaryUrl, QWidget* parent) :
QWidget(parent),
m_expandingContainer{nullptr},
m_primaryViewActive(true),
m_splitViewEnabled(false),
m_active(true)
DolphinTabPage::DolphinTabPage(const QUrl &primaryUrl, const QUrl &secondaryUrl, QWidget *parent)
: QWidget(parent)
, m_expandingContainer{nullptr}
, m_primaryViewActive(true)
, m_splitViewEnabled(false)
, m_active(true)
{
QGridLayout *layout = new QGridLayout(this);
layout->setSpacing(0);
@ -27,17 +27,14 @@ DolphinTabPage::DolphinTabPage(const QUrl &primaryUrl, const QUrl &secondaryUrl,
m_splitter = new DolphinTabPageSplitter(Qt::Horizontal, this);
m_splitter->setChildrenCollapsible(false);
connect(m_splitter, &QSplitter::splitterMoved,
this, &DolphinTabPage::splitterMoved);
connect(m_splitter, &QSplitter::splitterMoved, this, &DolphinTabPage::splitterMoved);
layout->addWidget(m_splitter, 1, 0);
layout->setRowStretch(1, 1);
// Create a new primary view
m_primaryViewContainer = createViewContainer(primaryUrl);
connect(m_primaryViewContainer->view(), &DolphinView::urlChanged,
this, &DolphinTabPage::activeViewUrlChanged);
connect(m_primaryViewContainer->view(), &DolphinView::redirection,
this, &DolphinTabPage::slotViewUrlRedirection);
connect(m_primaryViewContainer->view(), &DolphinView::urlChanged, this, &DolphinTabPage::activeViewUrlChanged);
connect(m_primaryViewContainer->view(), &DolphinView::redirection, this, &DolphinTabPage::slotViewUrlRedirection);
m_splitter->addWidget(m_primaryViewContainer);
m_primaryViewContainer->show();
@ -69,9 +66,8 @@ void DolphinTabPage::setSplitViewEnabled(bool enabled, Animated animated, const
{
if (m_splitViewEnabled != enabled) {
m_splitViewEnabled = enabled;
if (animated == WithAnimation && (
style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, this) < 1 ||
GlobalConfig::animationDurationFactor() <= 0.0)) {
if (animated == WithAnimation
&& (style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, this) < 1 || GlobalConfig::animationDurationFactor() <= 0.0)) {
animated = WithoutAnimation;
}
if (m_expandViewAnimation) {
@ -93,8 +89,7 @@ void DolphinTabPage::setSplitViewEnabled(bool enabled, Animated animated, const
}
m_secondaryViewContainer->connectUrlNavigator(secondaryNavigator);
m_navigatorsWidget->setSecondaryNavigatorVisible(true);
m_navigatorsWidget->followViewContainersGeometry(m_primaryViewContainer,
m_secondaryViewContainer);
m_navigatorsWidget->followViewContainersGeometry(m_primaryViewContainer, m_secondaryViewContainer);
m_splitter->addWidget(m_secondaryViewContainer);
m_secondaryViewContainer->setActive(true);
@ -115,8 +110,7 @@ void DolphinTabPage::setSplitViewEnabled(bool enabled, Animated animated, const
view = activeViewContainer();
if (m_primaryViewActive) {
m_primaryViewContainer->disconnectUrlNavigator();
m_secondaryViewContainer->connectUrlNavigator(
m_navigatorsWidget->primaryUrlNavigator());
m_secondaryViewContainer->connectUrlNavigator(m_navigatorsWidget->primaryUrlNavigator());
// If the primary view is active, we have to swap the pointers
// 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;
if (!m_primaryViewActive) {
m_primaryViewContainer->disconnectUrlNavigator();
m_secondaryViewContainer->connectUrlNavigator(
m_navigatorsWidget->primaryUrlNavigator());
m_secondaryViewContainer->connectUrlNavigator(m_navigatorsWidget->primaryUrlNavigator());
// If the secondary view is active, we have to swap the pointers
// because the secondary view will be the new primary view.
@ -168,8 +161,7 @@ DolphinViewContainer* DolphinTabPage::secondaryViewContainer() const
DolphinViewContainer *DolphinTabPage::activeViewContainer() const
{
return m_primaryViewActive ? m_primaryViewContainer :
m_secondaryViewContainer;
return m_primaryViewActive ? m_primaryViewContainer : m_secondaryViewContainer;
}
KFileItemList DolphinTabPage::selectedItems() const
@ -200,8 +192,7 @@ void DolphinTabPage::connectNavigators(DolphinNavigatorsWidgetAction *navigators
auto secondaryNavigator = navigatorsWidget->secondaryUrlNavigator();
m_secondaryViewContainer->connectUrlNavigator(secondaryNavigator);
}
m_navigatorsWidget->followViewContainersGeometry(m_primaryViewContainer,
m_secondaryViewContainer);
m_navigatorsWidget->followViewContainersGeometry(m_primaryViewContainer, m_secondaryViewContainer);
}
void DolphinTabPage::disconnectNavigators()
@ -343,8 +334,7 @@ void DolphinTabPage::slotAnimationFinished()
{
for (int i = 0; i < m_splitter->count(); ++i) {
QWidget *viewContainer = m_splitter->widget(i);
if (viewContainer != m_primaryViewContainer &&
viewContainer != m_secondaryViewContainer) {
if (viewContainer != m_primaryViewContainer && viewContainer != m_secondaryViewContainer) {
viewContainer->close();
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.
for (int i = m_splitter->count() - 1; i >= 0; --i) {
if (m_splitter->widget(i) == m_primaryViewContainer ||
m_splitter->widget(i) == m_secondaryViewContainer) {
if (m_splitter->widget(i) == m_primaryViewContainer || m_splitter->widget(i) == m_secondaryViewContainer) {
continue;
}
newSplitterSizes[i] = oldSplitterSizes.at(i) - expansionWidthNeeded;
@ -404,7 +393,6 @@ void DolphinTabPage::slotAnimationValueChanged(const QVariant& value)
}
}
void DolphinTabPage::slotViewActivated()
{
const DolphinView *oldActiveView = activeViewContainer()->view();
@ -429,14 +417,10 @@ void DolphinTabPage::slotViewActivated()
return;
}
disconnect(oldActiveView, &DolphinView::urlChanged,
this, &DolphinTabPage::activeViewUrlChanged);
disconnect(oldActiveView, &DolphinView::redirection,
this, &DolphinTabPage::slotViewUrlRedirection);
connect(newActiveView, &DolphinView::urlChanged,
this, &DolphinTabPage::activeViewUrlChanged);
connect(newActiveView, &DolphinView::redirection,
this, &DolphinTabPage::slotViewUrlRedirection);
disconnect(oldActiveView, &DolphinView::urlChanged, this, &DolphinTabPage::activeViewUrlChanged);
disconnect(oldActiveView, &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 activeViewUrlChanged(activeViewContainer()->url());
}
@ -466,11 +450,9 @@ DolphinViewContainer* DolphinTabPage::createViewContainer(const QUrl& url) const
container->setActive(false);
const DolphinView *view = container->view();
connect(view, &DolphinView::activated,
this, &DolphinTabPage::slotViewActivated);
connect(view, &DolphinView::activated, this, &DolphinTabPage::slotViewActivated);
connect(view, &DolphinView::toggleActiveViewRequested,
this, &DolphinTabPage::switchActiveView);
connect(view, &DolphinView::toggleActiveViewRequested, this, &DolphinTabPage::switchActiveView);
return container;
}
@ -478,21 +460,16 @@ DolphinViewContainer* DolphinTabPage::createViewContainer(const QUrl& url) const
void DolphinTabPage::startExpandViewAnimation(DolphinViewContainer *expandingContainer)
{
Q_CHECK_PTR(expandingContainer);
Q_ASSERT(expandingContainer == m_primaryViewContainer ||
expandingContainer == m_secondaryViewContainer);
Q_ASSERT(expandingContainer == m_primaryViewContainer || expandingContainer == m_secondaryViewContainer);
m_expandingContainer = expandingContainer;
m_expandViewAnimation = new QVariantAnimation(m_splitter);
m_expandViewAnimation->setDuration(2 *
style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, this) *
GlobalConfig::animationDurationFactor());
m_expandViewAnimation->setDuration(2 * style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, this) * GlobalConfig::animationDurationFactor());
for (int i = 0; i < m_splitter->count(); ++i) {
m_splitter->widget(i)->setMinimumWidth(1);
}
connect(m_expandViewAnimation, &QAbstractAnimation::finished,
this, &DolphinTabPage::slotAnimationFinished);
connect(m_expandViewAnimation, &QVariantAnimation::valueChanged,
this, &DolphinTabPage::slotAnimationValueChanged);
connect(m_expandViewAnimation, &QAbstractAnimation::finished, this, &DolphinTabPage::slotAnimationFinished);
connect(m_expandViewAnimation, &QVariantAnimation::valueChanged, this, &DolphinTabPage::slotAnimationValueChanged);
m_expandViewAnimation->setStartValue(expandingContainer->width());
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)
: QSplitterHandle(orientation, parent)
, m_mouseReleaseWasReceived(false)
{}
{
}
bool DolphinTabPageSplitterHandle::event(QEvent *event)
{
@ -542,7 +520,8 @@ void DolphinTabPageSplitterHandle::resetSplitterSizes()
DolphinTabPageSplitter::DolphinTabPageSplitter(Qt::Orientation orientation, QWidget *parent)
: QSplitter(orientation, parent)
{}
{
}
QSplitterHandle *DolphinTabPageSplitter::createHandle()
{

View File

@ -11,9 +11,9 @@
#include "global.h"
#include <QPointer>
#include <QSplitter>
#include <QUrl>
#include <QWidget>
#include <QSplitter>
class DolphinNavigatorsWidgetAction;
class DolphinViewContainer;

View File

@ -10,35 +10,30 @@
#include "dolphintabbar.h"
#include "dolphinviewcontainer.h"
#include <KAcceleratorManager>
#include <KConfigGroup>
#include <KIO/CommandLauncherJob>
#include <KLocalizedString>
#include <KShell>
#include <kio/global.h>
#include <KIO/CommandLauncherJob>
#include <KAcceleratorManager>
#include <KLocalizedString>
#include <QApplication>
#include <QDropEvent>
DolphinTabWidget::DolphinTabWidget(DolphinNavigatorsWidgetAction *navigatorsWidget, QWidget* parent) :
QTabWidget(parent),
m_lastViewedTab(nullptr),
m_navigatorsWidget{navigatorsWidget}
DolphinTabWidget::DolphinTabWidget(DolphinNavigatorsWidgetAction *navigatorsWidget, QWidget *parent)
: QTabWidget(parent)
, m_lastViewedTab(nullptr)
, m_navigatorsWidget{navigatorsWidget}
{
KAcceleratorManager::setNoAccel(this);
connect(this, &DolphinTabWidget::tabCloseRequested,
this, QOverload<int>::of(&DolphinTabWidget::closeTab));
connect(this, &DolphinTabWidget::currentChanged,
this, &DolphinTabWidget::currentTabChanged);
connect(this, &DolphinTabWidget::tabCloseRequested, this, QOverload<int>::of(&DolphinTabWidget::closeTab));
connect(this, &DolphinTabWidget::currentChanged, this, &DolphinTabWidget::currentTabChanged);
DolphinTabBar *tabBar = new DolphinTabBar(this);
connect(tabBar, &DolphinTabBar::openNewActivatedTab,
this, QOverload<int>::of(&DolphinTabWidget::openNewActivatedTab));
connect(tabBar, &DolphinTabBar::tabDropEvent,
this, &DolphinTabWidget::tabDropEvent);
connect(tabBar, &DolphinTabBar::tabDetachRequested,
this, &DolphinTabWidget::detachTab);
connect(tabBar, &DolphinTabBar::openNewActivatedTab, this, QOverload<int>::of(&DolphinTabWidget::openNewActivatedTab));
connect(tabBar, &DolphinTabBar::tabDropEvent, this, &DolphinTabWidget::tabDropEvent);
connect(tabBar, &DolphinTabBar::tabDetachRequested, this, &DolphinTabWidget::detachTab);
tabBar->hide();
setTabBar(tabBar);
@ -164,10 +159,8 @@ void DolphinTabWidget::openNewTab(const QUrl& primaryUrl, const QUrl& secondaryU
DolphinTabPage *tabPage = new DolphinTabPage(primaryUrl, secondaryUrl, this);
tabPage->setActive(false);
connect(tabPage, &DolphinTabPage::activeViewChanged,
this, &DolphinTabWidget::activeViewChanged);
connect(tabPage, &DolphinTabPage::activeViewUrlChanged,
this, &DolphinTabWidget::tabUrlChanged);
connect(tabPage, &DolphinTabPage::activeViewChanged, this, &DolphinTabWidget::activeViewChanged);
connect(tabPage, &DolphinTabPage::activeViewUrlChanged, this, &DolphinTabWidget::tabUrlChanged);
connect(tabPage->activeViewContainer(), &DolphinViewContainer::captionChanged, this, [this, tabPage]() {
const int tabIndex = indexOf(tabPage);
Q_ASSERT(tabIndex >= 0);
@ -497,7 +490,7 @@ QString DolphinTabWidget::tabName(DolphinTabPage* tabPage) const
if (!tabPage) {
return QString();
}
// clang-format off
QString name;
if (tabPage->splitViewEnabled()) {
if (tabPage->primaryViewActive()) {
@ -512,6 +505,7 @@ QString DolphinTabWidget::tabName(DolphinTabPage* tabPage) const
} else {
name = tabPage->activeViewContainer()->caption();
}
// clang-format on
// Make sure that a '&' inside the directory name is displayed correctly
// 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();
}
while (i != currentIndex());
} while (i != currentIndex());
return std::nullopt;
}
@ -600,8 +593,7 @@ const std::optional<const DolphinTabWidget::ViewIndex> DolphinTabWidget::viewSho
}
i = (i + 1) % count();
}
while (i != currentIndex());
} while (i != currentIndex());
return std::nullopt;
}

View File

@ -23,7 +23,6 @@ class DolphinTabWidget : public QTabWidget
Q_OBJECT
public:
/**
* @param navigatorsWidget The navigatorsWidget which is always going to be connected
* to the active tabPage.

View File

@ -12,19 +12,20 @@
#include "dolphinurlnavigatorscontroller.h"
#include "global.h"
#include <KUrlComboBox>
#include <KLocalizedString>
#include <KUrlComboBox>
#include <QAbstractButton>
#include <QLayout>
#include <QLineEdit>
DolphinUrlNavigator::DolphinUrlNavigator(QWidget *parent) :
DolphinUrlNavigator(QUrl(), parent)
{}
DolphinUrlNavigator::DolphinUrlNavigator(QWidget *parent)
: DolphinUrlNavigator(QUrl(), parent)
{
}
DolphinUrlNavigator::DolphinUrlNavigator(const QUrl &url, QWidget *parent) :
KUrlNavigator(DolphinPlacesModelSingleton::instance().placesModel(), url, parent)
DolphinUrlNavigator::DolphinUrlNavigator(const QUrl &url, QWidget *parent)
: KUrlNavigator(DolphinPlacesModelSingleton::instance().placesModel(), url, parent)
{
const GeneralSettings *settings = GeneralSettings::self();
setUrlEditable(settings->editableUrl());
@ -47,8 +48,7 @@ DolphinUrlNavigator::DolphinUrlNavigator(const QUrl &url, QWidget *parent) :
DolphinUrlNavigatorsController::registerDolphinUrlNavigator(this);
connect(this, &KUrlNavigator::returnPressed,
this, &DolphinUrlNavigator::slotReturnPressed);
connect(this, &KUrlNavigator::returnPressed, this, &DolphinUrlNavigator::slotReturnPressed);
}
DolphinUrlNavigator::~DolphinUrlNavigator()

View File

@ -46,8 +46,7 @@ bool DolphinUrlNavigatorsController::placesSelectorVisible()
void DolphinUrlNavigatorsController::registerDolphinUrlNavigator(DolphinUrlNavigator *dolphinUrlNavigator)
{
s_instances.push_front(dolphinUrlNavigator);
connect(dolphinUrlNavigator->editor(), &KUrlComboBox::completionModeChanged,
DolphinUrlNavigatorsController::setCompletionMode);
connect(dolphinUrlNavigator->editor(), &KUrlComboBox::completionModeChanged, DolphinUrlNavigatorsController::setCompletionMode);
}
void DolphinUrlNavigatorsController::unregisterDolphinUrlNavigator(DolphinUrlNavigator *dolphinUrlNavigator)

View File

@ -6,6 +6,7 @@
#include "dolphinviewcontainer.h"
#include "dolphin_detailsmodesettings.h"
#include "dolphin_generalsettings.h"
#include "dolphindebug.h"
#include "dolphinplacesmodelsingleton.h"
@ -14,7 +15,6 @@
#include "search/dolphinsearchbox.h"
#include "selectionmode/topbar.h"
#include "statusbar/dolphinstatusbar.h"
#include "dolphin_detailsmodesettings.h"
#include <KActionCollection>
#if HAVE_KACTIVITIES
@ -38,9 +38,9 @@
#include <QDropEvent>
#include <QGridLayout>
#include <QGuiApplication>
#include <QRegularExpression>
#include <QTimer>
#include <QUrl>
#include <QRegularExpression>
// An overview of the widgets contained by this ViewContainer
struct LayoutStructure {
@ -54,22 +54,22 @@ struct LayoutStructure {
};
constexpr LayoutStructure positionFor;
DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) :
QWidget(parent),
m_topLayout(nullptr),
m_urlNavigator{new DolphinUrlNavigator(url)},
m_urlNavigatorConnected{nullptr},
m_searchBox(nullptr),
m_searchModeEnabled(false),
m_messageWidget(nullptr),
m_selectionModeTopBar{nullptr},
m_view(nullptr),
m_filterBar(nullptr),
m_selectionModeBottomBar{nullptr},
m_statusBar(nullptr),
m_statusBarTimer(nullptr),
m_statusBarTimestamp(),
m_autoGrabFocus(true)
DolphinViewContainer::DolphinViewContainer(const QUrl &url, QWidget *parent)
: QWidget(parent)
, m_topLayout(nullptr)
, m_urlNavigator{new DolphinUrlNavigator(url)}
, m_urlNavigatorConnected{nullptr}
, m_searchBox(nullptr)
, m_searchModeEnabled(false)
, m_messageWidget(nullptr)
, m_selectionModeTopBar{nullptr}
, m_view(nullptr)
, m_filterBar(nullptr)
, m_selectionModeBottomBar{nullptr}
, m_statusBar(nullptr)
, m_statusBarTimer(nullptr)
, m_statusBarTimestamp()
, m_autoGrabFocus(true)
#if HAVE_KACTIVITIES
, m_activityResourceInstance(nullptr)
#endif
@ -105,7 +105,6 @@ DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) :
#ifndef Q_OS_WIN
if (getuid() == 0) {
// 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);
}
@ -115,86 +114,51 @@ DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) :
m_filterBar = new FilterBar(this);
m_filterBar->setVisible(GeneralSettings::filterBar());
connect(m_filterBar, &FilterBar::filterChanged,
this, &DolphinViewContainer::setNameFilter);
connect(m_filterBar, &FilterBar::closeRequest,
this, &DolphinViewContainer::closeFilterBar);
connect(m_filterBar, &FilterBar::focusViewRequest,
this, &DolphinViewContainer::requestFocus);
connect(m_filterBar, &FilterBar::filterChanged, this, &DolphinViewContainer::setNameFilter);
connect(m_filterBar, &FilterBar::closeRequest, this, &DolphinViewContainer::closeFilterBar);
connect(m_filterBar, &FilterBar::focusViewRequest, this, &DolphinViewContainer::requestFocus);
// Initialize the main view
m_view = new DolphinView(url, this);
connect(m_view, &DolphinView::urlChanged,
m_filterBar, &FilterBar::clearIfUnlocked);
connect(m_view, &DolphinView::urlChanged,
m_messageWidget, &KMessageWidget::hide);
connect(m_view, &DolphinView::urlChanged, m_filterBar, &FilterBar::clearIfUnlocked);
connect(m_view, &DolphinView::urlChanged, m_messageWidget, &KMessageWidget::hide);
// 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.
connect(m_view, &DolphinView::urlChanged,
m_urlNavigator.get(), &DolphinUrlNavigator::setLocationUrl);
connect(m_urlNavigator.get(), &DolphinUrlNavigator::urlChanged,
this, &DolphinViewContainer::slotUrlNavigatorLocationChanged);
connect(m_urlNavigator.get(), &DolphinUrlNavigator::urlAboutToBeChanged,
this, &DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged);
connect(m_urlNavigator.get(), &DolphinUrlNavigator::urlSelectionRequested,
this, &DolphinViewContainer::slotUrlSelectionRequested);
connect(m_view, &DolphinView::writeStateChanged,
this, &DolphinViewContainer::writeStateChanged);
connect(m_view, &DolphinView::requestItemInfo,
this, &DolphinViewContainer::showItemInfo);
connect(m_view, &DolphinView::itemActivated,
this, &DolphinViewContainer::slotItemActivated);
connect(m_view, &DolphinView::itemsActivated,
this, &DolphinViewContainer::slotItemsActivated);
connect(m_view, &DolphinView::redirection,
this, &DolphinViewContainer::redirect);
connect(m_view, &DolphinView::directoryLoadingStarted,
this, &DolphinViewContainer::slotDirectoryLoadingStarted);
connect(m_view, &DolphinView::directoryLoadingCompleted,
this, &DolphinViewContainer::slotDirectoryLoadingCompleted);
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);
connect(m_view, &DolphinView::urlChanged, m_urlNavigator.get(), &DolphinUrlNavigator::setLocationUrl);
connect(m_urlNavigator.get(), &DolphinUrlNavigator::urlChanged, this, &DolphinViewContainer::slotUrlNavigatorLocationChanged);
connect(m_urlNavigator.get(), &DolphinUrlNavigator::urlAboutToBeChanged, this, &DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged);
connect(m_urlNavigator.get(), &DolphinUrlNavigator::urlSelectionRequested, this, &DolphinViewContainer::slotUrlSelectionRequested);
connect(m_view, &DolphinView::writeStateChanged, this, &DolphinViewContainer::writeStateChanged);
connect(m_view, &DolphinView::requestItemInfo, this, &DolphinViewContainer::showItemInfo);
connect(m_view, &DolphinView::itemActivated, this, &DolphinViewContainer::slotItemActivated);
connect(m_view, &DolphinView::itemsActivated, this, &DolphinViewContainer::slotItemsActivated);
connect(m_view, &DolphinView::redirection, this, &DolphinViewContainer::redirect);
connect(m_view, &DolphinView::directoryLoadingStarted, this, &DolphinViewContainer::slotDirectoryLoadingStarted);
connect(m_view, &DolphinView::directoryLoadingCompleted, this, &DolphinViewContainer::slotDirectoryLoadingCompleted);
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
m_statusBar = new DolphinStatusBar(this);
m_statusBar->setUrl(m_view->url());
m_statusBar->setZoomLevel(m_view->zoomLevel());
connect(m_view, &DolphinView::urlChanged,
m_statusBar, &DolphinStatusBar::setUrl);
connect(m_view, &DolphinView::zoomLevelChanged,
m_statusBar, &DolphinStatusBar::setZoomLevel);
connect(m_view, &DolphinView::infoMessage,
m_statusBar, &DolphinStatusBar::setText);
connect(m_view, &DolphinView::operationCompletedMessage,
m_statusBar, &DolphinStatusBar::setText);
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);
connect(m_view, &DolphinView::urlChanged, m_statusBar, &DolphinStatusBar::setUrl);
connect(m_view, &DolphinView::zoomLevelChanged, m_statusBar, &DolphinStatusBar::setZoomLevel);
connect(m_view, &DolphinView::infoMessage, m_statusBar, &DolphinStatusBar::setText);
connect(m_view, &DolphinView::operationCompletedMessage, m_statusBar, &DolphinStatusBar::setText);
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->setSingleShot(true);
@ -202,8 +166,7 @@ DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) :
connect(m_statusBarTimer, &QTimer::timeout, this, &DolphinViewContainer::updateStatusBar);
KIO::FileUndoManager *undoManager = KIO::FileUndoManager::self();
connect(undoManager, &KIO::FileUndoManager::jobRecordingFinished,
this, &DolphinViewContainer::delayedStatusBarUpdate);
connect(undoManager, &KIO::FileUndoManager::jobRecordingFinished, this, &DolphinViewContainer::delayedStatusBarUpdate);
m_topLayout->addWidget(m_searchBox, positionFor.searchBox, 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();
connect(placesModel, &KFilePlacesModel::dataChanged,
this, &DolphinViewContainer::slotPlacesModelChanged);
connect(placesModel, &KFilePlacesModel::rowsInserted,
this, &DolphinViewContainer::slotPlacesModelChanged);
connect(placesModel, &KFilePlacesModel::rowsRemoved,
this, &DolphinViewContainer::slotPlacesModelChanged);
connect(placesModel, &KFilePlacesModel::dataChanged, this, &DolphinViewContainer::slotPlacesModelChanged);
connect(placesModel, &KFilePlacesModel::rowsInserted, this, &DolphinViewContainer::slotPlacesModelChanged);
connect(placesModel, &KFilePlacesModel::rowsRemoved, this, &DolphinViewContainer::slotPlacesModelChanged);
connect(this, &DolphinViewContainer::searchModeEnabledChanged,
this, &DolphinViewContainer::captionChanged);
connect(this, &DolphinViewContainer::searchModeEnabledChanged, this, &DolphinViewContainer::captionChanged);
// Initialize kactivities resource instance
@ -341,17 +300,13 @@ void DolphinViewContainer::connectUrlNavigator(DolphinUrlNavigator *urlNavigator
urlNavigator->setActive(isActive());
// Url changes are still done via m_urlNavigator.
connect(urlNavigator, &DolphinUrlNavigator::urlChanged,
m_urlNavigator.get(), &DolphinUrlNavigator::setLocationUrl);
connect(urlNavigator, &DolphinUrlNavigator::urlsDropped,
this, [=](const QUrl &destination, QDropEvent *event) {
connect(urlNavigator, &DolphinUrlNavigator::urlChanged, m_urlNavigator.get(), &DolphinUrlNavigator::setLocationUrl);
connect(urlNavigator, &DolphinUrlNavigator::urlsDropped, this, [=](const QUrl &destination, QDropEvent *event) {
m_view->dropUrls(destination, event, urlNavigator->dropWidget());
});
// Aside from these, only visual things need to be connected.
connect(m_view, &DolphinView::urlChanged,
urlNavigator, &DolphinUrlNavigator::setLocationUrl);
connect(urlNavigator, &DolphinUrlNavigator::activated,
this, &DolphinViewContainer::activate);
connect(m_view, &DolphinView::urlChanged, urlNavigator, &DolphinUrlNavigator::setLocationUrl);
connect(urlNavigator, &DolphinUrlNavigator::activated, this, &DolphinViewContainer::activate);
m_urlNavigatorConnected = urlNavigator;
}
@ -362,14 +317,10 @@ void DolphinViewContainer::disconnectUrlNavigator()
return;
}
disconnect(m_urlNavigatorConnected, &DolphinUrlNavigator::urlChanged,
m_urlNavigator.get(), &DolphinUrlNavigator::setLocationUrl);
disconnect(m_urlNavigatorConnected, &DolphinUrlNavigator::urlsDropped,
this, nullptr);
disconnect(m_view, &DolphinView::urlChanged,
m_urlNavigatorConnected, &DolphinUrlNavigator::setLocationUrl);
disconnect(m_urlNavigatorConnected, &DolphinUrlNavigator::activated,
this, &DolphinViewContainer::activate);
disconnect(m_urlNavigatorConnected, &DolphinUrlNavigator::urlChanged, m_urlNavigator.get(), &DolphinUrlNavigator::setLocationUrl);
disconnect(m_urlNavigatorConnected, &DolphinUrlNavigator::urlsDropped, this, nullptr);
disconnect(m_view, &DolphinView::urlChanged, m_urlNavigatorConnected, &DolphinUrlNavigator::setLocationUrl);
disconnect(m_urlNavigatorConnected, &DolphinUrlNavigator::activated, this, &DolphinViewContainer::activate);
m_urlNavigatorVisualState = m_urlNavigatorConnected->visualState();
m_urlNavigatorConnected = nullptr;
@ -435,10 +386,10 @@ bool DolphinViewContainer::isSelectionModeEnabled() const
const bool isEnabled = m_view->selectionMode();
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.
&& (!m_selectionModeBottomBar || !m_selectionModeBottomBar->isEnabled() ||
!m_selectionModeBottomBar->isVisible() || m_selectionModeBottomBar->contents() == SelectionMode::BottomBar::PasteContents))
|| ( isEnabled
&& m_selectionModeTopBar && m_selectionModeTopBar->isVisible()
&& (!m_selectionModeBottomBar || !m_selectionModeBottomBar->isEnabled() || !m_selectionModeBottomBar->isVisible()
|| m_selectionModeBottomBar->contents() == SelectionMode::BottomBar::PasteContents))
|| (isEnabled && m_selectionModeTopBar
&& 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.
&& m_selectionModeBottomBar
&& (m_selectionModeBottomBar->isVisible() || m_selectionModeBottomBar->contents() == SelectionMode::BottomBar::GeneralContents)));
@ -452,7 +403,6 @@ void DolphinViewContainer::slotSplitTabDisabled()
}
}
void DolphinViewContainer::showMessage(const QString &msg, MessageType type)
{
if (msg.isEmpty()) {
@ -466,9 +416,15 @@ void DolphinViewContainer::showMessage(const QString& msg, MessageType type)
m_messageWidget->setWordWrap(true);
switch (type) {
case Information: m_messageWidget->setMessageType(KMessageWidget::Information); break;
case Warning: m_messageWidget->setMessageType(KMessageWidget::Warning); break;
case Error: m_messageWidget->setMessageType(KMessageWidget::Error); break;
case Information:
m_messageWidget->setMessageType(KMessageWidget::Information);
break;
case Warning:
m_messageWidget->setMessageType(KMessageWidget::Warning);
break;
case Error:
m_messageWidget->setMessageType(KMessageWidget::Error);
break;
default:
Q_ASSERT(false);
break;
@ -590,13 +546,13 @@ QString DolphinViewContainer::caption() const
KFilePlacesModel *placesModel = DolphinPlacesModelSingleton::instance().placesModel();
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()) {
return placesModel->text(matchedPlaces.first());
}
if (!url().isLocalFile()) {
QUrl adjustedUrl = url().adjusted(QUrl::StripTrailingSlash);
QString caption;
@ -842,9 +798,7 @@ void DolphinViewContainer::slotUrlNavigatorLocationChanged(const QUrl& url)
"Dolphin does not support web pages, the web browser has been launched"),
Information);
} else {
showMessage(i18nc("@info:status",
"Protocol not supported by Dolphin, default application has been launched"),
Information);
showMessage(i18nc("@info:status", "Protocol not supported by Dolphin, default application has been launched"), Information);
}
QDesktopServices::openUrl(url);
@ -863,14 +817,12 @@ void DolphinViewContainer::slotUrlSelectionRequested(const QUrl& url)
void DolphinViewContainer::disableUrlNavigatorSelectionRequests()
{
disconnect(m_urlNavigator.get(), &KUrlNavigator::urlSelectionRequested,
this, &DolphinViewContainer::slotUrlSelectionRequested);
disconnect(m_urlNavigator.get(), &KUrlNavigator::urlSelectionRequested, this, &DolphinViewContainer::slotUrlSelectionRequested);
}
void DolphinViewContainer::enableUrlNavigatorSelectionRequests()
{
connect(m_urlNavigator.get(), &KUrlNavigator::urlSelectionRequested,
this, &DolphinViewContainer::slotUrlSelectionRequested);
connect(m_urlNavigator.get(), &KUrlNavigator::urlSelectionRequested, this, &DolphinViewContainer::slotUrlSelectionRequested);
}
void DolphinViewContainer::redirect(const QUrl &oldUrl, const QUrl &newUrl)
@ -993,8 +945,7 @@ QString DolphinViewContainer::getNearestExistingAncestorOfPath(const QString& pa
QDir dir(path);
do {
dir.setPath(QDir::cleanPath(dir.filePath(QStringLiteral(".."))));
}
while (!dir.exists() && !dir.isRoot());
} while (!dir.exists() && !dir.isRoot());
return dir.exists() ? dir.path() : QString{};
}

View File

@ -21,7 +21,8 @@
#include <QWidget>
#if HAVE_KACTIVITIES
namespace KActivities {
namespace KActivities
{
class ResourceInstance;
}
#endif
@ -33,7 +34,8 @@ class QGridLayout;
class QUrl;
class DolphinSearchBox;
class DolphinStatusBar;
namespace SelectionMode {
namespace SelectionMode
{
class TopBar;
}
@ -54,12 +56,7 @@ class DolphinViewContainer : public QWidget
Q_OBJECT
public:
enum MessageType
{
Information,
Warning,
Error
};
enum MessageType { Information, Warning, Error };
DolphinViewContainer(const QUrl &url, QWidget *parent);
~DolphinViewContainer() override;
@ -149,7 +146,9 @@ public:
* @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.
*/
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() */
bool isSelectionModeEnabled() const;
@ -167,7 +166,6 @@ public:
/** Returns true, if the filter bar is visible. */
bool isFilterBarVisible() const;
/** Returns true if the search mode is enabled. */
bool isSearchModeEnabled() const;

View File

@ -15,8 +15,8 @@
#include <QLineEdit>
#include <QToolButton>
FilterBar::FilterBar(QWidget* parent) :
QWidget(parent)
FilterBar::FilterBar(QWidget *parent)
: QWidget(parent)
{
// Create button to lock text when changing folders
m_lockButton = new QToolButton(this);
@ -26,14 +26,12 @@ FilterBar::FilterBar(QWidget* parent) :
m_lockButton->setToolTip(i18nc("@info:tooltip", "Keep Filter When Changing Folders"));
connect(m_lockButton, &QToolButton::toggled, this, &FilterBar::slotToggleLockButton);
// Create filter editor
m_filterInput = new QLineEdit(this);
m_filterInput->setLayoutDirection(Qt::LeftToRight);
m_filterInput->setClearButtonEnabled(true);
m_filterInput->setPlaceholderText(i18n("Filter..."));
connect(m_filterInput, &QLineEdit::textChanged,
this, &FilterBar::filterChanged);
connect(m_filterInput, &QLineEdit::textChanged, this, &FilterBar::filterChanged);
setFocusProxy(m_filterInput);
// Create close button
@ -120,4 +118,3 @@ void FilterBar::keyReleaseEvent(QKeyEvent* event)
break;
}
}

View File

@ -57,7 +57,11 @@ void Dolphin::openNewWindow(const QList<QUrl> &urls, QWidget *window, const Open
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;
@ -101,8 +105,7 @@ bool Dolphin::attachToExistingInstance(const QList<QUrl>& inputUrls, bool openFi
}
i = (i + 1) % dolphinInterfaces.size();
}
while (i != activeWindowIndex);
} while (i != activeWindowIndex);
if (!urlFound) {
if (GeneralSettings::openExternallyCalledFolderInNewTab()) {
@ -117,9 +120,7 @@ bool Dolphin::attachToExistingInstance(const QList<QUrl>& inputUrls, bool openFi
if (interface.second.isEmpty()) {
continue;
}
auto reply = openFiles ?
interface.first->openFiles(interface.second, splitView) :
interface.first->openDirectories(interface.second, splitView);
auto reply = openFiles ? interface.first->openFiles(interface.second, splitView) : interface.first->openDirectories(interface.second, splitView);
reply.waitForFinished();
if (!reply.isError()) {
interface.first->activateWindow(activationToken);
@ -142,9 +143,7 @@ QVector<QPair<QSharedPointer<OrgKdeDolphinMainWindowInterface>, QStringList>> Do
QVector<QPair<QSharedPointer<OrgKdeDolphinMainWindowInterface>, QStringList>> dolphinInterfaces;
if (!preferredService.isEmpty()) {
QSharedPointer<OrgKdeDolphinMainWindowInterface> preferredInterface(
new OrgKdeDolphinMainWindowInterface(preferredService,
QStringLiteral("/dolphin/Dolphin_1"),
QDBusConnection::sessionBus()));
new OrgKdeDolphinMainWindowInterface(preferredService, QStringLiteral("/dolphin/Dolphin_1"), QDBusConnection::sessionBus()));
if (preferredInterface->isValid() && !preferredInterface->lastError().isValid()) {
dolphinInterfaces.append(qMakePair(preferredInterface, QStringList()));
}
@ -161,9 +160,7 @@ QVector<QPair<QSharedPointer<OrgKdeDolphinMainWindowInterface>, QStringList>> Do
if (service.startsWith(pattern) && !service.endsWith(myPid)) {
// Check if instance can handle our URLs
QSharedPointer<OrgKdeDolphinMainWindowInterface> interface(
new OrgKdeDolphinMainWindowInterface(service,
QStringLiteral("/dolphin/Dolphin_1"),
QDBusConnection::sessionBus()));
new OrgKdeDolphinMainWindowInterface(service, QStringLiteral("/dolphin/Dolphin_1"), QDBusConnection::sessionBus()));
if (interface->isValid() && !interface->lastError().isValid()) {
dolphinInterfaces.append(qMakePair(interface, QStringList()));
}
@ -189,17 +186,14 @@ double GlobalConfig::animationDurationFactor()
updateAnimationDurationFactor(kdeGlobalsConfig, {"AnimationDurationFactor"});
KConfigWatcher::Ptr configWatcher = KConfigWatcher::create(KSharedConfig::openConfig());
connect(configWatcher.data(), &KConfigWatcher::configChanged,
&GlobalConfig::updateAnimationDurationFactor);
connect(configWatcher.data(), &KConfigWatcher::configChanged, &GlobalConfig::updateAnimationDurationFactor);
return s_animationDurationFactor;
}
void GlobalConfig::updateAnimationDurationFactor(const KConfigGroup &group, const QByteArrayList &names)
{
if (group.name() == QLatin1String("KDE") &&
names.contains(QByteArrayLiteral("AnimationDurationFactor"))) {
s_animationDurationFactor = std::max(0.0,
group.readEntry("AnimationDurationFactor", 1.0));
if (group.name() == QLatin1String("KDE") && names.contains(QByteArrayLiteral("AnimationDurationFactor"))) {
s_animationDurationFactor = std::max(0.0, group.readEntry("AnimationDurationFactor", 1.0));
}
}

View File

@ -14,7 +14,8 @@
class KConfigGroup;
class OrgKdeDolphinMainWindowInterface;
namespace Dolphin {
namespace Dolphin
{
QList<QUrl> validateUris(const QStringList &uriList);
/**
@ -22,10 +23,7 @@ namespace Dolphin {
*/
QUrl homeUrl();
enum class OpenNewWindowFlag {
None = 0,
Select = 1<<1
};
enum class OpenNewWindowFlag { None = 0, Select = 1 << 1 };
Q_DECLARE_FLAGS(OpenNewWindowFlags, OpenNewWindowFlag)
/**
@ -55,10 +53,7 @@ namespace Dolphin {
const int LAYOUT_SPACING_SMALL = 2;
}
enum Animated {
WithAnimation,
WithoutAnimation
};
enum Animated { WithAnimation, WithoutAnimation };
class GlobalConfig : public QObject
{

View File

@ -19,27 +19,35 @@ QString fileItemListToString(KFileItemList items, int maximumTextWidth, const QF
QString text;
switch (items.count()) {
case 1:
text = i18nc("Textual representation of a file. %1 is the name of the file/folder.",
"\"%1\"", items.first().name());
text = i18nc("Textual representation of a file. %1 is the name of the file/folder.", "\"%1\"", items.first().name());
break;
case 2:
text = i18nc("Textual representation of two files. %1 and %2 are names of files/folders.",
"\"%1\" and \"%2\"", items.first().name(), items.last().name());
text =
i18nc("Textual representation of two files. %1 and %2 are names of files/folders.", "\"%1\" and \"%2\"", items.first().name(), items.last().name());
break;
case 3:
text = i18nc("Textual representation of three files. %1, %2 and %3 are names of files/folders.",
"\"%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;
case 4:
text = i18nc("Textual representation of four files. %1, %2, %3 and %4 are names of files/folders.",
"\"%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;
case 5:
text = i18nc("Textual representation of five files. %1, %2, %3, %4 and %5 are names of files/folders.",
"\"%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;
default:
text = QString();
@ -54,14 +62,15 @@ QString fileItemListToString(KFileItemList items, int maximumTextWidth, const QF
const KFileItemListProperties properties(items);
if (itemsState == Selected) {
if (properties.isFile()) {
text = i18ncp("Textual representation of selected files. %1 is the number of files.",
"One Selected File", "%1 Selected Files", items.count());
text = i18ncp("Textual representation of selected files. %1 is the number of files.", "One Selected File", "%1 Selected Files", items.count());
} else if (properties.isDirectory()) {
text = i18ncp("Textual representation of selected folders. %1 is the number of folders.",
"One Selected Folder", "%1 Selected Folders", items.count());
text =
i18ncp("Textual representation of selected folders. %1 is the number of folders.", "One Selected Folder", "%1 Selected Folders", items.count());
} else {
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) {
@ -70,13 +79,10 @@ QString fileItemListToString(KFileItemList items, int maximumTextWidth, const QF
}
if (properties.isFile()) {
return i18ncp("Textual representation of files. %1 is the number of files.",
"One File", "%1 Files", items.count());
return i18ncp("Textual representation of files. %1 is the number of files.", "One File", "%1 Files", items.count());
} else if (properties.isDirectory()) {
return i18ncp("Textual representation of folders. %1 is the number of folders.",
"One Folder", "%1 Folders", items.count());
return i18ncp("Textual representation of folders. %1 is the number of folders.", "One Folder", "%1 Folders", items.count());
} else {
return i18ncp("Textual representation of fileitems. %1 is the number of files/folders.",
"One Item", "%1 Items", items.count());
return i18ncp("Textual representation of fileitems. %1 is the number of files/folders.", "One Item", "%1 Items", items.count());
}
}

View File

@ -12,10 +12,7 @@ class KFileItemList;
class QFontMetrics;
class QString;
enum ItemsState {
None,
Selected
};
enum ItemsState { None, Selected };
/**
* @brief Generates a textual representation of the given list of KFileItems.

View File

@ -15,14 +15,15 @@
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QPainter>
#include <QTimer>
#include <QIcon>
#include <QMimeDatabase>
#include <QPainter>
#include <QTimer>
// #define KFILEITEMLISTVIEW_DEBUG
namespace {
namespace
{
// If the visible index range changes, KFileItemModelRolesUpdater is not
// informed immediately, but with a short delay. This ensures that scrolling
// always feels smooth and is not interrupted by icon loading (which can be
@ -35,12 +36,12 @@ namespace {
const int LongInterval = 300;
}
KFileItemListView::KFileItemListView(QGraphicsWidget* parent) :
KStandardItemListView(parent),
m_modelRolesUpdater(nullptr),
m_updateVisibleIndexRangeTimer(nullptr),
m_updateIconSizeTimer(nullptr),
m_scanDirectories(true)
KFileItemListView::KFileItemListView(QGraphicsWidget *parent)
: KStandardItemListView(parent)
, m_modelRolesUpdater(nullptr)
, m_updateVisibleIndexRangeTimer(nullptr)
, m_updateIconSizeTimer(nullptr)
, m_scanDirectories(true)
{
setAcceptDrops(true);
@ -328,8 +329,7 @@ void KFileItemListView::onTransactionEnd()
// 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
// soon as the timer has been exceeded.
const bool timerActive = m_updateVisibleIndexRangeTimer->isActive() ||
m_updateIconSizeTimer->isActive();
const bool timerActive = m_updateVisibleIndexRangeTimer->isActive() || m_updateIconSizeTimer->isActive();
if (!timerActive) {
m_modelRolesUpdater->setPaused(false);
}
@ -457,4 +457,3 @@ QSize KFileItemListView::availableIconSize() const
return QSize(iconSize, iconSize);
}

View File

@ -143,5 +143,3 @@ private:
};
#endif

View File

@ -18,8 +18,8 @@
#include <QGraphicsView>
#include <QMimeDatabase>
KFileItemListWidgetInformant::KFileItemListWidgetInformant() :
KStandardItemListWidgetInformant()
KFileItemListWidgetInformant::KFileItemListWidgetInformant()
: KStandardItemListWidgetInformant()
{
}
@ -45,8 +45,7 @@ bool KFileItemListWidgetInformant::itemIsLink(int index, const KItemListView* vi
return item.isLink();
}
QString KFileItemListWidgetInformant::roleText(const QByteArray& role,
const QHash<QByteArray, QVariant>& values) const
QString KFileItemListWidgetInformant::roleText(const QByteArray &role, const QHash<QByteArray, QVariant> &values) const
{
QString text;
const QVariant roleValue = values.value(role);
@ -114,8 +113,8 @@ QFont KFileItemListWidgetInformant::customizedFontForLinks(const QFont& baseFont
return font;
}
KFileItemListWidget::KFileItemListWidget(KItemListWidgetInformant* informant, QGraphicsItem* parent) :
KStandardItemListWidget(informant, parent)
KFileItemListWidget::KFileItemListWidget(KItemListWidgetInformant *informant, QGraphicsItem *parent)
: KStandardItemListWidget(informant, parent)
{
}
@ -222,4 +221,3 @@ KFileItemListView* KFileItemListWidget::listView()
{
return dynamic_cast<KFileItemListView *>(parentItem());
}

View File

@ -12,7 +12,6 @@
class KFileItemListView;
class DOLPHIN_EXPORT KFileItemListWidgetInformant : public KStandardItemListWidgetInformant
{
public:
@ -55,5 +54,3 @@ private:
};
#endif

View File

@ -8,24 +8,24 @@
#include "kfileitemmodel.h"
#include "dolphin_generalsettings.h"
#include "dolphin_detailsmodesettings.h"
#include "dolphin_generalsettings.h"
#include "dolphindebug.h"
#include "private/kfileitemmodelsortalgorithm.h"
#include <KDirLister>
#include <KIO/Job>
#include <kio_version.h>
#include <KLocalizedString>
#include <KUrlMimeData>
#include <kio_version.h>
#include <QElapsedTimer>
#include <QIcon>
#include <QMimeData>
#include <QMimeDatabase>
#include <QRecursiveMutex>
#include <QTimer>
#include <QWidget>
#include <QRecursiveMutex>
#include <QIcon>
#include <algorithm>
#include <klazylocalizedstring.h>
@ -33,25 +33,25 @@ Q_GLOBAL_STATIC(QRecursiveMutex, s_collatorMutex)
// #define KFILEITEMMODEL_DEBUG
KFileItemModel::KFileItemModel(QObject* parent) :
KItemModelBase("text", parent),
m_dirLister(nullptr),
m_sortDirsFirst(true),
m_sortHiddenLast(false),
m_sortRole(NameRole),
m_sortingProgressPercent(-1),
m_roles(),
m_itemData(),
m_items(),
m_filter(),
m_filteredItems(),
m_requestRole(),
m_maximumUpdateIntervalTimer(nullptr),
m_resortAllItemsTimer(nullptr),
m_pendingItemsToInsert(),
m_groups(),
m_expandedDirs(),
m_urlsToExpand()
KFileItemModel::KFileItemModel(QObject *parent)
: KItemModelBase("text", parent)
, m_dirLister(nullptr)
, m_sortDirsFirst(true)
, m_sortHiddenLast(false)
, m_sortRole(NameRole)
, m_sortingProgressPercent(-1)
, m_roles()
, m_itemData()
, m_items()
, m_filter()
, m_filteredItems()
, m_requestRole()
, m_maximumUpdateIntervalTimer(nullptr)
, m_resortAllItemsTimer(nullptr)
, m_pendingItemsToInsert()
, m_groups()
, m_expandedDirs()
, m_urlsToExpand()
{
m_collator.setNumericMode(true);
@ -353,8 +353,12 @@ QList<QPair<int, QVariant> > KFileItemModel::groups() const
timer.start();
#endif
switch (typeForRole(sortRole())) {
case NameRole: m_groups = nameRoleGroups(); break;
case SizeRole: m_groups = sizeRoleGroups(); break;
case NameRole:
m_groups = nameRoleGroups();
break;
case SizeRole:
m_groups = sizeRoleGroups();
break;
case ModificationTimeRole:
m_groups = timeRoleGroups([](const ItemData *item) {
return item->item.time(KFileItem::ModificationTime);
@ -375,9 +379,15 @@ QList<QPair<int, QVariant> > KFileItemModel::groups() const
return item->values.value("deletiontime").toDateTime();
});
break;
case PermissionsRole: m_groups = permissionRoleGroups(); break;
case RatingRole: m_groups = ratingRoleGroups(); break;
default: m_groups = genericStringRoleGroups(sortRole()); break;
case PermissionsRole:
m_groups = permissionRoleGroups();
break;
case RatingRole:
m_groups = ratingRoleGroups();
break;
default:
m_groups = genericStringRoleGroups(sortRole());
break;
}
#ifdef KFILEITEMMODEL_DEBUG
@ -662,7 +672,6 @@ void KFileItemModel::restoreExpandedDirectories(const QSet<QUrl> &urls)
void KFileItemModel::expandParentDirectories(const QUrl &url)
{
// Assure that each sub-path of the URL that should be
// expanded is added to m_urlsToExpand. KDirLister
// 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) {
ItemData *itemData = m_itemData.at(index);
if (m_filter.matches(itemData->item)
|| (itemShownBelow && itemShownBelow->parent == itemData)) {
if (m_filter.matches(itemData->item) || (itemShownBelow && itemShownBelow->parent == itemData)) {
// We could've entered here for two reasons:
// 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
@ -952,8 +960,7 @@ void KFileItemModel::resortAllItems()
// Determine the first index that has been moved.
int firstMovedIndex = 0;
while (firstMovedIndex < itemCount
&& firstMovedIndex == m_items.value(oldUrls.at(firstMovedIndex))) {
while (firstMovedIndex < itemCount && firstMovedIndex == m_items.value(oldUrls.at(firstMovedIndex))) {
++firstMovedIndex;
}
@ -962,8 +969,7 @@ void KFileItemModel::resortAllItems()
m_groups.clear();
int lastMovedIndex = itemCount - 1;
while (lastMovedIndex > firstMovedIndex
&& lastMovedIndex == m_items.value(oldUrls.at(lastMovedIndex))) {
while (lastMovedIndex > firstMovedIndex && lastMovedIndex == m_items.value(oldUrls.at(lastMovedIndex))) {
--lastMovedIndex;
}
@ -1436,8 +1442,7 @@ void KFileItemModel::insertItems(QList<ItemData*>& newItems)
if (m_sortRole == NameRole) {
parallelMergeSort(newItems.begin(), newItems.end(), nameLessThan, QThread::idealThreadCount());
} 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);
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,
// (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.
if (first > 0
&& lessThan(m_itemData.at(first), m_itemData.at(first - 1), m_collator)) {
if (first > 0 && lessThan(m_itemData.at(first), m_itemData.at(first - 1), m_collator)) {
needsResorting = true;
} else if (last < count() - 1
&& lessThan(m_itemData.at(last + 1), m_itemData.at(last), m_collator)) {
} else if (last < count() - 1 && lessThan(m_itemData.at(last + 1), m_itemData.at(last), m_collator)) {
needsResorting = true;
} else {
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;
}
void KFileItemModel::sort(const QList<KFileItemModel::ItemData*>::iterator &begin,
const QList<KFileItemModel::ItemData*>::iterator &end) const
{
auto lambdaLessThan = [&] (const KFileItemModel::ItemData* a, const KFileItemModel::ItemData* b)
void KFileItemModel::sort(const QList<KFileItemModel::ItemData *>::iterator &begin, const QList<KFileItemModel::ItemData *>::iterator &end) const
{
auto lambdaLessThan = [&](const KFileItemModel::ItemData *a, const KFileItemModel::ItemData *b) {
return lessThan(a, b, m_collator);
};
@ -2156,7 +2157,6 @@ int KFileItemModel::sortRoleCompare(const ItemData* a, const ItemData* b, const
}
break;
}
}
if (result != 0) {
@ -2226,7 +2226,6 @@ QList<QPair<int, QVariant> > KFileItemModel::nameRoleGroups() const
if (firstChar != newFirstChar) {
QString newGroupValue;
if (newFirstChar.isLetter()) {
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.
@ -2345,19 +2344,23 @@ QList<QPair<int, QVariant> > KFileItemModel::timeRoleGroups(const std::function<
const int daysDistance = fileDate.daysTo(currentDate);
QString newGroupValue;
if (currentDate.year() == fileDate.year() &&
currentDate.month() == fileDate.month()) {
if (currentDate.year() == fileDate.year() && currentDate.month() == fileDate.month()) {
switch (daysDistance / 7) {
case 0:
switch (daysDistance) {
case 0: newGroupValue = i18nc("@title:group Date", "Today"); break;
case 1: newGroupValue = i18nc("@title:group Date", "Yesterday"); break;
case 0:
newGroupValue = i18nc("@title:group Date", "Today");
break;
case 1:
newGroupValue = i18nc("@title:group Date", "Yesterday");
break;
default:
newGroupValue = fileTime.toString(
i18nc("@title:group Date: The week day name: dddd", "dddd"));
newGroupValue = i18nc("Can be used to script translation of \"dddd\""
"with context @title:group Date", "%1", newGroupValue);
newGroupValue = fileTime.toString(i18nc("@title:group Date: The week day name: dddd", "dddd"));
newGroupValue = i18nc(
"Can be used to script translation of \"dddd\""
"with context @title:group Date",
"%1",
newGroupValue);
}
break;
case 1:
@ -2378,100 +2381,135 @@ QList<QPair<int, QVariant> > KFileItemModel::timeRoleGroups(const std::function<
}
} else {
const QDate lastMonthDate = currentDate.addMonths(-1);
if (lastMonthDate.year() == fileDate.year() &&
lastMonthDate.month() == fileDate.month()) {
if (lastMonthDate.year() == fileDate.year() && lastMonthDate.month() == fileDate.month()) {
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 "
"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();
if (translatedFormat.count(QLatin1Char('\'')) == 2) {
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",
"%1", newGroupValue);
"%1",
newGroupValue);
} 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")});
newGroupValue = fileTime.toString(untranslatedFormat);
}
} 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 "
"in current locale, and yyyy is full year number.",
"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",
"%1", newGroupValue);
"%1",
newGroupValue);
} 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 "
"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();
if (translatedFormat.count(QLatin1Char('\'')) == 2) {
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",
"%1", newGroupValue);
"%1",
newGroupValue);
} 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")});
newGroupValue = fileTime.toString(untranslatedFormat);
}
} 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 "
"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();
if (translatedFormat.count(QLatin1Char('\'')) == 2) {
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",
"%1", newGroupValue);
"%1",
newGroupValue);
} 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")});
newGroupValue = fileTime.toString(untranslatedFormat);
}
} 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 "
"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();
if (translatedFormat.count(QLatin1Char('\'')) == 2) {
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",
"%1", newGroupValue);
"%1",
newGroupValue);
} 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")});
newGroupValue = fileTime.toString(untranslatedFormat);
}
} 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 "
"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();
if (translatedFormat.count(QLatin1Char('\'')) == 2) {
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",
"%1", newGroupValue);
"%1",
newGroupValue);
} 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")});
newGroupValue = fileTime.toString(untranslatedFormat);
}
}
} 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, "
"and yyyy is full year number", "MMMM, yyyy"));
newGroupValue = i18nc("Can be used to script translation of "
"and yyyy is full year number",
"MMMM, yyyy"));
newGroupValue = i18nc(
"Can be used to script translation of "
"\"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.
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:"
<< fileItem(i - 1) << fileItem(i);
qCWarning(DolphinDebug) << "The order of items" << i - 1 << "and" << i << "is wrong:" << fileItem(i - 1) << fileItem(i);
return false;
}
@ -2753,7 +2790,8 @@ bool KFileItemModel::isConsistent() const
const int parentIndex = index(parent->item);
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;
}
}

View File

@ -25,7 +25,8 @@ class KDirLister;
class QTimer;
namespace KIO {
namespace KIO
{
class Job;
}
@ -181,8 +182,8 @@ public:
void setMimeTypeFilters(const QStringList &filters);
QStringList mimeTypeFilters() const;
struct RoleInfo
{ QByteArray role;
struct RoleInfo {
QByteArray role;
QString translation;
QString group;
bool requiresBaloo;
@ -294,30 +295,63 @@ private Q_SLOTS:
private:
enum RoleType {
// User visible roles:
NoRole, NameRole, SizeRole, ModificationTimeRole, CreationTimeRole, AccessTimeRole, PermissionsRole, OwnerRole,
GroupRole, TypeRole, ExtensionRole, DestinationRole, PathRole, DeletionTimeRole,
NoRole,
NameRole,
SizeRole,
ModificationTimeRole,
CreationTimeRole,
AccessTimeRole,
PermissionsRole,
OwnerRole,
GroupRole,
TypeRole,
ExtensionRole,
DestinationRole,
PathRole,
DeletionTimeRole,
// User visible roles available with Baloo:
CommentRole, TagsRole, RatingRole, DimensionsRole, WidthRole, HeightRole, ImageDateTimeRole, OrientationRole,
PublisherRole, PageCountRole, WordCountRole, TitleRole, AuthorRole, LineCountRole, ArtistRole, GenreRole, AlbumRole, DurationRole, TrackRole, ReleaseYearRole,
BitrateRole, OriginUrlRole, AspectRatioRole, FrameRateRole,
CommentRole,
TagsRole,
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:
IsDirRole, IsLinkRole, IsHiddenRole, IsExpandedRole, IsExpandableRole, ExpandedParentsCountRole,
IsDirRole,
IsLinkRole,
IsHiddenRole,
IsExpandedRole,
IsExpandableRole,
ExpandedParentsCountRole,
// Mandatory last entry:
RolesCount
};
struct ItemData
{
struct ItemData {
KFileItem item;
QHash<QByteArray, QVariant> values;
ItemData *parent;
};
enum RemoveItemsBehavior {
KeepItemData,
DeleteItemData,
DeleteItemDataIfUnfiltered
};
enum RemoveItemsBehavior { KeepItemData, DeleteItemData, DeleteItemDataIfUnfiltered };
void insertItems(QList<ItemData *> &items);
void removeItems(const KItemRangeList &itemRanges, RemoveItemsBehavior behavior);
@ -442,8 +476,7 @@ private:
* Maps the QByteArray-roles to RoleTypes and provides translation- and
* group-contexts.
*/
struct RoleInfoMap
{
struct RoleInfoMap {
const char *const role;
const RoleType roleType;
const KLazyLocalizedString roleTranslation;
@ -531,19 +564,9 @@ private:
inline bool KFileItemModel::isRoleValueNatural(RoleType roleType)
{
return (roleType == TypeRole ||
roleType == ExtensionRole ||
roleType == TagsRole ||
roleType == CommentRole ||
roleType == TitleRole ||
roleType == ArtistRole ||
roleType == GenreRole ||
roleType == AlbumRole ||
roleType == PathRole ||
roleType == DestinationRole ||
roleType == OriginUrlRole ||
roleType == OwnerRole ||
roleType == GroupRole);
return (roleType == TypeRole || roleType == ExtensionRole || roleType == TagsRole || 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)
@ -561,5 +584,3 @@ inline bool KFileItemModel::isChildItem(int index) const
}
#endif

View File

@ -38,7 +38,8 @@ using namespace std::chrono_literals;
// #define KFILEITEMMODELROLESUPDATER_DEBUG
namespace {
namespace
{
// Maximum time in ms that the KFileItemModelRolesUpdater
// may perform a blocking operation
const int MaxBlockTimeout = 200;
@ -52,38 +53,38 @@ namespace {
const int ReadAheadPages = 5;
}
KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel* model, QObject* parent) :
QObject(parent),
m_state(Idle),
m_previewChangedDuringPausing(false),
m_iconSizeChangedDuringPausing(false),
m_rolesChangedDuringPausing(false),
m_previewShown(false),
m_enlargeSmallPreviews(true),
m_clearPreviews(false),
m_finishedItems(),
m_model(model),
m_iconSize(),
m_firstVisibleIndex(0),
m_lastVisibleIndex(-1),
m_maximumVisibleItems(50),
m_roles(),
m_resolvableRoles(),
m_enabledPlugins(),
m_localFileSizePreviewLimit(0),
m_scanDirectories(true),
m_pendingSortRoleItems(),
m_pendingIndexes(),
m_pendingPreviewItems(),
m_previewJob(),
m_hoverSequenceItem(),
m_hoverSequenceIndex(0),
m_hoverSequencePreviewJob(nullptr),
m_hoverSequenceNumSuccessiveFailures(0),
m_recentlyChangedItemsTimer(nullptr),
m_recentlyChangedItems(),
m_changedItems(),
m_directoryContentsCounter(nullptr)
KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel *model, QObject *parent)
: QObject(parent)
, m_state(Idle)
, m_previewChangedDuringPausing(false)
, m_iconSizeChangedDuringPausing(false)
, m_rolesChangedDuringPausing(false)
, m_previewShown(false)
, m_enlargeSmallPreviews(true)
, m_clearPreviews(false)
, m_finishedItems()
, m_model(model)
, m_iconSize()
, m_firstVisibleIndex(0)
, m_lastVisibleIndex(-1)
, m_maximumVisibleItems(50)
, m_roles()
, m_resolvableRoles()
, m_enabledPlugins()
, m_localFileSizePreviewLimit(0)
, m_scanDirectories(true)
, m_pendingSortRoleItems()
, m_pendingIndexes()
, m_pendingPreviewItems()
, m_previewJob()
, m_hoverSequenceItem()
, m_hoverSequenceIndex(0)
, m_hoverSequencePreviewJob(nullptr)
, m_hoverSequenceNumSuccessiveFailures(0)
, m_recentlyChangedItemsTimer(nullptr)
, m_recentlyChangedItems()
, m_changedItems()
, m_directoryContentsCounter(nullptr)
#if HAVE_BALOO
, m_balooFileMonitor(nullptr)
#endif
@ -94,16 +95,11 @@ KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel* model, QO
m_enabledPlugins = globalConfig.readEntry("Plugins", KIO::PreviewJob::defaultPlugins());
m_localFileSizePreviewLimit = static_cast<qulonglong>(globalConfig.readEntry("MaximumSize", 0));
connect(m_model, &KFileItemModel::itemsInserted,
this, &KFileItemModelRolesUpdater::slotItemsInserted);
connect(m_model, &KFileItemModel::itemsRemoved,
this, &KFileItemModelRolesUpdater::slotItemsRemoved);
connect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
connect(m_model, &KFileItemModel::itemsMoved,
this, &KFileItemModelRolesUpdater::slotItemsMoved);
connect(m_model, &KFileItemModel::sortRoleChanged,
this, &KFileItemModelRolesUpdater::slotSortRoleChanged);
connect(m_model, &KFileItemModel::itemsInserted, this, &KFileItemModelRolesUpdater::slotItemsInserted);
connect(m_model, &KFileItemModel::itemsRemoved, this, &KFileItemModelRolesUpdater::slotItemsRemoved);
connect(m_model, &KFileItemModel::itemsChanged, 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
// 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
m_directoryContentsCounter = new KDirectoryContentsCounter(m_model, this);
connect(m_directoryContentsCounter, &KDirectoryContentsCounter::result,
this, &KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived);
connect(m_directoryContentsCounter, &KDirectoryContentsCounter::result, this, &KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived);
const auto plugins = KPluginMetaData::findPlugins(QStringLiteral("kf" QT_STRINGIFY(QT_VERSION_MAJOR)) + QStringLiteral("/overlayicon"));
for (const KPluginMetaData &data : plugins) {
@ -241,8 +236,7 @@ void KFileItemModelRolesUpdater::setPaused(bool paused)
m_state = Paused;
killPreviewJob();
} else {
const bool updatePreviews = (m_iconSizeChangedDuringPausing && m_previewShown) ||
m_previewChangedDuringPausing;
const bool updatePreviews = (m_iconSizeChangedDuringPausing && m_previewShown) || m_previewChangedDuringPausing;
const bool resolveAll = updatePreviews || m_rolesChangedDuringPausing;
if (resolveAll) {
m_finishedItems.clear();
@ -286,8 +280,7 @@ void KFileItemModelRolesUpdater::setRoles(const QSet<QByteArray>& roles)
if (hasBalooRole && m_balooConfig.fileIndexingEnabled() && !m_balooFileMonitor) {
m_balooFileMonitor = new Baloo::FileMonitor(this);
connect(m_balooFileMonitor, &Baloo::FileMonitor::fileMetaDataChanged,
this, &KFileItemModelRolesUpdater::applyChangedBalooRoles);
connect(m_balooFileMonitor, &Baloo::FileMonitor::fileMetaDataChanged, this, &KFileItemModelRolesUpdater::applyChangedBalooRoles);
} else if (!hasBalooRole && m_balooFileMonitor) {
delete m_balooFileMonitor;
m_balooFileMonitor = nullptr;
@ -465,8 +458,7 @@ void KFileItemModelRolesUpdater::slotItemsMoved(KItemRange itemRange, const QLis
startUpdating();
}
void KFileItemModelRolesUpdater::slotItemsChanged(const KItemRangeList& itemRanges,
const QSet<QByteArray>& roles)
void KFileItemModelRolesUpdater::slotItemsChanged(const KItemRangeList &itemRanges, const QSet<QByteArray> &roles)
{
Q_UNUSED(roles)
@ -493,8 +485,7 @@ void KFileItemModelRolesUpdater::slotItemsChanged(const KItemRangeList& itemRang
}
}
void KFileItemModelRolesUpdater::slotSortRoleChanged(const QByteArray& current,
const QByteArray& previous)
void KFileItemModelRolesUpdater::slotSortRoleChanged(const QByteArray &current, const QByteArray &previous)
{
Q_UNUSED(current)
Q_UNUSED(previous)
@ -567,11 +558,9 @@ void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem& item, const QPi
data.insert("iconPixmap", scaledPixmap);
disconnect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
disconnect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
m_model->setData(index, data);
connect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
connect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
m_finishedItems.insert(item);
}
@ -589,11 +578,9 @@ void KFileItemModelRolesUpdater::slotPreviewFailed(const KFileItem& item)
QHash<QByteArray, QVariant> data;
data.insert("iconPixmap", QPixmap());
disconnect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
disconnect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
m_model->setData(index, data);
connect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
connect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
applyResolvedRoles(index, ResolveAll);
m_finishedItems.insert(item);
@ -653,8 +640,7 @@ void KFileItemModelRolesUpdater::slotHoverSequenceGotPreview(const KFileItem& it
m_model->setData(index, data);
const auto loadedIt = std::find(m_hoverSequenceLoadedItems.begin(),
m_hoverSequenceLoadedItems.end(), item);
const auto loadedIt = std::find(m_hoverSequenceLoadedItems.begin(), m_hoverSequenceLoadedItems.end(), item);
if (loadedIt == m_hoverSequenceLoadedItems.end()) {
m_hoverSequenceLoadedItems.push_back(item);
trimHoverSequenceLoadedItems();
@ -676,11 +662,8 @@ void KFileItemModelRolesUpdater::slotHoverSequencePreviewFailed(const KFileItem&
QHash<QByteArray, QVariant> data = m_model->data(index);
QVector<QPixmap> pixmaps = data["hoverSequencePixmaps"].value<QVector<QPixmap>>();
qCDebug(DolphinDebug).nospace()
<< "Failed to generate hover sequence preview #" << pixmaps.size()
<< " for file " << item.url().toString()
<< " (attempt " << (m_hoverSequenceNumSuccessiveFailures+1)
<< "/" << (numRetries+1) << ")";
qCDebug(DolphinDebug).nospace() << "Failed to generate hover sequence preview #" << pixmaps.size() << " for file " << item.url().toString() << " (attempt "
<< (m_hoverSequenceNumSuccessiveFailures + 1) << "/" << (numRetries + 1) << ")";
if (m_hoverSequenceNumSuccessiveFailures >= numRetries) {
// Give up and simply duplicate the previous sequence image (if any)
@ -755,11 +738,9 @@ void KFileItemModelRolesUpdater::resolveNextSortRole()
m_state = Idle;
// Prevent that we try to update the items twice.
disconnect(m_model, &KFileItemModel::itemsMoved,
this, &KFileItemModelRolesUpdater::slotItemsMoved);
disconnect(m_model, &KFileItemModel::itemsMoved, this, &KFileItemModelRolesUpdater::slotItemsMoved);
applySortProgressToModel();
connect(m_model, &KFileItemModel::itemsMoved,
this, &KFileItemModelRolesUpdater::slotItemsMoved);
connect(m_model, &KFileItemModel::itemsMoved, this, &KFileItemModelRolesUpdater::slotItemsMoved);
startUpdating();
}
}
@ -796,18 +777,13 @@ void KFileItemModelRolesUpdater::resolveNextPendingRoles()
data.insert("iconPixmap", QPixmap());
data.insert("hoverSequencePixmaps", QVariant::fromValue(QVector<QPixmap>()));
disconnect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
disconnect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
for (int index = 0; index <= m_model->count(); ++index) {
if (m_model->data(index).contains("iconPixmap") ||
m_model->data(index).contains("hoverSequencePixmaps"))
{
if (m_model->data(index).contains("iconPixmap") || m_model->data(index).contains("hoverSequencePixmaps")) {
m_model->setData(index, data);
}
}
connect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
connect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
}
m_clearPreviews = false;
}
@ -864,12 +840,10 @@ void KFileItemModelRolesUpdater::applyChangedBalooRolesForItem(const KFileItem &
data.insert(it.key(), it.value());
}
disconnect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
disconnect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
const int index = m_model->index(item);
m_model->setData(index, data);
connect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
connect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
#else
#ifndef Q_CC_MSVC
Q_UNUSED(item)
@ -895,11 +869,9 @@ void KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived(const QStrin
data.insert("isExpandable", count > 0);
}
disconnect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
disconnect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
m_model->setData(index, data);
connect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
connect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
}
}
}
@ -995,8 +967,7 @@ void KFileItemModelRolesUpdater::startPreviewJob()
// 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
// cache sizes are requested.
const QSize cacheSize = (m_iconSize.width() > 128) || (m_iconSize.height() > 128)
? QSize(256, 256) : QSize(128, 128);
const QSize cacheSize = (m_iconSize.width() > 128) || (m_iconSize.height() > 128) ? QSize(256, 256) : QSize(128, 128);
// 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
@ -1033,12 +1004,9 @@ void KFileItemModelRolesUpdater::startPreviewJob()
KJobWidgets::setWindow(job, qApp->activeWindow());
}
connect(job, &KIO::PreviewJob::gotPreview,
this, &KFileItemModelRolesUpdater::slotGotPreview);
connect(job, &KIO::PreviewJob::failed,
this, &KFileItemModelRolesUpdater::slotPreviewFailed);
connect(job, &KIO::PreviewJob::finished,
this, &KFileItemModelRolesUpdater::slotPreviewJobFinished);
connect(job, &KIO::PreviewJob::gotPreview, this, &KFileItemModelRolesUpdater::slotGotPreview);
connect(job, &KIO::PreviewJob::failed, this, &KFileItemModelRolesUpdater::slotPreviewFailed);
connect(job, &KIO::PreviewJob::finished, this, &KFileItemModelRolesUpdater::slotPreviewJobFinished);
m_previewJob = job;
}
@ -1047,17 +1015,14 @@ QPixmap KFileItemModelRolesUpdater::transformPreviewPixmap(const QPixmap& pixmap
{
QPixmap scaledPixmap = pixmap;
if (!pixmap.hasAlpha() && !pixmap.isNull()
&& m_iconSize.width() > KIconLoader::SizeSmallMedium
&& m_iconSize.height() > KIconLoader::SizeSmallMedium) {
if (!pixmap.hasAlpha() && !pixmap.isNull() && m_iconSize.width() > KIconLoader::SizeSmallMedium && m_iconSize.height() > KIconLoader::SizeSmallMedium) {
if (m_enlargeSmallPreviews) {
KPixmapModifier::applyFrame(scaledPixmap, m_iconSize);
} else {
// Assure that small previews don't get enlarged. Instead they
// should be shown centered within the frame.
const QSize contentSize = KPixmapModifier::sizeInsideFrame(m_iconSize);
const bool enlargingRequired = scaledPixmap.width() < contentSize.width() &&
scaledPixmap.height() < contentSize.height();
const bool enlargingRequired = scaledPixmap.width() < contentSize.width() && scaledPixmap.height() < contentSize.height();
if (enlargingRequired) {
QSize frameSize = scaledPixmap.size() / scaledPixmap.devicePixelRatio();
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
// do a downscaling anyhow because of the frame, so in this case only the provided
// cache sizes are requested.
const QSize cacheSize = (m_iconSize.width() > 128) || (m_iconSize.height() > 128)
? QSize(256, 256) : QSize(128, 128);
const QSize cacheSize = (m_iconSize.width() > 128) || (m_iconSize.height() > 128) ? QSize(256, 256) : QSize(128, 128);
KIO::PreviewJob *job = new KIO::PreviewJob({m_hoverSequenceItem}, cacheSize, &m_enabledPlugins);
@ -1142,12 +1106,9 @@ void KFileItemModelRolesUpdater::loadNextHoverSequencePreview()
KJobWidgets::setWindow(job, qApp->activeWindow());
}
connect(job, &KIO::PreviewJob::gotPreview,
this, &KFileItemModelRolesUpdater::slotHoverSequenceGotPreview);
connect(job, &KIO::PreviewJob::failed,
this, &KFileItemModelRolesUpdater::slotHoverSequencePreviewFailed);
connect(job, &KIO::PreviewJob::finished,
this, &KFileItemModelRolesUpdater::slotHoverSequencePreviewJobFinished);
connect(job, &KIO::PreviewJob::gotPreview, this, &KFileItemModelRolesUpdater::slotHoverSequenceGotPreview);
connect(job, &KIO::PreviewJob::failed, this, &KFileItemModelRolesUpdater::slotHoverSequencePreviewFailed);
connect(job, &KIO::PreviewJob::finished, this, &KFileItemModelRolesUpdater::slotHoverSequencePreviewJobFinished);
m_hoverSequencePreviewJob = job;
}
@ -1155,12 +1116,9 @@ void KFileItemModelRolesUpdater::loadNextHoverSequencePreview()
void KFileItemModelRolesUpdater::killHoverSequencePreviewJob()
{
if (m_hoverSequencePreviewJob) {
disconnect(m_hoverSequencePreviewJob, &KIO::PreviewJob::gotPreview,
this, &KFileItemModelRolesUpdater::slotHoverSequenceGotPreview);
disconnect(m_hoverSequencePreviewJob, &KIO::PreviewJob::failed,
this, &KFileItemModelRolesUpdater::slotHoverSequencePreviewFailed);
disconnect(m_hoverSequencePreviewJob, &KIO::PreviewJob::finished,
this, &KFileItemModelRolesUpdater::slotHoverSequencePreviewJobFinished);
disconnect(m_hoverSequencePreviewJob, &KIO::PreviewJob::gotPreview, this, &KFileItemModelRolesUpdater::slotHoverSequenceGotPreview);
disconnect(m_hoverSequencePreviewJob, &KIO::PreviewJob::failed, this, &KFileItemModelRolesUpdater::slotHoverSequencePreviewFailed);
disconnect(m_hoverSequencePreviewJob, &KIO::PreviewJob::finished, this, &KFileItemModelRolesUpdater::slotHoverSequencePreviewJobFinished);
m_hoverSequencePreviewJob->kill();
m_hoverSequencePreviewJob = nullptr;
}
@ -1261,11 +1219,9 @@ void KFileItemModelRolesUpdater::applySortRole(int index)
data = rolesData(item);
}
disconnect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
disconnect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
m_model->setData(index, data);
connect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
connect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
}
void KFileItemModelRolesUpdater::applySortProgressToModel()
@ -1308,11 +1264,9 @@ bool KFileItemModelRolesUpdater::applyResolvedRoles(int index, ResolveHint hint)
data.insert("hoverSequencePixmaps", QVariant::fromValue(QVector<QPixmap>()));
}
disconnect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
disconnect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
m_model->setData(index, data);
connect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
connect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
return true;
}
@ -1393,12 +1347,9 @@ void KFileItemModelRolesUpdater::updateAllPreviews()
void KFileItemModelRolesUpdater::killPreviewJob()
{
if (m_previewJob) {
disconnect(m_previewJob, &KIO::PreviewJob::gotPreview,
this, &KFileItemModelRolesUpdater::slotGotPreview);
disconnect(m_previewJob, &KIO::PreviewJob::failed,
this, &KFileItemModelRolesUpdater::slotPreviewFailed);
disconnect(m_previewJob, &KIO::PreviewJob::finished,
this, &KFileItemModelRolesUpdater::slotPreviewJobFinished);
disconnect(m_previewJob, &KIO::PreviewJob::gotPreview, this, &KFileItemModelRolesUpdater::slotGotPreview);
disconnect(m_previewJob, &KIO::PreviewJob::failed, this, &KFileItemModelRolesUpdater::slotPreviewFailed);
disconnect(m_previewJob, &KIO::PreviewJob::finished, this, &KFileItemModelRolesUpdater::slotPreviewJobFinished);
m_previewJob->kill();
m_previewJob = nullptr;
m_pendingPreviewItems.clear();
@ -1410,9 +1361,7 @@ QList<int> KFileItemModelRolesUpdater::indexesToResolve() const
const int count = m_model->count();
QList<int> result;
result.reserve(qMin(count, (m_lastVisibleIndex - m_firstVisibleIndex + 1) +
ResolveAllItemsLimit +
(2 * m_maximumVisibleItems)));
result.reserve(qMin(count, (m_lastVisibleIndex - m_firstVisibleIndex + 1) + ResolveAllItemsLimit + (2 * m_maximumVisibleItems)));
// Add visible items.
// Resolve files first, their previews are quicker.
@ -1492,4 +1441,3 @@ void KFileItemModelRolesUpdater::trimHoverSequenceLoadedItems()
}
}
}

View File

@ -12,8 +12,8 @@
#include <list>
#include <KFileItem>
#include "config-dolphin.h"
#include <KFileItem>
#include <QObject>
#include <QSet>
@ -26,7 +26,8 @@ class QPixmap;
class QTimer;
class KOverlayIconPlugin;
namespace KIO {
namespace KIO
{
class PreviewJob;
}
@ -178,10 +179,8 @@ private Q_SLOTS:
void slotItemsInserted(const KItemRangeList &itemRanges);
void slotItemsRemoved(const KItemRangeList &itemRanges);
void slotItemsMoved(KItemRange itemRange, const QList<int> &movedToIndexes);
void slotItemsChanged(const KItemRangeList& itemRanges,
const QSet<QByteArray>& roles);
void slotSortRoleChanged(const QByteArray& current,
const QByteArray& previous);
void slotItemsChanged(const KItemRangeList &itemRanges, const QSet<QByteArray> &roles);
void slotSortRoleChanged(const QByteArray &current, const QByteArray &previous);
/**
* Is invoked after a preview has been received successfully.
@ -318,10 +317,7 @@ private:
void applySortProgressToModel();
enum ResolveHint {
ResolveFast,
ResolveAll
};
enum ResolveHint { ResolveFast, ResolveAll };
bool applyResolvedRoles(int index, ResolveHint hint);
QHash<QByteArray, QVariant> rolesData(const KFileItem &item);
@ -338,13 +334,7 @@ private:
void trimHoverSequenceLoadedItems();
private:
enum State {
Idle,
Paused,
ResolvingSortRole,
ResolvingAllRoles,
PreviewJobRunning
};
enum State { Idle, Paused, ResolvingSortRole, ResolvingAllRoles, PreviewJobRunning };
State m_state;

View File

@ -31,12 +31,13 @@ class KItemListContainerViewport : public QGraphicsView
public:
KItemListContainerViewport(QGraphicsScene *scene, QWidget *parent);
protected:
void wheelEvent(QWheelEvent *event) override;
};
KItemListContainerViewport::KItemListContainerViewport(QGraphicsScene* scene, QWidget* parent) :
QGraphicsView(scene, parent)
KItemListContainerViewport::KItemListContainerViewport(QGraphicsScene *scene, QWidget *parent)
: QGraphicsView(scene, parent)
{
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@ -51,12 +52,12 @@ void KItemListContainerViewport::wheelEvent(QWheelEvent* event)
event->ignore();
}
KItemListContainer::KItemListContainer(KItemListController* controller, QWidget* parent) :
QAbstractScrollArea(parent),
m_controller(controller),
m_horizontalSmoothScroller(nullptr),
m_verticalSmoothScroller(nullptr),
m_scroller(nullptr)
KItemListContainer::KItemListContainer(KItemListController *controller, QWidget *parent)
: QAbstractScrollArea(parent)
, m_controller(controller)
, m_horizontalSmoothScroller(nullptr)
, m_verticalSmoothScroller(nullptr)
, m_scroller(nullptr)
{
Q_ASSERT(controller);
controller->setParent(this);
@ -74,17 +75,13 @@ KItemListContainer::KItemListContainer(KItemListController* controller, QWidget*
slotViewChanged(controller->view(), nullptr);
}
connect(controller, &KItemListController::modelChanged,
this, &KItemListContainer::slotModelChanged);
connect(controller, &KItemListController::viewChanged,
this, &KItemListContainer::slotViewChanged);
connect(controller, &KItemListController::modelChanged, this, &KItemListContainer::slotModelChanged);
connect(controller, &KItemListController::viewChanged, this, &KItemListContainer::slotViewChanged);
m_scroller = QScroller::scroller(viewport());
m_scroller->grabGesture(viewport());
connect(controller, &KItemListController::scrollerStop,
this, &KItemListContainer::stopScroller);
connect(m_scroller, &QScroller::stateChanged,
controller, &KItemListController::slotStateChanged);
connect(controller, &KItemListController::scrollerStop, this, &KItemListContainer::stopScroller);
connect(m_scroller, &QScroller::stateChanged, controller, &KItemListController::slotStateChanged);
}
KItemListContainer::~KItemListContainer()
@ -172,10 +169,8 @@ void KItemListContainer::wheelEvent(QWheelEvent* event)
return;
}
const bool scrollHorizontally = (qAbs(event->angleDelta().y()) < qAbs(event->angleDelta().x())) ||
(!verticalScrollBar()->isVisible());
KItemListSmoothScroller* smoothScroller = scrollHorizontally ?
m_horizontalSmoothScroller : m_verticalSmoothScroller;
const bool scrollHorizontally = (qAbs(event->angleDelta().y()) < qAbs(event->angleDelta().x())) || (!verticalScrollBar()->isVisible());
KItemListSmoothScroller *smoothScroller = scrollHorizontally ? m_horizontalSmoothScroller : m_verticalSmoothScroller;
smoothScroller->handleWheelEvent(event);
}
@ -197,16 +192,11 @@ void KItemListContainer::slotViewChanged(KItemListView* current, KItemListView*
QGraphicsScene *scene = static_cast<QGraphicsView *>(viewport())->scene();
if (previous) {
scene->removeItem(previous);
disconnect(previous, &KItemListView::scrollOrientationChanged,
this, &KItemListContainer::slotScrollOrientationChanged);
disconnect(previous, &KItemListView::scrollOffsetChanged,
this, &KItemListContainer::updateScrollOffsetScrollBar);
disconnect(previous, &KItemListView::maximumScrollOffsetChanged,
this, &KItemListContainer::updateScrollOffsetScrollBar);
disconnect(previous, &KItemListView::itemOffsetChanged,
this, &KItemListContainer::updateItemOffsetScrollBar);
disconnect(previous, &KItemListView::maximumItemOffsetChanged,
this, &KItemListContainer::updateItemOffsetScrollBar);
disconnect(previous, &KItemListView::scrollOrientationChanged, this, &KItemListContainer::slotScrollOrientationChanged);
disconnect(previous, &KItemListView::scrollOffsetChanged, this, &KItemListContainer::updateScrollOffsetScrollBar);
disconnect(previous, &KItemListView::maximumScrollOffsetChanged, 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(m_horizontalSmoothScroller, &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) {
scene->addItem(current);
connect(current, &KItemListView::scrollOrientationChanged,
this, &KItemListContainer::slotScrollOrientationChanged);
connect(current, &KItemListView::scrollOffsetChanged,
this, &KItemListContainer::updateScrollOffsetScrollBar);
connect(current, &KItemListView::maximumScrollOffsetChanged,
this, &KItemListContainer::updateScrollOffsetScrollBar);
connect(current, &KItemListView::itemOffsetChanged,
this, &KItemListContainer::updateItemOffsetScrollBar);
connect(current, &KItemListView::maximumItemOffsetChanged,
this, &KItemListContainer::updateItemOffsetScrollBar);
connect(current, &KItemListView::scrollOrientationChanged, this, &KItemListContainer::slotScrollOrientationChanged);
connect(current, &KItemListView::scrollOffsetChanged, this, &KItemListContainer::updateScrollOffsetScrollBar);
connect(current, &KItemListView::maximumScrollOffsetChanged, 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(m_horizontalSmoothScroller, &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();
if (smoothScroller->requestScrollBarUpdate(maximum)) {
const bool updatePolicy = (scrollOffsetScrollBar->maximum() > 0 && maximum == 0)
|| horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOn;
const bool updatePolicy = (scrollOffsetScrollBar->maximum() > 0 && maximum == 0) || horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOn;
scrollOffsetScrollBar->setSingleStep(singleStep);
scrollOffsetScrollBar->setPageStep(pageStep);
@ -356,16 +340,12 @@ void KItemListContainer::updateGeometries()
scrollbarSpacing = style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarSpacing, &option, this);
}
const int widthDec = verticalScrollBar()->isVisible()
? extra + scrollbarSpacing + style()->pixelMetric(QStyle::PM_ScrollBarExtent, &option, this)
: extra;
const int widthDec = verticalScrollBar()->isVisible() ? extra + scrollbarSpacing + style()->pixelMetric(QStyle::PM_ScrollBarExtent, &option, this) : extra;
const int heightDec = horizontalScrollBar()->isVisible()
? extra + scrollbarSpacing + style()->pixelMetric(QStyle::PM_ScrollBarExtent, &option, this)
: extra;
const int heightDec =
horizontalScrollBar()->isVisible() ? extra + scrollbarSpacing + style()->pixelMetric(QStyle::PM_ScrollBarExtent, &option, this) : extra;
const QRectF newGeometry(0, 0, rect.width() - widthDec,
rect.height() - heightDec);
const QRectF newGeometry(0, 0, rect.width() - widthDec, rect.height() - heightDec);
if (m_controller->view()->geometry() != newGeometry) {
m_controller->view()->setGeometry(newGeometry);
@ -407,8 +387,7 @@ void KItemListContainer::updateScrollOffsetScrollBarPolicy()
newViewSize.rheight() += scrollBarInc;
}
const Qt::ScrollBarPolicy policy = view->scrollBarRequired(newViewSize)
? Qt::ScrollBarAlwaysOn : Qt::ScrollBarAsNeeded;
const Qt::ScrollBarPolicy policy = view->scrollBarRequired(newViewSize) ? Qt::ScrollBarAlwaysOn : Qt::ScrollBarAsNeeded;
if (vertical) {
setVerticalScrollBarPolicy(policy);
} else {

View File

@ -80,5 +80,3 @@ private:
};
#endif

View File

@ -30,40 +30,37 @@
#include <QTimer>
#include <QTouchEvent>
KItemListController::KItemListController(KItemModelBase* model, KItemListView* view, QObject* parent) :
QObject(parent),
m_singleClickActivationEnforced(false),
m_selectionMode(false),
m_selectionTogglePressed(false),
m_clearSelectionIfItemsAreNotDragged(false),
m_isSwipeGesture(false),
m_dragActionOrRightClick(false),
m_scrollerIsScrolling(false),
m_pinchGestureInProgress(false),
m_mousePress(false),
m_isTouchEvent(false),
m_selectionBehavior(NoSelection),
m_autoActivationBehavior(ActivationAndExpansion),
m_mouseDoubleClickAction(ActivateItemOnly),
m_model(nullptr),
m_view(nullptr),
m_selectionManager(new KItemListSelectionManager(this)),
m_keyboardManager(new KItemListKeyboardSearchManager(this)),
m_pressedIndex(std::nullopt),
m_pressedMousePos(),
m_autoActivationTimer(nullptr),
m_swipeGesture(Qt::CustomGesture),
m_twoFingerTapGesture(Qt::CustomGesture),
m_oldSelection(),
m_keyboardAnchorIndex(-1),
m_keyboardAnchorPos(0)
KItemListController::KItemListController(KItemModelBase *model, KItemListView *view, QObject *parent)
: QObject(parent)
, m_singleClickActivationEnforced(false)
, m_selectionMode(false)
, m_selectionTogglePressed(false)
, m_clearSelectionIfItemsAreNotDragged(false)
, m_isSwipeGesture(false)
, m_dragActionOrRightClick(false)
, m_scrollerIsScrolling(false)
, m_pinchGestureInProgress(false)
, m_mousePress(false)
, m_isTouchEvent(false)
, m_selectionBehavior(NoSelection)
, m_autoActivationBehavior(ActivationAndExpansion)
, m_mouseDoubleClickAction(ActivateItemOnly)
, m_model(nullptr)
, m_view(nullptr)
, m_selectionManager(new KItemListSelectionManager(this))
, m_keyboardManager(new KItemListKeyboardSearchManager(this))
, m_pressedIndex(std::nullopt)
, m_pressedMousePos()
, m_autoActivationTimer(nullptr)
, m_swipeGesture(Qt::CustomGesture)
, m_twoFingerTapGesture(Qt::CustomGesture)
, m_oldSelection()
, m_keyboardAnchorIndex(-1)
, m_keyboardAnchorPos(0)
{
connect(m_keyboardManager, &KItemListKeyboardSearchManager::changeCurrentItem,
this, &KItemListController::slotChangeCurrentItem);
connect(m_selectionManager, &KItemListSelectionManager::currentChanged,
m_keyboardManager, &KItemListKeyboardSearchManager::slotCurrentChanged);
connect(m_selectionManager, &KItemListSelectionManager::selectionChanged,
m_keyboardManager, &KItemListKeyboardSearchManager::slotSelectionChanged);
connect(m_keyboardManager, &KItemListKeyboardSearchManager::changeCurrentItem, this, &KItemListController::slotChangeCurrentItem);
connect(m_selectionManager, &KItemListSelectionManager::currentChanged, m_keyboardManager, &KItemListKeyboardSearchManager::slotCurrentChanged);
connect(m_selectionManager, &KItemListSelectionManager::selectionChanged, m_keyboardManager, &KItemListKeyboardSearchManager::slotSelectionChanged);
m_autoActivationTimer = new QTimer(this);
m_autoActivationTimer->setSingleShot(true);
@ -252,10 +249,8 @@ bool KItemListController::keyPressEvent(QKeyEvent* event)
const bool shiftPressed = event->modifiers() & Qt::ShiftModifier;
const bool controlPressed = event->modifiers() & Qt::ControlModifier;
const bool shiftOrControlPressed = shiftPressed || controlPressed;
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_Down ||
key == Qt::Key_Left || key == Qt::Key_Right;
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_Down || key == Qt::Key_Left || key == Qt::Key_Right;
const int itemCount = m_model->count();
@ -263,11 +258,20 @@ bool KItemListController::keyPressEvent(QKeyEvent* event)
// the arrow keys to simplify the event handling.
if (m_view->scrollOrientation() == Qt::Horizontal) {
switch (key) {
case Qt::Key_Up: key = Qt::Key_Left; break;
case Qt::Key_Down: 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;
case Qt::Key_Up:
key = Qt::Key_Left;
break;
case Qt::Key_Down:
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;
if (selectedItems.count() >= 2) {
const int currentItemIndex = m_selectionManager->currentItem();
index = selectedItems.contains(currentItemIndex)
? currentItemIndex : selectedItems.first();
index = selectedItems.contains(currentItemIndex) ? currentItemIndex : selectedItems.first();
} else if (selectedItems.count() == 1) {
index = selectedItems.first();
}
@ -689,9 +692,8 @@ bool KItemListController::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event,
return true;
}
bool emitItemActivated = !(m_view->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) || m_singleClickActivationEnforced) &&
(event->button() & Qt::LeftButton) &&
index.has_value() && index.value() < m_model->count();
bool emitItemActivated = !(m_view->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) || m_singleClickActivationEnforced)
&& (event->button() & Qt::LeftButton) && index.has_value() && index.value() < m_model->count();
if (emitItemActivated) {
Q_EMIT itemActivated(index.value());
}
@ -731,7 +733,6 @@ bool KItemListController::dragMoveEvent(QGraphicsSceneDragDropEvent* event, cons
return false;
}
QUrl hoveredDir = m_model->directory();
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) {
return widget->expansionAreaHovered();
});
const auto oldHoveredExpansionWidget = oldHoveredExpansionWidgetIterator == visibleItemListWidgets.end() ?
std::nullopt : std::make_optional(*oldHoveredExpansionWidgetIterator);
const auto oldHoveredExpansionWidget =
oldHoveredExpansionWidgetIterator == visibleItemListWidgets.end() ? std::nullopt : std::make_optional(*oldHoveredExpansionWidgetIterator);
const auto unhoverOldHoveredWidget = [&]() {
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)
unhoverOldHoveredWidget();
newHoveredWidget->setExpansionAreaHovered(true);
} else {
// 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) {
m_dragActionOrRightClick = false;
}
else {
} else {
onPress(tap->hotSpot().toPoint(), tap->position().toPoint(), Qt::NoModifier, Qt::LeftButton);
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)
{
//the Qt TabAndHold gesture is triggerable with a mouse click, we don't want this
if (!m_isTouchEvent) {
return;
@ -1160,7 +1158,6 @@ void KItemListController::twoFingerTapTriggered(QGestureEvent* event, const QTra
onPress(twoTap->screenPos().toPoint(), twoTap->pos().toPoint(), Qt::ControlModifier, Qt::LeftButton);
onRelease(transform.map(twoTap->pos()), Qt::ControlModifier, Qt::LeftButton, false);
}
}
}
@ -1257,8 +1254,7 @@ void KItemListController::slotRubberBandChanged()
if (!m_oldSelection.isEmpty()) {
// Clear the old selection that was available before the rubberband has
// been activated in case if no Shift- or Control-key are pressed
const bool shiftOrControlPressed = QApplication::keyboardModifiers() & Qt::ShiftModifier ||
QApplication::keyboardModifiers() & Qt::ControlModifier;
const bool shiftOrControlPressed = QApplication::keyboardModifiers() & Qt::ShiftModifier || QApplication::keyboardModifiers() & Qt::ControlModifier;
if (!shiftOrControlPressed && !m_selectionMode) {
m_oldSelection.clear();
}
@ -1284,8 +1280,7 @@ void KItemListController::slotRubberBandChanged()
// Select all invisible items that intersect with the rubberband. Instead of
// iterating all items only the area which might be touched by the rubberband
// will be checked.
const bool increaseIndex = scrollVertical ?
startPos.y() > endPos.y(): startPos.x() > endPos.x();
const bool increaseIndex = scrollVertical ? startPos.y() > endPos.y() : startPos.x() > endPos.x();
int index = increaseIndex ? m_view->lastVisibleIndex() + 1 : m_view->firstVisibleIndex() - 1;
bool selectionFinished = false;
@ -1297,14 +1292,12 @@ void KItemListController::slotRubberBandChanged()
if (increaseIndex) {
++index;
selectionFinished = (index >= m_model->count()) ||
( scrollVertical && widgetRect.top() > rubberBandRect.bottom()) ||
(!scrollVertical && widgetRect.left() > rubberBandRect.right());
selectionFinished = (index >= m_model->count()) || (scrollVertical && widgetRect.top() > rubberBandRect.bottom())
|| (!scrollVertical && widgetRect.left() > rubberBandRect.right());
} else {
--index;
selectionFinished = (index < 0) ||
( scrollVertical && widgetRect.bottom() < rubberBandRect.top()) ||
(!scrollVertical && widgetRect.right() < rubberBandRect.left());
selectionFinished = (index < 0) || (scrollVertical && widgetRect.bottom() < rubberBandRect.top())
|| (!scrollVertical && widgetRect.right() < rubberBandRect.left());
}
} while (!selectionFinished);
@ -1314,8 +1307,7 @@ void KItemListController::slotRubberBandChanged()
// 1. All previously selected items which are not inside the rubberband, and
// 2. all items inside the rubberband which have not been selected previously.
m_selectionManager->setSelectedItems(m_oldSelection ^ selectedItems);
}
else {
} else {
m_selectionManager->setSelectedItems(selectedItems + m_oldSelection);
}
}
@ -1400,9 +1392,8 @@ KItemListWidget* KItemListController::widgetForDropPos(const QPointF& pos) const
void KItemListController::updateKeyboardAnchor()
{
const bool validAnchor = m_keyboardAnchorIndex >= 0 &&
m_keyboardAnchorIndex < m_model->count() &&
keyboardAnchorPos(m_keyboardAnchorIndex) == m_keyboardAnchorPos;
const bool validAnchor =
m_keyboardAnchorIndex >= 0 && m_keyboardAnchorIndex < m_model->count() && keyboardAnchorPos(m_keyboardAnchorIndex) == m_keyboardAnchorPos;
if (!validAnchor) {
const int index = m_selectionManager->currentItem();
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.
const bool shiftOrControlPressed = shiftPressed || controlPressed;
const bool pressedItemAlreadySelected = m_pressedIndex.has_value() && m_selectionManager->isSelected(m_pressedIndex.value());
const bool clearSelection = m_selectionBehavior == SingleSelection ||
(!shiftOrControlPressed && !pressedItemAlreadySelected);
const bool clearSelection = m_selectionBehavior == SingleSelection || (!shiftOrControlPressed && !pressedItemAlreadySelected);
// When this method returns false, a rubberBand selection is created using KItemListController::startRubberBand via the caller.
if (clearSelection) {
@ -1597,7 +1586,6 @@ bool KItemListController::onPress(const QPoint& screenPos, const QPointF& pos, c
}
if (rightClick) {
// Do header hit check and short circuit before commencing any state changing effects
if (m_view->headerBoundaries().contains(pos)) {
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 shiftOrControlPressed = modifiers & Qt::ShiftModifier ||
controlPressed;
const bool shiftOrControlPressed = modifiers & Qt::ShiftModifier || controlPressed;
const std::optional<int> index = m_view->itemAt(pos);

View File

@ -56,22 +56,12 @@ class DOLPHIN_EXPORT KItemListController : public QObject
Q_PROPERTY(MouseDoubleClickAction mouseDoubleClickAction READ mouseDoubleClickAction WRITE setMouseDoubleClickAction)
public:
enum SelectionBehavior {
NoSelection,
SingleSelection,
MultiSelection
};
enum SelectionBehavior { NoSelection, SingleSelection, MultiSelection };
Q_ENUM(SelectionBehavior)
enum AutoActivationBehavior {
ActivationAndExpansion,
ExpansionOnly
};
enum AutoActivationBehavior { ActivationAndExpansion, ExpansionOnly };
enum MouseDoubleClickAction {
ActivateAndExpandItem,
ActivateItemOnly
};
enum MouseDoubleClickAction { ActivateAndExpandItem, ActivateItemOnly };
/**
* @param model Model of the controller. The ownership is passed to the controller.
@ -394,5 +384,3 @@ private:
};
#endif

View File

@ -14,17 +14,17 @@
#include <QPainter>
#include <QStyleOptionGraphicsItem>
KItemListGroupHeader::KItemListGroupHeader(QGraphicsWidget* parent) :
QGraphicsWidget(parent),
m_dirtyCache(true),
m_role(),
m_data(),
m_styleOption(),
m_scrollOrientation(Qt::Vertical),
m_itemIndex(-1),
m_separatorColor(),
m_roleColor(),
m_roleBounds()
KItemListGroupHeader::KItemListGroupHeader(QGraphicsWidget *parent)
: QGraphicsWidget(parent)
, m_dirtyCache(true)
, m_role()
, m_data()
, m_styleOption()
, m_scrollOrientation(Qt::Vertical)
, m_itemIndex(-1)
, m_separatorColor()
, m_roleColor()
, m_roleBounds()
{
}
@ -190,10 +190,7 @@ void KItemListGroupHeader::updateSize()
const int y = (m_scrollOrientation == Qt::Vertical) ? padding : horizontalMargin;
m_roleBounds = QRectF(horizontalMargin + padding,
y,
size().width() - 2 * padding - horizontalMargin,
roleHeight);
m_roleBounds = QRectF(horizontalMargin + padding, y, size().width() - 2 * padding - horizontalMargin, roleHeight);
update();
}
@ -229,4 +226,3 @@ QColor KItemListGroupHeader::baseColor() const
const QPalette::ColorGroup group = isActiveWindow() ? QPalette::Active : QPalette::Inactive;
return styleOption().palette.color(group, normalBaseColorRole());
}

View File

@ -114,5 +114,3 @@ private:
QRectF m_roleBounds;
};
#endif

View File

@ -61,7 +61,8 @@ qreal KItemListHeader::preferredColumnWidth(const QByteArray& role) const
return m_headerWidget->preferredColumnWidth(role);
}
void KItemListHeader::setSidePadding(qreal width){
void KItemListHeader::setSidePadding(qreal width)
{
if (m_headerWidget->sidePadding() != width) {
m_headerWidget->setSidePadding(width);
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();
}
KItemListHeader::KItemListHeader(KItemListView* listView) :
QObject(listView),
m_view(listView)
KItemListHeader::KItemListHeader(KItemListView *listView)
: QObject(listView)
, m_view(listView)
{
m_headerWidget = m_view->m_headerWidget;
Q_ASSERT(m_headerWidget);
connect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged,
this, &KItemListHeader::columnWidthChanged);
connect(m_headerWidget, &KItemListHeaderWidget::columnWidthChangeFinished,
this, &KItemListHeader::columnWidthChangeFinished);
connect(m_headerWidget, &KItemListHeaderWidget::sidePaddingChanged,
this, &KItemListHeader::sidePaddingChanged);
connect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged, this, &KItemListHeader::columnWidthChanged);
connect(m_headerWidget, &KItemListHeaderWidget::columnWidthChangeFinished, this, &KItemListHeader::columnWidthChangeFinished);
connect(m_headerWidget, &KItemListHeaderWidget::sidePaddingChanged, this, &KItemListHeader::sidePaddingChanged);
}

View File

@ -72,16 +72,13 @@ Q_SIGNALS:
* 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).
*/
void columnWidthChanged(const QByteArray& role,
qreal currentWidth,
qreal previousWidth);
void columnWidthChanged(const QByteArray &role, qreal currentWidth, qreal previousWidth);
/**
* Is emitted if the user has released the mouse button after adjusting the
* width of a visible role.
*/
void columnWidthChangeFinished(const QByteArray& role,
qreal currentWidth);
void columnWidthChangeFinished(const QByteArray &role, qreal currentWidth);
private:
explicit KItemListHeader(KItemListView *listView);
@ -94,5 +91,3 @@ private:
};
#endif

View File

@ -9,13 +9,13 @@
#include "kitemlistselectionmanager.h"
KItemListSelectionManager::KItemListSelectionManager(QObject* parent) :
QObject(parent),
m_currentItem(-1),
m_anchorItem(-1),
m_selectedItems(),
m_isAnchoredSelectionActive(false),
m_model(nullptr)
KItemListSelectionManager::KItemListSelectionManager(QObject *parent)
: QObject(parent)
, m_currentItem(-1)
, m_anchorItem(-1)
, m_selectedItems()
, m_isAnchoredSelectionActive(false)
, m_model(nullptr)
{
}
@ -359,8 +359,7 @@ void KItemListSelectionManager::itemsMoved(const KItemRange& itemRange, const QL
for (int index : previous) {
if (index >= itemRange.index && index < itemRange.index + itemRange.count) {
m_selectedItems.insert(movedToIndexes.at(index - itemRange.index));
}
else {
} else {
m_selectedItems.insert(index);
}
}
@ -372,8 +371,7 @@ void KItemListSelectionManager::itemsMoved(const KItemRange& itemRange, const QL
}
}
int KItemListSelectionManager::indexAfterRangesRemoving(int index, const KItemRangeList& itemRanges,
const RangesRemovingBehaviour behaviour) const
int KItemListSelectionManager::indexAfterRangesRemoving(int index, const KItemRangeList &itemRanges, const RangesRemovingBehaviour behaviour) const
{
int dec = 0;
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);
}

View File

@ -24,17 +24,10 @@ class DOLPHIN_EXPORT KItemListSelectionManager : public QObject
{
Q_OBJECT
enum RangesRemovingBehaviour {
DiscardRemovedIndex,
AdjustRemovedIndex
};
enum RangesRemovingBehaviour { DiscardRemovedIndex, AdjustRemovedIndex };
public:
enum SelectionMode {
Select,
Deselect,
Toggle
};
enum SelectionMode { Select, Deselect, Toggle };
explicit KItemListSelectionManager(QObject *parent = nullptr);
~KItemListSelectionManager() override;
@ -73,7 +66,6 @@ private:
void itemsRemoved(const KItemRangeList &itemRanges);
void itemsMoved(const KItemRange &itemRange, const QList<int> &movedToIndexes);
/**
* 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.

View File

@ -6,19 +6,18 @@
#include "kitemliststyleoption.h"
KItemListStyleOption::KItemListStyleOption() :
rect(),
font(),
fontMetrics(QFont()),
palette(),
padding(-1),
horizontalMargin(-1),
verticalMargin(-1),
iconSize(-1),
extendedSelectionRegion(false),
maxTextLines(0),
maxTextWidth(0)
KItemListStyleOption::KItemListStyleOption()
: rect()
, font()
, fontMetrics(QFont())
, palette()
, padding(-1)
, horizontalMargin(-1)
, verticalMargin(-1)
, iconSize(-1)
, extendedSelectionRegion(false)
, maxTextLines(0)
, maxTextWidth(0)
{
}
@ -28,17 +27,9 @@ KItemListStyleOption::~KItemListStyleOption()
bool KItemListStyleOption::operator==(const KItemListStyleOption &other) const
{
return rect == other.rect
&& font == other.font
&& fontMetrics == other.fontMetrics
&& palette == other.palette
&& padding == other.padding
&& horizontalMargin == other.horizontalMargin
&& verticalMargin == other.verticalMargin
&& iconSize == other.iconSize
&& extendedSelectionRegion == other.extendedSelectionRegion
&& maxTextLines == other.maxTextLines
&& maxTextWidth == other.maxTextWidth;
return rect == other.rect && font == other.font && fontMetrics == other.fontMetrics && 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

View File

@ -36,5 +36,3 @@ public:
bool operator!=(const KItemListStyleOption &other) const;
};
#endif

View File

@ -29,8 +29,8 @@
#include <QTimer>
#include <QVariantAnimation>
namespace {
namespace
{
// Time in ms until reaching the autoscroll margin triggers
// an initial autoscrolling
const int InitialAutoScrollDelay = 700;
@ -59,44 +59,44 @@ QAccessibleInterface* accessibleInterfaceFactory(const QString& key, QObject* ob
}
#endif
KItemListView::KItemListView(QGraphicsWidget* parent) :
QGraphicsWidget(parent),
m_enabledSelectionToggles(false),
m_grouped(false),
m_highlightEntireRow(false),
m_alternateBackgrounds(false),
m_supportsItemExpanding(false),
m_editingRole(false),
m_activeTransactions(0),
m_endTransactionAnimationHint(Animation),
m_itemSize(),
m_controller(nullptr),
m_model(nullptr),
m_visibleRoles(),
m_widgetCreator(nullptr),
m_groupHeaderCreator(nullptr),
m_styleOption(),
m_visibleItems(),
m_visibleGroups(),
m_visibleCells(),
m_scrollBarExtent(0),
m_layouter(nullptr),
m_animation(nullptr),
m_oldScrollOffset(0),
m_oldMaximumScrollOffset(0),
m_oldItemOffset(0),
m_oldMaximumItemOffset(0),
m_skipAutoScrollForRubberBand(false),
m_rubberBand(nullptr),
m_tapAndHoldIndicator(nullptr),
m_mousePos(),
m_autoScrollIncrement(0),
m_autoScrollTimer(nullptr),
m_header(nullptr),
m_headerWidget(nullptr),
m_indicatorAnimation(nullptr),
m_dropIndicator(),
m_sizeHintResolver(nullptr)
KItemListView::KItemListView(QGraphicsWidget *parent)
: QGraphicsWidget(parent)
, m_enabledSelectionToggles(false)
, m_grouped(false)
, m_highlightEntireRow(false)
, m_alternateBackgrounds(false)
, m_supportsItemExpanding(false)
, m_editingRole(false)
, m_activeTransactions(0)
, m_endTransactionAnimationHint(Animation)
, m_itemSize()
, m_controller(nullptr)
, m_model(nullptr)
, m_visibleRoles()
, m_widgetCreator(nullptr)
, m_groupHeaderCreator(nullptr)
, m_styleOption()
, m_visibleItems()
, m_visibleGroups()
, m_visibleCells()
, m_scrollBarExtent(0)
, m_layouter(nullptr)
, m_animation(nullptr)
, m_oldScrollOffset(0)
, m_oldMaximumScrollOffset(0)
, m_oldItemOffset(0)
, m_oldMaximumItemOffset(0)
, m_skipAutoScrollForRubberBand(false)
, m_rubberBand(nullptr)
, m_tapAndHoldIndicator(nullptr)
, m_mousePos()
, m_autoScrollIncrement(0)
, m_autoScrollTimer(nullptr)
, m_header(nullptr)
, m_headerWidget(nullptr)
, m_indicatorAnimation(nullptr)
, m_dropIndicator()
, m_sizeHintResolver(nullptr)
{
setAcceptHoverEvents(true);
setAcceptTouchEvents(true);
@ -106,8 +106,7 @@ KItemListView::KItemListView(QGraphicsWidget* parent) :
m_layouter = new KItemListViewLayouter(m_sizeHintResolver, this);
m_animation = new KItemListViewAnimation(this);
connect(m_animation, &KItemListViewAnimation::finished,
this, &KItemListView::slotAnimationFinished);
connect(m_animation, &KItemListViewAnimation::finished, this, &KItemListView::slotAnimationFinished);
m_rubberBand = new KItemListRubberBand(this);
connect(m_rubberBand, &KItemListRubberBand::activationChanged, this, &KItemListView::slotRubberBandActivationChanged);
@ -137,7 +136,6 @@ KItemListView::KItemListView(QGraphicsWidget* parent) :
#ifndef QT_NO_ACCESSIBILITY
QAccessible::installFactory(accessibleInterfaceFactory);
#endif
}
KItemListView::~KItemListView()
@ -244,9 +242,8 @@ void KItemListView::setVisibleRoles(const QList<QByteArray>& roles)
}
}
const bool alternateBackgroundsChanged = m_itemSize.isEmpty() &&
((roles.count() > 1 && previousRoles.count() <= 1) ||
(roles.count() <= 1 && previousRoles.count() > 1));
const bool alternateBackgroundsChanged =
m_itemSize.isEmpty() && ((roles.count() > 1 && previousRoles.count() <= 1) || (roles.count() <= 1 && previousRoles.count() > 1));
QHashIterator<int, KItemListWidget *> it(m_visibleItems);
while (it.hasNext()) {
@ -365,8 +362,7 @@ void KItemListView::setGeometry(const QRectF& rect)
applyAutomaticColumnWidths();
} else {
const qreal requiredWidth = columnWidthsSum();
const QSizeF dynamicItemSize(qMax(newSize.width(), requiredWidth),
m_itemSize.height());
const QSizeF dynamicItemSize(qMax(newSize.width(), requiredWidth), m_itemSize.height());
m_layouter->setItemSize(dynamicItemSize);
}
}
@ -533,8 +529,7 @@ void KItemListView::scrollToItem(int index)
QRectF currentRect = itemRect(index);
// Fix for Bug 311099 - View the underscore when using Ctrl + PagDown
currentRect.adjust(-m_styleOption.horizontalMargin, -m_styleOption.verticalMargin,
m_styleOption.horizontalMargin, m_styleOption.verticalMargin);
currentRect.adjust(-m_styleOption.horizontalMargin, -m_styleOption.verticalMargin, m_styleOption.horizontalMargin, m_styleOption.verticalMargin);
if (!viewGeometry.contains(currentRect)) {
qreal newOffset = scrollOffset();
@ -593,8 +588,7 @@ void KItemListView::setHeaderVisible(bool visible)
{
if (visible && !m_headerWidget->isVisible()) {
QStyleOptionHeader option;
const QSize headerSize = style()->sizeFromContents(QStyle::CT_HeaderSection,
&option, QSize());
const QSize headerSize = style()->sizeFromContents(QStyle::CT_HeaderSection, &option, QSize());
m_headerWidget->setPos(0, 0);
m_headerWidget->resize(size().width(), headerSize.height());
@ -602,30 +596,20 @@ void KItemListView::setHeaderVisible(bool visible)
m_headerWidget->setColumns(m_visibleRoles);
m_headerWidget->setZValue(1);
connect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged,
this, &KItemListView::slotHeaderColumnWidthChanged);
connect(m_headerWidget, &KItemListHeaderWidget::sidePaddingChanged,
this, &KItemListView::slotSidePaddingChanged);
connect(m_headerWidget, &KItemListHeaderWidget::columnMoved,
this, &KItemListView::slotHeaderColumnMoved);
connect(m_headerWidget, &KItemListHeaderWidget::sortOrderChanged,
this, &KItemListView::sortOrderChanged);
connect(m_headerWidget, &KItemListHeaderWidget::sortRoleChanged,
this, &KItemListView::sortRoleChanged);
connect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged, this, &KItemListView::slotHeaderColumnWidthChanged);
connect(m_headerWidget, &KItemListHeaderWidget::sidePaddingChanged, this, &KItemListView::slotSidePaddingChanged);
connect(m_headerWidget, &KItemListHeaderWidget::columnMoved, 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_headerWidget->setVisible(true);
} else if (!visible && m_headerWidget->isVisible()) {
disconnect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged,
this, &KItemListView::slotHeaderColumnWidthChanged);
disconnect(m_headerWidget, &KItemListHeaderWidget::sidePaddingChanged,
this, &KItemListView::slotSidePaddingChanged);
disconnect(m_headerWidget, &KItemListHeaderWidget::columnMoved,
this, &KItemListView::slotHeaderColumnMoved);
disconnect(m_headerWidget, &KItemListHeaderWidget::sortOrderChanged,
this, &KItemListView::sortOrderChanged);
disconnect(m_headerWidget, &KItemListHeaderWidget::sortRoleChanged,
this, &KItemListView::sortRoleChanged);
disconnect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged, this, &KItemListView::slotHeaderColumnWidthChanged);
disconnect(m_headerWidget, &KItemListHeaderWidget::sidePaddingChanged, this, &KItemListView::slotSidePaddingChanged);
disconnect(m_headerWidget, &KItemListHeaderWidget::columnMoved, this, &KItemListView::slotHeaderColumnMoved);
disconnect(m_headerWidget, &KItemListHeaderWidget::sortOrderChanged, this, &KItemListView::sortOrderChanged);
disconnect(m_headerWidget, &KItemListHeaderWidget::sortRoleChanged, this, &KItemListView::sortRoleChanged);
m_layouter->setHeaderHeight(0);
m_headerWidget->setVisible(false);
@ -671,13 +655,10 @@ void KItemListView::editRole(int index, const QByteArray& role)
m_editingRole = true;
widget->setEditedRole(role);
connect(widget, &KItemListWidget::roleEditingCanceled,
this, &KItemListView::slotRoleEditingCanceled);
connect(widget, &KItemListWidget::roleEditingFinished,
this, &KItemListView::slotRoleEditingFinished);
connect(widget, &KItemListWidget::roleEditingCanceled, this, &KItemListView::slotRoleEditingCanceled);
connect(widget, &KItemListWidget::roleEditingFinished, this, &KItemListView::slotRoleEditingFinished);
connect(this, &KItemListView::scrollOffsetChanged,
widget, &KStandardItemListWidget::finishRoleEditing);
connect(this, &KItemListView::scrollOffsetChanged, widget, &KStandardItemListWidget::finishRoleEditing);
}
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()) {
QRectF rubberBandRect = QRectF(m_rubberBand->startPosition(),
m_rubberBand->endPosition()).normalized();
QRectF rubberBandRect = QRectF(m_rubberBand->startPosition(), m_rubberBand->endPosition()).normalized();
const QPointF topLeft = rubberBandRect.topLeft();
if (scrollOrientation() == Qt::Vertical) {
@ -729,8 +709,8 @@ void KItemListView::paint(QPainter* painter, const QStyleOptionGraphicsItem* opt
if (m_tapAndHoldIndicator->isActive()) {
const QPointF indicatorSize = m_tapAndHoldIndicator->endPosition();
const QRectF rubberBandRect = QRectF(m_tapAndHoldIndicator->startPosition() - indicatorSize,
(m_tapAndHoldIndicator->startPosition()) + indicatorSize).normalized();
const QRectF rubberBandRect =
QRectF(m_tapAndHoldIndicator->startPosition() - indicatorSize, (m_tapAndHoldIndicator->startPosition()) + indicatorSize).normalized();
QStyleOptionRubberBand opt;
initStyleOption(&opt);
opt.shape = QRubberBand::Rectangle;
@ -776,13 +756,9 @@ void KItemListView::setItemSize(const QSizeF& size)
// Skip animations when the number of rows or columns
// are changed in the grid layout. Although the animation
// engine can handle this usecase, it looks obtrusive.
const bool animate = !changesItemGridLayout(m_layouter->size(),
size,
m_layouter->itemMargin());
const bool animate = !changesItemGridLayout(m_layouter->size(), size, m_layouter->itemMargin());
const bool alternateBackgroundsChanged = m_alternateBackgrounds &&
(( m_itemSize.isEmpty() && !size.isEmpty()) ||
(!m_itemSize.isEmpty() && size.isEmpty()));
const bool alternateBackgroundsChanged = m_alternateBackgrounds && ((m_itemSize.isEmpty() && !size.isEmpty()) || (!m_itemSize.isEmpty() && size.isEmpty()));
m_itemSize = size;
@ -827,9 +803,7 @@ void KItemListView::setStyleOption(const KItemListStyleOption& option)
// Skip animations when the number of rows or columns
// are changed in the grid layout. Although the animation
// engine can handle this usecase, it looks obtrusive.
animate = !changesItemGridLayout(m_layouter->size(),
m_layouter->itemSize(),
margin);
animate = !changesItemGridLayout(m_layouter->size(), m_layouter->itemSize(), margin);
m_layouter->setItemMargin(margin);
}
@ -837,8 +811,7 @@ void KItemListView::setStyleOption(const KItemListStyleOption& option)
updateGroupHeaderHeight();
}
if (animate &&
(previousOption.maxTextLines != option.maxTextLines || previousOption.maxTextWidth != option.maxTextWidth)) {
if (animate && (previousOption.maxTextLines != option.maxTextLines || previousOption.maxTextWidth != option.maxTextWidth)) {
// Animating a change of the maximum text size just results in expensive
// temporary eliding and clipping operations and does not look good visually.
animate = false;
@ -879,7 +852,6 @@ void KItemListView::setScrollOrientation(Qt::Orientation orientation)
it.value()->setScrollOrientation(orientation);
}
updateGroupHeaderHeight();
}
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
// an unnecessary temporary animation due to the geometry change of the inserted scrollbar.
const bool verticalScrollOrientation = (scrollOrientation() == Qt::Vertical);
const bool decreaseLayouterSize = ( verticalScrollOrientation && maximumScrollOffset() > size().height()) ||
(!verticalScrollOrientation && maximumScrollOffset() > size().width());
const bool decreaseLayouterSize = (verticalScrollOrientation && maximumScrollOffset() > size().height())
|| (!verticalScrollOrientation && maximumScrollOffset() > size().width());
if (decreaseLayouterSize) {
const int scrollBarExtent = style()->pixelMetric(QStyle::PM_ScrollBarExtent);
@ -1317,8 +1289,7 @@ void KItemListView::slotItemsMoved(const KItemRange& itemRange, const QList<int>
updateSiblingsInformation();
}
void KItemListView::slotItemsChanged(const KItemRangeList& itemRanges,
const QSet<QByteArray>& roles)
void KItemListView::slotItemsChanged(const KItemRangeList &itemRanges, const QSet<QByteArray> &roles)
{
const bool updateSizeHints = itemSizeHintUpdateRequired(roles);
if (updateSizeHints && m_itemSize.isEmpty()) {
@ -1451,8 +1422,7 @@ void KItemListView::slotSelectionChanged(const KItemSet& current, const KItemSet
}
}
void KItemListView::slotAnimationFinished(QGraphicsWidget* widget,
KItemListViewAnimation::AnimationType type)
void KItemListView::slotAnimationFinished(QGraphicsWidget *widget, KItemListViewAnimation::AnimationType type)
{
KItemListWidget *itemListWidget = qobject_cast<KItemListWidget *>(widget);
Q_ASSERT(itemListWidget);
@ -1470,8 +1440,7 @@ void KItemListView::slotAnimationFinished(QGraphicsWidget* widget,
widgetCreator()->recycle(itemListWidget);
} else {
const int index = itemListWidget->index();
const bool invisible = (index < m_layouter->firstVisibleIndex()) ||
(index > m_layouter->lastVisibleIndex());
const bool invisible = (index < m_layouter->firstVisibleIndex()) || (index > m_layouter->lastVisibleIndex());
if (invisible && !m_animation->isStarted(itemListWidget)) {
recycleWidget(itemListWidget);
}
@ -1490,8 +1459,7 @@ void KItemListView::slotRubberBandActivationChanged(bool active)
connect(m_rubberBand, &KItemListRubberBand::endPositionChanged, this, &KItemListView::slotRubberBandPosChanged);
m_skipAutoScrollForRubberBand = true;
} else {
QRectF rubberBandRect = QRectF(m_rubberBand->startPosition(),
m_rubberBand->endPosition()).normalized();
QRectF rubberBandRect = QRectF(m_rubberBand->startPosition(), m_rubberBand->endPosition()).normalized();
auto animation = new QVariantAnimation(this);
animation->setStartValue(1.0);
@ -1522,9 +1490,7 @@ void KItemListView::slotRubberBandActivationChanged(bool active)
update();
}
void KItemListView::slotHeaderColumnWidthChanged(const QByteArray& role,
qreal currentWidth,
qreal previousWidth)
void KItemListView::slotHeaderColumnWidthChanged(const QByteArray &role, qreal currentWidth, qreal previousWidth)
{
Q_UNUSED(role)
Q_UNUSED(currentWidth)
@ -1545,9 +1511,7 @@ void KItemListView::slotSidePaddingChanged(qreal width)
doLayout(NoAnimation);
}
void KItemListView::slotHeaderColumnMoved(const QByteArray& role,
int currentIndex,
int previousIndex)
void KItemListView::slotHeaderColumnMoved(const QByteArray &role, int currentIndex, int previousIndex)
{
Q_ASSERT(m_visibleRoles[previousIndex] == role);
@ -1597,8 +1561,7 @@ void KItemListView::triggerAutoScrolling()
// an autoscrolling.
const qreal minDiff = 4; // Ignore any autoscrolling if the rubberband is very small
const qreal diff = (scrollOrientation() == Qt::Vertical)
? m_rubberBand->endPosition().y() - m_rubberBand->startPosition().y()
const qreal diff = (scrollOrientation() == Qt::Vertical) ? m_rubberBand->endPosition().y() - m_rubberBand->startPosition().y()
: m_rubberBand->endPosition().x() - m_rubberBand->startPosition().x();
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
@ -1677,22 +1640,14 @@ void KItemListView::setModel(KItemModelBase* model)
KItemModelBase *previous = m_model;
if (m_model) {
disconnect(m_model, &KItemModelBase::itemsChanged,
this, &KItemListView::slotItemsChanged);
disconnect(m_model, &KItemModelBase::itemsInserted,
this, &KItemListView::slotItemsInserted);
disconnect(m_model, &KItemModelBase::itemsRemoved,
this, &KItemListView::slotItemsRemoved);
disconnect(m_model, &KItemModelBase::itemsMoved,
this, &KItemListView::slotItemsMoved);
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);
disconnect(m_model, &KItemModelBase::itemsChanged, this, &KItemListView::slotItemsChanged);
disconnect(m_model, &KItemModelBase::itemsInserted, this, &KItemListView::slotItemsInserted);
disconnect(m_model, &KItemModelBase::itemsRemoved, this, &KItemListView::slotItemsRemoved);
disconnect(m_model, &KItemModelBase::itemsMoved, this, &KItemListView::slotItemsMoved);
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()));
}
@ -1702,22 +1657,14 @@ void KItemListView::setModel(KItemModelBase* model)
m_grouped = model->groupedSorting();
if (m_model) {
connect(m_model, &KItemModelBase::itemsChanged,
this, &KItemListView::slotItemsChanged);
connect(m_model, &KItemModelBase::itemsInserted,
this, &KItemListView::slotItemsInserted);
connect(m_model, &KItemModelBase::itemsRemoved,
this, &KItemListView::slotItemsRemoved);
connect(m_model, &KItemModelBase::itemsMoved,
this, &KItemListView::slotItemsMoved);
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);
connect(m_model, &KItemModelBase::itemsChanged, this, &KItemListView::slotItemsChanged);
connect(m_model, &KItemModelBase::itemsInserted, this, &KItemListView::slotItemsInserted);
connect(m_model, &KItemModelBase::itemsRemoved, this, &KItemListView::slotItemsRemoved);
connect(m_model, &KItemModelBase::itemsMoved, this, &KItemListView::slotItemsMoved);
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();
if (itemCount > 0) {
@ -1805,8 +1752,7 @@ void KItemListView::doLayout(LayoutAnimationHint hint, int changedIndex, int cha
const int previousIndex = i - changedCount;
const QRectF itemRect = m_layouter->itemRect(previousIndex);
if (itemRect.isEmpty()) {
const QPointF invisibleOldPos = (scrollOrientation() == Qt::Vertical)
? QPointF(0, size().height()) : QPointF(size().width(), 0);
const QPointF invisibleOldPos = (scrollOrientation() == Qt::Vertical) ? QPointF(0, size().height()) : QPointF(size().width(), 0);
widget->setPos(invisibleOldPos);
} else {
widget->setPos(itemRect.topLeft());
@ -1920,9 +1866,7 @@ void KItemListView::doLayout(LayoutAnimationHint hint, int changedIndex, int cha
emitOffsetChanges();
}
QList<int> KItemListView::recycleInvisibleItems(int firstVisibleIndex,
int lastVisibleIndex,
LayoutAnimationHint hint)
QList<int> KItemListView::recycleInvisibleItems(int firstVisibleIndex, int lastVisibleIndex, LayoutAnimationHint hint)
{
// Determine all items that are completely invisible and might be
// 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 bool vertical = (scrollOrientation() == Qt::Vertical);
const bool updateCell = (vertical && oldCell.row == newCell.row) ||
(!vertical && oldCell.column == newCell.column);
const bool updateCell = (vertical && oldCell.row == newCell.row) || (!vertical && oldCell.column == newCell.column);
if (updateCell) {
m_visibleCells.insert(index, newCell);
}
@ -2081,9 +2024,14 @@ void KItemListView::moveWidgetToIndex(KItemListWidget* widget, int index)
void KItemListView::setLayouterSize(const QSizeF &size, SizeType sizeType)
{
switch (sizeType) {
case LayouterSize: m_layouter->setSize(size); break;
case ItemSize: m_layouter->setItemSize(size); break;
default: break;
case LayouterSize:
m_layouter->setSize(size);
break;
case ItemSize:
m_layouter->setItemSize(size);
break;
default:
break;
}
}
@ -2317,8 +2265,7 @@ void KItemListView::applyColumnWidthsFromHeader()
{
// Apply the new size to the layouter
const qreal requiredWidth = columnWidthsSum() + m_headerWidget->sidePadding();
const QSizeF dynamicItemSize(qMax(size().width(), requiredWidth),
m_itemSize.height());
const QSizeF dynamicItemSize(qMax(size().width(), requiredWidth), m_itemSize.height());
m_layouter->setItemSize(dynamicItemSize);
// Update the role sizes for all visible widgets
@ -2463,9 +2410,7 @@ QRectF KItemListView::headerBoundaries() const
return m_headerWidget->isVisible() ? m_headerWidget->geometry() : QRectF();
}
bool KItemListView::changesItemGridLayout(const QSizeF& newGridSize,
const QSizeF& newItemSize,
const QSizeF& newItemMargin) const
bool KItemListView::changesItemGridLayout(const QSizeF &newGridSize, const QSizeF &newItemSize, const QSizeF &newItemMargin) const
{
if (newItemSize.isEmpty() || newGridSize.isEmpty()) {
return false;
@ -2474,26 +2419,18 @@ bool KItemListView::changesItemGridLayout(const QSizeF& newGridSize,
if (m_layouter->scrollOrientation() == Qt::Vertical) {
const qreal itemWidth = m_layouter->itemSize().width();
if (itemWidth > 0) {
const int newColumnCount = itemsPerSize(newGridSize.width(),
newItemSize.width(),
newItemMargin.width());
const int newColumnCount = itemsPerSize(newGridSize.width(), newItemSize.width(), newItemMargin.width());
if (m_model->count() > newColumnCount) {
const int oldColumnCount = itemsPerSize(m_layouter->size().width(),
itemWidth,
m_layouter->itemMargin().width());
const int oldColumnCount = itemsPerSize(m_layouter->size().width(), itemWidth, m_layouter->itemMargin().width());
return oldColumnCount != newColumnCount;
}
}
} else {
const qreal itemHeight = m_layouter->itemSize().height();
if (itemHeight > 0) {
const int newRowCount = itemsPerSize(newGridSize.height(),
newItemSize.height(),
newItemMargin.height());
const int newRowCount = itemsPerSize(newGridSize.height(), newItemSize.height(), newItemMargin.height());
if (m_model->count() > newRowCount) {
const int oldRowCount = itemsPerSize(m_layouter->size().height(),
itemHeight,
m_layouter->itemMargin().height());
const int oldRowCount = itemsPerSize(m_layouter->size().height(), itemHeight, m_layouter->itemMargin().height());
return oldRowCount != newRowCount;
}
}
@ -2514,14 +2451,12 @@ bool KItemListView::animateChangedItemCount(int changedItemCount) const
return false;
}
const int maximum = (scrollOrientation() == Qt::Vertical)
? m_layouter->size().width() / m_layouter->itemSize().width()
const int maximum = (scrollOrientation() == Qt::Vertical) ? m_layouter->size().width() / m_layouter->itemSize().width()
: m_layouter->size().height() / m_layouter->itemSize().height();
// Only animate if up to 2/3 of a row or column are inserted or removed
return changedItemCount <= maximum * 2 / 3;
}
bool KItemListView::scrollBarRequired(const QSizeF &size) const
{
const QSizeF oldSize = m_layouter->size();
@ -2530,8 +2465,7 @@ bool KItemListView::scrollBarRequired(const QSizeF& size) const
const qreal maxOffset = m_layouter->maximumScrollOffset();
m_layouter->setSize(oldSize);
return m_layouter->scrollOrientation() == Qt::Vertical ? maxOffset > size.height()
: maxOffset > size.width();
return m_layouter->scrollOrientation() == Qt::Vertical ? maxOffset > size.height() : maxOffset > size.width();
}
int KItemListView::showDropIndicator(const QPointF &pos)
@ -2615,8 +2549,7 @@ void KItemListView::updateSiblingsInformation(int firstIndex, int lastIndex)
firstIndex = m_layouter->firstVisibleIndex();
lastIndex = m_layouter->lastVisibleIndex();
} else {
const bool isRangeVisible = (firstIndex <= m_layouter->lastVisibleIndex() &&
lastIndex >= m_layouter->firstVisibleIndex());
const bool isRangeVisible = (firstIndex <= m_layouter->lastVisibleIndex() && lastIndex >= m_layouter->firstVisibleIndex());
if (!isRangeVisible) {
return;
}
@ -2777,8 +2710,6 @@ int KItemListView::itemsPerSize(qreal size, qreal itemSize, qreal itemMargin)
return count;
}
KItemListCreatorBase::~KItemListCreatorBase()
{
qDeleteAll(m_recycleableWidgets);
@ -2834,4 +2765,3 @@ void KItemListGroupHeaderCreatorBase::recycle(KItemListGroupHeader* header)
header->setOpacity(1.0);
pushRecycleableWidget(header);
}

View File

@ -403,8 +403,7 @@ protected Q_SLOTS:
virtual void slotItemsInserted(const KItemRangeList &itemRanges);
virtual void slotItemsRemoved(const KItemRangeList &itemRanges);
virtual void slotItemsMoved(const KItemRange &itemRange, const QList<int> &movedToIndexes);
virtual void slotItemsChanged(const KItemRangeList& itemRanges,
const QSet<QByteArray>& roles);
virtual void slotItemsChanged(const KItemRangeList &itemRanges, const QSet<QByteArray> &roles);
virtual void slotGroupsChanged();
virtual void slotGroupedSortingChanged(bool current);
@ -414,8 +413,7 @@ protected Q_SLOTS:
virtual void slotSelectionChanged(const KItemSet &current, const KItemSet &previous);
private Q_SLOTS:
void slotAnimationFinished(QGraphicsWidget* widget,
KItemListViewAnimation::AnimationType type);
void slotAnimationFinished(QGraphicsWidget *widget, KItemListViewAnimation::AnimationType type);
void slotRubberBandPosChanged();
void slotRubberBandActivationChanged(bool active);
@ -426,9 +424,7 @@ private Q_SLOTS:
* will be turned off as soon as this method has been called at
* least once.
*/
void slotHeaderColumnWidthChanged(const QByteArray& role,
qreal currentWidth,
qreal previousWidth);
void slotHeaderColumnWidthChanged(const QByteArray &role, qreal currentWidth, qreal previousWidth);
void slotSidePaddingChanged(qreal width);
@ -436,9 +432,7 @@ private Q_SLOTS:
* Is invoked if a column has been moved by the user. Applies
* the moved role to the view.
*/
void slotHeaderColumnMoved(const QByteArray& role,
int currentIndex,
int previousIndex);
void slotHeaderColumnMoved(const QByteArray &role, int currentIndex, int previousIndex);
/**
* 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);
private:
enum LayoutAnimationHint
{
NoAnimation,
Animation
};
enum LayoutAnimationHint { NoAnimation, Animation };
enum SizeType
{
LayouterSize,
ItemSize
};
enum SizeType { LayouterSize, ItemSize };
void setController(KItemListController *controller);
void setModel(KItemModelBase *model);
@ -485,9 +471,7 @@ private:
* won't be reused. Reusing items is faster in comparison to deleting invisible
* items and creating a new instance for visible items.
*/
QList<int> recycleInvisibleItems(int firstVisibleIndex,
int lastVisibleIndex,
LayoutAnimationHint hint);
QList<int> recycleInvisibleItems(int firstVisibleIndex, int lastVisibleIndex, LayoutAnimationHint hint);
/**
* 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
* should be done when applying the new layout.
*/
bool changesItemGridLayout(const QSizeF& newGridSize,
const QSizeF& newItemSize,
const QSizeF& newItemMargin) const;
bool changesItemGridLayout(const QSizeF &newGridSize, const QSizeF &newItemSize, const QSizeF &newItemMargin) const;
/**
* @param changedItemCount Number of inserted or removed items.
@ -731,10 +713,17 @@ private:
QHash<int, KItemListWidget *> m_visibleItems;
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 row;
};
@ -823,9 +812,7 @@ public:
virtual void calculateItemSizeHints(QVector<std::pair<qreal, bool>> &logicalHeightHints, qreal &logicalWidthHint, const KItemListView *view) const = 0;
virtual qreal preferredRoleColumnWidth(const QByteArray& role,
int index,
const KItemListView* view) const = 0;
virtual qreal preferredRoleColumnWidth(const QByteArray &role, 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;
qreal preferredRoleColumnWidth(const QByteArray& role,
int index,
const KItemListView* view) const override;
qreal preferredRoleColumnWidth(const QByteArray &role, int index, const KItemListView *view) const override;
private:
KItemListWidgetInformant *m_informant;
};
template<class T>
KItemListWidgetCreator<T>::KItemListWidgetCreator() :
m_informant(T::createInformant())
KItemListWidgetCreator<T>::KItemListWidgetCreator()
: m_informant(T::createInformant())
{
}
@ -874,15 +860,15 @@ KItemListWidget* KItemListWidgetCreator<T>::create(KItemListView* view)
}
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);
}
template<class T>
qreal KItemListWidgetCreator<T>::preferredRoleColumnWidth(const QByteArray& role,
int index,
const KItemListView* view) const
qreal KItemListWidgetCreator<T>::preferredRoleColumnWidth(const QByteArray &role, int index, const KItemListView *view) const
{
return m_informant->preferredRoleColumnWidth(role, index, view);
}

View File

@ -21,8 +21,8 @@ KItemListView* KItemListViewAccessible::view() const
return qobject_cast<KItemListView *>(object());
}
KItemListViewAccessible::KItemListViewAccessible(KItemListView* view_) :
QAccessibleObject(view_)
KItemListViewAccessible::KItemListViewAccessible(KItemListView *view_)
: QAccessibleObject(view_)
{
Q_ASSERT(view());
m_cells.resize(childCount());
@ -185,7 +185,8 @@ bool KItemListViewAccessible::unselectColumn(int)
}
void KItemListViewAccessible::modelChange(QAccessibleTableModelChangeEvent * /*event*/)
{}
{
}
QAccessible::Role KItemListViewAccessible::role() const
{
@ -251,17 +252,17 @@ QAccessibleInterface* KItemListViewAccessible::child(int index) const
return nullptr;
}
KItemListViewAccessible::AccessibleIdWrapper::AccessibleIdWrapper() :
isValid(false),
id(0)
KItemListViewAccessible::AccessibleIdWrapper::AccessibleIdWrapper()
: isValid(false)
, id(0)
{
}
// Table Cell
KItemListAccessibleCell::KItemListAccessibleCell(KItemListView* view, int index) :
m_view(view),
m_index(index)
KItemListAccessibleCell::KItemListAccessibleCell(KItemListView *view, int index)
: m_view(view)
, m_index(index)
{
Q_ASSERT(index >= 0 && index < view->model()->count());
}
@ -427,8 +428,8 @@ QObject* KItemListAccessibleCell::object() const
}
// Container Interface
KItemListContainerAccessible::KItemListContainerAccessible(KItemListContainer* container) :
QAccessibleWidget(container)
KItemListContainerAccessible::KItemListContainerAccessible(KItemListContainer *container)
: QAccessibleWidget(container)
{
}

View File

@ -73,7 +73,8 @@ protected:
inline QAccessibleInterface *cell(int index) const;
private:
class AccessibleIdWrapper {
class AccessibleIdWrapper
{
public:
AccessibleIdWrapper();
bool isValid;

View File

@ -27,28 +27,28 @@ KItemListWidgetInformant::~KItemListWidgetInformant()
{
}
KItemListWidget::KItemListWidget(KItemListWidgetInformant* informant, QGraphicsItem* parent) :
QGraphicsWidget(parent),
m_informant(informant),
m_index(-1),
m_selected(false),
m_current(false),
m_hovered(false),
m_expansionAreaHovered(false),
m_alternateBackground(false),
m_enabledSelectionToggle(false),
m_data(),
m_visibleRoles(),
m_columnWidths(),
m_styleOption(),
m_siblingsInfo(),
m_hoverOpacity(0),
m_hoverCache(nullptr),
m_hoverAnimation(nullptr),
m_hoverSequenceIndex(0),
m_selectionToggle(nullptr),
m_editedRole(),
m_iconSize(-1)
KItemListWidget::KItemListWidget(KItemListWidgetInformant *informant, QGraphicsItem *parent)
: QGraphicsWidget(parent)
, m_informant(informant)
, m_index(-1)
, m_selected(false)
, m_current(false)
, m_hovered(false)
, m_expansionAreaHovered(false)
, m_alternateBackground(false)
, m_enabledSelectionToggle(false)
, m_data()
, m_visibleRoles()
, m_columnWidths()
, m_styleOption()
, m_siblingsInfo()
, m_hoverOpacity(0)
, m_hoverCache(nullptr)
, m_hoverAnimation(nullptr)
, m_hoverSequenceIndex(0)
, m_selectionToggle(nullptr)
, m_editedRole()
, m_iconSize(-1)
{
connect(&m_hoverSequenceTimer, &QTimer::timeout, this, &KItemListWidget::slotHoverSequenceTimerTimeout);
}
@ -79,8 +79,7 @@ int KItemListWidget::index() const
return m_index;
}
void KItemListWidget::setData(const QHash<QByteArray, QVariant>& data,
const QSet<QByteArray>& roles)
void KItemListWidget::setData(const QHash<QByteArray, QVariant> &data, const QSet<QByteArray> &roles)
{
clearHoverCache();
if (roles.isEmpty()) {
@ -112,10 +111,7 @@ void KItemListWidget::paint(QPainter* painter, const QStyleOptionGraphicsItem* o
if (m_selected && m_editedRole.isEmpty()) {
const QStyle::State activeState(isActiveWindow() ? QStyle::State_Active : 0);
drawItemStyleOption(painter, widget, activeState |
QStyle::State_Enabled |
QStyle::State_Selected |
QStyle::State_Item);
drawItemStyleOption(painter, widget, activeState | QStyle::State_Enabled | QStyle::State_Selected | QStyle::State_Item);
}
if (m_current && m_editedRole.isEmpty()) {
@ -139,10 +135,7 @@ void KItemListWidget::paint(QPainter* painter, const QStyleOptionGraphicsItem* o
QPainter pixmapPainter(m_hoverCache);
const QStyle::State activeState(isActiveWindow() ? QStyle::State_Active : 0);
drawItemStyleOption(&pixmapPainter, widget, activeState |
QStyle::State_Enabled |
QStyle::State_MouseOver |
QStyle::State_Item);
drawItemStyleOption(&pixmapPainter, widget, activeState | QStyle::State_Enabled | QStyle::State_MouseOver | QStyle::State_Item);
}
const qreal opacity = painter->opacity();
@ -166,7 +159,6 @@ QList<QByteArray> KItemListWidget::visibleRoles() const
return m_visibleRoles;
}
void KItemListWidget::setColumnWidth(const QByteArray &role, qreal width)
{
const qreal previousWidth = m_columnWidths.value(role);
@ -182,11 +174,13 @@ qreal KItemListWidget::columnWidth(const QByteArray& role) const
return m_columnWidths.value(role);
}
qreal KItemListWidget::sidePadding() const {
qreal KItemListWidget::sidePadding() const
{
return m_sidePadding;
}
void KItemListWidget::setSidePadding(qreal width) {
void KItemListWidget::setSidePadding(qreal width)
{
if (m_sidePadding != width) {
m_sidePadding = width;
sidePaddingChanged(width);
@ -400,10 +394,7 @@ bool KItemListWidget::contains(const QPointF& point) const
return false;
}
return iconRect().contains(point) ||
textRect().contains(point) ||
expansionToggleRect().contains(point) ||
selectionToggleRect().contains(point);
return iconRect().contains(point) || textRect().contains(point) || expansionToggleRect().contains(point) || selectionToggleRect().contains(point);
}
QRectF KItemListWidget::textFocusRect() const
@ -421,8 +412,7 @@ QRectF KItemListWidget::expansionToggleRect() const
return QRectF();
}
QPixmap KItemListWidget::createDragPixmap(const QStyleOptionGraphicsItem* option,
QWidget* widget)
QPixmap KItemListWidget::createDragPixmap(const QStyleOptionGraphicsItem *option, QWidget *widget)
{
QPixmap pixmap(size().toSize() * widget->devicePixelRatio());
pixmap.setDevicePixelRatio(widget->devicePixelRatio());
@ -446,23 +436,19 @@ QPixmap KItemListWidget::createDragPixmap(const QStyleOptionGraphicsItem* option
return pixmap;
}
void KItemListWidget::dataChanged(const QHash<QByteArray, QVariant>& current,
const QSet<QByteArray>& roles)
void KItemListWidget::dataChanged(const QHash<QByteArray, QVariant> &current, const QSet<QByteArray> &roles)
{
Q_UNUSED(current)
Q_UNUSED(roles)
}
void KItemListWidget::visibleRolesChanged(const QList<QByteArray>& current,
const QList<QByteArray>& previous)
void KItemListWidget::visibleRolesChanged(const QList<QByteArray> &current, const QList<QByteArray> &previous)
{
Q_UNUSED(current)
Q_UNUSED(previous)
}
void KItemListWidget::columnWidthChanged(const QByteArray& role,
qreal current,
qreal previous)
void KItemListWidget::columnWidthChanged(const QByteArray &role, qreal current, qreal previous)
{
Q_UNUSED(role)
Q_UNUSED(current)
@ -474,8 +460,7 @@ void KItemListWidget::sidePaddingChanged(qreal width)
Q_UNUSED(width)
}
void KItemListWidget::styleOptionChanged(const KItemListStyleOption& current,
const KItemListStyleOption& previous)
void KItemListWidget::styleOptionChanged(const KItemListStyleOption &current, const KItemListStyleOption &previous)
{
Q_UNUSED(previous)
@ -618,4 +603,3 @@ void KItemListWidget::drawItemStyleOption(QPainter* painter, QWidget* widget, QS
viewItemOption.rect = selectionRect().toRect();
style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &viewItemOption, painter, widget);
}

View File

@ -37,9 +37,7 @@ public:
virtual void calculateItemSizeHints(QVector<std::pair<qreal, bool>> &logicalHeightHints, qreal &logicalWidthHint, const KItemListView *view) const = 0;
virtual qreal preferredRoleColumnWidth(const QByteArray& role,
int index,
const KItemListView* view) const = 0;
virtual qreal preferredRoleColumnWidth(const QByteArray &role, int index, const KItemListView *view) const = 0;
};
/**
@ -282,5 +280,3 @@ inline const KItemListWidgetInformant* KItemListWidget::informant() const
}
#endif

View File

@ -8,19 +8,19 @@
#include "kitemmodelbase.h"
KItemModelBase::KItemModelBase(QObject* parent) :
QObject(parent),
m_groupedSorting(false),
m_sortRole(),
m_sortOrder(Qt::AscendingOrder)
KItemModelBase::KItemModelBase(QObject *parent)
: QObject(parent)
, m_groupedSorting(false)
, m_sortRole()
, m_sortOrder(Qt::AscendingOrder)
{
}
KItemModelBase::KItemModelBase(const QByteArray& sortRole, QObject* parent) :
QObject(parent),
m_groupedSorting(false),
m_sortRole(sortRole),
m_sortOrder(Qt::AscendingOrder)
KItemModelBase::KItemModelBase(const QByteArray &sortRole, QObject *parent)
: QObject(parent)
, m_groupedSorting(false)
, m_sortRole(sortRole)
, m_sortOrder(Qt::AscendingOrder)
{
}

View File

@ -279,5 +279,3 @@ inline Qt::SortOrder KItemModelBase::sortOrder() const
}
#endif

View File

@ -12,8 +12,7 @@
#include <QList>
struct KItemRange
{
struct KItemRange {
KItemRange(int index = 0, int count = 0);
int index;
int count;
@ -21,9 +20,9 @@ struct KItemRange
bool operator==(const KItemRange &other) const;
};
inline KItemRange::KItemRange(int index, int count) :
index(index),
count(count)
inline KItemRange::KItemRange(int index, int count)
: index(index)
, count(count)
{
}
@ -32,12 +31,17 @@ inline bool KItemRange::operator == (const KItemRange& other) const
return index == other.index && count == other.count;
}
class KItemRangeList : public QList<KItemRange>
{
public:
KItemRangeList() : QList<KItemRange>() {}
explicit KItemRangeList(const QList<KItemRange>& list) : QList<KItemRange>(list) {}
KItemRangeList()
: QList<KItemRange>()
{
}
explicit KItemRangeList(const QList<KItemRange> &list)
: QList<KItemRange>(list)
{
}
template<class Container>
static KItemRangeList fromSortedContainer(const Container &container);

View File

@ -6,7 +6,6 @@
#include "kitemset.h"
KItemSet::iterator KItemSet::insert(int i)
{
if (m_itemRanges.empty()) {
@ -170,8 +169,7 @@ KItemSet KItemSet::operator+(const KItemSet& other) const
count = qMax(count, it2->index + it2->count - index);
++it2;
}
} while ((it1 != end1 && it1->index <= index + count)
|| (it2 != end2 && it2->index <= index + count));
} while ((it1 != end1 && it1->index <= index + count) || (it2 != end2 && it2->index <= index + count));
sum.m_itemRanges.append(KItemRange(index, count));
}

View File

@ -4,7 +4,6 @@
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef KITEMSET_H
#define KITEMSET_H
@ -51,16 +50,16 @@ public:
class iterator
{
iterator(const KItemRangeList::iterator& rangeIt, int offset) :
m_rangeIt(rangeIt),
m_offset(offset)
iterator(const KItemRangeList::iterator &rangeIt, int offset)
: m_rangeIt(rangeIt)
, m_offset(offset)
{
}
public:
iterator(const iterator& other) :
m_rangeIt(other.m_rangeIt),
m_offset(other.m_offset)
iterator(const iterator &other)
: m_rangeIt(other.m_rangeIt)
, m_offset(other.m_offset)
{
}
@ -134,25 +133,24 @@ public:
friend class KItemSet;
};
class const_iterator
{
const_iterator(KItemRangeList::const_iterator rangeIt, int offset) :
m_rangeIt(rangeIt),
m_offset(offset)
const_iterator(KItemRangeList::const_iterator rangeIt, int offset)
: m_rangeIt(rangeIt)
, m_offset(offset)
{
}
public:
const_iterator(const const_iterator& other) :
m_rangeIt(other.m_rangeIt),
m_offset(other.m_offset)
const_iterator(const const_iterator &other)
: m_rangeIt(other.m_rangeIt)
, m_offset(other.m_offset)
{
}
explicit const_iterator(const iterator& other) :
m_rangeIt(other.m_rangeIt),
m_offset(other.m_offset)
explicit const_iterator(const iterator &other)
: m_rangeIt(other.m_rangeIt)
, m_offset(other.m_offset)
{
}
@ -282,13 +280,13 @@ private:
friend class KItemSetTest;
};
inline KItemSet::KItemSet() :
m_itemRanges()
inline KItemSet::KItemSet()
: m_itemRanges()
{
}
inline KItemSet::KItemSet(const KItemSet& other) :
m_itemRanges(other.m_itemRanges)
inline KItemSet::KItemSet(const KItemSet &other)
: m_itemRanges(other.m_itemRanges)
{
}

View File

@ -11,13 +11,12 @@
#include <KRatingPainter>
#include <QPainter>
KStandardItemListGroupHeader::KStandardItemListGroupHeader(QGraphicsWidget* parent) :
KItemListGroupHeader(parent),
m_dirtyCache(true),
m_text(),
m_pixmap()
KStandardItemListGroupHeader::KStandardItemListGroupHeader(QGraphicsWidget *parent)
: KItemListGroupHeader(parent)
, m_dirtyCache(true)
, m_text()
, m_pixmap()
{
}
KStandardItemListGroupHeader::~KStandardItemListGroupHeader()
@ -110,4 +109,3 @@ void KStandardItemListGroupHeader::updateCache()
m_text = text;
}
}

View File

@ -38,5 +38,3 @@ private:
QPixmap m_pixmap;
};
#endif

View File

@ -10,9 +10,9 @@
#include <KIconLoader>
KStandardItemListView::KStandardItemListView(QGraphicsWidget* parent) :
KItemListView(parent),
m_itemLayout(DetailsLayout)
KStandardItemListView::KStandardItemListView(QGraphicsWidget *parent)
: KItemListView(parent)
, m_itemLayout(DetailsLayout)
{
setAcceptDrops(true);
setScrollOrientation(Qt::Vertical);
@ -66,17 +66,24 @@ void KStandardItemListView::initializeItemListWidget(KItemListWidget* item)
Q_ASSERT(standardItemListWidget);
switch (itemLayout()) {
case IconsLayout: standardItemListWidget->setLayout(KStandardItemListWidget::IconsLayout); break;
case CompactLayout: standardItemListWidget->setLayout(KStandardItemListWidget::CompactLayout); break;
case DetailsLayout: standardItemListWidget->setLayout(KStandardItemListWidget::DetailsLayout); break;
default: Q_ASSERT(false); break;
case IconsLayout:
standardItemListWidget->setLayout(KStandardItemListWidget::IconsLayout);
break;
case CompactLayout:
standardItemListWidget->setLayout(KStandardItemListWidget::CompactLayout);
break;
case DetailsLayout:
standardItemListWidget->setLayout(KStandardItemListWidget::DetailsLayout);
break;
default:
Q_ASSERT(false);
break;
}
standardItemListWidget->setHighlightEntireRow(highlightEntireRow());
standardItemListWidget->setSupportsItemExpanding(supportsItemExpanding());
}
bool KStandardItemListView::itemSizeHintUpdateRequired(const QSet<QByteArray> &changedRoles) const
{
// 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();
}
void KStandardItemListView::polishEvent()
{
switch (m_itemLayout) {
case IconsLayout: applyDefaultStyleOption(style()->pixelMetric(QStyle::PM_LargeIconSize), 2, 4, 8); 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;
case IconsLayout:
applyDefaultStyleOption(style()->pixelMetric(QStyle::PM_LargeIconSize), 2, 4, 8);
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();
}
void KStandardItemListView::applyDefaultStyleOption(int iconSize,
int padding,
int horizontalMargin,
int verticalMargin)
void KStandardItemListView::applyDefaultStyleOption(int iconSize, int padding, int horizontalMargin, int verticalMargin)
{
KItemListStyleOption option = styleOption();
@ -168,4 +179,3 @@ void KStandardItemListView::updateLayoutOfVisibleItems()
}
}
}

View File

@ -31,12 +31,7 @@ class DOLPHIN_EXPORT KStandardItemListView : public KItemListView
Q_OBJECT
public:
enum ItemLayout
{
IconsLayout,
CompactLayout,
DetailsLayout
};
enum ItemLayout { IconsLayout, CompactLayout, DetailsLayout };
explicit KStandardItemListView(QGraphicsWidget *parent = nullptr);
~KStandardItemListView() override;
@ -66,5 +61,3 @@ private:
};
#endif

View File

@ -26,8 +26,8 @@
// #define KSTANDARDITEMLISTWIDGET_DEBUG
KStandardItemListWidgetInformant::KStandardItemListWidgetInformant() :
KItemListWidgetInformant()
KStandardItemListWidgetInformant::KStandardItemListWidgetInformant()
: 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()) {
case KStandardItemListView::IconsLayout:
@ -56,9 +58,7 @@ void KStandardItemListWidgetInformant::calculateItemSizeHints(QVector<std::pair<
}
}
qreal KStandardItemListWidgetInformant::preferredRoleColumnWidth(const QByteArray& role,
int index,
const KItemListView* view) const
qreal KStandardItemListWidgetInformant::preferredRoleColumnWidth(const QByteArray &role, int index, const KItemListView *view) const
{
const QHash<QByteArray, QVariant> values = view->model()->data(index);
const KItemListStyleOption &option = view->styleOption();
@ -105,8 +105,7 @@ bool KStandardItemListWidgetInformant::itemIsLink(int index, const KItemListView
return false;
}
QString KStandardItemListWidgetInformant::roleText(const QByteArray& role,
const QHash<QByteArray, QVariant>& values) const
QString KStandardItemListWidgetInformant::roleText(const QByteArray &role, const QHash<QByteArray, QVariant> &values) const
{
if (role == "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;
}
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 QFont &normalFont = option.font;
@ -177,7 +178,9 @@ void KStandardItemListWidgetInformant::calculateIconsLayoutItemSizeHints(QVector
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 QFontMetrics &normalFontMetrics = option.fontMetrics;
@ -225,7 +228,9 @@ void KStandardItemListWidgetInformant::calculateCompactLayoutItemSizeHints(QVect
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 qreal height = option.padding * 2 + qMax(option.iconSize, option.fontMetrics.height());
@ -233,35 +238,35 @@ void KStandardItemListWidgetInformant::calculateDetailsLayoutItemSizeHints(QVect
logicalWidthHint = -1.0;
}
KStandardItemListWidget::KStandardItemListWidget(KItemListWidgetInformant* informant, QGraphicsItem* parent) :
KItemListWidget(informant, parent),
m_textInfo(),
m_isCut(false),
m_isHidden(false),
m_customizedFont(),
m_customizedFontMetrics(m_customizedFont),
m_isExpandable(false),
m_highlightEntireRow(false),
m_supportsItemExpanding(false),
m_dirtyLayout(true),
m_dirtyContent(true),
m_dirtyContentRoles(),
m_layout(IconsLayout),
m_pixmapPos(),
m_pixmap(),
m_scaledPixmapSize(),
m_columnWidthSum(),
m_iconRect(),
m_hoverPixmap(),
m_textRect(),
m_sortedVisibleRoles(),
m_expansionArea(),
m_customTextColor(),
m_additionalInfoTextColor(),
m_overlay(),
m_rating(),
m_roleEditor(nullptr),
m_oldRoleEditor(nullptr)
KStandardItemListWidget::KStandardItemListWidget(KItemListWidgetInformant *informant, QGraphicsItem *parent)
: KItemListWidget(informant, parent)
, m_textInfo()
, m_isCut(false)
, m_isHidden(false)
, m_customizedFont()
, m_customizedFontMetrics(m_customizedFont)
, m_isExpandable(false)
, m_highlightEntireRow(false)
, m_supportsItemExpanding(false)
, m_dirtyLayout(true)
, m_dirtyContent(true)
, m_dirtyContentRoles()
, m_layout(IconsLayout)
, m_pixmapPos()
, m_pixmap()
, m_scaledPixmapSize()
, m_columnWidthSum()
, m_iconRect()
, m_hoverPixmap()
, m_textRect()
, m_sortedVisibleRoles()
, m_expansionArea()
, m_customTextColor()
, m_additionalInfoTextColor()
, m_overlay()
, m_rating()
, m_roleEditor(nullptr)
, m_oldRoleEditor(nullptr)
{
}
@ -294,7 +299,8 @@ KStandardItemListWidget::Layout KStandardItemListWidget::layout() const
return m_layout;
}
void KStandardItemListWidget::setHighlightEntireRow(bool highlightEntireRow) {
void KStandardItemListWidget::setHighlightEntireRow(bool highlightEntireRow)
{
if (m_highlightEntireRow != highlightEntireRow) {
m_highlightEntireRow = highlightEntireRow;
m_dirtyLayout = true;
@ -302,7 +308,8 @@ void KStandardItemListWidget::setHighlightEntireRow(bool highlightEntireRow) {
}
}
bool KStandardItemListWidget::highlightEntireRow() const {
bool KStandardItemListWidget::highlightEntireRow() const
{
return m_highlightEntireRow;
}
@ -564,8 +571,7 @@ QRectF KStandardItemListWidget::selectionToggleRect() const
return QRectF(pos, QSizeF(toggleSize, toggleSize));
}
QPixmap KStandardItemListWidget::createDragPixmap(const QStyleOptionGraphicsItem* option,
QWidget* widget)
QPixmap KStandardItemListWidget::createDragPixmap(const QStyleOptionGraphicsItem *option, QWidget *widget)
{
QPixmap pixmap = KItemListWidget::createDragPixmap(option, widget);
if (m_layout != DetailsLayout) {
@ -576,9 +582,7 @@ QPixmap KStandardItemListWidget::createDragPixmap(const QStyleOptionGraphicsItem
const int leftClip = m_pixmapPos.x();
const TextInfo *textInfo = m_textInfo.value("text");
const int rightClip = textInfo->pos.x() +
textInfo->staticText.size().width() +
2 * styleOption().padding;
const int rightClip = textInfo->pos.x() + textInfo->staticText.size().width() + 2 * styleOption().padding;
QPixmap clippedPixmap(rightClip - leftClip + 1, pixmap.height());
clippedPixmap.fill(Qt::transparent);
@ -589,7 +593,6 @@ QPixmap KStandardItemListWidget::createDragPixmap(const QStyleOptionGraphicsItem
return clippedPixmap;
}
KItemListWidgetInformant *KStandardItemListWidget::createInformant()
{
return new KStandardItemListWidgetInformant();
@ -669,15 +672,12 @@ QPixmap KStandardItemListWidget::overlay() const
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);
}
void KStandardItemListWidget::dataChanged(const QHash<QByteArray, QVariant>& current,
const QSet<QByteArray>& roles)
void KStandardItemListWidget::dataChanged(const QHash<QByteArray, QVariant> &current, const QSet<QByteArray> &roles)
{
Q_UNUSED(current)
@ -709,17 +709,14 @@ void KStandardItemListWidget::dataChanged(const QHash<QByteArray, QVariant>& cur
}
}
void KStandardItemListWidget::visibleRolesChanged(const QList<QByteArray>& current,
const QList<QByteArray>& previous)
void KStandardItemListWidget::visibleRolesChanged(const QList<QByteArray> &current, const QList<QByteArray> &previous)
{
Q_UNUSED(previous)
m_sortedVisibleRoles = current;
m_dirtyLayout = true;
}
void KStandardItemListWidget::columnWidthChanged(const QByteArray& role,
qreal current,
qreal previous)
void KStandardItemListWidget::columnWidthChanged(const QByteArray &role, qreal current, qreal previous)
{
Q_UNUSED(role)
Q_UNUSED(current)
@ -727,13 +724,13 @@ void KStandardItemListWidget::columnWidthChanged(const QByteArray& role,
m_dirtyLayout = true;
}
void KStandardItemListWidget::sidePaddingChanged(qreal padding) {
void KStandardItemListWidget::sidePaddingChanged(qreal padding)
{
Q_UNUSED(padding)
m_dirtyLayout = true;
}
void KStandardItemListWidget::styleOptionChanged(const KItemListStyleOption& current,
const KItemListStyleOption& previous)
void KStandardItemListWidget::styleOptionChanged(const KItemListStyleOption &current, const KItemListStyleOption &previous)
{
KItemListWidget::styleOptionChanged(current, previous);
@ -775,10 +772,8 @@ void KStandardItemListWidget::editedRoleChanged(const QByteArray& current, const
if (m_roleEditor) {
Q_EMIT roleEditingCanceled(index(), current, data().value(current));
disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled,
this, &KStandardItemListWidget::slotRoleEditingCanceled);
disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished,
this, &KStandardItemListWidget::slotRoleEditingFinished);
disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled, this, &KStandardItemListWidget::slotRoleEditingCanceled);
disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished, this, &KStandardItemListWidget::slotRoleEditingFinished);
if (m_oldRoleEditor) {
m_oldRoleEditor->deleteLater();
@ -814,10 +809,8 @@ void KStandardItemListWidget::editedRoleChanged(const QByteArray& current, const
m_roleEditor->setTextCursor(cursor);
}
connect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled,
this, &KStandardItemListWidget::slotRoleEditingCanceled);
connect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished,
this, &KStandardItemListWidget::slotRoleEditingFinished);
connect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled, this, &KStandardItemListWidget::slotRoleEditingCanceled);
connect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished, this, &KStandardItemListWidget::slotRoleEditingFinished);
// Adjust the geometry of the editor
QRectF rect = roleEditingRect(current);
@ -863,22 +856,19 @@ void KStandardItemListWidget::showEvent(QShowEvent* event)
const QUrl itemUrl = data().value("url").toUrl();
m_isCut = clipboard->isCut(itemUrl);
connect(clipboard, &KFileItemClipboard::cutItemsChanged,
this, &KStandardItemListWidget::slotCutItemsChanged);
connect(clipboard, &KFileItemClipboard::cutItemsChanged, this, &KStandardItemListWidget::slotCutItemsChanged);
}
void KStandardItemListWidget::hideEvent(QHideEvent *event)
{
disconnect(KFileItemClipboard::instance(), &KFileItemClipboard::cutItemsChanged,
this, &KStandardItemListWidget::slotCutItemsChanged);
disconnect(KFileItemClipboard::instance(), &KFileItemClipboard::cutItemsChanged, this, &KStandardItemListWidget::slotCutItemsChanged);
KItemListWidget::hideEvent(event);
}
bool KStandardItemListWidget::event(QEvent *event)
{
if (event->type() == QEvent::WindowDeactivate || event->type() == QEvent::WindowActivate
|| event->type() == QEvent::PaletteChange) {
if (event->type() == QEvent::WindowDeactivate || event->type() == QEvent::WindowActivate || event->type() == QEvent::PaletteChange) {
m_dirtyContent = true;
}
@ -904,16 +894,14 @@ void KStandardItemListWidget::slotCutItemsChanged()
}
}
void KStandardItemListWidget::slotRoleEditingCanceled(const QByteArray& role,
const QVariant& value)
void KStandardItemListWidget::slotRoleEditingCanceled(const QByteArray &role, const QVariant &value)
{
closeRoleEditor();
Q_EMIT roleEditingCanceled(index(), role, value);
setEditedRole(QByteArray());
}
void KStandardItemListWidget::slotRoleEditingFinished(const QByteArray& role,
const QVariant& value)
void KStandardItemListWidget::slotRoleEditingFinished(const QByteArray &role, const QVariant &value)
{
closeRoleEditor();
Q_EMIT roleEditingFinished(index(), role, value);
@ -933,8 +921,9 @@ void KStandardItemListWidget::triggerCacheRefreshing()
m_isHidden = isHidden();
m_customizedFont = customizedFont(styleOption().font);
m_customizedFontMetrics = QFontMetrics(m_customizedFont);
m_columnWidthSum = std::accumulate(m_sortedVisibleRoles.begin(), m_sortedVisibleRoles.end(),
qreal(), [this](qreal sum, const auto &role){ return sum + columnWidth(role); });
m_columnWidthSum = std::accumulate(m_sortedVisibleRoles.begin(), m_sortedVisibleRoles.end(), qreal(), [this](qreal sum, const auto &role) {
return sum + columnWidth(role);
});
updateExpansionArea();
updateTextsCache();
@ -984,9 +973,7 @@ void KStandardItemListWidget::updatePixmapCache()
bool updatePixmap = (m_pixmap.width() != maxIconWidth || m_pixmap.height() != maxIconHeight);
if (!updatePixmap && m_dirtyContent) {
updatePixmap = m_dirtyContentRoles.isEmpty()
|| m_dirtyContentRoles.contains("iconPixmap")
|| m_dirtyContentRoles.contains("iconName")
updatePixmap = m_dirtyContentRoles.isEmpty() || m_dirtyContentRoles.contains("iconPixmap") || m_dirtyContentRoles.contains("iconName")
|| m_dirtyContentRoles.contains("iconOverlays");
}
@ -1028,7 +1015,8 @@ void KStandardItemListWidget::updatePixmapCache()
iconName = QStringLiteral("unknown");
}
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) {
// A custom pixmap has been applied. Assure that the pixmap
@ -1074,8 +1062,7 @@ void KStandardItemListWidget::updatePixmapCache()
} else {
const int textRowsCount = (m_layout == CompactLayout) ? visibleRoles().count() : 1;
const qreal requiredTextHeight = textRowsCount * m_customizedFontMetrics.height();
scaledIconSize = (requiredTextHeight < maxIconHeight) ?
widgetSize.height() - 2 * padding : maxIconHeight;
scaledIconSize = (requiredTextHeight < maxIconHeight) ? widgetSize.height() - 2 * padding : maxIconHeight;
}
const int maxScaledIconWidth = iconOnTop ? widgetSize.width() - 2 * padding : scaledIconSize;
@ -1092,16 +1079,12 @@ void KStandardItemListWidget::updatePixmapCache()
} else {
// Center horizontally and vertically within the icon-area
const TextInfo *textInfo = m_textInfo.value("text");
m_pixmapPos.setX(textInfo->pos.x() - 2.0 * padding
- (scaledIconSize + m_scaledPixmapSize.width()) / 2.0);
m_pixmapPos.setX(textInfo->pos.x() - 2.0 * padding - (scaledIconSize + m_scaledPixmapSize.width()) / 2.0);
// 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
const qreal midlineShift = m_customizedFontMetrics.height() / 2.0
- m_customizedFontMetrics.descent()
- m_customizedFontMetrics.capHeight() / 2.0;
const qreal midlineShift = m_customizedFontMetrics.height() / 2.0 - m_customizedFontMetrics.descent() - m_customizedFontMetrics.capHeight() / 2.0;
m_pixmapPos.setY(m_textRect.center().y() + midlineShift - m_scaledPixmapSize.height() / 2.0);
}
if (m_layout == IconsLayout) {
@ -1109,8 +1092,7 @@ void KStandardItemListWidget::updatePixmapCache()
} else {
const qreal widthOffset = widgetIconSize - m_scaledPixmapSize.width();
const qreal heightOffset = widgetIconSize - m_scaledPixmapSize.height();
const QPointF squareIconPos(m_pixmapPos.x() - 0.5 * widthOffset,
m_pixmapPos.y() - 0.5 * heightOffset);
const QPointF squareIconPos(m_pixmapPos.x() - 0.5 * widthOffset, m_pixmapPos.y() - 0.5 * heightOffset);
const QSizeF squareIconSize(widgetIconSize, widgetIconSize);
m_iconRect = QRectF(squareIconPos, squareIconSize);
}
@ -1160,10 +1142,18 @@ void KStandardItemListWidget::updateTextsCache()
}
switch (m_layout) {
case IconsLayout: updateIconsLayoutTextCache(); break;
case CompactLayout: updateCompactLayoutTextCache(); break;
case DetailsLayout: updateDetailsLayoutTextCache(); break;
default: Q_ASSERT(false); break;
case IconsLayout:
updateIconsLayoutTextCache();
break;
case CompactLayout:
updateCompactLayoutTextCache();
break;
case DetailsLayout:
updateDetailsLayoutTextCache();
break;
default:
Q_ASSERT(false);
break;
}
const TextInfo *ratingTextInfo = m_textInfo.value("rating");
@ -1173,9 +1163,7 @@ void KStandardItemListWidget::updateTextsCache()
const KItemListStyleOption &option = styleOption();
QSizeF ratingSize = preferredRatingSize(option);
const qreal availableWidth = (m_layout == DetailsLayout)
? columnWidth("rating") - columnPadding(option)
: size().width();
const qreal availableWidth = (m_layout == DetailsLayout) ? columnWidth("rating") - columnPadding(option) : size().width();
if (ratingSize.width() > availableWidth) {
ratingSize.rwidth() = availableWidth;
}
@ -1202,9 +1190,7 @@ QString KStandardItemListWidget::elideRightKeepExtension(const QString &text, in
const auto extensionWidth = m_customizedFontMetrics.horizontalAdvance(text.right(extensionLength));
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
QString ret = m_customizedFontMetrics.elidedText(text.chopped(extensionLength),
Qt::ElideRight,
elidingWidth - extensionWidth);
QString ret = m_customizedFontMetrics.elidedText(text.chopped(extensionLength), Qt::ElideRight, elidingWidth - extensionWidth);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
ret.append(text.rightRef(extensionLength));
#else
@ -1213,8 +1199,7 @@ QString KStandardItemListWidget::elideRightKeepExtension(const QString &text, in
return ret;
}
}
return m_customizedFontMetrics.elidedText(text,Qt::ElideRight,
elidingWidth);
return m_customizedFontMetrics.elidedText(text, Qt::ElideRight, elidingWidth);
}
void KStandardItemListWidget::updateIconsLayoutTextCache()
@ -1289,10 +1274,7 @@ void KStandardItemListWidget::updateIconsLayoutTextCache()
// Use one line for each additional information
nameTextInfo->staticText.setTextWidth(maxWidth);
nameTextInfo->pos = QPointF(padding, iconSize() + 2 * padding);
m_textRect = QRectF(padding + (maxWidth - nameWidth) / 2,
nameTextInfo->pos.y(),
nameWidth,
nameHeight);
m_textRect = QRectF(padding + (maxWidth - nameWidth) / 2, nameTextInfo->pos.y(), nameWidth, nameHeight);
// Calculate the position for each additional information
qreal y = nameTextInfo->pos.y() + nameHeight;
@ -1436,11 +1418,8 @@ void KStandardItemListWidget::updateDetailsLayoutTextCache()
x += roleWidth;
if (isTextRole) {
const qreal textWidth = option.extendedSelectionRegion
? size().width() - textInfo->pos.x()
: requiredWidth + 2 * option.padding;
m_textRect = QRectF(textInfo->pos.x() - option.padding, 0,
textWidth, size().height());
const qreal textWidth = option.extendedSelectionRegion ? size().width() - textInfo->pos.x() : 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
// from the expansion-level shown in the name column
@ -1471,9 +1450,8 @@ void KStandardItemListWidget::updateAdditionalInfoTextColor()
const QColor c2 = styleOption().palette.base().color();
const int p1 = 70;
const int p2 = 100 - p1;
m_additionalInfoTextColor = QColor((c1.red() * p1 + c2.red() * p2) / 100,
(c1.green() * p1 + c2.green() * p2) / 100,
(c1.blue() * p1 + c2.blue() * p2) / 100);
m_additionalInfoTextColor =
QColor((c1.red() * p1 + c2.red() * p2) / 100, (c1.green() * p1 + c2.green() * p2) / 100, (c1.blue() * p1 + c2.blue() * p2) / 100);
}
void KStandardItemListWidget::drawPixmap(QPainter *painter, const QPixmap &pixmap)
@ -1545,10 +1523,8 @@ QRectF KStandardItemListWidget::roleEditingRect(const QByteArray& role) const
void KStandardItemListWidget::closeRoleEditor()
{
disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled,
this, &KStandardItemListWidget::slotRoleEditingCanceled);
disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished,
this, &KStandardItemListWidget::slotRoleEditingFinished);
disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled, this, &KStandardItemListWidget::slotRoleEditingCanceled);
disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished, this, &KStandardItemListWidget::slotRoleEditingFinished);
if (m_roleEditor->hasFocus()) {
// 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()) {
icon = QIcon(name);
}
if (icon.isNull()
|| icon.pixmap(size / qApp->devicePixelRatio(), size / qApp->devicePixelRatio(), mode).isNull()) {
if (icon.isNull() || icon.pixmap(size / qApp->devicePixelRatio(), size / qApp->devicePixelRatio(), mode).isNull()) {
icon = fallbackIcon;
}
@ -1635,4 +1610,3 @@ qreal KStandardItemListWidget::columnPadding(const KItemListStyleOption& option)
{
return option.padding * 6;
}

View File

@ -24,12 +24,12 @@ public:
KStandardItemListWidgetInformant();
~KStandardItemListWidgetInformant() override;
void calculateItemSizeHints(QVector<std::pair<qreal /* height */, bool /* isElided */>>& logicalHeightHints, qreal& logicalWidthHint, const KItemListView* view) const override;
qreal preferredRoleColumnWidth(const QByteArray& role,
int index,
void calculateItemSizeHints(QVector<std::pair<qreal /* height */, bool /* isElided */>> &logicalHeightHints,
qreal &logicalWidthHint,
const KItemListView *view) const override;
qreal preferredRoleColumnWidth(const QByteArray &role, int index, const KItemListView *view) const override;
protected:
/**
* @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
* are passed as parameter.
*/
virtual QString roleText(const QByteArray& role,
const QHash<QByteArray, QVariant>& values) const;
virtual QString roleText(const QByteArray &role, const QHash<QByteArray, QVariant> &values) const;
/**
* @return A font based on baseFont which is customized for symlinks.
@ -75,12 +74,7 @@ class DOLPHIN_EXPORT KStandardItemListWidget : public KItemListWidget
Q_OBJECT
public:
enum Layout
{
IconsLayout,
CompactLayout,
DetailsLayout
};
enum Layout { IconsLayout, CompactLayout, DetailsLayout };
KStandardItemListWidget(KItemListWidgetInformant *informant, QGraphicsItem *parent);
~KStandardItemListWidget() override;
@ -183,8 +177,7 @@ protected:
void hideEvent(QHideEvent *event) override;
bool event(QEvent *event) override;
struct TextInfo
{
struct TextInfo {
QPointF pos;
QStaticText staticText;
};

View File

@ -14,7 +14,8 @@
#include <QCollator>
#include <QSize>
namespace {
namespace
{
QString tagsFromValues(const QStringList &values)
{
if (values.size() == 1) {
@ -24,7 +25,9 @@ namespace {
QStringList alphabeticalOrderTags = values;
QCollator coll;
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(", "));
}
@ -58,13 +61,11 @@ namespace {
}
}
struct KBalooRolesProviderSingleton
{
struct KBalooRolesProviderSingleton {
KBalooRolesProvider instance;
};
Q_GLOBAL_STATIC(KBalooRolesProviderSingleton, s_balooRolesProvider)
KBalooRolesProvider &KBalooRolesProvider::instance()
{
return s_balooRolesProvider->instance;
@ -79,8 +80,7 @@ QSet<QByteArray> KBalooRolesProvider::roles() const
return m_roles;
}
QHash<QByteArray, QVariant> KBalooRolesProvider::roleValues(const Baloo::File& file,
const QSet<QByteArray>& roles) const
QHash<QByteArray, QVariant> KBalooRolesProvider::roleValues(const Baloo::File &file, const QSet<QByteArray> &roles) const
{
QHash<QByteArray, QVariant> values;
@ -92,8 +92,9 @@ QHash<QByteArray, QVariant> KBalooRolesProvider::roleValues(const Baloo::File& f
while (rangeBegin != propMap.constKeyValueEnd()) {
auto key = (*rangeBegin).first;
auto rangeEnd = std::find_if(rangeBegin, propMap.constKeyValueEnd(),
[key](const entry& e) { return e.first != key; });
auto rangeEnd = std::find_if(rangeBegin, propMap.constKeyValueEnd(), [key](const entry &e) {
return e.first != key;
});
const QByteArray role = propertyRoleMap().value(key);
if (role.isEmpty() || !roles.contains(role)) {
@ -106,7 +107,9 @@ QHash<QByteArray, QVariant> KBalooRolesProvider::roleValues(const Baloo::File& f
if (distance > 1) {
QVariantList list;
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));
} else {
if (propertyInfo.valueType() == QVariant::DateTime) {
@ -182,4 +185,3 @@ KBalooRolesProvider::KBalooRolesProvider()
m_roles.insert(QByteArrayLiteral("comment"));
m_roles.insert(QByteArrayLiteral("originUrl"));
}

View File

@ -14,7 +14,8 @@
#include <QSet>
#include <QVariant>
namespace Baloo {
namespace Baloo
{
class File;
}
@ -39,8 +40,7 @@ public:
* @return Values for the roles \a roles that can be determined from the file
* with the URL \a url.
*/
QHash<QByteArray, QVariant> roleValues(const Baloo::File& file,
const QSet<QByteArray>& roles) const;
QHash<QByteArray, QVariant> roleValues(const Baloo::File &file, const QSet<QByteArray> &roles) const;
protected:
KBalooRolesProvider();
@ -52,4 +52,3 @@ private:
};
#endif

View File

@ -10,26 +10,26 @@
#include <KDirWatch>
#include <QFileInfo>
#include <QDir>
#include <QFileInfo>
#include <QThread>
namespace {
namespace
{
/// cache of directory counting result
static QHash<QString, QPair<int, long>> *s_cache;
}
KDirectoryContentsCounter::KDirectoryContentsCounter(KFileItemModel* model, QObject* parent) :
QObject(parent),
m_model(model),
m_queue(),
m_worker(nullptr),
m_workerIsBusy(false),
m_dirWatcher(nullptr),
m_watchedDirs()
KDirectoryContentsCounter::KDirectoryContentsCounter(KFileItemModel *model, QObject *parent)
: QObject(parent)
, m_model(model)
, m_queue()
, m_worker(nullptr)
, m_workerIsBusy(false)
, m_dirWatcher(nullptr)
, m_watchedDirs()
{
connect(m_model, &KFileItemModel::itemsRemoved,
this, &KDirectoryContentsCounter::slotItemsRemoved);
connect(m_model, &KFileItemModel::itemsRemoved, this, &KDirectoryContentsCounter::slotItemsRemoved);
if (!m_workerThread) {
m_workerThread = new QThread();
@ -43,10 +43,8 @@ KDirectoryContentsCounter::KDirectoryContentsCounter(KFileItemModel* model, QObj
m_worker = new KDirectoryContentsCounterWorker();
m_worker->moveToThread(m_workerThread);
connect(this, &KDirectoryContentsCounter::requestDirectoryContentsCount,
m_worker, &KDirectoryContentsCounterWorker::countDirectoryContents);
connect(m_worker, &KDirectoryContentsCounterWorker::result,
this, &KDirectoryContentsCounter::slotResult);
connect(this, &KDirectoryContentsCounter::requestDirectoryContentsCount, m_worker, &KDirectoryContentsCounterWorker::countDirectoryContents);
connect(m_worker, &KDirectoryContentsCounterWorker::result, this, &KDirectoryContentsCounter::slotResult);
m_dirWatcher = new KDirWatch(this);
connect(m_dirWatcher, &KDirWatch::dirty, this, &KDirectoryContentsCounter::slotDirWatchDirty);
@ -170,8 +168,8 @@ void KDirectoryContentsCounter::startWorker(const QString& path)
}
if (m_workerIsBusy) {
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()) {
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()) {
if (alreadyInCache) {
m_queue.push_back(path);
} else {

View File

@ -17,17 +17,15 @@
#include "dolphin_detailsmodesettings.h"
KDirectoryContentsCounterWorker::KDirectoryContentsCounterWorker(QObject* parent) :
QObject(parent)
KDirectoryContentsCounterWorker::KDirectoryContentsCounterWorker(QObject *parent)
: QObject(parent)
{
qRegisterMetaType<KDirectoryContentsCounterWorker::Options>();
}
#ifndef Q_OS_WIN
KDirectoryContentsCounterWorker::CountResult walkDir(const QString &dirPath,
const bool countHiddenFiles,
const bool countDirectoriesOnly,
const uint allowedRecursiveLevel)
KDirectoryContentsCounterWorker::CountResult
walkDir(const QString &dirPath, const bool countHiddenFiles, const bool countDirectoriesOnly, const uint allowedRecursiveLevel)
{
int count = -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
// as directory instead of trying to do an expensive stat()
// (see bugs 292642 and 299997).
const bool countEntry = !countDirectoriesOnly ||
dirEntry->d_type == DT_DIR ||
dirEntry->d_type == DT_LNK ||
dirEntry->d_type == DT_UNKNOWN;
const bool countEntry = !countDirectoriesOnly || dirEntry->d_type == DT_DIR || dirEntry->d_type == DT_LNK || dirEntry->d_type == DT_UNKNOWN;
if (countEntry) {
++count;
}

View File

@ -17,11 +17,7 @@ class KDirectoryContentsCounterWorker : public QObject
Q_OBJECT
public:
enum Option {
NoOptions = 0x0,
CountHiddenFiles = 0x1,
CountDirectoriesOnly = 0x2
};
enum Option { NoOptions = 0x0, CountHiddenFiles = 0x1, CountDirectoriesOnly = 0x2 };
Q_DECLARE_FLAGS(Options, Option)
struct CountResult {

View File

@ -19,8 +19,6 @@ public:
};
Q_GLOBAL_STATIC(KFileItemClipboardSingleton, s_KFileItemClipboard)
KFileItemClipboard *KFileItemClipboard::instance()
{
return &s_KFileItemClipboard->instance;
@ -62,12 +60,11 @@ void KFileItemClipboard::updateCutItems()
Q_EMIT cutItemsChanged();
}
KFileItemClipboard::KFileItemClipboard() :
QObject(nullptr),
m_cutItems()
KFileItemClipboard::KFileItemClipboard()
: QObject(nullptr)
, m_cutItems()
{
updateCutItems();
connect(QApplication::clipboard(), &QClipboard::dataChanged,
this, &KFileItemClipboard::updateCutItems);
connect(QApplication::clipboard(), &QClipboard::dataChanged, this, &KFileItemClipboard::updateCutItems);
}

View File

@ -10,11 +10,11 @@
#include <KFileItem>
KFileItemModelFilter::KFileItemModelFilter() :
m_useRegExp(false),
m_regExp(nullptr),
m_lowerCasePattern(),
m_pattern()
KFileItemModelFilter::KFileItemModelFilter()
: m_useRegExp(false)
, m_regExp(nullptr)
, m_lowerCasePattern()
, m_pattern()
{
}
@ -61,7 +61,6 @@ bool KFileItemModelFilter::hasSetFilters() const
return (!m_pattern.isEmpty() || !m_mimeTypes.isEmpty());
}
bool KFileItemModelFilter::matches(const KFileItem &item) const
{
const bool hasPatternFilter = !m_pattern.isEmpty();

View File

@ -24,7 +24,6 @@ class QRegularExpression;
*/
class DOLPHIN_EXPORT KFileItemModelFilter
{
public:
KFileItemModelFilter();
virtual ~KFileItemModelFilter();
@ -76,5 +75,3 @@ private:
QStringList m_mimeTypes; // Property set by setMimeTypes()
};
#endif

View File

@ -22,9 +22,7 @@
*/
template<typename RandomAccessIterator, typename LessThan>
static void mergeSort(RandomAccessIterator begin,
RandomAccessIterator end,
const LessThan& lessThan)
static void mergeSort(RandomAccessIterator begin, RandomAccessIterator end, const LessThan &lessThan)
{
// The implementation is based on qStableSortHelper() from qalgorithms.h
// SPDX-FileCopyrightText: 2011 Nokia Corporation and/or its subsidiary(-ies).
@ -50,11 +48,8 @@ static void mergeSort(RandomAccessIterator begin,
*/
template<typename RandomAccessIterator, typename LessThan>
static void parallelMergeSort(RandomAccessIterator begin,
RandomAccessIterator end,
LessThan lessThan,
int numberOfThreads,
int parallelMergeSortingThreshold = 100)
static void
parallelMergeSort(RandomAccessIterator begin, RandomAccessIterator end, LessThan lessThan, int numberOfThreads, int parallelMergeSortingThreshold = 100)
{
const int span = end - begin;
@ -62,7 +57,8 @@ static void parallelMergeSort(RandomAccessIterator begin,
const int newNumberOfThreads = numberOfThreads / 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);
future.waitForFinished();
@ -83,10 +79,7 @@ static void parallelMergeSort(RandomAccessIterator begin,
*/
template<typename RandomAccessIterator, typename LessThan>
static void merge(RandomAccessIterator begin,
RandomAccessIterator pivot,
RandomAccessIterator end,
const LessThan& lessThan)
static void merge(RandomAccessIterator begin, RandomAccessIterator pivot, RandomAccessIterator end, const LessThan &lessThan)
{
// The implementation is based on qMerge() from qalgorithms.h
// SPDX-FileCopyrightText: 2011 Nokia Corporation and/or its subsidiary(-ies).
@ -111,14 +104,12 @@ static void merge(RandomAccessIterator begin,
if (len1 > len2) {
const int len1Half = len1 / 2;
firstCut = begin + len1Half;
secondCut = std::lower_bound<RandomAccessIterator,
decltype(*firstCut), const LessThan&>(pivot, end, *firstCut, lessThan);
secondCut = std::lower_bound<RandomAccessIterator, decltype(*firstCut), const LessThan &>(pivot, end, *firstCut, lessThan);
len2Half = secondCut - pivot;
} else {
len2Half = len2 / 2;
secondCut = pivot + len2Half;
firstCut = std::upper_bound<RandomAccessIterator,
decltype(*secondCut), const LessThan&>(begin, pivot, *secondCut, lessThan);
firstCut = std::upper_bound<RandomAccessIterator, decltype(*secondCut), const LessThan &>(begin, pivot, *secondCut, lessThan);
}
std::rotate(firstCut, pivot, secondCut);
@ -129,4 +120,3 @@ static void merge(RandomAccessIterator begin,
}
#endif

View File

@ -12,21 +12,20 @@
#include <QPainter>
#include <QStyleOptionHeader>
KItemListHeaderWidget::KItemListHeaderWidget(QGraphicsWidget* parent) :
QGraphicsWidget(parent),
m_automaticColumnResizing(true),
m_model(nullptr),
m_offset(0),
m_sidePadding(0),
m_columns(),
m_columnWidths(),
m_preferredColumnWidths(),
m_hoveredRoleIndex(-1),
m_pressedRoleIndex(-1),
m_roleOperation(NoRoleOperation),
m_pressedMousePos(),
m_movingRole()
KItemListHeaderWidget::KItemListHeaderWidget(QGraphicsWidget *parent)
: QGraphicsWidget(parent)
, m_automaticColumnResizing(true)
, m_model(nullptr)
, m_offset(0)
, m_sidePadding(0)
, m_columns()
, m_columnWidths()
, m_preferredColumnWidths()
, m_hoveredRoleIndex(-1)
, m_pressedRoleIndex(-1)
, m_roleOperation(NoRoleOperation)
, m_pressedMousePos()
, m_movingRole()
{
m_movingRole.x = 0;
m_movingRole.xDec = 0;
@ -48,19 +47,15 @@ void KItemListHeaderWidget::setModel(KItemModelBase* model)
}
if (m_model) {
disconnect(m_model, &KItemModelBase::sortRoleChanged,
this, &KItemListHeaderWidget::slotSortRoleChanged);
disconnect(m_model, &KItemModelBase::sortOrderChanged,
this, &KItemListHeaderWidget::slotSortOrderChanged);
disconnect(m_model, &KItemModelBase::sortRoleChanged, this, &KItemListHeaderWidget::slotSortRoleChanged);
disconnect(m_model, &KItemModelBase::sortOrderChanged, this, &KItemListHeaderWidget::slotSortOrderChanged);
}
m_model = model;
if (m_model) {
connect(m_model, &KItemModelBase::sortRoleChanged,
this, &KItemListHeaderWidget::slotSortRoleChanged);
connect(m_model, &KItemModelBase::sortOrderChanged,
this, &KItemListHeaderWidget::slotSortOrderChanged);
connect(m_model, &KItemModelBase::sortRoleChanged, this, &KItemListHeaderWidget::slotSortRoleChanged);
connect(m_model, &KItemModelBase::sortOrderChanged, this, &KItemListHeaderWidget::slotSortOrderChanged);
}
}
@ -194,8 +189,7 @@ void KItemListHeaderWidget::mousePressEvent(QGraphicsSceneMouseEvent* event)
m_roleOperation = ResizePaddingColumnOperation;
} else {
updatePressedRoleIndex(event->pos());
m_roleOperation = isAboveRoleGrip(m_pressedMousePos, m_pressedRoleIndex) ?
ResizeRoleOperation : NoRoleOperation;
m_roleOperation = isAboveRoleGrip(m_pressedMousePos, m_pressedRoleIndex) ? ResizeRoleOperation : NoRoleOperation;
}
event->accept();
} else {
@ -219,8 +213,7 @@ void KItemListHeaderWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
if (m_pressedRoleIndex == sortRoleIndex) {
// Toggle the sort order
const Qt::SortOrder previous = m_model->sortOrder();
const Qt::SortOrder current = (m_model->sortOrder() == Qt::AscendingOrder) ?
Qt::DescendingOrder : Qt::AscendingOrder;
const Qt::SortOrder current = (m_model->sortOrder() == Qt::AscendingOrder) ? Qt::DescendingOrder : Qt::AscendingOrder;
m_model->setSortOrder(current);
Q_EMIT sortOrderChanged(current, previous);
} else {
@ -390,9 +383,8 @@ void KItemListHeaderWidget::hoverMoveEvent(QGraphicsSceneHoverEvent* event)
const QPointF &pos = event->pos();
updateHoveredRoleIndex(pos);
if ((m_hoveredRoleIndex >= 0 && isAboveRoleGrip(pos, m_hoveredRoleIndex)) ||
isAbovePaddingGrip(pos, PaddingGrip::Leading) ||
isAbovePaddingGrip(pos, PaddingGrip::Trailing)) {
if ((m_hoveredRoleIndex >= 0 && isAboveRoleGrip(pos, m_hoveredRoleIndex)) || isAbovePaddingGrip(pos, PaddingGrip::Leading)
|| isAbovePaddingGrip(pos, PaddingGrip::Trailing)) {
setCursor(Qt::SplitHCursor);
} else {
unsetCursor();
@ -413,11 +405,7 @@ void KItemListHeaderWidget::slotSortOrderChanged(Qt::SortOrder current, Qt::Sort
update();
}
void KItemListHeaderWidget::paintRole(QPainter* painter,
const QByteArray& role,
const QRectF& rect,
int orderIndex,
QWidget* widget) const
void KItemListHeaderWidget::paintRole(QPainter *painter, const QByteArray &role, const QRectF &rect, int orderIndex, QWidget *widget) const
{
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).
QStyleOptionHeader option;
option.direction = direction;
option.textAlignment =
direction == Qt::LeftToRight
? Qt::AlignLeft
: Qt::AlignRight;
option.textAlignment = direction == Qt::LeftToRight ? Qt::AlignLeft : Qt::AlignRight;
option.section = orderIndex;
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;
}
if (m_model->sortRole() == role) {
option.sortIndicator = (m_model->sortOrder() == Qt::AscendingOrder) ?
QStyleOptionHeader::SortDown : QStyleOptionHeader::SortUp;
option.sortIndicator = (m_model->sortOrder() == Qt::AscendingOrder) ? QStyleOptionHeader::SortDown : QStyleOptionHeader::SortUp;
}
option.rect = rect.toRect();
option.orientation = Qt::Horizontal;
@ -546,8 +530,7 @@ bool KItemListHeaderWidget::isAbovePaddingGrip(const QPointF& pos, PaddingGrip p
switch (paddingGrip) {
case Leading:
return pos.x() >= (lx - grip) && pos.x() <= lx;
case Trailing:
{
case Trailing: {
qreal rx = lx;
for (const QByteArray &role : qAsConst(m_columns)) {
rx += m_columnWidths.value(role);
@ -596,12 +579,8 @@ int KItemListHeaderWidget::targetOfMovingRole() const
const qreal targetWidth = m_columnWidths.value(role);
const qreal targetRight = targetLeft + targetWidth - 1;
const bool isInTarget = (targetWidth >= movingWidth &&
movingLeft >= targetLeft &&
movingRight <= targetRight) ||
(targetWidth < movingWidth &&
movingLeft <= targetLeft &&
movingRight >= targetRight);
const bool isInTarget = (targetWidth >= movingWidth && movingLeft >= targetLeft && movingRight <= targetRight)
|| (targetWidth < movingWidth && movingLeft <= targetLeft && movingRight >= targetRight);
if (isInTarget) {
return targetIndex;
@ -627,4 +606,3 @@ qreal KItemListHeaderWidget::roleXPosition(const QByteArray& role) const
return -1;
}

View File

@ -62,9 +62,7 @@ Q_SIGNALS:
* 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).
*/
void columnWidthChanged(const QByteArray& role,
qreal currentWidth,
qreal previousWidth);
void columnWidthChanged(const QByteArray &role, qreal currentWidth, qreal previousWidth);
void sidePaddingChanged(qreal width);
@ -72,8 +70,7 @@ Q_SIGNALS:
* Is emitted if the user has released the mouse button after adjusting the
* width of a visible role.
*/
void columnWidthChangeFinished(const QByteArray& role,
qreal currentWidth);
void columnWidthChangeFinished(const QByteArray &role, qreal currentWidth);
/**
* 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);
private:
enum PaddingGrip
{
enum PaddingGrip {
Leading,
Trailing,
};
void paintRole(QPainter* painter,
const QByteArray& role,
const QRectF& rect,
int orderIndex,
QWidget* widget = nullptr) const;
void paintRole(QPainter *painter, const QByteArray &role, const QRectF &rect, int orderIndex, QWidget *widget = nullptr) const;
void updatePressedRoleIndex(const QPointF &pos);
void updateHoveredRoleIndex(const QPointF &pos);
@ -147,13 +138,7 @@ private:
qreal roleXPosition(const QByteArray &role) const;
private:
enum RoleOperation
{
NoRoleOperation,
ResizeRoleOperation,
ResizePaddingColumnOperation,
MoveRoleOperation
};
enum RoleOperation { NoRoleOperation, ResizeRoleOperation, ResizePaddingColumnOperation, MoveRoleOperation };
bool m_automaticColumnResizing;
KItemModelBase *m_model;
@ -168,8 +153,7 @@ private:
RoleOperation m_roleOperation;
QPointF m_pressedMousePos;
struct MovingRole
{
struct MovingRole {
QPixmap pixmap;
int x;
int xDec;
@ -178,5 +162,3 @@ private:
};
#endif

View File

@ -8,10 +8,10 @@
#include "kitemlistkeyboardsearchmanager.h"
KItemListKeyboardSearchManager::KItemListKeyboardSearchManager(QObject* parent) :
QObject(parent),
m_isSearchRestarted(false),
m_timeout(1000)
KItemListKeyboardSearchManager::KItemListKeyboardSearchManager(QObject *parent)
: QObject(parent)
, m_isSearchRestarted(false)
, m_timeout(1000)
{
m_keyboardInputTime.invalidate();
}

View File

@ -27,7 +27,6 @@ class DOLPHIN_EXPORT KItemListKeyboardSearchManager : public QObject
Q_OBJECT
public:
explicit KItemListKeyboardSearchManager(QObject *parent = nullptr);
~KItemListKeyboardSearchManager() override;
@ -82,5 +81,3 @@ private:
};
#endif

View File

@ -8,10 +8,10 @@
#include <KIO/Global>
KItemListRoleEditor::KItemListRoleEditor(QWidget *parent) :
KTextEdit(parent),
m_role(),
m_blockFinishedSignal(false)
KItemListRoleEditor::KItemListRoleEditor(QWidget *parent)
: KTextEdit(parent)
, m_role()
, m_blockFinishedSignal(false)
{
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@ -118,12 +118,8 @@ void KItemListRoleEditor::keyPressEvent(QKeyEvent* event)
case Qt::Key_Home:
case Qt::Key_End: {
if (event->modifiers() == Qt::NoModifier || event->modifiers() == Qt::ShiftModifier) {
const QTextCursor::MoveOperation op = event->key() == Qt::Key_Home
? QTextCursor::Start
: QTextCursor::End;
const QTextCursor::MoveMode mode = event->modifiers() == Qt::NoModifier
? QTextCursor::MoveAnchor
: QTextCursor::KeepAnchor;
const QTextCursor::MoveOperation op = event->key() == Qt::Key_Home ? QTextCursor::Start : QTextCursor::End;
const QTextCursor::MoveMode mode = event->modifiers() == Qt::NoModifier ? QTextCursor::MoveAnchor : QTextCursor::KeepAnchor;
QTextCursor cursor = textCursor();
cursor.movePosition(op, mode);
setTextCursor(cursor);
@ -173,4 +169,3 @@ void KItemListRoleEditor::emitRoleEditingFinished(EditResultDirection direction)
Q_EMIT roleEditingFinished(m_role, ret);
}
}

View File

@ -18,8 +18,7 @@ enum EditResultDirection{
};
Q_DECLARE_METATYPE(EditResultDirection)
struct EditResult
{
struct EditResult {
QString newName;
EditResultDirection direction;
};

View File

@ -6,11 +6,11 @@
#include "kitemlistrubberband.h"
KItemListRubberBand::KItemListRubberBand(QObject* parent) :
QObject(parent),
m_active(false),
m_startPos(),
m_endPos()
KItemListRubberBand::KItemListRubberBand(QObject *parent)
: QObject(parent)
, m_active(false)
, m_startPos()
, m_endPos()
{
}
@ -74,4 +74,3 @@ bool KItemListRubberBand::isActive() const
{
return m_active;
}

View File

@ -45,5 +45,3 @@ private:
};
#endif

View File

@ -11,10 +11,10 @@
#include <QIcon>
#include <QPainter>
KItemListSelectionToggle::KItemListSelectionToggle(QGraphicsItem* parent) :
QGraphicsWidget(parent),
m_checked(false),
m_hovered(false)
KItemListSelectionToggle::KItemListSelectionToggle(QGraphicsItem *parent)
: QGraphicsWidget(parent)
, m_checked(false)
, m_hovered(false)
{
}
@ -99,4 +99,3 @@ int KItemListSelectionToggle::iconSize() const
return iconSize;
}

View File

@ -11,7 +11,6 @@
#include <QGraphicsWidget>
#include <QPixmap>
/**
* @brief Allows to toggle between the selected and unselected state of an item.
*/
@ -44,5 +43,3 @@ private:
};
#endif

View File

@ -7,12 +7,12 @@
#include "kitemlistsizehintresolver.h"
#include "kitemviews/kitemlistview.h"
KItemListSizeHintResolver::KItemListSizeHintResolver(const KItemListView* itemListView) :
m_itemListView(itemListView),
m_logicalHeightHintCache(),
m_logicalWidthHint(0.0),
m_minHeightHint(0.0),
m_needsResolving(false)
KItemListSizeHintResolver::KItemListSizeHintResolver(const KItemListView *itemListView)
: m_itemListView(itemListView)
, m_logicalHeightHintCache()
, m_logicalWidthHint(0.0)
, m_minHeightHint(0.0)
, m_needsResolving(false)
{
}

View File

@ -12,20 +12,18 @@
#include <QStyle>
#include <QWheelEvent>
KItemListSmoothScroller::KItemListSmoothScroller(QScrollBar* scrollBar,
QObject* parent) :
QObject(parent),
m_scrollBarPressed(false),
m_smoothScrolling(true),
m_scrollBar(scrollBar),
m_animation(nullptr)
KItemListSmoothScroller::KItemListSmoothScroller(QScrollBar *scrollBar, QObject *parent)
: QObject(parent)
, m_scrollBarPressed(false)
, m_smoothScrolling(true)
, m_scrollBar(scrollBar)
, m_animation(nullptr)
{
m_animation = new QPropertyAnimation(this);
const int animationDuration = m_scrollBar->style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, m_scrollBar);
const bool animationEnabled = (animationDuration > 0);
m_animation->setDuration(animationEnabled ? animationDuration : 1);
connect(m_animation, &QPropertyAnimation::stateChanged,
this, &KItemListSmoothScroller::slotAnimationStateChanged);
connect(m_animation, &QPropertyAnimation::stateChanged, this, &KItemListSmoothScroller::slotAnimationStateChanged);
m_scrollBar->installEventFilter(this);
}
@ -168,8 +166,7 @@ bool KItemListSmoothScroller::eventFilter(QObject* obj, QEvent* event)
return QObject::eventFilter(obj, event);
}
void KItemListSmoothScroller::slotAnimationStateChanged(QAbstractAnimation::State newState,
QAbstractAnimation::State oldState)
void KItemListSmoothScroller::slotAnimationStateChanged(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
{
Q_UNUSED(oldState)
if (newState == QAbstractAnimation::Stopped && m_smoothScrolling && !m_scrollBarPressed) {
@ -198,4 +195,3 @@ void KItemListSmoothScroller::handleWheelEvent(QWheelEvent* event)
m_smoothScrolling = previous;
}

View File

@ -25,8 +25,7 @@ class DOLPHIN_EXPORT KItemListSmoothScroller : public QObject
Q_OBJECT
public:
explicit KItemListSmoothScroller(QScrollBar* scrollBar,
QObject* parent = nullptr);
explicit KItemListSmoothScroller(QScrollBar *scrollBar, QObject *parent = nullptr);
~KItemListSmoothScroller() override;
void setScrollBar(QScrollBar *scrollBar);
@ -74,12 +73,12 @@ Q_SIGNALS:
* Emitted when the scrolling animation has finished
*/
void scrollingStopped();
protected:
bool eventFilter(QObject *obj, QEvent *event) override;
private Q_SLOTS:
void slotAnimationStateChanged(QAbstractAnimation::State newState,
QAbstractAnimation::State oldState);
void slotAnimationStateChanged(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
private:
bool m_scrollBarPressed;
@ -89,5 +88,3 @@ private:
};
#endif

View File

@ -9,11 +9,11 @@
#include <QPropertyAnimation>
KItemListViewAnimation::KItemListViewAnimation(QObject* parent) :
QObject(parent),
m_scrollOrientation(Qt::Vertical),
m_scrollOffset(0),
m_animation()
KItemListViewAnimation::KItemListViewAnimation(QObject *parent)
: QObject(parent)
, m_scrollOrientation(Qt::Vertical)
, m_scrollOffset(0)
, m_animation()
{
}
@ -65,8 +65,7 @@ void KItemListViewAnimation::setScrollOffset(qreal offset)
if (type == MovingAnimation) {
// Stop the animation, calculate the moved start- and end-value
// and restart the animation for the remaining duration.
const int remainingDuration = propertyAnim->duration()
- propertyAnim->currentTime();
const int remainingDuration = propertyAnim->duration() - propertyAnim->currentTime();
const bool block = propertyAnim->signalsBlocked();
propertyAnim->blockSignals(true);
@ -172,11 +171,18 @@ void KItemListViewAnimation::stop(QGraphicsWidget* widget, AnimationType type)
propertyAnim->stop();
switch (type) {
case MovingAnimation: break;
case CreateAnimation: widget->setOpacity(1.0); break;
case DeleteAnimation: widget->setOpacity(0.0); break;
case ResizeAnimation: break;
default: break;
case MovingAnimation:
break;
case CreateAnimation:
widget->setOpacity(1.0);
break;
case DeleteAnimation:
widget->setOpacity(0.0);
break;
case ResizeAnimation:
break;
default:
break;
}
m_animation[type].remove(widget);
@ -228,4 +234,3 @@ void KItemListViewAnimation::slotFinished()
}
Q_ASSERT(false);
}

View File

@ -28,14 +28,7 @@ class DOLPHIN_EXPORT KItemListViewAnimation : public QObject
Q_OBJECT
public:
enum AnimationType {
MovingAnimation,
CreateAnimation,
DeleteAnimation,
ResizeAnimation,
IconResizeAnimation,
AnimationTypeCount
};
enum AnimationType { MovingAnimation, CreateAnimation, DeleteAnimation, ResizeAnimation, IconResizeAnimation, AnimationTypeCount };
explicit KItemListViewAnimation(QObject *parent = nullptr);
~KItemListViewAnimation() override;
@ -87,5 +80,3 @@ private:
};
#endif

View File

@ -14,32 +14,32 @@
// #define KITEMLISTVIEWLAYOUTER_DEBUG
KItemListViewLayouter::KItemListViewLayouter(KItemListSizeHintResolver* sizeHintResolver, QObject* parent) :
QObject(parent),
m_dirty(true),
m_visibleIndexesDirty(true),
m_scrollOrientation(Qt::Vertical),
m_size(),
m_itemSize(128, 128),
m_itemMargin(),
m_headerHeight(0),
m_model(nullptr),
m_sizeHintResolver(sizeHintResolver),
m_scrollOffset(0),
m_maximumScrollOffset(0),
m_itemOffset(0),
m_maximumItemOffset(0),
m_firstVisibleIndex(-1),
m_lastVisibleIndex(-1),
m_columnWidth(0),
m_xPosInc(0),
m_columnCount(0),
m_rowOffsets(),
m_columnOffsets(),
m_groupItemIndexes(),
m_groupHeaderHeight(0),
m_groupHeaderMargin(0),
m_itemInfos()
KItemListViewLayouter::KItemListViewLayouter(KItemListSizeHintResolver *sizeHintResolver, QObject *parent)
: QObject(parent)
, m_dirty(true)
, m_visibleIndexesDirty(true)
, m_scrollOrientation(Qt::Vertical)
, m_size()
, m_itemSize(128, 128)
, m_itemMargin()
, m_headerHeight(0)
, m_model(nullptr)
, m_sizeHintResolver(sizeHintResolver)
, m_scrollOffset(0)
, m_maximumScrollOffset(0)
, m_itemOffset(0)
, m_maximumItemOffset(0)
, m_firstVisibleIndex(-1)
, m_lastVisibleIndex(-1)
, m_columnWidth(0)
, m_xPosInc(0)
, m_columnCount(0)
, m_rowOffsets()
, m_columnOffsets()
, m_groupItemIndexes()
, m_groupHeaderHeight(0)
, m_groupHeaderMargin(0)
, m_itemInfos()
{
Q_ASSERT(m_sizeHintResolver);
}
@ -271,9 +271,8 @@ QRectF KItemListViewLayouter::groupHeaderRect(int index) const
break;
}
const qreal itemWidth = (m_scrollOrientation == Qt::Vertical)
? m_sizeHintResolver->sizeHint(index).width()
: m_sizeHintResolver->sizeHint(index).height();
const qreal itemWidth =
(m_scrollOrientation == Qt::Vertical) ? m_sizeHintResolver->sizeHint(index).width() : m_sizeHintResolver->sizeHint(index).height();
if (itemWidth > headerWidth) {
headerWidth = itemWidth;
@ -294,9 +293,7 @@ int KItemListViewLayouter::itemColumn(int index) const
return -1;
}
return (m_scrollOrientation == Qt::Vertical)
? m_itemInfos[index].column
: m_itemInfos[index].row;
return (m_scrollOrientation == Qt::Vertical) ? m_itemInfos[index].column : m_itemInfos[index].row;
}
int KItemListViewLayouter::itemRow(int index) const
@ -306,9 +303,7 @@ int KItemListViewLayouter::itemRow(int index) const
return -1;
}
return (m_scrollOrientation == Qt::Vertical)
? m_itemInfos[index].row
: m_itemInfos[index].column;
return (m_scrollOrientation == Qt::Vertical) ? m_itemInfos[index].row : m_itemInfos[index].column;
}
int KItemListViewLayouter::maximumVisibleItems() const
@ -336,7 +331,6 @@ void KItemListViewLayouter::markAsDirty()
m_dirty = true;
}
#ifndef QT_NO_DEBUG
bool KItemListViewLayouter::isDirty()
{
@ -347,7 +341,9 @@ void KItemListViewLayouter::markAsDirty()
void KItemListViewLayouter::doLayout()
{
// we always want to update visible indexes after performing a layout
auto qsg = qScopeGuard([this] { updateVisibleIndexes(); });
auto qsg = qScopeGuard([this] {
updateVisibleIndexes();
});
if (!m_dirty) {
return;
@ -409,11 +405,13 @@ void KItemListViewLayouter::doLayout()
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;
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;
currentOffset -= m_columnWidth;
}
@ -615,4 +613,3 @@ qreal KItemListViewLayouter::minimumGroupHeaderWidth() const
{
return 100;
}

View File

@ -223,5 +223,3 @@ private:
};
#endif

View File

@ -19,45 +19,25 @@
#include <QImage>
#include <QPainter>
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,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,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,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,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,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 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,
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,
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,
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,
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,
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] =
{
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, 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, 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, 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 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,
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,
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,
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)
{
@ -236,16 +216,15 @@ static void shadowBlur(QImage& image, float radius, const QColor& color)
p.fillRect(image.rect(), color);
}
namespace {
namespace
{
/** Helper class for drawing frames for KPixmapModifier::applyFrame(). */
class TileSet
{
public:
enum { LeftMargin = 3, TopMargin = 2, RightMargin = 3, BottomMargin = 4 };
enum Tile { TopLeftCorner = 0, TopSide, TopRightCorner, LeftSide,
RightSide, BottomLeftCorner, BottomSide, BottomRightCorner,
NumTiles };
enum Tile { TopLeftCorner = 0, TopSide, TopRightCorner, LeftSide, RightSide, BottomLeftCorner, BottomSide, BottomRightCorner, NumTiles };
TileSet()
{
@ -287,8 +266,7 @@ namespace {
}
p->drawPixmap(r.right() - 8 + 1, r.bottom() - 8 + 1, m_tiles[BottomRightCorner]);
const QRect contentRect = r.adjusted(LeftMargin + 1, TopMargin + 1,
-(RightMargin + 1), -(BottomMargin + 1));
const QRect contentRect = r.adjusted(LeftMargin + 1, TopMargin + 1, -(RightMargin + 1), -(BottomMargin + 1));
p->fillRect(contentRect, Qt::transparent);
}
@ -319,8 +297,7 @@ void KPixmapModifier::applyFrame(QPixmap& icon, const QSize& scaledSize)
qreal dpr = qApp->devicePixelRatio();
// Resize the icon to the maximum size minus the space required for the frame
const QSize size(scaledSize.width() - TileSet::LeftMargin - TileSet::RightMargin,
scaledSize.height() - TileSet::TopMargin - TileSet::BottomMargin);
const QSize size(scaledSize.width() - TileSet::LeftMargin - TileSet::RightMargin, scaledSize.height() - TileSet::TopMargin - TileSet::BottomMargin);
scale(icon, size * dpr);
icon.setDevicePixelRatio(dpr);
@ -341,7 +318,5 @@ void KPixmapModifier::applyFrame(QPixmap& icon, const QSize& scaledSize)
QSize KPixmapModifier::sizeInsideFrame(const QSize &frameSize)
{
return QSize(frameSize.width() - TileSet::LeftMargin - TileSet::RightMargin,
frameSize.height() - TileSet::TopMargin - TileSet::BottomMargin);
return QSize(frameSize.width() - TileSet::LeftMargin - TileSet::RightMargin, frameSize.height() - TileSet::TopMargin - TileSet::BottomMargin);
}

View File

@ -39,5 +39,3 @@ public:
};
#endif

View File

@ -6,23 +6,23 @@
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config-dolphin.h"
#include "dbusinterface.h"
#include "dolphin_generalsettings.h"
#include "dolphin_version.h"
#include "dolphindebug.h"
#include "dolphinmainwindow.h"
#include "global.h"
#include "config-dolphin.h"
#if HAVE_KUSERFEEDBACK
#include "userfeedback/dolphinfeedbackprovider.h"
#endif
#include <KAboutData>
#include <KConfigGui>
#include <KCrash>
#include <KDBusService>
#include <KLocalizedString>
#include <KConfigGui>
#include <KIO/PreviewJob>
#include <KLocalizedString>
#include <KWindowSystem>
#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)
if (getuid() == 0) {
if (!qEnvironmentVariableIsEmpty("SUDO_USER")) {
std::cout << "Running Dolphin with sudo can cause bugs and expose you to security vulnerabilities."
<< std::endl;
std::cout << "Running Dolphin with sudo can cause bugs and expose you to security vulnerabilities." << std::endl;
return EXIT_FAILURE;
} else if (!qEnvironmentVariableIsEmpty("KDESU_USER")) {
std::cout << "Running Dolphin with kdesu can cause bugs and expose you to security vulnerabilities."
<< std::endl;
std::cout << "Running Dolphin with kdesu can cause bugs and expose you to security vulnerabilities." << std::endl;
return EXIT_FAILURE;
}
}
@ -88,7 +86,9 @@ int main(int argc, char **argv)
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"),
KAboutLicense::GPL,
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"),
i18nc("@info:credit", "Maintainer and developer (2006-2012)"),
QStringLiteral("peter.penz19@gmail.com"));
aboutData.addAuthor(i18nc("@info:credit", "Sebastian Trüg"),
i18nc("@info:credit", "Developer"),
QStringLiteral("trueg@kde.org"));
aboutData.addAuthor(i18nc("@info:credit", "David Faure"),
i18nc("@info:credit", "Developer"),
QStringLiteral("faure@kde.org"));
aboutData.addAuthor(i18nc("@info:credit", "Aaron J. Seigo"),
i18nc("@info:credit", "Developer"),
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"));
aboutData.addAuthor(i18nc("@info:credit", "Sebastian Trüg"), i18nc("@info:credit", "Developer"), QStringLiteral("trueg@kde.org"));
aboutData.addAuthor(i18nc("@info:credit", "David Faure"), i18nc("@info:credit", "Developer"), QStringLiteral("faure@kde.org"));
aboutData.addAuthor(i18nc("@info:credit", "Aaron J. Seigo"), i18nc("@info:credit", "Developer"), 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);
@ -142,11 +126,14 @@ int main(int argc, char **argv)
aboutData.setupCommandLine(&parser);
// 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.")));
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("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.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
const bool startedWithURLs = !urls.isEmpty();
if (parser.isSet(QStringLiteral("daemon"))) {
// Disable session management for the daemonized version
// 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"))) {
QString token;
if (KWindowSystem::isPlatformWayland()) {
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
// reboot is in use
// 3. There is a session available to restore
if (!parser.isSet(QStringLiteral("new-window"))
&& (app.isSessionRestored() || GeneralSettings::rememberOpenedTabs())
) {
if (!parser.isSet(QStringLiteral("new-window")) && (app.isSessionRestored() || GeneralSettings::rememberOpenedTabs())) {
// Get saved state data for the last-closed Dolphin instance
const QString serviceName = QStringLiteral("org.kde.dolphin-%1").arg(QCoreApplication::applicationPid());
if (Dolphin::dolphinGuiInstances(serviceName).size() > 0) {

Some files were not shown because too many files have changed in this diff Show More