Develop and Download Open Source Software

Browse CVS Repository

Diff of /malonnote/mnFrameController.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.4 by maloninc, Thu Oct 6 05:29:01 2005 UTC revision 1.7 by maloninc, Tue Oct 11 09:05:15 2005 UTC
# Line 25  BEGIN_EVENT_TABLE(mnFrameController, wxE Line 25  BEGIN_EVENT_TABLE(mnFrameController, wxE
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)
# Line 112  void mnFrameController::handleAddDir(wxC Line 113  void mnFrameController::handleAddDir(wxC
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  }  }
# Line 131  void mnFrameController::updateConfig() Line 138  void mnFrameController::updateConfig()
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++) {
# Line 147  void mnFrameController::updateConfig() Line 156  void mnFrameController::updateConfig()
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    }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.7

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26