Commit ab2e0c38 authored by twanvl's avatar twanvl

Allow multiple cards to be selected in a card list,

Allow card actions to add/remove multiple cards.
not yet: actually use these multicard actions.
parent 17a4fab9
...@@ -19,40 +19,34 @@ DECLARE_TYPEOF_COLLECTION(KeywordModeP); ...@@ -19,40 +19,34 @@ DECLARE_TYPEOF_COLLECTION(KeywordModeP);
// ----------------------------------------------------------------------------- : Add Keyword // ----------------------------------------------------------------------------- : Add Keyword
AddKeywordAction::AddKeywordAction(Adding, Set& set, const KeywordP& keyword) AddKeywordAction::AddKeywordAction(Set& set)
: KeywordListAction(set), adding(true), keyword(keyword ? keyword : new_intrusive<Keyword>()) : KeywordListAction(set)
, keyword_id(set.keywords.size()) , action(ADD, new_intrusive<Keyword>(), set.keywords)
{ {
Keyword& keyword = *action.steps.front().item;
// find default mode // find default mode
FOR_EACH(mode, set.game->keyword_modes) { FOR_EACH(mode, set.game->keyword_modes) {
if (mode->is_default) { if (mode->is_default) {
this->keyword->mode = mode->name; keyword.mode = mode->name;
break; break;
} }
} }
} }
AddKeywordAction::AddKeywordAction(Removing, Set& set, const KeywordP& keyword) AddKeywordAction::AddKeywordAction(AddingOrRemoving ar, Set& set, const KeywordP& keyword)
: KeywordListAction(set), adding(false), keyword(keyword) : KeywordListAction(set)
// find the keyword_id of the keyword we want to remove , action(ar, keyword, set.keywords)
, keyword_id(find(set.keywords.begin(), set.keywords.end(), keyword) - set.keywords.begin()) {}
{ /*AddKeywordAction::AddKeywordAction(AddingOrRemoving ar, Set& set, const vector<KeywordP>& keyword)
if (keyword_id >= set.keywords.size()) { : KeywordListAction(set)
throw InternalError(_("Keyword to remove not found in set")); , action(ar, keywords, set.keywords)
} {}*/
}
String AddKeywordAction::getName(bool to_undo) const { String AddKeywordAction::getName(bool to_undo) const {
return adding ? _("Add keyword") : _("Remove keyword"); return action.getName();
} }
void AddKeywordAction::perform(bool to_undo) { void AddKeywordAction::perform(bool to_undo) {
if (adding != to_undo) { action.perform(set.keywords, to_undo);
assert(keyword_id <= set.keywords.size());
set.keywords.insert(set.keywords.begin() + keyword_id, keyword);
} else {
assert(keyword_id < set.keywords.size());
set.keywords.erase(set.keywords.begin() + keyword_id);
}
set.keyword_db.clear(); set.keyword_db.clear();
} }
......
...@@ -18,9 +18,11 @@ ...@@ -18,9 +18,11 @@
#include <util/action_stack.hpp> #include <util/action_stack.hpp>
#include <util/error.hpp> #include <util/error.hpp>
#include <data/field/text.hpp> #include <data/field/text.hpp>
#include <data/action/generic.hpp>
class Set; class Set;
DECLARE_POINTER_TYPE(Keyword); DECLARE_POINTER_TYPE(Keyword);
DECLARE_TYPEOF_COLLECTION(GenericAddAction<KeywordP>::Step);
// ----------------------------------------------------------------------------- : Add Keyword // ----------------------------------------------------------------------------- : Add Keyword
...@@ -34,22 +36,16 @@ class KeywordListAction : public Action { ...@@ -34,22 +36,16 @@ class KeywordListAction : public Action {
// therefore we don't need a smart pointer // therefore we don't need a smart pointer
}; };
enum Adding {ADD};
enum Removing {REMOVE};
/// Adding or removing a keyword from a set /// Adding or removing a keyword from a set
class AddKeywordAction : public KeywordListAction { class AddKeywordAction : public KeywordListAction {
public: public:
AddKeywordAction(Adding, Set& set, const KeywordP& keyword = KeywordP()); AddKeywordAction(Set& set);
AddKeywordAction(Removing, Set& set, const KeywordP& keyword); AddKeywordAction(AddingOrRemoving, Set& set, const KeywordP& keyword);
virtual String getName(bool to_undo) const; virtual String getName(bool to_undo) const;
virtual void perform(bool to_undo); virtual void perform(bool to_undo);
//private: const GenericAddAction<KeywordP> action;
const bool adding; ///< Was a keyword added? (as opposed to removed)
const KeywordP keyword; ///< The new/removed keyword
const size_t keyword_id; ///< Position of the keyword in the set
}; };
// ----------------------------------------------------------------------------- : Changing keywords // ----------------------------------------------------------------------------- : Changing keywords
......
...@@ -18,51 +18,26 @@ DECLARE_TYPEOF_COLLECTION(IndexMap<FieldP COMMA ValueP>); ...@@ -18,51 +18,26 @@ DECLARE_TYPEOF_COLLECTION(IndexMap<FieldP COMMA ValueP>);
// ----------------------------------------------------------------------------- : Add card // ----------------------------------------------------------------------------- : Add card
AddCardAction::AddCardAction(Set& set) AddCardAction::AddCardAction(Set& set)
: CardListAction(set), card(new Card(*set.game)) : CardListAction(set)
, action(ADD, new_intrusive1<Card>(*set.game), set.cards)
{} {}
AddCardAction::AddCardAction(Set& set, const CardP& card) AddCardAction::AddCardAction(AddingOrRemoving ar, Set& set, const CardP& card)
: CardListAction(set), card(card) : CardListAction(set)
, action(ar, card, set.cards)
{}
AddCardAction::AddCardAction(AddingOrRemoving ar, Set& set, const vector<CardP>& cards)
: CardListAction(set)
, action(ar, cards, set.cards)
{} {}
String AddCardAction::getName(bool to_undo) const { String AddCardAction::getName(bool to_undo) const {
return _("Add card"); return action.getName();
} }
void AddCardAction::perform(bool to_undo) { void AddCardAction::perform(bool to_undo) {
if (!to_undo) { action.perform(set.cards, to_undo);
set.cards.push_back(card);
} else {
assert(!set.cards.empty());
set.cards.pop_back();
}
}
// ----------------------------------------------------------------------------- : Remove card
RemoveCardAction::RemoveCardAction(Set& set, const CardP& card)
: CardListAction(set), card(card)
// find the card_id of the card we want to remove
, card_id(find(set.cards.begin(), set.cards.end(), card) - set.cards.begin())
{
if (card_id >= set.cards.size()) {
throw InternalError(_("Card to remove not found in set"));
}
}
String RemoveCardAction::getName(bool to_undo) const {
return _("Remove card");
}
void RemoveCardAction::perform(bool to_undo) {
if (!to_undo) {
assert(card_id < set.cards.size());
set.cards.erase(set.cards.begin() + card_id);
} else {
assert(card_id <= set.cards.size());
set.cards.insert(set.cards.begin() + card_id, card);
}
} }
......
...@@ -16,12 +16,14 @@ ...@@ -16,12 +16,14 @@
#include <util/prec.hpp> #include <util/prec.hpp>
#include <util/action_stack.hpp> #include <util/action_stack.hpp>
#include <data/action/generic.hpp>
class Set; class Set;
DECLARE_POINTER_TYPE(Card); DECLARE_POINTER_TYPE(Card);
DECLARE_POINTER_TYPE(StyleSheet); DECLARE_POINTER_TYPE(StyleSheet);
DECLARE_POINTER_TYPE(Field); DECLARE_POINTER_TYPE(Field);
DECLARE_POINTER_TYPE(Value); DECLARE_POINTER_TYPE(Value);
DECLARE_TYPEOF_COLLECTION(GenericAddAction<CardP>::Step);
// ----------------------------------------------------------------------------- : Add card // ----------------------------------------------------------------------------- : Add card
...@@ -38,29 +40,15 @@ class CardListAction : public Action { ...@@ -38,29 +40,15 @@ class CardListAction : public Action {
/// Adding a new card to a set /// Adding a new card to a set
class AddCardAction : public CardListAction { class AddCardAction : public CardListAction {
public: public:
/// Add a newly allocated card
AddCardAction(Set& set); AddCardAction(Set& set);
AddCardAction(Set& set, const CardP& card); AddCardAction(AddingOrRemoving, Set& set, const CardP& card);
AddCardAction(AddingOrRemoving, Set& set, const vector<CardP>& cards);
virtual String getName(bool to_undo) const; virtual String getName(bool to_undo) const;
virtual void perform(bool to_undo); virtual void perform(bool to_undo);
//private: const GenericAddAction<CardP> action;
const CardP card; ///< The new card
};
// ----------------------------------------------------------------------------- : Remove card
/// Removing a card from a set
class RemoveCardAction : public CardListAction {
public:
RemoveCardAction(Set& set, const CardP& card);
virtual String getName(bool to_undo) const;
virtual void perform(bool to_undo);
//private:
const CardP card; ///< The removed card
const size_t card_id; ///< Position of the card in the set
}; };
// ----------------------------------------------------------------------------- : Reorder cards // ----------------------------------------------------------------------------- : Reorder cards
......
...@@ -41,7 +41,7 @@ DEFINE_EVENT_TYPE(EVENT_CARD_ACTIVATE); ...@@ -41,7 +41,7 @@ DEFINE_EVENT_TYPE(EVENT_CARD_ACTIVATE);
vector<CardListBase*> CardListBase::card_lists; vector<CardListBase*> CardListBase::card_lists;
CardListBase::CardListBase(Window* parent, int id, long additional_style) CardListBase::CardListBase(Window* parent, int id, long additional_style)
: ItemList(parent, id, additional_style) : ItemList(parent, id, additional_style, true)
{ {
// add to the list of card lists // add to the list of card lists
card_lists.push_back(this); card_lists.push_back(this);
...@@ -62,38 +62,36 @@ void CardListBase::onChangeSet() { ...@@ -62,38 +62,36 @@ void CardListBase::onChangeSet() {
void CardListBase::onAction(const Action& action, bool undone) { void CardListBase::onAction(const Action& action, bool undone) {
TYPE_CASE(action, AddCardAction) { TYPE_CASE(action, AddCardAction) {
if (undone) { if (action.action.adding != undone) {
refreshList(); // select the new cards
if (!allowModify()) { focusNone();
// Let some other card list else do the selecting selectItem(action.action.steps.front().item, false, true);
return;
}
selectItemPos(GetItemCount() - 1, true);
} else {
// select the new card
selectItem(action.card, false /*list will be refreshed anyway*/, true);
refreshList();
}
}
TYPE_CASE(action, RemoveCardAction) {
if (undone) {
// select the re-added card
selectItem(action.card, false /*list will be refreshed anyway*/, true);
refreshList(); refreshList();
FOR_EACH_CONST(s, action.action.steps) focusItem(s.item); // focus all the new cards
} else { } else {
long pos = selected_item_pos; long pos = -1;
// adjust focus for all the removed cards
//FOR_EACH_CONST(s, action.action.steps) focusItem(s.item, false);
long count = GetItemCount();
long delta = 0;
for (long i = 0 ; i < count ; ++i) {
if (delta < (long)action.action.steps.size() && getItem(i) == action.action.steps[delta].item) {
Select(i - delta, false);
delta++;
} else if (delta > 0) {
Select(i - delta, IsSelected(i));
}
if (pos == -1 && IsSelected(i - delta)) pos = i - delta;
}
if (pos == -1) pos = selected_item_pos; // select next item if selection would become empty
refreshList(); refreshList();
if (!allowModify()) { if (!allowModify()) {
// Let some other card list else do the selecting // Let some other card list do the selecting, otherwise we get conflicting events
return; return;
} }
if (action.card == selected_item) { if (selected_item_pos == -1) {
// select the next card, if not possible, select the last // selected item was deleted, select something else
if (pos + 1 < GetItemCount()) { selectItemPos(pos, true, true);
selectItemPos(pos, true);
} else {
selectItemPos(GetItemCount() - 1, true);
}
} }
} }
} }
...@@ -105,7 +103,7 @@ void CardListBase::onAction(const Action& action, bool undone) { ...@@ -105,7 +103,7 @@ void CardListBase::onAction(const Action& action, bool undone) {
// reselect the current card, it has moved // reselect the current card, it has moved
selected_item_pos = (long)action.card_id1 == selected_item_pos ? (long)action.card_id2 : (long)action.card_id1; selected_item_pos = (long)action.card_id1 == selected_item_pos ? (long)action.card_id2 : (long)action.card_id1;
// select the right card // select the right card
selectCurrentItem(); focusSelectedItem();
} }
RefreshItem((long)action.card_id1); RefreshItem((long)action.card_id1);
RefreshItem((long)action.card_id2); RefreshItem((long)action.card_id2);
...@@ -148,7 +146,7 @@ bool CardListBase::doCut() { ...@@ -148,7 +146,7 @@ bool CardListBase::doCut() {
// cut = copy + delete // cut = copy + delete
if (!canCut()) return false; if (!canCut()) return false;
if (!doCopy()) return false; if (!doCopy()) return false;
set->actions.add(new RemoveCardAction(*set, getCard())); doDelete();
return true; return true;
} }
bool CardListBase::doPaste() { bool CardListBase::doPaste() {
...@@ -162,12 +160,17 @@ bool CardListBase::doPaste() { ...@@ -162,12 +160,17 @@ bool CardListBase::doPaste() {
// add card to set // add card to set
CardP card = data.getCard(set); CardP card = data.getCard(set);
if (card) { if (card) {
set->actions.add(new AddCardAction(*set, card)); set->actions.add(new AddCardAction(ADD, *set, card));
return true; return true;
} else { } else {
return false; return false;
} }
} }
bool CardListBase::doDelete() {
//vector<>
set->actions.add(new AddCardAction(REMOVE, *set, getCard()));
return true;
}
// ----------------------------------------------------------------------------- : CardListBase : Building the list // ----------------------------------------------------------------------------- : CardListBase : Building the list
...@@ -310,7 +313,7 @@ void CardListBase::onSelectColumns(wxCommandEvent&) { ...@@ -310,7 +313,7 @@ void CardListBase::onSelectColumns(wxCommandEvent&) {
void CardListBase::onChar(wxKeyEvent& ev) { void CardListBase::onChar(wxKeyEvent& ev) {
if (ev.GetKeyCode() == WXK_DELETE && allowModify()) { if (ev.GetKeyCode() == WXK_DELETE && allowModify()) {
set->actions.add(new RemoveCardAction(*set, getCard())); doDelete();
} else if (ev.GetKeyCode() == WXK_TAB) { } else if (ev.GetKeyCode() == WXK_TAB) {
// send a navigation event to our parent, to select another control // send a navigation event to our parent, to select another control
// we need this because tabs are not handled on the cards panel // we need this because tabs are not handled on the cards panel
......
...@@ -71,6 +71,7 @@ class CardListBase : public ItemList, public SetView { ...@@ -71,6 +71,7 @@ class CardListBase : public ItemList, public SetView {
bool doCut(); bool doCut();
bool doCopy(); bool doCopy();
bool doPaste(); bool doPaste();
bool doDelete();
// --------------------------------------------------- : Set actions // --------------------------------------------------- : Set actions
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
// ----------------------------------------------------------------------------- : ItemList // ----------------------------------------------------------------------------- : ItemList
ItemList::ItemList(Window* parent, int id, long additional_style) ItemList::ItemList(Window* parent, int id, long additional_style, bool multi_sel)
: wxListView(parent, id, wxDefaultPosition, wxDefaultSize, additional_style | wxLC_REPORT | wxLC_VIRTUAL | wxLC_SINGLE_SEL) : wxListView(parent, id, wxDefaultPosition, wxDefaultSize, additional_style | wxLC_REPORT | wxLC_VIRTUAL | (multi_sel ? 0 : wxLC_SINGLE_SEL))
, selected_item_pos(-1) , selected_item_pos(-1)
, sort_by_column(-1), sort_ascending(true) , sort_by_column(-1), sort_ascending(true)
{ {
...@@ -52,21 +52,23 @@ void ItemList::selectItem(const VoidP& item, bool focus, bool event) { ...@@ -52,21 +52,23 @@ void ItemList::selectItem(const VoidP& item, bool focus, bool event) {
selected_item = item; selected_item = item;
if (event) sendEvent(); if (event) sendEvent();
findSelectedItemPos(); findSelectedItemPos();
if (focus) { if (focus) focusSelectedItem();
selectCurrentItem();
}
} }
void ItemList::selectItemPos(long pos, bool focus) { void ItemList::selectItemPos(long pos, bool focus, bool force_focus) {
if (selected_item_pos == pos && !focus) return; // this item is already selected VoidP item;
if ((size_t)pos < sorted_list.size()) { if ((size_t)pos < sorted_list.size()) {
// only if there is something to select item = getItem(pos);
selectItem(getItem(pos), false, true); } else if (!sorted_list.empty()) {
item = sorted_list.back();
} else { } else {
selectItem(VoidP(), false, true); // clear selection
} }
selected_item_pos = pos; if (item != selected_item) {
if (focus) selectCurrentItem(); selectItem(item, false, true);
}
//!selected_item_pos = pos;
if (focus) focusSelectedItem(force_focus);
} }
void ItemList::findSelectedItemPos() { void ItemList::findSelectedItemPos() {
...@@ -80,18 +82,33 @@ void ItemList::findSelectedItemPos() { ...@@ -80,18 +82,33 @@ void ItemList::findSelectedItemPos() {
} }
} }
} }
void ItemList::selectCurrentItem() { void ItemList::focusSelectedItem(bool force_focus) {
if (GetItemCount() > 0) { if (GetItemCount() > 0) {
if (selected_item_pos == -1 || (size_t)selected_item_pos > sorted_list.size()) { if (selected_item_pos == -1 || (size_t)selected_item_pos > sorted_list.size()) {
// deselect currently selected item, if any // deselect currently selected item, if any
long sel = GetFirstSelected(); long sel = GetFirstSelected();
Select(sel, false); Select(sel, false);
} else { } else if (selected_item_pos != GetFocusedItem() || force_focus) {
Select(selected_item_pos); Select(selected_item_pos);
Focus (selected_item_pos); Focus (selected_item_pos);
} }
} }
} }
void ItemList::focusNone() {
long count = GetItemCount();
for (long pos = 0 ; pos < count ; ++pos) {
Select(pos, false);
}
}
void ItemList::focusItem(const VoidP& item, bool focus) {
long count = GetItemCount();
for (long pos = 0 ; pos < count ; ++pos) {
if (getItem(pos) == item) {
Select(pos, focus);
break;
}
}
}
// ----------------------------------------------------------------------------- : ItemList : Building the list // ----------------------------------------------------------------------------- : ItemList : Building the list
...@@ -124,7 +141,7 @@ void ItemList::refreshList() { ...@@ -124,7 +141,7 @@ void ItemList::refreshList() {
if (item_count == 0) Refresh(); if (item_count == 0) Refresh();
// (re)select current item // (re)select current item
findSelectedItemPos(); findSelectedItemPos();
selectCurrentItem(); focusSelectedItem();
} }
void ItemList::sortBy(long column, bool ascending) { void ItemList::sortBy(long column, bool ascending) {
......
...@@ -17,10 +17,14 @@ ...@@ -17,10 +17,14 @@
/// A generic list of items /// A generic list of items
/** The list is shown in report mode, and allows sorting. /** The list is shown in report mode, and allows sorting.
* Currently used for cards and keywords. * Currently used for cards and keywords.
*
* Terminology:
* selected item = a single item in the variable selected_item
* focused items = items that are drawn as selected in the control
*/ */
class ItemList : public wxListView { class ItemList : public wxListView {
public: public:
ItemList(Window* parent, int id, long additional_style = 0); ItemList(Window* parent, int id, long additional_style = 0, bool multi_sel = false);
// --------------------------------------------------- : Selection // --------------------------------------------------- : Selection
...@@ -72,15 +76,20 @@ class ItemList : public wxListView { ...@@ -72,15 +76,20 @@ class ItemList : public wxListView {
/// Select an item, send an event to the parent /// Select an item, send an event to the parent
/** If focus then the item is also focused and selected in the actual control. /** If focus then the item is also focused and selected in the actual control.
* This should abviously not be done when the item is selected because it was focused (leading to a loop). * This should not be done when the item is selected because it was focused (leading to a loop).
*/ */
void selectItem(const VoidP& item, bool focus, bool event); void selectItem(const VoidP& item, bool focus, bool event);
/// Select a item at the specified position /// Select a item at the specified position
void selectItemPos(long pos, bool focus); void selectItemPos(long pos, bool focus, bool force_focus = false);
/// Find the position for the selected_item /// Find the position for the selected_item
void findSelectedItemPos(); void findSelectedItemPos();
/// Actually select the card at selected_item_pos in the control /// Actually select the item at selected_item_pos in the control
void selectCurrentItem(); /** if force_focus == true, then the item is highlighted again if it already is focused. */
void focusSelectedItem(bool force_focus = false);
/// Deselect everything in the control
void focusNone();
/// Actually select a certain item in the control
void focusItem(const VoidP& item, bool focus = true);
// --------------------------------------------------- : Data // --------------------------------------------------- : Data
VoidP selected_item; ///< The currently selected item VoidP selected_item; ///< The currently selected item
......
...@@ -57,10 +57,10 @@ void KeywordList::onChangeSet() { ...@@ -57,10 +57,10 @@ void KeywordList::onChangeSet() {
} }
void KeywordList::onAction(const Action& action, bool undone) { void KeywordList::onAction(const Action& action, bool undone) {
TYPE_CASE(action, AddKeywordAction) { /*TYPE_CASE(action, AddKeywordAction) {
if (action.adding != undone) { if (action.adding != undone) {
// select the new keyword // select the new keyword
selectItem(action.keyword, false /*list will be refreshed anyway*/, true); selectItem(action.keyword, false /*list will be refreshed anyway* /, true);
refreshList(); refreshList();
} else { } else {
long pos = selected_item_pos; long pos = selected_item_pos;
...@@ -74,7 +74,7 @@ void KeywordList::onAction(const Action& action, bool undone) { ...@@ -74,7 +74,7 @@ void KeywordList::onAction(const Action& action, bool undone) {
} }
} }
} }
} }*/ // TODO!!!
TYPE_CASE(action, ValueAction) { TYPE_CASE(action, ValueAction) {
if (!action.card) { if (!action.card) {
KeywordTextValue* value = dynamic_cast<KeywordTextValue*>(action.valueP.get()); KeywordTextValue* value = dynamic_cast<KeywordTextValue*>(action.valueP.get());
...@@ -117,7 +117,7 @@ bool KeywordList::doCut() { ...@@ -117,7 +117,7 @@ bool KeywordList::doCut() {
// cut = copy + delete // cut = copy + delete
if (!canCut()) return false; if (!canCut()) return false;
if (!doCopy()) return false; if (!doCopy()) return false;
set->actions.add(new AddKeywordAction(REMOVE, *set, getKeyword())); doDelete();
return true; return true;
} }
bool KeywordList::doPaste() { bool KeywordList::doPaste() {
...@@ -137,6 +137,10 @@ bool KeywordList::doPaste() { ...@@ -137,6 +137,10 @@ bool KeywordList::doPaste() {
return false; return false;
} }
} }
bool KeywordList::doDelete() {
set->actions.add(new AddKeywordAction(REMOVE, *set, getKeyword()));
return true;
}
// ----------------------------------------------------------------------------- : KeywordListBase : for ItemList // ----------------------------------------------------------------------------- : KeywordListBase : for ItemList
......
...@@ -60,6 +60,7 @@ class KeywordList : public ItemList, public SetView { ...@@ -60,6 +60,7 @@ class KeywordList : public ItemList, public SetView {
bool doCut(); bool doCut();
bool doCopy(); bool doCopy();
bool doPaste(); bool doPaste();
bool doDelete();
// --------------------------------------------------- : The keywords // --------------------------------------------------- : The keywords
protected: protected:
......
...@@ -154,7 +154,7 @@ void KeywordsPanel::onCommand(int id) { ...@@ -154,7 +154,7 @@ void KeywordsPanel::onCommand(int id) {
list->selectNext(); list->selectNext();
break; break;
case ID_KEYWORD_ADD: case ID_KEYWORD_ADD:
set->actions.add(new AddKeywordAction(ADD, *set)); set->actions.add(new AddKeywordAction(*set));
break; break;
case ID_KEYWORD_REMOVE: case ID_KEYWORD_REMOVE:
if (!list->getKeyword()->fixed) { if (!list->getKeyword()->fixed) {
......
...@@ -25,7 +25,7 @@ void SymbolPartsSelection::clear() { ...@@ -25,7 +25,7 @@ void SymbolPartsSelection::clear() {
} }
bool SymbolPartsSelection::select(const SymbolPartP& part, SelectMode mode) { bool SymbolPartsSelection::select(const SymbolPartP& part, SelectMode mode) {
assert(part); if (!part) return false;
// make sure part is not the decendent of a part that is already selected // make sure part is not the decendent of a part that is already selected
if (mode != SELECT_OVERRIDE) { if (mode != SELECT_OVERRIDE) {
FOR_EACH(s, selection) { FOR_EACH(s, selection) {
......
...@@ -1422,6 +1422,9 @@ ...@@ -1422,6 +1422,9 @@
<Filter <Filter
Name="action" Name="action"
Filter=""> Filter="">
<File
RelativePath=".\data\action\generic.hpp">
</File>
<File <File
RelativePath=".\data\action\keyword.cpp"> RelativePath=".\data\action\keyword.cpp">
<FileConfiguration <FileConfiguration
......
...@@ -190,11 +190,16 @@ void SetScriptManager::onAction(const Action& action, bool undone) { ...@@ -190,11 +190,16 @@ void SetScriptManager::onAction(const Action& action, bool undone) {
return; // Don't go into an infinite loop because of our own events return; // Don't go into an infinite loop because of our own events
} }
TYPE_CASE(action, AddCardAction) { TYPE_CASE(action, AddCardAction) {
// update the added card specificly if (action.action.adding != undone) {
Context& ctx = getContext(action.card); // update the added cards specificly
FOR_EACH(v, action.card->data) { FOR_EACH_CONST(step, action.action.steps) {
const CardP& card = step.item;
Context& ctx = getContext(card);
FOR_EACH(v, card->data) {
v->update(ctx); v->update(ctx);
} }
}
}
// note: fallthrough // note: fallthrough
} }
TYPE_CASE_(action, CardListAction) { TYPE_CASE_(action, CardListAction) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment