diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-30 00:15:53 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-30 00:15:53 +0000 |
commit | 0aaa8e3fc8f8a1481333b564f0922277c8d8ad59 (patch) | |
tree | b95c0ca86c4876dd139af376b9f4afd8917cf0cd /src/devices/base/device_group.cpp | |
parent | b79a2c28534cf09987eeeba3077fff9236df182a (diff) | |
download | piklab-0aaa8e3fc8f8a1481333b564f0922277c8d8ad59.tar.gz piklab-0aaa8e3fc8f8a1481333b564f0922277c8d8ad59.zip |
TQt4 port piklab
This enables compilation under both Qt3 and Qt4
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/piklab@1238822 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/devices/base/device_group.cpp')
-rw-r--r-- | src/devices/base/device_group.cpp | 192 |
1 files changed, 96 insertions, 96 deletions
diff --git a/src/devices/base/device_group.cpp b/src/devices/base/device_group.cpp index df230d1..4b9d75d 100644 --- a/src/devices/base/device_group.cpp +++ b/src/devices/base/device_group.cpp @@ -9,32 +9,32 @@ #include "device_group.h" #if !defined(NO_KDE) -# include <qpainter.h> +# include <tqpainter.h> # include <kglobal.h> -QColor Device::statusColor(Status status) +TQColor Device::statusColor(tqStatus status) { switch (status.type()) { - case Status::Future: return Qt::blue; - case Status::InProduction: return Qt::green; - case Status::Mature: - case Status::NotRecommended: return QColor("orange"); - case Status::EOL: return Qt::red; - case Status::Unknown: - case Status::Nb_Types: break; + case tqStatus::Future: return TQt::blue; + case tqStatus::InProduction: return TQt::green; + case tqStatus::Mature: + case tqStatus::NotRecommended: return TQColor("orange"); + case tqStatus::EOL: return TQt::red; + case tqStatus::Unknown: + case tqStatus::Nb_Types: break; } - return Qt::black; + return TQt::black; } -QString coloredString(const QString &text, QColor color) +TQString coloredString(const TQString &text, TQColor color) { - return QString("<font color=\"") + color.name() + "\">" + text + "</font>"; + return TQString("<font color=\"") + color.name() + "\">" + text + "</font>"; } -QString supportedString(bool supported) +TQString supportedString(bool supported) { return coloredString(supported ? i18n("Supported") : i18n("Unsupported"), - supported ? Qt::green : Qt::red); + supported ? TQt::green : TQt::red); } class Tick { @@ -44,27 +44,27 @@ public: s = KGlobal::locale()->formatNumber(value, 1); min = oValue; } - QString s; + TQString s; double min; }; -class TickMap : public QMap<double, Tick> +class TickMap : public TQMap<double, Tick> { public: TickMap() {} void add(double value, double oValue) { insert(value, Tick(value, oValue), false); - (*this)[value].min = QMIN((*this)[value].min, oValue); + (*this)[value].min = TQMIN((*this)[value].min, oValue); } }; -QPixmap drawGraph(const QValueVector<Device::RangeBox> &boxes) +TQPixmap drawGraph(const TQValueVector<Device::RangeBox> &boxes) { const uint w = 300, h = 200; - QPixmap pixmap(w, h); - pixmap.fill(Qt::white); - QPainter p(&pixmap); - QFontMetrics f(p.font()); + TQPixmap pixmap(w, h); + pixmap.fill(TQt::white); + TQPainter p(&pixmap); + TQFontMetrics f(p.font()); TickMap xTicks, yTicks; xTicks.add(0.0, 0.0); yTicks.add(0.0, 0.0); @@ -85,67 +85,67 @@ QPixmap drawGraph(const QValueVector<Device::RangeBox> &boxes) int yStart = h-1 - f.lineSpacing(); TickMap::const_iterator it = xTicks.begin(); for (; it!=xTicks.end(); ++it) { - xStart = QMAX(xStart, f.width(it.data().s)); - xMax = QMAX(xMax, it.key()); + xStart = TQMAX(xStart, f.width(it.data().s)); + xMax = TQMAX(xMax, it.key()); } for (it = yTicks.begin(); it!=yTicks.end(); ++it) - yMax = QMAX(yMax, it.key()); + yMax = TQMAX(yMax, it.key()); int xEnd = w-1 - f.width(xTicks[xMax].s)/2; - QRect rect = f.boundingRect(yTicks[yMax].s); + TQRect rect = f.boundingRect(yTicks[yMax].s); int yEnd = rect.height()/2; // draw boxes - p.setPen(Qt::lightGray); - p.setBrush(Qt::lightGray); + p.setPen(TQt::lightGray); + p.setBrush(TQt::lightGray); for (uint i=0; i<boxes.count(); i++) { double ax = double(xEnd - xStart)/xMax; double ay = double(yEnd - yStart)/yMax; - QPointArray pa(4); - pa.setPoint(0, qRound(ax*boxes[i].start.x), qRound(ay*boxes[i].start.yMin)); - pa.setPoint(1, qRound(ax*boxes[i].end.x), qRound(ay*boxes[i].end.yMin)); - pa.setPoint(2, qRound(ax*boxes[i].end.x), qRound(ay*boxes[i].end.yMax)); - pa.setPoint(3, qRound(ax*boxes[i].start.x), qRound(ay*boxes[i].start.yMax)); + TQPointArray pa(4); + pa.setPoint(0, tqRound(ax*boxes[i].start.x), tqRound(ay*boxes[i].start.yMin)); + pa.setPoint(1, tqRound(ax*boxes[i].end.x), tqRound(ay*boxes[i].end.yMin)); + pa.setPoint(2, tqRound(ax*boxes[i].end.x), tqRound(ay*boxes[i].end.yMax)); + pa.setPoint(3, tqRound(ax*boxes[i].start.x), tqRound(ay*boxes[i].start.yMax)); pa.translate(xStart, yStart); p.drawPolygon(pa); } // draw axis - p.setPen(Qt::black); + p.setPen(TQt::black); p.drawLine(xStart, yStart, w-1, yStart); p.drawLine(xStart, yStart, xStart, 0); // draw ticks and lines - p.setPen(Qt::DotLine); + p.setPen(TQt::DotLine); for (it = yTicks.begin(); it!=yTicks.end(); ++it) { - int y1 = yStart + qRound(it.key()*(yEnd-yStart)/yMax); - QRect rect = f.boundingRect(it.data().s); + int y1 = yStart + tqRound(it.key()*(yEnd-yStart)/yMax); + TQRect rect = f.boundingRect(it.data().s); p.drawText(xStart/2-rect.width()/2 , y1+rect.height()/2, it.data().s); - int xmin = xStart + qRound(it.data().min*(xEnd-xStart)/xMax); + int xmin = xStart + tqRound(it.data().min*(xEnd-xStart)/xMax); p.drawLine(xStart, y1, xmin, y1); } for (it = xTicks.begin(); it!=xTicks.end(); ++it) { - int x1 = xStart + qRound(it.key()*(xEnd-xStart)/xMax); - QRect rect = f.boundingRect(it.data().s); + int x1 = xStart + tqRound(it.key()*(xEnd-xStart)/xMax); + TQRect rect = f.boundingRect(it.data().s); p.drawText(x1-rect.width()/2, h-1, it.data().s); - int ymin = yStart + qRound(it.data().min*(yEnd-yStart)/yMax); + int ymin = yStart + tqRound(it.data().min*(yEnd-yStart)/yMax); p.drawLine(x1, yStart, x1, ymin); } return pixmap; } -QPixmap Device::vddGraph(const QString &xLabel, const QString &yLabel, - const QValueVector<Device::RangeBox> &boxes) +TQPixmap Device::vddGraph(const TQString &xLabel, const TQString &yLabel, + const TQValueVector<Device::RangeBox> &boxes) { uint sp = 10; - QPixmap graph = drawGraph(boxes); - QPainter p; - QFontMetrics f(p.font()); - QPixmap pixmap(graph.width() + sp + f.width(xLabel), graph.height() + sp + f.lineSpacing()); - pixmap.fill(Qt::white); + TQPixmap graph = drawGraph(boxes); + TQPainter p; + TQFontMetrics f(p.font()); + TQPixmap pixmap(graph.width() + sp + f.width(xLabel), graph.height() + sp + f.lineSpacing()); + pixmap.fill(TQt::white); copyBlt(&pixmap, 0, f.lineSpacing() + sp, &graph, 0, 0, graph.width(), graph.height()); p.begin(&pixmap); - p.setPen(Qt::black); + p.setPen(TQt::black); p.drawText(0, f.lineSpacing(), yLabel); p.drawText(pixmap.width()-1-f.width(xLabel), pixmap.height()-1, xLabel); return pixmap; @@ -159,31 +159,31 @@ const Device::Package *Device::barPackage(const char *name, const Device::Data & return 0; } -QPixmap Device::pinsGraph(const Device::Package &package) +TQPixmap Device::pinsGraph(const Device::Package &package) { - QPixmap pixmap; - QPainter p; - QFontMetrics fm(p.font()); + TQPixmap pixmap; + TQPainter p; + TQFontMetrics fm(p.font()); uint nb = package.pins.count(); const int hspacing = 3, wspacing = 3, wmark = 10, wpin = 4; int theight = fm.ascent() + (fm.ascent()%2==0 ? 1 : 0); int height = hspacing + (nb/2)*(hspacing + theight); int wnumber = fm.width("1"); - wnumber = QMAX(wnumber, fm.width(QString::number(nb/2))); - wnumber = QMAX(wnumber, fm.width(QString::number(nb/2+1))); - wnumber = QMAX(wnumber, fm.width(QString::number(nb))); + wnumber = TQMAX(wnumber, fm.width(TQString::number(nb/2))); + wnumber = TQMAX(wnumber, fm.width(TQString::number(nb/2+1))); + wnumber = TQMAX(wnumber, fm.width(TQString::number(nb))); int bwidth = 4*wspacing + 2*wnumber + wmark; int lwidth = 0, rwidth = 0; for (uint k=0; k<nb/2; k++) { - lwidth = QMAX(lwidth, fm.width(package.pins[k])); - rwidth = QMAX(rwidth, fm.width(package.pins[nb-k-1])); + lwidth = TQMAX(lwidth, fm.width(package.pins[k])); + rwidth = TQMAX(rwidth, fm.width(package.pins[nb-k-1])); } int bx = lwidth + wspacing + wpin; int width = bx + bwidth + wpin + wspacing + rwidth; pixmap.resize(width, height); - pixmap.fill(Qt::white); + pixmap.fill(TQt::white); p.begin(&pixmap); - p.setPen(QPen(Qt::black, 2)); + p.setPen(TQPen(TQt::black, 2)); p.drawRect(bx, 1, bwidth, height-1); p.drawArc(bx+wspacing+wnumber+wspacing, -wmark/2+2, wmark, wmark, 0, -180*16); for (uint k=0; k<nb/2; k++) { @@ -191,13 +191,13 @@ QPixmap Device::pinsGraph(const Device::Package &package) p.drawLine(bx-wpin-1, h, bx, h); p.drawLine(bx+bwidth, h, bx+bwidth+wpin, h); h += theight/2; - QString label = package.pins[k]; + TQString label = package.pins[k]; p.drawText(bx-wpin-wspacing-fm.width(label), h, label); p.drawText(bx+bwidth+wpin+wspacing, h, package.pins[nb-k-1]); uint pin = (k+1); if ( pin==1 || pin==(nb/2) ) { - p.drawText(bx+wspacing, h, QString::number(pin)); - label = QString::number(nb-k); + p.drawText(bx+wspacing, h, TQString::number(pin)); + label = TQString::number(nb-k); p.drawText(bx+bwidth-wspacing-fm.width(label), h, label); } } @@ -205,9 +205,9 @@ QPixmap Device::pinsGraph(const Device::Package &package) return pixmap; } -QString Device::htmlInfo(const Device::Data &data, const QString &deviceHref, const QString &documentHtml) +TQString Device::htmlInfo(const Device::Data &data, const TQString &deviceHref, const TQString &documentHtml) { - QString doc; + TQString doc; // title doc += "<h1>"; @@ -224,16 +224,16 @@ QString Device::htmlInfo(const Device::Data &data, const QString &deviceHref, co doc += "</h1>"; doc += "<table>"; - QString status = coloredString(data.status().label(), statusColor(data.status())); - doc += htmlTableRow(i18n("Status"), status); + TQString status = coloredString(data.status().label(), statusColor(data.status())); + doc += htmlTableRow(i18n("tqStatus"), status); if ( data.alternatives().count() ) { - QString s; + TQString s; for (uint i=0; i<data.alternatives().count(); i++) { if ( i!=0 ) s += ", "; if ( deviceHref.isEmpty() ) s += data.alternatives()[i].upper(); else { - QString href = deviceHref.arg(data.alternatives()[i].upper()); - s += QString("<a href=\"%1\">%2</a>").arg(href).arg(data.alternatives()[i].upper()); + TQString href = deviceHref.tqarg(data.alternatives()[i].upper()); + s += TQString("<a href=\"%1\">%2</a>").tqarg(href).tqarg(data.alternatives()[i].upper()); } } doc += htmlTableRow(i18n("Alternatives"), s); @@ -244,36 +244,36 @@ QString Device::htmlInfo(const Device::Data &data, const QString &deviceHref, co doc += "<hr />"; doc += "<table>"; doc += data.group().informationHtml(data); - QString s; + TQString s; for (uint i=0; i<data.packages().count(); i++) for (uint k=0; k<data.packages()[i].types.count(); k++) - s += i18n(Package::TYPE_DATA[data.packages()[i].types[k]].label) + QString("[%1] ").arg(data.packages()[i].pins.count()); + s += i18n(Package::TYPE_DATA[data.packages()[i].types[k]].label) + TQString("[%1] ").tqarg(data.packages()[i].pins.count()); doc += htmlTableRow(i18n("Packaging"), s); doc += "</table>"; return doc; } -QString Device::htmlPinDiagrams(const Device::Data &data, const QString &imagePrefix, QMimeSourceFactory *msf) +TQString Device::htmlPinDiagrams(const Device::Data &data, const TQString &imagePrefix, TQMimeSourceFactory *msf) { - QString doc; + TQString doc; // pins const Package *package = 0; for (uint i=0; Package::TYPE_DATA[i].name; i++) { - if ( Package::TYPE_DATA[i].shape!=Package::Bar ) continue; + if ( Package::TYPE_DATA[i].tqshape!=Package::Bar ) continue; package = barPackage(Package::TYPE_DATA[i].name, data); if (package) break; } if (package) { - QPixmap pix = pinsGraph(*package); + TQPixmap pix = pinsGraph(*package); doc += "<table cellpadding=\"3\"><tr bgcolor=\"gray\"><th align=\"center\">"; for (uint k=0; k<package->types.count(); k++) { if ( k!=0 ) doc += " "; doc += i18n(Package::TYPE_DATA[package->types[k]].label); - doc += "(" + QString::number(package->pins.count()) + ")"; + doc += "(" + TQString::number(package->pins.count()) + ")"; } doc += "</th></tr><tr><td align=\"center\">"; - QString label = data.name() + "_pins_graph.png"; + TQString label = data.name() + "_pins_graph.png"; doc += "<img src=\"" + imagePrefix + label + "\" />"; if (msf) msf->setPixmap(label, pix); doc += "</td></tr></table>"; @@ -281,15 +281,15 @@ QString Device::htmlPinDiagrams(const Device::Data &data, const QString &imagePr return doc; } -QString Device::htmlVoltageFrequencyGraphs(const Device::Data &data, const QString &imagePrefix, QMimeSourceFactory *msf) +TQString Device::htmlVoltageFrequencyGraphs(const Device::Data &data, const TQString &imagePrefix, TQMimeSourceFactory *msf) { - QString doc; + TQString doc; FOR_EACH(Special, special) { for (uint k=0; k<data.frequencyRanges().count(); k++) { const Device::FrequencyRange &fr = data.frequencyRanges()[k]; if ( fr.special!=special ) continue; doc += "<h3>" + data.fname(special) + " - " + i18n("Temperature range: ") + fr.operatingCondition.label() + "</h3>"; - QString label = data.name() + "_" + data.fname(special) + "_" + TQString label = data.name() + "_" + data.fname(special) + "_" + fr.operatingCondition.key() + ".png"; doc += "<img src=\"" + imagePrefix + label + "\" />"; if (msf) msf->setPixmap(label, Device::vddGraph(i18n("F (MHz)"), i18n("Vdd (V)"), fr.vdds)); @@ -298,18 +298,18 @@ QString Device::htmlVoltageFrequencyGraphs(const Device::Data &data, const QStri return doc; } -QPixmap Device::memoryGraph(const QValueList<MemoryGraphData> &r) +TQPixmap Device::memoryGraph(const TQValueList<MemoryGraphData> &r) { - QValueList<MemoryGraphData> ranges = r; - QPixmap pixmap; - QPainter p; - QFontMetrics fm(p.font()); + TQValueList<MemoryGraphData> ranges = r; + TQPixmap pixmap; + TQPainter p; + TQFontMetrics fm(p.font()); // order qHeapSort(ranges); // add empty ranges - QValueList<MemoryGraphData>::iterator it; + TQValueList<MemoryGraphData>::iterator it; for (it=ranges.begin(); it!=ranges.end(); ) { - QValueList<MemoryGraphData>::iterator prev = it; + TQValueList<MemoryGraphData>::iterator prev = it; ++it; if ( it==ranges.end() ) break; if ( (*prev).endAddress+1==(*it).startAddress ) continue; @@ -324,9 +324,9 @@ QPixmap Device::memoryGraph(const QValueList<MemoryGraphData> &r) int height = 1; int w1 = 0, w2 = 0; for (it=ranges.begin(); it!=ranges.end(); ++it) { - w1 = QMAX(w1, fm.width((*it).start)); - w1 = QMAX(w1, fm.width((*it).end)); - w2 = QMAX(w2, fm.width((*it).label)); + w1 = TQMAX(w1, fm.width((*it).start)); + w1 = TQMAX(w1, fm.width((*it).end)); + w2 = TQMAX(w2, fm.width((*it).label)); (*it).height = 2*hspacing + theight; if ( (*it).startAddress!=(*it).endAddress ) (*it).height += 2*theight; height += (*it).height; @@ -334,15 +334,15 @@ QPixmap Device::memoryGraph(const QValueList<MemoryGraphData> &r) int wspacing = 4; int width = wspacing + w1 + wspacing + wspacing + w2; pixmap.resize(width, height); - pixmap.fill(Qt::white); + pixmap.fill(TQt::white); p.begin(&pixmap); int h = 0; // draw ranges for (it=ranges.begin(); it!=ranges.end(); ++it) { - p.setPen(QPen(Qt::black, 1, Qt::DotLine)); + p.setPen(TQPen(TQt::black, 1, TQt::DotLine)); p.drawLine(0,h, width-1,h); - p.setPen(QPen(Qt::black, 1)); - p.setBrush((*it).label.isEmpty() ? Qt::gray : Qt::white); + p.setPen(TQPen(TQt::black, 1)); + p.setBrush((*it).label.isEmpty() ? TQt::gray : TQt::white); p.drawRect(0,h, wspacing+w1+wspacing,(*it).height+1); int hmid = h+(*it).height/2+theight/2; p.drawText(wspacing+w1+wspacing+wspacing,hmid, (*it).label); @@ -352,7 +352,7 @@ QPixmap Device::memoryGraph(const QValueList<MemoryGraphData> &r) p.drawText(wspacing,h+(*it).height-3, (*it).end); } h += (*it).height; - p.setPen(QPen(Qt::black, 1, Qt::DotLine)); + p.setPen(TQPen(TQt::black, 1, TQt::DotLine)); p.drawLine(0,h, width-1,h); } p.end(); |