From 595926ac27740a8822b6de9579e2e148c59f469c Mon Sep 17 00:00:00 2001 From: caballero Date: Tue, 19 May 2009 12:52:26 +0000 Subject: [PATCH] Added Settings dialog, customize configuration options and the listener on an external drive along with its panel. --- src2/CMakeLists.txt | 3 + src2/creaImageIOGimmick.cpp | 29 +++++ src2/creaImageIOGimmick.h | 10 ++ src2/creaImageIOGimmickView.h | 2 + src2/creaImageIOListener.cpp | 104 +++++++++++++++++ src2/creaImageIOListener.h | 66 +++++++++++ src2/creaImageIOSQLiteTreeHandler.cpp | 14 ++- src2/creaImageIOSQLiteTreeHandler.h | 5 + src2/creaImageIOSettings.cpp | 12 ++ src2/creaImageIOSettings.h | 3 + src2/creaImageIOSynchron.cpp | 20 +++- src2/creaImageIOSynchron.h | 4 + src2/creaImageIOTimestampDatabaseHandler.cpp | 11 ++ src2/creaImageIOTimestampDatabaseHandler.h | 5 + src2/creaImageIOTreeHandler.h | 5 + src2/creaImageIOTreeHandlerImageAdder.cpp | 51 ++++++++ src2/creaImageIOTreeHandlerImageAdder.h | 9 ++ src2/creaImageIOWxCustomizeConfigPanel.cpp | 74 ++++++++++++ src2/creaImageIOWxCustomizeConfigPanel.h | 54 +++++++++ src2/creaImageIOWxGimmickView.cpp | 115 ++++++++++++++++++- src2/creaImageIOWxGimmickView.h | 26 ++++- src2/creaImageIOWxListenerPanel.cpp | 95 +++++++++++++++ src2/creaImageIOWxListenerPanel.h | 56 +++++++++ src2/creaImageIOWxTreeView.cpp | 18 ++- src2/creaImageIOWxTreeView.h | 6 +- 25 files changed, 785 insertions(+), 12 deletions(-) create mode 100644 src2/creaImageIOListener.cpp create mode 100644 src2/creaImageIOListener.h create mode 100644 src2/creaImageIOWxCustomizeConfigPanel.cpp create mode 100644 src2/creaImageIOWxCustomizeConfigPanel.h create mode 100644 src2/creaImageIOWxListenerPanel.cpp create mode 100644 src2/creaImageIOWxListenerPanel.h diff --git a/src2/CMakeLists.txt b/src2/CMakeLists.txt index 709965a..e5b263e 100644 --- a/src2/CMakeLists.txt +++ b/src2/CMakeLists.txt @@ -35,6 +35,7 @@ SET( SRCS creaImageIOGimmick creaImageIOSynchron creaImageIOTimestampDatabaseHandler + creaImageIOListener # Abstract views creaImageIOGimmickView @@ -47,6 +48,8 @@ SET( SRCS creaImageIOWxGimmickFrame creaImageIOWxGimmickPanel creaImageIOWxGimmickTools + creaImageIOWxCustomizeConfigPanel + creaImageIOWxListenerPanel # BlockScopeWxApp diff --git a/src2/creaImageIOGimmick.cpp b/src2/creaImageIOGimmick.cpp index 2ed5b0c..3aae8a8 100644 --- a/src2/creaImageIOGimmick.cpp +++ b/src2/creaImageIOGimmick.cpp @@ -362,6 +362,35 @@ namespace creaImageIO GetTreeHandler(d)->GetTree().Print(); } //======================================================================== + + void Gimmick::GetSetting(const std::string& name, std::string& value) + { + value = mSettings->getValue(name); + } + //======================================================================== + + //======================================================================== + + void Gimmick::UpdateSetting(const std::string& name, const std::string& value) + { + mSettings->updateSetting(name,value); + mSettings->writeSettingsFile(); + } + //======================================================================== + + void Gimmick::DeleteDrive(const std::string& drive) + { + for( TreeHandlerMapType::const_iterator it = mTreeHandlerMap.begin(); + it!= mTreeHandlerMap.end(); ++it) + { + mImageAdder.SetTreeHandler(it->second); + mImageAdder.DeleteDriveFromMainDB(drive); + } + mImageAdder.SetTimestampHandler(mTimestampDatabase); + mImageAdder.SetSynchronizer(mSynchronizer); + mImageAdder.DeleteDriveFromOtherDB(drive); + } + ///////////////////////////////////////////////////////////////////////// // add DB from Settings file // // @param : - // diff --git a/src2/creaImageIOGimmick.h b/src2/creaImageIOGimmick.h index 6c3b1cc..09423fe 100644 --- a/src2/creaImageIOGimmick.h +++ b/src2/creaImageIOGimmick.h @@ -96,6 +96,10 @@ namespace creaImageIO void RemoveFile(const std::string& d, tree::Node* filename); + ///Deletes the given drive name from the databases + void DeleteDrive(const std::string& drive); + + /// Copies the files into the local directory void CopyFiles(const std::vector& filenames, const std::string& d ); @@ -126,6 +130,12 @@ namespace creaImageIO const SQLiteTreeHandler* GetLocalDatabase() const { return mLocalDatabase; } + ///Returns the given setting value for the given setting parameter + void GetSetting(const std::string& name, std::string& value); + + ///Updates the settings file + void UpdateSetting(const std::string& name, const std::string& value); + // add DB from Settings file void addDBSettings(); diff --git a/src2/creaImageIOGimmickView.h b/src2/creaImageIOGimmickView.h index c0e31d3..4621dbd 100644 --- a/src2/creaImageIOGimmickView.h +++ b/src2/creaImageIOGimmickView.h @@ -141,6 +141,8 @@ namespace creaImageIO void ConnectValidationObserver(ValidationCallbackType callback); //================================================================== + + void modifyValidationSignal(bool ivalid); private: diff --git a/src2/creaImageIOListener.cpp b/src2/creaImageIOListener.cpp new file mode 100644 index 0000000..d515b31 --- /dev/null +++ b/src2/creaImageIOListener.cpp @@ -0,0 +1,104 @@ +#include +#include +#include "boost/filesystem.hpp" +#include +#include + + +namespace fs = boost::filesystem; +using boost::filesystem::path; + +using namespace crea; + +namespace creaImageIO +{ + //===================================================================== + // CTor + Listener::Listener() + { + wxMutexLocker lock(mMutex); + GimmickDebugMessage(6,"Listener::Listener" + < +#include +#include +#include +// Signal/slot mechanism +#include +#include + +namespace creaImageIO +{ + + class Listener : public wxThread + { + public: + /// Ctors + Listener(); + /// Dtor + virtual ~Listener(); + ///Thread method that is executed once create is called + void* Entry(); + ///Thread method called upon exiting + void OnExit(); + ///Sets the new state of adding files + void SetAddFilesState(bool addFiles){wxMutexLocker lock(mMutex);mAddFiles=addFiles;} + ///Sets the new state of removing files + void SetRemoveFilesState(bool removeFiles){wxMutexLocker lock(mMutex);mRemoveFiles=removeFiles;} + ///Sets the new monitored drive + void SetMonitoredDrive(const std::string& dr){wxMutexLocker lock(mMutex);mDrive=dr;} + ///Puts the name of the monitored drive in the given string + void GetMonitoredDrive(std::string& drive){drive=mDrive;} + + ///Related with signals + //============================================= + typedef boost::signal MountingSignalType; + typedef MountingSignalType::slot_function_type MountingCallbackType; + //============================================= + + //================================================================== + void ConnectObserver(MountingCallbackType callback); + //================================================================== + + ///Sends a boost::signal to alert that the drive has changed its state (mounted/unmounted) + void SendSignal(bool ivalid); + + + private: + /// The mutex + wxMutex mMutex; + /// Boolean that declares if the files that are read on CD mount should be added + bool mAddFiles; + /// Boolean that declares if, on CD unmount, the files that were in the drive should be removed + bool mRemoveFiles; + ///Boolean that declares if a unit has been mounted + bool mMounted; + ///The monitored drive + std::string mDrive; + ///The validation signal + MountingSignalType mMountingSignal; + }; + +} + +#endif diff --git a/src2/creaImageIOSQLiteTreeHandler.cpp b/src2/creaImageIOSQLiteTreeHandler.cpp index 14bb3db..6d4d25b 100644 --- a/src2/creaImageIOSQLiteTreeHandler.cpp +++ b/src2/creaImageIOSQLiteTreeHandler.cpp @@ -149,7 +149,7 @@ namespace creaImageIO if (parent) { int nC = parent->RemoveChildrenFromList(node); - if(nC>0) + if(nC>0 && parent->GetLevel()>0) { std::stringstream out; out <& files , const std::string& refdb); void GetIgnoredFiles(const std::string& key, std::vector &ignoreList); std::string GetAttribute(const std::string& attribute, diff --git a/src2/creaImageIOTimestampDatabaseHandler.cpp b/src2/creaImageIOTimestampDatabaseHandler.cpp index 35a8153..f156111 100644 --- a/src2/creaImageIOTimestampDatabaseHandler.cpp +++ b/src2/creaImageIOTimestampDatabaseHandler.cpp @@ -427,5 +427,16 @@ namespace creaImageIO return false; } + //===================================================================== + void TimestampDatabaseHandler::RemoveEntries(const std::string i_table, + const std::string i_attribute, + const std::string i_operand, + const std::string i_val) + { + std::stringstream query; + query<<"DELETE FROM "<InsertIgnoreFile(addKey, itr->string(),"0",removedOn.str(),mCurrentDB); } + mProgressSignal(mProgress); if (mProgress.GetStop()) { //itr = end_itr; break; } + } mTimestampHandler->SetAttribute("TopLevelNodeId",parent_id,"PATH",dirpath); } @@ -444,6 +446,28 @@ namespace creaImageIO } } + //======================================================================= + void TreeHandlerImageAdder::FindNodePartial(tree::Node* parent, int level, const std::string& searchParam, const std::string& searchVal, tree::Node*& node) + { + if(level>1) + { + std::vector::iterator iter; + for(iter=parent->GetChildrenList().begin();iter!=parent->GetChildrenList().end() && node==0 ;++iter) + { + FindNodePartial(*iter,level-1,searchParam,searchVal,node); + } + } + else + { + if(parent->GetAttribute(searchParam).find(searchVal)<9000) + { + node=parent; + return; + } + + } + } + //======================================================================= void TreeHandlerImageAdder::CopyFiles(const std::vector& filenames, const std::string directory ) @@ -526,5 +550,32 @@ namespace creaImageIO //======================================================================= + void TreeHandlerImageAdder::DeleteDriveFromMainDB(const std::string& drive) + { + //Delete from local database and others + tree::Node* node=0; + mTreeHandler->LoadChildren(NULL,4); + FindNodePartial(mTreeHandler->GetTree().GetChildrenList()[0],3,"FullFileName",drive,node); + while(node!=0) + { + mTreeHandler->Remove(node); + node=0; + mTreeHandler->LoadChildren(NULL,4); + FindNodePartial(mTreeHandler->GetTree().GetChildrenList()[0],3,"FullFileName",drive,node); + } + } + + //======================================================================= + + void TreeHandlerImageAdder::DeleteDriveFromOtherDB(const std::string& drive) + { + //Delete from timestamp + mTimestampHandler->RemoveEntries("FILES", "PATH", "LIKE", drive+"%"); + + //Delete from maintenance + mSynchronizer->RemoveEntries("ADD_OPS", "PATH", "LIKE", drive+"%"); + mSynchronizer->RemoveEntries("IGNORED_FILES", "PATH", "LIKE", drive+"%"); + } + } diff --git a/src2/creaImageIOTreeHandlerImageAdder.h b/src2/creaImageIOTreeHandlerImageAdder.h index fe3c31d..53cff0b 100644 --- a/src2/creaImageIOTreeHandlerImageAdder.h +++ b/src2/creaImageIOTreeHandlerImageAdder.h @@ -130,8 +130,17 @@ namespace creaImageIO const std::string& searchParam, const std::string& searchVal, tree::Node*& node); + + ///Finds the nodes that partially match the searchVal + void FindNodePartial(tree::Node* parent, int level, const std::string& searchParam, const std::string& searchVal, tree::Node*& node); + ///Checks the attributes of the database against the ones in disk void CheckAttributes(bool repair, std::string& file, std::vector& attsModified); + ///Deletes the drive with the given name (use for all databases except maintenance and timestamp) + void DeleteDriveFromMainDB(const std::string& drive); + ///Deletes the drive with the given name (use for maintenance and timestamp databases) + void DeleteDriveFromOtherDB(const std::string& drive); + //==================================================================== diff --git a/src2/creaImageIOWxCustomizeConfigPanel.cpp b/src2/creaImageIOWxCustomizeConfigPanel.cpp new file mode 100644 index 0000000..8fd0e78 --- /dev/null +++ b/src2/creaImageIOWxCustomizeConfigPanel.cpp @@ -0,0 +1,74 @@ +#include +#include + +namespace creaImageIO +{ + // CTor + WxCustomizeConfigPanel::WxCustomizeConfigPanel(wxWindow *parent, wxDialog* dial, WxGimmickView* view, const std::string& cPath, + const std::string& dPath, + const std::string& sEvent, + const std::string& sFreq) + : wxPanel( parent, + -1, wxDefaultPosition, + wxDefaultSize, + wxRESIZE_BORDER | + wxSYSTEM_MENU | + wxCLOSE_BOX | + wxMAXIMIZE_BOX | + wxMINIMIZE_BOX | + wxCAPTION + ), + dialog(dial), + copyP (cPath), + databaseP(dPath), + syncEv(sEvent), + syncFr(sFreq), + mView(view) + { + GimmickDebugMessage(1,"WxCustomizeConfigPanel::WxCustomizeConfigPanel" + <GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxCustomizeConfigPanel::OnSaveConfig ); + + + //topsizer->Add( mView,1,wxGROW,0); + +// SetSizer( topsizer ); + Layout(); + } + + /// Destructor + WxCustomizeConfigPanel::~WxCustomizeConfigPanel() + { + GimmickDebugMessage(1,"WxCustomizeConfigPanel::~WxCustomizeConfigPanel" + <OnSaveSettingsCallback(crea::wx2std(copyPath->GetValue()), + crea::wx2std(dbPath->GetValue()), + crea::wx2std(syncEvent->GetValue()), + crea::wx2std(syncFrequency->GetValue())); + dialog->Destroy(); + } + +//====================================================================== + +//====================================================================== + +} // EO namespace creaImageIO + + diff --git a/src2/creaImageIOWxCustomizeConfigPanel.h b/src2/creaImageIOWxCustomizeConfigPanel.h new file mode 100644 index 0000000..0de052a --- /dev/null +++ b/src2/creaImageIOWxCustomizeConfigPanel.h @@ -0,0 +1,54 @@ +#ifndef __creaImageIOWxCustomizeConfigPanel_h_INCLUDED__ +#define __creaImageIOWxCustomizeConfigPanel_h_INCLUDED__ + +#ifdef USE_WXWIDGETS +#include +#include + + +namespace creaImageIO +{ + /** + * \ingroup GUI + */ + //===================================================================== + //===================================================================== + class WxCustomizeConfigPanel : public wxPanel + { + public: + WxCustomizeConfigPanel(); + WxCustomizeConfigPanel(wxWindow *parent, + wxDialog* dial, + WxGimmickView* view, + const std::string& cPath, + const std::string& dPath, + const std::string& sEvent, + const std::string& sFreq); + + ~WxCustomizeConfigPanel(); + ///Saves the configuration + void OnSaveConfig(wxCommandEvent& event); + + private : + std::string copyP; + std::string databaseP; + std::string syncEv; + std::string syncFr; + wxTextCtrl* copyPath; + wxTextCtrl* dbPath; + wxTextCtrl* syncEvent; + wxTextCtrl* syncFrequency; + wxDialog* dialog; + WxGimmickView* mView; + + + }; // class WxCustomizeConfigPanel + //===================================================================== + + +} // EO namespace creaImageIO + + +#endif // USE_WIDGETS +// EOF +#endif \ No newline at end of file diff --git a/src2/creaImageIOWxGimmickView.cpp b/src2/creaImageIOWxGimmickView.cpp index 6c84edb..fb46be6 100644 --- a/src2/creaImageIOWxGimmickView.cpp +++ b/src2/creaImageIOWxGimmickView.cpp @@ -1,6 +1,9 @@ #include #include #include +#include +#include + using namespace crea; // Icons #include "icons/accept.xpm" @@ -157,10 +160,14 @@ namespace creaImageIO sizer->Add( mSplitter,1,wxGROW ,0); - + mProgressDialog=0; SetSizer( sizer ); SetAutoLayout(true); Layout(); + mListener=new Listener(); + mListener->ConnectObserver(boost::bind( &WxGimmickView::OnDriveMount , this, _1 ) ); + mListener->Create(); + mListener->Run(); mConstructed = true; } @@ -174,6 +181,10 @@ namespace creaImageIO mViewer->StopPlayer(); GimmickDebugMessage(1,"WxGimmickView::~WxGimmickView" <IsAlive()) + { + mListener->Delete(); + } } //====================================================================== @@ -673,13 +684,13 @@ namespace creaImageIO //================================================= void WxGimmickView::OnSettings(wxCommandEvent& event) { - wxDialog* dial= new wxDialog (this,-1,_T("System Settings"),wxDefaultPosition, wxSize(450,600)); + wxDialog* dial= new wxDialog (this,-1,_T("System Settings"),wxDefaultPosition, wxSize(450,220)); wxBoxSizer *siz = new wxBoxSizer(wxVERTICAL); // Notebook wxNotebook* nb= new wxNotebook(dial, -1, wxDefaultPosition, wxDefaultSize, 0); siz->Add( nb,1,wxGROW ,0); - CreateSettingsDialog(nb); + CreateSettingsDialog(nb,dial); dial->SetSizer(siz); dial->ShowModal(); } @@ -750,22 +761,114 @@ namespace creaImageIO } //================================================= - void WxGimmickView::CreateSettingsDialog(wxNotebook* nb) + void WxGimmickView::CreateSettingsDialog(wxNotebook* nb, wxDialog* dial) { //First page: Customization of configurations - wxPanel* customConfig=new wxPanel(nb); + //Copy Path string + std::string cp; + mGimmick->GetSetting(SETTINGS_COPY_PATH,cp); + //Database Path String + std::string dp; + mGimmick->GetSetting(SETTINGS_DBPATH,dp); + //Syncronization Event String + std::string se; + mGimmick->GetSetting(SETTINGS_SYNC_EVENT,se); + //Syncronization Frequency String + std::string sf; + mGimmick->GetSetting(SETTINGS_SYNC_FREQ,sf); + + WxCustomizeConfigPanel * customConfig=new WxCustomizeConfigPanel(nb,dial,this,cp,dp,se,sf); + nb->AddPage( customConfig, crea::std2wx("Customize Configuration") ); + //Second page: Creation of Databases wxPanel* databaseCreation=new wxPanel(nb); nb->AddPage( databaseCreation, crea::std2wx("Create Database") ); + //Third page: CD/DVD Watch - wxPanel* cdWatch=new wxPanel(nb); + WxListenerPanel* cdWatch=new WxListenerPanel(nb,dial, this, mListener->IsPaused()); nb->AddPage( cdWatch, crea::std2wx("CD/DVD") ); + //Fourth page: Selection of attributes to show (edit) wxPanel* attSelection=new wxPanel(nb); nb->AddPage( attSelection, crea::std2wx("Selection of Attributes") ); } + //=================================================================== + void WxGimmickView::OnSaveSettingsCallback(const std::string& copyPath, + const std::string& dbPath, + const std::string& syncEvent, + const std::string& syncFreq) + { + mGimmick->UpdateSetting(SETTINGS_COPY_PATH,copyPath); + mGimmick->UpdateSetting(SETTINGS_DBPATH,dbPath); + mGimmick->UpdateSetting(SETTINGS_SYNC_EVENT,syncEvent); + mGimmick->UpdateSetting(SETTINGS_SYNC_FREQ,syncFreq); + } + + //=================================================================== + void WxGimmickView::OnListenerCallback(const std::string& drive, bool addFiles, bool removeFiles) + { + mListener->SetMonitoredDrive(drive); + mListener->SetAddFilesState(addFiles); + mListener->SetRemoveFilesState(removeFiles); + } + + //======================================================================== + + void WxGimmickView::OnDriveMount(bool mount) + { + GimmickMessage(1, "Gimmick::OnDriveMount"<GetMonitoredDrive(drive); + + if(mount) + { + mViewer->StopPlayer(); + wxBusyCursor busy; + wxString title(_T("Adding drive")); + mProgressDialog = + new wxProgressDialog(_T("Adding drive"), + _T(""), + 1000, + this, + wxPD_ELAPSED_TIME | + // wxPD_ESTIMATED_TIME | + // wxPD_REMAINING_TIME | + wxPD_CAN_ABORT ); + mCurrentDirectory = crea::std2wx(drive); + mGimmick->AddDir(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),drive,true); + mProgressDialog->Pulse(_T("Updating view...")); + + UpdateTreeViewLevel(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),1); + delete mProgressDialog; + DisplayAddSummary(); + mViewer->StartPlayer(); + + } + else + { + mGimmick->DeleteDrive(drive); + UpdateTreeViewLevel(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),1); + } + + } + + //======================================================================== + + void WxGimmickView::StartListeningThread() + { + mListener->Resume(); + } + + //======================================================================== + + void WxGimmickView::StopListeningThread() + { + mListener->Pause(); + } + + //================================================= /// AddProgress Gimmick callback void WxGimmickView::OnAddProgress( Gimmick::AddProgress& p) diff --git a/src2/creaImageIOWxGimmickView.h b/src2/creaImageIOWxGimmickView.h index 937442e..cf3dd3f 100644 --- a/src2/creaImageIOWxGimmickView.h +++ b/src2/creaImageIOWxGimmickView.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include "wx/wx.h" //#include "bruker2dicom.h" @@ -72,7 +73,25 @@ namespace creaImageIO ///Sends a request to read the currently selected node and the ones that surround it. void ReadImageThreaded(const std::vector& sel); - + + ///Saves the settings to the file + void OnSaveSettingsCallback(const std::string& copyPath, + const std::string& dbPath, + const std::string& syncEvent, + const std::string& syncFreq); + + ///Changes listener state + void OnListenerCallback(const std::string& drive, bool addFiles, bool removeFiles); + + ///Acts upon a drive mount + void OnDriveMount(bool mount); + + ///Starts the listening thread on the CD/DVD drive + void StartListeningThread(); + + ///Stops the listening thread on the CD/DVD drive + void StopListeningThread(); + protected: /// Creates the tool bar @@ -109,6 +128,8 @@ namespace creaImageIO void CreateIconList(); Gimmick * mGimmick; + + Listener* mListener; /// Callback for adding files void OnAddFiles(wxCommandEvent& event); /// Callback for adding dir @@ -122,7 +143,8 @@ namespace creaImageIO /// Callback for settings edition void OnTools(wxCommandEvent& event); ///Creates the settings dialog (the pages inside and the information) - void CreateSettingsDialog(wxNotebook* nb); + void CreateSettingsDialog(wxNotebook* nb, wxDialog* dial); + /// Display a message box with the last addition statistics void DisplayAddSummary(); diff --git a/src2/creaImageIOWxListenerPanel.cpp b/src2/creaImageIOWxListenerPanel.cpp new file mode 100644 index 0000000..f259388 --- /dev/null +++ b/src2/creaImageIOWxListenerPanel.cpp @@ -0,0 +1,95 @@ +#include +#include + +namespace creaImageIO +{ + // CTor + WxListenerPanel::WxListenerPanel(wxWindow *parent, wxDialog* dial, WxGimmickView* view, bool stat) + : wxPanel( parent, + -1, wxDefaultPosition, + wxDefaultSize, + wxRESIZE_BORDER | + wxSYSTEM_MENU | + wxCLOSE_BOX | + wxMAXIMIZE_BOX | + wxMINIMIZE_BOX | + wxCAPTION + ), + dialog(dial), + mView(view) + { + GimmickDebugMessage(1,"WxListener::WxListener" + <SetValue(true); + removeCheckBox = new wxCheckBox(this, -1, _T("Automatically remove images from the database when CD/DVD is unmounted?"), wxPoint(5,75) ); + removeCheckBox->SetValue(true); + Connect( addCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WxListenerPanel::OnAdd ); + Connect( removeCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WxListenerPanel::OnRemove ); + std::string name; + if (state){name="Start Monitoring Drive";} + else {name="Stop Monitoring Drive";} + wxButton *start = new wxButton(this,wxID_ANY,_T(name), wxPoint(5,110) ); + Connect( start->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxListenerPanel::OnChangeThreadState ); + + wxButton *save = new wxButton(this,wxID_ANY,_T("Save Changes"), wxPoint(130,110) ); + Connect( save->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxListenerPanel::OnChangeListenState ); + + + //topsizer->Add( mView,1,wxGROW,0); + +// SetSizer( topsizer ); + Layout(); + } + + /// Destructor + WxListenerPanel::~WxListenerPanel() + { + GimmickDebugMessage(1,"WxCustomizeConfigPanel::~WxCustomizeConfigPanel" + <GetValue(); + } + + void WxListenerPanel::OnRemove(wxCommandEvent& event) + { + removeFiles = removeCheckBox->GetValue(); + } + + void WxListenerPanel::OnChangeListenState(wxCommandEvent& event) + { + mView->OnListenerCallback(crea::wx2std(drives->GetValue()),addFiles, removeFiles); + dialog->Destroy(); + } + + void WxListenerPanel::OnChangeThreadState(wxCommandEvent& event) + { + if(state) + { + mView->StartListeningThread(); + } + else + { + mView->StopListeningThread(); + } + dialog->Destroy(); + } + +//====================================================================== + +//====================================================================== + +} // EO namespace creaImageIO + + diff --git a/src2/creaImageIOWxListenerPanel.h b/src2/creaImageIOWxListenerPanel.h new file mode 100644 index 0000000..17dff79 --- /dev/null +++ b/src2/creaImageIOWxListenerPanel.h @@ -0,0 +1,56 @@ +#ifndef __creaImageIOWxListenerPanel_h_INCLUDED__ +#define __creaImageIOWxListenerPanel_h_INCLUDED__ + +#ifdef USE_WXWIDGETS +#include +#include + + +namespace creaImageIO +{ + /** + * \ingroup GUI + */ + //===================================================================== + //===================================================================== + class WxListenerPanel : public wxPanel + { + public: + WxListenerPanel(); + WxListenerPanel(wxWindow *parent, + wxDialog* dial, + WxGimmickView* view, + bool stat); + + ~WxListenerPanel(); + ///Saves the configuration + void OnChangeListenState(wxCommandEvent& event); + ///Changes the thread state(start/stop) + void OnChangeThreadState(wxCommandEvent& event); + ///Changes the state of the add boolean + void OnAdd(wxCommandEvent& event); + ///Changes the state of the remove boolean + void OnRemove(wxCommandEvent& event); + + + private : + bool addFiles; + bool removeFiles; + bool state; + wxCheckBox* addCheckBox; + wxCheckBox* removeCheckBox; + wxComboBox* drives; + wxDialog* dialog; + WxGimmickView* mView; + + + }; // class WxListener + //===================================================================== + + +} // EO namespace creaImageIO + + +#endif // USE_WIDGETS +// EOF +#endif \ No newline at end of file diff --git a/src2/creaImageIOWxTreeView.cpp b/src2/creaImageIOWxTreeView.cpp index a2604c7..cf6f1eb 100644 --- a/src2/creaImageIOWxTreeView.cpp +++ b/src2/creaImageIOWxTreeView.cpp @@ -226,11 +226,14 @@ namespace creaImageIO menuItem =new wxMenu; wxMenuItem* m1Item=menuItem->Append(wxID_ANY, _T("&Anonymize")); wxMenuItem* m2Item=menuItem->Append(wxID_ANY, _T("&Local Copy")); + wxMenuItem* m3Item=menuItem->Append(wxID_ANY, _T("&Edit field")); mAnonymizingID=m1Item->GetId(); mLocalCopyID=m2Item->GetId(); + mEditFieldID=m3Item->GetId(); //Connect( mAnonymizingID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnAnonymize) ); Connect( mLocalCopyID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnLocalCopy) ); + Connect( mEditFieldID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnEditField) ); #endif // wxUSE_MENUS @@ -681,12 +684,16 @@ namespace creaImageIO wxPoint clientpt; clientpt.x = wxGetMousePosition().x - this->GetScreenPosition().x; clientpt.y = wxGetMousePosition().y - this->GetScreenPosition().y; - senderCtrl = event.GetEventObject(); + senderCtrl = event.GetEventObject(); unsigned int level = 0; for (level = 0; levelHitTest(clientpt,flag,ptr); + std::cout<