mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-21 16:50:53 +01:00
Remove isXrefCell method...
and use instead columnTypeForIndex method
This commit is contained in:
@@ -71,9 +71,12 @@ TerminalStripEditor::TerminalStripEditor(QETProject *project, QWidget *parent) :
|
|||||||
//Go the diagram of double clicked terminal
|
//Go the diagram of double clicked terminal
|
||||||
connect(ui->m_table_widget, &QAbstractItemView::doubleClicked, this, [=](const QModelIndex &index)
|
connect(ui->m_table_widget, &QAbstractItemView::doubleClicked, this, [=](const QModelIndex &index)
|
||||||
{
|
{
|
||||||
Element *elmt = nullptr;
|
if (m_model->columnTypeForIndex(index) == TerminalStripModel::XRef)
|
||||||
if (this->m_model->isXrefCell(index, &elmt))
|
|
||||||
{
|
{
|
||||||
|
auto rtd = m_model->realTerminalDataForIndex(index);
|
||||||
|
if (rtd.element_)
|
||||||
|
{
|
||||||
|
auto elmt = rtd.element_;
|
||||||
auto diagram = elmt->diagram();
|
auto diagram = elmt->diagram();
|
||||||
if (diagram)
|
if (diagram)
|
||||||
{
|
{
|
||||||
@@ -86,6 +89,7 @@ TerminalStripEditor::TerminalStripEditor(QETProject *project, QWidget *parent) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -327,31 +327,6 @@ QVector<QPair<RealTerminalData, RealTerminalData>> TerminalStripModel::modifiedR
|
|||||||
return returned_vector;
|
return returned_vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @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()
|
|
||||||
&& index.column() == XREF_CELL)
|
|
||||||
{
|
|
||||||
if (index.row() < rowCount())
|
|
||||||
{
|
|
||||||
if (auto data = dataAtRow(index.row()) ; data.element_) {
|
|
||||||
*element = data.element_.data();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief TerminalStripModel::levelCellCount
|
* @brief TerminalStripModel::levelCellCount
|
||||||
* Check for each index of @a index_list if the cell represented by the index
|
* Check for each index of @a index_list if the cell represented by the index
|
||||||
@@ -448,6 +423,20 @@ QVector<RealTerminalData> TerminalStripModel::realTerminalDataForIndex(QModelInd
|
|||||||
return vector_;
|
return vector_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TerminalStripModel::realTerminalDataForIndex
|
||||||
|
* @param index
|
||||||
|
* @return RealTerminalData at index @a index or null RealTerminalData if invalid
|
||||||
|
*/
|
||||||
|
RealTerminalData TerminalStripModel::realTerminalDataForIndex(const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
if (index.isValid()) {
|
||||||
|
return realDataAtIndex(index.row());
|
||||||
|
} else {
|
||||||
|
return RealTerminalData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TerminalStripModel::fillPhysicalTerminalData()
|
void TerminalStripModel::fillPhysicalTerminalData()
|
||||||
{
|
{
|
||||||
//Get all physical terminal
|
//Get all physical terminal
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2021 The QElectroTech Team
|
Copyright 2006-2021 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
@@ -64,10 +64,10 @@ class TerminalStripModel : public QAbstractTableModel
|
|||||||
virtual Qt::ItemFlags flags (const QModelIndex &index) const override;
|
virtual Qt::ItemFlags flags (const QModelIndex &index) const override;
|
||||||
QVector<QPair<RealTerminalData, RealTerminalData>> modifiedRealTerminalData() const;
|
QVector<QPair<RealTerminalData, RealTerminalData>> modifiedRealTerminalData() const;
|
||||||
|
|
||||||
bool isXrefCell(const QModelIndex &index, Element **element = nullptr);
|
|
||||||
QVector<int> levelCellCount(const QModelIndexList &index_list) const;
|
QVector<int> levelCellCount(const QModelIndexList &index_list) const;
|
||||||
QVector<PhysicalTerminalData> physicalTerminalDataForIndex(QModelIndexList index_list) const;
|
QVector<PhysicalTerminalData> physicalTerminalDataForIndex(QModelIndexList index_list) const;
|
||||||
QVector<RealTerminalData> realTerminalDataForIndex(QModelIndexList index_list) const;
|
QVector<RealTerminalData> realTerminalDataForIndex(QModelIndexList index_list) const;
|
||||||
|
RealTerminalData realTerminalDataForIndex(const QModelIndex &index) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void fillPhysicalTerminalData();
|
void fillPhysicalTerminalData();
|
||||||
|
|||||||
Reference in New Issue
Block a user