From a56d2e78ce3265b66b1443a7707cf54114da7f69 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Sat, 10 Oct 2009 20:12:58 +0000 Subject: Reactivate reading of the meta data for the rating, comments and tags. All expensive operations are done in a separate thread to assure that the Dolphin UI never gets blocked. svn path=/trunk/KDE/kdebase/apps/; revision=1033696 --- src/panels/information/commentwidget.cpp | 61 +++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) (limited to 'src/panels/information/commentwidget.cpp') diff --git a/src/panels/information/commentwidget.cpp b/src/panels/information/commentwidget.cpp index 63d8a1dc3..6397bc39a 100644 --- a/src/panels/information/commentwidget.cpp +++ b/src/panels/information/commentwidget.cpp @@ -1,4 +1,5 @@ /*************************************************************************** + * Copyright (C) 2008 by Sebastian Trueg * * Copyright (C) 2009 by Peter Penz * * * * This program is free software; you can redistribute it and/or modify * @@ -19,13 +20,71 @@ #include "commentwidget_p.h" +#include +#include + +#include +#include +#include + CommentWidget::CommentWidget(QWidget* parent) : - QWidget(parent) + QWidget(parent), + m_label(0), + m_comment() { + m_label = new QLabel(this); + connect(m_label, SIGNAL(linkActivated(const QString&)), this, SLOT(slotLinkActivated(const QString&))); + + QVBoxLayout* layout = new QVBoxLayout(this); + layout->addWidget(m_label); + + setText(m_comment); } CommentWidget::~CommentWidget() { } +void CommentWidget::setText(const QString& comment) +{ + if (comment.isEmpty()) { + m_label->setText("" + i18nc("@label", "Add Comment...") + ""); + } else { + m_label->setText("

" + comment + " " + i18nc("@label", "Change...") + "

"); + } + m_comment = comment; +} + +QString CommentWidget::text() const +{ + return m_comment; +} + +void CommentWidget::slotLinkActivated(const QString& link) +{ + KDialog dialog(0, Qt::Dialog); + + QTextEdit* editor = new QTextEdit(&dialog); + editor->setText(m_comment); + + dialog.setMainWidget(editor); + + const QString caption = (link == "changeComment") ? + i18nc("@title:window", "Change Comment") : + i18nc("@title:window", "Add Comment"); + dialog.setCaption(caption); + dialog.setButtons(KDialog::Ok | KDialog::Cancel); + dialog.setDefaultButton(KDialog::Ok); + + KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"), + "EditCommitDialog"); + dialog.restoreDialogSize(dialogConfig); + + if (dialog.exec() == QDialog::Accepted) { + setText(editor->toPlainText()); + } + + dialog.saveDialogSize(dialogConfig, KConfigBase::Persistent); +} + #include "commentwidget_p.moc" -- cgit v1.3