┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/urlbutton.cpp11
-rw-r--r--src/urlbutton.h2
-rw-r--r--src/urlnavigator.cpp73
-rw-r--r--src/urlnavigator.h75
-rw-r--r--src/urlnavigatorbutton.cpp26
-rw-r--r--src/urlnavigatorbutton.h6
6 files changed, 82 insertions, 111 deletions
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 <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),
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 ([email protected]) *
+ * Copyright (C) 2006 by Peter Penz (<[email protected]>) *
* Copyright (C) 2006 by Aaron J. Seigo (<[email protected]>) *
* Copyright (C) 2006 by Patrice Tremblay *
* *
@@ -21,42 +21,24 @@
#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;
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 *
-* *
-* 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 *
-***************************************************************************/
+/***************************************************************************
+ * Copyright (C) 2006 by Peter Penz (<[email protected]>) *
+ * Copyright (C) 2006 by Aaron J. Seigo (<[email protected]>) *
+ * 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
+#ifndef URLNAVIGATOR_H
+#define URLNAVIGATOR_H
-
-//Added by qt3to4:
-#include <QLabel>
-#include <Q3ValueList>
-#include <QKeyEvent>
-#include <Q3PopupMenu>
+#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;
/**
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 <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);
}
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 <kio/global.h>
#include <urlbutton.h>
@@ -27,6 +28,7 @@ class KJob;
class KUrl;
class UrlNavigator;
class QPainter;
+class QPaintEvent;
namespace KIO
{