1 /***************************************************************************** 2 * Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com> * 3 * * 4 * This library is free software; you can redistribute it and/or * 5 * modify it under the terms of the GNU Library General Public * 6 * License as published by the Free Software Foundation; either * 7 * version 2 of the License, or (at your option) any later version. * 8 * * 9 * This library is distributed in the hope that it will be useful, * 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 12 * Library General Public License for more details. * 13 * * 14 * You should have received a copy of the GNU Library General Public License * 15 * along with this library; see the file COPYING.LIB. If not, write to * 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * 17 * Boston, MA 02110-1301, USA. * 18 *****************************************************************************/ 19 20 #ifndef KFILEMETADATAREADER_H 21 #define KFILEMETADATAREADER_H 22 23 #include <nepomuk/core/variant.h> 24 25 #include <QHash> 26 #include <QList> 27 #include <QObject> 28 #include <QProcess> 29 #include <QString> 30 #include <QUrl> 31 32 /** 33 * @brief Provides metadata extracted from files. 34 * 35 * The reading of the metadata is done asynchronously in a process. 36 * This assures that the caller won't get blocked and also prevents 37 * that the caller crashes in case if a metadata-analyzer plugin is instable. 38 * 39 * @since 4.7 40 * @internal 41 */ 42 class KFileMetaDataReader : public QObject 43 { 44 Q_OBJECT 45 46 public: 47 /** 48 * @param urls List of files where the metadata should be extracted from. 49 * @param parent Parent object. 50 */ 51 KDELIBS4SUPPORT_DEPRECATED explicit KFileMetaDataReader(const QList<QUrl> &urls, QObject *parent = 0); 52 virtual ~KFileMetaDataReader(); 53 54 /** 55 * If \p read is set to true also metadata that is persisted outside the 56 * files itself (like e.g. rating, comments or tags) are read. Per 57 * default the reading of context data is enabled. Pass false if only the metadata 58 * persisted inside the file should be read. 59 */ 60 void setReadContextData(bool read); 61 bool readContextData() const; 62 63 /** 64 * Starts the reading of the metadata inside a custom process. 65 * The signal finished() will get emitted if the reading has been finished. 66 * Use metaData() to access the read metadata. 67 */ 68 void start(); 69 70 /** 71 * @return The read metadata of the given files. The method provides valid values 72 * after the signal finished() has been emitted. If it is invoked before 73 * an empty hash-table will be returned. 74 */ 75 QHash<QUrl, Nepomuk::Variant> metaData() const; 76 77 Q_SIGNALS: 78 /** 79 * Is emitted if the reading of the metadata inside a custom process has been finished. 80 * The method metaData() can be used afterwards to access the metadata. 81 */ 82 void finished(); 83 84 private: 85 class Private; 86 Private *d; 87 88 Q_PRIVATE_SLOT(d, void slotLoadingFinished(int, QProcess::ExitStatus)) 89 }; 90 91 #endif 92