]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Clicking on items in dolphin part finally implemented.
authorDavid Faure <faure@kde.org>
Tue, 28 Aug 2007 17:50:54 +0000 (17:50 +0000)
committerDavid Faure <faure@kde.org>
Tue, 28 Aug 2007 17:50:54 +0000 (17:50 +0000)
Fixed connect() error in dolphinstatusbar [unrelated].

svn path=/trunk/KDE/kdebase/apps/; revision=705835

src/dolphincontroller.h
src/dolphindetailsview.cpp
src/dolphindetailsview.h
src/dolphinpart.cpp
src/dolphinpart.h
src/dolphinstatusbar.cpp
src/dolphinview.cpp
src/dolphinview.h
src/dolphinviewcontainer.cpp
src/dolphinviewcontainer.h

index 356daead5e49a3b209bfc6cf75e28fffe41a7665..d91e7f5c1c1f576c6418903836105a88881cc1e0 100644 (file)
@@ -162,6 +162,7 @@ signals:
      * Is emitted if the item with the index \a index should be triggered.
      * Usually triggering on a directory opens the directory, triggering
      * on a file opens the corresponding application.
      * Is emitted if the item with the index \a index should be triggered.
      * Usually triggering on a directory opens the directory, triggering
      * on a file opens the corresponding application.
+     * Emitted with an invalid \a index when clicking on the viewport itself.
      */
     void itemTriggered(const QModelIndex& index);
 
      */
     void itemTriggered(const QModelIndex& index);
 
index ef3146c20d472aac751bc36cba319dd81aa0a259..1aec30cca05fd4edb1289776bec04d1b7b3d9612 100644 (file)
@@ -71,10 +71,10 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr
 
     if (KGlobalSettings::singleClick()) {
         connect(this, SIGNAL(clicked(const QModelIndex&)),
 
     if (KGlobalSettings::singleClick()) {
         connect(this, SIGNAL(clicked(const QModelIndex&)),
-                controller, SLOT(triggerItem(const QModelIndex&)));
+                this, SLOT(slotItemActivated(const QModelIndex&)));
     } else {
         connect(this, SIGNAL(doubleClicked(const QModelIndex&)),
     } else {
         connect(this, SIGNAL(doubleClicked(const QModelIndex&)),
-                controller, SLOT(triggerItem(const QModelIndex&)));
+                this, SLOT(slotItemActivated(const QModelIndex&)));
     }
     connect(this, SIGNAL(entered(const QModelIndex&)),
             this, SLOT(slotEntered(const QModelIndex&)));
     }
     connect(this, SIGNAL(entered(const QModelIndex&)),
             this, SLOT(slotEntered(const QModelIndex&)));
@@ -391,4 +391,19 @@ QRect DolphinDetailsView::elasticBandRect() const
     return QRect(topLeft, m_elasticBandDestination).normalized();
 }
 
     return QRect(topLeft, m_elasticBandDestination).normalized();
 }
 
+static bool isValidNameIndex(const QModelIndex& index)
+{
+    return index.isValid() && (index.column() == KDirModel::Name);
+}
+
+void DolphinDetailsView::slotItemActivated(const QModelIndex& index)
+{
+    if (!isValidNameIndex(index)) {
+        clearSelection();
+        m_controller->emitItemEntered(index);
+    } else {
+        m_controller->triggerItem(index);
+    }
+}
+
 #include "dolphindetailsview.moc"
 #include "dolphindetailsview.moc"
index b3944b4a1e1482e9d64093fad2975a5450c05207..fdd93b03c47553717970b634eb4ff744f6d4ef25 100644 (file)
@@ -103,6 +103,11 @@ private slots:
     void zoomIn();
     void zoomOut();
 
     void zoomIn();
     void zoomOut();
 
+    /**
+     * Called by QTreeView when an item is activated (clicked or double-clicked)
+     */
+    void slotItemActivated(const QModelIndex& index);
+
 private:
     bool isZoomInPossible() const;
     bool isZoomOutPossible() const;
 private:
     bool isZoomInPossible() const;
     bool isZoomOutPossible() const;
index 2a88fe6b8d764077277b9de7951d46e2600203fd..22f7940bd411c97e844ed768f9540ebfd3aea001 100644 (file)
@@ -66,8 +66,12 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi
                              m_proxyModel);
     setWidget(m_view);
 
                              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)));
