~ea4k/klog/trunk

« back to all changes in this revision

Viewing changes to branches/1.3/awards.h

  • Committer: jaime
  • Date: 2020-10-03 09:19:54 UTC
  • Revision ID: svn-v4:5834a56a-7829-0410-841d-b57922c102d6::782
KLogĀ 1.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef AWARDS_H
 
2
#define AWARDS_H
 
3
/***************************************************************************
 
4
                          awards.h  -  description
 
5
                             -------------------
 
6
    begin                : sept 2011
 
7
    copyright            : (C) 2011 by Jaime Robles
 
8
    email                : jaime@robles.es
 
9
 ***************************************************************************/
 
10
 
 
11
/*****************************************************************************
 
12
 * This file is part of KLog.                                                *
 
13
 *                                                                           *
 
14
 *    KLog is free software: you can redistribute it and/or modify           *
 
15
 *    it under the terms of the GNU General Public License as published by   *
 
16
 *    the Free Software Foundation, either version 3 of the License, or      *
 
17
 *    (at your option) any later version.                                    *
 
18
 *                                                                           *
 
19
 *    KLog is distributed in the hope that it will be useful,                *
 
20
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 
21
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
 
22
 *    GNU General Public License for more details.                           *
 
23
 *                                                                           *
 
24
 *    You should have received a copy of the GNU General Public License      *
 
25
 *    along with KLog.  If not, see <https://www.gnu.org/licenses/>.         *
 
26
 *                                                                           *
 
27
 *****************************************************************************/
 
28
 
 
29
//#include <QObject> // For the "tr" function
 
30
 
 
31
#include <QString>
 
32
#include <QSqlQuery>
 
33
#include <QSqlRecord>
 
34
#include <QVariant>
 
35
#include <QColor>
 
36
#include <QStringList>
 
37
#include <QProgressDialog>
 
38
#include <QMultiHash>
 
39
#include <QObject>
 
40
#include <QtGlobal>
 
41
 
 
42
#include "world.h"
 
43
#include "awarddxmarathon.h"
 
44
#include "dataproxy_sqlite.h"
 
45
#include "utilities.h"
 
46
 
 
47
class QProgressDialog;
 
