]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Cleanup: don't use deprecated Qt3 classes or methods, removed unnecessary includes
authorPeter Penz <peter.penz19@gmail.com>
Sat, 17 Feb 2007 13:43:47 +0000 (13:43 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Sat, 17 Feb 2007 13:43:47 +0000 (13:43 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=634516

src/urlbutton.cpp
src/urlbutton.h
src/urlnavigator.cpp
src/urlnavigator.h
src/urlnavigatorbutton.cpp
src/urlnavigatorbutton.h

index b1faae393915e1949bafecc047f824de15f65ca2..0ef302999a1b4dc519dbfe1fc709af949fa756ca 100644 (file)
  ***************************************************************************/
 
 #include "urlnavigatorbutton.h"
-#include <kurl.h>
-#include <qtooltip.h>
-#include <qcursor.h>
-#include <qfontmetrics.h>
-//Added by qt3to4:
-#include <QEvent>
-#include <kiconloader.h>
-#include <klocale.h>
-
 #include "urlnavigator.h"
-#include "dolphinmainwindow.h"
-
 
 UrlButton::UrlButton(UrlNavigator* parent) :
     QPushButton(parent),
index 06da18aba4c665d05219dd8418045409c92dab05..a922ea0cd365a09abe50ff38e57a4ea6dda069a9 100644 (file)
@@ -33,8 +33,6 @@ class QPainter;
  *
  * Each button of the URL navigator contains an URL, which
  * is set as soon as the button has been clicked.
-*
- * @author Peter Penz
  */
 class UrlButton : public QPushButton
 {
index 93de43e67817e186c654bfe057ec9d51c5f1ce5a..965e3f3d5a29db2683478ab73ed36e1d1fc0975f 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at)                  *
+ *   Copyright (C) 2006 by Peter Penz (<peter.penz@gmx.at>)                *
  *   Copyright (C) 2006 by Aaron J. Seigo (<aseigo@kde.org>)               *
  *   Copyright (C) 2006 by Patrice Tremblay                                *
  *                                                                         *
 
 #include "urlnavigator.h"
 
-#include <assert.h>
+#include "bookmarkselector.h"
+#include "dolphinsettings.h"
+#include "generalsettings.h"
+#include "protocolcombo.h"
+#include "urlnavigatorbutton.h"
 
-#include <qcombobox.h>
-#include <qfont.h>
-#include <qlabel.h>
-#include <q3listbox.h>
-#include <qlineedit.h>
-#include <qobject.h>
-#include <q3popupmenu.h>
-#include <qpushbutton.h>
-#include <qsizepolicy.h>
-#include <qtooltip.h>
-//Added by qt3to4:
-#include <QDir>
-#include <Q3ValueList>
-#include <QKeyEvent>
-#include <QCheckBox>
+#include <assert.h>
 
-#include <kaction.h>
-#include <kactioncollection.h>
-#include <kiconloader.h>
-#include <kio/job.h>
 #include <kfileitem.h>
 #include <klocale.h>
 #include <kprotocolinfo.h>
-#include <kurl.h>
 #include <kurlcombobox.h>
 #include <kurlcompletion.h>
-#include <kbookmarkmanager.h>
-#include <kvbox.h>
 
-#include "bookmarkselector.h"
-#include "dolphinsettings.h"
-#include "generalsettings.h"
-#include "protocolcombo.h"
-#include "urlnavigatorbutton.h"
+#include <QDir>
+#include <QCheckBox>
+#include <QLabel>
+#include <QLineEdit>
 
 UrlNavigator::HistoryElem::HistoryElem() :
     m_url(),
@@ -130,7 +112,9 @@ UrlNavigator::~UrlNavigator()
 const KUrl& UrlNavigator::url() const
 {
     assert(!m_history.empty());
-    return m_history[m_historyIndex].url();
+    QLinkedList<HistoryElem>::const_iterator it = m_history.begin();
+    it += m_historyIndex;
+    return (*it).url();
 }
 
 KUrl UrlNavigator::url(int index) const
@@ -147,7 +131,7 @@ KUrl UrlNavigator::url(int index) const
     return path;
 }
 
-const Q3ValueList<UrlNavigator::HistoryElem>& UrlNavigator::history(int& index) const
+const QLinkedList<UrlNavigator::HistoryElem>& UrlNavigator::history(int& index) const
 {
     index = m_historyIndex;
     return m_history;
@@ -243,7 +227,9 @@ void UrlNavigator::setUrl(const KUrl& url)
         // Check whether the previous element of the history has the same Url.
         // If yes, just go forward instead of inserting a duplicate history
         // element.
-        const KUrl& nextUrl = m_history[m_historyIndex - 1].url();
+        QLinkedList<HistoryElem>::const_iterator it = m_history.begin();
+        it += m_historyIndex - 1;
+        const KUrl& nextUrl = (*it).url();
         if (transformedUrl == nextUrl) {
             goForward();
 //             kDebug() << "goin' forward in history" << endl;
@@ -251,7 +237,8 @@ void UrlNavigator::setUrl(const KUrl& url)
         }
     }
 
-    const KUrl& currUrl = m_history[m_historyIndex].url();
+    QLinkedList<HistoryElem>::iterator it = m_history.begin() + m_historyIndex;
+    const KUrl& currUrl = (*it).url();
     if (currUrl == transformedUrl) {
         // don't insert duplicate history elements
 //         kDebug() << "currUrl == transformedUrl" << endl;
@@ -259,8 +246,6 @@ void UrlNavigator::setUrl(const KUrl& url)
     }
 
     updateHistoryElem();
-
-    const Q3ValueListIterator<UrlNavigator::HistoryElem> it = m_history.at(m_historyIndex);
     m_history.insert(it, HistoryElem(transformedUrl));
 
     updateContent();
@@ -296,8 +281,9 @@ void UrlNavigator::requestActivation()
 
 void UrlNavigator::storeContentsPosition(int x, int y)
 {
-    m_history[m_historyIndex].setContentsX(x);
-    m_history[m_historyIndex].setContentsY(y);
+    QLinkedList<HistoryElem>::iterator it = m_history.begin() + m_historyIndex;
+    (*it).setContentsX(x);
+    (*it).setContentsY(y);
 }
 
 void UrlNavigator::keyReleaseEvent(QKeyEvent* event)
@@ -391,8 +377,9 @@ void UrlNavigator::slotProtocolChanged(const QString& protocol)
     url.setProtocol(protocol);
     //url.setPath(KProtocolInfo::protocolClass(protocol) == ":local" ? "/" : "");
     url.setPath("/");
-    Q3ValueList<QWidget*>::const_iterator it = m_navButtons.constBegin();
-    while (it != m_navButtons.constEnd()) {
+    QLinkedList<QWidget*>::const_iterator it = m_navButtons.begin();
+    const QLinkedList<QWidget*>::const_iterator itEnd = m_navButtons.end();
+    while (it != itEnd) {
         (*it)->close();
         (*it)->deleteLater();
         ++it;
@@ -451,15 +438,17 @@ void UrlNavigator::updateHistoryElem()
     assert(m_historyIndex >= 0);
     const KFileItem* item = 0; // TODO: m_dolphinView->currentFileItem();
     if (item != 0) {
-        m_history[m_historyIndex].setCurrentFileName(item->name());
+        QLinkedList<HistoryElem>::iterator it = m_history.begin() + m_historyIndex;
+        (*it).setCurrentFileName(item->name());
     }
 }
 
 void UrlNavigator::updateContent()
 {
     // delete all existing Url navigator buttons
-    Q3ValueList<QWidget*>::const_iterator it = m_navButtons.constBegin();
-    while (it != m_navButtons.constEnd()) {
+    QLinkedList<QWidget*>::const_iterator it = m_navButtons.begin();
+    const QLinkedList<QWidget*>::const_iterator itEnd = m_navButtons.end();
+    while (it != itEnd) {
         (*it)->close();
         (*it)->deleteLater();
         ++it;
index bafece2ea98e179ac4909e257ecd1add8eb33630..1815a902c0a2d37c83e2cd9d037cb5b096b22ef0 100644 (file)
@@ -1,40 +1,33 @@
-/**************************************************************************
-*   Copyright (C) 2006 by Peter Penz                                      *
-*   peter.penz@gmx.at                                                     *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU General Public License as published by  *
-*   the Free Software Foundation; either version 2 of the License, or     *
-*   (at your option) any later version.                                   *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   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.,                                       *
-*   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
-***************************************************************************/
-
-#ifndef UrlNAVIGATOR_H
-#define UrlNAVIGATOR_H
-
-
-//Added by qt3to4:
-#include <QLabel>
-#include <Q3ValueList>
-#include <QKeyEvent>
-#include <Q3PopupMenu>
+/***************************************************************************
+ *   Copyright (C) 2006 by Peter Penz (<peter.penz@gmx.at>)                *
+ *   Copyright (C) 2006 by Aaron J. Seigo (<aseigo@kde.org>)               *
+ *   Copyright (C) 2006 by Patrice Tremblay                                *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   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.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
+ ***************************************************************************/
+
+#ifndef URLNAVIGATOR_H
+#define URLNAVIGATOR_H
+
+#include <khbox.h>
 #include <kurl.h>
-#include <qstring.h>
-#include <kvbox.h>
+#include <QLinkedList>
 
-class QComboBox;
 class QLabel;
 class QLineEdit;
-class Q3PopupMenu;
 class QCheckBox;
 
 class KUrl;
@@ -45,26 +38,24 @@ class BookmarkSelector;
 class ProtocolCombo;
 
 /**
- * @brief Navigation bar which contains the current shown Url.
+ * @brief Navigation bar which contains the current shown URL.
  *
- * The Url navigator offers two modes:
+ * The URL navigator offers two modes:
  * - Editable:     Represents the 'classic' mode, where the current Url
  *                 is editable inside a line editor.
- * - Non editable: The Url is represented by a number of buttons, where
- *                 clicking on a button results in activating the Url
+ * - Non editable: The URL is represented by a number of buttons, where
+ *                 clicking on a button results in activating the URL
  *                 the button represents. This mode also supports drag
  *                 and drop of items.
  *
  * The mode can be changed by a toggle button located on the left side of
  * the navigator.
  *
- * The Url navigator also remembers the Url history and allows to go
+ * The URL navigator also remembers the URL history and allows to go
  * back and forward within this history.
- *
- * @author Peter Penz
 */
 
-typedef Q3ValueList<KUrl> UrlStack;
+typedef QLinkedList<KUrl> UrlStack;
 
 class UrlNavigator : public KHBox
 {
@@ -117,7 +108,7 @@ public:
      * @param index     Output parameter which indicates the current
      *                  index of the location.
      */
-    const Q3ValueList<HistoryElem>& history(int& index) const;
+    const QLinkedList<HistoryElem>& history(int& index) const;
 
     /**
      * Goes back one step in the Url history. The signals
@@ -250,14 +241,14 @@ private slots:
 private:
     bool m_active;
     int m_historyIndex;
-    Q3ValueList<HistoryElem> m_history;
+    QLinkedList<HistoryElem> m_history;
     QCheckBox* m_toggleButton;
     BookmarkSelector* m_bookmarkSelector;
     KUrlComboBox* m_pathBox;
     ProtocolCombo* m_protocols;
     QLabel* m_protocolSeparator;
     QLineEdit* m_host;
-    Q3ValueList<QWidget*> m_navButtons;
+    QLinkedList<QWidget*> m_navButtons;
     //UrlStack m_urls;
 
     /**
index 9616558a56564f25ef5d0f00b9496136bb8f8676..fd8b7c225975188d9e8998ad6e5ac399ea7d40b4 100644 (file)
 
 #include "urlnavigator.h"
 
-#include <kglobalsettings.h>
-#include <kiconloader.h>
 #include <kio/job.h>
 #include <kio/jobclasses.h>
-#include <klocale.h>
-#include <kurl.h>
+#include <kglobalsettings.h>
+#include <kmenu.h>
 
-#include <Q3PopupMenu>
 #include <QPainter>
+#include <QPaintEvent>
 #include <QTimer>
 
 UrlNavigatorButton::UrlNavigatorButton(int index, UrlNavigator* parent) :
@@ -269,7 +267,7 @@ void UrlNavigatorButton::startListJob()
         return;
     }
 
-    KUrl url = urlNavigator()->url(m_index);
+    const KUrl& url = urlNavigator()->url(m_index);
     m_listJob = KIO::listDir(url, false, false);
     m_subdirs.clear(); // just to be ++safe
 
@@ -336,20 +334,22 @@ void UrlNavigatorButton::listJobFinished(KJob* job)
 
     setDisplayHintEnabled(PopupActiveHint, true);
     update(); // ensure the button is drawn highlighted
-    Q3PopupMenu* dirsMenu = new Q3PopupMenu(this);
-    //setMenu(dirsMenu);
+
+    KMenu* dirsMenu = new KMenu(this);
     QStringList::const_iterator it = m_subdirs.constBegin();
     QStringList::const_iterator itEnd = m_subdirs.constEnd();
     int i = 0;
     while (it != itEnd) {
-        dirsMenu->insertItem(*it, i);
+        QAction* action = new QAction(*it, this);
+        action->setData(i);
+        dirsMenu->addAction(action);
         ++it;
         ++i;
     }
 
-    int result = dirsMenu->exec(urlNavigator()->mapToGlobal(geometry().bottomLeft()));
-
-    if (result != -1) {
+    const QAction* action = dirsMenu->exec(urlNavigator()->mapToGlobal(geometry().bottomLeft()));
+    if (action != 0) {
+        const int result = action->data().toInt();
         KUrl url = urlNavigator()->url(m_index);
         url.addPath(m_subdirs[result]);
         urlNavigator()->setUrl(url);
@@ -358,6 +358,8 @@ void UrlNavigatorButton::listJobFinished(KJob* job)
     m_listJob = 0;
     m_subdirs.clear();
     delete dirsMenu;
+    dirsMenu = 0;
+
     setDisplayHintEnabled(PopupActiveHint, false);
 }
 
index 9234f0b104972f834ccba1d001342abe8c651ebe..55e74c46b19f6bad67499a302f92a6f69c8a22a0 100644 (file)
@@ -17,8 +17,9 @@
  *   Free Software Foundation, Inc.,                                       *
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
  ***************************************************************************/
-#ifndef UrlNAVIGATORBUTTON_H
-#define UrlNAVIGATORBUTTON_H
+
+#ifndef URLNAVIGATORBUTTON_H
+#define URLNAVIGATORBUTTON_H
 
 #include <kio/global.h>
 #include <urlbutton.h>
@@ -27,6 +28,7 @@ class KJob;
 class KUrl;
 class UrlNavigator;
 class QPainter;
+class QPaintEvent;
 
 namespace KIO
 {