creaImageIOGimmick
creaImageIOSynchron
creaImageIOTimestampDatabaseHandler
+ creaImageIOListener
# Abstract views
creaImageIOGimmickView
creaImageIOWxGimmickFrame
creaImageIOWxGimmickPanel
creaImageIOWxGimmickTools
+ creaImageIOWxCustomizeConfigPanel
+ creaImageIOWxListenerPanel
#
BlockScopeWxApp
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 : - //
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<std::string>& filenames, const std::string& d );
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();
void ConnectValidationObserver(ValidationCallbackType callback);
//==================================================================
+
+
void modifyValidationSignal(bool ivalid);
private:
--- /dev/null
+#include <creaImageIOListener.h>
+#include <creaImageIOSystem.h>
+#include "boost/filesystem.hpp"
+#include <boost/filesystem/operations.hpp>
+#include <boost/utility.hpp>
+
+
+namespace fs = boost::filesystem;
+using boost::filesystem::path;
+
+using namespace crea;
+
+namespace creaImageIO
+{
+ //=====================================================================
+ // CTor
+ Listener::Listener()
+ {
+ wxMutexLocker lock(mMutex);
+ GimmickDebugMessage(6,"Listener::Listener"
+ <<std::endl);
+ mDrive="E:";
+ mMounted=false;
+ mAddFiles=false;
+ mRemoveFiles=true;
+
+ }
+ //=====================================================================
+
+ //=====================================================================
+ /// Destructor
+ Listener::~Listener()
+ {
+ wxMutexLocker lock(mMutex);
+ GimmickDebugMessage(6,"Listener::~Listener"
+ <<std::endl);
+ }
+ //=====================================================================
+
+ void* Listener::Entry()
+ {
+ GimmickDebugMessage(6,"Listener::Entry()"<<std::endl);
+ while(!TestDestroy())
+ {
+ try
+ {
+ fs::exists( mDrive );
+ if(!mMounted && mAddFiles)
+ {
+ mMounted=true;
+ SendSignal(mMounted);
+ }
+ else if(!mMounted)
+ {
+ mMounted=true;
+ }
+
+ }
+ catch (...)
+ {
+ if(mMounted && mRemoveFiles)
+ {
+ mMounted=false;
+ SendSignal(mMounted);
+ }
+ else if(mMounted)
+ {
+ mMounted=false;
+ }
+ }
+
+ clock_t endwait;
+ endwait = clock () + 0.00000001 * CLOCKS_PER_SEC ;
+ while (clock() < endwait ) {}
+
+ }
+ return 0;
+ }
+
+ //=====================================================================
+
+ //=====================================================================
+ void Listener::OnExit()
+ {
+ GimmickDebugMessage(6,"Listener::OnExit() "<<std::endl);
+ }
+
+ //====================================================================
+ void Listener::ConnectObserver(MountingCallbackType callback)
+ {
+ mMountingSignal.connect(callback);
+ }
+
+ //======================================================================
+ void Listener::SendSignal(bool mount)
+ {
+ mMountingSignal(mount);
+ }
+
+
+
+
+} // EO namespace creaImageIO
+
--- /dev/null
+#ifndef __creaImageIOListener_h_INCLUDED__
+#define __creaImageIOListener_h_INCLUDED__
+
+#include <creaImageIOSystem.h>
+#include <stdio.h>
+#include <time.h>
+#include <wx/thread.h>
+// Signal/slot mechanism
+#include <boost/signal.hpp>
+#include <boost/bind.hpp>
+
+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<void (bool)> 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
if (parent)
{
int nC = parent->RemoveChildrenFromList(node);
- if(nC>0)
+ if(nC>0 && parent->GetLevel()>0)
{
std::stringstream out;
out <<nC;
sql += " = '";
sql += searchVal;
sql += "'";
+ std::cout<<sql<<std::endl;
UPDATEDB(sql);
}
//=====================================================================
}
+ //=====================================================================
+ void SQLiteTreeHandler::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 "<<i_table<<" WHERE "<<i_attribute<<" "<<i_operand<<" '"<<i_val<<"'";
+ UPDATEDB(query.str());
+ }
+
/*
//=====================================================================
bool SQLiteTreeHandler::DBInsert(Node* alien_node,
const std::string& searchVal);
//Deletes the tuple that matches the parameters given
virtual void DeleteTuple(std::string levelDescriptor, std::string key, std::string value);
+ //Deletes the entries that match the parameters given
+ virtual void RemoveEntries(const std::string i_table,
+ const std::string i_attribute,
+ const std::string i_operand,
+ const std::string i_val);
//====================================================================
}
}
}
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ // Update settings in config file //
+ // @param key : Key to update //
+ // @param value: New value to set //
+ // return : -
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+ void Settings::updateSetting(const std::string& key, const std::string &val)
+ {
+ m_SettingsMap[key.c_str()] = val;
+ }
+
////////////////////////////////////////////////////////////////////////////////////////////////
// add a path to a DB //
// @param i_path : DB path to add //
void addDB(const std::string &i_path);
void removeDB(const std::string &i_path);
+
+ void updateSetting(const std::string& key, const std::string &val);
+
//write configuration file
void writeSettingsFile();
/////////////////////////////////////////////////////////////////////////////////////////////////
// remove an entry of the DB
- //@param i_table : table where do the remove
+ //@param i_table : table where to do the remove
// @param i_key : the add_key reference (one entry to remove for ADD_OP table, many for IGNORED_FILES table
//@result : -
/////////////////////////////////////////////////////////////////////////////////////////////////
UPDATESYNCDB(query);
}
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+ // remove several entries of the DB
+ // @param i_table : table where to do the remove
+ // @param i_attribute: attribute to match
+ // @param i_operand : operand to use
+ // @param i_val : the reference
+ //@result : -
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+ void Synchronizer::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 "<<i_table<<" WHERE "<<i_attribute<<" "<<i_operand<<" '"<<i_val<<"'";
+ UPDATESYNCDB(query.str());
+ }
+
/////////////////////////////////////////////////////////////////////////////////////////////////
// clean DataBase if an operation has no child anymore
// @param refdb: the database segement to clean
const std::string& time,
const std::string& refdb);
void RemoveEntry(const std::string i_table, const std::string i_key);
+ void RemoveEntries(const std::string i_table,
+ const std::string i_attribute,
+ const std::string i_operand,
+ const std::string i_key);
void GetFileList(std::vector<AddList>& files , const std::string& refdb);
void GetIgnoredFiles(const std::string& key, std::vector<std::string> &ignoreList);
std::string GetAttribute(const std::string& attribute,
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 "<<i_table<<" WHERE "<<i_attribute<<" "<<i_operand<<" '"<<i_val<<"'";
+ UPDATETIMESTAMPDB(query.str());
+ }
+
}// namespace creaImageIO
///Checks the timestamp in the database and compares it with the given one.
//If there is a difference, it will return false, otherwise it will return true.
bool CheckTimestamp(const std::string pathId, const time_t lastModif, const std::string& refdb);
+ ///Removes the entries that match the given parameters
+ void RemoveEntries(const std::string i_table,
+ const std::string i_attribute,
+ const std::string i_operand,
+ const std::string i_val);
//====================================================================
const std::string& searchVal){}
//Deletes the tuple that matches the parameters given
virtual void DeleteTuple(std::string levelDescriptor, std::string key, std::string value){}
+ //Deletes the entries that match the parameters given
+ virtual void RemoveEntries(const std::string i_table,
+ const std::string i_attribute,
+ const std::string i_operand,
+ const std::string i_val){}
//====================================================================
removedOn<<time(0);
mSynchronizer->InsertIgnoreFile(addKey, itr->string(),"0",removedOn.str(),mCurrentDB);
}
+
mProgressSignal(mProgress);
if (mProgress.GetStop())
{
//itr = end_itr;
break;
}
+
}
mTimestampHandler->SetAttribute("TopLevelNodeId",parent_id,"PATH",dirpath);
}
}
}
+ //=======================================================================
+ void TreeHandlerImageAdder::FindNodePartial(tree::Node* parent, int level, const std::string& searchParam, const std::string& searchVal, tree::Node*& node)
+ {
+ if(level>1)
+ {
+ std::vector<tree::Node*>::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<std::string>& filenames, const std::string directory )
//=======================================================================
+ 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+"%");
+ }
+
}
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<std::string>& 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);
+
//====================================================================
--- /dev/null
+#include <creaImageIOWxCustomizeConfigPanel.h>
+#include <creaImageIOSystem.h>
+
+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"
+ <<std::endl);
+ wxStaticText * cp=new wxStaticText(this,-1,_T(" Copy Path: "), wxPoint(5,10));
+ copyPath=new wxTextCtrl(this, wxID_ANY, _T(copyP), wxPoint(150,10), wxSize(250,20));
+
+ wxStaticText * dp=new wxStaticText(this,-1,_T(" Database Path: "), wxPoint(5,40));
+ dbPath=new wxTextCtrl(this, wxID_ANY, _T(databaseP), wxPoint(150,40), wxSize(250,20));
+
+ wxStaticText * se=new wxStaticText(this,-1,_T(" Synchronization Event: "), wxPoint(5,70));
+ syncEvent=new wxTextCtrl(this, wxID_ANY, _T(syncEv), wxPoint(150,70), wxSize(250,20));
+
+ wxStaticText * sf=new wxStaticText(this,-1,_T(" Synchronization Frequency: "), wxPoint(5,100));
+ syncFrequency=new wxTextCtrl(this, wxID_ANY, _T(syncFr), wxPoint(150,100), wxSize(250,20));
+
+ wxButton *save = new wxButton(this,wxID_ANY,_T("Save Changes"), wxPoint(5,130) );
+ Connect( save->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxCustomizeConfigPanel::OnSaveConfig );
+
+
+ //topsizer->Add( mView,1,wxGROW,0);
+
+// SetSizer( topsizer );
+ Layout();
+ }
+
+ /// Destructor
+ WxCustomizeConfigPanel::~WxCustomizeConfigPanel()
+ {
+ GimmickDebugMessage(1,"WxCustomizeConfigPanel::~WxCustomizeConfigPanel"
+ <<std::endl);
+ }
+
+ void WxCustomizeConfigPanel::OnSaveConfig(wxCommandEvent& event)
+ {
+ mView->OnSaveSettingsCallback(crea::wx2std(copyPath->GetValue()),
+ crea::wx2std(dbPath->GetValue()),
+ crea::wx2std(syncEvent->GetValue()),
+ crea::wx2std(syncFrequency->GetValue()));
+ dialog->Destroy();
+ }
+
+//======================================================================
+
+//======================================================================
+
+} // EO namespace creaImageIO
+
+
--- /dev/null
+#ifndef __creaImageIOWxCustomizeConfigPanel_h_INCLUDED__
+#define __creaImageIOWxCustomizeConfigPanel_h_INCLUDED__
+
+#ifdef USE_WXWIDGETS
+#include <creaWx.h>
+#include <creaImageIOWxGimmickView.h>
+
+
+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
#include <creaImageIOWxGimmickView.h>
#include <creaImageIOWxTreeView.h>
#include <creaImageIOSystem.h>
+#include <creaImageIOWxCustomizeConfigPanel.h>
+#include <creaImageIOWxListenerPanel.h>
+
using namespace crea;
// Icons
#include "icons/accept.xpm"
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;
}
mViewer->StopPlayer();
GimmickDebugMessage(1,"WxGimmickView::~WxGimmickView"
<<std::endl);
+ if(mListener->IsAlive())
+ {
+ mListener->Delete();
+ }
}
//======================================================================
//=================================================
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();
}
}
//=================================================
- 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"<<std::endl);
+ std::string drive;
+ mListener->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)
#include <creaImageIOGimmickView.h>
#include <creaImageIOWxViewer.h>
#include <creaImageIOWxGimmickTools.h>
+#include <creaImageIOListener.h>
#include <creaWx.h>
#include "wx/wx.h"
//#include "bruker2dicom.h"
///Sends a request to read the currently selected node and the ones that surround it.
void ReadImageThreaded(const std::vector<tree::Node*>& 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
void CreateIconList();
Gimmick * mGimmick;
+
+ Listener* mListener;
/// Callback for adding files
void OnAddFiles(wxCommandEvent& event);
/// Callback for adding dir
/// 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();
--- /dev/null
+#include <creaImageIOWxListenerPanel.h>
+#include <creaImageIOSystem.h>
+
+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"
+ <<std::endl);
+ state=stat;
+ wxStaticText * cp=new wxStaticText(this,-1,_T(" Drive to monitor: "), wxPoint(5,15));
+ const wxString choices[] = { _T("D:"),
+ _T("E:"),
+ _T("F:"),
+ _T("G:") };
+ drives=new wxComboBox(this, -1,"E:",wxPoint(100, 10),wxDefaultSize,4,choices);
+
+ addCheckBox = new wxCheckBox(this, -1, _T("Automatically add images to the database when CD/DVD is mounted?"), wxPoint(5,45) );
+ addCheckBox->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"
+ <<std::endl);
+ }
+
+ void WxListenerPanel::OnAdd(wxCommandEvent& event)
+ {
+ addFiles = addCheckBox->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
+
+
--- /dev/null
+#ifndef __creaImageIOWxListenerPanel_h_INCLUDED__
+#define __creaImageIOWxListenerPanel_h_INCLUDED__
+
+#ifdef USE_WXWIDGETS
+#include <creaWx.h>
+#include <creaImageIOWxGimmickView.h>
+
+
+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
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
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; level<mLevelList.size(); ++level)
{
if ( GetCtrl(level) == senderCtrl ) break;
}
+ long* ptr=0;
+ int flag=wxLIST_HITTEST_ONITEM;
+ long itemId=GetCtrl(level)->HitTest(clientpt,flag,ptr);
+ std::cout<<itemId<<std::endl;
PopupMenu(menuItem, clientpt);
}
}
+ }
+ //================================================================
+
+ //================================================================
+ void WxTreeView::OnEditField(wxCommandEvent& event)
+ {
+
+
+
}
//================================================================
///Callback when the user need the items filtered
void OnPopupFilter(wxCommandEvent& event);
- ///Callback when the user need the items filtered
+ ///Callback when the user needs the item copied to the local disk
void OnLocalCopy(wxCommandEvent& event);
+
+ ///Callback when the user needs to edit a field
+ void OnEditField(wxCommandEvent& event);
///Callback on mouse click
void OnMouseClick(wxMouseEvent& event);
wxMenu* menuItem;
int mAnonymizingID;
int mLocalCopyID;
+ int mEditFieldID;
// If set to true then OnSelectedChanged returns immediately.
// Used to do avoid useless process during multiple selections
// or sorting