<commit_before>/*=============================================================================

  Library: CTK

  Copyright (c) University of Sheffield

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

=============================================================================*/

// Qt include
#include <QSharedData>
#include <QStandardItem>
#include <QString>
#include <QStringList>

// DCMTK includes
#include "dcmtk/dcmdata/dcdeftag.h"
#include "dcmtk/dcmdata/dcdatset.h"
#include "dcmtk/dcmdata/dcfilefo.h"
#include "dcmtk/dcmdata/dcmetinf.h"
#include "dcmtk/dcmdata/dcitem.h"
#include "dcmtk/ofstd/ofcond.h"
#include "dcmtk/ofstd/ofstring.h"
#include "dcmtk/ofstd/ofstd.h"        /* for class OFStandard */

// CTK DICOM Core
#include "ctkDICOMObjectModel.h"

//------------------------------------------------------------------------------
class ctkDICOMObjectModelPrivate
{
  Q_DECLARE_PUBLIC(ctkDICOMObjectModel);
protected:
  ctkDICOMObjectModel* const q_ptr;

public:
  ctkDICOMObjectModelPrivate(ctkDICOMObjectModel&);
  virtual ~ctkDICOMObjectModelPrivate();
  void init();
  void ctkDICOMObjectModelPrivate::traverseDataElements( DcmItem *dataset, QStandardItem *parent);
  QString ctkDICOMObjectModelPrivate::getTagValue( DcmElement *dcmElem);
  QStandardItem* ctkDICOMObjectModelPrivate::populateModelRow(const QString& tagName,const QString& tagValue, QStandardItem *parent);

  DcmFileFormat fileFormat;
  QStandardItem *rootItem;
};
//------------------------------------------------------------------------------
ctkDICOMObjectModelPrivate::ctkDICOMObjectModelPrivate(ctkDICOMObjectModel& o):q_ptr(&o)
{
}

//------------------------------------------------------------------------------
ctkDICOMObjectModelPrivate::~ctkDICOMObjectModelPrivate()
{
}
//------------------------------------------------------------------------------
void ctkDICOMObjectModelPrivate::init()
{
  Q_Q(ctkDICOMObjectModel);
  QStringList horizontalHeaderLabels;
  horizontalHeaderLabels.append( QString("Tag"));
  horizontalHeaderLabels.append( QString("Value"));
  q->setHorizontalHeaderLabels(horizontalHeaderLabels);
	
}
//------------------------------------------------------------------------------
void ctkDICOMObjectModelPrivate::traverseDataElements( DcmItem *dataset, QStandardItem *parent)
{
  DcmStack stack;
  dataset->nextObject( stack, OFTrue);
  for( ; stack.top(); dataset->nextObject( stack, OFFalse))
    {
    DcmObject *dO =  stack.top();
    // put in the visit node function
    QString tagValue = "";
    DcmTag tag = dO->getTag();
	  // std::cout<<tag;
    QString tagName = tag.getTagName();
    DcmTag tagKey = tag.getXTag();
	  // std::cout<< tagName.toUtf8().constData()<<std::endl;
    if( tagKey == DCM_SequenceDelimitationItem
    || tagKey == DCM_ItemDelimitationItem
    || "Item" == tagName)
      {
	    return;
	    }
  
    DcmElement *dcmElem = dynamic_cast<DcmElement *> (dO);
    tagValue = getTagValue(dcmElem);
  
    // Populate QStandardModel with current DICOM element tag name and value
    QStandardItem *tagItem = populateModelRow(tagName,tagValue,parent);
    
    // check if the DICOM object is a SQ Data element and extract the nested DICOM objects
    if( dcmElem && !dcmElem->isLeaf())<commit_msg>FIX: The method names for ctkDICOMObjectModelPrivate modified in order to resolve the qulification on member error.<commit_after>/*=============================================================================

  Library: CTK

  Copyright (c) University of Sheffield

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

=============================================================================*/

// Qt include
#include <QSharedData>
#include <QStandardItem>
#include <QString>
#include <QStringList>

// DCMTK includes
#include "dcmtk/dcmdata/dcdeftag.h"
#include "dcmtk/dcmdata/dcdatset.h"
#include "dcmtk/dcmdata/dcfilefo.h"
#include "dcmtk/dcmdata/dcmetinf.h"
#include "dcmtk/dcmdata/dcitem.h"
#include "dcmtk/ofstd/ofcond.h"
#include "dcmtk/ofstd/ofstring.h"
#include "dcmtk/ofstd/ofstd.h"        /* for class OFStandard */

// CTK DICOM Core
#include "ctkDICOMObjectModel.h"

//------------------------------------------------------------------------------
class ctkDICOMObjectModelPrivate
{
  Q_DECLARE_PUBLIC(ctkDICOMObjectModel);
protected:
  ctkDICOMObjectModel* const q_ptr;

public:
  ctkDICOMObjectModelPrivate(ctkDICOMObjectModel&);
  virtual ~ctkDICOMObjectModelPrivate();
  void init();
  void traverseDataElements( DcmItem *dataset, QStandardItem *parent);
  QString getTagValue( DcmElement *dcmElem);
  QStandardItem* populateModelRow(const QString& tagName,const QString& tagValue, QStandardItem *parent);

  DcmFileFormat fileFormat;
  QStandardItem *rootItem;
};
//------------------------------------------------------------------------------
ctkDICOMObjectModelPrivate::ctkDICOMObjectModelPrivate(ctkDICOMObjectModel& o):q_ptr(&o)
{
}

//------------------------------------------------------------------------------
ctkDICOMObjectModelPrivate::~ctkDICOMObjectModelPrivate()
{
}
//------------------------------------------------------------------------------
void ctkDICOMObjectModelPrivate::init()
{
  Q_Q(ctkDICOMObjectModel);
  QStringList horizontalHeaderLabels;
  horizontalHeaderLabels.append( QString("Tag"));
  horizontalHeaderLabels.append( QString("Value"));
  q->setHorizontalHeaderLabels(horizontalHeaderLabels);
}
//------------------------------------------------------------------------------
void ctkDICOMObjectModelPrivate::traverseDataElements( DcmItem *dataset, QStandardItem *parent)
{
  DcmStack stack;
  dataset->nextObject( stack, OFTrue);
  for( ; stack.top(); dataset->nextObject( stack, OFFalse))
    {
    DcmObject *dO =  stack.top();
    // put in the visit node function
    QString tagValue = "";
    DcmTag tag = dO->getTag();
	  // std::cout<<tag;
    QString tagName = tag.getTagName();
    DcmTag tagKey = tag.getXTag();
	  // std::cout<< tagName.toUtf8().constData()<<std::endl;
    if( tagKey == DCM_SequenceDelimitationItem
    || tagKey == DCM_ItemDelimitationItem
    || "Item" == tagName)
      {
	    return;
	    }
  
    DcmElement *dcmElem = dynamic_cast<DcmElement *> (dO);
    tagValue = getTagValue(dcmElem);
  
    // Populate QStandardModel with current DICOM element tag name and value
    QStandardItem *tagItem = populateModelRow(tagName,tagValue,parent);
    
    // check if the DICOM object is a SQ Data element and extract the nested DICOM objects
    if( dcmElem && !dcmElem->isLeaf())
{'fraction_non_alphanumeric': 0.23647027459344175, 'fraction_numerical': 0.0013329778725673154, 'mean_word_length': 2.922111866178777, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2478365', 'n_tokens_mistral': 2177, 'n_tokens_neox': 2145, 'n_words': 524}