mirror of
				https://github.com/saitohirga/WSJT-X.git
				synced 2025-11-04 05:50:31 -05:00 
			
		
		
		
	Logbook:
-changed log to hash table for faster lookup -improved ADIF compatibility mainwindow.ui -fixed typo in menu entry git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3538 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
		
							parent
							
								
									f70a09cb98
								
							
						
					
					
						commit
						c0ce066408
					
				@ -6,6 +6,7 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
<CALL:4>W1XT<BAND:3>20m<FREQ:6>14.076<GRIDSQUARE:4>DM33<MODE:4>JT65<RST_RCVD:3>-21<RST_SENT:3>-14<QSO_DATE:8>20110422<TIME_ON:4>0417<TIME_OFF:4>0424<TX_PWR:1>4<COMMENT:34>1st JT65A QSO.   Him: mag loop 20W<STATION_CALLSIGN:6>VK3ACF<MY_GRIDSQUARE:6>qf22lb<eor>
 | 
					<CALL:4>W1XT<BAND:3>20m<FREQ:6>14.076<GRIDSQUARE:4>DM33<MODE:4>JT65<RST_RCVD:3>-21<RST_SENT:3>-14<QSO_DATE:8>20110422<TIME_ON:4>0417<TIME_OFF:4>0424<TX_PWR:1>4<COMMENT:34>1st JT65A QSO.   Him: mag loop 20W<STATION_CALLSIGN:6>VK3ACF<MY_GRIDSQUARE:6>qf22lb<eor>
 | 
				
			||||||
<CALL:6>IK1SOW<BAND:3>20m<FREQ:6>14.076<GRIDSQUARE:4>JN35<MODE:4>JT65<RST_RCVD:3>-19<RST_SENT:3>-11<QSO_DATE:8>20110422<TIME_ON:4>0525<TIME_OFF:4>0533<TX_PWR:1>3<STATION_CALLSIGN:6>VK3ACF<MY_GRIDSQUARE:6>qf22lb<eor>
 | 
					<CALL:6>IK1SOW<BAND:3>20m<FREQ:6>14.076<GRIDSQUARE:4>JN35<MODE:4>JT65<RST_RCVD:3>-19<RST_SENT:3>-11<QSO_DATE:8>20110422<TIME_ON:4>0525<TIME_OFF:4>0533<TX_PWR:1>3<STATION_CALLSIGN:6>VK3ACF<MY_GRIDSQUARE:6>qf22lb<eor>
 | 
				
			||||||
 | 
					<CALL:6:S>W4ABC> ...
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ADIF::init(QString filename)
 | 
					void ADIF::init(QString filename)
 | 
				
			||||||
@ -14,21 +15,32 @@ void ADIF::init(QString filename)
 | 
				
			|||||||
    _data.clear(); 
 | 
					    _data.clear(); 
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QString ADIF::_extractField(const QString line, const QString fieldName)
 | 
					QString ADIF::_extractField(const QString line, const QString fieldName)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int s1 = line.indexOf(fieldName,0,Qt::CaseInsensitive);
 | 
					    int fieldNameIndex = line.indexOf(fieldName,0,Qt::CaseInsensitive);
 | 
				
			||||||
    if (s1 >=0)
 | 
					    if (fieldNameIndex >=0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      int s2 = line.indexOf('>',s1);
 | 
					        int closingBracketIndex = line.indexOf('>',fieldNameIndex);
 | 
				
			||||||
      if (s2 >= 0)
 | 
					        int fieldLengthIndex = line.indexOf(':',fieldNameIndex);  // find the size delimiter
 | 
				
			||||||
 | 
					        int dataTypeIndex = -1;
 | 
				
			||||||
 | 
					        if (fieldLengthIndex >= 0)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          int flsi = s1+fieldName.length();
 | 
					          dataTypeIndex = line.indexOf(':',fieldLengthIndex+1);  // check for a second : indicating there is a data type
 | 
				
			||||||
          int flsl = s2-flsi;
 | 
					          if (dataTypeIndex > closingBracketIndex)
 | 
				
			||||||
          if (flsl>0)
 | 
					            dataTypeIndex = -1; // second : was found but it was beyond the closing >
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if ((closingBracketIndex > fieldNameIndex) && (fieldLengthIndex > fieldNameIndex) && (fieldLengthIndex< closingBracketIndex))
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
              QString fieldLengthString = line.mid(flsi,flsl);
 | 
					            int fieldLengthCharCount = closingBracketIndex - fieldLengthIndex -1;
 | 
				
			||||||
 | 
					            if (dataTypeIndex >= 0)
 | 
				
			||||||
 | 
					              fieldLengthCharCount -= 2; // data type indicator is always a colon followed by a single character
 | 
				
			||||||
 | 
					            QString fieldLengthString = line.mid(fieldLengthIndex+1,fieldLengthCharCount);
 | 
				
			||||||
            int fieldLength = fieldLengthString.toInt();
 | 
					            int fieldLength = fieldLengthString.toInt();
 | 
				
			||||||
              QString field = line.mid(s2+1,fieldLength);
 | 
					            if (fieldLength > 0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              QString field = line.mid(closingBracketIndex+1,fieldLength);
 | 
				
			||||||
              return field;
 | 
					              return field;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
       }
 | 
					       }
 | 
				
			||||||
