瀏覽代碼

Added Option for changing tables text density in dicom browser

stylistic changes
Alireza Mehrtash 11 年之前
父節點
當前提交
acbb81b4bd

+ 34 - 2
Libs/DICOM/Widgets/Resources/UI/ctkDICOMBrowser.ui

@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>788</width>
+    <width>802</width>
     <height>607</height>
    </rect>
   </property>
@@ -74,7 +74,7 @@
         </widget>
        </item>
        <item>
-        <widget class="ctkDirectoryButton" name="DirectoryButton" native="true">
+        <widget class="ctkDirectoryButton" name="DirectoryButton">
          <property name="minimumSize">
           <size>
            <width>200</width>
@@ -84,6 +84,38 @@
         </widget>
        </item>
        <item>
+        <widget class="QLabel" name="tablesDensityLabel">
+         <property name="maximumSize">
+          <size>
+           <width>100</width>
+           <height>20</height>
+          </size>
+         </property>
+         <property name="text">
+          <string>Density</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QComboBox" name="tableDensityComboBox">
+         <item>
+          <property name="text">
+           <string>Comfortable</string>
+          </property>
+         </item>
+         <item>
+          <property name="text">
+           <string>Cozy</string>
+          </property>
+         </item>
+         <item>
+          <property name="text">
+           <string>Compact</string>
+          </property>
+         </item>
+        </widget>
+       </item>
+       <item>
         <spacer name="HorizontalSpacer">
          <property name="orientation">
           <enum>Qt::Horizontal</enum>

+ 22 - 0
Libs/DICOM/Widgets/ctkDICOMBrowser.cpp

@@ -43,6 +43,7 @@
 #include "ctkDICOMQueryResultsTabWidget.h"
 #include "ctkDICOMQueryRetrieveWidget.h"
 #include "ctkDICOMQueryWidget.h"
+#include "ctkDICOMTableManager.h"
 
 #include "ui_ctkDICOMBrowser.h"
 
@@ -207,6 +208,8 @@ ctkDICOMBrowser::ctkDICOMBrowser(QWidget* _parent):Superclass(_parent),
   connect(d->DICOMDatabase.data(), SIGNAL(seriesAdded(QString)), this, SLOT(onSeriesAdded(QString)));
   connect(d->DICOMDatabase.data(), SIGNAL(instanceAdded(QString)), this, SLOT(onInstanceAdded(QString)));
 
+  connect(d->tableDensityComboBox ,SIGNAL(currentIndexChanged (const QString&)),
+     this, SLOT(onTablesDensityComboBox(QString)));
 
   //Set ToolBar button style
   d->ToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
@@ -462,6 +465,25 @@ void ctkDICOMBrowser::onRemoveAction()
 }
 
 //----------------------------------------------------------------------------
+void ctkDICOMBrowser::onTablesDensityComboBox(QString density)
+{
+  Q_D(ctkDICOMBrowser);
+
+  if ( density == "Comfortable")
+  {
+    d->dicomTableManager->setDisplayDensity(ctkDICOMTableManager::Comfortable);
+  }
+  else if ( density == "Cozy")
+  {
+    d->dicomTableManager->setDisplayDensity(ctkDICOMTableManager::Cozy);
+  }
+  else if ( density == "Compact")
+  {
+    d->dicomTableManager->setDisplayDensity(ctkDICOMTableManager::Compact);
+  }
+}
+
+//----------------------------------------------------------------------------
 void ctkDICOMBrowser::onPatientAdded(int databaseID, QString patientID, QString patientName, QString patientBirthDate )
 {
   Q_D(ctkDICOMBrowser);

+ 2 - 0
Libs/DICOM/Widgets/ctkDICOMBrowser.h

@@ -87,6 +87,8 @@ public Q_SLOTS:
   void openQueryDialog();
   void onRemoveAction();
 
+  void onTablesDensityComboBox(QString);
+
   /// Import a directory - this is used when the user selects a directory
   /// from the Import Dialog, but can also be used externally to trigger
   /// an import (i.e. for testing or to support drag-and-drop)

+ 53 - 0
Libs/DICOM/Widgets/ctkDICOMTableManager.cpp

@@ -78,6 +78,8 @@ void ctkDICOMTableManagerPrivate::init()
   this->seriesTable->setQueryTableName("Series");
   this->seriesTable->setQueryForeignKey("StudyInstanceUID");
 
+  q->setDisplayDensity(ctkDICOMTableManager::Comfortable);
+
   // For propagating patient selection changes
   QObject::connect(this->patientsTable, SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
                    q, SIGNAL(patientsSelectionChanged(const QItemSelection&, const QItemSelection&)));
@@ -265,3 +267,54 @@ void ctkDICOMTableManager::resizeEvent(QResizeEvent *e)
   //Minimum size = 800 * 1.28 = 1024 => use horizontal layout (otherwise table size would be too small)
   this->setTableOrientation(e->size().width() > 1.28*this->minimumWidth() ? Qt::Horizontal : Qt::Vertical);
 }
+
+//------------------------------------------------------------------------------
+void ctkDICOMTableManager::setDisplayDensity(DisplayDensity density)
+{
+  Q_D(ctkDICOMTableManager);
+
+  // Compact density
+  if (density == ctkDICOMTableManager::Compact)
+  {
+    d->patientsTable->setTableSectionSize(15);
+    d->studiesTable->setTableSectionSize(15);
+    d->seriesTable->setTableSectionSize(15);
+  }
+  // Cozy density
+  if (density == ctkDICOMTableManager::Cozy)
+  {
+    d->patientsTable->setTableSectionSize(20);
+    d->studiesTable->setTableSectionSize(20);
+    d->seriesTable->setTableSectionSize(20);
+  }
+  // Comfortable density
+  if (density == ctkDICOMTableManager::Comfortable)
+  {
+    d->patientsTable->setTableSectionSize(30);
+    d->studiesTable->setTableSectionSize(30);
+    d->seriesTable->setTableSectionSize(30);
+  }
+}
+
+//------------------------------------------------------------------------------
+ctkDICOMTableManager::DisplayDensity ctkDICOMTableManager::displayDensity()
+{
+  Q_D(ctkDICOMTableManager);
+  int sectionSize;
+  sectionSize = d->patientsTable->tableSectionSize();
+
+  ctkDICOMTableManager::DisplayDensity density;
+  if (sectionSize == 30)
+  {
+    density = ctkDICOMTableManager::Comfortable;
+  }
+  else if (sectionSize == 20)
+  {
+    density = ctkDICOMTableManager::Cozy;
+  }
+  else if (sectionSize == 15)
+  {
+    density = ctkDICOMTableManager::Compact;
+  }
+   return density;
+}

+ 18 - 0
Libs/DICOM/Widgets/ctkDICOMTableManager.h

@@ -50,6 +50,14 @@ class CTK_DICOM_WIDGETS_EXPORT ctkDICOMTableManager : public QWidget
     */
   Q_PROPERTY(bool dynamicTableLayout READ dynamicTableLayout WRITE setDynamicTableLayout)
 
+  Q_ENUMS(DisplayDensity)
+  /**
+  * This property holds the density of tables in the table Manager. There are three denisity
+  * levels: Comfortable (least dense), Cozy and Compact (most dense).
+   */
+
+  Q_PROPERTY(ctkDICOMTableManager::DisplayDensity displayDensity READ displayDensity WRITE setDisplayDensity);
+
 public:
   typedef QWidget Superclass;
 
@@ -79,6 +87,16 @@ public:
 
   void updateTableViews();
 
+  enum DisplayDensity
+  {
+    Compact = 0,
+    Cozy = 1,
+    Comfortable = 2
+  };
+
+  DisplayDensity displayDensity();
+  void setDisplayDensity(DisplayDensity density);
+
 public Q_SLOTS:
 
   void onPatientsQueryChanged(const QStringList&);

+ 15 - 0
Libs/DICOM/Widgets/ctkDICOMTableView.cpp

@@ -372,3 +372,18 @@ bool ctkDICOMTableView::filterActive()
   Q_D(ctkDICOMTableView);
   return (d->leSearchBox->text().length() != 0);
 }
+
+//------------------------------------------------------------------------------
+void ctkDICOMTableView::setTableSectionSize(int size)
+{
+  Q_D(ctkDICOMTableView);
+  d->tblDicomDatabaseView->verticalHeader()->setDefaultSectionSize(size);
+  d->setUpTableView();
+}
+
+//------------------------------------------------------------------------------
+int ctkDICOMTableView::tableSectionSize()
+{
+  Q_D(ctkDICOMTableView);
+  return d->tblDicomDatabaseView->verticalHeader()->defaultSectionSize();
+}

+ 3 - 0
Libs/DICOM/Widgets/ctkDICOMTableView.h

@@ -115,6 +115,9 @@ public:
 
   bool filterActive();
 
+  void setTableSectionSize(int);
+  int tableSectionSize();
+
 public Q_SLOTS:
 
   /**