From: konrad Date: Sun, 16 May 2010 09:14:24 +0000 (+0000) Subject: better size for order windows table X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=63cf6978c7f1b19361ca59a810ad260ca43badda;p=web%2Fkonrad%2Fsmoke.git better size for order windows table git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@457 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- diff --git a/src/dialogs/orderwin.cpp b/src/dialogs/orderwin.cpp index 3721f97..aafa586 100644 --- a/src/dialogs/orderwin.cpp +++ b/src/dialogs/orderwin.cpp @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include #include #include @@ -45,6 +47,36 @@ #include +/**helper class that has a more sensible sizeHint than the original QTableView - it tries to make sure the full table is visible*/ +class MOWTableView:public QTableView +{ + public: + MOWTableView() + { + //set a sensible policy + QSizePolicy sp=sizePolicy(); + sp.setVerticalPolicy (QSizePolicy::Expanding); + sp.setHorizontalPolicy(QSizePolicy::Expanding); + setSizePolicy(sp); + //remember absolute maximum + absmax=QDesktopWidget().availableGeometry(this).size()-QSize(50,50); + } + QSize sizeHint()const{ + QSize psz=QTableView::minimumSizeHint(); + QSize vsz=maximumViewportSize()+QSize(50,50); + //get maximum of parents view and viewports view of things + if(psz.width()>vsz.width())vsz.setWidth(psz.width()); + if(psz.height()>vsz.height())vsz.setHeight(psz.height()); + //constrain to absolute maximum + if(absmax.width()setColumnStretch(0,0); gl->setColumnStretch(1,10); - QSize sz=size(); vl->addSpacing(10); - vl->addWidget(m_table=new QTableView,10); + vl->update(); + QSize sz=size();qDebug()<<"size"<addWidget(m_table=new MOWTableView,10); m_table->setModel(m_model=new QStandardItemModel(this)); m_table->setEditTriggers(QAbstractItemView::NoEditTriggers); updateData(); - //make sure everything is visible - QSize vsz=m_table->maximumViewportSize(); - vsz.setWidth(vsz.width()+40); - if(sz.width()