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.7 by maloninc, Mon Aug 1 10:46:20 2005 UTC revision 1.10 by maloninc, Sat Aug 13 06:12:05 2005 UTC
# Line 4  Line 4 
4  #include "mnDef.h"  #include "mnDef.h"
5  #include "mnController.h"  #include "mnController.h"
6  #include <wx/config.h>  #include <wx/config.h>
7    #include <wx/tokenzr.h>
8    #include <wx/utils.h>
9    
10  BEGIN_EVENT_TABLE(mnController, wxEvtHandler)  BEGIN_EVENT_TABLE(mnController, wxEvtHandler)
11          EVT_TEXT_ENTER(ID_SearchTextCtrl, mnController::handleSearch)          EVT_TEXT_ENTER(ID_SearchTextCtrl, mnController::handleSearch)
# Line 28  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 62  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 77  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 96  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 137  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 165  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 174  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 231  void mnController::handleEditButton(wxCo Line 222  void mnController::handleEditButton(wxCo
222    
223  void mnController::handleLinkClick(wxCommandEvent &event)  void mnController::handleLinkClick(wxCommandEvent &event)
224  {  {
225          wxLogMessage(event.GetString());          const wxString* wikiDataDir;
226            wxString href = event.GetString();
227            wxString tag;
228            wxString val;
229            wxString doc;
230            wxStringTokenizer tkz(href, wxT(":"));
231    
232            tag = tkz.GetNextToken();      
233            val = tkz.GetNextToken();
234            if(tag.CmpNoCase(wxT("mnlink")) == 0) {
235                    event.SetString(val);
236                    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 {
244                    openUrl(href);
245            }
246    }
247    
248    void mnController::openUrl(wxString& url)
249    {
250            wxString cmd;
251    
252    #ifdef __WXMSW__
253            cmd.sprintf(wxT("explorer %s"), url.c_str());
254    #endif
255    
256    #ifdef __WXMAC__
257            cmd.sprintf(wxT("open %s"), url.c_str());
258    #endif
259    
260    #ifdef __WXCOCOA__
261            cmd.sprintf(wxT("open %s"), url.c_str());
262    #endif
263    
264    #ifdef __WXGTK__
265            wxLogMessage(wxT("Ooops!, I don't know how to launch %s"), url.c_str());
266            return;
267    #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);
295            wxExecute(cmd);
296    }

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

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