feat:完成告警列表中操作按钮的点击响应逻辑
This commit is contained in:
parent
0306b1742d
commit
ed64a0378d
|
|
@ -134,6 +134,10 @@ public:
|
|||
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
|
||||
bool editorEvent(QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index) override;
|
||||
|
||||
signals:
|
||||
void confirmBtnClicked(const QModelIndex& index);
|
||||
void replayBtnClicked(const QModelIndex& index);
|
||||
|
||||
private:
|
||||
struct ControlButton
|
||||
{
|
||||
|
|
@ -168,6 +172,10 @@ public:
|
|||
|
||||
void setModelMode(AlarmDataMode, int maxRealTimeEvents = 5);
|
||||
|
||||
public slots:
|
||||
void onBtnClicked_Confirm(const QModelIndex& index);
|
||||
void onBtnClicked_Replay(const QModelIndex& index);
|
||||
|
||||
private:
|
||||
QTableView* m_tableView;
|
||||
AlarmEventDataModel* m_tableModel;
|
||||
|
|
|
|||
|
|
@ -470,6 +470,10 @@ bool AlarmEventDataDelegate::editorEvent(QEvent* event, QAbstractItemModel* mode
|
|||
else if(mouseEvent->button() == Qt::LeftButton && mouseEvent->type() == QEvent::MouseButtonRelease)
|
||||
{
|
||||
emit m_tableView->model()->dataChanged(index, index); //触发重绘
|
||||
if(m_btnConfirm.rect.contains(m_mousePositon))
|
||||
emit confirmBtnClicked(index);
|
||||
else if(m_btnReplay.rect.contains(m_mousePositon))
|
||||
emit replayBtnClicked(index);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -501,6 +505,8 @@ AlarmEventDataView::AlarmEventDataView(QWidget* parent)
|
|||
}
|
||||
|
||||
m_delegate = new AlarmEventDataDelegate(m_tableView, this);
|
||||
connect(m_delegate, &AlarmEventDataDelegate::confirmBtnClicked, this, &AlarmEventDataView::onBtnClicked_Confirm);
|
||||
connect(m_delegate, &AlarmEventDataDelegate::replayBtnClicked, this, &AlarmEventDataView::onBtnClicked_Replay);
|
||||
m_tableView->setItemDelegate(m_delegate);
|
||||
|
||||
m_vLayout = new QVBoxLayout(this);
|
||||
|
|
@ -522,3 +528,13 @@ void AlarmEventDataView::setModelMode(AlarmDataMode mode, int maxRealTimeEvents)
|
|||
m_tableModel->setMaxRealTimeEvents(maxRealTimeEvents);
|
||||
}
|
||||
}
|
||||
|
||||
void AlarmEventDataView::onBtnClicked_Confirm(const QModelIndex& index)
|
||||
{
|
||||
qDebug() << QString("confirmBtnClicked, row: %1").arg(index.row());
|
||||
}
|
||||
|
||||
void AlarmEventDataView::onBtnClicked_Replay(const QModelIndex& index)
|
||||
{
|
||||
qDebug() << QString("replayBtnClicked, row: %1").arg(index.row());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue