diff --git a/examples/DesignerWidget.cpp b/examples/DesignerWidget.cpp --- a/examples/DesignerWidget.cpp +++ b/examples/DesignerWidget.cpp @@ -111,7 +111,7 @@ void ReportDesignerWidget::slotDesignerPropertySetChanged() { if (m_propertyEditor) { - m_propertyEditor->changeSet(m_reportDesigner->itemPropertySet()); + m_propertyEditor->changeSet(m_reportDesigner->selectedItemPropertySet()); } } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -58,9 +58,9 @@ wrtembed/KReportDesigner.cpp wrtembed/KReportPropertiesButton.cpp wrtembed/KReportSectionEditor.cpp - wrtembed/KReportRuler.cpp - wrtembed/KReportZoomHandler.cpp - wrtembed/KReportZoomMode.cpp + wrtembed/KReportRuler_p.cpp + wrtembed/KReportZoomHandler_p.cpp + wrtembed/KReportZoomMode_p.cpp items/label/KReportItemLabel.cpp items/label/KReportDesignerItemLabel.cpp @@ -298,10 +298,8 @@ ORIGINAL CAMELCASE RELATIVE wrtembed HEADER_NAMES - KReportZoomMode KReportDesignerSectionDetail KReportDesignerSection - KReportZoomHandler KReportDesignerItemBase KReportDesignerSectionDetailGroup KReportDesignerItemRectBase diff --git a/src/wrtembed/KReportDesigner.h b/src/wrtembed/KReportDesigner.h --- a/src/wrtembed/KReportDesigner.h +++ b/src/wrtembed/KReportDesigner.h @@ -1,7 +1,7 @@ /* This file is part of the KDE project * Copyright (C) 2001-2007 by OpenMFG, LLC * Copyright (C) 2007-2008 by Adam Pigg - * Copyright (C) 2011 Jarosław Staniek + * Copyright (C) 2011-2017 Jarosław Staniek * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -34,7 +34,6 @@ class QGraphicsSceneContextMenuEvent; class QString; -class KReportZoomHandler; class KReportDesignerSectionDetail; class KReportDesignerSection; class KReportUnit; @@ -90,6 +89,13 @@ KReportDesignerSection* section(KReportSectionData::Section) const; /** + @brief Creates new section + @return Pointer to a new report section section object, ownership is transferred to + the caller + */ + KReportDesignerSection* createSection() Q_REQUIRED_RESULT; + + /** @brief Deletes the section specified @param section KReportSectionData::Section enum value of the section to return */ @@ -177,11 +183,6 @@ virtual QSize sizeHint() const; /** - @brief Return a pointer to the zoom handler - */ - KReportZoomHandler* zoomHandler() const; - - /** @brief Return the current unit assigned to the report */ KReportUnit pageUnit() const; @@ -208,13 +209,13 @@ /** @brief Return the property set for the curently selected item */ - KPropertySet* itemPropertySet() const; + KPropertySet* selectedItemPropertySet() const; /** @brief Sets the modified status, defaulting to true for modified @param modified Modified status */ - void setModified(bool = true); + void setModified(bool modified); /** @brief Return a unique name that can be used by the entity diff --git a/src/wrtembed/KReportDesigner.cpp b/src/wrtembed/KReportDesigner.cpp --- a/src/wrtembed/KReportDesigner.cpp +++ b/src/wrtembed/KReportDesigner.cpp @@ -1,7 +1,7 @@ /* This file is part of the KDE project * Copyright (C) 2001-2007 by OpenMFG, LLC * Copyright (C) 2007-2010 by Adam Pigg - * Copyright (C) 2011 Jarosław Staniek + * Copyright (C) 2011-2017 Jarosław Staniek * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,7 +27,7 @@ #include "KReportDesignerSectionDetail.h" #include "KReportDesignerItemLine.h" #include "KReportRuler_p.h" -#include "KReportZoomHandler.h" +#include "KReportZoomHandler_p.h" #include "KReportPageSize.h" #include "KReportUtils_p.h" #include "KReportUtils.h" @@ -96,7 +96,7 @@ int selected_y_offset; MouseAction mouseAction; - QString insertItem; + QString itemToInsert; QList copy_list; QList cut_list; @@ -110,21 +110,18 @@ ~Private() { - delete zoom; - delete sectionData; - delete set; delete dataSource; } QGridLayout *grid; KReportRuler *hruler; - KReportZoomHandler *zoom; + KReportZoomHandler zoomHandler; QVBoxLayout *vboxlayout; KReportPropertiesButton *pageButton; QGraphicsScene *activeScene = nullptr; - ReportWriterSectionData *sectionData; + ReportWriterSectionData sectionData; KReportDesignerSection *reportHeader = nullptr; KReportDesignerSection *pageHeaderFirst = nullptr; @@ -142,8 +139,8 @@ KReportDesignerSectionDetail *detail = nullptr; //Properties - KPropertySet *set; - KPropertySet *itmset; + KPropertySet set; + KPropertySet *itemSet; KProperty *title; KProperty *pageSize; KProperty *orientation; @@ -195,7 +192,6 @@ { KReportPluginManager::self(); // this loads icons early enough - d->sectionData = new ReportWriterSectionData(); createProperties(); createActions(); @@ -212,8 +208,7 @@ d->vboxlayout->setSizeConstraint(QLayout::SetFixedSize); //Create nice rulers - d->zoom = new KReportZoomHandler(); - d->hruler = new KReportRuler(this, Qt::Horizontal, d->zoom); + d->hruler = new KReportRuler(this, Qt::Horizontal, d->zoomHandler); d->pageButton = new KReportPropertiesButton(this); @@ -232,12 +227,12 @@ setLayout(d->grid); connect(d->pageButton, SIGNAL(released()), this, SLOT(slotPageButton_Pressed())); - emit pagePropertyChanged(*d->set); + emit pagePropertyChanged(d->set); - connect(d->set, SIGNAL(propertyChanged(KPropertySet&,KProperty&)), + connect(&d->set, SIGNAL(propertyChanged(KPropertySet&,KProperty&)), this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); - changeSet(d->set); + changeSet(&d->set); } KReportDesigner::~KReportDesigner() @@ -343,7 +338,7 @@ } this->slotPageButton_Pressed(); emit reportDataChanged(); - slotPropertyChanged(*d->set, *d->unit); // set unit for all items + slotPropertyChanged(d->set, *d->unit); // set unit for all items setModified(false); } @@ -499,6 +494,12 @@ } return sec; } + +KReportDesignerSection* KReportDesigner::createSection() +{ + return new KReportDesignerSection(this, d->zoomHandler); +} + void KReportDesigner::removeSection(KReportSectionData::Section s) { KReportDesignerSection* sec = section(s); @@ -563,7 +564,7 @@ if (s > KReportSectionData::ReportHeader) idx++; //kreportDebug() << idx; - KReportDesignerSection *rs = new KReportDesignerSection(this); + KReportDesignerSection *rs = createSection(); d->vboxlayout->insertWidget(idx, rs); switch (s) { @@ -626,7 +627,7 @@ rs->show(); setModified(true); adjustSize(); - emit pagePropertyChanged(*d->set); + emit pagePropertyChanged(d->set); } } @@ -638,14 +639,14 @@ } } -KPropertySet * KReportDesigner::propertySet() const +KPropertySet* KReportDesigner::propertySet() const { - return d->set; + return &d->set; } -KPropertySet* KReportDesigner::itemPropertySet() const +KPropertySet* KReportDesigner::selectedItemPropertySet() const { - return d->itmset; + return d->itemSet; } KReportDataSource *KReportDesigner::reportDataSource() const @@ -668,9 +669,9 @@ return d->modified; } -void KReportDesigner::setModified(bool mod) +void KReportDesigner::setModified(bool modified) { - d->modified = mod; + d->modified = modified; if (d->modified) { emit dirty(); @@ -700,11 +701,10 @@ void KReportDesigner::createProperties() { QStringList keys, strings; - d->set = new KPropertySet; - KReportDesigner::addMetaProperties(d->set, + KReportDesigner::addMetaProperties(&d->set, tr("Report", "Main report element"), QLatin1String("kreport-report-element")); - connect(d->set, SIGNAL(propertyChanged(KPropertySet&,KProperty&)), + connect(&d->set, SIGNAL(propertyChanged(KPropertySet&,KProperty&)), this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); d->title = new KProperty("title", QLatin1String("Report"), tr("Title"), tr("Report Title")); @@ -748,21 +748,21 @@ d->topMargin->setOption("unit", QLatin1String("cm")); d->bottomMargin->setOption("unit", QLatin1String("cm")); - d->set->addProperty(d->title); - d->set->addProperty(d->pageSize); - d->set->addProperty(d->orientation); - d->set->addProperty(d->unit); - d->set->addProperty(d->gridSnap); - d->set->addProperty(d->showGrid); - d->set->addProperty(d->gridDivisions); - d->set->addProperty(d->leftMargin); - d->set->addProperty(d->rightMargin); - d->set->addProperty(d->topMargin); - d->set->addProperty(d->bottomMargin); + d->set.addProperty(d->title); + d->set.addProperty(d->pageSize); + d->set.addProperty(d->orientation); + d->set.addProperty(d->unit); + d->set.addProperty(d->gridSnap); + d->set.addProperty(d->showGrid); + d->set.addProperty(d->gridDivisions); + d->set.addProperty(d->leftMargin); + d->set.addProperty(d->rightMargin); + d->set.addProperty(d->topMargin); + d->set.addProperty(d->bottomMargin); #ifdef KREPORT_SCRIPTING d->script = new KProperty("script", QStringList(), QStringList(), QString(), tr("Object Script")); - d->set->addProperty(d->script); + d->set.addProperty(d->script); #endif // KProperty* _customHeight; @@ -780,12 +780,12 @@ if (p.name() == "page-unit") { d->hruler->setUnit(pageUnit()); - QString newstr = d->set->property("page-unit").value().toString(); + QString newstr = d->set.property("page-unit").value().toString(); - d->set->property("margin-left").setOption("unit", newstr); - d->set->property("margin-right").setOption("unit", newstr); - d->set->property("margin-top").setOption("unit", newstr); - d->set->property("margin-bottom").setOption("unit", newstr); + d->set.property("margin-left").setOption("unit", newstr); + d->set.property("margin-right").setOption("unit", newstr); + d->set.property("margin-top").setOption("unit", newstr); + d->set.property("margin-bottom").setOption("unit", newstr); } } @@ -797,7 +797,7 @@ sl.prepend(QLatin1String("")); d->script->setListData(sl, sl); } - changeSet(d->set); + changeSet(&d->set); #endif } @@ -844,13 +844,16 @@ int KReportDesigner::pageWidthPx() const { - QPageLayout layout = QPageLayout(QPageSize(KReportPageSize::pageSize(d->set->property("page-size").value().toString())), d->set->property("print-orientation").value().toString() == QLatin1String("portrait") ? QPageLayout::Portrait : QPageLayout::Landscape, QMarginsF(0,0,0,0));; + QPageLayout layout = QPageLayout( + QPageSize(KReportPageSize::pageSize(d->set.property("page-size").value().toString())), + d->set.property("print-orientation").value().toString() + == QLatin1String("portrait") ? QPageLayout::Portrait : QPageLayout::Landscape, QMarginsF(0,0,0,0)); QSize pageSizePx = layout.fullRectPixels(KReportPrivate::dpiX()).size(); int width = pageSizePx.width(); - width = width - POINT_TO_INCH(d->set->property("margin-left").value().toDouble()) * KReportPrivate::dpiX(); - width = width - POINT_TO_INCH(d->set->property("margin-right").value().toDouble()) * KReportPrivate::dpiX(); + width = width - POINT_TO_INCH(d->set.property("margin-left").value().toDouble()) * KReportPrivate::dpiX(); + width = width - POINT_TO_INCH(d->set.property("margin-right").value().toDouble()) * KReportPrivate::dpiX(); return width; } @@ -922,7 +925,7 @@ connect(a, SIGNAL(triggered()), this, SLOT(slotEditCopy())); pop.addAction(a); } - if (!d->sectionData->copy_list.isEmpty()) { + if (!d->sectionData.copy_list.isEmpty()) { QAction *a = new QAction(QIcon::fromTheme(QLatin1String("edit-paste")), tr("Paste"), this); connect(a, SIGNAL(triggered()), this, SLOT(slotEditPaste())); pop.addAction(a); @@ -970,18 +973,18 @@ end.setX(v->scene()->width()); } - if (d->sectionData->mouseAction == ReportWriterSectionData::MA_Insert) { + if (d->sectionData.mouseAction == ReportWriterSectionData::MA_Insert) { QGraphicsItem * item = 0; QString classString; QString iconName; - if (d->sectionData->insertItem == QLatin1String("org.kde.kreport.line")) { + if (d->sectionData.itemToInsert == QLatin1String("org.kde.kreport.line")) { item = new KReportDesignerItemLine(v->designer(), v->scene(), pos, end); classString = tr("Line", "Report line element"); iconName = QLatin1String("kreport-line-element"); } else { KReportPluginManager* pluginManager = KReportPluginManager::self(); - KReportPluginInterface *plug = pluginManager->plugin(d->sectionData->insertItem); + KReportPluginInterface *plug = pluginManager->plugin(d->sectionData.itemToInsert); if (plug) { QObject *obj = plug->createDesignerInstance(v->designer(), v->scene(), pos); if (obj) { @@ -1006,12 +1009,12 @@ if (v && v->designer()) { v->designer()->setModified(true); } - emit itemInserted(d->sectionData->insertItem); + emit itemInserted(d->sectionData.itemToInsert); } } - d->sectionData->mouseAction = ReportWriterSectionData::MA_None; - d->sectionData->insertItem.clear(); + d->sectionData.mouseAction = ReportWriterSectionData::MA_None; + d->sectionData.itemToInsert.clear(); unsetSectionCursor(); } } @@ -1028,12 +1031,12 @@ void KReportDesigner::changeSet(KPropertySet *s) { //Set the checked state of the report properties button - if (s == d->set) + if (s == &d->set) d->pageButton->setCheckState(Qt::Checked); else d->pageButton->setCheckState(Qt::Unchecked); - d->itmset = s; + d->itemSet = s; emit propertySetChanged(); } @@ -1044,8 +1047,8 @@ void KReportDesigner::slotItem(const QString &entity) { //kreportDebug() << entity; - d->sectionData->mouseAction = ReportWriterSectionData::MA_Insert; - d->sectionData->insertItem = entity; + d->sectionData.mouseAction = ReportWriterSectionData::MA_Insert; + d->sectionData.itemToInsert = entity; setSectionCursor(QCursor(Qt::CrossCursor)); } @@ -1059,7 +1062,7 @@ QGraphicsScene * scene = item->scene(); delete item; scene->update(); - d->sectionData->mouseAction = ReportWriterSectionData::MA_None; + d->sectionData.mouseAction = ReportWriterSectionData::MA_None; modified = true; } } @@ -1069,8 +1072,8 @@ if weve deleted something in the list should really check if an item is in the list first and remove it. */ - d->sectionData->cut_list.clear(); - d->sectionData->copy_list.clear(); + d->sectionData.cut_list.clear(); + d->sectionData.copy_list.clear(); if (modified) { setModified(true); } @@ -1081,24 +1084,24 @@ if (selectionCount() > 0) { //First delete any items that are curerntly in the list //so as not to leak memory - qDeleteAll(d->sectionData->cut_list); - d->sectionData->cut_list.clear(); + qDeleteAll(d->sectionData.cut_list); + d->sectionData.cut_list.clear(); QGraphicsItem * item = activeScene()->selectedItems().first(); bool modified = false; if (item) { - d->sectionData->copy_list.clear(); + d->sectionData.copy_list.clear(); foreach(QGraphicsItem *item, activeScene()->selectedItems()) { - d->sectionData->cut_list.append(dynamic_cast(item)); - d->sectionData->copy_list.append(dynamic_cast(item)); + d->sectionData.cut_list.append(dynamic_cast(item)); + d->sectionData.copy_list.append(dynamic_cast(item)); } foreach(QGraphicsItem *item, activeScene()->selectedItems()) { activeScene()->removeItem(item); activeScene()->update(); modified = true; } - d->sectionData->selected_x_offset = 10; - d->sectionData->selected_y_offset = 10; + d->sectionData.selected_x_offset = 10; + d->sectionData.selected_y_offset = 10; } if (modified) { setModified(true); @@ -1113,12 +1116,12 @@ QGraphicsItem * item = activeScene()->selectedItems().first(); if (item) { - d->sectionData->copy_list.clear(); + d->sectionData.copy_list.clear(); foreach(QGraphicsItem *item, activeScene()->selectedItems()) { - d->sectionData->copy_list.append(dynamic_cast(item)); + d->sectionData.copy_list.append(dynamic_cast(item)); } - d->sectionData->selected_x_offset = 10; - d->sectionData->selected_y_offset = 10; + d->sectionData.selected_x_offset = 10; + d->sectionData.selected_y_offset = 10; } } @@ -1132,19 +1135,19 @@ { // paste a new item of the copy we have in the specified location - if (!d->sectionData->copy_list.isEmpty()) { + if (!d->sectionData.copy_list.isEmpty()) { QList activeItems = canvas->selectedItems(); QGraphicsItem *activeItem = 0; if (activeItems.count() == 1) { activeItem = activeItems.first(); } canvas->clearSelection(); - d->sectionData->mouseAction = ReportWriterSectionData::MA_None; + d->sectionData.mouseAction = ReportWriterSectionData::MA_None; //! @todo this code sucks :) //! The setPos calls only work AFTER the name has been set ?!?!? - foreach(KReportDesignerItemBase *item, d->sectionData->copy_list) { + foreach(KReportDesignerItemBase *item, d->sectionData.copy_list) { KReportItemBase *obj = dynamic_cast(item); const QString type = obj ? obj->typeName() : QLatin1String("object"); //kreportDebug() << type; @@ -1164,7 +1167,7 @@ pasted_ent->setSelected(true); canvas->addItem(pasted_ent); pasted_ent->show(); - d->sectionData->mouseAction = ReportWriterSectionData::MA_Grab; + d->sectionData.mouseAction = ReportWriterSectionData::MA_Grab; setModified(true); } } @@ -1195,11 +1198,6 @@ update(); } -KReportZoomHandler* KReportDesigner::zoomHandler() const -{ - return d->zoom; -} - QString KReportDesigner::suggestEntityName(const QString &n) const { KReportDesignerSection *sec; diff --git a/src/wrtembed/KReportDesignerSection.h b/src/wrtembed/KReportDesignerSection.h --- a/src/wrtembed/KReportDesignerSection.h +++ b/src/wrtembed/KReportDesignerSection.h @@ -35,6 +35,7 @@ class KProperty; class KReportDesigner; +class KReportZoomHandler; // // Class ReportSection @@ -46,7 +47,6 @@ { Q_OBJECT public: - explicit KReportDesignerSection(KReportDesigner * rptdes); virtual ~KReportDesignerSection(); void setTitle(const QString & s); @@ -70,6 +70,10 @@ protected Q_SLOTS: void slotResizeBarDragged(int delta); +protected: + explicit KReportDesignerSection(KReportDesigner * rptdes, + const KReportZoomHandler &zoomHandler); + private Q_SLOTS: void slotPageOptionsChanged(KPropertySet &); void slotSceneClicked(); @@ -79,6 +83,7 @@ Q_DISABLE_COPY(KReportDesignerSection) class Private; Private * const d; + friend class KReportDesigner; friend class KReportDesignerSectionTitle; }; diff --git a/src/wrtembed/KReportDesignerSection.cpp b/src/wrtembed/KReportDesignerSection.cpp --- a/src/wrtembed/KReportDesignerSection.cpp +++ b/src/wrtembed/KReportDesignerSection.cpp @@ -29,7 +29,7 @@ #include "KReportDesignerItemRectBase.h" #include "KReportDesignerItemLine.h" #include "KReportRuler_p.h" -#include "KReportZoomHandler.h" +#include "KReportZoomHandler_p.h" #include "KReportUtils_p.h" #include "KReportPluginMetaData.h" #include "kreport_debug.h" @@ -97,7 +97,8 @@ }; -KReportDesignerSection::KReportDesignerSection(KReportDesigner * rptdes) +KReportDesignerSection::KReportDesignerSection(KReportDesigner * rptdes, + const KReportZoomHandler &zoomHandler) : QWidget(rptdes) , d(new Private()) { @@ -123,7 +124,7 @@ d->title->setObjectName(QLatin1String("detail")); d->title->setText(tr("Detail")); - d->sectionRuler = new KReportRuler(this, Qt::Vertical, d->reportDesigner->zoomHandler()); + d->sectionRuler = new KReportRuler(this, Qt::Vertical, zoomHandler); d->sectionRuler->setUnit(d->reportDesigner->pageUnit()); d->scene = new KReportDesignerSectionScene(d->reportDesigner->pageWidthPx(), d->dpiY, rptdes); d->scene->setBackgroundBrush(d->sectionData->backgroundColor()); diff --git a/src/wrtembed/KReportDesignerSectionDetail.cpp b/src/wrtembed/KReportDesignerSectionDetail.cpp --- a/src/wrtembed/KReportDesignerSectionDetail.cpp +++ b/src/wrtembed/KReportDesignerSectionDetail.cpp @@ -53,7 +53,7 @@ d->vboxlayout->setSpacing(0); d->vboxlayout->setMargin(0); d->reportDesigner = rptdes; - d->detail = new KReportDesignerSection(rptdes /*, this*/); + d->detail = d->reportDesigner->createSection(); d->vboxlayout->addWidget(d->detail); this->setLayout(d->vboxlayout); diff --git a/src/wrtembed/KReportDesignerSectionDetailGroup.cpp b/src/wrtembed/KReportDesignerSectionDetailGroup.cpp --- a/src/wrtembed/KReportDesignerSectionDetailGroup.cpp +++ b/src/wrtembed/KReportDesignerSectionDetailGroup.cpp @@ -59,8 +59,8 @@ return; } KReportDesigner * rd = rsd->reportDesigner(); - d->groupHeader = new KReportDesignerSection(rd /*, _rsd*/); - d->groupFooter = new KReportDesignerSection(rd /*, _rsd*/); + d->groupHeader = rd->createSection(); + d->groupFooter = rd->createSection(); setGroupHeaderVisible(false); setGroupFooterVisible(false); setColumn(column); diff --git a/src/wrtembed/KReportRuler_p.h b/src/wrtembed/KReportRuler_p.h --- a/src/wrtembed/KReportRuler_p.h +++ b/src/wrtembed/KReportRuler_p.h @@ -28,108 +28,6 @@ #include class KReportZoomHandler; -class KReportRulerPrivate; - -class RulerTabChooser : public QWidget -{ -public: - RulerTabChooser(QWidget *parent) : QWidget(parent), m_type(QTextOption::LeftTab), m_showTabs(false) {} - virtual ~RulerTabChooser() {} - - inline QTextOption::TabType type() {return m_type;} - void setShowTabs(bool showTabs) { if (m_showTabs == showTabs) return; m_showTabs = showTabs; update(); } - void mousePressEvent(QMouseEvent *); - - void paintEvent(QPaintEvent *); - -private: - QTextOption::TabType m_type; - bool m_showTabs :1; -}; - -class PaintingStrategy -{ -public: - /// constructor - PaintingStrategy() {} - /// destructor - virtual ~PaintingStrategy() {} - - /** - * Draw the background of the ruler. - * @param ruler the ruler to draw on. - * @param painter the painter we can paint with. - */ - virtual QRectF drawBackground(const KReportRulerPrivate *ruler, QPainter *painter) = 0; - - /** - * Draw the indicators for text-tabs. - * @param ruler the ruler to draw on. - * @param painter the painter we can paint with. - */ - virtual void drawTabs(const KReportRulerPrivate *ruler, QPainter *painter) = 0; - - /** - * Draw the indicators for the measurements which typically are drawn every [unit]. - * @param ruler the ruler to draw on. - * @param painter the painter we can paint with. - * @param rectangle - */ - virtual void drawMeasurements(const KReportRulerPrivate *ruler, QPainter *painter, const QRectF &rectangle) = 0; - - /** - * Draw the indicators for the indents of a text paragraph - * @param ruler the ruler to draw on. - * @param painter the painter we can paint with. - */ - virtual void drawIndents(const KReportRulerPrivate *ruler, QPainter *painter) = 0; - - /** - *returns the size suggestion for a ruler with this strategy. - */ - virtual QSize sizeHint() = 0; -}; - -class HorizontalPaintingStrategy : public PaintingStrategy -{ -public: - HorizontalPaintingStrategy() : lengthInPixel(1) {} - - virtual QRectF drawBackground(const KReportRulerPrivate *ruler, QPainter *painter); - virtual void drawTabs(const KReportRulerPrivate *ruler, QPainter *painter); - virtual void drawMeasurements(const KReportRulerPrivate *ruler, QPainter *painter, const QRectF &rectangle); - virtual void drawIndents(const KReportRulerPrivate *ruler, QPainter *painter); - virtual QSize sizeHint(); - -private: - qreal lengthInPixel; -}; - -class VerticalPaintingStrategy : public PaintingStrategy -{ -public: - VerticalPaintingStrategy() : lengthInPixel(1) {} - - virtual QRectF drawBackground(const KReportRulerPrivate *ruler, QPainter *painter); - virtual void drawTabs(const KReportRulerPrivate *, QPainter *) {} - virtual void drawMeasurements(const KReportRulerPrivate *ruler, QPainter *painter, const QRectF &rectangle); - virtual void drawIndents(const KReportRulerPrivate *, QPainter *) { } - virtual QSize sizeHint(); - -private: - qreal lengthInPixel; -}; - -class HorizontalDistancesPaintingStrategy : public HorizontalPaintingStrategy -{ -public: - HorizontalDistancesPaintingStrategy() {} - - virtual void drawMeasurements(const KReportRulerPrivate *ruler, QPainter *painter, const QRectF &rectangle); - -private: - void drawDistanceLine(const KReportRulerPrivate *d, QPainter *painter, qreal start, qreal end); -}; /** * Decorator widget to draw a single ruler around a canvas. @@ -144,7 +42,8 @@ * @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* viewConverter); + KReportRuler(QWidget* parent, Qt::Orientation orientation, + const KReportZoomHandler &zoomHandler); ~KReportRuler(); /// For paragraphs each tab definition is represented by this struct. @@ -195,6 +94,8 @@ /// reimplemented virtual QSize sizeHint() const; + class Private; + public Q_SLOTS: /// Set the unit of the ruler void setUnit(const KReportUnit &unit); @@ -357,92 +258,8 @@ virtual void mouseMoveEvent(QMouseEvent *ev); private: - KReportRulerPrivate * const d; - friend class KReportRulerPrivate; -}; - - -class KReportRulerPrivate -{ -public: - KReportRulerPrivate(KReportRuler *parent, const KReportZoomHandler *vc, Qt::Orientation orientation); - ~KReportRulerPrivate(); - - void emitTabChanged(); - - KReportUnit unit; - const Qt::Orientation orientation; - const KReportZoomHandler * const viewConverter; - - int offset; - qreal rulerLength; - qreal activeRangeStart; - qreal activeRangeEnd; - qreal activeOverrideRangeStart; - qreal activeOverrideRangeEnd; - - int mouseCoordinate; - int showMousePosition; - - bool showSelectionBorders; - qreal firstSelectionBorder; - qreal secondSelectionBorder; - - bool showIndents; - qreal firstLineIndent; - qreal paragraphIndent; - qreal endIndent; - - bool showTabs; - bool relativeTabs; - bool tabMoved; // set to true on first move of a selected tab - QList tabs; - int originalIndex; //index of selected tab before we started dragging it. - int currentIndex; //index of selected tab or selected HotSpot - only valid when selected indicates tab or hotspot - KReportRuler::Tab deletedTab; - qreal tabDistance; - - struct HotSpotData { - qreal position; - int id; - }; - QList hotspots; - - bool rightToLeft; - enum Selection { - None, - Tab, - FirstLineIndent, - ParagraphIndent, - EndIndent, - HotSpot - }; - Selection selected; - int selectOffset; - - QList popupActions; - - RulerTabChooser *tabChooser; - - // Cached painting strategies - PaintingStrategy * normalPaintingStrategy; - PaintingStrategy * distancesPaintingStrategy; - - // Current painting strategy - PaintingStrategy * paintingStrategy; - - KReportRuler *ruler; - - qreal numberStepForUnit() const; - /// @return The rounding of value to the nearest multiple of stepValue - qreal doSnapping(qreal value) const; - Selection selectionAtPosition(const QPoint & pos, int *selectOffset = 0); - int hotSpotIndex(const QPoint & pos); - qreal effectiveActiveRangeStart() const; - qreal effectiveActiveRangeEnd() const; - - friend class VerticalPaintingStrategy; - friend class HorizontalPaintingStrategy; + Private * const d; + friend class KReportRuler::Private; }; #endif diff --git a/src/wrtembed/KReportRuler.cpp b/src/wrtembed/KReportRuler_p.cpp rename from src/wrtembed/KReportRuler.cpp rename to src/wrtembed/KReportRuler_p.cpp --- a/src/wrtembed/KReportRuler.cpp +++ b/src/wrtembed/KReportRuler_p.cpp @@ -22,7 +22,7 @@ */ #include "KReportRuler_p.h" -#include "KReportZoomHandler.h" +#include "KReportZoomHandler_p.h" #include #include @@ -37,6 +37,199 @@ static const int quarterStepMarkerLength = 3; static const int measurementTextAboveBelowMargin = 1; +class RulerTabChooser : public QWidget +{ +public: + RulerTabChooser(QWidget *parent) : QWidget(parent), m_type(QTextOption::LeftTab), m_showTabs(false) {} + virtual ~RulerTabChooser() {} + + inline QTextOption::TabType type() {return m_type;} + void setShowTabs(bool showTabs) { if (m_showTabs == showTabs) return; m_showTabs = showTabs; update(); } + void mousePressEvent(QMouseEvent *); + + void paintEvent(QPaintEvent *); + +private: + QTextOption::TabType m_type; + bool m_showTabs :1; +}; + +// ---- + +class PaintingStrategy +{ +public: + /// constructor + PaintingStrategy() {} + /// destructor + virtual ~PaintingStrategy() {} + + /** + * Draw the background of the ruler. + * @param ruler the ruler to draw on. + * @param painter the painter we can paint with. + */ + virtual QRectF drawBackground(const KReportRuler::Private *ruler, QPainter *painter) = 0; + + /** + * Draw the indicators for text-tabs. + * @param ruler the ruler to draw on. + * @param painter the painter we can paint with. + */ + virtual void drawTabs(const KReportRuler::Private *ruler, QPainter *painter) = 0; + + /** + * Draw the indicators for the measurements which typically are drawn every [unit]. + * @param ruler the ruler to draw on. + * @param painter the painter we can paint with. + * @param rectangle + */ + virtual void drawMeasurements(const KReportRuler::Private *ruler, QPainter *painter, const QRectF &rectangle) = 0; + + /** + * Draw the indicators for the indents of a text paragraph + * @param ruler the ruler to draw on. + * @param painter the painter we can paint with. + */ + virtual void drawIndents(const KReportRuler::Private *ruler, QPainter *painter) = 0; + + /** + *returns the size suggestion for a ruler with this strategy. + */ + virtual QSize sizeHint() = 0; +}; + +// ---- + +class HorizontalPaintingStrategy : public PaintingStrategy +{ +public: + HorizontalPaintingStrategy() : lengthInPixel(1) {} + + virtual QRectF drawBackground(const KReportRuler::Private *ruler, QPainter *painter); + virtual void drawTabs(const KReportRuler::Private *ruler, QPainter *painter); + virtual void drawMeasurements(const KReportRuler::Private *ruler, QPainter *painter, const QRectF &rectangle); + virtual void drawIndents(const KReportRuler::Private *ruler, QPainter *painter); + virtual QSize sizeHint(); + +private: + qreal lengthInPixel; +}; + +// ---- + +class VerticalPaintingStrategy : public PaintingStrategy +{ +public: + VerticalPaintingStrategy() : lengthInPixel(1) {} + + virtual QRectF drawBackground(const KReportRuler::Private *ruler, QPainter *painter); + virtual void drawTabs(const KReportRuler::Private *, QPainter *) {} + virtual void drawMeasurements(const KReportRuler::Private *ruler, QPainter *painter, const QRectF &rectangle); + virtual void drawIndents(const KReportRuler::Private *, QPainter *) { } + virtual QSize sizeHint(); + +private: + qreal lengthInPixel; +}; + +class HorizontalDistancesPaintingStrategy : public HorizontalPaintingStrategy +{ +public: + HorizontalDistancesPaintingStrategy() {} + + virtual void drawMeasurements(const KReportRuler::Private *ruler, QPainter *painter, const QRectF &rectangle); + +private: + void drawDistanceLine(const KReportRuler::Private *d, QPainter *painter, qreal start, qreal end); +}; + +// ---- + +class KReportRuler::Private +{ +public: + Private(KReportRuler *parent, const KReportZoomHandler &zoomHandler, Qt::Orientation orientation); + ~Private(); + + void emitTabChanged(); + + KReportUnit unit; + const Qt::Orientation orientation; + const KReportZoomHandler * const viewConverter; + + int offset; + qreal rulerLength; + qreal activeRangeStart; + qreal activeRangeEnd; + qreal activeOverrideRangeStart; + qreal activeOverrideRangeEnd; + + int mouseCoordinate; + int showMousePosition; + + bool showSelectionBorders; + qreal firstSelectionBorder; + qreal secondSelectionBorder; + + bool showIndents; + qreal firstLineIndent; + qreal paragraphIndent; + qreal endIndent; + + bool showTabs; + bool relativeTabs; + bool tabMoved; // set to true on first move of a selected tab + QList tabs; + int originalIndex; //index of selected tab before we started dragging it. + int currentIndex; //index of selected tab or selected HotSpot - only valid when selected indicates tab or hotspot + KReportRuler::Tab deletedTab; + qreal tabDistance; + + struct HotSpotData { + qreal position; + int id; + }; + QList hotspots; + + bool rightToLeft; + enum Selection { + None, + Tab, + FirstLineIndent, + ParagraphIndent, + EndIndent, + HotSpot + }; + Selection selected; + int selectOffset; + + QList popupActions; + + RulerTabChooser *tabChooser; + + // Cached painting strategies + PaintingStrategy * normalPaintingStrategy; + PaintingStrategy * distancesPaintingStrategy; + + // Current painting strategy + PaintingStrategy * paintingStrategy; + + KReportRuler *ruler; + + qreal numberStepForUnit() const; + /// @return The rounding of value to the nearest multiple of stepValue + qreal doSnapping(qreal value) const; + Selection selectionAtPosition(const QPoint & pos, int *selectOffset = 0); + int hotSpotIndex(const QPoint & pos); + qreal effectiveActiveRangeStart() const; + qreal effectiveActiveRangeEnd() const; + + friend class VerticalPaintingStrategy; + friend class HorizontalPaintingStrategy; +}; + +// ---- void RulerTabChooser::mousePressEvent(QMouseEvent *) { @@ -114,7 +307,7 @@ return tab1.position < tab2.position; } -QRectF HorizontalPaintingStrategy::drawBackground(const KReportRulerPrivate *d, QPainter *painter) +QRectF HorizontalPaintingStrategy::drawBackground(const KReportRuler::Private *d, QPainter *painter) { lengthInPixel = d->viewConverter->documentToViewX(d->rulerLength); QRectF rectangle; @@ -153,7 +346,7 @@ return rectangle; } -void HorizontalPaintingStrategy::drawTabs(const KReportRulerPrivate *d, QPainter *painter) +void HorizontalPaintingStrategy::drawTabs(const KReportRuler::Private *d, QPainter *painter) { if (! d->showTabs) return; @@ -241,7 +434,7 @@ } } -void HorizontalPaintingStrategy::drawMeasurements(const KReportRulerPrivate *d, QPainter *painter, const QRectF &rectangle) +void HorizontalPaintingStrategy::drawMeasurements(const KReportRuler::Private *d, QPainter *painter, const QRectF &rectangle) { qreal numberStep = d->numberStepForUnit(); // number step in unit // QRectF activeRangeRectangle; @@ -359,19 +552,19 @@ // Draw the mouse indicator const int mouseCoord = d->mouseCoordinate - start; - if (d->selected == KReportRulerPrivate::None || d->selected == KReportRulerPrivate::HotSpot) { + if (d->selected == KReportRuler::Private::None || d->selected == KReportRuler::Private::HotSpot) { const qreal top = rectangle.y() + 1; const qreal bottom = rectangle.bottom() -1; - if (d->selected == KReportRulerPrivate::None && d->showMousePosition && mouseCoord > 0 && mouseCoord < rectangle.width() ) + if (d->selected == KReportRuler::Private::None && d->showMousePosition && mouseCoord > 0 && mouseCoord < rectangle.width() ) painter->drawLine(QPointF(mouseCoord, top), QPointF(mouseCoord, bottom)); - foreach (const KReportRulerPrivate::HotSpotData & hp, d->hotspots) { + foreach (const KReportRuler::Private::HotSpotData & hp, d->hotspots) { const qreal x = d->viewConverter->documentToViewX(hp.position) + d->offset; painter->drawLine(QPointF(x, top), QPointF(x, bottom)); } } } -void HorizontalPaintingStrategy::drawIndents(const KReportRulerPrivate *d, QPainter *painter) +void HorizontalPaintingStrategy::drawIndents(const KReportRuler::Private *d, QPainter *painter) { QPolygonF polygon; @@ -429,7 +622,7 @@ return QSize(0, minimum); } -QRectF VerticalPaintingStrategy::drawBackground(const KReportRulerPrivate *d, QPainter *painter) +QRectF VerticalPaintingStrategy::drawBackground(const KReportRuler::Private *d, QPainter *painter) { lengthInPixel = d->viewConverter->documentToViewY(d->rulerLength); QRectF rectangle; @@ -469,7 +662,7 @@ return rectangle; } -void VerticalPaintingStrategy::drawMeasurements(const KReportRulerPrivate *d, QPainter *painter, const QRectF &rectangle) +void VerticalPaintingStrategy::drawMeasurements(const KReportRuler::Private *d, QPainter *painter, const QRectF &rectangle) { qreal numberStep = d->numberStepForUnit(); // number step in unit int numberStepPixel = qRound(d->viewConverter->documentToViewY( d->unit.fromUserValue(numberStep))); @@ -570,12 +763,12 @@ // Draw the mouse indicator const int mouseCoord = d->mouseCoordinate - start; - if (d->selected == KReportRulerPrivate::None || d->selected == KReportRulerPrivate::HotSpot) { + if (d->selected == KReportRuler::Private::None || d->selected == KReportRuler::Private::HotSpot) { const qreal left = rectangle.left() + 1; const qreal right = rectangle.right() -1; - if (d->selected == KReportRulerPrivate::None && d->showMousePosition && mouseCoord > 0 && mouseCoord < rectangle.height() ) + if (d->selected == KReportRuler::Private::None && d->showMousePosition && mouseCoord > 0 && mouseCoord < rectangle.height() ) painter->drawLine(QPointF(left, mouseCoord), QPointF(right, mouseCoord)); - foreach (const KReportRulerPrivate::HotSpotData & hp, d->hotspots) { + foreach (const KReportRuler::Private::HotSpotData & hp, d->hotspots) { const qreal y = d->viewConverter->documentToViewY(hp.position) + d->offset; painter->drawLine(QPointF(left, y), QPointF(right, y)); } @@ -593,7 +786,7 @@ } -void HorizontalDistancesPaintingStrategy::drawDistanceLine(const KReportRulerPrivate *d, +void HorizontalDistancesPaintingStrategy::drawDistanceLine(const KReportRuler::Private *d, QPainter *painter, qreal start, qreal end) { @@ -642,7 +835,7 @@ painter->restore(); } -void HorizontalDistancesPaintingStrategy::drawMeasurements(const KReportRulerPrivate *d, +void HorizontalDistancesPaintingStrategy::drawMeasurements(const KReportRuler::Private *d, QPainter *painter, const QRectF&) { QList points; @@ -662,10 +855,11 @@ } } -KReportRulerPrivate::KReportRulerPrivate(KReportRuler *parent, const KReportZoomHandler *vc, Qt::Orientation o) +KReportRuler::Private::Private(KReportRuler *parent, + const KReportZoomHandler &zoomHandler, Qt::Orientation o) : unit(KReportUnit(KReportUnit::Point)), orientation(o), - viewConverter(vc), + viewConverter(&zoomHandler), offset(0), rulerLength(0), activeRangeStart(0), @@ -699,13 +893,13 @@ { } -KReportRulerPrivate::~KReportRulerPrivate() +KReportRuler::Private::~Private() { delete normalPaintingStrategy; delete distancesPaintingStrategy; } -qreal KReportRulerPrivate::numberStepForUnit() const +qreal KReportRuler::Private::numberStepForUnit() const { switch(unit.type()) { case KReportUnit::Inch: @@ -722,64 +916,64 @@ } } -qreal KReportRulerPrivate::doSnapping(qreal value) const +qreal KReportRuler::Private::doSnapping(qreal value) const { qreal numberStep = unit.fromUserValue(numberStepForUnit()/4.0); return numberStep * qRound(value / numberStep); } -KReportRulerPrivate::Selection KReportRulerPrivate::selectionAtPosition(const QPoint & pos, int *selectOffset ) +KReportRuler::Private::Selection KReportRuler::Private::selectionAtPosition(const QPoint & pos, int *selectOffset ) { const int height = ruler->height(); if (rightToLeft) { int x = int(viewConverter->documentToViewX(effectiveActiveRangeEnd() - firstLineIndent - paragraphIndent) + offset); if (pos.x() >= x - 8 && pos.x() <= x +8 && pos.y() < height / 2) { if (selectOffset) *selectOffset = x - pos.x(); - return KReportRulerPrivate::FirstLineIndent; + return KReportRuler::Private::FirstLineIndent; } x = int(viewConverter->documentToViewX(effectiveActiveRangeEnd() - paragraphIndent) + offset); if (pos.x() >= x - 8 && pos.x() <= x +8 && pos.y() > height / 2) { if (selectOffset) *selectOffset = x - pos.x(); - return KReportRulerPrivate::ParagraphIndent; + return KReportRuler::Private::ParagraphIndent; } x = int(viewConverter->documentToViewX(effectiveActiveRangeStart() + endIndent) + offset); if (pos.x() >= x - 8 && pos.x() <= x + 8) { if (selectOffset) *selectOffset = x - pos.x(); - return KReportRulerPrivate::EndIndent; + return KReportRuler::Private::EndIndent; } } else { int x = int(viewConverter->documentToViewX(effectiveActiveRangeStart() + firstLineIndent + paragraphIndent) + offset); if (pos.x() >= x -8 && pos.x() <= x + 8 && pos.y() < height / 2) { if (selectOffset) *selectOffset = x - pos.x(); - return KReportRulerPrivate::FirstLineIndent; + return KReportRuler::Private::FirstLineIndent; } x = int(viewConverter->documentToViewX(effectiveActiveRangeStart() + paragraphIndent) + offset); if (pos.x() >= x - 8 && pos.x() <= x + 8 && pos.y() > height/2) { if (selectOffset) *selectOffset = x - pos.x(); - return KReportRulerPrivate::ParagraphIndent; + return KReportRuler::Private::ParagraphIndent; } x = int(viewConverter->documentToViewX(effectiveActiveRangeEnd() - endIndent) + offset); if (pos.x() >= x - 8 && pos.x() <= x + 8) { if (selectOffset) *selectOffset = x - pos.x(); - return KReportRulerPrivate::EndIndent; + return KReportRuler::Private::EndIndent; } } - return KReportRulerPrivate::None; + return KReportRuler::Private::None; } -int KReportRulerPrivate::hotSpotIndex(const QPoint & pos) +int KReportRuler::Private::hotSpotIndex(const QPoint & pos) { for(int counter = 0; counter < hotspots.count(); counter++) { bool hit; @@ -794,36 +988,37 @@ return -1; } -qreal KReportRulerPrivate::effectiveActiveRangeStart() const +qreal KReportRuler::Private::effectiveActiveRangeStart() const { if (activeOverrideRangeStart != activeOverrideRangeEnd) { return activeOverrideRangeStart; } else { return activeRangeStart; } } -qreal KReportRulerPrivate::effectiveActiveRangeEnd() const +qreal KReportRuler::Private::effectiveActiveRangeEnd() const { if (activeOverrideRangeStart != activeOverrideRangeEnd) { return activeOverrideRangeEnd; } else { return activeRangeEnd; } } -void KReportRulerPrivate::emitTabChanged() +void KReportRuler::Private::emitTabChanged() { KReportRuler::Tab tab; if (currentIndex >= 0) tab = tabs[currentIndex]; emit ruler->tabChanged(originalIndex, currentIndex >= 0 ? &tab : 0); } -KReportRuler::KReportRuler(QWidget* parent, Qt::Orientation orientation, const KReportZoomHandler* viewConverter) +KReportRuler::KReportRuler(QWidget* parent, Qt::Orientation orientation, + const KReportZoomHandler &zoomHandler) : QWidget(parent) - , d( new KReportRulerPrivate( this, viewConverter, orientation) ) + , d(new KReportRuler::Private(this, zoomHandler, orientation)) { setMouseTracking( true ); } @@ -1049,7 +1244,7 @@ void KReportRuler::mousePressEvent ( QMouseEvent* ev ) { d->tabMoved = false; - d->selected = KReportRulerPrivate::None; + d->selected = KReportRuler::Private::None; if (ev->button() == Qt::RightButton && !d->popupActions.isEmpty()) QMenu::exec(d->popupActions, ev->globalPos()); if (ev->button() != Qt::LeftButton) { @@ -1071,7 +1266,7 @@ + (d->relativeTabs ? d->paragraphIndent : 0) + t.position) + d->offset; } if (pos.x() >= x-6 && pos.x() <= x+6) { - d->selected = KReportRulerPrivate::Tab; + d->selected = KReportRuler::Private::Tab; d->selectOffset = x - pos.x(); d->currentIndex = i; break; @@ -1081,17 +1276,17 @@ d->originalIndex = d->currentIndex; } - if (d->selected == KReportRulerPrivate::None) + if (d->selected == KReportRuler::Private::None) d->selected = d->selectionAtPosition(ev->pos(), &d->selectOffset); - if (d->selected == KReportRulerPrivate::None) { + if (d->selected == KReportRuler::Private::None) { int hotSpotIndex = d->hotSpotIndex(ev->pos()); if (hotSpotIndex >= 0) { - d->selected = KReportRulerPrivate::HotSpot; + d->selected = KReportRuler::Private::HotSpot; update(); } } - if (d->showTabs && d->selected == KReportRulerPrivate::None) { + if (d->showTabs && d->selected == KReportRuler::Private::None) { // still haven't found something so let assume the user wants to add a tab qreal tabpos; if (d->rightToLeft) { @@ -1106,26 +1301,26 @@ QTextOption::LeftTab); d->tabs.append(t); d->selectOffset = 0; - d->selected = KReportRulerPrivate::Tab; + d->selected = KReportRuler::Private::Tab; d->currentIndex = d->tabs.count() - 1; d->originalIndex = -1; // new! update(); } if (d->orientation == Qt::Horizontal && (ev->modifiers() & Qt::ShiftModifier) && - (d->selected == KReportRulerPrivate::FirstLineIndent || - d->selected == KReportRulerPrivate::ParagraphIndent || - d->selected == KReportRulerPrivate::Tab || - d->selected == KReportRulerPrivate::EndIndent)) + (d->selected == KReportRuler::Private::FirstLineIndent || + d->selected == KReportRuler::Private::ParagraphIndent || + d->selected == KReportRuler::Private::Tab || + d->selected == KReportRuler::Private::EndIndent)) d->paintingStrategy = d->distancesPaintingStrategy; - if (d->selected != KReportRulerPrivate::None) + if (d->selected != KReportRuler::Private::None) emit aboutToChange(); } void KReportRuler::mouseReleaseEvent ( QMouseEvent* ev ) { ev->accept(); - if (d->selected == KReportRulerPrivate::Tab) { + if (d->selected == KReportRuler::Private::Tab) { if (d->originalIndex >= 0 && !d->tabMoved) { int type = d->tabs[d->currentIndex].type; type++; @@ -1136,13 +1331,13 @@ } d->emitTabChanged(); } - else if( d->selected != KReportRulerPrivate::None) + else if( d->selected != KReportRuler::Private::None) emit indentsChanged(true); else ev->ignore(); d->paintingStrategy = d->normalPaintingStrategy; - d->selected = KReportRulerPrivate::None; + d->selected = KReportRuler::Private::None; } void KReportRuler::mouseMoveEvent ( QMouseEvent* ev ) @@ -1152,7 +1347,7 @@ qreal activeLength = d->effectiveActiveRangeEnd() - d->effectiveActiveRangeStart(); switch (d->selected) { - case KReportRulerPrivate::FirstLineIndent: + case KReportRuler::Private::FirstLineIndent: if (d->rightToLeft) d->firstLineIndent = d->effectiveActiveRangeEnd() - d->paragraphIndent - d->viewConverter->viewToDocumentX(pos.x() + d->selectOffset - d->offset); @@ -1169,7 +1364,7 @@ emit indentsChanged(false); break; - case KReportRulerPrivate::ParagraphIndent: + case KReportRuler::Private::ParagraphIndent: if (d->rightToLeft) d->paragraphIndent = d->effectiveActiveRangeEnd() - d->viewConverter->viewToDocumentX(pos.x() + d->selectOffset - d->offset); @@ -1188,7 +1383,7 @@ d->paragraphIndent = activeLength - d->endIndent; emit indentsChanged(false); break; - case KReportRulerPrivate::EndIndent: + case KReportRuler::Private::EndIndent: if (d->rightToLeft) d->endIndent = d->viewConverter->viewToDocumentX(pos.x() + d->selectOffset - d->offset) - d->effectiveActiveRangeStart(); @@ -1207,7 +1402,7 @@ d->endIndent = activeLength - d->paragraphIndent; emit indentsChanged(false); break; - case KReportRulerPrivate::Tab: + case KReportRuler::Private::Tab: d->tabMoved = true; if (d->currentIndex < 0) { // tab is deleted. if (ev->pos().y() < height()) { // reinstante it. @@ -1243,31 +1438,31 @@ d->emitTabChanged(); break; - case KReportRulerPrivate::HotSpot: + case KReportRuler::Private::HotSpot: qreal newPos; if (d->orientation == Qt::Horizontal) newPos= d->viewConverter->viewToDocumentX(pos.x() - d->offset); else newPos= d->viewConverter->viewToDocumentY(pos.y() - d->offset); d->hotspots[d->currentIndex].position = newPos; emit hotSpotChanged(d->hotspots[d->currentIndex].id, newPos); break; - case KReportRulerPrivate::None: + case KReportRuler::Private::None: d->mouseCoordinate = (d->orientation == Qt::Horizontal ? pos.x() : pos.y()) - d->offset; int hotSpotIndex = d->hotSpotIndex(pos); if (hotSpotIndex >= 0) { setCursor(QCursor( d->orientation == Qt::Horizontal ? Qt::SplitHCursor : Qt::SplitVCursor )); break; } unsetCursor(); - KReportRulerPrivate::Selection selection = d->selectionAtPosition(pos); + KReportRuler::Private::Selection selection = d->selectionAtPosition(pos); QString text; switch(selection) { - case KReportRulerPrivate::FirstLineIndent: text = tr("First line indent"); break; - case KReportRulerPrivate::ParagraphIndent: text = tr("Left indent"); break; - case KReportRulerPrivate::EndIndent: text = tr("Right indent"); break; - case KReportRulerPrivate::None: + case KReportRuler::Private::FirstLineIndent: text = tr("First line indent"); break; + case KReportRuler::Private::ParagraphIndent: text = tr("Left indent"); break; + case KReportRuler::Private::EndIndent: text = tr("Right indent"); break; + case KReportRuler::Private::None: if (ev->buttons() & Qt::LeftButton) { if (d->orientation == Qt::Horizontal && ev->pos().y() > height() + OutsideRulerThreshold) emit guideLineCreated(d->orientation, d->viewConverter->viewToDocumentY(ev->pos().y())); @@ -1295,23 +1490,23 @@ { int hotspotCount = d->hotspots.count(); for (int i = 0; i < hotspotCount; ++i) { - KReportRulerPrivate::HotSpotData & hs = d->hotspots[i]; + KReportRuler::Private::HotSpotData & hs = d->hotspots[i]; if (hs.id == id) { hs.position = position; update(); return; } } // not there yet, then insert it. - KReportRulerPrivate::HotSpotData hs; + KReportRuler::Private::HotSpotData hs; hs.position = position; hs.id = id; d->hotspots.append(hs); } bool KReportRuler::removeHotSpot(int id) { - QList::Iterator iter = d->hotspots.begin(); + QList::Iterator iter = d->hotspots.begin(); while(iter != d->hotspots.end()) { if (iter->id == id) { d->hotspots.erase(iter); diff --git a/src/wrtembed/KReportZoomHandler.h b/src/wrtembed/KReportZoomHandler_p.h rename from src/wrtembed/KReportZoomHandler.h rename to src/wrtembed/KReportZoomHandler_p.h --- a/src/wrtembed/KReportZoomHandler.h +++ b/src/wrtembed/KReportZoomHandler_p.h @@ -21,13 +21,12 @@ #ifndef KREPORTZOOMHANDLER_H #define KREPORTZOOMHANDLER_H -#include "KReportZoomMode.h" +#include "KReportZoomMode_p.h" class QPointF; class QRectF; class QSizeF; - /** * This class handles the zooming and DPI stuff (conversions between * postscript pt values and pixels). If the internal data of your diff --git a/src/wrtembed/KReportZoomHandler.cpp b/src/wrtembed/KReportZoomHandler_p.cpp rename from src/wrtembed/KReportZoomHandler.cpp rename to src/wrtembed/KReportZoomHandler_p.cpp --- a/src/wrtembed/KReportZoomHandler.cpp +++ b/src/wrtembed/KReportZoomHandler_p.cpp @@ -19,7 +19,7 @@ Boston, MA 02110-1301, USA. */ -#include "KReportZoomHandler.h" +#include "KReportZoomHandler_p.h" #include "KReportUnit.h" // for POINT_TO_INCH #include "KReportUtils_p.h" diff --git a/src/wrtembed/KReportZoomMode.h b/src/wrtembed/KReportZoomMode_p.h rename from src/wrtembed/KReportZoomMode.h rename to src/wrtembed/KReportZoomMode_p.h diff --git a/src/wrtembed/KReportZoomMode.cpp b/src/wrtembed/KReportZoomMode_p.cpp rename from src/wrtembed/KReportZoomMode.cpp rename to src/wrtembed/KReportZoomMode_p.cpp --- a/src/wrtembed/KReportZoomMode.cpp +++ b/src/wrtembed/KReportZoomMode_p.cpp @@ -18,7 +18,7 @@ * Boston, MA 02110-1301, USA. */ -#include "KReportZoomMode.h" +#include "KReportZoomMode_p.h" #include