Column adding
This commit is contained in:
parent
83cf73a286
commit
736b14fc2d
1 changed files with 37 additions and 14 deletions
51
source/app.d
51
source/app.d
|
@ -159,29 +159,52 @@ void main(string[] args)
|
||||||
});
|
});
|
||||||
|
|
||||||
buttonNewCol.addOnClicked((Button){
|
buttonNewCol.addOnClicked((Button){
|
||||||
auto store = cast(ListStore)tree.getModel();
|
auto oldstore = cast(ListStore)tree.getModel();
|
||||||
int newColIndex = store.getNColumns();
|
int newColIndex = oldstore.getNColumns();
|
||||||
|
|
||||||
|
|
||||||
GType[] types;
|
GType[] types;
|
||||||
foreach(i ; 0..newColIndex+1)
|
string[] titles;
|
||||||
types~= store.getColumnType(i);
|
foreach(i ; 0..newColIndex){
|
||||||
store.setColumnTypes(types);
|
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();
|
foreach(i ; 0..newColIndex+1){
|
||||||
//if(store.getIterFirst(it)){
|
if(i<newColIndex){
|
||||||
// do{
|
if(types[i]==GType.INT) store.setValue(newit, cast(int)i, oldstore.getValueInt(oldit, i));
|
||||||
// store.setValue(it, newColIndex, "_");
|
else store.setValue(newit, cast(int)i, oldstore.getValueString(oldit, i));
|
||||||
// }while(store.iterNext(it));
|
|
||||||
//}
|
|
||||||
|
|
||||||
//tree.appendColumn(col);
|
}
|
||||||
|
else
|
||||||
|
store.setValue(newit, cast(int)i, "_");
|
||||||
|
}
|
||||||
|
|
||||||
|
}while(oldstore.iterNext(oldit));
|
||||||
|
}
|
||||||
|
|
||||||
|
oldstore.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue