Explorar o código

Added function for adding a new child node to ctkXnatTreeModel

Andreas Fetzer %!s(int64=10) %!d(string=hai) anos
pai
achega
241c41a972

+ 1 - 2
Applications/ctkXnatTreeBrowser/ctkXnatTreeBrowserMainWindow.cpp

@@ -176,7 +176,6 @@ void ctkXnatTreeBrowserMainWindow::uploadFileClicked()
       msgbox.setIcon(QMessageBox::Critical);
       msgbox.setIcon(QMessageBox::Critical);
       msgbox.exec();
       msgbox.exec();
     }
     }
-
+    m_TreeModel->addChildNode(index, file);
   }
   }
-
 }
 }

+ 11 - 0
Libs/XNAT/Core/ctkXnatTreeModel.cpp

@@ -296,3 +296,14 @@ void ctkXnatTreeModel::downloadFile(const QModelIndex& index, const QString& zip
 
 
   return;
   return;
 }
 }
+
+//----------------------------------------------------------------------------
+void ctkXnatTreeModel::addChildNode(const QModelIndex &index, ctkXnatObject* child)
+{
+  Q_D(ctkXnatTreeModel);
+  ctkXnatTreeItem* item = d->itemAt(index);
+
+  beginInsertRows(index, 0, 1);
+  item->appendChild(new ctkXnatTreeItem(child, item));
+  endInsertRows();
+}

+ 2 - 0
Libs/XNAT/Core/ctkXnatTreeModel.h

@@ -59,6 +59,8 @@ public:
 
 
   void downloadFile (const QModelIndex& index, const QString& zipFilename);
   void downloadFile (const QModelIndex& index, const QString& zipFilename);
 
 
+  void addChildNode(const QModelIndex& index, ctkXnatObject *child);
+
 private:
 private:
 
 
   const QScopedPointer<ctkXnatTreeModelPrivate> d_ptr;
   const QScopedPointer<ctkXnatTreeModelPrivate> d_ptr;