DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
table.cpp File Reference
#include "dbe/table.hpp"
#include "dbe/treenode.hpp"
#include "dbe/confaccessor.hpp"
#include "dbe/StyleUtility.hpp"
#include "dbe/Conversion.hpp"
#include "dbe/messenger.hpp"
#include "dbe/Exceptions.hpp"
#include "dbe/dbcontroller.hpp"
#include "dbe/config_api_set.hpp"
#include <QFont>
#include <QBrush>
#include <QMimeData>
#include <bitset>
Include dependency graph for table.cpp:

Go to the source code of this file.

Functions

 MODEL_COMMON_INTERFACE_CREATE_THAT_OBJ_IMPL (dbe::models::table)
 MODEL_COMMON_INTERFACE_DELETE_THAT_OBJ_IMPL (dbe::models::table)
 MODEL_COMMON_INTERFACE_RENAME_THAT_OBJ_IMPL (dbe::models::table)
 MODEL_COMMON_INTERFACE_UPDATE_THAT_OBJ_IMPL (dbe::models::table)
 MODEL_COMMON_INTERFACE_LOOKUP_IMPL (dbe::models::table)
 MODEL_REMOVE_ROWS_DEF (dbe::models::table)

Function Documentation

◆ MODEL_COMMON_INTERFACE_CREATE_THAT_OBJ_IMPL()

MODEL_COMMON_INTERFACE_CREATE_THAT_OBJ_IMPL ( dbe::models::table )

Definition at line 528 of file table.cpp.

529{
530 Q_UNUSED(index);
531 if ( treenode * handlerclass = confaccessor::gethandler()->getnode ( obj.class_name() ) )
532 {
533 if ( obj.class_name() == this_class_name.toStdString()
534 or config::api::info::onclass::derived (
535 this_class_name.toStdString(), obj.class_name() ) )
536 {
537
538 dbe::treenode const * handlernode = dbe::datahandler::findchild (
539 handlerclass, QString::fromStdString ( obj.UID() ) );
540
541 if ( handlernode == nullptr )
542 {
543 handlernode = new ObjectNode ( obj, false, handlerclass );
544 }
545
546 emit layoutAboutToBeChanged();
547
548 // We assume that the objects are sorted and we want to insert a new element
549
550 tref const handlerobj = handlernode->GetObject();
551 auto sit = this_structure.begin();
552 auto it = this_objects.begin();
553
554 for ( ;
555 it != this_objects.end() and sit != this_structure.end()
556 and it->UID() < handlerobj.UID(); ++it, ++sit )
557 {}
558
559 this_structure.insert ( ++sit, createrow ( handlernode ) );
560
561 this_objects.insert ( ++it, handlerobj );
562
563 // Normally we would have to call changePersistentIndex.
564 // Because an objectnode is created which had no index
565 // before this creation had occured there is no need to call it.
566 emit layoutChanged();
567 }
568 }
569}
static treenode * findchild(treenode *top, QString const &name)
virtual tref GetObject() const
Definition treenode.cpp:81
inner::configobject::tref tref
Definition tref.hpp:35

◆ MODEL_COMMON_INTERFACE_DELETE_THAT_OBJ_IMPL()

MODEL_COMMON_INTERFACE_DELETE_THAT_OBJ_IMPL ( dbe::models::table )

Definition at line 571 of file table.cpp.

572{
573 if ( index.isValid() )
574 {
575 try
576 {
577 this->removeRows ( index.row(), 1, index.parent() );
578 }
579 catch ( daq::dbe::ObjectChangeWasNotSuccessful const & err )
580 {
581 WARN ( "Object cannot be deleted", dbe::config::errors::parse ( err ).c_str() );
582 }
583 }
584}
#define WARN(...)
Definition messenger.hpp:85
std::string const parse(ers::Issue const &)

◆ MODEL_COMMON_INTERFACE_LOOKUP_IMPL()

MODEL_COMMON_INTERFACE_LOOKUP_IMPL ( dbe::models::table )

Definition at line 646 of file table.cpp.

647{
648 for ( int row = 0; row < this_objects.size(); ++row )
649 {
650 dref ListElement = this_objects.at ( row );
651
652 if ( ListElement.UID() == obj.UID() )
653 {
654 return this->index ( row, 0 );
655 }
656 }
657
658 return QModelIndex();
659}
config_object_description dref

◆ MODEL_COMMON_INTERFACE_RENAME_THAT_OBJ_IMPL()

MODEL_COMMON_INTERFACE_RENAME_THAT_OBJ_IMPL ( dbe::models::table )

Definition at line 586 of file table.cpp.

587{
588 if ( index.isValid() )
589 {
590 type_datum * element = getnode ( index );
591 element->resetdata ( QStringList ( QString::fromStdString ( obj.ref().UID() ) ) );
592 this_objects[index.row()] = obj.ref();
593 emit dataChanged ( index, index );
594 }
595}

◆ MODEL_COMMON_INTERFACE_UPDATE_THAT_OBJ_IMPL()

MODEL_COMMON_INTERFACE_UPDATE_THAT_OBJ_IMPL ( dbe::models::table )

Definition at line 597 of file table.cpp.

598{
599 if ( treenode * handlerclass = confaccessor::gethandler()->getnode ( obj.class_name() ) )
600 {
601 if ( obj.class_name() == this_class_name.toStdString()
602 or config::api::info::onclass::derived (
603 this_class_name.toStdString(), obj.class_name() ) )
604 {
605 dbe::treenode const * handlernode = dbe::datahandler::findchild (
606 handlerclass, QString::fromStdString ( obj.UID() ) );
607
608 tref handlerobj = handlernode->GetObject();
609
610 auto sit = this_structure.begin();
611 auto it = this_objects.begin();
612
613 // find the object to be updated by looping through both objects and nodes
614
615 for ( ;
616 it != this_objects.end() and sit != this_structure.end()
617 and it->UID() != handlerobj.UID(); ++it, ++sit )
618
619 ;
620
621 // delete all table nodes in the list ( remove elements of the row )
622 for ( TableNode * x : *sit )
623 {
624 delete x;
625 }
626
627 // Recreate the row
628 *sit = createrow ( handlernode );
629
630 int row = index.row() == 0 ? 0 : index.row() - 1;
631
632 int column = index.column() == 0 ? 0 : index.column() - 1;
633
634 emit dataChanged ( createIndex ( row, column ), createIndex ( row + 1, column + 1 ) );
635 }
636 }
637}

◆ MODEL_REMOVE_ROWS_DEF()

MODEL_REMOVE_ROWS_DEF ( dbe::models::table )

Definition at line 664 of file table.cpp.

665{
666 beginRemoveRows ( parent, row, row + count - 1 );
667
668 for ( ; count != 0; --count )
669 {
670 this_structure.removeOne ( this_structure.at ( row + count - 1 ) );
671 this_objects.removeAt ( row + count - 1 );
672 }
673
674 endRemoveRows();
675 return true;
676}