Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
224379c0
Commit
224379c0
authored
May 30, 2008
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Selection in cardlist is correctly moved when changes are made;
cuting/copying/pasting/deleting multiple cards now works.
parent
9e75298e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
30 deletions
+41
-30
src/gui/control/card_list.cpp
src/gui/control/card_list.cpp
+13
-23
src/gui/control/card_list.hpp
src/gui/control/card_list.hpp
+4
-4
src/gui/control/item_list.cpp
src/gui/control/item_list.cpp
+20
-1
src/gui/control/item_list.hpp
src/gui/control/item_list.hpp
+3
-1
src/gui/set/cards_panel.cpp
src/gui/set/cards_panel.cpp
+1
-1
No files found.
src/gui/control/card_list.cpp
View file @
224379c0
...
...
@@ -60,8 +60,15 @@ void CardListBase::onChangeSet() {
rebuild
();
}
struct
Freezer
{
Window
*
window
;
Freezer
(
Window
*
window
)
:
window
(
window
)
{
window
->
Freeze
();
}
~
Freezer
()
{
window
->
Thaw
();
}
};
void
CardListBase
::
onAction
(
const
Action
&
action
,
bool
undone
)
{
TYPE_CASE
(
action
,
AddCardAction
)
{
Freezer
freeze
(
this
);
if
(
action
.
action
.
adding
!=
undone
)
{
// select the new cards
focusNone
();
...
...
@@ -69,21 +76,8 @@ void CardListBase::onAction(const Action& action, bool undone) {
refreshList
();
FOR_EACH_CONST
(
s
,
action
.
action
.
steps
)
focusItem
(
s
.
item
);
// focus all the new cards
}
else
{
long
pos
=
-
1
;
long
pos
=
selected_item_pos
;
// 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
();
if
(
!
allowModify
())
{
// Let some other card list do the selecting, otherwise we get conflicting events
...
...
@@ -129,11 +123,14 @@ void CardListBase::sendEvent() {
// ----------------------------------------------------------------------------- : CardListBase : Clipboard
bool
CardListBase
::
canC
opy
()
const
{
return
!!
selected_item
;
}
bool
CardListBase
::
canC
ut
()
const
{
return
canCopy
()
&&
allowModify
()
;
}
bool
CardListBase
::
canC
ut
()
const
{
return
canDelete
()
;
}
bool
CardListBase
::
canC
opy
()
const
{
return
focusCount
()
>
0
;
}
bool
CardListBase
::
canPaste
()
const
{
return
allowModify
()
&&
wxTheClipboard
->
IsSupported
(
CardsDataObject
::
format
);
}
bool
CardListBase
::
canDelete
()
const
{
return
allowModify
()
&&
focusCount
()
>
0
;
// TODO: check for selection?
}
bool
CardListBase
::
doCopy
()
{
if
(
!
canCopy
())
return
false
;
...
...
@@ -152,13 +149,6 @@ bool CardListBase::doCopy() {
wxTheClipboard
->
Close
();
return
ok
;
}
bool
CardListBase
::
doCut
()
{
// cut = copy + delete
if
(
!
canCut
())
return
false
;
if
(
!
doCopy
())
return
false
;
doDelete
();
return
true
;
}
bool
CardListBase
::
doPaste
()
{
// get data
if
(
!
canPaste
())
return
false
;
...
...
src/gui/control/card_list.hpp
View file @
224379c0
...
...
@@ -64,11 +64,11 @@ class CardListBase : public ItemList, public SetView {
// --------------------------------------------------- : Clipboard
bool
canCut
()
const
;
bool
canCopy
()
const
;
bool
canPaste
()
const
;
bool
canCut
()
const
;
bool
canCopy
()
const
;
bool
canPaste
()
const
;
bool
canDelete
()
const
;
// Try to perform a clipboard operation, return success
bool
doCut
();
bool
doCopy
();
bool
doPaste
();
bool
doDelete
();
...
...
src/gui/control/item_list.cpp
View file @
224379c0
...
...
@@ -46,6 +46,14 @@ void ItemList::selectFirst() {
selectItemPos
(
0
,
true
);
}
bool
ItemList
::
doCut
()
{
// cut = copy + delete
if
(
!
canCut
())
return
false
;
if
(
!
doCopy
())
return
false
;
doDelete
();
return
true
;
}
// ----------------------------------------------------------------------------- : ItemList : Selection (private)
void
ItemList
::
selectItem
(
const
VoidP
&
item
,
bool
focus
,
bool
event
)
{
...
...
@@ -109,6 +117,14 @@ void ItemList::focusItem(const VoidP& item, bool focus) {
}
}
}
long
ItemList
::
focusCount
()
const
{
long
count
=
GetItemCount
();
long
focused
=
0
;
for
(
long
pos
=
0
;
pos
<
count
;
++
pos
)
{
if
(
const_cast
<
ItemList
*>
(
this
)
->
IsSelected
(
pos
))
focused
++
;
}
return
focused
;
}
// ----------------------------------------------------------------------------- : ItemList : Building the list
...
...
@@ -127,6 +143,7 @@ struct ItemList::ItemComparer {
};
void
ItemList
::
refreshList
()
{
Freeze
();
// Get all items
sorted_list
.
clear
();
getItems
(
sorted_list
);
...
...
@@ -141,7 +158,9 @@ void ItemList::refreshList() {
if
(
item_count
==
0
)
Refresh
();
// (re)select current item
findSelectedItemPos
();
focusSelectedItem
();
focusNone
();
focusSelectedItem
(
true
);
Thaw
();
}
void
ItemList
::
sortBy
(
long
column
,
bool
ascending
)
{
...
...
src/gui/control/item_list.hpp
View file @
224379c0
...
...
@@ -46,7 +46,7 @@ class ItemList : public wxListView {
virtual
bool
canPaste
()
const
{
return
false
;
}
virtual
bool
canDelete
()
const
{
return
false
;
}
// Try to perform a clipboard operation, return success
virtual
bool
doCut
()
{
return
false
;
}
virtual
bool
doCut
()
;
virtual
bool
doCopy
()
{
return
false
;
}
virtual
bool
doPaste
()
{
return
false
;
}
virtual
bool
doDelete
()
{
return
false
;
}
...
...
@@ -90,6 +90,8 @@ class ItemList : public wxListView {
void
focusNone
();
/// Actually select a certain item in the control
void
focusItem
(
const
VoidP
&
item
,
bool
focus
=
true
);
/// Count the number of focused items
long
focusCount
()
const
;
// --------------------------------------------------- : Data
VoidP
selected_item
;
///< The currently selected item
...
...
src/gui/set/cards_panel.cpp
View file @
224379c0
...
...
@@ -168,7 +168,7 @@ void CardsPanel::onUpdateUI(wxUpdateUIEvent& ev) {
break
;
}
case
ID_CARD_ADD_MULT
:
ev
.
Enable
(
false
);
break
;
// not implemented
case
ID_CARD_REMOVE
:
ev
.
Enable
(
set
->
cards
.
size
()
>
1
);
break
;
case
ID_CARD_REMOVE
:
ev
.
Enable
(
card_list
->
canDelete
()
);
break
;
case
ID_FORMAT_BOLD
:
case
ID_FORMAT_ITALIC
:
case
ID_FORMAT_SYMBOL
:
case
ID_FORMAT_REMINDER
:
{
if
(
focused_control
(
this
)
==
ID_EDITOR
)
{
ev
.
Enable
(
editor
->
canFormat
(
ev
.
GetId
()));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment