mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-12 13:37:00 -04:00
feat: revert hack for time card columns, use scripts instead
This commit is contained in:
+1
-1
@@ -8,7 +8,7 @@ Features:
|
|||||||
* Independently control Export Zoom setting in Preferences Window.
|
* Independently control Export Zoom setting in Preferences Window.
|
||||||
* Center the loaded image by default in the Image Slice 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 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.
|
* Add filter box to Game and Stylesheet selection.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -1325,6 +1325,7 @@ card field:
|
|||||||
show statistics: false
|
show statistics: false
|
||||||
save value: false
|
save value: false
|
||||||
editable: false
|
editable: false
|
||||||
|
script: card.time_created
|
||||||
card list visible: true
|
card list visible: true
|
||||||
card list name: Created At
|
card list name: Created At
|
||||||
card list column: 100
|
card list column: 100
|
||||||
@@ -1335,17 +1336,8 @@ card field:
|
|||||||
show statistics: false
|
show statistics: false
|
||||||
save value: false
|
save value: false
|
||||||
editable: false
|
editable: false
|
||||||
|
script: card.time_modified
|
||||||
card list visible: true
|
card list visible: true
|
||||||
card list name: Last Modified At
|
card list name: Last Modified At
|
||||||
card list column: 101
|
card list column: 101
|
||||||
card list width: 150
|
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
|
|
||||||
|
|||||||
@@ -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 {
|
bool Card::contains(QuickFilterPart const& query) const {
|
||||||
FOR_EACH_CONST(v, data) {
|
FOR_EACH_CONST(v, data) {
|
||||||
if (query.match(v->fieldP->name, v->toString())) return true;
|
if (query.match(v->fieldP->name, v->toString())) return true;
|
||||||
|
|||||||
@@ -61,9 +61,6 @@ public:
|
|||||||
/// Get the identification of this card, an identification is something like a name, title, etc.
|
/// Get the identification of this card, an identification is something like a name, title, etc.
|
||||||
/** May return "" */
|
/** May return "" */
|
||||||
String identification() const;
|
String identification() const;
|
||||||
|
|
||||||
String valueOfDataKey(FieldP fieldP);
|
|
||||||
|
|
||||||
/// Does any field contains the given query string?
|
/// Does any field contains the given query string?
|
||||||
bool contains(QuickFilterPart const& query) const;
|
bool contains(QuickFilterPart const& query) const;
|
||||||
|
|
||||||
|
|||||||
@@ -186,17 +186,9 @@ bool CardListBase::doDelete() {
|
|||||||
// Comparison object for comparing cards
|
// Comparison object for comparing cards
|
||||||
bool CardListBase::compareItems(void* a, void* b) const {
|
bool CardListBase::compareItems(void* a, void* b) const {
|
||||||
FieldP sort_field = column_fields[sort_by_column];
|
FieldP sort_field = column_fields[sort_by_column];
|
||||||
|
|
||||||
ValueP va = reinterpret_cast<Card*>(a)->data[sort_field];
|
ValueP va = reinterpret_cast<Card*>(a)->data[sort_field];
|
||||||
ValueP vb = reinterpret_cast<Card*>(b)->data[sort_field];
|
ValueP vb = reinterpret_cast<Card*>(b)->data[sort_field];
|
||||||
assert(va && vb);
|
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
|
// compare sort keys
|
||||||
int cmp = smart_compare( va->getSortKey(), vb->getSortKey() );
|
int cmp = smart_compare( va->getSortKey(), vb->getSortKey() );
|
||||||
if (cmp != 0) return cmp < 0;
|
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!
|
// wx may give us non existing columns!
|
||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
}
|
}
|
||||||
|
ValueP val = getCard(pos)->data[column_fields[col]];
|
||||||
return getCard(pos)->valueOfDataKey(column_fields[col]);
|
if (val) return val->toString();
|
||||||
|
else return wxEmptyString;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CardListBase::OnGetItemImage(long pos) const {
|
int CardListBase::OnGetItemImage(long pos) const {
|
||||||
|
|||||||
Reference in New Issue
Block a user