1 /* 2 <one line to give the library's name and an idea of what it does.> 3 Copyright (C) 2012 Vishesh Handa <me@vhanda.in> 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with this library; if not, write to the Free Software 17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 */ 19 20 21 #ifndef WIDGETFACTORY_H 22 #define WIDGETFACTORY_H 23 24 #include "filemetadatawidget.h" 25 26 #include <QObject> 27 #include <QStringList> 28 29 class KJob; 30 class QLabel; 31 class QUrl; 32 class KCommentWidget; 33 class KRatingWidget; 34 35 namespace Baloo { 36 37 class Tag; 38 class TagWidget; 39 40 class WidgetFactory : public QObject 41 { 42 Q_OBJECT 43 public: 44 explicit WidgetFactory(QObject* parent = nullptr); 45 ~WidgetFactory() override; 46 47 void setItems(const KFileItemList& items); 48 49 void setReadOnly(bool value); 50 51 void setDateFormat(const DateFormats format); 52 DateFormats dateFormat() const; 53 54 QWidget* createWidget(const QString& prop, const QVariant& value, QWidget* parent); 55 56 Q_SIGNALS: 57 void urlActivated(const QUrl& url); 58 void dataChangeStarted(); 59 void dataChangeFinished(); 60 61 private Q_SLOTS: 62 void slotTagsChanged(const QStringList& tags); 63 void slotCommentChanged(const QString& comment); 64 void slotRatingChanged(uint rating); 65 66 void slotTagClicked(const QString& tag); 67 void slotLinkActivated(const QString& url); 68 69 private: 70 QWidget* createRatingWidget(int rating, QWidget* parent); 71 QWidget* createTagWidget(const QStringList& tags, QWidget* parent); 72 QWidget* createCommentWidget(const QString& comment, QWidget* parent); 73 QLabel* createValueWidget(QWidget* parent); 74 75 TagWidget* m_tagWidget; 76 KRatingWidget* m_ratingWidget; 77 KCommentWidget* m_commentWidget; 78 79 KFileItemList m_items; 80 QStringList m_prevTags; 81 bool m_readOnly; 82 QLocale::FormatType m_dateFormat; 83 }; 84 } 85 86 #endif // WIDGETFACTORY_H 87