1 /***************************************************************************** 2 * Copyright (C) 2004 Shie Erlich <erlich@users.sourceforge.net> * 3 * Copyright (C) 2004 Rafi Yanai <yanai@users.sourceforge.net> * 4 * Copyright (C) 2010 Jan Lepper <dehtris@yahoo.de> * 5 * Copyright (C) 2004-2019 Krusader Krew [https://krusader.org] * 6 * * 7 * This file is part of Krusader [https://krusader.org]. * 8 * * 9 * Krusader is free software: you can redistribute it and/or modify * 10 * it under the terms of the GNU General Public License as published by * 11 * the Free Software Foundation, either version 2 of the License, or * 12 * (at your option) any later version. * 13 * * 14 * Krusader is distributed in the hope that it will be useful, * 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 17 * GNU General Public License for more details. * 18 * * 19 * You should have received a copy of the GNU General Public License * 20 * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * 21 *****************************************************************************/ 22 23 #ifndef DIRHISTORYQUEUE_H 24 #define DIRHISTORYQUEUE_H 25 26 // QtCore 27 #include <QObject> 28 #include <QStringList> 29 #include <QUrl> 30 31 # include <KConfigCore/KConfigGroup> 32 33 class KrPanel; 34 35 class DirHistoryQueue : public QObject 36 { 37 Q_OBJECT 38 public: 39 explicit DirHistoryQueue(KrPanel *panel); 40 ~DirHistoryQueue(); 41 42 void clear(); currentPos()43 int currentPos() { 44 return _currentPos; 45 } count()46 int count() { 47 return _urlQueue.count(); 48 } 49 QUrl currentUrl(); 50 void setCurrentUrl(const QUrl &url); get(int pos)51 const QUrl &get(int pos) { 52 return _urlQueue[pos]; 53 } 54 void add(QUrl url, QString currentItem); 55 bool gotoPos(int pos); 56 bool goBack(); 57 bool goForward(); canGoBack()58 bool canGoBack() { 59 return _currentPos < count() - 1; 60 } canGoForward()61 bool canGoForward() { 62 return _currentPos > 0; 63 } 64 QString currentItem(); // current item of the view 65 66 void save(KConfigGroup cfg); 67 bool restore(KConfigGroup cfg); 68 69 public slots: 70 void saveCurrentItem(); 71 72 private: 73 KrPanel* _panel; 74 int _currentPos; 75 QList<QUrl> _urlQueue; 76 QStringList _currentItems; 77 }; 78 79 #endif 80