+    connect(m_view, SIGNAL(infoMessage(QString)),
+            this, SLOT(slotInfoMessage(QString)));
+    connect(m_view, SIGNAL(errorMessage(QString)),
+            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>)));
     // TODO connect to urlsDropped
     // TOOD connect to requestContextMenu
     connect(m_view, SIGNAL(selectionChanged(QList<KFileItem>)), m_extension, SIGNAL(selectionInfo(QList<KFileItem>)));
@@ -77,9 +81,6 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi
     // 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)
 
-    // 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
     // TODO MMB-click should do something like KonqDirPart::mmbClicked
 
     // TODO updating the paste action
@@ -135,4 +136,9 @@ void DolphinPart::slotRequestItemInfo(const KFileItem& item)
     emit m_extension->mouseOverInfo(&item);
 }
 
     emit m_extension->mouseOverInfo(&item);
 }
 
+void DolphinPart::slotItemTriggered(const KFileItem& item)
+{
+    emit m_extension->openUrlRequest(item.url());
+}
+
 #include "dolphinpart.moc"
 #include "dolphinpart.moc"
index d6d126cc7b6581aa966978c69ac6877be71372d1..a9806d595c17f28f9b6588ffeacc751d1e1b59d1 100644 (file)
@@ -52,6 +52,7 @@ private Q_SLOTS:
     void slotInfoMessage(const QString& msg);
     void slotErrorMessage(const QString& msg);
     void slotRequestItemInfo(const KFileItem& item);
     void slotInfoMessage(const QString& msg);
     void slotErrorMessage(const QString& msg);
     void slotRequestItemInfo(const KFileItem& item);
+    void slotItemTriggered(const KFileItem& item);
 
 private:
     DolphinView* m_view;
 
 private:
     DolphinView* m_view;
index edf242e669bc6c48340e27c587441dab8d319140..b2c621dbdfca69a71b991adc56cd3cd9a10fd64b 100644 (file)
@@ -58,9 +58,6 @@ DolphinStatusBar::DolphinStatusBar(QWidget* parent, const KUrl& url) :
     setMinimumHeight(barHeight);
     m_messageLabel->setMinimumTextHeight(barHeight);
     m_spaceInfo->setFixedHeight(barHeight);
     setMinimumHeight(barHeight);
     m_messageLabel->setMinimumTextHeight(barHeight);
     m_spaceInfo->setFixedHeight(barHeight);
-
-    connect(parent, SIGNAL(urlChanged(const KUrl&)),
-            this, SLOT(updateSpaceInfoContent(const KUrl&)));
 }
 
 
 }
 
 
index 207b236ee9e6e02e4c965fee23ec26e43d99b220..073ab55898744d6cc0fee19cbc998ab8e623e3af 100644 (file)
@@ -450,11 +450,7 @@ void DolphinView::activate()
 
 void DolphinView::triggerItem(const QModelIndex& index)
 {
 
 void DolphinView::triggerItem(const QModelIndex& index)
 {
-    if (!isValidNameIndex(index)) {
-        clearSelection();
-        showHoverInformation(index);
-        return;
-    }
+    Q_ASSERT(index.isValid());
 
     const Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers();
     if ((modifier & Qt::ShiftModifier) || (modifier & Qt::ControlModifier)) {
 
     const Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers();
     if ((modifier & Qt::ShiftModifier) || (modifier & Qt::ControlModifier)) {
@@ -463,38 +459,12 @@ void DolphinView::triggerItem(const QModelIndex& index)
         return;
     }
 
         return;
     }
 
-    KFileItem item = m_dirModel->itemForIndex(m_proxyModel->mapToSource(index));
+    const KFileItem item = m_dirModel->itemForIndex(m_proxyModel->mapToSource(index));
     if (item.isNull()) {
         return;
     }
 
     if (item.isNull()) {
         return;
     }
 
-    // The stuff below should be moved to ViewContainer and be just a signal?
-
-    // Prefer the local path over the URL.
-    bool isLocal;
-    KUrl url = item.mostLocalUrl(isLocal);
-
-    if (item.isDir()) {
-        setUrl(url);
-    } else if (item.isFile()) {
-        // allow to browse through ZIP and tar files
-        KMimeType::Ptr mime = item.mimeTypePtr();
-        if (mime->is("application/zip")) {
-            url.setProtocol("zip");
-            setUrl(url);
-        } else if (mime->is("application/x-tar") ||
-                   mime->is("application/x-tarz") ||
-                   mime->is("application/x-bzip-compressed-tar") ||
-                   mime->is("application/x-compressed-tar") ||
-                   mime->is("application/x-tzo")) {
-            url.setProtocol("tar");
-            setUrl(url);
-        } else {
-            item.run();
-        }
-    } else {
-        item.run();
-    }
+    emit itemTriggered(item); // caught by DolphinViewContainer or DolphinPart
 }
 
 void DolphinView::generatePreviews(const QList<KFileItem>& items)
 }
 
 void DolphinView::generatePreviews(const QList<KFileItem>& items)
