Krita Source Code Documentation
Loading...
Searching...
No Matches
KoRuler Class Reference

#include <KoRuler.h>

+ Inheritance diagram for KoRuler:

Classes

struct  Tab
 For paragraphs each tab definition is represented by this struct. More...
 

Public Slots

void clearHotSpots ()
 
void createGuideToolConnection (KoCanvasBase *canvas)
 
bool removeHotSpot (int id)
 
void setActiveRange (qreal start, qreal end)
 
void setEndIndent (qreal indent)
 
void setFirstLineIndent (qreal indent)
 
void setHotSpot (qreal position, int id=-1)
 
void setOffset (int offset)
 
void setOverrideActiveRange (qreal start, qreal end)
 
void setParagraphIndent (qreal indent)
 
void setRelativeTabs (bool relative)
 
void setRightToLeft (bool isRightToLeft)
 
void setRulerLength (qreal length)
 Sets the length of the ruler to length in points (pt)
 
void setShowIndents (bool show)
 
void setShowMousePosition (bool show)
 
void setShowSelectionBorders (bool show)
 
void setShowTabs (bool show)
 
void setUnit (const KoUnit &unit)
 Set the unit of the ruler.
 
void setUnitPixelMultiple2 (bool enabled)
 
bool showMousePosition () const
 
QList< Tabtabs () const
 
void updateMouseCoordinate (int coordinate)
 
void updateSelectionBorders (qreal first, qreal second)
 
void updateTabs (const QList< Tab > &tabs, qreal tabDistance)
 

Signals

void aboutToChange ()
 emitted when there the user is about to change a tab or hotspot
 
void guideCreationFinished (Qt::Orientation orientation, const QPoint &globalPos)
 
void guideCreationInProgress (Qt::Orientation orientation, const QPoint &globalPos)
 
void guideLineCreated (Qt::Orientation orientation, qreal viewPosition)
 emitted when the mouse is drag+released outside the ruler
 
void hotSpotChanged (int id, qreal newPosition)
 
void indentsChanged (bool final)
 
void tabChanged (int originalTabIndex, KoRuler::Tab *tab)
 

Public Member Functions

qreal endIndent () const
 The end indent of all lines.
 
qreal firstLineIndent () const
 The start indent of the first line.
 
 KoRuler (QWidget *parent, Qt::Orientation orientation, const KoViewConverter *viewConverter)
 
QSize minimumSizeHint () const override
 reimplemented
 
Qt::Orientation orientation () const
 The orientation of the ruler.
 
qreal paragraphIndent () const
 The start indent of the rest of the lines.
 
QList< QAction * > popupActionList () const
 
qreal rulerLength () const
 The length of the ruler in points (pt)
 
void setPopupActionList (const QList< QAction * > &popupActionList)
 
QSize sizeHint () const override
 reimplemented
 
QWidget * tabChooser ()
 
KoUnit unit () const
 The ruler's unit.
 
 ~KoRuler () override
 

Protected Member Functions

void mouseMoveEvent (QMouseEvent *ev) override
 reimplemented
 
void mousePressEvent (QMouseEvent *ev) override
 reimplemented
 
void mouseReleaseEvent (QMouseEvent *ev) override
 reimplemented
 
void paintEvent (QPaintEvent *event) override
 reimplemented
 

Private Attributes

KoRulerPrivate *const d
 

Friends

class KoRulerPrivate
 

Detailed Description

Decorator widget to draw a single ruler around a canvas.

Definition at line 29 of file KoRuler.h.

Constructor & Destructor Documentation

◆ KoRuler()

KoRuler::KoRuler ( QWidget * parent,
Qt::Orientation orientation,
const KoViewConverter * viewConverter )

Creates a ruler with the orientation orientation

Parameters
parentparent widget
orientationthe orientation of the ruler
viewConverterthe view converter used to convert from point to pixel

Definition at line 826 of file KoRuler.cpp.

827 : QWidget(parent)
828 , d( new KoRulerPrivate( this, viewConverter, orientation) )
829{
830 setMouseTracking( true );
831}
friend class KoRulerPrivate
Definition KoRuler.h:269
KoRulerPrivate *const d
Definition KoRuler.h:268
Qt::Orientation orientation() const
The orientation of the ruler.
Definition KoRuler.cpp:854

◆ ~KoRuler()

KoRuler::~KoRuler ( )
override

Definition at line 833 of file KoRuler.cpp.

834{
835 delete d;
836}

References d.

Member Function Documentation

◆ aboutToChange

void KoRuler::aboutToChange ( )
signal

emitted when there the user is about to change a tab or hotspot

◆ clearHotSpots

void KoRuler::clearHotSpots ( )
slot

Clear all previously set hotspots. A hotspot is a position on the ruler that the user can manipulate by dragging.

Definition at line 1320 of file KoRuler.cpp.

