#include <QBoxLayout>
#include <QComboBox>
#include <QDateTimeEdit>
+#include <QDebug>
+#include <QDesktopWidget>
#include <QDoubleSpinBox>
#include <QFileDialog>
#include <QGridLayout>
#include <math.h>
+/**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()<vsz.width())vsz.setWidth(absmax.width());
+ if(absmax.height()<vsz.height())vsz.setHeight(absmax.height());
+ qDebug()<<"ret min"<<vsz;
+ return vsz;
+ }
+ private:
+ QSize absmax;
+};
+
MOrderWindow::MOrderWindow(QWidget*par,const MOOrder&o)
:QMainWindow(par),m_order(o)
{
gl->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"<<sz;
+
+ vl->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()<vsz.width())sz.setWidth(vsz.width());
- sz.setHeight(sz.height()+vsz.height()+40);
- //TODO: limit this to the screen size; find a better measure than viewport
- resize(sz);
}
static const int ITEM_TICKET=1;