fix:修复历史事件浏窗口中‘QDateTimeEdit的upButton无法点击问题’

This commit is contained in:
duanshengchao 2025-11-17 10:13:02 +08:00
parent fdc164ed5e
commit 7d1e06bda9
11 changed files with 109 additions and 144 deletions

View File

@ -3,6 +3,7 @@
#include <QDialog> #include <QDialog>
#include "alarmEventGlobal.h" #include "alarmEventGlobal.h"
#include "alarmEventUtils.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
namespace Ui { namespace Ui {
@ -10,6 +11,7 @@ class alarmEventMainDialog;
} }
QT_END_NAMESPACE QT_END_NAMESPACE
class AlarmEventDataView;
class AlarmEventMainDialog : public QDialog class AlarmEventMainDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
@ -31,7 +33,9 @@ public slots:
private: private:
Ui::alarmEventMainDialog* ui; Ui::alarmEventMainDialog* ui;
AlarmEventDataView* m_tableView;
AlarmDataMode m_mode; AlarmDataMode m_mode;
AlarmEventDataFilter m_eventFilter;
}; };

View File

@ -225,6 +225,7 @@ public:
QVector<EventData> apply(const QVector<EventData>& events); QVector<EventData> apply(const QVector<EventData>& events);
private: private:
void reset();
bool isEmpty(); bool isEmpty();
QDateTime m_startTime; QDateTime m_startTime;

View File

@ -20,7 +20,7 @@ signals:
void clicked(); void clicked();
protected: protected:
void mousePressEvent(QMouseEvent* event) override; void mouseDoubleClickEvent(QMouseEvent* event) override;
}; };
#endif #endif

View File

@ -7,6 +7,7 @@
<file>images/icon_doubleArrow_down_hover.png</file> <file>images/icon_doubleArrow_down_hover.png</file>
<file>images/icon_doubleArrow_up_default.png</file> <file>images/icon_doubleArrow_up_default.png</file>
<file>images/icon_doubleArrow_up_hover.png</file> <file>images/icon_doubleArrow_up_hover.png</file>
<file>images/up-arrow.png</file>
<file>images/icon_first.png</file> <file>images/icon_first.png</file>
<file>images/icon_last.png</file> <file>images/icon_last.png</file>
<file>images/icon_next.png</file> <file>images/icon_next.png</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 788 B

View File

@ -36,9 +36,9 @@ AlarmEventDataModel::AlarmEventDataModel(AlarmDataMode mode, QObject* parent)
//实时数据测试 //实时数据测试
/*m_simulatedDataTimer = new QTimer(this); m_simulatedDataTimer = new QTimer(this);
connect(m_simulatedDataTimer, &QTimer::timeout, this, &AlarmEventDataModel::onTimeoutSimulateData); connect(m_simulatedDataTimer, &QTimer::timeout, this, &AlarmEventDataModel::onTimeoutSimulateData);
m_simulatedDataTimer->start(3000);*/ m_simulatedDataTimer->start(3000);
} }
AlarmEventDataModel::~AlarmEventDataModel() AlarmEventDataModel::~AlarmEventDataModel()
@ -173,10 +173,10 @@ void AlarmEventDataModel::iniHeaderData()
m_headerData.emplace_back(SectionData("厂站", 200, Station)); m_headerData.emplace_back(SectionData("厂站", 200, Station));
m_headerData.emplace_back(SectionData("间隔", 200, Bay)); m_headerData.emplace_back(SectionData("间隔", 200, Bay));
m_headerData.emplace_back(SectionData("信息", -1, Description)); m_headerData.emplace_back(SectionData("信息", -1, Description));
m_headerData.emplace_back(SectionData("类型", 150, Type)); m_headerData.emplace_back(SectionData("类型", 160, Type));
m_headerData.emplace_back(SectionData("等级", 150, Severity)); m_headerData.emplace_back(SectionData("等级", 160, Severity));
m_headerData.emplace_back(SectionData("确认状态", 150, Status)); m_headerData.emplace_back(SectionData("确认状态", 150, Status));
m_headerData.emplace_back(SectionData("操作", 172, Operation)); m_headerData.emplace_back(SectionData("操作", 180, Operation));
} }
/*void AlarmEventDataModel::setMode(AlarmDataMode mode) /*void AlarmEventDataModel::setMode(AlarmDataMode mode)

View File

@ -1,5 +1,6 @@
#include "alarmEventMainDialog.h" #include "alarmEventMainDialog.h"
#include "ui_alarmEventMainDialog.h" #include "ui_alarmEventMainDialog.h"
#include "alarmEventDataView.h"
AlarmEventMainDialog::AlarmEventMainDialog(QWidget *parent) AlarmEventMainDialog::AlarmEventMainDialog(QWidget *parent)
: QDialog(parent) : QDialog(parent)
@ -10,6 +11,9 @@ AlarmEventMainDialog::AlarmEventMainDialog(QWidget *parent)
setWindowFlags(Qt::FramelessWindowHint); setWindowFlags(Qt::FramelessWindowHint);
setAttribute(Qt::WA_TranslucentBackground); setAttribute(Qt::WA_TranslucentBackground);
m_tableView = new AlarmEventDataView(Historical, this);
ui->tableLayout->addWidget(m_tableView);
connect(ui->btnClose, &QPushButton::clicked, this, &AlarmEventMainDialog::onBtnClicked_close); connect(ui->btnClose, &QPushButton::clicked, this, &AlarmEventMainDialog::onBtnClicked_close);
} }

View File

@ -3,10 +3,33 @@
///////------AlarmEventDataFilter----- ///////------AlarmEventDataFilter-----
AlarmEventDataFilter::AlarmEventDataFilter() AlarmEventDataFilter::AlarmEventDataFilter()
{ {
reset();
}
void AlarmEventDataFilter::reset()
{
m_startTime = QDateTime();
m_endTime = QDateTime();
m_station.clear();
m_bay.clear();
m_type = -1; m_type = -1;
m_severity.clear();
m_description.clear();
m_status = -1; m_status = -1;
} }
bool AlarmEventDataFilter::isEmpty()
{
return !m_startTime.isValid() &&
!m_endTime.isValid() &&
m_station.isEmpty() &&
m_bay.isEmpty() &&
m_type == -1 &&
m_severity.isEmpty() &&
m_description.isEmpty() &&
m_status == -1;
}
bool AlarmEventDataFilter::matches(const EventData& event) bool AlarmEventDataFilter::matches(const EventData& event)
{ {
QDateTime eventTime = QDateTime::fromMSecsSinceEpoch(event.timestamp); QDateTime eventTime = QDateTime::fromMSecsSinceEpoch(event.timestamp);
@ -38,14 +61,7 @@ bool AlarmEventDataFilter::matches(const EventData& event)
void AlarmEventDataFilter::clear() void AlarmEventDataFilter::clear()
{ {
m_startTime = QDateTime(); reset();
m_endTime = QDateTime();
m_station.clear();
m_bay.clear();
m_type = -1;
m_severity.clear();
m_description.clear();
m_status = -1;
} }
QVector<EventData> AlarmEventDataFilter::apply(const QVector<EventData>& events) QVector<EventData> AlarmEventDataFilter::apply(const QVector<EventData>& events)
@ -65,18 +81,6 @@ QVector<EventData> AlarmEventDataFilter::apply(const QVector<EventData>& events)
return filteredEvents; //RVO + QT的隐式共享(QVector),不用担心开销 return filteredEvents; //RVO + QT的隐式共享(QVector),不用担心开销
} }
bool AlarmEventDataFilter::isEmpty()
{
return !m_startTime.isValid() &&
!m_endTime.isValid() &&
m_station.isEmpty() &&
m_bay.isEmpty() &&
m_type == -1 &&
m_severity.isEmpty() &&
m_description.isEmpty() &&
m_status == -1;
}
///////------AlarmEventDataFilter----- ///////------AlarmEventDataFilter-----
AlarmEventCache::AlarmEventCache() AlarmEventCache::AlarmEventCache()

View File

@ -5,10 +5,10 @@ CustomLineEdit::CustomLineEdit(QWidget* parent)
: QLineEdit(parent) : QLineEdit(parent)
{} {}
void CustomLineEdit::mousePressEvent(QMouseEvent* event) void CustomLineEdit::mouseDoubleClickEvent(QMouseEvent* event)
{ {
if(event->button() == Qt::LeftButton) if(event->button() == Qt::LeftButton)
emit clicked(); emit clicked();
QLineEdit::mousePressEvent(event); QLineEdit::mouseDoubleClickEvent(event);
} }

View File

@ -56,6 +56,48 @@ QLineEdit:focus
border:1px solid rgb(67,160,249); border:1px solid rgb(67,160,249);
} }
QDateTimeEdit
{
font: 12pt &quot;黑体&quot;;
color: rgb(250, 250, 250);
background-color: rgb(24, 32, 38);
border:1px solid rgb(200,200,200);
padding-right:25px;
}
QDateTimeEdit:focus
{
border:1px solid rgb(67,160,249);
}
QDateTimeEdit::up-button
{
border: 0px;
margin:2px;
}
QDateTimeEdit::up-button:hover
{
background-color: rgb(54, 62, 74);
}
QDateTimeEdit::up-arrow
{
margin-top:5px;
width:14px;
image: url(:/images/up-arrow.png);
}
QDateTimeEdit::down-button
{
border: 0px;
margin:2px;
}
QDateTimeEdit::down-button:hover
{
background-color: rgb(54, 62, 74);
}
QDateTimeEdit::down-arrow
{
width:14px;
image: url(:/images/down-arrow.png);
}
QComboBox QComboBox
{ {
font: 12pt &quot;黑体&quot;; font: 12pt &quot;黑体&quot;;
@ -570,28 +612,6 @@ icon: url(:/images/icon_configuration.png);
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1">
<widget class="CustomLineEdit" name="lineEdit_beginTime">
<property name="minimumSize">
<size>
<width>0</width>
<height>31</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>31</height>
</size>
</property>
<property name="text">
<string>2025/09/16 10:06:12 </string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_endTime"> <widget class="QLabel" name="label_endTime">
<property name="minimumSize"> <property name="minimumSize">
@ -611,8 +631,8 @@ icon: url(:/images/icon_configuration.png);
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="0" column="1">
<widget class="CustomLineEdit" name="lineEdit_endTime"> <widget class="QDateTimeEdit" name="beginTime">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
@ -625,11 +645,27 @@ icon: url(:/images/icon_configuration.png);
<height>31</height> <height>31</height>
</size> </size>
</property> </property>
<property name="text"> <property name="displayFormat">
<string>2025/09/16 10:07:12</string> <string>yyyy/MM/dd H:mm</string>
</property> </property>
<property name="readOnly"> </widget>
<bool>true</bool> </item>
<item row="1" column="1">
<widget class="QDateTimeEdit" name="endTime">
<property name="minimumSize">
<size>
<width>0</width>
<height>31</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>31</height>
</size>
</property>
<property name="displayFormat">
<string>yyyy/MM/dd H:mm</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -639,7 +675,7 @@ icon: url(:/images/icon_configuration.png);
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QWidget" name="tableView" native="true"> <widget class="QWidget" name="tableWidget" native="true">
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">QWidget #tableView <string notr="true">QWidget #tableView
{ {
@ -682,88 +718,10 @@ QTableView::item:selected
{ {
}</string> }</string>
</property> </property>
<layout class="QVBoxLayout" name="vLayout_table"> <layout class="QVBoxLayout" name="tableLayout">
<property name="topMargin"> <property name="topMargin">
<number>15</number> <number>15</number>
</property> </property>
<item>
<widget class="QTableWidget" name="tableWidget">
<property name="textElideMode">
<enum>Qt::TextElideMode::ElideNone</enum>
</property>
<property name="showGrid">
<bool>false</bool>
</property>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<row>
<property name="text">
<string>新建行</string>
</property>
</row>
<row>
<property name="text">
<string>新建行</string>
</property>
</row>
<row>
<property name="text">
<string>新建行</string>
</property>
</row>
<column>
<property name="text">
<string>序号</string>
</property>
</column>
<column>
<property name="text">
<string>时间</string>
</property>
</column>
<column>
<property name="text">
<string>厂站</string>
</property>
</column>
<column>
<property name="text">
<string>详情</string>
</property>
</column>
<column>
<property name="text">
<string>类型</string>
</property>
</column>
<column>
<property name="text">
<string>级别</string>
</property>
</column>
<column>
<property name="text">
<string>操作</string>
</property>
</column>
<item row="0" column="0">
<property name="text">
<string>1</string>
</property>
</item>
<item row="0" column="1">
<property name="text">
<string>2025-09-17 165101</string>
</property>
</item>
<item row="0" column="2">
<property name="text">
<string>灵州换流站</string>
</property>
</item>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -1074,13 +1032,6 @@ QPushButton:pressed
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>CustomLineEdit</class>
<extends>QLineEdit</extends>
<header location="global">customLineEdit.h</header>
</customwidget>
</customwidgets>
<resources> <resources>
<include location="../resource/PowerMaster.qrc"/> <include location="../resource/PowerMaster.qrc"/>
</resources> </resources>

View File

@ -582,7 +582,7 @@ QTableView::item:selected
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QWidget" name="talbeWidget" native="true"> <widget class="QWidget" name="tableWidget" native="true">
<layout class="QVBoxLayout" name="tableLayout"> <layout class="QVBoxLayout" name="tableLayout">
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>