From: Peter Penz Date: Sat, 17 Feb 2007 13:43:47 +0000 (+0000) Subject: Cleanup: don't use deprecated Qt3 classes or methods, removed unnecessary includes X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/7cbd7aafd65b19102d1c81d9ed3955304f272ecd Cleanup: don't use deprecated Qt3 classes or methods, removed unnecessary includes svn path=/trunk/KDE/kdebase/apps/; revision=634516 --- diff --git a/src/urlbutton.cpp b/src/urlbutton.cpp index b1faae393..0ef302999 100644 --- a/src/urlbutton.cpp +++ b/src/urlbutton.cpp @@ -19,18 +19,7 @@ ***************************************************************************/ #include "urlnavigatorbutton.h" -#include -#include -#include -#include -//Added by qt3to4: -#include -#include -#include - #include "urlnavigator.h" -#include "dolphinmainwindow.h" - UrlButton::UrlButton(UrlNavigator* parent) : QPushButton(parent), diff --git a/src/urlbutton.h b/src/urlbutton.h index 06da18aba..a922ea0cd 100644 --- a/src/urlbutton.h +++ b/src/urlbutton.h @@ -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 { diff --git a/src/urlnavigator.cpp b/src/urlnavigator.cpp index 93de43e67..965e3f3d5 100644 --- a/src/urlnavigator.cpp +++ b/src/urlnavigator.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at) * + * Copyright (C) 2006 by Peter Penz () * * Copyright (C) 2006 by Aaron J. Seigo () * * Copyright (C) 2006 by Patrice Tremblay * * * @@ -21,42 +21,24 @@ #include "urlnavigator.h" -#include +#include "bookmarkselector.h" +#include "dolphinsettings.h" +#include "generalsettings.h" +#include "protocolcombo.h" +#include "urlnavigatorbutton.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//Added by qt3to4: -#include -#include -#include -#include +#include -#include -#include -#include -#include #include #include #include -#include #include #include -#include -#include -#include "bookmarkselector.h" -#include "dolphinsettings.h" -#include "generalsettings.h" -#include "protocolcombo.h" -#include "urlnavigatorbutton.h" +#include +#include +#include +#include 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::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::history(int& index) const +const QLinkedList& 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::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::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 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::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::const_iterator it = m_navButtons.constBegin(); - while (it != m_navButtons.constEnd()) { + QLinkedList::const_iterator it = m_navButtons.begin(); + const QLinkedList::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::iterator it = m_history.begin() + m_historyIndex; + (*it).setCurrentFileName(item->name()); } } void UrlNavigator::updateContent() { // delete all existing Url navigator buttons - Q3ValueList::const_iterator it = m_navButtons.constBegin(); - while (it != m_navButtons.constEnd()) { + QLinkedList::const_iterator it = m_navButtons.begin(); + const QLinkedList::const_iterator itEnd = m_navButtons.end(); + while (it != itEnd) { (*it)->close(); (*it)->deleteLater(); ++it; diff --git a/src/urlnavigator.h b/src/urlnavigator.h index bafece2ea..1815a902c 100644 --- a/src/urlnavigator.h +++ b/src/urlnavigator.h @@ -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 -#include -#include -#include +/*************************************************************************** + * Copyright (C) 2006 by Peter Penz () * + * Copyright (C) 2006 by Aaron J. Seigo () * + * 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 #include -#include -#include +#include -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 UrlStack; +typedef QLinkedList UrlStack; class UrlNavigator : public KHBox { @@ -117,7 +108,7 @@ public: * @param index Output parameter which indicates the current * index of the location. */ - const Q3ValueList& history(int& index) const; + const QLinkedList& 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 m_history; + QLinkedList m_history; QCheckBox* m_toggleButton; BookmarkSelector* m_bookmarkSelector; KUrlComboBox* m_pathBox; ProtocolCombo* m_protocols; QLabel* m_protocolSeparator; QLineEdit* m_host; - Q3ValueList m_navButtons; + QLinkedList m_navButtons; //UrlStack m_urls; /** diff --git a/src/urlnavigatorbutton.cpp b/src/urlnavigatorbutton.cpp index 9616558a5..fd8b7c225 100644 --- a/src/urlnavigatorbutton.cpp +++ b/src/urlnavigatorbutton.cpp @@ -24,15 +24,13 @@ #include "urlnavigator.h" -#include -#include #include #include -#include -#include +#include +#include -#include #include +#include #include 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); } diff --git a/src/urlnavigatorbutton.h b/src/urlnavigatorbutton.h index 9234f0b10..55e74c46b 100644 --- a/src/urlnavigatorbutton.h +++ b/src/urlnavigatorbutton.h @@ -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 #include @@ -27,6 +28,7 @@ class KJob; class KUrl; class UrlNavigator; class QPainter; +class QPaintEvent; namespace KIO {