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.6 by maloninc, Sun Jul 31 22:22:14 2005 UTC revision 1.8 by maloninc, Tue Aug 2 07:21:38 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 18  BEGIN_EVENT_TABLE(mnController, wxEvtHan Line 20  BEGIN_EVENT_TABLE(mnController, wxEvtHan
20          EVT_MENU(ID_MenuFileConfig, mnController::handleConfig)          EVT_MENU(ID_MenuFileConfig, mnController::handleConfig)
21          EVT_MENU(wxID_ABOUT, mnController::handleAbout)          EVT_MENU(wxID_ABOUT, mnController::handleAbout)
22          EVT_CLOSE(mnController::handleClose)          EVT_CLOSE(mnController::handleClose)
23            EVT_COMMAND(ID_HtmlTextCtrl, mnEVT_LINK_CLICK, mnController::handleLinkClick)
24  END_EVENT_TABLE()  END_EVENT_TABLE()
25    
26  mnController::mnController(mnFrame* inframe)  mnController::mnController(mnFrame* inframe)
# Line 56  void mnController::handleConfig(wxComman Line 59  void mnController::handleConfig(wxComman
59          wxString gotDirName;          wxString gotDirName;
60          wxString* dirName = new wxString();          wxString* dirName = new wxString();
61    
         saveData();  
   
62          wxConfig* config = new wxConfig(wxT(CONF_APP_NAME));          wxConfig* config = new wxConfig(wxT(CONF_APP_NAME));
63    
64          if(config->Read(wxT(CONF_WIKI_DIR), dirName)) {          if(config->Read(wxT(CONF_WIKI_DIR), dirName)) {
# Line 87  void mnController::handleSearch(wxComman Line 88  void mnController::handleSearch(wxComman
88          WikiList*       wikiList;          WikiList*       wikiList;
89          WikiList::Node* node;          WikiList::Node* node;
90    
         saveData();  
   
91          wikiList = wiki->search(str->mb_str());          wikiList = wiki->search(str->mb_str());
92    
93          node = wikiList->GetFirst();          node = wikiList->GetFirst();
# Line 152  void mnController::handleTreeItemSelect( Line 151  void mnController::handleTreeItemSelect(
151    
152  void mnController::handleTreeItemSelecting(wxTreeEvent& event)  void mnController::handleTreeItemSelecting(wxTreeEvent& event)
153  {  {
         saveData();  
   
154          if(frame->isNewItem(event.GetOldItem())) {          if(frame->isNewItem(event.GetOldItem())) {
155                  frame->showSearchResult(wiki);                  frame->showSearchResult(wiki);
156                  event.Veto();                  event.Veto();
# Line 170  void mnController::handleEndLabelEdit(wx Line 167  void mnController::handleEndLabelEdit(wx
167          wxString newSubject   = event.GetLabel();          wxString newSubject   = event.GetLabel();
168          wxTreeItemData* item  = frame->getSelectedItem();          wxTreeItemData* item  = frame->getSelectedItem();
169    
         saveData();  
   
170          if(item == NULL) return ;          if(item == NULL) return ;
171                    
172          if(newSubject.Len() == 0) {          if(newSubject.Len() == 0) {
# Line 191  void mnController::handleEndLabelEdit(wx Line 186  void mnController::handleEndLabelEdit(wx
186    
187  void mnController::handleClose(wxCloseEvent& event)  void mnController::handleClose(wxCloseEvent& event)
188  {  {
         saveData();  
189          frame->Destroy();          frame->Destroy();
190  }  }
191    
# Line 237  void mnController::handleEditButton(wxCo Line 231  void mnController::handleEditButton(wxCo
231          delete dlg;          delete dlg;
232  }  }
233    
234  void mnController::saveData()  void mnController::handleLinkClick(wxCommandEvent &event)
235  {  {
236  #if 0          wxString href = event.GetString();
237          wxTreeItemData* item         = frame->getSelectedItem();          wxString tag;
238          wxString        plainTextStr = frame->getPlainText();          wxString url;
239          if(item == NULL) return ;          wxStringTokenizer tkz(href, wxT(":"));
240    
241            tag = tkz.GetNextToken();      
242            url = tkz.GetNextToken();
243    
244            if(tag.Cmp(wxT("mnlink")) == 0) {
245                    event.SetString(url);
246                    handleSearch(event);
247            }
248            else {
249                    openUrl(href);
250            }
251    }
252    
253          ((WikiData*)(item))->modText(&plainTextStr);  void mnController::openUrl(wxString& url)
254          ((WikiData*)(item))->save();  {
255          //frame->showSearchResult(wiki);          wxChar* argv[5];
256            wxString cmd;
257    
258    #ifdef __WXMSW__
259            argv[0] = wxT("explorer");
260            argv[1] = (wxChar*)url.c_str();
261            argv[2] = NULL;
262            cmd.sprintf(wxT("explorer %s"), url.c_str());
263  #endif  #endif
264    
265    #ifdef __WXMAC__
266            cmd.sprintf(wxT("open %s"), url.c_str());
267    #endif
268    
269    #ifdef __WXCOCOA__
270            cmd.sprintf(wxT("open %s"), url.c_str());
271    #endif
272    
273    #ifdef __WXGTK__
274            wxLogMessage(wxT("Ooops!, I don't know how to launch %s"), url.c_str());
275            return;
276    #endif
277    
278            //wxExecute(argv);
279            wxExecute(cmd);
280  }  }

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

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