┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews
diff options
context:
space:
mode:
authorarnav dhamija <[email protected]>2016-09-25 23:13:22 +0530
committerarnav dhamija <[email protected]>2016-09-25 23:13:22 +0530
commit67099640b90588af1c72c340756253400da3e95b (patch)
tree16fe472cc13677496793c2a4967097e978379ef4 /src/kitemviews
parentccd0a74eed22c35b5eb72e6f46e747f621169732 (diff)
parent1710304e9ba926d2aec4226d00974b826f9bcbc0 (diff)
Merge branch 'master' of git.kde.org:dolphin
Diffstat (limited to 'src/kitemviews')
-rw-r--r--src/kitemviews/kfileitemmodelrolesupdater.cpp12
-rw-r--r--src/kitemviews/kitemlistcontainer.cpp22
-rw-r--r--src/kitemviews/kitemlistwidget.cpp4
-rw-r--r--src/kitemviews/kstandarditemlistwidget.cpp17
-rw-r--r--src/kitemviews/kstandarditemlistwidget.h3
-rw-r--r--src/kitemviews/private/kbaloorolesprovider.h2
-rw-r--r--src/kitemviews/private/kitemlistsmoothscroller.cpp25
-rw-r--r--src/kitemviews/private/kitemlistsmoothscroller.h12
8 files changed, 35 insertions, 62 deletions
diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp b/src/kitemviews/kfileitemmodelrolesupdater.cpp
index e5353dc2a..92a020003 100644
--- a/src/kitemviews/kfileitemmodelrolesupdater.cpp
+++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp
@@ -133,7 +133,7 @@ KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel* model, QO
connect(m_directoryContentsCounter, &KDirectoryContentsCounter::result,
this, &KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived);
- auto plugins = KPluginLoader::instantiatePlugins(QStringLiteral("kf5/overlayicon"), nullptr, this);
+ auto plugins = KPluginLoader::instantiatePlugins(QStringLiteral("kf5/overlayicon"), nullptr, qApp);
foreach (QObject *it, plugins) {
auto plugin = qobject_cast<KOverlayIconPlugin*>(it);
if (plugin) {
@@ -374,9 +374,9 @@ void KFileItemModelRolesUpdater::slotItemsRemoved(const KItemRangeList& itemRang
m_balooFileMonitor->clear();
} else {
QStringList newFileList;
- foreach (const QString& itemUrl, m_balooFileMonitor->files()) {
- if (m_model->index(itemUrl) >= 0) {
- newFileList.append(itemUrl);
+ foreach (const QString& file, m_balooFileMonitor->files()) {
+ if (m_model->index(QUrl::fromLocalFile(file)) >= 0) {
+ newFileList.append(file);
}
}
m_balooFileMonitor->setFiles(newFileList);
@@ -707,10 +707,10 @@ void KFileItemModelRolesUpdater::resolveRecentlyChangedItems()
updateChangedItems();
}
-void KFileItemModelRolesUpdater::applyChangedBalooRoles(const QString& itemUrl)
+void KFileItemModelRolesUpdater::applyChangedBalooRoles(const QString& file)
{
#ifdef HAVE_BALOO
- const KFileItem item = m_model->fileItem(itemUrl);
+ const KFileItem item = m_model->fileItem(QUrl::fromLocalFile(file));
if (item.isNull()) {
// itemUrl is not in the model anymore, probably because
diff --git a/src/kitemviews/kitemlistcontainer.cpp b/src/kitemviews/kitemlistcontainer.cpp
index 69a0a5f27..6974ebb48 100644
--- a/src/kitemviews/kitemlistcontainer.cpp
+++ b/src/kitemviews/kitemlistcontainer.cpp
@@ -185,27 +185,7 @@ void KItemListContainer::wheelEvent(QWheelEvent* event)
KItemListSmoothScroller* smoothScroller = scrollHorizontally ?
m_horizontalSmoothScroller : m_verticalSmoothScroller;
- const QScrollBar* scrollBar = smoothScroller->scrollBar();
- if (!event->pixelDelta().isNull()) {
- const int numPixels = event->pixelDelta().y();
- if (event->modifiers().testFlag(Qt::ShiftModifier)) {
- const int scrollingDirection = numPixels > 0 ? 1 : -1;
- smoothScroller->scrollTo(scrollBar->value() - scrollBar->pageStep() * scrollingDirection);
- } else {
- smoothScroller->scrollTo(scrollBar->value() - numPixels);
- }
- } else {
- const int numDegrees = event->angleDelta().y() / 8;
- const int numSteps = qApp->wheelScrollLines() * numDegrees / 15;
- if (event->modifiers().testFlag(Qt::ShiftModifier)) {
- const int scrollingDirection = numSteps > 0 ? 1 : -1;
- smoothScroller->scrollTo(scrollBar->value() - scrollBar->pageStep() * scrollingDirection);
- } else {
- smoothScroller->scrollTo(scrollBar->value() - numSteps * scrollBar->pageStep() / 12);
- }
- }
-
- event->accept();
+ smoothScroller->handleWheelEvent(event);
}
void KItemListContainer::slotScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous)
diff --git a/src/kitemviews/kitemlistwidget.cpp b/src/kitemviews/kitemlistwidget.cpp
index b834e951f..9c31155b3 100644
--- a/src/kitemviews/kitemlistwidget.cpp
+++ b/src/kitemviews/kitemlistwidget.cpp
@@ -516,10 +516,10 @@ void KItemListWidget::clearHoverCache()
void KItemListWidget::drawItemStyleOption(QPainter* painter, QWidget* widget, QStyle::State styleState)
{
- QStyleOptionViewItemV4 viewItemOption;
+ QStyleOptionViewItem viewItemOption;
viewItemOption.initFrom(widget);
viewItemOption.state = styleState;
- viewItemOption.viewItemPosition = QStyleOptionViewItemV4::OnlyOne;
+ viewItemOption.viewItemPosition = QStyleOptionViewItem::OnlyOne;
viewItemOption.showDecorationSelected = true;
viewItemOption.rect = selectionRect().toRect();
widget->style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &viewItemOption, painter, widget);
diff --git a/src/kitemviews/kstandarditemlistwidget.cpp b/src/kitemviews/kstandarditemlistwidget.cpp
index 51c5bc896..8740cb73f 100644
--- a/src/kitemviews/kstandarditemlistwidget.cpp
+++ b/src/kitemviews/kstandarditemlistwidget.cpp
@@ -850,6 +850,15 @@ void KStandardItemListWidget::hideEvent(QHideEvent* event)
KItemListWidget::hideEvent(event);
}
+bool KStandardItemListWidget::event(QEvent *event)
+{
+ if (event->type() == QEvent::WindowDeactivate || event->type() == QEvent::WindowActivate) {
+ m_dirtyContent = true;
+ }
+
+ return KItemListWidget::event(event);
+}
+
void KStandardItemListWidget::slotCutItemsChanged()
{
const QUrl itemUrl = data().value("url").toUrl();
@@ -954,7 +963,7 @@ void KStandardItemListWidget::updatePixmapCache()
iconName = QStringLiteral("unknown");
}
const QStringList overlays = values["iconOverlays"].toStringList();
- m_pixmap = pixmapForIcon(iconName, overlays, maxIconHeight);
+ m_pixmap = pixmapForIcon(iconName, overlays, maxIconHeight, isSelected() && isActiveWindow() ? 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
@@ -1438,11 +1447,11 @@ void KStandardItemListWidget::closeRoleEditor()
m_roleEditor = 0;
}
-QPixmap KStandardItemListWidget::pixmapForIcon(const QString& name, const QStringList& overlays, int size)
+QPixmap KStandardItemListWidget::pixmapForIcon(const QString& name, const QStringList& overlays, int size, QIcon::Mode mode)
{
static const QIcon fallbackIcon = QIcon::fromTheme(QStringLiteral("unknown"));
size *= qApp->devicePixelRatio();
- const QString key = "KStandardItemListWidget:" % name % ":" % overlays.join(QStringLiteral(":")) % ":" % QString::number(size);
+ const QString key = "KStandardItemListWidget:" % name % ":" % overlays.join(QStringLiteral(":")) % ":" % QString::number(size) % ":" % QString::number(mode);
QPixmap pixmap;
if (!QPixmapCache::find(key, pixmap)) {
@@ -1467,7 +1476,7 @@ QPixmap KStandardItemListWidget::pixmapForIcon(const QString& name, const QStrin
requestedSize = size;
}
- pixmap = icon.pixmap(requestedSize / qApp->devicePixelRatio(), requestedSize / qApp->devicePixelRatio());
+ pixmap = icon.pixmap(requestedSize / qApp->devicePixelRatio(), requestedSize / qApp->devicePixelRatio(), mode);
if (requestedSize != size) {
KPixmapModifier::scale(pixmap, QSize(size, size));
}
diff --git a/src/kitemviews/kstandarditemlistwidget.h b/src/kitemviews/kstandarditemlistwidget.h
index 9ab5d4c8f..e6ba4bb3f 100644
--- a/src/kitemviews/kstandarditemlistwidget.h
+++ b/src/kitemviews/kstandarditemlistwidget.h
@@ -183,6 +183,7 @@ protected:
virtual void resizeEvent(QGraphicsSceneResizeEvent* event) Q_DECL_OVERRIDE;
virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
virtual void hideEvent(QHideEvent* event) Q_DECL_OVERRIDE;
+ bool event(QEvent *event) Q_DECL_OVERRIDE;
private slots:
void slotCutItemsChanged();
@@ -212,7 +213,7 @@ private:
*/
void closeRoleEditor();
- static QPixmap pixmapForIcon(const QString& name, const QStringList& overlays, int size);
+ static QPixmap pixmapForIcon(const QString& name, const QStringList& overlays, int size, QIcon::Mode mode);
/**
* @return Preferred size of the rating-image based on the given
diff --git a/src/kitemviews/private/kbaloorolesprovider.h b/src/kitemviews/private/kbaloorolesprovider.h
index 9673bff4f..a9bd2e8ef 100644
--- a/src/kitemviews/private/kbaloorolesprovider.h
+++ b/src/kitemviews/private/kbaloorolesprovider.h
@@ -82,7 +82,7 @@ private:
QSet<QByteArray> m_roles;
QHash<QString, QByteArray> m_roleForProperty;
- friend class KBalooRolesProviderSingleton;
+ friend struct KBalooRolesProviderSingleton;
};
#endif
diff --git a/src/kitemviews/private/kitemlistsmoothscroller.cpp b/src/kitemviews/private/kitemlistsmoothscroller.cpp
index c89d3cf8f..6bfdba4c9 100644
--- a/src/kitemviews/private/kitemlistsmoothscroller.cpp
+++ b/src/kitemviews/private/kitemlistsmoothscroller.cpp
@@ -172,8 +172,7 @@ bool KItemListSmoothScroller::eventFilter(QObject* obj, QEvent* event)
break;
case QEvent::Wheel:
- handleWheelEvent(static_cast<QWheelEvent*>(event));
- return true; // eat event so that QScrollBar does not scroll one step more by itself
+ return false; // we're the ones sending them
default:
break;
@@ -196,25 +195,11 @@ void KItemListSmoothScroller::handleWheelEvent(QWheelEvent* event)
const bool previous = m_smoothScrolling;
m_smoothScrolling = true;
- int numPixels;
- if (!event->pixelDelta().isNull()) {
- numPixels = event->pixelDelta().y();
- } else {
- const int numDegrees = event->angleDelta().y() / 8;
- const int numSteps = qApp->wheelScrollLines() * numDegrees / 15;
- numPixels = numSteps * m_scrollBar->pageStep() / 12;
- }
- int value = m_scrollBar->value();
- if (event->modifiers().testFlag(Qt::ShiftModifier)) {
- const int scrollingDirection = numPixels > 0 ? 1 : -1;
- value -= m_scrollBar->pageStep() * scrollingDirection;
- } else {
- value -= numPixels;
- }
- m_scrollBar->setValue(value);
- m_smoothScrolling = previous;
+ QWheelEvent copy = *event;
+ QApplication::sendEvent(m_scrollBar, &copy);
+ event->setAccepted(copy.isAccepted());
- event->accept();
+ m_smoothScrolling = previous;
}
diff --git a/src/kitemviews/private/kitemlistsmoothscroller.h b/src/kitemviews/private/kitemlistsmoothscroller.h
index fca4b0c53..a3576a3fd 100644
--- a/src/kitemviews/private/kitemlistsmoothscroller.h
+++ b/src/kitemviews/private/kitemlistsmoothscroller.h
@@ -77,6 +77,11 @@ public:
// stable.
bool requestScrollBarUpdate(int newMaximum);
+ /**
+ * Forwards wheel events to the scrollbar, ensuring smooth and proper scrolling
+ */
+ void handleWheelEvent(QWheelEvent* event);
+
protected:
virtual bool eventFilter(QObject* obj, QEvent* event);
@@ -85,13 +90,6 @@ private slots:
QAbstractAnimation::State oldState);
private:
- /**
- * Results into a smooth-scrolling of the target dependent on the direction
- * of the wheel event.
- */
- void handleWheelEvent(QWheelEvent* event);
-
-private:
bool m_scrollBarPressed;
bool m_smoothScrolling;
QScrollBar* m_scrollBar;