From: David Faure Date: Mon, 2 Jul 2007 17:24:54 +0000 (+0000) Subject: Change signature of requestItemInfo signal, to avoid fileitem -> url -> index ->... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/d89f43f66bb323a612c2f7de09d5969e437845e0 Change signature of requestItemInfo signal, to avoid fileitem -> url -> index -> fileitem roundtrip in dolphin, and to match the BrowserExtension mouseOverInfo() signal. Started to implement more of the part (e.g. spinning wheel in konq). svn path=/trunk/KDE/kdebase/apps/; revision=682440 --- diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index ddf7b19b1..6e1beb6a5 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -366,9 +366,9 @@ void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection) emit selectionChanged(selection); } -void DolphinMainWindow::slotRequestItemInfo(const KUrl& url) +void DolphinMainWindow::slotRequestItemInfo(const KFileItem& item) { - emit requestItemInfo(url); + emit requestItemInfo(item); } void DolphinMainWindow::slotHistoryChanged() @@ -1340,8 +1340,8 @@ void DolphinMainWindow::setupDockWidgets() infoWidget, SLOT(setUrl(KUrl))); connect(this, SIGNAL(selectionChanged(KFileItemList)), infoWidget, SLOT(setSelection(KFileItemList))); - connect(this, SIGNAL(requestItemInfo(KUrl)), - infoWidget, SLOT(requestDelayedItemInfo(KUrl))); + connect(this, SIGNAL(requestItemInfo(KFileItem)), + infoWidget, SLOT(requestDelayedItemInfo(KFileItem))); // setup "Tree View" QDockWidget* treeViewDock = new QDockWidget(i18nc("@title:window", "Folders")); @@ -1561,8 +1561,8 @@ void DolphinMainWindow::connectViewSignals(int viewIndex) this, SLOT(slotAdditionalInfoChanged(KFileItemDelegate::AdditionalInformation))); connect(view, SIGNAL(selectionChanged(KFileItemList)), this, SLOT(slotSelectionChanged(KFileItemList))); - connect(view, SIGNAL(requestItemInfo(KUrl)), - this, SLOT(slotRequestItemInfo(KUrl))); + connect(view, SIGNAL(requestItemInfo(KFileItem)), + this, SLOT(slotRequestItemInfo(KFileItem))); connect(view, SIGNAL(activated()), this, SLOT(toggleActiveView())); diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index 93ab2762a..f8c0367e8 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -148,9 +148,9 @@ signals: /** * Is emitted if information of an item is requested to be shown e. g. in the sidebar. - * It the URL is empty, no item information request is pending. + * If item is null, no item information request is pending. */ - void requestItemInfo(const KUrl& url); + void requestItemInfo(const KFileItem& item); protected: /** @see QMainWindow::closeEvent */ @@ -407,7 +407,7 @@ private slots: void slotSelectionChanged(const KFileItemList& selection); /** Emits the signal requestItemInfo(). */ - void slotRequestItemInfo(const KUrl& url); + void slotRequestItemInfo(const KFileItem&); /** * Updates the state of the 'Back' and 'Forward' menu diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index 2a766afd4..c0d807910 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -18,27 +18,41 @@ */ #include "dolphinpart.h" -#include -#include "dolphinview.h" #include "dolphinsortfilterproxymodel.h" -#include +#include "dolphinview.h" + #include +#include +#include +#include +#include typedef KParts::GenericFactory DolphinPartFactory; K_EXPORT_COMPONENT_FACTORY(dolphinpart, DolphinPartFactory) +class DolphinPartBrowserExtension : public KParts::BrowserExtension +{ +public: + DolphinPartBrowserExtension( KParts::ReadOnlyPart* part ) + : KParts::BrowserExtension( part ) {} +}; + DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringList& args) : KParts::ReadOnlyPart(parent) { Q_UNUSED(args) setComponentData( DolphinPartFactory::componentData() ); - //setBrowserExtension( new DolphinPartBrowserExtension( this ) ); + m_extension = new DolphinPartBrowserExtension(this); m_dirLister = new KDirLister; m_dirLister->setAutoUpdate(true); m_dirLister->setMainWindow(parentWidget->topLevelWidget()); m_dirLister->setDelayedMimeTypes(true); + //connect(m_dirLister, SIGNAL(started(KUrl)), this, SLOT(slotStarted())); + connect(m_dirLister, SIGNAL(completed(KUrl)), this, SLOT(slotCompleted(KUrl))); + connect(m_dirLister, SIGNAL(canceled(KUrl)), this, SLOT(slotCanceled(KUrl))); + m_dirModel = new KDirModel(this); m_dirModel->setDirLister(m_dirLister); @@ -51,6 +65,26 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi m_dirModel, m_proxyModel); setWidget(m_view); + + connect(m_view, SIGNAL(infoMessage(QString)), this, SLOT(slotInfoMessage(QString))); + connect(m_view, SIGNAL(errorMessage(QString)), this, SLOT(slotErrorMessage(QString))); + // TODO connect to urlsDropped + // TOOD connect to requestContextMenu + connect(m_view, SIGNAL(selectionChanged(KFileItemList)), m_extension, SIGNAL(selectionInfo(KFileItemList))); + + connect(m_view, SIGNAL(requestItemInfo(KFileItem)), this, SLOT(slotRequestItemInfo(KFileItem))); + + // TODO there was a "always open a new window" (when clicking on a directory) setting in konqueror + // (sort of spacial navigation) + + // TODO when clicking on a file we want to emit m_extension->openUrlRequest(url, args) + // to be able to embed the viewer + + // TODO MMB-click should do something like KonqDirPart::mmbClicked + + // TODO updating the paste action + // if (paste) emit m_extension->setActionText( "paste", actionText ); + // emit m_extension->enableAction( "paste", paste ); } DolphinPart::~DolphinPart() @@ -65,8 +99,41 @@ KAboutData* DolphinPart::createAboutData() bool DolphinPart::openUrl(const KUrl& url) { + const QString prettyUrl = url.pathOrUrl(); + setWindowCaption(prettyUrl); + m_extension->setLocationBarUrl(prettyUrl); + const KParts::URLArgs args = m_extension->urlArgs(); m_view->setUrl(url); + if (args.reload) + m_view->reload(); + emit started(0); // get the wheel to spin return true; } +void DolphinPart::slotCompleted(const KUrl& url) +{ + Q_UNUSED(url) + emit completed(); +} + +void DolphinPart::slotCanceled(const KUrl& url) +{ + slotCompleted(url); +} + +void DolphinPart::slotInfoMessage(const QString& msg) +{ + emit setStatusBarText(msg); +} + +void DolphinPart::slotErrorMessage(const QString& msg) +{ + KMessageBox::error(m_view, msg); +} + +void DolphinPart::slotRequestItemInfo(const KFileItem& item) +{ + emit m_extension->mouseOverInfo(&item); +} + #include "dolphinpart.moc" diff --git a/src/dolphinpart.h b/src/dolphinpart.h index 08dfce90a..d6d126cc7 100644 --- a/src/dolphinpart.h +++ b/src/dolphinpart.h @@ -21,6 +21,8 @@ #define DOLPHINPART_H #include +class KFileItem; +class DolphinPartBrowserExtension; class DolphinSortFilterProxyModel; class KDirModel; class KDirLister; @@ -44,11 +46,19 @@ public: protected: virtual bool openFile() { return true; } +private Q_SLOTS: + void slotCompleted(const KUrl& url); + void slotCanceled(const KUrl& url); + void slotInfoMessage(const QString& msg); + void slotErrorMessage(const QString& msg); + void slotRequestItemInfo(const KFileItem& item); + private: DolphinView* m_view; KDirLister* m_dirLister; KDirModel* m_dirModel; DolphinSortFilterProxyModel* m_proxyModel; + DolphinPartBrowserExtension* m_extension; Q_DISABLE_COPY(DolphinPart) }; diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 5a1de5217..042c74b2c 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -803,13 +803,13 @@ void DolphinView::showHoverInformation(const QModelIndex& index) const KFileItem* item = fileItem(index); if (item != 0) { - emit requestItemInfo(item->url()); + emit requestItemInfo(*item); } } void DolphinView::clearHoverInformation() { - emit requestItemInfo(KUrl()); + emit requestItemInfo(KFileItem()); } diff --git a/src/dolphinview.h b/src/dolphinview.h index 899eb492e..b9fe49f00 100644 --- a/src/dolphinview.h +++ b/src/dolphinview.h @@ -344,9 +344,9 @@ signals: /** * Is emitted if information of an item is requested to be shown e. g. in the sidebar. - * It the URL is empty, no item information request is pending. + * If item is null, no item information request is pending. */ - void requestItemInfo(const KUrl& url); + void requestItemInfo(const KFileItem& item); /** Is emitted if the contents has been moved to \a x, \a y. */ void contentsMoved(int x, int y); diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index 6e5b00af2..568cba93a 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -133,8 +133,8 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow, m_mainWindow, SLOT(dropUrls(const KUrl::List&, const KUrl&))); connect(m_view, SIGNAL(contentsMoved(int, int)), this, SLOT(saveContentsPos(int, int))); - connect(m_view, SIGNAL(requestItemInfo(const KUrl&)), - this, SLOT(showItemInfo(const KUrl&))); + connect(m_view, SIGNAL(requestItemInfo(KFileItem)), + this, SLOT(showItemInfo(KFileItem))); connect(m_view, SIGNAL(errorMessage(const QString&)), this, SLOT(showErrorMessage(const QString&))); connect(m_view, SIGNAL(infoMessage(const QString&)), @@ -322,17 +322,12 @@ void DolphinViewContainer::updateItemCount() QTimer::singleShot(100, this, SLOT(restoreContentsPos())); } -void DolphinViewContainer::showItemInfo(const KUrl& url) +void DolphinViewContainer::showItemInfo(const KFileItem& item) { - if (url.isEmpty()) { + if (item.isNull()) { m_statusBar->clear(); - return; - } - - const QModelIndex index = m_dirModel->indexForUrl(url); - const KFileItem* item = m_dirModel->itemForIndex(index); - if (item != 0) { - m_statusBar->setMessage(item->getStatusBarInfo(), DolphinStatusBar::Default); + } else { + m_statusBar->setMessage(item.getStatusBarInfo(), DolphinStatusBar::Default); } } diff --git a/src/dolphinviewcontainer.h b/src/dolphinviewcontainer.h index de77fb03a..40bfff7ed 100644 --- a/src/dolphinviewcontainer.h +++ b/src/dolphinviewcontainer.h @@ -155,7 +155,7 @@ private slots: * Shows the item information for the URL \a url inside the statusbar. If the * URL is empty, the default statusbar information is shown. */ - void showItemInfo(const KUrl& url); + void showItemInfo(const KFileItem& item); /** Shows the information \a msg inside the statusbar. */ void showInfoMessage(const QString& msg);