+void View::on_table_item_clicked(const QModelIndex& index)
+{
+ (void)index;
+
+ // Force repaint, otherwise the new selection isn't shown for some reason
+ table_view_->viewport()->update();
+}
+
+void View::on_table_item_double_clicked(const QModelIndex& index)
+{
+ const Annotation* ann = static_cast<const Annotation*>(index.internalPointer());
+
+ shared_ptr<views::ViewBase> main_view = session_.main_view();
+
+ main_view->focus_on_range(ann->start_sample(), ann->end_sample());
+}
+
+void View::on_table_header_requested(const QPoint& pos)
+{
+ QMenu* menu = new QMenu(this);
+
+ for (int i = 0; i < table_view_->horizontalHeader()->count(); i++) {
+ int column = table_view_->horizontalHeader()->logicalIndex(i);
+
+ const QString title = model_->headerData(column, Qt::Horizontal, Qt::DisplayRole).toString();
+ QAction* action = new QAction(title, this);
+
+ action->setCheckable(true);
+ action->setChecked(!table_view_->horizontalHeader()->isSectionHidden(column));
+ action->setData(column);
+
+ connect(action, SIGNAL(toggled(bool)), this, SLOT(on_table_header_toggled(bool)));
+
+ menu->addAction(action);
+ }
+
+ menu->popup(table_view_->horizontalHeader()->viewport()->mapToGlobal(pos));
+}
+
+void View::on_table_header_toggled(bool checked)
+{
+ QAction* action = qobject_cast<QAction*>(QObject::sender());
+ assert(action);
+
+ const int column = action->data().toInt();
+
+ table_view_->horizontalHeader()->setSectionHidden(column, !checked);
+}
+