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 523 of file table.cpp.

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

◆ MODEL_COMMON_INTERFACE_DELETE_THAT_OBJ_IMPL()

MODEL_COMMON_INTERFACE_DELETE_THAT_OBJ_IMPL ( dbe::models::table )

Definition at line 566 of file table.cpp.

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

◆ MODEL_COMMON_INTERFACE_LOOKUP_IMPL()

MODEL_COMMON_INTERFACE_LOOKUP_IMPL ( dbe::models::table )

Definition at line 641 of file table.cpp.

642{
643 for ( int row = 0; row < this_objects.size(); ++row )
644 {
645 dref ListElement = this_objects.at ( row );
646
647 if ( ListElement.UID() == obj.UID() )
648 {
649 return this->index ( row, 0 );
650 }
651 }
652
653 return QModelIndex();
654}
config_object_description dref

◆ MODEL_COMMON_INTERFACE_RENAME_THAT_OBJ_IMPL()

MODEL_COMMON_INTERFACE_RENAME_THAT_OBJ_IMPL ( dbe::models::table )

Definition at line 581 of file table.cpp.

582{
583 if ( index.isValid() )
584 {
585 type_datum * element = getnode ( index );
586 element->resetdata ( QStringList ( QString::fromStdString ( obj.ref().UID() ) ) );
587 this_objects[index.row()] = obj.ref();
588 emit dataChanged ( index, index );
589 }
590}

◆ MODEL_COMMON_INTERFACE_UPDATE_THAT_OBJ_IMPL()

MODEL_COMMON_INTERFACE_UPDATE_THAT_OBJ_IMPL ( dbe::models::table )

Definition at line 592 of file table.cpp.

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

◆ MODEL_REMOVE_ROWS_DEF()

MODEL_REMOVE_ROWS_DEF ( dbe::models::table )

Definition at line 659 of file table.cpp.

660{
661 beginRemoveRows ( parent, row, row + count - 1 );
662
663 for ( ; count != 0; --count )
664 {
665 this_structure.removeOne ( this_structure.at ( row + count - 1 ) );
666 this_objects.removeAt ( row + count - 1 );
667 }
668
669 endRemoveRows();
670 return true;
671}