mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-13 14:07:01 -04:00
feat: super sloppy way of adding more card list columns (created, modified, notes)
This commit is contained in:
@@ -1110,4 +1110,38 @@ card field:
|
|||||||
type: image
|
type: image
|
||||||
name: mainframe image 2
|
name: mainframe image 2
|
||||||
show statistics: false
|
show statistics: false
|
||||||
description: An extra image of the card
|
description: An extra image of the card
|
||||||
|
|
||||||
|
|
||||||
|
############################# Exposing Internal Fields?
|
||||||
|
|
||||||
|
card field:
|
||||||
|
type: text
|
||||||
|
name: time created
|
||||||
|
show statistics: false
|
||||||
|
save value: false
|
||||||
|
editable: false
|
||||||
|
card list visible: true
|
||||||
|
card list name: Created At
|
||||||
|
card list column: 100
|
||||||
|
card list width: 150
|
||||||
|
card field:
|
||||||
|
type: text
|
||||||
|
name: time modified
|
||||||
|
show statistics: false
|
||||||
|
save value: false
|
||||||
|
editable: false
|
||||||
|
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
|
||||||
|
|||||||
@@ -52,6 +52,24 @@ 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,6 +61,9 @@ 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,9 +186,17 @@ 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;
|
||||||
@@ -309,9 +317,8 @@ 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]];
|
|
||||||
if (val) return val->toString();
|
return getCard(pos)->valueOfDataKey(column_fields[col]);
|
||||||
else return wxEmptyString;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int CardListBase::OnGetItemImage(long pos) const {
|
int CardListBase::OnGetItemImage(long pos) const {
|
||||||
|
|||||||
Reference in New Issue
Block a user