45 lines
1.5 KiB
C++
45 lines
1.5 KiB
C++
#include "verticalpreviewwidget.h"
|
|
#include "ui_verticalpreviewwidget.h"
|
|
|
|
#include <QFileSystemModel>
|
|
#include <QDateTime>
|
|
#include <QFileInfo>
|
|
#include <QDebug>
|
|
#include <QMimeDatabase>
|
|
|
|
VerticalPreviewWidget::VerticalPreviewWidget(QWidget *parent) :
|
|
QWidget(parent),
|
|
ui(new Ui::VerticalPreviewWidget)
|
|
{
|
|
ui->setupUi(this);
|
|
}
|
|
|
|
VerticalPreviewWidget::~VerticalPreviewWidget()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void VerticalPreviewWidget::setModel(QFileSystemModel *fsmodel)
|
|
{
|
|
this->m_fsmodel = fsmodel;
|
|
}
|
|
|
|
void VerticalPreviewWidget::updatePreviewContent(const QModelIndex &index)
|
|
{
|
|
ui->fileIconLabel->setPixmap(m_fsmodel->fileIcon(index).pixmap(64));
|
|
ui->filenameLabel->setText(m_fsmodel->fileName(index));
|
|
|
|
const QFileInfo & info = m_fsmodel->fileInfo(index);
|
|
static QMimeDatabase mimetypeDatabase;
|
|
QMimeType mimeType = mimetypeDatabase.mimeTypeForFile(info);
|
|
QString mimeTypeDisplayName = mimeType.comment();
|
|
|
|
ui->typeAndSizeLabel->setText(QString("%1 - %2").arg(mimeTypeDisplayName, this->locale().formattedDataSize(info.size())));
|
|
|
|
ui->createdAtLabel->setText(info.birthTime().toString(tr("yyyy/MM/dd hh:mm:ss", "Qt string format")));
|
|
ui->lastUpdateLabel->setText(info.lastModified().toString(tr("yyyy/MM/dd hh:mm:ss", "Qt string format")));
|
|
ui->lastAccessLabel->setText(info.lastRead().toString(tr("yyyy/MM/dd hh:mm:ss", "Qt string format")));
|
|
|
|
// ui->formLayout->addRow("Created at:", new QLabel(info.birthTime().toString()));
|
|
}
|