2015-05-03 16:49:26 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
* Copyright (C) 2010 by Peter Penz <peter.penz@gmx.at> *
|
|
|
|
* *
|
|
|
|
* This library is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU Library General Public *
|
|
|
|
* License as published by the Free Software Foundation; either *
|
|
|
|
* version 2 of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This library is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
|
|
|
* Library General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Library General Public License *
|
|
|
|
* along with this library; see the file COPYING.LIB. If not, write to *
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
|
|
|
|
* Boston, MA 02110-1301, USA. *
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef KFILEMETADATAMODEL_H
|
|
|
|
#define KFILEMETADATAMODEL_H
|
|
|
|
|
|
|
|
#include <kurl.h>
|
2022-03-09 22:43:30 +02:00
|
|
|
#include <kfileitem.h>
|
2015-05-03 16:49:26 +00:00
|
|
|
|
|
|
|
#include <QtCore/QHash>
|
|
|
|
#include <QtCore/QObject>
|
|
|
|
#include <QtCore/QString>
|
2017-08-04 09:17:49 +00:00
|
|
|
#include <QWidget>
|
2015-05-03 16:49:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Provides the data for the KMetaDataWidget.
|
|
|
|
*
|
2022-03-09 22:11:20 +02:00
|
|
|
* @see KFileMetaDataWidget, KFileMetaInfo
|
2015-05-03 16:49:26 +00:00
|
|
|
*/
|
|
|
|
class KFileMetaDataProvider : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit KFileMetaDataProvider(QObject* parent = 0);
|
2022-03-09 22:11:20 +02:00
|
|
|
~KFileMetaDataProvider();
|
2015-05-03 16:49:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the items, where the meta data should be
|
|
|
|
* requested. The loading of the meta data is done
|
|
|
|
* asynchronously. The signal loadingFinished() is
|
|
|
|
* emitted, as soon as the loading has been finished.
|
|
|
|
* The meta data can be retrieved by
|
|
|
|
* KFileMetaDataProvider::data() afterwards. The label for
|
|
|
|
* each item can be retrieved by KFileMetaDataProvider::label().
|
|
|
|
*/
|
|
|
|
void setItems(const KFileItemList& items);
|
|
|
|
KFileItemList items() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Translated string for the label of the meta data represented
|
2022-03-09 22:43:30 +02:00
|
|
|
* by \p metaDataUri.
|
2015-05-03 16:49:26 +00:00
|
|
|
*/
|
2022-03-09 22:11:20 +02:00
|
|
|
QString label(const KUrl& metaDataUri) const;
|
2015-05-03 16:49:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Meta data for the items that have been set by
|
|
|
|
* KFileMetaDataProvider::setItems(). The method should
|
|
|
|
* be invoked after the signal loadingFinished() has
|
|
|
|
* been received (otherwise no data will be returned).
|
|
|
|
*/
|
2022-03-11 02:05:34 +02:00
|
|
|
QHash<KUrl, QString> data() const;
|
2015-05-03 16:49:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Factory method that returns a widget that should be used
|
2022-03-09 22:43:30 +02:00
|
|
|
* to show the meta data represented by \p metaDataUri. A
|
|
|
|
* QLabel will be returned.
|
2015-05-03 16:49:26 +00:00
|
|
|
*/
|
2022-03-09 22:11:20 +02:00
|
|
|
QWidget* createValueWidget(const KUrl& metaDataUri,
|
2022-03-11 02:05:34 +02:00
|
|
|
const QString& value,
|
2022-03-09 22:11:20 +02:00
|
|
|
QWidget* parent) const;
|
2015-05-03 16:49:26 +00:00
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
/**
|
|
|
|
* Is emitted after the loading triggered by KFileMetaDataProvider::setItems()
|
|
|
|
* has been finished.
|
|
|
|
*/
|
|
|
|
void loadingFinished();
|
|
|
|
|
|
|
|
void urlActivated(const KUrl& url);
|
|
|
|
|
2022-03-09 22:43:30 +02:00
|
|
|
private Q_SLOTS:
|
|
|
|
void slotLinkActivated(const QString&);
|
2015-05-03 16:49:26 +00:00
|
|
|
|
2022-03-09 22:43:30 +02:00
|
|
|
private:
|
|
|
|
/*!
|
|
|
|
* @return The number of subdirectories for the directory \a path.
|
|
|
|
*/
|
|
|
|
static int subDirectoriesCount(const QString &path);
|
2015-05-03 16:49:26 +00:00
|
|
|
|
2022-03-09 22:43:30 +02:00
|
|
|
QList<KFileItem> m_fileItems;
|
2022-03-11 02:05:34 +02:00
|
|
|
QHash<KUrl, QString> m_data;
|
2015-05-03 16:49:26 +00:00
|
|
|
};
|
|
|
|
|
2022-03-09 22:43:30 +02:00
|
|
|
#endif // KFILEMETADATAMODEL_H
|