Column adding

This commit is contained in:
Crom (Thibaut CHARLES) 2014-11-19 08:58:47 +01:00
parent 83cf73a286
commit 736b14fc2d
1 changed files with 37 additions and 14 deletions

View File

@ -159,29 +159,52 @@ void main(string[] args)
});
buttonNewCol.addOnClicked((Button){
auto store = cast(ListStore)tree.getModel();
int newColIndex = store.getNColumns();
auto oldstore = cast(ListStore)tree.getModel();
int newColIndex = oldstore.getNColumns();
GType[] types;
foreach(i ; 0..newColIndex+1)
types~= store.getColumnType(i);
store.setColumnTypes(types);
string[] titles;
foreach(i ; 0..newColIndex){
if(i==0)types~= GType.INT;
else types~= GType.STRING;
titles~= tree.getColumn(0).getTitle;
tree.removeColumn(tree.getColumn(0));
}
types~=GType.STRING;
titles~="new_col";
writeln(types.length);
writeln(types);
auto store = new ListStore(types);
tree.setModel(store);
//auto col = SetupColumn(tree, "new_col", newColIndex);
//setup cols
foreach(i ; 0..newColIndex+1){
tree.appendColumn(SetupColumn(tree, titles[i], i));
}
//Fill them
TreeIter oldit = new TreeIter();
TreeIter newit = new TreeIter();
if(oldstore.getIterFirst(oldit)){
do{
store.append(newit);
//TreeIter it = new TreeIter();
//if(store.getIterFirst(it)){
// do{
// store.setValue(it, newColIndex, "_");
// }while(store.iterNext(it));
//}
foreach(i ; 0..newColIndex+1){
if(i<newColIndex){
if(types[i]==GType.INT) store.setValue(newit, cast(int)i, oldstore.getValueInt(oldit, i));
else store.setValue(newit, cast(int)i, oldstore.getValueString(oldit, i));
//tree.appendColumn(col);
}
else
store.setValue(newit, cast(int)i, "_");
}
}while(oldstore.iterNext(oldit));
}
oldstore.destroy();
});