瀏覽代碼

Added basic layout switching functionality.
TODO create a better button with changing icon

Andreas Fetzer 12 年之前
父節點
當前提交
0bbb38792a
共有 2 個文件被更改,包括 56 次插入6 次删除
  1. 52 5
      Libs/DICOM/Widgets/ctkDICOMTableManager.cpp
  2. 4 1
      Libs/DICOM/Widgets/ctkDICOMTableManager.h

+ 52 - 5
Libs/DICOM/Widgets/ctkDICOMTableManager.cpp

@@ -20,9 +20,13 @@
 
 // ctk includes
 #include "ctkDICOMTableManager.h"
+#include "ctkDICOMTableView.h"
 
 // Qt includes
 #include <QHBoxLayout>
+#include <QVBoxLayout>
+#include <QRadioButton>
+#include <QButtonGroup>
 #include <QPushButton>
 
 class ctkDICOMTableManagerPrivate
@@ -36,6 +40,13 @@ public:
   ctkDICOMTableManagerPrivate(ctkDICOMTableManager& obj);
   ~ctkDICOMTableManagerPrivate();
 
+  QVBoxLayout* layout;
+  QBoxLayout* layoutTables;
+
+  ctkDICOMTableView* patientsTable;
+  ctkDICOMTableView* studiesTable;
+  ctkDICOMTableView* seriesTable;
+
   void init();
 };
 
@@ -54,10 +65,23 @@ void ctkDICOMTableManagerPrivate::init()
 {
   //setup UI
   Q_Q(ctkDICOMTableManager);
-  QHBoxLayout layout;
-  QPushButton button("Test");
-  layout.addWidget(&button);
-  q->setLayout(&layout);
+
+  this->layout = new QVBoxLayout();
+  this->layoutTables = new QBoxLayout(QBoxLayout::LeftToRight);
+  this->patientsTable = new ctkDICOMTableView();
+  this->studiesTable = new ctkDICOMTableView();
+  this->seriesTable = new ctkDICOMTableView();
+  this->layoutTables->addWidget(patientsTable);
+  this->layoutTables->addWidget(studiesTable);
+  this->layoutTables->addWidget(seriesTable);
+
+  QPushButton* changeLayoutButton = new QPushButton("Change Layout");
+  QObject::connect(changeLayoutButton, SIGNAL(clicked()), q, SLOT(onChangeLayoutPushed()));
+
+  this->layout->addWidget(changeLayoutButton);
+  this->layout->addLayout(this->layoutTables);
+
+  q->setLayout(layout);
 }
 
 //----------------------------------------------------------------------------
@@ -78,7 +102,30 @@ ctkDICOMTableManager::~ctkDICOMTableManager()
 
 }
 
-void ctkDICOMTableManager::onChangeLayout()
+void ctkDICOMTableManager::onChangeLayoutPushed()
 {
+  Q_D(ctkDICOMTableManager);
+  if (d->layoutTables->direction() == QBoxLayout::TopToBottom)
+  {
+    this->changeTableLayout(QBoxLayout::LeftToRight);
+  }
+  else
+  {
+    this->changeTableLayout(QBoxLayout::TopToBottom);
+  }
+}
 
+void ctkDICOMTableManager::changeTableLayout(QBoxLayout::Direction direction)
+{
+  Q_D(ctkDICOMTableManager);
+  d->layoutTables->removeWidget(d->patientsTable);
+  d->layoutTables->removeWidget(d->studiesTable);
+  d->layoutTables->removeWidget(d->seriesTable);
+  delete d->layoutTables;
+
+  d->layoutTables = new QBoxLayout(direction);
+  d->layoutTables->addWidget(d->patientsTable);
+  d->layoutTables->addWidget(d->studiesTable);
+  d->layoutTables->addWidget(d->seriesTable);
+  d->layout->addLayout(d->layoutTables);
 }

+ 4 - 1
Libs/DICOM/Widgets/ctkDICOMTableManager.h

@@ -25,6 +25,7 @@
 
 // Qt includes
 #include <QWidget>
+#include <QBoxLayout>
 
 class ctkDICOMTableManagerPrivate;
 
@@ -44,9 +45,11 @@ protected:
   QScopedPointer<ctkDICOMTableManagerPrivate> d_ptr;
 
 private Q_SLOTS:
-  void onChangeLayout(/*param*/);
+  void onChangeLayoutPushed();
 
 private:
+  void changeTableLayout(QBoxLayout::Direction direction);
+
   Q_DECLARE_PRIVATE(ctkDICOMTableManager)
   Q_DISABLE_COPY(ctkDICOMTableManager)
 };