File indexing completed on 2024-04-28 04:18:50

0001 /*
0002 Gwenview: an image viewer
0003 Copyright 2007 Aurélien Gâteau <agateau@kde.org>
0004 
0005 This program is free software; you can redistribute it and/or
0006 modify it under the terms of the GNU General Public License
0007 as published by the Free Software Foundation; either version 2
0008 of the License, or (at your option) any later version.
0009 
0010 This program is distributed in the hope that it will be useful,
0011 but WITHOUT ANY WARRANTY; without even the implied warranty of
0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013 GNU General Public License for more details.
0014 
0015 You should have received a copy of the GNU General Public License
0016 along with this program; if not, write to the Free Software
0017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
0018 
0019 */
0020 #ifndef CONTEXTMANAGER_H
0021 #define CONTEXTMANAGER_H
0022 
0023 #include <lib/gwenviewlib_export.h>
0024 
0025 // Qt
0026 #include <QObject>
0027 #include <QUrl>
0028 
0029 // KF
0030 #include <KFileItem>
0031 
0032 class QItemSelectionModel;
0033 class QModelIndex;
0034 
0035 namespace Gwenview
0036 {
0037 class SortedDirModel;
0038 
0039 struct ContextManagerPrivate;
0040 
0041 /**
0042  * Manages the state of the application.
0043  * TODO: Most of GvCore should be merged in this class
0044  */
0045 class GWENVIEWLIB_EXPORT ContextManager : public QObject
0046 {
0047     Q_OBJECT
0048 public:
0049     ContextManager(SortedDirModel *, QObject *parent);
0050 
0051     ~ContextManager() override;
0052 
0053     void loadConfig();
0054     void saveConfig() const;
0055 
0056     QUrl currentUrl() const;
0057 
0058     void setCurrentDirUrl(const QUrl &);
0059 
0060     QUrl currentDirUrl() const;
0061 
0062     void setCurrentUrl(const QUrl &currentUrl);
0063 
0064     KFileItemList selectedFileItemList() const;
0065 
0066     SortedDirModel *dirModel() const;
0067 
0068     QItemSelectionModel *selectionModel() const;
0069 
0070     bool currentUrlIsRasterImage() const;
0071 
0072     QUrl urlToSelect() const;
0073 
0074     void setUrlToSelect(const QUrl &);
0075 
0076     QUrl targetDirUrl() const;
0077 
0078     void setTargetDirUrl(const QUrl &);
0079 
0080 Q_SIGNALS:
0081     void currentDirUrlChanged(const QUrl &);
0082     void currentUrlChanged(const QUrl &);
0083     void selectionChanged();
0084     void selectionDataChanged();
0085 
0086 public Q_SLOTS:
0087     void slotSelectionChanged();
0088 
0089 private Q_SLOTS:
0090     void slotDirModelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
0091     void slotCurrentChanged(const QModelIndex &);
0092     void emitQueuedSignals();
0093     void slotRowsAboutToBeRemoved(const QModelIndex & /*parent*/, int start, int end);
0094     void slotRowsInserted();
0095     void selectUrlToSelect();
0096     void slotDirListerCompleted();
0097 
0098 private:
0099     ContextManagerPrivate *const d;
0100 };
0101 
0102 } // namespace
0103 
0104 #endif /* CONTEXTMANAGER_H */