void DolphinDirLister::handleError(KIO::Job* job)
{
- emit errorMessage(job->errorString());
+ if (job->error() == KIO::ERR_IS_FILE) {
+ emit urlIsFileError(url());
+ } else {
+ emit errorMessage(job->errorString());
+ }
}
#include "dolphindirlister.moc"
/** Is emitted whenever an error has occurred. */
void errorMessage(const QString& msg);
+ /** Is emitted when the URL of the directory lister represents a file. */
+ void urlIsFileError(const KUrl& url);
+
protected:
virtual void handleError(KIO::Job* job);
};
this, SLOT(showInfoMessage(const QString&)));
connect(m_dirLister, SIGNAL(errorMessage(const QString&)),
this, SLOT(showErrorMessage(const QString&)));
+ connect(m_dirLister, SIGNAL(urlIsFileError(const KUrl&)),
+ this, SLOT(openFile(const KUrl&)));
m_view = new DolphinView(this,
url,
item.run();
}
+void DolphinViewContainer::openFile(const KUrl& url)
+{
+ // Using m_dolphinModel for getting the file item instance is not possible
+ // here: openFile() is triggered by an error of the directory lister
+ // job, so the file item must be received "manually".
+ const KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url);
+ slotItemTriggered(item);
+}
+
#include "dolphinviewcontainer.moc"
void slotDirListerCompleted();
/**
- * Handles clicking on an item
+ * Handles clicking on an item. If the item is a directory, the
+ * directory is opened in the view. If the item is a file, the file
+ * gets started by the corresponding application.
*/
void slotItemTriggered(const KFileItem& item);
+ /**
+ * Opens a the file \a url by opening the corresponding application.
+ * Is connected with the signal urlIsFile() from DolphinDirLister and will
+ * get invoked if the user manually has entered a file into the URL navigator.
+ */
+ void openFile(const KUrl& url);
+
/**
* Shows the information for the item \a item inside the statusbar. If the
* item is null, the default statusbar information is shown.