Simple User operation log table, v1.1
This commit is contained in:
@@ -4,15 +4,25 @@
|
|||||||
|
|
||||||
#include "UserOperationLogForm.h"
|
#include "UserOperationLogForm.h"
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QHBoxLayout>
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include "log/UserOperationLog.h"
|
#include "log/UserOperationLog.h"
|
||||||
#include "log/LogFileTableModel.h"
|
#include "log/LogFileTableModel.h"
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QTableView>
|
||||||
|
#include "components/SlideableTableView.h"
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
UserOperationLogForm::UserOperationLogForm(QWidget *parent) {
|
UserOperationLogForm::UserOperationLogForm(QWidget *parent) {
|
||||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||||
QWidget* header = new QWidget(this);
|
QWidget* header = new QWidget(this);
|
||||||
table = new QTableView(this);
|
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);
|
||||||
layout->addWidget(header);
|
layout->addWidget(header);
|
||||||
layout->addWidget(table);
|
layout->addWidget(table);
|
||||||
//暂时先放构造函数,之后需要移除,等需要时再调用
|
//暂时先放构造函数,之后需要移除,等需要时再调用
|
||||||
@@ -23,19 +33,24 @@ UserOperationLogForm::~UserOperationLogForm() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString fileNameToDate(QString fileName)
|
||||||
|
{
|
||||||
|
return fileName.replace("./log/","").replace("-op.log","");
|
||||||
|
}
|
||||||
|
|
||||||
void UserOperationLogForm::loadUserOperationLog() {
|
void UserOperationLogForm::loadUserOperationLog() {
|
||||||
LogFileTableModel* model = new LogFileTableModel(this);
|
LogFileTableModel* model = new LogFileTableModel(this);
|
||||||
QString filePath = UserOperationLog::Default()->currentLogFile();
|
QString filePath = UserOperationLog::Default()->currentLogFile();
|
||||||
model->setFileName(filePath);
|
model->setFileName(filePath);
|
||||||
|
btn->setText(fileNameToDate(filePath));
|
||||||
QStringList header;
|
QStringList header;
|
||||||
header<<"Operation Date"<<"Operation Time"<<"User"<<"Operation";
|
header<<"Operation Date"<<"Operation Time"<<"User"<<"Operation";
|
||||||
model->setHeader(header);
|
model->setHeader(header);
|
||||||
// UserOperationLog::getHistoryLogFiles();
|
// UserOperationLog::getHistoryLogFiles();
|
||||||
table->setModel(model);
|
table->setModel(model);
|
||||||
table->setAlternatingRowColors(true);
|
table->setAlternatingRowColors(true);
|
||||||
table->setSelectionMode(QAbstractItemView::SingleSelection);
|
table->setSelectionMode(QAbstractItemView::NoSelection);
|
||||||
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||||
table->setSelectionBehavior(QAbstractItemView::SelectRows);
|
|
||||||
table->verticalHeader()->setDefaultSectionSize(38);
|
table->verticalHeader()->setDefaultSectionSize(38);
|
||||||
table->horizontalHeader()->setStretchLastSection(true);
|
table->horizontalHeader()->setStretchLastSection(true);
|
||||||
table->setColumnWidth(0,250);
|
table->setColumnWidth(0,250);
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
#define GUI_USEROPERATIONLOGFORM_H
|
#define GUI_USEROPERATIONLOGFORM_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QtWidgets/QTableView>
|
class QTableView;
|
||||||
|
class QPushButton;
|
||||||
class UserOperationLogForm:public QWidget {
|
class UserOperationLogForm:public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@@ -17,6 +17,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QTableView * table = nullptr;
|
QTableView * table = nullptr;
|
||||||
|
QPushButton* btn = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user