2 #include "ui_QmitkSelectXnatUploadDestinationDialog.h"
4 #include <ctkXnatObject.h>
5 #include <ctkXnatResource.h>
6 #include <ctkXnatResourceFolder.h>
7 #include <ctkXnatSession.h>
11 #include <QModelIndex>
14 const QStringList &availableResources,
20 m_CreateNewFolder(false)
25 m_TreeModel->addDataModel(session->dataModel());
26 ui->treeView->setModel(m_TreeModel);
28 connect(ui->cbSelectResources,
29 SIGNAL(currentIndexChanged(
const QString &)),
32 connect(ui->treeView, SIGNAL(clicked(
const QModelIndex &)),
this, SLOT(
OnXnatNodeSelected(
const QModelIndex &)));
33 connect(ui->rbSelectResource, SIGNAL(toggled(
bool)),
this, SLOT(
OnSelectResource(
bool)));
34 connect(ui->rbSelectFromTreeView, SIGNAL(toggled(
bool)),
this, SLOT(
OnSelectFromTreeView(
bool)));
35 connect(ui->leResourceName, SIGNAL(textChanged(
const QString &)),
this, SLOT(
OnResourceEntered(
const QString &)));
36 connect(ui->pbCancel, SIGNAL(clicked()),
this, SLOT(
OnCancel()));
37 connect(ui->pbUpload, SIGNAL(clicked()),
this, SLOT(
OnUpload()));
40 ui->pbUpload->setEnabled(
false);
41 ui->leResourceName->setVisible(
false);
44 if (availableResources.isEmpty())
46 ui->rbSelectFromTreeView->setChecked(
true);
47 ui->rbSelectResource->setEnabled(
false);
51 foreach (QString resourceName, availableResources)
53 ui->cbSelectResources->addItem(resourceName);
55 ui->cbSelectResources->addItem(
"Create new resource folder...");
66 this->done(QDialog::Rejected);
71 this->done(QDialog::Accepted);
76 ui->pbUpload->setEnabled(
false);
77 ui->cbSelectResources->setVisible(selectResource);
78 ui->leResourceName->setVisible(!selectResource);
79 ui->treeView->setVisible(!selectResource);
81 ui->cbSelectResources->setCurrentIndex(0);
86 ui->pbUpload->setEnabled(
false);
87 ui->cbSelectResources->setVisible(!selectFromTreeView);
88 ui->leResourceName->setVisible(!selectFromTreeView);
89 ui->treeView->setVisible(selectFromTreeView);
99 if (ui->rbSelectResource->isChecked() && !m_Url.isEmpty() && !m_ResourceName.isEmpty())
103 ctkXnatResource *resource =
new ctkXnatResource();
104 resource->setName(m_ResourceName);
105 resource->setParent(selectedXnatObject);
106 if (!resource->exists())
112 QModelIndex index = ui->treeView->selectionModel()->currentIndex();
113 return m_TreeModel->xnatObject(index);
119 if (resource.isEmpty())
120 ui->pbUpload->setEnabled(
false);
122 if (resource !=
"Create new resource folder...")
124 ui->pbUpload->setEnabled(
true);
125 m_ResourceName = resource;
126 ui->leResourceName->hide();
128 else if (resource ==
"Create new resource folder...")
130 ui->pbUpload->setEnabled(
false);
131 ui->leResourceName->show();
137 m_CreateNewFolder = !resourceEntered.isEmpty();
138 ui->pbUpload->setEnabled(m_CreateNewFolder);
139 m_ResourceName = resourceEntered;
144 if (!index.isValid())
147 ctkXnatObject *selectedObject = m_TreeModel->xnatObject(index);
148 ui->pbUpload->setEnabled(dynamic_cast<ctkXnatResource *>(selectedObject) !=
nullptr);
ctkXnatObject * GetXnatObjectFromUrl(const QString &)
void OnSelectFromTreeView(bool selectFromTreeView)
void OnResourceSelected(const QString &resource)
~QmitkSelectXnatUploadDestinationDialog()
void OnResourceEntered(const QString &resourceEntered)
void OnSelectResource(bool selectResource)
ctkXnatObject * GetUploadDestination()
QmitkSelectXnatUploadDestinationDialog(ctkXnatSession *session, const QStringList &, QWidget *parent=0)
void SetXnatResourceFolderUrl(const QString &url)
void OnXnatNodeSelected(const QModelIndex &)