Most operations OK

This commit is contained in:
Crom (Thibaut CHARLES) 2014-11-18 14:41:47 +01:00
parent 12e083eb1d
commit 9f6bbb689b

View File

@ -99,6 +99,44 @@ void main(string[] args)
fc.destroy();
});
buttonInsert.addOnClicked((Button){
TreeIter it = tree.getSelectedIter();
auto store = cast(ListStore)tree.getModel();
if(store !is null){
store.insertAfter(it, it);
store.setValue(it, 0, 0);
foreach(i ; 1..store.getNColumns()){
store.setValue(it, cast(int)i, "_");
}
}
});
buttonDelete.addOnClicked((Button){
TreeIter it = tree.getSelectedIter();
auto store = cast(ListStore)tree.getModel();
if(store !is null)
store.remove(it);
});
buttonRenumber.addOnClicked((Button){
auto store = cast(ListStore)tree.getModel();
if(store !is null){
TreeIter it = new TreeIter();
if(store.getIterFirst(it)){
int id = 0;
do{
store.setValue(it, 0, id++);
}while(store.iterNext(it));
}
}
});
//Open if exists
if(args.length>=2 && exists(args[1])){
version(Windows) Open(args[1], tree, cast(Object)window);
@ -115,14 +153,15 @@ void Save(ref TreeView tree){
auto store = cast(ListStore)tree.getModel();
if(store !is null){
TreeIter it = new TreeIter();
store.getIterFirst(it);//TODO: fail if first is null
do{
std.stdio.write("\t",store.getValueInt(it, 0));
foreach(i ; 1..store.getNColumns()){
std.stdio.write("\t",store.getValueString(it, i));
}
writeln();
}while(store.iterNext(it));
if(store.getIterFirst(it)){
do{
std.stdio.write("\t",store.getValueInt(it, 0));
foreach(i ; 1..store.getNColumns()){
std.stdio.write("\t",store.getValueString(it, i));
}
writeln();
}while(store.iterNext(it));
}
}
else
writeln("Nothing to save !");