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