feat: Add top and bottom button in UserOperationLog page.

This commit is contained in:
sunwen
2024-07-29 10:16:37 +08:00
parent 9f09c59df1
commit 9c96fbbba6
4 changed files with 138 additions and 105 deletions

View File

@@ -13,6 +13,7 @@
#include "src/dialogs/SelectDialog.h"
#include "windows/MainWindow.h"
#include "event/EventCenter.h"
QString fileNameToDate(QString fileName)
{
return fileName.split("log/UserOperationLog/")[1].replace("-op.log", "");
@@ -25,51 +26,59 @@ QString dateToFileName(QString date)
UserOperationLogForm::UserOperationLogForm(QWidget* parent)
: QWidget (parent)
{
layout = new QVBoxLayout(this);
mLayout = new QVBoxLayout(this);
QWidget* header = new QWidget(this);
QHBoxLayout* headerLayout = new QHBoxLayout(header);
QLabel* logdate = new QLabel(tr("Log Date:"));
headerLayout->addWidget(logdate);
btn = new QPushButton(header);
headerLayout->addWidget(btn, 0, Qt::AlignLeft);
mDateButton = new QPushButton(header);
headerLayout->addWidget(mDateButton, 0, Qt::AlignLeft);
mTopButton = new QPushButton(header);
mTopButton->setFixedWidth(150);
mTopButton->setText(tr("Top"));
mBottomButton = new QPushButton(header);
mBottomButton->setFixedWidth(150);
mBottomButton->setText(tr("Bottom"));
headerLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding));
headerLayout->addWidget(mTopButton, 0, Qt::AlignLeft);
headerLayout->addWidget(mBottomButton, 0, Qt::AlignLeft);
model = new LogFileTableModel(this);
model->setHeader(QStringList()<< tr("Operation Date") << tr("Operation Time") << tr("User") << tr("Operation"));
mModel = new LogFileTableModel(this);
mModel->setHeader(QStringList()<< tr("Operation Date") << tr("Operation Time") << tr("User") << tr("Operation"));
loadUserOperationLog();
table = new SlideTableView(this);
layout->addWidget(header);
layout->addWidget(table);
table->setModel(model);
table->setAlternatingRowColors(true);
table->setSelectionMode(QAbstractItemView::NoSelection);
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
table->verticalHeader()->setDefaultSectionSize(38);
table->horizontalHeader()->setStretchLastSection(true);
table->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);
table->setColumnWidth(0, 250);
table->setColumnWidth(1, 250);
table->setColumnWidth(2, 200);
table->verticalScrollBar()->setStyleSheet("QScrollBar:vertical { width: 40px; }");;
mLogTable = new SlideTableView(this);
mLayout->addWidget(header);
mLayout->addWidget(mLogTable);
mLogTable->setModel(mModel);
mLogTable->setAlternatingRowColors(true);
mLogTable->setSelectionMode(QAbstractItemView::NoSelection);
mLogTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
mLogTable->verticalHeader()->setDefaultSectionSize(38);
mLogTable->horizontalHeader()->setStretchLastSection(true);
mLogTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);
mLogTable->setColumnWidth(0, 250);
mLogTable->setColumnWidth(1, 250);
mLogTable->setColumnWidth(2, 200);
mLogTable->verticalScrollBar()->setStyleSheet("QScrollBar:vertical { width: 40px; }");;
//暂时先放构造函数,之后需要移除,等需要时再调用
connect(btn, &QPushButton::clicked, [=]() {
connect(mDateButton, &QPushButton::clicked, [=]() {
auto files = UserOperationLog::getHistoryLogFiles();
QStringList dates;
for (auto f : files)
{
dates << fileNameToDate(f);
}
if (!dialog) {
dialog = new SelectDialog(this);
dialog->setWindowModality(Qt::WindowModal);
if (!mSelectDateDialog) {
mSelectDateDialog = new SelectDialog(this);
mSelectDateDialog->setWindowModality(Qt::WindowModal);
}
dialog->setValues(dates);
if (!selectedDateStr.isEmpty()) dialog->setSelectedValue(selectedDateStr);
if (dialog->exec() == QDialog::Accepted)
mSelectDateDialog->setValues(dates);
if (!mSelectedDateStr.isEmpty()) mSelectDateDialog->setSelectedValue(mSelectedDateStr);
if (mSelectDateDialog->exec() == QDialog::Accepted)
{
QString date = dialog->getSelectedValue();
QString date = mSelectDateDialog->getSelectedValue();
QString f = dateToFileName(date);
this->loadUserOperationLog(f, date);
}
@@ -77,9 +86,12 @@ UserOperationLogForm::UserOperationLogForm(QWidget* parent)
connect(EventCenter::Default(), &EventCenter::ReloadLanguage, [=]() {
logdate->setText(tr("Log Date:"));
model->setHeader(QStringList()<< tr("Operation Date") << tr("Operation Time") << tr("User") << tr("Operation"));
mModel->setHeader(QStringList()<< tr("Operation Date") << tr("Operation Time") << tr("User") << tr("Operation"));
});
connect(mTopButton, &QPushButton::clicked, mLogTable, &SlideTableView::scrollToTop);
connect(mBottomButton, &QPushButton::clicked, mLogTable, &SlideTableView::scrollToBottom);
}
UserOperationLogForm::~UserOperationLogForm() {
@@ -90,19 +102,19 @@ UserOperationLogForm::~UserOperationLogForm() {
void UserOperationLogForm::loadUserOperationLog() {
QString filePath = UserOperationLog::Default()->currentLogFile();
btn->setText(fileNameToDate(filePath));
mDateButton->setText(fileNameToDate(filePath));
loadUserOperationLog(filePath, fileNameToDate(filePath));
selectedDateStr = fileNameToDate(filePath);
mSelectedDateStr = fileNameToDate(filePath);
}
void UserOperationLogForm::loadUserOperationLog(const QString& fileName, const QString& date) {
selectedDateStr = date;
model->setFileName(dateToFileName(date));
btn->setText(date);
mSelectedDateStr = date;
mModel->setFileName(dateToFileName(date));
mDateButton->setText(date);
}
void UserOperationLogForm::showEvent(QShowEvent *aEvent)
{
loadUserOperationLog("", selectedDateStr);
loadUserOperationLog("", mSelectedDateStr);
QWidget::showEvent(aEvent);
}

View File

@@ -19,12 +19,14 @@ protected:
void showEvent(QShowEvent *aEvent) override;
private:
QTableView* table = nullptr;
QPushButton* btn = nullptr;
LogFileTableModel* model = nullptr;
SelectDialog* dialog = nullptr;
QVBoxLayout* layout = nullptr;
QString selectedDateStr;
QTableView* mLogTable = nullptr;
QPushButton* mDateButton = nullptr;
QPushButton* mTopButton = nullptr;
QPushButton* mBottomButton = nullptr;
LogFileTableModel* mModel = nullptr;
SelectDialog* mSelectDateDialog = nullptr;
QVBoxLayout* mLayout = nullptr;
QString mSelectedDateStr;
};

View File

@@ -1898,6 +1898,14 @@ progress:99%</source>
<source>Operation</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Top</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bottom</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>WarningMessageWidget</name>

View File

@@ -247,47 +247,47 @@
</message>
<message>
<location filename="../forms/settings/AccountTableForm.cpp" line="38"/>
<location filename="../forms/settings/AccountTableForm.cpp" line="139"/>
<location filename="../forms/settings/AccountTableForm.cpp" line="141"/>
<source>Name</source>
<translation></translation>
</message>
<message>
<location filename="../forms/settings/AccountTableForm.cpp" line="39"/>
<location filename="../forms/settings/AccountTableForm.cpp" line="140"/>
<location filename="../forms/settings/AccountTableForm.cpp" line="142"/>
<source>Role</source>
<translation></translation>
</message>
<message>
<location filename="../forms/settings/AccountTableForm.cpp" line="40"/>
<location filename="../forms/settings/AccountTableForm.cpp" line="141"/>
<location filename="../forms/settings/AccountTableForm.cpp" line="143"/>
<source>Comment</source>
<translation></translation>
</message>
<message>
<location filename="../forms/settings/AccountTableForm.cpp" line="71"/>
<location filename="../forms/settings/AccountTableForm.cpp" line="143"/>
<location filename="../forms/settings/AccountTableForm.cpp" line="145"/>
<source>Add</source>
<translation></translation>
</message>
<message>
<location filename="../forms/settings/AccountTableForm.cpp" line="72"/>
<location filename="../forms/settings/AccountTableForm.cpp" line="144"/>
<location filename="../forms/settings/AccountTableForm.cpp" line="146"/>
<source>Edit</source>
<translation></translation>
</message>
<message>
<location filename="../forms/settings/AccountTableForm.cpp" line="73"/>
<location filename="../forms/settings/AccountTableForm.cpp" line="145"/>
<location filename="../forms/settings/AccountTableForm.cpp" line="147"/>
<source>Delete</source>
<translation></translation>
</message>
<message>
<location filename="../forms/settings/AccountTableForm.cpp" line="126"/>
<location filename="../forms/settings/AccountTableForm.cpp" line="128"/>
<source>Can&apos;t delete current log in account!</source>
<translation></translation>
</message>
<message>
<location filename="../forms/settings/AccountTableForm.cpp" line="130"/>
<location filename="../forms/settings/AccountTableForm.cpp" line="132"/>
<source>Delete account with ID:&quot;%1&quot;!</source>
<translation>ID:&quot;%1&quot;!</translation>
</message>
@@ -416,6 +416,7 @@
<name>DeviceManager</name>
<message>
<location filename="../device/DeviceManager.cpp" line="167"/>
<location filename="../device/DeviceManager.cpp" line="810"/>
<location filename="../device/DeviceManager.cpp" line="818"/>
<location filename="../device/DeviceManager.cpp" line="1427"/>
<source>DMS connection error</source>
@@ -662,58 +663,58 @@ progress:99%</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dialogs/EditPatientDialog.cpp" line="60"/>
<location filename="../dialogs/EditPatientDialog.cpp" line="61"/>
<source>Accession Number</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dialogs/EditPatientDialog.cpp" line="72"/>
<location filename="../dialogs/EditPatientDialog.cpp" line="74"/>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dialogs/EditPatientDialog.cpp" line="83"/>
<location filename="../dialogs/EditPatientDialog.cpp" line="86"/>
<source>Gender</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dialogs/EditPatientDialog.cpp" line="86"/>
<location filename="../dialogs/EditPatientDialog.cpp" line="93"/>
<location filename="../dialogs/EditPatientDialog.cpp" line="146"/>
<location filename="../dialogs/EditPatientDialog.cpp" line="214"/>
<location filename="../dialogs/EditPatientDialog.cpp" line="89"/>
<location filename="../dialogs/EditPatientDialog.cpp" line="96"/>
<location filename="../dialogs/EditPatientDialog.cpp" line="149"/>
<location filename="../dialogs/EditPatientDialog.cpp" line="217"/>
<source>Female</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dialogs/EditPatientDialog.cpp" line="93"/>
<location filename="../dialogs/EditPatientDialog.cpp" line="146"/>
<location filename="../dialogs/EditPatientDialog.cpp" line="214"/>
<location filename="../dialogs/EditPatientDialog.cpp" line="96"/>
<location filename="../dialogs/EditPatientDialog.cpp" line="149"/>
<location filename="../dialogs/EditPatientDialog.cpp" line="217"/>
<source>Male</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dialogs/EditPatientDialog.cpp" line="93"/>
<location filename="../dialogs/EditPatientDialog.cpp" line="146"/>
<location filename="../dialogs/EditPatientDialog.cpp" line="96"/>
<location filename="../dialogs/EditPatientDialog.cpp" line="149"/>
<source>Other</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dialogs/EditPatientDialog.cpp" line="111"/>
<location filename="../dialogs/EditPatientDialog.cpp" line="114"/>
<source>Birth Date</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dialogs/EditPatientDialog.cpp" line="183"/>
<location filename="../dialogs/EditPatientDialog.cpp" line="186"/>
<source>ID can&apos;t be empty!</source>
<translation type="unfinished">ID不能为空</translation>
</message>
<message>
<location filename="../dialogs/EditPatientDialog.cpp" line="189"/>
<location filename="../dialogs/EditPatientDialog.cpp" line="192"/>
<source>Patient Name can&apos;t be empty!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dialogs/EditPatientDialog.cpp" line="201"/>
<location filename="../dialogs/EditPatientDialog.cpp" line="204"/>
<source>The ID and Accession number is already existed!</source>
<translation type="unfinished">ID和检查单号已存在</translation>
</message>
@@ -722,12 +723,12 @@ progress:99%</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="../dialogs/EditPatientDialog.cpp" line="146"/>
<location filename="../dialogs/EditPatientDialog.cpp" line="149"/>
<source>F</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../dialogs/EditPatientDialog.cpp" line="146"/>
<location filename="../dialogs/EditPatientDialog.cpp" line="149"/>
<source>M</source>
<translation type="unfinished"></translation>
</message>
@@ -1708,7 +1709,7 @@ progress:99%</source>
<location filename="../forms/select/PatientDetailForm.cpp" line="70"/>
<location filename="../forms/select/PatientDetailForm.cpp" line="92"/>
<source>Other</source>
<translation type="unfinished"></translation>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../forms/select/PatientDetailForm.cpp" line="38"/>
@@ -2261,99 +2262,99 @@ parameters
<translation type="vanished">()</translation>
</message>
<message>
<location filename="../forms/select/SelectFormWidget.cpp" line="112"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="304"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="115"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="312"/>
<source>Add</source>
<translation></translation>
</message>
<message>
<location filename="../forms/select/SelectFormWidget.cpp" line="110"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="302"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="113"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="310"/>
<source>Edit</source>
<translation></translation>
</message>
<message>
<location filename="../forms/select/SelectFormWidget.cpp" line="50"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="306"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="51"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="314"/>
<source>Patient Information Manage</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../forms/select/SelectFormWidget.cpp" line="111"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="303"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="114"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="311"/>
<source>Delete</source>
<translation></translation>
</message>
<message>
<location filename="../forms/select/SelectFormWidget.cpp" line="113"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="305"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="116"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="313"/>
<source>Select</source>
<translation></translation>
</message>
<message>
<location filename="../forms/select/SelectFormWidget.cpp" line="158"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="161"/>
<source>Can&apos;t delete selected Patient !</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../forms/select/SelectFormWidget.cpp" line="158"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="179"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="161"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="182"/>
<source>Alert</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../forms/select/SelectFormWidget.cpp" line="163"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="166"/>
<source>Delete Patient &quot;%1&quot; ?</source>
<translation type="unfinished">&quot;%1&quot;</translation>
</message>
<message>
<location filename="../forms/select/SelectFormWidget.cpp" line="163"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="166"/>
<source>Confirm</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../forms/select/SelectFormWidget.cpp" line="179"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="182"/>
<source>Can&apos;t delete selected Patient , db submit error!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../forms/select/SelectFormWidget.cpp" line="274"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="282"/>
<source>ID</source>
<translation type="unfinished">ID</translation>
</message>
<message>
<location filename="../forms/select/SelectFormWidget.cpp" line="275"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="295"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="283"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="303"/>
<source>AccessionNumber</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../forms/select/SelectFormWidget.cpp" line="276"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="296"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="284"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="304"/>
<source>Name</source>
<translation></translation>
</message>
<message>
<location filename="../forms/select/SelectFormWidget.cpp" line="277"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="297"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="285"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="305"/>
<source>Birth Date</source>
<translation></translation>
</message>
<message>
<location filename="../forms/select/SelectFormWidget.cpp" line="278"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="298"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="286"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="306"/>
<source>Gender</source>
<translation></translation>
</message>
<message>
<location filename="../forms/select/SelectFormWidget.cpp" line="279"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="299"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="287"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="307"/>
<source>Add Date</source>
<translation></translation>
</message>
<message>
<location filename="../forms/select/SelectFormWidget.cpp" line="280"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="300"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="288"/>
<location filename="../forms/select/SelectFormWidget.cpp" line="308"/>
<source>Comment</source>
<translation></translation>
</message>
@@ -2675,32 +2676,42 @@ parameters
<context>
<name>UserOperationLogForm</name>
<message>
<location filename="../UserOperationLogForm.cpp" line="31"/>
<location filename="../UserOperationLogForm.cpp" line="79"/>
<location filename="../UserOperationLogForm.cpp" line="32"/>
<location filename="../UserOperationLogForm.cpp" line="88"/>
<source>Log Date:</source>
<translation></translation>
</message>
<message>
<location filename="../UserOperationLogForm.cpp" line="38"/>
<location filename="../UserOperationLogForm.cpp" line="80"/>
<source>Top</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../UserOperationLogForm.cpp" line="41"/>
<source>Bottom</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../UserOperationLogForm.cpp" line="47"/>
<location filename="../UserOperationLogForm.cpp" line="89"/>
<source>Operation Date</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../UserOperationLogForm.cpp" line="38"/>
<location filename="../UserOperationLogForm.cpp" line="80"/>
<location filename="../UserOperationLogForm.cpp" line="47"/>
<location filename="../UserOperationLogForm.cpp" line="89"/>
<source>Operation Time</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../UserOperationLogForm.cpp" line="38"/>
<location filename="../UserOperationLogForm.cpp" line="80"/>
<location filename="../UserOperationLogForm.cpp" line="47"/>
<location filename="../UserOperationLogForm.cpp" line="89"/>
<source>User</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../UserOperationLogForm.cpp" line="38"/>
<location filename="../UserOperationLogForm.cpp" line="80"/>
<location filename="../UserOperationLogForm.cpp" line="47"/>
<location filename="../UserOperationLogForm.cpp" line="89"/>
<source>Operation</source>
<translation type="unfinished"></translation>
</message>