1321{
1322 if (d->hotspots.isEmpty())
1323 return;
1324 d->hotspots.clear();
1325 update();
1326}
QList< HotSpotData > hotspots
Definition KoRuler_p.h:156
bool update(QSpinBox *spinBox)

References d, and KoRulerPrivate::hotspots.

◆ createGuideToolConnection

void KoRuler::createGuideToolConnection ( KoCanvasBase * canvas)
slot

Connect the ruler to a guides tool This allows the user to drag a guide out of the ruler and get in one smooth operation the guide tool to draw and position the guide line.

Parameters
canvasthe canvas that has had the KoToolManager create the tool for previously.

Definition at line 1359 of file KoRuler.cpp.

1360{
1361 Q_ASSERT(canvas);
1362 KoToolBase *tool = KoToolManager::instance()->toolById(canvas, QLatin1String("GuidesTool"));
1363 if (!tool) return; // It's perfectly fine to have no guides tool, we don't have to warn the user about it
1364 connect(this, SIGNAL(guideLineCreated(Qt::Orientation,qreal)),
1365 tool, SLOT(createGuideLine(Qt::Orientation,qreal)));
1366}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void guideLineCreated(Qt::Orientation orientation, qreal viewPosition)
emitted when the mouse is drag+released outside the ruler
KoToolBase * toolById(KoCanvasBase *canvas, const QString &id) const
static KoToolManager * instance()
Return the toolmanager singleton.

References connect(), guideLineCreated(), KoToolManager::instance(), and KoToolManager::toolById().

◆ endIndent()

qreal KoRuler::endIndent ( ) const

The end indent of all lines.

Definition at line 986 of file KoRuler.cpp.

987{
988 return d->endIndent;
989}

References d, and KoRulerPrivate::endIndent.

◆ firstLineIndent()

qreal KoRuler::firstLineIndent ( ) const

The start indent of the first line.

Definition at line 976 of file KoRuler.cpp.

977{
978 return d->firstLineIndent;
979}
qreal firstLineIndent
Definition KoRuler_p.h:139

References d, and KoRulerPrivate::firstLineIndent.

◆ guideCreationFinished

void KoRuler::guideCreationFinished ( Qt::Orientation orientation,
const QPoint & globalPos )
signal

◆ guideCreationInProgress

void KoRuler::guideCreationInProgress ( Qt::Orientation orientation,
const QPoint & globalPos )
signal

◆ guideLineCreated

void KoRuler::guideLineCreated ( Qt::Orientation orientation,
qreal viewPosition )
signal

emitted when the mouse is drag+released outside the ruler

◆ hotSpotChanged

void KoRuler::hotSpotChanged ( int id,
qreal newPosition )
signal

◆ indentsChanged

void KoRuler::indentsChanged ( bool final)
signal

emitted when any of the indents is moved by the user.

Parameters
finalfalse until the user releases the mouse. So you can implement live update.

◆ minimumSizeHint()

QSize KoRuler::minimumSizeHint ( ) const
override

reimplemented

Definition at line 897 of file KoRuler.cpp.

898{
899 return d->paintingStrategy->sizeHint();
900}
PaintingStrategy * paintingStrategy
Definition KoRuler_p.h:179
virtual QSize sizeHint()=0

References d, KoRulerPrivate::paintingStrategy, and PaintingStrategy::sizeHint().

◆ mouseMoveEvent()

void KoRuler::mouseMoveEvent ( QMouseEvent * ev)
overrideprotected

reimplemented

Definition at line 1175 of file KoRuler.cpp.

