File indexing completed on 2024-04-21 04:39:57
0001 /* 0002 SPDX-FileCopyrightText: 2012 Vishesh Handa <me@vhanda.in> 0003 0004 SPDX-License-Identifier: LGPL-2.1-or-later 0005 */ 0006 0007 #ifndef WIDGETFACTORY_H 0008 #define WIDGETFACTORY_H 0009 0010 #include "filemetadatawidget.h" 0011 0012 #include <QObject> 0013 #include <QStringList> 0014 0015 class QLabel; 0016 class QUrl; 0017 class KCommentWidget; 0018 class KRatingWidget; 0019 0020 namespace Baloo 0021 { 0022 class TagWidget; 0023 0024 class WidgetFactory : public QObject 0025 { 0026 Q_OBJECT 0027 public: 0028 explicit WidgetFactory(QObject *parent = nullptr); 0029 ~WidgetFactory() override; 0030 0031 void setItems(const KFileItemList &items); 0032 0033 void setReadOnly(bool value); 0034 0035 void setDateFormat(const DateFormats format); 0036 DateFormats dateFormat() const; 0037 0038 QWidget *createWidget(const QString &prop, const QVariant &value, QWidget *parent); 0039 0040 Q_SIGNALS: 0041 void urlActivated(const QUrl &url); 0042 0043 private Q_SLOTS: 0044 void slotTagsChanged(const QStringList &tags); 0045 void slotCommentChanged(const QString &comment); 0046 void slotRatingChanged(int rating); 0047 0048 private: 0049 QWidget *createRatingWidget(int rating, QWidget *parent); 0050 QWidget *createTagWidget(const QStringList &tags, QWidget *parent); 0051 QWidget *createCommentWidget(const QString &comment, QWidget *parent); 0052 QLabel *createValueWidget(QWidget *parent); 0053 QLabel *createLinkWidget(QWidget *parent); 0054 0055 TagWidget *m_tagWidget = nullptr; 0056 KRatingWidget *m_ratingWidget = nullptr; 0057 KCommentWidget *m_commentWidget = nullptr; 0058 0059 KFileItemList m_items; 0060 QStringList m_prevTags; 0061 bool m_readOnly = false; 0062 QLocale::FormatType m_dateFormat; 0063 }; 0064 } 0065 0066 #endif // WIDGETFACTORY_H