@@ -235,10 +235,11 @@ PropertiesDialog::PropertiesDialog (QWidget * /*parent*/, db::Manager *manager,
235235 m_current_object = 0 ;
236236
237237 // look for next usable editable
238+ m_object_indexes.resize (mp_properties_pages.size ());
238239 if (m_index >= int (mp_properties_pages.size ())) {
239240 m_index = -1 ;
240241 } else {
241- m_object_indexes.push_back (0 );
242+ m_object_indexes [m_index] .push_back (0 );
242243 }
243244
244245 update_title ();
@@ -383,6 +384,7 @@ BEGIN_PROTECTED
383384 delete *p;
384385 } else {
385386 mp_properties_pages.push_back (*p);
387+ (*p)->set_page_set (this );
386388 }
387389 }
388390 }
@@ -398,10 +400,11 @@ BEGIN_PROTECTED
398400 // look for next usable editable
399401 m_index = 0 ;
400402 m_object_indexes.clear ();
403+ m_object_indexes.resize (mp_properties_pages.size ());
401404 if (m_index >= int (mp_properties_pages.size ())) {
402405 m_index = -1 ;
403406 } else {
404- m_object_indexes.push_back (0 );
407+ m_object_indexes [m_index] .push_back (0 );
405408 }
406409
407410 mp_tree_model->end_reset_model ();
@@ -436,6 +439,7 @@ PropertiesDialog::current_index_changed (const QModelIndex &index, const QModelI
436439 }
437440
438441 m_object_indexes.clear ();
442+ m_object_indexes.resize (mp_properties_pages.size ());
439443
440444 if (! index.isValid ()) {
441445
@@ -462,56 +466,66 @@ PropertiesDialog::current_index_changed (const QModelIndex &index, const QModelI
462466
463467 }
464468
465- if (mp_tree_model->parent (index).isValid ()) {
466-
467- m_index = mp_tree_model->page_index (index);
469+ m_index = -1 ;
468470
469- if (mp_properties_pages [m_index]-> can_apply_to_all ()) {
471+ auto selection = mp_ui-> tree -> selectionModel ()-> selectedIndexes ();
470472
471- m_object_indexes.push_back (size_t (mp_tree_model->object_index (index)));
473+ // establish a single-selection on the current item
474+ if (mp_tree_model->parent (index).isValid ()) {
475+ int oi = mp_tree_model->object_index (index);
476+ int pi = mp_tree_model->page_index (index);
477+ m_index = pi;
478+ m_object_indexes [pi].push_back (size_t (oi));
479+ }
472480
473- auto selection = mp_ui-> tree -> selectionModel ()-> selectedIndexes ();
474- for ( auto i = selection. begin (); i != selection. end (); ++i) {
475- if (mp_tree_model-> parent (*i). isValid () && mp_tree_model-> page_index (*i) == m_index ) {
476- int oi = mp_tree_model->object_index (*i);
477- if ( oi != int (m_object_indexes. front ())) {
478- m_object_indexes. push_back ( size_t (oi) );
479- }
480- }
481+ // establish individual selections for the other items
482+ // as far as allowed by "can_apply_to_all"
483+ for ( auto i = selection. begin (); i != selection. end (); ++i ) {
484+ if (*i != index && mp_tree_model->parent (*i). isValid ()) {
485+ int oi = mp_tree_model-> object_index (*i);
486+ int pi = mp_tree_model-> page_index (*i );
487+ if (mp_properties_pages [pi]-> can_apply_to_all ()) {
488+ m_object_indexes [pi]. push_back ( size_t (oi));
481489 }
482-
483- } else {
484-
485- m_object_indexes.push_back (size_t (mp_tree_model->object_index (index)));
486-
487490 }
491+ }
488492
489- } else {
490-
491- m_index = index.row ();
492-
493- if (mp_properties_pages [m_index]->can_apply_to_all ()) {
494-
495- for (size_t oi = 0 ; oi < mp_properties_pages [m_index]->count (); ++oi) {
496- m_object_indexes.push_back (oi);
493+ // establish group node selection as current item -> translate into "all" for "can_apply_to_all" pages
494+ // or first item unless an item is explicitly selected.
495+ if (! mp_tree_model->parent (index).isValid ()) {
496+ int pi = index.row ();
497+ m_index = pi;
498+ m_object_indexes [pi].clear ();
499+ if (mp_properties_pages [pi]->can_apply_to_all ()) {
500+ for (size_t oi = 0 ; oi < mp_properties_pages [pi]->count (); ++oi) {
501+ m_object_indexes [pi].push_back (oi);
497502 }
498-
499- } else if (mp_properties_pages [m_index]->count () > 0 ) {
500-
501- m_object_indexes.push_back (0 );
502-
503+ } else if (mp_properties_pages [pi]->count () > 0 && m_object_indexes [pi].empty ()) {
504+ m_object_indexes [pi].push_back (0 );
503505 }
506+ }
504507
508+ // establish group node selection for other items -> translate into "all" for "can_apply_to_all" pages
509+ for (auto i = selection.begin (); i != selection.end (); ++i) {
510+ if (*i != index && ! mp_tree_model->parent (*i).isValid ()) {
511+ int pi = i->row ();
512+ m_object_indexes [pi].clear ();
513+ if (mp_properties_pages [pi]->can_apply_to_all ()) {
514+ for (size_t oi = 0 ; oi < mp_properties_pages [pi]->count (); ++oi) {
515+ m_object_indexes[pi].push_back (oi);
516+ }
517+ }
518+ }
505519 }
506520
507521 }
508522
509- if (! m_object_indexes.empty ()) {
523+ if (m_index >= 0 && ! m_object_indexes [m_index] .empty ()) {
510524 m_current_object = 0 ;
511525 for (int i = 0 ; i < m_index; ++i) {
512526 m_current_object += mp_properties_pages [i]->count ();
513527 }
514- m_current_object += int (m_object_indexes.front ());
528+ m_current_object += int (m_object_indexes [m_index] .front ());
515529 } else {
516530 m_current_object = -1 ;
517531 }
@@ -552,7 +566,10 @@ PropertiesDialog::update_controls ()
552566 mp_ui->ok_button ->setEnabled (! mp_properties_pages [m_index]->readonly ());
553567 mp_ui->tree ->setEnabled (true );
554568
555- mp_properties_pages [m_index]->select_entries (m_object_indexes);
569+ for (int i = 0 ; i < int (mp_properties_pages.size ()); ++i) {
570+ mp_properties_pages [i]->select_entries (m_object_indexes [i]);
571+ }
572+
556573 mp_properties_pages [m_index]->update ();
557574
558575 }
@@ -563,7 +580,7 @@ PropertiesDialog::next_pressed ()
563580{
564581BEGIN_PROTECTED
565582
566- if (m_object_indexes.empty ()) {
583+ if (m_index < 0 || m_object_indexes [m_index] .empty ()) {
567584 return ;
568585 }
569586
@@ -576,7 +593,7 @@ BEGIN_PROTECTED
576593 }
577594
578595 // advance the current entry
579- int object_index = int (m_object_indexes.front ());
596+ int object_index = int (m_object_indexes [m_index] .front ());
580597 ++object_index;
581598
582599 // look for next usable editable if at end
@@ -593,7 +610,8 @@ BEGIN_PROTECTED
593610 }
594611
595612 m_object_indexes.clear ();
596- m_object_indexes.push_back (object_index);
613+ m_object_indexes.resize (mp_properties_pages.size ());
614+ m_object_indexes [m_index].push_back (object_index);
597615
598616 ++m_current_object;
599617 update_title ();
@@ -611,7 +629,7 @@ PropertiesDialog::prev_pressed ()
611629{
612630BEGIN_PROTECTED
613631
614- if (m_object_indexes.empty ()) {
632+ if (m_index < 0 || m_object_indexes [m_index] .empty ()) {
615633 return ;
616634 }
617635
@@ -624,7 +642,7 @@ BEGIN_PROTECTED
624642 }
625643
626644 // advance the current entry
627- int object_index = int (m_object_indexes.front ());
645+ int object_index = int (m_object_indexes [m_index] .front ());
628646 if (object_index == 0 ) {
629647
630648 // look for last usable editable if at end
@@ -643,7 +661,8 @@ BEGIN_PROTECTED
643661 --object_index;
644662
645663 m_object_indexes.clear ();
646- m_object_indexes.push_back (object_index);
664+ m_object_indexes.resize (mp_properties_pages.size ());
665+ m_object_indexes [m_index].push_back (object_index);
647666
648667 --m_current_object;
649668 update_title ();
@@ -669,12 +688,12 @@ PropertiesDialog::update_title ()
669688bool
670689PropertiesDialog::any_next () const
671690{
672- if (m_object_indexes.empty ()) {
691+ if (m_index < 0 || m_object_indexes [m_index] .empty ()) {
673692 return false ;
674693 }
675694
676695 int index = m_index;
677- if (m_object_indexes.front () + 1 >= mp_properties_pages [index]->count ()) {
696+ if (m_object_indexes [m_index] .front () + 1 >= mp_properties_pages [index]->count ()) {
678697 ++index;
679698 }
680699
@@ -685,12 +704,12 @@ PropertiesDialog::any_next () const
685704bool
686705PropertiesDialog::any_prev () const
687706{
688- if (m_object_indexes.empty ()) {
707+ if (m_index < 0 || m_object_indexes [m_index] .empty ()) {
689708 return false ;
690709 }
691710
692711 int index = m_index;
693- if (m_object_indexes.front () == 0 ) {
712+ if (m_object_indexes [m_index] .front () == 0 ) {
694713 --index;
695714 }
696715
0 commit comments