48
 
 
49
 
 
50
class Awards : public QObject {
 
51
     Q_OBJECT
 
52
    //friend class World;
 
53
 
 
54
public:
 
55
    Awards(DataProxy_SQLite *dp, const QString &_parentFunction);
 
56
    ~Awards();
 
57
    void setAwards(const int _qsoId);
 
58
    void setAwards(const int _dxcc, const int _waz, const int _band, const int _mode, const int _workedOrConfirmed, const int _logNumber, const int _qsoId);
 
59
    /*
 
60
    _workedOrConfirmed = 0     Set as Worked
 
61
    _workedOrConfirmed = 1     Set as Confirmed
 
62
    */
 
63
    void setManageModes(const bool _manageModes=false);   // Defines if the mode is to be taken into account when calculating an award
 
64
 
 
65
    void recalculateAwards();
 
66
    //void recalculateDXCC(const int _logNumber);
 
67
    //void setAwards(const int _qsoId, bool modify);
 
68
    int getDXCCWorked(const int _logNumber);
 
69
    int getDXCCConfirmed(const int _logNumber);
 
70
    int getWAZWorked(const int _logNumber);
 
71
    int getWAZConfirmed(const int _logNumber);
 
72
 
 
73
 
 
74
 
 
75
    int getQSOsInLog(const int _logNumber);
 
76
 
 
77
    bool getIsDXCCConfirmed(const int _dxcc, const int _logNumber);
 
78
    bool isThisSpotConfirmed(const QStringList &_qs);
 
79
 
 
80
    QString checkIfValidIOTA(const QString &_tiota); //TODO: There is an equivalent function in the MainWindowInputOthers class. I should use only one!
 
81
 
 
82
    int getEntityDXStatus (const int _enti, const int _bandid, int _modeid = -1, int _log = -1);
 
83
    QString getQSOofAward (const int _enti, const int _bandid);
 
84
    int getQSOIdofAward (const int _enti, const int _bandid);
 
85
 
 
86
    int getDXStatus (const QStringList &_qs);
 
87
    QString getDXStatusString (const int &_status); // Needs to be called with the output of getDXStatus
 
88
    QString getDXCCStatusBand(const int _dxcc, const int _band, const int _logNumber=0); // Returns -, W or C (Not worked, worked, Confirmed)
 
89
 
 
90
    void setColors (const QString &_newOne, const QString &_needed, const QString &_worked, const QString &_confirmed, const QString &_default);
 
91
    QColor getQRZDXStatusColor(const QStringList &_qs); // Receives Entity, band, mode & log
 
92
    QColor getDefaultColor();
 
93
 
 
94
    int getDXMarathonQSO(const int _year, const int _logNumber);
 
95
    int getDXMarathonDXCC(const int _year, const int _logNumber);
 
96
    int getDXMarathonCQ(const int _year, const int _logNumber);
 
97
    int getDXMarathonScore(const int _year, const int _logNumber);
 
98
    bool isDXMarathonNeed(const int _dxcc, const int _cq, const int _year, const int _logNumber);
 
99
 
 
100
    // Receives:  QStringList _qs;
 
101
    //_qs << QRZ << BandId << lognumber;
 
102
    /*
 
103
    0 - New one.
 
104
    1 - Worked but not confirmed: New one in this band.
 
105
    2 - Worked but not confirmed: Worked in this band.
 
106
    3 - Confirmed: New one in this band.
 
107
    4 - Confirmed: Worked in this band.
 
108
    5 - Confirmed: Confirmed in this band.
 
109
    6 - Default: Not applicable
 
110
    */
 
111
 
 
112
 
 
113
private:
 
114
 
 
115
    void setAwardDXCC(const int _qsoId);
 
116
    //bool setAwardDXCC(const int _dxcc, const int _band, const int _mode, const QString _workedOrConfirmed, const int _logNumber, const int _qsoId);
 
117
    int setAwardDXCCst(const int _dxcc, const int _band, const int _mode, const bool _confirmed, const int _logNumber, const int _qsoId);
 
118
 
 
119
    int setAwardDXCCConfirmed(const int _band, const int _mode, const int _dxcc, const int _newQSOid); // Changes the status of a DXCC from worked to confirmed
 
120
    int setDXCCToQSO(const int _dxcc, const int _qsoid); // Defines the DXCC in a QSO
 
121
    int setCQToQSO(const int _cqz, const int _qsoid); // Defines the CQ zone in a QSO
 
122
 
 
123
    int dxccStatusBandMode(const int _ent, const int _band, const int _mode, const int _logNumber, bool _checkingMode); //-1 error / 0 Not worked / 1 worked / 2 confirmed
 
124
    int dxccStatus(const int _ent, const int _logNumber); //-1 error / 0 Not worked / 1 worked / 2 confirmed
 
125
 
 
126
    /*
 
127
    _confirmed = 0     Set as Worked
 
128
    _cConfirmed = 1     Set as Confirmed
 
129
    */
 
130
 
 
131
 
 
132
    /**/
 
133
    int dxccStatusBand(const int _ent, const int band, const int _logNumber); //-1 error / 0 Not worked / 1 worked / 2 confirmed
 
134
    int dxccStatusMode(const int _ent, const int band, const int _logNumber); //-1 error / 0 Not worked / 1 worked / 2 confirmed
 
135
    /**/
 
136
 
 
137
    void setAwardWAZ(const int _qsoId);
 
138
    //bool setAwardWAZ(const int _cqz, const int _band, const int _mode, const QString _workedOrConfirmed, const int _logNumber, const int _qsoId);
 
139
    int setAwardWAZst(const int _cqz, const int _band, const int _mode, const bool _confirmed, const int _logNumber, const int _qsoId);
 
140
    /*
 
141
    _confirmed = 0     Set as Worked
 
142
    _confirmed = 1     Set as Confirmed
 
143
    */
 
144
    //int getProgresStepForDialog(int totalSteps);
 
145
 
 
146
    QColor newOneColor;     //
 
147
    QColor neededColor;     //
 
148
    QColor workedColor;     //
 
149
    QColor confirmedColor;  //
 
150
    QColor defaultColor;
 
151
 
 
152
    World *world;
 
153
    DataProxy_SQLite *dataProxy;
 
154
    DXMarathon *dxMarathon;
 
155
    Utilities *util;
 
156
 
 
157
 
 
158
    typedef QMultiHash<int, int> DXStatus;
 
159
 
 
160
    DXStatus dxccWorked, dxccConfirmed, wazWorked, wazConfirmed;
 
161
    bool manageModes;
 
162
 
 
163
signals:
 
164
    void queryError(QString functionFailed, QString errorCodeS, int errorCodeN, QString failedQuery); // To alert about any failed query execution
 
165
    void awardDXCCUpdated();
 
166
 
 
167
};
 
168
#endif // AWARDS_H