index cd6bd977aff34b524321dba7ca6b2216a2166006..aae342574113af588273b2378780bd41188a9e81 100644 (file)
@@ -318,6 +318,11 @@ signals:
     /** Is emitted if URL of the view has been changed to \a url. */
     void urlChanged(const KUrl& url);
 
     /** Is emitted if URL of the view has been changed to \a url. */
     void urlChanged(const KUrl& url);
 
+    /**
+     * Is emitted when clicking on an item
+     */
+    void itemTriggered(const KFileItem& item);
+
     /**
      * Is emitted if the view mode (IconsView, DetailsView,
      * PreviewsView) has been changed.
     /**
      * Is emitted if the view mode (IconsView, DetailsView,
      * PreviewsView) has been changed.
index dad35463e4595a1a506200730346b36f367129df..514e9e7b3ddd7c632b964900cfb56941c046333d 100644 (file)
@@ -139,11 +139,15 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow,
             this, SLOT(showErrorMessage(const QString&)));
     connect(m_view, SIGNAL(infoMessage(const QString&)),
             this, SLOT(showInfoMessage(const QString&)));
             this, SLOT(showErrorMessage(const QString&)));
     connect(m_view, SIGNAL(infoMessage(const QString&)),
             this, SLOT(showInfoMessage(const QString&)));
+    connect(m_view, SIGNAL(itemTriggered(KFileItem)),
+            this, SLOT(slotItemTriggered(KFileItem)));
 
     connect(m_urlNavigator, SIGNAL(urlChanged(const KUrl&)),
             m_view, SLOT(setUrl(const KUrl&)));
 
     m_statusBar = new DolphinStatusBar(this, url);
 
     connect(m_urlNavigator, SIGNAL(urlChanged(const KUrl&)),
             m_view, SLOT(setUrl(const KUrl&)));
 
     m_statusBar = new DolphinStatusBar(this, url);
+    connect(m_view, SIGNAL(urlChanged(const KUrl&)),
+            m_statusBar, SLOT(updateSpaceInfoContent(const KUrl&)));
 
     m_filterBar = new FilterBar(this);
     m_filterBar->setVisible(settings->filterBar());
 
     m_filterBar = new FilterBar(this);
     m_filterBar->setVisible(settings->filterBar());
@@ -475,4 +479,33 @@ void DolphinViewContainer::activate()
     setActive(true);
 }
 
     setActive(true);
 }
 
+void DolphinViewContainer::slotItemTriggered(const KFileItem& item)
+{
+    // Prefer the local path over the URL.
+    bool isLocal;
+    KUrl url = item.mostLocalUrl(isLocal);
+
+    if (item.isDir()) {
+        m_view->setUrl(url);
+    } else if (item.isFile()) {
+        // allow to browse through ZIP and tar files
+        KMimeType::Ptr mime = item.mimeTypePtr();
+        if (mime->is("application/zip")) {
+            url.setProtocol("zip");
+            m_view->setUrl(url);
+        } else if (mime->is("application/x-tar") ||
+                   mime->is("application/x-tarz") ||
+                   mime->is("application/x-bzip-compressed-tar") ||
+                   mime->is("application/x-compressed-tar") ||
+                   mime->is("application/x-tzo")) {
+            url.setProtocol("tar");
+            m_view->setUrl(url);
+        } else {
+            item.run();
+        }
+    } else {
+        item.run();
+    }
+}
+
 #include "dolphinviewcontainer.moc"
 #include "dolphinviewcontainer.moc"
index 95be9134c50684b9ea223c7f7a15ca6050cc0367..2e49933161de4d15e1100ca673c6a1f39311f04d 100644 (file)
@@ -151,6 +151,11 @@ private slots:
      */
     void updateItemCount();
 
      */
     void updateItemCount();
 
+    /**
+     * Handles clicking on an item
+     */
+    void slotItemTriggered(const KFileItem& item);
+
     /**
      * Shows the information for the item \a item inside the statusbar. If the
      * item is null, the default statusbar information is shown.
     /**
      * Shows the information for the item \a item inside the statusbar. If the
      * item is null, the default statusbar information is shown.