1176{
1177 QPoint pos = ev->pos();
1178
1180 Q_EMIT guideCreationInProgress(d->orientation, ev->globalPos());
1181 ev->accept();
1182 update();
1183 return;
1184 }
1185
1186 qreal activeLength = d->effectiveActiveRangeEnd() - d->effectiveActiveRangeStart();
1187
1188 switch (d->selected) {
1190 if (d->rightToLeft)
1193 else
1196 if( ! (ev->modifiers() & Qt::ShiftModifier)) {
1199 } else {
1200 if (d->orientation == Qt::Horizontal)
1202 }
1203
1204 Q_EMIT indentsChanged(false);
1205 break;
1207 if (d->rightToLeft)
1210 else
1213 if( ! (ev->modifiers() & Qt::ShiftModifier)) {
1216 } else {
1217 if (d->orientation == Qt::Horizontal)
1219 }
1220
1221 if (d->paragraphIndent + d->endIndent > activeLength)
1222 d->paragraphIndent = activeLength - d->endIndent;
1223 Q_EMIT indentsChanged(false);
1224 break;
1226 if (d->rightToLeft)
1229 else
1231 + d->selectOffset - d->offset);
1232 if (!(ev->modifiers() & Qt::ShiftModifier)) {
1235 } else {
1236 if (d->orientation == Qt::Horizontal)
1238 }
1239
1240 if (d->paragraphIndent + d->endIndent > activeLength)
1241 d->endIndent = activeLength - d->paragraphIndent;
1242 Q_EMIT indentsChanged(false);
1243 break;
1245 d->tabMoved = true;
1246 if (d->currentIndex < 0) { // tab is deleted.
1247 if (ev->pos().y() < height()) { // reinstate it.
1248 d->currentIndex = d->tabs.count();
1249 d->tabs.append(d->deletedTab);
1250 } else {
1251 break;
1252 }
1253 }
1254 if (d->rightToLeft)
1255 d->tabs[d->currentIndex].position = d->effectiveActiveRangeEnd() -
1257 else
1258 d->tabs[d->currentIndex].position = d->viewConverter->viewToDocumentX(pos.x() + d->selectOffset
1260 if (!(ev->modifiers() & Qt::ShiftModifier))
1261 d->tabs[d->currentIndex].position = d->doSnapping(d->tabs[d->currentIndex].position);
1262 if (d->tabs[d->currentIndex].position < 0)
1263 d->tabs[d->currentIndex].position = 0;
1264 if (d->tabs[d->currentIndex].position > activeLength)
1265 d->tabs[d->currentIndex].position = activeLength;
1266
1267 if (ev->pos().y() > height() + OutsideRulerThreshold ) { // moved out of the ruler, delete it.
1268 d->deletedTab = d->tabs.takeAt(d->currentIndex);
1269 d->currentIndex = -1;
1270 // was that a temporary added tab?
1271 if ( d->originalIndex == -1 )
1273 d->orientation == Qt::Horizontal
1274 ? d->viewConverter->viewToDocumentY(ev->pos().y())
1275 : d->viewConverter->viewToDocumentX(ev->pos().x()));
1276 }
1277
1278 d->emitTabChanged();
1279 break;
1281 qreal newPos;
1282 if (d->orientation == Qt::Horizontal)
1283 newPos= d->viewConverter->viewToDocumentX(pos.x() - d->offset);
1284 else
1285 newPos= d->viewConverter->viewToDocumentY(pos.y() - d->offset);
1286 d->hotspots[d->currentIndex].position = newPos;
1287 Q_EMIT hotSpotChanged(d->hotspots[d->currentIndex].id, newPos);
1288 break;
1290 d->mouseCoordinate = (d->orientation == Qt::Horizontal ? pos.x() : pos.y()) - d->offset;
1291 int hotSpotIndex = d->hotSpotIndex(pos);
1292 if (hotSpotIndex >= 0) {
1293 setCursor(QCursor( d->orientation == Qt::Horizontal ? Qt::SplitHCursor : Qt::SplitVCursor ));
1294 break;
1295 }
1296 unsetCursor();
1297
1299 QString text;
1300 switch(selection) {
1301 case KoRulerPrivate::FirstLineIndent: text = i18n("First line indent"); break;
1302 case KoRulerPrivate::ParagraphIndent: text = i18n("Left indent"); break;
1303 case KoRulerPrivate::EndIndent: text = i18n("Right indent"); break;
1305 if (ev->buttons() & Qt::LeftButton) {
1306 if (d->orientation == Qt::Horizontal && ev->pos().y() > height() + OutsideRulerThreshold)
1307 Q_EMIT guideLineCreated(d->orientation, d->viewConverter->viewToDocumentY(ev->pos().y()));
1308 else if (d->orientation == Qt::Vertical && ev->pos().x() > width() + OutsideRulerThreshold)
1309 Q_EMIT guideLineCreated(d->orientation, d->viewConverter->viewToDocumentX(ev->pos().x()));
1310 }
1311 break;
1312 default:
1313 break;
1314 }
1315 setToolTip(text);
1316 }
1317 update();
1318}
static const int OutsideRulerThreshold
Definition KoRuler.cpp:31
int hotSpotIndex(const QPoint &pos)
Definition KoRuler.cpp:784
bool guideCreationStarted
Definition KoRuler_p.h:183
qreal paragraphIndent
Definition KoRuler_p.h:140
qreal effectiveActiveRangeEnd() const
Definition KoRuler.cpp:808
KoRuler::Tab deletedTab
Definition KoRuler_p.h:149
void emitTabChanged()
Definition KoRuler.cpp:817
qreal doSnapping(const qreal value) const
Definition KoRuler.cpp:727
const KoViewConverter *const viewConverter
Definition KoRuler_p.h:122
qreal effectiveActiveRangeStart() const
Definition KoRuler.cpp:799
QList< KoRuler::Tab > tabs
Definition KoRuler_p.h:146
const Qt::Orientation orientation
Definition KoRuler_p.h:121
Selection selectionAtPosition(const QPoint &pos, int *selectOffset=0)
Definition KoRuler.cpp:733
PaintingStrategy * distancesPaintingStrategy
Definition KoRuler_p.h:176
PaintingStrategy * normalPaintingStrategy
Definition KoRuler_p.h:175
Selection selected
Definition KoRuler_p.h:167
void indentsChanged(bool final)
void guideCreationInProgress(Qt::Orientation orientation, const QPoint &globalPos)
void hotSpotChanged(int id, qreal newPosition)
virtual qreal viewToDocumentY(qreal viewY) const
virtual qreal viewToDocumentX(qreal viewX) const

