┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/private
diff options
context:
space:
mode:
Diffstat (limited to 'src/kitemviews/private')
-rw-r--r--src/kitemviews/private/kfileitemmodelfilter.cpp62
-rw-r--r--src/kitemviews/private/kfileitemmodelfilter.h39
-rw-r--r--src/kitemviews/private/kitemlistroleeditor.cpp16
-rw-r--r--src/kitemviews/private/kitemlistroleeditor.h1
-rw-r--r--src/kitemviews/private/kitemlistsmoothscroller.cpp1
-rw-r--r--src/kitemviews/private/kitemlistviewanimation.cpp2
-rw-r--r--src/kitemviews/private/kitemlistviewanimation.h1
-rw-r--r--src/kitemviews/private/kpixmapmodifier.cpp7
8 files changed, 99 insertions, 30 deletions
diff --git a/src/kitemviews/private/kfileitemmodelfilter.cpp b/src/kitemviews/private/kfileitemmodelfilter.cpp
index 45c62e7ca..48d2f6276 100644
--- a/src/kitemviews/private/kfileitemmodelfilter.cpp
+++ b/src/kitemviews/private/kfileitemmodelfilter.cpp
@@ -13,7 +13,8 @@
#include <KFileItem>
KFileItemModelFilter::KFileItemModelFilter()
- : m_useRegExp(false)
+ : m_filterMode(Glob)
+ , m_caseSensitive(false)
, m_regExp(nullptr)
, m_lowerCasePattern()
, m_pattern()
@@ -31,16 +32,29 @@ void KFileItemModelFilter::setPattern(const QString &filter)
m_pattern = filter;
m_lowerCasePattern = filter.toLower();
- if (filter.contains(QLatin1Char('*')) || filter.contains(QLatin1Char('?')) || filter.contains(QLatin1Char('['))) {
- if (!m_regExp) {
- m_regExp = new QRegularExpression();
- m_regExp->setPatternOptions(QRegularExpression::CaseInsensitiveOption);
- }
- m_regExp->setPattern(QRegularExpression::wildcardToRegularExpression(filter));
- m_useRegExp = m_regExp->isValid();
- } else {
- m_useRegExp = false;
- }
+ updateFilter();
+}
+
+void KFileItemModelFilter::setFilterMode(FilterMode mode)
+{
+ m_filterMode = mode;
+ updateFilter();
+}
+
+KFileItemModelFilter::FilterMode KFileItemModelFilter::filterMode() const
+{
+ return m_filterMode;
+}
+
+void KFileItemModelFilter::setCaseSensitive(bool caseSensitive)
+{
+ m_caseSensitive = caseSensitive;
+ updateFilter();
+}
+
+bool KFileItemModelFilter::isCaseSensitive() const
+{
+ return m_caseSensitive;
}
QString KFileItemModelFilter::pattern() const
@@ -48,6 +62,26 @@ QString KFileItemModelFilter::pattern() const
return m_pattern;
}
+void KFileItemModelFilter::updateFilter()
+{
+ if (m_filterMode == PlainText) {
+ return;
+ }
+
+ if (!m_regExp) {
+ m_regExp = new QRegularExpression();
+ }
+
+ QRegularExpression::PatternOptions options = m_caseSensitive ? QRegularExpression::NoPatternOption : QRegularExpression::CaseInsensitiveOption;
+ if (m_filterMode == Regex) {
+ m_regExp->setPattern(m_pattern);
+ m_regExp->setPatternOptions(options);
+ } else if (m_filterMode == Glob) {
+ m_regExp->setPattern(QRegularExpression::wildcardToRegularExpression(m_pattern, QRegularExpression::UnanchoredWildcardConversion));
+ m_regExp->setPatternOptions(options);
+ }
+}
+
void KFileItemModelFilter::setMimeTypes(const QStringList &types)
{
m_mimeTypes = types;
@@ -98,8 +132,10 @@ bool KFileItemModelFilter::matches(const KFileItem &item) const
bool KFileItemModelFilter::matchesPattern(const KFileItem &item) const
{
- if (m_useRegExp) {
- return m_regExp->match(item.text()).hasMatch();
+ if (m_filterMode == Glob || m_filterMode == Regex) {
+ return m_regExp->isValid() && m_regExp->match(item.text()).hasMatch();
+ } else if (m_caseSensitive) {
+ return item.text().contains(m_pattern);
} else {
return item.text().toLower().contains(m_lowerCasePattern);
}
diff --git a/src/kitemviews/private/kfileitemmodelfilter.h b/src/kitemviews/private/kfileitemmodelfilter.h
index ce6cbeebb..4559f880f 100644
--- a/src/kitemviews/private/kfileitemmodelfilter.h
+++ b/src/kitemviews/private/kfileitemmodelfilter.h
@@ -28,16 +28,39 @@ public:
KFileItemModelFilter();
virtual ~KFileItemModelFilter();
+ KFileItemModelFilter(const KFileItemModelFilter &) = delete;
+ KFileItemModelFilter &operator=(const KFileItemModelFilter &) = delete;
+
+ /** Filtering modes of KFileItemModelFilter */
+ enum FilterMode {
+ /** Substring matching. */
+ PlainText = 0,
+ /** Matching with glob, default. */
+ Glob,
+ /** Matching with regex. */
+ Regex
+ };
+
/**
* Sets the pattern that is used for a comparison with the item
- * in KFileItemModelFilter::matches(). Per default the pattern
- * defines a sub-string. As soon as the pattern contains at least
- * a '*', '?' or '[' the pattern represents a regular expression.
+ * in KFileItemModelFilter::matches().
*/
void setPattern(const QString &pattern);
QString pattern() const;
/**
+ * Sets the filtering mode used in KFileItemModelFilter::matches().
+ */
+ void setFilterMode(FilterMode mode);
+ FilterMode filterMode() const;
+
+ /**
+ * Enable or disable the case sensitive filtering.
+ */
+ void setCaseSensitive(bool caseSensitive);
+ bool isCaseSensitive() const;
+
+ /**
* Set the list of mimetypes that are used for comparison with the
* item in KFileItemModelFilter::matchesMimeType.
*/
@@ -73,8 +96,14 @@ private:
*/
bool matchesType(const KFileItem &item) const;
- bool m_useRegExp; // If true, m_regExp is used for filtering,
- // otherwise m_lowerCaseFilter is used.
+ /**
+ * Instantiate and configure m_regExp according to m_filterMode and m_caseSensitive.
+ */
+ void updateFilter();
+
+ FilterMode m_filterMode; // The current filtering mode.
+ bool m_caseSensitive; // If true the matching will be case sensitive.
+
QRegularExpression *m_regExp;
QString m_lowerCasePattern; // Lowercase version of m_filter for
// faster comparison in matches().
diff --git a/src/kitemviews/private/kitemlistroleeditor.cpp b/src/kitemviews/private/kitemlistroleeditor.cpp
index 6105d604f..cec9bb98b 100644
--- a/src/kitemviews/private/kitemlistroleeditor.cpp
+++ b/src/kitemviews/private/kitemlistroleeditor.cpp
@@ -64,6 +64,11 @@ bool KItemListRoleEditor::event(QEvent *event)
return KTextEdit::event(event);
}
+void KItemListRoleEditor::setFinishedSignalBlocked(bool blocked)
+{
+ m_blockFinishedSignal = blocked;
+}
+
void KItemListRoleEditor::keyPressEvent(QKeyEvent *event)
{
switch (event->key()) {
@@ -141,17 +146,6 @@ void KItemListRoleEditor::autoAdjustSize()
const auto originalSize = size();
auto newSize = originalSize;
- document()->adjustSize();
- const qreal requiredWidth = document()->size().width();
- const qreal availableWidth = size().width() - frameBorder;
- if (requiredWidth > availableWidth) {
- qreal newWidth = requiredWidth + frameBorder;
- if (parentWidget() && pos().x() + newWidth > parentWidget()->width()) {
- newWidth = parentWidget()->width() - pos().x();
- }
- newSize.setWidth(newWidth);
- }
-
const qreal requiredHeight = document()->size().height();
const qreal availableHeight = size().height() - frameBorder;
if (requiredHeight > availableHeight) {
diff --git a/src/kitemviews/private/kitemlistroleeditor.h b/src/kitemviews/private/kitemlistroleeditor.h
index eb8a9cb5e..3956380cd 100644
--- a/src/kitemviews/private/kitemlistroleeditor.h
+++ b/src/kitemviews/private/kitemlistroleeditor.h
@@ -45,6 +45,7 @@ public:
QByteArray role() const;
void setAllowUpDownKeyChainEdit(bool allowChainEdit);
+ void setFinishedSignalBlocked(bool blocked);
bool eventFilter(QObject *watched, QEvent *event) override;
Q_SIGNALS:
diff --git a/src/kitemviews/private/kitemlistsmoothscroller.cpp b/src/kitemviews/private/kitemlistsmoothscroller.cpp
index b7d0a8cd4..915b6b3d5 100644
--- a/src/kitemviews/private/kitemlistsmoothscroller.cpp
+++ b/src/kitemviews/private/kitemlistsmoothscroller.cpp
@@ -214,6 +214,7 @@ void KItemListSmoothScroller::handleWheelEvent(QWheelEvent *event)
QWheelEvent *copy = event->clone();
QApplication::sendEvent(m_scrollBar, copy);
event->setAccepted(copy->isAccepted());
+ delete copy;
m_smoothScrolling = previous;
}
diff --git a/src/kitemviews/private/kitemlistviewanimation.cpp b/src/kitemviews/private/kitemlistviewanimation.cpp
index 2ea884461..db98713f7 100644
--- a/src/kitemviews/private/kitemlistviewanimation.cpp
+++ b/src/kitemviews/private/kitemlistviewanimation.cpp
@@ -143,6 +143,8 @@ void KItemListViewAnimation::start(QGraphicsWidget *widget, AnimationType type,
m_animation[type].insert(widget, propertyAnim);
propertyAnim->start();
+
+ Q_EMIT started(widget, type, endValue);
}
void KItemListViewAnimation::stop(QGraphicsWidget *widget, AnimationType type)
diff --git a/src/kitemviews/private/kitemlistviewanimation.h b/src/kitemviews/private/kitemlistviewanimation.h
index 821566161..a23715a8a 100644
--- a/src/kitemviews/private/kitemlistviewanimation.h
+++ b/src/kitemviews/private/kitemlistviewanimation.h
@@ -74,6 +74,7 @@ public:
Q_SIGNALS:
void finished(QGraphicsWidget *widget, KItemListViewAnimation::AnimationType type);
+ void started(QGraphicsWidget *widget, AnimationType type, const QVariant &endValue);
private Q_SLOTS:
void slotFinished();
diff --git a/src/kitemviews/private/kpixmapmodifier.cpp b/src/kitemviews/private/kpixmapmodifier.cpp
index bf316b880..96aea26d4 100644
--- a/src/kitemviews/private/kpixmapmodifier.cpp
+++ b/src/kitemviews/private/kpixmapmodifier.cpp
@@ -15,6 +15,8 @@
#include "kpixmapmodifier.h"
+#include "dolphin_iconsmodesettings.h"
+
#include <QGuiApplication>
#include <QImage>
#include <QPainter>
@@ -281,7 +283,10 @@ void KPixmapModifier::scale(QPixmap &pixmap, const QSize &scaledSize)
return;
}
qreal dpr = pixmap.devicePixelRatio();
- pixmap = pixmap.scaled(scaledSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+ const Qt::TransformationMode mode = IconsModeSettings::usePixelatedScaling()
+ ? Qt::FastTransformation
+ : Qt::SmoothTransformation;
+ pixmap = pixmap.scaled(scaledSize, Qt::KeepAspectRatio, mode);
pixmap.setDevicePixelRatio(dpr);
}