From 09ba6bcb62297c45c0a5ea664aca1ecb52ba0149 Mon Sep 17 00:00:00 2001 From: Weng Xuetian Date: Mon, 27 Aug 2012 13:55:17 -0400 Subject: Make --select can automatically scroll to the selected file. REVIEW: 106209 --- src/dolphinpart.cpp | 5 +++++ src/views/dolphinview.cpp | 30 ++++++++++-------------------- src/views/dolphinview.h | 14 +++----------- 3 files changed, 18 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index d1626e55d..fff7dc0e0 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -554,7 +554,12 @@ void DolphinPart::createDirectory() void DolphinPart::setFilesToSelect(const KUrl::List& files) { + if (files.isEmpty()) { + return; + } + m_view->markUrlsAsSelected(files); + m_view->markUrlAsCurrent(files.at(0)); } //// diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 7cfb3fc41..f2b0a5c8c 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -98,8 +98,8 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) : m_toolTipManager(0), m_selectionChangedTimer(0), m_currentItemUrl(), + m_scrollToCurrentItem(false), m_restoredContentsPosition(), - m_createdItemUrl(), m_selectedUrls(), m_versionControlObserver(0) { @@ -363,6 +363,7 @@ void DolphinView::markUrlsAsSelected(const QList& urls) void DolphinView::markUrlAsCurrent(const KUrl& url) { m_currentItemUrl = url; + m_scrollToCurrentItem = true; } void DolphinView::selectItems(const QRegExp& pattern, bool enabled) @@ -1142,25 +1143,8 @@ QString DolphinView::viewPropertiesContext() const void DolphinView::observeCreatedItem(const KUrl& url) { - m_createdItemUrl = url; - connect(m_model, SIGNAL(directoryLoadingCompleted()), - this, SLOT(selectAndScrollToCreatedItem())); -} - -void DolphinView::selectAndScrollToCreatedItem() -{ - KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager(); - const int index = m_model->index(m_createdItemUrl); - if (index != -1) { - selectionManager->setCurrentItem(index); - selectionManager->clearSelection(); - selectionManager->setSelected(index); - m_view->scrollToItem(index); - } - - disconnect(m_model, SIGNAL(directoryLoadingCompleted()), - this, SLOT(selectAndScrollToCreatedItem())); - m_createdItemUrl = KUrl(); + markUrlAsCurrent(url); + markUrlsAsSelected(QList() << url); } void DolphinView::slotDirectoryRedirection(const KUrl& oldUrl, const KUrl& newUrl) @@ -1178,6 +1162,12 @@ void DolphinView::updateViewState() const int currentIndex = m_model->index(m_currentItemUrl); if (currentIndex != -1) { selectionManager->setCurrentItem(currentIndex); + + // scroll to current item and reset the state + if (m_scrollToCurrentItem) { + m_view->scrollToItem(currentIndex); + m_scrollToCurrentItem = false; + } } else { selectionManager->setCurrentItem(0); } diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h index 1ad4d6c82..10f63c57a 100644 --- a/src/views/dolphinview.h +++ b/src/views/dolphinview.h @@ -181,8 +181,8 @@ public: void markUrlsAsSelected(const QList& urls); /** - * Marks the item indicated by \p url as the current item after the - * directory DolphinView::url() has been loaded. + * Marks the item indicated by \p url to be scrolled to and as the + * current item after directory DolphinView::url() has been loaded. */ void markUrlAsCurrent(const KUrl& url); @@ -640,17 +640,9 @@ private slots: * Observes the item with the URL \a url. As soon as the directory * model indicates that the item is available, the item will * get selected and it is assured that the item stays visible. - * - * @see selectAndScrollToCreatedItem() */ void observeCreatedItem(const KUrl& url); - /** - * Selects and scrolls to the item that got observed - * by observeCreatedItem(). - */ - void selectAndScrollToCreatedItem(); - /** * Called when a redirection happens. * Testcase: fish://localhost @@ -754,8 +746,8 @@ private: QTimer* m_selectionChangedTimer; KUrl m_currentItemUrl; // Used for making the view to remember the current URL after F5 + bool m_scrollToCurrentItem; // Used for marking we need to scroll to current item or not QPoint m_restoredContentsPosition; - KUrl m_createdItemUrl; // URL for a new item that got created by the "Create New..." menu QList m_selectedUrls; // Used for making the view to remember selections after F5 -- cgit v1.3 From bdd0b97662293bf5a9ecdedc46e0e4e48e6b237c Mon Sep 17 00:00:00 2001 From: Weng Xuetian Date: Wed, 29 Aug 2012 07:43:03 -0400 Subject: fix missing enum REVIEW: 106239 --- src/views/dolphinfileitemlistwidget.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/views/dolphinfileitemlistwidget.cpp b/src/views/dolphinfileitemlistwidget.cpp index 43030c634..33ee6a277 100644 --- a/src/views/dolphinfileitemlistwidget.cpp +++ b/src/views/dolphinfileitemlistwidget.cpp @@ -115,6 +115,8 @@ QPixmap DolphinFileItemListWidget::overlayForState(KVersionControlPlugin2::ItemV iconName = "vcs-conflicting"; break; case KVersionControlPlugin::UnversionedVersion: + case KVersionControlPlugin2::IgnoredVersion: + case KVersionControlPlugin2::MissingVersion: break; default: Q_ASSERT(false); -- cgit v1.3 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/dolphinpart.cpp | 61 ++++++++++++++++++- src/dolphinpart.h | 16 +++++ src/kitemviews/kfileitemmodel.cpp | 78 +++++++++++++++---------- src/kitemviews/kfileitemmodel.h | 8 +++ src/kitemviews/private/kfileitemmodelfilter.cpp | 51 ++++++++++++++++ src/kitemviews/private/kfileitemmodelfilter.h | 29 ++++++++- src/views/dolphinview.cpp | 10 ++++ src/views/dolphinview.h | 8 +++ 8 files changed, 227 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index fff7dc0e0..bf3d2a54f 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -61,7 +61,6 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL Q_UNUSED(args) setComponentData(DolphinPartFactory::componentData(), false); m_extension = new DolphinPartBrowserExtension(this); - new DolphinPartFileInfoExtension(this); // make sure that other apps using this part find Dolphin's view-file-columns icons KIconLoader::global()->addAppDir("dolphin"); @@ -116,6 +115,11 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL connect(clipboard, SIGNAL(dataChanged()), this, SLOT(updatePasteAction())); + // Create file info and listing filter extensions. + // NOTE: Listing filter needs to be instantiated after the creation of the view. + new DolphinPartFileInfoExtension(this); + new DolphinPartListingFilterExtension(this); + createActions(); m_actionHandler->updateViewActions(); slotSelectionChanged(KFileItemList()); // initially disable selection-dependent actions @@ -647,4 +651,59 @@ KFileItemList DolphinPartFileInfoExtension::queryFor(KParts::FileInfoExtension:: return list; } +DolphinPartListingFilterExtension::DolphinPartListingFilterExtension (DolphinPart* part) + : KParts::ListingFilterExtension(part) + , m_part(part) +{ +} + +KParts::ListingFilterExtension::FilterModes DolphinPartListingFilterExtension::supportedFilterModes() const +{ + return (KParts::ListingFilterExtension::MimeType | + KParts::ListingFilterExtension::SubString | + KParts::ListingFilterExtension::WildCard); +} + +bool DolphinPartListingFilterExtension::supportsMultipleFilters (KParts::ListingFilterExtension::FilterMode mode) const +{ + if (mode == KParts::ListingFilterExtension::MimeType) + return true; + + return false; +} + +QVariant DolphinPartListingFilterExtension::filter (KParts::ListingFilterExtension::FilterMode mode) const +{ + QVariant result; + + switch (mode) { + case KParts::ListingFilterExtension::MimeType: + result = m_part->view()->mimeTypeFilters(); + break; + case KParts::ListingFilterExtension::SubString: + case KParts::ListingFilterExtension::WildCard: + result = m_part->view()->nameFilter(); + break; + default: + break; + } + + return result; +} + +void DolphinPartListingFilterExtension::setFilter (KParts::ListingFilterExtension::FilterMode mode, const QVariant& filter) +{ + switch (mode) { + case KParts::ListingFilterExtension::MimeType: + m_part->view()->setMimeTypeFilters(filter.toStringList()); + break; + case KParts::ListingFilterExtension::SubString: + case KParts::ListingFilterExtension::WildCard: + m_part->view()->setNameFilter(filter.toString()); + break; + default: + break; + } +} + #include "dolphinpart.moc" diff --git a/src/dolphinpart.h b/src/dolphinpart.h index e5693b363..f9c0bbf62 100644 --- a/src/dolphinpart.h +++ b/src/dolphinpart.h @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -281,4 +282,19 @@ protected: DolphinPart* part() const; }; +class DolphinPartListingFilterExtension : public KParts::ListingFilterExtension +{ + Q_OBJECT + +public: + DolphinPartListingFilterExtension (DolphinPart* part); + virtual FilterModes supportedFilterModes() const; + virtual bool supportsMultipleFilters (FilterMode mode) const; + virtual QVariant filter (FilterMode mode) const; + virtual void setFilter (FilterMode mode, const QVariant& filter); + +private: + DolphinPart* m_part; +}; + #endif /* DOLPHINPART_H */ 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 diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index f2b0a5c8c..08e26c5d6 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -510,6 +510,16 @@ QString DolphinView::nameFilter() const return m_model->nameFilter(); } +void DolphinView::setMimeTypeFilters(const QStringList& filters) +{ + return m_model->setMimeTypeFilters(filters); +} + +QStringList DolphinView::mimeTypeFilters() const +{ + return m_model->mimeTypeFilters(); +} + QString DolphinView::statusBarText() const { QString summary; diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h index 10f63c57a..3f08c4480 100644 --- a/src/views/dolphinview.h +++ b/src/views/dolphinview.h @@ -237,6 +237,14 @@ public: void setNameFilter(const QString& nameFilter); QString nameFilter() const; + /** + * Filters the currently shown items by \a filters. All items + * whose content-type matches those given by the list of filters + * will be shown. + */ + void setMimeTypeFilters(const QStringList& filters); + QStringList mimeTypeFilters() const; + /** * Returns a textual representation of the state of the current * folder or selected items, suitable for use in the status bar. -- 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') 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') 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 f9ba9a7236a0252a54a51b2f70a04ab13c68f85b Mon Sep 17 00:00:00 2001 From: Frank Reininghaus Date: Tue, 11 Sep 2012 19:25:20 +0200 Subject: Use a better icon for recently accessed items, part 2 I had missed one places where the incorrect icon was used in my previous commit d7e7ca53bb95c7555bbf107d92b47ac25eda1918. BUG: 304323 FIXED-IN: 4.9.2 --- src/panels/places/placesitemmodel.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/panels/places/placesitemmodel.cpp b/src/panels/places/placesitemmodel.cpp index 497901345..bd50c9a4b 100644 --- a/src/panels/places/placesitemmodel.cpp +++ b/src/panels/places/placesitemmodel.cpp @@ -885,8 +885,7 @@ void PlacesItemModel::createSystemBookmarks() Q_ASSERT(m_systemBookmarks.isEmpty()); Q_ASSERT(m_systemBookmarksIndexes.isEmpty()); - const QString timeLineIcon = "package_utility_time"; // TODO: Ask the Oxygen team to create - // a custom icon for the timeline-protocol + const QString timeLineIcon = "chronometer"; // Note: The context of the I18N_NOOP2 must be "KFile System Bookmarks". The real // i18nc call is done after reading the bookmark. The reason why the i18nc call is not -- 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') 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 42dad0a9483de340118ce67622cb930619dd4699 Mon Sep 17 00:00:00 2001 From: Frank Reininghaus Date: Tue, 11 Sep 2012 19:43:53 +0200 Subject: Fix possible crash when refreshing the view while renaming inline It is not reproducible on every machine for me, but it seems that it can happen that DolphinView's slot slotRoleEditingFinished() is invoked after the items have already been removed from the model. In that case, we have to return from the slot immediately to prevent a crash. BUG: 306147 FIXED-IN: 4.9.2 --- src/views/dolphinview.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 08e26c5d6..72ccb8372 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -1321,6 +1321,10 @@ void DolphinView::slotVisibleRolesChangedByHeader(const QList& curre void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, const QVariant& value) { + if (index < 0 || index >= m_model->count()) { + return; + } + if (role == "text") { const KFileItem oldItem = m_model->fileItem(index); const QString newName = value.toString(); -- cgit v1.3 From 5fbc0101790adf5613e8c686a38bf9d831881a6d Mon Sep 17 00:00:00 2001 From: Emmanuel Pescosta Date: Tue, 11 Sep 2012 20:17:56 +0200 Subject: Mount unmounted devices, when a file is dropped upon it in places-panel. BUG: 176277 REVIEW: 106072 FIXED-IN: 4.9.2 (cherry picked from commit 824fa6a43734cf9ad2a690778c50bdaf76a1fb0e) --- src/panels/places/placespanel.cpp | 50 ++++++++++++++++++++++++++++++++++++++- src/panels/places/placespanel.h | 5 ++++ 2 files changed, 54 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/panels/places/placespanel.cpp b/src/panels/places/placespanel.cpp index d4450888e..4b28c8510 100644 --- a/src/panels/places/placespanel.cpp +++ b/src/panels/places/placespanel.cpp @@ -52,7 +52,10 @@ PlacesPanel::PlacesPanel(QWidget* parent) : m_controller(0), m_model(0), m_storageSetupFailedUrl(), - m_triggerStorageSetupButton() + m_triggerStorageSetupButton(), + m_itemDropEventIndex(-1), + m_itemDropEventMimeData(0), + m_itemDropEvent(0) { } @@ -268,6 +271,30 @@ void PlacesPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even return; } + if (m_model->storageSetupNeeded(index)) { + connect(m_model, SIGNAL(storageSetupDone(int,bool)), + this, SLOT(slotItemDropEventStorageSetupDone(int,bool))); + + m_itemDropEventIndex = index; + + // Make a full copy of the Mime-Data + m_itemDropEventMimeData = new QMimeData; + m_itemDropEventMimeData->setText(event->mimeData()->text()); + m_itemDropEventMimeData->setHtml(event->mimeData()->html()); + m_itemDropEventMimeData->setUrls(event->mimeData()->urls()); + m_itemDropEventMimeData->setImageData(event->mimeData()->imageData()); + m_itemDropEventMimeData->setColorData(event->mimeData()->colorData()); + + m_itemDropEvent = new QDropEvent(event->pos().toPoint(), + event->possibleActions(), + m_itemDropEventMimeData, + event->buttons(), + event->modifiers()); + + m_model->requestStorageSetup(index); + return; + } + KUrl destUrl = m_model->placesItem(index)->url(); QDropEvent dropEvent(event->pos().toPoint(), event->possibleActions(), @@ -278,6 +305,27 @@ void PlacesPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even DragAndDropHelper::dropUrls(KFileItem(), destUrl, &dropEvent); } +void PlacesPanel::slotItemDropEventStorageSetupDone(int index, bool success) +{ + disconnect(m_model, SIGNAL(storageSetupDone(int,bool)), + this, SLOT(slotItemDropEventStorageSetupDone(int,bool))); + + if ((index == m_itemDropEventIndex) && m_itemDropEvent && m_itemDropEventMimeData) { + if (success) { + KUrl destUrl = m_model->placesItem(index)->url(); + + DragAndDropHelper::dropUrls(KFileItem(), destUrl, m_itemDropEvent); + } + + delete m_itemDropEventMimeData; + delete m_itemDropEvent; + + m_itemDropEventIndex = -1; + m_itemDropEventMimeData = 0; + m_itemDropEvent = 0; + } +} + void PlacesPanel::slotAboveItemDropEvent(int index, QGraphicsSceneDragDropEvent* event) { m_model->dropMimeDataBefore(index, event->mimeData()); diff --git a/src/panels/places/placespanel.h b/src/panels/places/placespanel.h index 8a84e00a0..989a0916b 100644 --- a/src/panels/places/placespanel.h +++ b/src/panels/places/placespanel.h @@ -56,6 +56,7 @@ private slots: void slotItemContextMenuRequested(int index, const QPointF& pos); void slotViewContextMenuRequested(const QPointF& pos); void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event); + void slotItemDropEventStorageSetupDone(int index, bool success); void slotAboveItemDropEvent(int index, QGraphicsSceneDragDropEvent* event); void slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent); void slotTrashUpdated(KJob* job); @@ -80,6 +81,10 @@ private: KUrl m_storageSetupFailedUrl; Qt::MouseButton m_triggerStorageSetupButton; + + int m_itemDropEventIndex; + QMimeData* m_itemDropEventMimeData; + QDropEvent* m_itemDropEvent; }; #endif // PLACESPANEL_H -- cgit v1.3 From 7bccdf85f792ede6a66f7001f60278091b0df87b Mon Sep 17 00:00:00 2001 From: Dawit Alemayehu Date: Tue, 11 Sep 2012 16:40:32 -0400 Subject: Fix compile against the minimum required kdelibs version (v4.7.97) --- src/dolphinpart.cpp | 7 +++++++ src/dolphinpart.h | 7 +++++++ 2 files changed, 14 insertions(+) (limited to 'src') diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index a957fa665..a7e8bffec 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -120,6 +120,8 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL // Create file info and listing filter extensions. // NOTE: Listing filter needs to be instantiated after the creation of the view. new DolphinPartFileInfoExtension(this); + +#if KDE_IS_VERSION(4, 9, 2) new DolphinPartListingFilterExtension(this); KDirLister* lister = m_view->m_model->m_dirLister; @@ -130,6 +132,7 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL } else { kWarning() << "NULL KDirLister object! KParts::ListingNotificationExtension will NOT be supported"; } +#endif createActions(); m_actionHandler->updateViewActions(); @@ -661,6 +664,8 @@ KFileItemList DolphinPartFileInfoExtension::queryFor(KParts::FileInfoExtension:: return list; } +#if KDE_IS_VERSION(4, 9, 2) + DolphinPartListingFilterExtension::DolphinPartListingFilterExtension (DolphinPart* part) : KParts::ListingFilterExtension(part) , m_part(part) @@ -739,4 +744,6 @@ void DolphinPartListingNotificationExtension::slotItemsDeleted(const KFileItemLi emit listingEvent(KParts::ListingNotificationExtension::ItemsDeleted, items); } +#endif + #include "dolphinpart.moc" diff --git a/src/dolphinpart.h b/src/dolphinpart.h index 6cf9fe324..0895686b8 100644 --- a/src/dolphinpart.h +++ b/src/dolphinpart.h @@ -20,10 +20,15 @@ #ifndef DOLPHINPART_H #define DOLPHINPART_H +#include + #include #include #include + +#if KDE_IS_VERSION(4, 9, 2) #include +#endif #include @@ -282,6 +287,7 @@ protected: DolphinPart* part() const; }; +#if KDE_IS_VERSION(4, 9, 2) class DolphinPartListingFilterExtension : public KParts::ListingFilterExtension { Q_OBJECT @@ -309,5 +315,6 @@ public Q_SLOTS: void slotNewItems(const KFileItemList&); void slotItemsDeleted(const KFileItemList&); }; +#endif #endif /* DOLPHINPART_H */ -- cgit v1.3 From fa255857a05f1408fe1e1df8bc7c377a3058f655 Mon Sep 17 00:00:00 2001 From: Frank Reininghaus Date: Wed, 12 Sep 2012 21:13:26 +0200 Subject: Re-enable renaming items with the rename dialog User feedback has shown that many users used the dialog for renaming files. Since the dialog is still used when renaming multiple files, I think there is no good reason not to use it for renaming single files as well if the user wants. Note that we cannot add an option in the settings dialog due to string freeze issues. For the time being, you will have to add the line "RenameInline=false" to the [General] section of $KDEHOME/share/config/dolphinrc. BUG: 304627 FIXED-IN: 4.9.2 --- src/settings/dolphin_generalsettings.kcfg | 4 ++++ src/views/dolphinview.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/settings/dolphin_generalsettings.kcfg b/src/settings/dolphin_generalsettings.kcfg index 9f261dc5f..050750199 100644 --- a/src/settings/dolphin_generalsettings.kcfg +++ b/src/settings/dolphin_generalsettings.kcfg @@ -52,6 +52,10 @@ true + + + true + true diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 72ccb8372..b5dba04ad 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -635,7 +635,7 @@ void DolphinView::renameSelectedItems() return; } - if (items.count() == 1) { + if (items.count() == 1 && GeneralSettings::renameInline()) { const int index = m_model->index(items.first()); m_view->editRole(index, "text"); } else { -- cgit v1.3 From 0b918c3f825c35e83b5208c5fbfef8d20a0725a8 Mon Sep 17 00:00:00 2001 From: Dawit Alemayehu Date: Wed, 12 Sep 2012 15:54:37 -0400 Subject: Corrected the compile fix commit, rev 965fc6b3. --- src/CMakeLists.txt | 7 ++++ src/dolphinpart.cpp | 87 +++------------------------------------ src/dolphinpart.h | 36 ---------------- src/dolphinpart_ext.cpp | 107 ++++++++++++++++++++++++++++++++++++++++++++++++ src/dolphinpart_ext.h | 56 +++++++++++++++++++++++++ 5 files changed, 175 insertions(+), 118 deletions(-) create mode 100644 src/dolphinpart_ext.cpp create mode 100644 src/dolphinpart_ext.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index afc190f83..1c6b40c4b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -131,6 +131,13 @@ set(dolphinpart_SRCS dolphinpart.cpp ) +# Add dolphinpart_ext.cpp conditionally, only with KDE > 4.9.1. +if (${KDE_VERSION} VERSION_GREATER "4.9.1") +set(dolphinpart_SRCS + ${dolphinpart_SRCS} + dolphinpart_ext.cpp) +endif (${KDE_VERSION} VERSION_GREATER "4.9.1") + kde4_add_plugin(dolphinpart ${dolphinpart_SRCS}) target_link_libraries(dolphinpart dolphinprivate konq ${KDE4_KPARTS_LIBS} ${KDE4_KFILE_LIBS}) diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index a7e8bffec..ccc91fd7d 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -40,6 +40,11 @@ #include #include #include +#include + +#if KDE_IS_VERSION(4, 9, 2) +#include "dolphinpart_ext.h" +#endif #include "views/dolphinview.h" #include "views/dolphinviewactionhandler.h" @@ -664,86 +669,4 @@ KFileItemList DolphinPartFileInfoExtension::queryFor(KParts::FileInfoExtension:: return list; } -#if KDE_IS_VERSION(4, 9, 2) - -DolphinPartListingFilterExtension::DolphinPartListingFilterExtension (DolphinPart* part) - : KParts::ListingFilterExtension(part) - , m_part(part) -{ -} - -KParts::ListingFilterExtension::FilterModes DolphinPartListingFilterExtension::supportedFilterModes() const -{ - return (KParts::ListingFilterExtension::MimeType | - KParts::ListingFilterExtension::SubString | - KParts::ListingFilterExtension::WildCard); -} - -bool DolphinPartListingFilterExtension::supportsMultipleFilters (KParts::ListingFilterExtension::FilterMode mode) const -{ - if (mode == KParts::ListingFilterExtension::MimeType) - return true; - - return false; -} - -QVariant DolphinPartListingFilterExtension::filter (KParts::ListingFilterExtension::FilterMode mode) const -{ - QVariant result; - - switch (mode) { - case KParts::ListingFilterExtension::MimeType: - result = m_part->view()->mimeTypeFilters(); - break; - case KParts::ListingFilterExtension::SubString: - case KParts::ListingFilterExtension::WildCard: - result = m_part->view()->nameFilter(); - break; - default: - break; - } - - return result; -} - -void DolphinPartListingFilterExtension::setFilter (KParts::ListingFilterExtension::FilterMode mode, const QVariant& filter) -{ - switch (mode) { - case KParts::ListingFilterExtension::MimeType: - m_part->view()->setMimeTypeFilters(filter.toStringList()); - break; - case KParts::ListingFilterExtension::SubString: - case KParts::ListingFilterExtension::WildCard: - m_part->view()->setNameFilter(filter.toString()); - break; - default: - break; - } -} - -//// - -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); -} - -#endif - #include "dolphinpart.moc" diff --git a/src/dolphinpart.h b/src/dolphinpart.h index 0895686b8..e5693b363 100644 --- a/src/dolphinpart.h +++ b/src/dolphinpart.h @@ -20,16 +20,10 @@ #ifndef DOLPHINPART_H #define DOLPHINPART_H -#include - #include #include #include -#if KDE_IS_VERSION(4, 9, 2) -#include -#endif - #include class KNewFileMenu; @@ -287,34 +281,4 @@ protected: DolphinPart* part() const; }; -#if KDE_IS_VERSION(4, 9, 2) -class DolphinPartListingFilterExtension : public KParts::ListingFilterExtension -{ - Q_OBJECT - -public: - DolphinPartListingFilterExtension (DolphinPart* part); - virtual FilterModes supportedFilterModes() const; - virtual bool supportsMultipleFilters (FilterMode mode) const; - virtual QVariant filter (FilterMode mode) const; - virtual void setFilter (FilterMode mode, const QVariant& filter); - -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 - #endif /* DOLPHINPART_H */ diff --git a/src/dolphinpart_ext.cpp b/src/dolphinpart_ext.cpp new file mode 100644 index 000000000..e98c0648e --- /dev/null +++ b/src/dolphinpart_ext.cpp @@ -0,0 +1,107 @@ +/* This file is part of the KDE project + * Copyright (c) 2012 Dawit Alemayehu + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "dolphinpart_ext.h" + +#include "dolphinpart.h" +#include "views/dolphinview.h" + +#include + +#include + +DolphinPartListingFilterExtension::DolphinPartListingFilterExtension(DolphinPart* part) + : KParts::ListingFilterExtension(part) + , m_part(part) +{ +} + +KParts::ListingFilterExtension::FilterModes DolphinPartListingFilterExtension::supportedFilterModes() const +{ + return (KParts::ListingFilterExtension::MimeType | + KParts::ListingFilterExtension::SubString | + KParts::ListingFilterExtension::WildCard); +} + +bool DolphinPartListingFilterExtension::supportsMultipleFilters(KParts::ListingFilterExtension::FilterMode mode) const +{ + if (mode == KParts::ListingFilterExtension::MimeType) + return true; + + return false; +} + +QVariant DolphinPartListingFilterExtension::filter(KParts::ListingFilterExtension::FilterMode mode) const +{ + QVariant result; + + switch (mode) { + case KParts::ListingFilterExtension::MimeType: + result = m_part->view()->mimeTypeFilters(); + break; + case KParts::ListingFilterExtension::SubString: + case KParts::ListingFilterExtension::WildCard: + result = m_part->view()->nameFilter(); + break; + default: + break; + } + + return result; +} + +void DolphinPartListingFilterExtension::setFilter(KParts::ListingFilterExtension::FilterMode mode, const QVariant& filter) +{ + switch (mode) { + case KParts::ListingFilterExtension::MimeType: + m_part->view()->setMimeTypeFilters(filter.toStringList()); + break; + case KParts::ListingFilterExtension::SubString: + case KParts::ListingFilterExtension::WildCard: + m_part->view()->setNameFilter(filter.toString()); + break; + default: + break; + } +} + +//// + +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_ext.moc" diff --git a/src/dolphinpart_ext.h b/src/dolphinpart_ext.h new file mode 100644 index 000000000..423e79efe --- /dev/null +++ b/src/dolphinpart_ext.h @@ -0,0 +1,56 @@ +/* This file is part of the KDE project + * Copyright (c) 2012 Dawit Alemayehu + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef DOLPHINPART_EXT_H +#define DOLPHINPART_EXT_H + + +#include + +class DolphinPart; + +class DolphinPartListingFilterExtension : public KParts::ListingFilterExtension +{ + Q_OBJECT + +public: + DolphinPartListingFilterExtension(DolphinPart* part); + virtual FilterModes supportedFilterModes() const; + virtual bool supportsMultipleFilters(FilterMode mode) const; + virtual QVariant filter(FilterMode mode) const; + virtual void setFilter(FilterMode mode, const QVariant& filter); + +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 -- cgit v1.3 From 40c513d4774fca0ecfe5141ece642874e2664f89 Mon Sep 17 00:00:00 2001 From: Frank Reininghaus Date: Wed, 19 Sep 2012 09:28:22 +0200 Subject: Prevent unwanted URL changes when using the Terminal Panel The root cause of the problem was that TerminalPanel's member m_konsolePartCurrentDirectory, which is used to determine in TerminalPanel::sendCdToTerminal(QString& dir) if the Konsole part's directory is aleady 'dir', such that issuing the 'cd' command is not needed, was updated too late, namely when the part's currentDirectoryChanged(QString) signal was received, which may be up to one second after the 'cd' command. When changing the directory from "dir1" to "dir2" and going back to the "dir1" in less than one second (either by using the 'Back' action or by activating a tab which still had "dir1" open), the 'cd dir1' command was therefore suppressed because the Terminal Panel still thought that "dir1" was the current directory in the part. However, the directory of the part was actually "dir2", and when the currentDirectoryChanged(QString) signal was received from the part, the view's URL was set to "dir2" as well. BUG: 306349 BUG: 304838 FIXED-IN: 4.9.2 --- src/panels/terminal/terminalpanel.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/panels/terminal/terminalpanel.cpp b/src/panels/terminal/terminalpanel.cpp index 889c07e45..f6d3a5981 100644 --- a/src/panels/terminal/terminalpanel.cpp +++ b/src/panels/terminal/terminalpanel.cpp @@ -159,6 +159,7 @@ void TerminalPanel::sendCdToTerminal(const QString& dir) } m_terminal->sendInput(" cd " + KShell::quoteArg(dir) + '\n'); + m_konsolePartCurrentDirectory = dir; if (m_clearTerminal) { m_terminal->sendInput(" clear\n"); -- 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') 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 4855b582b48beafd99c13f591bb9c814807c812d Mon Sep 17 00:00:00 2001 From: Emmanuel Pescosta Date: Thu, 20 Sep 2012 17:56:00 +0200 Subject: Fixes Bug 304878 - Dolphin shows "ghost" folders in places after autofs umount nfs shares BUG: 304878 REVIEW: 106456 FIXED-IN: 4.9.2 --- src/panels/places/placesitemmodel.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/panels/places/placesitemmodel.cpp b/src/panels/places/placesitemmodel.cpp index bd50c9a4b..706092bc7 100644 --- a/src/panels/places/placesitemmodel.cpp +++ b/src/panels/places/placesitemmodel.cpp @@ -659,11 +659,22 @@ void PlacesItemModel::updateBookmarks() } if (!found) { - PlacesItem* item = new PlacesItem(newBookmark); - if (item->isHidden() && !m_hiddenItemsShown) { - m_bookmarkedItems.append(item); - } else { - appendItemToGroup(item); + const QString udi = newBookmark.metaDataItem("UDI"); + + /* + * See Bug 304878 + * Only add a new places item, if the item text is not empty + * and if the device is available. Fixes the strange behaviour - + * add a places item without text in the Places section - when you + * remove a device (e.g. a usb stick) without unmounting. + */ + if (udi.isEmpty() || Solid::Device(udi).isValid()) { + PlacesItem* item = new PlacesItem(newBookmark); + if (item->isHidden() && !m_hiddenItemsShown) { + m_bookmarkedItems.append(item); + } else { + appendItemToGroup(item); + } } } } -- 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') 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 From c8243401470156d9ee76e2015a23741570d3dba1 Mon Sep 17 00:00:00 2001 From: Emmanuel Pescosta Date: Thu, 20 Sep 2012 17:57:10 +0200 Subject: Fix Bug 297355 - Dolphin leaves file preview tooltips open even when is not visible BUG: 297355 FIXED-IN: 4.9.2 REVIEW: 106499 --- src/views/dolphinview.cpp | 14 ++++++++++++++ src/views/dolphinview.h | 1 + 2 files changed, 15 insertions(+) (limited to 'src') diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index b5dba04ad..f0dc3caba 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -753,6 +753,20 @@ void DolphinView::hideEvent(QHideEvent* event) QWidget::hideEvent(event); } +bool DolphinView::event(QEvent* event) +{ + /* See Bug 297355 + * Dolphin leaves file preview tooltips open even when is not visible. + * + * Hide tool-tip when Dolphin loses focus. + */ + if (event->type() == QEvent::WindowDeactivate) { + hideToolTip(); + } + + return QWidget::event(event); +} + void DolphinView::activate() { setActive(true); diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h index 3f71fdc54..7d8e8b76a 100644 --- a/src/views/dolphinview.h +++ b/src/views/dolphinview.h @@ -532,6 +532,7 @@ protected: /** @reimp */ virtual void hideEvent(QHideEvent* event); + virtual bool event(QEvent* event); private slots: /** -- cgit v1.3