@ -54,7 +66,7 @@ void ADIF::load()
 | 
				
			|||||||
            q.mode = _extractField(line,"MODE:");
 | 
					            q.mode = _extractField(line,"MODE:");
 | 
				
			||||||
            q.date = _extractField(line,"QSO_DATE:");
 | 
					            q.date = _extractField(line,"QSO_DATE:");
 | 
				
			||||||
            if (q.call != "")
 | 
					            if (q.call != "")
 | 
				
			||||||
			_data << q;
 | 
					            _data.insert(q.call,q);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        inputFile.close();
 | 
					        inputFile.close();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -68,18 +80,21 @@ void ADIF::add(const QString call)
 | 
				
			|||||||
    q.band = "";     //TODO
 | 
					    q.band = "";     //TODO
 | 
				
			||||||
    q.mode = "JT9";  //TODO
 | 
					    q.mode = "JT9";  //TODO
 | 
				
			||||||
    q.date = "";     //TODO
 | 
					    q.date = "";     //TODO
 | 
				
			||||||
    _data << q;
 | 
					    _data.insert(q.call,q);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// return true if in the log same band and mode (where JT65 == JT9)
 | 
					// return true if in the log same band and mode (where JT65 == JT9)
 | 
				
			||||||
bool ADIF::match(const QString call, const QString band, const QString mode)
 | 
					bool ADIF::match(const QString call, const QString band, const QString mode)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    QList<QSO> qsos = _data.values(call);
 | 
				
			||||||
 | 
					    if (qsos.size()>0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        QSO q;
 | 
					        QSO q;
 | 
				
			||||||
	foreach(q,_data)
 | 
					        foreach(q,qsos)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
      if (call.compare(q.call) == 0)   //TODO handle multiple log entries from same call, should this be a hash table rather than a list?
 | 
					            if (     (band.compare(q.band) == 0)
 | 
				
			||||||
      {
 | 
					                  || (band=="")
 | 
				
			||||||
		if ((band.compare(q.band) == 0) || (band=="") || (q.band==""))
 | 
					                  || (q.band==""))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (
 | 
					                if (
 | 
				
			||||||
                     (
 | 
					                     (
 | 
				
			||||||
@ -88,6 +103,7 @@ bool ADIF::match(const QString call, const QString band, const QString mode)
 | 
				
			|||||||
                       ((q.mode.compare("JT65",Qt::CaseInsensitive)==0) || (q.mode.compare("JT9",Qt::CaseInsensitive)==0))
 | 
					                       ((q.mode.compare("JT65",Qt::CaseInsensitive)==0) || (q.mode.compare("JT9",Qt::CaseInsensitive)==0))
 | 
				
			||||||
                     )
 | 
					                     )
 | 
				
			||||||
                        || (mode.compare(q.mode)==0)
 | 
					                        || (mode.compare(q.mode)==0)
 | 
				
			||||||
 | 
					                        || (mode=="")
 | 
				
			||||||
                    )
 | 
					                    )
 | 
				
			||||||
                return true;
 | 
					                return true;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@ -99,14 +115,17 @@ bool ADIF::match(const QString call, const QString band, const QString mode)
 | 
				
			|||||||
QList<QString> ADIF::getCallList()
 | 
					QList<QString> ADIF::getCallList()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    QList<QString> p;
 | 
					    QList<QString> p;
 | 
				
			||||||
    QSO q;
 | 
					    QMultiHash<QString,QSO>::const_iterator i = _data.constBegin();
 | 
				
			||||||
    foreach(q,_data)
 | 
					     while (i != _data.constEnd())
 | 
				
			||||||
      p << q.call;
 | 
					     {
 | 
				
			||||||
 | 
					         p << i.key();
 | 
				
			||||||
 | 
					         ++i;
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
    return p;
 | 
					    return p;
 | 
				
			||||||
}   
 | 
					}   
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
int ADIF::getCount()
 | 
					int ADIF::getCount()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return _data.length();
 | 
					    return _data.size();
 | 
				
			||||||
}   
 | 
					}   
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
				
			|||||||
