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.14 by maloninc, Tue Sep 13 00:51:06 2005 UTC
# Line 15  BEGIN_EVENT_TABLE(mnController, wxEvtHan Line 15  BEGIN_EVENT_TABLE(mnController, wxEvtHan
15          EVT_TREE_END_LABEL_EDIT(ID_SearchTree, mnController::handleEndLabelEdit)          EVT_TREE_END_LABEL_EDIT(ID_SearchTree, mnController::handleEndLabelEdit)
16          EVT_MENU(ID_MenuFileNew, mnController::handleNewButton)          EVT_MENU(ID_MenuFileNew, mnController::handleNewButton)
17          EVT_MENU(ID_MenuFileRemove, mnController::handleRemoveButton)          EVT_MENU(ID_MenuFileRemove, mnController::handleRemoveButton)
18            EVT_MENU(ID_MenuFileHighlight, mnController::handleHighlightButton)
19          EVT_MENU(ID_MenuFileEdit, mnController::handleEditButton)          EVT_MENU(ID_MenuFileEdit, mnController::handleEditButton)
20          EVT_MENU(ID_MenuFileExit, mnController::handleExit)          EVT_MENU(ID_MenuFileExit, mnController::handleExit)
21          EVT_MENU(ID_MenuFileConfig, mnController::handleConfig)          EVT_MENU(ID_MenuFileConfig, mnController::handleConfig)
# Line 30  mnController::mnController(mnFrame* infr Line 31  mnController::mnController(mnFrame* infr
31          wxDirDialog* dlg;          wxDirDialog* dlg;
32    
33          frame = inframe;          frame = inframe;
         isEditing = FALSE;  
34    
35          /* create wiki model */          /* create wiki model */
36          wxConfig* config = new wxConfig(wxT(CONF_APP_NAME));          wxConfig* config = new wxConfig(wxT(CONF_APP_NAME));
# Line 64  void mnController::handleConfig(wxComman Line 64  void mnController::handleConfig(wxComman
64          if(config->Read(wxT(CONF_WIKI_DIR), dirName)) {          if(config->Read(wxT(CONF_WIKI_DIR), dirName)) {
65                  if(wxMessageBox(*dirName, wxT("Change data directory?"), wxYES_NO|wxICON_QUESTION) == wxNO){                  if(wxMessageBox(*dirName, wxT("Change data directory?"), wxYES_NO|wxICON_QUESTION) == wxNO){
66                          delete config;                          delete config;
                         isEditing = FALSE;  
67                          return;                          return;
68                  }                  }
69          }                }      
# Line 79  void mnController::handleConfig(wxComman Line 78  void mnController::handleConfig(wxComman
78          delete config;          delete config;
79    
80          frame->showSearchResult(wiki);          frame->showSearchResult(wiki);
         isEditing = FALSE;  
81  }  }
82    
83  void mnController::handleSearch(wxCommandEvent& event)  void mnController::handleSearch(wxCommandEvent& event)
# Line 98  void mnController::handleSearch(wxComman Line 96  void mnController::handleSearch(wxComman
96    
97          wiki->addSearchStr(str);          wiki->addSearchStr(str);
98          frame->showSearchResult(wiki);          frame->showSearchResult(wiki);
         isEditing = FALSE;  
99  }  }
100    
101  void mnController::handleNewButton(wxCommandEvent& event)  void mnController::handleNewButton(wxCommandEvent& event)
# Line 133  void mnController::handleRemoveButton(wx Line 130  void mnController::handleRemoveButton(wx
130          wxTreeItemData* item = frame->getSelectedItem();          wxTreeItemData* item = frame->getSelectedItem();
131    
132          if(item){          if(item){
133                  ((WikiData*)(item))->removeDataFile();                  if(wxMessageBox(wxT("Do you realy remove this memo?\n") + frame->getSelectedLabel(), wxT("Realy?"), wxYES_NO|wxICON_QUESTION) == wxYES){
134                            ((WikiData*)(item))->removeDataFile();
135                    }
136          }          }
137          else {          else {
138                  wiki->removeSearchStr(frame->getSelectedLabel());                  wiki->removeSearchStr(frame->getSelectedLabel());
139          }          }
140          frame->showSearchResult(wiki);          frame->showSearchResult(wiki);
         isEditing = FALSE;  
