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.2 by maloninc, Wed Oct 5 04:55:48 2005 UTC revision 1.5 by maloninc, Fri Oct 7 10:19:46 2005 UTC
# Line 29  END_EVENT_TABLE() Line 29  END_EVENT_TABLE()
29    
30  mnFrameController::mnFrameController(mnFrame* inframe)  mnFrameController::mnFrameController(mnFrame* inframe)
31  {  {
         wxString* dirName = new wxString();  
         wxString gotDirName;  
         wxDirDialog* dlg;  
   
32          frame = inframe;          frame = inframe;
   
         /* create wiki model */  
         wxConfig* config = new wxConfig(wxT(CONF_APP_NAME));  
         if(config->Read(wxT(CONF_WIKI_DIR), dirName) == FALSE) {  
                 delete dirName;  
                 dlg = new wxDirDialog(frame);  
                 if(dlg->ShowModal() == wxID_OK) {  
                         gotDirName = dlg->GetPath();  
                         config->Write(wxT(CONF_WIKI_DIR), gotDirName.c_str());  
                         frame->addNotePanel(&gotDirName);  
                 }  
                 else {  
                         frame->Close();  
                 }  
         }  
         else {  
                 frame->addNotePanel(dirName);  
   
                 wxString testDir(wxT("C:\\wiki_test"));  
                 frame->addNotePanel(&testDir);  
         }  
   
         delete config;  
33  }  }
34    
35  void mnFrameController::handleConfig(wxCommandEvent& event)  void mnFrameController::handleConfig(wxCommandEvent& event)
# Line 132  void mnFrameController::handleAbout(wxCo Line 105  void mnFrameController::handleAbout(wxCo
105    
106  void mnFrameController::handleAddDir(wxCommandEvent& event)  void mnFrameController::handleAddDir(wxCommandEvent& event)
107  {  {
 /*  
108          wxDirDialog* dlg;          wxDirDialog* dlg;
109          wxString gotDirName;          wxString gotDirName;
110          wxString* dirName = new wxString();          wxString* dirName = new wxString();
111            
112            dlg = new wxDirDialog(frame);
113            if(dlg->ShowModal() == wxID_OK) {
114                    gotDirName = dlg->GetPath();
115                    if(isExistConfig(&gotDirName) == false){
116                            frame->addNotePanel(&gotDirName);
117                    }
118                    else {
119                            wxMessageBox(wxT("It already exist in MalonNote"), wxT("Already exist"), wxOK|wxICON_INFORMATION);
120                            return;
121                    }
122            }
123            updateConfig();
124    }
125    
126    void mnFrameController::handleRemoveDir(wxCommandEvent& event)
127    {
128            frame->removeSelectedNotePanel();
129            updateConfig();
130    }
131    
132    void mnFrameController::updateConfig()
133    {
134          wxString  confKey;          wxString  confKey;
135            wxNotebook* notebook;
136            mnNotePanel* panel;
137    
138          wxConfig* config = new wxConfig(wxT(CONF_APP_NAME));          wxConfig* config = new wxConfig(wxT(CONF_APP_NAME));
139            config->DeleteAll();
140            notebook = frame->getNotebook();
141            int count = notebook->GetPageCount();
142            for(int i = 0; i < count; i++) {
143                    panel = (mnNotePanel*)notebook->GetPage(i);
144                    const wxString* dataDir = panel->getController()->getWikiDataDir();
145    
146          dlg = new wxDirDialog(frame);                  if(i == 0){
147          if(dlg->ShowModal() == wxID_OK) {                          config->Write(wxT(CONF_WIKI_DIR), dataDir->c_str());
148                  gotDirName = dlg->GetPath();                  }
149                  confKey.sprintf(wxT(CONF_WIKI_DIR) "%d", numOfMemoDir);                  else{
150                  config->Write(wxT(CONF_WIKI_DIR), gotDirName.c_str());                          confKey.sprintf(wxT(CONF_WIKI_DIR) "%d", i);
151                            config->Write(confKey.c_str(), dataDir->c_str());
152                    }
153          }          }
154          delete config;          delete config;
 */  
 /*  
  * frame->addNotePanel を最終的に呼び出せばよい  
  * その後、frame->noteBook内の情報をNotePanel毎に一つずつ取り出し  
  * 一つ目をCONF_WIKI_DIR, 二つ目からCONF_WIKI_DIR+1のように設定ファイルに  
  * 記録すればよい  
  * 記録前に以前の記録をすべて削除するために、DeleteAllを呼ぶこと  
  */  
155  }  }
156    
157  void mnFrameController::handleRemoveDir(wxCommandEvent& event)  bool mnFrameController::isExistConfig(wxString* dir)
158  {  {
159            wxString* dirName = new wxString();
160            wxString gotDirName;
161            wxDirDialog* dlg;
162            wxString confKey;
163    
164            wxConfig* config = new wxConfig(wxT(CONF_APP_NAME));
165            for(int i = 0; ;i++) {
166                    if(i == 0) {
167                            confKey.sprintf(wxT(CONF_WIKI_DIR));
168                    }
169                    else {
170                            confKey.sprintf(wxT(CONF_WIKI_DIR) "%d", i);
171                    }
172                    if(config->Read(confKey.c_str(), dirName)) {
173                            if(*dir == *dirName) return true;    /* Exist */
174                    }
175                    else {
176                            break;
177                    }
178            }
179            
180            delete dirName;
181            delete config;
182    
183            return false;
184  }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.5

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