diff --git a/qucs/qucs/diagrams/diagramdialog.cpp b/qucs/qucs/diagrams/diagramdialog.cpp index f0061f56ef..5b63135987 100644 --- a/qucs/qucs/diagrams/diagramdialog.cpp +++ b/qucs/qucs/diagrams/diagramdialog.cpp @@ -105,7 +105,7 @@ static const int NumDefaultColors = 8; DiagramDialog::DiagramDialog(Diagram *d, QWidget *parent, Graph *currentGraph) - : QDialog(parent, 0, TRUE, Qt::WDestructiveClose) + : QDialog(parent, Qt::WDestructiveClose) { Diag = d; Graphs.setAutoDelete(true); @@ -114,7 +114,7 @@ DiagramDialog::DiagramDialog(Diagram *d, QWidget *parent, Graph *currentGraph) const Schematic* s = dynamic_cast(parent); assert(s); QFileInfo Info(s->DocName); - defaultDataSet = Info.dirPath() + QDir::separator() + s->DataSet; + defaultDataSet = Info.path() + QDir::separator() + s->DataSet; }else{ defaultDataSet = "unknown"; } @@ -190,10 +190,10 @@ DiagramDialog::DiagramDialog(Diagram *d, QWidget *parent, Graph *currentGraph) Box2Layout->addWidget(Label1); PropertyBox = new QComboBox(); Box2Layout->addWidget(PropertyBox); - PropertyBox->insertItem(tr("real/imaginary")); - PropertyBox->insertItem(tr("magnitude/angle (degree)")); - PropertyBox->insertItem(tr("magnitude/angle (radian)")); - PropertyBox->setCurrentItem(1); + PropertyBox->insertItem(0,tr("real/imaginary")); + PropertyBox->insertItem(1,tr("magnitude/angle (degree)")); + PropertyBox->insertItem(2,tr("magnitude/angle (radian)")); + PropertyBox->setCurrentIndex(0); connect(PropertyBox, SIGNAL(activated(int)), SLOT(slotSetNumMode(int))); Box2Layout->setStretchFactor(new QWidget(Box2), 5); // stretchable placeholder @@ -221,14 +221,14 @@ DiagramDialog::DiagramDialog(Diagram *d, QWidget *parent, Graph *currentGraph) Label3->setEnabled(false); PropertyBox = new QComboBox(); Box2Layout->addWidget(PropertyBox); - PropertyBox->insertItem(tr("solid line")); - PropertyBox->insertItem(tr("dash line")); - PropertyBox->insertItem(tr("dot line")); + PropertyBox->insertItem(0,tr("solid line")); + PropertyBox->insertItem(1,tr("dash line")); + PropertyBox->insertItem(2,tr("dot line")); if(Diag->Name != "Time") { - PropertyBox->insertItem(tr("long dash line")); - PropertyBox->insertItem(tr("stars")); - PropertyBox->insertItem(tr("circles")); - PropertyBox->insertItem(tr("arrows")); + PropertyBox->insertItem(3,tr("long dash line")); + PropertyBox->insertItem(4,tr("stars")); + PropertyBox->insertItem(5,tr("circles")); + PropertyBox->insertItem(6,tr("arrows")); } connect(PropertyBox, SIGNAL(activated(int)), SLOT(slotSetGraphStyle(int))); @@ -249,8 +249,8 @@ DiagramDialog::DiagramDialog(Diagram *d, QWidget *parent, Graph *currentGraph) Label4->setEnabled(false); yAxisBox = new QComboBox(); Box2Layout->addWidget(yAxisBox); - yAxisBox->insertItem(NameY); - yAxisBox->insertItem(NameZ); + yAxisBox->insertItem(0,NameY); + yAxisBox->insertItem(1,NameZ); yAxisBox->setEnabled(false); connect(yAxisBox, SIGNAL(activated(int)), SLOT(slotSetYAxis(int))); } @@ -327,59 +327,56 @@ DiagramDialog::DiagramDialog(Diagram *d, QWidget *parent, Graph *currentGraph) int Row = 0; if(Diag->Name.at(0) != 'T') { // not tabular or timing diagram QWidget *Tab2 = new QWidget(t); - QGridLayout *gp = new QGridLayout(Tab2,13,3,5,5); + QGridLayout *gp = new QGridLayout(Tab2); - gp->addMultiCellWidget(new QLabel(tr("x-Axis Label:"), Tab2), Row,Row,0,0); + gp->addWidget(new QLabel(tr("x-Axis Label:"), Tab2), Row,0); xLabel = new QLineEdit(Tab2); xLabel->setValidator(Validator); - gp->addMultiCellWidget(xLabel, Row,Row,1,2); + gp->addWidget(xLabel, Row,1); Row++; - gp->addMultiCellWidget( - new QLabel(NameY+" "+tr("Label:"), Tab2), Row,Row,0,0); + gp->addWidget(new QLabel(NameY+" "+tr("Label:"), Tab2), Row,0); ylLabel = new QLineEdit(Tab2); ylLabel->setValidator(Validator); - gp->addMultiCellWidget(ylLabel, Row,Row,1,2); + gp->addWidget(ylLabel, Row,1); Row++; if((Diag->Name != "Smith") && (Diag->Name != "Polar")) { - gp->addMultiCellWidget( - new QLabel(NameZ +" "+tr("Label:"), Tab2), Row,Row,0,0); + gp->addWidget(new QLabel(NameZ +" "+tr("Label:"), Tab2), Row,0); yrLabel = new QLineEdit(Tab2); yrLabel->setValidator(Validator); - gp->addMultiCellWidget(yrLabel, Row,Row,1,2); + gp->addWidget(yrLabel, Row,1); Row++; } - gp->addMultiCellWidget(new QLabel( + gp->addWidget(new QLabel( tr("Label text: Use LaTeX style for special characters, e.g. \\tau"), - Tab2), Row,Row,0,2); + Tab2), Row,0,1,2); Row++; if(Diag->Name != "Rect3D") { GridOn = new QCheckBox(tr("show Grid"), Tab2); - gp->addMultiCellWidget(GridOn, Row,Row,0,2); + gp->addWidget(GridOn, Row,0); Row++; GridLabel1 = new QLabel(tr("Grid Color:"),Tab2); - gp->addMultiCellWidget(GridLabel1, Row,Row,0,0); + gp->addWidget(GridLabel1, Row,0); GridColorButt = new QPushButton(" ",Tab2); connect(GridColorButt, SIGNAL(clicked()), SLOT(slotSetGridColor())); - gp->addMultiCellWidget(GridColorButt, Row,Row,1,2); + gp->addWidget(GridColorButt, Row,1); Row++; - GridColorButt->setPaletteBackgroundColor(Diag->GridPen.color()); - + GridColorButt->setStyleSheet(QString("QPushButton {color: %1};").arg(QString("#a0a0a4"))); GridLabel2 = new QLabel(tr("Grid Style: "), Tab2); - gp->addMultiCellWidget(GridLabel2, Row,Row,0,0); + gp->addWidget(GridLabel2, Row,0); GridStyleBox = new QComboBox(Tab2); - GridStyleBox->insertItem(tr("solid line")); - GridStyleBox->insertItem(tr("dash line")); - GridStyleBox->insertItem(tr("dot line")); - GridStyleBox->insertItem(tr("dash dot line")); - GridStyleBox->insertItem(tr("dash dot dot line")); - gp->addMultiCellWidget(GridStyleBox, Row,Row,1,2); + GridStyleBox->insertItem(0,tr("solid line")); + GridStyleBox->insertItem(1,tr("dash line")); + GridStyleBox->insertItem(2,tr("dot line")); + GridStyleBox->insertItem(3,tr("dash dot line")); + GridStyleBox->insertItem(4,tr("dash dot dot line")); + gp->addWidget(GridStyleBox, Row,1); Row++; - GridStyleBox->setCurrentItem(Diag->GridPen.style()-1); + GridStyleBox->setCurrentIndex(Diag->GridPen.style()-1); GridOn->setChecked(Diag->xAxis.GridOn); if(!Diag->xAxis.GridOn) slotSetGridBox(0); @@ -390,7 +387,6 @@ DiagramDialog::DiagramDialog(Diagram *d, QWidget *parent, Graph *currentGraph) GridColorButt = 0; GridStyleBox = 0; } - // ........................................................... xLabel->setText(Diag->xAxis.Label); ylLabel->setText(Diag->yAxis.Label); @@ -398,15 +394,15 @@ DiagramDialog::DiagramDialog(Diagram *d, QWidget *parent, Graph *currentGraph) if((Diag->Name.left(4) == "Rect") || (Diag->Name == "Curve")) { GridLogX = new QCheckBox(tr("logarithmical X Axis Grid"), Tab2); - gp->addMultiCellWidget(GridLogX, Row,Row,0,2); + gp->addWidget(GridLogX, Row,0); Row++; GridLogY = new QCheckBox(tr("logarithmical")+" "+NameY+" "+tr("Grid"), Tab2); - gp->addMultiCellWidget(GridLogY, Row,Row,0,2); + gp->addWidget(GridLogY, Row,0); Row++; GridLogZ = new QCheckBox(tr("logarithmical")+" "+NameZ+" "+tr("Grid"), Tab2); - gp->addMultiCellWidget(GridLogZ, Row,Row,0,2); + gp->addWidget(GridLogZ, Row,0); Row++; // ........................................................... @@ -418,53 +414,54 @@ DiagramDialog::DiagramDialog(Diagram *d, QWidget *parent, Graph *currentGraph) if(Diag->Name == "Rect3D") { hideInvisible = new QCheckBox(tr("hide invisible lines"), Tab2); - gp->addMultiCellWidget(hideInvisible, Row,Row,0,2); + gp->addWidget(hideInvisible,Row,0); Row++; QLabel *LabelRotX = new QLabel(tr("Rotation around x-Axis:"), Tab2); - LabelRotX->setPaletteForegroundColor(Qt::red); + LabelRotX->setStyleSheet(QString("QLabel {color: red};")); gp->addWidget(LabelRotX, Row,0); - SliderRotX = new QSlider(0,360,20, ((Rect3DDiagram*)Diag)->rotX, - Qt::Horizontal, Tab2); - gp->addWidget(SliderRotX, Row,1); + SliderRotX = new QSlider(Qt::Horizontal, Tab2); + SliderRotX->setMaximum(360); + gp->addWidget(SliderRotX, Row,1,1,3); connect(SliderRotX, SIGNAL(valueChanged(int)), SLOT(slotNewRotX(int))); rotationX = new QLineEdit(Tab2); rotationX->setValidator(ValInteger); rotationX->setMaxLength(3); rotationX->setMaximumWidth(40); - gp->addWidget(rotationX, Row,2); + gp->addWidget(rotationX, Row,4); connect(rotationX, SIGNAL(textChanged(const QString&)), SLOT(slotEditRotX(const QString&))); Row++; QLabel *LabelRotY = new QLabel(tr("Rotation around y-Axis:"), Tab2); - LabelRotY->setPaletteForegroundColor(Qt::green); + LabelRotY->setStyleSheet(QString("QLabel {color: green};")); gp->addWidget(LabelRotY, Row,0); - SliderRotY = new QSlider(0,360,20, ((Rect3DDiagram*)Diag)->rotY, - Qt::Horizontal, Tab2); - gp->addWidget(SliderRotY, Row,1); + SliderRotY =new QSlider(Qt::Horizontal, Tab2); + SliderRotY->setMaximum(360); + + gp->addWidget(SliderRotY, Row,1,1,3); connect(SliderRotY, SIGNAL(valueChanged(int)), SLOT(slotNewRotY(int))); rotationY = new QLineEdit(Tab2); rotationY->setValidator(ValInteger); rotationY->setMaxLength(3); rotationY->setMaximumWidth(40); - gp->addWidget(rotationY, Row,2); + gp->addWidget(rotationY, Row,4); connect(rotationY, SIGNAL(textChanged(const QString&)), SLOT(slotEditRotY(const QString&))); Row++; QLabel *LabelRotZ = new QLabel(tr("Rotation around z-Axis:"), Tab2); - LabelRotZ->setPaletteForegroundColor(Qt::blue); + LabelRotZ->setStyleSheet(QString("QLabel {color: blue};")); gp->addWidget(LabelRotZ, Row,0); - SliderRotZ = new QSlider(0,360,20, ((Rect3DDiagram*)Diag)->rotZ, - Qt::Horizontal, Tab2); - gp->addWidget(SliderRotZ, Row,1); + SliderRotZ = new QSlider(Qt::Horizontal, Tab2); + SliderRotZ->setMaximum(360); + gp->addWidget(SliderRotZ, Row,1,1,3); connect(SliderRotZ, SIGNAL(valueChanged(int)), SLOT(slotNewRotZ(int))); rotationZ = new QLineEdit(Tab2); rotationZ->setValidator(ValInteger); rotationZ->setMaxLength(3); rotationZ->setMaximumWidth(40); - gp->addWidget(rotationZ, Row,2); + gp->addWidget(rotationZ, Row,4); connect(rotationZ, SIGNAL(textChanged(const QString&)), SLOT(slotEditRotZ(const QString&))); Row++; @@ -590,7 +587,6 @@ DiagramDialog::DiagramDialog(Diagram *d, QWidget *parent, Graph *currentGraph) VBox9Layout->addWidget(manualZ); connect(manualZ, SIGNAL(stateChanged(int)), SLOT(slotManualZ(int))); VBox9->setLayout(VBox9Layout); - QWidget *VBox10 = new QWidget(); axisZLayout->addWidget(VBox10); QVBoxLayout *VBox10Layout = new QVBoxLayout(); @@ -684,18 +680,17 @@ DiagramDialog::DiagramDialog(Diagram *d, QWidget *parent, Graph *currentGraph) OkButt->setDefault(true); - // ........................................................... // put all data files into ComboBox QFileInfo Info(defaultDataSet); - QDir ProjDir(Info.dirPath()); - QStringList Elements = ProjDir.entryList("*.dat", QDir::Files, QDir::Name); + QDir ProjDir(Info.path()); + QStringList Elements = ProjDir.entryList(QStringList("*.dat"), QDir::Files, QDir::Name); QStringList::iterator it; for(it = Elements.begin(); it != Elements.end(); ++it) { - ChooseData->insertItem((*it).left((*it).length()-4)); + ChooseData->insertItem(ChooseData->count(), (*it).left((*it).length()-4)); if((*it) == Info.fileName()) // default dataset should be the current - ChooseData->setCurrentItem(ChooseData->count()-1); + ChooseData->setCurrentIndex(ChooseData->count()-1); } slotReadVars(0); // put variables into the ListView @@ -716,7 +711,6 @@ DiagramDialog::DiagramDialog(Diagram *d, QWidget *parent, Graph *currentGraph) QColor selectedColor(DefaultColors[GraphList->count()%NumDefaultColors]); QString stylesheet = QString("QPushButton {background-color: %1};").arg(selectedColor.name()); ColorButt->setStyleSheet(stylesheet); - ColorButt->setPaletteBackgroundColor(selectedColor); } } } @@ -734,8 +728,7 @@ void DiagramDialog::slotReadVars(int) { QFileInfo Info(defaultDataSet); QString DocName = ChooseData->currentText()+".dat"; - - QFile file(Info.dirPath() + QDir::separator() + DocName); + QFile file(Info.path() + QDir::separator() + DocName); if(!file.open(QIODevice::ReadOnly)) { return; } @@ -766,7 +759,7 @@ void DiagramDialog::slotReadVars(int) if(Line.left(3) == "dep") { tmp = Line.section(' ', 2); //new Q3ListViewItem(ChooseVars, Var, "dep", tmp.remove('>')); - qDebug() << varNumber << Var << tmp.remove('>'); + // qDebug() << varNumber << Var << tmp.remove('>'); ChooseVars->setRowCount(varNumber+1); QTableWidgetItem *cell = new QTableWidgetItem(Var); cell->setFlags(cell->flags() ^ Qt::ItemIsEditable); @@ -782,7 +775,7 @@ void DiagramDialog::slotReadVars(int) else if(Line.left(5) == "indep") { tmp = Line.section(' ', 2, 2); //new Q3ListViewItem(ChooseVars, Var, "indep", tmp.remove('>')); - qDebug() << varNumber << Var << tmp.remove('>'); + // qDebug() << varNumber << Var << tmp.remove('>'); ChooseVars->setRowCount(varNumber+1); QTableWidgetItem *cell = new QTableWidgetItem(Var); cell->setFlags(cell->flags() ^ Qt::ItemIsEditable); @@ -816,7 +809,7 @@ void DiagramDialog::slotTakeVar(QTableWidgetItem* Item) int row = Item->row(); QString s1 = ChooseVars->item(row, 0)->text(); QFileInfo Info(defaultDataSet); - if(ChooseData->currentText() != Info.baseName(true)) + if(ChooseData->currentText() != Info.baseName()) s1 = ChooseData->currentText() + ":" + s1; GraphInput->setText(s1); @@ -828,19 +821,18 @@ void DiagramDialog::slotTakeVar(QTableWidgetItem* Item) if(Diag->Name != "Tab") { if(Diag->Name != "Truth") { - g->Color = ColorButt->paletteBackgroundColor(); + g->Color = QColor(ColorButt->styleSheet().section(' ',2,2).mid(0,7)); g->Thick = Property2->text().toInt(); QColor selectedColor(DefaultColors[GraphList->count()%NumDefaultColors]); QString stylesheet = QString("QPushButton {background-color: %1};").arg(selectedColor.name()); ColorButt->setStyleSheet(stylesheet); - ColorButt->setPaletteBackgroundColor(selectedColor); if(g->Var.right(3) == ".Vb") // harmonic balance output ? if(PropertyBox->count() >= GRAPHSTYLE_ARROW) - PropertyBox->setCurrentItem(GRAPHSTYLE_ARROW); - g->Style = toGraphStyle(PropertyBox->currentItem()); + PropertyBox->setCurrentIndex(GRAPHSTYLE_ARROW); + g->Style = toGraphStyle(PropertyBox->currentIndex()); assert(g->Style!=GRAPHSTYLE_INVALID); if(yAxisBox) { - g->yAxisNo = yAxisBox->currentItem(); + g->yAxisNo = yAxisBox->currentIndex(); yAxisBox->setEnabled(true); Label4->setEnabled(true); } @@ -852,7 +844,7 @@ void DiagramDialog::slotTakeVar(QTableWidgetItem* Item) } else { g->Precision = Property2->text().toInt(); - g->numMode = PropertyBox->currentItem(); + g->numMode = PropertyBox->currentIndex(); } Graphs.append(g); @@ -897,10 +889,9 @@ void DiagramDialog::SelectGraph(Graph *g) Property2->setText(QString::number(g->Thick)); QString stylesheet = QString("QPushButton {background-color: %1};").arg(g->Color.name()); ColorButt->setStyleSheet(stylesheet); - ColorButt->setPaletteBackgroundColor(g->Color); - PropertyBox->setCurrentItem(g->Style); + PropertyBox->setCurrentIndex(g->Style); if(yAxisBox) { - yAxisBox->setCurrentItem(g->yAxisNo); + yAxisBox->setCurrentIndex(g->yAxisNo); yAxisBox->setEnabled(true); Label4->setEnabled(true); } @@ -911,7 +902,7 @@ void DiagramDialog::SelectGraph(Graph *g) } else { Property2->setText(QString::number(g->Precision)); - PropertyBox->setCurrentItem(g->numMode); + PropertyBox->setCurrentIndex(g->numMode); } toTake = false; @@ -951,10 +942,9 @@ void DiagramDialog::slotDeleteGraph() QColor selectedColor(DefaultColors[GraphList->count()%NumDefaultColors]); QString stylesheet = QString("QPushButton {background-color: %1};").arg(selectedColor.name()); ColorButt->setStyleSheet(stylesheet); - ColorButt->setPaletteBackgroundColor(selectedColor); Property2->setText("0"); if(yAxisBox) { - yAxisBox->setCurrentItem(0); + yAxisBox->setCurrentIndex(0); yAxisBox->setEnabled(false); Label4->setEnabled(false); } @@ -968,7 +958,7 @@ void DiagramDialog::slotDeleteGraph() toTake = false; if(Property2) { - PropertyBox->setCurrentItem(0); + PropertyBox->setCurrentIndex(0); Label1->setEnabled(false); PropertyBox->setEnabled(false); @@ -989,17 +979,17 @@ void DiagramDialog::slotNewGraph() // FIXME: call Diag->whateverelse(); if(Diag->Name != "Tab") { // BUG if(Diag->Name != "Truth") { // BUG - g->Color = ColorButt->paletteBackgroundColor(); + g->Color = QColor(ColorButt->styleSheet().section(' ',2,2).mid(0,7)); g->Thick = Property2->text().toInt(); - g->Style = toGraphStyle(PropertyBox->currentItem()); + g->Style = toGraphStyle(PropertyBox->currentIndex()); assert(g->Style!=GRAPHSTYLE_INVALID); - if(yAxisBox) g->yAxisNo = yAxisBox->currentItem(); + if(yAxisBox) g->yAxisNo = yAxisBox->currentIndex(); else if(Diag->Name == "Rect3D") g->yAxisNo = 1; } } else { g->Precision = Property2->text().toInt(); - g->numMode = PropertyBox->currentItem(); + g->numMode = PropertyBox->currentIndex(); } Graphs.append(g); changed = true; @@ -1009,7 +999,7 @@ void DiagramDialog::slotNewGraph() /*! Is called if "Ok" button is pressed. */ -void DiagramDialog::slotOK() +void DiagramDialog::slotOK() { slotApply(); slotCancel(); @@ -1041,14 +1031,19 @@ void DiagramDialog::slotApply() Diag->yAxis.GridOn = GridOn->isChecked(); changed = true; } + if(GridColorButt) - if(Diag->GridPen.color() != GridColorButt->paletteBackgroundColor()) { - Diag->GridPen.setColor(GridColorButt->paletteBackgroundColor()); - changed = true; + { + QColor GridColor = QColor(GridColorButt->styleSheet().section(' ',2,2).mid(0,7)); + if(Diag->GridPen.color() != GridColor) + { + Diag->GridPen.setColor(GridColor); + changed = true; + } } if(GridStyleBox) - if(Diag->GridPen.style()!=(Qt::PenStyle)(GridStyleBox->currentItem()+1)) { - Diag->GridPen.setStyle((Qt::PenStyle)(GridStyleBox->currentItem()+1)); + if(Diag->GridPen.style()!=(Qt::PenStyle)(GridStyleBox->currentIndex()+1)) { + Diag->GridPen.setStyle((Qt::PenStyle)(GridStyleBox->currentIndex()+1)); changed = true; } if((Diag->Name != "Smith") && (Diag->Name != "Polar")) { @@ -1136,7 +1131,6 @@ void DiagramDialog::slotApply() Diag->zAxis.limit_max = stopZ->text().toDouble(); changed = true; } - // for "rect3D" if(hideInvisible) if(((Rect3DDiagram*)Diag)->hideLines != hideInvisible->isChecked()) { @@ -1163,7 +1157,6 @@ 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()) @@ -1198,11 +1191,10 @@ void DiagramDialog::reject() // -------------------------------------------------------------------------- void DiagramDialog::slotSetColor() { - QColor c = QColorDialog::getColor(ColorButt->paletteBackgroundColor(),this); + QColor c = QColorDialog::getColor(QColor(ColorButt->styleSheet().section(' ',2,2).mid(0,7)),this); if(!c.isValid()) return; QString stylesheet = QString("QPushButton {background-color: %1};").arg(c.name()); ColorButt->setStyleSheet(stylesheet); - ColorButt->setPaletteBackgroundColor(c); int i = GraphList->currentRow(); if(i < 0) return; // return, if no item selected @@ -1216,10 +1208,9 @@ void DiagramDialog::slotSetColor() // -------------------------------------------------------------------------- void DiagramDialog::slotSetGridColor() { - QColor c = QColorDialog::getColor( - GridColorButt->paletteBackgroundColor(),this); + QColor c = QColorDialog::getColor(QColor(GridColorButt->styleSheet().section(' ',2,2).mid(0,7)),this); if(!c.isValid()) return; - GridColorButt->setPaletteBackgroundColor(c); + GridColorButt->setStyleSheet(QString("QPushButton {background-color: %1};").arg(c.name())); changed = true; } diff --git a/qucs/qucs/diagrams/marker.cpp b/qucs/qucs/diagrams/marker.cpp index c0733dc2a1..70e3c703ef 100644 --- a/qucs/qucs/diagrams/marker.cpp +++ b/qucs/qucs/diagrams/marker.cpp @@ -91,7 +91,7 @@ MarkerID = ID; createText(); } -int Marker::setDataset(QString dataset) +void Marker::setDataset(QString dataset) { DefaultDataset = dataset; } @@ -277,7 +277,7 @@ void Marker::createText() in.readLine();//Reads 3rd line } } - } + } double *pp; nVarPos = pGraph->numAxes(); DataX const *pD; diff --git a/qucs/qucs/diagrams/marker.h b/qucs/qucs/diagrams/marker.h index 441575fb1b..a12d0a27b4 100644 --- a/qucs/qucs/diagrams/marker.h +++ b/qucs/qucs/diagrams/marker.h @@ -42,7 +42,7 @@ class Marker : public Element { void initText(int); public: QString DefaultDataset; - int setDataset(QString dataset=""); + void setDataset(QString dataset=""); QString getDataset(void); void createText(); void makeInvalid(); diff --git a/qucs/qucs/diagrams/markerdialog.cpp b/qucs/qucs/diagrams/markerdialog.cpp index 6cca0662f9..c2ee7c47ad 100644 --- a/qucs/qucs/diagrams/markerdialog.cpp +++ b/qucs/qucs/diagrams/markerdialog.cpp @@ -27,7 +27,7 @@ MarkerDialog::MarkerDialog(Marker *pm_, QWidget *parent) - : QDialog(parent, 0, FALSE, Qt::WDestructiveClose) + : QDialog(parent, Qt::WDestructiveClose) { setWindowTitle(tr("Edit Marker Properties")); pMarker = pm_; @@ -42,10 +42,10 @@ MarkerDialog::MarkerDialog(Marker *pm_, QWidget *parent) g->addWidget(Precision, 0, 1); NumberBox = new QComboBox(); - NumberBox->insertItem(tr("real/imaginary")); - NumberBox->insertItem(tr("magnitude/angle (degree)")); - NumberBox->insertItem(tr("magnitude/angle (radian)")); - NumberBox->setCurrentItem(pMarker->numMode); + NumberBox->insertItem(0,tr("real/imaginary")); + NumberBox->insertItem(1, tr("magnitude/angle (degree)")); + NumberBox->insertItem(2, tr("magnitude/angle (radian)")); + NumberBox->setCurrentIndex(pMarker->numMode); g->addWidget(new QLabel(tr("Number Notation: ")), 1,0); g->addWidget(NumberBox, 1, 1); @@ -72,6 +72,9 @@ MarkerDialog::MarkerDialog(Marker *pm_, QWidget *parent) g->addWidget(new QLabel(tr("Color ")), 5,0); ColorButton = new QPushButton(""); + QColor c = pMarker->getColor(); + QString stylesheet = QString("QPushButton {background-color: %1};").arg(c.name()); + ColorButton->setStyleSheet(stylesheet); connect(ColorButton, SIGNAL(clicked()), SLOT(slotSetColor())); g->addWidget(ColorButton, 5, 1); @@ -113,7 +116,7 @@ MarkerDialog::MarkerDialog(Marker *pm_, QWidget *parent) b->setSpacing(9); b->addWidget(ButtOK); b->addWidget(ButtCancel); - g->addMultiCellLayout(b,9,9,0,1); + g->addLayout(b,9,0); this->setLayout(g); } @@ -122,6 +125,8 @@ MarkerDialog::~MarkerDialog() { } + +//This function returns the list of markers stored in the dataset. QStringList MarkerDialog::getSavedMarkers(QString DefaultDatasetPath) { QFile file(DefaultDatasetPath); @@ -133,20 +138,24 @@ QStringList MarkerDialog::getSavedMarkers(QString DefaultDatasetPath) QString line = in.readLine(); if (line.compare(line.mid(0, 7), QString("getID()))continue; - Markers.append(markerstr); + if (markerstr.compare(pMarker->getID())) Markers.append(markerstr); in.readLine();//Reads 2nd line in.readLine();//Reads 3rd line } Markers.removeDuplicates(); return Markers; } + +//This function opens a color picker window to choose the color of the marker void MarkerDialog::slotSetColor() { - QColor c = QColorDialog::getColor(ColorButton->paletteBackgroundColor(),this); + QColor c = QColorDialog::getColor(QColor(ColorButton->styleSheet().section(' ',2,2).mid(0,7)),this); if(c.isValid()) pMarker->setColor(c); + QString stylesheet = QString("QPushButton {background-color: %1};").arg(c.name()); + ColorButton->setStyleSheet(stylesheet); } +//Enables/Disables delta mode void MarkerDialog::slotDeltaMode() { (DeltaModeCheckBox->isChecked()) ? RefMarkerComboBox->setEnabled(true): RefMarkerComboBox->setEnabled(false); @@ -156,11 +165,10 @@ void MarkerDialog::slotDeltaMode() // ---------------------------------------------------------- void MarkerDialog::slotAcceptValues() { - bool changed = false; pMarker->setID(MarkerID->text());//Marker identifier pMarker->setLineWidth(MarkerLineWidth->text().toInt());//Marker line width property // Mode of operation: Normal (0) or Delta (1) - int MarkerMode; + if (DeltaModeCheckBox->isChecked()) { pMarker->setMode(1); @@ -176,7 +184,6 @@ void MarkerDialog::slotAcceptValues() int tmp = Precision->text().toInt(); if(tmp != pMarker->Precision) { pMarker->Precision = tmp; - changed = true; } assert(pMarker->diag()); if(pMarker->diag()->Name=="Smith") // BUG: need generic MarkerDialog. @@ -185,16 +192,13 @@ void MarkerDialog::slotAcceptValues() if(SrcImp != pMarker->Z0) { pMarker->Z0 = SrcImp; - changed = true; } } - if(NumberBox->currentItem() != pMarker->numMode) { - pMarker->numMode = NumberBox->currentItem(); - changed = true; + if(NumberBox->currentIndex() != pMarker->numMode) { + pMarker->numMode = NumberBox->currentIndex(); } if(TransBox->isChecked() != pMarker->transparent) { pMarker->transparent = TransBox->isChecked(); - changed = true; } pMarker->createText();