141  }  }
142    
143    void mnController::handleHighlightButton(wxCommandEvent& event)
144    {
145            frame->highlightSelectedItem();
146    }
147    
148    
149  void mnController::handleTreeItemSelect(wxTreeEvent& event)  void mnController::handleTreeItemSelect(wxTreeEvent& event)
150  {  {
151          frame->showSelectedItemText(event);          frame->showSelectedItemText(event);
         isEditing = FALSE;  
152  }  }
153    
154    
155  void mnController::handleTreeItemSelecting(wxTreeEvent& event)  void mnController::handleTreeItemSelecting(wxTreeEvent& event)
156  {  {
         if(frame->isNewItem(event.GetOldItem())) {  
                 frame->showSearchResult(wiki);  
                 event.Veto();  
         }  
157  }  }
158    
159  void mnController::handleBeginLabelEdit(wxTreeEvent& event)  void mnController::handleBeginLabelEdit(wxTreeEvent& event)
# Line 167  void mnController::handleEndLabelEdit(wx Line 166  void mnController::handleEndLabelEdit(wx
166          wxString newSubject   = event.GetLabel();          wxString newSubject   = event.GetLabel();
167          wxTreeItemData* item  = frame->getSelectedItem();          wxTreeItemData* item  = frame->getSelectedItem();
168    
169          if(item == NULL) return ;          if(item == NULL) {
170                    return ;
171            }
172                    
173          if(newSubject.Len() == 0) {          if(newSubject.Len() == 0) {
174                  event.Veto();                  event.Veto();
# Line 176  void mnController::handleEndLabelEdit(wx Line 177  void mnController::handleEndLabelEdit(wx
177          }          }
178    
179          ((WikiData*)(item))->modSubject(&newSubject);          ((WikiData*)(item))->modSubject(&newSubject);
         if(frame->isNewItem(event.GetItem())){  
                 return;  
         }  
180    
181          event.Veto();          event.Veto();
182          frame->showSearchResult(wiki);          frame->showSearchResult(wiki);
# Line 233  void mnController::handleEditButton(wxCo Line 231  void mnController::handleEditButton(wxCo
231    
232  void mnController::handleLinkClick(wxCommandEvent &event)  void mnController::handleLinkClick(wxCommandEvent &event)
233  {  {
234            const wxString* wikiDataDir;
235          wxString href = event.GetString();          wxString href = event.GetString();
236          wxString tag;          wxString tag;
237          wxString url;          wxString val;
238            wxString doc;
239          wxStringTokenizer tkz(href, wxT(":"));          wxStringTokenizer tkz(href, wxT(":"));
240    
241          tag = tkz.GetNextToken();                tag = tkz.GetNextToken();      
242          url = tkz.GetNextToken();          val = tkz.GetNextToken();
243            if(tag.CmpNoCase(wxT("mnlink")) == 0) {
244          if(tag.Cmp(wxT("mnlink")) == 0) {                  event.SetString(val);
                 event.SetString(url);  
245                  handleSearch(event);                  handleSearch(event);
246          }          }
247            else if(tag.CmpNoCase(wxT("mndoc")) == 0) {
248                    wikiDataDir = wiki->getWikiDataDir();
249                    doc = *wikiDataDir + wxT("/docs/") + val;
250                    openDoc(doc);
251            }
252          else {          else {
253                  openUrl(href);                  openUrl(href);
254          }          }
# Line 252  void mnController::handleLinkClick(wxCom Line 256  void mnController::handleLinkClick(wxCom
256    
257  void mnController::openUrl(wxString& url)  void mnController::openUrl(wxString& url)
258  {  {
         wxChar* argv[5];  
259          wxString cmd;          wxString cmd;
260    
261  #ifdef __WXMSW__  #ifdef __WXMSW__
         argv[0] = wxT("explorer");  
         argv[1] = (wxChar*)url.c_str();  
         argv[2] = NULL;  
262          cmd.sprintf(wxT("explorer %s"), url.c_str());          cmd.sprintf(wxT("explorer %s"), url.c_str());
263  #endif  #endif
264    
# Line 271  void mnController::openUrl(wxString& url Line 271  void mnController::openUrl(wxString& url
271  #endif  #endif
272    
273  #ifdef __WXGTK__  #ifdef __WXGTK__
274          wxLogMessage(wxT("Ooops!, I don't know how to launch %s"), url.c_str());          cmd.sprintf(wxT("gnome-open %s"), url.c_str());
         return;  
275  #endif  #endif
276    
277          //wxExecute(argv);          //wxExecute(argv);
278          wxExecute(cmd);          wxExecute(cmd);
279  }  }
280    
281    void mnController::openDoc(wxString& doc)
282    {
283            wxString cmd;
284    
285    #ifdef __WXMSW__
286            cmd.sprintf(wxT("cmd /c \"start %s\""), doc.c_str());
287    #endif
288    
289    #ifdef __WXMAC__
290            cmd.sprintf(wxT("open %s"), doc.c_str());
291    #endif
292    
293    #ifdef __WXCOCOA__
294            cmd.sprintf(wxT("open %s"), doc.c_str());
295    #endif
296    
297    #ifdef __WXGTK__
298            cmd.sprintf(wxT("gnome-open %s"), doc.c_str());
299    #endif
300    
301            wxExecute(cmd);
302    }

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

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