Change LogDateSelectDialog to selectDialog
This commit is contained in:
@@ -2,11 +2,11 @@
|
|||||||
// Created by Krad on 2021/11/24.
|
// Created by Krad on 2021/11/24.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "LogDateSelectDialog.h"
|
#include "SelectDialog.h"
|
||||||
#include "components/SlidePickerBox.h"
|
#include "components/SlidePickerBox.h"
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
LogDateSelectDialog::LogDateSelectDialog(QWidget *parent, Qt::WindowFlags f) : GUIFormBaseDialog(parent, f) {
|
SelectDialog::SelectDialog(QWidget *parent, Qt::WindowFlags f) : GUIFormBaseDialog(parent, f) {
|
||||||
this->setFixedSize(360,380);
|
this->setFixedSize(360,380);
|
||||||
QVBoxLayout* layout = new QVBoxLayout(formWidget);
|
QVBoxLayout* layout = new QVBoxLayout(formWidget);
|
||||||
box = new SlidePickerBox(formWidget);
|
box = new SlidePickerBox(formWidget);
|
||||||
@@ -14,22 +14,22 @@ LogDateSelectDialog::LogDateSelectDialog(QWidget *parent, Qt::WindowFlags f) : G
|
|||||||
layout->addWidget(box);
|
layout->addWidget(box);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogDateSelectDialog::~LogDateSelectDialog() {
|
SelectDialog::~SelectDialog() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LogDateSelectDialog::updateReferenceData() {
|
bool SelectDialog::updateReferenceData() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogDateSelectDialog::setAvailableDates(QStringList dates) {
|
void SelectDialog::setAvailableDates(QStringList dates) {
|
||||||
box->setItems(dates);
|
box->setItems(dates);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString LogDateSelectDialog::getSelectedValue() {
|
QString SelectDialog::getSelectedValue() {
|
||||||
return box->getSelectedValue();
|
return box->getSelectedValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogDateSelectDialog::setSelectedValue(QString & val) {
|
void SelectDialog::setSelectedValue(QString & val) {
|
||||||
box->setSelectedValue(val);
|
box->setSelectedValue(val);
|
||||||
}
|
}
|
||||||
@@ -2,16 +2,16 @@
|
|||||||
// Created by Krad on 2021/11/24.
|
// Created by Krad on 2021/11/24.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef GUI_LOGDATESELECTDIALOG_H
|
#ifndef GUI_SelectDialog_H
|
||||||
#define GUI_LOGDATESELECTDIALOG_H
|
#define GUI_SelectDialog_H
|
||||||
|
|
||||||
#include "GUIFormBaseDialog.h"
|
#include "GUIFormBaseDialog.h"
|
||||||
class SlidePickerBox;
|
class SlidePickerBox;
|
||||||
class LogDateSelectDialog :public GUIFormBaseDialog{
|
class SelectDialog :public GUIFormBaseDialog{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit LogDateSelectDialog(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
|
explicit SelectDialog(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
|
||||||
~LogDateSelectDialog() override;
|
~SelectDialog() override;
|
||||||
void setAvailableDates(QStringList dates);
|
void setAvailableDates(QStringList dates);
|
||||||
QString getSelectedValue();
|
QString getSelectedValue();
|
||||||
void setSelectedValue(QString& val);
|
void setSelectedValue(QString& val);
|
||||||
@@ -21,4 +21,4 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif //GUI_LOGDATESELECTDIALOG_H
|
#endif //GUI_SelectDialog_H
|
||||||
@@ -13,41 +13,41 @@
|
|||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
#include "components/SlideableTableView.h"
|
#include "components/SlideableTableView.h"
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include "LogDateSelectDialog.h"
|
#include "SelectDialog.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
QString fileNameToDate(QString fileName)
|
QString fileNameToDate(QString fileName)
|
||||||
{
|
{
|
||||||
return fileName.split("log/")[1].replace("-op.log","");
|
return fileName.split("log/")[1].replace("-op.log", "");
|
||||||
}
|
}
|
||||||
QString dateToFileName(QString date)
|
QString dateToFileName(QString date)
|
||||||
{
|
{
|
||||||
return QString("./log/") + date + QString("-op.log");
|
return QString("./log/") + date + QString("-op.log");
|
||||||
}
|
}
|
||||||
|
|
||||||
UserOperationLogForm::UserOperationLogForm(QWidget *parent) {
|
UserOperationLogForm::UserOperationLogForm(QWidget* parent) {
|
||||||
layout = new QVBoxLayout(this);
|
layout = new QVBoxLayout(this);
|
||||||
QWidget* header = new QWidget(this);
|
QWidget* header = new QWidget(this);
|
||||||
QHBoxLayout* headerLayout = new QHBoxLayout(header);
|
QHBoxLayout* headerLayout = new QHBoxLayout(header);
|
||||||
headerLayout->addWidget(new QLabel(tr("Log Date:")));
|
headerLayout->addWidget(new QLabel(tr("Log Date:")));
|
||||||
btn = new QPushButton(header);
|
btn = new QPushButton(header);
|
||||||
headerLayout->addWidget(btn, 0, Qt::AlignLeft);
|
headerLayout->addWidget(btn, 0, Qt::AlignLeft);
|
||||||
headerLayout->addSpacerItem(new QSpacerItem(20,20,QSizePolicy::Expanding));
|
headerLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding));
|
||||||
table = new SlideableTableView(this);
|
table = new SlideableTableView(this);
|
||||||
layout->addWidget(header);
|
layout->addWidget(header);
|
||||||
layout->addWidget(table);
|
layout->addWidget(table);
|
||||||
model = new LogFileTableModel(this);
|
model = new LogFileTableModel(this);
|
||||||
//暂时先放构造函数,之后需要移除,等需要时再调用
|
//暂时先放构造函数,之后需要移除,等需要时再调用
|
||||||
loadUserOperationLog();
|
loadUserOperationLog();
|
||||||
connect(btn,&QPushButton::clicked,[=](){
|
connect(btn, &QPushButton::clicked, [=]() {
|
||||||
auto files = UserOperationLog::getHistoryLogFiles();
|
auto files = UserOperationLog::getHistoryLogFiles();
|
||||||
QStringList dates;
|
QStringList dates;
|
||||||
for (auto f :files)
|
for (auto f : files)
|
||||||
{
|
{
|
||||||
dates<<fileNameToDate(f);
|
dates << fileNameToDate(f);
|
||||||
}
|
}
|
||||||
if(!dialog){
|
if (!dialog) {
|
||||||
dialog = new LogDateSelectDialog(this);
|
dialog = new SelectDialog(this);
|
||||||
dialog->setWindowModality(Qt::WindowModal);
|
dialog->setWindowModality(Qt::WindowModal);
|
||||||
}
|
}
|
||||||
dialog->setAvailableDates(dates);
|
dialog->setAvailableDates(dates);
|
||||||
@@ -56,7 +56,7 @@ UserOperationLogForm::UserOperationLogForm(QWidget *parent) {
|
|||||||
{
|
{
|
||||||
QString date = dialog->getSelectedValue();
|
QString date = dialog->getSelectedValue();
|
||||||
QString f = dateToFileName(date);
|
QString f = dateToFileName(date);
|
||||||
this->loadUserOperationLog(f,date);
|
this->loadUserOperationLog(f, date);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -81,9 +81,9 @@ void UserOperationLogForm::loadUserOperationLog(const QString& fileName, const Q
|
|||||||
model->setFileName(dateToFileName(date));
|
model->setFileName(dateToFileName(date));
|
||||||
btn->setText(date);
|
btn->setText(date);
|
||||||
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();
|
||||||
delete table;
|
delete table;
|
||||||
table = new SlideableTableView(this);
|
table = new SlideableTableView(this);
|
||||||
layout->addWidget(table);
|
layout->addWidget(table);
|
||||||
@@ -94,6 +94,6 @@ void UserOperationLogForm::loadUserOperationLog(const QString& fileName, const Q
|
|||||||
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||||
table->verticalHeader()->setDefaultSectionSize(38);
|
table->verticalHeader()->setDefaultSectionSize(38);
|
||||||
table->horizontalHeader()->setStretchLastSection(true);
|
table->horizontalHeader()->setStretchLastSection(true);
|
||||||
table->setColumnWidth(0,250);
|
table->setColumnWidth(0, 250);
|
||||||
table->setColumnWidth(1,250);
|
table->setColumnWidth(1, 250);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,20 +10,20 @@ class QTableView;
|
|||||||
class QPushButton;
|
class QPushButton;
|
||||||
class LogFileTableModel;
|
class LogFileTableModel;
|
||||||
class QVBoxLayout;
|
class QVBoxLayout;
|
||||||
class LogDateSelectDialog;
|
class SelectDialog;
|
||||||
class UserOperationLogForm:public QWidget {
|
class UserOperationLogForm :public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit UserOperationLogForm(QWidget *parent = nullptr);
|
explicit UserOperationLogForm(QWidget* parent = nullptr);
|
||||||
~UserOperationLogForm();
|
~UserOperationLogForm();
|
||||||
void loadUserOperationLog();
|
void loadUserOperationLog();
|
||||||
void loadUserOperationLog(const QString& fileName, const QString& date);
|
void loadUserOperationLog(const QString& fileName, const QString& date);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTableView * table = nullptr;
|
QTableView* table = nullptr;
|
||||||
QPushButton* btn = nullptr;
|
QPushButton* btn = nullptr;
|
||||||
LogFileTableModel* model = nullptr;
|
LogFileTableModel* model = nullptr;
|
||||||
LogDateSelectDialog* dialog = nullptr;
|
SelectDialog* dialog = nullptr;
|
||||||
QVBoxLayout* layout = nullptr;
|
QVBoxLayout* layout = nullptr;
|
||||||
QString selectedDateStr;
|
QString selectedDateStr;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user