From 565bd3bf23dfb9b139de089d3c4f8b57e124f7ee Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Wed, 4 Nov 2009 19:14:39 +0000 Subject: Don't call QThread::wait() in the destructor - in the worst case an issue in Nepomuk will block Dolphin for several seconds. Refactored the load-meta-data-thread in a way that the meta data widget does not require to wait for a result of the thread. svn path=/trunk/KDE/kdebase/apps/; revision=1044848 --- src/panels/information/kloadmetadatathread_p.h | 97 ++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 src/panels/information/kloadmetadatathread_p.h (limited to 'src/panels/information/kloadmetadatathread_p.h') diff --git a/src/panels/information/kloadmetadatathread_p.h b/src/panels/information/kloadmetadatathread_p.h new file mode 100644 index 000000000..e229766d6 --- /dev/null +++ b/src/panels/information/kloadmetadatathread_p.h @@ -0,0 +1,97 @@ +/***************************************************************************** + * Copyright (C) 2009 by Peter Penz * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License version 2 as published by the Free Software Foundation. * + * * + * 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 KLOADMETADATATHREAD_H +#define KLOADMETADATATHREAD_H + +#define DISABLE_NEPOMUK_LEGACY +#include +#include + +#include +#include +#include + +/** + * Loads the meta data of files that are + * required by the widget KMetaDataWidget. + */ +class KLoadMetaDataThread : public QThread +{ + Q_OBJECT + +public: + KLoadMetaDataThread(); + virtual ~KLoadMetaDataThread(); + + /** + * Starts the thread and loads the meta data for + * the files given by \p urls. After receiving + * the signal finished(), the methods + * rating(), comment(), tags(), metaInfoLabels(), + * metaInfoValues() and files() return valid data. + */ + void load(const KUrl::List& urls); + + /** + * Cancels the thread and assures that the thread deletes + * itself as soon as the cancelling has been successful. In + * opposite to QThread::wait() the caller of cancelAndDelete() + * will not be blocked. + */ + void cancelAndDelete(); + + /** @see QThread::run() */ + virtual void run(); + + int rating() const; + QString comment() const; + QList tags() const; + QList metaInfoLabels() const; + QList metaInfoValues() const; + QMap files() const; + +private slots: + void slotFinished(); + +private: + /** + * Assures that the settings for the meta information + * are initialized with proper default values. + */ + void initMetaInfoSettings(KConfigGroup& group); + + /** + * Temporary helper method for KDE 4.3 as we currently don't get + * translated labels for Nepmok literals: Replaces camelcase labels + * like "fileLocation" by "File Location:". + */ + QString tunedLabel(const QString& label) const; + +private: + int m_rating; + QString m_comment; + QList m_tags; + QList m_metaInfoLabels; + QList m_metaInfoValues; + QMap m_files; + + KUrl::List m_urls; + bool m_canceled; +}; +#endif -- cgit v1.3.1