Krita Source Code Documentation
Loading...
Searching...
No Matches
KisResourceItemChooser.h
Go to the documentation of this file.
1/* This file is part of the KDE project
2 SPDX-FileCopyrightText: 2002 Patrick Julien <freak@codepimps.org>
3 SPDX-FileCopyrightText: 2007 Jan Hambrecht <jaham@gmx.net>
4 SPDX-FileCopyrightText: 2007 Sven Langkamp <sven.langkamp@gmail.com>
5 SPDX-FileCopyrightText: 2010 Boudewijn Rempt <boud@valdyas.org>
6 SPDX-FileCopyrightText: 2011 Srikanth Tiyyagura <srikanth.tulasiram@gmail.com>
7 SPDX-FileCopyrightText: 2011 José Luis Vergara <pentalis@gmail.com>
8 SPDX-FileCopyrightText: 2013 Sascha Suelzer <s.suelzer@gmail.com>
9 SPDX-FileCopyrightText: 2019 Boudewijn Rempt <boud@valdyas.org>
10
11 SPDX-License-Identifier: LGPL-2.0-or-later
12*/
13
14#ifndef KIS_RESOURCE_ITEM_CHOOSER
15#define KIS_RESOURCE_ITEM_CHOOSER
16
17#include <QWidget>
18
19#include <QModelIndex>
20#include <QListView>
21
22#include <KoResource.h>
23#include <KisKineticScroller.h>
24#include "KisPopupButton.h"
26
27class QAbstractProxyModel;
28class QAbstractItemDelegate;
29class QAbstractButton;
30class QToolButton;
31class QSortFilterProxyModel;
34
35#include "kritaresourcewidgets_export.h"
36
37
41class KRITARESOURCEWIDGETS_EXPORT KisResourceItemChooser : public QWidget
42{
43 Q_OBJECT
44public:
45 enum Buttons { Button_Import, Button_Remove };
46 enum class Layout {
47 NotSet,
48 Vertical,
49 Horizontal2Rows,
50 Horizontal1Row
51 };
52
58 explicit KisResourceItemChooser(const QString &resourceType, bool usePreview = false, QWidget *parent = 0);
59 ~KisResourceItemChooser() override;
60
63 void setResponsiveness(bool isResponsive);
64
67 void setListViewMode(ListViewMode viewMode);
68
71 void showTaggingBar(bool show);
72
73 KisTagFilterResourceProxyModel *tagFilterModel() const;
74
77 void showViewModeBtn(bool visible);
78
80
83 void showStorageBtn(bool visible);
84
86 void setRowHeight(int rowHeight);
87
89 void setColumnWidth(int columnWidth);
90
92 void setItemDelegate(QAbstractItemDelegate *delegate);
93
100 KoResourceSP currentResource(bool includeHidden = false) const;
101
103 void setCurrentResource(KoResourceSP resource);
104 void setCurrentResource(QString resourceName);
105
111 void setCurrentItem(int row);
112
115 void showImportExportBtns(bool show);
116
118 void setPreviewOrientation(Qt::Orientation orientation);
119
121 void setPreviewTiled(bool tiled);
122
124 void setGrayscalePreview(bool grayscale);
125
127 QSize viewSize() const;
128
132 KisResourceItemListView *itemView() const;
133
134 void setSynced(bool sync);
135
137 bool eventFilter(QObject *object, QEvent *event) override;
138
139Q_SIGNALS:
142
145
149
150public Q_SLOTS:
151 void slotButtonClicked(int button);
152 void slotScrollerStateChanged(QScroller::State state){ KisKineticScroller::updateCursor(this, state); }
153 void updateView();
154
155private Q_SLOTS:
156 void scrollBackwards();
157 void scrollForwards();
158 void activate(const QModelIndex &index);
159 void clicked(const QModelIndex &index);
160 void contextMenuRequested(const QPoint &pos);
161 void baseLengthChanged(int length);
162 void afterFilterChanged();
163 void slotSaveSplitterState();
164
165protected:
166 void showEvent(QShowEvent *event) override;
167 void resizeEvent(QResizeEvent *event) override;
168
169private:
170 void updateButtonState();
171 void updatePreview(const QModelIndex &idx);
172
173 void hideEverything();
174 void applyVerticalLayout();
175 void changeLayoutBasedOnSize();
176
179 KoResourceSP resourceFromModelIndex(const QModelIndex &index) const;
180
181 class Private;
182 Private *const d;
183};
184
185#endif // KO_RESOURCE_ITEM_CHOOSER
qreal length(const QPointF &vec)
Definition Ellipse.cc:82
void slotScrollerStateChanged(QScroller::State state)
void listViewModeChanged(ListViewMode newViewMode)
Emitted when the view mode for the internal KisResourceItemListView changes.
KoResourceSP currentResource(bool includeHidden=false) const
Gets the currently selected resource.
KisPopupButton * viewModeButton() const
void resourceSelected(KoResourceSP resource)
Emitted when a resource was selected.
void showViewModeBtn(bool visible)
void resourceClicked(KoResourceSP resource)
The KisTagFilterResourceProxyModel class filters the resources by tag or resource name.
QString button(const QWheelEvent &ev)
KRITAWIDGETUTILS_EXPORT void updateCursor(QWidget *source, QScroller::State state)