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.12 by maloninc, Sat Aug 27 01:19:57 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 139  void mnController::handleRemoveButton(wx Line 136  void mnController::handleRemoveButton(wx
136                  wiki->removeSearchStr(frame->getSelectedLabel());                  wiki->removeSearchStr(frame->getSelectedLabel());
137          }          }
138          frame->showSearchResult(wiki);          frame->showSearchResult(wiki);
         isEditing = FALSE;  
139  }  }
140    
141    void mnController::handleHighlightButton(wxCommandEvent& event)
142    {
143            frame->highlightSelectedItem();
144    }
145    
146    
147  void mnController::handleTreeItemSelect(wxTreeEvent& event)  void mnController::handleTreeItemSelect(wxTreeEvent& event)
148  {  {
149          frame->showSelectedItemText(event);          frame->showSelectedItemText(event);
         isEditing = FALSE;  
150  }  }
151    
152    
153  void mnController::handleTreeItemSelecting(wxTreeEvent& event)  void mnController::handleTreeItemSelecting(wxTreeEvent& event)
154  {  {
         if(frame->isNewItem(event.GetOldItem())) {  
                 frame->showSearchResult(wiki);  
                 event.Veto();  
         }  
155  }  }
156    
157  void mnController::handleBeginLabelEdit(wxTreeEvent& event)  void mnController::handleBeginLabelEdit(wxTreeEvent& event)
# Line 167  void mnController::handleEndLabelEdit(wx Line 164  void mnController::handleEndLabelEdit(wx
164          wxString newSubject   = event.GetLabel();          wxString newSubject   = event.GetLabel();
165          wxTreeItemData* item  = frame->getSelectedItem();          wxTreeItemData* item  = frame->getSelectedItem();
166    
167          if(item == NULL) return ;          if(item == NULL) {
168                    return ;
169            }
170                    
171          if(newSubject.Len() == 0) {          if(newSubject.Len() == 0) {
172                  event.Veto();                  event.Veto();
# Line 176  void mnController::handleEndLabelEdit(wx Line 175  void mnController::handleEndLabelEdit(wx
175          }          }
176    
177          ((WikiData*)(item))->modSubject(&newSubject);          ((WikiData*)(item))->modSubject(&newSubject);
         if(frame->isNewItem(event.GetItem())){  
                 return;  
         }  
178    
179          event.Veto();          event.Veto();
180          frame->showSearchResult(wiki);          frame->showSearchResult(wiki);
# Line 233  void mnController::handleEditButton(wxCo Line 229  void mnController::handleEditButton(wxCo
229    
230  void mnController::handleLinkClick(wxCommandEvent &event)  void mnController::handleLinkClick(wxCommandEvent &event)
231  {  {
232            const wxString* wikiDataDir;
233          wxString href = event.GetString();          wxString href = event.GetString();
234          wxString tag;          wxString tag;
235          wxString url;          wxString val;
236            wxString doc;
237          wxStringTokenizer tkz(href, wxT(":"));          wxStringTokenizer tkz(href, wxT(":"));
238    
239          tag = tkz.GetNextToken();                tag = tkz.GetNextToken();      
240          url = tkz.GetNextToken();          val = tkz.GetNextToken();
241            if(tag.CmpNoCase(wxT("mnlink")) == 0) {
242          if(tag.Cmp(wxT("mnlink")) == 0) {                  event.SetString(val);
                 event.SetString(url);  
243                  handleSearch(event);                  handleSearch(event);
244          }          }
245            else if(tag.CmpNoCase(wxT("mndoc")) == 0) {
246                    wikiDataDir = wiki->getWikiDataDir();
247                    doc = *wikiDataDir + wxT("/docs/") + val;
248                    openDoc(doc);
249            }
250          else {          else {
251                  openUrl(href);                  openUrl(href);
252          }          }
# Line 252  void mnController::handleLinkClick(wxCom Line 254  void mnController::handleLinkClick(wxCom
254    
255  void mnController::openUrl(wxString& url)  void mnController::openUrl(wxString& url)
256  {  {
         wxChar* argv[5];  
257          wxString cmd;          wxString cmd;
258    
259  #ifdef __WXMSW__  #ifdef __WXMSW__
         argv[0] = wxT("explorer");  
         argv[1] = (wxChar*)url.c_str();  
         argv[2] = NULL;  
260          cmd.sprintf(wxT("explorer %s"), url.c_str());          cmd.sprintf(wxT("explorer %s"), url.c_str());
261  #endif  #endif
262    
# Line 271  void mnController::openUrl(wxString& url Line 269  void mnController::openUrl(wxString& url
269  #endif  #endif
270    
271  #ifdef __WXGTK__  #ifdef __WXGTK__
272          wxLogMessage(wxT("Ooops!, I don't know how to launch %s"), url.c_str());          cmd.sprintf(wxT("gnome-open %s"), url.c_str());
         return;  
273  #endif  #endif
274    
275          //wxExecute(argv);          //wxExecute(argv);
276          wxExecute(cmd);          wxExecute(cmd);
277  }  }
278    
279    void mnController::openDoc(wxString& doc)
280    {
281            wxString cmd;
282    
283    #ifdef __WXMSW__
284            cmd.sprintf(wxT("cmd /c \"start %s\""), doc.c_str());
285    #endif
286    
287    #ifdef __WXMAC__
288            cmd.sprintf(wxT("open %s"), doc.c_str());
289    #endif
290    
291    #ifdef __WXCOCOA__
292            cmd.sprintf(wxT("open %s"), doc.c_str());
293    #endif
294    
295    #ifdef __WXGTK__
296            cmd.sprintf(wxT("gnome-open %s"), doc.c_str());
297    #endif
298    
299            wxExecute(cmd);
300    }

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

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