From 0aaa8e3fc8f8a1481333b564f0922277c8d8ad59 Mon Sep 17 00:00:00 2001 From: tpearson Date: Thu, 30 Jun 2011 00:15:53 +0000 Subject: 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 --- src/devices/base/device_group.cpp | 192 +++++++++++++++++++------------------- 1 file changed, 96 insertions(+), 96 deletions(-) (limited to 'src/devices/base/device_group.cpp') 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 +# include # include -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("" + text + ""; + return TQString("" + text + ""; } -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 +class TickMap : public TQMap { 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 &boxes) +TQPixmap drawGraph(const TQValueVector &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 &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) +TQPixmap Device::vddGraph(const TQString &xLabel, const TQString &yLabel, + const TQValueVector &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%2").arg(href).arg(data.alternatives()[i].upper()); + TQString href = deviceHref.tqarg(data.alternatives()[i].upper()); + s += TQString("%2").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 += "
"; doc += ""; doc += data.group().informationHtml(data); - QString s; + TQString s; for (uint i=0; i
"; for (uint k=0; ktypes.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 += "
"; - QString label = data.name() + "_pins_graph.png"; + TQString label = data.name() + "_pins_graph.png"; doc += ""; if (msf) msf->setPixmap(label, pix); doc += "
"; @@ -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"; - QString label = data.name() + "_" + data.fname(special) + "_" + TQString label = data.name() + "_" + data.fname(special) + "_" + fr.operatingCondition.key() + ".png"; doc += ""; 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 &r) +TQPixmap Device::memoryGraph(const TQValueList &r) { - QValueList ranges = r; - QPixmap pixmap; - QPainter p; - QFontMetrics fm(p.font()); + TQValueList ranges = r; + TQPixmap pixmap; + TQPainter p; + TQFontMetrics fm(p.font()); // order qHeapSort(ranges); // add empty ranges - QValueList::iterator it; + TQValueList::iterator it; for (it=ranges.begin(); it!=ranges.end(); ) { - QValueList::iterator prev = it; + TQValueList::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 &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 &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 &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(); -- cgit v1.2.1