diff options
author | Michele Calgaro <[email protected]> | 2022-08-09 08:23:06 +0900 |
---|---|---|
committer | Michele Calgaro <[email protected]> | 2022-08-09 08:23:06 +0900 |
commit | 0c22a14875913dc185e029d0078a8d15c9ffe102 (patch) | |
tree | 30b7a68ba98bd7a78cd5f695d8b00d75f4e89163 | |
parent | 96955a58cbbbdba22bdfb8e4fdfdbea0444ccd14 (diff) | |
download | tdebase-0c22a14875913dc185e029d0078a8d15c9ffe102.tar.gz tdebase-0c22a14875913dc185e029d0078a8d15c9ffe102.zip |
TCC khotkeys: fixed logic related to action and condition item selection after deleting an existing item.
Signed-off-by: Michele Calgaro <[email protected]>
-rw-r--r-- | khotkeys/kcontrol/action_list_widget.cpp | 37 | ||||
-rw-r--r-- | khotkeys/kcontrol/condition_list_widget.cpp | 39 |
2 files changed, 57 insertions, 19 deletions
diff --git a/khotkeys/kcontrol/action_list_widget.cpp b/khotkeys/kcontrol/action_list_widget.cpp index 79744a09e..ffa71bce0 100644 --- a/khotkeys/kcontrol/action_list_widget.cpp +++ b/khotkeys/kcontrol/action_list_widget.cpp @@ -148,24 +148,45 @@ void Action_list_widget::new_selected( int type_P ) void Action_list_widget::copy_pressed() { - if ( !selected_item ) - return; + if ( !selected_item ) + { + return; + } + actions_listview->setSelected( create_listview_item( selected_item->action(), - selected_item->parent() ? NULL : actions_listview, selected_item->parent(), - selected_item, true ), true ); + selected_item->parent() ? NULL : actions_listview, selected_item->parent(), + selected_item, true ), true ); } void Action_list_widget::delete_pressed() { - delete selected_item; // CHECKME snad vyvola signaly pro enable() + if ( !selected_item ) + { + return; + } + + Action_list_item *nextItem = static_cast< Action_list_item* >(selected_item->nextSibling()); + delete selected_item; selected_item = NULL; + if (!nextItem) + { + // If the last item of the list was deleted, get the new last item + nextItem = static_cast< Action_list_item* >(actions_listview->lastItem()); + } + if (nextItem) + { + actions_listview->setSelected(nextItem, true); + current_changed(nextItem); + } } void Action_list_widget::modify_pressed() { - if ( !selected_item ) - return; - edit_listview_item( selected_item ); + if ( !selected_item ) + { + return; + } + edit_listview_item( selected_item ); } void Action_list_widget::current_changed( TQListViewItem* item_P ) diff --git a/khotkeys/kcontrol/condition_list_widget.cpp b/khotkeys/kcontrol/condition_list_widget.cpp index ba3be5e71..864c2d4a5 100644 --- a/khotkeys/kcontrol/condition_list_widget.cpp +++ b/khotkeys/kcontrol/condition_list_widget.cpp @@ -213,8 +213,11 @@ void Condition_list_widget::new_selected( int type_P ) void Condition_list_widget::copy_pressed() { - if ( !selected_item ) - return; + if ( !selected_item ) + { + return; + } + conditions_listview->setSelected( create_listview_item( selected_item->condition()->copy( selected_item->condition()->parent()), selected_item->parent() ? NULL : conditions_listview, @@ -223,19 +226,33 @@ void Condition_list_widget::copy_pressed() } void Condition_list_widget::delete_pressed() -{ - if ( selected_item ) { - conditions.remove( selected_item->condition()); // we own it - delete selected_item; // CHECKME snad vyvola signaly pro enable() - selected_item = NULL; + if ( !selected_item ) + { + return; + } + Condition_list_item *nextItem = static_cast< Condition_list_item* >(selected_item->nextSibling()); + conditions.remove( selected_item->condition()); // we own it + delete selected_item; + selected_item = NULL; + if (!nextItem) + { + // If the last item of the list was deleted, get the new last item + nextItem = static_cast< Condition_list_item* >(conditions_listview->lastItem()); + } + if (nextItem) + { + conditions_listview->setSelected(nextItem, true); + current_changed(nextItem); + } } -} void Condition_list_widget::modify_pressed() { - if ( !selected_item ) - return; + if ( !selected_item ) + { + return; + } edit_listview_item( selected_item ); } @@ -268,7 +285,7 @@ Condition_list_item* Condition_list_widget::create_listview_item( Condition* con #ifdef KHOTKEYS_DEBUG kdDebug( 1217 ) << "Condition_list_widget::create_listview_item():" << endl; Condition::debug_list( conditions ); - kdDebug( 1217 ) << kdBacktrace() << endl; + kdDebug( 1217 ) << kdBacktrace() << endl; #endif Condition* new_cond = copy_P ? condition_P->copy( parent2_P ? static_cast< Condition_list_base* >( parent2_P->condition()) : NULL ) : condition_P; |