feat: revert hack for time card columns, use scripts instead

This commit is contained in:
Brendan Hagan
2022-06-20 21:06:27 -04:00
parent f9525fab82
commit 4173d5017b
5 changed files with 273 additions and 309 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ Features:
* Independently control Export Zoom setting in Preferences Window.
* Center the loaded image by default in the Image Slice Window.
* Add Button to Center the loaded image in the Image Slice Window.
* Add "Created At", "Last Modified At", "Has Notes" columns to card list.
* Add "Created At", "Last Modified At" columns to card list.
* Add filter box to Game and Stylesheet selection.
------------------------------------------------------------------------------
+2 -10
View File
@@ -1325,6 +1325,7 @@ card field:
show statistics: false
save value: false
editable: false
script: card.time_created
card list visible: true
card list name: Created At
card list column: 100
@@ -1335,17 +1336,8 @@ card field:
show statistics: false
save value: false
editable: false
script: card.time_modified
card list visible: true
card list name: Last Modified At
card list column: 101
card list width: 150
card field:
type: text
name: has notes
show statistics: false
save value: false
editable: false
card list visible: true
card list name: Has Notes
card list column: 102
card list width: 50
-18
View File
@@ -52,24 +52,6 @@ String Card::identification() const {
}
}
String Card::valueOfDataKey(FieldP fieldP) {
String columnName = fieldP.get()->name;
if (columnName == "time_created") {
return time_created.Format("%Y-%m-%d %H:%M:%S").ToStdString();
}
else if (columnName == "time_modified") {
return time_modified.Format("%Y-%m-%d %H:%M:%S").ToStdString();
}
else if (columnName == "has_notes") {
return notes.empty() ? "N" : "Y";
}
ValueP val = data[fieldP];
if (val) return val->toString();
else return wxEmptyString;
}
bool Card::contains(QuickFilterPart const& query) const {
FOR_EACH_CONST(v, data) {
if (query.match(v->fieldP->name, v->toString())) return true;
-3
View File
@@ -61,9 +61,6 @@ public:
/// Get the identification of this card, an identification is something like a name, title, etc.
/** May return "" */
String identification() const;
String valueOfDataKey(FieldP fieldP);
/// Does any field contains the given query string?
bool contains(QuickFilterPart const& query) const;
+3 -10
View File
@@ -186,17 +186,9 @@ bool CardListBase::doDelete() {
// Comparison object for comparing cards
bool CardListBase::compareItems(void* a, void* b) const {
FieldP sort_field = column_fields[sort_by_column];
ValueP va = reinterpret_cast<Card*>(a)->data[sort_field];
ValueP vb = reinterpret_cast<Card*>(b)->data[sort_field];
assert(va && vb);
// Super hack for sorting internal fields. Couldn't figure out how to bind these to ValuePs.
if (sort_field->name == "time_created" || sort_field->name == "time_modified" || sort_field->name == "has_notes") {
int cmp = smart_compare(reinterpret_cast<Card*>(a)->valueOfDataKey(sort_field), reinterpret_cast<Card*>(b)->valueOfDataKey(sort_field));
if (cmp != 0) return cmp < 0;
}
// compare sort keys
int cmp = smart_compare( va->getSortKey(), vb->getSortKey() );
if (cmp != 0) return cmp < 0;
@@ -317,8 +309,9 @@ String CardListBase::OnGetItemText(long pos, long col) const {
// wx may give us non existing columns!
return wxEmptyString;
}
return getCard(pos)->valueOfDataKey(column_fields[col]);
ValueP val = getCard(pos)->data[column_fields[col]];
if (val) return val->toString();
else return wxEmptyString;
}
int CardListBase::OnGetItemImage(long pos) const {