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/progs/psp/base/psp.cpp | 48 +++++++++++++++++++-------------------- src/progs/psp/base/psp.h | 6 ++--- src/progs/psp/base/psp_data.h | 6 ++--- src/progs/psp/base/psp_prog.h | 7 +++--- src/progs/psp/base/psp_serial.cpp | 20 ++++++++-------- src/progs/psp/base/psp_serial.h | 8 +++---- 6 files changed, 48 insertions(+), 47 deletions(-) (limited to 'src/progs/psp/base') diff --git a/src/progs/psp/base/psp.cpp b/src/progs/psp/base/psp.cpp index 1b76bf5..188fbcb 100644 --- a/src/progs/psp/base/psp.cpp +++ b/src/progs/psp/base/psp.cpp @@ -13,9 +13,9 @@ #include "common/common/misc.h" //----------------------------------------------------------------------------- -QMemArray Psp::createConfigInfo(const Pic::Data &data) +TQMemArray Psp::createConfigInfo(const Pic::Data &data) { - QMemArray array(33); + TQMemArray array(33); array.fill(0x00); const Pic::Config &config = data.config(); @@ -35,10 +35,10 @@ QMemArray Psp::createConfigInfo(const Pic::Data &data) return array; } -QMemArray Psp::createDeviceInfo(const Pic::Data &data) +TQMemArray Psp::createDeviceInfo(const Pic::Data &data) { - QMemArray config = createConfigInfo(data); - QMemArray array(45); + TQMemArray config = createConfigInfo(data); + TQMemArray array(45); array.fill(0x00); // memory code length @@ -46,7 +46,7 @@ QMemArray Psp::createDeviceInfo(const Pic::Data &data) array[0] = v.byte(1); array[1] = v.byte(0); // address word width - v = data.mask(Pic::MemoryRangeType::Code); + v = data.tqmask(Pic::MemoryRangeType::Code); array[2] = v.byte(1); array[3] = v.byte(0); // data word width @@ -59,12 +59,12 @@ QMemArray Psp::createDeviceInfo(const Pic::Data &data) if ( data.nbBytesWord(Pic::MemoryRangeType::UserId)==1 ) v += v << 8; array[6] = v.byte(1); array[7] = v.byte(0); - // user id mask + // user id tqmask array[8] = v.byte(1); array[9] = v.byte(0); } - // memory config mask + // memory config tqmask array[10] = config[0]; array[11] = config[1]; array[12] = config[16]; @@ -72,20 +72,20 @@ QMemArray Psp::createDeviceInfo(const Pic::Data &data) if ( data.isReadable(Pic::MemoryRangeType::Eeprom) ) { // memory eeprom width - v = data.mask(Pic::MemoryRangeType::Eeprom); + v = data.tqmask(Pic::MemoryRangeType::Eeprom); array[14] = v.byte(1); array[15] = v.byte(0); - // memory eeprom mask + // memory eeprom tqmask array[16] = v.byte(1); array[17] = v.byte(0); } if ( data.isReadable(Pic::MemoryRangeType::Cal) ) { // memory calibration width - v = data.mask(Pic::MemoryRangeType::Cal); + v = data.tqmask(Pic::MemoryRangeType::Cal); array[18] = v.byte(1); array[19] = v.byte(0); - // memory calibration mask + // memory calibration tqmask array[20] = v.byte(1); array[21] = v.byte(0); } @@ -159,8 +159,8 @@ QMemArray Psp::createDeviceInfo(const Pic::Data &data) } //----------------------------------------------------------------------------- -Psp::Hardware::Hardware(::Programmer::Base &base, const QString &portDevice) - : Programmer::PicHardware(base, new SerialPort(portDevice, base), QString::null) +Psp::Hardware::Hardware(::Programmer::Base &base, const TQString &portDevice) + : Programmer::PicHardware(base, new SerialPort(portDevice, base), TQString()) {} bool Psp::Hardware::internalConnectHardware() @@ -168,7 +168,7 @@ bool Psp::Hardware::internalConnectHardware() if ( !port()->open() ) return false; if ( !port()->reset() ) return false; // #### TODO: detect Warp13 or JuPic - QMemArray a; + TQMemArray a; if ( !port()->command(0x88, 1, a) ) return false; if ( a[0]!=0xAB ) { log(Log::LineType::Error, i18n("Wrong programmer connected")); @@ -179,13 +179,13 @@ bool Psp::Hardware::internalConnectHardware() bool Psp::Hardware::getFirmwareVersion(VersionData &version) { - QMemArray a1; + TQMemArray a1; if ( !port()->commandAck(0x8D, 2, &a1) ) return false; if ( a1[1]==0xFF ) { log(Log::LineType::Warning, i18n("Invalid firmware version")); version = VersionData(0xFF, 0, 0); } else { - QMemArray a2; + TQMemArray a2; if ( !port()->receive(2, a2) ) return false; version = VersionData(a1[1], a2[0], a2[1]); } @@ -197,7 +197,7 @@ bool Psp::Hardware::setTarget() log(Log::DebugLevel::Max, "set target"); // load device info if ( !port()->commandAck(0x81) ) return false; - QMemArray a = createDeviceInfo(device()); + TQMemArray a = createDeviceInfo(device()); if ( !port()->send(a) ) return false; if ( !port()->receiveEnd() ) return false; @@ -212,7 +212,7 @@ bool Psp::Hardware::setTarget() bool Psp::Hardware::setRange(uint start, uint size) { - QMemArray a(6); + TQMemArray a(6); a[0] = 0x8E; a[1] = start >> 16; a[2] = (start >> 8) & 0xFF; @@ -220,7 +220,7 @@ bool Psp::Hardware::setRange(uint start, uint size) a[4] = size >> 8; a[5] = size & 0xFF; if ( !port()->send(a) ) return false; - QMemArray r; + TQMemArray r; if ( !port()->receive(6, r) ) return false; for (uint i=0; i<6; i++) { if ( r[i]!=a[i] ) { @@ -269,7 +269,7 @@ char Psp::Hardware::writeCommand(Pic::MemoryRangeType type) bool Psp::Hardware::readMemory(Pic::MemoryRangeType type, Device::Array &data, const ::Programmer::VerifyData *vdata) { - QMemArray a; + TQMemArray a; uint nbWords = device().nbWords(type); data.resize(nbWords); uint nbBytes = nbWords * device().nbBytesWord(type); @@ -281,8 +281,8 @@ bool Psp::Hardware::readMemory(Pic::MemoryRangeType type, Device::Array &data, c for (uint i=0; ireceive(2, a) ) return false; data[i] = (a[0] << 8) + a[1]; -// log(Log::DebugLevel::Max, QString("code data %1: %2 (%3, %4)").arg(i).arg(toHexLabel(data[i], 4)) -// .arg(toHexLabel(a[0], 2)).arg(toHexLabel(a[1], 2))); +// log(Log::DebugLevel::Max, TQString("code data %1: %2 (%3, %4)").tqarg(i).tqarg(toHexLabel(data[i], 4)) +// .tqarg(toHexLabel(a[0], 2)).tqarg(toHexLabel(a[1], 2))); } if ( !port()->receiveEnd() ) return false; break; @@ -336,7 +336,7 @@ bool Psp::Hardware::writeMemory(Pic::MemoryRangeType type, const Device::Array & bool Psp::Hardware::eraseAll() { - QMemArray a; + TQMemArray a; if ( !port()->commandAck(0x8F, 2, &a) ) return false; if ( a[1]!=0x00 ) { log(Log::LineType::Error, i18n("Erase failed")); diff --git a/src/progs/psp/base/psp.h b/src/progs/psp/base/psp.h index ad4a160..087b1aa 100644 --- a/src/progs/psp/base/psp.h +++ b/src/progs/psp/base/psp.h @@ -16,14 +16,14 @@ namespace Psp { - extern QMemArray createConfigInfo(const Pic::Data &data); - extern QMemArray createDeviceInfo(const Pic::Data &data); + extern TQMemArray createConfigInfo(const Pic::Data &data); + extern TQMemArray createDeviceInfo(const Pic::Data &data); //----------------------------------------------------------------------------- class Hardware : public Programmer::PicHardware { public: - Hardware(::Programmer::Base &base, const QString &portDevice); + Hardware(::Programmer::Base &base, const TQString &portDevice); SerialPort *port() { return static_cast(_port); } virtual bool uploadFirmware(const Pic::Memory &) { return false; } virtual bool setTarget(); diff --git a/src/progs/psp/base/psp_data.h b/src/progs/psp/base/psp_data.h index c643961..509ee71 100644 --- a/src/progs/psp/base/psp_data.h +++ b/src/progs/psp/base/psp_data.h @@ -9,15 +9,15 @@ #ifndef PSP_DATA_H #define PSP_DATA_H -#include +#include namespace Psp { struct Data { uint algorithm, overprogram, tries; }; - extern bool isSupported(const QString &device); - extern const Data &data(const QString &device); + extern bool isSupported(const TQString &device); + extern const Data &data(const TQString &device); } // namespace #endif diff --git a/src/progs/psp/base/psp_prog.h b/src/progs/psp/base/psp_prog.h index ef525cd..02d0c68 100644 --- a/src/progs/psp/base/psp_prog.h +++ b/src/progs/psp/base/psp_prog.h @@ -18,6 +18,7 @@ namespace Psp class Base : public Programmer::PicBase { Q_OBJECT + TQ_OBJECT public: Base(const Programmer::Group &group, const Pic::Data *data) : Programmer::PicBase(group, data, "psp_programmer_base") {} @@ -33,9 +34,9 @@ protected: class Group : public ::Programmer::PicGroup { public: - virtual QString name() const { return "psp"; } - virtual QString label() const { return i18n("Picstart Plus"); } - virtual QString xmlName() const { return "psp"; } + virtual TQString name() const { return "psp"; } + virtual TQString label() const { return i18n("Picstart Plus"); } + virtual TQString xmlName() const { return "psp"; } virtual ::Programmer::Properties properties() const; virtual ::Programmer::TargetPowerMode targetPowerMode() const { return ::Programmer::TargetExternallyPowered; } virtual bool isPortSupported(PortType type) const { return ( type==PortType::Serial ); } diff --git a/src/progs/psp/base/psp_serial.cpp b/src/progs/psp/base/psp_serial.cpp index 964d604..7da4c00 100644 --- a/src/progs/psp/base/psp_serial.cpp +++ b/src/progs/psp/base/psp_serial.cpp @@ -14,7 +14,7 @@ #include "common/common/number.h" //----------------------------------------------------------------------------- -Psp::SerialPort::SerialPort(const QString &device, Log::Base &log) +Psp::SerialPort::SerialPort(const TQString &device, Log::Base &log) : Port::Serial(device, NeedFlush, log) {} @@ -46,9 +46,9 @@ bool Psp::SerialPort::reset() return flush(0); } -bool Psp::SerialPort::command(uchar c, uint nbBytes, QMemArray &a) +bool Psp::SerialPort::command(uchar c, uint nbBytes, TQMemArray &a) { - log(Log::DebugLevel::Extra, QString("Command %1").arg(toHexLabel(c, 2))); + log(Log::DebugLevel::Extra, TQString("Command %1").tqarg(toHexLabel(c, 2))); if ( !sendChar(c) ) return false; return receive(nbBytes, a); } @@ -57,7 +57,7 @@ bool Psp::SerialPort::checkAck(uchar ec, uchar rc) { if ( ec==rc ) return true; log(Log::LineType::Error, i18n("Incorrect ack: expecting %1, received %2") - .arg(QString(toHex(ec, 2))).arg(QString(toHex(rc, 2)))); + .tqarg(TQString(toHex(ec, 2))).tqarg(TQString(toHex(rc, 2)))); return false; } @@ -65,14 +65,14 @@ bool Psp::SerialPort::checkEnd(uchar c) { if ( c==0 ) return true; log(Log::LineType::Error, i18n("Incorrect received data end: expecting 00, received %1") - .arg(QString(toHex(c, 2)))); + .tqarg(TQString(toHex(c, 2)))); return false; } -bool Psp::SerialPort::commandAck(uchar c, uint nbBytes, QMemArray *a) +bool Psp::SerialPort::commandAck(uchar c, uint nbBytes, TQMemArray *a) { Q_ASSERT( nbBytes>=1 ); - QMemArray tmp; + TQMemArray tmp; if ( !command(c, nbBytes, tmp) ) return false; if ( !checkAck(c, tmp[0]) ) return false; if (a) *a = tmp; @@ -81,13 +81,13 @@ bool Psp::SerialPort::commandAck(uchar c, uint nbBytes, QMemArray *a) bool Psp::SerialPort::receiveEnd() { - QMemArray a; + TQMemArray a; if ( !receive(1, a) ) return false; if ( !checkEnd(a[0]) ) return false; return true; } -bool Psp::SerialPort::commandAckEnd(uchar c, uint nbBytes, QMemArray &a) +bool Psp::SerialPort::commandAckEnd(uchar c, uint nbBytes, TQMemArray &a) { Q_ASSERT( nbBytes>=2 ); if ( !command(c, nbBytes, a) ) return false; @@ -100,7 +100,7 @@ bool Psp::SerialPort::sendData(uint value, uint nbBytes) { Q_ASSERT( nbBytes==1 || nbBytes==2 ); Q_ASSERT( value a(nbBytes); + TQMemArray a(nbBytes); if ( nbBytes==2 ) { a[0] = value / 256; a[1] = value & 0xFF; diff --git a/src/progs/psp/base/psp_serial.h b/src/progs/psp/base/psp_serial.h index 6f379dd..a7ebf77 100644 --- a/src/progs/psp/base/psp_serial.h +++ b/src/progs/psp/base/psp_serial.h @@ -18,12 +18,12 @@ namespace Psp class SerialPort : public Port::Serial { public: - SerialPort(const QString &portDevice, Log::Base &log); + SerialPort(const TQString &portDevice, Log::Base &log); bool open(); bool reset(); - bool command(uchar c, uint nbBytes, QMemArray &a); - bool commandAck(uchar c, uint nbBytes = 1, QMemArray *a = 0); - bool commandAckEnd(uchar c, uint nbBytes, QMemArray &a); + bool command(uchar c, uint nbBytes, TQMemArray &a); + bool commandAck(uchar c, uint nbBytes = 1, TQMemArray *a = 0); + bool commandAckEnd(uchar c, uint nbBytes, TQMemArray &a); bool receiveEnd(); bool sendData(uint value, uint nbBytes); -- cgit v1.2.1