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