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.13 by maloninc, Tue Sep 13 00:40:08 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 13  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 28  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 62  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 77  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 96  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 131  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(frame->getSelectedLabel(), wxT("Do you realy remove this memo?"), 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 165  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 174  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 231  void mnController::handleEditButton(wxCo Line 231  void mnController::handleEditButton(wxCo
231    
232  void mnController::handleLinkClick(wxCommandEvent &event)  void mnController::handleLinkClick(wxCommandEvent &event)
233  {  {
234          wxLogMessage(event.GetString());          const wxString* wikiDataDir;
235            wxString href = event.GetString();
236            wxString tag;
237            wxString val;
238            wxString doc;
239            wxStringTokenizer tkz(href, wxT(":"));
240    
241            tag = tkz.GetNextToken();      
242            val = tkz.GetNextToken();
243            if(tag.CmpNoCase(wxT("mnlink")) == 0) {
244                    event.SetString(val);
245                    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 {
253                    openUrl(href);
254            }
255  }  }
256    
257    void mnController::openUrl(wxString& url)
258    {
259            wxString cmd;
260    
261    #ifdef __WXMSW__
262            cmd.sprintf(wxT("explorer %s"), url.c_str());
263    #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            cmd.sprintf(wxT("gnome-open %s"), url.c_str());
275    #endif
276    
277            //wxExecute(argv);
278            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.7  
changed lines
  Added in v.1.13

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