@ -11,6 +11,7 @@
 | 
				
			|||||||
#if defined (QT5)
 | 
					#if defined (QT5)
 | 
				
			||||||
#include <QList>
 | 
					#include <QList>
 | 
				
			||||||
#include <QString>
 | 
					#include <QString>
 | 
				
			||||||
 | 
					#include <QMultiHash>
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
#include <QtGui>
 | 
					#include <QtGui>
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
@ -33,7 +34,7 @@ class ADIF
 | 
				
			|||||||
		  QString call,band,mode,date;
 | 
							  QString call,band,mode,date;
 | 
				
			||||||
		};		  
 | 
							};		  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		QList<QSO> _data;
 | 
					        QMultiHash<QString, QSO> _data;
 | 
				
			||||||
		QString _filename;
 | 
							QString _filename;
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
        QString _extractField(const QString line, const QString fieldName);
 | 
					        QString _extractField(const QString line, const QString fieldName);
 | 
				
			||||||
 | 
				
			|||||||
@ -6,7 +6,10 @@
 | 
				
			|||||||
#ifndef __COUNTRIESWORKDED_H
 | 
					#ifndef __COUNTRIESWORKDED_H
 | 
				
			||||||
#define __COUNTRIESWORKDED_H
 | 
					#define __COUNTRIESWORKDED_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QtGui>
 | 
					#include <QList>
 | 
				
			||||||
 | 
					#include <QString>
 | 
				
			||||||
 | 
					#include <QStringList>
 | 
				
			||||||
 | 
					#include <QHash>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class CountriesWorked
 | 
					class CountriesWorked
 | 
				
			||||||
 | 
				
			|||||||
@ -29,9 +29,13 @@ void CountryDat::init(const QString filename)
 | 
				
			|||||||
QString CountryDat::_extractName(const QString line)
 | 
					QString CountryDat::_extractName(const QString line)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int s1 = line.indexOf(':');
 | 
					    int s1 = line.indexOf(':');
 | 
				
			||||||
 | 
					    if (s1>=0)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
        QString name = line.mid(0,s1);
 | 
					        QString name = line.mid(0,s1);
 | 
				
			||||||
        return name;
 | 
					        return name;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    return "";
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void CountryDat::_removeBrackets(QString &line, const QString a, const QString b)
 | 
					void CountryDat::_removeBrackets(QString &line, const QString a, const QString b)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -71,7 +75,7 @@ QStringList CountryDat::_extractPrefix(QString &line, bool &more)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void CountryDat::load()
 | 
					void CountryDat::load()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    _data.clear(); //dictionary was = {}
 | 
					    _data.clear();
 | 
				
			||||||
    _countryNames.clear(); //used by countriesWorked
 | 
					    _countryNames.clear(); //used by countriesWorked
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
    QFile inputFile(_filename);
 | 
					    QFile inputFile(_filename);
 | 
				
			||||||
