]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Implement contextMenu handling in dolphin part (for konqueror)
authorDavid Faure <faure@kde.org>
Tue, 28 Aug 2007 19:48:36 +0000 (19:48 +0000)
committerDavid Faure <faure@kde.org>
Tue, 28 Aug 2007 19:48:36 +0000 (19:48 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=705873

src/dolphinpart.cpp
src/dolphinpart.h
src/dolphinviewcontainer.h

index 22f7940bd411c97e844ed768f9540ebfd3aea001..39df8feaed5383b4c151ce40148810f82567fe94 100644 (file)
@@ -72,11 +72,15 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi
             this, SLOT(slotErrorMessage(QString)));
     connect(m_view, SIGNAL(itemTriggered(KFileItem)),
             this, SLOT(slotItemTriggered(KFileItem)));
             this, SLOT(slotErrorMessage(QString)));
     connect(m_view, SIGNAL(itemTriggered(KFileItem)),
             this, SLOT(slotItemTriggered(KFileItem)));
-    // TODO connect to urlsDropped
-    // TOOD connect to requestContextMenu
-    connect(m_view, SIGNAL(selectionChanged(QList<KFileItem>)), m_extension, SIGNAL(selectionInfo(QList<KFileItem>)));
+    connect(m_view, SIGNAL(requestContextMenu(KFileItem, const KUrl&)),
+            this, SLOT(slotOpenContextMenu(KFileItem, const KUrl&)));
+    connect(m_view, SIGNAL(selectionChanged(QList<KFileItem>)),
+            m_extension, SIGNAL(selectionInfo(QList<KFileItem>)));
+
+    connect(m_view, SIGNAL(requestItemInfo(KFileItem)),
+            this, SLOT(slotRequestItemInfo(KFileItem)));
 
 
-    connect(m_view, SIGNAL(requestItemInfo(KFileItem)), this, SLOT(slotRequestItemInfo(KFileItem)));
+    // TODO connect to urlsDropped
 
     // TODO there was a "always open a new window" (when clicking on a directory) setting in konqueror
     // (sort of spacial navigation)
 
     // TODO there was a "always open a new window" (when clicking on a directory) setting in konqueror
     // (sort of spacial navigation)
@@ -101,8 +105,8 @@ KAboutData* DolphinPart::createAboutData()
 bool DolphinPart::openUrl(const KUrl& url)
 {
     const QString prettyUrl = url.pathOrUrl();
 bool DolphinPart::openUrl(const KUrl& url)
 {
     const QString prettyUrl = url.pathOrUrl();
-    setWindowCaption(prettyUrl);
-    m_extension->setLocationBarUrl(prettyUrl);
+    emit setWindowCaption(prettyUrl);
+    emit m_extension->setLocationBarUrl(prettyUrl);
     m_view->setUrl(url);
     if (arguments().reload())
         m_view->reload();
     m_view->setUrl(url);
     if (arguments().reload())
         m_view->reload();
@@ -141,4 +145,19 @@ void DolphinPart::slotItemTriggered(const KFileItem& item)
     emit m_extension->openUrlRequest(item.url());
 }
 
     emit m_extension->openUrlRequest(item.url());
 }
 
+void DolphinPart::slotOpenContextMenu(const KFileItem& item, const KUrl&)
+{
+    // TODO KonqKfmIconView had if ( !rootItem->isWritable() )
+    //            popupFlags |= KParts::BrowserExtension::NoDeletion;
+
+    // and when clicking on the viewport:
+    //        KParts::BrowserExtension::PopupFlags popupFlags = KParts::BrowserExtension::ShowNavigationItems | KParts::BrowserExtension::ShowUp;
+
+
+    KFileItem* itemCopy = new KFileItem(item); // ugly
+    KFileItemList items; items.append(itemCopy);
+    emit m_extension->popupMenu( 0, QCursor::pos(), items );
+    delete itemCopy;
+}
+
 #include "dolphinpart.moc"
 #include "dolphinpart.moc"
index a9806d595c17f28f9b6588ffeacc751d1e1b59d1..3ca066a572b9ef1c7bb800e7693a3a9d6f1d9e86 100644 (file)
@@ -51,8 +51,22 @@ private Q_SLOTS:
     void slotCanceled(const KUrl& url);
     void slotInfoMessage(const QString& msg);
     void slotErrorMessage(const QString& msg);
     void slotCanceled(const KUrl& url);
     void slotInfoMessage(const QString& msg);
     void slotErrorMessage(const QString& msg);
+    /**
+     * Shows the information for the item \a item inside the statusbar. If the
+     * item is null, the default statusbar information is shown.
+     */
     void slotRequestItemInfo(const KFileItem& item);
     void slotRequestItemInfo(const KFileItem& item);
+    /**
+     * Handles clicking on an item
+     */
     void slotItemTriggered(const KFileItem& item);
     void slotItemTriggered(const KFileItem& item);
+    /**
+     * Opens the context menu on the current mouse position.
+     * @item  File item context. If item is 0, the context menu
+     *        should be applied to \a url.
+     * @url   URL which contains \a item.
+     */
+    void slotOpenContextMenu(const KFileItem& item, const KUrl& url);
 
 private:
     DolphinView* m_view;
 
 private:
     DolphinView* m_view;
index 2e49933161de4d15e1100ca673c6a1f39311f04d..3c9223f19c94e1d5393af50b6cb63570df865711 100644 (file)
@@ -177,7 +177,7 @@ private slots:
     void changeNameFilter(const QString& nameFilter);
 
     /**
     void changeNameFilter(const QString& nameFilter);
 
     /**
-     * Opens the context menu on the current mouse postition.
+     * Opens the context menu on the current mouse position.
      * @item  File item context. If item is 0, the context menu
      *        should be applied to \a url.
      * @url   URL which contains \a item.
      * @item  File item context. If item is 0, the context menu
      *        should be applied to \a url.
      * @url   URL which contains \a item.