References KoRulerPrivate::currentIndex, d, KoRulerPrivate::deletedTab, KoRulerPrivate::distancesPaintingStrategy, KoRulerPrivate::doSnapping(), KoRulerPrivate::effectiveActiveRangeEnd(), KoRulerPrivate::effectiveActiveRangeStart(), KoRulerPrivate::emitTabChanged(), KoRulerPrivate::endIndent, KoRulerPrivate::EndIndent, KoRulerPrivate::firstLineIndent, KoRulerPrivate::FirstLineIndent, guideCreationInProgress(), KoRulerPrivate::guideCreationStarted, guideLineCreated(), KoRulerPrivate::HotSpot, hotSpotChanged(), KoRulerPrivate::hotSpotIndex(), KoRulerPrivate::hotspots, indentsChanged(), KoRulerPrivate::mouseCoordinate, KoRulerPrivate::None, KoRulerPrivate::normalPaintingStrategy, KoRulerPrivate::offset, KoRulerPrivate::orientation, KoRulerPrivate::originalIndex, OutsideRulerThreshold, KoRulerPrivate::paintingStrategy, KoRulerPrivate::paragraphIndent, KoRulerPrivate::ParagraphIndent, KoRulerPrivate::rightToLeft, KoRulerPrivate::selected, KoRulerPrivate::selectionAtPosition(), KoRulerPrivate::selectOffset, KoRulerPrivate::Tab, KoRulerPrivate::tabMoved, KoRulerPrivate::tabs, KoRulerPrivate::viewConverter, KoViewConverter::viewToDocumentX(), and KoViewConverter::viewToDocumentY().

◆ mousePressEvent()

void KoRuler::mousePressEvent ( QMouseEvent * ev)
overrideprotected

reimplemented

HACK ALERT: We don't need all that indentation stuff in Krita. Just ensure the rulers are created correctly.

Definition at line 1064 of file KoRuler.cpp.

1065{
1066 d->tabMoved = false;
1068 if (ev->button() == Qt::RightButton && !d->popupActions.isEmpty())
1069 QMenu::exec(d->popupActions, ev->globalPos());
1070 if (ev->button() != Qt::LeftButton) {
1071 ev->ignore();
1072 return;
1073 }
1074
1080 d->guideCreationStarted = true;
1081 return;
1082 }
1083
1084 QPoint pos = ev->pos();
1085
1086 if (d->showTabs) {
1087 int i = 0;
1088 int x;
1089 foreach (const Tab & t, d->tabs) {
1090 if (d->rightToLeft) {
1092 - (d->relativeTabs ? d->paragraphIndent : 0) - t.position) + d->offset;
1093 } else {
1095 + (d->relativeTabs ? d->paragraphIndent : 0) + t.position) + d->offset;
1096 }
1097 if (pos.x() >= x-6 && pos.x() <= x+6) {
1099 d->selectOffset = x - pos.x();
1100 d->currentIndex = i;
1101 break;
1102 }
1103 i++;
1104 }
1106 }
1107
1109 d->selected = d->selectionAtPosition(ev->pos(), &d->selectOffset);
1111 int hotSpotIndex = d->hotSpotIndex(ev->pos());
1112 if (hotSpotIndex >= 0) {
1114 update();
1115 }
1116 }
1117
1119 // still haven't found something so let assume the user wants to add a tab
1120 qreal tabpos;
1121 if (d->rightToLeft) {
1122 tabpos = d->viewConverter->viewToDocumentX(pos.x() - d->offset)
1124 } else {
1125 tabpos = d->viewConverter->viewToDocumentX(pos.x() - d->offset)
1127 }
1128 Tab t = {tabpos, d->tabChooser ? d->tabChooser->type() :
1129 d->rightToLeft ? QTextOption::RightTab :
1130 QTextOption::LeftTab};
1131 d->tabs.append(t);
1132 d->selectOffset = 0;
1134 d->currentIndex = d->tabs.count() - 1;
1135 d->originalIndex = -1; // new!
1136 update();
1137 }
1138 if (d->orientation == Qt::Horizontal && (ev->modifiers() & Qt::ShiftModifier) &&
1144
1146 Q_EMIT aboutToChange();
1147}
RulerTabChooser * tabChooser
Definition KoRuler_p.h:172
QList< QAction * > popupActions
Definition KoRuler_p.h:170
void aboutToChange()
emitted when there the user is about to change a tab or hotspot
virtual qreal documentToViewX(qreal documentX) const
QTextOption::TabType type()
Definition KoRuler_p.h:17
@ Tab

