diff options
Diffstat (limited to 'src')
52 files changed, 1279 insertions, 1002 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8f7f4db77..f8d266994 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,17 +1,18 @@ -macro_optional_find_package(Nepomuk) -macro_log_feature(Nepomuk_FOUND "Nepomuk" "Nepomuk" "http://www.kde.org" FALSE "" "For adding desktop-wide tagging support to dolphin") -macro_bool_to_01(Nepomuk_FOUND HAVE_NEPOMUK) +macro_optional_find_package(Soprano) +macro_optional_find_package(NepomukCore) +macro_log_feature(NepomukCore_FOUND "Nepomuk" "Nepomuk" "http://www.kde.org" FALSE "" "For adding desktop-wide tagging support to dolphin") +macro_bool_to_01(NepomukCore_FOUND HAVE_NEPOMUK) configure_file(config-nepomuk.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-nepomuk.h ) macro_bool_to_01(X11_Xrender_FOUND HAVE_XRENDER) configure_file(config-X11.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-X11.h ) -include_directories( ${KDE4_INCLUDE_DIR} ${QT_INCLUDES} ) +include_directories( ${KACTIVITIES_INCLUDE_DIRS} ) -if (Nepomuk_FOUND) +if (NepomukCore_FOUND) # Yes, Soprano includes is what we need here - include_directories( ${SOPRANO_INCLUDE_DIR} ${NEPOMUK_INCLUDE_DIR} ) -endif (Nepomuk_FOUND) + include_directories( ${SOPRANO_INCLUDE_DIR} ${NEPOMUK_CORE_INCLUDE_DIR} ) +endif (NepomukCore_FOUND) add_subdirectory(tests) @@ -29,12 +30,13 @@ set(dolphinprivate_LIB_SRCS kitemviews/kitemlistselectionmanager.cpp kitemviews/kitemliststyleoption.cpp kitemviews/kitemlistview.cpp + kitemviews/kitemlistviewaccessible.cpp kitemviews/kitemlistwidget.cpp kitemviews/kitemmodelbase.cpp kitemviews/kstandarditem.cpp kitemviews/kstandarditemlistgroupheader.cpp - kitemviews/kstandarditemlistview.cpp kitemviews/kstandarditemlistwidget.cpp + kitemviews/kstandarditemlistview.cpp kitemviews/kstandarditemmodel.cpp kitemviews/private/kfileitemclipboard.cpp kitemviews/private/kfileitemmodeldirlister.cpp @@ -72,21 +74,12 @@ set(dolphinprivate_LIB_SRCS views/zoomlevelinfo.cpp ) -if (Nepomuk_FOUND) +if (NepomukCore_FOUND) set(dolphinprivate_LIB_SRCS ${dolphinprivate_LIB_SRCS} kitemviews/private/knepomukrolesprovider.cpp - kitemviews/private/nepomuk/resourcewatcher.cpp ) - - qt4_add_dbus_interface(dolphinprivate_LIB_SRCS - kitemviews/private/nepomuk/org.kde.nepomuk.ResourceWatcherConnection.xml - resourcewatcherconnectioninterface) - - qt4_add_dbus_interface(dolphinprivate_LIB_SRCS - kitemviews/private/nepomuk/org.kde.nepomuk.ResourceWatcher.xml - resourcewatchermanagerinterface) -endif (Nepomuk_FOUND) +endif (NepomukCore_FOUND) kde4_add_kcfg_files(dolphinprivate_LIB_SRCS settings/dolphin_compactmodesettings.kcfgc @@ -106,15 +99,13 @@ target_link_libraries( ${KDE4_KNEWSTUFF3_LIBS} ) -if (Nepomuk_FOUND) +if (NepomukCore_FOUND) target_link_libraries( dolphinprivate - ${NEPOMUK_LIBRARIES} - ${NEPOMUK_QUERY_LIBRARIES} - nepomukutils + ${NEPOMUK_CORE_LIBRARY} ${SOPRANO_LIBRARIES} ) -endif (Nepomuk_FOUND) +endif (NepomukCore_FOUND) if(X11_Xrender_FOUND) target_link_libraries(dolphinprivate ${X11_Xrender_LIB}) @@ -234,14 +225,19 @@ target_link_libraries(kdeinit_dolphin ${KDE4_PHONON_LIBS} ) -if (Nepomuk_FOUND) +if (NepomukCore_FOUND) target_link_libraries(kdeinit_dolphin - ${NEPOMUK_LIBRARIES} + ${NEPOMUK_CORE_LIBRARY} ${SOPRANO_LIBRARIES} - ${NEPOMUK_QUERY_LIBRARIES} - nepomukutils ) -endif (Nepomuk_FOUND) +endif (NepomukCore_FOUND) + +if (KActivities_FOUND) + target_link_libraries( + kdeinit_dolphin + ${KACTIVITIES_LIBRARY} + ) +endif (KActivities_FOUND) install(TARGETS kdeinit_dolphin ${INSTALL_TARGETS_DEFAULT_ARGS}) install(TARGETS dolphin ${INSTALL_TARGETS_DEFAULT_ARGS}) @@ -305,12 +301,12 @@ target_link_libraries(kcm_dolphinviewmodes ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS target_link_libraries(kcm_dolphinnavigation ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS} dolphinprivate) target_link_libraries(kcm_dolphinservices ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS} ${KDE4_KIO_LIBS} ${KDE4_KNEWSTUFF3_LIBRARY} dolphinprivate) target_link_libraries(kcm_dolphingeneral ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS} ${KDE4_KIO_LIBS} dolphinprivate) -if (Nepomuk_FOUND) - target_link_libraries(kcm_dolphinviewmodes ${NEPOMUK_LIBRARIES}) - target_link_libraries(kcm_dolphinnavigation ${NEPOMUK_LIBRARIES}) - target_link_libraries(kcm_dolphinservices ${NEPOMUK_LIBRARIES}) - target_link_libraries(kcm_dolphingeneral ${NEPOMUK_LIBRARIES}) -endif (Nepomuk_FOUND) +if (NepomukCore_FOUND) + target_link_libraries(kcm_dolphinviewmodes ${NEPOMUK_CORE_LIBRARY}) + target_link_libraries(kcm_dolphinnavigation ${NEPOMUK_CORE_LIBRARY}) + target_link_libraries(kcm_dolphinservices ${NEPOMUK_CORE_LIBRARY}) + target_link_libraries(kcm_dolphingeneral ${NEPOMUK_CORE_LIBRARY}) +endif (NepomukCore_FOUND) install(TARGETS kcm_dolphinviewmodes DESTINATION ${PLUGIN_INSTALL_DIR} ) install(TARGETS kcm_dolphinnavigation DESTINATION ${PLUGIN_INSTALL_DIR} ) diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index babaf1486..11e03d0f1 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -617,7 +617,7 @@ void DolphinMainWindow::closeEvent(QCloseEvent* event) break; case KDialog::No: // Close only the current tab - closeTab(); + closeTab(); default: event->ignore(); return; @@ -683,7 +683,7 @@ void DolphinMainWindow::readProperties(const KConfigGroup& group) // openNewTab() needs to be called only tabCount - 1 times if (i != tabCount - 1) { - openNewTab(); + openNewTab(); } } @@ -1560,12 +1560,12 @@ void DolphinMainWindow::setupActions() KToggleAction* editableLocation = actionCollection()->add<KToggleAction>("editable_location"); editableLocation->setText(i18nc("@action:inmenu Navigation Bar", "Editable Location")); - editableLocation->setShortcut(Qt::CTRL | Qt::Key_L); + editableLocation->setShortcut(Qt::Key_F6); connect(editableLocation, SIGNAL(triggered()), this, SLOT(toggleEditLocation())); KAction* replaceLocation = actionCollection()->addAction("replace_location"); replaceLocation->setText(i18nc("@action:inmenu Navigation Bar", "Replace Location")); - replaceLocation->setShortcut(Qt::Key_F6); + replaceLocation->setShortcut(Qt::CTRL | Qt::Key_L); connect(replaceLocation, SIGNAL(triggered()), this, SLOT(replaceLocation())); // setup 'Go' menu @@ -1704,7 +1704,7 @@ void DolphinMainWindow::setupDockWidgets() connect(foldersPanel, SIGNAL(folderActivated(KUrl)), this, SLOT(changeUrl(KUrl))); connect(foldersPanel, SIGNAL(folderMiddleClicked(KUrl)), - this, SLOT(openNewActivatedTab(KUrl))); + this, SLOT(openNewTab(KUrl))); connect(foldersPanel, SIGNAL(errorMessage(QString)), this, SLOT(slotPanelErrorMessage(QString))); @@ -1756,13 +1756,15 @@ void DolphinMainWindow::setupDockWidgets() connect(placesPanel, SIGNAL(placeActivated(KUrl)), this, SLOT(changeUrl(KUrl))); connect(placesPanel, SIGNAL(placeMiddleClicked(KUrl)), - this, SLOT(openNewActivatedTab(KUrl))); + this, SLOT(openNewTab(KUrl))); connect(placesPanel, SIGNAL(errorMessage(QString)), this, SLOT(slotPanelErrorMessage(QString))); connect(this, SIGNAL(urlChanged(KUrl)), placesPanel, SLOT(setUrl(KUrl))); connect(placesDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotPlacesPanelVisibilityChanged(bool))); + connect(this, SIGNAL(settingsChanged()), + placesPanel, SLOT(readSettings())); // Add actions into the "Panels" menu KActionMenu* panelsMenu = new KActionMenu(i18nc("@action:inmenu View", "Panels"), this); @@ -1953,6 +1955,8 @@ void DolphinMainWindow::refreshViews() toggleSplitView(); } } + + emit settingsChanged(); } void DolphinMainWindow::clearStatusBar() diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index ab79fb0e6..7da5801ff 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -151,6 +151,11 @@ signals: */ void requestItemInfo(const KFileItem& item); + /** + * Is emitted if the settings have been changed. + */ + void settingsChanged(); + protected: /** @see QWidget::showEvent() */ virtual void showEvent(QShowEvent* event); diff --git a/src/dolphinnewfilemenu.cpp b/src/dolphinnewfilemenu.cpp index 30d79c670..9d9baabe2 100644 --- a/src/dolphinnewfilemenu.cpp +++ b/src/dolphinnewfilemenu.cpp @@ -22,7 +22,6 @@ #include "dolphinmainwindow.h" #include "dolphinviewcontainer.h" -#include "statusbar/dolphinstatusbar.h" #include "views/dolphinnewfilemenuobserver.h" #include "views/dolphinview.h" diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index 31c82d606..6e99437d9 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -44,6 +44,10 @@ #include <KUrlNavigator> #include <KRun> +#ifdef KActivities_FOUND +#include <KActivities/ResourceInstance> +#endif + #include "dolphin_generalsettings.h" #include "filterbar/filterbar.h" #include "search/dolphinsearchbox.h" @@ -64,6 +68,9 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) : m_statusBarTimer(0), m_statusBarTimestamp(), m_autoGrabFocus(true) +#ifdef KActivities_FOUND + , m_activityResourceInstance(0) +#endif { hide(); @@ -104,6 +111,7 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) : connect(m_view, SIGNAL(redirection(KUrl,KUrl)), this, SLOT(redirect(KUrl,KUrl))); connect(m_view, SIGNAL(directoryLoadingStarted()), this, SLOT(slotDirectoryLoadingStarted())); connect(m_view, SIGNAL(directoryLoadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted())); + connect(m_view, SIGNAL(directoryLoadingCanceled()), this, SLOT(slotDirectoryLoadingCanceled())); connect(m_view, SIGNAL(itemCountChanged()), this, SLOT(delayedStatusBarUpdate())); connect(m_view, SIGNAL(directoryLoadingProgress(int)), this, SLOT(updateDirectoryLoadingProgress(int))); connect(m_view, SIGNAL(directorySortingProgress(int)), this, SLOT(updateDirectorySortingProgress(int))); @@ -157,6 +165,14 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) : m_topLayout->addWidget(m_statusBar); setSearchModeEnabled(isSearchUrl(url)); + + // Initialize kactivities resource instance + + #ifdef KActivities_FOUND + m_activityResourceInstance = new KActivities::ResourceInstance( + window()->winId(), url); + m_activityResourceInstance->setParent(this); + #endif } DolphinViewContainer::~DolphinViewContainer() @@ -172,6 +188,14 @@ void DolphinViewContainer::setActive(bool active) { m_urlNavigator->setActive(active); m_view->setActive(active); + + #ifdef KActivities_FOUND + if (active) { + m_activityResourceInstance->notifyFocusedIn(); + } else { + m_activityResourceInstance->notifyFocusedOut(); + } + #endif } bool DolphinViewContainer::isActive() const @@ -338,6 +362,10 @@ void DolphinViewContainer::setUrl(const KUrl& newUrl) if (newUrl != m_urlNavigator->locationUrl()) { m_urlNavigator->setLocationUrl(newUrl); } + + #ifdef KActivities_FOUND + m_activityResourceInstance->setUri(newUrl); + #endif } void DolphinViewContainer::setFilterBarVisible(bool visible) @@ -424,6 +452,16 @@ void DolphinViewContainer::slotDirectoryLoadingCompleted() } } +void DolphinViewContainer::slotDirectoryLoadingCanceled() +{ + if (!m_statusBar->progressText().isEmpty()) { + m_statusBar->setProgressText(QString()); + m_statusBar->setProgress(100); + } + + showErrorMessage("Directory loading has been canceled."); +} + void DolphinViewContainer::slotUrlIsFileError(const KUrl& url) { const KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url); diff --git a/src/dolphinviewcontainer.h b/src/dolphinviewcontainer.h index fd52806d9..0300273c1 100644 --- a/src/dolphinviewcontainer.h +++ b/src/dolphinviewcontainer.h @@ -31,6 +31,13 @@ #include <QWidget> #include <views/dolphinview.h> +#include <config-apps.h> + +#ifdef KActivities_FOUND +namespace KActivities { + class ResourceInstance; +} +#endif class FilterBar; class KMessageWidget; @@ -189,6 +196,12 @@ private slots: void slotDirectoryLoadingCompleted(); /** + * Updates the statusbar to show, that the directory loading has + * been canceled. + */ + void slotDirectoryLoadingCanceled(); + + /** * Is called if the URL set by DolphinView::setUrl() represents * a file and not a directory. Takes care to activate the file. */ @@ -308,6 +321,11 @@ private: QTimer* m_statusBarTimer; // Triggers a delayed update QElapsedTimer m_statusBarTimestamp; // Time in ms since last update bool m_autoGrabFocus; + +#ifdef KActivities_FOUND +private: + KActivities::ResourceInstance * m_activityResourceInstance; +#endif }; #endif // DOLPHINVIEWCONTAINER_H diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index 61f512a8e..231bfe077 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -716,6 +716,8 @@ void KFileItemModel::slotCanceled() { m_maximumUpdateIntervalTimer->stop(); dispatchPendingItemsToInsert(); + + emit directoryLoadingCanceled(); } void KFileItemModel::slotNewItems(const KFileItemList& items) diff --git a/src/kitemviews/kfileitemmodel.h b/src/kitemviews/kfileitemmodel.h index 5bcebce24..ef9dc98b9 100644 --- a/src/kitemviews/kfileitemmodel.h +++ b/src/kitemviews/kfileitemmodel.h @@ -217,6 +217,11 @@ signals: void directoryLoadingCompleted(); /** + * Is emitted after the loading of a directory has been canceled. + */ + void directoryLoadingCanceled(); + + /** * Informs about the progress in percent when loading a directory. It is assured * that the signal directoryLoadingStarted() has been emitted before. */ diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp b/src/kitemviews/kfileitemmodelrolesupdater.cpp index 57beb9d2f..ae9358192 100644 --- a/src/kitemviews/kfileitemmodelrolesupdater.cpp +++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp @@ -40,7 +40,7 @@ #ifdef HAVE_NEPOMUK #include "private/knepomukrolesprovider.h" - #include "private/nepomuk/resourcewatcher.h" + #include <Nepomuk2/ResourceWatcher> #endif // Required includes for subItemsCount(): @@ -92,7 +92,6 @@ KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel* model, QO , m_nepomukResourceWatcher(0), m_nepomukUriItems() #endif - { Q_ASSERT(model); @@ -277,15 +276,15 @@ void KFileItemModelRolesUpdater::setRoles(const QSet<QByteArray>& roles) if (hasNepomukRole && !m_nepomukResourceWatcher) { Q_ASSERT(m_nepomukUriItems.isEmpty()); - m_nepomukResourceWatcher = new Nepomuk::ResourceWatcher(this); - connect(m_nepomukResourceWatcher, SIGNAL(propertyChanged(Nepomuk::Resource,Nepomuk::Types::Property,QVariantList,QVariantList)), - this, SLOT(applyChangedNepomukRoles(Nepomuk::Resource))); - connect(m_nepomukResourceWatcher, SIGNAL(propertyRemoved(Nepomuk::Resource,Nepomuk::Types::Property,QVariant)), - this, SLOT(applyChangedNepomukRoles(Nepomuk::Resource))); - connect(m_nepomukResourceWatcher, SIGNAL(propertyAdded(Nepomuk::Resource,Nepomuk::Types::Property,QVariant)), - this, SLOT(applyChangedNepomukRoles(Nepomuk::Resource))); - connect(m_nepomukResourceWatcher, SIGNAL(resourceCreated(Nepomuk::Resource,QList<QUrl>)), - this, SLOT(applyChangedNepomukRoles(Nepomuk::Resource))); + m_nepomukResourceWatcher = new Nepomuk2::ResourceWatcher(this); + connect(m_nepomukResourceWatcher, SIGNAL(propertyChanged(Nepomuk2::Resource,Nepomuk2::Types::Property,QVariantList,QVariantList)), + this, SLOT(applyChangedNepomukRoles(Nepomuk2::Resource))); + connect(m_nepomukResourceWatcher, SIGNAL(propertyRemoved(Nepomuk2::Resource,Nepomuk2::Types::Property,QVariant)), + this, SLOT(applyChangedNepomukRoles(Nepomuk2::Resource))); + connect(m_nepomukResourceWatcher, SIGNAL(propertyAdded(Nepomuk2::Resource,Nepomuk2::Types::Property,QVariant)), + this, SLOT(applyChangedNepomukRoles(Nepomuk2::Resource))); + connect(m_nepomukResourceWatcher, SIGNAL(resourceCreated(Nepomuk2::Resource,QList<QUrl>)), + this, SLOT(applyChangedNepomukRoles(Nepomuk2::Resource))); } else if (!hasNepomukRole && m_nepomukResourceWatcher) { delete m_nepomukResourceWatcher; m_nepomukResourceWatcher = 0; @@ -352,14 +351,14 @@ void KFileItemModelRolesUpdater::slotItemsRemoved(const KItemRangeList& itemRang if (m_nepomukResourceWatcher) { // Don't let the ResourceWatcher watch for removed items if (allItemsRemoved) { - m_nepomukResourceWatcher->setResources(QList<Nepomuk::Resource>()); + m_nepomukResourceWatcher->setResources(QList<Nepomuk2::Resource>()); m_nepomukResourceWatcher->stop(); m_nepomukUriItems.clear(); } else { - QList<Nepomuk::Resource> newResources; - const QList<Nepomuk::Resource> oldResources = m_nepomukResourceWatcher->resources(); - foreach (const Nepomuk::Resource& resource, oldResources) { - const QUrl uri = resource.resourceUri(); + QList<Nepomuk2::Resource> newResources; + const QList<Nepomuk2::Resource> oldResources = m_nepomukResourceWatcher->resources(); + foreach (const Nepomuk2::Resource& resource, oldResources) { + const QUrl uri = resource.uri(); const KUrl itemUrl = m_nepomukUriItems.value(uri); if (m_model->index(itemUrl) >= 0) { newResources.append(resource); @@ -439,22 +438,9 @@ void KFileItemModelRolesUpdater::slotSortRoleChanged(const QByteArray& current, void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem& item, const QPixmap& pixmap) { - const int oldNumberOfPendingItems = m_pendingVisibleItems.count() + m_pendingInvisibleItems.count(); - m_pendingVisibleItems.remove(item); m_pendingInvisibleItems.remove(item); - const int newNumberOfPendingItems = m_pendingVisibleItems.count() + m_pendingInvisibleItems.count(); - - if (oldNumberOfPendingItems == newNumberOfPendingItems) { - // 'item' could not be removed from either of the sets. It looks like - // we have hit bug 304986. Replace the items in the sets by the items - // in the model to work around the problem. - // NOTE: This workaround is not needed any more in KDE 4.10. - m_pendingVisibleItems = sortedItems(m_pendingVisibleItems).toSet(); - m_pendingInvisibleItems = sortedItems(m_pendingInvisibleItems).toSet(); - } - const int index = m_model->index(item); if (index < 0) { return; @@ -512,22 +498,9 @@ void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem& item, const QPi void KFileItemModelRolesUpdater::slotPreviewFailed(const KFileItem& item) { - const int oldNumberOfPendingItems = m_pendingVisibleItems.count() + m_pendingInvisibleItems.count(); - m_pendingVisibleItems.remove(item); m_pendingInvisibleItems.remove(item); - const int newNumberOfPendingItems = m_pendingVisibleItems.count() + m_pendingInvisibleItems.count(); - - if (oldNumberOfPendingItems == newNumberOfPendingItems) { - // 'item' could not be removed from either of the sets. It looks like - // we have hit bug 304986. Replace the items in the sets by the items - // in the model to work around the problem. - // NOTE: This workaround is not needed any more in KDE 4.10. - m_pendingVisibleItems = sortedItems(m_pendingVisibleItems).toSet(); - m_pendingInvisibleItems = sortedItems(m_pendingInvisibleItems).toSet(); - } - const bool clearPreviews = m_clearPreviews; m_clearPreviews = true; applyResolvedRoles(item, ResolveAll); @@ -568,11 +541,10 @@ void KFileItemModelRolesUpdater::resolveNextPendingRoles() bool changed = false; for (int i = 0; i <= 1; ++i) { QSet<KFileItem>& pendingItems = (i == 0) ? m_pendingVisibleItems : m_pendingInvisibleItems; - QSetIterator<KFileItem> it(pendingItems); - while (it.hasNext() && !changed && resolvedCount < MaxResolveItemsCount) { - const KFileItem item = it.next(); - pendingItems.remove(item); - changed = applyResolvedRoles(item, ResolveAll); + QSet<KFileItem>::iterator it = pendingItems.begin(); + while (it != pendingItems.end() && !changed && resolvedCount < MaxResolveItemsCount) { + changed = applyResolvedRoles(*it, ResolveAll); + it = pendingItems.erase(it); ++resolvedCount; } } @@ -616,10 +588,10 @@ void KFileItemModelRolesUpdater::resolveChangedItems() startUpdating(itemRanges); } -void KFileItemModelRolesUpdater::applyChangedNepomukRoles(const Nepomuk::Resource& resource) +void KFileItemModelRolesUpdater::applyChangedNepomukRoles(const Nepomuk2::Resource& resource) { #ifdef HAVE_NEPOMUK - const KUrl itemUrl = m_nepomukUriItems.value(resource.resourceUri()); + const KUrl itemUrl = m_nepomukUriItems.value(resource.uri()); const KFileItem item = m_model->fileItem(itemUrl); if (item.isNull()) { @@ -682,13 +654,15 @@ void KFileItemModelRolesUpdater::startUpdating(const KItemRangeList& itemRanges) if (hasValidIndexRange) { // Move all current pending visible items that are not visible anymore // to the pending invisible items. - QSetIterator<KFileItem> it(m_pendingVisibleItems); - while (it.hasNext()) { - const KFileItem item = it.next(); + QSet<KFileItem>::iterator it = m_pendingVisibleItems.begin(); + while (it != m_pendingVisibleItems.end()) { + const KFileItem item = *it; const int index = m_model->index(item); if (index < m_firstVisibleIndex || index > m_lastVisibleIndex) { - m_pendingVisibleItems.remove(item); + it = m_pendingVisibleItems.erase(it); m_pendingInvisibleItems.insert(item); + } else { + ++it; } } } @@ -735,11 +709,14 @@ void KFileItemModelRolesUpdater::startPreviewJob(const KFileItemList& items) // MIME-type in a fast way. QElapsedTimer timer; timer.start(); + KFileItemList itemSubSet; - for (int i = 0; i < items.count(); ++i) { + const int count = items.count(); + itemSubSet.reserve(count); + for (int i = 0; i < count; ++i) { KFileItem item = items.at(i); item.determineMimeType(); - itemSubSet.append(items.at(i)); + itemSubSet.append(item); if (timer.elapsed() > MaxBlockTimeout) { #ifdef KFILEITEMMODELROLESUPDATER_DEBUG kDebug() << "Maximum time of" << MaxBlockTimeout << "ms exceeded, creating only previews for" @@ -794,13 +771,15 @@ void KFileItemModelRolesUpdater::resolvePendingRoles() timer.start(); // Resolve the MIME type of all visible items - QSetIterator<KFileItem> visibleIt(m_pendingVisibleItems); - while (visibleIt.hasNext()) { - const KFileItem item = visibleIt.next(); + QSet<KFileItem>::iterator visibleIt = m_pendingVisibleItems.begin(); + while (visibleIt != m_pendingVisibleItems.end()) { + const KFileItem item = *visibleIt; if (!hasSlowRoles) { Q_ASSERT(!m_pendingInvisibleItems.contains(item)); // All roles will be resolved by applyResolvedRoles() - m_pendingVisibleItems.remove(item); + visibleIt = m_pendingVisibleItems.erase(visibleIt); + } else { + ++visibleIt; } applyResolvedRoles(item, resolveHint); ++resolvedCount; @@ -898,7 +877,8 @@ void KFileItemModelRolesUpdater::sortAndResolveAllRoles() m_pendingInvisibleItems.insert(item); } } - for (int i = m_lastVisibleIndex + 1; i < m_model->count(); ++i) { + const int count = m_model->count(); + for (int i = m_lastVisibleIndex + 1; i < count; ++i) { const KFileItem item = m_model->fileItem(i); if (!item.isNull()) { m_pendingInvisibleItems.insert(item); @@ -921,26 +901,42 @@ void KFileItemModelRolesUpdater::sortAndResolvePendingRoles() // Trigger a preview generation of all pending items. Assure that the visible // pending items get generated first. - QSet<KFileItem> pendingItems; - pendingItems += m_pendingVisibleItems; - pendingItems += m_pendingInvisibleItems; - resetPendingRoles(); - Q_ASSERT(m_pendingVisibleItems.isEmpty()); - Q_ASSERT(m_pendingInvisibleItems.isEmpty()); + // Step 1: Check if any items in m_pendingVisibleItems are not visible any more + // and move them to m_pendingInvisibleItems. + QSet<KFileItem>::iterator itVisible = m_pendingVisibleItems.begin(); + while (itVisible != m_pendingVisibleItems.end()) { + const KFileItem item = *itVisible; + if (item.isNull()) { + itVisible = m_pendingVisibleItems.erase(itVisible); + continue; + } - QSetIterator<KFileItem> it(pendingItems); - while (it.hasNext()) { - const KFileItem item = it.next(); + const int index = m_model->index(item); + if (!hasValidIndexRange || (index >= m_firstVisibleIndex && index <= m_lastVisibleIndex)) { + ++itVisible; + } else { + itVisible = m_pendingVisibleItems.erase(itVisible); + m_pendingInvisibleItems.insert(item); + } + } + + // Step 2: Check if any items in m_pendingInvisibleItems have become visible + // and move them to m_pendingVisibleItems. + QSet<KFileItem>::iterator itInvisible = m_pendingInvisibleItems.begin(); + while (itInvisible != m_pendingInvisibleItems.end()) { + const KFileItem item = *itInvisible; if (item.isNull()) { + itInvisible = m_pendingInvisibleItems.erase(itInvisible); continue; } const int index = m_model->index(item); if (!hasValidIndexRange || (index >= m_firstVisibleIndex && index <= m_lastVisibleIndex)) { + itInvisible = m_pendingInvisibleItems.erase(itInvisible); m_pendingVisibleItems.insert(item); } else { - m_pendingInvisibleItems.insert(item); + ++itInvisible; } } @@ -1075,19 +1071,19 @@ QHash<QByteArray, QVariant> KFileItemModelRolesUpdater::rolesData(const KFileIte #ifdef HAVE_NEPOMUK if (m_nepomukResourceWatcher) { const KNepomukRolesProvider& rolesProvider = KNepomukRolesProvider::instance(); - Nepomuk::Resource resource(item.nepomukUri()); + Nepomuk2::Resource resource(item.nepomukUri()); QHashIterator<QByteArray, QVariant> it(rolesProvider.roleValues(resource, m_roles)); while (it.hasNext()) { it.next(); data.insert(it.key(), it.value()); } - QUrl uri = resource.resourceUri(); + QUrl uri = resource.uri(); if (uri.isEmpty()) { // TODO: Is there another way to explicitly create a resource? // We need a resource to be able to track it for changes. resource.setRating(0); - uri = resource.resourceUri(); + uri = resource.uri(); } if (!uri.isEmpty() && !m_nepomukUriItems.contains(uri)) { m_nepomukResourceWatcher->addResource(resource); diff --git a/src/kitemviews/kfileitemmodelrolesupdater.h b/src/kitemviews/kfileitemmodelrolesupdater.h index cabb00391..68559d8dd 100644 --- a/src/kitemviews/kfileitemmodelrolesupdater.h +++ b/src/kitemviews/kfileitemmodelrolesupdater.h @@ -39,7 +39,7 @@ class QPixmap; class QTimer; #ifdef HAVE_NEPOMUK - namespace Nepomuk + namespace Nepomuk2 { class ResourceWatcher; class Resource; @@ -47,7 +47,7 @@ class QTimer; #else // Required for the slot applyChangedNepomukRoles() that // cannot be ifdefined due to moc. - namespace Nepomuk + namespace Nepomuk2 { class Resource; } @@ -160,7 +160,7 @@ private slots: */ void resolveChangedItems(); - void applyChangedNepomukRoles(const Nepomuk::Resource& resource); + void applyChangedNepomukRoles(const Nepomuk2::Resource& resource); /** * Is invoked if a directory watched by KDirWatch got dirty. Updates @@ -274,7 +274,7 @@ private: mutable QSet<QString> m_watchedDirs; // Required as sadly KDirWatch does not offer a getter method // to get all watched directories. #ifdef HAVE_NEPOMUK - Nepomuk::ResourceWatcher* m_nepomukResourceWatcher; + Nepomuk2::ResourceWatcher* m_nepomukResourceWatcher; mutable QHash<QUrl, KUrl> m_nepomukUriItems; #endif }; diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp index df940de7d..697e04fef 100644 --- a/src/kitemviews/kitemlistcontroller.cpp +++ b/src/kitemviews/kitemlistcontroller.cpp @@ -40,6 +40,7 @@ #include <QGraphicsView> #include <QMimeData> #include <QTimer> +#include <QAccessible> KItemListController::KItemListController(KItemModelBase* model, KItemListView* view, QObject* parent) : QObject(parent), @@ -889,6 +890,8 @@ bool KItemListController::dropEvent(QGraphicsSceneDragDropEvent* event, const QT emit itemDropEvent(m_view->itemAt(pos), event); } + QAccessible::updateAccessibility(view(), 0, QAccessible::DragDropEnd); + return true; } @@ -1136,6 +1139,7 @@ void KItemListController::startDragging() drag->setHotSpot(hotSpot); drag->exec(Qt::MoveAction | Qt::CopyAction | Qt::LinkAction, Qt::CopyAction); + QAccessible::updateAccessibility(view(), 0, QAccessible::DragDropStart); } KItemListWidget* KItemListController::hoveredWidget() const diff --git a/src/kitemviews/kitemlistview.cpp b/src/kitemviews/kitemlistview.cpp index ef6dfc833..6a68ae798 100644 --- a/src/kitemviews/kitemlistview.cpp +++ b/src/kitemviews/kitemlistview.cpp @@ -23,6 +23,7 @@ #include "kitemlistview.h" #include <KDebug> +#include "kitemlistcontainer.h" #include "kitemlistcontroller.h" #include "kitemlistheader.h" #include "kitemlistselectionmanager.h" @@ -43,6 +44,8 @@ #include <QStyleOptionRubberBand> #include <QTimer> +#include "kitemlistviewaccessible.h" + namespace { // Time in ms until reaching the autoscroll margin triggers // an initial autoscrolling @@ -52,6 +55,21 @@ namespace { const int RepeatingAutoScrollDelay = 1000 / 60; } +#ifndef QT_NO_ACCESSIBILITY +QAccessibleInterface* accessibleInterfaceFactory(const QString &key, QObject *object) +{ + Q_UNUSED(key) + + if (KItemListContainer* container = qobject_cast<KItemListContainer*>(object)) { + return new KItemListContainerAccessible(container); + } else if (KItemListView* view = qobject_cast<KItemListView*>(object)) { + return new KItemListViewAccessible(view); + } + + return 0; +} +#endif + KItemListView::KItemListView(QGraphicsWidget* parent) : QGraphicsWidget(parent), m_enabledSelectionToggles(false), @@ -110,6 +128,11 @@ KItemListView::KItemListView(QGraphicsWidget* parent) : m_headerWidget->setVisible(false); m_header = new KItemListHeader(this); + +#ifndef QT_NO_ACCESSIBILITY + QAccessible::installFactory(accessibleInterfaceFactory); +#endif + } KItemListView::~KItemListView() @@ -1189,6 +1212,7 @@ void KItemListView::slotItemsChanged(const KItemRangeList& itemRanges, doLayout(NoAnimation); } } + QAccessible::updateAccessibility(this, 0, QAccessible::TableModelChanged); } void KItemListView::slotGroupedSortingChanged(bool current) @@ -1251,6 +1275,7 @@ void KItemListView::slotCurrentChanged(int current, int previous) if (currentWidget) { currentWidget->setCurrent(true); } + QAccessible::updateAccessibility(this, current+1, QAccessible::Focus); } void KItemListView::slotSelectionChanged(const QSet<int>& current, const QSet<int>& previous) @@ -1413,9 +1438,9 @@ void KItemListView::triggerAutoScrolling() const qreal newScrollOffset = qMin(scrollOffset() + m_autoScrollIncrement, maxVisibleOffset); setScrollOffset(newScrollOffset); - // Trigger the autoscroll timer which will periodically call - // triggerAutoScrolling() - m_autoScrollTimer->start(RepeatingAutoScrollDelay); + // Trigger the autoscroll timer which will periodically call + // triggerAutoScrolling() + m_autoScrollTimer->start(RepeatingAutoScrollDelay); } void KItemListView::slotGeometryOfGroupHeaderParentChanged() diff --git a/src/kitemviews/kitemlistview.h b/src/kitemviews/kitemlistview.h index 984781569..2baf20c94 100644 --- a/src/kitemviews/kitemlistview.h +++ b/src/kitemviews/kitemlistview.h @@ -749,6 +749,8 @@ private: friend class KItemListHeader; // Accesses m_headerWidget friend class KItemListController; friend class KItemListControllerTest; + friend class KItemListViewAccessible; + friend class KItemListAccessibleCell; }; /** diff --git a/src/kitemviews/kitemlistviewaccessible.cpp b/src/kitemviews/kitemlistviewaccessible.cpp new file mode 100644 index 000000000..d4b8bf6e6 --- /dev/null +++ b/src/kitemviews/kitemlistviewaccessible.cpp @@ -0,0 +1,539 @@ +/*************************************************************************** + * Copyright (C) 2012 by Amandeep Singh <[email protected]> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program 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 General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#ifndef QT_NO_ACCESSIBILITY + +#include "kitemlistviewaccessible.h" + +#include "kitemlistcontainer.h" +#include "kitemlistcontroller.h" +#include "kitemlistselectionmanager.h" +#include "kitemlistview.h" +#include "private/kitemlistviewlayouter.h" + +#include <QtGui/qaccessible2.h> +#include <qgraphicsscene.h> +#include <qgraphicsview.h> + +#include <KDebug> +#include <QHash> + +KItemListView* KItemListViewAccessible::view() const +{ + return qobject_cast<KItemListView*>(object()); +} + +KItemListViewAccessible::KItemListViewAccessible(KItemListView* view_) : + QAccessibleObjectEx(view_) +{ + Q_ASSERT(view()); +} + +void KItemListViewAccessible::modelReset() +{ +} + +QAccessible::Role KItemListViewAccessible::cellRole() const +{ + return QAccessible::Cell; +} + +QAccessibleTable2CellInterface* KItemListViewAccessible::cell(int index) const +{ + if (index < 0 || index >= view()->model()->count()) { + return 0; + } else { + return new KItemListAccessibleCell(view(), index); + } +} + +QVariant KItemListViewAccessible::invokeMethodEx(Method, int, const QVariantList&) +{ + return QVariant(); +} + +QAccessibleTable2CellInterface* KItemListViewAccessible::cellAt(int row, int column) const +{ + return cell(columnCount() * row + column); +} + +QAccessibleInterface* KItemListViewAccessible::caption() const +{ + return 0; +} + +QString KItemListViewAccessible::columnDescription(int) const +{ + return QString(); +} + +int KItemListViewAccessible::columnCount() const +{ + return view()->m_layouter->columnCount(); +} + +int KItemListViewAccessible::rowCount() const +{ + if (columnCount() <= 0) { + return 0; + } + + int itemCount = view()->model()->count(); + int rowCount = itemCount / columnCount(); + + if (rowCount <= 0) { + return 0; + } + + if (itemCount % columnCount()) { + ++rowCount; + } + return rowCount; +} + +int KItemListViewAccessible::selectedCellCount() const +{ + return view()->controller()->selectionManager()->selectedItems().size(); +} + +int KItemListViewAccessible::selectedColumnCount() const +{ + return 0; +} + +int KItemListViewAccessible::selectedRowCount() const +{ + return 0; +} + +QString KItemListViewAccessible::rowDescription(int) const +{ + return QString(); +} + +QList<QAccessibleTable2CellInterface*> KItemListViewAccessible::selectedCells() const +{ + QList<QAccessibleTable2CellInterface*> cells; + Q_FOREACH (int index, view()->controller()->selectionManager()->selectedItems()) { + cells.append(cell(index)); + } + return cells; +} + +QList<int> KItemListViewAccessible::selectedColumns() const +{ + return QList<int>(); +} + +QList<int> KItemListViewAccessible::selectedRows() const +{ + return QList<int>(); +} + +QAccessibleInterface* KItemListViewAccessible::summary() const +{ + return 0; +} + +bool KItemListViewAccessible::isColumnSelected(int) const +{ + return false; +} + +bool KItemListViewAccessible::isRowSelected(int) const +{ + return false; +} + +bool KItemListViewAccessible::selectRow(int) +{ + return true; +} + +bool KItemListViewAccessible::selectColumn(int) +{ + return true; +} + +bool KItemListViewAccessible::unselectRow(int) +{ + return true; +} + +bool KItemListViewAccessible::unselectColumn(int) +{ + return true; +} + +QAccessible2::TableModelChange KItemListViewAccessible::modelChange() const +{ + QAccessible2::TableModelChange change; + change.lastRow = rowCount(); + change.lastColumn = columnCount(); + return change; +} + +QAccessible::Role KItemListViewAccessible::role(int child) const +{ + Q_ASSERT(child >= 0); + + if (child > 0) { + return QAccessible::Cell; + } else { + return QAccessible::Table; + } +} + +QAccessible::State KItemListViewAccessible::state(int child) const +{ + if (child) { + QAccessibleInterface* interface = 0; + navigate(Child, child, &interface); + if (interface) { + return interface->state(0); + } + } + + return QAccessible::Normal | QAccessible::HasInvokeExtension; +} + +int KItemListViewAccessible::childAt(int x, int y) const +{ + const QPointF point = QPointF(x,y); + return view()->itemAt(view()->mapFromScene(point)); +} + +int KItemListViewAccessible::childCount() const +{ + return view()->model()->count(); +} + +int KItemListViewAccessible::indexOfChild(const QAccessibleInterface* interface) const +{ + const KItemListAccessibleCell* widget = static_cast<const KItemListAccessibleCell*>(interface); + return widget->index() + 1; +} + +QString KItemListViewAccessible::text(Text, int child) const +{ + Q_ASSERT(child == 0); + return QString(); +} + +QRect KItemListViewAccessible::rect(int child) const +{ + Q_UNUSED(child) + if (!view()->isVisible()) { + return QRect(); + } + const QPoint origin = view()->scene()->views()[0]->mapToGlobal(QPoint(0, 0)); + const QRect viewRect = view()->geometry().toRect(); + return viewRect.translated(origin); +} + +int KItemListViewAccessible::navigate(RelationFlag relation, int index, QAccessibleInterface** interface) const +{ + *interface = 0; + + switch (relation) { + case QAccessible::Child: + Q_ASSERT(index > 0); + *interface = cell(index - 1); + if (*interface) { + return 0; + } + break; + + default: + break; + } + + return -1; +} + +QAccessible::Relation KItemListViewAccessible::relationTo(int, const QAccessibleInterface*, int) const +{ + return QAccessible::Unrelated; +} + +#ifndef QT_NO_ACTION + +int KItemListViewAccessible::userActionCount(int) const +{ + return 0; +} + +QString KItemListViewAccessible::actionText(int, Text, int) const +{ + return QString(); +} + +bool KItemListViewAccessible::doAction(int, int, const QVariantList&) +{ + return false; +} + +#endif + +// Table Cell + +KItemListAccessibleCell::KItemListAccessibleCell(KItemListView* view, int index) : + m_view(view), + m_index(index) +{ + Q_ASSERT(index >= 0 && index < view->model()->count()); +} + +int KItemListAccessibleCell::columnExtent() const +{ + return 1; +} + +int KItemListAccessibleCell::rowExtent() const +{ + return 1; +} + +QList<QAccessibleInterface*> KItemListAccessibleCell::rowHeaderCells() const +{ + return QList<QAccessibleInterface*>(); +} + +QList<QAccessibleInterface*> KItemListAccessibleCell::columnHeaderCells() const +{ + return QList<QAccessibleInterface*>(); +} + +int KItemListAccessibleCell::columnIndex() const +{ + return m_view->m_layouter->itemColumn(m_index); +} + +int KItemListAccessibleCell::rowIndex() const +{ + return m_view->m_layouter->itemRow(m_index); +} + +bool KItemListAccessibleCell::isSelected() const +{ + return m_view->controller()->selectionManager()->isSelected(m_index); +} + +void KItemListAccessibleCell::rowColumnExtents(int* row, int* column, int* rowExtents, int* columnExtents, bool* selected) const +{ + const KItemListViewLayouter* layouter = m_view->m_layouter; + *row = layouter->itemRow(m_index); + *column = layouter->itemColumn(m_index); + *rowExtents = 1; + *columnExtents = 1; + *selected = isSelected(); +} + +QAccessibleTable2Interface* KItemListAccessibleCell::table() const +{ + return QAccessible::queryAccessibleInterface(m_view)->table2Interface(); +} + +QAccessible::Role KItemListAccessibleCell::role(int child) const +{ + Q_ASSERT(child == 0); + return QAccessible::Cell; +} + +QAccessible::State KItemListAccessibleCell::state(int child) const +{ + Q_ASSERT(child == 0); + QAccessible::State state = Normal; + + if (isSelected()) { + state |= Selected; + } + + if (m_view->controller()->selectionManager()->currentItem() == m_index) { + state |= Focused; + } + + state |= Selectable; + state |= Focusable; + + if (m_view->controller()->selectionBehavior() == KItemListController::MultiSelection) { + state |= MultiSelectable; + } + + if (m_view->model()->isExpandable(m_index)) { + if (m_view->model()->isExpanded(m_index)) { + state |= Expanded; + } else { + state |= Collapsed; + } + } + + return state; +} + +bool KItemListAccessibleCell::isExpandable() const +{ + return m_view->model()->isExpandable(m_index); +} + +QRect KItemListAccessibleCell::rect(int) const +{ + QRect rect = m_view->itemRect(m_index).toRect(); + + if (rect.isNull()) { + return QRect(); + } + + rect.translate(m_view->mapToScene(QPointF(0.0, 0.0)).toPoint()); + rect.translate(m_view->scene()->views()[0]->mapToGlobal(QPoint(0, 0))); + return rect; +} + +QString KItemListAccessibleCell::text(QAccessible::Text t, int child) const +{ + Q_ASSERT(child == 0); + Q_UNUSED(child) + + switch (t) { + case QAccessible::Value: + case QAccessible::Name: { + const QHash<QByteArray, QVariant> data = m_view->model()->data(m_index); + return data["text"].toString(); + } + + default: + break; + } + + return QString(); +} + +void KItemListAccessibleCell::setText(QAccessible::Text, int child, const QString&) +{ + Q_ASSERT(child == 0); +} + +bool KItemListAccessibleCell::isValid() const +{ + return m_view && (m_index >= 0) && (m_index < m_view->model()->count()); +} + +int KItemListAccessibleCell::childAt(int, int) const +{ + return 0; +} + +int KItemListAccessibleCell::childCount() const +{ + return 0; +} + +int KItemListAccessibleCell::indexOfChild(const QAccessibleInterface* child) const +{ + Q_UNUSED(child); + return -1; +} + +int KItemListAccessibleCell::navigate(RelationFlag relation, int index, QAccessibleInterface** interface) const +{ + if (relation == Ancestor && index == 1) { + *interface = new KItemListViewAccessible(m_view); + return 0; + } + + *interface = 0; + return -1; +} + +QAccessible::Relation KItemListAccessibleCell::relationTo(int child, const QAccessibleInterface* , int otherChild) const +{ + Q_ASSERT(child == 0); + Q_ASSERT(otherChild == 0); + return QAccessible::Unrelated; +} + +#ifndef QT_NO_ACTION + +int KItemListAccessibleCell::userActionCount(int) const +{ + return 0; +} + +QString KItemListAccessibleCell::actionText(int, Text, int) const +{ + return QString(); +} + +bool KItemListAccessibleCell::doAction(int, int, const QVariantList&) +{ + return false; +} + +#endif + +int KItemListAccessibleCell::index() const +{ + return m_index; +} + +QObject* KItemListAccessibleCell::object() const +{ + return 0; +} + +// Container Interface +KItemListContainerAccessible::KItemListContainerAccessible(KItemListContainer* container) : + QAccessibleWidgetEx(container) +{ +} + +KItemListContainerAccessible::~KItemListContainerAccessible() +{ +} + +int KItemListContainerAccessible::childCount() const +{ + return 1; +} + +int KItemListContainerAccessible::indexOfChild(const QAccessibleInterface* child) const +{ + if (child->object() == container()->controller()->view()) { + return 1; + } else { + return -1; + } +} + +int KItemListContainerAccessible::navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface** target) const +{ + if (relation == QAccessible::Child) { + *target = new KItemListViewAccessible(container()->controller()->view()); + return 0; + } else { + return QAccessibleWidgetEx::navigate(relation, index, target); + } +} + +const KItemListContainer* KItemListContainerAccessible::container() const +{ + return qobject_cast<KItemListContainer*>(object()); +} + +#endif // QT_NO_ACCESSIBILITY diff --git a/src/kitemviews/kitemlistviewaccessible.h b/src/kitemviews/kitemlistviewaccessible.h new file mode 100644 index 000000000..c2213cd67 --- /dev/null +++ b/src/kitemviews/kitemlistviewaccessible.h @@ -0,0 +1,163 @@ +/*************************************************************************** + * Copyright (C) 2012 by Amandeep Singh <[email protected]> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program 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 General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#ifndef KITEMLISTVIEWACCESSIBLE_H +#define KITEMLISTVIEWACCESSIBLE_H + +#ifndef QT_NO_ACCESSIBILITY + +#include <QtCore/qpointer.h> +#include <QtGui/qaccessible.h> +#include <QtGui/qaccessible2.h> +#include <QtGui/qaccessiblewidget.h> +#include <QtGui/qaccessibleobject.h> + +class KItemListView; +class KItemListContainer; + +class KItemListViewAccessible: public QAccessibleTable2Interface, public QAccessibleObjectEx +{ + Q_ACCESSIBLE_OBJECT + +public: + explicit KItemListViewAccessible(KItemListView* view); + + Role role(int child) const; + State state(int child) const; + QString text(Text t, int child) const; + QRect rect(int child) const; + + int childAt(int x, int y) const; + int childCount() const; + int indexOfChild(const QAccessibleInterface*) const; + + int navigate(RelationFlag relation, int index, QAccessibleInterface** interface) const; + Relation relationTo(int child, const QAccessibleInterface* other, int otherChild) const; + +#ifndef QT_NO_ACTION + int userActionCount(int child) const; + QString actionText(int action, Text t, int child) const; + bool doAction(int action, int child, const QVariantList& params); +#endif + QVariant invokeMethodEx(Method, int, const QVariantList&); + + // Table2 interface + virtual QAccessibleTable2CellInterface* cellAt(int row, int column) const; + virtual QAccessibleInterface* caption() const; + virtual QAccessibleInterface* summary() const; + virtual QString columnDescription(int column) const; + virtual QString rowDescription(int row) const; + virtual int columnCount() const; + virtual int rowCount() const; + virtual QAccessible2::TableModelChange modelChange() const; + virtual void rowsInserted(const QModelIndex&, int, int) {} + virtual void rowsRemoved(const QModelIndex&, int, int) {} + virtual void columnsInserted(const QModelIndex&, int, int) {} + virtual void columnsRemoved(const QModelIndex&, int, int) {} + virtual void rowsMoved(const QModelIndex&, int, int, const QModelIndex&, int) {} + virtual void columnsMoved(const QModelIndex&, int, int, const QModelIndex&, int) {} + + // Selection + virtual int selectedCellCount() const; + virtual int selectedColumnCount() const; + virtual int selectedRowCount() const; + virtual QList<QAccessibleTable2CellInterface*> selectedCells() const; + virtual QList<int> selectedColumns() const; + virtual QList<int> selectedRows() const; + virtual bool isColumnSelected(int column) const; + virtual bool isRowSelected(int row) const; + virtual bool selectRow(int row); + virtual bool selectColumn(int column); + virtual bool unselectRow(int row); + virtual bool unselectColumn(int column); + + KItemListView* view() const; + +protected: + virtual void modelReset(); + /** + * Create an QAccessibleTable2CellInterface representing the table + * cell at the @index. Index is 0-based. + */ + inline QAccessibleTable2CellInterface* cell(int index) const; + inline QAccessible::Role cellRole() const; +}; + +class KItemListAccessibleCell: public QAccessibleTable2CellInterface +{ +public: + KItemListAccessibleCell(KItemListView* view, int m_index); + + QObject* object() const; + Role role(int) const; + State state(int) const; + QRect rect(int) const; + bool isValid() const; + int childAt(int, int) const; + int childCount() const; + int indexOfChild(const QAccessibleInterface*) const; + QString text(Text t, int child) const; + void setText(Text t, int child, const QString& text); + int navigate(RelationFlag relation, int m_index, QAccessibleInterface** interface) const; + Relation relationTo(int child, const QAccessibleInterface* other, int otherChild) const; + bool isExpandable() const; + +#ifndef QT_NO_ACTION + int userActionCount(int child) const; + QString actionText(int action, Text t, int child) const; + bool doAction(int action, int child, const QVariantList& params); +#endif + + // Cell Interface + virtual int columnExtent() const; + virtual QList<QAccessibleInterface*> columnHeaderCells() const; + virtual int columnIndex() const; + virtual int rowExtent() const; + virtual QList<QAccessibleInterface*> rowHeaderCells() const; + virtual int rowIndex() const; + virtual bool isSelected() const; + virtual void rowColumnExtents(int* row, int* column, int* rowExtents, int* columnExtents, bool* selected) const; + virtual QAccessibleTable2Interface* table() const; + + inline int index() const; + +private: + QPointer<KItemListView> m_view; + int m_index; +}; + +class KItemListContainerAccessible : public QAccessibleWidgetEx +{ + Q_ACCESSIBLE_OBJECT + +public: + explicit KItemListContainerAccessible(KItemListContainer* container); + virtual ~KItemListContainerAccessible(); + + int childCount() const; + int indexOfChild(const QAccessibleInterface* child) const; + int navigate(RelationFlag relation, int entry, QAccessibleInterface** target) const; + +private: + const KItemListContainer* container() const; +}; + +#endif // QT_NO_ACCESSIBILITY + +#endif diff --git a/src/kitemviews/kstandarditemlistwidget.cpp b/src/kitemviews/kstandarditemlistwidget.cpp index f92cab50f..4d1031943 100644 --- a/src/kitemviews/kstandarditemlistwidget.cpp +++ b/src/kitemviews/kstandarditemlistwidget.cpp @@ -42,6 +42,7 @@ #include <QStyleOption> #include <QTextLayout> #include <QTextLine> +#include <QPixmapCache> // #define KSTANDARDITEMLISTWIDGET_DEBUG @@ -600,8 +601,8 @@ void KStandardItemListWidget::editedRoleChanged(const QByteArray& current, const { Q_UNUSED(previous); - QGraphicsView* parent = scene()->views()[0]; - if (current.isEmpty() || !parent || current != "text") { + QGraphicsView* parent = scene()->views()[0]; + if (current.isEmpty() || !parent || current != "text") { if (m_roleEditor) { emit roleEditingCanceled(index(), current, data().value(current)); @@ -1287,30 +1288,37 @@ void KStandardItemListWidget::closeRoleEditor() QPixmap KStandardItemListWidget::pixmapForIcon(const QString& name, int size) { - const KIcon icon(name); + const QString key = "KStandardItemListWidget:" % name % ":" % QString::number(size); + QPixmap pixmap; - int requestedSize; - if (size <= KIconLoader::SizeSmall) { - requestedSize = KIconLoader::SizeSmall; - } else if (size <= KIconLoader::SizeSmallMedium) { - requestedSize = KIconLoader::SizeSmallMedium; - } else if (size <= KIconLoader::SizeMedium) { - requestedSize = KIconLoader::SizeMedium; - } else if (size <= KIconLoader::SizeLarge) { - requestedSize = KIconLoader::SizeLarge; - } else if (size <= KIconLoader::SizeHuge) { - requestedSize = KIconLoader::SizeHuge; - } else if (size <= KIconLoader::SizeEnormous) { - requestedSize = KIconLoader::SizeEnormous; - } else if (size <= KIconLoader::SizeEnormous * 2) { - requestedSize = KIconLoader::SizeEnormous * 2; - } else { - requestedSize = size; - } + if (!QPixmapCache::find(key, pixmap)) { + const KIcon icon(name); + + int requestedSize; + if (size <= KIconLoader::SizeSmall) { + requestedSize = KIconLoader::SizeSmall; + } else if (size <= KIconLoader::SizeSmallMedium) { + requestedSize = KIconLoader::SizeSmallMedium; + } else if (size <= KIconLoader::SizeMedium) { + requestedSize = KIconLoader::SizeMedium; + } else if (size <= KIconLoader::SizeLarge) { + requestedSize = KIconLoader::SizeLarge; + } else if (size <= KIconLoader::SizeHuge) { + requestedSize = KIconLoader::SizeHuge; + } else if (size <= KIconLoader::SizeEnormous) { + requestedSize = KIconLoader::SizeEnormous; + } else if (size <= KIconLoader::SizeEnormous * 2) { + requestedSize = KIconLoader::SizeEnormous * 2; + } else { + requestedSize = size; + } + + pixmap = icon.pixmap(requestedSize, requestedSize); + if (requestedSize != size) { + KPixmapModifier::scale(pixmap, QSize(size, size)); + } - QPixmap pixmap = icon.pixmap(requestedSize, requestedSize); - if (requestedSize != size) { - KPixmapModifier::scale(pixmap, QSize(size, size)); + QPixmapCache::insert(key, pixmap); } return pixmap; diff --git a/src/kitemviews/private/kfileitemmodelsortalgorithm.cpp b/src/kitemviews/private/kfileitemmodelsortalgorithm.cpp index e0aac13de..9588d19bf 100644 --- a/src/kitemviews/private/kfileitemmodelsortalgorithm.cpp +++ b/src/kitemviews/private/kfileitemmodelsortalgorithm.cpp @@ -19,10 +19,21 @@ #include "kfileitemmodelsortalgorithm.h" +#include <QThread> +#include <QtCore> + void KFileItemModelSortAlgorithm::sort(KFileItemModel* model, QList<KFileItemModel::ItemData*>::iterator begin, QList<KFileItemModel::ItemData*>::iterator end) { + static const int numberOfThreads = QThread::idealThreadCount(); + parallelSort(model, begin, end, numberOfThreads); +} + +void KFileItemModelSortAlgorithm::sequentialSort(KFileItemModel* model, + QList< KFileItemModel::ItemData* >::iterator begin, + QList< KFileItemModel::ItemData* >::iterator end) +{ // The implementation is based on qStableSortHelper() from qalgorithms.h // Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). @@ -32,11 +43,33 @@ void KFileItemModelSortAlgorithm::sort(KFileItemModel* model, } const QList<KFileItemModel::ItemData*>::iterator middle = begin + span / 2; - sort(model, begin, middle); - sort(model, middle, end); + sequentialSort(model, begin, middle); + sequentialSort(model, middle, end); merge(model, begin, middle, end); } +void KFileItemModelSortAlgorithm::parallelSort(KFileItemModel* model, + QList< KFileItemModel::ItemData* >::iterator begin, + QList< KFileItemModel::ItemData* >::iterator end, + const int numberOfThreads) +{ + const int span = end - begin; + + if (numberOfThreads > 1 && span > 100) { + const int newNumberOfThreads = numberOfThreads / 2; + const QList<KFileItemModel::ItemData*>::iterator middle = begin + span / 2; + + QFuture<void> future = QtConcurrent::run(parallelSort, model, begin, middle, newNumberOfThreads); + parallelSort(model, middle, end, newNumberOfThreads); + + future.waitForFinished(); + + merge(model, begin, middle, end); + } else { + sequentialSort(model, begin, end); + } +} + void KFileItemModelSortAlgorithm::merge(KFileItemModel* model, QList<KFileItemModel::ItemData*>::iterator begin, QList<KFileItemModel::ItemData*>::iterator pivot, diff --git a/src/kitemviews/private/kfileitemmodelsortalgorithm.h b/src/kitemviews/private/kfileitemmodelsortalgorithm.h index 3a596dff5..07e5d4a81 100644 --- a/src/kitemviews/private/kfileitemmodelsortalgorithm.h +++ b/src/kitemviews/private/kfileitemmodelsortalgorithm.h @@ -44,6 +44,15 @@ public: QList<KFileItemModel::ItemData*>::iterator end); private: + static void sequentialSort(KFileItemModel* model, + QList<KFileItemModel::ItemData*>::iterator begin, + QList<KFileItemModel::ItemData*>::iterator end); + + static void parallelSort(KFileItemModel* model, + QList<KFileItemModel::ItemData*>::iterator begin, + QList<KFileItemModel::ItemData*>::iterator end, + const int numberOfThreads); + static void merge(KFileItemModel* model, QList<KFileItemModel::ItemData*>::iterator begin, QList<KFileItemModel::ItemData*>::iterator pivot, diff --git a/src/kitemviews/private/kitemlistviewlayouter.h b/src/kitemviews/private/kitemlistviewlayouter.h index da5bd1d7d..5ca73e1ad 100644 --- a/src/kitemviews/private/kitemlistviewlayouter.h +++ b/src/kitemviews/private/kitemlistviewlayouter.h @@ -164,6 +164,11 @@ public: */ void markAsDirty(); + inline int columnCount() const + { + return m_columnCount; + } + #ifndef QT_NO_DEBUG /** * @return True if the layouter has been marked as dirty and hence has diff --git a/src/kitemviews/private/knepomukrolesprovider.cpp b/src/kitemviews/private/knepomukrolesprovider.cpp index b0e179807..1bdac6dfc 100644 --- a/src/kitemviews/private/knepomukrolesprovider.cpp +++ b/src/kitemviews/private/knepomukrolesprovider.cpp @@ -23,10 +23,10 @@ #include <KGlobal> #include <KLocale> -#include <Nepomuk/Resource> -#include <Nepomuk/Tag> -#include <Nepomuk/Types/Property> -#include <Nepomuk/Variant> +#include <Nepomuk2/Resource> +#include <Nepomuk2/Tag> +#include <Nepomuk2/Types/Property> +#include <Nepomuk2/Variant> #include <QTime> @@ -51,7 +51,7 @@ QSet<QByteArray> KNepomukRolesProvider::roles() const return m_roles; } -QHash<QByteArray, QVariant> KNepomukRolesProvider::roleValues(const Nepomuk::Resource& resource, +QHash<QByteArray, QVariant> KNepomukRolesProvider::roleValues(const Nepomuk2::Resource& resource, const QSet<QByteArray>& roles) const { if (!resource.isValid()) { @@ -63,17 +63,17 @@ QHash<QByteArray, QVariant> KNepomukRolesProvider::roleValues(const Nepomuk::Res int width = -1; int height = -1; - QHashIterator<QUrl, Nepomuk::Variant> it(resource.properties()); + QHashIterator<QUrl, Nepomuk2::Variant> it(resource.properties()); while (it.hasNext()) { it.next(); - const Nepomuk::Types::Property property = it.key(); + const Nepomuk2::Types::Property property = it.key(); const QByteArray role = m_roleForUri.value(property.uri()); if (role.isEmpty() || !roles.contains(role)) { continue; } - const Nepomuk::Variant value = it.value(); + const Nepomuk2::Variant value = it.value(); if (role == "imageSize") { // Merge the two Nepomuk properties for width and height @@ -101,7 +101,7 @@ QHash<QByteArray, QVariant> KNepomukRolesProvider::roleValues(const Nepomuk::Res const QString duration = durationFromValue(value.toInt()); values.insert(role, duration); } else if (value.isResource()) { - const Nepomuk::Resource resource = value.toResource(); + const Nepomuk2::Resource resource = value.toResource(); values.insert(role, resource.genericLabel()); } else { values.insert(role, value.toString()); @@ -155,7 +155,7 @@ QString KNepomukRolesProvider::tagsFromValues(const QStringList& values) const tags.append(QLatin1String(", ")); } - const Nepomuk::Tag tag(values[i]); + const Nepomuk2::Tag tag(values[i]); tags += tag.genericLabel(); } diff --git a/src/kitemviews/private/knepomukrolesprovider.h b/src/kitemviews/private/knepomukrolesprovider.h index 17683568c..8290b571e 100644 --- a/src/kitemviews/private/knepomukrolesprovider.h +++ b/src/kitemviews/private/knepomukrolesprovider.h @@ -26,7 +26,7 @@ #include <QSet> #include <QUrl> -namespace Nepomuk +namespace Nepomuk2 { class Resource; } @@ -52,7 +52,7 @@ public: * @return Values for the roles \a roles that can be determined from the file * with the URL \a url. */ - QHash<QByteArray, QVariant> roleValues(const Nepomuk::Resource& resource, + QHash<QByteArray, QVariant> roleValues(const Nepomuk2::Resource& resource, const QSet<QByteArray>& roles) const; protected: diff --git a/src/kitemviews/private/nepomuk/ReadMe.txt b/src/kitemviews/private/nepomuk/ReadMe.txt deleted file mode 100644 index c070f3090..000000000 --- a/src/kitemviews/private/nepomuk/ReadMe.txt +++ /dev/null @@ -1,3 +0,0 @@ -The files in this directory are a copy of kde-runtime/nepomuk. They -are updated manually until the Nepomuk resoure-watcher is made -public in a future release of the Nepomuk API. diff --git a/src/kitemviews/private/nepomuk/org.kde.nepomuk.ResourceWatcher.xml b/src/kitemviews/private/nepomuk/org.kde.nepomuk.ResourceWatcher.xml deleted file mode 100644 index 7f414443b..000000000 --- a/src/kitemviews/private/nepomuk/org.kde.nepomuk.ResourceWatcher.xml +++ /dev/null @@ -1,14 +0,0 @@ -<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> -<node> - <interface name="org.kde.nepomuk.ResourceWatcher"> - <method name="stopWatcher"> - <arg name="objectName" type="s" direction="in"/> - </method> - <method name="watch"> - <arg name="resources" type="as" direction="in"/> - <arg name="properties" type="as" direction="in"/> - <arg name="types" type="as" direction="in"/> - <arg name="queryobject" type="o" direction="out" /> - </method> - </interface> -</node> diff --git a/src/kitemviews/private/nepomuk/org.kde.nepomuk.ResourceWatcherConnection.xml b/src/kitemviews/private/nepomuk/org.kde.nepomuk.ResourceWatcherConnection.xml deleted file mode 100644 index 7848343a7..000000000 --- a/src/kitemviews/private/nepomuk/org.kde.nepomuk.ResourceWatcherConnection.xml +++ /dev/null @@ -1,65 +0,0 @@ -<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> -<node> - <interface name="org.kde.nepomuk.ResourceWatcherConnection"> - <signal name="resourceCreated"> - <arg name="uri" type="s" direction="out"/> - <arg name="types" type="as" direction="out"/> - </signal> - <signal name="resourceRemoved"> - <arg name="uri" type="s" direction="out"/> - <arg name="types" type="as" direction="out"/> - </signal> - <signal name="resourceTypesAdded"> - <arg name="resUri" type="s" direction="out"/> - <arg name="types" type="as" direction="out"/> - </signal> - <signal name="resourceTypesRemoved"> - <arg name="resUri" type="s" direction="out"/> - <arg name="types" type="as" direction="out"/> - </signal> - <signal name="propertyAdded"> - <arg name="resource" type="s" direction="out"/> - <arg name="property" type="s" direction="out"/> - <arg name="values" type="av" direction="out"/> - </signal> - <signal name="propertyRemoved"> - <arg name="resource" type="s" direction="out"/> - <arg name="property" type="s" direction="out"/> - <arg name="values" type="av" direction="out"/> - </signal> - <signal name="propertyChanged"> - <arg name="resource" type="s" direction="out"/> - <arg name="property" type="s" direction="out"/> - <arg name="addedValues" type="av" direction="out"/> - <arg name="removedValues" type="av" direction="out"/> - </signal> - <method name="setResources"> - <arg name="resources" type="as" direction="in"/> - </method> - <method name="addResource"> - <arg name="resource" type="s" direction="in"/> - </method> - <method name="removeResource"> - <arg name="resource" type="s" direction="in"/> - </method> - <method name="setProperties"> - <arg name="properties" type="as" direction="in"/> - </method> - <method name="addProperty"> - <arg name="property" type="s" direction="in"/> - </method> - <method name="removeProperty"> - <arg name="property" type="s" direction="in"/> - </method> - <method name="setTypes"> - <arg name="types" type="as" direction="in"/> - </method> - <method name="addType"> - <arg name="type" type="s" direction="in"/> - </method> - <method name="removeType"> - <arg name="type" type="s" direction="in"/> - </method> - <method name="close" /> - </interface> -</node> diff --git a/src/kitemviews/private/nepomuk/resourcewatcher.cpp b/src/kitemviews/private/nepomuk/resourcewatcher.cpp deleted file mode 100644 index 2dcf567ca..000000000 --- a/src/kitemviews/private/nepomuk/resourcewatcher.cpp +++ /dev/null @@ -1,299 +0,0 @@ -/* - This file is part of the Nepomuk KDE project. - Copyright (C) 2011 Vishesh Handa <[email protected]> - Copyright (C) 2011-2012 Sebastian Trueg <[email protected]> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - - -#include "resourcewatcher.h" -#include "resourcewatcherconnectioninterface.h" -#include "resourcewatchermanagerinterface.h" - -#include <QtDBus/QDBusObjectPath> - -#include <nepomuk/resource.h> -#include <nepomuk/resourcemanager.h> - -#include <KUrl> -#include <KDebug> - -namespace { - QString convertUri(const QUrl& uri) { - return KUrl(uri).url(); - } - - QStringList convertUris(const QList<QUrl>& uris) { - QStringList cs; - foreach(const QUrl& uri, uris) { - cs << convertUri(uri); - } - return cs; - } - - QList<QUrl> convertUris(const QStringList& uris) { - QList<QUrl> us; - foreach(const QString& uri, uris) { - us << KUrl(uri); - } - return us; - } -} - -class Nepomuk::ResourceWatcher::Private { -public: - QList<QUrl> m_types; - QList<QUrl> m_resources; - QList<QUrl> m_properties; - - org::kde::nepomuk::ResourceWatcherConnection * m_connectionInterface; - org::kde::nepomuk::ResourceWatcher * m_watchManagerInterface; -}; - -Nepomuk::ResourceWatcher::ResourceWatcher(QObject* parent) - : QObject(parent), - d(new Private) -{ - d->m_watchManagerInterface - = new org::kde::nepomuk::ResourceWatcher( "org.kde.nepomuk.DataManagement", - "/resourcewatcher", - QDBusConnection::sessionBus() ); - d->m_connectionInterface = 0; -} - -Nepomuk::ResourceWatcher::~ResourceWatcher() -{ - stop(); - delete d; -} - -bool Nepomuk::ResourceWatcher::start() -{ - stop(); - - // - // Convert to list of strings - // - QList<QString> uris = convertUris(d->m_resources); - QList<QString> props = convertUris(d->m_properties); - QList<QString> types_ = convertUris(d->m_types); - - // - // Watch for the RW service to (re-)appear and then re-connect to make sure we always get updates - // We create this watcher even if we fail to connect below. Thus, once the rw service comes up we - // can re-attach. - // - connect(ResourceManager::instance(), SIGNAL(nepomukSystemStarted()), this, SLOT(start())); - - // - // Create the dbus object to watch - // - QDBusPendingReply<QDBusObjectPath> reply = d->m_watchManagerInterface->watch( uris, props, types_ ); - QDBusObjectPath path = reply.value(); - - if(!path.path().isEmpty()) { - d->m_connectionInterface = new org::kde::nepomuk::ResourceWatcherConnection( "org.kde.nepomuk.DataManagement", - path.path(), - QDBusConnection::sessionBus() ); - connect( d->m_connectionInterface, SIGNAL(propertyAdded(QString,QString,QVariantList)), - this, SLOT(slotPropertyAdded(QString,QString,QVariantList)) ); - connect( d->m_connectionInterface, SIGNAL(propertyRemoved(QString,QString,QVariantList)), - this, SLOT(slotPropertyRemoved(QString,QString,QVariantList)) ); - connect( d->m_connectionInterface, SIGNAL(resourceCreated(QString,QStringList)), - this, SLOT(slotResourceCreated(QString,QStringList)) ); - connect( d->m_connectionInterface, SIGNAL(propertyChanged(QString,QString,QVariantList,QVariantList)), - this, SLOT(slotPropertyChanged(QString,QString,QVariantList,QVariantList)) ); - connect( d->m_connectionInterface, SIGNAL(resourceRemoved(QString,QStringList)), - this, SLOT(slotResourceRemoved(QString,QStringList)) ); - connect( d->m_connectionInterface, SIGNAL(resourceTypesAdded(QString,QStringList)), - this, SLOT(slotResourceTypesAdded(QString,QStringList)) ); - connect( d->m_connectionInterface, SIGNAL(resourceTypesRemoved(QString,QStringList)), - this, SLOT(slotResourceTypesRemoved(QString,QStringList)) ); - - kDebug() << "Successfully connected to watch service"; - return true; - } - else { - kDebug() << "Failed to connect to watch service" << reply.error().message(); - return false; - } -} - -void Nepomuk::ResourceWatcher::stop() -{ - if (d->m_connectionInterface) { - d->m_connectionInterface->close(); - delete d->m_connectionInterface; - d->m_connectionInterface = 0; - } - - disconnect(ResourceManager::instance(), SIGNAL(nepomukSystemStarted()), this, SLOT(start())); -} - -void Nepomuk::ResourceWatcher::addProperty(const Nepomuk::Types::Property& property) -{ - d->m_properties << property.uri(); - if(d->m_connectionInterface) { - d->m_connectionInterface->addProperty(convertUri(property.uri())); - } -} - -void Nepomuk::ResourceWatcher::addResource(const Nepomuk::Resource& res) -{ - d->m_resources << res.resourceUri(); - if(d->m_connectionInterface) { - d->m_connectionInterface->addResource(convertUri(res.resourceUri())); - } -} - -void Nepomuk::ResourceWatcher::addType(const Nepomuk::Types::Class& type) -{ - d->m_types << type.uri(); - if(d->m_connectionInterface) { - d->m_connectionInterface->addType(convertUri(type.uri())); - } -} - -void Nepomuk::ResourceWatcher::removeProperty(const Nepomuk::Types::Property& property) -{ - d->m_properties.removeAll(property.uri()); - if(d->m_connectionInterface) { - d->m_connectionInterface->removeProperty(convertUri(property.uri())); - } -} - -void Nepomuk::ResourceWatcher::removeResource(const Nepomuk::Resource& res) -{ - d->m_resources.removeAll(res.resourceUri()); - if(d->m_connectionInterface) { - d->m_connectionInterface->removeResource(convertUri(res.resourceUri())); - } -} - -void Nepomuk::ResourceWatcher::removeType(const Nepomuk::Types::Class& type) -{ - d->m_types.removeAll(type.uri()); - if(d->m_connectionInterface) { - d->m_connectionInterface->removeType(convertUri(type.uri())); - } -} - -QList< Nepomuk::Types::Property > Nepomuk::ResourceWatcher::properties() const -{ - QList< Nepomuk::Types::Property > props; - foreach(const QUrl& uri, d->m_properties) - props << Types::Property(uri); - return props; -} - -QList<Nepomuk::Resource> Nepomuk::ResourceWatcher::resources() const -{ - QList<Nepomuk::Resource> resources; - foreach(const QUrl& uri, d->m_resources) - resources << Resource::fromResourceUri(uri); - return resources; -} - -QList< Nepomuk::Types::Class > Nepomuk::ResourceWatcher::types() const -{ - QList<Nepomuk::Types::Class> types; - foreach(const QUrl& uri, d->m_types) - types << Types::Class(uri); - return types; -} - -void Nepomuk::ResourceWatcher::setProperties(const QList< Nepomuk::Types::Property >& properties_) -{ - d->m_properties.clear(); - foreach(const Nepomuk::Types::Property& p, properties_) { - d->m_properties << p.uri(); - } - - if(d->m_connectionInterface) { - d->m_connectionInterface->setProperties(convertUris(d->m_properties)); - } -} - -void Nepomuk::ResourceWatcher::setResources(const QList< Nepomuk::Resource >& resources_) -{ - d->m_resources.clear(); - foreach(const Nepomuk::Resource& res, resources_) { - d->m_resources << res.resourceUri(); - } - - if(d->m_connectionInterface) { - d->m_connectionInterface->setResources(convertUris(d->m_resources)); - } -} - -void Nepomuk::ResourceWatcher::setTypes(const QList< Nepomuk::Types::Class >& types_) -{ - d->m_types.clear(); - foreach(const Nepomuk::Types::Class& t, types_) { - d->m_types << t.uri(); - } - - if(d->m_connectionInterface) { - d->m_connectionInterface->setTypes(convertUris(d->m_types)); - } -} - -void Nepomuk::ResourceWatcher::slotResourceCreated(const QString &res, const QStringList &types) -{ - emit resourceCreated(Nepomuk::Resource::fromResourceUri(KUrl(res)), convertUris(types)); -} - -void Nepomuk::ResourceWatcher::slotResourceRemoved(const QString &res, const QStringList &types) -{ - emit resourceRemoved(KUrl(res), convertUris(types)); -} - -void Nepomuk::ResourceWatcher::slotResourceTypesAdded(const QString &res, const QStringList &types) -{ - foreach(const QString& type, types) { - emit resourceTypeAdded(KUrl(res), KUrl(type)); - } -} - -void Nepomuk::ResourceWatcher::slotResourceTypesRemoved(const QString &res, const QStringList &types) -{ - foreach(const QString& type, types) { - emit resourceTypeRemoved(KUrl(res), KUrl(type)); - } -} - -void Nepomuk::ResourceWatcher::slotPropertyAdded(const QString& res, const QString& prop, const QVariantList &objects) -{ - foreach(const QVariant& v, objects) { - emit propertyAdded( Resource::fromResourceUri(KUrl(res)), Types::Property( KUrl(prop) ), v ); - } -} - -void Nepomuk::ResourceWatcher::slotPropertyRemoved(const QString& res, const QString& prop, const QVariantList &objects) -{ - foreach(const QVariant& v, objects) { - emit propertyRemoved( Resource::fromResourceUri(KUrl(res)), Types::Property( KUrl(prop) ), v ); - } -} - -void Nepomuk::ResourceWatcher::slotPropertyChanged(const QString& res, const QString& prop, const QVariantList& oldObjs, const QVariantList& newObjs) -{ - emit propertyChanged( Resource::fromResourceUri(KUrl(res)), Types::Property( KUrl(prop) ), - oldObjs, newObjs ); -} - -#include "resourcewatcher.moc" - diff --git a/src/kitemviews/private/nepomuk/resourcewatcher.h b/src/kitemviews/private/nepomuk/resourcewatcher.h deleted file mode 100644 index 96a75ef94..000000000 --- a/src/kitemviews/private/nepomuk/resourcewatcher.h +++ /dev/null @@ -1,319 +0,0 @@ -/* - This file is part of the Nepomuk KDE project. - Copyright (C) 2011 Vishesh Handa <[email protected]> - Copyright (C) 2011 Sebastian Trueg <[email protected]> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - - -#ifndef RESOURCEWATCHER_H -#define RESOURCEWATCHER_H - -#include <Nepomuk/Types/Class> -#include <Nepomuk/Types/Property> -#include <Nepomuk/Resource> - -#include <QtDBus/QDBusVariant> -#include <QtCore/QVariant> - -//#include "nepomukdatamanagement_export.h" - -namespace Nepomuk { - - /** - * \class ResourceWatcher resourcewatcher.h - * - * \brief Selectively monitor the nepomuk repository for changes. - * - * Resources may be monitored on the basis of types, properties, and uris. - * - * Changes may be monitored in one of the following ways: - * -# By resources - - * Specify the exact resources that should be watched. Any changes made to the specified resources - * (Excluding \ref nepomuk_dms_metadata) will be notified through the propertyAdded() and propertyRemoved() - * signals. Notifications will also be sent if any of the watched resources is deleted. - * -# By resources and properties - - * Specify the exact resources and their properties. Any changes made to the specified resources - * which touch one of the specified properties will be notified through the propertyAdded() and propertyRemoved() - * signals. - * -# By types - - * Specific types may be specified via add/setType. If types are set, then notifications will be - * sent for all new resources of that type. This includes property changes and resource creation and removal. - * TODO: add flags that allow to only watch for resource creation and removal. - * -# By types and properties - - * Both the types and properties may be specified. Notifications will be sent for property changes - * in resource with the specified types. - * - * \section nepomuk_rw_examples Resource Watcher Usage Example - * - * The following code creates a new ResourceWatcher, configures it to listen to changes on the \c nmm:performer - * property on one specific resource \c res. - * - * \code - * Nepomuk::ResourceWatcher* watcher = new Nepomuk::ResourceWatcher(this); - * watcher->addResource(res); - * watcher->addProperty(NMM:performer()); - * connect(watcher, SIGNAL(propertyAdded(Nepomuk::Resource, Nepomuk::Types::Property, QVariant)), - * this, SLOT(slotPropertyChanged())); - * connect(watcher, SIGNAL(propertyRemoved(Nepomuk::Resource, Nepomuk::Types::Property, QVariant)), - * this, SLOT(slotPropertyChanged())); - * rwatcher->start(); - * \endcode - * - * \author Vishesh Handa <[email protected]>, Sebastian Trueg <[email protected]> - * - * \ingroup nepomuk_datamanagement - */ - class ResourceWatcher : public QObject - { - Q_OBJECT - - public: - /** - * \brief Create a new %ResourceWatcher instance. - * - * This instance will not emit any signals before it has been configured - * and started. - */ - ResourceWatcher( QObject* parent = 0 ); - - /** - * \brief Destructor. - */ - virtual ~ResourceWatcher(); - - public Q_SLOTS: - /** - * \brief Add a type to be watched. - * - * Every resource of this type will be watched for changes. - * - * \sa setTypes() - */ - void addType( const Types::Class & type ); - - /** - * \brief Add a resource to be watched. - * - * Every change to this resource will be - * signalled, depending on the configured properties(). - * - * \sa setResources() - */ - void addResource( const Nepomuk::Resource & res ); - - /** - * \brief Add a property to be watched. - * - * Every change to a value of this property - * will be signalled, depending on the configured resources() or types(). - * - * \sa setProperties() - */ - void addProperty( const Types::Property & property ); - - /** - * \brief Remove a type to be watched. - * - * Every resource of this type will be watched for changes. - * - * \sa setTypes() - */ - void removeType( const Types::Class & type ); - - /** - * \brief Remove a resource to be watched. - * - * Every change to this resource will be - * signalled, depending on the configured properties(). - * - * \sa setResources() - */ - void removeResource( const Nepomuk::Resource & res ); - - /** - * \brief Remove a property to be watched. - * - * Every change to a value of this property - * will be signalled, depending on the configured resources() or types(). - * - * \sa setProperties() - */ - void removeProperty( const Types::Property & property ); - - /** - * \brief Set the types to be watched. - * - * Every resource having one of these types will be watched for changes. - * - * \sa addType() - */ - void setTypes( const QList<Types::Class> & types_ ); - - /** - * \brief Set the resources to be watched. - * - * Every change to one of these resources will be - * signalled, depending on the configured properties(). - * - * \sa addResource() - */ - void setResources( const QList<Nepomuk::Resource> & resources_ ); - - /** - * \brief Set the properties to be watched. - * - * Every change to a value of any of these properties - * will be signalled, depending on the configured resources() or types(). - * - * \sa addProperty() - */ - void setProperties( const QList<Types::Property> & properties_ ); - - /** - * \brief The types that have been configured via addType() and setTypes(). - * - * Every resource having one of these types will be watched - * for changes. - */ - QList<Types::Class> types() const; - - /** - * \brief The resources that have been configured via addResource() and setResources(). - * - * Every change to one of these resources will be - * signalled, depending on the configured properties(). - */ - QList<Nepomuk::Resource> resources() const; - - /** - * \brief The properties that have been configured via addProperty() and setProperties(). - * - * Every change to a value of any of these properties - * will be signalled, depending on the configured resources() or types(). - */ - QList<Types::Property> properties() const; - - /** - * \brief Start the signalling of changes. - * - * Before calling this method no signal will be emitted. In - * combination with stop() this allows to suspend the watching. - * Calling start() multiple times has no effect. - */ - bool start(); - - /** - * \brief Stop the signalling of changes. - * - * Allows to stop the watcher which has been started - * via start(). Calling stop() multiple times has no effect. - */ - void stop(); - - Q_SIGNALS: - /** - * \brief This signal is emitted when a new resource is created. - * \param resource The newly created resource. - * \param types The types the new resource has. If types() have been configured this list will always - * contain one of the configured types. - */ - void resourceCreated( const Nepomuk::Resource & resource, const QList<QUrl>& types ); //FIXME: Use either Resource or uri, not a mix - - /** - * \brief This signal is emitted when a resource is deleted. - * \param uri The resource URI of the removed resource. - * \param types The types the removed resource had. If types() have been configured this list will always - * contain one of the configured types. - */ - void resourceRemoved( const QUrl & uri, const QList<QUrl>& types ); - - /** - * \brief This signal is emitted when a type has been added to a resource. This does not include creation which - * is signalled via resourceCreated(). It only applies to changes in a resource's types. - * \param res The changed resource. - * \param type The newly added type. If types() have been configured it will be one of them. - */ - void resourceTypeAdded( const Nepomuk::Resource & res, const Nepomuk::Types::Class & type ); - - /** - * \brief This signal is emitted when a type has been removed from a resource. - * - * This does not include removal of entire resources which is signalled via resourceRemoved(). - * It only applies to changes in a resource's types. - * \param res The changed resource. - * \param type The removed type. If types() have been configured it will be one of them. - */ - void resourceTypeRemoved( const Nepomuk::Resource & res, const Nepomuk::Types::Class & type ); - - /** - * \brief This signal is emitted when a property value is added. - * \param resource The changed resource. - * \param property The property which has a new value. - * \param value The newly added property value. - */ - void propertyAdded( const Nepomuk::Resource & resource, - const Nepomuk::Types::Property & property, - const QVariant & value ); - - /** - * \brief This signal is emitted when a property value is removed. - * \param resource The changed resource. - * \param property The property which was changed. - * \param value The removed property value. - */ - void propertyRemoved( const Nepomuk::Resource & resource, - const Nepomuk::Types::Property & property, - const QVariant & value ); - - /** - * \brief This signal is emitted when a property value is changed. - * - * This signal is essentially a combination of the propertyAdded and propertyRemoved signals. - * - * Be aware that removing and then adding a property will result in two separate - * propertyChanged signals. They are never combined. - * - * Specially, since one could theoretically take forever between the removal and the - * setting of the property. - * - * \param resource The changed resource. - * \param property The property which was changed. - * \param addedValues The values that have been added. - * \param removedValues The values that have been removed. - */ - void propertyChanged( const Nepomuk::Resource & resource, - const Nepomuk::Types::Property & property, - const QVariantList & addedValues, - const QVariantList & removedValues ); - - private Q_SLOTS: - void slotResourceCreated(const QString& res, const QStringList& types); - void slotResourceRemoved(const QString& res, const QStringList& types); - void slotResourceTypesAdded(const QString& res, const QStringList& types); - void slotResourceTypesRemoved(const QString& res, const QStringList& types); - void slotPropertyAdded(const QString& res, const QString& prop, const QVariantList& objects); - void slotPropertyRemoved(const QString& res, const QString& prop, const QVariantList& objects); - void slotPropertyChanged(const QString& res, const QString& prop, - const QVariantList & oldObjs, - const QVariantList & newObjs); - private: - class Private; - Private * d; - }; -} - -#endif // RESOURCEWATCHER_H diff --git a/src/main.cpp b/src/main.cpp index 39ecee8b8..26912d845 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -33,17 +33,17 @@ KDE_EXPORT int kdemain(int argc, char **argv) { KAboutData about("dolphin", 0, ki18nc("@title", "Dolphin"), - "2.1", + "2.1.85", ki18nc("@title", "File Manager"), KAboutData::License_GPL, - ki18nc("@info:credit", "(C) 2006-2012 Peter Penz")); + ki18nc("@info:credit", "(C) 2006-2012 Peter Penz and Frank Reininghaus")); about.setHomepage("http://dolphin.kde.org"); - about.addAuthor(ki18nc("@info:credit", "Peter Penz"), - ki18nc("@info:credit", "Maintainer and developer"), - "[email protected]"); about.addAuthor(ki18nc("@info:credit", "Frank Reininghaus"), - ki18nc("@info:credit", "Developer"), + ki18nc("@info:credit", "Maintainer (since 2012) and developer"), + about.addAuthor(ki18nc("@info:credit", "Peter Penz"), + ki18nc("@info:credit", "Maintainer and developer (2006-2012)"), + "[email protected]"); about.addAuthor(ki18nc("@info:credit", "Sebastian Trüg"), ki18nc("@info:credit", "Developer"), diff --git a/src/panels/folders/folderspanel.cpp b/src/panels/folders/folderspanel.cpp index 13093fff6..6e3a7678f 100644 --- a/src/panels/folders/folderspanel.cpp +++ b/src/panels/folders/folderspanel.cpp @@ -24,6 +24,7 @@ #include "treeviewcontextmenu.h" #include "foldersitemlistwidget.h" +#include <views/renamedialog.h> #include <kitemviews/kitemlistselectionmanager.h> #include <kitemviews/kfileitemlistview.h> #include <kitemviews/kfileitemlistwidget.h> @@ -90,8 +91,16 @@ bool FoldersPanel::autoScrolling() const void FoldersPanel::rename(const KFileItem& item) { - const int index = m_model->index(item); - m_controller->view()->editRole(index, "text"); + if (GeneralSettings::renameInline()) { + const int index = m_model->index(item); + m_controller->view()->editRole(index, "text"); + } else { + RenameDialog* dialog = new RenameDialog(this, KFileItemList() << item); + dialog->setAttribute(Qt::WA_DeleteOnClose); + dialog->show(); + dialog->raise(); + dialog->activateWindow(); + } } bool FoldersPanel::urlChanged() diff --git a/src/panels/panel.cpp b/src/panels/panel.cpp index c2681ecfb..14b7c0230 100644 --- a/src/panels/panel.cpp +++ b/src/panels/panel.cpp @@ -71,4 +71,9 @@ void Panel::setUrl(const KUrl& url) } } +void Panel::readSettings() +{ + +} + #include "panel.moc" diff --git a/src/panels/panel.h b/src/panels/panel.h index 064e1f362..a0b25d6cc 100644 --- a/src/panels/panel.h +++ b/src/panels/panel.h @@ -60,6 +60,11 @@ public slots: */ void setUrl(const KUrl& url); + /** + * Refreshes the view to get synchronized with the settings. + */ + virtual void readSettings(); + protected: /** * Must be implemented by derived classes and is invoked when diff --git a/src/panels/places/placesitemmodel.cpp b/src/panels/places/placesitemmodel.cpp index 1789f1806..a37c17fd8 100644 --- a/src/panels/places/placesitemmodel.cpp +++ b/src/panels/places/placesitemmodel.cpp @@ -52,13 +52,13 @@ #include <views/viewproperties.h> #ifdef HAVE_NEPOMUK - #include <Nepomuk/ResourceManager> - #include <Nepomuk/Query/ComparisonTerm> - #include <Nepomuk/Query/LiteralTerm> - #include <Nepomuk/Query/FileQuery> - #include <Nepomuk/Query/ResourceTypeTerm> - #include <Nepomuk/Vocabulary/NFO> - #include <Nepomuk/Vocabulary/NIE> + #include <Nepomuk2/ResourceManager> + #include <Nepomuk2/Query/ComparisonTerm> + #include <Nepomuk2/Query/LiteralTerm> + #include <Nepomuk2/Query/FileQuery> + #include <Nepomuk2/Query/ResourceTypeTerm> + #include <Nepomuk2/Vocabulary/NFO> + #include <Nepomuk2/Vocabulary/NIE> #endif namespace { @@ -88,7 +88,7 @@ PlacesItemModel::PlacesItemModel(QObject* parent) : m_storageSetupInProgress() { #ifdef HAVE_NEPOMUK - if (Nepomuk::ResourceManager::instance()->initialized()) { + if (Nepomuk2::ResourceManager::instance()->initialized()) { KConfig config("nepomukserverrc"); m_fileIndexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", false); } @@ -578,14 +578,14 @@ void PlacesItemModel::slotDeviceRemoved(const QString& udi) delete item; return; } - } + } - for (int i = 0; i < count(); ++i) { - if (placesItem(i)->udi() == udi) { - removeItem(i); - return; - } - } + for (int i = 0; i < count(); ++i) { + if (placesItem(i)->udi() == udi) { + removeItem(i); + return; + } + } } void PlacesItemModel::slotStorageTeardownDone(Solid::ErrorType error, const QVariant& errorData) @@ -900,8 +900,6 @@ void PlacesItemModel::createSystemBookmarks() Q_ASSERT(m_systemBookmarks.isEmpty()); Q_ASSERT(m_systemBookmarksIndexes.isEmpty()); - 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 // done here is because otherwise switching the language would not result in retranslating the @@ -921,16 +919,16 @@ void PlacesItemModel::createSystemBookmarks() if (m_fileIndexingEnabled) { m_systemBookmarks.append(SystemBookmarkData(KUrl("timeline:/today"), - timeLineIcon, + "go-jump-today", I18N_NOOP2("KFile System Bookmarks", "Today"))); m_systemBookmarks.append(SystemBookmarkData(KUrl("timeline:/yesterday"), - timeLineIcon, + "view-calendar-day", I18N_NOOP2("KFile System Bookmarks", "Yesterday"))); m_systemBookmarks.append(SystemBookmarkData(KUrl("timeline:/thismonth"), - timeLineIcon, + "view-calendar-month", I18N_NOOP2("KFile System Bookmarks", "This Month"))); m_systemBookmarks.append(SystemBookmarkData(KUrl("timeline:/lastmonth"), - timeLineIcon, + "view-calendar-month", I18N_NOOP2("KFile System Bookmarks", "Last Month"))); m_systemBookmarks.append(SystemBookmarkData(KUrl("search:/documents"), "folder-txt", @@ -1161,15 +1159,15 @@ KUrl PlacesItemModel::createSearchUrl(const KUrl& url) #ifdef HAVE_NEPOMUK const QString path = url.pathOrUrl(); if (path.endsWith(QLatin1String("documents"))) { - searchUrl = searchUrlForTerm(Nepomuk::Query::ResourceTypeTerm(Nepomuk::Vocabulary::NFO::Document())); + searchUrl = searchUrlForTerm(Nepomuk2::Query::ResourceTypeTerm(Nepomuk2::Vocabulary::NFO::Document())); } else if (path.endsWith(QLatin1String("images"))) { - searchUrl = searchUrlForTerm(Nepomuk::Query::ResourceTypeTerm(Nepomuk::Vocabulary::NFO::Image())); + searchUrl = searchUrlForTerm(Nepomuk2::Query::ResourceTypeTerm(Nepomuk2::Vocabulary::NFO::Image())); } else if (path.endsWith(QLatin1String("audio"))) { - searchUrl = searchUrlForTerm(Nepomuk::Query::ComparisonTerm(Nepomuk::Vocabulary::NIE::mimeType(), - Nepomuk::Query::LiteralTerm("audio"))); + searchUrl = searchUrlForTerm(Nepomuk2::Query::ComparisonTerm(Nepomuk2::Vocabulary::NIE::mimeType(), + Nepomuk2::Query::LiteralTerm("audio"))); } else if (path.endsWith(QLatin1String("videos"))) { - searchUrl = searchUrlForTerm(Nepomuk::Query::ComparisonTerm(Nepomuk::Vocabulary::NIE::mimeType(), - Nepomuk::Query::LiteralTerm("video"))); + searchUrl = searchUrlForTerm(Nepomuk2::Query::ComparisonTerm(Nepomuk2::Vocabulary::NIE::mimeType(), + Nepomuk2::Query::LiteralTerm("video"))); } else { Q_ASSERT(false); } @@ -1181,9 +1179,9 @@ KUrl PlacesItemModel::createSearchUrl(const KUrl& url) } #ifdef HAVE_NEPOMUK -KUrl PlacesItemModel::searchUrlForTerm(const Nepomuk::Query::Term& term) +KUrl PlacesItemModel::searchUrlForTerm(const Nepomuk2::Query::Term& term) { - const Nepomuk::Query::FileQuery query(term); + const Nepomuk2::Query::FileQuery query(term); return query.toSearchUrl(); } #endif diff --git a/src/panels/places/placesitemmodel.h b/src/panels/places/placesitemmodel.h index 463e564e3..e42187860 100644 --- a/src/panels/places/placesitemmodel.h +++ b/src/panels/places/placesitemmodel.h @@ -38,7 +38,7 @@ class QAction; class QTimer; #ifdef HAVE_NEPOMUK - namespace Nepomuk + namespace Nepomuk2 { namespace Query { @@ -255,7 +255,7 @@ private: * @return URL that can be listed by KIO and results in searching * for the given term. */ - static KUrl searchUrlForTerm(const Nepomuk::Query::Term& term); + static KUrl searchUrlForTerm(const Nepomuk2::Query::Term& term); #endif #ifdef PLACESITEMMODEL_DEBUG diff --git a/src/panels/places/placespanel.cpp b/src/panels/places/placespanel.cpp index a81b99770..61c15a7a1 100644 --- a/src/panels/places/placespanel.cpp +++ b/src/panels/places/placespanel.cpp @@ -23,6 +23,8 @@ #include "placespanel.h" +#include "dolphin_generalsettings.h" + #include <KDebug> #include <KDirNotify> #include <KIcon> @@ -78,6 +80,14 @@ bool PlacesPanel::urlChanged() return true; } +void PlacesPanel::readSettings() +{ + if (m_controller) { + const int delay = GeneralSettings::autoExpandFolders() ? 750 : -1; + m_controller->setAutoActivationDelay(delay); + } +} + void PlacesPanel::showEvent(QShowEvent* event) { if (event->spontaneous()) { @@ -94,13 +104,16 @@ void PlacesPanel::showEvent(QShowEvent* event) connect(m_model, SIGNAL(errorMessage(QString)), this, SIGNAL(errorMessage(QString))); - PlacesView* view = new PlacesView(); - view->setWidgetCreator(new KItemListWidgetCreator<PlacesItemListWidget>()); - view->setGroupHeaderCreator(new KItemListGroupHeaderCreator<PlacesItemListGroupHeader>()); + m_view = new PlacesView(); + m_view->setWidgetCreator(new KItemListWidgetCreator<PlacesItemListWidget>()); + m_view->setGroupHeaderCreator(new KItemListGroupHeaderCreator<PlacesItemListGroupHeader>()); - m_controller = new KItemListController(m_model, view, this); + m_controller = new KItemListController(m_model, m_view, this); m_controller->setSelectionBehavior(KItemListController::SingleSelection); m_controller->setSingleClickActivation(true); + + readSettings(); + connect(m_controller, SIGNAL(itemActivated(int)), this, SLOT(slotItemActivated(int))); connect(m_controller, SIGNAL(itemMiddleClicked(int)), this, SLOT(slotItemMiddleClicked(int))); connect(m_controller, SIGNAL(itemContextMenuRequested(int,QPointF)), this, SLOT(slotItemContextMenuRequested(int,QPointF))); @@ -204,6 +217,41 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos) } menu.addSeparator(); + KMenu* iconSizeSubMenu = new KMenu(i18nc("@item:inmenu", "Icon Size"), &menu); + + struct IconSizeInfo + { + int size; + const char* context; + const char* text; + }; + + const int iconSizeCount = 4; + static const IconSizeInfo iconSizes[iconSizeCount] = { + {KIconLoader::SizeSmall, I18N_NOOP2_NOSTRIP("Small icon size", "Small (%1x%2)")}, + {KIconLoader::SizeSmallMedium, I18N_NOOP2_NOSTRIP("Medium icon size", "Medium (%1x%2)")}, + {KIconLoader::SizeMedium, I18N_NOOP2_NOSTRIP("Large icon size", "Large (%1x%2)")}, + {KIconLoader::SizeLarge, I18N_NOOP2_NOSTRIP("Huge icon size", "Huge (%1x%2)")} + }; + + QMap<QAction*, int> iconSizeActionMap; + QActionGroup* iconSizeGroup = new QActionGroup(iconSizeSubMenu); + + for (int i = 0; i < iconSizeCount; ++i) { + const int size = iconSizes[i].size; + const QString text = i18nc(iconSizes[i].context, iconSizes[i].text, + size, size); + + QAction* action = iconSizeSubMenu->addAction(text); + iconSizeActionMap.insert(action, size); + action->setActionGroup(iconSizeGroup); + action->setCheckable(true); + action->setChecked(m_view->iconSize() == size); + } + + menu.addMenu(iconSizeSubMenu); + + menu.addSeparator(); foreach (QAction* action, customContextMenuActions()) { menu.addAction(action); } @@ -229,6 +277,8 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos) m_model->requestTeardown(index); } else if (action == ejectAction) { m_model->requestEject(index); + } else if (iconSizeActionMap.contains(action)) { + m_view->setIconSize(iconSizeActionMap.value(action)); } } diff --git a/src/panels/places/placespanel.h b/src/panels/places/placespanel.h index 989a0916b..16112e8b2 100644 --- a/src/panels/places/placespanel.h +++ b/src/panels/places/placespanel.h @@ -28,6 +28,7 @@ class KItemListController; class PlacesItemEditDialog; class PlacesItem; class PlacesItemModel; +class PlacesView; class QGraphicsSceneDragDropEvent; /** @@ -50,6 +51,9 @@ protected: virtual bool urlChanged(); virtual void showEvent(QShowEvent* event); +public slots: + virtual void readSettings(); + private slots: void slotItemActivated(int index); void slotItemMiddleClicked(int index); @@ -78,6 +82,7 @@ private: private: KItemListController* m_controller; PlacesItemModel* m_model; + PlacesView* m_view; KUrl m_storageSetupFailedUrl; Qt::MouseButton m_triggerStorageSetupButton; diff --git a/src/panels/places/placesview.cpp b/src/panels/places/placesview.cpp index dce5083d7..a298a5250 100644 --- a/src/panels/places/placesview.cpp +++ b/src/panels/places/placesview.cpp @@ -26,10 +26,27 @@ PlacesView::PlacesView(QGraphicsWidget* parent) : { const int iconSize = PlacesPanelSettings::iconSize(); if (iconSize >= 0) { + setIconSize(iconSize); + } +} + +void PlacesView::setIconSize(int size) +{ + if (size != iconSize()) { + PlacesPanelSettings* settings = PlacesPanelSettings::self(); + settings->setIconSize(size); + settings->writeConfig(); + KItemListStyleOption option = styleOption(); - option.iconSize = iconSize; + option.iconSize = size; setStyleOption(option); } } +int PlacesView::iconSize() const +{ + const KItemListStyleOption option = styleOption(); + return option.iconSize; +} + #include "placesview.moc" diff --git a/src/panels/places/placesview.h b/src/panels/places/placesview.h index 87eb3a50b..19c99c39b 100644 --- a/src/panels/places/placesview.h +++ b/src/panels/places/placesview.h @@ -33,6 +33,9 @@ class PlacesView : public KStandardItemListView public: explicit PlacesView(QGraphicsWidget* parent = 0); + + void setIconSize(int size); + int iconSize() const; }; #endif diff --git a/src/search/dolphinfacetswidget.cpp b/src/search/dolphinfacetswidget.cpp index 9306efdb4..de715d78f 100644 --- a/src/search/dolphinfacetswidget.cpp +++ b/src/search/dolphinfacetswidget.cpp @@ -28,14 +28,14 @@ #include <QVBoxLayout> #ifdef HAVE_NEPOMUK - #include <Nepomuk/Query/AndTerm> - #include <Nepomuk/Query/ComparisonTerm> - #include <Nepomuk/Query/LiteralTerm> - #include <Nepomuk/Query/OrTerm> - #include <Nepomuk/Query/Query> - #include <Nepomuk/Query/ResourceTypeTerm> - #include <Nepomuk/Vocabulary/NFO> - #include <Nepomuk/Vocabulary/NIE> + #include <Nepomuk2/Query/AndTerm> + #include <Nepomuk2/Query/ComparisonTerm> + #include <Nepomuk2/Query/LiteralTerm> + #include <Nepomuk2/Query/OrTerm> + #include <Nepomuk2/Query/Query> + #include <Nepomuk2/Query/ResourceTypeTerm> + #include <Nepomuk2/Vocabulary/NFO> + #include <Nepomuk2/Vocabulary/NIE> #include <Soprano/Vocabulary/NAO> #endif @@ -121,33 +121,33 @@ DolphinFacetsWidget::~DolphinFacetsWidget() } #ifdef HAVE_NEPOMUK -Nepomuk::Query::Term DolphinFacetsWidget::facetsTerm() const +Nepomuk2::Query::Term DolphinFacetsWidget::facetsTerm() const { - Nepomuk::Query::AndTerm andTerm; + Nepomuk2::Query::AndTerm andTerm; const bool hasTypeFilter = m_documents->isChecked() || m_images->isChecked() || m_audio->isChecked() || m_videos->isChecked(); if (hasTypeFilter) { - Nepomuk::Query::OrTerm orTerm; + Nepomuk2::Query::OrTerm orTerm; if (m_documents->isChecked()) { - orTerm.addSubTerm(Nepomuk::Query::ResourceTypeTerm(Nepomuk::Vocabulary::NFO::Document())); + orTerm.addSubTerm(Nepomuk2::Query::ResourceTypeTerm(Nepomuk2::Vocabulary::NFO::Document())); } if (m_images->isChecked()) { - orTerm.addSubTerm(Nepomuk::Query::ResourceTypeTerm(Nepomuk::Vocabulary::NFO::Image())); + orTerm.addSubTerm(Nepomuk2::Query::ResourceTypeTerm(Nepomuk2::Vocabulary::NFO::Image())); } if (m_audio->isChecked()) { - orTerm.addSubTerm(Nepomuk::Query::ComparisonTerm(Nepomuk::Vocabulary::NIE::mimeType(), - Nepomuk::Query::LiteralTerm("audio"))); + orTerm.addSubTerm(Nepomuk2::Query::ComparisonTerm(Nepomuk2::Vocabulary::NIE::mimeType(), + Nepomuk2::Query::LiteralTerm("audio"))); } if (m_videos->isChecked()) { - orTerm.addSubTerm(Nepomuk::Query::ComparisonTerm(Nepomuk::Vocabulary::NIE::mimeType(), - Nepomuk::Query::LiteralTerm("video"))); + orTerm.addSubTerm(Nepomuk2::Query::ComparisonTerm(Nepomuk2::Vocabulary::NIE::mimeType(), + Nepomuk2::Query::LiteralTerm("video"))); } andTerm.addSubTerm(orTerm); @@ -166,9 +166,9 @@ Nepomuk::Query::Term DolphinFacetsWidget::facetsTerm() const } const int rating = stars * 2; - Nepomuk::Query::ComparisonTerm term(Soprano::Vocabulary::NAO::numericRating(), - Nepomuk::Query::LiteralTerm(rating), - Nepomuk::Query::ComparisonTerm::GreaterOrEqual); + Nepomuk2::Query::ComparisonTerm term(Soprano::Vocabulary::NAO::numericRating(), + Nepomuk2::Query::LiteralTerm(rating), + Nepomuk2::Query::ComparisonTerm::GreaterOrEqual); andTerm.addSubTerm(term); } @@ -184,9 +184,9 @@ Nepomuk::Query::Term DolphinFacetsWidget::facetsTerm() const date.addDays(1 - date.dayOfYear()); } - Nepomuk::Query::ComparisonTerm term(Nepomuk::Vocabulary::NIE::lastModified(), - Nepomuk::Query::LiteralTerm(QDateTime(date)), - Nepomuk::Query::ComparisonTerm::GreaterOrEqual); + Nepomuk2::Query::ComparisonTerm term(Nepomuk2::Vocabulary::NIE::lastModified(), + Nepomuk2::Query::LiteralTerm(QDateTime(date)), + Nepomuk2::Query::ComparisonTerm::GreaterOrEqual); andTerm.addSubTerm(term); } diff --git a/src/search/dolphinfacetswidget.h b/src/search/dolphinfacetswidget.h index 65734aa66..57bed9e68 100644 --- a/src/search/dolphinfacetswidget.h +++ b/src/search/dolphinfacetswidget.h @@ -24,7 +24,7 @@ #include <config-nepomuk.h> #ifdef HAVE_NEPOMUK - #include <Nepomuk/Query/Term> + #include <Nepomuk2/Query/Term> #endif class QButtonGroup; @@ -56,7 +56,7 @@ public: virtual ~DolphinFacetsWidget(); #ifdef HAVE_NEPOMUK - Nepomuk::Query::Term facetsTerm() const; + Nepomuk2::Query::Term facetsTerm() const; #endif signals: diff --git a/src/search/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp index 28f1f1af5..8b660712a 100644 --- a/src/search/dolphinsearchbox.cpp +++ b/src/search/dolphinsearchbox.cpp @@ -42,16 +42,16 @@ #include <config-nepomuk.h> #ifdef HAVE_NEPOMUK - #include <Nepomuk/Query/AndTerm> - #include <Nepomuk/Query/FileQuery> - #include <Nepomuk/Query/LiteralTerm> - #include <Nepomuk/Query/OrTerm> - #include <Nepomuk/Query/Query> - #include <Nepomuk/Query/QueryParser> - #include <Nepomuk/Query/ResourceTypeTerm> - #include <Nepomuk/Query/ComparisonTerm> - #include <Nepomuk/ResourceManager> - #include <Nepomuk/Vocabulary/NFO> + #include <Nepomuk2/Query/AndTerm> + #include <Nepomuk2/Query/FileQuery> + #include <Nepomuk2/Query/LiteralTerm> + #include <Nepomuk2/Query/OrTerm> + #include <Nepomuk2/Query/Query> + #include <Nepomuk2/Query/QueryParser> + #include <Nepomuk2/Query/ResourceTypeTerm> + #include <Nepomuk2/Query/ComparisonTerm> + #include <Nepomuk2/ResourceManager> + #include <Nepomuk2/Vocabulary/NFO> #endif DolphinSearchBox::DolphinSearchBox(QWidget* parent) : @@ -239,10 +239,9 @@ void DolphinSearchBox::slotReturnPressed(const QString& text) void DolphinSearchBox::slotFacetsButtonToggled() { - const bool visible = !m_facetsWidget->isVisible(); - m_facetsWidget->setVisible(visible); - SearchSettings::setShowFacetsWidget(visible); - updateFacetsToggleButtonIcon(); + const bool facetsIsVisible = !m_facetsWidget->isVisible(); + m_facetsWidget->setVisible(facetsIsVisible); + updateFacetsToggleButton(); } void DolphinSearchBox::slotFacetChanged() @@ -281,6 +280,7 @@ void DolphinSearchBox::saveSettings() { SearchSettings::setLocation(m_fromHereButton->isChecked() ? "FromHere" : "Everywhere"); SearchSettings::setWhat(m_fileNameButton->isChecked() ? "FileName" : "Content"); + SearchSettings::setShowFacetsWidget(m_facetsToggleButton->isChecked()); SearchSettings::self()->writeConfig(); } @@ -343,7 +343,8 @@ void DolphinSearchBox::init() // Create "Facets" widgets m_facetsToggleButton = new QToolButton(this); - m_facetsToggleButton->setAutoRaise(true); + m_facetsToggleButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + initButton(m_facetsToggleButton); connect(m_facetsToggleButton, SIGNAL(clicked()), this, SLOT(slotFacetsButtonToggled())); m_facetsWidget = new DolphinFacetsWidget(this); @@ -390,7 +391,7 @@ void DolphinSearchBox::init() m_startSearchTimer->setInterval(1000); connect(m_startSearchTimer, SIGNAL(timeout()), this, SLOT(emitSearchRequest())); - updateFacetsToggleButtonIcon(); + updateFacetsToggleButton(); applyReadOnlyState(); } @@ -401,30 +402,30 @@ KUrl DolphinSearchBox::nepomukUrlForSearching() const // dependent on whether a searching for content or // filename is done const QString text = m_searchInput->text(); - Nepomuk::Query::Term searchLabelTerm; + Nepomuk2::Query::Term searchLabelTerm; if (m_contentButton->isChecked()) { // Let Nepomuk parse the query - searchLabelTerm = Nepomuk::Query::QueryParser::parseQuery(text, Nepomuk::Query::QueryParser::DetectFilenamePattern).term(); + searchLabelTerm = Nepomuk2::Query::QueryParser::parseQuery(text, Nepomuk2::Query::QueryParser::DetectFilenamePattern).term(); } else { // Search the text in the filename only QString regex = QRegExp::escape(text); regex.replace("\\*", QLatin1String(".*")); regex.replace("\\?", QLatin1String(".")); regex.replace("\\", "\\\\"); - searchLabelTerm = Nepomuk::Query::ComparisonTerm( - Nepomuk::Vocabulary::NFO::fileName(), - Nepomuk::Query::LiteralTerm(regex), - Nepomuk::Query::ComparisonTerm::Regexp); + searchLabelTerm = Nepomuk2::Query::ComparisonTerm( + Nepomuk2::Vocabulary::NFO::fileName(), + Nepomuk2::Query::LiteralTerm(regex), + Nepomuk2::Query::ComparisonTerm::Regexp); } // Get the term from the facets and merge it with the // created term from the input-field. - Nepomuk::Query::Term facetsTerm = m_facetsWidget->facetsTerm(); + Nepomuk2::Query::Term facetsTerm = m_facetsWidget->facetsTerm(); - Nepomuk::Query::FileQuery fileQuery; - fileQuery.setFileMode(Nepomuk::Query::FileQuery::QueryFilesAndFolders); + Nepomuk2::Query::FileQuery fileQuery; + fileQuery.setFileMode(Nepomuk2::Query::FileQuery::QueryFilesAndFolders); if (facetsTerm.isValid()) { - Nepomuk::Query::AndTerm andTerm; + Nepomuk2::Query::AndTerm andTerm; andTerm.addSubTerm(searchLabelTerm); andTerm.addSubTerm(facetsTerm); fileQuery.setTerm(andTerm); @@ -449,7 +450,7 @@ void DolphinSearchBox::applyReadOnlyState() { #ifdef HAVE_NEPOMUK if (m_readOnly) { - m_searchLabel->setText(Nepomuk::Query::Query::titleFromQueryUrl(m_readOnlyQuery)); + m_searchLabel->setText(Nepomuk2::Query::Query::titleFromQueryUrl(m_readOnlyQuery)); } else { #else { @@ -467,10 +468,12 @@ void DolphinSearchBox::applyReadOnlyState() } } -void DolphinSearchBox::updateFacetsToggleButtonIcon() +void DolphinSearchBox::updateFacetsToggleButton() { - const bool visible = SearchSettings::showFacetsWidget(); - m_facetsToggleButton->setIcon(KIcon(visible ? "list-remove" : "list-add")); + const bool facetsIsVisible = SearchSettings::showFacetsWidget(); + m_facetsToggleButton->setChecked(facetsIsVisible ? true : false); + m_facetsToggleButton->setIcon(KIcon(facetsIsVisible ? "arrow-up-double" : "arrow-down-double")); + m_facetsToggleButton->setText(facetsIsVisible ? i18nc("action:button", "Less Options") : i18nc("action:button", "More Options")); } #include "dolphinsearchbox.moc" diff --git a/src/search/dolphinsearchbox.h b/src/search/dolphinsearchbox.h index ee9987a38..f3cc535d6 100644 --- a/src/search/dolphinsearchbox.h +++ b/src/search/dolphinsearchbox.h @@ -133,8 +133,7 @@ private: void applyReadOnlyState(); - void updateFacetsToggleButtonIcon(); - + void updateFacetsToggleButton(); private: bool m_startedSearching; bool m_readOnly; diff --git a/src/search/dolphinsearchinformation.cpp b/src/search/dolphinsearchinformation.cpp index 8af951a7b..7fa5f7ba8 100644 --- a/src/search/dolphinsearchinformation.cpp +++ b/src/search/dolphinsearchinformation.cpp @@ -23,7 +23,7 @@ #ifdef HAVE_NEPOMUK #include <KConfig> #include <KConfigGroup> - #include <Nepomuk/ResourceManager> + #include <Nepomuk2/ResourceManager> #endif #include <KGlobal> @@ -90,7 +90,7 @@ DolphinSearchInformation::DolphinSearchInformation() : m_indexingEnabled(false) { #ifdef HAVE_NEPOMUK - if (Nepomuk::ResourceManager::instance()->initialized()) { + if (Nepomuk2::ResourceManager::instance()->initialized()) { KConfig config("nepomukserverrc"); m_indexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", false); } diff --git a/src/settings/additionalinfodialog.cpp b/src/settings/additionalinfodialog.cpp index 3e2350968..dba1f92c7 100644 --- a/src/settings/additionalinfodialog.cpp +++ b/src/settings/additionalinfodialog.cpp @@ -28,7 +28,7 @@ #include <QVBoxLayout> #ifdef HAVE_NEPOMUK - #include <Nepomuk/ResourceManager> + #include <Nepomuk2/ResourceManager> #endif AdditionalInfoDialog::AdditionalInfoDialog(QWidget* parent, @@ -53,7 +53,7 @@ AdditionalInfoDialog::AdditionalInfoDialog(QWidget* parent, bool nepomukRunning = false; bool indexingEnabled = false; #ifdef HAVE_NEPOMUK - nepomukRunning = (Nepomuk::ResourceManager::instance()->initialized()); + nepomukRunning = (Nepomuk2::ResourceManager::instance()->initialized()); if (nepomukRunning) { KConfig config("nepomukserverrc"); indexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", false); diff --git a/src/settings/general/behaviorsettingspage.cpp b/src/settings/general/behaviorsettingspage.cpp index 1ade93c8e..cbbde1d7c 100644 --- a/src/settings/general/behaviorsettingspage.cpp +++ b/src/settings/general/behaviorsettingspage.cpp @@ -42,7 +42,8 @@ BehaviorSettingsPage::BehaviorSettingsPage(const KUrl& url, QWidget* parent) : m_globalViewProps(0), m_showToolTips(0), m_showSelectionToggle(0), - m_naturalSorting(0) + m_naturalSorting(0), + m_renameInline(0) { QVBoxLayout* topLayout = new QVBoxLayout(this); @@ -66,10 +67,14 @@ BehaviorSettingsPage::BehaviorSettingsPage(const KUrl& url, QWidget* parent) : // 'Natural sorting of items' m_naturalSorting = new QCheckBox(i18nc("option:check", "Natural sorting of items"), this); + // 'Inline renaming of items' + m_renameInline = new QCheckBox(i18nc("option:check", "Rename inline"), this); + topLayout->addWidget(viewPropsBox); topLayout->addWidget(m_showToolTips); topLayout->addWidget(m_showSelectionToggle); topLayout->addWidget(m_naturalSorting); + topLayout->addWidget(m_renameInline); topLayout->addStretch(); loadSettings(); @@ -79,6 +84,7 @@ BehaviorSettingsPage::BehaviorSettingsPage(const KUrl& url, QWidget* parent) : connect(m_showToolTips, SIGNAL(toggled(bool)), this, SIGNAL(changed())); connect(m_showSelectionToggle, SIGNAL(toggled(bool)), this, SIGNAL(changed())); connect(m_naturalSorting, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + connect(m_renameInline, SIGNAL(toggled(bool)), this, SIGNAL(changed())); } BehaviorSettingsPage::~BehaviorSettingsPage() @@ -95,6 +101,7 @@ void BehaviorSettingsPage::applySettings() settings->setShowToolTips(m_showToolTips->isChecked()); settings->setShowSelectionToggle(m_showSelectionToggle->isChecked()); + settings->setRenameInline(m_renameInline->isChecked()); settings->writeConfig(); if (useGlobalViewProps) { @@ -131,6 +138,7 @@ void BehaviorSettingsPage::loadSettings() m_showToolTips->setChecked(GeneralSettings::showToolTips()); m_showSelectionToggle->setChecked(GeneralSettings::showSelectionToggle()); m_naturalSorting->setChecked(KGlobalSettings::naturalSorting()); + m_renameInline->setChecked(GeneralSettings::renameInline()); } #include "behaviorsettingspage.moc" diff --git a/src/settings/general/behaviorsettingspage.h b/src/settings/general/behaviorsettingspage.h index 398986262..7a9c2f027 100644 --- a/src/settings/general/behaviorsettingspage.h +++ b/src/settings/general/behaviorsettingspage.h @@ -58,6 +58,7 @@ private: QLabel* m_configureToolTips; QCheckBox* m_showSelectionToggle; QCheckBox* m_naturalSorting; + QCheckBox* m_renameInline; }; #endif diff --git a/src/settings/startup/startupsettingspage.cpp b/src/settings/startup/startupsettingspage.cpp index 43c176560..633cdacad 100644 --- a/src/settings/startup/startupsettingspage.cpp +++ b/src/settings/startup/startupsettingspage.cpp @@ -65,6 +65,11 @@ StartupSettingsPage::StartupSettingsPage(const KUrl& url, QWidget* parent) : m_homeUrl->setClearButtonShown(true); QPushButton* selectHomeUrlButton = new QPushButton(KIcon("folder-open"), QString(), homeUrlBox); + +#ifndef QT_NO_ACCESSIBILITY + selectHomeUrlButton->setAccessibleName(i18nc("@action:button", "Select Home Location")); +#endif + connect(selectHomeUrlButton, SIGNAL(clicked()), this, SLOT(selectHomeUrl())); diff --git a/src/settings/viewpropertiesdialog.cpp b/src/settings/viewpropertiesdialog.cpp index 6c2b0230d..c5002ff9f 100644 --- a/src/settings/viewpropertiesdialog.cpp +++ b/src/settings/viewpropertiesdialog.cpp @@ -29,7 +29,7 @@ #include <config-nepomuk.h> #ifdef HAVE_NEPOMUK -#include <Nepomuk/ResourceManager> +#include <Nepomuk2/ResourceManager> #endif #include <KComponentData> diff --git a/src/statusbar/dolphinstatusbar.cpp b/src/statusbar/dolphinstatusbar.cpp index c19c0fe52..068b6325a 100644 --- a/src/statusbar/dolphinstatusbar.cpp +++ b/src/statusbar/dolphinstatusbar.cpp @@ -66,7 +66,8 @@ DolphinStatusBar::DolphinStatusBar(QWidget* parent) : // Initialize zoom widget m_zoomSlider = new QSlider(Qt::Horizontal, this); - m_zoomSlider->setAccessibleName(i18n("Zoom slider")); + m_zoomSlider->setAccessibleName(i18n("Zoom")); + m_zoomSlider->setAccessibleDescription(i18nc("Description for zoom-slider (accessibility)", "Sets the size of the file icons.")); m_zoomSlider->setPageStep(1); m_zoomSlider->setRange(ZoomLevelInfo::minimumLevel(), ZoomLevelInfo::maximumLevel()); diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 3f906d187..6575eecde 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -20,6 +20,7 @@ set(kitemlistcontrollertest_SRCS ../kitemviews/kfileitemlistview.cpp ../kitemviews/kitemmodelbase.cpp ../kitemviews/kitemlistview.cpp + ../kitemviews/kitemlistviewaccessible.cpp ) kde4_add_unit_test(kitemlistcontrollertest TEST ${kitemlistcontrollertest_SRCS}) target_link_libraries(kitemlistcontrollertest dolphinprivate ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY}) @@ -32,6 +33,7 @@ set(kfileitemlistviewtest_SRCS ../kitemviews/kfileitemlistview.cpp ../kitemviews/kitemmodelbase.cpp ../kitemviews/kitemlistview.cpp + ../kitemviews/kitemlistviewaccessible.cpp ) kde4_add_unit_test(kfileitemlistviewtest TEST ${kfileitemlistviewtest_SRCS}) target_link_libraries(kfileitemlistviewtest dolphinprivate ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY}) @@ -66,7 +68,7 @@ if (Nepomuk_FOUND) ../search/dolphin_searchsettings.kcfgc ) kde4_add_unit_test(dolphinsearchboxtest TEST ${dolphinsearchboxtest_SRCS}) - target_link_libraries(dolphinsearchboxtest ${KDE4_KIO_LIBS} ${SOPRANO_LIBRARIES} ${NEPOMUK_LIBRARIES} ${NEPOMUK_QUERY_LIBRARIES} nepomukutils ${QT_QTTEST_LIBRARY}) + target_link_libraries(dolphinsearchboxtest ${KDE4_KIO_LIBS} ${SOPRANO_LIBRARIES} ${NEPOMUK_CORE_LIBRARY} nepomukutils ${QT_QTTEST_LIBRARY}) endif (Nepomuk_FOUND) # KStandardItemModelTest diff --git a/src/tests/kfileitemmodeltest.cpp b/src/tests/kfileitemmodeltest.cpp index 65c28ce75..9d53ea7e6 100644 --- a/src/tests/kfileitemmodeltest.cpp +++ b/src/tests/kfileitemmodeltest.cpp @@ -28,20 +28,20 @@ void myMessageOutput(QtMsgType type, const char* msg) { switch (type) { - case QtDebugMsg: - break; - case QtWarningMsg: - break; - case QtCriticalMsg: - fprintf(stderr, "Critical: %s\n", msg); - break; - case QtFatalMsg: - fprintf(stderr, "Fatal: %s\n", msg); - abort(); - default: + case QtDebugMsg: break; + case QtWarningMsg: + break; + case QtCriticalMsg: + fprintf(stderr, "Critical: %s\n", msg); + break; + case QtFatalMsg: + fprintf(stderr, "Fatal: %s\n", msg); + abort(); + default: + break; } - } +} namespace { const int DefaultTimeout = 5000; diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 70a739427..035d3dc55 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -73,7 +73,7 @@ #include "zoomlevelinfo.h" #ifdef HAVE_NEPOMUK - #include <Nepomuk/ResourceManager> + #include <Nepomuk2/ResourceManager> #endif namespace { @@ -155,6 +155,7 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) : connect(m_model, SIGNAL(directoryLoadingStarted()), this, SLOT(slotDirectoryLoadingStarted())); connect(m_model, SIGNAL(directoryLoadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted())); + connect(m_model, SIGNAL(directoryLoadingCanceled()), this, SIGNAL(directoryLoadingCanceled())); connect(m_model, SIGNAL(directoryLoadingProgress(int)), this, SIGNAL(directoryLoadingProgress(int))); connect(m_model, SIGNAL(directorySortingProgress(int)), this, SIGNAL(directorySortingProgress(int))); connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)), @@ -638,25 +639,25 @@ void DolphinView::clearSelection() void DolphinView::renameSelectedItems() { const KFileItemList items = selectedItems(); - if (items.isEmpty()) { - return; - } + if (items.isEmpty()) { + return; + } - if (items.count() == 1 && GeneralSettings::renameInline()) { - const int index = m_model->index(items.first()); - m_view->editRole(index, "text"); - } else { - RenameDialog* dialog = new RenameDialog(this, items); - dialog->setAttribute(Qt::WA_DeleteOnClose); - dialog->show(); - dialog->raise(); - dialog->activateWindow(); - } + if (items.count() == 1 && GeneralSettings::renameInline()) { + const int index = m_model->index(items.first()); + m_view->editRole(index, "text"); + } else { + RenameDialog* dialog = new RenameDialog(this, items); + dialog->setAttribute(Qt::WA_DeleteOnClose); + dialog->show(); + dialog->raise(); + dialog->activateWindow(); + } - // Assure that the current index remains visible when KFileItemModel - // will notify the view about changed items (which might result in - // a changed sorting). - m_assureVisibleCurrentIndex = true; + // Assure that the current index remains visible when KFileItemModel + // will notify the view about changed items (which might result in + // a changed sorting). + m_assureVisibleCurrentIndex = true; } void DolphinView::trashSelectedItems() @@ -799,6 +800,14 @@ void DolphinView::slotItemsActivated(const QSet<int>& indexes) items.append(m_model->fileItem(index)); } + if (items.count() > 5) { + QString question = QString("Are you sure you want to open %1 items?").arg(items.count()); + const int answer = KMessageBox::warningYesNo(this, question); + if (answer != KMessageBox::Yes) { + return; + } + } + foreach (const KFileItem& item, items) { if (item.isDir()) { emit tabRequested(item.url()); @@ -839,7 +848,7 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos) bool nepomukRunning = false; bool indexingEnabled = false; #ifdef HAVE_NEPOMUK - nepomukRunning = (Nepomuk::ResourceManager::instance()->initialized()); + nepomukRunning = (Nepomuk2::ResourceManager::instance()->initialized()); if (nepomukRunning) { KConfig config("nepomukserverrc"); indexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", false); diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h index f756de05e..6d15ebf32 100644 --- a/src/views/dolphinview.h +++ b/src/views/dolphinview.h @@ -484,6 +484,12 @@ signals: void directoryLoadingCompleted(); /** + * Is emitted after the directory loading triggered by DolphinView::setUrl() + * has been canceled. + */ + void directoryLoadingCanceled(); + + /** * Is emitted after DolphinView::setUrl() has been invoked and provides * the information how much percent of the current directory have been loaded. */ diff --git a/src/views/dolphinviewactionhandler.cpp b/src/views/dolphinviewactionhandler.cpp index 0249964ac..88f1c8248 100644 --- a/src/views/dolphinviewactionhandler.cpp +++ b/src/views/dolphinviewactionhandler.cpp @@ -40,7 +40,7 @@ #include <KIcon> #ifdef HAVE_NEPOMUK - #include <Nepomuk/ResourceManager> + #include <Nepomuk2/ResourceManager> #endif #include <KDebug> @@ -237,7 +237,7 @@ QActionGroup* DolphinViewActionHandler::createFileItemRolesActionGroup(const QSt bool nepomukRunning = false; bool indexingEnabled = false; #ifdef HAVE_NEPOMUK - nepomukRunning = (Nepomuk::ResourceManager::instance()->initialized()); + nepomukRunning = (Nepomuk2::ResourceManager::instance()->initialized()); if (nepomukRunning) { KConfig config("nepomukserverrc"); indexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", false); |
