diff options
Diffstat (limited to 'src')
25 files changed, 138 insertions, 93 deletions
diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp index f4b469886..3deeb38cd 100644 --- a/src/dolphincontextmenu.cpp +++ b/src/dolphincontextmenu.cpp @@ -196,7 +196,7 @@ void DolphinContextMenu::openItemContextMenu() if (m_selectedItems.count() == 1) { if (m_fileInfo.isDir()) { // setup 'Create New' menu - DolphinNewFileMenu* newFileMenu = new DolphinNewFileMenu(m_mainWindow); + DolphinNewFileMenu* newFileMenu = new DolphinNewFileMenu(m_mainWindow->actionCollection(), this); const DolphinView* view = m_mainWindow->activeViewContainer()->view(); newFileMenu->setViewShowsHiddenFiles(view->hiddenFilesShown()); newFileMenu->checkUpToDate(); @@ -204,6 +204,7 @@ void DolphinContextMenu::openItemContextMenu() newFileMenu->setEnabled(selectedItemsProps.supportsWriting()); connect(newFileMenu, SIGNAL(fileCreated(KUrl)), newFileMenu, SLOT(deleteLater())); connect(newFileMenu, SIGNAL(directoryCreated(KUrl)), newFileMenu, SLOT(deleteLater())); + connect(newFileMenu, SIGNAL(errorMessage(QString)), this, SIGNAL(errorMessage(QString))); KMenu* menu = newFileMenu->menu(); menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New")); diff --git a/src/dolphincontextmenu.h b/src/dolphincontextmenu.h index 180f91787..c9840eae5 100644 --- a/src/dolphincontextmenu.h +++ b/src/dolphincontextmenu.h @@ -95,6 +95,9 @@ protected: virtual void keyPressEvent(QKeyEvent *ev); virtual void keyReleaseEvent(QKeyEvent *ev); +signals: + void errorMessage(const QString& error); + private: void openTrashContextMenu(); void openTrashItemContextMenu(); diff --git a/src/dolphindockwidget.cpp b/src/dolphindockwidget.cpp index 0d8aea7bd..6495c8da9 100644 --- a/src/dolphindockwidget.cpp +++ b/src/dolphindockwidget.cpp @@ -21,6 +21,14 @@ #include <QStyle> +namespace { + // Disable the 'Floatable' feature, i.e., the possibility to drag the + // dock widget out of the main window. This works around problems like + // https://bugs.kde.org/show_bug.cgi?id=288629 + // https://bugs.kde.org/show_bug.cgi?id=322299 + const QDockWidget::DockWidgetFeatures DefaultDockWidgetFeatures = QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable; +} + // Empty titlebar for the dock widgets when "Lock Layout" has been activated. class DolphinDockTitleBar : public QWidget { @@ -45,6 +53,7 @@ DolphinDockWidget::DolphinDockWidget(const QString& title, QWidget* parent, Qt:: m_locked(false), m_dockTitleBar(0) { + setFeatures(DefaultDockWidgetFeatures); } DolphinDockWidget::DolphinDockWidget(QWidget* parent, Qt::WindowFlags flags) : @@ -52,6 +61,7 @@ DolphinDockWidget::DolphinDockWidget(QWidget* parent, Qt::WindowFlags flags) : m_locked(false), m_dockTitleBar(0) { + setFeatures(DefaultDockWidgetFeatures); } DolphinDockWidget::~DolphinDockWidget() @@ -71,9 +81,7 @@ void DolphinDockWidget::setLocked(bool lock) setFeatures(QDockWidget::NoDockWidgetFeatures); } else { setTitleBarWidget(0); - setFeatures(QDockWidget::DockWidgetMovable | - QDockWidget::DockWidgetFloatable | - QDockWidget::DockWidgetClosable); + setFeatures(DefaultDockWidgetFeatures); } } } diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 73001bf54..5cc608fd4 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -1297,6 +1297,8 @@ void DolphinMainWindow::openContextMenu(const QPoint& pos, { QWeakPointer<DolphinContextMenu> contextMenu = new DolphinContextMenu(this, pos, item, url); contextMenu.data()->setCustomActions(customActions); + connect(contextMenu.data(), SIGNAL(errorMessage(QString)), + this, SLOT(showErrorMessage(QString))); const DolphinContextMenu::Command command = contextMenu.data()->open(); switch (command) { @@ -1482,13 +1484,15 @@ DolphinViewContainer* DolphinMainWindow::createViewContainer(const KUrl& url, QW void DolphinMainWindow::setupActions() { // setup 'File' menu - m_newFileMenu = new DolphinNewFileMenu(this); + m_newFileMenu = new DolphinNewFileMenu(actionCollection(), this); KMenu* menu = m_newFileMenu->menu(); menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New")); menu->setIcon(KIcon("document-new")); m_newFileMenu->setDelayed(false); connect(menu, SIGNAL(aboutToShow()), this, SLOT(updateNewMenu())); + connect(m_newFileMenu, SIGNAL(errorMessage(QString)), + this, SLOT(showErrorMessage(QString))); KAction* newWindow = actionCollection()->addAction("new_window"); newWindow->setIcon(KIcon("window-new")); diff --git a/src/dolphinnewfilemenu.cpp b/src/dolphinnewfilemenu.cpp index 9d9baabe2..480889f72 100644 --- a/src/dolphinnewfilemenu.cpp +++ b/src/dolphinnewfilemenu.cpp @@ -20,17 +20,13 @@ #include "dolphinnewfilemenu.h" -#include "dolphinmainwindow.h" -#include "dolphinviewcontainer.h" #include "views/dolphinnewfilemenuobserver.h" -#include "views/dolphinview.h" #include <KActionCollection> #include <KIO/Job> -DolphinNewFileMenu::DolphinNewFileMenu(DolphinMainWindow* parent) : - KNewFileMenu(parent->actionCollection(), "create_new", parent), - m_mainWin(parent) +DolphinNewFileMenu::DolphinNewFileMenu(KActionCollection* collection, QObject* parent) : + KNewFileMenu(collection, "create_new", parent) { DolphinNewFileMenuObserver::instance().attach(this); } @@ -43,8 +39,7 @@ DolphinNewFileMenu::~DolphinNewFileMenu() void DolphinNewFileMenu::slotResult(KJob* job) { if (job->error()) { - DolphinViewContainer* container = m_mainWin->activeViewContainer(); - container->showMessage(job->errorString(), DolphinViewContainer::Error); + emit errorMessage(job->errorString()); } else { KNewFileMenu::slotResult(job); } diff --git a/src/dolphinnewfilemenu.h b/src/dolphinnewfilemenu.h index 0d336080b..ae5881366 100644 --- a/src/dolphinnewfilemenu.h +++ b/src/dolphinnewfilemenu.h @@ -23,7 +23,6 @@ #include <KNewFileMenu> -class DolphinMainWindow; class KJob; /** @@ -39,15 +38,15 @@ class DolphinNewFileMenu : public KNewFileMenu Q_OBJECT public: - DolphinNewFileMenu(DolphinMainWindow* parent); + DolphinNewFileMenu(KActionCollection* collection, QObject* parent); virtual ~DolphinNewFileMenu(); +signals: + void errorMessage(const QString& error); + protected slots: /** @see KNewFileMenu::slotResult() */ virtual void slotResult(KJob* job); - -private: - DolphinMainWindow* m_mainWin; }; #endif diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index 81fbacb77..de4c6070d 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -572,7 +572,8 @@ void DolphinPart::updateNewMenu() void DolphinPart::updateStatusBar() { - emit ReadOnlyPart::setStatusBarText(m_view->statusBarText()); + const QString escapedText = Qt::convertFromPlainText(m_view->statusBarText()); + emit ReadOnlyPart::setStatusBarText(QString("<qt>%1</qt>").arg(escapedText)); } void DolphinPart::updateProgress(int percent) diff --git a/src/dolphinpart.desktop b/src/dolphinpart.desktop index a553034a2..ac6607cc0 100644 --- a/src/dolphinpart.desktop +++ b/src/dolphinpart.desktop @@ -196,6 +196,7 @@ Exec=dolphin [Desktop Action compact] Name=Compact Name[ar]=مضغوط +Name[bg]=Компактно Name[bs]=Sabij Name[ca]=Compacte Name[ca@valencia]=Compacte @@ -323,7 +324,7 @@ Name[te]=వివరాలు Name[tg]=Тафсилотҳо Name[th]=รายละเอียด Name[tr]=Ayrıntılar -Name[ug]=تەپسىلاتى +Name[ug]=تەپسىلاتلار Name[uk]=Подробиці Name[uz]=Tafsilotlar Name[uz@cyrillic]=Тафсилотлар diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index 1e9e79ae7..3ea81e4ba 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -506,8 +506,7 @@ void DolphinViewContainer::showItemInfo(const KFileItem& item) if (item.isNull()) { m_statusBar->resetToDefaultText(); } else { - const QString text = item.isDir() ? item.text() : item.getStatusBarInfo(); - m_statusBar->setText(text); + m_statusBar->setText(item.getStatusBarInfo()); } } diff --git a/src/kitemviews/kfileitemlistview.cpp b/src/kitemviews/kfileitemlistview.cpp index 2da238d7a..1f0fcbd6f 100644 --- a/src/kitemviews/kfileitemlistview.cpp +++ b/src/kitemviews/kfileitemlistview.cpp @@ -213,12 +213,6 @@ void KFileItemListView::onPreviewsShownChanged(bool shown) void KFileItemListView::onItemLayoutChanged(ItemLayout current, ItemLayout previous) { - if (previous == DetailsLayout || current == DetailsLayout) { - // The details-layout requires some invisible roles that - // must be added to the model if the new layout is "details". - // If the old layout was "details" the roles will get removed. - applyRolesToModel(); - } KStandardItemListView::onItemLayoutChanged(current, previous); triggerVisibleIndexRangeUpdate(); } diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index 7bbc1d17f..37a30519a 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -711,7 +711,6 @@ void KFileItemModel::resortAllItems() oldUrls.append(itemData->item.url()); } - m_groups.clear(); m_items.clear(); // Resort the items @@ -720,20 +719,45 @@ void KFileItemModel::resortAllItems() m_items.insert(m_itemData.at(i)->item.url(), i); } - // Determine the indexes that have been moved - QList<int> movedToIndexes; - movedToIndexes.reserve(itemCount); - for (int i = 0; i < itemCount; i++) { - const int newIndex = m_items.value(oldUrls.at(i)); - movedToIndexes.append(newIndex); + // Determine the first index that has been moved. + int firstMovedIndex = 0; + while (firstMovedIndex < itemCount + && firstMovedIndex == m_items.value(oldUrls.at(firstMovedIndex))) { + ++firstMovedIndex; } - // Don't check whether items have really been moved and always emit a - // itemsMoved() signal after resorting: In case of grouped items - // the groups might change even if the items themselves don't change their - // position. Let the receiver of the signal decide whether a check for moved - // items makes sense. - emit itemsMoved(KItemRange(0, itemCount), movedToIndexes); + const bool itemsHaveMoved = firstMovedIndex < itemCount; + if (itemsHaveMoved) { + m_groups.clear(); + + int lastMovedIndex = itemCount - 1; + while (lastMovedIndex > firstMovedIndex + && lastMovedIndex == m_items.value(oldUrls.at(lastMovedIndex))) { + --lastMovedIndex; + } + + Q_ASSERT(firstMovedIndex <= lastMovedIndex); + + // Create a list movedToIndexes, which has the property that + // movedToIndexes[i] is the new index of the item with the old index + // firstMovedIndex + i. + const int movedItemsCount = lastMovedIndex - firstMovedIndex + 1; + QList<int> movedToIndexes; + movedToIndexes.reserve(movedItemsCount); + for (int i = firstMovedIndex; i <= lastMovedIndex; ++i) { + const int newIndex = m_items.value(oldUrls.at(i)); + movedToIndexes.append(newIndex); + } + + emit itemsMoved(KItemRange(firstMovedIndex, movedItemsCount), movedToIndexes); + } else if (groupedSorting()) { + // The groups might have changed even if the order of the items has not. + const QList<QPair<int, QVariant> > oldGroups = m_groups; + m_groups.clear(); + if (groups() != oldGroups) { + emit groupsChanged(); + } + } #ifdef KFILEITEMMODEL_DEBUG kDebug() << "[TIME] Resorting of" << itemCount << "items:" << timer.elapsed(); diff --git a/src/kitemviews/kitemlistview.cpp b/src/kitemviews/kitemlistview.cpp index 7f1526151..d8edcfc50 100644 --- a/src/kitemviews/kitemlistview.cpp +++ b/src/kitemviews/kitemlistview.cpp @@ -1229,6 +1229,13 @@ void KItemListView::slotItemsChanged(const KItemRangeList& itemRanges, QAccessible::updateAccessibility(this, 0, QAccessible::TableModelChanged); } +void KItemListView::slotGroupsChanged() +{ + updateVisibleGroupHeaders(); + doLayout(NoAnimation); + updateSiblingsInformation(); +} + void KItemListView::slotGroupedSortingChanged(bool current) { m_grouped = current; @@ -1523,6 +1530,8 @@ void KItemListView::setModel(KItemModelBase* model) this, SLOT(slotItemsRemoved(KItemRangeList))); disconnect(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)), this, SLOT(slotItemsMoved(KItemRange,QList<int>))); + disconnect(m_model, SIGNAL(groupsChanged()), + this, SLOT(slotGroupsChanged())); disconnect(m_model, SIGNAL(groupedSortingChanged(bool)), this, SLOT(slotGroupedSortingChanged(bool))); disconnect(m_model, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)), @@ -1546,6 +1555,8 @@ void KItemListView::setModel(KItemModelBase* model) this, SLOT(slotItemsRemoved(KItemRangeList))); connect(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)), this, SLOT(slotItemsMoved(KItemRange,QList<int>))); + connect(m_model, SIGNAL(groupsChanged()), + this, SLOT(slotGroupsChanged())); connect(m_model, SIGNAL(groupedSortingChanged(bool)), this, SLOT(slotGroupedSortingChanged(bool))); connect(m_model, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)), diff --git a/src/kitemviews/kitemlistview.h b/src/kitemviews/kitemlistview.h index 6467b8c91..14360b02b 100644 --- a/src/kitemviews/kitemlistview.h +++ b/src/kitemviews/kitemlistview.h @@ -394,6 +394,7 @@ protected slots: virtual void slotItemsMoved(const KItemRange& itemRange, const QList<int>& movedToIndexes); virtual void slotItemsChanged(const KItemRangeList& itemRanges, const QSet<QByteArray>& roles); + virtual void slotGroupsChanged(); virtual void slotGroupedSortingChanged(bool current); virtual void slotSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous); diff --git a/src/kitemviews/kitemmodelbase.h b/src/kitemviews/kitemmodelbase.h index 70f688390..7545192da 100644 --- a/src/kitemviews/kitemmodelbase.h +++ b/src/kitemviews/kitemmodelbase.h @@ -218,11 +218,20 @@ signals: * with the items 5 and 6 then the parameters look like this: * - itemRange: has the index 0 and a count of 7. * - movedToIndexes: Contains the seven values 5, 6, 2, 3, 4, 0, 1 + * + * This signal implies that the groups might have changed. Therefore, + * gropusChanged() is not emitted if this signal is emitted. */ void itemsMoved(const KItemRange& itemRange, const QList<int>& movedToIndexes); void itemsChanged(const KItemRangeList& itemRanges, const QSet<QByteArray>& roles); + /** + * Is emitted if the groups have changed, even though the order of the + * items has not been modified. + */ + void groupsChanged(); + void groupedSortingChanged(bool current); void sortRoleChanged(const QByteArray& current, const QByteArray& previous); void sortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous); diff --git a/src/kitemviews/kstandarditemlistview.cpp b/src/kitemviews/kstandarditemlistview.cpp index bd4f6081f..135cd0b7d 100644 --- a/src/kitemviews/kstandarditemlistview.cpp +++ b/src/kitemviews/kstandarditemlistview.cpp @@ -48,23 +48,8 @@ void KStandardItemListView::setItemLayout(ItemLayout layout) const ItemLayout previous = m_itemLayout; m_itemLayout = layout; - switch (layout) { - case IconsLayout: - setScrollOrientation(Qt::Vertical); - setSupportsItemExpanding(false); - break; - case DetailsLayout: - setScrollOrientation(Qt::Vertical); - setSupportsItemExpanding(true); - break; - case CompactLayout: - setScrollOrientation(Qt::Horizontal); - setSupportsItemExpanding(false); - break; - default: - Q_ASSERT(false); - break; - } + setSupportsItemExpanding(itemLayoutSupportsItemExpanding(layout)); + setScrollOrientation(layout == CompactLayout ? Qt::Horizontal : Qt::Vertical); onItemLayoutChanged(layout, previous); @@ -117,6 +102,11 @@ bool KStandardItemListView::itemSizeHintUpdateRequired(const QSet<QByteArray>& c return false; } +bool KStandardItemListView::itemLayoutSupportsItemExpanding(ItemLayout layout) const +{ + return layout == DetailsLayout; +} + void KStandardItemListView::onItemLayoutChanged(ItemLayout current, ItemLayout previous) { Q_UNUSED(current); diff --git a/src/kitemviews/kstandarditemlistview.h b/src/kitemviews/kstandarditemlistview.h index fd4fa861c..f5b0bfd8c 100644 --- a/src/kitemviews/kstandarditemlistview.h +++ b/src/kitemviews/kstandarditemlistview.h @@ -63,6 +63,7 @@ protected: virtual KItemListGroupHeaderCreatorBase* defaultGroupHeaderCreator() const; virtual void initializeItemListWidget(KItemListWidget* item); virtual bool itemSizeHintUpdateRequired(const QSet<QByteArray>& changedRoles) const; + virtual bool itemLayoutSupportsItemExpanding(ItemLayout layout) const; virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous); virtual void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous); virtual void onSupportsItemExpandingChanged(bool supportsExpanding); diff --git a/src/kitemviews/private/kitemlistsizehintresolver.cpp b/src/kitemviews/private/kitemlistsizehintresolver.cpp index e44630243..0e2286b45 100644 --- a/src/kitemviews/private/kitemlistsizehintresolver.cpp +++ b/src/kitemviews/private/kitemlistsizehintresolver.cpp @@ -120,7 +120,7 @@ void KItemListSizeHintResolver::itemsMoved(const KItemRange& range, const QList< const int movedRangeEnd = range.index + range.count; for (int i = range.index; i < movedRangeEnd; ++i) { - const int newIndex = movedToIndexes.at(i); + const int newIndex = movedToIndexes.at(i - range.index); newSizeHintCache[newIndex] = m_sizeHintCache.at(i); } @@ -139,8 +139,5 @@ void KItemListSizeHintResolver::itemsChanged(int index, int count, const QSet<QB void KItemListSizeHintResolver::clearCache() { - const int count = m_sizeHintCache.count(); - for (int i = 0; i < count; ++i) { - m_sizeHintCache[i] = QSizeF(); - } + m_sizeHintCache.fill(QSizeF()); } diff --git a/src/settings/kcm/kcmdolphingeneral.desktop b/src/settings/kcm/kcmdolphingeneral.desktop index 5f3772d28..54bece16a 100644 --- a/src/settings/kcm/kcmdolphingeneral.desktop +++ b/src/settings/kcm/kcmdolphingeneral.desktop @@ -297,6 +297,7 @@ Comment[zh_CN]=配置常规文件管理器设置 Comment[zh_TW]=設定一般檔案管理員 X-KDE-Keywords=file manager X-KDE-Keywords[ar]=مدير الملفات +X-KDE-Keywords[bg]=преглед на файлове X-KDE-Keywords[bs]=upravitelj datoteka X-KDE-Keywords[ca]=gestor de fitxers X-KDE-Keywords[ca@valencia]=gestor de fitxers diff --git a/src/settings/kcm/kcmdolphinnavigation.desktop b/src/settings/kcm/kcmdolphinnavigation.desktop index ab79449f5..cecf495bd 100644 --- a/src/settings/kcm/kcmdolphinnavigation.desktop +++ b/src/settings/kcm/kcmdolphinnavigation.desktop @@ -297,6 +297,7 @@ Comment[zh_CN]=配置文件管理器导航 Comment[zh_TW]=設定檔案管理員導覽 X-KDE-Keywords=file manager X-KDE-Keywords[ar]=مدير الملفات +X-KDE-Keywords[bg]=преглед на файлове X-KDE-Keywords[bs]=upravitelj datoteka X-KDE-Keywords[ca]=gestor de fitxers X-KDE-Keywords[ca@valencia]=gestor de fitxers diff --git a/src/settings/kcm/kcmdolphinservices.desktop b/src/settings/kcm/kcmdolphinservices.desktop index 14436dd99..de88fb589 100644 --- a/src/settings/kcm/kcmdolphinservices.desktop +++ b/src/settings/kcm/kcmdolphinservices.desktop @@ -246,6 +246,7 @@ Comment[zh_CN]=配置文件管理器服务 Comment[zh_TW]=設定檔案管理員服務 X-KDE-Keywords=file manager X-KDE-Keywords[ar]=مدير الملفات +X-KDE-Keywords[bg]=преглед на файлове X-KDE-Keywords[bs]=upravitelj datoteka X-KDE-Keywords[ca]=gestor de fitxers X-KDE-Keywords[ca@valencia]=gestor de fitxers diff --git a/src/settings/kcm/kcmdolphinviewmodes.desktop b/src/settings/kcm/kcmdolphinviewmodes.desktop index a05d944c2..205570cc0 100644 --- a/src/settings/kcm/kcmdolphinviewmodes.desktop +++ b/src/settings/kcm/kcmdolphinviewmodes.desktop @@ -295,6 +295,7 @@ Comment[zh_CN]=配置文件管理器视图模式 Comment[zh_TW]=設定檔案管理員檢視模式 X-KDE-Keywords=file manager X-KDE-Keywords[ar]=مدير الملفات +X-KDE-Keywords[bg]=преглед на файлове X-KDE-Keywords[bs]=upravitelj datoteka X-KDE-Keywords[ca]=gestor de fitxers X-KDE-Keywords[ca@valencia]=gestor de fitxers diff --git a/src/tests/kfileitemmodeltest.cpp b/src/tests/kfileitemmodeltest.cpp index f8439789b..e55e3eb33 100644 --- a/src/tests/kfileitemmodeltest.cpp +++ b/src/tests/kfileitemmodeltest.cpp @@ -49,6 +49,7 @@ namespace { const int DefaultTimeout = 5000; }; +Q_DECLARE_METATYPE(KItemRange) Q_DECLARE_METATYPE(KItemRangeList) Q_DECLARE_METATYPE(QList<int>) @@ -744,7 +745,8 @@ void KFileItemModelTest::testSorting() QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder); QCOMPARE(itemsInModel(), QStringList() << "a" << "b" << "c" << "c-1" << "c-2" << "c-3" << "d" << "e"); QCOMPARE(spyItemsMoved.count(), 1); - QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 2 << 4 << 5 << 3 << 0 << 1 << 6 << 7); + QCOMPARE(spyItemsMoved.first().at(0).value<KItemRange>(), KItemRange(0, 6)); + QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 2 << 4 << 5 << 3 << 0 << 1); // Sort by Name, descending m_model->setSortDirectoriesFirst(true); @@ -753,8 +755,10 @@ void KFileItemModelTest::testSorting() QCOMPARE(m_model->sortOrder(), Qt::DescendingOrder); QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "e" << "d" << "b" << "a"); QCOMPARE(spyItemsMoved.count(), 2); - QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 4 << 5 << 0 << 3 << 1 << 2 << 6 << 7); - QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 0 << 1 << 2 << 3 << 7 << 6 << 5 << 4); + QCOMPARE(spyItemsMoved.first().at(0).value<KItemRange>(), KItemRange(0, 6)); + QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 4 << 5 << 0 << 3 << 1 << 2); + QCOMPARE(spyItemsMoved.first().at(0).value<KItemRange>(), KItemRange(4, 4)); + QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 7 << 6 << 5 << 4); // Sort by Date, descending m_model->setSortDirectoriesFirst(true); @@ -763,7 +767,8 @@ void KFileItemModelTest::testSorting() QCOMPARE(m_model->sortOrder(), Qt::DescendingOrder); QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "b" << "d" << "a" << "e"); QCOMPARE(spyItemsMoved.count(), 1); - QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 0 << 1 << 2 << 3 << 7 << 5 << 4 << 6); + QCOMPARE(spyItemsMoved.first().at(0).value<KItemRange>(), KItemRange(4, 4)); + QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 7 << 5 << 4 << 6); // Sort by Date, ascending m_model->setSortOrder(Qt::AscendingOrder); @@ -771,7 +776,8 @@ void KFileItemModelTest::testSorting() QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder); QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "e" << "a" << "d" << "b"); QCOMPARE(spyItemsMoved.count(), 1); - QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 0 << 1 << 2 << 3 << 7 << 6 << 5 << 4); + QCOMPARE(spyItemsMoved.first().at(0).value<KItemRange>(), KItemRange(4, 4)); + QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 7 << 6 << 5 << 4); // Sort by Date, ascending, 'Sort Folders First' disabled m_model->setSortDirectoriesFirst(false); @@ -780,7 +786,8 @@ void KFileItemModelTest::testSorting() QVERIFY(!m_model->sortDirectoriesFirst()); QCOMPARE(itemsInModel(), QStringList() << "e" << "a" << "c" << "c-1" << "c-2" << "c-3" << "d" << "b"); QCOMPARE(spyItemsMoved.count(), 1); - QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 2 << 4 << 5 << 3 << 0 << 1 << 6 << 7); + QCOMPARE(spyItemsMoved.first().at(0).value<KItemRange>(), KItemRange(0, 6)); + QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 2 << 4 << 5 << 3 << 0 << 1); // Sort by Name, ascending, 'Sort Folders First' disabled m_model->setSortRole("text"); @@ -788,6 +795,7 @@ void KFileItemModelTest::testSorting() QVERIFY(!m_model->sortDirectoriesFirst()); QCOMPARE(itemsInModel(), QStringList() << "a" << "b" << "c" << "c-1" << "c-2" << "c-3" << "d" << "e"); QCOMPARE(spyItemsMoved.count(), 1); + QCOMPARE(spyItemsMoved.first().at(0).value<KItemRange>(), KItemRange(0, 8)); QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 7 << 0 << 2 << 3 << 4 << 5 << 6 << 1); // Sort by Size, ascending, 'Sort Folders First' disabled @@ -797,19 +805,15 @@ void KFileItemModelTest::testSorting() QVERIFY(!m_model->sortDirectoriesFirst()); QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "a" << "b" << "e" << "d"); QCOMPARE(spyItemsMoved.count(), 1); + QCOMPARE(spyItemsMoved.first().at(0).value<KItemRange>(), KItemRange(0, 8)); QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 4 << 5 << 0 << 3 << 1 << 2 << 7 << 6); - QSKIP("2 tests of testSorting() are temporary deactivated as in KFileItemModel resortAllItems() " - "always emits a itemsMoved() signal. Before adjusting the tests think about probably introducing " - "another signal", SkipSingle); - // Internal note: Check comment in KFileItemModel::resortAllItems() for details. - // In 'Sort by Size' mode, folders are always first -> changing 'Sort Folders First' does not resort the model m_model->setSortDirectoriesFirst(true); QCOMPARE(m_model->sortRole(), QByteArray("size")); QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder); QVERIFY(m_model->sortDirectoriesFirst()); - QCOMPARE(itemsInModel(), QStringList() << "c" << "a" << "b" << "e" << "d"); + QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "a" << "b" << "e" << "d"); QCOMPARE(spyItemsMoved.count(), 0); // Sort by Size, descending, 'Sort Folders First' enabled @@ -817,9 +821,10 @@ void KFileItemModelTest::testSorting() QCOMPARE(m_model->sortRole(), QByteArray("size")); QCOMPARE(m_model->sortOrder(), Qt::DescendingOrder); QVERIFY(m_model->sortDirectoriesFirst()); - QCOMPARE(itemsInModel(), QStringList() << "c" << "d" << "e" << "b" << "a"); + QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "d" << "e" << "b" << "a"); QCOMPARE(spyItemsMoved.count(), 1); - QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 0 << 4 << 3 << 2 << 1); + QCOMPARE(spyItemsMoved.first().at(0).value<KItemRange>(), KItemRange(4, 4)); + QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 7 << 6 << 5 << 4); // TODO: Sort by other roles; show/hide hidden files } @@ -1237,7 +1242,7 @@ void KFileItemModelTest::testNameRoleGroups() // Rename c.txt to d.txt. data.insert("text", "d.txt"); m_model->setData(2, data); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)), DefaultTimeout)); + QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(groupsChanged()), DefaultTimeout)); QCOMPARE(itemsInModel(), QStringList() << "a.txt" << "b.txt" << "d.txt" << "e.txt"); expectedGroups.clear(); diff --git a/src/views/dolphinitemlistview.cpp b/src/views/dolphinitemlistview.cpp index 039b5f230..4799d7679 100644 --- a/src/views/dolphinitemlistview.cpp +++ b/src/views/dolphinitemlistview.cpp @@ -89,10 +89,7 @@ void DolphinItemListView::readSettings() beginTransaction(); setEnabledSelectionToggles(GeneralSettings::showSelectionToggle()); - - const bool expandableFolders = (itemLayout() == KFileItemListView::DetailsLayout) && - DetailsModeSettings::expandableFolders(); - setSupportsItemExpanding(expandableFolders); + setSupportsItemExpanding(itemLayoutSupportsItemExpanding(itemLayout())); updateFont(); updateGridSize(); @@ -119,19 +116,19 @@ KItemListWidgetCreatorBase* DolphinItemListView::defaultWidgetCreator() const return new KItemListWidgetCreator<DolphinFileItemListWidget>(); } -void DolphinItemListView::onItemLayoutChanged(ItemLayout current, ItemLayout previous) +bool DolphinItemListView::itemLayoutSupportsItemExpanding(ItemLayout layout) const { - Q_UNUSED(previous); + return layout == DetailsLayout && DetailsModeSettings::expandableFolders(); +} - if (current == DetailsLayout) { - setSupportsItemExpanding(DetailsModeSettings::expandableFolders()); - setHeaderVisible(true); - } else { - setHeaderVisible(false); - } +void DolphinItemListView::onItemLayoutChanged(ItemLayout current, ItemLayout previous) +{ + setHeaderVisible(current == DetailsLayout); updateFont(); updateGridSize(); + + KFileItemListView::onItemLayoutChanged(current, previous); } void DolphinItemListView::onPreviewsShownChanged(bool shown) diff --git a/src/views/dolphinitemlistview.h b/src/views/dolphinitemlistview.h index c2d86cc5e..18bb284ac 100644 --- a/src/views/dolphinitemlistview.h +++ b/src/views/dolphinitemlistview.h @@ -50,6 +50,7 @@ public: protected: virtual KItemListWidgetCreatorBase* defaultWidgetCreator() const; + virtual bool itemLayoutSupportsItemExpanding(ItemLayout layout) const; virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous); virtual void onPreviewsShownChanged(bool shown); virtual void onVisibleRolesChanged(const QList<QByteArray>& current, diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 20bc9f522..c1d245301 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -556,8 +556,8 @@ QString DolphinView::statusBarText() const } if (folderCount + fileCount == 1) { - // If only one item is selected, show the filename - filesText = i18nc("@info:status", "<filename>%1</filename> selected", list.first().text()); + // If only one item is selected, show info about it + return list.first().getStatusBarInfo(); } else { // At least 2 items are selected foldersText = i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount); @@ -1666,7 +1666,7 @@ QMimeData* DolphinView::selectionMimeData() const void DolphinView::updateWritableState() { const bool wasFolderWritable = m_isFolderWritable; - m_isFolderWritable = true; + m_isFolderWritable = false; const KFileItem item = m_model->rootItem(); if (!item.isNull()) { |
