From: Peter Penz Date: Wed, 28 Oct 2009 07:18:00 +0000 (+0000) Subject: After some discussions at http://reviewboard.kde.org/r/1938 it turned out that moving... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/73007f7d632bdd5565b8394043bb2de07bebb336?ds=sidebyside After some discussions at http://reviewboard.kde.org/r/1938 it turned out that moving KMetaDataWidget and KMetaDataConfigurationDialog to kdelibs should be postponed to KDE 4.5. The main reason is that adding application specific properties is not possible with the current API in a generic way. Also the topic how to hide properties application specific is an open point... So now all adjustments from the review have been adapted to the Dolphin code. After KDE 4.4 has been released some refactoring will be done so that the open topics above are handled in a nice way. svn path=/trunk/KDE/kdebase/apps/; revision=1041547 --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ea6bda63a..f34367854 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -112,8 +112,8 @@ set(dolphin_SRCS pixmapviewer.cpp panels/information/informationpanel.cpp panels/information/informationpanelcontent.cpp - panels/information/metadatawidget.cpp - panels/information/metadataconfigurationdialog.cpp + panels/information/kmetadatawidget.cpp + panels/information/kmetadataconfigurationdialog.cpp panels/information/phononwidget.cpp panels/folders/ktreeview.cpp panels/places/placespanel.cpp @@ -157,10 +157,10 @@ kde4_add_kcfg_files(dolphin_SRCS if(Nepomuk_FOUND) set(dolphin_SRCS ${dolphin_SRCS} - panels/information/commentwidget.cpp - panels/information/edittagsdialog.cpp + panels/information/kcommentwidget.cpp + panels/information/kedittagsdialog.cpp panels/information/nepomukmassupdatejob.cpp - panels/information/taggingwidget.cpp + panels/information/ktaggingwidget.cpp ) endif(Nepomuk_FOUND) diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index e82b42483..000e9ce6e 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -35,7 +35,6 @@ #include "panels/folders/folderspanel.h" #include "panels/places/placespanel.h" #include "panels/information/informationpanel.h" -#include "panels/information/metadatawidget.h" #include "mainwindowadaptor.h" #include "statusbar/dolphinstatusbar.h" #include "viewproperties.h" diff --git a/src/panels/information/commentwidget_p.h b/src/panels/information/commentwidget_p.h deleted file mode 100644 index 3985487d5..000000000 --- a/src/panels/information/commentwidget_p.h +++ /dev/null @@ -1,51 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008 by Sebastian Trueg * - * Copyright (C) 2009 by Peter Penz * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ - -#ifndef COMMENT_WIDGET -#define COMMENT_WIDGET - -#include -#include - -class QLabel; - -class CommentWidget : public QWidget -{ - Q_OBJECT - -public: - CommentWidget(QWidget* parent); - virtual ~CommentWidget(); - - void setText(const QString& comment); - QString text() const; - -signals: - void commentChanged(const QString& comment); - -private slots: - void slotLinkActivated(const QString& link); - -private: - QLabel* m_label; - QString m_comment; -}; - -#endif diff --git a/src/panels/information/edittagsdialog_p.h b/src/panels/information/edittagsdialog_p.h deleted file mode 100644 index f72d5d84d..000000000 --- a/src/panels/information/edittagsdialog_p.h +++ /dev/null @@ -1,67 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2009 by Peter Penz * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ - -#ifndef EDIT_TAGS_DIALOG_H -#define EDIT_TAGS_DIALOG_H - -#include - -#include - -class KLineEdit; -class QListWidget; -class QListWidgetItem; - -/** - * @brief Dialog to edit a list of Nepomuk tags. - * - * It is possible for the user to add existing tags, - * create new tags or to remove tags. - */ -class EditTagsDialog : public KDialog -{ - Q_OBJECT - -public: - EditTagsDialog(const QList& tags, - QWidget* parent = 0, - Qt::WFlags flags = 0); - - virtual ~EditTagsDialog(); - - QList tags() const; - -protected slots: - virtual void slotButtonClicked(int button); - -private slots: - void slotTextEdited(const QString& text); - -private: - void loadTags(); - void removeNewTagItem(); - -private: - QList m_tags; - QListWidget* m_tagsList; - QListWidgetItem* m_newTagItem; - KLineEdit* m_newTagEdit; -}; - -#endif diff --git a/src/panels/information/informationpanelcontent.cpp b/src/panels/information/informationpanelcontent.cpp index 854af58ef..831a6e78b 100644 --- a/src/panels/information/informationpanelcontent.cpp +++ b/src/panels/information/informationpanelcontent.cpp @@ -47,21 +47,11 @@ #include "dolphin_informationpanelsettings.h" #include "settings/dolphinsettings.h" -#include "metadatawidget.h" -#include "metadataconfigurationdialog.h" +#include "kmetadatawidget.h" +#include "kmetadataconfigurationdialog.h" #include "phononwidget.h" #include "pixmapviewer.h" -/** - * Helper function for sorting items with qSort() in - * InformationPanelContent::contextMenu(). - */ -bool lessThan(const QAction* action1, const QAction* action2) -{ - return action1->text() < action2->text(); -} - - InformationPanelContent::InformationPanelContent(QWidget* parent) : Panel(parent), m_item(), @@ -117,7 +107,7 @@ InformationPanelContent::InformationPanelContent(QWidget* parent) : m_preview->setVisible(showPreview); m_previewSeparator->setVisible(showPreview); - m_metaDataWidget = new MetaDataWidget(parent); + m_metaDataWidget = new KMetaDataWidget(parent); m_metaDataWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); // Encapsulate the MetaDataWidget inside a container that has a dummy widget @@ -302,7 +292,7 @@ void InformationPanelContent::configureSettings() m_previewSeparator->setVisible(isChecked); InformationPanelSettings::setShowPreview(isChecked); } else if (action == configureAction) { - MetaDataConfigurationDialog dialog(m_metaDataWidget, this, Qt::Dialog); + KMetaDataConfigurationDialog dialog(m_metaDataWidget, this, Qt::Dialog); dialog.exec(); } diff --git a/src/panels/information/informationpanelcontent.h b/src/panels/information/informationpanelcontent.h index 63948fd4f..9c17b9397 100644 --- a/src/panels/information/informationpanelcontent.h +++ b/src/panels/information/informationpanelcontent.h @@ -26,14 +26,14 @@ #include #include +class KFileItem; +class KMetaDataWidget; +class KSeparator; +class MetaTextLabel; class PhononWidget; class PixmapViewer; -class MetaDataWidget; -class MetaTextLabel; class QPixmap; class QString; -class KFileItem; -class KSeparator; class QLabel; class QScrollArea; @@ -120,7 +120,7 @@ private: PixmapViewer* m_preview; KSeparator* m_previewSeparator; PhononWidget* m_phononWidget; - MetaDataWidget* m_metaDataWidget; + KMetaDataWidget* m_metaDataWidget; QScrollArea* m_metaDataArea; }; diff --git a/src/panels/information/commentwidget.cpp b/src/panels/information/kcommentwidget.cpp similarity index 57% rename from src/panels/information/commentwidget.cpp rename to src/panels/information/kcommentwidget.cpp index 06a4c33be..770b6c10c 100644 --- a/src/panels/information/commentwidget.cpp +++ b/src/panels/information/kcommentwidget.cpp @@ -1,24 +1,23 @@ -/*************************************************************************** - * Copyright (C) 2008 by Sebastian Trueg * - * Copyright (C) 2009 by Peter Penz * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ - -#include "commentwidget_p.h" +/***************************************************************************** + * Copyright (C) 2008 by Sebastian Trueg * + * 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. * + *****************************************************************************/ + +#include "kcommentwidget_p.h" #include #include @@ -28,7 +27,7 @@ #include #include -CommentWidget::CommentWidget(QWidget* parent) : +KCommentWidget::KCommentWidget(QWidget* parent) : QWidget(parent), m_label(0), m_comment() @@ -46,11 +45,11 @@ CommentWidget::CommentWidget(QWidget* parent) : setText(m_comment); } -CommentWidget::~CommentWidget() +KCommentWidget::~KCommentWidget() { } -void CommentWidget::setText(const QString& comment) +void KCommentWidget::setText(const QString& comment) { if (comment.isEmpty()) { m_label->setText("" + i18nc("@label", "Add Comment...") + ""); @@ -60,12 +59,12 @@ void CommentWidget::setText(const QString& comment) m_comment = comment; } -QString CommentWidget::text() const +QString KCommentWidget::text() const { return m_comment; } -void CommentWidget::slotLinkActivated(const QString& link) +void KCommentWidget::slotLinkActivated(const QString& link) { KDialog dialog(this, Qt::Dialog); @@ -81,7 +80,7 @@ void CommentWidget::slotLinkActivated(const QString& link) dialog.setButtons(KDialog::Ok | KDialog::Cancel); dialog.setDefaultButton(KDialog::Ok); - KConfigGroup dialogConfig(KGlobal::config(), "Nepomuk EditCommentDialog"); + KConfigGroup dialogConfig(KGlobal::config(), "Nepomuk KEditCommentDialog"); dialog.restoreDialogSize(dialogConfig); if (dialog.exec() == QDialog::Accepted) { @@ -95,4 +94,4 @@ void CommentWidget::slotLinkActivated(const QString& link) dialog.saveDialogSize(dialogConfig, KConfigBase::Persistent); } -#include "commentwidget_p.moc" +#include "kcommentwidget_p.moc" diff --git a/src/panels/information/kcommentwidget_p.h b/src/panels/information/kcommentwidget_p.h new file mode 100644 index 000000000..977531372 --- /dev/null +++ b/src/panels/information/kcommentwidget_p.h @@ -0,0 +1,53 @@ +/***************************************************************************** + * Copyright (C) 2008 by Sebastian Trueg * + * 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 KCOMMENT_WIDGET +#define KCOMMENT_WIDGET + +#include +#include + +class QLabel; + +/** + * @brief Allows to edit and show a comment as part of KMetaDataWidget. + */ +class KCommentWidget : public QWidget +{ + Q_OBJECT + +public: + KCommentWidget(QWidget* parent); + virtual ~KCommentWidget(); + + void setText(const QString& comment); + QString text() const; + +signals: + void commentChanged(const QString& comment); + +private slots: + void slotLinkActivated(const QString& link); + +private: + QLabel* m_label; + QString m_comment; +}; + +#endif diff --git a/src/panels/information/edittagsdialog.cpp b/src/panels/information/kedittagsdialog.cpp similarity index 72% rename from src/panels/information/edittagsdialog.cpp rename to src/panels/information/kedittagsdialog.cpp index c3b3efcad..4dfe0275d 100644 --- a/src/panels/information/edittagsdialog.cpp +++ b/src/panels/information/kedittagsdialog.cpp @@ -1,23 +1,22 @@ -/*************************************************************************** - * Copyright (C) 2009 by Peter Penz * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ - -#include "edittagsdialog_p.h" +/***************************************************************************** + * 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. * + *****************************************************************************/ + +#include "kedittagsdialog_p.h" #include #include @@ -28,9 +27,9 @@ #include #include -EditTagsDialog::EditTagsDialog(const QList& tags, - QWidget* parent, - Qt::WFlags flags) : +KEditTagsDialog::KEditTagsDialog(const QList& tags, + QWidget* parent, + Qt::WFlags flags) : KDialog(parent, flags), m_tags(tags), m_tagsList(0), @@ -75,21 +74,21 @@ EditTagsDialog::EditTagsDialog(const QList& tags, loadTags(); } -EditTagsDialog::~EditTagsDialog() +KEditTagsDialog::~KEditTagsDialog() { } -QList EditTagsDialog::tags() const +QList KEditTagsDialog::tags() const { return m_tags; } -void EditTagsDialog::slotButtonClicked(int button) +void KEditTagsDialog::slotButtonClicked(int button) { if (button == KDialog::Ok) { // update m_tags with the checked values, so - // that the caller of the EditTagsDialog can - // receive the tags by EditTagsDialog::tags() + // that the caller of the KEditTagsDialog can + // receive the tags by KEditTagsDialog::tags() m_tags.clear(); const int count = m_tagsList->count(); @@ -109,7 +108,7 @@ void EditTagsDialog::slotButtonClicked(int button) } } -void EditTagsDialog::slotTextEdited(const QString& text) +void KEditTagsDialog::slotTextEdited(const QString& text) { // Remove unnecessary spaces from a new tag is // mandatory, as the user cannot see the difference @@ -145,10 +144,10 @@ void EditTagsDialog::slotTextEdited(const QString& text) m_tagsList->scrollToItem(m_newTagItem); } -void EditTagsDialog::loadTags() +void KEditTagsDialog::loadTags() { // load all available tags and mark those tags as checked - // that have been passed to the EditTagsDialog + // that have been passed to the KEditTagsDialog QList tags = Nepomuk::Tag::allTags(); foreach (const Nepomuk::Tag& tag, tags) { const QString label = tag.label(); @@ -167,7 +166,7 @@ void EditTagsDialog::loadTags() } } -void EditTagsDialog::removeNewTagItem() +void KEditTagsDialog::removeNewTagItem() { if (m_newTagItem != 0) { const int row = m_tagsList->row(m_newTagItem); @@ -177,4 +176,4 @@ void EditTagsDialog::removeNewTagItem() } } -#include "edittagsdialog_p.moc" +#include "kedittagsdialog_p.moc" diff --git a/src/panels/information/kedittagsdialog_p.h b/src/panels/information/kedittagsdialog_p.h new file mode 100644 index 000000000..d85bcf9da --- /dev/null +++ b/src/panels/information/kedittagsdialog_p.h @@ -0,0 +1,67 @@ +/***************************************************************************** + * 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 KEDIT_TAGS_DIALOG_H +#define KEDIT_TAGS_DIALOG_H + +#include +#include + +class KLineEdit; +class QListWidget; +class QListWidgetItem; + +/** + * @brief Dialog to edit a list of Nepomuk tags. + * + * It is possible for the user to add existing tags, + * create new tags or to remove tags. + * + * @see KMetaDataConfigurationDialog + */ +class KEditTagsDialog : public KDialog +{ + Q_OBJECT + +public: + KEditTagsDialog(const QList& tags, + QWidget* parent = 0, + Qt::WFlags flags = 0); + + virtual ~KEditTagsDialog(); + + QList tags() const; + +protected slots: + virtual void slotButtonClicked(int button); + +private slots: + void slotTextEdited(const QString& text); + +private: + void loadTags(); + void removeNewTagItem(); + +private: + QList m_tags; + QListWidget* m_tagsList; + QListWidgetItem* m_newTagItem; + KLineEdit* m_newTagEdit; +}; + +#endif diff --git a/src/panels/information/metadataconfigurationdialog.cpp b/src/panels/information/kmetadataconfigurationdialog.cpp similarity index 66% rename from src/panels/information/metadataconfigurationdialog.cpp rename to src/panels/information/kmetadataconfigurationdialog.cpp index a53eaa339..bbe437139 100644 --- a/src/panels/information/metadataconfigurationdialog.cpp +++ b/src/panels/information/kmetadataconfigurationdialog.cpp @@ -1,64 +1,61 @@ -/*************************************************************************** - * Copyright (C) 2009 by Peter Penz * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ - -#include "metadataconfigurationdialog.h" - -#include "metadatawidget.h" - +/***************************************************************************** + * 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. * + *****************************************************************************/ + +#include "kmetadataconfigurationdialog.h" +#include "kmetadatawidget.h" #include #include #ifdef HAVE_NEPOMUK #define DISABLE_NEPOMUK_LEGACY - #include - #include - #include - #include + #include + #include + #include + #include #endif #include #include #include -class MetaDataConfigurationDialog::Private +class KMetaDataConfigurationDialog::Private { public: - Private(MetaDataConfigurationDialog* parent, MetaDataWidget* metaDataWidget); + Private(KMetaDataConfigurationDialog* parent, KMetaDataWidget* metaDataWidget); ~Private(); void init(); void loadMetaData(); QString tunedLabel(const QString& label) const; - int m_hiddenData; - MetaDataWidget* m_metaDataWidget; + int m_visibleDataTypes; + KMetaDataWidget* m_metaDataWidget; QListWidget* m_metaDataList; private: - MetaDataConfigurationDialog* const q; + KMetaDataConfigurationDialog* const q; }; -MetaDataConfigurationDialog::Private::Private(MetaDataConfigurationDialog* parent, - MetaDataWidget* metaDataWidget) : +KMetaDataConfigurationDialog::Private::Private(KMetaDataConfigurationDialog* parent, + KMetaDataWidget* metaDataWidget) : q(parent) { - m_hiddenData = 0; + m_visibleDataTypes = 0; m_metaDataWidget = metaDataWidget; q->setCaption(i18nc("@title:window", "Configure Shown Data")); @@ -82,54 +79,61 @@ MetaDataConfigurationDialog::Private::Private(MetaDataConfigurationDialog* paren loadMetaData(); - const KConfigGroup dialogConfig(KGlobal::config(), "Nepomuk MetaDataConfigurationDialog"); + const KConfigGroup dialogConfig(KGlobal::config(), "Nepomuk KMetaDataConfigurationDialog"); q->restoreDialogSize(dialogConfig); } -MetaDataConfigurationDialog::Private::~Private() +KMetaDataConfigurationDialog::Private::~Private() { - KConfigGroup dialogConfig(KGlobal::config(), "Nepomuk MetaDataConfigurationDialog"); + KConfigGroup dialogConfig(KGlobal::config(), "Nepomuk KMetaDataConfigurationDialog"); q->saveDialogSize(dialogConfig, KConfigBase::Persistent); } -void MetaDataConfigurationDialog::Private::loadMetaData() +void KMetaDataConfigurationDialog::Private::loadMetaData() { KConfig config("kmetainformationrc", KConfig::NoGlobals); KConfigGroup settings = config.group("Show"); // Add fixed meta data items where the visibility does not // depend on the currently used URL. - int hiddenData = 0; + KMetaDataWidget::MetaDataTypes visibleDataTypes = KMetaDataWidget::TypeData | + KMetaDataWidget::SizeData | + KMetaDataWidget::ModifiedData | + KMetaDataWidget::OwnerData | + KMetaDataWidget::PermissionsData | + KMetaDataWidget::RatingData | + KMetaDataWidget::TagsData | + KMetaDataWidget::CommentData; if (m_metaDataWidget != 0) { - hiddenData = m_metaDataWidget->hiddenData(); + visibleDataTypes = m_metaDataWidget->visibleDataTypes(); } typedef QPair FixedItem; QList fixedItems; - if (!(hiddenData & MetaDataWidget::TypeData)) { + if (visibleDataTypes & KMetaDataWidget::TypeData) { fixedItems.append(FixedItem("type", i18nc("@item::inlistbox", "Type"))); } - if (!(hiddenData & MetaDataWidget::SizeData)) { + if (visibleDataTypes & KMetaDataWidget::SizeData) { fixedItems.append(FixedItem("size", i18nc("@item::inlistbox", "Size"))); } - if (!(hiddenData & MetaDataWidget::ModifiedData)) { + if (visibleDataTypes & KMetaDataWidget::ModifiedData) { fixedItems.append(FixedItem("modified", i18nc("@item::inlistbox", "Modified"))); } - if (!(hiddenData & MetaDataWidget::OwnerData)) { + if (visibleDataTypes & KMetaDataWidget::OwnerData) { fixedItems.append(FixedItem("owner", i18nc("@item::inlistbox", "Owner"))); } - if (!(hiddenData & MetaDataWidget::PermissionsData)) { + if (visibleDataTypes & KMetaDataWidget::PermissionsData) { fixedItems.append(FixedItem("permissions", i18nc("@item::inlistbox", "Permissions"))); } #ifdef HAVE_NEPOMUK if (Nepomuk::ResourceManager::instance()->init() == 0) { - if (!(hiddenData & MetaDataWidget::RatingData)) { + if (visibleDataTypes & KMetaDataWidget::RatingData) { fixedItems.append(FixedItem("rating", i18nc("@item::inlistbox", "Rating"))); - } - if (!(hiddenData & MetaDataWidget::TagsData)) { + } + if (visibleDataTypes & KMetaDataWidget::TagsData) { fixedItems.append(FixedItem("tags", i18nc("@item::inlistbox", "Tags"))); } - if (!(hiddenData & MetaDataWidget::CommentData)) { + if (visibleDataTypes & KMetaDataWidget::CommentData) { fixedItems.append(FixedItem("comment", i18nc("@item::inlistbox", "Comment"))); } } @@ -175,6 +179,7 @@ void MetaDataConfigurationDialog::Private::loadMetaData() // should not be shown as second entry. static const char* hiddenProperties[] = { "contentSize", // = fixed item "size" + "description", // = fixed item "comment" "fileExtension", // ~ fixed item "type" "hasTag", // = fixed item "tags" "name", // not shown as part of the meta data widget @@ -211,7 +216,7 @@ void MetaDataConfigurationDialog::Private::loadMetaData() #endif } -QString MetaDataConfigurationDialog::Private::tunedLabel(const QString& label) const +QString KMetaDataConfigurationDialog::Private::tunedLabel(const QString& label) const { QString tunedLabel; const int labelLength = label.length(); @@ -230,14 +235,14 @@ QString MetaDataConfigurationDialog::Private::tunedLabel(const QString& label) c return tunedLabel; } -MetaDataConfigurationDialog::MetaDataConfigurationDialog(QWidget* parent, +KMetaDataConfigurationDialog::KMetaDataConfigurationDialog(QWidget* parent, Qt::WFlags flags) : KDialog(parent, flags), d(new Private(this, 0)) { } -MetaDataConfigurationDialog::MetaDataConfigurationDialog(MetaDataWidget* metaDataWidget, +KMetaDataConfigurationDialog::KMetaDataConfigurationDialog(KMetaDataWidget* metaDataWidget, QWidget* parent, Qt::WFlags flags) : KDialog(parent, flags), @@ -245,11 +250,11 @@ MetaDataConfigurationDialog::MetaDataConfigurationDialog(MetaDataWidget* metaDat { } -MetaDataConfigurationDialog::~MetaDataConfigurationDialog() +KMetaDataConfigurationDialog::~KMetaDataConfigurationDialog() { } -void MetaDataConfigurationDialog::slotButtonClicked(int button) +void KMetaDataConfigurationDialog::slotButtonClicked(int button) { if (button == KDialog::Ok) { KConfig config("kmetainformationrc", KConfig::NoGlobals); @@ -267,7 +272,7 @@ void MetaDataConfigurationDialog::slotButtonClicked(int button) if (d->m_metaDataWidget != 0) { // trigger an update - d->m_metaDataWidget->setHiddenData(d->m_metaDataWidget->hiddenData()); + d->m_metaDataWidget->setVisibleDataTypes(d->m_metaDataWidget->visibleDataTypes()); } accept(); } else { @@ -275,4 +280,4 @@ void MetaDataConfigurationDialog::slotButtonClicked(int button) } } -#include "metadataconfigurationdialog.moc" +#include "kmetadataconfigurationdialog.moc" diff --git a/src/panels/information/kmetadataconfigurationdialog.h b/src/panels/information/kmetadataconfigurationdialog.h new file mode 100644 index 000000000..98579d751 --- /dev/null +++ b/src/panels/information/kmetadataconfigurationdialog.h @@ -0,0 +1,63 @@ +/***************************************************************************** + * 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 KMETA_DATA_CONFIGURATION_DIALOG_H +#define KMETA_DATA_CONFIGURATION_DIALOG_H + +#include +#include + +class KMetaDataWidget; + +/** + * @brief Dialog which allows to configure which meta data should be shown. + * @see KMetaDataWidget + */ +class KFILE_EXPORT KMetaDataConfigurationDialog : public KDialog +{ + Q_OBJECT + +public: + /** + * Allows to configure the visibility of all available meta + * data. + */ + KMetaDataConfigurationDialog(QWidget* parent = 0, + Qt::WFlags flags = 0); + + /** + * Allows to configure the visibility of the meta data + * shown by the meta data widget. The number of offered + * meta data is optimized for the set of file items + * that are applied to the meta data widget. + */ + KMetaDataConfigurationDialog(KMetaDataWidget* metaDataWidget, + QWidget* parent = 0, + Qt::WFlags flags = 0); + + virtual ~KMetaDataConfigurationDialog(); + +protected slots: + virtual void slotButtonClicked(int button); + +private: + class Private; + Private* d; +}; + +#endif diff --git a/src/panels/information/metadatawidget.cpp b/src/panels/information/kmetadatawidget.cpp similarity index 78% rename from src/panels/information/metadatawidget.cpp rename to src/panels/information/kmetadatawidget.cpp index 67e3d1e44..fd2f237dd 100644 --- a/src/panels/information/metadatawidget.cpp +++ b/src/panels/information/kmetadatawidget.cpp @@ -1,24 +1,23 @@ -/*************************************************************************** - * Copyright (C) 2008 by Sebastian Trueg * - * Copyright (C) 2009 by Peter Penz * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ - -#include "metadatawidget.h" +/***************************************************************************** + * Copyright (C) 2008 by Sebastian Trueg * + * 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. * + *****************************************************************************/ + +#include "kmetadatawidget.h" #include #include @@ -36,24 +35,22 @@ #ifdef HAVE_NEPOMUK #define DISABLE_NEPOMUK_LEGACY - #include "commentwidget_p.h" - #include "nepomukmassupdatejob_p.h" - #include "taggingwidget_p.h" + #include "kcommentwidget_p.h" + #include "ktaggingwidget_p.h" - #include - #include - #include - #include - #include + #include + #include + #include + #include + #include + #include "nepomukmassupdatejob_p.h" #include #include #include #endif -#include - -class MetaDataWidget::Private +class KMetaDataWidget::Private { public: struct Row @@ -62,7 +59,7 @@ public: QWidget* infoWidget; }; - Private(MetaDataWidget* parent); + Private(KMetaDataWidget* parent); ~Private(); void addRow(QLabel* label, QWidget* infoWidget); @@ -96,7 +93,7 @@ public: void startChangeDataJob(KJob* job); bool m_isSizeVisible; - MetaDataTypes m_hiddenData; + MetaDataTypes m_visibleDataTypes; QList m_fileItems; QList m_rows; @@ -111,8 +108,8 @@ public: #ifdef HAVE_NEPOMUK KRatingWidget* m_ratingWidget; - TaggingWidget* m_taggingWidget; - CommentWidget* m_commentWidget; + KTaggingWidget* m_taggingWidget; + KCommentWidget* m_commentWidget; // shared data between the GUI-thread and // the loader-thread (see LoadFilesThread): @@ -165,12 +162,13 @@ public: #endif private: - MetaDataWidget* const q; + KMetaDataWidget* const q; }; -MetaDataWidget::Private::Private(MetaDataWidget* parent) : +KMetaDataWidget::Private::Private(KMetaDataWidget* parent) : m_isSizeVisible(true), - m_hiddenData(None), + m_visibleDataTypes(TypeData | SizeData | ModifiedData | OwnerData | + PermissionsData | RatingData | TagsData | CommentData), m_fileItems(), m_rows(), m_gridLayout(0), @@ -212,11 +210,11 @@ MetaDataWidget::Private::Private(MetaDataWidget* parent) : connect(m_ratingWidget, SIGNAL(ratingChanged(unsigned int)), q, SLOT(slotRatingChanged(unsigned int))); - m_taggingWidget = new TaggingWidget(parent); + m_taggingWidget = new KTaggingWidget(parent); connect(m_taggingWidget, SIGNAL(tagsChanged(const QList&)), q, SLOT(slotTagsChanged(const QList&))); - m_commentWidget = new CommentWidget(parent); + m_commentWidget = new KCommentWidget(parent); connect(m_commentWidget, SIGNAL(commentChanged(const QString&)), q, SLOT(slotCommentChanged(const QString&))); @@ -235,14 +233,14 @@ MetaDataWidget::Private::Private(MetaDataWidget* parent) : updateRowsVisibility(); } -MetaDataWidget::Private::~Private() +KMetaDataWidget::Private::~Private() { #ifdef HAVE_NEPOMUK delete m_loadFilesThread; #endif } -void MetaDataWidget::Private::addRow(QLabel* label, QWidget* infoWidget) +void KMetaDataWidget::Private::addRow(QLabel* label, QWidget* infoWidget) { Row row; row.label = label; @@ -275,7 +273,7 @@ void MetaDataWidget::Private::addRow(QLabel* label, QWidget* infoWidget) m_gridLayout->addWidget(infoWidget, rowIndex, 2, Qt::AlignLeft); } -void MetaDataWidget::Private::setRowVisible(QWidget* infoWidget, bool visible) +void KMetaDataWidget::Private::setRowVisible(QWidget* infoWidget, bool visible) { foreach (const Row& row, m_rows) { if (row.infoWidget == infoWidget) { @@ -287,7 +285,7 @@ void MetaDataWidget::Private::setRowVisible(QWidget* infoWidget, bool visible) } -void MetaDataWidget::Private::initMetaInfoSettings() +void KMetaDataWidget::Private::initMetaInfoSettings() { KConfig config("kmetainformationrc", KConfig::NoGlobals); KConfigGroup settings = config.group("Show"); @@ -314,52 +312,52 @@ void MetaDataWidget::Private::initMetaInfoSettings() } } -void MetaDataWidget::Private::updateRowsVisibility() +void KMetaDataWidget::Private::updateRowsVisibility() { KConfig config("kmetainformationrc", KConfig::NoGlobals); KConfigGroup settings = config.group("Show"); setRowVisible(m_typeInfo, - !(m_hiddenData & MetaDataWidget::TypeData) && + (m_visibleDataTypes & KMetaDataWidget::TypeData) && settings.readEntry("type", true)); // Cache in m_isSizeVisible whether the size should be shown. This // is necessary as the size is temporary hidden when the target // file item is a directory. - m_isSizeVisible = !(m_hiddenData & MetaDataWidget::SizeData) && + m_isSizeVisible = (m_visibleDataTypes & KMetaDataWidget::SizeData) && settings.readEntry("size", true); setRowVisible(m_sizeInfo, m_isSizeVisible); setRowVisible(m_modifiedInfo, - !(m_hiddenData & MetaDataWidget::ModifiedData) && + (m_visibleDataTypes & KMetaDataWidget::ModifiedData) && settings.readEntry("modified", true)); setRowVisible(m_ownerInfo, - !(m_hiddenData & MetaDataWidget::OwnerData) && + (m_visibleDataTypes & KMetaDataWidget::OwnerData) && settings.readEntry("owner", true)); setRowVisible(m_permissionsInfo, - !(m_hiddenData & MetaDataWidget::PermissionsData) && + (m_visibleDataTypes & KMetaDataWidget::PermissionsData) && settings.readEntry("permissions", true)); #ifdef HAVE_NEPOMUK if (Nepomuk::ResourceManager::instance()->init() == 0) { setRowVisible(m_ratingWidget, - !(m_hiddenData & MetaDataWidget::RatingData) && + (m_visibleDataTypes & KMetaDataWidget::RatingData) && settings.readEntry("rating", true)); setRowVisible(m_taggingWidget, - !(m_hiddenData & MetaDataWidget::TagsData) && + (m_visibleDataTypes & KMetaDataWidget::TagsData) && settings.readEntry("tags", true)); setRowVisible(m_commentWidget, - !(m_hiddenData & MetaDataWidget::CommentData) && + (m_visibleDataTypes & KMetaDataWidget::CommentData) && settings.readEntry("comment", true)); } #endif } -void MetaDataWidget::Private::slotLoadingFinished() +void KMetaDataWidget::Private::slotLoadingFinished() { #ifdef HAVE_NEPOMUK QMutexLocker locker(&m_mutex); @@ -401,12 +399,10 @@ void MetaDataWidget::Private::slotLoadingFinished() delete m_rows[i].infoWidget; m_rows.pop_back(); } - - emit q->loadingFinished(); #endif } -void MetaDataWidget::Private::slotRatingChanged(unsigned int rating) +void KMetaDataWidget::Private::slotRatingChanged(unsigned int rating) { #ifdef HAVE_NEPOMUK QMutexLocker locker(&m_mutex); @@ -415,10 +411,9 @@ void MetaDataWidget::Private::slotRatingChanged(unsigned int rating) locker.unlock(); startChangeDataJob(job); #endif - emit q->ratingChanged(rating); } -void MetaDataWidget::Private::slotTagsChanged(const QList& tags) +void KMetaDataWidget::Private::slotTagsChanged(const QList& tags) { #ifdef HAVE_NEPOMUK m_taggingWidget->setTags(tags); @@ -429,10 +424,9 @@ void MetaDataWidget::Private::slotTagsChanged(const QList& tags) locker.unlock(); startChangeDataJob(job); #endif - emit q->tagsChanged(tags); } -void MetaDataWidget::Private::slotCommentChanged(const QString& comment) +void KMetaDataWidget::Private::slotCommentChanged(const QString& comment) { #ifdef HAVE_NEPOMUK QMutexLocker locker(&m_mutex); @@ -441,15 +435,14 @@ void MetaDataWidget::Private::slotCommentChanged(const QString& comment) locker.unlock(); startChangeDataJob(job); #endif - emit q->commentChanged(comment); } -void MetaDataWidget::Private::slotMetaDataUpdateDone() +void KMetaDataWidget::Private::slotMetaDataUpdateDone() { q->setEnabled(true); } -void MetaDataWidget::Private::startChangeDataJob(KJob* job) +void KMetaDataWidget::Private::startChangeDataJob(KJob* job) { connect(job, SIGNAL(result(KJob*)), q, SLOT(slotMetaDataUpdateDone())); @@ -458,8 +451,8 @@ void MetaDataWidget::Private::startChangeDataJob(KJob* job) } #ifdef HAVE_NEPOMUK -MetaDataWidget::Private::LoadFilesThread::LoadFilesThread( - MetaDataWidget::Private::SharedData* m_sharedData, +KMetaDataWidget::Private::LoadFilesThread::LoadFilesThread( + KMetaDataWidget::Private::SharedData* m_sharedData, QMutex* m_mutex) : m_sharedData(m_sharedData), m_mutex(m_mutex), @@ -468,7 +461,7 @@ MetaDataWidget::Private::LoadFilesThread::LoadFilesThread( { } -MetaDataWidget::Private::LoadFilesThread::~LoadFilesThread() +KMetaDataWidget::Private::LoadFilesThread::~LoadFilesThread() { // This thread may very well be deleted during execution. We need // to protect it from crashes here. @@ -476,7 +469,7 @@ MetaDataWidget::Private::LoadFilesThread::~LoadFilesThread() wait(); } -void MetaDataWidget::Private::LoadFilesThread::loadFiles(const KUrl::List& urls) +void KMetaDataWidget::Private::LoadFilesThread::loadFiles(const KUrl::List& urls) { QMutexLocker locker(m_mutex); m_urls = urls; @@ -484,7 +477,7 @@ void MetaDataWidget::Private::LoadFilesThread::loadFiles(const KUrl::List& urls) start(); } -void MetaDataWidget::Private::LoadFilesThread::run() +void KMetaDataWidget::Private::LoadFilesThread::run() { QMutexLocker locker(m_mutex); const KUrl::List urls = m_urls; @@ -557,7 +550,7 @@ void MetaDataWidget::Private::LoadFilesThread::run() m_sharedData->files = files; } -QString MetaDataWidget::Private::LoadFilesThread::tunedLabel(const QString& label) const +QString KMetaDataWidget::Private::LoadFilesThread::tunedLabel(const QString& label) const { QString tunedLabel; const int labelLength = label.length(); @@ -578,18 +571,18 @@ QString MetaDataWidget::Private::LoadFilesThread::tunedLabel(const QString& labe #endif // HAVE_NEPOMUK -MetaDataWidget::MetaDataWidget(QWidget* parent) : +KMetaDataWidget::KMetaDataWidget(QWidget* parent) : QWidget(parent), d(new Private(this)) { } -MetaDataWidget::~MetaDataWidget() +KMetaDataWidget::~KMetaDataWidget() { delete d; } -void MetaDataWidget::setItem(const KFileItem& item) +void KMetaDataWidget::setItem(const KFileItem& item) { // update values for "type", "size", "modified", // "owner" and "permissions" synchronously @@ -609,7 +602,7 @@ void MetaDataWidget::setItem(const KFileItem& item) setItems(KFileItemList() << item); } -void MetaDataWidget::setItems(const KFileItemList& items) +void KMetaDataWidget::setItems(const KFileItemList& items) { d->m_fileItems = items; @@ -642,14 +635,14 @@ void MetaDataWidget::setItems(const KFileItemList& items) #endif } -void MetaDataWidget::setItem(const KUrl& url) +void KMetaDataWidget::setItem(const KUrl& url) { KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url); item.refresh(); setItem(item); } -void MetaDataWidget::setItems(const QList& urls) +void KMetaDataWidget::setItems(const QList& urls) { KFileItemList items; foreach (const KUrl& url, urls) { @@ -660,50 +653,20 @@ void MetaDataWidget::setItems(const QList& urls) setItems(items); } -KFileItemList MetaDataWidget::items() const +KFileItemList KMetaDataWidget::items() const { return d->m_fileItems; } -void MetaDataWidget::setHiddenData(MetaDataTypes data) +void KMetaDataWidget::setVisibleDataTypes(MetaDataTypes data) { - d->m_hiddenData = data; + d->m_visibleDataTypes = data; d->updateRowsVisibility(); } -MetaDataWidget::MetaDataTypes MetaDataWidget::hiddenData() const -{ - return d->m_hiddenData; -} - -unsigned int MetaDataWidget::rating() const +KMetaDataWidget::MetaDataTypes KMetaDataWidget::visibleDataTypes() const { -#ifdef HAVE_NEPOMUK - QMutexLocker locker(&d->m_mutex); - return d->m_sharedData.rating; -#else - return 0; -#endif -} - -QList MetaDataWidget::tags() const -{ -#ifdef HAVE_NEPOMUK - QMutexLocker locker(&d->m_mutex); - return d->m_sharedData.tags; -#else - return QList(); -#endif -} - -QString MetaDataWidget::comment() const -{ -#ifdef HAVE_NEPOMUK - QMutexLocker locker(&d->m_mutex); - return d->m_sharedData.comment; -#else - return QString(); -#endif + return d->m_visibleDataTypes; } -#include "metadatawidget.moc" +#include "kmetadatawidget.moc" diff --git a/src/panels/information/kmetadatawidget.h b/src/panels/information/kmetadatawidget.h new file mode 100644 index 000000000..fbcf79f40 --- /dev/null +++ b/src/panels/information/kmetadatawidget.h @@ -0,0 +1,129 @@ +/***************************************************************************** + * Copyright (C) 2008 by Sebastian Trueg * + * 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 KMETADATAWIDGET_H +#define KMETADATAWIDGET_H + +#include +#include + +#include +#include + +class KUrl; + +/** + * @brief Shows the meta data of one or more file items. + * + * Meta data like name, size, rating, comment, ... are + * shown as several rows containing a description and + * the meta data value. It is possible for the user + * to change specific meta data like rating, tags and + * comment. The changes are stored automatically by the + * meta data widget. + */ +class KFILE_EXPORT KMetaDataWidget : public QWidget +{ + Q_OBJECT + +public: + /** + * Allows to specify which general data types should be shown + * by the meta data widget. + * @see KMetaDataWidget::setVisibleDataTypes() + * @see KMetaDataWidget::visibleDataTypes() + */ + enum MetaDataType + { + None = 0, + TypeData = 1, + SizeData = 2, + ModifiedData = 4, + OwnerData = 8, + PermissionsData = 16, + RatingData = 32, + TagsData = 64, + CommentData = 128 + }; + Q_DECLARE_FLAGS(MetaDataTypes, MetaDataType) + + explicit KMetaDataWidget(QWidget* parent = 0); + virtual ~KMetaDataWidget(); + + /** + * Triggers the asynchronous loading of the meta data + * for the file item \p item. Connect to the signal + * loadingFinished() to be able to read the meta + * data. + */ + void setItem(const KFileItem& item); + + /** + * Triggers the asynchronous loading of the meta data + * for the file items \p items. Connect to the signal + * loadingFinished() to be able to read the meta + * data. + */ + void setItems(const KFileItemList& items); + + /** + * Convenience method for KMetaDataWidget::setItem(const KFileItem&), + * if the application has only an URL and no file item. + * For performance reason it is recommended to use this convenience + * method only if the application does not have a file item already. + */ + void setItem(const KUrl& url); + + /** + * Convenience method for KMetaDataWidget::setItems(const KFileItemList&), + * if the application has only URLs and no file items. + * For performance reason it is recommended to use this convenience + * method only if the application does not have a file items already. + */ + void setItems(const QList& urls); + + KFileItemList items() const; + + /** + * Specifies which kind of data types should be shown (@see KMetaDataWidget::Data). + * Example: metaDataWidget->setVisibleDataTypes(KMetaDataWidget::TypeData | KMetaDataWidget::ModifiedData); + * Per default all data types are shown. + */ + void setVisibleDataTypes(MetaDataTypes data); + + /** + * Returns which kind of data is shown (@see KMetaDataWidget::Data). + * Example: if (metaDataWidget->shownData() & KMetaDataWidget::TypeData) ... + */ + MetaDataTypes visibleDataTypes() const; + +private: + class Private; + Private* d; + + Q_PRIVATE_SLOT(d, void slotLoadingFinished()) + Q_PRIVATE_SLOT(d, void slotRatingChanged(unsigned int rating)) + Q_PRIVATE_SLOT(d, void slotTagsChanged(const QList& tags)) + Q_PRIVATE_SLOT(d, void slotCommentChanged(const QString& comment)) + Q_PRIVATE_SLOT(d, void slotMetaDataUpdateDone()) +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(KMetaDataWidget::MetaDataTypes) + +#endif diff --git a/src/panels/information/taggingwidget.cpp b/src/panels/information/ktaggingwidget.cpp similarity index 59% rename from src/panels/information/taggingwidget.cpp rename to src/panels/information/ktaggingwidget.cpp index 1c081f07c..3fc3b0026 100644 --- a/src/panels/information/taggingwidget.cpp +++ b/src/panels/information/ktaggingwidget.cpp @@ -1,25 +1,24 @@ -/*************************************************************************** - * Copyright (C) 2009 by Peter Penz * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ - -#include "taggingwidget_p.h" - -#include "edittagsdialog_p.h" +/***************************************************************************** + * 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. * + *****************************************************************************/ + +#include "ktaggingwidget_p.h" + +#include "kedittagsdialog_p.h" #include #include @@ -27,7 +26,7 @@ #include #include -TaggingWidget::TaggingWidget(QWidget* parent) : +KTaggingWidget::KTaggingWidget(QWidget* parent) : QWidget(parent), m_label(0), m_tags(), @@ -46,11 +45,11 @@ TaggingWidget::TaggingWidget(QWidget* parent) : setTags(QList()); } -TaggingWidget::~TaggingWidget() +KTaggingWidget::~KTaggingWidget() { } -void TaggingWidget::setTags(const QList& tags) +void KTaggingWidget::setTags(const QList& tags) { m_tags = tags; @@ -71,17 +70,17 @@ void TaggingWidget::setTags(const QList& tags) } } -QList TaggingWidget::tags() const +QList KTaggingWidget::tags() const { return m_tags; } -void TaggingWidget::slotLinkActivated(const QString& link) +void KTaggingWidget::slotLinkActivated(const QString& link) { Q_UNUSED(link); - EditTagsDialog dialog(m_tags, this, Qt::Dialog); - KConfigGroup dialogConfig(KGlobal::config(), "Nepomuk EditTagsDialog"); + KEditTagsDialog dialog(m_tags, this, Qt::Dialog); + KConfigGroup dialogConfig(KGlobal::config(), "Nepomuk KEditTagsDialog"); dialog.restoreDialogSize(dialogConfig); if (dialog.exec() == QDialog::Accepted) { @@ -107,4 +106,4 @@ void TaggingWidget::slotLinkActivated(const QString& link) dialog.saveDialogSize(dialogConfig, KConfigBase::Persistent); } -#include "taggingwidget_p.moc" +#include "ktaggingwidget_p.moc" diff --git a/src/panels/information/ktaggingwidget_p.h b/src/panels/information/ktaggingwidget_p.h new file mode 100644 index 000000000..b26bdca49 --- /dev/null +++ b/src/panels/information/ktaggingwidget_p.h @@ -0,0 +1,54 @@ +/***************************************************************************** + * 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 TAGGING_WIDGET_H +#define TAGGING_WIDGET_H + +#include +#include +#include + +class QLabel; + +/** + * @brief Allows to edit and show tags as part of KMetaDataWidget. + */ +class KTaggingWidget : public QWidget +{ + Q_OBJECT + +public: + KTaggingWidget(QWidget* parent); + virtual ~KTaggingWidget(); + + void setTags(const QList& tags); + QList tags() const; + +signals: + void tagsChanged(const QList& tags); + +private slots: + void slotLinkActivated(const QString& link); + +private: + QLabel* m_label; + QList m_tags; + QString m_tagsText; +}; + +#endif diff --git a/src/panels/information/metadataconfigurationdialog.h b/src/panels/information/metadataconfigurationdialog.h deleted file mode 100644 index 82dc06ddf..000000000 --- a/src/panels/information/metadataconfigurationdialog.h +++ /dev/null @@ -1,62 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2009 by Peter Penz * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ - -#ifndef META_DATA_CONFIGURATION_DIALOG_H -#define META_DATA_CONFIGURATION_DIALOG_H - -#include - -class MetaDataWidget; - -/** - * @brief Dialog which allows to configure which meta data should be shown. - */ -class MetaDataConfigurationDialog : public KDialog -{ - Q_OBJECT - -public: - /** - * Allows to configure the visibility of all available meta - * data. - */ - MetaDataConfigurationDialog(QWidget* parent = 0, - Qt::WFlags flags = 0); - - /** - * Allows to configure the visibility of the meta data - * shown by the meta data widget. The number of offered - * meta data is optimized for the set of file items - * that are applied to the meta data widget. - */ - MetaDataConfigurationDialog(MetaDataWidget* metaDataWidget, - QWidget* parent = 0, - Qt::WFlags flags = 0); - - virtual ~MetaDataConfigurationDialog(); - -protected slots: - virtual void slotButtonClicked(int button); - -private: - class Private; - Private* d; -}; - -#endif diff --git a/src/panels/information/metadatawidget.h b/src/panels/information/metadatawidget.h deleted file mode 100644 index b03469014..000000000 --- a/src/panels/information/metadatawidget.h +++ /dev/null @@ -1,202 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008 by Sebastian Trueg * - * Copyright (C) 2009 by Peter Penz * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ - -#ifndef METADATAWIDGET_H -#define METADATAWIDGET_H - -#include -#ifdef HAVE_NEPOMUK - #include -#else - // The HAVE_NEPOMUK macro cannot be used in combination with - // Q_PRIVATE_SLOT, hence a workaround is used for environments - // where Nepomuk is not available: - namespace Nepomuk { - typedef int Tag; - } -#endif - -#include - -#include -#include - -class KUrl; - -/** - * @brief Shows the meta data of one or more file items. - * - * Meta data like name, size, rating, comment, ... are - * shown as several rows containing a description and - * the meta data value. It is possible for the user - * to change specific meta data like rating, tags and - * comment. The changes are stored automatically by the - * meta data widget. - */ -class MetaDataWidget : public QWidget -{ - Q_OBJECT - -public: - /** - * Allows to specify which general data should be hidden - * by the meta data widget. - * @see MetaDataWidget::setHiddenData() - * @see MetaDataWidget::hiddenData() - */ - enum MetaDataType - { - None = 0, - TypeData = 1, - SizeData= 2, - ModifiedData = 4, - OwnerData = 8, - PermissionsData = 16, - RatingData = 32, - TagsData = 64, - CommentData = 128 - }; - Q_DECLARE_FLAGS( MetaDataTypes, MetaDataType ) - - explicit MetaDataWidget(QWidget* parent = 0); - virtual ~MetaDataWidget(); - - /** - * Triggers the asynchronous loading of the meta data - * for the file item \p item. Connect to the signal - * loadingFinished() to be able to read the meta - * data. - */ - void setItem(const KFileItem& item); - - /** - * Triggers the asynchronous loading of the meta data - * for the file items \p items. Connect to the signal - * loadingFinished() to be able to read the meta - * data. - */ - void setItems(const KFileItemList& items); - - /** - * Convenience method for MetaDataWidget::setItem(const KFileItem&), - * if the application has only an URL and no file item. - * For performance reason it is recommended to use this convenience - * method only if the application does not have a file item already. - */ - void setItem(const KUrl& url); - - /** - * Convenience method for MetaDataWidget::setItems(const KFileItemList&), - * if the application has only URLs and no file items. - * For performance reason it is recommended to use this convenience - * method only if the application does not have a file items already. - */ - void setItems(const QList& urls); - - KFileItemList items() const; - - /** - * Specifies which kind of data should be hidden (@see MetaDataWidget::Data). - * Example: metaDataWidget->setHiddenData(MetaDataWidget::TypeData | ModifiedData); - * Per default no data is hidden. - */ - void setHiddenData(MetaDataTypes data); - - /** - * Returns which kind of data is hidden (@see MetaDataWidget::Data). - * Example: if (metaDataWidget->hiddenData() & MetaDataWidget::TypeData) ... - */ - MetaDataTypes hiddenData() const; - - /** - * Returns the rating for the currently set item(s). It is required - * to wait for the signal loadingFinished() or ratingChanged() - * to get a valid result. - */ - unsigned int rating() const; - - /** - * Returns the tags for the currently set item(s). It is required - * to wait for the signal loadingFinished() or tagsChanged() - * to get a valid result. - */ - QList tags() const; - - /** - * Returns the comment for the currently set item(s). It is required - * to wait for the signal loadingFinished() or commentChanged() - * to get a valid result. - */ - QString comment() const; - -signals: - /** - * Is emitted if the loading of the meta data has been finished - * after invoking MetaDataWidget::setItem() or MetaDataWidget::setItems(). - */ - void loadingFinished(); - - /** - * Is emitted after the user has changed the rating. - * The changed rating is automatically stored already by - * the meta data widget. - * Note that the signal is not emitted if the rating has - * indirectly been changed by MetaDataWidget::setItem() or - * MetaDataWidget::setItems(). In this case connect to - * the signal loadingFinished() instead. - */ - void ratingChanged(const int rating); - - /** - * Is emitted after the user has changed the tags. - * The changed tags are automatically stored already by - * the meta data widget. - * Note that the signal is not emitted if the tags have - * indirectly been changed by MetaDataWidget::setItem() or - * MetaDataWidget::setItems(). In this case connect to - * the signal loadingFinished() instead. - */ - void tagsChanged(const QList& tags); - - /** - * Is emitted after the user has changed the comment. - * The changed comment is automatically stored already by - * the meta data widget. - * Note that the signal is not emitted if the comment has - * indirectly been changed by MetaDataWidget::setItem() or - * MetaDataWidget::setItems(). In this case connect to - * the signal loadingFinished() instead. - */ - void commentChanged(const QString& comment); - -private: - class Private; - Private* d; - - Q_PRIVATE_SLOT(d, void slotLoadingFinished()) - Q_PRIVATE_SLOT(d, void slotRatingChanged(unsigned int rating)) - Q_PRIVATE_SLOT(d, void slotTagsChanged(const QList& tags)) - Q_PRIVATE_SLOT(d, void slotCommentChanged(const QString& comment)) - Q_PRIVATE_SLOT(d, void slotMetaDataUpdateDone()) -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(MetaDataWidget::MetaDataTypes) - -#endif diff --git a/src/panels/information/taggingwidget_p.h b/src/panels/information/taggingwidget_p.h deleted file mode 100644 index 64f8bffd5..000000000 --- a/src/panels/information/taggingwidget_p.h +++ /dev/null @@ -1,52 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2009 by Peter Penz * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ - -#ifndef TAGGING_WIDGET_H -#define TAGGING_WIDGET_H - -#include -#include -#include - -class QLabel; - -class TaggingWidget : public QWidget -{ - Q_OBJECT - -public: - TaggingWidget(QWidget* parent); - virtual ~TaggingWidget(); - - void setTags(const QList& tags); - QList tags() const; - -signals: - void tagsChanged(const QList& tags); - -private slots: - void slotLinkActivated(const QString& link); - -private: - QLabel* m_label; - QList m_tags; - QString m_tagsText; -}; - -#endif