return m_data;
}
+QVariant KItemListWidget::value(const QByteArray &key) const
+{
+ return m_data.value(key);
+}
+
void KItemListWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(option)
{
Q_OBJECT
- Q_PROPERTY(int iconSize READ iconSize WRITE setIconSize)
-
public:
KItemListWidget(KItemListWidgetInformant *informant, QGraphicsItem *parent);
~KItemListWidget() override;
void setData(const QHash<QByteArray, QVariant> &data, const QSet<QByteArray> &roles = QSet<QByteArray>());
QHash<QByteArray, QVariant> data() const;
+ QVariant value(const QByteArray &key) const;
/**
* Draws the hover-rectangle if the item is hovered. Overwrite this method
void drawItemStyleOption(QPainter *painter, QWidget *widget, QStyle::State styleState);
private:
- Q_PROPERTY(qreal hoverOpacity READ hoverOpacity WRITE setHoverOpacity)
-
KItemListWidgetInformant *m_informant;
int m_index;
bool m_selected;
m_activateSoonAnimation->setEndValue(1.0);
m_activateSoonAnimation->setDuration(timeUntilActivation);
- const QVariant originalIconName{data()["iconName"]};
+ const QVariant originalIconName{value("iconName")};
connect(m_activateSoonAnimation, &QVariantAnimation::valueChanged, this, [originalIconName, this](const QVariant &value) {
auto progress = value.toFloat();
bool KStandardItemListWidget::isIconControlledByActivateSoonAnimation() const
{
- return m_activateSoonAnimation && data()["iconName"] == "folder-open";
+ return m_activateSoonAnimation && value("iconName") == "folder-open";
}
KItemListWidgetInformant *KStandardItemListWidget::createInformant()
// use a generic icon as fallback
iconName = QStringLiteral("unknown");
}
- const QStringList overlays = values["iconOverlays"].toStringList();
const bool hasFocus = scene()->views()[0]->parentWidget()->hasFocus();
m_pixmap = pixmapForIcon(iconName,
QSize(maxIconWidth, maxIconHeight),
KConfigGroup configGroup(globalConfig, QStringLiteral("KDE"));
updateAnimationDuration(configGroup.readEntry("SmoothScroll", true));
- QDBusConnection::sessionBus().connect(QStringLiteral(""),
+ QDBusConnection::sessionBus().connect(QString(),
QStringLiteral("/SmoothScroll"),
QStringLiteral("org.kde.SmoothScroll"),
QStringLiteral("notifyChange"),
* @see UpdatableStateInterface::updateStateToMatch().
* @see commitCurrentConfiguration().
*/
- void slotConfigurationChanged(const DolphinQuery &searchConfiguration);
+ void slotConfigurationChanged(const Search::DolphinQuery &searchConfiguration);
/**
* Changes the m_searchConfiguration in response to the user editing the search term. If no further changes to the search term happen within a time limit,
Q_SIGNALS:
/** Is emitted whenever settings have changed and a new search might be necessary. */
- void configurationChanged(const DolphinQuery &dolphinQuery);
+ void configurationChanged(const Search::DolphinQuery &dolphinQuery);
protected:
void paintEvent(QPaintEvent *event) override;
Q_SIGNALS:
/** Is emitted whenever settings have changed and a new search might be necessary. */
- void configurationChanged(const DolphinQuery &dolphinQuery);
+ void configurationChanged(const Search::DolphinQuery &dolphinQuery);
/**
* Requests for @p message with the given @p messageType to be shown to the user in a non-modal way.
Q_SIGNALS:
/** Is emitted whenever settings have changed and a new search might be necessary. */
- void configurationChanged(const DolphinQuery &dolphinQuery);
+ void configurationChanged(const Search::DolphinQuery &dolphinQuery);
private:
void updateState(const std::shared_ptr<const DolphinQuery> &dolphinQuery) override;
Q_SIGNALS:
/** Is emitted whenever settings have changed and a new search might be necessary. */
- void configurationChanged(const DolphinQuery &dolphinQuery);
+ void configurationChanged(const Search::DolphinQuery &dolphinQuery);
private:
void updateState(const std::shared_ptr<const DolphinQuery> &dolphinQuery) override;
Q_SIGNALS:
/** Is emitted whenever settings have changed and a new search might be necessary. */
- void configurationChanged(const DolphinQuery &dolphinQuery);
+ void configurationChanged(const Search::DolphinQuery &dolphinQuery);
private:
void updateState(const std::shared_ptr<const DolphinQuery> &dolphinQuery) override;
menu()->hide(); // The menu needs to be hidden now, then updated, and then shown again.
}
// Delete all existing actions in the menu
- for (QAction *action : menu()->actions()) {
+ const auto actions = menu()->actions();
+ for (QAction *action : actions) {
action->deleteLater();
}
menu()->clear();
setIcon(QIcon{}); // No icon for the empty state
setText(i18nc("@action:button Required tags for search results: None", "None"));
}
- for (const auto &tag : dolphinQuery->requiredTags()) {
+ const auto tags = dolphinQuery->requiredTags();
+ for (const auto &tag : tags) {
tagsList()->addTag(tag); // We add it just in case this tag is not (or no longer) available on the system. This way the UI always works as expected.
}
if (menu()->isVisible()) {
Q_SIGNALS:
/** Is emitted whenever settings have changed and a new search might be necessary. */
- void configurationChanged(const DolphinQuery &dolphinQuery);
+ void configurationChanged(const Search::DolphinQuery &dolphinQuery);
private:
/**
void WidgetMenu::resizeToFitContents()
{
- auto *widgetAction = static_cast<QWidgetAction *>(actions().first());
+ auto *widgetAction = static_cast<QWidgetAction *>(actions().constFirst());
auto focusedChildWidget = QApplication::focusWidget();
if (!widgetAction->defaultWidget()->isAncestorOf(focusedChildWidget)) {
focusedChildWidget = nullptr;
void WidgetMenu::showEvent(QShowEvent *event)
{
if (!event->spontaneous()) {
- auto widgetAction = static_cast<QWidgetAction *>(actions().first());
+ auto widgetAction = static_cast<QWidgetAction *>(actions().constFirst());
widgetAction->defaultWidget()->setFocus();
}
QMenu::showEvent(event);
{
#ifndef IS_KCM
DolphinMainWindow *mainWindow = nullptr;
- for (const auto widget : QApplication::topLevelWidgets()) {
+ const auto topLevelsWidgets = QApplication::topLevelWidgets();
+ for (const auto widget : topLevelsWidgets) {
mainWindow = qobject_cast<DolphinMainWindow *>(widget);
if (mainWindow) {
break;
void DiskSpaceUsageMenu::showEvent(QShowEvent *event)
{
- if (!event->spontaneous()) {
- auto widgetAction = qobject_cast<QWidgetAction *>(actions().first());
+ if (!event->spontaneous() && !actions().isEmpty()) {
+ auto widgetAction = qobject_cast<QWidgetAction *>(*actions().constBegin());
if (widgetAction) {
widgetAction->defaultWidget()->setFocus();
}
do {
QVERIFY2(desktopUiElement.tagName() == phoneUiElement.tagName(),
qPrintable(QStringLiteral("Node mismatch: dolphinui.rc/%1::%2 and dolphinuiforphones.rc/%3::%4")
- .arg(desktopUiElement.parentNode().toElement().tagName())
- .arg(desktopUiElement.tagName())
- .arg(phoneUiElement.parentNode().toElement().tagName())
- .arg(phoneUiElement.tagName())));
+ .arg(desktopUiElement.parentNode().toElement().tagName(),
+ desktopUiElement.tagName(),
+ phoneUiElement.parentNode().toElement().tagName(),
+ phoneUiElement.tagName())));
QCOMPARE(desktopUiElement.text(), phoneUiElement.text());
const auto desktopUiElementAttributes = desktopUiElement.attributes();
const auto phoneUiElementAttributes = phoneUiElement.attributes();
for (int i = 0; i < desktopUiElementAttributes.count(); i++) {
QVERIFY2(phoneUiElementAttributes.count() >= i,
qPrintable(QStringLiteral("Attribute mismatch: dolphinui.rc/%1::%2 has more attributes than dolphinuiforphones.rc/%3::%4")
- .arg(desktopUiElement.parentNode().toElement().tagName())
- .arg(desktopUiElement.tagName())
- .arg(phoneUiElement.parentNode().toElement().tagName())
- .arg(phoneUiElement.tagName())));
+ .arg(desktopUiElement.parentNode().toElement().tagName(),
+ desktopUiElement.tagName(),
+ phoneUiElement.parentNode().toElement().tagName(),
+ phoneUiElement.tagName())));
if (exceptions.count(desktopUiElementAttributes.item(i).nodeName())) {
continue;
}
}
QVERIFY2(desktopUiElementAttributes.count() == phoneUiElementAttributes.count(),
qPrintable(QStringLiteral("Attribute mismatch: dolphinui.rc/%1::%2 has fewer attributes than dolphinuiforphones.rc/%3::%4. %5 < %6")
- .arg(desktopUiElement.parentNode().toElement().tagName())
- .arg(desktopUiElement.tagName())
- .arg(phoneUiElement.parentNode().toElement().tagName())
- .arg(phoneUiElement.tagName())
- .arg(phoneUiElementAttributes.count())
- .arg(desktopUiElementAttributes.count())));
+ .arg(desktopUiElement.parentNode().toElement().tagName(),
+ desktopUiElement.tagName(),
+ phoneUiElement.parentNode().toElement().tagName(),
+ phoneUiElement.tagName())
+ .arg(phoneUiElementAttributes.count(), desktopUiElementAttributes.count())));
desktopUiElement = nextUiElement(desktopUiElement);
phoneUiElement = nextUiElement(phoneUiElement);
const Qt::Key previousRowKey = Qt::Key_Up;
const Qt::LayoutDirection layoutDirection = Qt::LeftToRight;
- const KItemListController::SelectionBehavior &selectionBehavior = KItemListController::MultiSelection;
const bool groupingEnabled = false;
QList<QPair<KeyPress, ViewState>> testList;
Q_ASSERT_X(false, "DolphinView", "Selecting the next item failed.");
return;
}
- const auto lastSelectedIndex = m_model->index(selectedItems().last());
+ const auto lastSelectedIndex = m_model->index(*selectedItems().constEnd());
if (lastSelectedIndex < 0) {
Q_ASSERT_X(false, "DolphinView", "Selecting the next item failed.");
return;
viewSettings->setText(i18nc("@action:intoolbar", "View Settings"));
viewSettings->setWhatsThis(
xi18nc("@info:whatsthis View Settings Toolbutton", "This cycles through all view modes. The dropdown menu contains various view-related actions."));
- for (QAction *action : viewModeActions->actions()) {
+ const auto actions = viewModeActions->actions();
+ for (QAction *action : actions) {
viewSettings->addAction(action);
}
viewSettings->addSeparator();