diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2013-03-24 12:24:17 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2013-03-24 12:24:17 (GMT) |
| commit | 9b5b85f9b01cbda7ef9a7ec2a15b2a35630a5b9d (patch) | |
| tree | ac7d040253b459ce102e476cb19ab59e3cfa90d7 /src/gui/preview/PreviewModel.h | |
| parent | 6bf98ccdca39936a3c51367862eed7c49f8786ec (diff) | |
| parent | bdc69f31c0be94191015838886bdcc2bc67f1acb (diff) | |
| download | powder-9b5b85f9b01cbda7ef9a7ec2a15b2a35630a5b9d.zip powder-9b5b85f9b01cbda7ef9a7ec2a15b2a35630a5b9d.tar.gz | |
Merge branch 'reorganisation' of github.com:FacialTurd/The-Powder-Toy
Diffstat (limited to 'src/gui/preview/PreviewModel.h')
| -rw-r--r-- | src/gui/preview/PreviewModel.h | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/src/gui/preview/PreviewModel.h b/src/gui/preview/PreviewModel.h new file mode 100644 index 0000000..846614c --- /dev/null +++ b/src/gui/preview/PreviewModel.h @@ -0,0 +1,85 @@ +#ifndef PREVIEWMODEL_H_ +#define PREVIEWMODEL_H_ + +#include <vector> +#include <iostream> +#include <pthread.h> +#undef GetUserName //God dammit microsoft! +#include "PreviewView.h" +#include "client/SaveInfo.h" +#include "gui/preview/Comment.h" +#include "gui/search/Thumbnail.h" + +using namespace std; + +struct SaveData +{ + unsigned char * data; + int length; +}; + +class PreviewView; +class PreviewModel { + bool doOpen; + bool commentBoxEnabled; + vector<PreviewView*> observers; + SaveInfo * save; + vector<char> saveDataBuffer; + std::vector<SaveComment*> * saveComments; + void notifySaveChanged(); + void notifySaveCommentsChanged(); + void notifyCommentsPageChanged(); + void notifyCommentBoxEnabledChanged(); + + //Background retrieval + int tSaveID; + int tSaveDate; + + // + bool commentsLoaded; + int commentsTotal; + int commentsPageNumber; + + bool updateSaveDataWorking; + volatile bool updateSaveDataFinished; + pthread_t updateSaveDataThread; + static void * updateSaveDataTHelper(void * obj); + static void updateSaveDataTDelete(void * arg); + void * updateSaveDataT(); + + bool updateSaveInfoWorking; + volatile bool updateSaveInfoFinished; + pthread_t updateSaveInfoThread; + static void * updateSaveInfoTHelper(void * obj); + static void updateSaveInfoTDelete(void * arg); + void * updateSaveInfoT(); + + bool updateSaveCommentsWorking; + volatile bool updateSaveCommentsFinished; + pthread_t updateSaveCommentsThread; + static void * updateSaveCommentsTHelper(void * obj); + static void updateSaveCommentsTDelete(void * arg); + void * updateSaveCommentsT(); +public: + PreviewModel(); + SaveInfo * GetSave(); + std::vector<SaveComment*> * GetComments(); + + bool GetCommentBoxEnabled(); + void SetCommentBoxEnabled(bool enabledState); + + bool GetCommentsLoaded(); + int GetCommentsPageNum(); + int GetCommentsPageCount(); + void UpdateComments(int pageNumber); + + 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_ */ |
