feat: able to get icon from DGioFileInfo

This commit is contained in:
Gary Wang 2019-08-06 13:08:43 +08:00
parent 8ddb30527b
commit 72fe073e31
4 changed files with 13 additions and 0 deletions

View file

@ -54,6 +54,7 @@ public:
QString basename() const; QString basename() const;
QString path() const; QString path() const;
QString uri() const; QString uri() const;
QExplicitlySharedDataPointer<DGioFileInfo> createFileInfo(QString attr = "*", DGioFileQueryInfoFlags queryInfoFlags = FILE_QUERY_INFO_NONE); QExplicitlySharedDataPointer<DGioFileInfo> createFileInfo(QString attr = "*", DGioFileQueryInfoFlags queryInfoFlags = FILE_QUERY_INFO_NONE);
QExplicitlySharedDataPointer<DGioFileInfo> createFileSystemInfo(QString attr = "*"); QExplicitlySharedDataPointer<DGioFileInfo> createFileSystemInfo(QString attr = "*");
QExplicitlySharedDataPointer<DGioFileIterator> createFileIterator(QString attr = "*", DGioFileQueryInfoFlags queryInfoFlags = FILE_QUERY_INFO_NONE); QExplicitlySharedDataPointer<DGioFileIterator> createFileIterator(QString attr = "*", DGioFileQueryInfoFlags queryInfoFlags = FILE_QUERY_INFO_NONE);

View file

@ -51,6 +51,7 @@ public:
QString displayName() const; QString displayName() const;
DGioFileType fileType() const; DGioFileType fileType() const;
quint64 fileSize() const; quint64 fileSize() const;
QStringList themedIconNames() const;
// filesystem info. // filesystem info.
bool fsReadOnly() const; bool fsReadOnly() const;

View file

@ -19,6 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "dgiofileinfo.h" #include "dgiofileinfo.h"
#include "dgiohelper.h"
#include <giomm/fileinfo.h> #include <giomm/fileinfo.h>
@ -127,6 +128,15 @@ quint64 DGioFileInfo::fileSize() const
return static_cast<quint64>(d->getGmmFileInfoInstance()->get_size()); return static_cast<quint64>(d->getGmmFileInfoInstance()->get_size());
} }
QStringList DGioFileInfo::themedIconNames() const
{
Q_D(const DGioFileInfo);
Glib::RefPtr<const Icon> icon = d->getGmmFileInfoInstance()->get_icon();
return DGioPrivate::getThemedIconNames(icon);
}
bool DGioFileInfo::fsReadOnly() const bool DGioFileInfo::fsReadOnly() const
{ {
Q_D(const DGioFileInfo); Q_D(const DGioFileInfo);

View file

@ -31,6 +31,7 @@ void DGioSimpleFileInfoTest::testCase_RegularFile()
QCOMPARE(file->basename(), tmpFileInfo.fileName()); QCOMPARE(file->basename(), tmpFileInfo.fileName());
QCOMPARE(file->path(), tmpFileInfo.absoluteFilePath()); QCOMPARE(file->path(), tmpFileInfo.absoluteFilePath());
QCOMPARE(fi->fileSize(), tmpFileInfo.size()); QCOMPARE(fi->fileSize(), tmpFileInfo.size());
QVERIFY(fi->themedIconNames().contains("text-plain")); // is this check okay? better approach?
} }
QTEST_APPLESS_MAIN(DGioSimpleFileInfoTest) QTEST_APPLESS_MAIN(DGioSimpleFileInfoTest)