]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Using a QLinkedList mostly for "accessing element at index i" is not the best solutio...
authorDavid Faure <faure@kde.org>
Mon, 26 Mar 2007 18:34:52 +0000 (18:34 +0000)
committerDavid Faure <faure@kde.org>
Mon, 26 Mar 2007 18:34:52 +0000 (18:34 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=646813

src/dolphinmainwindow.cpp
src/dolphinview.cpp
src/dolphinview.h
src/urlnavigator.cpp
src/urlnavigator.h

index 775ef9864f75a3fd6396eb5fe06a4260cf6c1461..ebf8a3f826c7b6d4698ce8e8b5ebc2a5d82f91d5 100644 (file)
@@ -1348,7 +1348,7 @@ void DolphinMainWindow::setupDockWidgets()
 void DolphinMainWindow::updateHistory()\r
 {\r
     int index = 0;\r
 void DolphinMainWindow::updateHistory()\r
 {\r
     int index = 0;\r
-    const QLinkedList<UrlNavigator::HistoryElem> list = m_activeView->urlHistory(index);\r
+    const QList<UrlNavigator::HistoryElem> list = m_activeView->urlHistory(index);\r
 \r
     QAction* backAction = actionCollection()->action("go_back");\r
     if (backAction != 0) {\r
 \r
     QAction* backAction = actionCollection()->action("go_back");\r
     if (backAction != 0) {\r
index 99757bac7510015391bd6c6bc5340e34b847a258..311ca36b4508c1db2ec37daae2be552712d89f59 100644 (file)
@@ -453,7 +453,7 @@ void DolphinView::setUrlEditable(bool editable)
     m_urlNavigator->editUrl(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);
 }
 {
     return m_urlNavigator->history(index);
 }
@@ -771,15 +771,14 @@ void DolphinView::showPreview(const KFileItem* item, const QPixmap& pixmap)
 void DolphinView::restoreContentsPos()
 {
     int index = 0;
 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());
 
     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());
     }
 }
 
     }
 }
 
index aee10bcad5684d680a6908027d538b256b5aeca8..0bec4824af97cc932d708a02562c05bfba2cd38d 100644 (file)
@@ -217,7 +217,7 @@ public:
      * @param index     Output parameter which indicates the current
      *                  index of the location.
      */
      * @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;
 
     /** Returns true, if at least one item is selected. */
     bool hasSelection() const;
index 00edcfe503c8f7985c07ee36c51d076b9ebdb986..1a49b386b580007187fbebc99f08bbbea4a00c83 100644 (file)
@@ -142,9 +142,7 @@ UrlNavigator::~UrlNavigator()
 const KUrl& UrlNavigator::url() const
 {
     assert(!m_history.empty());
 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
 }
 
 KUrl UrlNavigator::url(int index) const
@@ -167,7 +165,7 @@ KUrl UrlNavigator::url(int index) const
     return newurl;
 }
 
     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;
 {
     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.
         // 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;
         }
     }
 
             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
         // don't insert duplicate history elements
-//         kDebug() << "currUrl == transformedUrl" << endl;
+//         kDebug() << "current url == transformedUrl" << endl;
         return;
     }
 
     updateHistoryElem();
         return;
     }
 
     updateHistoryElem();
-    m_history.insert(it, HistoryElem(transformedUrl));
+    m_history.insert(m_historyIndex, HistoryElem(transformedUrl));
 
     updateContent();
 
 
     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) {
     // 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;
     }
 
         --m_historyIndex;
     }
 
@@ -326,9 +320,9 @@ void UrlNavigator::requestActivation()
 
 void UrlNavigator::storeContentsPosition(int x, int y)
 {
 
 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)
 }
 
 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) {
     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());
     }
 }
 
     }
 }
 
index 01be439f76ef8d51128dfe8accac763d77c978a8..5e0d7f836feb9c3cf1596b33d7b24eda9922e930 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <kurl.h>
 #include <QWidget>
 
 #include <kurl.h>
 #include <QWidget>
+#include <QList>
 #include <QLinkedList>
 
 class QHBoxLayout;
 #include <QLinkedList>
 
 class QHBoxLayout;
@@ -58,7 +59,7 @@ class ProtocolCombo;
  * back and forward within this history.
 */
 
  * back and forward within this history.
 */
 
-typedef QLinkedList<KUrl> UrlStack;
+//typedef QList<KUrl> UrlStack;
 
 class UrlNavigator : public QWidget
 {
 
 class UrlNavigator : public QWidget
 {
@@ -111,7 +112,7 @@ public:
      * @param index     Output parameter which indicates the current
      *                  index of the location.
      */
      * @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
 
     /**
      * Goes back one step in the URL history. The signals
@@ -304,7 +305,7 @@ private:
 
     QHBoxLayout* m_layout;
 
 
     QHBoxLayout* m_layout;
 
-    QLinkedList<HistoryElem> m_history;
+    QList<HistoryElem> m_history;
     QToolButton* m_toggleButton;
     BookmarkSelector* m_bookmarkSelector;
     KUrlComboBox* m_pathBox;
     QToolButton* m_toggleButton;
     BookmarkSelector* m_bookmarkSelector;
     KUrlComboBox* m_pathBox;