Column adding

master
Crom (Thibaut CHARLES) 8 years ago
parent 83cf73a286
commit 736b14fc2d

@ -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);
//setup cols
foreach(i ; 0..newColIndex+1){
tree.appendColumn(SetupColumn(tree, titles[i], i));
}
//auto col = SetupColumn(tree, "new_col", newColIndex);
//Fill them
TreeIter oldit = new TreeIter();
TreeIter newit = new TreeIter();
if(oldstore.getIterFirst(oldit)){
do{
store.append(newit);
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));
//TreeIter it = new TreeIter();
//if(store.getIterFirst(it)){
// do{
// store.setValue(it, newColIndex, "_");
// }while(store.iterNext(it));
//}
}
else
store.setValue(newit, cast(int)i, "_");
}
}while(oldstore.iterNext(oldit));
}
//tree.appendColumn(col);
oldstore.destroy();
});

Loading…
Cancel
Save