References aboutToChange(), KoRulerPrivate::currentIndex, d, KoRulerPrivate::distancesPaintingStrategy, KoViewConverter::documentToViewX(), KoRulerPrivate::effectiveActiveRangeEnd(), KoRulerPrivate::effectiveActiveRangeStart(), KoRulerPrivate::EndIndent, KoRulerPrivate::FirstLineIndent, KoRulerPrivate::guideCreationStarted, KoRulerPrivate::HotSpot, KoRulerPrivate::hotSpotIndex(), KoRulerPrivate::None, KoRulerPrivate::offset, KoRulerPrivate::orientation, KoRulerPrivate::originalIndex, KoRulerPrivate::paintingStrategy, KoRulerPrivate::paragraphIndent, KoRulerPrivate::ParagraphIndent, KoRulerPrivate::popupActions, KoRuler::Tab::position, KoRulerPrivate::relativeTabs, KoRulerPrivate::rightToLeft, KoRulerPrivate::selected, KoRulerPrivate::selectionAtPosition(), KoRulerPrivate::selectOffset, KoRulerPrivate::showTabs, KoRulerPrivate::Tab, KoRulerPrivate::tabChooser, KoRulerPrivate::tabMoved, KoRulerPrivate::tabs, RulerTabChooser::type(), KoRulerPrivate::viewConverter, and KoViewConverter::viewToDocumentX().

◆ mouseReleaseEvent()

void KoRuler::mouseReleaseEvent ( QMouseEvent * ev)
overrideprotected

reimplemented

Definition at line 1149 of file KoRuler.cpp.

1150{
1151 ev->accept();
1153 d->guideCreationStarted = false;
1154 Q_EMIT guideCreationFinished(d->orientation, ev->globalPos());
1155 } else if (d->selected == KoRulerPrivate::Tab) {
1156 if (d->originalIndex >= 0 && !d->tabMoved) {
1157 int type = d->tabs[d->currentIndex].type;
1158 type++;
1159 if (type > 3)
1160 type = 0;
1161 d->tabs[d->currentIndex].type = static_cast<QTextOption::TabType> (type);
1162 update();
1163 }
1164 d->emitTabChanged();
1165 }
1166 else if( d->selected != KoRulerPrivate::None)
1167 Q_EMIT indentsChanged(true);
1168 else
1169 ev->ignore();
1170
1173}
void guideCreationFinished(Qt::Orientation orientation, const QPoint &globalPos)

References KoRulerPrivate::currentIndex, d, KoRulerPrivate::emitTabChanged(), guideCreationFinished(), KoRulerPrivate::guideCreationStarted, indentsChanged(), KoRulerPrivate::None, KoRulerPrivate::normalPaintingStrategy, KoRulerPrivate::orientation, KoRulerPrivate::originalIndex, KoRulerPrivate::paintingStrategy, KoRulerPrivate::selected, KoRulerPrivate::Tab, KoRulerPrivate::tabMoved, and KoRulerPrivate::tabs.

◆ orientation()

Qt::Orientation KoRuler::orientation ( ) const

The orientation of the ruler.

Definition at line 854 of file KoRuler.cpp.

855{
856 return d->orientation;
857}

References d, and KoRulerPrivate::orientation.

◆ paintEvent()

void KoRuler::paintEvent ( QPaintEvent * event)
overrideprotected

reimplemented

Definition at line 871 of file KoRuler.cpp.

872{
873 QPainter painter(this);
874
875 painter.setClipRegion(event->region());
876
877 painter.save();
878 // Add subtle shade to entire widget to separate from neighbors..
879 painter.fillRect(rect(), QColor(0, 0, 0, 24));
880
881 QRectF rectangle = d->paintingStrategy->drawBackground(d, painter);
882 painter.restore();
883
884 painter.save();
885 d->paintingStrategy->drawMeasurements(d, painter, rectangle);
886 painter.restore();
887
888 if (d->showIndents) {
889 painter.save();
890 d->paintingStrategy->drawIndents(d, painter);
891 painter.restore();
892 }
893
894 d->paintingStrategy->drawTabs(d, painter);
895}
virtual void drawTabs(const KoRulerPrivate *ruler, QPainter &painter)=0
virtual QRectF drawBackground(const KoRulerPrivate *ruler, QPainter &painter)=0
virtual void drawIndents(const KoRulerPrivate *ruler, QPainter &painter)=0
virtual void drawMeasurements(const KoRulerPrivate *ruler, QPainter &painter, const QRectF &rectangle)=0

References d, PaintingStrategy::drawBackground(), PaintingStrategy::drawIndents(), PaintingStrategy::drawMeasurements(), PaintingStrategy::drawTabs(), KoRulerPrivate::paintingStrategy, and KoRulerPrivate::showIndents.

