mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-19 16:31:21 +00:00
Reactivate showing of general meta information. This is also done as part of the LoadFilesThread and is no special case anymore like in the old code base.
svn path=/trunk/KDE/kdebase/apps/; revision=1033722
This commit is contained in:
parent
a56d2e78ce
commit
b786c28e04
|
@ -51,13 +51,6 @@
|
||||||
#include "phononwidget.h"
|
#include "phononwidget.h"
|
||||||
#include "pixmapviewer.h"
|
#include "pixmapviewer.h"
|
||||||
|
|
||||||
#ifdef HAVE_NEPOMUK
|
|
||||||
#define DISABLE_NEPOMUK_LEGACY
|
|
||||||
#include <Nepomuk/Resource>
|
|
||||||
#include <Nepomuk/Types/Property>
|
|
||||||
#include <Nepomuk/Variant>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function for sorting items with qSort() in
|
* Helper function for sorting items with qSort() in
|
||||||
* InformationPanelContent::contextMenu().
|
* InformationPanelContent::contextMenu().
|
||||||
|
@ -188,30 +181,6 @@ void InformationPanelContent::showItem(const KFileItem& item)
|
||||||
setNameLabelText(itemUrl.fileName());
|
setNameLabelText(itemUrl.fileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: move to MetaDataWidget
|
|
||||||
if (!item.isDir() && item.nepomukUri().isValid()) {
|
|
||||||
KConfig config("kmetainformationrc", KConfig::NoGlobals);
|
|
||||||
KConfigGroup settings = config.group("Show");
|
|
||||||
initMetaInfoSettings(settings);
|
|
||||||
|
|
||||||
Nepomuk::Resource res(item.url());
|
|
||||||
|
|
||||||
QHash<QUrl, Nepomuk::Variant> properties = res.properties();
|
|
||||||
QHash<QUrl, Nepomuk::Variant>::const_iterator it = properties.constBegin();
|
|
||||||
while (it != properties.constEnd()) {
|
|
||||||
Nepomuk::Types::Property prop(it.key());
|
|
||||||
if (settings.readEntry(prop.name(), true)) {
|
|
||||||
// TODO #1: use Nepomuk::formatValue(res, prop) if available
|
|
||||||
// instead of it.value().toString()
|
|
||||||
// TODO #2: using tunedLabel() is a workaround for KDE 4.3 until
|
|
||||||
// we get translated labels
|
|
||||||
m_metaTextLabel->add(tunedLabel(prop.label()) + ':', it.value().toString());
|
|
||||||
}
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (m_metaDataWidget != 0) {
|
if (m_metaDataWidget != 0) {
|
||||||
m_metaDataWidget->setItem(item);
|
m_metaDataWidget->setItem(item);
|
||||||
}
|
}
|
||||||
|
@ -299,7 +268,6 @@ bool InformationPanelContent::eventFilter(QObject* obj, QEvent* event)
|
||||||
|
|
||||||
void InformationPanelContent::configureSettings()
|
void InformationPanelContent::configureSettings()
|
||||||
{
|
{
|
||||||
#ifdef HAVE_NEPOMUK
|
|
||||||
if (m_item.isNull() ||
|
if (m_item.isNull() ||
|
||||||
!m_item.nepomukUri().isValid()) {
|
!m_item.nepomukUri().isValid()) {
|
||||||
return;
|
return;
|
||||||
|
@ -333,13 +301,12 @@ void InformationPanelContent::configureSettings()
|
||||||
|
|
||||||
KConfig config("kmetainformationrc", KConfig::NoGlobals);
|
KConfig config("kmetainformationrc", KConfig::NoGlobals);
|
||||||
KConfigGroup settings = config.group("Show");
|
KConfigGroup settings = config.group("Show");
|
||||||
initMetaInfoSettings(settings);
|
|
||||||
|
|
||||||
QList<QAction*> actions;
|
QList<QAction*> actions;
|
||||||
|
|
||||||
// Get all meta information labels that are available for
|
// Get all meta information labels that are available for
|
||||||
// the currently shown file item and add them to the popup.
|
// the currently shown file item and add them to the popup.
|
||||||
Nepomuk::Resource res(m_item.url());
|
/*Nepomuk::Resource res(m_item.url());
|
||||||
QHash<QUrl, Nepomuk::Variant> properties = res.properties();
|
QHash<QUrl, Nepomuk::Variant> properties = res.properties();
|
||||||
QHash<QUrl, Nepomuk::Variant>::const_iterator it = properties.constBegin();
|
QHash<QUrl, Nepomuk::Variant>::const_iterator it = properties.constBegin();
|
||||||
while (it != properties.constEnd()) {
|
while (it != properties.constEnd()) {
|
||||||
|
@ -375,7 +342,7 @@ void InformationPanelContent::configureSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
++it;
|
++it;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if (!actions.isEmpty()) {
|
if (!actions.isEmpty()) {
|
||||||
popup.addSeparator();
|
popup.addSeparator();
|
||||||
|
@ -421,7 +388,6 @@ void InformationPanelContent::configureSettings()
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
showItem(m_item);
|
showItem(m_item);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InformationPanelContent::showIcon(const KFileItem& item)
|
void InformationPanelContent::showIcon(const KFileItem& item)
|
||||||
|
@ -511,52 +477,4 @@ void InformationPanelContent::setNameLabelText(const QString& text)
|
||||||
m_nameLabel->setText(wrappedText);
|
m_nameLabel->setText(wrappedText);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InformationPanelContent::initMetaInfoSettings(KConfigGroup& group)
|
|
||||||
{
|
|
||||||
if (!group.readEntry("initialized", false)) {
|
|
||||||
// The resource file is read the first time. Assure
|
|
||||||
// that some meta information is disabled per default.
|
|
||||||
|
|
||||||
static const char* disabledProperties[] = {
|
|
||||||
"asText", "contentSize", "depth", "fileExtension",
|
|
||||||
"fileName", "fileSize", "isPartOf", "mimetype", "name",
|
|
||||||
"parentUrl", "plainTextContent", "sourceModified",
|
|
||||||
"size", "url",
|
|
||||||
0 // mandatory last entry
|
|
||||||
};
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
while (disabledProperties[i] != 0) {
|
|
||||||
group.writeEntry(disabledProperties[i], false);
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
|
|
||||||
// mark the group as initialized
|
|
||||||
group.writeEntry("initialized", true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString InformationPanelContent::tunedLabel(const QString& label) const
|
|
||||||
{
|
|
||||||
QString tunedLabel;
|
|
||||||
const int labelLength = label.length();
|
|
||||||
if (labelLength > 0) {
|
|
||||||
tunedLabel.reserve(labelLength);
|
|
||||||
tunedLabel = label[0].toUpper();
|
|
||||||
for (int i = 1; i < labelLength; ++i) {
|
|
||||||
if (label[i].isUpper() && !label[i - 1].isSpace() && !label[i - 1].isUpper()) {
|
|
||||||
tunedLabel += ' ';
|
|
||||||
tunedLabel += label[i].toLower();
|
|
||||||
} else {
|
|
||||||
tunedLabel += label[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return tunedLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InformationPanelContent::init()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "informationpanelcontent.moc"
|
#include "informationpanelcontent.moc"
|
||||||
|
|
|
@ -110,21 +110,6 @@ private:
|
||||||
*/
|
*/
|
||||||
void setNameLabelText(const QString& text);
|
void setNameLabelText(const QString& text);
|
||||||
|
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
|
|
||||||
void init();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KFileItem m_item;
|
KFileItem m_item;
|
||||||
|
|
||||||
|
|
|
@ -30,13 +30,21 @@
|
||||||
|
|
||||||
#include <config-nepomuk.h>
|
#include <config-nepomuk.h>
|
||||||
#ifdef HAVE_NEPOMUK
|
#ifdef HAVE_NEPOMUK
|
||||||
|
#define DISABLE_NEPOMUK_LEGACY
|
||||||
|
|
||||||
#include "commentwidget_p.h"
|
#include "commentwidget_p.h"
|
||||||
#include "nepomukmassupdatejob_p.h"
|
#include "nepomukmassupdatejob_p.h"
|
||||||
#include "taggingwidget_p.h"
|
#include "taggingwidget_p.h"
|
||||||
|
|
||||||
#include <nepomuk/kratingwidget.h>
|
#include <kconfig.h>
|
||||||
#include <nepomuk/resource.h>
|
#include <kconfiggroup.h>
|
||||||
#include <nepomuk/tag.h>
|
|
||||||
|
#include <Nepomuk/KRatingWidget>
|
||||||
|
#include <Nepomuk/Resource>
|
||||||
|
#include <Nepomuk/Tag>
|
||||||
|
#include <Nepomuk/Types/Property>
|
||||||
|
#include <Nepomuk/Variant>
|
||||||
|
|
||||||
#include <Soprano/Vocabulary/Xesam>
|
#include <Soprano/Vocabulary/Xesam>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
@ -55,35 +63,38 @@ public:
|
||||||
~Private();
|
~Private();
|
||||||
|
|
||||||
void addRow(QLabel* label, QWidget* infoWidget);
|
void addRow(QLabel* label, QWidget* infoWidget);
|
||||||
|
void removeMetaInfoRows();
|
||||||
void setRowVisible(QWidget* infoWidget, bool visible);
|
void setRowVisible(QWidget* infoWidget, bool visible);
|
||||||
|
|
||||||
void slotLoadingFinished();
|
void slotLoadingFinished();
|
||||||
|
|
||||||
QList<Row> rows;
|
QList<Row> m_rows;
|
||||||
|
|
||||||
QGridLayout* gridLayout;
|
QGridLayout* m_gridLayout;
|
||||||
|
|
||||||
QLabel* typeInfo;
|
QLabel* m_typeInfo;
|
||||||
QLabel* sizeLabel;
|
QLabel* m_sizeLabel;
|
||||||
QLabel* sizeInfo;
|
QLabel* m_sizeInfo;
|
||||||
QLabel* modifiedInfo;
|
QLabel* m_modifiedInfo;
|
||||||
QLabel* ownerInfo;
|
QLabel* m_ownerInfo;
|
||||||
QLabel* permissionsInfo;
|
QLabel* m_permissionsInfo;
|
||||||
|
|
||||||
#ifdef HAVE_NEPOMUK
|
#ifdef HAVE_NEPOMUK
|
||||||
KRatingWidget* ratingWidget;
|
KRatingWidget* m_ratingWidget;
|
||||||
TaggingWidget* taggingWidget;
|
TaggingWidget* m_taggingWidget;
|
||||||
CommentWidget* commentWidget;
|
CommentWidget* m_commentWidget;
|
||||||
|
|
||||||
// shared data between the GUI-thread and
|
// shared data between the GUI-thread and
|
||||||
// the loader-thread (see LoadFilesThread):
|
// the loader-thread (see LoadFilesThread):
|
||||||
QMutex mutex;
|
QMutex m_mutex;
|
||||||
struct SharedData
|
struct SharedData
|
||||||
{
|
{
|
||||||
int rating;
|
int rating;
|
||||||
QString comment;
|
QString comment;
|
||||||
QList<Nepomuk::Tag> tags;
|
QList<Nepomuk::Tag> tags;
|
||||||
} sharedData;
|
QList<QString> metaInfoLabels;
|
||||||
|
QList<QString> metaInfoValues;
|
||||||
|
} m_sharedData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the meta data of files and writes
|
* Loads the meta data of files and writes
|
||||||
|
@ -93,19 +104,33 @@ public:
|
||||||
class LoadFilesThread : public QThread
|
class LoadFilesThread : public QThread
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LoadFilesThread(SharedData* sharedData, QMutex* mutex);
|
LoadFilesThread(SharedData* m_sharedData, QMutex* m_mutex);
|
||||||
virtual ~LoadFilesThread();
|
virtual ~LoadFilesThread();
|
||||||
void loadFiles(const KUrl::List& urls);
|
void loadFiles(const KUrl::List& urls);
|
||||||
virtual void run();
|
virtual void run();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SharedData* m_sharedData;
|
/**
|
||||||
QMutex* m_mutex;
|
* 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:
|
||||||
|
SharedData* m_m_sharedData;
|
||||||
|
QMutex* m_m_mutex;
|
||||||
KUrl::List m_urls;
|
KUrl::List m_urls;
|
||||||
bool m_canceled;
|
bool m_canceled;
|
||||||
};
|
};
|
||||||
|
|
||||||
LoadFilesThread* loadFilesThread;
|
LoadFilesThread* m_loadFilesThread;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -113,56 +138,56 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
MetaDataWidget::Private::Private(MetaDataWidget* parent) :
|
MetaDataWidget::Private::Private(MetaDataWidget* parent) :
|
||||||
rows(),
|
m_rows(),
|
||||||
gridLayout(0),
|
m_gridLayout(0),
|
||||||
typeInfo(0),
|
m_typeInfo(0),
|
||||||
sizeLabel(0),
|
m_sizeLabel(0),
|
||||||
sizeInfo(0),
|
m_sizeInfo(0),
|
||||||
modifiedInfo(0),
|
m_modifiedInfo(0),
|
||||||
ownerInfo(0),
|
m_ownerInfo(0),
|
||||||
permissionsInfo(0),
|
m_permissionsInfo(0),
|
||||||
#ifdef HAVE_NEPOMUK
|
#ifdef HAVE_NEPOMUK
|
||||||
ratingWidget(0),
|
m_ratingWidget(0),
|
||||||
taggingWidget(0),
|
m_taggingWidget(0),
|
||||||
commentWidget(0),
|
m_commentWidget(0),
|
||||||
loadFilesThread(0),
|
m_loadFilesThread(0),
|
||||||
#endif
|
#endif
|
||||||
q(parent)
|
q(parent)
|
||||||
{
|
{
|
||||||
gridLayout = new QGridLayout(parent);
|
m_gridLayout = new QGridLayout(parent);
|
||||||
|
|
||||||
typeInfo = new QLabel(parent);
|
m_typeInfo = new QLabel(parent);
|
||||||
sizeLabel = new QLabel(parent);
|
m_sizeLabel = new QLabel(parent);
|
||||||
sizeInfo = new QLabel(parent);
|
m_sizeInfo = new QLabel(parent);
|
||||||
modifiedInfo = new QLabel(parent);
|
m_modifiedInfo = new QLabel(parent);
|
||||||
ownerInfo = new QLabel(parent);
|
m_ownerInfo = new QLabel(parent);
|
||||||
permissionsInfo = new QLabel(parent);
|
m_permissionsInfo = new QLabel(parent);
|
||||||
#ifdef HAVE_NEPOMUK
|
#ifdef HAVE_NEPOMUK
|
||||||
ratingWidget = new KRatingWidget(parent);
|
m_ratingWidget = new KRatingWidget(parent);
|
||||||
taggingWidget = new TaggingWidget(parent);
|
m_taggingWidget = new TaggingWidget(parent);
|
||||||
commentWidget = new CommentWidget(parent);
|
m_commentWidget = new CommentWidget(parent);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
addRow(new QLabel(i18nc("@label", "Type:"), parent), typeInfo);
|
addRow(new QLabel(i18nc("@label", "Type:"), parent), m_typeInfo);
|
||||||
addRow(sizeLabel, sizeInfo);
|
addRow(m_sizeLabel, m_sizeInfo);
|
||||||
addRow(new QLabel(i18nc("@label", "Modified:"), parent), modifiedInfo);
|
addRow(new QLabel(i18nc("@label", "Modified:"), parent), m_modifiedInfo);
|
||||||
addRow(new QLabel(i18nc("@label", "Owner:"), parent), ownerInfo);
|
addRow(new QLabel(i18nc("@label", "Owner:"), parent), m_ownerInfo);
|
||||||
addRow(new QLabel(i18nc("@label", "Permissions:"), parent), permissionsInfo);
|
addRow(new QLabel(i18nc("@label", "Permissions:"), parent), m_permissionsInfo);
|
||||||
#ifdef HAVE_NEPOMUK
|
#ifdef HAVE_NEPOMUK
|
||||||
addRow(new QLabel(i18nc("@label", "Rating:"), parent), ratingWidget);
|
addRow(new QLabel(i18nc("@label", "Rating:"), parent), m_ratingWidget);
|
||||||
addRow(new QLabel(i18nc("@label", "Tags:"), parent), taggingWidget);
|
addRow(new QLabel(i18nc("@label", "Tags:"), parent), m_taggingWidget);
|
||||||
addRow(new QLabel(i18nc("@label", "Comment:"), parent), commentWidget);
|
addRow(new QLabel(i18nc("@label", "Comment:"), parent), m_commentWidget);
|
||||||
|
|
||||||
sharedData.rating = 0;
|
m_sharedData.rating = 0;
|
||||||
loadFilesThread = new LoadFilesThread(&sharedData, &mutex);
|
m_loadFilesThread = new LoadFilesThread(&m_sharedData, &m_mutex);
|
||||||
connect(loadFilesThread, SIGNAL(finished()), q, SLOT(slotLoadingFinished()));
|
connect(m_loadFilesThread, SIGNAL(finished()), q, SLOT(slotLoadingFinished()));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaDataWidget::Private::~Private()
|
MetaDataWidget::Private::~Private()
|
||||||
{
|
{
|
||||||
#ifdef HAVE_NEPOMUK
|
#ifdef HAVE_NEPOMUK
|
||||||
delete loadFilesThread;
|
delete m_loadFilesThread;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +196,7 @@ void MetaDataWidget::Private::addRow(QLabel* label, QWidget* infoWidget)
|
||||||
Row row;
|
Row row;
|
||||||
row.label = label;
|
row.label = label;
|
||||||
row.infoWidget = infoWidget;
|
row.infoWidget = infoWidget;
|
||||||
rows.append(row);
|
m_rows.append(row);
|
||||||
|
|
||||||
// use a brighter color for the label
|
// use a brighter color for the label
|
||||||
QPalette palette = label->palette();
|
QPalette palette = label->palette();
|
||||||
|
@ -181,14 +206,14 @@ void MetaDataWidget::Private::addRow(QLabel* label, QWidget* infoWidget)
|
||||||
label->setPalette(palette);
|
label->setPalette(palette);
|
||||||
|
|
||||||
// add the row to grid layout
|
// add the row to grid layout
|
||||||
const int rowIndex = rows.count();
|
const int rowIndex = m_rows.count();
|
||||||
gridLayout->addWidget(label, rowIndex, 0, Qt::AlignLeft);
|
m_gridLayout->addWidget(label, rowIndex, 0, Qt::AlignLeft);
|
||||||
gridLayout->addWidget(infoWidget, rowIndex, 1, Qt::AlignRight);
|
m_gridLayout->addWidget(infoWidget, rowIndex, 1, Qt::AlignRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetaDataWidget::Private::setRowVisible(QWidget* infoWidget, bool visible)
|
void MetaDataWidget::Private::setRowVisible(QWidget* infoWidget, bool visible)
|
||||||
{
|
{
|
||||||
foreach (const Row& row, rows) {
|
foreach (const Row& row, m_rows) {
|
||||||
if (row.infoWidget == infoWidget) {
|
if (row.infoWidget == infoWidget) {
|
||||||
row.label->setVisible(visible);
|
row.label->setVisible(visible);
|
||||||
row.infoWidget->setVisible(visible);
|
row.infoWidget->setVisible(visible);
|
||||||
|
@ -200,19 +225,51 @@ void MetaDataWidget::Private::setRowVisible(QWidget* infoWidget, bool visible)
|
||||||
void MetaDataWidget::Private::slotLoadingFinished()
|
void MetaDataWidget::Private::slotLoadingFinished()
|
||||||
{
|
{
|
||||||
#ifdef HAVE_NEPOMUK
|
#ifdef HAVE_NEPOMUK
|
||||||
QMutexLocker locker(&mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
ratingWidget->setRating(sharedData.rating);
|
m_ratingWidget->setRating(m_sharedData.rating);
|
||||||
commentWidget->setText(sharedData.comment);
|
m_commentWidget->setText(m_sharedData.comment);
|
||||||
taggingWidget->setTags(sharedData.tags);
|
m_taggingWidget->setTags(m_sharedData.tags);
|
||||||
|
|
||||||
|
// Show the remaining meta information as text. The number
|
||||||
|
// of required rows may very. Existing rows are reused to
|
||||||
|
// prevent flickering.
|
||||||
|
int index = 8; // TODO: don't hardcode this value here
|
||||||
|
const int rowCount = m_rows.count();
|
||||||
|
Q_ASSERT(rowCount >= index);
|
||||||
|
|
||||||
|
Q_ASSERT(m_sharedData.metaInfoLabels.count() == m_sharedData.metaInfoValues.count());
|
||||||
|
const int metaInfoCount = m_sharedData.metaInfoLabels.count();
|
||||||
|
for (int i = 0; i < metaInfoCount; ++i) {
|
||||||
|
if (index < rowCount) {
|
||||||
|
// adjust texts of the current row
|
||||||
|
m_rows[index].label->setText(m_sharedData.metaInfoLabels[i]);
|
||||||
|
QLabel* infoValueLabel = qobject_cast<QLabel*>(m_rows[index].infoWidget);
|
||||||
|
Q_ASSERT(infoValueLabel != 0);
|
||||||
|
infoValueLabel->setText(m_sharedData.metaInfoValues[i]);
|
||||||
|
} else {
|
||||||
|
// create new row
|
||||||
|
QLabel* infoLabel = new QLabel(m_sharedData.metaInfoLabels[i], q);
|
||||||
|
QLabel* infoValue = new QLabel(m_sharedData.metaInfoValues[i], q);
|
||||||
|
addRow(infoLabel, infoValue);
|
||||||
|
}
|
||||||
|
++index;
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove rows that are not needed anymore
|
||||||
|
for (int i = rowCount - 1; i > index; --i) {
|
||||||
|
delete m_rows[i].label;
|
||||||
|
delete m_rows[i].infoWidget;
|
||||||
|
m_rows.pop_back();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_NEPOMUK
|
#ifdef HAVE_NEPOMUK
|
||||||
MetaDataWidget::Private::LoadFilesThread::LoadFilesThread(
|
MetaDataWidget::Private::LoadFilesThread::LoadFilesThread(
|
||||||
MetaDataWidget::Private::SharedData* sharedData,
|
MetaDataWidget::Private::SharedData* m_sharedData,
|
||||||
QMutex* mutex) :
|
QMutex* m_mutex) :
|
||||||
m_sharedData(sharedData),
|
m_m_sharedData(m_sharedData),
|
||||||
m_mutex(mutex),
|
m_m_mutex(m_mutex),
|
||||||
m_urls(),
|
m_urls(),
|
||||||
m_canceled(false)
|
m_canceled(false)
|
||||||
{
|
{
|
||||||
|
@ -228,7 +285,7 @@ MetaDataWidget::Private::LoadFilesThread::~LoadFilesThread()
|
||||||
|
|
||||||
void MetaDataWidget::Private::LoadFilesThread::loadFiles(const KUrl::List& urls)
|
void MetaDataWidget::Private::LoadFilesThread::loadFiles(const KUrl::List& urls)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(m_mutex);
|
QMutexLocker locker(m_m_mutex);
|
||||||
m_urls = urls;
|
m_urls = urls;
|
||||||
m_canceled = false;
|
m_canceled = false;
|
||||||
start();
|
start();
|
||||||
|
@ -236,14 +293,20 @@ void MetaDataWidget::Private::LoadFilesThread::loadFiles(const KUrl::List& urls)
|
||||||
|
|
||||||
void MetaDataWidget::Private::LoadFilesThread::run()
|
void MetaDataWidget::Private::LoadFilesThread::run()
|
||||||
{
|
{
|
||||||
QMutexLocker locker(m_mutex);
|
QMutexLocker locker(m_m_mutex);
|
||||||
const KUrl::List urls = m_urls;
|
const KUrl::List urls = m_urls;
|
||||||
locker.unlock();
|
locker.unlock();
|
||||||
|
|
||||||
|
KConfig config("kmetainformationrc", KConfig::NoGlobals);
|
||||||
|
KConfigGroup settings = config.group("Show");
|
||||||
|
initMetaInfoSettings(settings);
|
||||||
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
unsigned int rating = 0;
|
unsigned int rating = 0;
|
||||||
QString comment;
|
QString comment;
|
||||||
QList<Nepomuk::Tag> tags;
|
QList<Nepomuk::Tag> tags;
|
||||||
|
QList<QString> metaInfoLabels;
|
||||||
|
QList<QString> metaInfoValues;
|
||||||
foreach (const KUrl& url, urls) {
|
foreach (const KUrl& url, urls) {
|
||||||
if (m_canceled) {
|
if (m_canceled) {
|
||||||
return;
|
return;
|
||||||
|
@ -269,14 +332,80 @@ void MetaDataWidget::Private::LoadFilesThread::run()
|
||||||
tags = file.tags();
|
tags = file.tags();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (first && (urls.count() == 1)) {
|
||||||
|
// TODO: show shared meta informations instead
|
||||||
|
// of not showing anything on multiple selections
|
||||||
|
QHash<QUrl, Nepomuk::Variant> properties = file.properties();
|
||||||
|
QHash<QUrl, Nepomuk::Variant>::const_iterator it = properties.constBegin();
|
||||||
|
while (it != properties.constEnd()) {
|
||||||
|
Nepomuk::Types::Property prop(it.key());
|
||||||
|
if (true /*settings.readEntry(prop.name(), true)*/) {
|
||||||
|
// TODO #1: use Nepomuk::formatValue(res, prop) if available
|
||||||
|
// instead of it.value().toString()
|
||||||
|
// TODO #2: using tunedLabel() is a workaround for KDE 4.3 until
|
||||||
|
// we get translated labels
|
||||||
|
metaInfoLabels.append(tunedLabel(prop.label()));
|
||||||
|
metaInfoValues.append(it.value().toString());
|
||||||
|
}
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
locker.relock();
|
locker.relock();
|
||||||
m_sharedData->rating = rating;
|
m_m_sharedData->rating = rating;
|
||||||
m_sharedData->comment = comment;
|
m_m_sharedData->comment = comment;
|
||||||
m_sharedData->tags = tags;
|
m_m_sharedData->tags = tags;
|
||||||
|
m_m_sharedData->metaInfoLabels = metaInfoLabels;
|
||||||
|
m_m_sharedData->metaInfoValues = metaInfoValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MetaDataWidget::Private::LoadFilesThread::initMetaInfoSettings(KConfigGroup& group)
|
||||||
|
{
|
||||||
|
if (!group.readEntry("initialized", false)) {
|
||||||
|
// The resource file is read the first time. Assure
|
||||||
|
// that some meta information is disabled per default.
|
||||||
|
|
||||||
|
static const char* disabledProperties[] = {
|
||||||
|
"asText", "contentSize", "depth", "fileExtension",
|
||||||
|
"fileName", "fileSize", "isPartOf", "mimetype", "name",
|
||||||
|
"parentUrl", "plainTextContent", "sourceModified",
|
||||||
|
"size", "url",
|
||||||
|
0 // mandatory last entry
|
||||||
|
};
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
while (disabledProperties[i] != 0) {
|
||||||
|
group.writeEntry(disabledProperties[i], false);
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
// mark the group as initialized
|
||||||
|
group.writeEntry("initialized", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString MetaDataWidget::Private::LoadFilesThread::tunedLabel(const QString& label) const
|
||||||
|
{
|
||||||
|
QString tunedLabel;
|
||||||
|
const int labelLength = label.length();
|
||||||
|
if (labelLength > 0) {
|
||||||
|
tunedLabel.reserve(labelLength);
|
||||||
|
tunedLabel = label[0].toUpper();
|
||||||
|
for (int i = 1; i < labelLength; ++i) {
|
||||||
|
if (label[i].isUpper() && !label[i - 1].isSpace() && !label[i - 1].isUpper()) {
|
||||||
|
tunedLabel += ' ';
|
||||||
|
tunedLabel += label[i].toLower();
|
||||||
|
} else {
|
||||||
|
tunedLabel += label[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tunedLabel + ':';
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MetaDataWidget::MetaDataWidget(QWidget* parent) :
|
MetaDataWidget::MetaDataWidget(QWidget* parent) :
|
||||||
|
@ -294,18 +423,18 @@ void MetaDataWidget::setItem(const KFileItem& item)
|
||||||
{
|
{
|
||||||
// update values for "type", "size", "modified",
|
// update values for "type", "size", "modified",
|
||||||
// "owner" and "permissions" synchronously
|
// "owner" and "permissions" synchronously
|
||||||
d->sizeLabel->setText(i18nc("@label", "Size:"));
|
d->m_sizeLabel->setText(i18nc("@label", "Size:"));
|
||||||
if (item.isDir()) {
|
if (item.isDir()) {
|
||||||
d->typeInfo->setText(i18nc("@label", "Folder"));
|
d->m_typeInfo->setText(i18nc("@label", "Folder"));
|
||||||
d->setRowVisible(d->sizeInfo, false);
|
d->setRowVisible(d->m_sizeInfo, false);
|
||||||
} else {
|
} else {
|
||||||
d->typeInfo->setText(item.mimeComment());
|
d->m_typeInfo->setText(item.mimeComment());
|
||||||
d->sizeInfo->setText(KIO::convertSize(item.size()));
|
d->m_sizeInfo->setText(KIO::convertSize(item.size()));
|
||||||
d->setRowVisible(d->sizeInfo, true);
|
d->setRowVisible(d->m_sizeInfo, true);
|
||||||
}
|
}
|
||||||
d->modifiedInfo->setText(item.timeString());
|
d->m_modifiedInfo->setText(item.timeString());
|
||||||
d->ownerInfo->setText(item.user());
|
d->m_ownerInfo->setText(item.user());
|
||||||
d->permissionsInfo->setText(item.permissionsString());
|
d->m_permissionsInfo->setText(item.permissionsString());
|
||||||
|
|
||||||
setItems(KFileItemList() << item);
|
setItems(KFileItemList() << item);
|
||||||
}
|
}
|
||||||
|
@ -315,8 +444,8 @@ void MetaDataWidget::setItems(const KFileItemList& items)
|
||||||
if (items.count() > 1) {
|
if (items.count() > 1) {
|
||||||
// calculate the size of all items and show this
|
// calculate the size of all items and show this
|
||||||
// information to the user
|
// information to the user
|
||||||
d->sizeLabel->setText(i18nc("@label", "Total Size:"));
|
d->m_sizeLabel->setText(i18nc("@label", "Total Size:"));
|
||||||
d->setRowVisible(d->sizeInfo, true);
|
d->setRowVisible(d->m_sizeInfo, true);
|
||||||
|
|
||||||
quint64 totalSize = 0;
|
quint64 totalSize = 0;
|
||||||
foreach (const KFileItem& item, items) {
|
foreach (const KFileItem& item, items) {
|
||||||
|
@ -324,7 +453,7 @@ void MetaDataWidget::setItems(const KFileItemList& items)
|
||||||
totalSize += item.size();
|
totalSize += item.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
d->sizeInfo->setText(KIO::convertSize(totalSize));
|
d->m_sizeInfo->setText(KIO::convertSize(totalSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_NEPOMUK
|
#ifdef HAVE_NEPOMUK
|
||||||
|
@ -335,7 +464,7 @@ void MetaDataWidget::setItems(const KFileItemList& items)
|
||||||
urls.append(url);
|
urls.append(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
d->loadFilesThread->loadFiles(urls);
|
d->m_loadFilesThread->loadFiles(urls);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue