UPDATEDB(query.str());
}
+ //=====================================================================
+ void SQLiteTreeHandler::BeginTransaction()
+ {
+ std::stringstream out;
+ out<<"begin transaction;";
+ UPDATEDB(out.str());
+ }
+
+ //=====================================================================
+ void SQLiteTreeHandler::EndTransaction()
+ {
+ std::stringstream out;
+ out<<"commit transaction;";
+ UPDATEDB(out.str());
+ }
+
/*
//=====================================================================
bool SQLiteTreeHandler::DBInsert(Node* alien_node,
virtual bool Create(bool writable = false);
/// Destroys the 'source'
virtual bool Destroy();
+ /// Begins a transaction
+ virtual void BeginTransaction();
+ ///Commits results and ends transaction
+ virtual void EndTransaction();
//====================================================================
virtual bool Create(bool writable = false) { return false; }
/// Destroys the 'source'
virtual bool Destroy() { return false; }
+ /// Begins a transaction
+ virtual void BeginTransaction(){}
+ ///Commits results and ends transaction
+ virtual void EndTransaction(){}
//====================================================================
rec<<recurse;
mSynchronizer->InsertAddOp(directory,rec.str(),"0",mCurrentDB);
std::string addKey=mSynchronizer->GetAttribute("ADD_KEY","ADD_OPS","PATH",directory,mCurrentDB);
+ mTreeHandler->BeginTransaction();
AddDirectoryRecursor( directory, recurse, addKey );
int nFiles=GetProgress().GetNumberAddedFiles();
files<<nFiles;
mSynchronizer->SetAttribute("FILES_ADDED","ADD_OPS",files.str(),"ADD_KEY",addKey,mCurrentDB);
+ mTreeHandler->EndTransaction();
GimmickDebugMessage(3,mProgress<<std::endl);
}
/// Gets the attributes that are being shown and the ones that have been blocked on a specific level
virtual void GetAttributes(std::vector<std::string>& areShown, std::vector<std::string>& notShown, int level){ GimmickError("INTERNAL ERROR : TreeView::GetAttributes not overloaded"); }
+
+ ///Sets the non visible attributes and refreshes the GUI
+ virtual void SetNonVisibleAttributes(const std::vector<std::string>& notShown, int level){ GimmickError("INTERNAL ERROR : TreeView::SetNonVisibleAttributes not overloaded"); }
+
+ ///Creates a new listctrl
+ virtual void CreateCtrl(std::vector<std::string>& notShown, int nlevel){ GimmickError("INTERNAL ERROR : TreeView::CreateCtrl not overloaded"); }
protected:
TreeHandler* GetTreeHandler() { return mTreeHandler; }
levels=new wxComboBox(this, ID_COMBO,"1",wxPoint(190, 5),wxDefaultSize,as);
wxStaticText * na=new wxStaticText(this,-1,_T(" Currently hidden attributes: "), wxPoint(255,10));
- shownAtts=new wxListCtrl(this, wxID_ANY, wxPoint(5,30), wxSize(160,90), wxLC_REPORT | wxLC_NO_HEADER | wxLC_SINGLE_SEL );
+ shownAtts=new wxListCtrl(this, wxID_ANY, wxPoint(5,30), wxSize(160,90), wxLC_REPORT | wxLC_NO_HEADER );
shownAtts->InsertColumn(0,
crea::std2wx(""),
wxButton *remove = new wxButton(this,wxID_ANY,_T("<<"), wxPoint(170,70) );
Connect( remove->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAttributeSelectionPanel::OnRemove );
- notShownAtts=new wxListCtrl(this, wxID_ANY, wxPoint(255,30), wxSize(160,90), wxLC_REPORT | wxLC_NO_HEADER | wxLC_SINGLE_SEL );
+ notShownAtts=new wxListCtrl(this, wxID_ANY, wxPoint(255,30), wxSize(160,90), wxLC_REPORT | wxLC_NO_HEADER );
notShownAtts->InsertColumn(0,
crea::std2wx(""),
void WxAttributeSelectionPanel::OnSaveConfig(wxCommandEvent& event)
{
- /*mView->OnSaveSettingsCallback(crea::wx2std(copyPath->GetValue()),
- crea::wx2std(dbPath->GetValue()),
- crea::wx2std(syncEvent->GetValue()),
- crea::wx2std(syncFrequency->GetValue()));
- */
+ int n=levels->GetSelection();
+ if(n<0){n=0;}
+ mView->OnAttributesChanged(notShownA,n);
dialog->Destroy();
}
}
shownA.erase(it-1);
notShownA.push_back(change);
- LoadCtrls();
-
}
+ LoadCtrls();
}
}
notShownA.erase(it-1);
shownA.push_back(change);
- LoadCtrls();
}
+ LoadCtrls();
}
std::string val=node->GetAttribute(keys[0]);
if(val.compare("")==0){val="?";}
- wxStaticText * av=new wxStaticText(this,-1,_T(" Actual Value: "), wxPoint(5,40));
+ wxStaticText * av=new wxStaticText(this,-1,_T(" Current Value: "), wxPoint(5,40));
actualVal=new wxStaticText(this,-1,_T(val), wxPoint(110,40));
wxStaticText * nv=new wxStaticText(this,-1,_T(" New Value: "), wxPoint(5,70));
void WxEditFieldsPanel::OnEdit(wxCommandEvent& event)
{
std::string val=crea::wx2std(newVal->GetValue());
- mView->OnFieldsEdited(node,names[attributes->GetSelection()],keys[attributes->GetSelection()],val);
+ int sel=attributes->GetSelection();
+ if(sel==-1)
+ {
+ sel=0;
+ }
+ mView->OnFieldsEdited(node,names[sel],keys[sel],val);
dialog->Destroy();
}
{
GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->GetAttributes(shown,nShown,level);
}
+
+ //===================================================================
+ void WxGimmickView::OnAttributesChanged(const std::vector<std::string>& nShown, int level)
+ {
+ GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->SetNonVisibleAttributes(nShown,level);
+ std::vector<std::string> n=nShown;
+ GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->CreateCtrl(n,level);
+ }
//===================================================================
void WxGimmickView::OnSaveSettingsCallback(const std::string& copyPath,
const std::string& dbPath,
///Called upon to return the visible attributes of the current tab
void GetVisibleAttributes(std::vector<std::string>& shown,std::vector<std::string>& nShown, int level);
-
-
-
+
+ ///Called when there has been a change in the visible attributes of a tree view
+ void OnAttributesChanged(const std::vector<std::string>& nShown, int level);
protected:
/// Creates the tool bar
a != GetTreeHandler()->GetTree().GetAttributeDescriptorList(level).end();
++a)
{
- if(a->GetFlags()==creaImageIO::tree::AttributeDescriptor::EDITABLE)
+ if(a->GetFlags()==creaImageIO::tree::AttributeDescriptor::EDITABLE && IsAttributeVisible(a->GetName(),level))
{
areShown.push_back(a->GetName());
}
}
notShown=mLevelList[level-1].notShownAtts;
}
+
+ //================================================================
+ void WxTreeView::SetNonVisibleAttributes(const std::vector<std::string>& notShown, int nlevel)
+ {
+ mLevelList[nlevel].notShownAtts=notShown;
+ }
+
+ //================================================================
+ void WxTreeView::CreateCtrl(std::vector<std::string>& notShown, int nlevel)
+ {
+ int ctrl_style = wxLC_REPORT | wxLC_VRULES;
+ int col_style = wxLIST_FORMAT_LEFT;
+ LevelType level;
+ mLevelList[nlevel].SelectedUpToDate = true;
+ mLevelList[nlevel].SortColumn = 0;
+ mLevelList[nlevel].key.clear();
+
+ mLevelList[nlevel].wxCtrl = new wxListCtrl(mLevelList[nlevel].wxSplitter,
+ nlevel,
+ wxDefaultPosition,
+ wxDefaultSize,
+ ctrl_style);
+ wxWindow* oldWin=mLevelList[nlevel].wxSplitter->GetWindow1();
+ mLevelList[nlevel].wxSplitter->ReplaceWindow(oldWin,mLevelList[nlevel].wxCtrl);
+ mLevelList[nlevel].wxSplitter->Initialize(mLevelList[nlevel].wxCtrl);
+
+ // Create the columns : one for each attribute of the level
+ int col = 0;
+ std::string title;
+
+ tree::LevelDescriptor::AttributeDescriptorListType::const_iterator a;
+ for (a = GetTreeHandler()->GetTree().GetAttributeDescriptorList(nlevel+1).begin();
+ a != GetTreeHandler()->GetTree().GetAttributeDescriptorList(nlevel+1).end();
+ ++a)
+
+ {
+ if(a->GetFlags()!=creaImageIO::tree::AttributeDescriptor::PRIVATE && IsAttributeVisible(a->GetName(),nlevel+1))
+ {
+ title=a->GetName();
+ std::string temp = a->GetKey();
+ if (temp.compare("ID") != 0)
+ {
+ mLevelList[nlevel].wxCtrl->InsertColumn(col,
+ crea::std2wx(title),
+ col_style);
+ col++;
+ }
+ mLevelList[nlevel].key.push_back(a->GetKey());
+ }
+
+ }
+ oldWin->Destroy();
+ UpdateLevel(1);
+ }
+
+ //================================================================
+ bool WxTreeView::IsAttributeVisible(const std::string& val, int level)
+ {
+ std::vector<std::string> ns=mLevelList[level-1].notShownAtts;
+ std::vector<std::string>::iterator it;
+ bool found=false;
+ for(it=ns.begin();it!=ns.end()&&!found;++it)
+ {
+ if(val.compare(*it)==0)
+ {
+ found=true;
+ }
+ }
+
+ return !found;
+ }
+
//================================================================
//================================================================
BEGIN_EVENT_TABLE(WxTreeView, wxPanel)
/// Gets the attributes that are being shown and the ones that have been blocked on a specific level
void GetAttributes(std::vector<std::string>& areShown, std::vector<std::string>& notShown, int level);
+
+ ///Sets the non visible attributes and refreshes the GUI
+ void SetNonVisibleAttributes(const std::vector<std::string>& notShown, int level);
+
+ ///Creates a new listctrl
+ void CreateCtrl(std::vector<std::string>& notShown, int nlevel);
+
+ ///Returns true if the attribute passed as a parameter is visible or not
+ bool IsAttributeVisible(const std::string& val, int level);
/// Actual processing of item selection/deselection
/// Called by OnItemSelected and OnItemDeSelected