| 1 |
#ifndef MNMODEL_H |
| 2 |
#define MNMODEL_H |
| 3 |
|
| 4 |
#include <wx/wx.h> |
| 5 |
#include <wx/treebase.h> |
| 6 |
|
| 7 |
#include "config.h" |
| 8 |
|
| 9 |
#define MAX_WIKI_TEXT_SIZE 10000 |
| 10 |
#define MAX_TOKEN 32 |
| 11 |
#define MAX_BUF_SIZE 1024 |
| 12 |
#define EXT_TAG ".txt" |
| 13 |
#define DATE_TAG ":''DATE'':" |
| 14 |
#define TYPE_TAG ":''TYPE'':" |
| 15 |
#define NEW_DATA DATE_TAG " %Y/%m/%d %H:%M:%S\n\n" TYPE_TAG " memo\n---------------------------------------------------------\n" |
| 16 |
#define NEW_DATA_TEMPLATE "new.template" |
| 17 |
|
| 18 |
#define ALLMEMO_TAG "malon-all" |
| 19 |
#define TYPESEARCH_TAG "malon-type:" |
| 20 |
|
| 21 |
#define CODE_SET_EUC_JP "euc-jp" |
| 22 |
#ifdef __WXMAC__ |
| 23 |
#define CODE_SET_SYSTEM "CP932" |
| 24 |
#endif |
| 25 |
#ifdef __WXCOCOA__ |
| 26 |
#define CODE_SET_SYSTEM "CP932" |
| 27 |
#endif |
| 28 |
#ifdef __WXMSW__ |
| 29 |
#define CODE_SET_SYSTEM "CP932" |
| 30 |
#endif |
| 31 |
#ifdef __WXMOTIF__ |
| 32 |
#define CODE_SET_SYSTEM "eucJP" |
| 33 |
#endif |
| 34 |
#ifdef __WXGTK__ |
| 35 |
#define CODE_SET_SYSTEM "euc-jp" |
| 36 |
#endif |
| 37 |
#ifdef __WXX11__ |
| 38 |
#define CODE_SET_SYSTEM "eucJP" |
| 39 |
#endif |
| 40 |
|
| 41 |
#define MAC_BACKSLASH 0x80 |
| 42 |
|
| 43 |
|
| 44 |
class WikiData : wxTreeItemData{ |
| 45 |
|
| 46 |
public: |
| 47 |
WikiData(wxString* dataDir, wxString* fileName); |
| 48 |
WikiData(wxString* dataDir); |
| 49 |
~WikiData(); |
| 50 |
const wxString* getFileName(); |
| 51 |
const wxString* getSubject(); |
| 52 |
const wxString* getOldSubject(); |
| 53 |
const wxString* getDate(); |
| 54 |
const wxString* getText(); |
| 55 |
void modText(wxString* text); |
| 56 |
void modSubject(wxString* newName); |
| 57 |
void save(); |
| 58 |
void removeDataFile(); |
| 59 |
void setOldSubjectFromCurrent(); |
| 60 |
|
| 61 |
private: |
| 62 |
wxString* subject; |
| 63 |
wxString* oldSubject; |
| 64 |
wxString* dataDirName; |
| 65 |
wxString* fileName; |
| 66 |
wxString* date; |
| 67 |
wxString* text; |
| 68 |
}; |
| 69 |
|
| 70 |
/* Search Result List */ |
| 71 |
WX_DECLARE_LIST(WikiData, WikiList); |
| 72 |
|
| 73 |
/* Search Result Hash (Key is search string) */ |
| 74 |
WX_DECLARE_STRING_HASH_MAP(WikiList*, WikiHash); |
| 75 |
|
| 76 |
|
| 77 |
class mnModel { |
| 78 |
|
| 79 |
public: |
| 80 |
mnModel(const char* dataDir); |
| 81 |
~mnModel(); |
| 82 |
bool makeSearchToken(const char* searchStr, char* tokenList[]); |
| 83 |
bool matchWithToken(wxString* fileName, char* tokenList[]); |
| 84 |
WikiList* search(const char* searchStr); |
| 85 |
void group(); |
| 86 |
bool normalSearch(char* tokenList[], FILE*fp, char* decodeFileNameBuf); |
| 87 |
bool typeSearch(char* typeStr, FILE*fp); |
| 88 |
void addWikiData(WikiData* wikiData); |
| 89 |
bool addSearchStr(wxString* searchStr); |
| 90 |
void addSearchList(wxString* searchStr, WikiList* list); |
| 91 |
void removeSearchStr(wxString searchStr); |
| 92 |
void modSearchStr(wxString* oldStr, wxString* newStr); |
| 93 |
const wxArrayString* getSearchStrList(); |
| 94 |
const WikiList* getSearchResultList(wxString* searchStr); |
| 95 |
void addSearchResultList(wxString* searchStr, WikiData* addData); |
| 96 |
bool delSearchResultList(wxString* searchStr, WikiData* delData); |
| 97 |
WikiData* newWikiData(); |
| 98 |
const wxString* getWikiDataDir(); |
| 99 |
void clearSearchStrList(); |
| 100 |
void clearSearchResultList(); |
| 101 |
private: |
| 102 |
wxString* wikiDataDir; |
| 103 |
wxArrayString* searchStrList; |
| 104 |
WikiHash wikiHash; |
| 105 |
}; |
| 106 |
|
| 107 |
|
| 108 |
#endif //MNMODEL_H |