◆ paragraphIndent()

qreal KoRuler::paragraphIndent ( ) const

The start indent of the rest of the lines.

Definition at line 981 of file KoRuler.cpp.

982{
983 return d->paragraphIndent;
984}

References d, and KoRulerPrivate::paragraphIndent.

◆ popupActionList()

QList< QAction * > KoRuler::popupActionList ( ) const

Return the actions list.

See also
setPopupActionList()

Definition at line 1059 of file KoRuler.cpp.

1060{
1061 return d->popupActions;
1062}

References d, and KoRulerPrivate::popupActions.

◆ removeHotSpot

bool KoRuler::removeHotSpot ( int id)
slot

Remove a previously set hotspot, returning true if one is actually returned.

Parameters
idthe unique id for the hotspot. A hotspot is a position on the ruler that the user can manipulate by dragging.

Definition at line 1346 of file KoRuler.cpp.

1347{
1349 while(iter != d->hotspots.end()) {
1350 if (iter->id == id) {
1351 d->hotspots.erase(iter);
1352 update();
1353 return true;
1354 }
1355 }
1356 return false;
1357}

References d, and KoRulerPrivate::hotspots.

◆ rulerLength()

qreal KoRuler::rulerLength ( ) const

The length of the ruler in points (pt)

Definition at line 849 of file KoRuler.cpp.

850{
851 return d->rulerLength;
852}
qreal rulerLength
Definition KoRuler_p.h:125

References d, and KoRulerPrivate::rulerLength.

◆ setActiveRange

void KoRuler::setActiveRange ( qreal start,
qreal end )
slot

Set the active range, ie the part of the ruler that is most likely used. set to 0, 0 when there is no longer any active range

Parameters
startthe start of the range in pt
endthe end of the range in pt

Definition at line 907 of file KoRuler.cpp.

908{
909 d->activeRangeStart = start;
910 d->activeRangeEnd = end;
911 update();
912}
qreal activeRangeEnd
Definition KoRuler_p.h:127
qreal activeRangeStart
Definition KoRuler_p.h:126

References KoRulerPrivate::activeRangeEnd, KoRulerPrivate::activeRangeStart, and d.

◆ setEndIndent

void KoRuler::setEndIndent ( qreal indent)
slot

Set the position of the end indent relative to the active range. If Right To left is set the indent is relative to the left side of the active range .

Parameters
indentthe value relative to the active range.

Definition at line 968 of file KoRuler.cpp.

969{
970 d->endIndent = indent;
971 if (d->showIndents) {
972 update();
973 }
974}

References d, KoRulerPrivate::endIndent, and KoRulerPrivate::showIndents.

◆ setFirstLineIndent

void KoRuler::setFirstLineIndent ( qreal indent)
slot

Set the position of the first line start indent relative to the active range. If Right To left is set the indent is relative to the right side of the active range .

Parameters
indentthe value relative to the active range.

Definition at line 952 of file KoRuler.cpp.

953{
954 d->firstLineIndent = indent;
955 if (d->showIndents) {
956 update();
957 }
958}

References d, KoRulerPrivate::firstLineIndent, and KoRulerPrivate::showIndents.

◆ setHotSpot

void KoRuler::setHotSpot ( qreal position,
int id = -1 )
slot

Add or set a hotspot. A hotspot is a position on the ruler that the user can manipulate by dragging.

Parameters
positionthe new position of the hotspot.
idthe unique id for the hotspot. If the id has not been set before, it will be added.

Definition at line 1328 of file KoRuler.cpp.

1329{
1330 uint hotspotCount = d->hotspots.count();
1331 for( uint i = 0; i < hotspotCount; ++i ) {
1333 if (hs.id == id) {
1334 hs.position = position;
1335 update();
1336 return;
1337 }
1338 }
1339 // not there yet, then insert it.
1341 hs.position = position;
1342 hs.id = id;
1343 d->hotspots.append(hs);
1344}
unsigned int uint

References d, KoRulerPrivate::hotspots, KoRulerPrivate::HotSpotData::id, and KoRulerPrivate::HotSpotData::position.

◆ setOffset

void KoRuler::setOffset ( int offset)
slot

Set the offset. Use this function to sync the ruler with the canvas' position on screen

Parameters
offsetThe offset in pixels

Definition at line 859 of file KoRuler.cpp.

860{
861 d->offset = offset;
862 update();
863}

References d, and KoRulerPrivate::offset.

◆ setOverrideActiveRange

void KoRuler::setOverrideActiveRange ( qreal start,
qreal end )
slot

Set the override active range, ie the part of the ruler that is most likely used. set to 0, 0 when there is no longer any active range The override, means that if set it takes precedence over the normal active range.

Parameters
startthe start of the range in pt
endthe end of the range in pt

Definition at line 914 of file KoRuler.cpp.

