소스 검색

Added function for adding a new child node to ctkXnatTreeModel

Andreas Fetzer 10 년 전
부모
커밋
241c41a972
3개의 변경된 파일14개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 2
      Applications/ctkXnatTreeBrowser/ctkXnatTreeBrowserMainWindow.cpp
  2. 11 0
      Libs/XNAT/Core/ctkXnatTreeModel.cpp
  3. 2 0
      Libs/XNAT/Core/ctkXnatTreeModel.h

+ 1 - 2
Applications/ctkXnatTreeBrowser/ctkXnatTreeBrowserMainWindow.cpp

@@ -176,7 +176,6 @@ void ctkXnatTreeBrowserMainWindow::uploadFileClicked()
       msgbox.setIcon(QMessageBox::Critical);
       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;
 }
+
+//----------------------------------------------------------------------------
+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 addChildNode(const QModelIndex& index, ctkXnatObject *child);
+
 private:
 
   const QScopedPointer<ctkXnatTreeModelPrivate> d_ptr;