~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to libs/main/KoRuler.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-09-21 15:36:35 UTC
  • mfrom: (1.4.1 upstream) (60.2.11 maverick)
  • Revision ID: james.westby@ubuntu.com-20100921153635-6tejqkiro2u21ydi
Tags: 1:2.2.2-0ubuntu3
Add kubuntu_03_fix-crash-on-closing-sqlite-connection-2.2.2.diff and
kubuntu_04_support-large-memo-values-for-msaccess-2.2.2.diff as
recommended by upstream http://kexi-
project.org/wiki/wikiview/index.php@Kexi2.2_Patches.html#sqlite_stab
ility

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include "KoRuler.h"
25
25
 
26
26
#include "KoRuler_p.h"
 
27
#include <KoToolBase.h>
 
28
#include <KoToolManager.h>
27
29
 
28
30
#include <klocale.h>
29
31
#include <kdebug.h>
759
761
    return d->unit;
760
762
}
761
763
 
762
 
void KoRuler::setUnit(KoUnit unit)
 
764
void KoRuler::setUnit(const KoUnit &unit)
763
765
{
764
766
    d->unit = unit;
765
767
    update();
1025
1027
 
1026
1028
    qreal activeLength = d->activeRangeEnd - d->activeRangeStart;
1027
1029
 
1028
 
    switch(d->selected) {
 
1030
    switch (d->selected) {
1029
1031
    case KoRulerPrivate::FirstLineIndent:
1030
1032
        if (d->rightToLeft)
1031
1033
            d->firstLineIndent = d->activeRangeEnd - d->paragraphIndent -
1071
1073
        else
1072
1074
            d->endIndent = d->activeRangeEnd - d->viewConverter->viewToDocumentX(pos.x()
1073
1075
                 + d->selectOffset - d->offset);
1074
 
        if( ! (ev->modifiers() & Qt::ShiftModifier)) {
 
1076
        if (!(ev->modifiers() & Qt::ShiftModifier)) {
1075
1077
            d->endIndent = d->doSnapping(d->endIndent);
1076
1078
            d->paintingStrategy = d->normalPaintingStrategy;
1077
1079
        } else {
1091
1093
            if (ev->pos().y() < height()) { // reinstante it.
1092
1094
                d->currentIndex = d->tabs.count();
1093
1095
                d->tabs.append(d->deletedTab);
 
1096
            } else {
 
1097
                break;
1094
1098
            }
1095
 
            else
1096
 
                break;
1097
1099
        }
1098
1100
        if (d->rightToLeft)
1099
1101
            d->tabs[d->currentIndex].position = d->activeRangeEnd -
1101
1103
        else
1102
1104
            d->tabs[d->currentIndex].position = d->viewConverter->viewToDocumentX(pos.x() + d->selectOffset
1103
1105
                - d->offset) - d->activeRangeStart;
1104
 
        if( ! (ev->modifiers() & Qt::ShiftModifier))
 
1106
        if (!(ev->modifiers() & Qt::ShiftModifier))
1105
1107
            d->tabs[d->currentIndex].position = d->doSnapping(d->tabs[d->currentIndex].position);
1106
1108
        if (d->tabs[d->currentIndex].position < 0)
1107
1109
            d->tabs[d->currentIndex].position = 0;
1112
1114
            d->deletedTab = d->tabs.takeAt(d->currentIndex);
1113
1115
            d->currentIndex = -1;
1114
1116
            // was that a temporary added tab?
1115
 
            if( d->originalIndex == -1 )
1116
 
            {
1117
 
                emit guideLineCreated( d->orientation, d->orientation == Qt::Horizontal ? ev->pos().y() : ev->pos().x() );
1118
 
            }
 
1117
            if ( d->originalIndex == -1 )
 
1118
                emit guideLineCreated(d->orientation,
 
1119
                        d->orientation == Qt::Horizontal
 
1120
                        ? d->viewConverter->viewToDocumentY(ev->pos().y())
 
1121
                        : d->viewConverter->viewToDocumentX(ev->pos().x()));
1119
1122
        }
1120
1123
 
1121
1124
        d->emitTabChanged();
1145
1148
        case KoRulerPrivate::ParagraphIndent: text = i18n("Left indent"); break;
1146
1149
        case KoRulerPrivate::EndIndent: text = i18n("Right indent"); break;
1147
1150
        case KoRulerPrivate::None:
1148
 
            if( ev->buttons() & Qt::LeftButton )
1149
 
            {
1150
 
                if( d->orientation == Qt::Horizontal && ev->pos().y() > height() + OutsideRulerThreshold )
1151
 
                {
1152
 
                    emit guideLineCreated( d->orientation, ev->pos().y() );
1153
 
                }
1154
 
                else if( d->orientation == Qt::Vertical && ev->pos().x() > width() + OutsideRulerThreshold )
1155
 
                {
1156
 
                    emit guideLineCreated( d->orientation, ev->pos().x() );
1157
 
                }
 
1151
            if (ev->buttons() & Qt::LeftButton) {
 
1152
                if (d->orientation == Qt::Horizontal && ev->pos().y() > height() + OutsideRulerThreshold)
 
1153
                    emit guideLineCreated(d->orientation, d->viewConverter->viewToDocumentY(ev->pos().y()));
 
1154
                else if (d->orientation == Qt::Vertical && ev->pos().x() > width() + OutsideRulerThreshold)
 
1155
                    emit guideLineCreated(d->orientation, d->viewConverter->viewToDocumentX(ev->pos().x()));
1158
1156
            }
1159
1157
            break;
1160
1158
        default:
1204
1202
    return false;
1205
1203
}
1206
1204
 
1207
 
#include "KoRuler.moc"
 
1205
void KoRuler::createGuideToolConnection(KoCanvasBase *canvas)
 
1206
{
 
1207
    Q_ASSERT(canvas);
 
1208
    KoToolBase *tool = KoToolManager::instance()->toolById(canvas, QLatin1String("GuidesTool_ID"));
 
1209
    if (tool == 0) {
 
1210
        kWarning(30003) << "No guides tool found, skipping connection";
 
1211
        return;
 
1212
    }
 
1213
    connect(this, SIGNAL(guideLineCreated(Qt::Orientation,qreal)),
 
1214
        tool, SLOT(startGuideLineCreation(Qt::Orientation,qreal)));
 
1215
}
 
1216
 
 
1217
#include <KoRuler.moc>