-
Notifications
You must be signed in to change notification settings - Fork 0
/
ddmModel.h
80 lines (55 loc) · 2.1 KB
/
ddmModel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef DDM_MODEL_H
#define DDM_MODEL_H
#include <QObject>
#include <QtSql>
#include <QStringList>
#include <QVariantList>
#include <QVariantMap>
#include "ddmState.h"
#include "ddmCounty.h"
class QStringList;
typedef QMap<int, ddmState*> ddmStateMap;
typedef QMap<int, ddmCounty*> ddmCountyMap;
class ddmModel : public QObject
{
Q_OBJECT
public:
ddmModel( QObject* parent = 0 );
bool openDatabase( const QString& fullPath );
ddmStateMap& states() const;
ddmCountyMap& counties() const;
ddmState* currentState() const;
ddmCounty* currentCounty() const;
void setCurrentState( int id );
void setCurrentState( const QString& stateName );
void setCurrentCounty( int id );
void setCurrentCounty( const QString& countyName );
QStringList stateNames() const;
QStringList countyNames() const;
QVariantMap getProperties() const;
Q_PROPERTY( QVariantMap props READ getProperties );
// устанавливаем текущее графство в ГПИ при пикинге мышкой по карте
Q_INVOKABLE void setCurrentCountyFromJS( int countyId );
// получаем текущие координаты при движении мышки по карте
Q_INVOKABLE void getCurrentCoordsFromJS( const QString& lat, const QString& lng );
Q_INVOKABLE int getCurrentCountyId();
virtual ~ddmModel();
signals:
void changedState( ddmState* state );
void changedCounty( ddmCounty* county );
void changedCoords( const QString& lat, const QString& lng );
private:
typedef QMap<ddmState*, QList<ddmCounty*> > ddmStateCountyMap;
ddmStateMap m_states;
ddmCountyMap m_counties;
ddmStateCountyMap m_stateCounties;
ddmState* m_currentState;
ddmCounty* m_currentCounty;
QSqlDatabase m_db;
void loadStates();
void loadCounties();
void loadBoundaries();
void setCurrentState( ddmState* state );
void setCurrentCounty( ddmCounty* county );
};
#endif // DDM_MODEL_H