LCOV - code coverage report
Current view: top level - dbe/src/object - ValidatorComboBox.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 49 0
Test Date: 2025-12-21 13:07:08 Functions: 0.0 % 10 0

            Line data    Source code
       1              : /// Including QT Headers
       2              : #include <QApplication>
       3              : /// Including DBE
       4              : #include "dbe/ValidatorComboBox.hpp"
       5              : #include "dbe/StyleUtility.hpp"
       6              : 
       7            0 : dbe::ValidatorComboBox::ValidatorComboBox ( QWidget * parent )
       8              :   : QComboBox ( parent ),
       9            0 :     Valid ( false ),
      10            0 :     ValueChanged ( false )
      11              : {
      12            0 :   connect ( this, SIGNAL ( editTextChanged ( const QString & ) ), this,
      13              :             SLOT ( TryValidate ( const QString & ) ) );
      14            0 :   connect ( this, SIGNAL ( activated ( const QString & ) ), this,
      15              :             SLOT ( ChangeDetected ( const QString & ) ) );
      16            0 :   connect ( this, SIGNAL ( currentIndexChanged ( int ) ), this,
      17              :             SLOT ( CheckDefaults ( int ) ) );
      18            0 : }
      19              : 
      20            0 : dbe::ValidatorComboBox::~ValidatorComboBox()
      21              : {
      22            0 : }
      23              : 
      24            0 : bool dbe::ValidatorComboBox::IsValid() const
      25              : {
      26            0 :   return Valid;
      27              : }
      28              : 
      29            0 : bool dbe::ValidatorComboBox::IsChanged() const
      30              : {
      31            0 :   return ValueChanged;
      32              : }
      33              : 
      34            0 : QStringList dbe::ValidatorComboBox::GetDataList()
      35              : {
      36            0 :   DataList.clear();
      37            0 :   DataList << currentText();
      38            0 :   return DataList;
      39              : }
      40              : 
      41            0 : void dbe::ValidatorComboBox::wheelEvent ( QWheelEvent * event )
      42              : {
      43            0 :   ( void ) event;
      44            0 :   return;
      45              : }
      46              : 
      47            0 : void dbe::ValidatorComboBox::TryValidate ( const QString & ValidateString )
      48              : {
      49            0 :   QString Tmp = ValidateString;
      50            0 :   int index = 0;
      51              : 
      52            0 :   if ( this->validator() != nullptr )
      53              :   {
      54            0 :     if ( this->validator()->validate ( Tmp, index ) == QValidator::Acceptable )
      55              :     {
      56            0 :       Valid = true;
      57              : 
      58            0 :       if ( CompareDefaults() )
      59              :       {
      60            0 :         this->setPalette ( StyleUtility::LoadedDefault );
      61              :       }
      62              :       else
      63              :       {
      64            0 :         this->setPalette ( QApplication::palette ( this ) );
      65              :       }
      66              :     }
      67            0 :     else if ( this->validator()->validate ( Tmp, index ) == QValidator::Intermediate )
      68              :     {
      69            0 :       Valid = false;
      70            0 :       this->setPalette ( StyleUtility::WarningStatusBarPallete );
      71              :     }
      72              :   }
      73              :   else
      74              :   {
      75            0 :     if ( CompareDefaults() )
      76              :     {
      77            0 :       this->setPalette ( StyleUtility::LoadedDefault );
      78              :     }
      79              :     else
      80              :     {
      81            0 :       this->setPalette ( QApplication::palette ( this ) );
      82              :     }
      83              :   }
      84            0 : }
      85              : 
      86            0 : void dbe::ValidatorComboBox::ChangeDetected ( const QString & StringChange )
      87              : {
      88            0 :   Q_UNUSED ( StringChange )
      89            0 :   ValueChanged = true;
      90            0 :   emit ValueWasChanged();
      91            0 : }
      92              : 
      93            0 : void dbe::ValidatorComboBox::CheckDefaults ( int DefaultIndex )
      94              : {
      95            0 :   Q_UNUSED ( DefaultIndex )
      96              : 
      97            0 :   if ( !Default.isEmpty() )
      98              :   {
      99            0 :     TryValidate ( this->currentText() );
     100              :   }
     101            0 : }
     102              : 
     103            0 : bool dbe::ValidatorComboBox::CompareDefaults()
     104              : {
     105            0 :   if ( Default.isEmpty() )
     106              :   {
     107              :     return false;
     108              :   }
     109              : 
     110            0 :   if ( Default == this->currentText() )
     111              :   {
     112              :     return true;
     113              :   }
     114              : 
     115              :   return false;
     116              : }
        

Generated by: LCOV version 2.0-1