blob: 5a0fd536bbcb7b68705f027ffac86710a06ff093 (
plain)
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
|
/*
* PreviewModel.h
*
* Created on: Jan 21, 2012
* Author: Simon
*/
#ifndef PREVIEWMODEL_H_
#define PREVIEWMODEL_H_
#include <vector>
#include <iostream>
#include <pthread.h>
#include "PreviewView.h"
#include "client/SaveInfo.h"
#include "preview/Comment.h"
#include "search/Thumbnail.h"
using namespace std;
struct SaveData
{
unsigned char * data;
int length;
};
class PreviewView;
class PreviewModel {
bool doOpen;
vector<PreviewView*> observers;
SaveInfo * save;
vector<char> saveDataBuffer;
std::vector<SaveComment*> * saveComments;
void notifySaveChanged();
void notifySaveCommentsChanged();
//Background retrieval
int tSaveID;
int tSaveDate;
bool updateSaveDataWorking;
volatile bool updateSaveDataFinished;
pthread_t updateSaveDataThread;
static void * updateSaveDataTHelper(void * obj);
void * updateSaveDataT();
bool updateSaveInfoWorking;
volatile bool updateSaveInfoFinished;
pthread_t updateSaveInfoThread;
static void * updateSaveInfoTHelper(void * obj);
void * updateSaveInfoT();
bool updateSaveCommentsWorking;
volatile bool updateSaveCommentsFinished;
pthread_t updateSaveCommentsThread;
static void * updateSaveCommentsTHelper(void * obj);
void * updateSaveCommentsT();
public:
PreviewModel();
SaveInfo * GetSave();
std::vector<SaveComment*> * GetComments();
void AddObserver(PreviewView * observer);
void UpdateSave(int saveID, int saveDate);
void SetFavourite(bool favourite);
bool GetDoOpen();
void SetDoOpen(bool doOpen);
void Update();
virtual ~PreviewModel();
};
#endif /* PREVIEWMODEL_H_ */
|