SpikeStream Application Library
0.2
|
00001 #include "TruthTableView.h" 00002 using namespace spikestream; 00003 00004 //Qt includes 00005 #include <QDebug> 00006 #include <QHeaderView> 00007 00008 00010 TruthTableView::TruthTableView(TruthTableModel* model) : QTableView() { 00011 //Set up the view 00012 setShowGrid(false); 00013 setSelectionMode(QAbstractItemView::NoSelection); 00014 00015 //Set the model for this view and show it 00016 truthTableModel = model; 00017 setModel(model); 00018 show(); 00019 00020 //Listen for resize events 00021 connect(model, SIGNAL(modelReset()), this, SLOT(resizeHeaders())); 00022 } 00023 00024 00026 TruthTableView::~TruthTableView(){ 00027 } 00028 00029 00030 /*-------------------------------------------------------------*/ 00031 /*------- PRIVATE SLOTS ------*/ 00032 /*-------------------------------------------------------------*/ 00033 00035 void TruthTableView::resizeHeaders(){ 00036 QHeaderView* hHeader = horizontalHeader(); 00037 00038 //Resize columns 00039 if(truthTableModel->columnCount() > 0){ 00040 for(int i=0; i<truthTableModel->columnCount()-1; ++i) 00041 hHeader->resizeSection(hHeader->logicalIndex(i), 40);//Neuron ID column 00042 hHeader->resizeSection(hHeader->logicalIndex(truthTableModel->columnCount()-1), 50);//Output column 00043 } 00044 00045 hHeader->setDefaultAlignment(Qt::AlignLeft); 00046 } 00047 00048 00049