***************************************************************************/
#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),
*
* 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
{
/***************************************************************************
- * 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(),
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
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;
// 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;
}
}
- 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;
}
updateHistoryElem();
-
- const Q3ValueListIterator<UrlNavigator::HistoryElem> it = m_history.at(m_historyIndex);
m_history.insert(it, HistoryElem(transformedUrl));
updateContent();
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)
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;
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;
-/**************************************************************************
-* 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;
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
{
* @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
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;
/**
#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) :
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
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);
m_listJob = 0;
m_subdirs.clear();
delete dirsMenu;
+ dirsMenu = 0;
+
setDisplayHintEnabled(PopupActiveHint, false);
}
* 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>
class KUrl;
class UrlNavigator;
class QPainter;
+class QPaintEvent;
namespace KIO
{