Showing with 27 additions and 14 deletions.
  1. +14 −9 src/libkstapp/labelitem.cpp
  2. +2 −2 src/libkstapp/labelitem.h
  3. +3 −2 src/libkstapp/vectormodel.cpp
  4. +6 −1 src/libkstapp/viewvectordialog.cpp
  5. +2 −0 src/widgets/dialogdefaults.h
23 changes: 14 additions & 9 deletions src/libkstapp/labelitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ void LabelItem::applyDefaults() {
_color = dialogDefaults().value(defaultsGroupName()+"/color",QColor(Qt::black)).value<QColor>();
_scale = dialogDefaults().value(defaultsGroupName()+"/fontScale",12).toDouble();
_fixleft = dialogDefaults().value(defaultsGroupName()+"/fixLeft",true).toBool();
applyDialogDefaultsStroke();
applyDialogDefaultsFill();
applyDialogDefaultsLockPosToData();
}

Expand Down Expand Up @@ -101,7 +103,6 @@ void LabelItem::generateLabel(QPainter *p) {

Label::Parsed *parsed = Label::parse(_text, _color);
if (parsed) {
//parsed->chunk->attributes.color = _color; // FIXME: this should be set in label::parse!
_dirty = false;
QFont font(_font);

Expand All @@ -118,15 +119,17 @@ void LabelItem::generateLabel(QPainter *p) {
Label::renderLabel(*_labelRc, parsed->chunk, true, false);

_height = _labelRc->fontHeight();
qreal x_margin = _height/8.0;

// Make sure we have a rect for selection, movement, etc
if (_resized) {
_resized = false;
double x0 = rect().x();
double y0 = rect().y();
double x1 = x0 + rect().width();
double y1 = y0 + rect().height();
double w = _labelRc->xMax;
double h = (_labelRc->lines+1) * _height;
double w = _labelRc->xMax + 2*x_margin;
double h = (_labelRc->lines+1) * _height + x_margin;
switch(_activeGrip) {
case TopLeftGrip:
setViewRect(QRectF(x1-w,y1-h,w,h));
Expand All @@ -145,16 +148,15 @@ void LabelItem::generateLabel(QPainter *p) {
}
} else {
if (fixLeft()) {
setViewRect(QRectF(rect().left(), rect().bottom() - (_labelRc->lines+1) * _height,
_labelRc->xMax, (_labelRc->lines+1) * _height),true);
setViewRect(QRectF(rect().left(), rect().bottom() - (_labelRc->lines+1) * _height - x_margin,
_labelRc->xMax+2*x_margin, (_labelRc->lines+1) * _height+x_margin),true);
} else {
setViewRect(QRectF(rect().right()-_labelRc->xMax, rect().bottom() - (_labelRc->lines+1) * _height,
_labelRc->xMax, (_labelRc->lines+1) * _height),true);
setViewRect(QRectF(rect().right()-_labelRc->xMax-2*x_margin, rect().bottom() - (_labelRc->lines+1) * _height - x_margin,
_labelRc->xMax+2*x_margin, (_labelRc->lines+1) * _height + x_margin),true);
}
}
_paintTransform.reset();
_paintTransform.translate(rect().x(), rect().y() + _labelRc->fontAscent());

_paintTransform.translate(rect().x()+x_margin, rect().y() + _labelRc->fontAscent());
connect(_labelRc, SIGNAL(labelDirty()), this, SLOT(setDirty()));
connect(_labelRc, SIGNAL(labelDirty()), this, SLOT(triggerUpdate()));

Expand All @@ -172,6 +174,9 @@ void LabelItem::paint(QPainter *painter) {

if (_labelRc) {
painter->save();
painter->setBrush(brush());
painter->setPen(pen());
painter->drawRect(rect());
painter->setTransform(_paintTransform, true);
Label::paintLabel(*_labelRc, painter);
painter->restore();
Expand Down
4 changes: 2 additions & 2 deletions src/libkstapp/labelitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class LabelItem : public ViewItem {
static QString staticDefaultsGroupName() { return QString("label");}

// for view item dialogs
virtual bool hasStroke() const {return false;}
virtual bool hasBrush() const {return false;}
virtual bool hasStroke() const {return true;}
virtual bool hasBrush() const {return true;}
virtual bool hasFont() const {return true;}

virtual void save(QXmlStreamWriter &xml);
Expand Down
5 changes: 3 additions & 2 deletions src/libkstapp/vectormodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
***************************************************************************/

#include "vectormodel.h"
#include "dialogdefaults.h"

#include <assert.h>

Expand All @@ -33,8 +34,8 @@ bool VectorModel::addVector(VectorPtr v)
if (!_vectorList.contains(v)) {
beginInsertColumns(QModelIndex(), columnCount(), columnCount());
_vectorList.append(v);
// Standard nb of digits after comma: 6
_digitNbList.append(6);
// Standard nb of digits:
_digitNbList.append(dialogDefaults().value("viewvector/digits",12).toInt());
endInsertColumns();
reset();
_rows = rowCount();
Expand Down
7 changes: 6 additions & 1 deletion src/libkstapp/viewvectordialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "editmultiplewidget.h"
#include "updateserver.h"
#include "geticon.h"
#include "dialogdefaults.h"

#include <datacollection.h>
#include <objectstore.h>
Expand Down Expand Up @@ -112,7 +113,7 @@ void ViewVectorDialog::contextMenu(const QPoint& position) {
QMenu* submenu = new QMenu(tr("Significant digits"));
QAction* digitNb0Action = submenu->addAction(tr("Show as int"));
QAction* digitNb3Action = submenu->addAction("3");
QAction* digitNb6Action = submenu->addAction(tr("6 (default)"));
QAction* digitNb6Action = submenu->addAction(tr("6"));
QAction* digitNb12Action = submenu->addAction("12");
QAction* digitNb17Action = submenu->addAction("17");
menu.addMenu(submenu);
Expand All @@ -137,6 +138,9 @@ void ViewVectorDialog::contextMenu(const QPoint& position) {
foreach (int column, selectedColumns()) {
_model->setDigitNumber(column, digits);
}
dialogDefaults().setValue("viewvector/digits", digits);

_vectors->resizeColumnsToContents();
}

void ViewVectorDialog::update()
Expand Down Expand Up @@ -166,6 +170,7 @@ void ViewVectorDialog::addSelected() {
_model->addVector(vector);
}
}
_vectors->resizeColumnsToContents();
}

void ViewVectorDialog::removeSelected() {
Expand Down
2 changes: 2 additions & 0 deletions src/widgets/dialogdefaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,5 @@ namespace Kst {
// wizard/plotCount int datawizard.cpp

// changedatafile/newFileName QString changefiledialog.cpp

// viewvector/digits int vectormodel.cpp, viewvectordialog.cpp