1 /*************************************************************************** 2 ** ** 3 ** Polyphone, a soundfont editor ** 4 ** Copyright (C) 2013-2019 Davy Triponney ** 5 ** ** 6 ** This program is free software: you can redistribute it and/or modify ** 7 ** it under the terms of the GNU General Public License as published by ** 8 ** the Free Software Foundation, either version 3 of the License, or ** 9 ** (at your option) any later version. ** 10 ** ** 11 ** This program is distributed in the hope that it will be useful, ** 12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** 13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 14 ** GNU General Public License for more details. ** 15 ** ** 16 ** You should have received a copy of the GNU General Public License ** 17 ** along with this program. If not, see http://www.gnu.org/licenses/. ** 18 ** ** 19 **************************************************************************** 20 ** Author: Davy Triponney ** 21 ** Website/Contact: https://www.polyphone-soundfonts.com ** 22 ** Date: 01.01.2013 ** 23 ***************************************************************************/ 24 25 #ifndef ATTRIBUTEFLOW_H 26 #define ATTRIBUTEFLOW_H 27 28 #include <QWidget> 29 #include "soundfontinformation.h" 30 class FlowLayout; 31 class SoundfontFilter; 32 class ElidedPushButton; 33 34 class AttributeFlow : public QWidget 35 { 36 Q_OBJECT 37 38 public: 39 explicit AttributeFlow(QWidget *parent = nullptr); 40 ~AttributeFlow() override; 41 void clear(); 42 void addCategory(int id); 43 void addProperty(SoundfontInformation::Property property, QString propertyValue); 44 void addTag(QString tagName); 45 void polish(QStyle *style); 46 47 bool hasHeightForWidth() const override; 48 int heightForWidth(int width) const override; 49 50 signals: 51 // Signal emitted when an item is clicked 52 // The filter must be deleted then 53 void itemClicked(SoundfontFilter * filter); 54 55 protected: 56 void resizeEvent(QResizeEvent * event) override; 57 58 private slots: 59 void onClick(bool checked); 60 61 private: 62 enum FilterType 63 { 64 CATEGORY, 65 PROPERTY, 66 TAG 67 }; 68 69 class FilterDefinition 70 { 71 public: 72 FilterType _type; 73 int _id; 74 SoundfontInformation::Property _property; 75 QString _propertyValue; 76 QString _tag; 77 }; 78 79 ElidedPushButton * createItem(QString text); 80 81 FlowLayout * _layout; 82 QMap<ElidedPushButton *, FilterDefinition> _filterDefinitions; 83 QList<ElidedPushButton *> _filters; 84 }; 85 86 #endif // ATTRIBUTEFLOW_H 87