pineapple-files/verticalpreviewwidget.cpp

38 lines
1005 B
C++
Raw Normal View History

2020-09-23 18:33:30 +08:00
#include "verticalpreviewwidget.h"
#include "ui_verticalpreviewwidget.h"
#include <QFileSystemModel>
#include <QDateTime>
#include <QFileInfo>
#include <QDebug>
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);
ui->createdAtLabel->setText(info.birthTime().toString());
ui->lastUpdateLabel->setText(info.lastModified().toString());
// ui->formLayout->addRow("Created at:", new QLabel(info.birthTime().toString()));
}