mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-04-17 06:39:59 +02:00
Overridden properties of terminal elements are now saved/loaded from project
The overridden properties of terminal elements made in the terminal strip dialog are now saved and loaded from/to the project file.
This commit is contained in:
@@ -69,9 +69,6 @@ TerminalStripEditor::TerminalStripEditor(QETProject *project, QWidget *parent) :
|
||||
}
|
||||
}
|
||||
});
|
||||
connect(ui->m_table_widget, &QAbstractItemView::entered, [this](auto index) {
|
||||
qDebug() <<"entered";
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -221,8 +218,8 @@ QTreeWidgetItem* TerminalStripEditor::addTerminalStrip(TerminalStrip *terminal_s
|
||||
terminal_item->setData(0, TerminalStripTreeWidget::UUID_USER_ROLE, real_t.uuid_.toString());
|
||||
terminal_item->setIcon(0, QET::Icons::ElementTerminal);
|
||||
|
||||
if (real_t.is_element) {
|
||||
m_uuid_terminal_H.insert(real_t.uuid_, real_t.element_);
|
||||
if (real_t.element_) {
|
||||
m_uuid_terminal_H.insert(real_t.uuid_, qgraphicsitem_cast<TerminalElement *>(real_t.element_));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -440,7 +437,7 @@ void TerminalStripEditor::on_m_dialog_button_box_clicked(QAbstractButton *button
|
||||
{
|
||||
for (auto modified_data : m_model->modifiedRealTerminalData())
|
||||
{
|
||||
auto element = m_current_strip->elementForRealTerminal(modified_data.m_real_terminal);
|
||||
auto element = modified_data.element_;
|
||||
if (element) {
|
||||
auto current_data = element->elementData();
|
||||
current_data.setTerminalType(modified_data.type_);
|
||||
|
||||
@@ -116,8 +116,8 @@ QVariant TerminalStripModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
else if (role == Qt::BackgroundRole && index.column() <= CONDUCTOR_CELL )
|
||||
{
|
||||
if (m_modified_cell.contains(rtd.m_real_terminal) &&
|
||||
m_modified_cell.value(rtd.m_real_terminal).at(index.column()))
|
||||
if (m_modified_cell.contains(rtd.element_) &&
|
||||
m_modified_cell.value(rtd.element_).at(index.column()))
|
||||
{
|
||||
return QBrush(Qt::yellow);
|
||||
}
|
||||
@@ -168,17 +168,17 @@ bool TerminalStripModel::setData(const QModelIndex &index, const QVariant &value
|
||||
{
|
||||
replaceDataAtRow(rtd, index.row());
|
||||
|
||||
if (rtd.m_real_terminal)
|
||||
if (rtd.element_)
|
||||
{
|
||||
QVector<bool> vector_;
|
||||
if (m_modified_cell.contains(rtd.m_real_terminal)) {
|
||||
vector_ = m_modified_cell.value(rtd.m_real_terminal);
|
||||
if (m_modified_cell.contains(rtd.element_)) {
|
||||
vector_ = m_modified_cell.value(rtd.element_);
|
||||
} else {
|
||||
vector_ = UNMODIFIED_CELL_VECTOR;
|
||||
}
|
||||
|
||||
vector_.replace(modified_cell, true);
|
||||
m_modified_cell.insert(rtd.m_real_terminal, vector_);
|
||||
m_modified_cell.insert(rtd.element_, vector_);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -236,7 +236,7 @@ QVector<RealTerminalData> TerminalStripModel::modifiedRealTerminalData() const
|
||||
|
||||
for (const auto &ptd : m_physical_terminal_data) {
|
||||
for (const auto &rtd : ptd.real_terminals_vector) {
|
||||
if (modified_real_terminal.contains(rtd.m_real_terminal)) {
|
||||
if (modified_real_terminal.contains(rtd.element_)) {
|
||||
returned_vector.append(rtd);
|
||||
}
|
||||
}
|
||||
@@ -254,18 +254,17 @@ QVector<RealTerminalData> TerminalStripModel::modifiedRealTerminalData() const
|
||||
*/
|
||||
bool TerminalStripModel::isXrefCell(const QModelIndex &index, Element **element)
|
||||
{
|
||||
if (index.model() == this && index.isValid())
|
||||
if (index.model() == this
|
||||
&& index.isValid()
|
||||
&& index.column() == XREF_CELL)
|
||||
{
|
||||
if (index.column() == XREF_CELL)
|
||||
if (index.row() < rowCount())
|
||||
{
|
||||
if (index.row() < rowCount())
|
||||
{
|
||||
const auto data = dataAtRow(index.row());
|
||||
*element = m_terminal_strip->elementForRealTerminal(data.m_real_terminal);
|
||||
|
||||
if (auto data = dataAtRow(index.row()) ; data.element_) {
|
||||
*element = data.element_.data();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -52,7 +52,7 @@ class TerminalStripModel : public QAbstractTableModel
|
||||
private:
|
||||
QPointer<TerminalStrip> m_terminal_strip;
|
||||
QVector<PhysicalTerminalData> m_physical_terminal_data;
|
||||
QHash<QSharedPointer<RealTerminal>, QVector<bool>> m_modified_cell;
|
||||
QHash<Element *, QVector<bool>> m_modified_cell;
|
||||
};
|
||||
|
||||
class TerminalStripModelDelegate : public QStyledItemDelegate
|
||||
|
||||
Reference in New Issue
Block a user