diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-30 19:37:06 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-30 19:37:06 +0000 |
commit | 968af1d235ac30d737991b269156bee5dc99d318 (patch) | |
tree | 19b118fa5380087e10cb728be545760791ce0676 /src/knutclient.cpp | |
parent | aea4882f3b37f17c5b56bc77667e683c52254c30 (diff) | |
download | knutclient-968af1d235ac30d737991b269156bee5dc99d318.tar.gz knutclient-968af1d235ac30d737991b269156bee5dc99d318.zip |
TQt4 port knutclient
This enables compilation under both Qt3 and Qt4
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/knutclient@1238881 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/knutclient.cpp')
-rwxr-xr-x | src/knutclient.cpp | 146 |
1 files changed, 73 insertions, 73 deletions
diff --git a/src/knutclient.cpp b/src/knutclient.cpp index f7d7157..c0d262f 100755 --- a/src/knutclient.cpp +++ b/src/knutclient.cpp @@ -23,8 +23,8 @@ #include "knutrwvar.h" #include "knutclient.h" -#include <qdatetime.h> -#include <qmutex.h> +#include <tqdatetime.h> +#include <tqmutex.h> #include <kconfig.h> #include <ksimpleconfig.h> @@ -47,20 +47,20 @@ extern const char *nameUpsVars1[]; extern const char *nameUpsVars2[]; -KNutClient::KNutClient(bool noDock, QObject* parent, const char *name) : QObject(parent, name) { +KNutClient::KNutClient(bool noDock, TQObject* tqparent, const char *name) : TQObject(tqparent, name) { upsRecords = new KNutUpsData(); analogRecords = new KNutVarData(); - m_upsTimer = new QTimer (this); - connect( m_upsTimer, SIGNAL(timeout()), SLOT(slotTimeout()) ); + m_upsTimer = new TQTimer (this); + connect( m_upsTimer, TQT_SIGNAL(timeout()), TQT_SLOT(slotTimeout()) ); - m_reconnectTimer = new QTimer(this); - connect( m_reconnectTimer, SIGNAL(timeout()), SLOT(slotReconnectTimeout()) ); + m_reconnectTimer = new TQTimer(this); + connect( m_reconnectTimer, TQT_SIGNAL(timeout()), TQT_SLOT(slotReconnectTimeout()) ); // data for combo - m_listKNutEvent = new QStringList(); + m_listKNutEvent = new TQStringList(); // init and load of configuration initVars(); @@ -71,16 +71,16 @@ KNutClient::KNutClient(bool noDock, QObject* parent, const char *name) : QObject m_myDock = new KNutDock(&m_mainUpsInfo,&settingData,upsRecords); m_myDock->show(); - connect(m_myDock, SIGNAL(endApplication()), this, SLOT(slotExitApplication())); - connect(m_myDock, SIGNAL(activeMainWindow()), this, SLOT(slotActiveMainWindow())); - connect(m_myDock, SIGNAL(minimize()), this, SLOT(closeMainWindow())); - connect(m_myDock, SIGNAL(UPSChanged(QString)), this, SLOT(slotSetNewUPS (QString))); - - connect(m_myDock, SIGNAL(preferences()),this, SLOT(slotPreferenceUps())); - connect(m_myDock, SIGNAL(printUPSVars()),this, SLOT(slotPrintUPSVars())); - connect(m_myDock, SIGNAL(instComms()),this, SLOT(slotInstComms())); - connect(m_myDock, SIGNAL(RWVars()),this, SLOT(slotRWVars())); - connect(m_myDock, SIGNAL(makeRefreshConnection()),this, SLOT(slotRefreshConnection())); + connect(m_myDock, TQT_SIGNAL(endApplication()), this, TQT_SLOT(slotExitApplication())); + connect(m_myDock, TQT_SIGNAL(activeMainWindow()), this, TQT_SLOT(slotActiveMainWindow())); + connect(m_myDock, TQT_SIGNAL(minimize()), this, TQT_SLOT(closeMainWindow())); + connect(m_myDock, TQT_SIGNAL(UPSChanged(TQString)), this, TQT_SLOT(slotSetNewUPS (TQString))); + + connect(m_myDock, TQT_SIGNAL(preferences()),this, TQT_SLOT(slotPreferenceUps())); + connect(m_myDock, TQT_SIGNAL(printUPSVars()),this, TQT_SLOT(slotPrintUPSVars())); + connect(m_myDock, TQT_SIGNAL(instComms()),this, TQT_SLOT(slotInstComms())); + connect(m_myDock, TQT_SIGNAL(RWVars()),this, TQT_SLOT(slotRWVars())); + connect(m_myDock, TQT_SIGNAL(makeRefreshConnection()),this, TQT_SLOT(slotRefreshConnection())); } addEventString(i18n("Ready.")); @@ -90,7 +90,7 @@ KNutClient::KNutClient(bool noDock, QObject* parent, const char *name) : QObject // sets data for selected item setActiveUpsInfo(m_mainUpsInfo.record.name); - // sets mainUpsInfo.oldState to const value KNutNet::initStatus + // sets mainUpsInfo.oldState to const value KNutNet::inittqStatus m_mainUpsInfo.oldState=KNutNet::initState; @@ -99,11 +99,11 @@ KNutClient::KNutClient(bool noDock, QObject* parent, const char *name) : QObject m_mainUpsInfo.upsNet = new KNutNet( m_mainUpsInfo.record.upsAddress, m_mainUpsInfo.record.upsName, m_mainUpsInfo.record.port,5,200); - connect(m_mainUpsInfo.upsNet, SIGNAL(firstConnection(void)),this, SLOT(slotFirstConnection(void))); - connect(m_mainUpsInfo.upsNet, SIGNAL(connectionError(int)),this, SLOT(slotErrorConnection(int))); - connect(m_mainUpsInfo.upsNet, SIGNAL(connectionClosed(void )),this, SLOT(slotConnectionClosed(void))); - connect(m_mainUpsInfo.upsNet, SIGNAL(tryFirstConnection(int )),this, SLOT(slotTryFirstConnection(int))); - connect(m_mainUpsInfo.upsNet, SIGNAL(tryRepeatFirstConnection(int )),this, SLOT(slotTryReepatFirstConnection( int ))); + connect(m_mainUpsInfo.upsNet, TQT_SIGNAL(firstConnection(void)),this, TQT_SLOT(slotFirstConnection(void))); + connect(m_mainUpsInfo.upsNet, TQT_SIGNAL(connectionError(int)),this, TQT_SLOT(slotErrorConnection(int))); + connect(m_mainUpsInfo.upsNet, TQT_SIGNAL(connectionClosed(void )),this, TQT_SLOT(slotConnectionClosed(void))); + connect(m_mainUpsInfo.upsNet, TQT_SIGNAL(tryFirstConnection(int )),this, TQT_SLOT(slotTryFirstConnection(int))); + connect(m_mainUpsInfo.upsNet, TQT_SIGNAL(tryRepeatFirstConnection(int )),this, TQT_SLOT(slotTryReepatFirstConnection( int ))); // state of connection to usbd, this isn't state of knutnet @@ -112,7 +112,7 @@ KNutClient::KNutClient(bool noDock, QObject* parent, const char *name) : QObject // } // else mainUpsInfo.upsDriverState=knc::notConnected; - // repaints the dock + // tqrepaints the dock if (m_myDock) m_myDock->clearDockValues(); if (settingData.useMainWindow == KNutVarData::mw_yes || noDock || @@ -154,8 +154,8 @@ void KNutClient::slotTryFirstConnection (int maxCount) { //qDebug ("KNutClient::slotTryFirstConnection"); //knutNet begin the first test of connection (connectToHost will be made after emiting signal tryFirstConnection ) -// repaints icon - if (m_myDock) m_myDock->repaintDock(true); +// tqrepaints icon + if (m_myDock) m_myDock->tqrepaintDock(true); if (mainWindow) mainWindow->startConnectPB(maxCount); } @@ -206,7 +206,7 @@ void KNutClient::slotFirstConnection (void) { else m_mainUpsInfo.upsDriverState=knc::error; - if (m_myDock) m_myDock->repaintDock(true); + if (m_myDock) m_myDock->tqrepaintDock(true); addEventString (KNutVarData::errorToText(m_mainUpsInfo.netError),m_mainUpsInfo.record.name); // KNutVarData::showError (mainUpsInfo.netError); if ((m_myMessMan)) m_myMessMan->addMessage(KNutVarData::errorToText(m_mainUpsInfo.netError),knc::errorLevel,true); @@ -247,10 +247,10 @@ void KNutClient::slotFirstConnection (void) { if (mainWindow) setActiveUpsVars(true); else setActiveUpsVars(false); - // repaints main window and dock immediately + // tqrepaints main window and dock immediately if (mainWindow) mainWindow->showUpsData(); -// if (myDock) myDock->repaintDock(mainUpsInfo.netError,true); // dock is repainting always - if (m_myDock) m_myDock->repaintDock(true); // dock is repainting always +// if (myDock) myDock->tqrepaintDock(mainUpsInfo.netError,true); // dock is tqrepainting always + if (m_myDock) m_myDock->tqrepaintDock(true); // dock is tqrepainting always m_panelsAreZeroing=false; // analog panels isn't setting to zero } @@ -274,14 +274,14 @@ void KNutClient::slotErrorConnection (int error) { m_mainUpsInfo.upsDriverState=knc::notConnected; else m_mainUpsInfo.upsDriverState=knc::error; - if (m_myDock) m_myDock->repaintDock(true); + if (m_myDock) m_myDock->tqrepaintDock(true); if (m_mainUpsInfo.reconnecting) { //qDebug ("KNutClient::slotErrorConnection (2)"); m_mainUpsInfo.reconnectCount++; if (m_mainUpsInfo.reconnectCount > countNextConnDelay) m_mainUpsInfo.reconnectCount = countNextConnDelay; - addEventString(i18n("The connection failed. The next connection will make after %1 sec.").arg(nextConnDelay[m_mainUpsInfo.reconnectCount-1]),m_mainUpsInfo.record.name); + addEventString(i18n("The connection failed. The next connection will make after %1 sec.").tqarg(nextConnDelay[m_mainUpsInfo.reconnectCount-1]),m_mainUpsInfo.record.name); m_reconnectTimer->start( nextConnDelay[m_mainUpsInfo.reconnectCount-1]*1000, TRUE ); // starts reconnect timer again } else { @@ -331,9 +331,9 @@ void KNutClient::initVars (void) { void KNutClient::loadConfiguration ( void ) { - QString groupName; + TQString groupName; KNutUpsData::upsRecordDef upsData; // structure includes informations about UPS // struktura obsahuje udaje o UPS - QFont appFont = kapp->font(); // systemovy font pri startu + TQFont appFont = kapp->font(); // systemovy font pri startu kapp->config()->setGroup (""); settingData.areYouSure=kapp->config()->readBoolEntry("AreYouSure",FALSE); @@ -389,19 +389,19 @@ void KNutClient::initVars (void) { for (int i = 0; i < upsCount; i++) { groupName.sprintf ("UPS %d",i); kapp->config()->setGroup (groupName); - if ((upsData.name = kapp->config()->readEntry ("Name")) != QChar::null) { + if ((upsData.name = kapp->config()->readEntry ("Name")) != TQChar::null) { // record exist, we will go next part //if ActiveUps is empty, we use name of first ups from ups list if ((m_mainUpsInfo.record.name.isEmpty()) && (!(upsData.name.isEmpty()))) m_mainUpsInfo.record.name = upsData.name; upsData.upsName = kapp->config()->readEntry ("UpsName",""); - if (((upsData.upsAddress = kapp->config()->readEntry ("UpsAddress")) != QChar::null) - || (( upsData.upsAddress == QChar::null) && (upsData.upsName != QChar::null ))) { + if (((upsData.upsAddress = kapp->config()->readEntry ("UpsAddress")) != TQChar::null) + || (( upsData.upsAddress == TQChar::null) && (upsData.upsName != TQChar::null ))) { // only for backwards compatibility with older release then 0.7 if (upsData.upsAddress.isEmpty()) { int charPos; - if ((charPos=upsData.upsName.find('@')) == -1) { + if ((charPos=upsData.upsName.tqfind('@')) == -1) { upsData.upsAddress=upsData.upsName; upsData.upsName=""; } @@ -430,8 +430,8 @@ void KNutClient::initVars (void) { } void KNutClient::saveConfiguration ( bool all ) { - QString groupName; - QString codeName; + TQString groupName; + TQString codeName; KNutUpsData::upsRecordDef upsData; // struktura obsahuje udaje o UPS // structure includes information about UPS int upsCount = upsRecords->getCount(); @@ -450,7 +450,7 @@ void KNutClient::saveConfiguration ( bool all ) { upsRecords->get(0,upsData); kapp->config()->writeEntry ("ActiveUps",upsData.name); } - else kapp->config()->writeEntry ("ActiveUps",(QString)m_mainUpsInfo.record.name); // + else kapp->config()->writeEntry ("ActiveUps",(TQString)m_mainUpsInfo.record.name); // if (all) { kapp->config()->writeEntry ("AnalogFontColor",settingData.analogFontColor); @@ -513,13 +513,13 @@ void KNutClient::saveConfiguration ( bool all ) { } -bool KNutClient::commitData (QSessionManager&) { +bool KNutClient::commitData (TQSessionManager&) { saveConfiguration(false); return true; } - bool KNutClient::saveState (QSessionManager&) { + bool KNutClient::saveState (TQSessionManager&) { saveConfiguration(false); return true; @@ -602,7 +602,7 @@ void KNutClient::upsDeactivate (void) { // this function isn't interuptable function // upsDeactivateMutex.lock(); - QMutexLocker upsDeactivateLocker( &m_upsDeactivateMutex ); + TQMutexLocker upsDeactivateLocker( &m_upsDeactivateMutex ); m_mainUpsInfo.upsNet->close(); // close connection // state of connection to usbd, this isn't state of knutnet m_mainUpsInfo.upsDriverState=knc::notConnected; @@ -653,7 +653,7 @@ void KNutClient::setActiveXFerVars (bool activate) { } } -void KNutClient::setActiveUpsInfo (QString name) { +void KNutClient::setActiveUpsInfo (TQString name) { //presuneme jmena z databaze ups-ek - je nahrana z config. souboru KNutUpsData::upsRecordDef* upsRecordPointer; @@ -709,14 +709,14 @@ void KNutClient::getUpsData (void) { } -void KNutClient::addEventString (const QString text, const QString UPSAddress) { +void KNutClient::addEventString (const TQString text, const TQString UPSAddress) { if (mainWindow) mainWindow->addComboStatusItem (text,UPSAddress); else { - QString dateTime(QDate::currentDate().toString()); - dateTime +=" " + QTime::currentTime().toString(); + TQString dateTime(TQDate::tqcurrentDate().toString()); + dateTime +=" " + TQTime::currentTime().toString(); if (UPSAddress.isEmpty()) m_listKNutEvent->append(dateTime+" "+text); else m_listKNutEvent->append(dateTime+" "+UPSAddress+" : "+text); if (m_listKNutEvent->count() > knc::maxCountKNutEvent) m_listKNutEvent->remove(m_listKNutEvent->begin()); @@ -744,8 +744,8 @@ void KNutClient::slotTimeout (void) { getUpsData(); if (!m_mainUpsInfo.errorUpsData) { // no error if (mainWindow) { - mainWindow->repaintPanel(); - mainWindow->repaintAnalogs(); + mainWindow->tqrepaintPanel(); + mainWindow->tqrepaintAnalogs(); } m_panelsAreZeroing=false; showStatusEvent(); @@ -755,7 +755,7 @@ void KNutClient::slotTimeout (void) { m_panelsAreZeroing=true; if (m_myDock) m_myDock->clearDockValues(); } - if (m_myDock) m_myDock->repaintDock(); + if (m_myDock) m_myDock->tqrepaintDock(); m_upsTimer->start( m_mainUpsInfo.record.delay, TRUE ); // nastartujem znovu } @@ -791,7 +791,7 @@ void KNutClient::showStatusEvent(void) { //qDebug ("KNutClient::showStatusEvent"); - int myState = m_mainUpsInfo.upsNet->readStatus(); + int myState = m_mainUpsInfo.upsNet->readtqStatus(); if (myState != m_mainUpsInfo.oldState) { if ((myState & KNutNet::OFF) != (m_mainUpsInfo.oldState & KNutNet::OFF)) { @@ -876,7 +876,7 @@ void KNutClient::showStatusEvent(void) { } } -void KNutClient::slotSetNewUPS (QString name) { +void KNutClient::slotSetNewUPS (TQString name) { m_mainUpsInfo.reconnecting =false; m_reconnectTimer->stop(); @@ -925,7 +925,7 @@ void KNutClient::slotSetNewUPS (QString name) { void KNutClient::slotPreferenceUps (void) { KNutPrefDlg* prefDlg = new KNutPrefDlg ( upsRecords, analogRecords, &settingData, m_mainUpsInfo.record.name ); // aktivujeme dialog pro preference - connect (prefDlg,SIGNAL(signalChangeConfig(unsigned int)),this,SLOT(slotSetConfig(unsigned int))); + connect (prefDlg,TQT_SIGNAL(signalChangeConfig(unsigned int)),this,TQT_SLOT(slotSetConfig(unsigned int))); prefDlg->exec(); delete prefDlg; } @@ -951,7 +951,7 @@ void KNutClient::slotSetConfig (unsigned int changeSetting) { if (m_mainUpsInfo.record.name == "") { // the first record was added, because the first UPS is active UPS always - QString name = upsRecords->getName(0); + TQString name = upsRecords->getName(0); addEventString(i18n("Switched"),name); m_mainUpsInfo.record.name=name; m_mainUpsInfo.errorUpsData=false; @@ -978,7 +978,7 @@ void KNutClient::slotSetConfig (unsigned int changeSetting) { // showUpsData je nutno udelat take proto ze se mohl zmenit vyber meraku // if (mainWindow) mainWindow->showUpsData(); if (mainWindow) mainWindow->cleanPanels(); -// if (myDock) myDock->repaintDock(mainUpsInfo.netError); +// if (myDock) myDock->tqrepaintDock(mainUpsInfo.netError); if (m_myDock) m_myDock->clearDockValues(); m_mainUpsInfo.upsNet->newUPS(m_mainUpsInfo.record.upsAddress,m_mainUpsInfo.record.upsName, m_mainUpsInfo.record.port); @@ -1065,7 +1065,7 @@ void KNutClient::slotRWVars(void) { if (!m_mainUpsInfo.errorUpsData) { if (m_mainUpsInfo.upsNet->readNumberVars (KNutNet::RWVars)) { KNutRWVar *windowRWVars = new KNutRWVar(&m_mainUpsInfo.name,&m_mainUpsInfo.password,m_mainUpsInfo.record.userName,m_mainUpsInfo.record.password,m_mainUpsInfo.upsNet); - connect (windowRWVars,SIGNAL(signalChangeRWVars(QString)),this,SLOT(slotChangeRWVars(QString))); + connect (windowRWVars,TQT_SIGNAL(signalChangeRWVars(TQString)),this,TQT_SLOT(slotChangeRWVars(TQString))); if (windowRWVars->upsOk()) windowRWVars->exec(); delete windowRWVars; } @@ -1096,7 +1096,7 @@ void KNutClient::slotRefreshConnection(void) { if (m_myDock) { m_myDock->clearDockValues(); // myDock->initImage(); - // myDock->repaint(); + // myDock->tqrepaint(); } if (mainWindow) { mainWindow->cleanPanels(); @@ -1125,7 +1125,7 @@ void KNutClient::slotRefreshConnection(void) { } -void KNutClient::slotChangeRWVars( QString ) { +void KNutClient::slotChangeRWVars( TQString ) { // informace ze doslo k uspesne zmene promene // vzhledem k asynchronimu zpracovani muze upsd vratit tuto hodnotu az za nejakou dobu // nevim zda bude potreba @@ -1152,19 +1152,19 @@ void KNutClient::exitMainWindow (void) { void KNutClient::makeMainWindow (void) { mainWindow = new KNutMainWindow(m_listKNutEvent ,&m_mainUpsInfo, &settingData, upsRecords, analogRecords); - connect(mainWindow, SIGNAL(UPSChanged (QString)), this, SLOT(slotSetNewUPS (QString))); - connect(mainWindow, SIGNAL(preferenceUps()),this, SLOT(slotPreferenceUps())); - connect(mainWindow, SIGNAL(showUPSVars()),this, SLOT(slotPrintUPSVars())); - connect(mainWindow, SIGNAL(makeInstComms()),this, SLOT(slotInstComms())); - connect(mainWindow, SIGNAL(makeRWVars()),this, SLOT(slotRWVars())); - connect(mainWindow, SIGNAL(makeRefreshConnection()),this, SLOT(slotRefreshConnection())); - connect(mainWindow, SIGNAL(saveConf()),this, SLOT(slotSaveConf())); + connect(mainWindow, TQT_SIGNAL(UPSChanged (TQString)), this, TQT_SLOT(slotSetNewUPS (TQString))); + connect(mainWindow, TQT_SIGNAL(preferenceUps()),this, TQT_SLOT(slotPreferenceUps())); + connect(mainWindow, TQT_SIGNAL(showUPSVars()),this, TQT_SLOT(slotPrintUPSVars())); + connect(mainWindow, TQT_SIGNAL(makeInstComms()),this, TQT_SLOT(slotInstComms())); + connect(mainWindow, TQT_SIGNAL(makeRWVars()),this, TQT_SLOT(slotRWVars())); + connect(mainWindow, TQT_SIGNAL(makeRefreshConnection()),this, TQT_SLOT(slotRefreshConnection())); + connect(mainWindow, TQT_SIGNAL(saveConf()),this, TQT_SLOT(slotSaveConf())); - connect(mainWindow, SIGNAL(endApplication()), this, SLOT(slotExitApplication())); - connect(mainWindow, SIGNAL(destroyed()), this, SLOT(exitMainWindow())); + connect(mainWindow, TQT_SIGNAL(endApplication()), this, TQT_SLOT(slotExitApplication())); + connect(mainWindow, TQT_SIGNAL(destroyed()), this, TQT_SLOT(exitMainWindow())); } @@ -1179,7 +1179,7 @@ void KNutClient::slotActiveMainWindow (void) { setActiveUpsVars(true); getUpsData(); makeMainWindow(); - if (m_myDock) m_myDock->repaintDock(m_mainUpsInfo.netError); + if (m_myDock) m_myDock->tqrepaintDock(m_mainUpsInfo.netError); m_upsTimer->start( 1, TRUE ); // nastartujem znovu // 1 proto aby se zpracovali pripadne udalosti o zruseni spojeni } @@ -1189,7 +1189,7 @@ void KNutClient::slotActiveMainWindow (void) { // getValues error=0 a doslo by vypsani data ok. makeMainWindow(); if (!m_mainUpsInfo.errorUpsData) { - if (m_myDock) m_myDock->repaintDock(m_mainUpsInfo.netError); + if (m_myDock) m_myDock->tqrepaintDock(m_mainUpsInfo.netError); } } } @@ -1206,7 +1206,7 @@ void KNutClient::slotSaveConf (void) { void KNutClient::closeMainWindow (void) { if (mainWindow) { - if (m_myDock) m_myDock->repaintDock(m_mainUpsInfo.netError); + if (m_myDock) m_myDock->tqrepaintDock(m_mainUpsInfo.netError); m_upsTimer->stop(); mainWindow->close(); mainWindow=0; @@ -1220,7 +1220,7 @@ void KNutClient::slotExitApplication(void) { m_upsTimer->stop(); if (mainWindow) { // odpojime protoze exitMainWindow by byl vykonan az po zkonceni procedury; - disconnect(mainWindow, SIGNAL(destroyed()), this, SLOT(exitMainWindow())); + disconnect(mainWindow, TQT_SIGNAL(destroyed()), this, TQT_SLOT(exitMainWindow())); delete mainWindow; mainWindow = 0; } |