@@ -239,21 +239,7 @@ void NextcloudDeckDialog::resetEditFrameControls() {
239239    _currentCard = NextcloudDeckService::Card ();
240240}
241241
242- void  NextcloudDeckDialog::on_cardItemTreeWidget_currentItemChanged (QTreeWidgetItem *current,
243-                                                                    QTreeWidgetItem *previous) {
244-     Q_UNUSED (previous)
245- 
246-     //  in case all items were removed
247-     if  (current == nullptr ) {
248-         resetEditFrameControls ();
249-         return ;
250-     }
251- 
252-     MetricsService::instance ()->sendVisitIfEnabled (QStringLiteral (" deck/card/changed" 
253- 
254-     int  id = current->data (0 , Qt::UserRole).toInt ();
255- 
256-     //  Find the card in our hash using the ID
242+ void  NextcloudDeckDialog::jumpToCard (int  id) {
257243    if  (_cards.contains (id)) {
258244        _currentCard = _cards[id];
259245
@@ -277,6 +263,40 @@ void NextcloudDeckDialog::on_cardItemTreeWidget_currentItemChanged(QTreeWidgetIt
277263    }
278264}
279265
266+ void  NextcloudDeckDialog::on_cardItemTreeWidget_currentItemChanged (QTreeWidgetItem *current,
267+                                                                    QTreeWidgetItem *previous) {
268+     Q_UNUSED (previous)
269+ 
270+     //  in case all items were removed
271+     if  (current == nullptr ) {
272+         resetEditFrameControls ();
273+         return ;
274+     }
275+ 
276+     MetricsService::instance ()->sendVisitIfEnabled (QStringLiteral (" deck/card/changed" 
277+ 
278+     const  int  id = current->data (0 , Qt::UserRole).toInt ();
279+ 
280+     //  Find the card in our hash using the ID
281+     jumpToCard (id);
282+ }
283+ 
284+ void  NextcloudDeckDialog::setCardId (const  int  id) {
285+     if  (id < 1 ) {
286+         return ;
287+     }
288+ 
289+     if  (ui->cardItemTreeWidget ->topLevelItemCount () == 0 ) {
290+         reloadCardList ();
291+     }
292+ 
293+     const  auto  item = Utils::Gui::getTreeWidgetItemWithUserData (ui->cardItemTreeWidget , id);
294+ 
295+     if  (item != nullptr ) {
296+         ui->cardItemTreeWidget ->setCurrentItem (item);
297+     }
298+ }
299+ 
280300void  NextcloudDeckDialog::on_newItemEdit_textChanged (const  QString &arg1) {
281301    Utils::Gui::searchForTextInTreeWidget (
282302        ui->cardItemTreeWidget , arg1,
0 commit comments