]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Change signature of requestItemInfo signal, to avoid fileitem -> url -> index ->...
authorDavid Faure <faure@kde.org>
Mon, 2 Jul 2007 17:24:54 +0000 (17:24 +0000)
committerDavid Faure <faure@kde.org>
Mon, 2 Jul 2007 17:24:54 +0000 (17:24 +0000)
 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

src/dolphinmainwindow.cpp
src/dolphinmainwindow.h
src/dolphinpart.cpp
src/dolphinpart.h
src/dolphinview.cpp
src/dolphinview.h
src/dolphinviewcontainer.cpp
src/dolphinviewcontainer.h

index ddf7b19b11aa52e7b8c3f441711b64e7b7263bd4..6e1beb6a57f31fb50195949b693851ad066787f5 100644 (file)
@@ -366,9 +366,9 @@ void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection)
     emit selectionChanged(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()
 }
 
 void DolphinMainWindow::slotHistoryChanged()
@@ -1340,8 +1340,8 @@ void DolphinMainWindow::setupDockWidgets()
             infoWidget, SLOT(setUrl(KUrl)));
     connect(this, SIGNAL(selectionChanged(KFileItemList)),
             infoWidget, SLOT(setSelection(KFileItemList)));
             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"));
 
     // 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)));
             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()));
 
     connect(view, SIGNAL(activated()),
             this, SLOT(toggleActiveView()));
 
index 93ab2762a0810790b9d81232f4345dda4eb4cabb..f8c0367e8e82dc21f4329f0d4b3429e61aee3946 100644 (file)
@@ -148,9 +148,9 @@ signals:
 
     /**
      * Is emitted if information of an item is requested to be shown e. g. in the sidebar.
 
     /**
      * 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 */
 
 protected:
     /** @see QMainWindow::closeEvent */
@@ -407,7 +407,7 @@ private slots:
     void slotSelectionChanged(const KFileItemList& selection);
 
     /** Emits the signal requestItemInfo(). */
     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
 
     /**
      * Updates the state of the 'Back' and 'Forward' menu
index 2a766afd44004317b0b010d6603ae0f19c00e3e7..c0d807910b37875ee15fde3608e41ff97fe0a16f 100644 (file)
 */
 
 #include "dolphinpart.h"
 */
 
 #include "dolphinpart.h"
-#include <kparts/genericfactory.h>
-#include "dolphinview.h"
 #include "dolphinsortfilterproxymodel.h"
 #include "dolphinsortfilterproxymodel.h"
-#include <kdirmodel.h>
+#include "dolphinview.h"
+
 #include <kdirlister.h>
 #include <kdirlister.h>
+#include <kdirmodel.h>
+#include <kmessagebox.h>
+#include <kparts/browserextension.h>
+#include <kparts/genericfactory.h>
 
 typedef KParts::GenericFactory<DolphinPart> DolphinPartFactory;
 K_EXPORT_COMPONENT_FACTORY(dolphinpart, DolphinPartFactory)
 
 
 typedef KParts::GenericFactory<DolphinPart> 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() );
 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);
 
 
     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);
 
     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);
                              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()
 }
 
 DolphinPart::~DolphinPart()
@@ -65,8 +99,41 @@ KAboutData* DolphinPart::createAboutData()
 
 bool DolphinPart::openUrl(const KUrl& url)
 {
 
 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);
     m_view->setUrl(url);
+    if (args.reload)
+        m_view->reload();
+    emit started(0); // get the wheel to spin
     return true;
 }
 
     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"
 #include "dolphinpart.moc"
index 08dfce90a56238bce9033aa500b33c72ae3ddbfb..d6d126cc7b6581aa966978c69ac6877be71372d1 100644 (file)
@@ -21,6 +21,8 @@
 #define DOLPHINPART_H
 
 #include <kparts/part.h>
 #define DOLPHINPART_H
 
 #include <kparts/part.h>
+class KFileItem;
+class DolphinPartBrowserExtension;
 class DolphinSortFilterProxyModel;
 class KDirModel;
 class KDirLister;
 class DolphinSortFilterProxyModel;
 class KDirModel;
 class KDirLister;
@@ -44,11 +46,19 @@ public:
 protected:
     virtual bool openFile() { return true; }
 
 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;
 private:
     DolphinView* m_view;
     KDirLister* m_dirLister;
     KDirModel* m_dirModel;
     DolphinSortFilterProxyModel* m_proxyModel;
+    DolphinPartBrowserExtension* m_extension;
     Q_DISABLE_COPY(DolphinPart)
 };
 
     Q_DISABLE_COPY(DolphinPart)
 };
 
index 5a1de5217e1c0702e42d4ce281c3b18a3dee7f66..042c74b2c0151b7fa3e324fc4609603dcea72d63 100644 (file)
@@ -803,13 +803,13 @@ void DolphinView::showHoverInformation(const QModelIndex& index)
 
     const KFileItem* item = fileItem(index);
     if (item != 0) {
 
     const KFileItem* item = fileItem(index);
     if (item != 0) {
-        emit requestItemInfo(item->url());
+        emit requestItemInfo(*item);
     }
 }
 
 void DolphinView::clearHoverInformation()
 {
     }
 }
 
 void DolphinView::clearHoverInformation()
 {
-    emit requestItemInfo(KUrl());
+    emit requestItemInfo(KFileItem());
 }
 
 
 }
 
 
index 899eb492e683a47ae215eab20df82a30357f25c5..b9fe49f00fcc76ccda885834f86c43dbc1405984 100644 (file)
@@ -344,9 +344,9 @@ signals:
 
     /**
      * Is emitted if information of an item is requested to be shown e. g. in the sidebar.
 
     /**
      * 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);
 
     /** Is emitted if the contents has been moved to \a x, \a y. */
     void contentsMoved(int x, int y);
index 6e5b00af23368ad203fcff41425ca3f02430a433..568cba93ad0bd9477c1a20c954c3b2b0c2a7d448 100644 (file)
@@ -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)));
             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&)),
     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()));
 }
 
     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();
         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);
     }
 }
 
     }
 }
 
index de77fb03a6cc37a431fc687a1273f89eb199b792..40bfff7ed041ef7ad210957ba4773931f4826a95 100644 (file)
@@ -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.
      */
      * 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);
 
     /** Shows the information \a msg inside the statusbar. */
     void showInfoMessage(const QString& msg);