diff options
| author | Peter Penz <[email protected]> | 2008-12-12 19:44:28 +0000 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2008-12-12 19:44:28 +0000 |
| commit | 37c5fc08133ff32941c7215c71084d6cdb7c6c6a (patch) | |
| tree | defaa3691951450e77c99227fece8e16352d4ff4 /src | |
| parent | 03407356cac7e07147b22077c5e6218bb8d53063 (diff) | |
If the users enters an URL that represents a file, open the file by the corresponding application instead of showing an error message.
BUG: 165877
svn path=/trunk/KDE/kdebase/apps/; revision=896189
Diffstat (limited to 'src')
| -rw-r--r-- | src/dolphindirlister.cpp | 6 | ||||
| -rw-r--r-- | src/dolphindirlister.h | 3 | ||||
| -rw-r--r-- | src/dolphinviewcontainer.cpp | 11 | ||||
| -rw-r--r-- | src/dolphinviewcontainer.h | 11 |
4 files changed, 29 insertions, 2 deletions
diff --git a/src/dolphindirlister.cpp b/src/dolphindirlister.cpp index 8da962b18..63320b528 100644 --- a/src/dolphindirlister.cpp +++ b/src/dolphindirlister.cpp @@ -32,7 +32,11 @@ DolphinDirLister::~DolphinDirLister() 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" diff --git a/src/dolphindirlister.h b/src/dolphindirlister.h index 26eb76018..b615f63ba 100644 --- a/src/dolphindirlister.h +++ b/src/dolphindirlister.h @@ -41,6 +41,9 @@ signals: /** 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); }; diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index c75553c4b..371eef654 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -117,6 +117,8 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow, 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, @@ -425,4 +427,13 @@ void DolphinViewContainer::slotItemTriggered(const KFileItem& item) 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" diff --git a/src/dolphinviewcontainer.h b/src/dolphinviewcontainer.h index 15a0ae6a8..d2adb5ed7 100644 --- a/src/dolphinviewcontainer.h +++ b/src/dolphinviewcontainer.h @@ -142,11 +142,20 @@ private slots: 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. */ |
