Develop and Download Open Source Software

Browse CVS Repository

Diff of /malonnote/mnController.cpp

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

revision 1.8 by maloninc, Tue Aug 2 07:21:38 2005 UTC revision 1.10 by maloninc, Sat Aug 13 06:12:05 2005 UTC
# Line 30  mnController::mnController(mnFrame* infr Line 30  mnController::mnController(mnFrame* infr
30          wxDirDialog* dlg;          wxDirDialog* dlg;
31    
32          frame = inframe;          frame = inframe;
         isEditing = FALSE;  
33    
34          /* create wiki model */          /* create wiki model */
35          wxConfig* config = new wxConfig(wxT(CONF_APP_NAME));          wxConfig* config = new wxConfig(wxT(CONF_APP_NAME));
# Line 64  void mnController::handleConfig(wxComman Line 63  void mnController::handleConfig(wxComman
63          if(config->Read(wxT(CONF_WIKI_DIR), dirName)) {          if(config->Read(wxT(CONF_WIKI_DIR), dirName)) {
64                  if(wxMessageBox(*dirName, wxT("Change data directory?"), wxYES_NO|wxICON_QUESTION) == wxNO){                  if(wxMessageBox(*dirName, wxT("Change data directory?"), wxYES_NO|wxICON_QUESTION) == wxNO){
65                          delete config;                          delete config;
                         isEditing = FALSE;  
66                          return;                          return;
67                  }                  }
68          }                }      
# Line 79  void mnController::handleConfig(wxComman Line 77  void mnController::handleConfig(wxComman
77          delete config;          delete config;
78    
79          frame->showSearchResult(wiki);          frame->showSearchResult(wiki);
         isEditing = FALSE;  
80  }  }
81    
82  void mnController::handleSearch(wxCommandEvent& event)  void mnController::handleSearch(wxCommandEvent& event)
# Line 98  void mnController::handleSearch(wxComman Line 95  void mnController::handleSearch(wxComman
95    
96          wiki->addSearchStr(str);          wiki->addSearchStr(str);
97          frame->showSearchResult(wiki);          frame->showSearchResult(wiki);
         isEditing = FALSE;  
98  }  }
99    
100  void mnController::handleNewButton(wxCommandEvent& event)  void mnController::handleNewButton(wxCommandEvent& event)
# Line 139  void mnController::handleRemoveButton(wx Line 135  void mnController::handleRemoveButton(wx
135                  wiki->removeSearchStr(frame->getSelectedLabel());                  wiki->removeSearchStr(frame->getSelectedLabel());
136          }          }
137          frame->showSearchResult(wiki);          frame->showSearchResult(wiki);
         isEditing = FALSE;  
138  }  }
139    
140  void mnController::handleTreeItemSelect(wxTreeEvent& event)  void mnController::handleTreeItemSelect(wxTreeEvent& event)
141  {  {
142          frame->showSelectedItemText(event);          frame->showSelectedItemText(event);
         isEditing = FALSE;  
143  }  }
144    
145    
146  void mnController::handleTreeItemSelecting(wxTreeEvent& event)  void mnController::handleTreeItemSelecting(wxTreeEvent& event)
147  {  {
         if(frame->isNewItem(event.GetOldItem())) {  
                 frame->showSearchResult(wiki);  
                 event.Veto();  
         }  
148  }  }
149    
150  void mnController::handleBeginLabelEdit(wxTreeEvent& event)  void mnController::handleBeginLabelEdit(wxTreeEvent& event)
# Line 167  void mnController::handleEndLabelEdit(wx Line 157  void mnController::handleEndLabelEdit(wx
157          wxString newSubject   = event.GetLabel();          wxString newSubject   = event.GetLabel();
158          wxTreeItemData* item  = frame->getSelectedItem();          wxTreeItemData* item  = frame->getSelectedItem();
159    
160          if(item == NULL) return ;          if(item == NULL) {
161                    return ;
162            }
163                    
164          if(newSubject.Len() == 0) {          if(newSubject.Len() == 0) {
165                  event.Veto();                  event.Veto();
# Line 176  void mnController::handleEndLabelEdit(wx Line 168  void mnController::handleEndLabelEdit(wx
168          }          }
169    
170          ((WikiData*)(item))->modSubject(&newSubject);          ((WikiData*)(item))->modSubject(&newSubject);
         if(frame->isNewItem(event.GetItem())){  
                 return;  
         }  
171    
172          event.Veto();          event.Veto();
173          frame->showSearchResult(wiki);          frame->showSearchResult(wiki);
# Line 233  void mnController::handleEditButton(wxCo Line 222  void mnController::handleEditButton(wxCo
222    
223  void mnController::handleLinkClick(wxCommandEvent &event)  void mnController::handleLinkClick(wxCommandEvent &event)
224  {  {
225            const wxString* wikiDataDir;
226          wxString href = event.GetString();          wxString href = event.GetString();
227          wxString tag;          wxString tag;
228          wxString url;          wxString val;
229            wxString doc;
230          wxStringTokenizer tkz(href, wxT(":"));          wxStringTokenizer tkz(href, wxT(":"));
231    
232          tag = tkz.GetNextToken();                tag = tkz.GetNextToken();      
233          url = tkz.GetNextToken();          val = tkz.GetNextToken();
234            if(tag.CmpNoCase(wxT("mnlink")) == 0) {
235          if(tag.Cmp(wxT("mnlink")) == 0) {                  event.SetString(val);
                 event.SetString(url);  
236                  handleSearch(event);                  handleSearch(event);
237          }          }
238            else if(tag.CmpNoCase(wxT("mndoc")) == 0) {
239                    wikiDataDir = wiki->getWikiDataDir();
240                    doc = *wikiDataDir + wxT("/docs/") + val;
241                    openDoc(doc);
242            }
243          else {          else {
244                  openUrl(href);                  openUrl(href);
245          }          }
# Line 252  void mnController::handleLinkClick(wxCom Line 247  void mnController::handleLinkClick(wxCom
247    
248  void mnController::openUrl(wxString& url)  void mnController::openUrl(wxString& url)
249  {  {
         wxChar* argv[5];  
250          wxString cmd;          wxString cmd;
251    
252  #ifdef __WXMSW__  #ifdef __WXMSW__
         argv[0] = wxT("explorer");  
         argv[1] = (wxChar*)url.c_str();  
         argv[2] = NULL;  
253          cmd.sprintf(wxT("explorer %s"), url.c_str());          cmd.sprintf(wxT("explorer %s"), url.c_str());
254  #endif  #endif
255    
# Line 275  void mnController::openUrl(wxString& url Line 266  void mnController::openUrl(wxString& url
266          return;          return;
267  #endif  #endif
268    
269            //wxExecute(argv);
270            wxExecute(cmd);
271    }
272    
273    void mnController::openDoc(wxString& doc)
274    {
275            wxString cmd;
276    
277    #ifdef __WXMSW__
278            cmd.sprintf(wxT("cmd /c \"start %s\""), doc.c_str());
279    #endif
280    
281    #ifdef __WXMAC__
282            cmd.sprintf(wxT("open %s"), doc.c_str());
283    #endif
284    
285    #ifdef __WXCOCOA__
286            cmd.sprintf(wxT("open %s"), doc.c_str());
287    #endif
288    
289    #ifdef __WXGTK__
290            wxLogMessage(wxT("Ooops!, I don't know how to launch %s"), doc.c_str());
291            return;
292    #endif
293    
294          //wxExecute(argv);          //wxExecute(argv);
295          wxExecute(cmd);          wxExecute(cmd);
296  }  }

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.10

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