LCOV - code coverage report
Current view: top level - dbe/apps/SchemaEditor - SchemaGraphicObject.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 335 0
Test Date: 2026-02-16 10:18:04 Functions: 0.0 % 21 0

            Line data    Source code
       1              : /// Including QT Headers
       2              : #include <QApplication>
       3              : #include <QCursor>
       4              : #include <QEvent>
       5              : #include <QGraphicsScene>
       6              : #include <QGraphicsSceneHoverEvent>
       7              : #include <QGraphicsView>
       8              : #include <QPainter>
       9              : #include <QToolTip>
      10              : /// Include oks
      11              : #include"oks/method.hpp"
      12              : /// Including SchemaEditor
      13              : #include "dbe/SchemaClassEditor.hpp"
      14              : #include "dbe/SchemaGraphicObject.hpp"
      15              : #include "dbe/SchemaGraphicSegmentedArrow.hpp"
      16              : #include "dbe/SchemaGraphicsScene.hpp"
      17              : #include "dbe/SchemaKernelWrapper.hpp"
      18              : #include "dbe/SchemaStyle.hpp"
      19              : 
      20              : using namespace dunedaq::oks;
      21              : 
      22            0 : dbse::SchemaGraphicObject::SchemaGraphicObject ( QString & ClassName,
      23              :                                                  SchemaGraphicsScene* scene,
      24            0 :                                                  QGraphicsObject * parent )
      25              :   : QGraphicsObject ( parent ),
      26            0 :     m_scene(scene),
      27            0 :     LineOffsetX ( 0 ),
      28            0 :     LineOffsetY ( 0 )
      29              : {
      30            0 :   setAcceptHoverEvents(true);
      31              : 
      32            0 :   setFlag ( ItemIsMovable );
      33            0 :   setFlag ( ItemSendsGeometryChanges, true );
      34            0 :   setFlag ( ItemSendsScenePositionChanges, true );
      35              : 
      36              :   /// Connecting Signals
      37            0 :   connect ( &KernelWrapper::GetInstance(), SIGNAL ( ClassUpdated ( QString ) ), this,
      38              :             SLOT ( UpdateObject ( QString ) ) );
      39            0 :   connect ( &KernelWrapper::GetInstance(), SIGNAL ( ClassRemoved ( QString ) ), this,
      40              :             SLOT ( RemoveObject ( QString ) ) );
      41              :   /// Getting Class
      42            0 :   m_class_info = KernelWrapper::GetInstance().FindClass ( ClassName.toStdString() );
      43            0 :   m_class_object_name = ClassName;
      44              : 
      45              :   /// Getting class info
      46            0 :   GetInfo();
      47              : 
      48            0 :   set_font();
      49            0 : }
      50              : 
      51            0 : dbse::SchemaGraphicObject::~SchemaGraphicObject()
      52              : {
      53            0 : }
      54              : 
      55              : 
      56              : 
      57            0 : void dbse::SchemaGraphicObject::hoverEnterEvent ( QGraphicsSceneHoverEvent* he) {
      58              :   // std::cout << "hover event at scenePos" << he->scenePos().x() << "," << he->scenePos().y()
      59              :   //           << ", pos=" << he->pos().x() << "," << he->pos().y() << "\n";
      60              : 
      61            0 :   auto text = m_class_info->get_name();
      62            0 :   auto desc = m_class_info->get_description();
      63            0 :   if (!desc.empty()) {
      64            0 :     text += "\n" + desc;
      65              :   }
      66            0 :   text += "\n-----------";
      67              : 
      68            0 :   std::string attr_descriptions;
      69            0 :   auto attributes = m_class_info->direct_attributes();
      70            0 :   if (attributes != nullptr) {
      71            0 :     for (auto attr: *attributes) {
      72            0 :       if (!attr->get_description().empty()) {
      73            0 :         attr_descriptions += "\n " + attr->get_name() + ": " +
      74            0 :           attr->get_description();
      75              :       }
      76              :     }
      77              :   }
      78            0 :   std::string rel_descriptions;
      79            0 :   auto relationships = m_class_info->direct_relationships();
      80            0 :   if (relationships != nullptr) {
      81            0 :     for (auto rel: *relationships) {
      82            0 :       if (!rel->get_description().empty()) {
      83            0 :         rel_descriptions += "\n " + rel->get_name() + ": " +
      84            0 :           rel->get_description();
      85              :       }
      86              :     }
      87              :   }
      88            0 :   std::string method_descriptions;
      89            0 :   auto methods = m_class_info->direct_methods();
      90            0 :   if (methods != nullptr) {
      91            0 :     for (auto method: *methods) {
      92            0 :       if (!method->get_description().empty()) {
      93            0 :         method_descriptions += "\n " + method->get_name() + ": " +
      94            0 :           method->get_description();
      95              :       }
      96              :     }
      97              :   }
      98              : 
      99            0 :   std::string sep="\n-----";
     100            0 :   if (!attr_descriptions.empty()) {
     101            0 :     text += "\nAttributes:" + attr_descriptions;
     102            0 :     if (!(rel_descriptions.empty() && method_descriptions.empty())) {
     103            0 :       text += sep;
     104              :     }
     105              :   }
     106            0 :   if (!rel_descriptions.empty()) {
     107            0 :     text += "\nRelationships:" + rel_descriptions;
     108            0 :     if (!method_descriptions.empty()) {
     109            0 :       text += sep;
     110              :     }
     111              :   }
     112            0 :   if (method_descriptions != "") {
     113            0 :     text += "\nMethods:" + method_descriptions;
     114              :   }
     115              :   //std::cout << "text=<" << text << ">\n"; std::cout.flush();
     116            0 :   QToolTip::showText( he->screenPos(),
     117            0 :                       QString::fromStdString(text),
     118            0 :                       nullptr, QRect(), 10000);
     119            0 :   he->ignore();
     120            0 : }
     121            0 : void dbse::SchemaGraphicObject::hoverLeaveEvent ( QGraphicsSceneHoverEvent* he) {
     122              :   // std::cout << "hover leave\n";
     123            0 :   QToolTip::hideText();
     124            0 :   he->ignore();
     125            0 : }
     126              : 
     127            0 : void dbse::SchemaGraphicObject::mouseDoubleClickEvent ( QGraphicsSceneMouseEvent* ) {
     128            0 :   QString class_name = QString::fromStdString ( m_class_info->get_name() );
     129            0 :   SchemaClassEditor::launch(class_name);
     130            0 : }
     131              : 
     132            0 : OksClass * dbse::SchemaGraphicObject::GetClass() const
     133              : {
     134            0 :   return m_class_info;
     135              : }
     136              : 
     137            0 : QString dbse::SchemaGraphicObject::GetClassName() const
     138              : {
     139            0 :   return m_class_object_name;
     140              : }
     141              : 
     142            0 : void dbse::SchemaGraphicObject::GetInfo()
     143              : {
     144            0 :   m_class_attributes.clear();
     145            0 :   m_class_relationhips.clear();
     146            0 :   m_class_methods.clear();
     147              : 
     148            0 :   std::list<OksAttribute *> direct_attributes = {};
     149            0 :   if (m_class_info->direct_attributes()) {
     150            0 :     direct_attributes = *m_class_info->direct_attributes();
     151              :   }
     152            0 :   std::list<OksMethod *> direct_methods = {};
     153            0 :   if (m_class_info->direct_methods()) direct_methods = *m_class_info->direct_methods();
     154              : 
     155            0 :   std::list<OksRelationship *> direct_relationships = {};
     156            0 :   if (m_class_info->direct_relationships()) direct_relationships = *m_class_info->direct_relationships();
     157              : 
     158            0 :   std::list<OksAttribute *> all_attributes = {};
     159            0 :   if (m_class_info->all_attributes()) all_attributes = *m_class_info->all_attributes();
     160              : 
     161            0 :   std::list<OksMethod *> all_methods = {};
     162            0 :   if (m_class_info->all_methods()) all_methods = *m_class_info->all_methods();
     163              : 
     164            0 :   std::list<OksRelationship *> all_relationships = {};
     165            0 :   if (m_class_info->all_relationships()) all_relationships = *m_class_info->all_relationships();
     166              : 
     167              :   // Prepare indirect relationship list
     168            0 :   std::list<OksAttribute *> indirect_attributes = all_attributes;
     169            0 :   std::list<OksMethod *> indirect_methods = all_methods;
     170            0 :   std::list<OksRelationship *> indirect_relationships = all_relationships;
     171              : 
     172            0 :   for ( OksAttribute * attribute : direct_attributes ) {
     173            0 :     indirect_attributes.remove(attribute);
     174              :   }
     175              : 
     176            0 :   for ( OksMethod * method : direct_methods ) {
     177            0 :     indirect_methods.remove(method);
     178              :   } 
     179              : 
     180            0 :   for ( OksRelationship * relationship : direct_relationships ) {
     181            0 :     indirect_relationships.remove(relationship);
     182              :   } 
     183              : 
     184            0 :   std::map<OksRelationship::CardinalityConstraint, std::string> m = {
     185            0 :     {OksRelationship::Zero, "0"},
     186            0 :     {OksRelationship::One, "1"},
     187            0 :     {OksRelationship::Many, "n"}
     188            0 :   };
     189              : 
     190              :   /// Getting direct Attributes
     191            0 :   for ( OksAttribute * attribute : direct_attributes )
     192              :   {
     193            0 :     QString AttributeString (
     194            0 :       QString::fromStdString ( attribute->get_name() ) + " : "
     195            0 :       + QString::fromStdString ( attribute->get_type() ) + (attribute->get_is_multi_values() ? "[]" : "") );
     196            0 :     m_class_attributes.append ( AttributeString );
     197              : 
     198            0 :     QString value;
     199            0 :     if (!attribute->get_init_value().empty()) {
     200            0 :       value = QString::fromStdString (" = " + attribute->get_init_value());
     201              :     }
     202            0 :     m_class_attribute_values.append (value);
     203            0 :   }
     204              : 
     205              :   /// Getting direct Relationships
     206            0 :   for ( OksRelationship * relationship : direct_relationships )
     207              :   {
     208            0 :     QString relationship_string ( QString::fromStdString ( relationship->get_name() ) + " : " 
     209            0 :     + QString::fromStdString ( relationship->get_type() ) + " - "
     210            0 :     + QString::fromStdString ( m[ relationship->get_low_cardinality_constraint() ] ) + ":"
     211            0 :     + QString::fromStdString ( m[ relationship->get_high_cardinality_constraint() ] )  );
     212            0 :     m_class_relationhips.append ( relationship_string );
     213            0 :   }
     214              : 
     215              :   /// Getting direct Methods
     216            0 :   for ( OksMethod * Method : direct_methods )
     217              :   {
     218            0 :     QString MethodString ( QString::fromStdString ( Method->get_name() ) + "()" );
     219            0 :     m_class_methods.append ( MethodString );
     220            0 :   }
     221              : 
     222              :   /// Getting indirect Attributes
     223            0 :   for ( OksAttribute * attribute : indirect_attributes )
     224              :   {
     225            0 :     QString attribute_string (
     226            0 :       QString::fromStdString ( attribute->get_name() ) + " : "
     227            0 :       + QString::fromStdString ( attribute->get_type() ) );
     228            0 :     m_class_inherited_attributes.append ( attribute_string );
     229            0 :   }
     230              : 
     231              :   /// Getting indirect Relationships
     232            0 :   for ( OksRelationship * relationship : indirect_relationships )
     233              :   {
     234            0 :     QString relationship_string ( QString::fromStdString ( relationship->get_name() ) + " : " 
     235            0 :                                   + QString::fromStdString ( relationship->get_type() ) + " - "
     236            0 :                                   + QString::fromStdString ( m[ relationship->get_low_cardinality_constraint() ] ) + ":"
     237            0 :                                   + QString::fromStdString ( m[ relationship->get_high_cardinality_constraint() ] )  );
     238            0 :     m_class_inherited_relationhips.append ( relationship_string );
     239            0 :   }
     240              : 
     241              :   /// Getting indirect Methods
     242            0 :   for ( OksMethod * method : indirect_methods )
     243              :   {
     244            0 :     QString method_string ( QString::fromStdString ( method->get_name() ) + "()" );
     245            0 :     m_class_inherited_methods.append ( method_string );
     246            0 :   }
     247            0 : }
     248              : 
     249            0 : QRectF dbse::SchemaGraphicObject::boundingRect() const
     250              : {
     251            0 :   double SpaceX = 3;
     252            0 :   double TotalBoundingHeight = 0;
     253            0 :   double TotalBoundingWidth = 0;
     254              : 
     255            0 :   QFontMetrics FontMetrics ( m_font );
     256              : 
     257            0 :   TotalBoundingHeight += SpaceX * 5;
     258            0 :   TotalBoundingHeight += FontMetrics.boundingRect ( m_class_object_name ).height();
     259            0 :   TotalBoundingWidth += FontMetrics.boundingRect ( m_class_object_name ).width();
     260              : 
     261              : 
     262            0 :   for ( int entry=0; entry<m_class_attributes.size(); entry++)
     263              :   {
     264            0 :     QString attribute_name = m_class_attributes[entry];
     265            0 :     if (m_scene->show_defaults()) {
     266            0 :       attribute_name.append(m_class_attribute_values[entry]);
     267              :     }
     268            0 :     TotalBoundingHeight += FontMetrics.boundingRect ( attribute_name ).height();
     269              : 
     270            0 :     if ( FontMetrics.boundingRect (attribute_name).width() > TotalBoundingWidth )
     271              :     {
     272            0 :       TotalBoundingWidth =
     273            0 :         FontMetrics.boundingRect (attribute_name).width();
     274              :     }
     275            0 :   }
     276              : 
     277            0 :   if (m_scene->inherited_properties_visible()) {
     278            0 :     for ( auto & AttributeName : m_class_inherited_attributes )
     279              :     {
     280            0 :       TotalBoundingHeight += FontMetrics.boundingRect ( AttributeName ).height();
     281              : 
     282            0 :       if ( FontMetrics.boundingRect ( AttributeName ).width() > TotalBoundingWidth )
     283            0 :         TotalBoundingWidth =
     284            0 :           FontMetrics.boundingRect ( AttributeName ).width();
     285              :     }
     286              :   }
     287              : 
     288            0 :   for ( auto & relationship_name : m_class_relationhips )
     289              :   {
     290            0 :     TotalBoundingHeight += FontMetrics.boundingRect ( relationship_name ).height();
     291              : 
     292            0 :     if ( FontMetrics.boundingRect ( relationship_name ).width() > TotalBoundingWidth )
     293            0 :       TotalBoundingWidth =
     294            0 :         FontMetrics.boundingRect ( relationship_name ).width();
     295              :   }
     296              : 
     297            0 :   if (m_scene->inherited_properties_visible()) {
     298            0 :     for ( auto & relationship_name : m_class_inherited_relationhips )
     299              :     {
     300            0 :       TotalBoundingHeight += FontMetrics.boundingRect ( relationship_name ).height();
     301              : 
     302            0 :       if ( FontMetrics.boundingRect ( relationship_name ).width() > TotalBoundingWidth )
     303            0 :         TotalBoundingWidth =
     304            0 :           FontMetrics.boundingRect ( relationship_name ).width();
     305              :     }
     306              :   }
     307              : 
     308            0 :   for ( auto & MethodName : m_class_methods )
     309              :   {
     310            0 :     TotalBoundingHeight += FontMetrics.boundingRect ( MethodName ).height();
     311              : 
     312            0 :     if ( FontMetrics.boundingRect ( MethodName ).width() > TotalBoundingWidth )
     313            0 :       TotalBoundingWidth =
     314            0 :         FontMetrics.boundingRect ( MethodName ).width();
     315              :   }
     316              : 
     317            0 :   if (m_scene->inherited_properties_visible()) {
     318            0 :     for ( auto & MethodName : m_class_inherited_methods )
     319              :     {
     320            0 :       TotalBoundingHeight += FontMetrics.boundingRect ( MethodName ).height();
     321              : 
     322            0 :       if ( FontMetrics.boundingRect ( MethodName ).width() > TotalBoundingWidth )
     323            0 :         TotalBoundingWidth =
     324            0 :           FontMetrics.boundingRect ( MethodName ).width();
     325              :     }
     326              :   }
     327              : 
     328            0 :   TotalBoundingWidth += 15;
     329            0 :   return QRectF ( 0, 0, TotalBoundingWidth, TotalBoundingHeight );
     330            0 : }
     331              : 
     332            0 : QPainterPath dbse::SchemaGraphicObject::shape() const
     333              : {
     334            0 :   QPainterPath path;
     335            0 :   path.addRect ( boundingRect() );
     336            0 :   return path;
     337            0 : }
     338              : 
     339            0 : void dbse::SchemaGraphicObject::paint ( QPainter * painter,
     340              :                                         const QStyleOptionGraphicsItem * option,
     341              :                                         QWidget * widget )
     342              : {
     343            0 :   Q_UNUSED ( widget )
     344            0 :   Q_UNUSED ( option )
     345              : 
     346            0 :   double SpaceX = 3;
     347            0 :   double SpaceY = 3;
     348              : 
     349              : 
     350            0 :   QColor colour;
     351            0 :   QColor background;
     352            0 :   if (m_highlight_class) {
     353            0 :     colour = SchemaStyle::get_color("foreground", "highlight");
     354            0 :     background = SchemaStyle::get_color("background", "highlight");
     355              :   }
     356            0 :   else if (m_scene->highlight_active() &&
     357            0 :            (m_class_info->get_file()->get_full_file_name()
     358            0 :             == KernelWrapper::GetInstance().GetActiveSchema())) {
     359            0 :     colour = SchemaStyle::get_color("foreground", "active_file");
     360            0 :     background = SchemaStyle::get_color("background", "active_file");
     361              :   }
     362              :   else {
     363            0 :     colour = SchemaStyle::get_color("foreground", "default");
     364            0 :     background = SchemaStyle::get_color("background", "default");
     365              :   }
     366              : 
     367            0 :   set_font();
     368              : 
     369            0 :   const QPen bounding_box_pen = QPen(colour, 2.5);
     370            0 :   const QPen inner_line_pen = QPen(colour, 1.5);
     371              : 
     372            0 :   painter->setFont ( m_font );
     373            0 :   painter->setPen ( bounding_box_pen );
     374            0 :   painter->setBackground(background);
     375              :   //painter->setBackgroundMode(Qt::OpaqueMode);
     376            0 :   painter->drawRect ( boundingRect() );
     377              : 
     378            0 :   const QFontMetrics FontMetrics = painter->fontMetrics();
     379            0 :   const QRectF ClassNameBoundingRect = FontMetrics.boundingRect ( m_class_object_name );
     380            0 :   const QRectF ObjectBoundingRect = boundingRect();
     381              : 
     382            0 :   double HeightOffset = ClassNameBoundingRect.height() + SpaceY;
     383            0 :   const auto ClassNamePosition = QPointF(
     384            0 :     (ObjectBoundingRect.width() - ClassNameBoundingRect.width() ) / 2,
     385            0 :     ClassNameBoundingRect.height());
     386            0 :   painter->drawText ( ClassNamePosition, m_class_object_name );
     387            0 :   painter->drawLine ( 0, HeightOffset, ObjectBoundingRect.width(), HeightOffset );
     388              : 
     389            0 :   for ( int entry=0; entry<m_class_attributes.size(); entry++)
     390              :   {
     391            0 :     QString attribute_name = m_class_attributes[entry];
     392            0 :     if (m_scene->show_defaults()) {
     393            0 :       attribute_name.append(m_class_attribute_values[entry]);
     394              :     }
     395            0 :     const QRectF AttributeBoundingRect = FontMetrics.boundingRect (attribute_name);
     396            0 :     HeightOffset += AttributeBoundingRect.height();
     397            0 :     painter->drawText ( QPointF(SpaceX, HeightOffset), attribute_name );
     398            0 :   }
     399              : 
     400            0 :   if (m_scene->inherited_properties_visible()) {
     401            0 :     painter->setPen ( SchemaStyle::get_color("foreground", "inherited") );
     402            0 :     for ( QString & AttributeName : m_class_inherited_attributes )
     403              :     {
     404            0 :       const QRectF AttributeBoundingRect = FontMetrics.boundingRect ( AttributeName );
     405            0 :       HeightOffset += AttributeBoundingRect.height();
     406            0 :       painter->drawText ( QPointF(SpaceX, HeightOffset), AttributeName );
     407              :     }
     408            0 :     painter->setPen ( colour );
     409              :   }
     410              : 
     411            0 :   HeightOffset += SpaceY;
     412            0 :   painter->setPen ( inner_line_pen );
     413            0 :   painter->drawLine ( 0, HeightOffset, ObjectBoundingRect.width(), HeightOffset );
     414              : 
     415            0 :   for (const QString & relationship_name : m_class_relationhips )
     416              :   {
     417            0 :     const QRectF relationship_bounding_rect = FontMetrics.boundingRect ( relationship_name );
     418            0 :     HeightOffset += relationship_bounding_rect.height();
     419            0 :     painter->drawText ( QPointF(SpaceX, HeightOffset), relationship_name );
     420              :   }
     421              : 
     422            0 :   if (m_scene->inherited_properties_visible()) {
     423            0 :     painter->setPen ( SchemaStyle::get_color("foreground", "inherited") );
     424            0 :     for ( const QString & relationship_name : m_class_inherited_relationhips )
     425              :     {
     426            0 :       const QRectF relationship_bounding_rect = FontMetrics.boundingRect ( relationship_name );
     427            0 :       HeightOffset += relationship_bounding_rect.height();
     428            0 :       painter->drawText ( QPointF(SpaceX, HeightOffset), relationship_name );
     429              :     }
     430            0 :     painter->setPen ( colour );
     431              :   }
     432              : 
     433              : 
     434            0 :   HeightOffset += SpaceY;
     435            0 :   painter->setPen ( inner_line_pen );
     436            0 :   painter->drawLine ( 0, HeightOffset, ObjectBoundingRect.width(), HeightOffset );
     437              :   
     438            0 :   for ( const QString & MethodName : m_class_methods )
     439              :   {
     440            0 :     const QRectF AttributeBoundingRect = FontMetrics.boundingRect ( MethodName );
     441            0 :     HeightOffset += AttributeBoundingRect.height();
     442            0 :     painter->drawText ( QPointF(SpaceX, HeightOffset), MethodName );
     443              :   }
     444              : 
     445            0 :   if (m_scene->inherited_properties_visible()) {
     446            0 :     painter->setPen ( SchemaStyle::get_color("foreground", "inherited") );
     447            0 :     for ( const QString & MethodName : m_class_inherited_methods )
     448              :     {
     449            0 :       const QRectF AttributeBoundingRect = FontMetrics.boundingRect ( MethodName );
     450            0 :       HeightOffset += AttributeBoundingRect.height();
     451            0 :       painter->drawText (QPointF(SpaceX, HeightOffset), MethodName );
     452              :     }
     453            0 :     painter->setPen ( colour );
     454              :   }
     455            0 : }
     456              : 
     457            0 : void dbse::SchemaGraphicObject::AddArrow ( SchemaGraphicSegmentedArrow * Arrow )
     458              : {
     459            0 :   m_arrows.append ( Arrow );
     460            0 : }
     461              : 
     462            0 : void dbse::SchemaGraphicObject::RemoveArrow ( SchemaGraphicSegmentedArrow * Arrow )
     463              : {
     464            0 :   const int index = m_arrows.indexOf ( Arrow );
     465              : 
     466            0 :   if ( index != -1 )
     467              :   {
     468            0 :     m_arrows.removeAt ( index );
     469              :   }
     470            0 : }
     471              : 
     472            0 : void dbse::SchemaGraphicObject::RemoveArrows()
     473              : {
     474            0 :   for ( SchemaGraphicSegmentedArrow * arrow : m_arrows )
     475              :   {
     476            0 :     arrow->GetStartItem()->RemoveArrow ( arrow );
     477            0 :     arrow->GetEndItem()->RemoveArrow ( arrow );
     478            0 :     scene()->removeItem ( arrow );
     479              :   }
     480            0 : }
     481              : 
     482            0 : bool dbse::SchemaGraphicObject::HasArrow ( SchemaGraphicObject * Dest ) const
     483              : {
     484            0 :   if ( m_arrows.isEmpty() )
     485              :   {
     486              :     return false;
     487              :   }
     488              : 
     489            0 :   for ( SchemaGraphicSegmentedArrow * Arrow : m_arrows )
     490              :   {
     491            0 :     SchemaGraphicObject * ArrowSource = Arrow->GetStartItem();
     492            0 :     SchemaGraphicObject * ArrowDest = Arrow->GetEndItem();
     493              : 
     494            0 :     if ( ( ArrowSource == this ) && ( ArrowDest == Dest ) )
     495              :     {
     496            0 :       return true;
     497              :     }
     498              :   }
     499              : 
     500            0 :   return false;
     501              : }
     502              : 
     503            0 : void dbse::SchemaGraphicObject::update_arrows()
     504              : {
     505            0 :   for ( SchemaGraphicSegmentedArrow * arrow : m_arrows )
     506              :   {
     507            0 :     arrow->UpdatePosition();
     508              :   }
     509            0 : }
     510              : 
     511            0 : void dbse::SchemaGraphicObject::set_font()
     512              : {
     513            0 :   if (m_highlight_class) {
     514            0 :     m_font = SchemaStyle::get_font("highlight");
     515              :   }
     516              :   else {
     517            0 :     m_font = SchemaStyle::get_font("default");
     518              :   }
     519            0 :   if (m_class_info->get_is_abstract() && m_scene->highlight_abstract()) {
     520              :     // Use selected font but with style from abstract class font 
     521            0 :     m_font.setStyle(SchemaStyle::get_font("abstract").style());
     522              :   }
     523            0 : }
     524            0 : void dbse::SchemaGraphicObject::toggle_highlight_class()
     525              : {
     526            0 :   m_highlight_class = !m_highlight_class;
     527            0 :   set_font();
     528            0 :   update_arrows();
     529            0 : }
     530              : 
     531              : 
     532            0 : QVariant dbse::SchemaGraphicObject::itemChange ( GraphicsItemChange change,
     533              :                                                  const QVariant & value )
     534              : {
     535            0 :   if ( change == ItemPositionChange ) 
     536            0 :     for ( SchemaGraphicSegmentedArrow * arrow : m_arrows )
     537              :     {
     538            0 :       arrow->UpdatePosition();
     539              :     }
     540              : 
     541            0 :   return value;
     542              : }
     543              : 
     544            0 : void dbse::SchemaGraphicObject::UpdateObject ( QString Name )
     545              : {
     546            0 :   if ( Name != m_class_object_name )
     547              :   {
     548              :     return;
     549              :   }
     550              : 
     551              :   /// Updating object info
     552            0 :   GetInfo();
     553              :   /// Updating object representation
     554            0 :   SchemaGraphicsScene * Scene = dynamic_cast<SchemaGraphicsScene *> ( scene() );
     555              : 
     556            0 :   if ( Scene )
     557              :   {
     558            0 :     QStringList ClassesList;
     559            0 :     ClassesList.append ( Name );
     560              : 
     561            0 :     QList<QPointF> ClassesPositions;
     562            0 :     QPointF ClassPosition ( this->scenePos() );
     563            0 :     ClassesPositions.append ( ClassPosition );
     564              : 
     565            0 :     Scene->RemoveClassObject ( this );
     566            0 :     Scene->AddItemsToScene ( QStringList ( m_class_object_name ), ClassesPositions );
     567            0 :   }
     568              : 
     569              :   /// Repainting object
     570            0 :   update();
     571              : }
     572              : 
     573            0 : void dbse::SchemaGraphicObject::RemoveObject ( QString Name )
     574              : {
     575            0 :   if ( Name != m_class_object_name )
     576              :   {
     577              :     return;
     578              :   }
     579              : 
     580              :   /// Updating object representation
     581            0 :   SchemaGraphicsScene * Scene = dynamic_cast<SchemaGraphicsScene *> ( scene() );
     582              : 
     583            0 :   if ( Scene )
     584              :   {
     585            0 :     Scene->RemoveClassObject ( this );
     586              :   }
     587              : }
        

Generated by: LCOV version 2.0-1