##// END OF EJS Templates
test better layout calcuation
Michal Klocek -
r2353:f0ebc1456fe5
parent child
Show More
@@ -145,8 +145,8 void HorizontalAxis::updateGeometry()
145
145
146 //label overlap detection
146 //label overlap detection
147 if(labelItem->pos().x() < width ||
147 if(labelItem->pos().x() < width ||
148 labelItem->pos().x() < axisRect.left() ||
148 labelItem->pos().x() < axisRect.left() ||
149 labelItem->pos().x() + rect.width() - 1 > axisRect.right()) {
149 labelItem->pos().x() + rect.width() -1 > axisRect.right()){
150 labelItem->setVisible(false);
150 labelItem->setVisible(false);
151 } else {
151 } else {
152 labelItem->setVisible(true);
152 labelItem->setVisible(true);
@@ -95,31 +95,31 QSizeF ChartValueAxisX::sizeHint(Qt::SizeHint which, const QSizeF &constraint) c
95 qreal width = 0;
95 qreal width = 0;
96 qreal height = 0;
96 qreal height = 0;
97
97
98 int count = 1;
99
100 if(!ticksList.empty()) {
101 count = qMax(ticksList.last().count(),ticksList.first().count());
102 }
103
98
104 switch (which) {
99 switch (which) {
105 case Qt::MinimumSize:{
100 case Qt::MinimumSize: {
106 count = qMin(count,5);
101 if(!ticksList.empty()) {
107 width = fn.averageCharWidth() * count;
102 width = qMax(fn.boundingRect(ticksList.last()).width(),fn.boundingRect(ticksList.first()).width());
108 height = fn.height() + labelPadding();
103 }
109 width = qMax(width,base.width());
104 height = fn.height() + labelPadding();
110 height += base.height();
105 width = qMax(width,base.width());
111 sh = QSizeF(width,height);
106 height += base.height();
112 break;
107 sh = QSizeF(width,height);
113 }
108 break;
114 case Qt::PreferredSize:{
109 }
115 width=fn.averageCharWidth() * count;
110 case Qt::PreferredSize: {
116 height=fn.height()+labelPadding();
111 if(!ticksList.empty()) {
117 width=qMax(width,base.width());
112 foreach(QString label,ticksList) {
118 height+=base.height();
113 width+=fn.boundingRect(label).width();
119 sh = QSizeF(width,height);
114 }
120 break;
115 }
121 }
116 height=fn.height()+labelPadding();
122 default:
117 width=qMax(width,base.width());
118 height+=base.height();
119 sh = QSizeF(width,height);
120 break;
121 }
122 default:
123 break;
123 break;
124 }
124 }
125
125
General Comments 0
You need to be logged in to leave comments. Login now