Back to index

fet  5.18.0
Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes
SparseTableView Class Reference

#include <sparsetableview.h>

Collaboration diagram for SparseTableView:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 SparseTableView ()
void resizeToFit ()
void allTableChanged ()

Public Attributes

SparseItemModel model

Protected Member Functions

void resizeEvent (QResizeEvent *event)

Private Member Functions

int maxHorizontalHeaderSectionSize ()

Private Attributes

QList< int > horizontalSizesUntruncated

Detailed Description

Definition at line 30 of file sparsetableview.h.


Constructor & Destructor Documentation

Definition at line 32 of file sparsetableview.cpp.

                                 : QTableView()
{
       this->setModel(&model);
}

Member Function Documentation

Definition at line 141 of file sparsetableview.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 37 of file sparsetableview.cpp.

{
       return this->width()/3;
}

Here is the caller graph for this function:

void SparseTableView::resizeEvent ( QResizeEvent *  event) [protected]

Definition at line 113 of file sparsetableview.cpp.

{
       QTableView::resizeEvent(event);
       
       //So that if user resizes horizontal header and scroll bar appears, no automatic resize is done.
       if(event){
              if(event->size().width()==event->oldSize().width())
                     return;
       }
       
       //this->itWasResized();
       if(model.columnCount()!=horizontalSizesUntruncated.count()){ //do NOT remove this test, or you will get assertion failed a few lines below, when user clicks "Swap axes".
       //This situation can appear if user clicks "Swap axes", and it is taken care of then, so we can return in this case, safely assuming that the table will be redrawn correctly.
              //cout<<"different sizes"<<endl;
              return;
       }
       assert(model.columnCount()==horizontalSizesUntruncated.count());
       for(int i=0; i<model.columnCount(); i++){
              int size=horizontalSizesUntruncated.at(i);
              
              if(size>maxHorizontalHeaderSectionSize())
                     size=maxHorizontalHeaderSectionSize();
              
              if(this->horizontalHeader()->sectionSize(i)!=size)
                     this->horizontalHeader()->resizeSection(i, size);
       }
}

Here is the call graph for this function:

Definition at line 42 of file sparsetableview.cpp.

{
       QHash<int, int> columnSizes;
       QHash<int, int> rowSizes;
       
       QHashIterator<QPair<int, int>, QString> i(model.items);
       while(i.hasNext()){
              i.next();
              
              QPair<int, int> pair=i.key();
              
              if(this->isRowHidden(pair.first))
                     continue;
              if(this->isColumnHidden(pair.second))
                     continue;
              
              QString str=i.value();
              
              QAbstractItemDelegate* delegate=this->itemDelegate(model.index(pair.first, pair.second));
              
              QSize size=delegate->sizeHint(this->viewOptions(), model.index(pair.first, pair.second));
              
              if(size.width() > columnSizes.value(pair.second, 0))
                     columnSizes.insert(pair.second, size.width());
              if(size.height() > rowSizes.value(pair.first, 0))
                     rowSizes.insert(pair.first, size.height());
       }
       
       horizontalSizesUntruncated.clear();
       
       for(int i=0; i<model.columnCount(); i++){
              int k=columnSizes.value(i, 0);
              if(this->showGrid())
                     k++;
              if(k<this->horizontalHeader()->sectionSizeHint(i))
                     k=this->horizontalHeader()->sectionSizeHint(i);
                     
              //not too wide
              horizontalSizesUntruncated.append(k);
              
              if(k>maxHorizontalHeaderSectionSize()){
                     k=maxHorizontalHeaderSectionSize();
              }
                     
              this->horizontalHeader()->resizeSection(i, k);
       }

       for(int i=0; i<model.rowCount(); i++){
              int k=rowSizes.value(i, 0);
              if(this->showGrid())
                     k++;
              if(k<this->verticalHeader()->sectionSizeHint(i))
                     k=this->verticalHeader()->sectionSizeHint(i);
              this->verticalHeader()->resizeSection(i, k);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 32 of file sparsetableview.h.

Definition at line 37 of file sparsetableview.h.


The documentation for this class was generated from the following files: