| 25 |
EVT_MENU(XRCID("Quit"), mnFrameController::handleExit) |
EVT_MENU(XRCID("Quit"), mnFrameController::handleExit) |
| 26 |
EVT_MENU(wxID_ABOUT, mnFrameController::handleAbout) |
EVT_MENU(wxID_ABOUT, mnFrameController::handleAbout) |
| 27 |
EVT_CLOSE(mnFrameController::handleClose) |
EVT_CLOSE(mnFrameController::handleClose) |
| 28 |
|
EVT_NOTEBOOK_PAGE_CHANGED(XRCID("noteBook"), mnFrameController::handlePageChange) |
| 29 |
END_EVENT_TABLE() |
END_EVENT_TABLE() |
| 30 |
|
|
| 31 |
mnFrameController::mnFrameController(mnFrame* inframe) |
mnFrameController::mnFrameController(mnFrame* inframe) |
| 113 |
dlg = new wxDirDialog(frame); |
dlg = new wxDirDialog(frame); |
| 114 |
if(dlg->ShowModal() == wxID_OK) { |
if(dlg->ShowModal() == wxID_OK) { |
| 115 |
gotDirName = dlg->GetPath(); |
gotDirName = dlg->GetPath(); |
| 116 |
frame->addNotePanel(&gotDirName); |
if(isExistConfig(&gotDirName) == false){ |
| 117 |
|
frame->addNotePanel(&gotDirName); |
| 118 |
|
} |
| 119 |
|
else { |
| 120 |
|
wxMessageBox(wxT("It already exist in MalonNote"), wxT("Already exist"), wxOK|wxICON_INFORMATION); |
| 121 |
|
return; |
| 122 |
|
} |
| 123 |
} |
} |
| 124 |
updateConfig(); |
updateConfig(); |
| 125 |
} |
} |
| 138 |
|
|
| 139 |
wxConfig* config = new wxConfig(wxT(CONF_APP_NAME)); |
wxConfig* config = new wxConfig(wxT(CONF_APP_NAME)); |
| 140 |
config->DeleteAll(); |
config->DeleteAll(); |
| 141 |
|
delete config; |
| 142 |
|
config = new wxConfig(wxT(CONF_APP_NAME)); // recreate config object |
| 143 |
notebook = frame->getNotebook(); |
notebook = frame->getNotebook(); |
| 144 |
int count = notebook->GetPageCount(); |
int count = notebook->GetPageCount(); |
| 145 |
for(int i = 0; i < count; i++) { |
for(int i = 0; i < count; i++) { |
| 156 |
} |
} |
| 157 |
delete config; |
delete config; |
| 158 |
} |
} |
| 159 |
|
|
| 160 |
|
bool mnFrameController::isExistConfig(wxString* dir) |
| 161 |
|
{ |
| 162 |
|
wxString* dirName = new wxString(); |
| 163 |
|
wxString gotDirName; |
| 164 |
|
wxDirDialog* dlg; |
| 165 |
|
wxString confKey; |
| 166 |
|
|
| 167 |
|
wxConfig* config = new wxConfig(wxT(CONF_APP_NAME)); |
| 168 |
|
for(int i = 0; ;i++) { |
| 169 |
|
if(i == 0) { |
| 170 |
|
confKey.sprintf(wxT(CONF_WIKI_DIR)); |
| 171 |
|
} |
| 172 |
|
else { |
| 173 |
|
confKey.sprintf(wxT(CONF_WIKI_DIR) "%d", i); |
| 174 |
|
} |
| 175 |
|
if(config->Read(confKey.c_str(), dirName)) { |
| 176 |
|
if(*dir == *dirName) return true; /* Exist */ |
| 177 |
|
} |
| 178 |
|
else { |
| 179 |
|
break; |
| 180 |
|
} |
| 181 |
|
} |
| 182 |
|
|
| 183 |
|
delete dirName; |
| 184 |
|
delete config; |
| 185 |
|
|
| 186 |
|
return false; |
| 187 |
|
} |
| 188 |
|
|
| 189 |
|
|
| 190 |
|
void mnFrameController::handlePageChange(wxNotebookEvent& event) |
| 191 |
|
{ |
| 192 |
|
wxNotebook* notebook; |
| 193 |
|
mnNotePanel* panel; |
| 194 |
|
|
| 195 |
|
notebook = frame->getNotebook(); |
| 196 |
|
panel = (mnNotePanel*)notebook->GetPage(event.GetSelection()); |
| 197 |
|
const wxString* dataDir = panel->getController()->getWikiDataDir(); |
| 198 |
|
|
| 199 |
|
frame->GetStatusBar()->SetStatusText(*dataDir); |
| 200 |
|
} |