Build issues & column alignment
This commit is contained in:
parent
50100c3ea5
commit
aaefc184e8
42
source/app.d
Normal file → Executable file
42
source/app.d
Normal file → Executable file
@ -119,6 +119,7 @@ void main(string[] args)
|
||||
tree.setProperty("headers-clickable", true);
|
||||
tree.addOnColumnsChanged((TreeView tree){
|
||||
auto store = cast(ListStore)tree.getModel();
|
||||
if(store is null) return;
|
||||
|
||||
int si = GetColumnStoreIndex(tree, 0);
|
||||
if(si>=0 && store.getColumnType(si) != GType.INT){
|
||||
@ -201,6 +202,7 @@ void main(string[] args)
|
||||
|
||||
buttonNewCol.addOnClicked((Button){
|
||||
auto oldstore = cast(ListStore)tree.getModel();
|
||||
if(oldstore is null) return;
|
||||
int newColIndex = oldstore.getNColumns();
|
||||
|
||||
|
||||
@ -318,18 +320,42 @@ void Save(ref TreeView tree, string newpath=""){
|
||||
SetTitle(openedFile);
|
||||
}
|
||||
|
||||
auto file = File(openedFile, "w");
|
||||
|
||||
//Detect column sizes
|
||||
ulong colSize[];
|
||||
colSize.length = tree.getNColumns;
|
||||
foreach(i ; 0..tree.getNColumns)
|
||||
file.write(tree.getColumn(i).getTitle, "\t");
|
||||
file.write("\n");
|
||||
colSize[i] = tree.getColumn(i).getTitle.length +1;//+1 space
|
||||
|
||||
TreeIter it = new TreeIter();
|
||||
if(store.getIterFirst(it)){
|
||||
do{
|
||||
file.write(store.getValueInt(it, 0));
|
||||
import std.math : log10;
|
||||
int size0 = log10(store.getValueInt(it, 0)+1).to!int +1;//+1 space
|
||||
if(size0>colSize[0])
|
||||
colSize[0] = size0;
|
||||
|
||||
foreach(i ; 1..store.getNColumns()){
|
||||
file.write("\t\"", store.getValueString(it, GetColumnStoreIndex(tree, i)), "\"");
|
||||
int size = store.getValueString(it, GetColumnStoreIndex(tree, i)).length.to!int +3;//+2 double quotes added, +1 space
|
||||
if(size>colSize[i])
|
||||
colSize[i] = size;
|
||||
}
|
||||
}while(store.iterNext(it));
|
||||
}
|
||||
|
||||
|
||||
//Write file
|
||||
auto file = File(openedFile, "w");
|
||||
|
||||
foreach(i ; 0..tree.getNColumns)
|
||||
file.write(leftJustify(tree.getColumn(i).getTitle, colSize[i]));
|
||||
file.write("\n");
|
||||
|
||||
it = new TreeIter();
|
||||
if(store.getIterFirst(it)){
|
||||
do{
|
||||
file.write(leftJustify(store.getValueInt(it, 0).to!string, colSize[0]));
|
||||
foreach(i ; 1..store.getNColumns()){
|
||||
file.write(leftJustify("\""~store.getValueString(it, GetColumnStoreIndex(tree, i))~"\"", colSize[i]));
|
||||
}
|
||||
file.write("\n");
|
||||
}while(store.iterNext(it));
|
||||
@ -466,7 +492,7 @@ auto ref SetupColumn(TreeView tree, string sName, size_t index){
|
||||
|
||||
auto renameentry = new Entry(col.getTitle);
|
||||
version(Windows) auto renamebutton = new Button(StockID.APPLY, true);
|
||||
else static assert(0, "TODO");
|
||||
else auto renamebutton = new Button("object-select-symbolic", GtkIconSize.SMALL_TOOLBAR);
|
||||
renamebutton.addOnClicked((Button){
|
||||
auto newname = renameentry.getText.strip;
|
||||
if(newname.countchars(" \t\n\r")==0)
|
||||
@ -482,7 +508,7 @@ auto ref SetupColumn(TreeView tree, string sName, size_t index){
|
||||
dlg.getContentArea.packStart(deletebox, false, false, 0);
|
||||
|
||||
version(Windows) auto deletebutton = new Button(StockID.DELETE, true);
|
||||
else static assert(0, "TODO");
|
||||
else auto deletebutton = new Button("user-trash-symbolic", GtkIconSize.SMALL_TOOLBAR);
|
||||
deletebutton.addOnClicked((Button){
|
||||
tree.removeColumn(col);
|
||||
dlg.destroy();
|
||||
|
Loading…
Reference in New Issue
Block a user