From 1bac8668d7492a2e363f609efd30366a4cf798b7 Mon Sep 17 00:00:00 2001 From: Dawit Alemayehu Date: Mon, 3 Sep 2012 17:53:03 -0400 Subject: Implemented the new KParts' listing filter extension, KParts::ListingFilterExtension. REVIEW: 106289 --- src/kitemviews/kfileitemmodel.cpp | 78 +++++++++++++++---------- src/kitemviews/kfileitemmodel.h | 8 +++ src/kitemviews/private/kfileitemmodelfilter.cpp | 51 ++++++++++++++++ src/kitemviews/private/kfileitemmodelfilter.h | 29 ++++++++- 4 files changed, 133 insertions(+), 33 deletions(-) (limited to 'src/kitemviews') diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index 6936af431..752bc9365 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -508,46 +508,64 @@ void KFileItemModel::setNameFilter(const QString& nameFilter) { if (m_filter.pattern() != nameFilter) { dispatchPendingItemsToInsert(); - m_filter.setPattern(nameFilter); + applyFilters(); + } +} + +QString KFileItemModel::nameFilter() const +{ + return m_filter.pattern(); +} + +void KFileItemModel::setMimeTypeFilters(const QStringList& filters) +{ + if (m_filter.mimeTypes() != filters) { + dispatchPendingItemsToInsert(); + m_filter.setMimeTypes(filters); + applyFilters(); + } +} + +QStringList KFileItemModel::mimeTypeFilters() const +{ + return m_filter.mimeTypes(); +} - // Check which shown items from m_itemData must get - // hidden and hence moved to m_filteredItems. - KFileItemList newFilteredItems; - foreach (ItemData* itemData, m_itemData) { +void KFileItemModel::applyFilters() +{ + // Check which shown items from m_itemData must get + // hidden and hence moved to m_filteredItems. + KFileItemList newFilteredItems; + + foreach (ItemData* itemData, m_itemData) { + // Only filter non-expanded items as child items may never + // exist without a parent item + if (!itemData->values.value("isExpanded").toBool()) { if (!m_filter.matches(itemData->item)) { - // Only filter non-expanded items as child items may never - // exist without a parent item - if (!itemData->values.value("isExpanded").toBool()) { - newFilteredItems.append(itemData->item); - m_filteredItems.insert(itemData->item); - } + newFilteredItems.append(itemData->item); + m_filteredItems.insert(itemData->item); } } + } - removeItems(newFilteredItems); + removeItems(newFilteredItems); - // Check which hidden items from m_filteredItems should - // get visible again and hence removed from m_filteredItems. - KFileItemList newVisibleItems; + // Check which hidden items from m_filteredItems should + // get visible again and hence removed from m_filteredItems. + KFileItemList newVisibleItems; - QMutableSetIterator it(m_filteredItems); - while (it.hasNext()) { - const KFileItem item = it.next(); - if (m_filter.matches(item)) { - newVisibleItems.append(item); - it.remove(); - } + QMutableSetIterator it(m_filteredItems); + while (it.hasNext()) { + const KFileItem item = it.next(); + if (m_filter.matches(item)) { + newVisibleItems.append(item); + it.remove(); } - - insertItems(newVisibleItems); } -} -QString KFileItemModel::nameFilter() const -{ - return m_filter.pattern(); + insertItems(newVisibleItems); } QList KFileItemModel::rolesInformation() @@ -729,10 +747,10 @@ void KFileItemModel::slotNewItems(const KFileItemList& items) } } - if (m_filter.pattern().isEmpty()) { + if (!m_filter.hasSetFilters()) { m_pendingItemsToInsert.append(items); } else { - // The name-filter is active. Hide filtered items + // The name or type filter is active. Hide filtered items // before inserting them into the model and remember // the filtered items in m_filteredItems. KFileItemList filteredItems; diff --git a/src/kitemviews/kfileitemmodel.h b/src/kitemviews/kfileitemmodel.h index d9bebdf02..958fa104b 100644 --- a/src/kitemviews/kfileitemmodel.h +++ b/src/kitemviews/kfileitemmodel.h @@ -179,6 +179,9 @@ public: void setNameFilter(const QString& nameFilter); QString nameFilter() const; + void setMimeTypeFilters(const QStringList& filters); + QStringList mimeTypeFilters() const; + struct RoleInfo { QByteArray role; QString translation; @@ -388,6 +391,11 @@ private: */ void emitSortProgress(int resolvedCount); + /** + * Applies the filters set through @ref setNameFilter and @ref setMimeTypeFilters. + */ + void applyFilters(); + /** * Maps the QByteArray-roles to RoleTypes and provides translation- and * group-contexts. diff --git a/src/kitemviews/private/kfileitemmodelfilter.cpp b/src/kitemviews/private/kfileitemmodelfilter.cpp index 816d35634..2e320f2d9 100644 --- a/src/kitemviews/private/kfileitemmodelfilter.cpp +++ b/src/kitemviews/private/kfileitemmodelfilter.cpp @@ -23,6 +23,7 @@ #include #include + KFileItemModelFilter::KFileItemModelFilter() : m_useRegExp(false), m_regExp(0), @@ -61,7 +62,46 @@ QString KFileItemModelFilter::pattern() const return m_pattern; } +void KFileItemModelFilter::setMimeTypes(const QStringList& types) +{ + m_mimeTypes = types; +} + +QStringList KFileItemModelFilter::mimeTypes() const +{ + return m_mimeTypes; +} + +bool KFileItemModelFilter::hasSetFilters() const +{ + return (!m_pattern.isEmpty() || !m_mimeTypes.isEmpty()); +} + + bool KFileItemModelFilter::matches(const KFileItem& item) const +{ + const bool hasPatternFilter = !m_pattern.isEmpty(); + const bool hasMimeTypesFilter = !m_mimeTypes.isEmpty(); + + // If no filter is set, return true. + if (!hasPatternFilter && !hasMimeTypesFilter) { + return true; + } + + // If both filters are set, return true when both filters are matched + if (hasPatternFilter && hasMimeTypesFilter) { + return (matchesPattern(item) && matchesType(item)); + } + + // If only one filter is set, return true when that filter is matched + if (hasPatternFilter) { + return matchesPattern(item); + } + + return matchesType(item); +} + +bool KFileItemModelFilter::matchesPattern(const KFileItem& item) const { if (m_useRegExp) { return m_regExp->exactMatch(item.text()); @@ -69,3 +109,14 @@ bool KFileItemModelFilter::matches(const KFileItem& item) const return item.text().toLower().contains(m_lowerCasePattern); } } + +bool KFileItemModelFilter::matchesType(const KFileItem& item) const +{ + foreach (const QString& mimeType, m_mimeTypes) { + if (item.mimetype() == mimeType) { + return true; + } + } + + return m_mimeTypes.isEmpty(); +} diff --git a/src/kitemviews/private/kfileitemmodelfilter.h b/src/kitemviews/private/kfileitemmodelfilter.h index 9bdf1fd95..e4fb0a2ee 100644 --- a/src/kitemviews/private/kfileitemmodelfilter.h +++ b/src/kitemviews/private/kfileitemmodelfilter.h @@ -22,7 +22,7 @@ #define KFILEITEMMODELFILTER_H #include -#include +#include class KFileItem; class QRegExp; @@ -51,19 +51,42 @@ public: void setPattern(const QString& pattern); QString pattern() const; + /** + * Set the list of mimetypes that are used for comparison with the + * item in KFileItemModelFilter::matchesMimeType. + */ + void setMimeTypes(const QStringList& types); + QStringList mimeTypes() const; + + /** + * @return True if either the pattern or mimetype filters has been set. + */ + bool hasSetFilters() const; + /** * @return True if the item matches with the pattern defined by - * KFileItemModelFilter::setPattern(). + * @ref setPattern() or @ref setMimeTypes */ bool matches(const KFileItem& item) const; private: + /** + * @return True if item matches pattern set by @ref setPattern. + */ + bool matchesPattern(const KFileItem& item) const; + + /** + * @return True if item matches mimetypes set by @ref setMimeTypes. + */ + bool matchesType(const KFileItem& item) const; + bool m_useRegExp; // If true, m_regExp is used for filtering, // otherwise m_lowerCaseFilter is used. QRegExp* m_regExp; QString m_lowerCasePattern; // Lowercase version of m_filter for // faster comparison in matches(). - QString m_pattern; // Property set by setFilter(). + QString m_pattern; // Property set by setPattern(). + QStringList m_mimeTypes; // Property set by setMimeTypes() }; #endif -- cgit v1.3 From 85dfec046fc6c0b3e888d099afe0af1bd742bebc Mon Sep 17 00:00:00 2001 From: Frank Reininghaus Date: Thu, 6 Sep 2012 07:51:22 +0200 Subject: Do not show '-' for additional info which is not available for an item I'm only backporting the removal of the '-', not the update for the line number calculation in Icons View, because this is the safest part of the patch and also the one that fixes the most annoying part of the bug. Thanks to Todd Jennings for the patch! BUG: 304752 REVIEW: 106304 (cherry picked from commit 20b0cb68bf5cc1099fd6e61982817d9e2ae0130c) --- src/kitemviews/private/knepomukrolesprovider.cpp | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src/kitemviews') diff --git a/src/kitemviews/private/knepomukrolesprovider.cpp b/src/kitemviews/private/knepomukrolesprovider.cpp index 0ae9b6bd3..b0e179807 100644 --- a/src/kitemviews/private/knepomukrolesprovider.cpp +++ b/src/kitemviews/private/knepomukrolesprovider.cpp @@ -108,13 +108,6 @@ QHash KNepomukRolesProvider::roleValues(const Nepomuk::Res } } - // Assure that empty values get replaced by "-" - foreach (const QByteArray& role, roles) { - if (m_roles.contains(role) && values.value(role).toString().isEmpty()) { - values.insert(role, QLatin1String("-")); - } - } - return values; } -- cgit v1.3 From 8b11c747a04480dc6a433530d95790704c85c7e9 Mon Sep 17 00:00:00 2001 From: Dawit Alemayehu Date: Tue, 4 Sep 2012 22:26:28 -0400 Subject: Implemented the new KParts extension, KParts::ListingiNotificationExtension. REVIEW: 106333 --- src/dolphinpart.cpp | 35 ++++++++++++++++++++++++++++++++++- src/dolphinpart.h | 13 +++++++++++++ src/kitemviews/kfileitemmodel.h | 1 + src/views/dolphinview.h | 1 + 4 files changed, 49 insertions(+), 1 deletion(-) (limited to 'src/kitemviews') diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index bf3d2a54f..a957fa665 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -45,6 +45,8 @@ #include "views/dolphinviewactionhandler.h" #include "views/dolphinnewfilemenuobserver.h" #include "views/dolphinremoteencoding.h" +#include "kitemviews/kfileitemmodel.h" +#include "kitemviews/private/kfileitemmodeldirlister.h" #include #include @@ -120,6 +122,15 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL new DolphinPartFileInfoExtension(this); new DolphinPartListingFilterExtension(this); + KDirLister* lister = m_view->m_model->m_dirLister; + if (lister) { + DolphinPartListingNotificationExtension* notifyExt = new DolphinPartListingNotificationExtension(this); + connect(lister, SIGNAL(newItems(KFileItemList)), notifyExt, SLOT(slotNewItems(KFileItemList))); + connect(lister, SIGNAL(itemsDeleted(KFileItemList)), notifyExt, SLOT(slotItemsDeleted(KFileItemList))); + } else { + kWarning() << "NULL KDirLister object! KParts::ListingNotificationExtension will NOT be supported"; + } + createActions(); m_actionHandler->updateViewActions(); slotSelectionChanged(KFileItemList()); // initially disable selection-dependent actions @@ -128,7 +139,6 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL // (sort of spacial navigation) loadPlugins(this, this, componentData()); - } DolphinPart::~DolphinPart() @@ -706,4 +716,27 @@ void DolphinPartListingFilterExtension::setFilter (KParts::ListingFilterExtensio } } +//// + +DolphinPartListingNotificationExtension::DolphinPartListingNotificationExtension(DolphinPart* part) + :KParts::ListingNotificationExtension(part) +{ +} + +KParts::ListingNotificationExtension::NotificationEventTypes DolphinPartListingNotificationExtension::supportedNotificationEventTypes() const +{ + return (KParts::ListingNotificationExtension::ItemsAdded | + KParts::ListingNotificationExtension::ItemsDeleted); +} + +void DolphinPartListingNotificationExtension::slotNewItems(const KFileItemList& items) +{ + emit listingEvent(KParts::ListingNotificationExtension::ItemsAdded, items); +} + +void DolphinPartListingNotificationExtension::slotItemsDeleted(const KFileItemList& items) +{ + emit listingEvent(KParts::ListingNotificationExtension::ItemsDeleted, items); +} + #include "dolphinpart.moc" diff --git a/src/dolphinpart.h b/src/dolphinpart.h index f9c0bbf62..6cf9fe324 100644 --- a/src/dolphinpart.h +++ b/src/dolphinpart.h @@ -297,4 +297,17 @@ private: DolphinPart* m_part; }; +class DolphinPartListingNotificationExtension : public KParts::ListingNotificationExtension +{ + Q_OBJECT + +public: + DolphinPartListingNotificationExtension(DolphinPart* part); + virtual NotificationEventTypes supportedNotificationEventTypes() const; + +public Q_SLOTS: + void slotNewItems(const KFileItemList&); + void slotItemsDeleted(const KFileItemList&); +}; + #endif /* DOLPHINPART_H */ diff --git a/src/kitemviews/kfileitemmodel.h b/src/kitemviews/kfileitemmodel.h index 958fa104b..5bcebce24 100644 --- a/src/kitemviews/kfileitemmodel.h +++ b/src/kitemviews/kfileitemmodel.h @@ -475,6 +475,7 @@ private: friend class KFileItemModelRolesUpdater; // Accesses emitSortProgress() method friend class KFileItemModelTest; // For unit testing friend class KFileItemListViewTest; // For unit testing + friend class DolphinPart; // Accesses m_dirLister }; inline bool KFileItemModel::isChildItem(int index) const diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h index 3f08c4480..3f71fdc54 100644 --- a/src/views/dolphinview.h +++ b/src/views/dolphinview.h @@ -764,6 +764,7 @@ private: // For unit tests friend class TestBase; friend class DolphinDetailsViewTest; + friend class DolphinPart; // Accesses m_model }; /// Allow using DolphinView::Mode in QVariant -- cgit v1.3 From 7de641316a40ac1b570f66e5ca4109fe0b6f6702 Mon Sep 17 00:00:00 2001 From: Frank Reininghaus Date: Tue, 11 Sep 2012 19:34:23 +0200 Subject: Fix possible crash in KStandardItemListWidget::paint() According to the backtrace in the bug report, it is possible that KStandardItemListWidget::paint() is called if the hash m_textInfo has not been initialised. The widget's index must be -1 in this case, see KStandardItemListWidget::triggerCacheRefreshing(). It looks like this can only happen if the item is about to be removed from the view, see KItemListView::slotItemsRemoved(). I could not reproduce the crash, so I'm not sure why exactly this happens, but this commit should at least prevent the crash. BUG: 306167 FIXED-IN: 4.9.2 --- src/kitemviews/kstandarditemlistwidget.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/kitemviews') diff --git a/src/kitemviews/kstandarditemlistwidget.cpp b/src/kitemviews/kstandarditemlistwidget.cpp index 7ae7e2efc..72d10cf40 100644 --- a/src/kitemviews/kstandarditemlistwidget.cpp +++ b/src/kitemviews/kstandarditemlistwidget.cpp @@ -263,6 +263,16 @@ void KStandardItemListWidget::paint(QPainter* painter, const QStyleOptionGraphic painter->setFont(m_customizedFont); painter->setPen(m_isHidden ? m_additionalInfoTextColor : textColor()); const TextInfo* textInfo = m_textInfo.value("text"); + + if (!textInfo) { + // It seems that we can end up here even if m_textInfo does not contain + // the key "text", see bug 306167. According to triggerCacheRefreshing(), + // this can only happen if the index is negative. This can happen when + // the item is about to be removed, see KItemListView::slotItemsRemoved(). + // TODO: try to reproduce the crash and find a better fix. + return; + } + painter->drawStaticText(textInfo->pos, textInfo->staticText); bool clipAdditionalInfoBounds = false; -- cgit v1.3 From 580bcae62c1b0de6b7c6be42f68ead5c6d6c9d19 Mon Sep 17 00:00:00 2001 From: Emmanuel Pescosta Date: Wed, 19 Sep 2012 19:00:52 +0200 Subject: Fixes Bug 293200 - Drag&drop files in dolphin doesnt preserve origin Patch 106381 Comment #3: When "Open folders during drag operations" is enabled, two things happen, both in the DolphinView and in the Folders Panel: 1) When hovering a folder that can be expanded (this is the case for folders with sub-folders in the Folders Panel and in the DolphinView if in Details View mode), toggle its "expanded" state. 2) When hovering a folder that can not be expanded (i.e., a folder without sub-folders or any folder in Icons or Compact View), open this folder in the DolphinView via the KItemListController's itemActivated(int) signal. The bug described in bug 293200 comment 3 is that 1) is always wanted, but 2) is not wanted for the Folders Panel. BUG: 293200 FIXED-IN: 4.9.2 --- src/kitemviews/kitemlistcontroller.cpp | 13 ++++++++++++- src/kitemviews/kitemlistcontroller.h | 10 ++++++++++ src/panels/folders/folderspanel.cpp | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) (limited to 'src/kitemviews') diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp index 88f5d9f7c..52f8e0078 100644 --- a/src/kitemviews/kitemlistcontroller.cpp +++ b/src/kitemviews/kitemlistcontroller.cpp @@ -47,6 +47,7 @@ KItemListController::KItemListController(KItemModelBase* model, KItemListView* v m_selectionTogglePressed(false), m_clearSelectionIfItemsAreNotDragged(false), m_selectionBehavior(NoSelection), + m_autoActivationBehavior(ActivationAndExpansion), m_model(0), m_view(0), m_selectionManager(new KItemListSelectionManager(this)), @@ -157,6 +158,16 @@ KItemListController::SelectionBehavior KItemListController::selectionBehavior() return m_selectionBehavior; } +void KItemListController::setAutoActivationBehavior(AutoActivationBehavior behavior) +{ + m_autoActivationBehavior = behavior; +} + +KItemListController::AutoActivationBehavior KItemListController::autoActivationBehavior() const +{ + return m_autoActivationBehavior; +} + void KItemListController::setAutoActivationDelay(int delay) { m_autoActivationTimer->setInterval(delay); @@ -471,7 +482,7 @@ void KItemListController::slotAutoActivationTimeout() if (m_view->supportsItemExpanding() && m_model->isExpandable(index)) { const bool expanded = m_model->isExpanded(index); m_model->setExpanded(index, !expanded); - } else { + } else if (m_autoActivationBehavior != ExpansionOnly) { emit itemActivated(index); } } diff --git a/src/kitemviews/kitemlistcontroller.h b/src/kitemviews/kitemlistcontroller.h index a88152622..1ffd78564 100644 --- a/src/kitemviews/kitemlistcontroller.h +++ b/src/kitemviews/kitemlistcontroller.h @@ -64,6 +64,7 @@ class LIBDOLPHINPRIVATE_EXPORT KItemListController : public QObject Q_PROPERTY(KItemModelBase* model READ model WRITE setModel) Q_PROPERTY(KItemListView *view READ view WRITE setView) Q_PROPERTY(SelectionBehavior selectionBehavior READ selectionBehavior WRITE setSelectionBehavior) + Q_PROPERTY(AutoActivationBehavior autoActivationBehavior READ autoActivationBehavior WRITE setAutoActivationBehavior) public: enum SelectionBehavior { @@ -72,6 +73,11 @@ public: MultiSelection }; + enum AutoActivationBehavior { + ActivationAndExpansion, + ExpansionOnly + }; + /** * @param model Model of the controller. The ownership is passed to the controller. * @param view View of the controller. The ownership is passed to the controller. @@ -91,6 +97,9 @@ public: void setSelectionBehavior(SelectionBehavior behavior); SelectionBehavior selectionBehavior() const; + void setAutoActivationBehavior(AutoActivationBehavior behavior); + AutoActivationBehavior autoActivationBehavior() const; + /** * Sets the delay in milliseconds when dragging an object above an item * until the item gets activated automatically. A value of -1 indicates @@ -287,6 +296,7 @@ private: bool m_selectionTogglePressed; bool m_clearSelectionIfItemsAreNotDragged; SelectionBehavior m_selectionBehavior; + AutoActivationBehavior m_autoActivationBehavior; KItemModelBase* m_model; KItemListView* m_view; KItemListSelectionManager* m_selectionManager; diff --git a/src/panels/folders/folderspanel.cpp b/src/panels/folders/folderspanel.cpp index 0760200b6..e04842c4c 100644 --- a/src/panels/folders/folderspanel.cpp +++ b/src/panels/folders/folderspanel.cpp @@ -140,6 +140,7 @@ void FoldersPanel::showEvent(QShowEvent* event) m_controller = new KItemListController(m_model, view, this); m_controller->setSelectionBehavior(KItemListController::SingleSelection); + m_controller->setAutoActivationBehavior(KItemListController::ExpansionOnly); m_controller->setAutoActivationDelay(750); m_controller->setSingleClickActivation(true); -- cgit v1.3 From 904d7b0701f742328c531d262b345b0b2cba5f5a Mon Sep 17 00:00:00 2001 From: Emmanuel Pescosta Date: Thu, 20 Sep 2012 17:56:32 +0200 Subject: Restore old behavior: Navigating by double-clicking in folder panel (Double-Click - show folder content and expand folder) BUG: 295573 REVIEW: 106497 FIXED-IN: 4.9.2 --- src/kitemviews/kitemlistcontroller.cpp | 19 +++++++++++++++++++ src/kitemviews/kitemlistcontroller.h | 10 ++++++++++ src/panels/folders/folderspanel.cpp | 1 + 3 files changed, 30 insertions(+) (limited to 'src/kitemviews') diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp index 52f8e0078..41a86324b 100644 --- a/src/kitemviews/kitemlistcontroller.cpp +++ b/src/kitemviews/kitemlistcontroller.cpp @@ -48,6 +48,7 @@ KItemListController::KItemListController(KItemModelBase* model, KItemListView* v m_clearSelectionIfItemsAreNotDragged(false), m_selectionBehavior(NoSelection), m_autoActivationBehavior(ActivationAndExpansion), + m_mouseDoubleClickAction(ActivateItemOnly), m_model(0), m_view(0), m_selectionManager(new KItemListSelectionManager(this)), @@ -168,6 +169,16 @@ KItemListController::AutoActivationBehavior KItemListController::autoActivationB return m_autoActivationBehavior; } +void KItemListController::setMouseDoubleClickAction(MouseDoubleClickAction action) +{ + m_mouseDoubleClickAction = action; +} + +KItemListController::MouseDoubleClickAction KItemListController::mouseDoubleClickAction() const +{ + return m_mouseDoubleClickAction; +} + void KItemListController::setAutoActivationDelay(int delay) { m_autoActivationTimer->setInterval(delay); @@ -755,6 +766,14 @@ bool KItemListController::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event, const QPointF pos = transform.map(event->pos()); const int index = m_view->itemAt(pos); + // Expand item if desired - See Bug 295573 + if (m_mouseDoubleClickAction != ActivateItemOnly) { + if (m_view && m_model && m_view->supportsItemExpanding() && m_model->isExpandable(index)) { + const bool expanded = m_model->isExpanded(index); + m_model->setExpanded(index, !expanded); + } + } + bool emitItemActivated = !m_singleClickActivation && (event->button() & Qt::LeftButton) && index >= 0 && index < m_model->count(); diff --git a/src/kitemviews/kitemlistcontroller.h b/src/kitemviews/kitemlistcontroller.h index 1ffd78564..235e4a9eb 100644 --- a/src/kitemviews/kitemlistcontroller.h +++ b/src/kitemviews/kitemlistcontroller.h @@ -65,6 +65,7 @@ class LIBDOLPHINPRIVATE_EXPORT KItemListController : public QObject Q_PROPERTY(KItemListView *view READ view WRITE setView) Q_PROPERTY(SelectionBehavior selectionBehavior READ selectionBehavior WRITE setSelectionBehavior) Q_PROPERTY(AutoActivationBehavior autoActivationBehavior READ autoActivationBehavior WRITE setAutoActivationBehavior) + Q_PROPERTY(MouseDoubleClickAction mouseDoubleClickAction READ mouseDoubleClickAction WRITE setMouseDoubleClickAction) public: enum SelectionBehavior { @@ -78,6 +79,11 @@ public: ExpansionOnly }; + enum MouseDoubleClickAction { + ActivateAndExpandItem, + ActivateItemOnly + }; + /** * @param model Model of the controller. The ownership is passed to the controller. * @param view View of the controller. The ownership is passed to the controller. @@ -100,6 +106,9 @@ public: void setAutoActivationBehavior(AutoActivationBehavior behavior); AutoActivationBehavior autoActivationBehavior() const; + void setMouseDoubleClickAction(MouseDoubleClickAction action); + MouseDoubleClickAction mouseDoubleClickAction() const; + /** * Sets the delay in milliseconds when dragging an object above an item * until the item gets activated automatically. A value of -1 indicates @@ -297,6 +306,7 @@ private: bool m_clearSelectionIfItemsAreNotDragged; SelectionBehavior m_selectionBehavior; AutoActivationBehavior m_autoActivationBehavior; + MouseDoubleClickAction m_mouseDoubleClickAction; KItemModelBase* m_model; KItemListView* m_view; KItemListSelectionManager* m_selectionManager; diff --git a/src/panels/folders/folderspanel.cpp b/src/panels/folders/folderspanel.cpp index e04842c4c..13093fff6 100644 --- a/src/panels/folders/folderspanel.cpp +++ b/src/panels/folders/folderspanel.cpp @@ -141,6 +141,7 @@ void FoldersPanel::showEvent(QShowEvent* event) m_controller = new KItemListController(m_model, view, this); m_controller->setSelectionBehavior(KItemListController::SingleSelection); m_controller->setAutoActivationBehavior(KItemListController::ExpansionOnly); + m_controller->setMouseDoubleClickAction(KItemListController::ActivateAndExpandItem); m_controller->setAutoActivationDelay(750); m_controller->setSingleClickActivation(true); -- cgit v1.3