File indexing completed on 2024-04-28 17:06:19

0001 /*
0002     SPDX-FileCopyrightText: 2004 Shie Erlich <erlich@users.sourceforge.net>
0003     SPDX-FileCopyrightText: 2004 Rafi Yanai <yanai@users.sourceforge.net>
0004     SPDX-FileCopyrightText: 2010 Jan Lepper <dehtris@yahoo.de>
0005     SPDX-FileCopyrightText: 2004-2022 Krusader Krew <https://krusader.org>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #ifndef DIRHISTORYQUEUE_H
0011 #define DIRHISTORYQUEUE_H
0012 
0013 // QtCore
0014 #include <QObject>
0015 #include <QStringList>
0016 #include <QUrl>
0017 
0018 #include <KConfigCore/KConfigGroup>
0019 
0020 class KrPanel;
0021 
0022 class DirHistoryQueue : public QObject
0023 {
0024     Q_OBJECT
0025 public:
0026     explicit DirHistoryQueue(KrPanel *panel);
0027     ~DirHistoryQueue() override;
0028 
0029     void clear();
0030     int currentPos()
0031     {
0032         return _currentPos;
0033     }
0034     int count()
0035     {
0036         return _urlQueue.count();
0037     }
0038     QUrl currentUrl();
0039     void setCurrentUrl(const QUrl &url);
0040     const QUrl &get(int pos)
0041     {
0042         return _urlQueue[pos];
0043     }
0044     void add(QUrl url, const QString &currentItem);
0045     bool gotoPos(int pos);
0046     bool goBack();
0047     bool goForward();
0048     bool canGoBack()
0049     {
0050         return _currentPos < count() - 1;
0051     }
0052     bool canGoForward()
0053     {
0054         return _currentPos > 0;
0055     }
0056     QString currentItem(); // current item of the view
0057 
0058     void save(KConfigGroup cfg);
0059     bool restore(const KConfigGroup &cfg);
0060 
0061 public slots:
0062     void saveCurrentItem();
0063 
0064 private:
0065     KrPanel *_panel;
0066     int _currentPos;
0067     QList<QUrl> _urlQueue;
0068     QStringList _currentItems;
0069 };
0070 
0071 #endif