Add Select All functionality, closes #19

This commit is contained in:
Twan van Laarhoven
2020-05-08 01:54:51 +02:00
parent 8b25815f72
commit 2d171732a0
21 changed files with 291 additions and 209 deletions
+2
View File
@@ -250,11 +250,13 @@ bool DataEditor::canCopy() const { return current_editor && current_ed
bool DataEditor::canPaste() const { return current_editor && current_editor->canPaste(); }
bool DataEditor::canFormat(int type) const { return current_editor && current_editor->canFormat(type); }
bool DataEditor::hasFormat(int type) const { return current_editor && current_editor->hasFormat(type); }
bool DataEditor::canSelectAll() const { return current_editor && current_editor->canSelectAll(); }
void DataEditor::doCut() { if (current_editor) current_editor->doCut(); }
void DataEditor::doCopy() { if (current_editor) current_editor->doCopy(); }
void DataEditor::doPaste() { if (current_editor) current_editor->doPaste(); }
void DataEditor::doFormat(int type) { if (current_editor) current_editor->doFormat(type); }
void DataEditor::doSelectAll() { if (current_editor) current_editor->doSelectAll(); }
wxMenu* DataEditor::getMenu(int type) const {
+6 -1
View File
@@ -65,7 +65,12 @@ class DataEditor : public CardViewer {
wxMenu* getMenu(int type) const;
/// A menu item from getMenu was selected
void onCommand(int id);
// --------------------------------------------------- : Text selection
bool canSelectAll() const;
void doSelectAll();
// --------------------------------------------------- : Search/replace
/// Do a search or replace action for the given FindInfo
+9
View File
@@ -40,6 +40,9 @@ bool ItemList::canSelectPrevious() const {
bool ItemList::canSelectNext() const {
return selected_item_pos >= 0 && static_cast<size_t>(selected_item_pos + 1) < sorted_list.size();
}
bool ItemList::canSelectAll() const {
return sorted_list.size() > 0 && !(GetWindowStyle() & wxLC_SINGLE_SEL);
}
void ItemList::selectPrevious() {
assert(selected_item_pos >= 1);
focusNone();
@@ -54,6 +57,12 @@ void ItemList::selectFirst() {
if (sorted_list.empty()) return;
selectItemPos(0, true);
}
void ItemList::doSelectAll() {
long count = GetItemCount();
for (long pos = 0; pos < count; ++pos) {
Select(pos,true);
}
}
bool ItemList::doCut() {
// cut = copy + delete
+4
View File
@@ -32,12 +32,16 @@ class ItemList : public wxListView {
bool canSelectPrevious() const;
/// Is there a next item to select?
bool canSelectNext() const;
/// Can we select all?
bool canSelectAll() const;
/// Move the selection to the previous item (if possible)
void selectPrevious();
/// Move the selection to the next item (if possible)
void selectNext();
/// Move the selection to the first item (if possible)
void selectFirst();
/// Select all items
void doSelectAll();
// --------------------------------------------------- : Clipboard