SpikeStream Application Library  0.2
NeuronGroupSelectionView.cpp
Go to the documentation of this file.
00001 //SpikeStream includes
00002 #include "NeuronGroupSelectionView.h"
00003 #include "SpikeStreamException.h"
00004 using namespace spikestream;
00005 
00006 //Qt includes
00007 #include <QDebug>
00008 #include <QHeaderView>
00009 
00011 NeuronGroupSelectionView::NeuronGroupSelectionView(QWidget* parent, NeuronGroupSelectionModel* model) : QTableView(parent) {
00012         //Set up the view
00013         setShowGrid(false);
00014         setSelectionMode(QAbstractItemView::NoSelection);
00015         connect(this, SIGNAL(clicked(QModelIndex)), this, SLOT(tableClicked(QModelIndex)));
00016 
00017         //Header click events
00018         this->horizontalHeader()->setClickable(true);
00019         connect(this->horizontalHeader(), SIGNAL(sectionClicked(int)), this, SLOT(headerClicked(int)));
00020 
00021         //Set the model for this view and show it
00022         this->neuronGroupSelectionModel = model;
00023         setModel(model);
00024         show();
00025         resizeHeaders();
00026 }
00027 
00028 
00030 NeuronGroupSelectionView::~NeuronGroupSelectionView(){
00031 }
00032 
00033 
00034 /*--------------------------------------------------------*/
00035 /*-------             PUBLIC METHODS               -------*/
00036 /*--------------------------------------------------------*/
00037 
00040 void NeuronGroupSelectionView::resizeHeaders(){
00041         QHeaderView* hHeader = horizontalHeader();
00042         hHeader->setMinimumSectionSize(10);
00043         hHeader->resizeSection(hHeader->logicalIndex(NeuronGroupSelectionModel::SELECT_COL), 50);
00044         hHeader->resizeSection(hHeader->logicalIndex(NeuronGroupSelectionModel::NAME_COL), 200);
00045         hHeader->resizeSection(hHeader->logicalIndex(NeuronGroupSelectionModel::ID_COL), 50);
00046         hHeader->setDefaultAlignment(Qt::AlignLeft);
00047 }
00048 
00049 
00050 /*--------------------------------------------------------*/
00051 /*-------             PRIVATE SLOTS                -------*/
00052 /*--------------------------------------------------------*/
00053 
00055 void NeuronGroupSelectionView::headerClicked(int column){
00056         if(column == NeuronGroupSelectionModel::SELECT_COL)
00057                 neuronGroupSelectionModel->selectAllOrNone();
00058 }
00059 
00060 
00062 void NeuronGroupSelectionView::tableClicked(QModelIndex index){
00063         model()->setData(index, 0);
00064 }
00065 
00066 
00067 
00068 
 All Classes Files Functions Variables Typedefs Friends Defines