First try at removing columns
This commit is contained in:
parent
e27db91859
commit
50100c3ea5
61
source/app.d
61
source/app.d
@ -204,12 +204,25 @@ void main(string[] args)
|
|||||||
int newColIndex = oldstore.getNColumns();
|
int newColIndex = oldstore.getNColumns();
|
||||||
|
|
||||||
|
|
||||||
|
foreach(i ; 0..tree.getNColumns){
|
||||||
|
auto col = tree.getColumn(i);
|
||||||
|
writeln("col",i,"=",col, "(", col is null? "" : col.getTitle, ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
GType[] types;
|
GType[] types;
|
||||||
string[] titles;
|
string[] titles;
|
||||||
foreach(i ; 0..newColIndex){
|
int[] storeIndex;
|
||||||
|
foreach(i ; 0..tree.getNColumns){
|
||||||
|
writeln("Saving ",i);
|
||||||
if(i==0)types~= GType.INT;
|
if(i==0)types~= GType.INT;
|
||||||
else types~= GType.STRING;
|
else types~= GType.STRING;
|
||||||
titles~= tree.getColumn(0).getTitle;
|
|
||||||
|
storeIndex~= GetColumnStoreIndex(tree, 0)>=0?GetColumnStoreIndex(tree, 0):0;
|
||||||
|
|
||||||
|
auto col = tree.getColumn(0);
|
||||||
|
if(col !is null) titles~= tree.getColumn(0).getTitle;
|
||||||
|
else titles~= "ERR";
|
||||||
tree.removeColumn(tree.getColumn(0));
|
tree.removeColumn(tree.getColumn(0));
|
||||||
}
|
}
|
||||||
types~=GType.STRING;
|
types~=GType.STRING;
|
||||||
@ -227,9 +240,8 @@ void main(string[] args)
|
|||||||
|
|
||||||
foreach(i ; 0..newColIndex+1){
|
foreach(i ; 0..newColIndex+1){
|
||||||
if(i<newColIndex){
|
if(i<newColIndex){
|
||||||
if(types[i]==GType.INT) store.setValue(newit, cast(int)i, oldstore.getValueInt(oldit, i));
|
if(types[i]==GType.INT) store.setValue(newit, i, oldstore.getValueInt(oldit, storeIndex[i]));
|
||||||
else store.setValue(newit, cast(int)i, oldstore.getValueString(oldit, i));
|
else store.setValue(newit, i, oldstore.getValueString(oldit, storeIndex[i]));
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
store.setValue(newit, cast(int)i, "_");
|
store.setValue(newit, cast(int)i, "_");
|
||||||
@ -444,19 +456,44 @@ auto ref SetupColumn(TreeView tree, string sName, size_t index){
|
|||||||
col.setReorderable(true);
|
col.setReorderable(true);
|
||||||
col.addOnClicked((TreeViewColumn col){
|
col.addOnClicked((TreeViewColumn col){
|
||||||
import gtk.Dialog;
|
import gtk.Dialog;
|
||||||
auto dlg = new Dialog("Rename column", window, GtkDialogFlags.MODAL, ["Cancel","Rename"], [ResponseType.CANCEL, ResponseType.OK]);
|
auto dlg = new Dialog("Column options", window, GtkDialogFlags.MODAL, ["Close"], [ResponseType.CANCEL]);
|
||||||
auto entry = new Entry(col.getTitle);
|
|
||||||
dlg.getContentArea.packStart(entry, false, false, 5);
|
|
||||||
entry.show();
|
|
||||||
|
|
||||||
if(dlg.run()==ResponseType.OK){
|
//Rename
|
||||||
auto newname = entry.getText.strip;
|
dlg.getContentArea.packStart(new Label("Rename:"), false, false, 0);
|
||||||
|
|
||||||
|
auto renamebox = new HBox(false, 0);
|
||||||
|
dlg.getContentArea.packStart(renamebox, false, false, 0);
|
||||||
|
|
||||||
|
auto renameentry = new Entry(col.getTitle);
|
||||||
|
version(Windows) auto renamebutton = new Button(StockID.APPLY, true);
|
||||||
|
else static assert(0, "TODO");
|
||||||
|
renamebutton.addOnClicked((Button){
|
||||||
|
auto newname = renameentry.getText.strip;
|
||||||
if(newname.countchars(" \t\n\r")==0)
|
if(newname.countchars(" \t\n\r")==0)
|
||||||
col.setTitle(newname);
|
col.setTitle(newname);
|
||||||
else
|
else
|
||||||
SaySomething("Spaces are forbidden in column name");
|
SaySomething("Spaces are forbidden in column name");
|
||||||
}
|
});
|
||||||
|
renamebox.packStart(renameentry, true, true, 0);
|
||||||
|
renamebox.packEnd(renamebutton, false, false, 0);
|
||||||
|
|
||||||
|
//Delete
|
||||||
|
auto deletebox = new HBox(false, 0);
|
||||||
|
dlg.getContentArea.packStart(deletebox, false, false, 0);
|
||||||
|
|
||||||
|
version(Windows) auto deletebutton = new Button(StockID.DELETE, true);
|
||||||
|
else static assert(0, "TODO");
|
||||||
|
deletebutton.addOnClicked((Button){
|
||||||
|
tree.removeColumn(col);
|
||||||
|
dlg.destroy();
|
||||||
|
});
|
||||||
|
deletebox.packStart(new Label("Delete column"), true, true, 0);
|
||||||
|
deletebox.packEnd(deletebutton, false, false, 0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
dlg.showAll();
|
||||||
|
dlg.run();
|
||||||
dlg.destroy();
|
dlg.destroy();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user