2021-11-23 13:22:00 +08:00
|
|
|
//
|
|
|
|
|
// Created by Krad on 2021/11/23.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#include "UserOperationLogForm.h"
|
|
|
|
|
#include <QVBoxLayout>
|
2021-11-23 16:53:36 +08:00
|
|
|
#include <QHBoxLayout>
|
2021-11-23 13:22:00 +08:00
|
|
|
#include <QAbstractListModel>
|
|
|
|
|
#include "log/UserOperationLog.h"
|
|
|
|
|
#include "log/LogFileTableModel.h"
|
|
|
|
|
#include <QHeaderView>
|
2021-11-23 16:53:36 +08:00
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QTableView>
|
|
|
|
|
#include "components/SlideableTableView.h"
|
|
|
|
|
#include <QPushButton>
|
2021-11-23 13:22:00 +08:00
|
|
|
|
|
|
|
|
UserOperationLogForm::UserOperationLogForm(QWidget *parent) {
|
|
|
|
|
QVBoxLayout* layout = new QVBoxLayout(this);
|
|
|
|
|
QWidget* header = new QWidget(this);
|
2021-11-23 16:53:36 +08:00
|
|
|
QHBoxLayout* headerLayout = new QHBoxLayout(header);
|
|
|
|
|
headerLayout->addWidget(new QLabel(tr("Log Date:")));
|
|
|
|
|
btn = new QPushButton(header);
|
|
|
|
|
headerLayout->addWidget(btn, 0, Qt::AlignLeft);
|
|
|
|
|
headerLayout->addSpacerItem(new QSpacerItem(20,20,QSizePolicy::Expanding));
|
|
|
|
|
table = new SlideableTableView(this);
|
2021-11-23 13:22:00 +08:00
|
|
|
layout->addWidget(header);
|
|
|
|
|
layout->addWidget(table);
|
|
|
|
|
//暂时先放构造函数,之后需要移除,等需要时再调用
|
|
|
|
|
loadUserOperationLog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UserOperationLogForm::~UserOperationLogForm() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-23 16:53:36 +08:00
|
|
|
QString fileNameToDate(QString fileName)
|
|
|
|
|
{
|
|
|
|
|
return fileName.replace("./log/","").replace("-op.log","");
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-23 13:22:00 +08:00
|
|
|
void UserOperationLogForm::loadUserOperationLog() {
|
|
|
|
|
LogFileTableModel* model = new LogFileTableModel(this);
|
|
|
|
|
QString filePath = UserOperationLog::Default()->currentLogFile();
|
|
|
|
|
model->setFileName(filePath);
|
2021-11-23 16:53:36 +08:00
|
|
|
btn->setText(fileNameToDate(filePath));
|
2021-11-23 13:22:00 +08:00
|
|
|
QStringList header;
|
|
|
|
|
header<<"Operation Date"<<"Operation Time"<<"User"<<"Operation";
|
|
|
|
|
model->setHeader(header);
|
|
|
|
|
// UserOperationLog::getHistoryLogFiles();
|
|
|
|
|
table->setModel(model);
|
|
|
|
|
table->setAlternatingRowColors(true);
|
2021-11-23 16:53:36 +08:00
|
|
|
table->setSelectionMode(QAbstractItemView::NoSelection);
|
2021-11-23 13:22:00 +08:00
|
|
|
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
|
|
|
table->verticalHeader()->setDefaultSectionSize(38);
|
|
|
|
|
table->horizontalHeader()->setStretchLastSection(true);
|
|
|
|
|
table->setColumnWidth(0,250);
|
|
|
|
|
table->setColumnWidth(1,250);
|
|
|
|
|
}
|