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

503{
504 if ( treenode * handlerclass = confaccessor::gethandler()->getnode ( obj.class_name() ) )
505 {
506 if ( obj.class_name() == this_class_name.toStdString()
507 or config::api::info::onclass::derived (
508 this_class_name.toStdString(), obj.class_name() ) )
509 {
510
511 dbe::treenode const * handlernode = dbe::datahandler::findchild (
512 handlerclass, QString::fromStdString ( obj.UID() ) );
513
514 if ( handlernode == nullptr )
515 {
516 handlernode = new ObjectNode ( obj, false, handlerclass );
517 }
518
519 emit layoutAboutToBeChanged();
520
521 // We assume that the objects are sorted and we want to insert a new element
522
523 tref const handlerobj = handlernode->GetObject();
524 auto sit = this_structure.begin();
525 auto it = this_objects.begin();
526
527 for ( ;
528 it != this_objects.end() and sit != this_structure.end()
529 and it->UID() < handlerobj.UID(); ++it, ++sit )
530 {}
531
532 this_structure.insert ( ++sit, createrow ( handlernode ) );
533
534 this_objects.insert ( ++it, handlerobj );
535
536 // Normally we would have to call changePersistentIndex.
537 // Because an objectnode is created which had no index
538 // before this creation had occured there is no need to call it.
539 emit layoutChanged();
540 }
541 }
542}
static treenode * findchild(treenode *top, QString const &name)
virtual tref GetObject() const
Definition treenode.cpp:75
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 544 of file table.cpp.

545{
546 if ( index.isValid() )
547 {
548 try
549 {
550 this->removeRows ( index.row(), 1, index.parent() );
551 }
552 catch ( daq::dbe::ObjectChangeWasNotSuccessful const & err )
553 {
554 WARN ( "Object cannot be deleted", dbe::config::errors::parse ( err ).c_str() );
555 }
556 }
557}
#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 619 of file table.cpp.

620{
621 for ( int row = 0; row < this_objects.size(); ++row )
622 {
623 dref ListElement = this_objects.at ( row );
624
625 if ( ListElement.UID() == obj.UID() )
626 {
627 return this->index ( row, 0 );
628 }
629 }
630
631 return QModelIndex();
632}
config_object_description dref

◆ MODEL_COMMON_INTERFACE_RENAME_THAT_OBJ_IMPL()

MODEL_COMMON_INTERFACE_RENAME_THAT_OBJ_IMPL ( dbe::models::table )

Definition at line 559 of file table.cpp.

560{
561 if ( index.isValid() )
562 {
563 type_datum * element = getnode ( index );
564 element->resetdata ( QStringList ( QString::fromStdString ( obj.ref().UID() ) ) );
565 this_objects[index.row()] = obj.ref();
566 emit dataChanged ( index, index );
567 }
568}

◆ MODEL_COMMON_INTERFACE_UPDATE_THAT_OBJ_IMPL()

MODEL_COMMON_INTERFACE_UPDATE_THAT_OBJ_IMPL ( dbe::models::table )

Definition at line 570 of file table.cpp.

571{
572 if ( treenode * handlerclass = confaccessor::gethandler()->getnode ( obj.class_name() ) )
573 {
574 if ( obj.class_name() == this_class_name.toStdString()
575 or config::api::info::onclass::derived (
576 this_class_name.toStdString(), obj.class_name() ) )
577 {
578 dbe::treenode const * handlernode = dbe::datahandler::findchild (
579 handlerclass, QString::fromStdString ( obj.UID() ) );
580
581 tref handlerobj = handlernode->GetObject();
582
583 auto sit = this_structure.begin();
584 auto it = this_objects.begin();
585
586 // find the object to be updated by looping through both objects and nodes
587
588 for ( ;
589 it != this_objects.end() and sit != this_structure.end()
590 and it->UID() != handlerobj.UID(); ++it, ++sit )
591
592 ;
593
594 // delete all table nodes in the list ( remove elements of the row )
595 for ( TableNode * x : *sit )
596 {
597 delete x;
598 }
599
600 // Recreate the row
601 *sit = createrow ( handlernode );
602
603 int r = index.row() == 0 ? 0 : index.row() - 1;
604
605 int c = index.column() == 0 ? 0 : index.column() - 1;
606
607 emit dataChanged ( createIndex ( r, c ), createIndex ( r + 1, c + 1 ) );
608 }
609 }
610}

◆ MODEL_REMOVE_ROWS_DEF()

MODEL_REMOVE_ROWS_DEF ( dbe::models::table )

Definition at line 637 of file table.cpp.

638{
639 beginRemoveRows ( parent, row, row + count - 1 );
640
641 for ( ; count != 0; --count )
642 {
643 this_structure.removeOne ( this_structure.at ( row + count - 1 ) );
644 this_objects.removeAt ( row + count - 1 );
645 }
646
647 endRemoveRows();
648 return true;
649}