File indexing completed on 2024-05-05 16:27:56

0001 // SPDX-FileCopyrightText: 2003-2010, 2012-2013 Jesper K. Pedersen <jesper.pedersen@kdab.com>
0002 // SPDX-FileCopyrightText: 2005-2007 Dirk Mueller <mueller@kde.org>
0003 // SPDX-FileCopyrightText: 2006 Tuomas Suutari <tuomas@nepnep.net>
0004 // SPDX-FileCopyrightText: 2008 Henner Zeller <h.zeller@acm.org>
0005 // SPDX-FileCopyrightText: 2008 Jan Kundrát <jkt@flaska.net>
0006 // SPDX-FileCopyrightText: 2012 Miika Turkia <miika.turkia@gmail.com>
0007 // SPDX-FileCopyrightText: 2013 Dominik Broj <broj.dominik@gmail.com>
0008 // SPDX-FileCopyrightText: 2013-2023 Johannes Zarl-Zierl <johannes@zarl-zierl.at>
0009 // SPDX-FileCopyrightText: 2022 Tobias Leupold <tl@stonemx.de>
0010 //
0011 // SPDX-License-Identifier: GPL-2.0-or-later
0012 
0013 #ifndef BROWSER_H
0014 #define BROWSER_H
0015 #include "BreadcrumbList.h"
0016 #include "CenteringIconView.h"
0017 
0018 #include <DB/Category.h>
0019 #include <kpabase/SettingsData.h>
0020 
0021 #include <QListView>
0022 
0023 class CenteringIconView;
0024 class QSortFilterProxyModel;
0025 class QTreeView;
0026 class QListView;
0027 class QStackedWidget;
0028 
0029 namespace DB
0030 {
0031 class ImageSearchInfo;
0032 class FileName;
0033 }
0034 
0035 namespace Browser
0036 {
0037 class TreeFilter;
0038 class BrowserPage;
0039 
0040 /**
0041  * \brief The widget that makes up the Browser, and the interface to the other modules in KPhotoAlbum.
0042  *
0043  * See \ref Browser for a detailed description of how this fits in with the rest of the classes in this module
0044  */
0045 class BrowserWidget : public QWidget
0046 {
0047     Q_OBJECT
0048 
0049 public:
0050     explicit BrowserWidget(QWidget *parent);
0051     void addSearch(DB::ImageSearchInfo &info);
0052     void addImageView(const DB::FileName &context);
0053     static BrowserWidget *instance();
0054     void load(const QString &category, const QString &value);
0055     DB::ImageSearchInfo currentContext();
0056     void setFocus();
0057     QString currentCategory() const;
0058     void addAction(Browser::BrowserPage *);
0059     void setModel(QAbstractItemModel *);
0060     static bool isResizing() { return s_isResizing; }
0061 
0062 public Q_SLOTS:
0063     void back();
0064     void forward();
0065     void go();
0066     void home();
0067     void reload();
0068     void slotSmallListView();
0069     void slotLargeListView();
0070     void slotSmallIconView();
0071     void slotLargeIconView();
0072     void slotSortViewNaturally(bool on);
0073     void slotLimitToMatch(const QString &);
0074     void slotInvokeSeleted();
0075     void scrollKeyPressed(QKeyEvent *);
0076     void widenToBreadcrumb(const Browser::Breadcrumb &);
0077 
0078 Q_SIGNALS:
0079     void canGoBack(bool);
0080     void canGoForward(bool);
0081     void showingOverview();
0082     void pathChanged(const Browser::BreadcrumbList &);
0083     void isSearchable(bool);
0084     void isFilterable(bool);
0085     void isViewChangeable(bool);
0086     void currentViewTypeChanged(DB::Category::ViewType);
0087     void viewChanged(DB::ImageSearchInfo);
0088     void imageCount(int);
0089     void showSearch();
0090 
0091 protected:
0092     bool eventFilter(QObject *, QEvent *) override;
0093     void activatePage(int pageIndex);
0094 
0095 private Q_SLOTS:
0096     void resetIconViewSearch();
0097     void itemClicked(const QModelIndex &);
0098     void adjustTreeViewColumnSize();
0099     void emitSignals();
0100 
0101 private:
0102     void changeViewTypeForCurrentView(DB::Category::ViewType type);
0103     Browser::BrowserPage *currentAction() const;
0104     void switchToViewType(DB::Category::ViewType);
0105     void setBranchOpen(const QModelIndex &parent, bool open);
0106     Browser::BreadcrumbList createPath() const;
0107     void createWidgets();
0108     void handleResizeEvent(QMouseEvent *);
0109 
0110 private:
0111     static BrowserWidget *s_instance;
0112     QList<BrowserPage *> m_list;
0113     int m_current;
0114     QStackedWidget *m_stack;
0115     CenteringIconView *m_listView;
0116     QTreeView *m_treeView;
0117     QAbstractItemView *m_curView;
0118     TreeFilter *m_filterProxy;
0119     Browser::BreadcrumbList m_breadcrumbs;
0120     QPoint m_resizePressPos;
0121     static bool s_isResizing;
0122 };
0123 }
0124 
0125 #endif /* BROWSER_H */
0126 
0127 // vi:expandtab:tabstop=4 shiftwidth=4: