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.9 by maloninc, Thu Aug 4 05:10:02 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 174  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 231  void mnController::handleEditButton(wxCo Line 220  void mnController::handleEditButton(wxCo
220    
221  void mnController::handleLinkClick(wxCommandEvent &event)  void mnController::handleLinkClick(wxCommandEvent &event)
222  {  {
223          wxLogMessage(event.GetString());          const wxString* wikiDataDir;
224            wxString href = event.GetString();
225            wxString tag;
226            wxString val;
227            wxString doc;
228            wxStringTokenizer tkz(href, wxT(":"));
229    
230            tag = tkz.GetNextToken();      
231            val = tkz.GetNextToken();
232            if(tag.CmpNoCase(wxT("mnlink")) == 0) {
233                    event.SetString(val);
234                    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 {
242                    openUrl(href);
243            }
244  }  }
245    
246    void mnController::openUrl(wxString& url)
247    {
248            wxString cmd;
249    
250    #ifdef __WXMSW__
251            cmd.sprintf(wxT("explorer %s"), url.c_str());
252    #endif
253    
254    #ifdef __WXMAC__
255            cmd.sprintf(wxT("open %s"), url.c_str());
256    #endif
257    
258    #ifdef __WXCOCOA__
259            cmd.sprintf(wxT("open %s"), url.c_str());
260    #endif
261    
262    #ifdef __WXGTK__
263            wxLogMessage(wxT("Ooops!, I don't know how to launch %s"), url.c_str());
264            return;
265    #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);
293            wxExecute(cmd);
294    }

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

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