Warning, file /office/calligra/libs/widgets/KoResourceItemChooser.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) 2002 Patrick Julien <freak@codepimps.org> 0003 Copyright (c) 2007 Jan Hambrecht <jaham@gmx.net> 0004 Copyright (c) 2007 Sven Langkamp <sven.langkamp@gmail.com> 0005 Copyright (c) 2010 Boudewijn Rempt <boud@valdyas.org> 0006 Copyright (C) 2011 Srikanth Tiyyagura <srikanth.tulasiram@gmail.com> 0007 Copyright (c) 2011 José Luis Vergara <pentalis@gmail.com> 0008 Copyright (c) 2013 Sascha Suelzer <s.suelzer@gmail.com> 0009 0010 This library is free software; you can redistribute it and/or 0011 modify it under the terms of the GNU Library General Public 0012 License as published by the Free Software Foundation; either 0013 version 2 of the License, or (at your option) any later version. 0014 0015 This library is distributed in the hope that it will be useful, 0016 but WITHOUT ANY WARRANTY; without even the implied warranty of 0017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0018 Library General Public License for more details. 0019 0020 You should have received a copy of the GNU Library General Public License 0021 along with this library; see the file COPYING.LIB. If not, write to 0022 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0023 * Boston, MA 02110-1301, USA. 0024 */ 0025 0026 #ifndef KO_RESOURCE_ITEM_CHOOSER 0027 #define KO_RESOURCE_ITEM_CHOOSER 0028 0029 #include <QWidget> 0030 0031 #include "kowidgets_export.h" 0032 0033 class QModelIndex; 0034 class QAbstractProxyModel; 0035 class QAbstractItemDelegate; 0036 class QAbstractButton; 0037 class QToolButton; 0038 class KoAbstractResourceServerAdapter; 0039 class KoResourceItemView; 0040 class KoResource; 0041 0042 /** 0043 * A widget that contains a KoResourceChooser as well 0044 * as an import/export button 0045 */ 0046 class KOWIDGETS_EXPORT KoResourceItemChooser : public QWidget 0047 { 0048 Q_OBJECT 0049 public: 0050 enum Buttons { Button_Import, Button_Remove, Button_GhnsDownload, Button_GhnsUpload }; 0051 0052 /// \p usePreview shows the aside preview with the resource's image 0053 explicit KoResourceItemChooser(QSharedPointer<KoAbstractResourceServerAdapter> resourceAdapter, QWidget *parent = 0, bool usePreview = false); 0054 ~KoResourceItemChooser() override; 0055 0056 /// Sets number of columns in the view and causes the number of rows to be calculated accordingly 0057 void setColumnCount(int columnCount); 0058 0059 /// Sets number of rows in the view and causes the number of columns to be calculated accordingly 0060 void setRowCount(int rowCount); 0061 0062 /// Sets the height of the view rows 0063 void setRowHeight(int rowHeight); 0064 0065 /// Sets the width of the view columns 0066 void setColumnWidth(int columnWidth); 0067 0068 /// Sets a custom delegate for the view 0069 void setItemDelegate(QAbstractItemDelegate *delegate); 0070 0071 /// Gets the currently selected resource 0072 /// @returns the selected resource, 0 is no resource is selected 0073 KoResource *currentResource() const; 0074 0075 /// Sets the item representing the resource as selected 0076 void setCurrentResource(KoResource *resource); 0077 0078 /** 0079 * Sets the sected resource, does nothing if there is no valid item 0080 * @param row row of the item 0081 * @param column column of the item 0082 */ 0083 void setCurrentItem(int row, int column); 0084 0085 void showButtons(bool show); 0086 0087 void addCustomButton(QAbstractButton *button, int cell); 0088 0089 /// determines whether the preview right or below the splitter 0090 void setPreviewOrientation(Qt::Orientation orientation); 0091 /// determines whether the preview should tile the resource's image or not 0092 void setPreviewTiled(bool tiled); 0093 /// shows the preview converted to grayscale 0094 void setGrayscalePreview(bool grayscale); 0095 0096 0097 void showGetHotNewStuff(bool showDownload, bool showUpload); 0098 /// sets the visibility of tagging KlineEdits. 0099 void showTaggingBar(bool show); 0100 0101 ///Set a proxy model with will be used to filter the resources 0102 void setProxyModel(QAbstractProxyModel *proxyModel); 0103 0104 void setKnsrcFile(const QString &knsrcFileArg); 0105 QSize viewSize() const; 0106 0107 KoResourceItemView *itemView() const; 0108 0109 void setViewModeButtonVisible(bool visible); 0110 QToolButton *viewModeButton() const; 0111 0112 void setSynced(bool sync); 0113 0114 bool eventFilter(QObject *object, QEvent *event) override; 0115 0116 Q_SIGNALS: 0117 /// Emitted when a resource was selected 0118 void resourceSelected(KoResource *resource); 0119 void splitterMoved(); 0120 public Q_SLOTS: 0121 void slotButtonClicked(int button); 0122 0123 private Q_SLOTS: 0124 void activated(const QModelIndex &index); 0125 void contextMenuRequested(const QPoint &pos); 0126 void baseLengthChanged(int length); 0127 0128 void slotBeforeResourcesLayoutReset(KoResource *activateAfterReset); 0129 void slotAfterResourcesLayoutReset(); 0130 0131 void updateView(); 0132 0133 protected: 0134 void showEvent(QShowEvent *event) override; 0135 0136 private: 0137 void updateButtonState(); 0138 void updatePreview(KoResource *resource); 0139 0140 0141 0142 void resizeEvent(QResizeEvent *event) override; 0143 0144 /// Resource for a given model index 0145 /// @returns the resource pointer, 0 is index not valid 0146 KoResource *resourceFromModelIndex(const QModelIndex &index) const; 0147 0148 class Private; 0149 Private *const d; 0150 }; 0151 0152 #endif // KO_RESOURCE_ITEM_CHOOSER