-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDataModel.h
More file actions
64 lines (54 loc) · 2.03 KB
/
DataModel.h
File metadata and controls
64 lines (54 loc) · 2.03 KB
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
#ifndef DATAMODEL_H
#define DATAMODEL_H
#include <marble/GeoDataDocument.h>
#include <marble/GeoDataPlacemark.h>
#include <marble/GeoDataStyle.h>
#include <marble/GeoDataTreeModel.h>
#include <marble/GeoPainter.h>
#include <QMap>
#include "FriendMapSettings.h"
#include "GeoPeer.h"
#include "PositionManager.h"
#include "gui/notifyqt.h"
#include "interface.h"
class DataModel : public QObject {
public:
explicit DataModel(GeoDataTreeModel* treeModel);
~DataModel();
const GeoPeer& getPeer(const RsPgpId& pgp_id) const;
const QList<GeoPeer*> getPeers() const;
const GeoDataCoordinates getPosition(const GeoPeerLoc& geoloc);
const GeoPeerLoc& getLocationBySslID(const RsPeerId& peer_ssl_id) const;
/*!
* \brief getLocationByName
* \param name Name in the form "PeerName (LocationName)"
* \return ssl id
*/
const RsPeerId getLocationByName(const std::string& name) const;
std::list<const GeoPeerLoc*> getLocations(const GeoPeer& peer) const;
GeoDataCoordinates getMainLocation(const GeoPeer& peer) const;
private:
void updateAvatar(const std::string& peer_ssl_id);
void updatePeerStatus(const std::string& peer_ssl_id, uint32_t /*status*/);
class myNotifyClient : public NotifyClient {
public:
explicit myNotifyClient(DataModel* data_model) : data_model(data_model) {}
virtual void notifyPeerHasNewAvatar(std::string peer_id) {
data_model->updateAvatar(peer_id);
}
virtual void notifyPeerStatusChanged(const std::string& peer_id, uint32_t status) {
data_model->updatePeerStatus(peer_id, status);
}
private:
DataModel* data_model;
};
std::list<GeoPeer> geoPeers;
QMap<RsPgpId, GeoPeer*> peerTable;
QMap<RsPeerId, QSharedPointer<GeoPeerLoc> > peer_ssl_id_table;
QMap<std::string, QSharedPointer<const GeoPeerLoc> > name2loc_table;
void genPeerCache();
void addPeer(const RsPgpId& gpg_id);
myNotifyClient* notify_client;
GeoDataDocument* getDocument();
};
#endif // DATAMODEL_H