915{
918 update();
919}
qreal activeOverrideRangeStart
Definition KoRuler_p.h:128
qreal activeOverrideRangeEnd
Definition KoRuler_p.h:129

References KoRulerPrivate::activeOverrideRangeEnd, KoRulerPrivate::activeOverrideRangeStart, and d.

◆ setParagraphIndent

void KoRuler::setParagraphIndent ( qreal indent)
slot

Set the position of the rest of the lines start indent relative to the active range. If Right To left is set the indent is relative to the right side of the active range .

Parameters
indentthe value relative to the active range.

Definition at line 960 of file KoRuler.cpp.

961{
962 d->paragraphIndent = indent;
963 if (d->showIndents) {
964 update();
965 }
966}

References d, KoRulerPrivate::paragraphIndent, and KoRulerPrivate::showIndents.

◆ setPopupActionList()

void KoRuler::setPopupActionList ( const QList< QAction * > & popupActionList)

set a list of actions that will be shown in a popup should the user right click on this ruler.

Parameters
popupActionListthe list of actions
See also
popupActionList()

Definition at line 1054 of file KoRuler.cpp.

1055{
1057}
QList< QAction * > popupActionList() const
Definition KoRuler.cpp:1059

References d, popupActionList(), and KoRulerPrivate::popupActions.

◆ setRelativeTabs

void KoRuler::setRelativeTabs ( bool relative)
slot

Set whether the tabs is relative to the paragraph indent

Parameters
relativetabs are relative to paragraph indent if true, default is false.

Definition at line 1029 of file KoRuler.cpp.

1030{
1031 d->relativeTabs = relative;
1032 if (d->showTabs) {
1033 update();
1034 }
1035}

References d, KoRulerPrivate::relativeTabs, and KoRulerPrivate::showTabs.

◆ setRightToLeft

void KoRuler::setRightToLeft ( bool isRightToLeft)
slot

Set the state of the ruler so that it shows everything in right to left mode.

Parameters
isRightToLeftstate of right to left mode. Default is false.

Definition at line 940 of file KoRuler.cpp.

941{
942 d->rightToLeft = isRightToLeft;
943 update();
944}

References d, and KoRulerPrivate::rightToLeft.

◆ setRulerLength

void KoRuler::setRulerLength ( qreal length)
slot

Sets the length of the ruler to length in points (pt)

Definition at line 865 of file KoRuler.cpp.

866{
868 update();
869}
qreal length(const QPointF &vec)
Definition Ellipse.cc:82

References d, length(), and KoRulerPrivate::rulerLength.

◆ setShowIndents

void KoRuler::setShowIndents ( bool show)
slot

Set if the ruler should show indents as used in text editors. Set the indents with setFirstLineIndent(), setParagraphIndent(), setEndIndent() .

Parameters
showshow indents if true. Default is false.

Definition at line 946 of file KoRuler.cpp.

947{
948 d->showIndents = show;
949 update();
950}

References d, and KoRulerPrivate::showIndents.

◆ setShowMousePosition

void KoRuler::setShowMousePosition ( bool show)
slot

Set whether the ruler should show the current mouse position. Update the position with updateMouseCoordinate().

Parameters
showshow mouse position if true. Default is false.

Definition at line 929 of file KoRuler.cpp.

930{
931 d->showMousePosition = show;
932 update();
933}
int showMousePosition
Definition KoRuler_p.h:132

References d, and KoRulerPrivate::showMousePosition.

◆ setShowSelectionBorders

void KoRuler::setShowSelectionBorders ( bool show)
slot

Set whether the ruler should show the selection borders

Parameters
showshow selection borders if true, default is false.

Definition at line 1001 of file KoRuler.cpp.

1002{
1003 d->showSelectionBorders = show;
1004 update();
1005}
bool showSelectionBorders
Definition KoRuler_p.h:134

References d, and KoRulerPrivate::showSelectionBorders.

◆ setShowTabs

void KoRuler::setShowTabs ( bool show)
slot

Set whether the ruler should show tabs

Parameters
showshow selection borders if true, default is false.

Definition at line 1016 of file KoRuler.cpp.

1017{
1018 if (d->showTabs == show) {
1019 return;
1020 }
1021
1022 d->showTabs = show;
1023 if (d->tabChooser) {
1024 d->tabChooser->setShowTabs(show);
1025 }
1026 update();
1027}
void setShowTabs(bool showTabs)
Definition KoRuler_p.h:18

References d, RulerTabChooser::setShowTabs(), KoRulerPrivate::showTabs, and KoRulerPrivate::tabChooser.

◆ setUnit

void KoRuler::setUnit ( const KoUnit & unit)
slot

Set the unit of the ruler.

Definition at line 843 of file KoRuler.cpp.

844{
845 d->unit = unit;
846 update();
847}
KoUnit unit() const
The ruler's unit.
Definition KoRuler.cpp:838

References d, unit(), and KoRulerPrivate::unit.

