From kde-commits Mon Jun 30 22:47:54 2008 From: Jan Hambrecht Date: Mon, 30 Jun 2008 22:47:54 +0000 To: kde-commits Subject: koffice/libs/main Message-Id: <1214866074.802248.22952.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=121486608517552 SVN commit 826546 by jaham: added color member usewd for painting the guide lines added d-pointer M +41 -14 KoGuidesData.cpp M +13 -5 KoGuidesData.h --- trunk/koffice/libs/main/KoGuidesData.cpp #826545:826546 @@ -23,57 +23,74 @@ #include +class KoGuidesData::Private +{ +public: + Private() : showGuideLines(true), guidesColor( Qt::lightGray ) {} + /// list of positions of horizontal guide lines + QList horzGuideLines; + /// list of positions of vertical guide lines + QList vertGuideLines; + bool showGuideLines; + QColor guidesColor; +}; + KoGuidesData::KoGuidesData() - :m_bShowGuideLines(true) + : d( new Private() ) { } +KoGuidesData::~KoGuidesData() +{ + delete d; +} + void KoGuidesData::setHorizontalGuideLines( const QList &lines ) { - m_hGuideLines = lines; + d->horzGuideLines = lines; } void KoGuidesData::setVerticalGuideLines( const QList &lines ) { - m_vGuideLines = lines; + d->vertGuideLines = lines; } void KoGuidesData::setGuideLines( const QList &horizontalLines, const QList &verticalLines) { - m_hGuideLines = horizontalLines; - m_vGuideLines = verticalLines; + d->horzGuideLines = horizontalLines; + d->vertGuideLines = verticalLines; } void KoGuidesData::addGuideLine( Qt::Orientation o, double pos ) { if ( o == Qt::Horizontal ) { - m_hGuideLines.append( pos ); + d->horzGuideLines.append( pos ); } else { - m_vGuideLines.append( pos ); + d->vertGuideLines.append( pos ); } } bool KoGuidesData::showGuideLines() const { - return m_bShowGuideLines; + return d->showGuideLines; } void KoGuidesData::setShowGuideLines( bool show ) { - m_bShowGuideLines=show; + d->showGuideLines=show; } QList KoGuidesData::horizontalGuideLines() const { - return m_hGuideLines; + return d->horzGuideLines; } QList KoGuidesData::verticalGuideLines() const { - return m_vGuideLines; + return d->vertGuideLines; } void KoGuidesData::paintGuides(QPainter &painter, const KoViewConverter &converter, const QRectF &area) const @@ -81,15 +98,15 @@ if( ! showGuideLines() ) return; - painter.setPen( Qt::lightGray ); /// TODO: make member of guides data? - foreach( double guide, m_hGuideLines ) + painter.setPen( d->guidesColor ); + foreach( double guide, d->horzGuideLines ) { if( guide < area.top() || guide > area.bottom() ) continue; painter.drawLine( converter.documentToView( QPointF( area.left(), guide ) ), converter.documentToView( QPointF( area.right(), guide ) ) ); } - foreach( double guide, m_vGuideLines ) + foreach( double guide, d->vertGuideLines ) { if( guide < area.left() || guide > area.right() ) continue; @@ -97,3 +114,13 @@ converter.documentToView( QPointF( guide, area.bottom() ) ) ); } } + +void KoGuidesData::setGuidesColor( const QColor &color ) +{ + d->guidesColor = color; +} + +QColor KoGuidesData::guidesColor() const +{ + return d->guidesColor; +} --- trunk/koffice/libs/main/KoGuidesData.h #826545:826546 @@ -28,11 +28,13 @@ class QPainter; class KoViewConverter; class QRectF; +class QColor; class KOMAIN_EXPORT KoGuidesData { public: KoGuidesData(); + ~KoGuidesData(); /** * @brief Set the positions of the horizontal and vertical guide lines @@ -88,17 +90,23 @@ */ void paintGuides(QPainter &painter, const KoViewConverter &converter, const QRectF &area) const; + /** + * Sets the color of the guide lines. + * @param color the new guides color + */ + void setGuidesColor( const QColor &color ); + + /// Returns the color of the guide lines. + QColor guidesColor() const; + #if 0 //TODO void saveOasisSettings( KoXmlWriter &settingsWriter ); void loadOasisSettings(const QDomDocument&settingsDoc); #endif private: - /// list of positions of horizontal guide lines - QList m_hGuideLines; - /// list of positions of vertical guide lines - QList m_vGuideLines; - bool m_bShowGuideLines; + class Private; + Private * const d; };