Skip to content

Commit

Permalink
Merge pull request #387 from ra3xdh/qt66
Browse files Browse the repository at this point in the history
fix qt6.6 deprecation
  • Loading branch information
ra3xdh authored Nov 28, 2023
2 parents 661dc82 + 8c3cd05 commit e58bc3e
Show file tree
Hide file tree
Showing 18 changed files with 77 additions and 70 deletions.
8 changes: 3 additions & 5 deletions qucs/components/component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,7 @@ int Component::analyseLine(const QString &Row, int numProps) {
return 1;
} else if (s == "Text") { // must be last in order to reuse "s" *********
if (!getIntegers(Row, &i1, &i2, &i3, 0, &i4)) return -1;
Color.setNamedColor(Row.section(' ', 4, 4));
Color=misc::ColorFromString(Row.section(' ', 4, 4));
if (!Color.isValid()) return -1;

s = Row.mid(Row.indexOf('"') + 1); // Text (can contain " !!!)
Expand Down Expand Up @@ -1372,8 +1372,7 @@ bool Component::getPen(const QString &s, QPen &Pen, int i) {
QString n;

n = s.section(' ', i, i); // color
QColor co;
co.setNamedColor(n);
QColor co = misc::ColorFromString(n);
Pen.setColor(co);
if (!Pen.color().isValid()) return false;

Expand All @@ -1396,8 +1395,7 @@ bool Component::getBrush(const QString &s, QBrush &Brush, int i) {
QString n;

n = s.section(' ', i, i); // fill color
QColor co;
co.setNamedColor(n);
QColor co = misc::ColorFromString(n);
Brush.setColor(co);
if (!Brush.color().isValid()) return false;

Expand Down
3 changes: 1 addition & 2 deletions qucs/diagrams/diagram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1322,8 +1322,7 @@ bool Diagram::load(const QString &Line, QTextStream *stream) {
hideLines = (c & 2) != 0;

n = s.section(' ', 6, 6); // color for GridPen
QColor co;
co.setNamedColor(n);
QColor co = misc::ColorFromString(n);
GridPen.setColor(co);
if (!GridPen.color().isValid()) return false;

Expand Down
3 changes: 2 additions & 1 deletion qucs/diagrams/graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* *
***************************************************************************/
#include "graph.h"
#include "misc.h"

#include <cstdlib>
#include <iostream>
Expand Down Expand Up @@ -123,7 +124,7 @@ bool Graph::load(const QString& _s)

QString n;
n = s.section(' ',1,1); // Color
Color.setNamedColor(n);
Color = misc::ColorFromString(n);
if(!Color.isValid()) return false;

n = s.section(' ',2,2); // Thick
Expand Down
4 changes: 2 additions & 2 deletions qucs/extsimkernels/abstractspicekernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1331,8 +1331,8 @@ void AbstractSpiceKernel::normalizeVarsNames(QStringList &var_list)
QString suffix;
if ((*it).startsWith('I')) suffix = ".Ib";
else suffix = ".Vb";
int idx = it->indexOf('(');
int cnt = it->count();
auto idx = it->indexOf('(');
auto cnt = it->size();
*it = it->right(cnt-idx-1);
it->remove(')');
*it += suffix;
Expand Down
46 changes: 23 additions & 23 deletions qucs/extsimkernels/qucs2spice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ namespace qucs2spice
QString convert_rcl(const QString& line);
QString convert_header(QString line);
QString convert_diode(QString line,bool xyce=false);
QString convert_jfet(QString line, bool xyce=false);
QString convert_jfet(const QString& line, bool xyce=false);
QString convert_mosfet(QString line, bool xyce=false);
QString convert_bjt(QString line);
QString convert_bjt(const QString& line);
QString convert_cccs(const QString& line);
QString convert_ccvs(const QString& line);
QString convert_ccs(const QString& line, bool voltage);
Expand Down Expand Up @@ -131,8 +131,8 @@ QString qucs2spice::convert_rcl(const QString& line)
s += " " + lst.takeFirst();
s += " " + lst.takeFirst() + " ";
s1 = lst.takeFirst().remove("\"");
int idx = s1.indexOf('=');
s += s1.right(s1.count()-idx-1);
auto idx = s1.indexOf('=');
s += s1.right(s1.size()-idx-1);
s += "\n";
return s;
}
Expand All @@ -153,8 +153,8 @@ QString qucs2spice::convert_diode(QString line,bool xyce)
QString s="";
QStringList lst = line.split(" ",qucs::SkipEmptyParts);
QString name = lst.takeFirst();
int idx = name.indexOf(':');
name = name.right(name.count()-idx-1); // name
auto idx = name.indexOf(':');
name = name.right(name.size()-idx-1); // name
QString K = lst.takeFirst();
QString A = lst.takeFirst();
s += QString("D%1 %2 %3 DMOD_%4 \n").arg(name).arg(A).arg(K).arg(name);
Expand All @@ -170,8 +170,8 @@ QString qucs2spice::convert_mosfet(QString line, bool xyce)
QString s="";
QStringList lst = line.split(" ",qucs::SkipEmptyParts);
QString name = lst.takeFirst();
int idx = name.indexOf(':');
name = name.right(name.count()-idx-1); // name
auto idx = name.indexOf(':');
name = name.right(name.size()-idx-1); // name
QString G = lst.takeFirst();
QString D = lst.takeFirst();
QString S = lst.takeFirst();
Expand Down Expand Up @@ -207,21 +207,21 @@ QString qucs2spice::convert_mosfet(QString line, bool xyce)
return s;
}

QString qucs2spice::convert_jfet(QString line, bool xyce)
QString qucs2spice::convert_jfet(const QString& line, bool xyce)
{
QString s="";
QStringList lst = line.split(" ",qucs::SkipEmptyParts);
QString name = lst.takeFirst();
int idx = name.indexOf(':');
name = name.right(name.count()-idx-1); // name
auto idx = name.indexOf(':');
name = name.right(name.size()-idx-1); // name
QString G = lst.takeFirst();
QString D = lst.takeFirst();
QString S = lst.takeFirst();
QString Typ = "NJF";
QStringList par_lst;
par_lst.clear();
for(int i=0;i<lst.count();i++) {
QString s1 = lst.at(i);
const QString& s1 = lst.at(i);
if (s1.startsWith("Type=\"nfet\"")) {
Typ = "NJF";
} else if (s1.startsWith("Type=\"pfet\"")) {
Expand All @@ -238,13 +238,13 @@ QString qucs2spice::convert_jfet(QString line, bool xyce)
return s;
}

QString qucs2spice::convert_bjt(QString line)
QString qucs2spice::convert_bjt(const QString& line)
{
QString s="";
QStringList lst = line.split(" ",qucs::SkipEmptyParts);
QString name = lst.takeFirst();
int idx = name.indexOf(':');
name = name.right(name.count()-idx-1); // name
auto idx = name.indexOf(':');
name = name.right(name.size()-idx-1); // name
QString B = lst.takeFirst();
QString C = lst.takeFirst();
QString E = lst.takeFirst();
Expand Down Expand Up @@ -293,16 +293,16 @@ QString qucs2spice::convert_ccs(const QString& line, bool voltage)
{
QStringList lst = line.split(" ",qucs::SkipEmptyParts);
QString name = lst.takeFirst();
int idx = name.indexOf(':');
name = name.right(name.count()-idx-1); // name
auto idx = name.indexOf(':');
name = name.right(name.size()-idx-1); // name

QString nod0 = lst.takeFirst();
QString nod1 = lst.takeFirst();
QString nod2 = lst.takeFirst();
QString nod3 = lst.takeFirst();
QString s1 = lst.takeFirst().remove("\"");
idx = s1.indexOf('=');
QString val = s1.right(s1.count()-idx-1);
QString val = s1.right(s1.size()-idx-1);
QString s;
if (voltage) s="H";
else s="F";
Expand All @@ -325,16 +325,16 @@ QString qucs2spice::convert_vcs(const QString& line,bool voltage)
{
QStringList lst = line.split(" ",qucs::SkipEmptyParts);
QString name = lst.takeFirst();
int idx = name.indexOf(':');
name = name.right(name.count()-idx-1); // name
auto idx = name.indexOf(':');
name = name.right(name.size()-idx-1); // name

QString nod0 = lst.takeFirst();
QString nod1 = lst.takeFirst();
QString nod2 = lst.takeFirst();
QString nod3 = lst.takeFirst();
QString s1 = lst.takeFirst().remove("\"");
idx = s1.indexOf('=');
QString val = s1.right(s1.count()-idx-1);
QString val = s1.right(s1.size()-idx-1);

QString s;
if (voltage) s="E";
Expand All @@ -352,8 +352,8 @@ QString qucs2spice::convert_dc_src(const QString& line)
s += " " + lst.takeFirst();
s += " " + lst.takeFirst() + " ";
s1 = lst.takeFirst().remove("\"");
int idx = s1.indexOf('=');
QString val = s1.right(s1.count()-idx-1);
auto idx = s1.indexOf('=');
QString val = s1.right(s1.size()-idx-1);
s += "DC " + val + "\n";
return s;
}
Expand Down
4 changes: 2 additions & 2 deletions qucs/extsimkernels/spicecompat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ void spicecompat::convertNodeNames(QStringList &tokens, QString &sim)
if ((it->endsWith(".Vt"))||(it->endsWith(".It"))) sim = "tran";
if ((it->endsWith(".V"))||(it->endsWith(".I"))) sim = "dc";
QString suffix = it->section('.',1,1);
int idx = it->indexOf('.');
int cnt = it->count();
auto idx = it->indexOf('.');
auto cnt = it->size();
it->chop(cnt-idx);
if (suffix.toUpper().startsWith("I"))
*it = QString("V%1#branch").arg(*it);
Expand Down
7 changes: 4 additions & 3 deletions qucs/imagewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,10 @@ void ImageWriter::getSelAreaWidthAndHeight(Schematic *sch, int &wsel, int &hsel,
int x1,y1,x2,y2;
pd->Bounding(x1,y1,x2,y2);
updateMinMax(xmin,xmax,ymin,ymax,x1,x2,y1,y2);

for (auto& pg: qAsConst(pd->Graphs)) {
for (auto& pm: qAsConst(pg->Markers)) {
auto const graphs = pd->Graphs;
for (auto& pg: graphs) {
auto const markers = pg->Markers;
for (auto& pm: markers) {
if (pm->isSelected) {
//int x1,y1,x2,y2;
pm->Bounding(x1,y1,x2,y2);
Expand Down
26 changes: 13 additions & 13 deletions qucs/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,19 @@ bool loadSettings()
if(settings.contains("LargeFontSize"))QucsSettings.largeFontSize=settings.value("LargeFontSize").toDouble(); // use toDouble() as it can interpret the string according to the current locale
if(settings.contains("maxUndo"))QucsSettings.maxUndo=settings.value("maxUndo").toInt();
if(settings.contains("NodeWiring"))QucsSettings.NodeWiring=settings.value("NodeWiring").toInt();
if(settings.contains("BGColor"))QucsSettings.BGColor.setNamedColor(settings.value("BGColor").toString());
if(settings.contains("BGColor"))QucsSettings.BGColor = misc::ColorFromString(settings.value("BGColor").toString());
if(settings.contains("Editor"))QucsSettings.Editor=settings.value("Editor").toString();
if(settings.contains("FileTypes"))QucsSettings.FileTypes=settings.value("FileTypes").toStringList();
if(settings.contains("Language"))QucsSettings.Language=settings.value("Language").toString();
if(settings.contains("Comment"))QucsSettings.Comment.setNamedColor(settings.value("Comment").toString());
if(settings.contains("String"))QucsSettings.String.setNamedColor(settings.value("String").toString());
if(settings.contains("Integer"))QucsSettings.Integer.setNamedColor(settings.value("Integer").toString());
if(settings.contains("Real"))QucsSettings.Real.setNamedColor(settings.value("Real").toString());
if(settings.contains("Character"))QucsSettings.Character.setNamedColor(settings.value("Character").toString());
if(settings.contains("Type"))QucsSettings.Type.setNamedColor(settings.value("Type").toString());
if(settings.contains("Attribute"))QucsSettings.Attribute.setNamedColor(settings.value("Attribute").toString());
if(settings.contains("Directive"))QucsSettings.Directive.setNamedColor(settings.value("Directive").toString());
if(settings.contains("Task"))QucsSettings.Task.setNamedColor(settings.value("Task").toString());
if(settings.contains("Comment"))QucsSettings.Comment=misc::ColorFromString(settings.value("Comment").toString());
if(settings.contains("String"))QucsSettings.String=misc::ColorFromString(settings.value("String").toString());
if(settings.contains("Integer"))QucsSettings.Integer=misc::ColorFromString(settings.value("Integer").toString());
if(settings.contains("Real"))QucsSettings.Real=misc::ColorFromString(settings.value("Real").toString());
if(settings.contains("Character"))QucsSettings.Character=misc::ColorFromString(settings.value("Character").toString());
if(settings.contains("Type"))QucsSettings.Type=misc::ColorFromString(settings.value("Type").toString());
if(settings.contains("Attribute"))QucsSettings.Attribute=misc::ColorFromString(settings.value("Attribute").toString());
if(settings.contains("Directive"))QucsSettings.Directive=misc::ColorFromString(settings.value("Directive").toString());
if(settings.contains("Task"))QucsSettings.Task=misc::ColorFromString(settings.value("Task").toString());

if (settings.contains("panelIconsTheme")) QucsSettings.panelIconsTheme = settings.value("panelIconsTheme").toInt();
else QucsSettings.panelIconsTheme = qucs::autoIcons;
Expand Down Expand Up @@ -823,8 +823,8 @@ int main(int argc, char *argv[])
QucsSettings.maxUndo = 20;
QucsSettings.NodeWiring = 0;

QApplication::setAttribute(Qt::AA_EnableHighDpiScaling,true);
#if QT_VERSION < 0x060000
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling,true);
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps,true);
#endif

Expand Down Expand Up @@ -955,7 +955,7 @@ int main(int argc, char *argv[])
QucsSettings.Task = Qt::darkRed;

QucsSettings.sysDefaultFont = QApplication::font();
a.setFont(QucsSettings.appFont);
QApplication::setFont(QucsSettings.appFont);

QTranslator tor( 0 );
QString lang = QucsSettings.Language;
Expand All @@ -965,7 +965,7 @@ int main(int argc, char *argv[])
// lang = QTextCodec::locale();
}
tor.load( QString("qucs_") + lang, QucsSettings.LangDir);
a.installTranslator( &tor );
QApplication::installTranslator( &tor );

// This seems to be necessary on a few system to make strtod()
// work properly !???!
Expand Down
12 changes: 12 additions & 0 deletions qucs/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,18 @@ QString misc::num2str(double Num)
return Str;
}

QColor misc::ColorFromString(const QString& color)
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
return QColor::fromString(color);
#else
QColor c;
c.setNamedColor(color);
return c;
#endif

}

// #########################################################################
void misc::convert2Unicode(QString& Text)
{
Expand Down
1 change: 1 addition & 0 deletions qucs/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ namespace misc {
QString StringNum (double, char form='g', int Precision=3);
void str2num (const QString&, double&, QString&, double&);
QString num2str (double);
QColor ColorFromString(const QString& color);
QString StringNiceNum(double);
void convert2Unicode(QString&);
void convert2ASCII(QString&);
Expand Down
4 changes: 2 additions & 2 deletions qucs/paintings/arrow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "arrow.h"
#include "arrowdialog.h"
#include "schematic.h"
#include "misc.h"
#include <cmath>

#include <QPolygon>
Expand Down Expand Up @@ -176,8 +177,7 @@ bool Arrow::load(const QString& s)
if(!ok) return false;

n = s.section(' ',7,7); // color
QColor co;
co.setNamedColor(n);
QColor co = misc::ColorFromString(n);
Pen.setColor(co);
if(!Pen.color().isValid()) return false;

Expand Down
5 changes: 2 additions & 3 deletions qucs/paintings/ellipse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ bool qucs::Ellipse::load(const QString& s)
if(!ok) return false;

n = s.section(' ',5,5); // color
QColor co;
co.setNamedColor(n);
QColor co = misc::ColorFromString(n);
Pen.setColor(co);
if(!Pen.color().isValid()) return false;

Expand All @@ -151,7 +150,7 @@ bool qucs::Ellipse::load(const QString& s)
if(!ok) return false;

n = s.section(' ',8,8); // fill color
co.setNamedColor(n);
co = misc::ColorFromString(n);
Brush.setColor(co);
if(!Brush.color().isValid()) return false;

Expand Down
3 changes: 1 addition & 2 deletions qucs/paintings/ellipsearc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ bool EllipseArc::load(const QString& s)
if(!ok) return false;

n = s.section(' ',7,7); // color
QColor co;
co.setNamedColor(n);
QColor co = misc::ColorFromString(n);
Pen.setColor(co);
if(!Pen.color().isValid()) return false;

Expand Down
3 changes: 1 addition & 2 deletions qucs/paintings/graphicline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ bool GraphicLine::load(const QString& s)
if(!ok) return false;

n = s.section(' ',5,5); // color
QColor co;
co.setNamedColor(n);
QColor co = misc::ColorFromString(n);
Pen.setColor(co);
if(!Pen.color().isValid()) return false;

Expand Down
2 changes: 1 addition & 1 deletion qucs/paintings/graphictext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ bool GraphicText::load(const QString& s)
if(!ok) return false;

n = s.section(' ',4,4); // Color
Color.setNamedColor(n);
Color = misc::ColorFromString(n);
if(!Color.isValid()) return false;

n = s.section(' ',5,5); // Angle
Expand Down
Loading

0 comments on commit e58bc3e

Please sign in to comment.