◆ setUnitPixelMultiple2

void KoRuler::setUnitPixelMultiple2 ( bool enabled)
slot

Definition at line 1368 of file KoRuler.cpp.

1369{
1370 if (enabled) {
1371 d->pixelStep = 64.0;
1372 }
1373 else {
1374 d->pixelStep = 100.0;
1375 }
1376}

References d, and KoRulerPrivate::pixelStep.

◆ showMousePosition

bool KoRuler::showMousePosition ( ) const
slot
See also
setShowMousePosition

Definition at line 935 of file KoRuler.cpp.

936{
937 return d->showMousePosition;
938}

References d, and KoRulerPrivate::showMousePosition.

◆ sizeHint()

QSize KoRuler::sizeHint ( ) const
override

reimplemented

Definition at line 902 of file KoRuler.cpp.

903{
904 return d->paintingStrategy->sizeHint();
905}

References d, KoRulerPrivate::paintingStrategy, and PaintingStrategy::sizeHint().

◆ tabChanged

void KoRuler::tabChanged ( int originalTabIndex,
KoRuler::Tab * tab )
signal

Emitted when any of the tabs are moved, deleted or inserted by the user.

Parameters
originalTabIndexthe index in the list of tabs before the user interaction started, or -1 if this is a new tab
tabthe new tab, or zero when the tab has been removed.

◆ tabChooser()

QWidget * KoRuler::tabChooser ( )

The tab chooser widget, which you must put into a layout along with the ruler. Returns 0 for vertical rulers,

Definition at line 991 of file KoRuler.cpp.

992{
993 if ((d->tabChooser == 0) && (d->orientation == Qt::Horizontal)) {
994 d->tabChooser = new RulerTabChooser(parentWidget());
996 }
997
998 return d->tabChooser;
999}

References d, KoRulerPrivate::orientation, RulerTabChooser::setShowTabs(), KoRulerPrivate::showTabs, and KoRulerPrivate::tabChooser.

◆ tabs

QList< KoRuler::Tab > KoRuler::tabs ( ) const
slot

Definition at line 1046 of file KoRuler.cpp.

1047{
1048 QList<Tab> answer = d->tabs;
1049 std::sort(answer.begin(), answer.end(), compareTabs);
1050
1051 return answer;
1052}
struct @8 compareTabs

References compareTabs, d, and KoRulerPrivate::tabs.

◆ unit()

KoUnit KoRuler::unit ( ) const

The ruler's unit.

Definition at line 838 of file KoRuler.cpp.

839{
840 return d->unit;
841}

References d, and KoRulerPrivate::unit.

◆ updateMouseCoordinate

void KoRuler::updateMouseCoordinate ( int coordinate)
slot

Update the current position of the mouse pointer, repainting if changed. The ruler offset will be applied before painting.

Parameters
coordinateEither the x or y coordinate of the mouse depending of the orientation of the ruler.

Definition at line 921 of file KoRuler.cpp.

922{
923 if(d->mouseCoordinate == coordinate)
924 return;
925 d->mouseCoordinate = coordinate;
926 update();
927}

References d, and KoRulerPrivate::mouseCoordinate.

◆ updateSelectionBorders

void KoRuler::updateSelectionBorders ( qreal first,
qreal second )
slot

Update the selection borders

Parameters
firstthe first selection border in points
secondthe other selection border in points

Definition at line 1007 of file KoRuler.cpp.

1008{
1009 d->firstSelectionBorder = first;
1010 d->secondSelectionBorder = second;
1011
1013 update();
1014}
qreal firstSelectionBorder
Definition KoRuler_p.h:135
qreal secondSelectionBorder
Definition KoRuler_p.h:136

References d, KoRulerPrivate::firstSelectionBorder, KoRulerPrivate::secondSelectionBorder, and KoRulerPrivate::showSelectionBorders.

◆ updateTabs

void KoRuler::updateTabs ( const QList< Tab > & tabs,
qreal tabDistance )
slot

Update the tabs

Parameters
tabsa list of tabs that is shown on the ruler
tabDistancethe distance between regular interval tabs

Definition at line 1037 of file KoRuler.cpp.

1038{
1039 d->tabs = tabs;
1040 d->tabDistance = tabDistance;
1041 if (d->showTabs) {
1042 update();
1043 }
1044}
qreal tabDistance
Definition KoRuler_p.h:150
QList< Tab > tabs() const
Definition KoRuler.cpp:1046

References d, KoRulerPrivate::showTabs, KoRulerPrivate::tabDistance, tabs(), and KoRulerPrivate::tabs.

Friends And Related Symbol Documentation

◆ KoRulerPrivate

friend class KoRulerPrivate
friend

Definition at line 269 of file KoRuler.h.

Member Data Documentation

◆ d

KoRulerPrivate* const KoRuler::d
private

Definition at line 268 of file KoRuler.h.


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