diff --git a/src/common/KReportJsonTrader_p.h b/src/common/KReportJsonTrader_p.h index 2880c601..26d5dd91 100644 --- a/src/common/KReportJsonTrader_p.h +++ b/src/common/KReportJsonTrader_p.h @@ -1,66 +1,66 @@ /* This file is part of the KDE project Copyright (C) 1998, 1999 Torben Weis Copyright 2007 David Faure Copyright (C) 2015 Jarosław Staniek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KREPORTJSONTRADER_P_H #define KREPORTJSONTRADER_P_H #include #include class QPluginLoader; /** * Support class to fetch a list of relevant plugins */ class KReportJsonTrader { public: KReportJsonTrader(); ~KReportJsonTrader(); static KReportJsonTrader *self(); /** * The main function in the KReportJsonTrader class. * * It will return a list of QPluginLoader objects that match your * specifications. The only required parameter is the @a servicetype. * The @a mimetype parameter is used to limit the possible choices * returned based on the constraints you give it. * * The keys used in the query (Type, ServiceType, Exec) are all * fields found in the .desktop files. * * @param servicetype A service type like 'KMyApp/Plugin' or 'KFilePlugin'. * @param mimetype A mimetype constraint to limit the choices returned, QString() to - * get all services of the given @p servicetype. + * get all services of the given @a servicetype. * * @return A list of QPluginLoader that satisfy the query * @see http://techbase.kde.org/Development/Tutorials/Services/Traders#The_KTrader_Query_Language */ QList query(const QString &servicetype, const QString &mimetype = QString()); private: Q_DISABLE_COPY(KReportJsonTrader) class Private; Private * const d; }; #endif diff --git a/src/common/KReportUnit.h b/src/common/KReportUnit.h index 58430d1b..67222b92 100644 --- a/src/common/KReportUnit.h +++ b/src/common/KReportUnit.h @@ -1,344 +1,344 @@ /* This file is part of the KDE project Copyright (C) 1998 1999 Reginald Stadlbauer Copyright (C) 1998 1999 Torben Weis Copyright (C) 2004 Nicolas GOUTTE Copyright (C) 2010 Thomas Zander Copyright (C) 2012 Friedrich W. H. Kossebau Copyright (C) 2017 Jarosław Staniek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KREPORTUNIT_H #define KREPORTUNIT_H #include // for floor #include #include #include #include #include "kreport_export.h" // 1 inch ^= 72 pt // 1 inch ^= 25.399956 mm (-pedantic ;p) // 1 pt = 1/12 pi // 1 pt ^= 0.0077880997 cc // 1 cc = 12 dd // Note: I don't use division but multiplication with the inverse value // because it's faster ;p (Werner) #define POINT_TO_MM(px) qreal((px)*0.352777167) #define MM_TO_POINT(mm) qreal((mm)*2.83465058) #define POINT_TO_CM(px) qreal((px)*0.0352777167) #define CM_TO_POINT(cm) qreal((cm)*28.3465058) #define POINT_TO_DM(px) qreal((px)*0.00352777167) #define DM_TO_POINT(dm) qreal((dm)*283.465058) #define POINT_TO_INCH(px) qreal((px)*0.01388888888889) #define INCH_TO_POINT(inch) qreal((inch)*72.0) #define MM_TO_INCH(mm) qreal((mm)*0.039370147) #define INCH_TO_MM(inch) qreal((inch)*25.399956) #define POINT_TO_PI(px) qreal((px)*0.083333333) #define POINT_TO_CC(px) qreal((px)*0.077880997) #define PI_TO_POINT(pi) qreal((pi)*12) #define CC_TO_POINT(cc) qreal((cc)*12.840103) /*! * @brief Converts between different units * * KReportUnit stores everything in pt (using "qreal") internally. * When displaying a value to the user, the value is converted to the user's unit * of choice, and rounded to a reasonable precision to avoid 0.999999 * * For implementing the selection of a unit type in the UI use the allTypes() method. * it ensure the same order of the unit types in all places, with the order not * bound to the order in the enum so ABI-compatible extension is possible. */ class KREPORT_EXPORT KReportUnit { Q_DECLARE_TR_FUNCTIONS(KReportUnit) public: /** Length units supported by %KReport. */ enum class Type { Invalid, Millimeter, Centimeter, Decimeter, Inch, Pica, Cicero, Point, ///< Postscript point, 1/72th of an Inco Pixel, Last = Pixel ///< internal }; /** * @brief Constructs invalid unit * * @since 3.1 */ KReportUnit(); /** Construct unit with given type and factor. */ explicit KReportUnit(Type type, qreal factor = 1.0); KReportUnit(const KReportUnit &other); ~KReportUnit(); /// Assigns specified type and factor 1.0 to the object /// @param unit Type of unit KReportUnit& operator=(Type type); KReportUnit& operator=(const KReportUnit& other); bool operator!=(const KReportUnit &other) const; bool operator==(const KReportUnit &other) const; /** * @brief Returns true if type of this unit is valid * * @since 3.1 */ bool isValid() const; /** * @brief Returns list of all supported types (without Invalid) * * @since 3.1 */ static QList allTypes(); /** Returns the type of this unit */ KReportUnit::Type type() const; /** * @brief Returns (translated) description string for type of this unit * * @since 3.1 */ QString description() const; /** * @brief Returns (translated) description string for given unit type * * @since 3.1 */ static QString description(KReportUnit::Type type); /** * @brief Returns the list of (translated) description strings for given list of types * * @since 3.1 */ static QStringList descriptions(const QList &types); void setFactor(qreal factor); qreal factor() const; /** * Prepare ptValue to be displayed in pt * This method will round to 0.001 precision */ static inline qreal toPoint(qreal ptValue) { // No conversion, only rounding (to 0.001 precision) return floor(ptValue * 1000.0) / 1000.0; } /** * Prepare ptValue to be displayed in mm * This method will round to 0.0001 precision, use POINT_TO_MM() for lossless conversion. */ static inline qreal toMillimeter(qreal ptValue) { // "mm" values are rounded to 0.0001 millimeters return floor(POINT_TO_MM(ptValue) * 10000.0) / 10000.0; } /** * Prepare ptValue to be displayed in cm * This method will round to 0.0001 precision, use POINT_TO_CM() for lossless conversion. */ static inline qreal toCentimeter(qreal ptValue) { return floor(POINT_TO_CM(ptValue) * 10000.0) / 10000.0; } /** * Prepare ptValue to be displayed in dm * This method will round to 0.0001 precision, use POINT_TO_DM() for lossless conversion. */ static inline qreal toDecimeter(qreal ptValue) { return floor(POINT_TO_DM(ptValue) * 10000.0) / 10000.0; } /** * Prepare ptValue to be displayed in inch * This method will round to 0.00001 precision, use POINT_TO_INCH() for lossless conversion. */ static inline qreal toInch(qreal ptValue) { // "in" values are rounded to 0.00001 inches return floor(POINT_TO_INCH(ptValue) * 100000.0) / 100000.0; } /** * Prepare ptValue to be displayed in pica * This method will round to 0.00001 precision, use POINT_TO_PI() for lossless conversion. */ static inline qreal toPica(qreal ptValue) { // "pi" values are rounded to 0.00001 inches return floor(POINT_TO_PI(ptValue) * 100000.0) / 100000.0; } /** * Prepare ptValue to be displayed in cicero * This method will round to 0.00001 precision, use POINT_TO_CC() for lossless conversion. */ static inline qreal toCicero(qreal ptValue) { // "cc" values are rounded to 0.00001 inches return floor(POINT_TO_CC(ptValue) * 100000.0) / 100000.0; } /** * convert the given value directly from one unit to another with high accuracy */ static qreal convertFromUnitToUnit(qreal value, const KReportUnit &fromUnit, const KReportUnit &toUnit, qreal factor = 1.0); /** * convert the given value directly from one unit to another with high accuracy */ static QPointF convertFromUnitToUnit(const QPointF &value, const KReportUnit &fromUnit, const KReportUnit &toUnit); /** * convert the given value directly from one unit to another with high accuracy */ static QSizeF convertFromUnitToUnit(const QSizeF &value, const KReportUnit &fromUnit, const KReportUnit &toUnit); /** * This method is the one to use to display a value in a dialog - * \return the value @p ptValue converted to unit and rounded, ready to be displayed + * \return the value @a ptValue converted to unit and rounded, ready to be displayed */ qreal toUserValue(qreal ptValue) const; /** - * Convert the value @p ptValue to a given unit @p unit + * Convert the value @a ptValue to a given unit @a unit * Unlike KReportUnit::ptToUnit the return value remains unrounded, so that it can be used in complex calculation * \return the converted value */ static qreal ptToUnit(qreal ptValue, const KReportUnit &unit); /// This method is the one to use to display a value in a dialog - /// @return the value @p ptValue converted the unit and rounded, ready to be displayed + /// @return the value @a ptValue converted the unit and rounded, ready to be displayed QString toUserStringValue(qreal ptValue) const; //! @return the value converted to points with high accuracy qreal convertToPoint(qreal value) const; //! @return the value converted from points to the actual unit with high accuracy qreal convertFromPoint(qreal ptValue) const; //! @return the value converted from points to the actual unit with high accuracy QPointF convertFromPoint(const QPointF &ptValue) const; //! @return the value converted from points to the actual unit with high accuracy QSizeF convertFromPoint(const QSizeF &ptValue) const; //! Equal to convertToPoint(), use convertToPoint() instead for clarity inline qreal fromUserValue(qreal value) const { return convertToPoint(value); } /// @return the value converted to points with high accuracy QPointF convertToPoint(const QPointF &value) const; /// @return the value converted to points with high accuracy QSizeF convertToPoint(const QSizeF &value) const; /// @return the value converted to points with high accuracy /// @param value value entered by the user /// @param ok if set, the pointed bool is set to true if the value could be /// converted to a qreal, and to false otherwise. /// @return the value converted to points for internal use qreal convertToPoint(const QString &value, bool *ok = nullptr) const; //! Equal to convertToPoint(), use convertToPoint() instead for clarity inline qreal fromUserValue(const QString &value, bool *ok = nullptr) const { return convertToPoint(value, ok); } //! Returns the symbol string of given unit type //! Symbol for Invalid type is empty string. static QString symbol(KReportUnit::Type type); //! Returns the symbol string of the unit //! Symbol for Invalid type is empty string. QString symbol() const; /** * Equal to symbol(): returns the symbol string of the unit. */ inline QString toString() const { return symbol(); } /** * @brief Returns a unit symbol string to type * * @param symbol symbol to convert, must be lowercase * @return Invalid type for unsupported symbol * * @since 3.1 */ static KReportUnit::Type symbolToType(const QString &symbol); /** * @brief Returns the list of unit symbols for the given types * * @since 3.1 */ static QStringList symbols(const QList &types); /// Parses common %KReport and ODF values, like "10cm", "5mm" to pt. /// If no unit is specified, pt is assumed. /// @a defaultVal is in Points static qreal parseValue(const QString &value, qreal defaultVal = 0.0); /// parse an angle to its value in degrees /// @a defaultVal is in degrees static qreal parseAngle(const QString &value, qreal defaultVal = 0.0); private: class Private; Private * const d; }; #ifndef QT_NO_DEBUG_STREAM KREPORT_EXPORT QDebug operator<<(QDebug, const KReportUnit &); #endif Q_DECLARE_METATYPE(KReportUnit) #endif diff --git a/src/common/KReportUtils.h b/src/common/KReportUtils.h index 4884d450..46c98b1f 100644 --- a/src/common/KReportUtils.h +++ b/src/common/KReportUtils.h @@ -1,150 +1,152 @@ /* This file is part of the KDE project Copyright (C) 2010-2015 Jarosław Staniek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KREPORTUTILS_H #define KREPORTUTILS_H #include "kreport_export.h" #include #include #include #include class QDomDocument; class QDomElement; class QFont; class QPointF; class KProperty; class KReportTextStyleData; class KReportLineStyle; namespace KReportUtils { KREPORT_EXPORT QString attr(const QDomElement &el, const QString &attrName, const QString &defaultValue = QString()); KREPORT_EXPORT QByteArray attr(const QDomElement &el, const QString &attrName, const QByteArray &defaultValue = QByteArray()); KREPORT_EXPORT bool attr(const QDomElement &el, const QString &attrName, bool defaultValue = false); KREPORT_EXPORT int attr(const QDomElement &el, const QString &attrName, int defaultValue = 0); KREPORT_EXPORT qreal attr(const QDomElement &el, const QString &attrName, qreal defaultValue = 0.0); KREPORT_EXPORT QColor attr(const QDomElement &el, const QString &attrName, const QColor &defaultValue = QColor()); //! @return percent value converted to qreal, e.g. 1.0 for "100%", 0.505 for "50.5%". //! @a defaultValue is returned if there is not "%" suffix or no proper number. KREPORT_EXPORT qreal attrPercent(const QDomElement& el, const QString &attrName, qreal defaultValue = 0.0); //! @return pen style from @a str or @a defaultValue //! Values from ODF 1.2 19.493 style:line-style are also recognized. KREPORT_EXPORT Qt::PenStyle penStyle(const QString &str, Qt::PenStyle defaultValue); //! @return vertical alignment flag from @a str or @a defaultValue KREPORT_EXPORT Qt::Alignment verticalAlignment(const QString &str, Qt::Alignment defaultValue); //! @return horizontal alignment flag from @a str or @a defaultValue KREPORT_EXPORT Qt::Alignment horizontalAlignment(const QString &str, Qt::Alignment defaultValue); //! @return vertical alignment flag name from @a alignment KREPORT_EXPORT QString verticalToString(Qt::Alignment alignment); //! @return horizontal alignment flag from @a alignment KREPORT_EXPORT QString horizontalToString(Qt::Alignment alignment); //! @return name value read from report:name attribute of @a el. //! If the attribute is missing, @a defaultValue is returned. KREPORT_EXPORT QString readNameAttribute( const QDomElement &el, const QString &defaultValue = QString()); //! @return size value read from svg:width and svg:height attributes of @a el. //! If any of the attributes are missing, @a defaultValue is returned. //! @a defaultValue should be specified in Points. KREPORT_EXPORT QSizeF readSizeAttributes( const QDomElement &el, const QSizeF &defaultValue = QSizeF()); //! @return rectangle value read from svg:x, svg:y, svg:width, svg:height attributes of @a el. //! If any of the attributes are missing, @a defaultValue is returned. //! @a defaultValue should be specified in Points. KREPORT_EXPORT QRectF readRectAttributes( const QDomElement &el, const QRectF &defaultValue = QRectF()); //! @return Z index value read from report:z-index attribute of @a el. //! If the attribute is missing @a defaultValue is returned. //! @a defaultValue should be specified in Points. KREPORT_EXPORT qreal readZAttribute(const QDomElement &el, qreal defaultValue = 0.0); //! @return name of section type read from report:section-type attribute of @a el. //! If the attribute is missing, @a defaultValue is returned. KREPORT_EXPORT QString readSectionTypeNameAttribute( const QDomElement &el, const QString &defaultValue = QString()); //! @return percent value for element @a name. If the element is missing, returns @a defaultPercentValue. //! If @a ok is not 0, *ok is set to the result. KREPORT_EXPORT int readPercent(const QDomElement &el, const QString &attrName, int defaultPercentValue, bool *ok); //! Reads all font attributes for element @a el into @a font. //! @todo add unit tests KREPORT_EXPORT void readFontAttributes(const QDomElement& el, QFont* font); //! Writes all attributes of font @a font into element @a el. //! @todo add unit tests KREPORT_EXPORT void writeFontAttributes(QDomElement *el, const QFont &font); - //! Writes attributes for the rect position @p pos, @p siz + //! Writes attributes for the rect position @a pos, @a siz KREPORT_EXPORT void buildXMLRect(QDomElement *entity, const QPointF &pos, const QSizeF &size); - //! Writes attributes for text style @p ts + //! Writes attributes for text style @a ts KREPORT_EXPORT void buildXMLTextStyle(QDomDocument *doc, QDomElement *entity, const KReportTextStyleData &ts); - //! Writes attributes for line style @p ls + //! Writes attributes for line style @a ls KREPORT_EXPORT void buildXMLLineStyle(QDomDocument *doc, QDomElement *entity, const KReportLineStyle &ls); - //! Writes attributes for the property @p p + //! Writes attributes for the property @a p KREPORT_EXPORT void addPropertyAsAttribute(QDomElement* e, KProperty* p); - //! Writes @p attribute to element @p e, @p value is stored in points with unit 'pt' + //! Writes @a attribute to element @a e, @a value is stored in points with unit 'pt' KREPORT_EXPORT void setAttribute(QDomElement *e, const QString &attribute, double value); - //! Writes point @p value as attributes to element @p e + //! Writes point @a value as attributes to element @a e KREPORT_EXPORT void setAttribute(QDomElement *e, const QPointF &value); - //! Writes size @p value as attributes to element @p e + //! Writes size @a value as attributes to element @a e KREPORT_EXPORT void setAttribute(QDomElement *e, const QSizeF &value); - //! Reads attributes from @p elemSource into text style @p ts + //! Writes @a attribute to element @a e, @a value is stored as boolean + KREPORT_EXPORT void setAttribute(QDomElement *e, const QString &attribute, bool value); + + //! Reads attributes from @a elemSource into text style @a ts KREPORT_EXPORT bool parseReportTextStyleData(const QDomElement & elemSource, KReportTextStyleData *ts); - //! Reads attributes from @p elemSource into line style @p ls + //! Reads attributes from @a elemSource into line style @a ls KREPORT_EXPORT bool parseReportLineStyleData(const QDomElement & elemSource, KReportLineStyle *ls); //! @return page size ID for page key (the PPD standard mediaOption keyword, e.g. "A4") //! @note It's an efficient workaround because QPageSize misses this function. KREPORT_EXPORT QPageSize::PageSizeId pageSizeId(const QString &key); //! Like QPageSize::PageSizeId pageSizeId(const QString &key) but returns entire QPageSize object. KREPORT_EXPORT QPageSize pageSize(const QString &key); - } // KReportUtils #endif diff --git a/src/wrtembed/KReportRuler_p.h b/src/wrtembed/KReportRuler_p.h index b5b91aa4..d08a9059 100644 --- a/src/wrtembed/KReportRuler_p.h +++ b/src/wrtembed/KReportRuler_p.h @@ -1,266 +1,268 @@ /* This file is part of the KDE project * Copyright (C) 1998, 1999 Reginald Stadlbauer * Copyright (C) 2006 Peter Simonsson * Copyright (C) 2007 C. Boemann * Copyright (C) 2007 Thomas Zander * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KREPORTRULER_P_H #define KREPORTRULER_P_H #include "KReportUnit.h" #include #include class KReportZoomHandler; /** * Decorator widget to draw a single ruler around a canvas. */ class KReportRuler : public QWidget { Q_OBJECT public: /** - * Creates a ruler with the orientation @p orientation + * Creates a ruler with the orientation @a orientation * @param parent parent widget * @param orientation the orientation of the ruler * @param viewConverter the view converter used to convert from point to pixel */ KReportRuler(QWidget* parent, Qt::Orientation orientation, const KReportZoomHandler &zoomHandler); ~KReportRuler() override; /// For paragraphs each tab definition is represented by this struct. struct Tab { inline Tab(qreal aPosition, QTextOption::TabType aType) : position(aPosition), type(aType) {} inline Tab() : position(0.0), type(QTextOption::LeftTab) {} qreal position; ///< distance in point from the start of the text-shape QTextOption::TabType type; ///< Determine which type is used. }; /// The ruler's unit /// Default is Centimeter. KReportUnit unit() const; /// The length of the ruler in points (pt) qreal rulerLength() const; /// The orientation of the ruler Qt::Orientation orientation() const; /// The start indent of the first line qreal firstLineIndent() const; /// The start indent of the rest of the lines qreal paragraphIndent() const; /// The end indent of all lines qreal endIndent() const; /// The tab chooser widget, which you must put into a layout along with the ruler. /// Returns 0 for vertical rulers, QWidget *tabChooser(); /** * set a list of actions that will be shown in a popup should the user right click on this ruler. * @param popupActionList the list of actions * @see popupActionList() */ void setPopupActionList(const QList &popupActionList); /** * Return the actions list. * @see setPopupActionList() */ QList popupActionList() const; /// reimplemented QSize minimumSizeHint() const override; /// reimplemented QSize sizeHint() const override; class Private; public Q_SLOTS: /// Set the unit of the ruler void setUnit(const KReportUnit &unit); /** Set the offset. Use this function to sync the ruler with * the canvas' position on screen * @param offset The offset in pixels */ void setOffset(int offset); - /// Sets the length of the ruler to @p length in points (pt) + /** + * Sets the length of the ruler to @a length in points (pt) + */ void setRulerLength(qreal length); /** 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 * @param start the start of the range in pt * @param end the end of the range in pt */ void setActiveRange(qreal start, qreal end); /** 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. * @param start the start of the range in pt * @param end the end of the range in pt */ void setOverrideActiveRange(qreal start, qreal end); /** Set the state of the ruler so that it shows everything in right to left mode. * @param isRightToLeft state of right to left mode. Default is false. */ void setRightToLeft(bool isRightToLeft); /** Set if the ruler should show indents as used in textditors. * Set the indents with setFirstLineIndent(), setParagraphIndent(), setEndIndent() . * @param show show indents if true. Default is false. */ void setShowIndents(bool show); /** 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 . * @param indent the value relative to the active range. */ void setFirstLineIndent(qreal indent); /** 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 . * @param indent the value relative to the active range. */ void setParagraphIndent(qreal indent); /** 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 . * @param indent the value relative to the active range. */ void setEndIndent(qreal indent); /** Set whether the ruler should show the current mouse position. * Update the position with updateMouseCoordinate(). * @param show show mouse position if true. Default is false. */ void setShowMousePosition(bool show); /** Update the current position of the mouse pointer, repainting if changed. * The ruler offset will be applied before painting. * @param coordinate Either the x or y coordinate of the mouse depending * of the orientation of the ruler. */ void updateMouseCoordinate(int coordinate); /** * Set whether the ruler should show the selection borders * @param show show selection borders if true, default is false. */ void setShowSelectionBorders(bool show); /** * Update the selection borders * @param first the first selection border in points * @param second the other selection border in points */ void updateSelectionBorders(qreal first, qreal second); /** * Set whether the ruler should show tabs * @param show show selection borders if true, default is false. */ void setShowTabs(bool show); /** * Set whether the tabs is relative to the paragraph indent * @param relative tabs are relative to pragraph indent if true, default is false. */ void setRelativeTabs(bool relative); /** * Update the tabs * @param tabs a list of tabs that is shown on the ruler * @param tabDistance the distance between regular interval tabs */ void updateTabs(const QList &tabs, qreal tabDistance); /*** * Return the list of tabs set on this ruler. */ QList tabs() const; /** * Clear all previously set hotspots. * A hotspot is a position on the ruler that the user can manipulate by dragging. */ void clearHotSpots(); /** * Add or set a hotspot. * A hotspot is a position on the ruler that the user can manipulate by dragging. * @param position the new position of the hotspot. * @param id the unique id for the hotspot. If the id has not been set before, it will be added. */ void setHotSpot(qreal position, int id = -1); /** * Remove a previously set hotspot, returning true if one is actually returned. * @param id the unique id for the hotspot. * A hotspot is a position on the ruler that the user can manipulate by dragging. */ bool removeHotSpot(int id); Q_SIGNALS: /** * emitted when any of the indents is moved by the user. * @param final false until the user releases the mouse. So you can implement live update. */ void indentsChanged(bool final); /** * Emitted when any of the tabs are moved, deleted or inserted by the user. * @param originalTabIndex the index in the list of tabs before the user interaction * started, or -1 if this is a new tab * @param tab the new tab, or zero when the tab has been removed. */ void tabChanged(int originalTabIndex, KReportRuler::Tab *tab); /// emitted when there the user is about to change a tab or hotspot void aboutToChange(); void hotSpotChanged(int id, qreal newPosition); /// emitted when the mouse is drag+released outside the ruler void guideLineCreated(Qt::Orientation orientation, qreal viewPosition); protected: /// reimplemented void paintEvent(QPaintEvent* event) override; /// reimplemented void mousePressEvent(QMouseEvent *ev) override; /// reimplemented void mouseReleaseEvent(QMouseEvent *ev) override; /// reimplemented void mouseMoveEvent(QMouseEvent *ev) override; private: Private * const d; friend class KReportRuler::Private; }; #endif