Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Q3PtrList in diagram dialog #854

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 15 additions & 20 deletions qucs/diagrams/diagramdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ DiagramDialog::DiagramDialog(Diagram *d, QWidget *parent, Graph *currentGraph)
{
setAttribute(Qt::WA_DeleteOnClose);
Diag = d;
Graphs.setAutoDelete(true);
copyDiagramGraphs(); // make a copy of all graphs
if(parent){
const Schematic* s = dynamic_cast<const Schematic*>(parent);
Expand Down Expand Up @@ -1012,7 +1011,7 @@ void DiagramDialog::slotTakeVar(QTableWidgetItem* Item)
g->numMode = PropertyBox->currentIndex();
}

Graphs.append(g);
Graphs.emplace_back(g);
changed = true;
toTake = true;
//}
Expand All @@ -1037,7 +1036,7 @@ void DiagramDialog::slotSelectGraph(QListWidgetItem *item)
return;
}

SelectGraph (Graphs.at (GraphList->currentRow()));
SelectGraph (Graphs.at(GraphList->currentRow()).get());
}

/*!
Expand Down Expand Up @@ -1090,7 +1089,7 @@ void DiagramDialog::slotDeleteGraph()
if(i < 0) return; // return, if no item selected

GraphList->takeItem(i);
Graphs.remove(i);
Graphs.erase(std::next(Graphs.begin(), i));

int k=0;
if (GraphList->count()!=0) {
Expand Down Expand Up @@ -1159,7 +1158,7 @@ void DiagramDialog::slotNewGraph()
g->Precision = Property2->text().toInt();
g->numMode = PropertyBox->currentIndex();
}
Graphs.append(g);
Graphs.emplace_back(g);
changed = true;
toTake = false;
}
Expand Down Expand Up @@ -1350,11 +1349,11 @@ void DiagramDialog::slotApply()
} // of "if(Diag->Name != "Tab")"

Diag->Graphs.clear(); // delete the graphs
Graphs.setAutoDelete(false);
for(Graph *pg = Graphs.first(); pg != 0; pg = Graphs.next())
Diag->Graphs.append(pg); // transfer the new graphs to diagram

for (std::unique_ptr<Graph>& graph : Graphs) {
Diag->Graphs.append(graph.release()); // transfer the new graphs to diagram
}
Graphs.clear();
Graphs.setAutoDelete(true);

Diag->loadGraphData(defaultDataSet);
((Schematic*)parent())->viewport()->repaint();
Expand Down Expand Up @@ -1392,8 +1391,7 @@ void DiagramDialog::slotSetColor()
int i = GraphList->currentRow();
if(i < 0) return; // return, if no item selected

Graph *g = Graphs.at(i);
g->Color = c;
Graphs.at(i)->Color = c;
changed = true;
toTake = false;
}
Expand All @@ -1416,8 +1414,7 @@ void DiagramDialog::slotResetToTake(const QString& s)
int i = GraphList->currentRow();
if(i < 0) return; // return, if no item selected

Graph *g = Graphs.at(i);
g->Var = s;
Graphs.at(i)->Var = s;
// \todo GraphList->changeItem(s, i); // must done after the graph settings !!!
changed = true;
toTake = false;
Expand All @@ -1432,7 +1429,7 @@ void DiagramDialog::slotSetProp2(const QString& s)
int i = GraphList->currentRow();
if(i < 0) return; // return, if no item selected

Graph *g = Graphs.at(i);
Graph *g = Graphs.at(i).get();
if(Diag->Name == "Tab") g->Precision = s.toInt();
else g->Thick = s.toInt();
changed = true;
Expand All @@ -1447,8 +1444,7 @@ void DiagramDialog::slotSetNumMode(int Mode)
int i = GraphList->currentRow();
if(i < 0) return; // return, if no item selected

Graph *g = Graphs.at(i);
g->numMode = Mode;
Graphs.at(i)->numMode = Mode;
changed = true;
toTake = false;
}
Expand Down Expand Up @@ -1480,7 +1476,7 @@ void DiagramDialog::slotSetGraphStyle(int style)
int i = GraphList->currentRow();
if(i < 0) return; // return, if no item selected

Graph *g = Graphs.at(i);
Graph *g = Graphs.at(i).get();
g->Style = toGraphStyle(style);
assert(g->Style!=GRAPHSTYLE_INVALID);
changed = true;
Expand All @@ -1493,7 +1489,7 @@ void DiagramDialog::slotSetGraphStyle(int style)
void DiagramDialog::copyDiagramGraphs()
{
for (Graph *pg : Diag->Graphs)
Graphs.append(pg->sameNewOne());
Graphs.emplace_back(pg->sameNewOne());
}

/*!
Expand All @@ -1504,8 +1500,7 @@ void DiagramDialog::slotSetYAxis(int axis)
int i = GraphList->currentRow();
if(i < 0) return; // return, if no item selected

Graph *g = Graphs.at(i);
g->yAxisNo = axis;
Graphs.at(i)->yAxisNo = axis;
changed = true;
toTake = false;
}
Expand Down
5 changes: 2 additions & 3 deletions qucs/diagrams/diagramdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#ifndef DIAGRAMDIALOG_H
#define DIAGRAMDIALOG_H
#include "diagram.h"
#include "node.h"

/*#ifndef pi
#define pi 3.1415926535897932384626433832795029
Expand All @@ -27,7 +26,7 @@
#include <QDialog>
#include <QRegularExpression>
#include <QRegularExpressionValidator>
#include "qt3_compat/qt_compat.h"
#include <vector>

class QVBoxLayout;
class Cross3D;
Expand Down Expand Up @@ -130,7 +129,7 @@ protected slots:
QSlider *SliderRotX, *SliderRotY, *SliderRotZ;
Cross3D *DiagCross;
bool changed, transfer, toTake;
Q3PtrList<Graph> Graphs;
std::vector<std::unique_ptr<Graph>> Graphs;
};

#endif
1 change: 0 additions & 1 deletion qucs/diagrams/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

#include <cmath>
#include <QColor>
#include "qt3_compat/qt_compat.h"
#include <QDateTime>


Expand Down
Loading