+}
+
+// TreeViews creation
+void vvQPacsConnection::createTreeView()
+{
+ // Patient Tree View
+ Patientmodel = new QStandardItemModel(0,2,this);
+ QStringList Patientlist;
+ Patientlist.push_back(tr("PATIENT NAME"));
+ Patientlist.push_back(tr("PATIENT ID"));
+ Patientmodel->setHorizontalHeaderLabels(Patientlist);
+ ui.patientTreeView->setModel(Patientmodel);
+ ui.patientTreeView->setEnabled(true);
+ connect(ui.patientTreeView, SIGNAL(clicked(QModelIndex)), this, SLOT(selectStudies(QModelIndex)));
+
+ // Study Tree View
+ Studymodel = new QStandardItemModel(0,3,this);
+ QStringList Studylist;
+ Studylist.push_back(tr("DESCRIPTION"));
+ Studylist.push_back(tr("DATE"));
+ Studylist.push_back(tr("HOUR"));
+ Studylist.push_back(tr("STUDY ID"));
+ Studymodel->setHorizontalHeaderLabels(Studylist);
+ ui.studyTreeView->setModel(Studymodel);
+ connect(ui.studyTreeView, SIGNAL(clicked(QModelIndex)), this, SLOT(selectSeries(QModelIndex)));
+
+
+ // Series Tree View
+ Seriesmodel = new QStandardItemModel(0,2,this);
+ QStringList Serieslist;
+ Serieslist.push_back(tr("MODALITY"));
+ Serieslist.push_back(tr("DESCRIPTION"));
+ Serieslist.push_back(tr("no. accept."));
+ Seriesmodel->setHorizontalHeaderLabels(Serieslist);
+ ui.seriesTreeView->setModel(Seriesmodel);
+ connect(ui.seriesTreeView, SIGNAL(clicked(QModelIndex)), this, SLOT(selectImages(QModelIndex)));
+ connect(ui.imagesTreeView, SIGNAL(clicked(QModelIndex)), this, SLOT(selectImage(QModelIndex)));
+ // Images Tree View
+ Imagesmodel = new QStandardItemModel(0,1,this);
+ QStringList Imageslist;
+ Imageslist.push_back(tr("instance number"));
+ Imageslist.push_back(tr("sopuid"));
+ Imagesmodel->setHorizontalHeaderLabels(Imageslist);
+ ui.imagesTreeView->setModel(Imagesmodel);
+}
+
+// clean the different model Trees
+void vvQPacsConnection::cleanTree()
+{
+ Patientmodel->removeRows(0,Patientmodel->rowCount());
+ Studymodel->removeRows(0,Patientmodel->rowCount());
+ Seriesmodel->removeRows(0,Patientmodel->rowCount());
+ Imagesmodel->removeRows(0,Patientmodel->rowCount());
+
+}
+
+void vvQPacsConnection::selectStudies(const QModelIndex &index)
+{
+
+ m_patient= Patientmodel->data(index.sibling(index.row(),1)).toString().toStdString();
+ Studymodel->removeRows(0, Studymodel->rowCount(),QModelIndex());
+ Seriesmodel->removeRows(0, Seriesmodel->rowCount(),QModelIndex());
+ Imagesmodel->removeRows(0, Imagesmodel->rowCount(),QModelIndex());
+ manageSeriesFilter(true);
+ convertDataSet( findQuery( mQFactory.getQueryforStudy(m_patient, false)) , Studymodel, mQFactory.getQueryKeysforStudy("",true));
+}
+
+
+void vvQPacsConnection::clearMove()
+{
+
+}
+
+void vvQPacsConnection::selectSeries(const QModelIndex &index)
+{
+ m_study= Studymodel->data(index.sibling(index.row(),3)).toString().toStdString();
+ Seriesmodel->removeRows(0, Seriesmodel->rowCount());
+ Imagesmodel->removeRows(0, Imagesmodel->rowCount());
+ convertDataSet( findQuery( mQFactory.getQueryforSeries(m_patient,m_study, false)), Seriesmodel, mQFactory.getSeriesKeys("","",true));
+
+}
+
+void vvQPacsConnection::selectImages(const QModelIndex &index)
+{
+ m_series = Seriesmodel->data(index.sibling(index.row(),2)).toString().toStdString();
+ Imagesmodel->removeRows(0, Imagesmodel->rowCount(),QModelIndex());
+ convertDataSet( findQuery( mQFactory.getQueryforImages(m_patient,m_study, m_series, false) ), Imagesmodel, mQFactory.getQueryKeysforImages("","","",true));
+
+}
+
+void vvQPacsConnection::selectImage(const QModelIndex &index)
+{
+ std::string _image = Imagesmodel->data(index.sibling(index.row(),1)).toString().toStdString();
+ mQFactory.setQueryforImage(m_patient,m_study, m_series, _image);
+
+}
+
+
+std::vector<gdcm::DataSet> vvQPacsConnection::findQuery(vvQuery i_query)
+{
+ std::vector<gdcm::DataSet> theDataSet;
+ gdcm::CompositeNetworkFunctions::CFind(m_adress.c_str(), atoi(m_port.c_str()),
+ gdcm::CompositeNetworkFunctions::ConstructQuery(i_query.theRoot, i_query.theLevel,i_query.keys), theDataSet,
+ getDicomClientAETitle().c_str(), m_nickname.c_str());
+ return theDataSet;
+}
+
+void vvQPacsConnection::manageStudiesFilter(bool i_enable)
+{
+ ui.text_PHYS->setEnabled(i_enable);
+ ui.text_SDESC->setEnabled(i_enable);
+ ui.dateTab->setEnabled(i_enable);
+
+}
+
+void vvQPacsConnection::manageSeriesFilter(bool i_enable)
+{
+ ui.modalityTab->setEnabled(i_enable);
+}
+
+
+std::vector< std::pair<gdcm::Tag, std::string> > vvQPacsConnection::getStudyKeys(const std::string i_val)
+{
+ std::vector< std::pair<gdcm::Tag, std::string> > keys;
+ // Study Description
+ gdcm::Tag tagsdc(0x0008,0x1030);
+ keys.push_back(std::make_pair(tagsdc, ""));
+ // Study date
+ gdcm::Tag tagdb(0x0008,0x0020);
+ keys.push_back(std::make_pair(tagdb, ""));
+ // Study Hour
+ gdcm::Tag tagsdh(0x0008,0x0030);
+ keys.push_back(std::make_pair(tagsdh, ""));
+ // Study Instance UID
+ gdcm::Tag tagsid(0x0020,0x000d);
+ keys.push_back(std::make_pair(tagsid, i_val));
+
+ return keys;
+}
+
+std::vector< std::pair<gdcm::Tag, std::string> > vvQPacsConnection::getKeys()
+{
+ std::vector< std::pair<gdcm::Tag, std::string> > keys;
+ // Patient Name
+ gdcm::Tag tag(0x0010,0x0010);
+ keys.push_back(std::make_pair(tag, ""));
+
+ //// Patient ID
+ gdcm::Tag tagpid(0x0010,0x0020);
+ keys.push_back(std::make_pair(tagpid, ""));
+
+ // Modality
+ gdcm::Tag tagmod(0x0008,0x0061);
+ keys.push_back(std::make_pair(tagmod, ""));
+
+ // date of birth
+ gdcm::Tag tagdb(0x0010,0x0030);
+ keys.push_back(std::make_pair(tagdb, ""));
+
+ // Study Date
+ gdcm::Tag tagsd(0x0020,0x000D);
+ keys.push_back(std::make_pair(tagsd, ""));
+
+ //// Study Time
+ //gdcm::Tag tagst(8,30);
+ //keys.push_back(std::make_pair(tagst, ""));
+
+ //// Study Description
+ //gdcm::Tag tagsdc(8,1030);
+ //keys.push_back(std::make_pair(tagsdc, ""));
+
+ //// Accession
+ //gdcm::Tag tagacc(8,50);
+ //keys.push_back(std::make_pair(tagacc, ""));
+
+ return keys;
+}
+
+void vvQPacsConnection::on_check_ModAll_clicked(bool state)
+{
+ ui.check_MR->setEnabled(!state);
+ ui.check_CR->setEnabled(!state);
+ ui.check_OT->setEnabled(!state);
+ ui.check_RF->setEnabled(!state);
+ ui.check_SC->setEnabled(!state);
+ ui.check_CT->setEnabled(!state);
+ ui.check_US->setEnabled(!state);
+ ui.check_NM->setEnabled(!state);
+ ui.check_DR->setEnabled(!state);
+ ui.check_US->setEnabled(!state);
+ ui.check_NM->setEnabled(!state);
+ ui.check_DR->setEnabled(!state);
+ ui.check_SR->setEnabled(!state);
+ ui.check_XA->setEnabled(!state);
+ ui.check_MG->setEnabled(!state);
+ if(state)