X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/7e311509a4ac89ebe95f3d81928fe78a9f398aa9..2f0ceedae088158b8af24a5e94500a7d1c0edecb:/src/dolphinpart.cpp diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index 3d0748f84..df1d8b738 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -19,32 +19,31 @@ #include "dolphinpart.h" -#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include -#include -#include -#include +#include +#include +#include +#include #include "settings/dolphinsettings.h" #include "views/dolphinview.h" #include "views/dolphinviewactionhandler.h" -#include "views/dolphinsortfilterproxymodel.h" -#include "views/dolphinmodel.h" #include "views/dolphinnewfilemenuobserver.h" #include "views/dolphinremoteencoding.h" #include "views/dolphindirlister.h" @@ -67,28 +66,14 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL // make sure that other apps using this part find Dolphin's view-file-columns icons KIconLoader::global()->addAppDir("dolphin"); - m_dirLister = new DolphinDirLister; - m_dirLister->setAutoUpdate(true); - if (parentWidget) { - m_dirLister->setMainWindow(parentWidget->window()); - } - m_dirLister->setDelayedMimeTypes(true); - - connect(m_dirLister, SIGNAL(completed(KUrl)), this, SLOT(slotCompleted(KUrl))); - connect(m_dirLister, SIGNAL(canceled(KUrl)), this, SLOT(slotCanceled(KUrl))); - connect(m_dirLister, SIGNAL(percent(int)), this, SLOT(updateProgress(int))); - connect(m_dirLister, SIGNAL(errorMessage(QString)), this, SLOT(slotErrorMessage(QString))); - - m_dolphinModel = new DolphinModel(this); - m_dolphinModel->setDirLister(m_dirLister); // m_dolphinModel takes ownership of m_dirLister - - m_proxyModel = new DolphinSortFilterProxyModel(this); - m_proxyModel->setSourceModel(m_dolphinModel); - - m_view = new DolphinView(parentWidget, KUrl(), m_proxyModel); + m_view = new DolphinView(KUrl(), parentWidget); m_view->setTabsForFilesEnabled(true); setWidget(m_view); + connect(m_view, SIGNAL(finishedPathLoading(KUrl)), this, SLOT(slotCompleted(KUrl))); + connect(m_view, SIGNAL(pathLoadingProgress(int)), this, SLOT(updateProgress(int))); + connect(m_view, SIGNAL(errorMessage(QString)), this, SLOT(slotErrorMessage(QString))); + setXMLFile("dolphinpart.rc"); connect(m_view, SIGNAL(infoMessage(QString)), @@ -109,19 +94,15 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL this, SLOT(slotSelectionChanged(KFileItemList))); connect(m_view, SIGNAL(requestItemInfo(KFileItem)), this, SLOT(slotRequestItemInfo(KFileItem))); - connect(m_view, SIGNAL(modeChanged()), + connect(m_view, SIGNAL(modeChanged(DolphinView::Mode,DolphinView::Mode)), this, SIGNAL(viewModeChanged())); // relay signal - connect(m_view, SIGNAL(redirection(KUrl, KUrl)), - this, SLOT(slotRedirection(KUrl, KUrl))); + connect(m_view, SIGNAL(redirection(KUrl,KUrl)), + this, SLOT(slotRedirection(KUrl,KUrl))); // Watch for changes that should result in updates to the // status bar text. - connect(m_dirLister, SIGNAL(itemsDeleted(const KFileItemList&)), - this, SLOT(updateStatusBar())); - connect(m_dirLister, SIGNAL(clear()), - this, SLOT(updateStatusBar())); - connect(m_view, SIGNAL(selectionChanged(const KFileItemList)), - this, SLOT(updateStatusBar())); + connect(m_view, SIGNAL(itemCountChanged()), this, SLOT(updateStatusBar())); + connect(m_view, SIGNAL(selectionChanged(KFileItemList)), this, SLOT(updateStatusBar())); m_actionHandler = new DolphinViewActionHandler(actionCollection(), this); m_actionHandler->setCurrentView(m_view); @@ -211,6 +192,12 @@ void DolphinPart::createActions() goActionGroup); // Tools menu + KAction* findFile = actionCollection()->addAction("find_file"); + findFile->setText(i18nc("@action:inmenu Tools", "Find File...")); + findFile->setShortcut(Qt::CTRL | Qt::Key_F); + findFile->setIcon(KIcon("edit-find")); + connect(findFile, SIGNAL(triggered()), this, SLOT(slotFindFile())); + if (KAuthorized::authorizeKAction("shell_access")) { KAction* action = actionCollection()->addAction("open_terminal"); action->setIcon(KIcon("utilities-terminal")); @@ -218,7 +205,6 @@ void DolphinPart::createActions() connect(action, SIGNAL(triggered()), SLOT(slotOpenTerminal())); action->setShortcut(Qt::Key_F4); } - } void DolphinPart::createGoAction(const char* name, const char* iconName, @@ -292,7 +278,7 @@ bool DolphinPart::openUrl(const KUrl& url) bool reload = arguments().reload(); // A bit of a workaround so that changing the namefilter works: force reload. // Otherwise DolphinView wouldn't relist the URL, so nothing would happen. - if (m_nameFilter != m_dirLister->nameFilter()) + if (m_nameFilter != m_view->nameFilter()) reload = true; if (m_view->url() == url && !reload) { // DolphinView won't do anything in that case, so don't emit started return true; @@ -306,7 +292,7 @@ bool DolphinPart::openUrl(const KUrl& url) emit setWindowCaption(prettyUrl); emit m_extension->setLocationBarUrl(prettyUrl); emit started(0); // get the wheel to spin - m_dirLister->setNameFilter(m_nameFilter); + m_view->setNameFilter(m_nameFilter); m_view->setUrl(url); updatePasteAction(); emit aboutToOpenURL(); @@ -321,11 +307,6 @@ void DolphinPart::slotCompleted(const KUrl& url) emit completed(); } -void DolphinPart::slotCanceled(const KUrl& url) -{ - slotCompleted(url); -} - void DolphinPart::slotMessage(const QString& msg) { emit setStatusBarText(msg); @@ -383,7 +364,7 @@ void DolphinPart::slotOpenContextMenu(const KFileItem& _item, if (item.isNull()) { // viewport context menu popupFlags |= KParts::BrowserExtension::ShowNavigationItems | KParts::BrowserExtension::ShowUp; - item = m_dirLister->rootItem(); + item = m_view->rootItem(); if (item.isNull()) item = KFileItem( S_IFDIR, (mode_t)-1, url() ); else @@ -539,11 +520,16 @@ void DolphinPart::slotOpenTerminal() KToolInvocation::invokeTerminal(QString(), dir); } +void DolphinPart::slotFindFile() +{ + KRun::run("kfind", url(), widget()); +} + void DolphinPart::updateNewMenu() { // As requested by KNewFileMenu : m_newFileMenu->checkUpToDate(); - m_newFileMenu->setViewShowsHiddenFiles(m_view->showHiddenFiles()); + m_newFileMenu->setViewShowsHiddenFiles(m_view->hiddenFilesShown()); // And set the files that the menu apply on : m_newFileMenu->setPopupFiles(url()); } @@ -560,7 +546,7 @@ void DolphinPart::updateProgress(int percent) void DolphinPart::createDirectory() { - m_newFileMenu->setViewShowsHiddenFiles(m_view->showHiddenFiles()); + m_newFileMenu->setViewShowsHiddenFiles(m_view->hiddenFilesShown()); m_newFileMenu->setPopupFiles(url()); m_newFileMenu->createDirectory(); }