mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-24 03:10:52 +01:00
Double click on Xref cell show the terminal in the diagram
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
#include "terminalstriptreewidget.h"
|
#include "terminalstriptreewidget.h"
|
||||||
#include "../../qeticons.h"
|
#include "../../qeticons.h"
|
||||||
#include "terminalstripmodel.h"
|
#include "terminalstripmodel.h"
|
||||||
|
#include "../diagram.h"
|
||||||
|
|
||||||
#include <QTreeWidgetItem>
|
#include <QTreeWidgetItem>
|
||||||
|
|
||||||
@@ -48,6 +49,29 @@ TerminalStripEditor::TerminalStripEditor(QETProject *project, QWidget *parent) :
|
|||||||
buildTree();
|
buildTree();
|
||||||
ui->m_terminal_strip_tw->expandRecursively(ui->m_terminal_strip_tw->rootIndex());
|
ui->m_terminal_strip_tw->expandRecursively(ui->m_terminal_strip_tw->rootIndex());
|
||||||
setUpUndoConnections();
|
setUpUndoConnections();
|
||||||
|
|
||||||
|
//Go the diagram of double clicked terminal
|
||||||
|
connect(ui->m_table_widget, &QAbstractItemView::doubleClicked, [this](auto index)
|
||||||
|
{
|
||||||
|
Element *elmt = nullptr;
|
||||||
|
if (this->m_model->isXrefCell(index, &elmt))
|
||||||
|
{
|
||||||
|
auto diagram = elmt->diagram();
|
||||||
|
if (diagram)
|
||||||
|
{
|
||||||
|
diagram->showMe();
|
||||||
|
if (diagram->views().size())
|
||||||
|
{
|
||||||
|
auto fit_view = elmt->sceneBoundingRect();
|
||||||
|
fit_view.adjust(-200,-200,200,200);
|
||||||
|
diagram->views().first()->fitInView(fit_view, Qt::KeepAspectRatioByExpanding);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
connect(ui->m_table_widget, &QAbstractItemView::entered, [this](auto index) {
|
||||||
|
qDebug() <<"entered";
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -239,6 +239,32 @@ QHash<Element *, ElementData> TerminalStripModel::editedTerminalsData() const
|
|||||||
return returned_hash;
|
return returned_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripModel::isXrefCell
|
||||||
|
* @param index
|
||||||
|
* @param elmt : Pointer of a pointer element
|
||||||
|
* @return true if the index is the Xref cell, if true the pointer \p element
|
||||||
|
* will be set to the element associated to the cell.
|
||||||
|
*/
|
||||||
|
bool TerminalStripModel::isXrefCell(const QModelIndex &index, Element **element)
|
||||||
|
{
|
||||||
|
if (index.model() == this && index.isValid())
|
||||||
|
{
|
||||||
|
if (index.column() == XREF_CELL)
|
||||||
|
{
|
||||||
|
if (index.row() < m_real_terminal_data.size())
|
||||||
|
{
|
||||||
|
auto data = m_real_terminal_data.at(index.row());
|
||||||
|
*element = m_terminal_strip->elementForRealTerminal(data.m_real_terminal);
|
||||||
|
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void TerminalStripModel::fillRealTerminalData()
|
void TerminalStripModel::fillRealTerminalData()
|
||||||
{
|
{
|
||||||
if (m_terminal_strip) {
|
if (m_terminal_strip) {
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ class TerminalStripModel : public QAbstractTableModel
|
|||||||
|
|
||||||
QHash<Element *, ElementData> editedTerminalsData() const;
|
QHash<Element *, ElementData> editedTerminalsData() const;
|
||||||
|
|
||||||
|
bool isXrefCell(const QModelIndex &index, Element **element = nullptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void fillRealTerminalData();
|
void fillRealTerminalData();
|
||||||
static ElementData modifiedData(const ElementData &original_data, const RealTerminalData &edited_data);
|
static ElementData modifiedData(const ElementData &original_data, const RealTerminalData &edited_data);
|
||||||
|
|||||||
Reference in New Issue
Block a user