ソースを参照

Merge branch 'fix-threadid-errorlog-column-visibility'

* fix-threadid-errorlog-column-visibility:
  ENH: Add convenience method allowing to show/hide any error log column.
  BUG: Hide error log "threadid" column by setting model column count
Jean-Christophe Fillion-Robin 12 年 前
コミット
b759ef7b96
共有3 個のファイルを変更した14 個の追加2 個の削除を含む
  1. 1 0
      Libs/Core/ctkErrorLogModel.cpp
  2. 9 2
      Libs/Widgets/ctkErrorLogWidget.cpp
  3. 4 0
      Libs/Widgets/ctkErrorLogWidget.h

+ 1 - 0
Libs/Core/ctkErrorLogModel.cpp

@@ -217,6 +217,7 @@ public:
 ctkErrorLogModelPrivate::ctkErrorLogModelPrivate(ctkErrorLogModel& object)
   : q_ptr(&object)
 {
+  this->StandardItemModel.setColumnCount(ctkErrorLogModel::MaxColumn);
   this->LogEntryGrouping = false;
   this->AsynchronousLogging = true;
   this->AddingEntry = false;

+ 9 - 2
Libs/Widgets/ctkErrorLogWidget.cpp

@@ -83,8 +83,6 @@ void ctkErrorLogWidgetPrivate::init()
 
   QObject::connect(this->ClearButton, SIGNAL(clicked()),
                    q, SLOT(removeEntries()));
-
-  this->ErrorLogTableView->setColumnHidden(ctkErrorLogModel::ThreadIdColumn, true);
 }
 
 // --------------------------------------------------------------------------
@@ -177,6 +175,15 @@ void ctkErrorLogWidget::setErrorLogModel(ctkErrorLogModel * newErrorLogModel)
     {
     this->setAllEntriesVisible(0);
     }
+
+  d->ErrorLogTableView->setColumnHidden(ctkErrorLogModel::ThreadIdColumn, true);
+}
+
+// --------------------------------------------------------------------------
+void ctkErrorLogWidget::setColumnHidden(int columnId, bool hidden) const
+{
+  Q_D(const ctkErrorLogWidget);
+  d->ErrorLogTableView->setColumnHidden(columnId, hidden);
 }
 
 // --------------------------------------------------------------------------

+ 4 - 0
Libs/Widgets/ctkErrorLogWidget.h

@@ -45,6 +45,10 @@ public:
   ctkErrorLogModel* errorLogModel()const;
   void setErrorLogModel(ctkErrorLogModel * newErrorLogModel);
 
+  /// Hide table column identified by /a columnId.
+  /// \sa ctkErrorLogModel::ColumnsIds
+  Q_INVOKABLE void setColumnHidden(int columnId, bool hidden) const;
+
 public Q_SLOTS:
   void setAllEntriesVisible(bool visibility = true);