Warning, file /office/calligra/libs/widgets/KoResourceSelector.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE project 0002 * Copyright (C) 2008 Jan Hambrecht <jaham@gmx.net> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Library General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2 of the License, or (at your option) any later version. 0008 * 0009 * This library is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 * Library General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU Library General Public License 0015 * along with this library; see the file COPYING.LIB. If not, write to 0016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 * Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #ifndef KORESOURCESELECTOR_H 0021 #define KORESOURCESELECTOR_H 0022 0023 #include "kowidgets_export.h" 0024 #include <QComboBox> 0025 0026 class QMouseEvent; 0027 class KoAbstractResourceServerAdapter; 0028 class KoResource; 0029 0030 /** 0031 * A custom combobox widget for selecting resource items like gradients or patterns. 0032 */ 0033 class KOWIDGETS_EXPORT KoResourceSelector : public QComboBox 0034 { 0035 Q_OBJECT 0036 public: 0037 enum DisplayMode { 0038 ImageMode, ///< Displays image of resources (default) 0039 TextMode ///< Displays name of resources 0040 }; 0041 0042 /** 0043 * Constructs a new resource selector. 0044 * @param parent the parent widget 0045 */ 0046 explicit KoResourceSelector(QWidget *parent = nullptr); 0047 0048 /** 0049 * Constructs a new resource selector showing the resources of the given resource adapter. 0050 * @param resourceAdapter the resource adapter providing the resources to display 0051 * @param parent the parent widget 0052 */ 0053 explicit KoResourceSelector( QSharedPointer<KoAbstractResourceServerAdapter> resourceAdapter, QWidget * parent = 0 ); 0054 0055 /// Destroys the resource selector 0056 ~KoResourceSelector() override; 0057 0058 /// Sets the resource adaptor to get resources from 0059 void setResourceAdapter(QSharedPointer<KoAbstractResourceServerAdapter>resourceAdapter); 0060 0061 /// Sets the display mode 0062 void setDisplayMode(DisplayMode mode); 0063 0064 /// Sets number of columns to display in the popup view 0065 void setColumnCount( int columnCount ); 0066 0067 /// Sets the height of the popup view rows 0068 void setRowHeight( int rowHeight ); 0069 0070 Q_SIGNALS: 0071 /// Emitted when a resource was selected 0072 void resourceSelected( KoResource * resource ); 0073 0074 /// Is emitted when the user has clicked on the current resource 0075 void resourceApplied( KoResource * resource ); 0076 0077 protected: 0078 /// reimplemented 0079 void paintEvent( QPaintEvent * ) override; 0080 /// reimplemented 0081 void mousePressEvent( QMouseEvent * ) override; 0082 /// reimplemented 0083 void mouseMoveEvent( QMouseEvent * event ) override; 0084 0085 private Q_SLOTS: 0086 void indexChanged( int index ); 0087 void resourceAdded(KoResource*); 0088 void resourceRemoved(KoResource*); 0089 private: 0090 class Private; 0091 Private * const d; 0092 }; 0093 0094 #endif // KORESOURCESELECTOR_H