@ -86,6 +90,8 @@ void CountryDat::load()
 | 
				
			|||||||
            QString line2 = in.readLine();
 | 
					            QString line2 = in.readLine();
 | 
				
			||||||
              
 | 
					              
 | 
				
			||||||
            QString name = _extractName(line1);
 | 
					            QString name = _extractName(line1);
 | 
				
			||||||
 | 
					            if (name.length()>0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
                _countryNames << name;
 | 
					                _countryNames << name;
 | 
				
			||||||
                bool more = true;
 | 
					                bool more = true;
 | 
				
			||||||
                QStringList prefixs;
 | 
					                QStringList prefixs;
 | 
				
			||||||
@ -105,6 +111,7 @@ void CountryDat::load()
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
 | 
					       }
 | 
				
			||||||
    inputFile.close();
 | 
					    inputFile.close();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -8,7 +8,10 @@
 | 
				
			|||||||
#ifndef __COUNTRYDAT_H
 | 
					#ifndef __COUNTRYDAT_H
 | 
				
			||||||
#define __COUNTRYDAT_H
 | 
					#define __COUNTRYDAT_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QtGui>
 | 
					
 | 
				
			||||||
 | 
					#include <QString>
 | 
				
			||||||
 | 
					#include <QStringList>
 | 
				
			||||||
 | 
					#include <QHash>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class CountryDat
 | 
					class CountryDat
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,5 @@
 | 
				
			|||||||
#include "logbook.h"
 | 
					#include "logbook.h"
 | 
				
			||||||
 | 
					#include <QDebug>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void LogBook::init()
 | 
					void LogBook::init()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -58,7 +58,7 @@ void LogBook::match(/*in*/const QString call,
 | 
				
			|||||||
          countryWorkedBefore = false;
 | 
					          countryWorkedBefore = false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    qDebug() << "Logbook:" << call << ":" << countryName << "Cty B4:" << countryWorkedBefore << "call B4:" << callWorkedBefore;
 | 
					    //qDebug() << "Logbook:" << call << ":" << countryName << "Cty B4:" << countryWorkedBefore << "call B4:" << callWorkedBefore;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void LogBook::addAsWorked(const QString call)
 | 
					void LogBook::addAsWorked(const QString call)
 | 
				
			||||||
 | 
				
			|||||||
@ -7,7 +7,7 @@
 | 
				
			|||||||
#define LOGBOOK_H
 | 
					#define LOGBOOK_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QtGui>
 | 
					#include <QString>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "countrydat.h"
 | 
					#include "countrydat.h"
 | 
				
			||||||
#include "countriesworked.h"
 | 
					#include "countriesworked.h"
 | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,4 @@
 | 
				
			|||||||
//------------------------------------------------------------- MainWindow
 | 
					//-------------------------------------------------------------- MainWindow
 | 
				
			||||||
#include "mainwindow.h"
 | 
					#include "mainwindow.h"
 | 
				
			||||||
#include "ui_mainwindow.h"
 | 
					#include "ui_mainwindow.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -2223,7 +2223,7 @@ p, li { white-space: pre-wrap; }
 | 
				
			|||||||
     <x>0</x>
 | 
					     <x>0</x>
 | 
				
			||||||
     <y>0</y>
 | 
					     <y>0</y>
 | 
				
			||||||
     <width>760</width>
 | 
					     <width>760</width>
 | 
				
			||||||
     <height>21</height>
 | 
					     <height>20</height>
 | 
				
			||||||
    </rect>
 | 
					    </rect>
 | 
				
			||||||
   </property>
 | 
					   </property>
 | 
				
			||||||
   <widget class="QMenu" name="menuFile">
 | 
					   <widget class="QMenu" name="menuFile">
 | 
				
			||||||
@ -2615,7 +2615,7 @@ p, li { white-space: pre-wrap; }
 | 
				
			|||||||
    <bool>true</bool>
 | 
					    <bool>true</bool>
 | 
				
			||||||
   </property>
 | 
					   </property>
 | 
				
			||||||
   <property name="text">
 | 
					   <property name="text">
 | 
				
			||||||
    <string>Show DXCC entity and B4 status</string>
 | 
					    <string>Show DXCC entity and worked B4 status</string>
 | 
				
			||||||
   </property>
 | 
					   </property>
 | 
				
			||||||
  </action>
 | 
					  </action>
 | 
				
			||||||
 </widget>
 | 
					 </widget>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user