@@ -74,12 +74,21 @@ DXClusterWidget::DXClusterWidget(Awards *awards, QWidget *parent)
7474 dxClusterListWidget->setContextMenuPolicy (Qt::CustomContextMenu);
7575 connect (sendButton , SIGNAL (clicked ()), this , SLOT (slotClusterSendToServer ()) );
7676 connect (inputCommand, SIGNAL (textChanged (QString)), this , SLOT (slotClusterInputTextChanged ()) );
77+ connect (inputCommand, SIGNAL (returnPressed ()), this , SLOT (slotClusterSendToServer ()) );
7778
7879 // connect(searchResultsTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(slotDoubleClickSearch(QTreeWidgetItem *, int)));
7980 connect (dxClusterListWidget, SIGNAL (itemDoubleClicked ( QListWidgetItem *)), this , SLOT (slotClusterDXClusterWidgetItemDoubleClicked ( QListWidgetItem * )) );
8081 connect (dxClusterListWidget, SIGNAL (itemEntered ( QListWidgetItem *)), this , SLOT (slotClusterDXClusterWidgetItemEntered ( QListWidgetItem * )) );
8182 connect (dxClusterListWidget, SIGNAL (itemSelectionChanged ()), this , SLOT (slotClusterDXClusterWidgetItemSelected () ) );
8283 connect (dxClusterListWidget, SIGNAL (customContextMenuRequested ( const QPoint& ) ), this , SLOT (slotRightButton ( const QPoint& ) ) );
84+
85+ connect (tcpSocket, SIGNAL (connected ()), SLOT (slotClusterSocketConnected ()) );
86+ connect (tcpSocket, SIGNAL (readyRead ()), this , SLOT (slotClusterDataArrived () ));
87+ connect (tcpSocket, SIGNAL (errorOccurred (QAbstractSocket::SocketError)), this , SLOT (slotClusterDisplayError (QAbstractSocket::SocketError)));
88+ connect (tcpSocket, SIGNAL (disconnected ()), SLOT (slotClusterSocketConnectionClosed ()) );
89+
90+
91+ connect (clearButton, SIGNAL (clicked ()), this , SLOT (slotClusterClearLineInput ()) );
8392 // TESTADDSPOT();
8493 // qDebug() << "DXClusterWidget::DXClusterWidget2 - END" ;
8594}
@@ -195,13 +204,6 @@ void DXClusterWidget::connectToDXCluster()
195204 return ; // If we are connected we don't want to start another connection
196205 }
197206
198- connect (tcpSocket, SIGNAL (connected ()), SLOT (slotClusterSocketConnected ()) );
199- connect (tcpSocket, SIGNAL (readyRead ()), this , SLOT (slotClusterDataArrived () ));
200-
201- connect (tcpSocket, SIGNAL (errorOccurred (QAbstractSocket::SocketError)), this , SLOT (slotClusterDisplayError (QAbstractSocket::SocketError)));
202- connect (tcpSocket, SIGNAL (disconnected ()), SLOT (slotClusterSocketConnectionClosed ()) );
203- connect (inputCommand, SIGNAL (returnPressed ()), this , SLOT (slotClusterSendToServer ()) );
204- connect (clearButton, SIGNAL (clicked ()), this , SLOT (slotClusterClearLineInput ()) );
205207 // openFile(); // This functions opens the file to save the DX-Cluster activity. The file will be closed when the DX is disconnected.
206208 tcpSocket->connectToHost ( server, port );
207209 dxClusterListWidget->setSortingEnabled (false );
@@ -212,10 +214,12 @@ void DXClusterWidget::connectToDXCluster()
212214
213215void DXClusterWidget::slotClusterDisplayError (QAbstractSocket::SocketError socketError)
214216{
215- // qDebug() << Q_FUNC_INFO;
217+ qDebug () << Q_FUNC_INFO << " : " << socketError ;
216218 QString errorMessage;
219+
217220 switch (socketError) {
218221 case QAbstractSocket::RemoteHostClosedError:
222+ errorMessage = tr (" The DXCluster server desconnected the session." );
219223 break ;
220224 case QAbstractSocket::HostNotFoundError:
221225 errorMessage = tr (" The host was not found. Please check:" ) + " \n\n " +
@@ -229,8 +233,7 @@ void DXClusterWidget::slotClusterDisplayError(QAbstractSocket::SocketError socke
229233 " settings are correct." );
230234 break ;
231235 default :
232- errorMessage = tr (" The following error occurred: %1." )
233- .arg (tcpSocket->errorString ());
236+ errorMessage = tr (" The following error occurred: %1." ).arg (socketError);
234237 }
235238
236239 // qDebug() << Q_FUNC_INFO << errorMessage;
@@ -447,6 +450,7 @@ void DXClusterWidget::slotClusterSocketConnected()
447450
448451 if (!ok) {
449452 tcpSocket->disconnectFromHost ();
453+ dxClusterConnected = false ;
450454 return ;
451455 }
452456
@@ -457,6 +461,7 @@ void DXClusterWidget::slotClusterSocketConnected()
457461
458462 if (!ok) {
459463 tcpSocket->abort ();
464+ dxClusterConnected = false ;
460465 return ;
461466 }
462467
@@ -477,7 +482,7 @@ void DXClusterWidget::slotClusterSocketConnected()
477482
478483void DXClusterWidget::slotClusterSocketConnectionClosed ()
479484{
480- // qDebug() << Q_FUNC_INFO;
485+ qDebug () << Q_FUNC_INFO;
481486 addItemToClusterList (tr (" Connection closed by the server" ), awards->getDefaultColor ());
482487
483488 dxClusterConnected = false ;
@@ -491,28 +496,37 @@ void DXClusterWidget::slotClusterSocketConnectionClosed()
491496
492497void DXClusterWidget::slotClusterSendToServer ()
493498{
494- // qDebug() << Q_FUNC_INFO;
499+ qDebug () << Q_FUNC_INFO << " - 000 " ;
495500 if (!dxClusterConnected) {
501+ qDebug () << Q_FUNC_INFO << " - 001" ;
502+ qDebug () << Q_FUNC_INFO << " - Cluster already connected, END" ;
496503 connectToDXCluster ();
504+ qDebug () << Q_FUNC_INFO << " - 002 - END" ;
505+
497506 return ; // If we try to connect...
498507 }
499-
508+ qDebug () << Q_FUNC_INFO << " - 010 " ;
500509 QString inputText = inputCommand->text ();
501510 if (inputText.isEmpty ()) {
511+ qDebug () << Q_FUNC_INFO << " - 020" ;
502512 if (sendButton->text () == tr (" Disconnect" )) {
503513 // Disconnecting
504- QTextStream os (tcpSocket);
505- os << " bye\n " ;
506- return ;
514+ {
515+ qDebug () << Q_FUNC_INFO << " - 030" ;
516+ QTextStream os (tcpSocket);
517+ os << " bye\n " ;
518+ qDebug () << Q_FUNC_INFO << " - 033 - END" ;
519+ return ;
520+ }
507521 }
508522 // If input is empty and send button is not "Disconnect", do nothing
509523 return ;
510524 }
511-
525+ qDebug () << Q_FUNC_INFO << " - 050 " ;
512526 // Write to the server
513- QTextStream os (tcpSocket);
514- os << inputText << " \n " ;
527+ QTextStream (tcpSocket) << inputText << " \n " ;
515528 inputCommand->clear ();
529+ qDebug () << Q_FUNC_INFO << " - END" ;
516530}
517531
518532void DXClusterWidget::slotClusterClearLineInput ()
@@ -523,7 +537,7 @@ void DXClusterWidget::slotClusterClearLineInput()
523537
524538void DXClusterWidget::slotClusterInputTextChanged ()
525539{
526- // qDebug() << Q_FUNC_INFO;
540+ qDebug () << Q_FUNC_INFO;
527541 QString inputText = inputCommand->text ();
528542 if (inputText.isEmpty ()) {
529543 sendButton->setText (tr (" Disconnect" ));
@@ -621,10 +635,9 @@ DXSpot DXClusterWidget::readItem(const QString _stringSpot)
621635 if (fields.size () < 5 )
622636 return spot;
623637
624- bool doubleClick = false ;
625- if (fields.at (0 ) == " DOUBLE" )
626- {
627- doubleClick = true ;
638+ // Check for double click
639+ bool doubleClick = (fields.at (0 ) == " DOUBLE" );
640+ if (doubleClick) {
628641 fields.removeFirst ();
629642 }
630643
@@ -640,19 +653,18 @@ DXSpot DXClusterWidget::readItem(const QString _stringSpot)
640653 freq.fromQString (fields.at (3 ), MHz);
641654 else
642655 freq.fromQString (fields.at (3 ), KHz);
656+
643657 if (freq.isValid ())
644658 {
645659 // qDebug() << Q_FUNC_INFO << ": Freq is Valid";
646660 spot.setFrequency (freq);
647661 spot.setDXCall (fields.at (4 ));
648662
649- QDateTime datetime;
650- QTime time;
651663 QString aux = fields.last ();
652- aux.chop (1 );
653- time.fromString (aux," HHmm" );
664+ aux.chop (1 );
665+ QTime time = QTime::fromString (aux," HHmm" );
666+ QDateTime datetime = QDateTime::currentDateTime ();
654667 datetime.setTime (time);
655- datetime.setDate (QDate::currentDate ());
656668 spot.setDateTime (datetime);
657669
658670 aux.clear ();
@@ -664,7 +676,7 @@ DXSpot DXClusterWidget::readItem(const QString _stringSpot)
664676 spot.setComment (aux.trimmed ());
665677 }
666678 else
667- return spot;
679+ return spot;
668680 }
669681 // Check if the QSO is comming from sh/dx
670682 freq.fromQString (fields.at (0 ), KHz);
@@ -749,10 +761,7 @@ bool DXClusterWidget::openFile()
749761 msgBox.exec ();
750762 return false ;
751763 }
752- else
753- {
754- return true ;
755- }
764+ return true ;
756765}
757766
758767void DXClusterWidget::slotRightButton (const QPoint& pos)
@@ -805,27 +814,22 @@ void DXClusterWidget::saveSpot(const QString &_spot)
805814 // qDebug() << "DXClusterWidget::saveSpot: Not saving";
806815 return ;
807816 }
808- else
809- {
810- if (openFile ())
811- {
812- // qDebug() << "DXClusterWidget::saveSpot: File Open";
813- QTextStream out (saveSpotsFile);
814817
815- out << util->getDateTimeSQLiteStringFromDateTime (QDateTime::currentDateTime ()) << " - " << _spot.simplified ().toUtf8 ();
816- out << Qt::endl;
817- saveSpotsFile->close ();
818- }
819- }
818+ if (!openFile ())
819+ return ;
820+
821+ // qDebug() << "DXClusterWidget::saveSpot: File Open";
822+ QTextStream out (saveSpotsFile);
823+ out << util->getDateTimeSQLiteStringFromDateTime (QDateTime::currentDateTime ()) << " - " << _spot.simplified ().toUtf8 ();
824+ out << Qt::endl;
825+ saveSpotsFile->close ();
820826}
821827
822828void DXClusterWidget::loadSettings ()
823829{
824830 // qDebug() << Q_FUNC_INFO << " - Start";
825831 QSettings settings (util->getCfgFile (), QSettings::IniFormat);
826832
827-
828-
829833 QString aux = settings.value (" DXClusterServerToUse" ).toString ();
830834
831835 if (aux.contains (' :' ))
0 commit comments