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.9 by maloninc, Thu Aug 4 05:10:02 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 176  void mnController::handleEndLabelEdit(wx Line 166  void mnController::handleEndLabelEdit(wx
166          }          }
167    
168          ((WikiData*)(item))->modSubject(&newSubject);          ((WikiData*)(item))->modSubject(&newSubject);
         if(frame->isNewItem(event.GetItem())){  
                 return;  
         }  
169    
170          event.Veto();          event.Veto();
171          frame->showSearchResult(wiki);          frame->showSearchResult(wiki);
# Line 233  void mnController::handleEditButton(wxCo Line 220  void mnController::handleEditButton(wxCo
220    
221  void mnController::handleLinkClick(wxCommandEvent &event)  void mnController::handleLinkClick(wxCommandEvent &event)
222  {  {
223            const wxString* wikiDataDir;
224          wxString href = event.GetString();          wxString href = event.GetString();
225          wxString tag;          wxString tag;
226          wxString url;          wxString val;
227            wxString doc;
228          wxStringTokenizer tkz(href, wxT(":"));          wxStringTokenizer tkz(href, wxT(":"));
229    
230          tag = tkz.GetNextToken();                tag = tkz.GetNextToken();      
231          url = tkz.GetNextToken();          val = tkz.GetNextToken();
232            if(tag.CmpNoCase(wxT("mnlink")) == 0) {
233          if(tag.Cmp(wxT("mnlink")) == 0) {                  event.SetString(val);
                 event.SetString(url);  
234                  handleSearch(event);                  handleSearch(event);
235          }          }
236            else if(tag.CmpNoCase(wxT("mndoc")) == 0) {
237                    wikiDataDir = wiki->getWikiDataDir();
238                    doc = *wikiDataDir + wxT("/docs/") + val;
239                    openDoc(doc);
240            }
241          else {          else {
242                  openUrl(href);                  openUrl(href);
243          }          }
# Line 252  void mnController::handleLinkClick(wxCom Line 245  void mnController::handleLinkClick(wxCom
245    
246  void mnController::openUrl(wxString& url)  void mnController::openUrl(wxString& url)
247  {  {
         wxChar* argv[5];  
248          wxString cmd;          wxString cmd;
249    
250  #ifdef __WXMSW__  #ifdef __WXMSW__
         argv[0] = wxT("explorer");  
         argv[1] = (wxChar*)url.c_str();  
         argv[2] = NULL;  
251          cmd.sprintf(wxT("explorer %s"), url.c_str());          cmd.sprintf(wxT("explorer %s"), url.c_str());
252  #endif  #endif
253    
# Line 275  void mnController::openUrl(wxString& url Line 264  void mnController::openUrl(wxString& url
264          return;          return;
265  #endif  #endif
266    
267            //wxExecute(argv);
268            wxExecute(cmd);
269    }
270    
271    void mnController::openDoc(wxString& doc)
272    {
273            wxString cmd;
274    
275    #ifdef __WXMSW__
276            cmd.sprintf(wxT("cmd /c \"start %s\""), doc.c_str());
277    #endif
278    
279    #ifdef __WXMAC__
280            cmd.sprintf(wxT("open %s"), doc.c_str());
281    #endif
282    
283    #ifdef __WXCOCOA__
284            cmd.sprintf(wxT("open %s"), doc.c_str());
285    #endif
286    
287    #ifdef __WXGTK__
288            wxLogMessage(wxT("Ooops!, I don't know how to launch %s"), doc.c_str());
289            return;
290    #endif
291    
292          //wxExecute(argv);          //wxExecute(argv);
293          wxExecute(cmd);          wxExecute(cmd);
294  }  }

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

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