Fixed connect() error in dolphinstatusbar [unrelated].
svn path=/trunk/KDE/kdebase/apps/; revision=705835
* 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);
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&)),
- controller, SLOT(triggerItem(const QModelIndex&)));
+ this, SLOT(slotItemActivated(const QModelIndex&)));
}
connect(this, SIGNAL(entered(const QModelIndex&)),
this, SLOT(slotEntered(const QModelIndex&)));
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"
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;
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 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
emit m_extension->mouseOverInfo(&item);
}
+void DolphinPart::slotItemTriggered(const KFileItem& item)
+{
+ emit m_extension->openUrlRequest(item.url());
+}
+
#include "dolphinpart.moc"
void slotInfoMessage(const QString& msg);
void slotErrorMessage(const QString& msg);
void slotRequestItemInfo(const KFileItem& item);
+ void slotItemTriggered(const KFileItem& item);
private:
DolphinView* m_view;
setMinimumHeight(barHeight);
m_messageLabel->setMinimumTextHeight(barHeight);
m_spaceInfo->setFixedHeight(barHeight);
-
- connect(parent, SIGNAL(urlChanged(const KUrl&)),
- this, SLOT(updateSpaceInfoContent(const KUrl&)));
}
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)) {
return;
}
- KFileItem item = m_dirModel->itemForIndex(m_proxyModel->mapToSource(index));
+ const KFileItem item = m_dirModel->itemForIndex(m_proxyModel->mapToSource(index));
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)
/** 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.
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_view, SIGNAL(urlChanged(const KUrl&)),
+ m_statusBar, SLOT(updateSpaceInfoContent(const KUrl&)));
m_filterBar = new FilterBar(this);
m_filterBar->setVisible(settings->filterBar());
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"
*/
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.