]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/urlnavigator.cpp
Do a custom error handling in for the 'Create New...' submenu. Thanks to David for...
[dolphin.git] / src / urlnavigator.cpp
index c76278e6114df3e2b64ebec5221162e1d5bb784b..d7c586961c632c72c510e61af5f5eee110426b24 100644 (file)
@@ -16,7 +16,7 @@
  *   You should have received a copy of the GNU General Public License     *
  *   along with this program; if not, write to the                         *
  *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
  ***************************************************************************/
 
 #include "urlnavigator.h"
@@ -51,7 +51,7 @@
 #include <kvbox.h>
 
 #include "bookmarkselector.h"
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
 #include "dolphinsettings.h"
 #include "dolphinstatusbar.h"
 #include "dolphinview.h"
@@ -136,7 +136,7 @@ void UrlNavigator::setUrl(const KUrl& url)
 {
     QString urlStr(url.pathOrUrl());
     //kDebug() << "setUrl(" << url << ")" << endl;
-    if (urlStr.at(0) == '~') {
+    if ( urlStr.length() > 0 && urlStr.at(0) == '~') {
         // replace '~' by the home directory
         urlStr.remove(0, 1);
         urlStr.insert(0, QDir::home().path());
@@ -203,7 +203,7 @@ KUrl UrlNavigator::url(int index) const
     QString path(url().pathOrUrl());
     path = path.section('/', 0, index);
 
-    if (path.at(path.length()-1) != '/')
+    if ( path.length() >= 1 && path.at(path.length()-1) != '/')
     {
         path.append('/');
     }
@@ -301,7 +301,7 @@ void UrlNavigator::slotReturnPressed(const QString& text)
     }
 
     QStringList urls = m_pathBox->urls();
-    urls.remove(typedUrl.url());
+    urls.removeAll(typedUrl.url());
     urls.prepend(typedUrl.url());
     m_pathBox->setUrls(urls, KUrlComboBox::RemoveBottom);
 
@@ -323,7 +323,7 @@ void UrlNavigator::slotRemoteHostActivated()
     QString host = m_host->text();
     QString user;
 
-    int marker = host.find("@");
+    int marker = host.indexOf("@");
     if (marker != -1)
     {
         user = host.left(marker);
@@ -331,7 +331,7 @@ void UrlNavigator::slotRemoteHostActivated()
         host = host.right(host.length() - marker - 1);
     }
 
-    marker = host.find("/");
+    marker = host.indexOf("/");
     if (marker != -1)
     {
         u.setPath(host.right(host.length() - marker));
@@ -447,7 +447,7 @@ void UrlNavigator::slotClicked()
 void UrlNavigator::updateHistoryElem()
 {
     assert(m_historyIndex >= 0);
-    const KFileItem* item = m_dolphinView->currentFileItem();
+    const KFileItem* item = 0; // TODO: m_dolphinView->currentFileItem();
     if (item != 0) {
         m_history[m_historyIndex].setCurrentFileName(item->name());
     }
@@ -468,24 +468,24 @@ void UrlNavigator::updateContent()
 
     m_bookmarkSelector->updateSelection(url());
 
-    QToolTip::remove(m_toggleButton);
+    m_toggleButton->setToolTip(QString());
     QString path(url().pathOrUrl());
-    const KAction* action = Dolphin::mainWin().actionCollection()->action("editable_location");
+    const QAction* action = dolphinView()->mainWindow()->actionCollection()->action("editable_location");
     // TODO: registry of default shortcuts
-    QString shortcut = action? action->shortcutText() : "Ctrl+L";
+    QString shortcut = action? action->shortcut().toString() : "Ctrl+L";
     if (m_toggleButton->isChecked()) {
         delete m_protocols; m_protocols = 0;
         delete m_protocolSeparator; m_protocolSeparator = 0;
         delete m_host; m_host = 0;
 
-        QToolTip::add(m_toggleButton, i18n("Browse (%1, Escape)",shortcut));
+        m_toggleButton->setToolTip(i18n("Browse (%1, Escape)",shortcut));
 
         setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
         m_pathBox->show();
         m_pathBox->setUrl(url());
     }
     else {
-        QToolTip::add(m_toggleButton, i18n("Edit location (%1)",shortcut));
+        m_toggleButton->setToolTip(i18n("Edit location (%1)",shortcut));
 
         setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
         m_pathBox->hide();
@@ -502,8 +502,8 @@ void UrlNavigator::updateContent()
             // path. E. g. "fish://root@192.168.0.2/var/lib" writes
             // "fish://root@192.168.0.2" to 'bookmarkPath', which leads to the
             // navigation indication 'Custom Path > var > lib".
-            int idx = path.find(QString("//"));
-            idx = path.find("/", (idx < 0) ? 0 : idx + 2);
+            int idx = path.indexOf(QString("//"));
+            idx = path.indexOf("/", (idx < 0) ? 0 : idx + 2);
             bookmarkPath = (idx < 0) ? path : path.left(idx);
         }
         else {