2020-09-23 18:33:30 +08:00
|
|
|
#include "verticalpreviewwidget.h"
|
|
|
|
#include "ui_verticalpreviewwidget.h"
|
|
|
|
|
|
|
|
#include <QFileSystemModel>
|
|
|
|
#include <QDateTime>
|
|
|
|
#include <QFileInfo>
|
|
|
|
#include <QDebug>
|
2020-09-24 17:47:56 +08:00
|
|
|
#include <QMimeDatabase>
|
2020-09-23 18:33:30 +08:00
|
|
|
|
|
|
|
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);
|
2020-09-24 17:47:56 +08:00
|
|
|
static QMimeDatabase mimetypeDatabase;
|
|
|
|
QMimeType mimeType = mimetypeDatabase.mimeTypeForFile(info);
|
|
|
|
QString mimeTypeDisplayName = mimeType.comment();
|
2020-09-23 18:33:30 +08:00
|
|
|
|
2020-09-24 17:47:56 +08:00
|
|
|
ui->typeAndSizeLabel->setText(QString("%1 - %2").arg(mimeTypeDisplayName, this->locale().formattedDataSize(info.size())));
|
|
|
|
|
2020-10-07 16:22:55 +08:00
|
|
|
ui->createdAtLabel->setText(QLocale().toString(info.birthTime(), QLocale::LongFormat));
|
|
|
|
ui->lastUpdateLabel->setText(QLocale().toString(info.lastModified(), QLocale::LongFormat));
|
|
|
|
ui->lastAccessLabel->setText(QLocale().toString(info.lastRead(), QLocale::LongFormat));
|
2020-09-23 18:33:30 +08:00
|
|
|
|
|
|
|
// ui->formLayout->addRow("Created at:", new QLabel(info.birthTime().toString()));
|
|
|
|
}
|