Moving id is forbidden

master
Crom (Thibaut CHARLES) 8 years ago
parent c71aa68bc7
commit 61885f57aa

@ -101,6 +101,19 @@ void main(string[] args)
tree.setProperty("tooltip-column", 0);
tree.setProperty("reorderable", true);
tree.setProperty("headers-clickable", true);
tree.addOnColumnsChanged((TreeView tree){
auto store = cast(ListStore)tree.getModel();
if(store.getColumnType(GetColumnStoreIndex(tree, 0)) != GType.INT){
writeln("Position 0 is forbidden");
foreach(i ; 0..store.getNColumns()){
if(store.getColumnType(GetColumnStoreIndex(tree, i))==GType.INT){
tree.moveColumnAfter(tree.getColumn(i), null);
break;
}
}
}
});
//Configure button callbacks
@ -221,6 +234,10 @@ void main(string[] args)
}
int GetColumnStoreIndex(TreeView tree, int colindex){
return cast(int)(tree.getColumn(colindex).getData("colnumber"));
}
void Save(ref TreeView tree){
auto store = cast(ListStore)tree.getModel();
if(store !is null){
@ -236,8 +253,7 @@ void Save(ref TreeView tree){
do{
file.write(store.getValueInt(it, 0));
foreach(i ; 1..store.getNColumns()){
int storecol = cast(int)(tree.getColumn(i).getData("colnumber"));
file.write("\t\"", store.getValueString(it, storecol), "\"");
file.write("\t\"", store.getValueString(it, GetColumnStoreIndex(tree, i)), "\"");
}
file.write("\n");
}while(store.iterNext(it));

Loading…
Cancel
Save