From: Frank Reininghaus Date: Tue, 13 May 2014 16:42:05 +0000 (+0200) Subject: Merge remote-tracking branch 'origin/master' into frameworks X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/4cf04b91dd8804f2536fc31ae2f1b486bfc8cf9c?hp=-c Merge remote-tracking branch 'origin/master' into frameworks Since the master branch had never been merged into frameworks since the creation of the frameworks branch, I had to fix a couple of merge conflicts and make another change in order to make it build - I hope I did not get anything wrong. We should probably merge master into frameworks on a regular basis from now on. CCMAIL:kfm-devel@kde.org Conflicts: dolphin/src/dolphinmainwindow.cpp dolphin/src/search/dolphinfacetswidget.cpp dolphin/src/statusbar/dolphinstatusbar.cpp dolphin/src/views/dolphinview.cpp --- 4cf04b91dd8804f2536fc31ae2f1b486bfc8cf9c diff --combined src/dolphinmainwindow.cpp index 53f9826c9,e6b911209..dc5e37ff7 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@@ -53,10 -53,9 +53,10 @@@ #include #include #include +#include +#include #include #include -#include #include #include #include @@@ -87,8 -86,6 +87,8 @@@ #include #include #include +#include +#include namespace { // Used for GeneralSettings::version() to determine whether @@@ -130,20 -127,20 +130,20 @@@ DolphinMainWindow::DolphinMainWindow() ViewTab& viewTab = m_viewTab[m_tabIndex]; viewTab.wasActive = true; // The first opened tab is automatically active - connect(&DolphinNewFileMenuObserver::instance(), SIGNAL(errorMessage(QString)), - this, SLOT(showErrorMessage(QString))); + connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage, + this, &DolphinMainWindow::showErrorMessage); KIO::FileUndoManager* undoManager = KIO::FileUndoManager::self(); undoManager->setUiInterface(new UndoUiInterface()); - connect(undoManager, SIGNAL(undoAvailable(bool)), - this, SLOT(slotUndoAvailable(bool))); - connect(undoManager, SIGNAL(undoTextChanged(QString)), - this, SLOT(slotUndoTextChanged(QString))); - connect(undoManager, SIGNAL(jobRecordingStarted(CommandType)), - this, SLOT(clearStatusBar())); - connect(undoManager, SIGNAL(jobRecordingFinished(CommandType)), - this, SLOT(showCommand(CommandType))); + connect(undoManager, static_cast(&KIO::FileUndoManager::undoAvailable), + this, &DolphinMainWindow::slotUndoAvailable); + connect(undoManager, &KIO::FileUndoManager::undoTextChanged, + this, &DolphinMainWindow::slotUndoTextChanged); + connect(undoManager, &KIO::FileUndoManager::jobRecordingStarted, + this, &DolphinMainWindow::clearStatusBar); + connect(undoManager, &KIO::FileUndoManager::jobRecordingFinished, + this, &DolphinMainWindow::showCommand); GeneralSettings* generalSettings = GeneralSettings::self(); const bool firstRun = (generalSettings->version() < 200); @@@ -161,8 -158,8 +161,8 @@@ const KUrl homeUrl(generalSettings->homeUrl()); setUrlAsCaption(homeUrl); m_actionHandler = new DolphinViewActionHandler(actionCollection(), this); - connect(m_actionHandler, SIGNAL(actionBeingHandled()), SLOT(clearStatusBar())); - connect(m_actionHandler, SIGNAL(createDirectory()), SLOT(createDirectory())); + connect(m_actionHandler, &DolphinViewActionHandler::actionBeingHandled, this, &DolphinMainWindow::clearStatusBar); + connect(m_actionHandler, &DolphinViewActionHandler::createDirectory, this, &DolphinMainWindow::createDirectory); viewTab.primaryView = createViewContainer(homeUrl, viewTab.splitter); @@@ -173,28 -170,28 +173,28 @@@ m_actionHandler->setCurrentView(view); m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler); - connect(this, SIGNAL(urlChanged(KUrl)), - m_remoteEncoding, SLOT(slotAboutToOpenUrl())); + connect(this, &DolphinMainWindow::urlChanged, + m_remoteEncoding, &DolphinRemoteEncoding::slotAboutToOpenUrl); m_tabBar = new KTabBar(this); m_tabBar->setMovable(true); m_tabBar->setTabsClosable(true); - connect(m_tabBar, SIGNAL(currentChanged(int)), - this, SLOT(setActiveTab(int))); - connect(m_tabBar, SIGNAL(tabCloseRequested(int)), - this, SLOT(closeTab(int))); - connect(m_tabBar, SIGNAL(contextMenu(int,QPoint)), - this, SLOT(openTabContextMenu(int,QPoint))); - connect(m_tabBar, SIGNAL(newTabRequest()), - this, SLOT(openNewTab())); - connect(m_tabBar, SIGNAL(testCanDecode(const QDragMoveEvent*,bool&)), - this, SLOT(slotTestCanDecode(const QDragMoveEvent*,bool&))); - connect(m_tabBar, SIGNAL(mouseMiddleClick(int)), - this, SLOT(closeTab(int))); - connect(m_tabBar, SIGNAL(tabMoved(int,int)), - this, SLOT(slotTabMoved(int,int))); - connect(m_tabBar, SIGNAL(receivedDropEvent(int,QDropEvent*)), - this, SLOT(tabDropEvent(int,QDropEvent*))); + connect(m_tabBar, &KTabBar::currentChanged, + this, &DolphinMainWindow::setActiveTab); + connect(m_tabBar, &KTabBar::tabCloseRequested, + this, static_cast(&DolphinMainWindow::closeTab)); + connect(m_tabBar, &KTabBar::contextMenu, + this, &DolphinMainWindow::openTabContextMenu); + connect(m_tabBar, &KTabBar::newTabRequest, + this, static_cast(&DolphinMainWindow::openNewTab)); + connect(m_tabBar, &KTabBar::testCanDecode, + this, &DolphinMainWindow::slotTestCanDecode); + connect(m_tabBar, &KTabBar::mouseMiddleClick, + this, static_cast(&DolphinMainWindow::closeTab)); + connect(m_tabBar, &KTabBar::tabMoved, + this, &DolphinMainWindow::slotTabMoved); + connect(m_tabBar, &KTabBar::receivedDropEvent, + this, &DolphinMainWindow::tabDropEvent); m_tabBar->blockSignals(true); // signals get unblocked after at least 2 tabs are open @@@ -213,8 -210,8 +213,8 @@@ stateChanged("new_file"); QClipboard* clipboard = QApplication::clipboard(); - connect(clipboard, SIGNAL(dataChanged()), - this, SLOT(updatePasteAction())); + connect(clipboard, &QClipboard::dataChanged, + this, &DolphinMainWindow::updatePasteAction); if (generalSettings->splitView()) { toggleSplitView(); @@@ -365,8 -362,8 +365,8 @@@ void DolphinMainWindow::changeUrl(cons if (m_viewTab.count() > 1) { m_tabBar->setTabText(m_tabIndex, squeezedText(tabName(m_activeViewContainer->url()))); } - const QString iconName = KMimeType::iconNameForUrl(url); - m_tabBar->setTabIcon(m_tabIndex, KIcon(iconName)); + const QString iconName = KIO::iconNameForUrl(url); + m_tabBar->setTabIcon(m_tabIndex, QIcon::fromTheme(iconName)); emit urlChanged(url); } } @@@ -466,12 -463,12 +466,12 @@@ void DolphinMainWindow::openNewTab(cons // Only one view is open currently and hence no tab is shown at // all. Before creating a tab for 'url', provide a tab for the current URL. const KUrl currentUrl = m_activeViewContainer->url(); - m_tabBar->addTab(KIcon(KMimeType::iconNameForUrl(currentUrl)), + m_tabBar->addTab(QIcon::fromTheme(KIO::iconNameForUrl(currentUrl)), squeezedText(tabName(currentUrl))); m_tabBar->blockSignals(false); } - m_tabBar->addTab(KIcon(KMimeType::iconNameForUrl(url)), + m_tabBar->addTab(QIcon::fromTheme(KIO::iconNameForUrl(url)), squeezedText(tabName(url))); ViewTab viewTab; @@@ -484,6 -481,8 +484,8 @@@ m_viewTab.append(viewTab); actionCollection()->action("close_tab")->setEnabled(true); + actionCollection()->action("activate_prev_tab")->setEnabled(true); + actionCollection()->action("activate_next_tab")->setEnabled(true); // Provide a split view, if the startup settings are set this way if (GeneralSettings::splitView()) { @@@ -553,7 -552,7 +555,7 @@@ void DolphinMainWindow::openInNewWindow } if (!newWindowUrl.isEmpty()) { - KRun::run("dolphin %u", KUrl::List() << newWindowUrl, this); + KRun::run("dolphin %u", QList() << newWindowUrl, this); } } @@@ -596,19 -595,18 +598,19 @@@ void DolphinMainWindow::closeEvent(QClo // KDialog::Yes -> Quit // KDialog::No -> Close only the current tab // KDialog::Cancel -> do nothing - KDialog *dialog = new KDialog(this, Qt::Dialog); - dialog->setCaption(i18nc("@title:window", "Confirmation")); - dialog->setButtons(KDialog::Yes | KDialog::No | KDialog::Cancel); + QDialog *dialog = new QDialog(this, Qt::Dialog); + dialog->setWindowTitle(i18nc("@title:window", "Confirmation")); dialog->setModal(true); - dialog->setButtonGuiItem(KDialog::Yes, KStandardGuiItem::quit()); - dialog->setButtonGuiItem(KDialog::No, KGuiItem(i18n("C&lose Current Tab"), KIcon("tab-close"))); - dialog->setButtonGuiItem(KDialog::Cancel, KStandardGuiItem::cancel()); - dialog->setDefaultButton(KDialog::Yes); + QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Yes | QDialogButtonBox::No | QDialogButtonBox::Cancel); + KGuiItem::assign(buttons->button(QDialogButtonBox::Yes), KStandardGuiItem::quit()); + KGuiItem::assign(buttons->button(QDialogButtonBox::No), KGuiItem(i18n("C&lose Current Tab"), QIcon::fromTheme("tab-close"))); + KGuiItem::assign(buttons->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel()); + buttons->button(QDialogButtonBox::Yes)->setDefault(true); bool doNotAskAgainCheckboxResult = false; const int result = KMessageBox::createKMessageBox(dialog, + buttons, QMessageBox::Warning, i18n("You have multiple tabs open in this window, are you sure you want to quit?"), QStringList(), @@@ -1062,7 -1060,7 +1064,7 @@@ void DolphinMainWindow::editSettings( const KUrl url = container->url(); DolphinSettingsDialog* settingsDialog = new DolphinSettingsDialog(url, this); - connect(settingsDialog, SIGNAL(settingsChanged()), this, SLOT(refreshViews())); + connect(settingsDialog, &DolphinSettingsDialog::settingsChanged, this, &DolphinMainWindow::refreshViews); settingsDialog->setAttribute(Qt::WA_DeleteOnClose); settingsDialog->show(); m_settingsDialog = settingsDialog; @@@ -1159,6 -1157,8 +1161,8 @@@ void DolphinMainWindow::closeTab(int in if (m_viewTab.count() == 1) { m_tabBar->removeTab(0); actionCollection()->action("close_tab")->setEnabled(false); + actionCollection()->action("activate_prev_tab")->setEnabled(false); + actionCollection()->action("activate_next_tab")->setEnabled(false); } else { m_tabBar->blockSignals(false); } @@@ -1168,14 -1168,14 +1172,14 @@@ void DolphinMainWindow::openTabContextM { KMenu menu(this); - QAction* newTabAction = menu.addAction(KIcon("tab-new"), i18nc("@action:inmenu", "New Tab")); + QAction* newTabAction = menu.addAction(QIcon::fromTheme("tab-new"), i18nc("@action:inmenu", "New Tab")); newTabAction->setShortcut(actionCollection()->action("new_tab")->shortcut()); - QAction* detachTabAction = menu.addAction(KIcon("tab-detach"), i18nc("@action:inmenu", "Detach Tab")); + QAction* detachTabAction = menu.addAction(QIcon::fromTheme("tab-detach"), i18nc("@action:inmenu", "Detach Tab")); - QAction* closeOtherTabsAction = menu.addAction(KIcon("tab-close-other"), i18nc("@action:inmenu", "Close Other Tabs")); + QAction* closeOtherTabsAction = menu.addAction(QIcon::fromTheme("tab-close-other"), i18nc("@action:inmenu", "Close Other Tabs")); - QAction* closeTabAction = menu.addAction(KIcon("tab-close"), i18nc("@action:inmenu", "Close Tab")); + QAction* closeTabAction = menu.addAction(QIcon::fromTheme("tab-close"), i18nc("@action:inmenu", "Close Tab")); closeTabAction->setShortcut(actionCollection()->action("close_tab")->shortcut()); QAction* selectedAction = menu.exec(pos); if (selectedAction == newTabAction) { @@@ -1236,10 -1236,10 +1240,10 @@@ void DolphinMainWindow::handleUrl(cons // stat the URL to see if it is a dir or not m_lastHandleUrlStatJob = KIO::stat(url, KIO::HideProgressInfo); if (m_lastHandleUrlStatJob->ui()) { - m_lastHandleUrlStatJob->ui()->setWindow(this); + KJobWidgets::setWindow(m_lastHandleUrlStatJob, this); } - connect(m_lastHandleUrlStatJob, SIGNAL(result(KJob*)), - this, SLOT(slotHandleUrlStatFinished(KJob*))); + connect(m_lastHandleUrlStatJob, &KIO::Job::result, + this, &DolphinMainWindow::slotHandleUrlStatFinished); } else { new KRun(url, this); // Automatically deletes itself after being finished @@@ -1289,13 -1289,12 +1293,13 @@@ void DolphinMainWindow::openContextMenu switch (command) { case DolphinContextMenu::OpenParentFolderInNewWindow: { - KRun::run("dolphin %u", KUrl::List() << item.url().upUrl(), this); + + KRun::run("dolphin %u", QList() << KIO::upUrl(item.url()), this); break; } case DolphinContextMenu::OpenParentFolderInNewTab: - openNewTab(item.url().upUrl()); + openNewTab(KIO::upUrl(item.url())); break; case DolphinContextMenu::None: @@@ -1362,7 -1361,7 +1366,7 @@@ void DolphinMainWindow::updateControlMe // Add "Go" menu KMenu* goMenu = new KMenu(i18nc("@action:inmenu", "Go"), menu); - connect(menu, SIGNAL(aboutToHide()), goMenu, SLOT(deleteLater())); + connect(menu, &KMenu::aboutToHide, goMenu, &KMenu::deleteLater); goMenu->addAction(ac->action(KStandardAction::name(KStandardAction::Back))); goMenu->addAction(ac->action(KStandardAction::name(KStandardAction::Forward))); goMenu->addAction(ac->action(KStandardAction::name(KStandardAction::Up))); @@@ -1372,7 -1371,7 +1376,7 @@@ // Add "Tool" menu KMenu* toolsMenu = new KMenu(i18nc("@action:inmenu", "Tools"), menu); - connect(menu, SIGNAL(aboutToHide()), toolsMenu, SLOT(deleteLater())); + connect(menu, &KMenu::aboutToHide, toolsMenu, &KMenu::deleteLater); toolsMenu->addAction(ac->action("show_filter_bar")); toolsMenu->addAction(ac->action("compare_files")); toolsMenu->addAction(ac->action("open_terminal")); @@@ -1386,7 -1385,7 +1390,7 @@@ // Add "Help" menu KMenu* helpMenu = new KMenu(i18nc("@action:inmenu", "Help"), menu); - connect(menu, SIGNAL(aboutToHide()), helpMenu, SLOT(deleteLater())); + connect(menu, &KMenu::aboutToHide, helpMenu, &KMenu::deleteLater); helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::HelpContents))); helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::WhatsThis))); helpMenu->addSeparator(); @@@ -1448,9 -1447,9 +1452,9 @@@ void DolphinMainWindow::setActiveViewCo // Activating the view container might trigger a recursive setActiveViewContainer() call // inside DolphinMainWindow::toggleActiveView() when having a split view. Temporary // disconnect the activated() signal in this case: - disconnect(m_activeViewContainer->view(), SIGNAL(activated()), this, SLOT(toggleActiveView())); + disconnect(m_activeViewContainer->view(), &DolphinView::activated, this, &DolphinMainWindow::toggleActiveView); m_activeViewContainer->setActive(true); - connect(m_activeViewContainer->view(), SIGNAL(activated()), this, SLOT(toggleActiveView())); + connect(m_activeViewContainer->view(), &DolphinView::activated, this, &DolphinMainWindow::toggleActiveView); m_actionHandler->setCurrentView(viewContainer->view()); @@@ -1463,7 -1462,7 +1467,7 @@@ setUrlAsCaption(url); if (m_viewTab.count() > 1) { m_tabBar->setTabText(m_tabIndex, tabName(url)); - m_tabBar->setTabIcon(m_tabIndex, KIcon(KMimeType::iconNameForUrl(url))); + m_tabBar->setTabIcon(m_tabIndex, QIcon::fromTheme(KIO::iconNameForUrl(url))); } emit urlChanged(url); @@@ -1485,31 -1484,31 +1489,31 @@@ void DolphinMainWindow::setupActions( { // setup 'File' menu m_newFileMenu = new DolphinNewFileMenu(actionCollection(), this); - KMenu* menu = m_newFileMenu->menu(); + QMenu* menu = m_newFileMenu->menu(); menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New")); - menu->setIcon(KIcon("document-new")); + menu->setIcon(QIcon::fromTheme("document-new")); m_newFileMenu->setDelayed(false); - connect(menu, SIGNAL(aboutToShow()), - this, SLOT(updateNewMenu())); + connect(menu, &QMenu::aboutToShow, + this, &DolphinMainWindow::updateNewMenu); - KAction* newWindow = actionCollection()->addAction("new_window"); - newWindow->setIcon(KIcon("window-new")); + QAction* newWindow = actionCollection()->addAction("new_window"); + newWindow->setIcon(QIcon::fromTheme("window-new")); newWindow->setText(i18nc("@action:inmenu File", "New &Window")); newWindow->setShortcut(Qt::CTRL | Qt::Key_N); - connect(newWindow, SIGNAL(triggered()), this, SLOT(openNewMainWindow())); + connect(newWindow, &QAction::triggered, this, &DolphinMainWindow::openNewMainWindow); - KAction* newTab = actionCollection()->addAction("new_tab"); - newTab->setIcon(KIcon("tab-new")); + QAction* newTab = actionCollection()->addAction("new_tab"); + newTab->setIcon(QIcon::fromTheme("tab-new")); newTab->setText(i18nc("@action:inmenu File", "New Tab")); - newTab->setShortcut(KShortcut(Qt::CTRL | Qt::Key_T, Qt::CTRL | Qt::SHIFT | Qt::Key_N)); - connect(newTab, SIGNAL(triggered()), this, SLOT(openNewTab())); + newTab->setShortcuts(QList() << QKeySequence(Qt::CTRL | Qt::Key_T) << QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_N)); + connect(newTab, &QAction::triggered, this, static_cast(&DolphinMainWindow::openNewTab)); - KAction* closeTab = actionCollection()->addAction("close_tab"); - closeTab->setIcon(KIcon("tab-close")); + QAction* closeTab = actionCollection()->addAction("close_tab"); + closeTab->setIcon(QIcon::fromTheme("tab-close")); closeTab->setText(i18nc("@action:inmenu File", "Close Tab")); closeTab->setShortcut(Qt::CTRL | Qt::Key_W); closeTab->setEnabled(false); - connect(closeTab, SIGNAL(triggered()), this, SLOT(closeTab())); + connect(closeTab, &QAction::triggered, this, static_cast(&DolphinMainWindow::closeTab)); KStandardAction::quit(this, SLOT(quit()), actionCollection()); @@@ -1520,12 -1519,12 +1524,12 @@@ // need to remove shift+del from cut action, else the shortcut for deletejob // doesn't work - KAction* cut = KStandardAction::cut(this, SLOT(cut()), actionCollection()); - KShortcut cutShortcut = cut->shortcut(); - cutShortcut.remove(Qt::SHIFT | Qt::Key_Delete, KShortcut::KeepEmpty); - cut->setShortcut(cutShortcut); + QAction* cut = KStandardAction::cut(this, SLOT(cut()), actionCollection()); + auto cutShortcuts = cut->shortcuts(); + cutShortcuts.removeAll(QKeySequence(Qt::SHIFT | Qt::Key_Delete)); + cut->setShortcuts(cutShortcuts); KStandardAction::copy(this, SLOT(copy()), actionCollection()); - KAction* paste = KStandardAction::paste(this, SLOT(paste()), actionCollection()); + QAction* paste = KStandardAction::paste(this, SLOT(paste()), actionCollection()); // The text of the paste-action is modified dynamically by Dolphin // (e. g. to "Paste One Folder"). To prevent that the size of the toolbar changes // due to the long text, the text "Paste" is used: @@@ -1533,135 -1532,139 +1537,139 @@@ KStandardAction::find(this, SLOT(find()), actionCollection()); - KAction* selectAll = actionCollection()->addAction("select_all"); + QAction* selectAll = actionCollection()->addAction("select_all"); selectAll->setText(i18nc("@action:inmenu Edit", "Select All")); selectAll->setShortcut(Qt::CTRL | Qt::Key_A); - connect(selectAll, SIGNAL(triggered()), this, SLOT(selectAll())); + connect(selectAll, &QAction::triggered, this, &DolphinMainWindow::selectAll); - KAction* invertSelection = actionCollection()->addAction("invert_selection"); + QAction* invertSelection = actionCollection()->addAction("invert_selection"); invertSelection->setText(i18nc("@action:inmenu Edit", "Invert Selection")); invertSelection->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_A); - connect(invertSelection, SIGNAL(triggered()), this, SLOT(invertSelection())); + connect(invertSelection, &QAction::triggered, this, &DolphinMainWindow::invertSelection); // setup 'View' menu // (note that most of it is set up in DolphinViewActionHandler) - KAction* split = actionCollection()->addAction("split_view"); + QAction* split = actionCollection()->addAction("split_view"); split->setShortcut(Qt::Key_F3); updateSplitAction(); - connect(split, SIGNAL(triggered()), this, SLOT(toggleSplitView())); + connect(split, &QAction::triggered, this, &DolphinMainWindow::toggleSplitView); - KAction* reload = actionCollection()->addAction("reload"); + QAction* reload = actionCollection()->addAction("reload"); reload->setText(i18nc("@action:inmenu View", "Reload")); reload->setShortcut(Qt::Key_F5); - reload->setIcon(KIcon("view-refresh")); - connect(reload, SIGNAL(triggered()), this, SLOT(reloadView())); + reload->setIcon(QIcon::fromTheme("view-refresh")); + connect(reload, &QAction::triggered, this, &DolphinMainWindow::reloadView); - KAction* stop = actionCollection()->addAction("stop"); + QAction* stop = actionCollection()->addAction("stop"); stop->setText(i18nc("@action:inmenu View", "Stop")); stop->setToolTip(i18nc("@info", "Stop loading")); - stop->setIcon(KIcon("process-stop")); - connect(stop, SIGNAL(triggered()), this, SLOT(stopLoading())); + stop->setIcon(QIcon::fromTheme("process-stop")); + connect(stop, &QAction::triggered, this, &DolphinMainWindow::stopLoading); KToggleAction* editableLocation = actionCollection()->add("editable_location"); editableLocation->setText(i18nc("@action:inmenu Navigation Bar", "Editable Location")); editableLocation->setShortcut(Qt::Key_F6); - connect(editableLocation, SIGNAL(triggered()), this, SLOT(toggleEditLocation())); + connect(editableLocation, &KToggleAction::triggered, this, &DolphinMainWindow::toggleEditLocation); - KAction* replaceLocation = actionCollection()->addAction("replace_location"); + QAction* replaceLocation = actionCollection()->addAction("replace_location"); replaceLocation->setText(i18nc("@action:inmenu Navigation Bar", "Replace Location")); replaceLocation->setShortcut(Qt::CTRL | Qt::Key_L); - connect(replaceLocation, SIGNAL(triggered()), this, SLOT(replaceLocation())); + connect(replaceLocation, &QAction::triggered, this, &DolphinMainWindow::replaceLocation); // setup 'Go' menu - KAction* backAction = KStandardAction::back(this, SLOT(goBack()), actionCollection()); - connect(backAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(goBack(Qt::MouseButtons))); - KShortcut backShortcut = backAction->shortcut(); - backShortcut.setAlternate(Qt::Key_Backspace); - backAction->setShortcut(backShortcut); + QAction* backAction = KStandardAction::back(this, SLOT(goBack()), actionCollection()); + connect(backAction, &QAction::triggered, this, static_cast(&DolphinMainWindow::goBack)); + auto backShortcuts = backAction->shortcuts(); + backShortcuts.append(QKeySequence(Qt::Key_Backspace)); + backAction->setShortcuts(backShortcuts); m_recentTabsMenu = new KActionMenu(i18n("Recently Closed Tabs"), this); - m_recentTabsMenu->setIcon(KIcon("edit-undo")); + m_recentTabsMenu->setIcon(QIcon::fromTheme("edit-undo")); m_recentTabsMenu->setDelayed(false); actionCollection()->addAction("closed_tabs", m_recentTabsMenu); - connect(m_recentTabsMenu->menu(), SIGNAL(triggered(QAction*)), - this, SLOT(restoreClosedTab(QAction*))); + connect(m_recentTabsMenu->menu(), &QMenu::triggered, + this, &DolphinMainWindow::restoreClosedTab); QAction* action = new QAction(i18n("Empty Recently Closed Tabs"), m_recentTabsMenu); - action->setIcon(KIcon("edit-clear-list")); + action->setIcon(QIcon::fromTheme("edit-clear-list")); action->setData(QVariant::fromValue(true)); m_recentTabsMenu->addAction(action); m_recentTabsMenu->addSeparator(); m_recentTabsMenu->setEnabled(false); - KAction* forwardAction = KStandardAction::forward(this, SLOT(goForward()), actionCollection()); - connect(forwardAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(goForward(Qt::MouseButtons))); + QAction* forwardAction = KStandardAction::forward(this, SLOT(goForward()), actionCollection()); + connect(forwardAction, &QAction::triggered, this, static_cast(&DolphinMainWindow::goForward)); - KAction* upAction = KStandardAction::up(this, SLOT(goUp()), actionCollection()); - connect(upAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(goUp(Qt::MouseButtons))); + QAction* upAction = KStandardAction::up(this, SLOT(goUp()), actionCollection()); + connect(upAction, &QAction::triggered, this, static_cast(&DolphinMainWindow::goUp)); - KAction* homeAction = KStandardAction::home(this, SLOT(goHome()), actionCollection()); - connect(homeAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(goHome(Qt::MouseButtons))); + QAction* homeAction = KStandardAction::home(this, SLOT(goHome()), actionCollection()); + connect(homeAction, &QAction::triggered, this, static_cast(&DolphinMainWindow::goHome)); // setup 'Tools' menu - KAction* showFilterBar = actionCollection()->addAction("show_filter_bar"); + QAction* showFilterBar = actionCollection()->addAction("show_filter_bar"); showFilterBar->setText(i18nc("@action:inmenu Tools", "Show Filter Bar")); - showFilterBar->setIcon(KIcon("view-filter")); + showFilterBar->setIcon(QIcon::fromTheme("view-filter")); showFilterBar->setShortcut(Qt::CTRL | Qt::Key_I); - connect(showFilterBar, SIGNAL(triggered()), this, SLOT(showFilterBar())); + connect(showFilterBar, &QAction::triggered, this, &DolphinMainWindow::showFilterBar); - KAction* compareFiles = actionCollection()->addAction("compare_files"); + QAction* compareFiles = actionCollection()->addAction("compare_files"); compareFiles->setText(i18nc("@action:inmenu Tools", "Compare Files")); - compareFiles->setIcon(KIcon("kompare")); + compareFiles->setIcon(QIcon::fromTheme("kompare")); compareFiles->setEnabled(false); - connect(compareFiles, SIGNAL(triggered()), this, SLOT(compareFiles())); + connect(compareFiles, &QAction::triggered, this, &DolphinMainWindow::compareFiles); - KAction* openTerminal = actionCollection()->addAction("open_terminal"); + QAction* openTerminal = actionCollection()->addAction("open_terminal"); openTerminal->setText(i18nc("@action:inmenu Tools", "Open Terminal")); - openTerminal->setIcon(KIcon("utilities-terminal")); + openTerminal->setIcon(QIcon::fromTheme("utilities-terminal")); openTerminal->setShortcut(Qt::SHIFT | Qt::Key_F4); - connect(openTerminal, SIGNAL(triggered()), this, SLOT(openTerminal())); + connect(openTerminal, &QAction::triggered, this, &DolphinMainWindow::openTerminal); // setup 'Settings' menu KToggleAction* showMenuBar = KStandardAction::showMenubar(0, 0, actionCollection()); - connect(showMenuBar, SIGNAL(triggered(bool)), // Fixes #286822 - this, SLOT(toggleShowMenuBar()), Qt::QueuedConnection); + connect(showMenuBar, &KToggleAction::triggered, // Fixes #286822 + this, &DolphinMainWindow::toggleShowMenuBar, Qt::QueuedConnection); KStandardAction::preferences(this, SLOT(editSettings()), actionCollection()); // not in menu actions QList nextTabKeys; - nextTabKeys.append(KStandardShortcut::tabNext().primary()); + nextTabKeys.append(KStandardShortcut::tabNext().first()); //TODO: is this correct nextTabKeys.append(QKeySequence(Qt::CTRL | Qt::Key_Tab)); QList prevTabKeys; - prevTabKeys.append(KStandardShortcut::tabPrev().primary()); + prevTabKeys.append(KStandardShortcut::tabPrev().first()); //TODO: is this correct prevTabKeys.append(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_Tab)); - KAction* activateNextTab = actionCollection()->addAction("activate_next_tab"); + QAction* activateNextTab = actionCollection()->addAction("activate_next_tab"); + activateNextTab->setIconText(i18nc("@action:inmenu", "Next Tab")); activateNextTab->setText(i18nc("@action:inmenu", "Activate Next Tab")); + activateNextTab->setEnabled(false); - connect(activateNextTab, SIGNAL(triggered()), SLOT(activateNextTab())); + connect(activateNextTab, &QAction::triggered, this, &DolphinMainWindow::activateNextTab); activateNextTab->setShortcuts(QApplication::isRightToLeft() ? prevTabKeys : nextTabKeys); - KAction* activatePrevTab = actionCollection()->addAction("activate_prev_tab"); + QAction* activatePrevTab = actionCollection()->addAction("activate_prev_tab"); + activatePrevTab->setIconText(i18nc("@action:inmenu", "Previous Tab")); activatePrevTab->setText(i18nc("@action:inmenu", "Activate Previous Tab")); + activatePrevTab->setEnabled(false); - connect(activatePrevTab, SIGNAL(triggered()), SLOT(activatePrevTab())); + connect(activatePrevTab, &QAction::triggered, this, &DolphinMainWindow::activatePrevTab); activatePrevTab->setShortcuts(QApplication::isRightToLeft() ? nextTabKeys : prevTabKeys); // for context menu - KAction* openInNewTab = actionCollection()->addAction("open_in_new_tab"); + QAction* openInNewTab = actionCollection()->addAction("open_in_new_tab"); openInNewTab->setText(i18nc("@action:inmenu", "Open in New Tab")); - openInNewTab->setIcon(KIcon("tab-new")); - connect(openInNewTab, SIGNAL(triggered()), this, SLOT(openInNewTab())); + openInNewTab->setIcon(QIcon::fromTheme("tab-new")); + connect(openInNewTab, &QAction::triggered, this, &DolphinMainWindow::openInNewTab); - KAction* openInNewTabs = actionCollection()->addAction("open_in_new_tabs"); + QAction* openInNewTabs = actionCollection()->addAction("open_in_new_tabs"); openInNewTabs->setText(i18nc("@action:inmenu", "Open in New Tabs")); - openInNewTabs->setIcon(KIcon("tab-new")); - connect(openInNewTabs, SIGNAL(triggered()), this, SLOT(openInNewTab())); + openInNewTabs->setIcon(QIcon::fromTheme("tab-new")); + connect(openInNewTabs, &QAction::triggered, this, &DolphinMainWindow::openInNewTab); - KAction* openInNewWindow = actionCollection()->addAction("open_in_new_window"); + QAction* openInNewWindow = actionCollection()->addAction("open_in_new_window"); openInNewWindow->setText(i18nc("@action:inmenu", "Open in New Window")); - openInNewWindow->setIcon(KIcon("window-new")); - connect(openInNewWindow, SIGNAL(triggered()), this, SLOT(openInNewWindow())); + openInNewWindow->setIcon(QIcon::fromTheme("window-new")); + connect(openInNewWindow, &QAction::triggered, this, &DolphinMainWindow::openInNewWindow); } void DolphinMainWindow::setupDockWidgets() @@@ -1670,32 -1673,32 +1678,32 @@@ KDualAction* lockLayoutAction = actionCollection()->add("lock_panels"); lockLayoutAction->setActiveText(i18nc("@action:inmenu Panels", "Unlock Panels")); - lockLayoutAction->setActiveIcon(KIcon("object-unlocked")); + lockLayoutAction->setActiveIcon(QIcon::fromTheme("object-unlocked")); lockLayoutAction->setInactiveText(i18nc("@action:inmenu Panels", "Lock Panels")); - lockLayoutAction->setInactiveIcon(KIcon("object-locked")); + lockLayoutAction->setInactiveIcon(QIcon::fromTheme("object-locked")); lockLayoutAction->setActive(lock); - connect(lockLayoutAction, SIGNAL(triggered()), this, SLOT(togglePanelLockState())); + connect(lockLayoutAction, &KDualAction::triggered, this, &DolphinMainWindow::togglePanelLockState); // Setup "Information" DolphinDockWidget* infoDock = new DolphinDockWidget(i18nc("@title:window", "Information")); infoDock->setLocked(lock); infoDock->setObjectName("infoDock"); infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); - Panel* infoPanel = new InformationPanel(infoDock); + InformationPanel* infoPanel = new InformationPanel(infoDock); infoPanel->setCustomContextMenuActions(QList() << lockLayoutAction); - connect(infoPanel, SIGNAL(urlActivated(KUrl)), this, SLOT(handleUrl(KUrl))); + connect(infoPanel, &InformationPanel::urlActivated, this, &DolphinMainWindow::handleUrl); infoDock->setWidget(infoPanel); QAction* infoAction = infoDock->toggleViewAction(); - createPanelAction(KIcon("dialog-information"), Qt::Key_F11, infoAction, "show_information_panel"); + createPanelAction(QIcon::fromTheme("dialog-information"), Qt::Key_F11, infoAction, "show_information_panel"); addDockWidget(Qt::RightDockWidgetArea, infoDock); - connect(this, SIGNAL(urlChanged(KUrl)), - infoPanel, SLOT(setUrl(KUrl))); - connect(this, SIGNAL(selectionChanged(KFileItemList)), - infoPanel, SLOT(setSelection(KFileItemList))); - connect(this, SIGNAL(requestItemInfo(KFileItem)), - infoPanel, SLOT(requestDelayedItemInfo(KFileItem))); + connect(this, &DolphinMainWindow::urlChanged, + infoPanel, &InformationPanel::setUrl); + connect(this, &DolphinMainWindow::selectionChanged, + infoPanel, &InformationPanel::setSelection); + connect(this, &DolphinMainWindow::requestItemInfo, + infoPanel, &InformationPanel::requestDelayedItemInfo); // Setup "Folders" DolphinDockWidget* foldersDock = new DolphinDockWidget(i18nc("@title:window", "Folders")); @@@ -1707,17 -1710,17 +1715,17 @@@ foldersDock->setWidget(foldersPanel); QAction* foldersAction = foldersDock->toggleViewAction(); - createPanelAction(KIcon("folder"), Qt::Key_F7, foldersAction, "show_folders_panel"); + createPanelAction(QIcon::fromTheme("folder"), Qt::Key_F7, foldersAction, "show_folders_panel"); addDockWidget(Qt::LeftDockWidgetArea, foldersDock); - connect(this, SIGNAL(urlChanged(KUrl)), - foldersPanel, SLOT(setUrl(KUrl))); - connect(foldersPanel, SIGNAL(folderActivated(KUrl)), - this, SLOT(changeUrl(KUrl))); - connect(foldersPanel, SIGNAL(folderMiddleClicked(KUrl)), - this, SLOT(openNewTab(KUrl))); - connect(foldersPanel, SIGNAL(errorMessage(QString)), - this, SLOT(slotPanelErrorMessage(QString))); + connect(this, &DolphinMainWindow::urlChanged, + foldersPanel, &FoldersPanel::setUrl); + connect(foldersPanel, &FoldersPanel::folderActivated, + this, &DolphinMainWindow::changeUrl); + connect(foldersPanel, &FoldersPanel::folderMiddleClicked, + this, static_cast(&DolphinMainWindow::openNewTab)); + connect(foldersPanel, &FoldersPanel::errorMessage, + this, &DolphinMainWindow::slotPanelErrorMessage); // Setup "Terminal" #ifndef Q_OS_WIN @@@ -1725,21 -1728,21 +1733,21 @@@ terminalDock->setLocked(lock); terminalDock->setObjectName("terminalDock"); terminalDock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea); - Panel* terminalPanel = new TerminalPanel(terminalDock); + TerminalPanel* terminalPanel = new TerminalPanel(terminalDock); terminalPanel->setCustomContextMenuActions(QList() << lockLayoutAction); terminalDock->setWidget(terminalPanel); - connect(terminalPanel, SIGNAL(hideTerminalPanel()), terminalDock, SLOT(hide())); - connect(terminalPanel, SIGNAL(changeUrl(KUrl)), this, SLOT(slotTerminalDirectoryChanged(KUrl))); - connect(terminalDock, SIGNAL(visibilityChanged(bool)), - terminalPanel, SLOT(dockVisibilityChanged())); + connect(terminalPanel, &TerminalPanel::hideTerminalPanel, terminalDock, &DolphinDockWidget::hide); + connect(terminalPanel, &TerminalPanel::changeUrl, this, &DolphinMainWindow::slotTerminalDirectoryChanged); + connect(terminalDock, &DolphinDockWidget::visibilityChanged, + terminalPanel, &TerminalPanel::dockVisibilityChanged); QAction* terminalAction = terminalDock->toggleViewAction(); - createPanelAction(KIcon("utilities-terminal"), Qt::Key_F4, terminalAction, "show_terminal_panel"); + createPanelAction(QIcon::fromTheme("utilities-terminal"), Qt::Key_F4, terminalAction, "show_terminal_panel"); addDockWidget(Qt::BottomDockWidgetArea, terminalDock); - connect(this, SIGNAL(urlChanged(KUrl)), - terminalPanel, SLOT(setUrl(KUrl))); + connect(this, &DolphinMainWindow::urlChanged, + terminalPanel, &TerminalPanel::setUrl); #endif if (GeneralSettings::version() < 200) { @@@ -1761,21 -1764,21 +1769,21 @@@ placesDock->setWidget(placesPanel); QAction* placesAction = placesDock->toggleViewAction(); - createPanelAction(KIcon("bookmarks"), Qt::Key_F9, placesAction, "show_places_panel"); + createPanelAction(QIcon::fromTheme("bookmarks"), Qt::Key_F9, placesAction, "show_places_panel"); addDockWidget(Qt::LeftDockWidgetArea, placesDock); - connect(placesPanel, SIGNAL(placeActivated(KUrl)), - this, SLOT(slotPlaceActivated(KUrl))); - connect(placesPanel, SIGNAL(placeMiddleClicked(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())); + connect(placesPanel, &PlacesPanel::placeActivated, + this, &DolphinMainWindow::slotPlaceActivated); + connect(placesPanel, &PlacesPanel::placeMiddleClicked, + this, static_cast(&DolphinMainWindow::openNewTab)); + connect(placesPanel, &PlacesPanel::errorMessage, + this, &DolphinMainWindow::slotPanelErrorMessage); + connect(this, &DolphinMainWindow::urlChanged, + placesPanel, &PlacesPanel::setUrl); + connect(placesDock, &DolphinDockWidget::visibilityChanged, + this, &DolphinMainWindow::slotPlacesPanelVisibilityChanged); + connect(this, &DolphinMainWindow::settingsChanged, + placesPanel, &PlacesPanel::readSettings); // Add actions into the "Panels" menu KActionMenu* panelsMenu = new KActionMenu(i18nc("@action:inmenu View", "Panels"), this); @@@ -1848,29 -1851,29 +1856,29 @@@ void DolphinMainWindow::createControlBu Q_ASSERT(!m_controlButton); m_controlButton = new QToolButton(this); - m_controlButton->setIcon(KIcon("applications-system")); + m_controlButton->setIcon(QIcon::fromTheme("applications-system")); m_controlButton->setText(i18nc("@action", "Control")); m_controlButton->setPopupMode(QToolButton::InstantPopup); m_controlButton->setToolButtonStyle(toolBar()->toolButtonStyle()); KMenu* controlMenu = new KMenu(m_controlButton); - connect(controlMenu, SIGNAL(aboutToShow()), this, SLOT(updateControlMenu())); + connect(controlMenu, &KMenu::aboutToShow, this, &DolphinMainWindow::updateControlMenu); m_controlButton->setMenu(controlMenu); toolBar()->addWidget(m_controlButton); - connect(toolBar(), SIGNAL(iconSizeChanged(QSize)), - m_controlButton, SLOT(setIconSize(QSize))); - connect(toolBar(), SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)), - m_controlButton, SLOT(setToolButtonStyle(Qt::ToolButtonStyle))); + connect(toolBar(), &KToolBar::iconSizeChanged, + m_controlButton, &QToolButton::setIconSize); + connect(toolBar(), &KToolBar::toolButtonStyleChanged, + m_controlButton, &QToolButton::setToolButtonStyle); // The added widgets are owned by the toolbar and may get deleted when e.g. the toolbar // gets edited. In this case we must add them again. The adding is done asynchronously by // m_updateToolBarTimer. - connect(m_controlButton, SIGNAL(destroyed()), this, SLOT(slotControlButtonDeleted())); + connect(m_controlButton, &QToolButton::destroyed, this, &DolphinMainWindow::slotControlButtonDeleted); m_updateToolBarTimer = new QTimer(this); m_updateToolBarTimer->setInterval(500); - connect(m_updateToolBarTimer, SIGNAL(timeout()), this, SLOT(updateToolBar())); + connect(m_updateToolBarTimer, &QTimer::timeout, this, &DolphinMainWindow::updateToolBar); } void DolphinMainWindow::deleteControlButton() @@@ -1900,10 -1903,10 +1908,10 @@@ bool DolphinMainWindow::addActionToMenu void DolphinMainWindow::rememberClosedTab(int index) { - KMenu* tabsMenu = m_recentTabsMenu->menu(); + QMenu* tabsMenu = m_recentTabsMenu->menu(); const QString primaryPath = m_viewTab[index].primaryView->url().path(); - const QString iconName = KMimeType::iconNameForUrl(primaryPath); + const QString iconName = KIO::iconNameForUrl(primaryPath); QAction* action = new QAction(squeezedText(primaryPath), tabsMenu); @@@ -1918,7 -1921,7 +1926,7 @@@ } action->setData(QVariant::fromValue(closedTab)); - action->setIcon(KIcon(iconName)); + action->setIcon(QIcon::fromTheme(iconName)); // add the closed tab menu entry after the separator and // "Empty Recently Closed Tabs" entry @@@ -1977,40 -1980,40 +1985,40 @@@ void DolphinMainWindow::clearStatusBar( void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container) { - connect(container, SIGNAL(showFilterBarChanged(bool)), - this, SLOT(updateFilterBarAction(bool))); - connect(container, SIGNAL(writeStateChanged(bool)), - this, SLOT(slotWriteStateChanged(bool))); + connect(container, &DolphinViewContainer::showFilterBarChanged, + this, &DolphinMainWindow::updateFilterBarAction); + connect(container, &DolphinViewContainer::writeStateChanged, + this, &DolphinMainWindow::slotWriteStateChanged); DolphinView* view = container->view(); - connect(view, SIGNAL(selectionChanged(KFileItemList)), - this, SLOT(slotSelectionChanged(KFileItemList))); - connect(view, SIGNAL(requestItemInfo(KFileItem)), - this, SLOT(slotRequestItemInfo(KFileItem))); - connect(view, SIGNAL(activated()), - this, SLOT(toggleActiveView())); - connect(view, SIGNAL(tabRequested(KUrl)), - this, SLOT(openNewTab(KUrl))); - connect(view, SIGNAL(requestContextMenu(QPoint,KFileItem,KUrl,QList)), - this, SLOT(openContextMenu(QPoint,KFileItem,KUrl,QList))); - connect(view, SIGNAL(directoryLoadingStarted()), - this, SLOT(enableStopAction())); - connect(view, SIGNAL(directoryLoadingCompleted()), - this, SLOT(disableStopAction())); - connect(view, SIGNAL(goBackRequested()), - this, SLOT(goBack())); - connect(view, SIGNAL(goForwardRequested()), - this, SLOT(goForward())); + connect(view, &DolphinView::selectionChanged, + this, &DolphinMainWindow::slotSelectionChanged); + connect(view, &DolphinView::requestItemInfo, + this, &DolphinMainWindow::slotRequestItemInfo); + connect(view, &DolphinView::activated, + this, &DolphinMainWindow::toggleActiveView); + connect(view, &DolphinView::tabRequested, + this, static_cast(&DolphinMainWindow::openNewTab)); + connect(view, &DolphinView::requestContextMenu, + this, &DolphinMainWindow::openContextMenu); + connect(view, &DolphinView::directoryLoadingStarted, + this, &DolphinMainWindow::enableStopAction); + connect(view, &DolphinView::directoryLoadingCompleted, + this, &DolphinMainWindow::disableStopAction); + connect(view, &DolphinView::goBackRequested, + this, static_cast(&DolphinMainWindow::goBack)); + connect(view, &DolphinView::goForwardRequested, + this, static_cast(&DolphinMainWindow::goForward)); const KUrlNavigator* navigator = container->urlNavigator(); - connect(navigator, SIGNAL(urlChanged(KUrl)), - this, SLOT(changeUrl(KUrl))); - connect(navigator, SIGNAL(historyChanged()), - this, SLOT(updateHistory())); - connect(navigator, SIGNAL(editableStateChanged(bool)), - this, SLOT(slotEditableStateChanged(bool))); - connect(navigator, SIGNAL(tabRequested(KUrl)), - this, SLOT(openNewTab(KUrl))); + connect(navigator, &KUrlNavigator::urlChanged, + this, &DolphinMainWindow::changeUrl); + connect(navigator, &KUrlNavigator::historyChanged, + this, &DolphinMainWindow::updateHistory); + connect(navigator, &KUrlNavigator::editableStateChanged, + this, &DolphinMainWindow::slotEditableStateChanged); + connect(navigator, &KUrlNavigator::tabRequested, + this, static_cast(&DolphinMainWindow::openNewTab)); } void DolphinMainWindow::updateSplitAction() @@@ -2020,16 -2023,16 +2028,16 @@@ if (m_activeViewContainer == m_viewTab[m_tabIndex].secondaryView) { splitAction->setText(i18nc("@action:intoolbar Close right view", "Close")); splitAction->setToolTip(i18nc("@info", "Close right view")); - splitAction->setIcon(KIcon("view-right-close")); + splitAction->setIcon(QIcon::fromTheme("view-right-close")); } else { splitAction->setText(i18nc("@action:intoolbar Close left view", "Close")); splitAction->setToolTip(i18nc("@info", "Close left view")); - splitAction->setIcon(KIcon("view-left-close")); + splitAction->setIcon(QIcon::fromTheme("view-left-close")); } } else { splitAction->setText(i18nc("@action:intoolbar Split view", "Split")); splitAction->setToolTip(i18nc("@info", "Split view")); - splitAction->setIcon(KIcon("view-right-new")); + splitAction->setIcon(QIcon::fromTheme("view-right-new")); } } @@@ -2115,20 -2118,20 +2123,20 @@@ QString DolphinMainWindow::squeezedText return fm.elidedText(text, Qt::ElideMiddle, fm.maxWidth() * 10); } -void DolphinMainWindow::createPanelAction(const KIcon& icon, +void DolphinMainWindow::createPanelAction(const QIcon& icon, const QKeySequence& shortcut, QAction* dockAction, const QString& actionName) { - KAction* panelAction = actionCollection()->addAction(actionName); + QAction* panelAction = actionCollection()->addAction(actionName); panelAction->setCheckable(true); panelAction->setChecked(dockAction->isChecked()); panelAction->setText(dockAction->text()); panelAction->setIcon(icon); panelAction->setShortcut(shortcut); - connect(panelAction, SIGNAL(triggered()), dockAction, SLOT(trigger())); - connect(dockAction, SIGNAL(toggled(bool)), panelAction, SLOT(setChecked(bool))); + connect(panelAction, &QAction::triggered, dockAction, &QAction::trigger); + connect(dockAction, &QAction::toggled, panelAction, &QAction::setChecked); } DolphinMainWindow::UndoUiInterface::UndoUiInterface() : diff --combined src/dolphinviewcontainer.cpp index ae9cd93c0,57452b9e4..761062585 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@@ -26,7 -26,6 +26,7 @@@ #include #include #include +#include #include #include @@@ -83,113 -82,90 +83,113 @@@ DolphinViewContainer::DolphinViewContai m_topLayout->setMargin(0); m_urlNavigator = new KUrlNavigator(new KFilePlacesModel(this), url, this); - connect(m_urlNavigator, SIGNAL(urlsDropped(KUrl,QDropEvent*)), - this, SLOT(dropUrls(KUrl,QDropEvent*))); - connect(m_urlNavigator, SIGNAL(activated()), - this, SLOT(activate())); - connect(m_urlNavigator->editor(), SIGNAL(completionModeChanged(KGlobalSettings::Completion)), - this, SLOT(saveUrlCompletionMode(KGlobalSettings::Completion))); + connect(m_urlNavigator, &KUrlNavigator::urlsDropped, + this, &DolphinViewContainer::dropUrls); + connect(m_urlNavigator, &KUrlNavigator::activated, + this, &DolphinViewContainer::activate); + connect(m_urlNavigator->editor(), &KUrlComboBox::completionModeChanged, + this, &DolphinViewContainer::saveUrlCompletionMode); const GeneralSettings* settings = GeneralSettings::self(); m_urlNavigator->setUrlEditable(settings->editableUrl()); m_urlNavigator->setShowFullPath(settings->showFullPath()); m_urlNavigator->setHomeUrl(KUrl(settings->homeUrl())); KUrlComboBox* editor = m_urlNavigator->editor(); - editor->setCompletionMode(KGlobalSettings::Completion(settings->urlCompletionMode())); + editor->setCompletionMode(KCompletion::CompletionMode(settings->urlCompletionMode())); m_searchBox = new DolphinSearchBox(this); m_searchBox->hide(); - connect(m_searchBox, SIGNAL(activated()), this, SLOT(activate())); - connect(m_searchBox, SIGNAL(closeRequest()), this, SLOT(closeSearchBox())); - connect(m_searchBox, SIGNAL(searchRequest()), this, SLOT(startSearching())); - connect(m_searchBox, SIGNAL(returnPressed(QString)), this, SLOT(requestFocus())); + connect(m_searchBox, &DolphinSearchBox::activated, this, &DolphinViewContainer::activate); + connect(m_searchBox, &DolphinSearchBox::closeRequest, this, &DolphinViewContainer::closeSearchBox); + connect(m_searchBox, &DolphinSearchBox::searchRequest, this, &DolphinViewContainer::startSearching); + connect(m_searchBox, &DolphinSearchBox::returnPressed, this, &DolphinViewContainer::requestFocus); m_messageWidget = new KMessageWidget(this); m_messageWidget->setCloseButtonVisible(true); m_messageWidget->hide(); m_view = new DolphinView(url, this); - connect(m_view, SIGNAL(urlChanged(KUrl)), m_urlNavigator, SLOT(setUrl(KUrl))); - connect(m_view, SIGNAL(urlChanged(KUrl)), m_messageWidget, SLOT(hide())); - connect(m_view, SIGNAL(writeStateChanged(bool)), this, SIGNAL(writeStateChanged(bool))); - connect(m_view, SIGNAL(requestItemInfo(KFileItem)), this, SLOT(showItemInfo(KFileItem))); - connect(m_view, SIGNAL(itemActivated(KFileItem)), this, SLOT(slotItemActivated(KFileItem))); - connect(m_view, SIGNAL(itemsActivated(KFileItemList)), this, SLOT(slotItemsActivated(KFileItemList))); - 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))); - connect(m_view, SIGNAL(selectionChanged(KFileItemList)), this, SLOT(delayedStatusBarUpdate())); - connect(m_view, SIGNAL(urlAboutToBeChanged(KUrl)), this, SLOT(slotViewUrlAboutToBeChanged(KUrl))); - connect(m_view, SIGNAL(errorMessage(QString)), this, SLOT(showErrorMessage(QString))); - connect(m_view, SIGNAL(urlIsFileError(KUrl)), this, SLOT(slotUrlIsFileError(KUrl))); - - connect(m_urlNavigator, SIGNAL(urlAboutToBeChanged(KUrl)), - this, SLOT(slotUrlNavigatorLocationAboutToBeChanged(KUrl))); - connect(m_urlNavigator, SIGNAL(urlChanged(KUrl)), - this, SLOT(slotUrlNavigatorLocationChanged(KUrl))); - connect(m_urlNavigator, SIGNAL(historyChanged()), - this, SLOT(slotHistoryChanged())); - connect(m_urlNavigator, SIGNAL(returnPressed()), - this, SLOT(slotReturnPressed())); + connect(m_view, &DolphinView::urlChanged, + m_urlNavigator, &KUrlNavigator::setUrl); + connect(m_view, &DolphinView::urlChanged, + m_messageWidget, &KMessageWidget::hide); + connect(m_view, &DolphinView::writeStateChanged, + this, &DolphinViewContainer::writeStateChanged); + connect(m_view, &DolphinView::requestItemInfo, + this, &DolphinViewContainer::showItemInfo); + connect(m_view, &DolphinView::itemActivated, + this, &DolphinViewContainer::slotItemActivated); + connect(m_view, &DolphinView::itemsActivated, + this, &DolphinViewContainer::slotItemsActivated); + connect(m_view, &DolphinView::redirection, + this, &DolphinViewContainer::redirect); + connect(m_view, &DolphinView::directoryLoadingStarted, + this, &DolphinViewContainer::slotDirectoryLoadingStarted); + connect(m_view, &DolphinView::directoryLoadingCompleted, + this, &DolphinViewContainer::slotDirectoryLoadingCompleted); + connect(m_view, &DolphinView::directoryLoadingCanceled, + this, &DolphinViewContainer::slotDirectoryLoadingCanceled); + connect(m_view, &DolphinView::itemCountChanged, + this, &DolphinViewContainer::delayedStatusBarUpdate); + connect(m_view, &DolphinView::directoryLoadingProgress, + this, &DolphinViewContainer::updateDirectoryLoadingProgress); + connect(m_view, &DolphinView::directorySortingProgress, + this, &DolphinViewContainer::updateDirectorySortingProgress); + connect(m_view, &DolphinView::selectionChanged, + this, &DolphinViewContainer::delayedStatusBarUpdate); + connect(m_view, &DolphinView::urlAboutToBeChanged, + this, &DolphinViewContainer::slotViewUrlAboutToBeChanged); + connect(m_view, &DolphinView::errorMessage, + this, &DolphinViewContainer::showErrorMessage); + connect(m_view, &DolphinView::urlIsFileError, + this, &DolphinViewContainer::slotUrlIsFileError); + + connect(m_urlNavigator, &KUrlNavigator::urlAboutToBeChanged, + this, &DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged); + connect(m_urlNavigator, &KUrlNavigator::urlChanged, + this, &DolphinViewContainer::slotUrlNavigatorLocationChanged); + connect(m_urlNavigator, &KUrlNavigator::historyChanged, + this, &DolphinViewContainer::slotHistoryChanged); + connect(m_urlNavigator, &KUrlNavigator::returnPressed, + this, &DolphinViewContainer::slotReturnPressed); // Initialize status bar m_statusBar = new DolphinStatusBar(this); m_statusBar->setUrl(m_view->url()); m_statusBar->setZoomLevel(m_view->zoomLevel()); - connect(m_view, SIGNAL(urlChanged(KUrl)), m_statusBar, SLOT(setUrl(KUrl))); - connect(m_view, SIGNAL(zoomLevelChanged(int,int)), m_statusBar, SLOT(setZoomLevel(int))); - connect(m_view, SIGNAL(infoMessage(QString)), m_statusBar, SLOT(setText(QString))); - connect(m_view, SIGNAL(operationCompletedMessage(QString)), m_statusBar, SLOT(setText(QString))); - connect(m_statusBar, SIGNAL(stopPressed()), this, SLOT(stopDirectoryLoading())); - connect(m_statusBar, SIGNAL(zoomLevelChanged(int)), this, SLOT(slotStatusBarZoomLevelChanged(int))); + connect(m_view, &DolphinView::urlChanged, + m_statusBar, &DolphinStatusBar::setUrl); + connect(m_view, &DolphinView::zoomLevelChanged, + m_statusBar, &DolphinStatusBar::setZoomLevel); + connect(m_view, &DolphinView::infoMessage, + m_statusBar, &DolphinStatusBar::setText); + connect(m_view, &DolphinView::operationCompletedMessage, + m_statusBar, &DolphinStatusBar::setText); + connect(m_statusBar, &DolphinStatusBar::stopPressed, + this, &DolphinViewContainer::stopDirectoryLoading); + connect(m_statusBar, &DolphinStatusBar::zoomLevelChanged, + this, &DolphinViewContainer::slotStatusBarZoomLevelChanged); m_statusBarTimer = new QTimer(this); m_statusBarTimer->setSingleShot(true); m_statusBarTimer->setInterval(300); - connect(m_statusBarTimer, SIGNAL(timeout()), this, SLOT(updateStatusBar())); + connect(m_statusBarTimer, &QTimer::timeout, this, &DolphinViewContainer::updateStatusBar); KIO::FileUndoManager* undoManager = KIO::FileUndoManager::self(); - connect(undoManager, SIGNAL(jobRecordingFinished(CommandType)), - this, SLOT(delayedStatusBarUpdate())); + connect(undoManager, &KIO::FileUndoManager::jobRecordingFinished, + this, &DolphinViewContainer::delayedStatusBarUpdate); // Initialize filter bar m_filterBar = new FilterBar(this); m_filterBar->setVisible(settings->filterBar()); - connect(m_filterBar, SIGNAL(filterChanged(QString)), - this, SLOT(setNameFilter(QString))); - connect(m_filterBar, SIGNAL(closeRequest()), - this, SLOT(closeFilterBar())); - connect(m_filterBar, SIGNAL(focusViewRequest()), - this, SLOT(requestFocus())); - connect(m_view, SIGNAL(urlChanged(KUrl)), - m_filterBar, SLOT(slotUrlChanged())); + connect(m_filterBar, &FilterBar::filterChanged, + this, &DolphinViewContainer::setNameFilter); + connect(m_filterBar, &FilterBar::closeRequest, + this, &DolphinViewContainer::closeFilterBar); + connect(m_filterBar, &FilterBar::focusViewRequest, + this, &DolphinViewContainer::requestFocus); + connect(m_view, &DolphinView::urlChanged, + m_filterBar, &FilterBar::slotUrlChanged); m_topLayout->addWidget(m_urlNavigator); m_topLayout->addWidget(m_searchBox); @@@ -338,36 -314,18 +338,18 @@@ void DolphinViewContainer::setSearchMod m_urlNavigator->setVisible(!enabled); if (enabled) { - KUrl url = m_urlNavigator->locationUrl(); - m_searchBox->setText(QString()); - m_searchBox->setReadOnly(isSearchUrl(url), url); - - // Remember the most recent non-search URL as search path - // of the search-box, so that it can be restored - // when switching back to the URL navigator. - int index = m_urlNavigator->historyIndex(); - const int historySize = m_urlNavigator->historySize(); - while (isSearchUrl(url) && (index < historySize)) { - ++index; - url = m_urlNavigator->locationUrl(index); - } - - if (!isSearchUrl(url)) { - m_searchBox->setSearchPath(url); - } + const KUrl& locationUrl = m_urlNavigator->locationUrl(); + m_searchBox->fromSearchUrl(locationUrl); } else { m_view->setViewPropertiesContext(QString()); // Restore the URL for the URL navigator. If Dolphin has been // started with a search-URL, the home URL is used as fallback. - const KUrl url = m_searchBox->searchPath(); - if (url.isValid() && !url.isEmpty()) { - if (isSearchUrl(url)) { - m_urlNavigator->goHome(); - } else { - m_urlNavigator->setLocationUrl(url); - } + KUrl url = m_searchBox->searchPath(); + if (url.isEmpty() || !url.isValid() || isSearchUrl(url)) { + url = GeneralSettings::self()->homeUrl(); } + m_urlNavigator->setLocationUrl(url); } } @@@ -516,7 -474,7 +498,7 @@@ void DolphinViewContainer::slotItemActi return; } - item.run(); + new KRun(item.targetUrl(), this); } void DolphinViewContainer::slotItemsActivated(const KFileItemList& items) @@@ -678,7 -636,7 +660,7 @@@ void DolphinViewContainer::requestFocus m_view->setFocus(); } -void DolphinViewContainer::saveUrlCompletionMode(KGlobalSettings::Completion completion) +void DolphinViewContainer::saveUrlCompletionMode(KCompletion::CompletionMode completion) { GeneralSettings::setUrlCompletionMode(completion); } diff --combined src/kitemviews/kfileitemmodel.cpp index 066af20f7,a0f9305cb..196172f1d --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@@ -25,7 -25,6 +25,7 @@@ #include #include #include +#include //TODO: port to QCollator #include "private/kfileitemmodelsortalgorithm.h" #include "private/kfileitemmodeldirlister.h" @@@ -69,17 -68,17 +69,17 @@@ KFileItemModel::KFileItemModel(QObject m_dirLister->setMainWindow(parentWidget->window()); } - connect(m_dirLister, SIGNAL(started(KUrl)), this, SIGNAL(directoryLoadingStarted())); - connect(m_dirLister, SIGNAL(canceled()), this, SLOT(slotCanceled())); - connect(m_dirLister, SIGNAL(completed(KUrl)), this, SLOT(slotCompleted())); - connect(m_dirLister, SIGNAL(itemsAdded(KUrl,KFileItemList)), this, SLOT(slotItemsAdded(KUrl,KFileItemList))); - connect(m_dirLister, SIGNAL(itemsDeleted(KFileItemList)), this, SLOT(slotItemsDeleted(KFileItemList))); - connect(m_dirLister, SIGNAL(refreshItems(QList >)), this, SLOT(slotRefreshItems(QList >))); - connect(m_dirLister, SIGNAL(clear()), this, SLOT(slotClear())); - connect(m_dirLister, SIGNAL(infoMessage(QString)), this, SIGNAL(infoMessage(QString))); - connect(m_dirLister, SIGNAL(errorMessage(QString)), this, SIGNAL(errorMessage(QString))); - connect(m_dirLister, SIGNAL(redirection(KUrl,KUrl)), this, SIGNAL(directoryRedirection(KUrl,KUrl))); - connect(m_dirLister, SIGNAL(urlIsFileError(KUrl)), this, SIGNAL(urlIsFileError(KUrl))); + connect(m_dirLister, &KFileItemModelDirLister::started, this, &KFileItemModel::directoryLoadingStarted); + connect(m_dirLister, static_cast(&KFileItemModelDirLister::canceled), this, &KFileItemModel::slotCanceled); + connect(m_dirLister, static_cast(&KFileItemModelDirLister::completed), this, &KFileItemModel::slotCompleted); + connect(m_dirLister, &KFileItemModelDirLister::itemsAdded, this, &KFileItemModel::slotItemsAdded); + connect(m_dirLister, &KFileItemModelDirLister::itemsDeleted, this, &KFileItemModel::slotItemsDeleted); + connect(m_dirLister, &KFileItemModelDirLister::refreshItems, this, &KFileItemModel::slotRefreshItems); + connect(m_dirLister, static_cast(&KFileItemModelDirLister::clear), this, &KFileItemModel::slotClear); + connect(m_dirLister, &KFileItemModelDirLister::infoMessage, this, &KFileItemModel::infoMessage); + connect(m_dirLister, &KFileItemModelDirLister::errorMessage, this, &KFileItemModel::errorMessage); + connect(m_dirLister, static_cast(&KFileItemModelDirLister::redirection), this, &KFileItemModel::directoryRedirection); + connect(m_dirLister, &KFileItemModelDirLister::urlIsFileError, this, &KFileItemModel::urlIsFileError); // Apply default roles that should be determined resetRoles(); @@@ -95,7 -94,7 +95,7 @@@ m_maximumUpdateIntervalTimer = new QTimer(this); m_maximumUpdateIntervalTimer->setInterval(2000); m_maximumUpdateIntervalTimer->setSingleShot(true); - connect(m_maximumUpdateIntervalTimer, SIGNAL(timeout()), this, SLOT(dispatchPendingItemsToInsert())); + connect(m_maximumUpdateIntervalTimer, &QTimer::timeout, this, &KFileItemModel::dispatchPendingItemsToInsert); // When changing the value of an item which represents the sort-role a resorting must be // triggered. Especially in combination with KFileItemModelRolesUpdater this might be done @@@ -104,10 -103,9 +104,10 @@@ m_resortAllItemsTimer = new QTimer(this); m_resortAllItemsTimer->setInterval(500); m_resortAllItemsTimer->setSingleShot(true); - connect(m_resortAllItemsTimer, SIGNAL(timeout()), this, SLOT(resortAllItems())); + connect(m_resortAllItemsTimer, &QTimer::timeout, this, &KFileItemModel::resortAllItems); - connect(KGlobalSettings::self(), SIGNAL(naturalSortingChanged()), this, SLOT(slotNaturalSortingChanged())); + connect(KGlobalSettings::self(), &KGlobalSettings::naturalSortingChanged, + this, &KFileItemModel::slotNaturalSortingChanged); } KFileItemModel::~KFileItemModel() @@@ -218,7 -216,7 +218,7 @@@ void KFileItemModel::setShowHiddenFiles m_dirLister->setShowingDotFiles(show); m_dirLister->emitChanges(); if (show) { - slotCompleted(); + dispatchPendingItemsToInsert(); } } @@@ -365,7 -363,7 +365,7 @@@ KFileItem KFileItemModel::fileItem(cons int KFileItemModel::index(const KFileItem& item) const { - return index(item.url()); + return index(KUrl(item.url())); } int KFileItemModel::index(const KUrl& url) const @@@ -868,7 -866,7 +868,7 @@@ void KFileItemModel::slotItemsAdded(con // might result in emitting the same items twice due to the Keep-parameter. // This case happens if an item gets expanded, collapsed and expanded again // before the items could be loaded for the first expansion. - if (index(items.first().url()) >= 0) { + if (index(KUrl(items.first().url())) >= 0) { // The items are already part of the model. return; } @@@ -1463,8 -1461,8 +1463,8 @@@ QHash KFileItemMo // Don't use KFileItem::timeString() as this is too expensive when // having several thousands of items. Instead the formatting of the // date-time will be done on-demand by the view when the date will be shown. - const KDateTime dateTime = item.time(KFileItem::ModificationTime); - data.insert(sharedValue("date"), dateTime.dateTime()); + const QDateTime dateTime = item.time(KFileItem::ModificationTime); + data.insert(sharedValue("date"), dateTime); } if (m_requestRole[PermissionsRole]) { @@@ -1489,7 -1487,7 +1489,7 @@@ if (m_requestRole[PathRole]) { QString path; - if (item.url().protocol() == QLatin1String("trash")) { + if (item.url().scheme() == QLatin1String("trash")) { path = item.entry().stringValue(KIO::UDSEntry::UDS_EXTRA); } else { // For performance reasons cache the home-path in a static QString @@@ -1668,8 -1666,8 +1668,8 @@@ int KFileItemModel::sortRoleCompare(con } case DateRole: { - const KDateTime dateTimeA = itemA.time(KFileItem::ModificationTime); - const KDateTime dateTimeB = itemB.time(KFileItem::ModificationTime); + const QDateTime dateTimeA = itemA.time(KFileItem::ModificationTime); + const QDateTime dateTimeB = itemB.time(KFileItem::ModificationTime); if (dateTimeA < dateTimeB) { result = -1; } else if (dateTimeA > dateTimeB) { @@@ -1861,7 -1859,7 +1861,7 @@@ QList > KFileItemM const int maxIndex = count() - 1; QList > groups; - const QDate currentDate = KDateTime::currentLocalDateTime().date(); + const QDate currentDate = QDate::currentDate(); QDate previousModifiedDate; QString groupValue; @@@ -1870,7 -1868,7 +1870,7 @@@ continue; } - const KDateTime modifiedTime = m_itemData.at(i)->item.time(KFileItem::ModificationTime); + const QDateTime modifiedTime = m_itemData.at(i)->item.time(KFileItem::ModificationTime); const QDate modifiedDate = modifiedTime.date(); if (modifiedDate == previousModifiedDate) { // The current item is in the same group as the previous item @@@ -1957,7 -1955,7 +1957,7 @@@ QList > KFileItemM } permissionsString = newPermissionsString; - const QFileInfo info(itemData->item.url().pathOrUrl()); + const QFileInfo info(itemData->item.url().toLocalFile()); // Set user string QString user; diff --combined src/kitemviews/kitemlistcontroller.cpp index f45537445,8e2ef5ef3..e90f301a9 --- a/src/kitemviews/kitemlistcontroller.cpp +++ b/src/kitemviews/kitemlistcontroller.cpp @@@ -61,15 -61,15 +61,15 @@@ KItemListController::KItemListControlle m_keyboardAnchorIndex(-1), m_keyboardAnchorPos(0) { - connect(m_keyboardManager, SIGNAL(changeCurrentItem(QString,bool)), - this, SLOT(slotChangeCurrentItem(QString,bool))); - connect(m_selectionManager, SIGNAL(currentChanged(int,int)), - m_keyboardManager, SLOT(slotCurrentChanged(int,int))); + connect(m_keyboardManager, &KItemListKeyboardSearchManager::changeCurrentItem, + this, &KItemListController::slotChangeCurrentItem); + connect(m_selectionManager, &KItemListSelectionManager::currentChanged, + m_keyboardManager, &KItemListKeyboardSearchManager::slotCurrentChanged); m_autoActivationTimer = new QTimer(this); m_autoActivationTimer->setSingleShot(true); m_autoActivationTimer->setInterval(-1); - connect(m_autoActivationTimer, SIGNAL(timeout()), this, SLOT(slotAutoActivationTimeout())); + connect(m_autoActivationTimer, &QTimer::timeout, this, &KItemListController::slotAutoActivationTimeout); setModel(model); setView(view); @@@ -127,7 -127,7 +127,7 @@@ void KItemListController::setView(KItem KItemListView* oldView = m_view; if (oldView) { - disconnect(oldView, SIGNAL(scrollOffsetChanged(qreal,qreal)), this, SLOT(slotViewScrollOffsetChanged(qreal,qreal))); + disconnect(oldView, &KItemListView::scrollOffsetChanged, this, &KItemListController::slotViewScrollOffsetChanged); oldView->deleteLater(); } @@@ -137,7 -137,7 +137,7 @@@ m_view->setParent(this); m_view->setController(this); m_view->setModel(m_model); - connect(m_view, SIGNAL(scrollOffsetChanged(qreal,qreal)), this, SLOT(slotViewScrollOffsetChanged(qreal,qreal))); + connect(m_view, &KItemListView::scrollOffsetChanged, this, &KItemListController::slotViewScrollOffsetChanged); updateExtendedSelectionRegion(); } @@@ -538,11 -538,10 +538,10 @@@ bool KItemListController::mousePressEve m_pressedIndex = m_view->itemAt(m_pressedMousePos); emit mouseButtonPressed(m_pressedIndex, event->buttons()); - if ((event->buttons() & (Qt::XButton1 | Qt::XButton2)) && m_pressedIndex < 0) { - // Do not select items when clicking the empty part of the view with - // the back/forward buttons, see https://bugs.kde.org/show_bug.cgi?id=327412. - // Note that clicking an item with these buttons selects it, see comment in - // DolphinView::slotMouseButtonPressed(int, Qt::MouseButtons). + // TODO: Qt5: Replace Qt::XButton1 by Qt::BackButton and Qt::XButton2 by Qt::ForwardButton + if (event->buttons() & (Qt::XButton1 | Qt::XButton2)) { + // Do not select items when clicking the back/forward buttons, see + // https://bugs.kde.org/show_bug.cgi?id=327412. return true; } @@@ -656,7 -655,7 +655,7 @@@ rubberBand->setStartPosition(startPos); rubberBand->setEndPosition(startPos); rubberBand->setActive(true); - connect(rubberBand, SIGNAL(endPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandChanged())); + connect(rubberBand, &KItemListRubberBand::endPositionChanged, this, &KItemListController::slotRubberBandChanged); m_view->setAutoScroll(true); } @@@ -744,7 -743,7 +743,7 @@@ bool KItemListController::mouseReleaseE KItemListRubberBand* rubberBand = m_view->rubberBand(); if (rubberBand->isActive()) { - disconnect(rubberBand, SIGNAL(endPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandChanged())); + disconnect(rubberBand, &KItemListRubberBand::endPositionChanged, this, &KItemListController::slotRubberBandChanged); rubberBand->setActive(false); m_oldSelection.clear(); m_view->setAutoScroll(false); @@@ -952,8 -951,13 +951,13 @@@ bool KItemListController::hoverMoveEven if (newHoveredWidget) { newHoveredWidget->setHovered(true); + const QPointF mappedPos = newHoveredWidget->mapFromItem(m_view, pos); + newHoveredWidget->setHoverPosition(mappedPos); emit itemHovered(newHoveredWidget->index()); } + } else if (oldHoveredWidget) { + const QPointF mappedPos = oldHoveredWidget->mapFromItem(m_view, pos); + oldHoveredWidget->setHoverPosition(mappedPos); } return false; diff --combined src/kitemviews/kitemlistview.cpp index abde53904,f1b35fa53..0090f8620 --- a/src/kitemviews/kitemlistview.cpp +++ b/src/kitemviews/kitemlistview.cpp @@@ -46,12 -46,7 +46,12 @@@ #include +#if 0 #include "kitemlistviewaccessible.h" +#else +#define QT_NO_ACCESSIBILITY 1 +#pragma message("TODO: port accessibility to Qt5") +#endif namespace { // Time in ms until reaching the autoscroll margin triggers @@@ -119,16 -114,16 +119,16 @@@ KItemListView::KItemListView(QGraphicsW m_layouter = new KItemListViewLayouter(m_sizeHintResolver, this); m_animation = new KItemListViewAnimation(this); - connect(m_animation, SIGNAL(finished(QGraphicsWidget*,KItemListViewAnimation::AnimationType)), - this, SLOT(slotAnimationFinished(QGraphicsWidget*,KItemListViewAnimation::AnimationType))); + connect(m_animation, &KItemListViewAnimation::finished, + this, &KItemListView::slotAnimationFinished); m_layoutTimer = new QTimer(this); m_layoutTimer->setInterval(300); m_layoutTimer->setSingleShot(true); - connect(m_layoutTimer, SIGNAL(timeout()), this, SLOT(slotLayoutTimerFinished())); + connect(m_layoutTimer, &QTimer::timeout, this, &KItemListView::slotLayoutTimerFinished); m_rubberBand = new KItemListRubberBand(this); - connect(m_rubberBand, SIGNAL(activationChanged(bool)), this, SLOT(slotRubberBandActivationChanged(bool))); + connect(m_rubberBand, &KItemListRubberBand::activationChanged, this, &KItemListView::slotRubberBandActivationChanged); m_headerWidget = new KItemListHeaderWidget(this); m_headerWidget->setVisible(false); @@@ -272,7 -267,7 +272,7 @@@ void KItemListView::setAutoScroll(bool if (enabled && !m_autoScrollTimer) { m_autoScrollTimer = new QTimer(this); m_autoScrollTimer->setSingleShot(true); - connect(m_autoScrollTimer, SIGNAL(timeout()), this, SLOT(triggerAutoScrolling())); + connect(m_autoScrollTimer, &QTimer::timeout, this, &KItemListView::triggerAutoScrolling); m_autoScrollTimer->start(InitialAutoScrollDelay); } else if (!enabled && m_autoScrollTimer) { delete m_autoScrollTimer; @@@ -577,26 -572,26 +577,26 @@@ void KItemListView::setHeaderVisible(bo m_headerWidget->setColumns(m_visibleRoles); m_headerWidget->setZValue(1); - connect(m_headerWidget, SIGNAL(columnWidthChanged(QByteArray,qreal,qreal)), - this, SLOT(slotHeaderColumnWidthChanged(QByteArray,qreal,qreal))); - connect(m_headerWidget, SIGNAL(columnMoved(QByteArray,int,int)), - this, SLOT(slotHeaderColumnMoved(QByteArray,int,int))); - connect(m_headerWidget, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)), - this, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder))); - connect(m_headerWidget, SIGNAL(sortRoleChanged(QByteArray,QByteArray)), - this, SIGNAL(sortRoleChanged(QByteArray,QByteArray))); + connect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged, + this, &KItemListView::slotHeaderColumnWidthChanged); + connect(m_headerWidget, &KItemListHeaderWidget::columnMoved, + this, &KItemListView::slotHeaderColumnMoved); + connect(m_headerWidget, &KItemListHeaderWidget::sortOrderChanged, + this, &KItemListView::sortOrderChanged); + connect(m_headerWidget, &KItemListHeaderWidget::sortRoleChanged, + this, &KItemListView::sortRoleChanged); m_layouter->setHeaderHeight(headerSize.height()); m_headerWidget->setVisible(true); } else if (!visible && m_headerWidget->isVisible()) { - disconnect(m_headerWidget, SIGNAL(columnWidthChanged(QByteArray,qreal,qreal)), - this, SLOT(slotHeaderColumnWidthChanged(QByteArray,qreal,qreal))); - disconnect(m_headerWidget, SIGNAL(columnMoved(QByteArray,int,int)), - this, SLOT(slotHeaderColumnMoved(QByteArray,int,int))); - disconnect(m_headerWidget, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)), - this, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder))); - disconnect(m_headerWidget, SIGNAL(sortRoleChanged(QByteArray,QByteArray)), - this, SIGNAL(sortRoleChanged(QByteArray,QByteArray))); + disconnect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged, + this, &KItemListView::slotHeaderColumnWidthChanged); + disconnect(m_headerWidget, &KItemListHeaderWidget::columnMoved, + this, &KItemListView::slotHeaderColumnMoved); + disconnect(m_headerWidget, &KItemListHeaderWidget::sortOrderChanged, + this, &KItemListView::sortOrderChanged); + disconnect(m_headerWidget, &KItemListHeaderWidget::sortRoleChanged, + this, &KItemListView::sortRoleChanged); m_layouter->setHeaderHeight(0); m_headerWidget->setVisible(false); @@@ -642,10 -637,10 +642,10 @@@ void KItemListView::editRole(int index m_editingRole = true; widget->setEditedRole(role); - connect(widget, SIGNAL(roleEditingCanceled(int,QByteArray,QVariant)), - this, SLOT(slotRoleEditingCanceled(int,QByteArray,QVariant))); - connect(widget, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)), - this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant))); + connect(widget, &KItemListWidget::roleEditingCanceled, + this, &KItemListView::slotRoleEditingCanceled); + connect(widget, &KItemListWidget::roleEditingFinished, + this, &KItemListView::slotRoleEditingFinished); } void KItemListView::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) @@@ -765,7 -760,8 +765,8 @@@ void KItemListView::setStyleOption(cons updateGroupHeaderHeight(); } - if (animate && previousOption.maxTextSize != option.maxTextSize) { + if (animate && + (previousOption.maxTextLines != option.maxTextLines || previousOption.maxTextWidth != option.maxTextWidth)) { // Animating a change of the maximum text size just results in expensive // temporary eliding and clipping operations and does not look good visually. animate = false; @@@ -898,11 -894,23 +899,23 @@@ void KItemListView::onTransactionEnd( bool KItemListView::event(QEvent* event) { - // Forward all events to the controller and handle them there - if (!m_editingRole && m_controller && m_controller->processEvent(event, transform())) { - event->accept(); - return true; + switch (event->type()) { + case QEvent::PaletteChange: + updatePalette(); + break; + + case QEvent::FontChange: + updateFont(); + break; + + default: + // Forward all other events to the controller and handle them there + if (!m_editingRole && m_controller && m_controller->processEvent(event, transform())) { + event->accept(); + return true; + } } + return QGraphicsWidget::event(event); } @@@ -955,6 -963,27 +968,27 @@@ QList KItemListView:: return m_visibleItems.values(); } + void KItemListView::updateFont() + { + if (scene() && !scene()->views().isEmpty()) { + KItemListStyleOption option = styleOption(); + option.font = scene()->views().first()->font(); + option.fontMetrics = QFontMetrics(option.font); + + setStyleOption(option); + } + } + + void KItemListView::updatePalette() + { + if (scene() && !scene()->views().isEmpty()) { + KItemListStyleOption option = styleOption(); + option.palette = scene()->views().first()->palette(); + + setStyleOption(option); + } + } + void KItemListView::slotItemsInserted(const KItemRangeList& itemRanges) { if (m_itemSize.isEmpty()) { @@@ -1234,8 -1263,7 +1268,8 @@@ void KItemListView::slotItemsChanged(co doLayout(NoAnimation); } } - QAccessible::updateAccessibility(this, 0, QAccessible::TableModelChanged); +#pragma message("TODO: port accessibility otherwise the following line asserts") + //QAccessible::updateAccessibility(this, 0, QAccessible::TableModelChanged); } void KItemListView::slotGroupsChanged() @@@ -1307,8 -1335,7 +1341,8 @@@ void KItemListView::slotCurrentChanged( if (currentWidget) { currentWidget->setCurrent(true); } - QAccessible::updateAccessibility(this, current+1, QAccessible::Focus); +#pragma message("TODO: port accessibility otherwise the following line asserts") + //QAccessible::updateAccessibility(this, current+1, QAccessible::Focus); } void KItemListView::slotSelectionChanged(const KItemSet& current, const KItemSet& previous) @@@ -1375,12 -1402,12 +1409,12 @@@ void KItemListView::slotRubberBandPosCh void KItemListView::slotRubberBandActivationChanged(bool active) { if (active) { - connect(m_rubberBand, SIGNAL(startPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandPosChanged())); - connect(m_rubberBand, SIGNAL(endPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandPosChanged())); + connect(m_rubberBand, &KItemListRubberBand::startPositionChanged, this, &KItemListView::slotRubberBandPosChanged); + connect(m_rubberBand, &KItemListRubberBand::endPositionChanged, this, &KItemListView::slotRubberBandPosChanged); m_skipAutoScrollForRubberBand = true; } else { - disconnect(m_rubberBand, SIGNAL(startPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandPosChanged())); - disconnect(m_rubberBand, SIGNAL(endPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandPosChanged())); + disconnect(m_rubberBand, &KItemListRubberBand::startPositionChanged, this, &KItemListView::slotRubberBandPosChanged); + disconnect(m_rubberBand, &KItemListRubberBand::endPositionChanged, this, &KItemListView::slotRubberBandPosChanged); m_skipAutoScrollForRubberBand = false; } @@@ -1507,16 -1534,16 +1541,16 @@@ void KItemListView::setController(KItem KItemListController* previous = m_controller; if (previous) { KItemListSelectionManager* selectionManager = previous->selectionManager(); - disconnect(selectionManager, SIGNAL(currentChanged(int,int)), this, SLOT(slotCurrentChanged(int,int))); - disconnect(selectionManager, SIGNAL(selectionChanged(KItemSet,KItemSet)), this, SLOT(slotSelectionChanged(KItemSet,KItemSet))); + disconnect(selectionManager, &KItemListSelectionManager::currentChanged, this, &KItemListView::slotCurrentChanged); + disconnect(selectionManager, &KItemListSelectionManager::selectionChanged, this, &KItemListView::slotSelectionChanged); } m_controller = controller; if (controller) { KItemListSelectionManager* selectionManager = controller->selectionManager(); - connect(selectionManager, SIGNAL(currentChanged(int,int)), this, SLOT(slotCurrentChanged(int,int))); - connect(selectionManager, SIGNAL(selectionChanged(KItemSet,KItemSet)), this, SLOT(slotSelectionChanged(KItemSet,KItemSet))); + connect(selectionManager, &KItemListSelectionManager::currentChanged, this, &KItemListView::slotCurrentChanged); + connect(selectionManager, &KItemListSelectionManager::selectionChanged, this, &KItemListView::slotSelectionChanged); } onControllerChanged(controller, previous); @@@ -1532,22 -1559,22 +1566,22 @@@ void KItemListView::setModel(KItemModel KItemModelBase* previous = m_model; if (m_model) { - disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet)), - this, SLOT(slotItemsChanged(KItemRangeList,QSet))); - disconnect(m_model, SIGNAL(itemsInserted(KItemRangeList)), - this, SLOT(slotItemsInserted(KItemRangeList))); - disconnect(m_model, SIGNAL(itemsRemoved(KItemRangeList)), - this, SLOT(slotItemsRemoved(KItemRangeList))); - disconnect(m_model, SIGNAL(itemsMoved(KItemRange,QList)), - this, SLOT(slotItemsMoved(KItemRange,QList))); - disconnect(m_model, SIGNAL(groupsChanged()), - this, SLOT(slotGroupsChanged())); - disconnect(m_model, SIGNAL(groupedSortingChanged(bool)), - this, SLOT(slotGroupedSortingChanged(bool))); - disconnect(m_model, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)), - this, SLOT(slotSortOrderChanged(Qt::SortOrder,Qt::SortOrder))); - disconnect(m_model, SIGNAL(sortRoleChanged(QByteArray,QByteArray)), - this, SLOT(slotSortRoleChanged(QByteArray,QByteArray))); + disconnect(m_model, &KItemModelBase::itemsChanged, + this, &KItemListView::slotItemsChanged); + disconnect(m_model, &KItemModelBase::itemsInserted, + this, &KItemListView::slotItemsInserted); + disconnect(m_model, &KItemModelBase::itemsRemoved, + this, &KItemListView::slotItemsRemoved); + disconnect(m_model, &KItemModelBase::itemsMoved, + this, &KItemListView::slotItemsMoved); + disconnect(m_model, &KItemModelBase::groupsChanged, + this, &KItemListView::slotGroupsChanged); + disconnect(m_model, &KItemModelBase::groupedSortingChanged, + this, &KItemListView::slotGroupedSortingChanged); + disconnect(m_model, &KItemModelBase::sortOrderChanged, + this, &KItemListView::slotSortOrderChanged); + disconnect(m_model, &KItemModelBase::sortRoleChanged, + this, &KItemListView::slotSortRoleChanged); m_sizeHintResolver->itemsRemoved(KItemRangeList() << KItemRange(0, m_model->count())); } @@@ -1557,22 -1584,22 +1591,22 @@@ m_grouped = model->groupedSorting(); if (m_model) { - connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet)), - this, SLOT(slotItemsChanged(KItemRangeList,QSet))); - connect(m_model, SIGNAL(itemsInserted(KItemRangeList)), - this, SLOT(slotItemsInserted(KItemRangeList))); - connect(m_model, SIGNAL(itemsRemoved(KItemRangeList)), - this, SLOT(slotItemsRemoved(KItemRangeList))); - connect(m_model, SIGNAL(itemsMoved(KItemRange,QList)), - this, SLOT(slotItemsMoved(KItemRange,QList))); - connect(m_model, SIGNAL(groupsChanged()), - this, SLOT(slotGroupsChanged())); - connect(m_model, SIGNAL(groupedSortingChanged(bool)), - this, SLOT(slotGroupedSortingChanged(bool))); - connect(m_model, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)), - this, SLOT(slotSortOrderChanged(Qt::SortOrder,Qt::SortOrder))); - connect(m_model, SIGNAL(sortRoleChanged(QByteArray,QByteArray)), - this, SLOT(slotSortRoleChanged(QByteArray,QByteArray))); + connect(m_model, &KItemModelBase::itemsChanged, + this, &KItemListView::slotItemsChanged); + connect(m_model, &KItemModelBase::itemsInserted, + this, &KItemListView::slotItemsInserted); + connect(m_model, &KItemModelBase::itemsRemoved, + this, &KItemListView::slotItemsRemoved); + connect(m_model, &KItemModelBase::itemsMoved, + this, &KItemListView::slotItemsMoved); + connect(m_model, &KItemModelBase::groupsChanged, + this, &KItemListView::slotGroupsChanged); + connect(m_model, &KItemModelBase::groupedSortingChanged, + this, &KItemListView::slotGroupedSortingChanged); + connect(m_model, &KItemModelBase::sortOrderChanged, + this, &KItemListView::slotSortOrderChanged); + connect(m_model, &KItemModelBase::sortRoleChanged, + this, &KItemListView::slotSortRoleChanged); const int itemCount = m_model->count(); if (itemCount > 0) { @@@ -1981,7 -2008,7 +2015,7 @@@ void KItemListView::updateGroupHeaderFo groupHeader = groupHeaderCreator()->create(this); groupHeader->setParentItem(widget); m_visibleGroups.insert(widget, groupHeader); - connect(widget, SIGNAL(geometryChanged()), this, SLOT(slotGeometryOfGroupHeaderParentChanged())); + connect(widget, &KItemListWidget::geometryChanged, this, &KItemListView::slotGeometryOfGroupHeaderParentChanged); } Q_ASSERT(groupHeader->parentItem() == widget); @@@ -2028,7 -2055,7 +2062,7 @@@ void KItemListView::recycleGroupHeaderF header->setParentItem(0); groupHeaderCreator()->recycle(header); m_visibleGroups.remove(widget); - disconnect(widget, SIGNAL(geometryChanged()), this, SLOT(slotGeometryOfGroupHeaderParentChanged())); + disconnect(widget, &KItemListWidget::geometryChanged, this, &KItemListView::slotGeometryOfGroupHeaderParentChanged); } } @@@ -2582,8 -2609,8 +2616,8 @@@ void KItemListView::disconnectRoleEditi return; } - widget->disconnect(SIGNAL(roleEditingCanceled(int,QByteArray,QVariant)), this); - widget->disconnect(SIGNAL(roleEditingFinished(int,QByteArray,QVariant)), this); + disconnect(widget, &KItemListWidget::roleEditingCanceled, this, nullptr); + disconnect(widget, &KItemListWidget::roleEditingFinished, this, nullptr); } int KItemListView::calculateAutoScrollingIncrement(int pos, int range, int oldInc) diff --combined src/kitemviews/kitemlistwidget.cpp index d02cbe3bb,44754a694..38f9d0078 --- a/src/kitemviews/kitemlistwidget.cpp +++ b/src/kitemviews/kitemlistwidget.cpp @@@ -252,7 -252,7 +252,7 @@@ void KItemListWidget::setHovered(bool h m_hoverAnimation = new QPropertyAnimation(this, "hoverOpacity", this); const int duration = (KGlobalSettings::graphicEffectsLevel() == KGlobalSettings::NoEffects) ? 1 : 200; m_hoverAnimation->setDuration(duration); - connect(m_hoverAnimation, SIGNAL(finished()), this, SLOT(slotHoverAnimationFinished())); + connect(m_hoverAnimation, &QPropertyAnimation::finished, this, &KItemListWidget::slotHoverAnimationFinished); } m_hoverAnimation->stop(); @@@ -279,6 -279,13 +279,13 @@@ bool KItemListWidget::isHovered() cons return m_hovered; } + void KItemListWidget::setHoverPosition(const QPointF& pos) + { + if (m_selectionToggle) { + m_selectionToggle->setHovered(m_selectionToggle->contains(pos)); + } + } + void KItemListWidget::setAlternateBackground(bool enable) { if (m_alternateBackground != enable) { diff --combined src/kitemviews/kstandarditemlistwidget.cpp index 18a5391bb,037226997..7a9f31a15 --- a/src/kitemviews/kstandarditemlistwidget.cpp +++ b/src/kitemviews/kstandarditemlistwidget.cpp @@@ -86,16 -86,22 +86,22 @@@ qreal KStandardItemListWidgetInformant: const QString text = roleText(role, values); qreal width = KStandardItemListWidget::columnPadding(option); + const QFontMetrics& normalFontMetrics = option.fontMetrics; + const QFontMetrics linkFontMetrics(customizedFontForLinks(option.font)); + if (role == "rating") { width += KStandardItemListWidget::preferredRatingSize(option).width(); } else { - width += option.fontMetrics.width(text); + // If current item is a link, we use the customized link font metrics instead of the normal font metrics. + const QFontMetrics& fontMetrics = itemIsLink(index, view) ? linkFontMetrics : normalFontMetrics; + + width += fontMetrics.width(text); if (role == "text") { if (view->supportsItemExpanding()) { // Increase the width by the expansion-toggle and the current expansion level const int expandedParentsCount = values.value("expandedParentsCount", 0).toInt(); - const qreal height = option.padding * 2 + qMax(option.iconSize, option.fontMetrics.height()); + const qreal height = option.padding * 2 + qMax(option.iconSize, fontMetrics.height()); width += (expandedParentsCount + 1) * height; } @@@ -112,6 -118,11 +118,11 @@@ QString KStandardItemListWidgetInforman return view->model()->data(index).value("text").toString(); } + bool KStandardItemListWidgetInformant::itemIsLink(int index, const KItemListView* view) const + { + return false; + } + QString KStandardItemListWidgetInformant::roleText(const QByteArray& role, const QHash& values) const { @@@ -122,18 -133,24 +133,24 @@@ return values.value(role).toString(); } + QFont KStandardItemListWidgetInformant::customizedFontForLinks(const QFont& baseFont) const + { + return baseFont; + } + void KStandardItemListWidgetInformant::calculateIconsLayoutItemSizeHints(QVector& sizeHints, const KItemListView* view) const { const KItemListStyleOption& option = view->styleOption(); - const QFont& font = option.font; + const QFont& normalFont = option.font; const int additionalRolesCount = qMax(view->visibleRoles().count() - 1, 0); const qreal itemWidth = view->itemSize().width(); const qreal maxWidth = itemWidth - 2 * option.padding; - const qreal maxTextHeight = option.maxTextSize.height(); const qreal additionalRolesSpacing = additionalRolesCount * option.fontMetrics.lineSpacing(); const qreal spacingAndIconHeight = option.iconSize + option.padding * 3; + const QFont linkFont = customizedFontForLinks(normalFont); + QTextOption textOption(Qt::AlignHCenter); textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); @@@ -142,6 -159,9 +159,9 @@@ continue; } + // If the current item is a link, we use the customized link font instead of the normal font. + const QFont& font = itemIsLink(index, view) ? linkFont : normalFont; + const QString& text = KStringHandler::preProcessWrap(itemText(index, view)); // Calculate the number of lines required for wrapping the name @@@ -150,20 -170,22 +170,22 @@@ layout.setTextOption(textOption); layout.beginLayout(); QTextLine line; + int lineCount = 0; while ((line = layout.createLine()).isValid()) { line.setLineWidth(maxWidth); line.naturalTextWidth(); textHeight += line.height(); + + ++lineCount; + if (lineCount == option.maxTextLines) { + break; + } } layout.endLayout(); // Add one line for each additional information textHeight += additionalRolesSpacing; - if (maxTextHeight > 0 && textHeight > maxTextHeight) { - textHeight = maxTextHeight; - } - sizeHints[index] = QSizeF(itemWidth, textHeight + spacingAndIconHeight); } } @@@ -171,20 -193,25 +193,25 @@@ void KStandardItemListWidgetInformant::calculateCompactLayoutItemSizeHints(QVector& sizeHints, const KItemListView* view) const { const KItemListStyleOption& option = view->styleOption(); - const QFontMetrics& fontMetrics = option.fontMetrics; + const QFontMetrics& normalFontMetrics = option.fontMetrics; const int additionalRolesCount = qMax(view->visibleRoles().count() - 1, 0); const QList& visibleRoles = view->visibleRoles(); const bool showOnlyTextRole = (visibleRoles.count() == 1) && (visibleRoles.first() == "text"); - const qreal maxWidth = option.maxTextSize.width(); + const qreal maxWidth = option.maxTextWidth; const qreal paddingAndIconWidth = option.padding * 4 + option.iconSize; - const qreal height = option.padding * 2 + qMax(option.iconSize, (1 + additionalRolesCount) * option.fontMetrics.lineSpacing()); + const qreal height = option.padding * 2 + qMax(option.iconSize, (1 + additionalRolesCount) * normalFontMetrics.lineSpacing()); + + const QFontMetrics linkFontMetrics(customizedFontForLinks(option.font)); for (int index = 0; index < sizeHints.count(); ++index) { if (!sizeHints.at(index).isEmpty()) { continue; } + // If the current item is a link, we use the customized link font metrics instead of the normal font metrics. + const QFontMetrics& fontMetrics = itemIsLink(index, view) ? linkFontMetrics : normalFontMetrics; + // For each row exactly one role is shown. Calculate the maximum required width that is necessary // to show all roles without horizontal clipping. qreal maximumRequiredWidth = 0.0; @@@ -631,6 -658,12 +658,12 @@@ void KStandardItemListWidget::dataChang dirtyRoles = roles; } + // The URL might have changed (i.e., if the sort order of the items has + // been changed). Therefore, the "is cut" state must be updated. + KFileItemClipboard* clipboard = KFileItemClipboard::instance(); + const KUrl itemUrl = data().value("url").value(); + m_isCut = clipboard->isCut(itemUrl); + // The icon-state might depend from other roles and hence is // marked as dirty whenever a role has been changed dirtyRoles.insert("iconPixmap"); @@@ -704,10 -737,10 +737,10 @@@ void KStandardItemListWidget::editedRol if (m_roleEditor) { emit roleEditingCanceled(index(), current, data().value(current)); - disconnect(m_roleEditor, SIGNAL(roleEditingCanceled(QByteArray,QVariant)), - this, SLOT(slotRoleEditingCanceled(QByteArray,QVariant))); - disconnect(m_roleEditor, SIGNAL(roleEditingFinished(QByteArray,QVariant)), - this, SLOT(slotRoleEditingFinished(QByteArray,QVariant))); + disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled, + this, &KStandardItemListWidget::slotRoleEditingCanceled); + disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished, + this, &KStandardItemListWidget::slotRoleEditingFinished); if (m_oldRoleEditor) { m_oldRoleEditor->deleteLater(); @@@ -742,10 -775,10 +775,10 @@@ m_roleEditor->setTextCursor(cursor); } - connect(m_roleEditor, SIGNAL(roleEditingCanceled(QByteArray,QVariant)), - this, SLOT(slotRoleEditingCanceled(QByteArray,QVariant))); - connect(m_roleEditor, SIGNAL(roleEditingFinished(QByteArray,QVariant)), - this, SLOT(slotRoleEditingFinished(QByteArray,QVariant))); + connect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled, + this, &KStandardItemListWidget::slotRoleEditingCanceled); + connect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished, + this, &KStandardItemListWidget::slotRoleEditingFinished); // Adjust the geometry of the editor QRectF rect = roleEditingRect(current); @@@ -782,14 -815,14 +815,14 @@@ void KStandardItemListWidget::showEvent const KUrl itemUrl = data().value("url").value(); m_isCut = clipboard->isCut(itemUrl); - connect(clipboard, SIGNAL(cutItemsChanged()), - this, SLOT(slotCutItemsChanged())); + connect(clipboard, &KFileItemClipboard::cutItemsChanged, + this, &KStandardItemListWidget::slotCutItemsChanged); } void KStandardItemListWidget::hideEvent(QHideEvent* event) { - disconnect(KFileItemClipboard::instance(), SIGNAL(cutItemsChanged()), - this, SLOT(slotCutItemsChanged())); + disconnect(KFileItemClipboard::instance(), &KFileItemClipboard::cutItemsChanged, + this, &KStandardItemListWidget::slotCutItemsChanged); KItemListWidget::hideEvent(event); } @@@ -1066,9 -1099,6 +1099,6 @@@ void KStandardItemListWidget::updateIco qreal nameHeight = 0; QTextLine line; - const int additionalRolesCount = qMax(visibleRoles().count() - 1, 0); - const int maxNameLines = (option.maxTextSize.height() / int(lineSpacing)) - additionalRolesCount; - QTextLayout layout(nameTextInfo->staticText.text(), m_customizedFont); layout.setTextOption(nameTextInfo->staticText.textOption()); layout.beginLayout(); @@@ -1079,7 -1109,7 +1109,7 @@@ nameHeight += line.height(); ++nameLineIndex; - if (nameLineIndex == maxNameLines) { + if (nameLineIndex == option.maxTextLines) { // The maximum number of textlines has been reached. If this is // the case provide an elided text if necessary. const int textLength = line.textStart() + line.textLength(); @@@ -1101,6 -1131,7 +1131,7 @@@ layout.endLayout(); // Use one line for each additional information + const int additionalRolesCount = qMax(visibleRoles().count() - 1, 0); nameTextInfo->staticText.setTextWidth(maxWidth); nameTextInfo->pos = QPointF(padding, widgetHeight - nameHeight - @@@ -1353,10 -1384,10 +1384,10 @@@ QRectF KStandardItemListWidget::roleEdi void KStandardItemListWidget::closeRoleEditor() { - disconnect(m_roleEditor, SIGNAL(roleEditingCanceled(QByteArray,QVariant)), - this, SLOT(slotRoleEditingCanceled(QByteArray,QVariant))); - disconnect(m_roleEditor, SIGNAL(roleEditingFinished(QByteArray,QVariant)), - this, SLOT(slotRoleEditingFinished(QByteArray,QVariant))); + disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled, + this, &KStandardItemListWidget::slotRoleEditingCanceled); + disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished, + this, &KStandardItemListWidget::slotRoleEditingFinished); if (m_roleEditor->hasFocus()) { // If the editing was not ended by a FocusOut event, we have diff --combined src/kitemviews/private/kdirectorycontentscounter.cpp index 0e43dea2e,7d1e76999..cd448e233 --- a/src/kitemviews/private/kdirectorycontentscounter.cpp +++ b/src/kitemviews/private/kdirectorycontentscounter.cpp @@@ -35,8 -35,8 +35,8 @@@ KDirectoryContentsCounter::KDirectoryCo m_dirWatcher(0), m_watchedDirs() { - connect(m_model, SIGNAL(itemsRemoved(KItemRangeList)), - this, SLOT(slotItemsRemoved())); + connect(m_model, &KFileItemModel::itemsRemoved, + this, &KDirectoryContentsCounter::slotItemsRemoved); if (!m_workerThread) { m_workerThread = new QThread(); @@@ -47,27 -47,36 +47,36 @@@ m_worker->moveToThread(m_workerThread); ++m_workersCount; - connect(this, SIGNAL(requestDirectoryContentsCount(QString,KDirectoryContentsCounterWorker::Options)), - m_worker, SLOT(countDirectoryContents(QString,KDirectoryContentsCounterWorker::Options))); - connect(m_worker, SIGNAL(result(QString,int)), - this, SLOT(slotResult(QString,int))); + connect(this, &KDirectoryContentsCounter::requestDirectoryContentsCount, + m_worker, &KDirectoryContentsCounterWorker::countDirectoryContents); + connect(m_worker, &KDirectoryContentsCounterWorker::result, + this, &KDirectoryContentsCounter::slotResult); m_dirWatcher = new KDirWatch(this); - connect(m_dirWatcher, SIGNAL(dirty(QString)), this, SLOT(slotDirWatchDirty(QString))); + connect(m_dirWatcher, &KDirWatch::dirty, this, &KDirectoryContentsCounter::slotDirWatchDirty); } KDirectoryContentsCounter::~KDirectoryContentsCounter() { --m_workersCount; - if (m_workersCount == 0) { + if (m_workersCount > 0) { + // The worker thread will continue running. It could even be running + // a method of m_worker at the moment, so we delete it using + // deleteLater() to prevent a crash. + m_worker->deleteLater(); + } else { + // There are no remaining workers -> stop the worker thread. m_workerThread->quit(); m_workerThread->wait(); delete m_workerThread; m_workerThread = 0; - } - delete m_worker; + // The worker thread has finished running now, so it's safe to delete + // m_worker. deleteLater() would not work at all because the event loop + // which would deliver the event to m_worker is not running any more. + delete m_worker; + } } void KDirectoryContentsCounter::addDirectory(const QString& path) diff --combined src/kitemviews/private/kitemlistviewanimation.cpp index 1ddeb2b19,5a00c8c3a..43eed98c5 --- a/src/kitemviews/private/kitemlistviewanimation.cpp +++ b/src/kitemviews/private/kitemlistviewanimation.cpp @@@ -172,7 -172,7 +172,7 @@@ void KItemListViewAnimation::start(QGra } Q_ASSERT(propertyAnim); - connect(propertyAnim, SIGNAL(finished()), this, SLOT(slotFinished())); + connect(propertyAnim, &QPropertyAnimation::finished, this, &KItemListViewAnimation::slotFinished); m_animation[type].insert(widget, propertyAnim); propertyAnim->start(); @@@ -225,13 -225,13 +225,13 @@@ void KItemListViewAnimation::slotFinish { QPropertyAnimation* finishedAnim = qobject_cast(sender()); for (int type = 0; type < AnimationTypeCount; ++type) { - QHashIterator it(m_animation[type]); + QMutableHashIterator it(m_animation[type]); while (it.hasNext()) { it.next(); QPropertyAnimation* propertyAnim = it.value(); if (propertyAnim == finishedAnim) { QGraphicsWidget* widget = it.key(); - m_animation[type].remove(widget); + it.remove(); finishedAnim->deleteLater(); emit finished(widget, static_cast(type)); diff --combined src/panels/information/informationpanelcontent.cpp index fd58eb608,4fb0d9442..9dc59db13 --- a/src/panels/information/informationpanelcontent.cpp +++ b/src/panels/information/informationpanelcontent.cpp @@@ -24,10 -24,8 +24,10 @@@ #include #include #include +#include #include #include +#include #include #include #include @@@ -83,8 -81,8 +83,8 @@@ InformationPanelContent::InformationPan m_outdatedPreviewTimer = new QTimer(this); m_outdatedPreviewTimer->setInterval(300); m_outdatedPreviewTimer->setSingleShot(true); - connect(m_outdatedPreviewTimer, SIGNAL(timeout()), - this, SLOT(markOutdatedPreview())); + connect(m_outdatedPreviewTimer, &QTimer::timeout, + this, &InformationPanelContent::markOutdatedPreview); QVBoxLayout* layout = new QVBoxLayout(this); layout->setSpacing(KDialog::spacingHint()); @@@ -99,8 -97,8 +99,8 @@@ m_phononWidget = new PhononWidget(parent); m_phononWidget->hide(); m_phononWidget->setMinimumWidth(minPreviewWidth); - connect(m_phononWidget, SIGNAL(hasVideoChanged(bool)), - this, SLOT(slotHasVideoChanged(bool))); + connect(m_phononWidget, &PhononWidget::hasVideoChanged, + this, &InformationPanelContent::slotHasVideoChanged); // name m_nameLabel = new QLabel(parent); @@@ -116,15 -114,12 +116,15 @@@ #ifndef HAVE_BALOO m_metaDataWidget = new KFileMetaDataWidget(parent); + connect(m_metaDataWidget, &KFileMetaDataWidget::urlActivated, + this, &InformationPanelContent::urlActivated); #else m_metaDataWidget = new Baloo::FileMetaDataWidget(parent); + connect(m_metaDataWidget, &Baloo::FileMetaDataWidget::urlActivated, + this, &InformationPanelContent::urlActivated); #endif m_metaDataWidget->setFont(KGlobalSettings::smallestReadableFont()); m_metaDataWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); - connect(m_metaDataWidget, SIGNAL(urlActivated(KUrl)), this, SIGNAL(urlActivated(KUrl))); // Encapsulate the MetaDataWidget inside a container that has a dummy widget // at the bottom. This prevents that the meta data widget gets vertically stretched @@@ -198,13 -193,13 +198,13 @@@ void InformationPanelContent::showItem( m_previewJob->setScaleType(KIO::PreviewJob::Unscaled); m_previewJob->setIgnoreMaximumSize(item.isLocalFile()); if (m_previewJob->ui()) { - m_previewJob->ui()->setWindow(this); + KJobWidgets::setWindow(m_previewJob, this); } - connect(m_previewJob, SIGNAL(gotPreview(KFileItem,QPixmap)), - this, SLOT(showPreview(KFileItem,QPixmap))); - connect(m_previewJob, SIGNAL(failed(KFileItem)), - this, SLOT(showIcon(KFileItem))); + connect(m_previewJob.data(), &KIO::PreviewJob::gotPreview, + this, &InformationPanelContent::showPreview); + connect(m_previewJob.data(), &KIO::PreviewJob::failed, + this, &InformationPanelContent::showIcon); } } @@@ -276,6 -271,10 +276,10 @@@ bool InformationPanelContent::eventFilt adjustWidgetSizes(parentWidget()->width()); break; + case QEvent::FontChange: + m_metaDataWidget->setFont(KGlobalSettings::smallestReadableFont()); + break; + default: break; } @@@ -288,7 -287,7 +292,7 @@@ void InformationPanelContent::configure KMenu popup(this); QAction* previewAction = popup.addAction(i18nc("@action:inmenu", "Preview")); - previewAction->setIcon(KIcon("view-preview")); + previewAction->setIcon(QIcon::fromTheme("view-preview")); previewAction->setCheckable(true); previewAction->setChecked(InformationPanelSettings::previewsShown()); @@@ -320,7 -319,7 +324,7 @@@ dialog->show(); dialog->raise(); dialog->activateWindow(); - connect(dialog, SIGNAL(destroyed()), this, SLOT(refreshMetaData())); + connect(dialog, &FileMetaDataConfigurationDialog::destroyed, this, &InformationPanelContent::refreshMetaData); } } diff --combined src/panels/places/placesitemmodel.cpp index 1f8a213e3,1f05e07f9..6ba91c5ba --- a/src/panels/places/placesitemmodel.cpp +++ b/src/panels/places/placesitemmodel.cpp @@@ -35,7 -35,6 +35,7 @@@ #include #include #include +#include #include "placesitem.h" #include #include @@@ -99,17 -98,17 +99,17 @@@ PlacesItemModel::PlacesItemModel(QObjec m_saveBookmarksTimer = new QTimer(this); m_saveBookmarksTimer->setInterval(syncBookmarksTimeout); m_saveBookmarksTimer->setSingleShot(true); - connect(m_saveBookmarksTimer, SIGNAL(timeout()), this, SLOT(saveBookmarks())); + connect(m_saveBookmarksTimer, &QTimer::timeout, this, &PlacesItemModel::saveBookmarks); m_updateBookmarksTimer = new QTimer(this); m_updateBookmarksTimer->setInterval(syncBookmarksTimeout); m_updateBookmarksTimer->setSingleShot(true); - connect(m_updateBookmarksTimer, SIGNAL(timeout()), this, SLOT(updateBookmarks())); + connect(m_updateBookmarksTimer, &QTimer::timeout, this, &PlacesItemModel::updateBookmarks); - connect(m_bookmarkManager, SIGNAL(changed(QString,QString)), - m_updateBookmarksTimer, SLOT(start())); - connect(m_bookmarkManager, SIGNAL(bookmarksChanged(QString)), - m_updateBookmarksTimer, SLOT(start())); + connect(m_bookmarkManager, &KBookmarkManager::changed, + m_updateBookmarksTimer, static_cast(&QTimer::start)); + connect(m_bookmarkManager, &KBookmarkManager::bookmarksChanged, + m_updateBookmarksTimer, static_cast(&QTimer::start)); } PlacesItemModel::~PlacesItemModel() @@@ -313,8 -312,8 +313,8 @@@ void PlacesItemModel::requestEject(int if (item) { Solid::OpticalDrive* drive = item->device().parent().as(); if (drive) { - connect(drive, SIGNAL(ejectDone(Solid::ErrorType,QVariant,QString)), - this, SLOT(slotStorageTeardownDone(Solid::ErrorType,QVariant))); + connect(drive, &Solid::OpticalDrive::ejectDone, + this, &PlacesItemModel::slotStorageTeardownDone); drive->eject(); } else { const QString label = item->text(); @@@ -330,8 -329,8 +330,8 @@@ void PlacesItemModel::requestTeardown(i if (item) { Solid::StorageAccess* access = item->device().as(); if (access) { - connect(access, SIGNAL(teardownDone(Solid::ErrorType,QVariant,QString)), - this, SLOT(slotStorageTeardownDone(Solid::ErrorType,QVariant))); + connect(access, &Solid::StorageAccess::teardownDone, + this, &PlacesItemModel::slotStorageTeardownDone); access->teardown(); } } @@@ -359,8 -358,8 +359,8 @@@ void PlacesItemModel::requestStorageSet m_storageSetupInProgress[access] = index; - connect(access, SIGNAL(setupDone(Solid::ErrorType,QVariant,QString)), - this, SLOT(slotStorageSetupDone(Solid::ErrorType,QVariant,QString))); + connect(access, &Solid::StorageAccess::setupDone, + this, &PlacesItemModel::slotStorageSetupDone); access->setup(); } @@@ -651,6 -650,7 +651,7 @@@ void PlacesItemModel::updateBookmarks( found = true; if (newBookmark.metaDataItem("UDI").isEmpty()) { item->setBookmark(newBookmark); + item->setText(i18nc("KFile System Bookmarks", newBookmark.text().toUtf8().data())); } break; } @@@ -968,8 -968,8 +969,8 @@@ void PlacesItemModel::initializeAvailab Q_ASSERT(m_predicate.isValid()); Solid::DeviceNotifier* notifier = Solid::DeviceNotifier::instance(); - connect(notifier, SIGNAL(deviceAdded(QString)), this, SLOT(slotDeviceAdded(QString))); - connect(notifier, SIGNAL(deviceRemoved(QString)), this, SLOT(slotDeviceRemoved(QString))); + connect(notifier, &Solid::DeviceNotifier::deviceAdded, this, &PlacesItemModel::slotDeviceAdded); + connect(notifier, &Solid::DeviceNotifier::deviceRemoved, this, &PlacesItemModel::slotDeviceRemoved); const QList& deviceList = Solid::Device::listFromQuery(m_predicate); foreach (const Solid::Device& device, deviceList) { diff --combined src/panels/places/placespanel.cpp index 1f825426e,f19fa1e25..d3614c9ce --- a/src/panels/places/placespanel.cpp +++ b/src/panels/places/placespanel.cpp @@@ -30,9 -30,7 +30,9 @@@ #include #include #include +#include #include +#include #include #include #include @@@ -50,7 -48,6 +50,7 @@@ #include #include #include +#include PlacesPanel::PlacesPanel(QWidget* parent) : Panel(parent), @@@ -104,8 -101,8 +104,8 @@@ void PlacesPanel::showEvent(QShowEvent // used at all and stays invisible. m_model = new PlacesItemModel(this); m_model->setGroupedSorting(true); - connect(m_model, SIGNAL(errorMessage(QString)), - this, SIGNAL(errorMessage(QString))); + connect(m_model, &PlacesItemModel::errorMessage, + this, &PlacesPanel::errorMessage); m_view = new PlacesView(); m_view->setWidgetCreator(new KItemListWidgetCreator()); @@@ -117,12 -114,12 +117,12 @@@ 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))); - connect(m_controller, SIGNAL(viewContextMenuRequested(QPointF)), this, SLOT(slotViewContextMenuRequested(QPointF))); - connect(m_controller, SIGNAL(itemDropEvent(int,QGraphicsSceneDragDropEvent*)), this, SLOT(slotItemDropEvent(int,QGraphicsSceneDragDropEvent*))); - connect(m_controller, SIGNAL(aboveItemDropEvent(int,QGraphicsSceneDragDropEvent*)), this, SLOT(slotAboveItemDropEvent(int,QGraphicsSceneDragDropEvent*))); + connect(m_controller, &KItemListController::itemActivated, this, &PlacesPanel::slotItemActivated); + connect(m_controller, &KItemListController::itemMiddleClicked, this, &PlacesPanel::slotItemMiddleClicked); + connect(m_controller, &KItemListController::itemContextMenuRequested, this, &PlacesPanel::slotItemContextMenuRequested); + connect(m_controller, &KItemListController::viewContextMenuRequested, this, &PlacesPanel::slotViewContextMenuRequested); + connect(m_controller, &KItemListController::itemDropEvent, this, &PlacesPanel::slotItemDropEvent); + connect(m_controller, &KItemListController::aboveItemDropEvent, this, &PlacesPanel::slotAboveItemDropEvent); KItemListContainer* container = new KItemListContainer(m_controller, this); container->setEnabledFrame(false); @@@ -286,8 -283,9 +286,9 @@@ void PlacesPanel::slotItemContextMenuRe } else if (action == hideAction) { item->setHidden(hideAction->isChecked()); } else if (action == openInNewTabAction) { - const KUrl url = m_model->item(index)->dataValue("url").value(); - emit placeMiddleClicked(url); + // TriggerItem does set up the storage first and then it will + // emit the slotItemMiddleClicked signal, because of Qt::MiddleButton. + triggerItem(index, Qt::MiddleButton); } else if (action == teardownAction) { m_model->requestTeardown(index); } else if (action == ejectAction) { @@@ -342,8 -340,8 +343,8 @@@ void PlacesPanel::slotItemDropEvent(in } if (m_model->storageSetupNeeded(index)) { - connect(m_model, SIGNAL(storageSetupDone(int,bool)), - this, SLOT(slotItemDropEventStorageSetupDone(int,bool))); + connect(m_model, &PlacesItemModel::storageSetupDone, + this, &PlacesPanel::slotItemDropEventStorageSetupDone); m_itemDropEventIndex = index; @@@ -381,8 -379,8 +382,8 @@@ void PlacesPanel::slotItemDropEventStorageSetupDone(int index, bool success) { - disconnect(m_model, SIGNAL(storageSetupDone(int,bool)), - this, SLOT(slotItemDropEventStorageSetupDone(int,bool))); + disconnect(m_model, &PlacesItemModel::storageSetupDone, + this, &PlacesPanel::slotItemDropEventStorageSetupDone); if ((index == m_itemDropEventIndex) && m_itemDropEvent && m_itemDropEventMimeData) { if (success) { @@@ -425,13 -423,13 +426,13 @@@ void PlacesPanel::slotTrashUpdated(KJob if (job->error()) { emit errorMessage(job->errorString()); } - org::kde::KDirNotify::emitFilesAdded("trash:/"); + org::kde::KDirNotify::emitFilesAdded(QUrl("trash:/")); } void PlacesPanel::slotStorageSetupDone(int index, bool success) { - disconnect(m_model, SIGNAL(storageSetupDone(int,bool)), - this, SLOT(slotStorageSetupDone(int,bool))); + disconnect(m_model, &PlacesItemModel::storageSetupDone, + this, &PlacesPanel::slotStorageSetupDone); if (m_triggerStorageSetupButton == Qt::NoButton) { return; @@@ -462,8 -460,8 +463,8 @@@ void PlacesPanel::emptyTrash( stream << int(1); KIO::Job *job = KIO::special(KUrl("trash:/"), packedArgs); KNotification::event("Trash: emptied", QString() , QPixmap() , 0, KNotification::DefaultEvent); - job->ui()->setWindow(parentWidget()); - connect(job, SIGNAL(result(KJob*)), SLOT(slotTrashUpdated(KJob*))); + KJobWidgets::setWindow(job, parentWidget()); + connect(job, &KIO::Job::result, this, &PlacesPanel::slotTrashUpdated); } } @@@ -526,8 -524,8 +527,8 @@@ void PlacesPanel::triggerItem(int index m_triggerStorageSetupButton = button; m_storageSetupFailedUrl = url(); - connect(m_model, SIGNAL(storageSetupDone(int,bool)), - this, SLOT(slotStorageSetupDone(int,bool))); + connect(m_model, &PlacesItemModel::storageSetupDone, + this, &PlacesPanel::slotStorageSetupDone); m_model->requestStorageSetup(index); } else { diff --combined src/search/dolphinfacetswidget.cpp index 4fd2eb30b,f20ae68d5..fa46a50e8 --- a/src/search/dolphinfacetswidget.cpp +++ b/src/search/dolphinfacetswidget.cpp @@@ -46,13 -46,16 +46,16 @@@ DolphinFacetsWidget::DolphinFacetsWidge m_fourOrMore(0), m_maxRating(0) { - m_documents = createCheckBox(i18nc("@option:check", "Documents")); - m_images = createCheckBox(i18nc("@option:check", "Images")); - m_audio = createCheckBox(i18nc("@option:check", "Audio Files")); - m_videos = createCheckBox(i18nc("@option:check", "Videos")); + QButtonGroup* filetypeGroup = new QButtonGroup(this); + m_anyType = createRadioButton(i18nc("@option:check", "Any"), filetypeGroup); + m_documents = createRadioButton(i18nc("@option:check", "Documents"), filetypeGroup); + m_images = createRadioButton(i18nc("@option:check", "Images"), filetypeGroup); + m_audio = createRadioButton(i18nc("@option:check", "Audio Files"), filetypeGroup); + m_videos = createRadioButton(i18nc("@option:check", "Videos"), filetypeGroup); QVBoxLayout* typeLayout = new QVBoxLayout(); typeLayout->setSpacing(0); + typeLayout->addWidget(m_anyType); typeLayout->addWidget(m_documents); typeLayout->addWidget(m_images); typeLayout->addWidget(m_audio); @@@ -100,6 -103,7 +103,7 @@@ topLayout->addLayout(ratingLayout); topLayout->addStretch(); + m_anyType->setChecked(true); m_anytime->setChecked(true); m_anyRating->setChecked(true); } @@@ -111,6 -115,9 +115,9 @@@ DolphinFacetsWidget::~DolphinFacetsWidg #ifdef HAVE_BALOO Baloo::Term DolphinFacetsWidget::ratingTerm() const { + Baloo::Term ratingTerm; + Baloo::Term modifiedTerm; + if (!m_anyRating->isChecked()) { int stars = 1; // represents m_oneOrMore if (m_twoOrMore->isChecked()) { @@@ -124,15 -131,9 +131,9 @@@ } const int rating = stars * 2; - - Baloo::Term term("rating", rating, Baloo::Term::GreaterEqual); - return term; + ratingTerm = Baloo::Term("rating", rating, Baloo::Term::GreaterEqual); } - return Baloo::Term(); - - /* - // FIXME: Handle date time filters if (!m_anytime->isChecked()) { QDate date = QDate::currentDate(); // represents m_today if (m_yesterday->isChecked()) { @@@ -145,51 -146,156 +146,156 @@@ date = date.addDays(1 - date.dayOfYear()); } - Nepomuk2::Query::ComparisonTerm term(Nepomuk2::Vocabulary::NIE::lastModified(), - Nepomuk2::Query::LiteralTerm(QDateTime(date)), - Nepomuk2::Query::ComparisonTerm::GreaterOrEqual); - andTerm.addSubTerm(term); + modifiedTerm = Baloo::Term("modified", date, Baloo::Term::GreaterEqual); } - */ + + if (ratingTerm.isValid() && modifiedTerm.isValid()) { + Baloo::Term term(Baloo::Term::And); + term.addSubTerm(ratingTerm); + term.addSubTerm(modifiedTerm); + + return term; + } else if (modifiedTerm.isValid()) { + return modifiedTerm; + } else if (ratingTerm.isValid()) { + return ratingTerm; + } + + return Baloo::Term(); } - QStringList DolphinFacetsWidget::facetTypes() const + QString DolphinFacetsWidget::facetType() const { - QStringList types; if (m_documents->isChecked()) { - types << "Document"; + return QLatin1String("Document"); + } else if (m_images->isChecked()) { + return QLatin1String("Image"); + } else if (m_audio->isChecked()) { + return QLatin1String("Audio"); + } else if (m_videos->isChecked()) { + return QLatin1String("Video"); } - if (m_images->isChecked()) { - types << "Image"; - } + return QString(); + } + + bool DolphinFacetsWidget::isRatingTerm(const Baloo::Term& term) const + { + const QList subTerms = term.subTerms(); + if (subTerms.isEmpty()) { + // If term has no sub terms, then the term itself is either a "rating" term + // or a "modified" term. + return term.property() == QLatin1String("modified") || + term.property() == QLatin1String("rating"); - if (m_audio->isChecked()) { - types << "Audio"; + } else if (subTerms.size() == 2) { + // If term has sub terms, then the sub terms are always "rating" and "modified" terms. + + QStringList properties; + foreach (const Baloo::Term& subTerm, subTerms) { + properties << subTerm.property(); + } + + return properties.contains(QLatin1String("modified")) && + properties.contains(QLatin1String("rating")); } - if (m_videos->isChecked()) { - types << "Video"; + return false; + } + + void DolphinFacetsWidget::setRatingTerm(const Baloo::Term& term) + { + // If term has sub terms, then the sub terms are always "rating" and "modified" terms. + // If term has no sub terms, then the term itself is either a "rating" term or a "modified" + // term. To avoid code duplication we add term to subTerms list, if the list is empty. + QList subTerms = term.subTerms(); + if (subTerms.isEmpty()) { + subTerms << term; } - return types; + foreach (const Baloo::Term& subTerm, subTerms) { + const QString property = subTerm.property(); + + if (property == QLatin1String("modified")) { + const QDate date = subTerm.value().toDate(); + setTimespan(date); + } else if (property == QLatin1String("rating")) { + const int stars = subTerm.value().toInt() / 2; + setRating(stars); + } + } } #endif + void DolphinFacetsWidget::setFacetType(const QString& type) + { + if (type == QLatin1String("Document")) { + m_documents->setChecked(true); + } else if (type == QLatin1String("Image")) { + m_images->setChecked(true); + } else if (type == QLatin1String("Audio")) { + m_audio->setChecked(true); + } else if (type == QLatin1String("Video")) { + m_videos->setChecked(true); + } else { + m_anyType->setChecked(true); + } + } - QCheckBox* DolphinFacetsWidget::createCheckBox(const QString& text) + void DolphinFacetsWidget::setRating(const int stars) { - QCheckBox* checkBox = new QCheckBox(text); - connect(checkBox, &QCheckBox::clicked, this, &DolphinFacetsWidget::facetChanged); - return checkBox; + switch (stars) { + case 5: + m_maxRating->setChecked(true); + break; + + case 4: + m_fourOrMore->setChecked(true); + break; + + case 3: + m_threeOrMore->setChecked(true); + break; + + case 2: + m_twoOrMore->setChecked(true); + break; + + case 1: + m_oneOrMore->setChecked(true); + break; + + default: + m_anyRating->setChecked(true); + } + } + + void DolphinFacetsWidget::setTimespan(const QDate& date) + { + const QDate currentDate = QDate::currentDate(); + const int days = date.daysTo(currentDate); + + if (days <= 0) { + m_today->setChecked(true); + } else if (days <= 1) { + m_yesterday->setChecked(true); + } else if (days <= currentDate.dayOfWeek()) { + m_thisWeek->setChecked(true); + } else if (days <= currentDate.day()) { + m_thisMonth->setChecked(true); + } else if (days <= currentDate.dayOfYear()) { + m_thisYear->setChecked(true); + } else { + m_anytime->setChecked(true); + } } QRadioButton* DolphinFacetsWidget::createRadioButton(const QString& text, QButtonGroup* group) { QRadioButton* button = new QRadioButton(text); - connect(button, SIGNAL(clicked()), this, SIGNAL(facetChanged())); + connect(button, &QRadioButton::clicked, this, &DolphinFacetsWidget::facetChanged); group->addButton(button); return button; } diff --combined src/search/dolphinsearchbox.cpp index d47996a78,46ca01a4c..f9942f98e --- a/src/search/dolphinsearchbox.cpp +++ b/src/search/dolphinsearchbox.cpp @@@ -26,7 -26,6 +26,7 @@@ #include #include #include +#include #include #include @@@ -50,7 -49,6 +50,6 @@@ DolphinSearchBox::DolphinSearchBox(QWidget* parent) : QWidget(parent), m_startedSearching(false), - m_readOnly(false), m_active(true), m_topLayout(0), m_searchLabel(0), @@@ -64,7 -62,6 +63,6 @@@ m_facetsToggleButton(0), m_facetsWidget(0), m_searchPath(), - m_readOnlyQuery(), m_startSearchTimer(0) { } @@@ -103,7 -100,7 +101,7 @@@ void DolphinSearchBox::setSearchPath(co const QString elidedLocation = metrics.elidedText(location, Qt::ElideMiddle, maxWidth); m_fromHereButton->setText(i18nc("action:button", "From Here (%1)", elidedLocation)); - const bool showSearchFromButtons = url.isLocalFile() && !m_readOnly; + const bool showSearchFromButtons = url.isLocalFile(); m_separator->setVisible(showSearchFromButtons); m_fromHereButton->setVisible(showSearchFromButtons); m_everywhereButton->setVisible(showSearchFromButtons); @@@ -153,23 -150,24 +151,24 @@@ KUrl DolphinSearchBox::urlForSearching( return url; } - void DolphinSearchBox::selectAll() - { - m_searchInput->selectAll(); - } - - void DolphinSearchBox::setReadOnly(bool readOnly, const KUrl& query) + void DolphinSearchBox::fromSearchUrl(const KUrl& url) { - if (m_readOnly != readOnly || m_readOnlyQuery != query) { - m_readOnly = readOnly; - m_readOnlyQuery = query; - applyReadOnlyState(); + if (url.protocol() == "baloosearch") { + fromBalooSearchUrl(url); + } else if (url.protocol() == "filenamesearch") { + const QMap& queryItems = url.queryItems(); + setText(queryItems.value("search")); + setSearchPath(queryItems.value("url")); + m_contentButton->setChecked(queryItems.value("checkContent") == "yes"); + } else { + setText(QString()); + setSearchPath(url); } } - bool DolphinSearchBox::isReadOnly() const + void DolphinSearchBox::selectAll() { - return m_readOnly; + m_searchInput->selectAll(); } void DolphinSearchBox::setActive(bool active) @@@ -289,7 -287,7 +288,7 @@@ void DolphinSearchBox::initButton(QTool button->setAutoExclusive(true); button->setAutoRaise(true); button->setCheckable(true); - connect(button, SIGNAL(clicked(bool)), this, SLOT(slotConfigurationChanged())); + connect(button, &QToolButton::clicked, this, &DolphinSearchBox::slotConfigurationChanged); } void DolphinSearchBox::loadSettings() @@@ -324,7 -322,7 +323,7 @@@ void DolphinSearchBox::init( closeButton->setAutoRaise(true); closeButton->setIcon(KIcon("dialog-close")); closeButton->setToolTip(i18nc("@info:tooltip", "Quit searching")); - connect(closeButton, SIGNAL(clicked()), this, SLOT(emitCloseRequest())); + connect(closeButton, &QToolButton::clicked, this, &DolphinSearchBox::emitCloseRequest); // Create search label m_searchLabel = new QLabel(this); @@@ -335,10 -333,10 +334,10 @@@ m_searchInput->setClearButtonShown(true); m_searchInput->setFont(KGlobalSettings::generalFont()); setFocusProxy(m_searchInput); - connect(m_searchInput, SIGNAL(returnPressed(QString)), - this, SLOT(slotReturnPressed(QString))); - connect(m_searchInput, SIGNAL(textChanged(QString)), - this, SLOT(slotSearchTextChanged(QString))); + connect(m_searchInput, static_cast(&KLineEdit::returnPressed), + this, &DolphinSearchBox::slotReturnPressed); + connect(m_searchInput, &KLineEdit::textChanged, + this, &DolphinSearchBox::slotSearchTextChanged); // Apply layout for the search input QHBoxLayout* searchInputLayout = new QHBoxLayout(); @@@ -379,12 -377,12 +378,12 @@@ m_facetsToggleButton = new QToolButton(this); m_facetsToggleButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); initButton(m_facetsToggleButton); - connect(m_facetsToggleButton, SIGNAL(clicked()), this, SLOT(slotFacetsButtonToggled())); + connect(m_facetsToggleButton, &QToolButton::clicked, this, &DolphinSearchBox::slotFacetsButtonToggled); m_facetsWidget = new DolphinFacetsWidget(this); m_facetsWidget->installEventFilter(this); m_facetsWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); - connect(m_facetsWidget, SIGNAL(facetChanged()), this, SLOT(slotFacetChanged())); + connect(m_facetsWidget, &DolphinFacetsWidget::facetChanged, this, &DolphinSearchBox::slotFacetChanged); // Apply layout for the options QHBoxLayout* optionsLayout = new QHBoxLayout(); @@@ -424,10 -422,9 +423,9 @@@ m_startSearchTimer = new QTimer(this); m_startSearchTimer->setSingleShot(true); m_startSearchTimer->setInterval(1000); - connect(m_startSearchTimer, SIGNAL(timeout()), this, SLOT(emitSearchRequest())); + connect(m_startSearchTimer, &QTimer::timeout, this, &DolphinSearchBox::emitSearchRequest); updateFacetsToggleButton(); - applyReadOnlyState(); } KUrl DolphinSearchBox::balooUrlForSearching() const @@@ -437,7 -434,7 +435,7 @@@ Baloo::Query query; query.addType("File"); - query.addTypes(m_facetsWidget->facetTypes()); + query.addType(m_facetsWidget->facetType()); Baloo::Term term(Baloo::Term::And); @@@ -448,14 -445,16 +446,16 @@@ if (m_contentButton->isChecked()) { query.setSearchString(text); - } else { - term.addSubTerm(Baloo::Term("filename", text)); + } else if (!text.isEmpty()) { + term.addSubTerm(Baloo::Term(QLatin1String("filename"), text)); } if (m_fromHereButton->isChecked()) { query.addCustomOption("includeFolder", m_searchPath.toLocalFile()); } + query.setTerm(term); + return query.toSearchUrl(i18nc("@title UDS_DISPLAY_NAME for a KIO directory listing. %1 is the query the user entered.", "Query Results from '%1'", text)); #else @@@ -463,26 -462,46 +463,46 @@@ #endif } - void DolphinSearchBox::applyReadOnlyState() + void DolphinSearchBox::fromBalooSearchUrl(const KUrl& url) { #ifdef HAVE_BALOO - if (m_readOnly) { - m_searchLabel->setText(Baloo::Query::titleFromQueryUrl(m_readOnlyQuery)); + const Baloo::Query query = Baloo::Query::fromSearchUrl(url); + const Baloo::Term term = query.term(); + + // Block all signals to avoid unnecessary "searchRequest" signals + // while we adjust the search text and the facet widget. + blockSignals(true); + + const QVariantHash customOptions = query.customOptions(); + if (customOptions.contains("includeFolder")) { + setSearchPath(customOptions.value("includeFolder").toString()); } else { - #else - { - #endif - m_searchLabel->setText(i18nc("@label:textbox", "Find:")); + setSearchPath(QDir::homePath()); } - m_searchInput->setVisible(!m_readOnly); - m_optionsScrollArea->setVisible(!m_readOnly); + if (!query.searchString().isEmpty()) { + setText(query.searchString()); + } - if (m_readOnly) { - m_facetsWidget->hide(); - } else { - m_facetsWidget->setVisible(SearchSettings::showFacetsWidget()); + QStringList types = query.types(); + types.removeOne("File"); // We are only interested in facet widget types + if (!types.isEmpty()) { + m_facetsWidget->setFacetType(types.first()); } + + foreach (const Baloo::Term& subTerm, term.subTerms()) { + const QString property = subTerm.property(); + + if (property == QLatin1String("filename")) { + setText(subTerm.value().toString()); + } else if (m_facetsWidget->isRatingTerm(subTerm)) { + m_facetsWidget->setRatingTerm(subTerm); + } + } + + m_startSearchTimer->stop(); + blockSignals(false); + #endif } void DolphinSearchBox::updateFacetsToggleButton() diff --combined src/search/filenamesearchprotocol.cpp index fd56f68b7,fd7f09a88..3333dcc07 --- a/src/search/filenamesearchprotocol.cpp +++ b/src/search/filenamesearchprotocol.cpp @@@ -25,7 -25,6 +25,7 @@@ #include #include #include +#include #include #include @@@ -45,22 -44,22 +45,22 @@@ FileNameSearchProtocol::~FileNameSearch cleanup(); } -void FileNameSearchProtocol::listDir(const KUrl& url) +void FileNameSearchProtocol::listDir(const QUrl& url) { cleanup(); - const QString search = url.queryItem("search"); + const QString search = url.queryItemValue("search"); if (!search.isEmpty()) { m_regExp = new QRegExp(search, Qt::CaseInsensitive, QRegExp::Wildcard); } m_checkContent = false; - const QString checkContent = url.queryItem("checkContent"); + const QString checkContent = url.queryItemValue("checkContent"); if (checkContent == QLatin1String("yes")) { m_checkContent = true; } - const QString urlString = url.queryItem("url"); + const QString urlString = url.queryItemValue("url"); searchDirectory(KUrl(urlString)); cleanup(); @@@ -81,8 -80,8 +81,8 @@@ void FileNameSearchProtocol::searchDire dirLister->openUrl(directory); QEventLoop eventLoop; - QObject::connect(dirLister, SIGNAL(canceled()), &eventLoop, SLOT(quit())); - QObject::connect(dirLister, SIGNAL(completed()), &eventLoop, SLOT(quit())); + QObject::connect(dirLister, static_cast(&KDirLister::canceled), &eventLoop, &QEventLoop::quit); + QObject::connect(dirLister, static_cast(&KDirLister::completed), &eventLoop, &QEventLoop::quit); eventLoop.exec(); // Visualize all items that match the search pattern @@@ -92,8 -91,11 +92,11 @@@ bool addItem = false; if (!m_regExp || item.name().contains(*m_regExp)) { addItem = true; - } else if (m_checkContent && item.mimetype().startsWith(QLatin1String("text/"))) { - } else if (m_checkContent && item.determineMimeType()->is(QLatin1String("text/plain"))) { ++ } else if (m_checkContent && item.determineMimeType().inherits(QLatin1String("text/plain"))) { + qDebug() << "### Checking" << item; addItem = contentContainsPattern(item.url()); + } else { + qDebug() << "### NOT Checking" << item; } if (addItem) { diff --combined src/statusbar/dolphinstatusbar.cpp index 79355fb55,169395e63..9f17c8ecd --- a/src/statusbar/dolphinstatusbar.cpp +++ b/src/statusbar/dolphinstatusbar.cpp @@@ -72,8 -72,9 +72,9 @@@ DolphinStatusBar::DolphinStatusBar(QWid m_zoomSlider->setPageStep(1); m_zoomSlider->setRange(ZoomLevelInfo::minimumLevel(), ZoomLevelInfo::maximumLevel()); - connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SIGNAL(zoomLevelChanged(int))); - connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(updateZoomSliderToolTip(int))); - connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(showZoomSliderToolTip(int))); + connect(m_zoomSlider, &QSlider::valueChanged, this, &DolphinStatusBar::zoomLevelChanged); ++ connect(m_zoomSlider, &QSlider::valueChanged, this, &DolphinStatusBar::updateZoomSliderToolTip); + connect(m_zoomSlider, &QSlider::sliderMoved, this, &DolphinStatusBar::showZoomSliderToolTip); // Initialize space information m_spaceInfo = new StatusBarSpaceInfo(this); @@@ -85,7 -86,7 +86,7 @@@ m_stopButton->setAutoRaise(true); m_stopButton->setToolTip(i18nc("@tooltip", "Stop loading")); m_stopButton->hide(); - connect(m_stopButton, SIGNAL(clicked()), this, SIGNAL(stopPressed())); + connect(m_stopButton, &QToolButton::clicked, this, &DolphinStatusBar::stopPressed); m_progressTextLabel = new QLabel(this); m_progressTextLabel->hide(); @@@ -96,12 -97,12 +97,12 @@@ m_showProgressBarTimer = new QTimer(this); m_showProgressBarTimer->setInterval(500); m_showProgressBarTimer->setSingleShot(true); - connect(m_showProgressBarTimer, SIGNAL(timeout()), this, SLOT(updateProgressInfo())); + connect(m_showProgressBarTimer, &QTimer::timeout, this, &DolphinStatusBar::updateProgressInfo); m_resetToDefaultTextTimer = new QTimer(this); m_resetToDefaultTextTimer->setInterval(ResetToDefaultTimeout); m_resetToDefaultTextTimer->setSingleShot(true); - connect(m_resetToDefaultTextTimer, SIGNAL(timeout()), this, SLOT(slotResetToDefaultText())); + connect(m_resetToDefaultTextTimer, &QTimer::timeout, this, &DolphinStatusBar::slotResetToDefaultText); // Initialize top layout and size policies const int fontHeight = QFontMetrics(m_label->font()).height(); @@@ -240,7 -241,6 +241,6 @@@ void DolphinStatusBar::setZoomLevel(in { if (zoomLevel != m_zoomSlider->value()) { m_zoomSlider->setValue(zoomLevel); - updateZoomSliderToolTip(zoomLevel); } } @@@ -338,6 -338,12 +338,12 @@@ void DolphinStatusBar::slotResetToDefau updateLabelText(); } + void DolphinStatusBar::updateZoomSliderToolTip(int zoomLevel) + { + const int size = ZoomLevelInfo::iconSizeForZoomLevel(zoomLevel); + m_zoomSlider->setToolTip(i18ncp("@info:tooltip", "Size: 1 pixel", "Size: %1 pixels", size)); + } + void DolphinStatusBar::setExtensionsVisible(bool visible) { bool showSpaceInfo = visible; @@@ -350,10 -356,4 +356,4 @@@ m_zoomSlider->setVisible(showZoomSlider); } - void DolphinStatusBar::updateZoomSliderToolTip(int zoomLevel) - { - const int size = ZoomLevelInfo::iconSizeForZoomLevel(zoomLevel); - m_zoomSlider->setToolTip(i18ncp("@info:tooltip", "Size: 1 pixel", "Size: %1 pixels", size)); - } - #include "dolphinstatusbar.moc" diff --combined src/views/dolphinitemlistview.cpp index 26148f61f,db4dadf2f..9f600e43f --- a/src/views/dolphinitemlistview.cpp +++ b/src/views/dolphinitemlistview.cpp @@@ -31,7 -31,6 +31,7 @@@ #include #include +#include #include @@@ -145,6 -144,26 +145,26 @@@ void DolphinItemListView::onVisibleRole updateGridSize(); } + void DolphinItemListView::updateFont() + { + const ViewModeSettings settings(viewMode()); + + if (settings.useSystemFont()) { + KItemListView::updateFont(); + } else { + QFont font(settings.fontFamily(), qRound(settings.fontSize())); + font.setItalic(settings.italicFont()); + font.setWeight(settings.fontWeight()); + font.setPointSizeF(settings.fontSize()); + + KItemListStyleOption option = styleOption(); + option.font = font; + option.fontMetrics = QFontMetrics(font); + + setStyleOption(option); + } + } + void DolphinItemListView::updateGridSize() { const ViewModeSettings settings(viewMode()); @@@ -161,7 -180,8 +181,8 @@@ // Calculate the item-width and item-height int itemWidth; int itemHeight; - QSize maxTextSize; + int maxTextLines = 0; + int maxTextWidth = 0; switch (itemLayout()) { case KFileItemListView::IconsLayout: { @@@ -181,16 -201,10 +202,10 @@@ } itemHeight = padding * 3 + iconSize + option.fontMetrics.lineSpacing(); - if (IconsModeSettings::maximumTextLines() > 0) { - // A restriction is given for the maximum number of textlines (0 means - // having no restriction) - const int additionalInfoCount = visibleRoles().count() - 1; - const int maxAdditionalLines = additionalInfoCount + IconsModeSettings::maximumTextLines(); - maxTextSize.rheight() = option.fontMetrics.lineSpacing() * maxAdditionalLines; - } horizontalMargin = 4; verticalMargin = 8; + maxTextLines = IconsModeSettings::maximumTextLines(); break; } case KFileItemListView::CompactLayout: { @@@ -201,8 -215,7 +216,7 @@@ if (CompactModeSettings::maximumTextWidthIndex() > 0) { // A restriction is given for the maximum width of the text (0 means // having no restriction) - maxTextSize.rwidth() = option.fontMetrics.height() * 10 * - CompactModeSettings::maximumTextWidthIndex(); + maxTextWidth = option.fontMetrics.height() * 10 * CompactModeSettings::maximumTextWidthIndex(); } horizontalMargin = 8; @@@ -225,30 -238,14 +239,14 @@@ option.horizontalMargin = horizontalMargin; option.verticalMargin = verticalMargin; option.iconSize = iconSize; - option.maxTextSize = maxTextSize; + option.maxTextLines = maxTextLines; + option.maxTextWidth = maxTextWidth; beginTransaction(); setStyleOption(option); setItemSize(QSizeF(itemWidth, itemHeight)); endTransaction(); } - void DolphinItemListView::updateFont() - { - KItemListStyleOption option = styleOption(); - - const ViewModeSettings settings(viewMode()); - - QFont font(settings.fontFamily(), qRound(settings.fontSize())); - font.setItalic(settings.italicFont()); - font.setWeight(settings.fontWeight()); - font.setPointSizeF(settings.fontSize()); - - option.font = font; - option.fontMetrics = QFontMetrics(font); - - setStyleOption(option); - } - ViewModeSettings::ViewMode DolphinItemListView::viewMode() const { ViewModeSettings::ViewMode mode; diff --combined src/views/dolphinview.cpp index 247b10bc8,c1f585da9..0e43dcda1 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@@ -32,8 -32,6 +32,8 @@@ #include #include #include +#include +#include #include #include @@@ -57,9 -55,7 +57,9 @@@ #include #include #include +#include #include +#include #include #include #include @@@ -118,14 -114,14 +118,14 @@@ DolphinView::DolphinView(const KUrl& ur // When a new item has been created by the "Create New..." menu, the item should // get selected and it must be assured that the item will get visible. As the // creation is done asynchronously, several signals must be checked: - connect(&DolphinNewFileMenuObserver::instance(), SIGNAL(itemCreated(KUrl)), - this, SLOT(observeCreatedItem(KUrl))); + connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::itemCreated, + this, &DolphinView::observeCreatedItem); m_selectionChangedTimer = new QTimer(this); m_selectionChangedTimer->setSingleShot(true); m_selectionChangedTimer->setInterval(300); - connect(m_selectionChangedTimer, SIGNAL(timeout()), - this, SLOT(emitSelectionChangedSignal())); + connect(m_selectionChangedTimer, &QTimer::timeout, + this, &DolphinView::emitSelectionChangedSignal); m_model = new KFileItemModel(this); m_view = new DolphinItemListView(); @@@ -144,60 -140,60 +144,60 @@@ m_container = new KItemListContainer(controller, this); m_container->installEventFilter(this); setFocusProxy(m_container); - connect(m_container->horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(hideToolTip())); - connect(m_container->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(hideToolTip())); + connect(m_container->horizontalScrollBar(), &QScrollBar::valueChanged, this, &DolphinView::hideToolTip); + connect(m_container->verticalScrollBar(), &QScrollBar::valueChanged, this, &DolphinView::hideToolTip); controller->setSelectionBehavior(KItemListController::MultiSelection); - connect(controller, SIGNAL(itemActivated(int)), this, SLOT(slotItemActivated(int))); - connect(controller, SIGNAL(itemsActivated(KItemSet)), this, SLOT(slotItemsActivated(KItemSet))); - connect(controller, SIGNAL(itemMiddleClicked(int)), this, SLOT(slotItemMiddleClicked(int))); - connect(controller, SIGNAL(itemContextMenuRequested(int,QPointF)), this, SLOT(slotItemContextMenuRequested(int,QPointF))); - connect(controller, SIGNAL(viewContextMenuRequested(QPointF)), this, SLOT(slotViewContextMenuRequested(QPointF))); - connect(controller, SIGNAL(headerContextMenuRequested(QPointF)), this, SLOT(slotHeaderContextMenuRequested(QPointF))); - connect(controller, SIGNAL(mouseButtonPressed(int,Qt::MouseButtons)), this, SLOT(slotMouseButtonPressed(int,Qt::MouseButtons))); - connect(controller, SIGNAL(itemHovered(int)), this, SLOT(slotItemHovered(int))); - connect(controller, SIGNAL(itemUnhovered(int)), this, SLOT(slotItemUnhovered(int))); - connect(controller, SIGNAL(itemDropEvent(int,QGraphicsSceneDragDropEvent*)), this, SLOT(slotItemDropEvent(int,QGraphicsSceneDragDropEvent*))); - connect(controller, SIGNAL(escapePressed()), this, SLOT(stopLoading())); - connect(controller, SIGNAL(modelChanged(KItemModelBase*,KItemModelBase*)), this, SLOT(slotModelChanged(KItemModelBase*,KItemModelBase*))); - - 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)), - this, SLOT(slotItemsChanged())); - connect(m_model, SIGNAL(itemsRemoved(KItemRangeList)), this, SIGNAL(itemCountChanged())); - connect(m_model, SIGNAL(itemsInserted(KItemRangeList)), this, SIGNAL(itemCountChanged())); - connect(m_model, SIGNAL(infoMessage(QString)), this, SIGNAL(infoMessage(QString))); - connect(m_model, SIGNAL(errorMessage(QString)), this, SIGNAL(errorMessage(QString))); - connect(m_model, SIGNAL(directoryRedirection(KUrl,KUrl)), this, SLOT(slotDirectoryRedirection(KUrl,KUrl))); - connect(m_model, SIGNAL(urlIsFileError(KUrl)), this, SIGNAL(urlIsFileError(KUrl))); + connect(controller, &KItemListController::itemActivated, this, &DolphinView::slotItemActivated); + connect(controller, &KItemListController::itemsActivated, this, &DolphinView::slotItemsActivated); + connect(controller, &KItemListController::itemMiddleClicked, this, &DolphinView::slotItemMiddleClicked); + connect(controller, &KItemListController::itemContextMenuRequested, this, &DolphinView::slotItemContextMenuRequested); + connect(controller, &KItemListController::viewContextMenuRequested, this, &DolphinView::slotViewContextMenuRequested); + connect(controller, &KItemListController::headerContextMenuRequested, this, &DolphinView::slotHeaderContextMenuRequested); + connect(controller, &KItemListController::mouseButtonPressed, this, &DolphinView::slotMouseButtonPressed); + connect(controller, &KItemListController::itemHovered, this, &DolphinView::slotItemHovered); + connect(controller, &KItemListController::itemUnhovered, this, &DolphinView::slotItemUnhovered); + connect(controller, &KItemListController::itemDropEvent, this, &DolphinView::slotItemDropEvent); + connect(controller, &KItemListController::escapePressed, this, &DolphinView::stopLoading); + connect(controller, &KItemListController::modelChanged, this, &DolphinView::slotModelChanged); + + connect(m_model, &KFileItemModel::directoryLoadingStarted, this, &DolphinView::slotDirectoryLoadingStarted); + connect(m_model, &KFileItemModel::directoryLoadingCompleted, this, &DolphinView::slotDirectoryLoadingCompleted); + connect(m_model, &KFileItemModel::directoryLoadingCanceled, this, &DolphinView::directoryLoadingCanceled); + connect(m_model, &KFileItemModel::directoryLoadingProgress, this, &DolphinView::directoryLoadingProgress); + connect(m_model, &KFileItemModel::directorySortingProgress, this, &DolphinView::directorySortingProgress); + connect(m_model, &KFileItemModel::itemsChanged, + this, &DolphinView::slotItemsChanged); + connect(m_model, &KFileItemModel::itemsRemoved, this, &DolphinView::itemCountChanged); + connect(m_model, &KFileItemModel::itemsInserted, this, &DolphinView::itemCountChanged); + connect(m_model, &KFileItemModel::infoMessage, this, &DolphinView::infoMessage); + connect(m_model, &KFileItemModel::errorMessage, this, &DolphinView::errorMessage); + connect(m_model, &KFileItemModel::directoryRedirection, this, &DolphinView::slotDirectoryRedirection); + connect(m_model, &KFileItemModel::urlIsFileError, this, &DolphinView::urlIsFileError); m_view->installEventFilter(this); - connect(m_view, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)), - this, SLOT(slotSortOrderChangedByHeader(Qt::SortOrder,Qt::SortOrder))); - connect(m_view, SIGNAL(sortRoleChanged(QByteArray,QByteArray)), - this, SLOT(slotSortRoleChangedByHeader(QByteArray,QByteArray))); - connect(m_view, SIGNAL(visibleRolesChanged(QList,QList)), - this, SLOT(slotVisibleRolesChangedByHeader(QList,QList))); - connect(m_view, SIGNAL(roleEditingCanceled(int,QByteArray,QVariant)), - this, SLOT(slotRoleEditingCanceled())); - connect(m_view->header(), SIGNAL(columnWidthChanged(QByteArray,qreal,qreal)), - this, SLOT(slotHeaderColumnWidthChanged(QByteArray,qreal,qreal))); + connect(m_view, &DolphinItemListView::sortOrderChanged, + this, &DolphinView::slotSortOrderChangedByHeader); + connect(m_view, &DolphinItemListView::sortRoleChanged, + this, &DolphinView::slotSortRoleChangedByHeader); + connect(m_view, &DolphinItemListView::visibleRolesChanged, + this, &DolphinView::slotVisibleRolesChangedByHeader); + connect(m_view, &DolphinItemListView::roleEditingCanceled, + this, &DolphinView::slotRoleEditingCanceled); + connect(m_view->header(), &KItemListHeader::columnWidthChanged, + this, &DolphinView::slotHeaderColumnWidthChanged); KItemListSelectionManager* selectionManager = controller->selectionManager(); - connect(selectionManager, SIGNAL(selectionChanged(KItemSet,KItemSet)), - this, SLOT(slotSelectionChanged(KItemSet,KItemSet))); + connect(selectionManager, &KItemListSelectionManager::selectionChanged, + this, &DolphinView::slotSelectionChanged); m_toolTipManager = new ToolTipManager(this); m_versionControlObserver = new VersionControlObserver(this); m_versionControlObserver->setModel(m_model); - connect(m_versionControlObserver, SIGNAL(infoMessage(QString)), this, SIGNAL(infoMessage(QString))); - connect(m_versionControlObserver, SIGNAL(errorMessage(QString)), this, SIGNAL(errorMessage(QString))); - connect(m_versionControlObserver, SIGNAL(operationCompletedMessage(QString)), this, SIGNAL(operationCompletedMessage(QString))); + connect(m_versionControlObserver, &VersionControlObserver::infoMessage, this, &DolphinView::infoMessage); + connect(m_versionControlObserver, &VersionControlObserver::errorMessage, this, &DolphinView::errorMessage); + connect(m_versionControlObserver, &VersionControlObserver::operationCompletedMessage, this, &DolphinView::operationCompletedMessage); applyViewProperties(); m_topLayout->addWidget(m_container); @@@ -299,7 -295,7 +299,7 @@@ void DolphinView::setHiddenFilesShown(b const KFileItemList itemList = selectedItems(); m_selectedUrls.clear(); - m_selectedUrls = itemList.urlList(); + m_selectedUrls = KUrl::List(itemList.urlList()); ViewProperties props(viewPropertiesUrl()); props.setHiddenFilesShown(show); @@@ -476,7 -472,7 +476,7 @@@ void DolphinView::reload( const KFileItemList itemList = selectedItems(); m_selectedUrls.clear(); - m_selectedUrls = itemList.urlList(); + m_selectedUrls = KUrl::List(itemList.urlList()); setUrl(url()); loadDirectory(url(), true); @@@ -610,8 -606,8 +610,8 @@@ void DolphinView::setUrl(const KUrl& ur hideToolTip(); - disconnect(m_view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)), - this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant))); + disconnect(m_view, &DolphinItemListView::roleEditingFinished, + this, &DolphinView::slotRoleEditingFinished); // It is important to clear the items from the model before // applying the view properties, otherwise expensive operations @@@ -655,8 -651,8 +655,8 @@@ void DolphinView::renameSelectedItems( hideToolTip(); - connect(m_view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)), - this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant))); + connect(m_view, &DolphinItemListView::roleEditingFinished, + this, &DolphinView::slotRoleEditingFinished); } else { RenameDialog* dialog = new RenameDialog(this, items); dialog->setAttribute(Qt::WA_DeleteOnClose); @@@ -688,10 -684,10 +688,10 @@@ void DolphinView::deleteSelectedItems( if (del) { KIO::Job* job = KIO::del(list); if (job->ui()) { - job->ui()->setWindow(this); + KJobWidgets::setWindow(job, this); } - connect(job, SIGNAL(result(KJob*)), - this, SLOT(slotDeleteFileFinished(KJob*))); + connect(job, &KIO::Job::result, + this, &DolphinView::slotDeleteFileFinished); } } @@@ -1050,7 -1046,8 +1050,8 @@@ void DolphinView::slotItemDropEvent(in if (op && destUrl == url()) { // Mark the dropped urls as selected. m_clearSelectionBeforeSelectingNewItems = true; + m_markFirstNewlySelectedItemAsCurrent = true; - connect(op, SIGNAL(aboutToCreate(KUrl::List)), this, SLOT(slotAboutToCreate(KUrl::List))); + connect(op, static_cast(&KonqOperations::aboutToCreate), this, &DolphinView::slotAboutToCreate); } setActive(true); @@@ -1059,33 -1056,30 +1060,31 @@@ void DolphinView::slotModelChanged(KItemModelBase* current, KItemModelBase* previous) { if (previous != 0) { - disconnect(previous, SIGNAL(directoryLoadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted())); + Q_ASSERT(qobject_cast(previous)); + KFileItemModel* fileItemModel = static_cast(previous); + disconnect(fileItemModel, &KFileItemModel::directoryLoadingCompleted, this, &DolphinView::slotDirectoryLoadingCompleted); m_versionControlObserver->setModel(0); } if (current) { Q_ASSERT(qobject_cast(current)); - connect(current, SIGNAL(loadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted())); - KFileItemModel* fileItemModel = static_cast(current); + connect(fileItemModel, &KFileItemModel::directoryLoadingCompleted, this, &DolphinView::slotDirectoryLoadingCompleted); m_versionControlObserver->setModel(fileItemModel); } } void DolphinView::slotMouseButtonPressed(int itemIndex, Qt::MouseButtons buttons) { + Q_UNUSED(itemIndex); + hideToolTip(); - if (itemIndex < 0) { - // Trigger the history navigation only when clicking on the viewport: - // Above an item the XButtons provide a simple way to select items in - // the singleClick mode. - if (buttons & Qt::XButton1) { - emit goBackRequested(); - } else if (buttons & Qt::XButton2) { - emit goForwardRequested(); - } + // TODO: Qt5: Replace Qt::XButton1 by Qt::BackButton and Qt::XButton2 by Qt::ForwardButton + if (buttons & Qt::XButton1) { + emit goBackRequested(); + } else if (buttons & Qt::XButton2) { + emit goForwardRequested(); } } @@@ -1096,7 -1090,7 +1095,7 @@@ void DolphinView::slotAboutToCreate(con markUrlAsCurrent(urls.first()); m_markFirstNewlySelectedItemAsCurrent = false; } - m_selectedUrls << KDirModel::simplifiedUrlList(urls); + m_selectedUrls << KUrl::List(KDirModel::simplifiedUrlList(urls)); } } @@@ -1359,16 -1353,6 +1358,6 @@@ void DolphinView::calculateItemCount(in } } - void DolphinView::showHoverInformation(const KFileItem& item) - { - emit requestItemInfo(item); - } - - void DolphinView::clearHoverInformation() - { - emit requestItemInfo(KFileItem()); - } - void DolphinView::slotDeleteFileFinished(KJob* job) { if (job->error() == 0) { @@@ -1456,14 -1440,14 +1445,14 @@@ void DolphinView::slotVisibleRolesChang void DolphinView::slotRoleEditingCanceled() { - disconnect(m_view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)), - this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant))); + disconnect(m_view, &DolphinItemListView::roleEditingFinished, + this, &DolphinView::slotRoleEditingFinished); } void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, const QVariant& value) { - disconnect(m_view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)), - this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant))); + disconnect(m_view, &DolphinItemListView::roleEditingFinished, + this, &DolphinView::slotRoleEditingFinished); if (index < 0 || index >= m_model->count()) { return; @@@ -1492,7 -1476,7 +1481,7 @@@ if (op && !newNameExistsAlready) { // Only connect the renamingFailed signal if there is no item with the new name // in the model yet, see bug 328262. - connect(op, SIGNAL(renamingFailed(KUrl,KUrl)), SLOT(slotRenamingFailed(KUrl,KUrl))); + connect(op, &KonqOperations::renamingFailed, this, &DolphinView::slotRenamingFailed); } } } @@@ -1633,7 -1617,7 +1622,7 @@@ void DolphinView::pasteToUrl(const KUrl if (op) { m_clearSelectionBeforeSelectingNewItems = true; m_markFirstNewlySelectedItemAsCurrent = true; - connect(op, SIGNAL(aboutToCreate(KUrl::List)), this, SLOT(slotAboutToCreate(KUrl::List))); + connect(op, static_cast(&KonqOperations::aboutToCreate), this, &DolphinView::slotAboutToCreate); } } diff --combined src/views/dolphinview.h index 0da9fa549,06c09edc3..4ba10293a --- a/src/views/dolphinview.h +++ b/src/views/dolphinview.h @@@ -30,7 -30,6 +30,7 @@@ #include #include #include +#include #include #include @@@ -614,20 -613,6 +614,6 @@@ private slots */ void updateSortFoldersFirst(bool foldersFirst); - /** - * Updates the status bar to show hover information for the - * item \a item. If currently other items are selected, - * no hover information is shown. - * @see DolphinView::clearHoverInformation() - */ - void showHoverInformation(const KFileItem& item); - - /** - * Clears the hover information shown in the status bar. - * @see DolphinView::showHoverInformation(). - */ - void clearHoverInformation(); - /** * Indicates in the status bar that the delete operation * of the job \a job has been finished. diff --combined src/views/renamedialog.cpp index 67f90a5da,5c0ae6126..3b94e01e5 --- a/src/views/renamedialog.cpp +++ b/src/views/renamedialog.cpp @@@ -23,7 -23,6 +23,7 @@@ #include #include #include +#include //TODO port to QCollator #include #include @@@ -31,15 -30,6 +31,6 @@@ #include #include - /** - * Helper function for sorting items with qSort() in - * DolphinView::renameSelectedItems(). - */ - bool lessThan(const KFileItem& item1, const KFileItem& item2) - { - return KStringHandler::naturalCompare(item1.name(), item2.name()) < 0; - } - RenameDialog::RenameDialog(QWidget *parent, const KFileItemList& items) : KDialog(parent), m_renameOneItem(false), @@@ -84,11 -74,11 +75,11 @@@ } m_lineEdit = new KLineEdit(page); - connect(m_lineEdit, SIGNAL(textChanged(QString)), this, SLOT(slotTextChanged(QString))); + connect(m_lineEdit, &KLineEdit::textChanged, this, &RenameDialog::slotTextChanged); int selectionLength = m_newName.length(); if (m_renameOneItem) { - const QString fileName = items.first().url().prettyUrl(); + const QString fileName = items.first().url().toDisplayString(); const QString extension = KMimeType::extractKnownExtension(fileName.toLower()); // If the current item is a directory, select the whole file name. @@@ -111,7 -101,7 +102,7 @@@ if (!m_renameOneItem) { QSet extensions; foreach (const KFileItem& item, m_items) { - const QString extension = KMimeType::extractKnownExtension(item.url().prettyUrl().toLower()); + const QString extension = KMimeType::extractKnownExtension(item.url().toDisplayString().toLower()); if (extensions.contains(extension)) { m_allExtensionsDifferent = false; diff --combined src/views/versioncontrol/updateitemstatesthread.cpp index 8472d7dd7,62fcd09aa..51a277831 --- a/src/views/versioncontrol/updateitemstatesthread.cpp +++ b/src/views/versioncontrol/updateitemstatesthread.cpp @@@ -20,7 -20,6 +20,7 @@@ #include "updateitemstatesthread.h" #include +#include #include @@@ -65,9 -64,9 +65,9 @@@ void UpdateItemStatesThread::run( items[i].version = static_cast(state); } } - - m_plugin->endRetrieval(); } + + m_plugin->endRetrieval(); } } diff --combined src/views/versioncontrol/versioncontrolobserver.cpp index 2c966e186,6affe80d3..9033e19da --- a/src/views/versioncontrol/versioncontrolobserver.cpp +++ b/src/views/versioncontrol/versioncontrolobserver.cpp @@@ -23,7 -23,6 +23,7 @@@ #include #include +#include #include #include #include @@@ -52,8 -51,8 +52,8 @@@ VersionControlObserver::VersionControlO m_dirVerificationTimer = new QTimer(this); m_dirVerificationTimer->setSingleShot(true); m_dirVerificationTimer->setInterval(500); - connect(m_dirVerificationTimer, SIGNAL(timeout()), - this, SLOT(verifyDirectory())); + connect(m_dirVerificationTimer, &QTimer::timeout, + this, &VersionControlObserver::verifyDirectory); } VersionControlObserver::~VersionControlObserver() @@@ -67,19 -66,19 +67,19 @@@ void VersionControlObserver::setModel(KFileItemModel* model) { if (m_model) { - disconnect(m_model, SIGNAL(itemsInserted(KItemRangeList)), - this, SLOT(delayedDirectoryVerification())); - disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet)), - this, SLOT(delayedDirectoryVerification())); + disconnect(m_model, &KFileItemModel::itemsInserted, + this, &VersionControlObserver::delayedDirectoryVerification); + disconnect(m_model, &KFileItemModel::itemsChanged, + this, &VersionControlObserver::delayedDirectoryVerification); } m_model = model; if (model) { - connect(m_model, SIGNAL(itemsInserted(KItemRangeList)), - this, SLOT(delayedDirectoryVerification())); - connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet)), - this, SLOT(delayedDirectoryVerification())); + connect(m_model, &KFileItemModel::itemsInserted, + this, &VersionControlObserver::delayedDirectoryVerification); + connect(m_model, &KFileItemModel::itemsChanged, + this, &VersionControlObserver::delayedDirectoryVerification); } } @@@ -117,7 -116,7 +117,7 @@@ QList VersionControlObserver: if (items.count() == 1) { const KFileItem rootItem = m_model->rootItem(); if (!rootItem.isNull() && items.first().url() == rootItem.url()) { - directory = rootItem.url().path(KUrl::AddTrailingSlash); + directory = rootItem.url().path(); } } @@@ -159,18 -158,18 +159,18 @@@ void VersionControlObserver::verifyDire if (m_plugin) { KVersionControlPlugin2* pluginV2 = qobject_cast(m_plugin); if (pluginV2) { - connect(pluginV2, SIGNAL(itemVersionsChanged()), - this, SLOT(silentDirectoryVerification())); + connect(pluginV2, &KVersionControlPlugin2::itemVersionsChanged, + this, &VersionControlObserver::silentDirectoryVerification); } else { - connect(m_plugin, SIGNAL(versionStatesChanged()), - this, SLOT(silentDirectoryVerification())); + connect(m_plugin, &KVersionControlPlugin::versionStatesChanged, + this, &VersionControlObserver::silentDirectoryVerification); } - connect(m_plugin, SIGNAL(infoMessage(QString)), - this, SIGNAL(infoMessage(QString))); - connect(m_plugin, SIGNAL(errorMessage(QString)), - this, SIGNAL(errorMessage(QString))); - connect(m_plugin, SIGNAL(operationCompletedMessage(QString)), - this, SIGNAL(operationCompletedMessage(QString))); + connect(m_plugin, &KVersionControlPlugin::infoMessage, + this, &VersionControlObserver::infoMessage); + connect(m_plugin, &KVersionControlPlugin::errorMessage, + this, &VersionControlObserver::errorMessage); + connect(m_plugin, &KVersionControlPlugin::operationCompletedMessage, + this, &VersionControlObserver::operationCompletedMessage); if (!m_versionedDirectory) { m_versionedDirectory = true; @@@ -242,10 -241,10 +242,10 @@@ void VersionControlObserver::updateItem emit infoMessage(i18nc("@info:status", "Updating version information...")); } m_updateItemStatesThread = new UpdateItemStatesThread(m_plugin, itemStates); - connect(m_updateItemStatesThread, SIGNAL(finished()), - this, SLOT(slotThreadFinished())); - connect(m_updateItemStatesThread, SIGNAL(finished()), - m_updateItemStatesThread, SLOT(deleteLater())); + connect(m_updateItemStatesThread, &UpdateItemStatesThread::finished, + this, &VersionControlObserver::slotThreadFinished); + connect(m_updateItemStatesThread, &UpdateItemStatesThread::finished, + m_updateItemStatesThread, &UpdateItemStatesThread::deleteLater); m_updateItemStatesThread->start(); // slotThreadFinished() is called when finished } @@@ -317,11 -316,18 +317,18 @@@ KVersionControlPlugin* VersionControlOb } } + // We use the number of upUrl() calls to find the best matching plugin + // for the given directory. The smaller value, the better it is (0 is best). + KVersionControlPlugin* bestPlugin = 0; + int bestScore = INT_MAX; + // Verify whether the current directory contains revision information // like .svn, .git, ... foreach (KVersionControlPlugin* plugin, plugins) { const QString fileName = directory.path(KUrl::AddTrailingSlash) + plugin->fileName(); if (QFile::exists(fileName)) { + // The score of this plugin is 0 (best), so we can just return this plugin, + // instead of going through the plugin scoring procedure, we can't find a better one ;) return plugin; } @@@ -334,18 -340,24 +341,24 @@@ if (m_versionedDirectory) { KUrl dirUrl(directory); KUrl upUrl = dirUrl.upUrl(); - while (upUrl != dirUrl) { + int upUrlCounter = 1; + while ((upUrlCounter < bestScore) && (upUrl != dirUrl)) { const QString fileName = dirUrl.path(KUrl::AddTrailingSlash) + plugin->fileName(); if (QFile::exists(fileName)) { - return plugin; + if (upUrlCounter < bestScore) { + bestPlugin = plugin; + bestScore = upUrlCounter; + } + break; } dirUrl = upUrl; upUrl = dirUrl.upUrl(); + ++upUrlCounter; } } } - return 0; + return bestPlugin; } bool VersionControlObserver::isVersioned() const