8#include "filemetadataconfigwidget.h"
9#include "filemetadataprovider.h"
12#include <KConfigGroup>
21class Baloo::FileMetaDataConfigWidgetPrivate
24 explicit FileMetaDataConfigWidgetPrivate(FileMetaDataConfigWidget *parent);
25 ~FileMetaDataConfigWidgetPrivate();
27 FileMetaDataConfigWidgetPrivate(
const FileMetaDataConfigWidgetPrivate&) =
delete;
28 FileMetaDataConfigWidget& operator=(
const FileMetaDataConfigWidgetPrivate&) =
delete;
32 void addItem(
const QString &property);
39 void slotLoadingFinished();
41 int m_visibleDataTypes;
42 KFileItemList m_fileItems;
43 FileMetaDataProvider *m_provider;
44 QListWidget *m_metaDataList;
47 FileMetaDataConfigWidget *
const q;
50FileMetaDataConfigWidgetPrivate::FileMetaDataConfigWidgetPrivate(FileMetaDataConfigWidget *parent)
51 : m_visibleDataTypes(0)
54 , m_metaDataList(nullptr)
59 m_metaDataList->setSortingEnabled(
true);
62 layout->addWidget(m_metaDataList);
65 m_provider->setReadOnly(
true);
66 QObject::connect(m_provider, SIGNAL(loadingFinished()), q, SLOT(slotLoadingFinished()));
69FileMetaDataConfigWidgetPrivate::~FileMetaDataConfigWidgetPrivate() =
default;
71void FileMetaDataConfigWidgetPrivate::loadMetaData()
73 m_metaDataList->clear();
74 m_provider->setItems(m_fileItems);
77void FileMetaDataConfigWidgetPrivate::addItem(
const QString &key)
82 static const char *
const hiddenProperties[] = {
90 while (hiddenProperties[i] !=
nullptr) {
91 if (key == QLatin1String(hiddenProperties[i])) {
100 KConfigGroup settings = config.group(QStringLiteral(
"Show"));
102 const QString
label = m_provider->label(key);
104 auto item =
new QListWidgetItem(label, m_metaDataList);
106 const bool show = settings.
readEntry(key,
true);
110void FileMetaDataConfigWidgetPrivate::slotLoadingFinished()
114 Q_ASSERT(m_provider !=
nullptr);
116 m_metaDataList->clear();
118 QVariantMap data = m_provider->data();
120 data.remove(QStringLiteral(
"rating"));
121 data.remove(QStringLiteral(
"tags"));
122 data.remove(QStringLiteral(
"userComment"));
124 QVariantMap::const_iterator it = data.constBegin();
125 while (it != data.constEnd()) {
130 addItem(QStringLiteral(
"rating"));
131 addItem(QStringLiteral(
"tags"));
132 addItem(QStringLiteral(
"userComment"));
135FileMetaDataConfigWidget::FileMetaDataConfigWidget(QWidget *parent)
137 , d(new FileMetaDataConfigWidgetPrivate(this))
141FileMetaDataConfigWidget::~FileMetaDataConfigWidget() =
default;
143void FileMetaDataConfigWidget::setItems(
const KFileItemList &items)
145 d->m_fileItems = items;
151 return d->m_fileItems;
154void FileMetaDataConfigWidget::save()
159 const int count = d->m_metaDataList->count();
160 for (
int i = 0; i < count; ++i) {
170bool FileMetaDataConfigWidget::event(
QEvent *event)
173 qDebug() <<
"GOT POLISH EVENT!!!";
182QSize FileMetaDataConfigWidget::sizeHint()
const
184 return d->m_metaDataList->sizeHint();
187#include "moc_filemetadataconfigwidget.cpp"
KConfigGroup group(const QString &group)
void writeEntry(const char *key, const char *value, WriteConfigFlags pFlags=Normal)
QString readEntry(const char *key, const char *aDefault=nullptr) const
AKONADI_CALENDAR_EXPORT KCalendarCore::Event::Ptr event(const Akonadi::Item &item)
QString label(StandardShortcut id)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QString toString() const const