┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Faure <[email protected]>2007-03-26 18:34:52 +0000
committerDavid Faure <[email protected]>2007-03-26 18:34:52 +0000
commitad6c01d200e2504de1a383355bd82906fe5c06ed (patch)
tree8adbbc4668426ef54f7fd0fc7d06b441bdd06a80 /src
parent1a321e5fbcdaf7d92d023bb1f8f2c6352b3c133e (diff)
Using a QLinkedList mostly for "accessing element at index i" is not the best solution performance-wise... use a QList instead.
svn path=/trunk/KDE/kdebase/apps/; revision=646813
Diffstat (limited to 'src')
-rw-r--r--src/dolphinmainwindow.cpp2
-rw-r--r--src/dolphinview.cpp11
-rw-r--r--src/dolphinview.h2
-rw-r--r--src/urlnavigator.cpp32
-rw-r--r--src/urlnavigator.h7
5 files changed, 24 insertions, 30 deletions
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
index 775ef9864..ebf8a3f82 100644
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -1348,7 +1348,7 @@ void DolphinMainWindow::setupDockWidgets()
void DolphinMainWindow::updateHistory()
{
int index = 0;
- const QLinkedList<UrlNavigator::HistoryElem> list = m_activeView->urlHistory(index);
+ const QList<UrlNavigator::HistoryElem> list = m_activeView->urlHistory(index);
QAction* backAction = actionCollection()->action("go_back");
if (backAction != 0) {
diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp
index 99757bac7..311ca36b4 100644
--- a/src/dolphinview.cpp
+++ b/src/dolphinview.cpp
@@ -453,7 +453,7 @@ void DolphinView::setUrlEditable(bool editable)
m_urlNavigator->editUrl(editable);
}
-const QLinkedList<UrlNavigator::HistoryElem> DolphinView::urlHistory(int& index) const
+const QList<UrlNavigator::HistoryElem> DolphinView::urlHistory(int& index) const
{
return m_urlNavigator->history(index);
}
@@ -771,15 +771,14 @@ void DolphinView::showPreview(const KFileItem* item, const QPixmap& pixmap)
void DolphinView::restoreContentsPos()
{
int index = 0;
- const QLinkedList<UrlNavigator::HistoryElem> history = urlHistory(index);
+ const QList<UrlNavigator::HistoryElem> history = urlHistory(index);
if (!history.isEmpty()) {
QAbstractItemView* view = itemView();
// TODO: view->setCurrentItem(history[index].currentFileName());
- QLinkedList<UrlNavigator::HistoryElem>::const_iterator it = history.begin();
- it += index;
- view->horizontalScrollBar()->setValue((*it).contentsX());
- view->verticalScrollBar()->setValue((*it).contentsY());
+ const UrlNavigator::HistoryElem& it = history[index];
+ view->horizontalScrollBar()->setValue(it.contentsX());
+ view->verticalScrollBar()->setValue(it.contentsY());
}
}
diff --git a/src/dolphinview.h b/src/dolphinview.h
index aee10bcad..0bec4824a 100644
--- a/src/dolphinview.h
+++ b/src/dolphinview.h
@@ -217,7 +217,7 @@ public:
* @param index Output parameter which indicates the current
* index of the location.
*/
- const QLinkedList<UrlNavigator::HistoryElem> urlHistory(int& index) const;
+ const QList<UrlNavigator::HistoryElem> urlHistory(int& index) const;
/** Returns true, if at least one item is selected. */
bool hasSelection() const;
diff --git a/src/urlnavigator.cpp b/src/urlnavigator.cpp
index 00edcfe50..1a49b386b 100644
--- a/src/urlnavigator.cpp
+++ b/src/urlnavigator.cpp
@@ -142,9 +142,7 @@ UrlNavigator::~UrlNavigator()
const KUrl& UrlNavigator::url() const
{
assert(!m_history.empty());
- QLinkedList<HistoryElem>::const_iterator it = m_history.begin();
- it += m_historyIndex;
- return (*it).url();
+ return m_history[m_historyIndex].url();
}
KUrl UrlNavigator::url(int index) const
@@ -167,7 +165,7 @@ KUrl UrlNavigator::url(int index) const
return newurl;
}
-const QLinkedList<UrlNavigator::HistoryElem>& UrlNavigator::history(int& index) const
+const QList<UrlNavigator::HistoryElem>& UrlNavigator::history(int& index) const
{
index = m_historyIndex;
return m_history;
@@ -273,26 +271,22 @@ 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.
- QLinkedList<HistoryElem>::const_iterator it = m_history.begin();
- it += m_historyIndex - 1;
- const KUrl& nextUrl = (*it).url();
- if (transformedUrl == nextUrl) {
+ HistoryElem& prevHistoryElem = m_history[m_historyIndex - 1];
+ if (transformedUrl == prevHistoryElem.url()) {
goForward();
// kDebug() << "goin' forward in history" << endl;
return;
}
}
- QLinkedList<HistoryElem>::iterator it = m_history.begin() + m_historyIndex;
- const KUrl& currUrl = (*it).url();
- if (currUrl == transformedUrl) {
+ if (this->url() == transformedUrl) {
// don't insert duplicate history elements
-// kDebug() << "currUrl == transformedUrl" << endl;
+// kDebug() << "current url == transformedUrl" << endl;
return;
}
updateHistoryElem();
- m_history.insert(it, HistoryElem(transformedUrl));
+ m_history.insert(m_historyIndex, HistoryElem(transformedUrl));
updateContent();
@@ -302,7 +296,7 @@ void UrlNavigator::setUrl(const KUrl& url)
// Prevent an endless growing of the history: remembering
// the last 100 Urls should be enough...
if (m_historyIndex > 100) {
- m_history.erase(m_history.begin());
+ m_history.removeFirst();
--m_historyIndex;
}
@@ -326,9 +320,9 @@ void UrlNavigator::requestActivation()
void UrlNavigator::storeContentsPosition(int x, int y)
{
- QLinkedList<HistoryElem>::iterator it = m_history.begin() + m_historyIndex;
- (*it).setContentsX(x);
- (*it).setContentsY(y);
+ HistoryElem& hist = m_history[m_historyIndex];
+ hist.setContentsX(x);
+ hist.setContentsY(y);
}
void UrlNavigator::keyReleaseEvent(QKeyEvent* event)
@@ -498,8 +492,8 @@ void UrlNavigator::updateHistoryElem()
assert(m_historyIndex >= 0);
const KFileItem* item = 0; // TODO: m_dolphinView->currentFileItem();
if (item != 0) {
- QLinkedList<HistoryElem>::iterator it = m_history.begin() + m_historyIndex;
- (*it).setCurrentFileName(item->name());
+ HistoryElem& hist = m_history[m_historyIndex];
+ hist.setCurrentFileName(item->name());
}
}
diff --git a/src/urlnavigator.h b/src/urlnavigator.h
index 01be439f7..5e0d7f836 100644
--- a/src/urlnavigator.h
+++ b/src/urlnavigator.h
@@ -24,6 +24,7 @@
#include <kurl.h>
#include <QWidget>
+#include <QList>
#include <QLinkedList>
class QHBoxLayout;
@@ -58,7 +59,7 @@ class ProtocolCombo;
* back and forward within this history.
*/
-typedef QLinkedList<KUrl> UrlStack;
+//typedef QList<KUrl> UrlStack;
class UrlNavigator : public QWidget
{
@@ -111,7 +112,7 @@ public:
* @param index Output parameter which indicates the current
* index of the location.
*/
- const QLinkedList<HistoryElem>& history(int& index) const;
+ const QList<HistoryElem>& history(int& index) const;
/**
* Goes back one step in the URL history. The signals
@@ -304,7 +305,7 @@ private:
QHBoxLayout* m_layout;
- QLinkedList<HistoryElem> m_history;
+ QList<HistoryElem> m_history;
QToolButton* m_toggleButton;
BookmarkSelector* m_bookmarkSelector;
KUrlComboBox* m_pathBox;