From d1635bf73accf21c07f6315ed04609d703250269 Mon Sep 17 00:00:00 2001 From: Frederic Cervenansky Date: Tue, 28 Apr 2009 09:36:18 +0000 Subject: [PATCH] Added Add DataBase event. --- src2/creaImageIOGimmick.cpp | 98 +++++++++++++++++++------------ src2/creaImageIOGimmick.h | 5 ++ src2/creaImageIOWxGimmickView.cpp | 30 ++++++++++ src2/creaImageIOWxGimmickView.h | 3 + 4 files changed, 99 insertions(+), 37 deletions(-) diff --git a/src2/creaImageIOGimmick.cpp b/src2/creaImageIOGimmick.cpp index 01e49bd..2d759d0 100644 --- a/src2/creaImageIOGimmick.cpp +++ b/src2/creaImageIOGimmick.cpp @@ -30,48 +30,19 @@ namespace creaImageIO //============================================================== void Gimmick::Initialize() { + std::string i_nameDB = "Local database"; // Create the UserSettings dir if does not exist CreateUserSettingsDirectory(); // Sets the current directory to the home dir mCurrentDirectory = GetHomeDirectory(); mSynchronizer=0; - // Create local database handler - mLocalDatabase = new SQLiteTreeHandler(GetLocalDatabasePath()); - // Add it to the TreeHandlerMap - mTreeHandlerMap["Local database"] = mLocalDatabase; + std::string dbpath = GetLocalDatabasePath(); // Create or open local database - if (! boost::filesystem::exists( GetLocalDatabasePath() ) ) - { - std::string mess = "Local database '"; - mess += GetLocalDatabasePath(); - mess += "' does not exist : creating it"; - GimmickMessage(1,mess<GetTree().GetDescriptor().CreateDefault(); - mLocalDatabase->GetTree().GetDescriptor().createDescriptorfromFile(mCurrentDirectory + "\\.gimmick\\localdatabase_Descriptor.txt"); - - if ( ! mLocalDatabase->Create(true) ) - { - GimmickError("ERROR CREATING '"<SetAttribute(0,"Name","Local database"); - } - else - { - /// Open and test it - GimmickMessage(1,"Opening local database '" - <Open(true) ) - { - GimmickError("ERROR OPENING '"<GetTree().GetDescriptor().createDescriptorfromFile(i_locDesc); + if ( ! sqlTreeH->Create(true) ) + { + GimmickError("ERROR CREATING '"<SetAttribute(0,"Name","i_name"); + } + else + { + /// Open and test it + GimmickMessage(1,"Opening local database '" <Open(true) ) + { + GimmickError("ERROR OPENING '"<second; + } delete mTimestampDatabase; } //============================================================== diff --git a/src2/creaImageIOGimmick.h b/src2/creaImageIOGimmick.h index 5b6606c..b7fd647 100644 --- a/src2/creaImageIOGimmick.h +++ b/src2/creaImageIOGimmick.h @@ -97,7 +97,12 @@ namespace creaImageIO /// Prints the tree handled by the handler void Print(const std::string& handler); + + ///create a DB from a given descriptor file and for a specific location + SQLiteTreeHandler *createDB(std::string &i_locDesc, std::string &i_locDB); + // add an existent DB + void addDB(std::string &i_nameDB, std::string &i_locationDB); /// Returns the TreeHandler with a given name TreeHandler* GetTreeHandler(const std::string& name) const; diff --git a/src2/creaImageIOWxGimmickView.cpp b/src2/creaImageIOWxGimmickView.cpp index 5b87845..70c845c 100644 --- a/src2/creaImageIOWxGimmickView.cpp +++ b/src2/creaImageIOWxGimmickView.cpp @@ -637,6 +637,35 @@ namespace creaImageIO mess << times; */ wxMessageBox(std2wx(mess.str()),_T("Addition result"),wxOK,this); + } + + void WxGimmickView::OnAddDB(wxCommandEvent& event) + { + + //Select DB + long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST; + std::string wc("*.sqlite3*"); + wxFileDialog* FD = new wxFileDialog( 0, + _T("Select file"), + _T(""), + _T(""), + crea::std2wx(wc), + style, + wxDefaultPosition); + + if (FD->ShowModal()==wxID_OK) + { + wxBusyCursor busy; + wxArrayString files; + FD->GetPaths(files); + for(int i = 0; i< files.size(); i++) + { + // gimmick->addDB("remote_" + i.c_str(),files[i]); + // AddTreeHandler(gimmick->getTreeHandlerMap("remote_" + i.c_str())); + } + } + + } //================================================= @@ -646,6 +675,7 @@ namespace creaImageIO EVT_TOOL(TOOL_ADDFILES_ID, WxGimmickView::OnAddFiles) EVT_TOOL(TOOL_ADDDIR_ID, WxGimmickView::OnAddDir) EVT_TOOL(TOOL_REMOVE_ID, WxGimmickView::OnRemove) + EVT_TOOL(TOOL_ADDDATABASE_ID, WxGimmickView::OnAddDB) END_EVENT_TABLE() //================================================= diff --git a/src2/creaImageIOWxGimmickView.h b/src2/creaImageIOWxGimmickView.h index 302698f..7dd38c9 100644 --- a/src2/creaImageIOWxGimmickView.h +++ b/src2/creaImageIOWxGimmickView.h @@ -116,6 +116,9 @@ namespace creaImageIO void OnAddProgress( Gimmick::AddProgress& ); /// Called upon to refresh the viewer once there are no actions to be done void OnInternalIdle(); + + // callback to add a database + void OnAddDB(wxCommandEvent& event); /// Progress dialog wxProgressDialog* mProgressDialog; -- 2.45.1