void InfoSidebarPage::showAnnotation(const KUrl& file)
{
if(m_metadata->storageUp()) {
- QString text = m_metadata->getAnnotation(file);
+ QString text = m_metadata->annotation(file);
if (!text.isEmpty()) {
m_annotationLabel->show();
m_annotationLabel->setText(QString("<b>%1</b> :<br/>%2").arg(i18n("Annotation")).arg(text));
void InfoSidebarPage::showAnnotations(const KUrl::List& files)
{
- static unsigned int maxShownAnnot = 3; //The maximum number of show annotations when selecting multiple files
if (m_metadata->storageUp()) {
bool hasAnnotation = false;
unsigned int annotateNum = 0;
QString firsts = QString("<b>%1 :</b><br/>").arg(i18n("Annotations"));
foreach (KUrl file, files) {
- QString annotation = m_metadata->getAnnotation(file);
+ QString annotation = m_metadata->annotation(file);
if (!annotation.isEmpty()) {
hasAnnotation = true;
- if(annotateNum < maxShownAnnot) {
+ if (annotateNum < 3) {
+ // don't show more than 3 annotations
firsts += m_annotationLabel->fontMetrics().elidedText(QString("<b>%1</b> : %2<br/>").arg(file.fileName()).arg(annotation), Qt::ElideRight, width());//FIXME not really the good method, does not handle resizing ...
annotateNum++;
}
if (hasAnnotation) {
m_annotationLabel->show();
m_annotationLabel->setText(firsts);
- } else m_annotationLabel->hide();
+ }
+ else {
+ m_annotationLabel->hide();
+ }
m_annotationButton->setText(hasAnnotation ? i18n("Change annotations") : i18n("Annotate files"));
}
}
}
else if (files.count() == 1) {
name = files[0].url();
- old = m_metadata->getAnnotation(files[0]);
+ old = m_metadata->annotation(files[0]);
}
else {
name = QString("%1 files").arg(files.count());
if (Nepomuk::KMetaData::ResourceManager::instance()->init()) {
m_up = false;
Nepomuk::KMetaData::ResourceManager::instance()->setAutoSync(false);
- } else {
+ }
+ else {
m_up = true;
}
#else
return m_up;
}
-QString MetadataLoader::getAnnotation(const KUrl& file)
+QString MetadataLoader::annotation(const KUrl& file)
{
#ifdef HAVE_KMETADATA
if(m_up)
void MetadataLoader::setAnnotation(const KUrl& file, const QString& annotation)
{
#ifdef HAVE_KMETADATA
- if(m_up)
+ if (m_up) {
Nepomuk::KMetaData::File(file.url()).setComment(annotation);
+ }
#endif
}
#ifndef METADATALOADER_H
#define METADATALOADER_H
-namespace Nempomuk {
-namespace Backbone {
- class Registry;
-}
-}
class KUrl;
class QString;
{
friend class DolphinApplication;
public:
- ~MetadataLoader();
- bool storageUp();
+ ~MetadataLoader();
+ bool storageUp();
- QString getAnnotation(const KUrl& file);
- void setAnnotation(const KUrl& file, const QString& annotation);
+ QString annotation(const KUrl& file);
+ void setAnnotation(const KUrl& file, const QString& annotation);
private:
- MetadataLoader();
- bool m_up;
+ MetadataLoader();
+ bool m_up;
};