diff --git a/src/contentlist/ContentListerBase.cpp b/src/contentlist/ContentListerBase.cpp index 146d208..b137937 100644 --- a/src/contentlist/ContentListerBase.cpp +++ b/src/contentlist/ContentListerBase.cpp @@ -1,42 +1,69 @@ /* * Copyright (C) 2015 Dan Leinir Turthra Jensen * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . * */ #include "ContentListerBase.h" +#include +#include +#include + +#include + ContentListerBase::ContentListerBase(QObject* parent) : QObject(parent) { } ContentListerBase::~ContentListerBase() { } void ContentListerBase::startSearch(const QList& queries) { Q_UNUSED(queries); } +QVariantMap ContentListerBase::metaDataForFile(const QString& file) { + QVariantMap metadata; + + //TODO: This should include the same information for both the Baloo and + //File searchers. Unfortunately, currently KFileMetaData does not seem able + //to provide this. So this needs changes at a lower level. + + QFileInfo info(file); + metadata["lastModified"] = info.lastModified(); + metadata["created"] = info.created(); + metadata["lastRead"] = info.lastRead(); + KFileMetaData::UserMetaData data(file); + if (data.hasAttribute("peruse.currentPage")) { + int currentPage = data.attribute("peruse.currentPage").toInt(); + metadata["currentPage"] = QVariant::fromValue(currentPage); + } + if (data.hasAttribute("peruse.totalPages")) { + int totalPages = data.attribute("peruse.totalPages").toInt(); + metadata["totalPages"] = QVariant::fromValue(totalPages); + } + return metadata; } diff --git a/src/contentlist/ContentListerBase.h b/src/contentlist/ContentListerBase.h index 45265a3..e795f7f 100644 --- a/src/contentlist/ContentListerBase.h +++ b/src/contentlist/ContentListerBase.h @@ -1,42 +1,44 @@ /* * Copyright (C) 2015 Dan Leinir Turthra Jensen * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . * */ #ifndef CONTENTLISTERBASE_H #define CONTENTLISTERBASE_H #include class ContentQuery; class ContentListerBase : public QObject { Q_OBJECT public: explicit ContentListerBase(QObject* parent = nullptr); ~ContentListerBase() override; Q_SLOT virtual void startSearch(const QList& queries); Q_SIGNAL void fileFound(const QString& filePath, const QVariantMap& metadata); Q_SIGNAL void searchCompleted(); + + static QVariantMap metaDataForFile(const QString& file); }; #endif//CONTENTLISTERBASE_H