Changeset View
Changeset View
Standalone View
Standalone View
src/wrtembed/KReportRuler_p.cpp
Show First 20 Lines • Show All 187 Lines • ▼ Show 20 Line(s) | 151 | public: | |||
---|---|---|---|---|---|
188 | 188 | | |||
189 | struct HotSpotData { | 189 | struct HotSpotData { | ||
190 | qreal position; | 190 | qreal position; | ||
191 | int id; | 191 | int id; | ||
192 | }; | 192 | }; | ||
193 | QList<HotSpotData> hotspots; | 193 | QList<HotSpotData> hotspots; | ||
194 | 194 | | |||
195 | bool rightToLeft; | 195 | bool rightToLeft; | ||
196 | enum Selection { | 196 | enum class Selection { | ||
197 | None, | 197 | None, | ||
198 | Tab, | 198 | Tab, | ||
199 | FirstLineIndent, | 199 | FirstLineIndent, | ||
200 | ParagraphIndent, | 200 | ParagraphIndent, | ||
201 | EndIndent, | 201 | EndIndent, | ||
202 | HotSpot | 202 | HotSpot | ||
203 | }; | 203 | }; | ||
204 | Selection selected; | 204 | Selection selected; | ||
▲ Show 20 Lines • Show All 342 Lines • ▼ Show 20 Line(s) | 542 | else if(i == nextQuarterStep) { | |||
547 | ++quarterStepCount; | 547 | ++quarterStepCount; | ||
548 | nextQuarterStep = qRound(d->viewConverter->documentToViewX(d->unit.fromUserValue( | 548 | nextQuarterStep = qRound(d->viewConverter->documentToViewX(d->unit.fromUserValue( | ||
549 | numberStep * 0.25 * quarterStepCount))); | 549 | numberStep * 0.25 * quarterStepCount))); | ||
550 | } | 550 | } | ||
551 | } | 551 | } | ||
552 | 552 | | |||
553 | // Draw the mouse indicator | 553 | // Draw the mouse indicator | ||
554 | const int mouseCoord = d->mouseCoordinate - start; | 554 | const int mouseCoord = d->mouseCoordinate - start; | ||
555 | if (d->selected == KReportRuler::Private::None || d->selected == KReportRuler::Private::HotSpot) { | 555 | if (d->selected == KReportRuler::Private::Selection::None | ||
556 | || d->selected == KReportRuler::Private::Selection::HotSpot) | ||||
557 | { | ||||
556 | const qreal top = rectangle.y() + 1; | 558 | const qreal top = rectangle.y() + 1; | ||
557 | const qreal bottom = rectangle.bottom() -1; | 559 | const qreal bottom = rectangle.bottom() -1; | ||
558 | if (d->selected == KReportRuler::Private::None && d->showMousePosition && mouseCoord > 0 && mouseCoord < rectangle.width() ) | 560 | if (d->selected == KReportRuler::Private::Selection::None && d->showMousePosition | ||
561 | && mouseCoord > 0 && mouseCoord < rectangle.width()) | ||||
562 | { | ||||
559 | painter->drawLine(QPointF(mouseCoord, top), QPointF(mouseCoord, bottom)); | 563 | painter->drawLine(QPointF(mouseCoord, top), QPointF(mouseCoord, bottom)); | ||
564 | } | ||||
560 | foreach (const KReportRuler::Private::HotSpotData & hp, d->hotspots) { | 565 | foreach (const KReportRuler::Private::HotSpotData & hp, d->hotspots) { | ||
561 | const qreal x = d->viewConverter->documentToViewX(hp.position) + d->offset; | 566 | const qreal x = d->viewConverter->documentToViewX(hp.position) + d->offset; | ||
562 | painter->drawLine(QPointF(x, top), QPointF(x, bottom)); | 567 | painter->drawLine(QPointF(x, top), QPointF(x, bottom)); | ||
563 | } | 568 | } | ||
564 | } | 569 | } | ||
565 | } | 570 | } | ||
566 | 571 | | |||
567 | void HorizontalPaintingStrategy::drawIndents(const KReportRuler::Private *d, QPainter *painter) | 572 | void HorizontalPaintingStrategy::drawIndents(const KReportRuler::Private *d, QPainter *painter) | ||
▲ Show 20 Lines • Show All 190 Lines • ▼ Show 20 Line(s) | 758 | } else if(i == nextQuarterStep) { | |||
758 | ++quarterStepCount; | 763 | ++quarterStepCount; | ||
759 | nextQuarterStep = qRound(d->viewConverter->documentToViewY(d->unit.fromUserValue( | 764 | nextQuarterStep = qRound(d->viewConverter->documentToViewY(d->unit.fromUserValue( | ||
760 | numberStep * 0.25 * quarterStepCount))); | 765 | numberStep * 0.25 * quarterStepCount))); | ||
761 | } | 766 | } | ||
762 | } | 767 | } | ||
763 | 768 | | |||
764 | // Draw the mouse indicator | 769 | // Draw the mouse indicator | ||
765 | const int mouseCoord = d->mouseCoordinate - start; | 770 | const int mouseCoord = d->mouseCoordinate - start; | ||
766 | if (d->selected == KReportRuler::Private::None || d->selected == KReportRuler::Private::HotSpot) { | 771 | if (d->selected == KReportRuler::Private::Selection::None | ||
772 | || d->selected == KReportRuler::Private::Selection::HotSpot) | ||||
773 | { | ||||
767 | const qreal left = rectangle.left() + 1; | 774 | const qreal left = rectangle.left() + 1; | ||
768 | const qreal right = rectangle.right() -1; | 775 | const qreal right = rectangle.right() -1; | ||
769 | if (d->selected == KReportRuler::Private::None && d->showMousePosition && mouseCoord > 0 && mouseCoord < rectangle.height() ) | 776 | if (d->selected == KReportRuler::Private::Selection::None && d->showMousePosition | ||
777 | && mouseCoord > 0 && mouseCoord < rectangle.height()) | ||||
778 | { | ||||
770 | painter->drawLine(QPointF(left, mouseCoord), QPointF(right, mouseCoord)); | 779 | painter->drawLine(QPointF(left, mouseCoord), QPointF(right, mouseCoord)); | ||
780 | } | ||||
771 | foreach (const KReportRuler::Private::HotSpotData & hp, d->hotspots) { | 781 | foreach (const KReportRuler::Private::HotSpotData & hp, d->hotspots) { | ||
772 | const qreal y = d->viewConverter->documentToViewY(hp.position) + d->offset; | 782 | const qreal y = d->viewConverter->documentToViewY(hp.position) + d->offset; | ||
773 | painter->drawLine(QPointF(left, y), QPointF(right, y)); | 783 | painter->drawLine(QPointF(left, y), QPointF(right, y)); | ||
774 | } | 784 | } | ||
775 | } | 785 | } | ||
776 | } | 786 | } | ||
777 | 787 | | |||
778 | QSize VerticalPaintingStrategy::sizeHint() | 788 | QSize VerticalPaintingStrategy::sizeHint() | ||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Line(s) | 868 | KReportRuler::Private::Private(KReportRuler *parent, | |||
877 | endIndent(0), | 887 | endIndent(0), | ||
878 | showTabs(false), | 888 | showTabs(false), | ||
879 | relativeTabs(false), | 889 | relativeTabs(false), | ||
880 | tabMoved(false), | 890 | tabMoved(false), | ||
881 | originalIndex(-1), | 891 | originalIndex(-1), | ||
882 | currentIndex(0), | 892 | currentIndex(0), | ||
883 | tabDistance(0.0), | 893 | tabDistance(0.0), | ||
884 | rightToLeft(false), | 894 | rightToLeft(false), | ||
885 | selected(None), | 895 | selected(Selection::None), | ||
886 | selectOffset(0), | 896 | selectOffset(0), | ||
887 | tabChooser(nullptr), | 897 | tabChooser(nullptr), | ||
888 | normalPaintingStrategy(o == Qt::Horizontal ? | 898 | normalPaintingStrategy(o == Qt::Horizontal ? | ||
889 | (PaintingStrategy*)new HorizontalPaintingStrategy() : (PaintingStrategy*)new VerticalPaintingStrategy()), | 899 | (PaintingStrategy*)new HorizontalPaintingStrategy() : (PaintingStrategy*)new VerticalPaintingStrategy()), | ||
890 | distancesPaintingStrategy((PaintingStrategy*)new HorizontalDistancesPaintingStrategy()), | 900 | distancesPaintingStrategy((PaintingStrategy*)new HorizontalDistancesPaintingStrategy()), | ||
891 | paintingStrategy(normalPaintingStrategy), | 901 | paintingStrategy(normalPaintingStrategy), | ||
892 | ruler(parent) | 902 | ruler(parent) | ||
893 | { | 903 | { | ||
Show All 31 Lines | |||||
925 | KReportRuler::Private::Selection KReportRuler::Private::selectionAtPosition(const QPoint & pos, int *selectOffset ) | 935 | KReportRuler::Private::Selection KReportRuler::Private::selectionAtPosition(const QPoint & pos, int *selectOffset ) | ||
926 | { | 936 | { | ||
927 | const int height = ruler->height(); | 937 | const int height = ruler->height(); | ||
928 | if (rightToLeft) { | 938 | if (rightToLeft) { | ||
929 | int x = int(viewConverter->documentToViewX(effectiveActiveRangeEnd() - firstLineIndent - paragraphIndent) + offset); | 939 | int x = int(viewConverter->documentToViewX(effectiveActiveRangeEnd() - firstLineIndent - paragraphIndent) + offset); | ||
930 | if (pos.x() >= x - 8 && pos.x() <= x +8 && pos.y() < height / 2) { | 940 | if (pos.x() >= x - 8 && pos.x() <= x +8 && pos.y() < height / 2) { | ||
931 | if (selectOffset) | 941 | if (selectOffset) | ||
932 | *selectOffset = x - pos.x(); | 942 | *selectOffset = x - pos.x(); | ||
933 | return KReportRuler::Private::FirstLineIndent; | 943 | return KReportRuler::Private::Selection::FirstLineIndent; | ||
934 | } | 944 | } | ||
935 | 945 | | |||
936 | x = int(viewConverter->documentToViewX(effectiveActiveRangeEnd() - paragraphIndent) + offset); | 946 | x = int(viewConverter->documentToViewX(effectiveActiveRangeEnd() - paragraphIndent) + offset); | ||
937 | if (pos.x() >= x - 8 && pos.x() <= x +8 && pos.y() > height / 2) { | 947 | if (pos.x() >= x - 8 && pos.x() <= x +8 && pos.y() > height / 2) { | ||
938 | if (selectOffset) | 948 | if (selectOffset) | ||
939 | *selectOffset = x - pos.x(); | 949 | *selectOffset = x - pos.x(); | ||
940 | return KReportRuler::Private::ParagraphIndent; | 950 | return KReportRuler::Private::Selection::ParagraphIndent; | ||
941 | } | 951 | } | ||
942 | 952 | | |||
943 | x = int(viewConverter->documentToViewX(effectiveActiveRangeStart() + endIndent) + offset); | 953 | x = int(viewConverter->documentToViewX(effectiveActiveRangeStart() + endIndent) + offset); | ||
944 | if (pos.x() >= x - 8 && pos.x() <= x + 8) { | 954 | if (pos.x() >= x - 8 && pos.x() <= x + 8) { | ||
945 | if (selectOffset) | 955 | if (selectOffset) | ||
946 | *selectOffset = x - pos.x(); | 956 | *selectOffset = x - pos.x(); | ||
947 | return KReportRuler::Private::EndIndent; | 957 | return KReportRuler::Private::Selection::EndIndent; | ||
948 | } | 958 | } | ||
949 | } | 959 | } | ||
950 | else { | 960 | else { | ||
951 | int x = int(viewConverter->documentToViewX(effectiveActiveRangeStart() + firstLineIndent + paragraphIndent) + offset); | 961 | int x = int(viewConverter->documentToViewX(effectiveActiveRangeStart() + firstLineIndent + paragraphIndent) + offset); | ||
952 | if (pos.x() >= x -8 && pos.x() <= x + 8 && pos.y() < height / 2) { | 962 | if (pos.x() >= x -8 && pos.x() <= x + 8 && pos.y() < height / 2) { | ||
953 | if (selectOffset) | 963 | if (selectOffset) | ||
954 | *selectOffset = x - pos.x(); | 964 | *selectOffset = x - pos.x(); | ||
955 | return KReportRuler::Private::FirstLineIndent; | 965 | return KReportRuler::Private::Selection::FirstLineIndent; | ||
956 | } | 966 | } | ||
957 | 967 | | |||
958 | x = int(viewConverter->documentToViewX(effectiveActiveRangeStart() + paragraphIndent) + offset); | 968 | x = int(viewConverter->documentToViewX(effectiveActiveRangeStart() + paragraphIndent) + offset); | ||
959 | if (pos.x() >= x - 8 && pos.x() <= x + 8 && pos.y() > height/2) { | 969 | if (pos.x() >= x - 8 && pos.x() <= x + 8 && pos.y() > height/2) { | ||
960 | if (selectOffset) | 970 | if (selectOffset) | ||
961 | *selectOffset = x - pos.x(); | 971 | *selectOffset = x - pos.x(); | ||
962 | return KReportRuler::Private::ParagraphIndent; | 972 | return KReportRuler::Private::Selection::ParagraphIndent; | ||
963 | } | 973 | } | ||
964 | 974 | | |||
965 | x = int(viewConverter->documentToViewX(effectiveActiveRangeEnd() - endIndent) + offset); | 975 | x = int(viewConverter->documentToViewX(effectiveActiveRangeEnd() - endIndent) + offset); | ||
966 | if (pos.x() >= x - 8 && pos.x() <= x + 8) { | 976 | if (pos.x() >= x - 8 && pos.x() <= x + 8) { | ||
967 | if (selectOffset) | 977 | if (selectOffset) | ||
968 | *selectOffset = x - pos.x(); | 978 | *selectOffset = x - pos.x(); | ||
969 | return KReportRuler::Private::EndIndent; | 979 | return KReportRuler::Private::Selection::EndIndent; | ||
970 | } | 980 | } | ||
971 | } | 981 | } | ||
972 | 982 | | |||
973 | return KReportRuler::Private::None; | 983 | return KReportRuler::Private::Selection::None; | ||
974 | } | 984 | } | ||
975 | 985 | | |||
976 | int KReportRuler::Private::hotSpotIndex(const QPoint & pos) | 986 | int KReportRuler::Private::hotSpotIndex(const QPoint & pos) | ||
977 | { | 987 | { | ||
978 | for(int counter = 0; counter < hotspots.count(); counter++) { | 988 | for(int counter = 0; counter < hotspots.count(); counter++) { | ||
979 | bool hit; | 989 | bool hit; | ||
980 | if (orientation == Qt::Horizontal) | 990 | if (orientation == Qt::Horizontal) | ||
981 | hit = qAbs(viewConverter->documentToViewX(hotspots[counter].position) - pos.x() + offset) < 3; | 991 | hit = qAbs(viewConverter->documentToViewX(hotspots[counter].position) - pos.x() + offset) < 3; | ||
▲ Show 20 Lines • Show All 257 Lines • ▼ Show 20 Line(s) | |||||
1239 | QList<QAction*> KReportRuler::popupActionList() const | 1249 | QList<QAction*> KReportRuler::popupActionList() const | ||
1240 | { | 1250 | { | ||
1241 | return d->popupActions; | 1251 | return d->popupActions; | ||
1242 | } | 1252 | } | ||
1243 | 1253 | | |||
1244 | void KReportRuler::mousePressEvent ( QMouseEvent* ev ) | 1254 | void KReportRuler::mousePressEvent ( QMouseEvent* ev ) | ||
1245 | { | 1255 | { | ||
1246 | d->tabMoved = false; | 1256 | d->tabMoved = false; | ||
1247 | d->selected = KReportRuler::Private::None; | 1257 | d->selected = KReportRuler::Private::Selection::None; | ||
1248 | if (ev->button() == Qt::RightButton && !d->popupActions.isEmpty()) | 1258 | if (ev->button() == Qt::RightButton && !d->popupActions.isEmpty()) | ||
1249 | QMenu::exec(d->popupActions, ev->globalPos()); | 1259 | QMenu::exec(d->popupActions, ev->globalPos()); | ||
1250 | if (ev->button() != Qt::LeftButton) { | 1260 | if (ev->button() != Qt::LeftButton) { | ||
1251 | ev->ignore(); | 1261 | ev->ignore(); | ||
1252 | return; | 1262 | return; | ||
1253 | } | 1263 | } | ||
1254 | 1264 | | |||
1255 | QPoint pos = ev->pos(); | 1265 | QPoint pos = ev->pos(); | ||
1256 | 1266 | | |||
1257 | if (d->showTabs) { | 1267 | if (d->showTabs) { | ||
1258 | int i = 0; | 1268 | int i = 0; | ||
1259 | int x; | 1269 | int x; | ||
1260 | foreach (const Tab & t, d->tabs) { | 1270 | foreach (const Tab & t, d->tabs) { | ||
1261 | if (d->rightToLeft) { | 1271 | if (d->rightToLeft) { | ||
1262 | x = d->viewConverter->documentToViewX(d->effectiveActiveRangeEnd() | 1272 | x = d->viewConverter->documentToViewX(d->effectiveActiveRangeEnd() | ||
1263 | - (d->relativeTabs ? d->paragraphIndent : 0) - t.position) + d->offset; | 1273 | - (d->relativeTabs ? d->paragraphIndent : 0) - t.position) + d->offset; | ||
1264 | } else { | 1274 | } else { | ||
1265 | x = d->viewConverter->documentToViewX(d->effectiveActiveRangeStart() | 1275 | x = d->viewConverter->documentToViewX(d->effectiveActiveRangeStart() | ||
1266 | + (d->relativeTabs ? d->paragraphIndent : 0) + t.position) + d->offset; | 1276 | + (d->relativeTabs ? d->paragraphIndent : 0) + t.position) + d->offset; | ||
1267 | } | 1277 | } | ||
1268 | if (pos.x() >= x-6 && pos.x() <= x+6) { | 1278 | if (pos.x() >= x-6 && pos.x() <= x+6) { | ||
1269 | d->selected = KReportRuler::Private::Tab; | 1279 | d->selected = KReportRuler::Private::Selection::Tab; | ||
1270 | d->selectOffset = x - pos.x(); | 1280 | d->selectOffset = x - pos.x(); | ||
1271 | d->currentIndex = i; | 1281 | d->currentIndex = i; | ||
1272 | break; | 1282 | break; | ||
1273 | } | 1283 | } | ||
1274 | i++; | 1284 | i++; | ||
1275 | } | 1285 | } | ||
1276 | d->originalIndex = d->currentIndex; | 1286 | d->originalIndex = d->currentIndex; | ||
1277 | } | 1287 | } | ||
1278 | 1288 | | |||
1279 | if (d->selected == KReportRuler::Private::None) | 1289 | if (d->selected == KReportRuler::Private::Selection::None) | ||
1280 | d->selected = d->selectionAtPosition(ev->pos(), &d->selectOffset); | 1290 | d->selected = d->selectionAtPosition(ev->pos(), &d->selectOffset); | ||
1281 | if (d->selected == KReportRuler::Private::None) { | 1291 | if (d->selected == KReportRuler::Private::Selection::None) { | ||
1282 | int hotSpotIndex = d->hotSpotIndex(ev->pos()); | 1292 | int hotSpotIndex = d->hotSpotIndex(ev->pos()); | ||
1283 | if (hotSpotIndex >= 0) { | 1293 | if (hotSpotIndex >= 0) { | ||
1284 | d->selected = KReportRuler::Private::HotSpot; | 1294 | d->selected = KReportRuler::Private::Selection::HotSpot; | ||
1285 | update(); | 1295 | update(); | ||
1286 | } | 1296 | } | ||
1287 | } | 1297 | } | ||
1288 | 1298 | | |||
1289 | if (d->showTabs && d->selected == KReportRuler::Private::None) { | 1299 | if (d->showTabs && d->selected == KReportRuler::Private::Selection::None) { | ||
1290 | // still haven't found something so let assume the user wants to add a tab | 1300 | // still haven't found something so let assume the user wants to add a tab | ||
1291 | qreal tabpos; | 1301 | qreal tabpos; | ||
1292 | if (d->rightToLeft) { | 1302 | if (d->rightToLeft) { | ||
1293 | tabpos = d->viewConverter->viewToDocumentX(pos.x() - d->offset) | 1303 | tabpos = d->viewConverter->viewToDocumentX(pos.x() - d->offset) | ||
1294 | + d->effectiveActiveRangeEnd() + (d->relativeTabs ? d->paragraphIndent : 0); | 1304 | + d->effectiveActiveRangeEnd() + (d->relativeTabs ? d->paragraphIndent : 0); | ||
1295 | } else { | 1305 | } else { | ||
1296 | tabpos = d->viewConverter->viewToDocumentX(pos.x() - d->offset) | 1306 | tabpos = d->viewConverter->viewToDocumentX(pos.x() - d->offset) | ||
1297 | - d->effectiveActiveRangeStart() - (d->relativeTabs ? d->paragraphIndent : 0); | 1307 | - d->effectiveActiveRangeStart() - (d->relativeTabs ? d->paragraphIndent : 0); | ||
1298 | } | 1308 | } | ||
1299 | Tab t(tabpos, d->tabChooser ? d->tabChooser->type() : | 1309 | Tab t(tabpos, d->tabChooser ? d->tabChooser->type() : | ||
1300 | d->rightToLeft ? QTextOption::RightTab : | 1310 | d->rightToLeft ? QTextOption::RightTab : | ||
1301 | QTextOption::LeftTab); | 1311 | QTextOption::LeftTab); | ||
1302 | d->tabs.append(t); | 1312 | d->tabs.append(t); | ||
1303 | d->selectOffset = 0; | 1313 | d->selectOffset = 0; | ||
1304 | d->selected = KReportRuler::Private::Tab; | 1314 | d->selected = KReportRuler::Private::Selection::Tab; | ||
1305 | d->currentIndex = d->tabs.count() - 1; | 1315 | d->currentIndex = d->tabs.count() - 1; | ||
1306 | d->originalIndex = -1; // new! | 1316 | d->originalIndex = -1; // new! | ||
1307 | update(); | 1317 | update(); | ||
1308 | } | 1318 | } | ||
1309 | if (d->orientation == Qt::Horizontal && (ev->modifiers() & Qt::ShiftModifier) && | 1319 | if (d->orientation == Qt::Horizontal && (ev->modifiers() & Qt::ShiftModifier) && | ||
1310 | (d->selected == KReportRuler::Private::FirstLineIndent || | 1320 | (d->selected == KReportRuler::Private::Selection::FirstLineIndent || | ||
1311 | d->selected == KReportRuler::Private::ParagraphIndent || | 1321 | d->selected == KReportRuler::Private::Selection::ParagraphIndent || | ||
1312 | d->selected == KReportRuler::Private::Tab || | 1322 | d->selected == KReportRuler::Private::Selection::Tab || | ||
1313 | d->selected == KReportRuler::Private::EndIndent)) | 1323 | d->selected == KReportRuler::Private::Selection::EndIndent)) | ||
1314 | d->paintingStrategy = d->distancesPaintingStrategy; | 1324 | d->paintingStrategy = d->distancesPaintingStrategy; | ||
1315 | 1325 | | |||
1316 | if (d->selected != KReportRuler::Private::None) | 1326 | if (d->selected != KReportRuler::Private::Selection::None) | ||
1317 | emit aboutToChange(); | 1327 | emit aboutToChange(); | ||
1318 | } | 1328 | } | ||
1319 | 1329 | | |||
1320 | void KReportRuler::mouseReleaseEvent ( QMouseEvent* ev ) | 1330 | void KReportRuler::mouseReleaseEvent ( QMouseEvent* ev ) | ||
1321 | { | 1331 | { | ||
1322 | ev->accept(); | 1332 | ev->accept(); | ||
1323 | if (d->selected == KReportRuler::Private::Tab) { | 1333 | if (d->selected == KReportRuler::Private::Selection::Tab) { | ||
1324 | if (d->originalIndex >= 0 && !d->tabMoved) { | 1334 | if (d->originalIndex >= 0 && !d->tabMoved) { | ||
1325 | int type = d->tabs[d->currentIndex].type; | 1335 | int type = d->tabs[d->currentIndex].type; | ||
1326 | type++; | 1336 | type++; | ||
1327 | if (type > 3) | 1337 | if (type > 3) | ||
1328 | type = 0; | 1338 | type = 0; | ||
1329 | d->tabs[d->currentIndex].type = static_cast<QTextOption::TabType> (type); | 1339 | d->tabs[d->currentIndex].type = static_cast<QTextOption::TabType> (type); | ||
1330 | update(); | 1340 | update(); | ||
1331 | } | 1341 | } | ||
1332 | d->emitTabChanged(); | 1342 | d->emitTabChanged(); | ||
1333 | } | 1343 | } | ||
1334 | else if( d->selected != KReportRuler::Private::None) | 1344 | else if( d->selected != KReportRuler::Private::Selection::None) | ||
1335 | emit indentsChanged(true); | 1345 | emit indentsChanged(true); | ||
1336 | else | 1346 | else | ||
1337 | ev->ignore(); | 1347 | ev->ignore(); | ||
1338 | 1348 | | |||
1339 | d->paintingStrategy = d->normalPaintingStrategy; | 1349 | d->paintingStrategy = d->normalPaintingStrategy; | ||
1340 | d->selected = KReportRuler::Private::None; | 1350 | d->selected = KReportRuler::Private::Selection::None; | ||
1341 | } | 1351 | } | ||
1342 | 1352 | | |||
1343 | void KReportRuler::mouseMoveEvent ( QMouseEvent* ev ) | 1353 | void KReportRuler::mouseMoveEvent ( QMouseEvent* ev ) | ||
1344 | { | 1354 | { | ||
1345 | QPoint pos = ev->pos(); | 1355 | QPoint pos = ev->pos(); | ||
1346 | 1356 | | |||
1347 | qreal activeLength = d->effectiveActiveRangeEnd() - d->effectiveActiveRangeStart(); | 1357 | qreal activeLength = d->effectiveActiveRangeEnd() - d->effectiveActiveRangeStart(); | ||
1348 | 1358 | | |||
1349 | switch (d->selected) { | 1359 | switch (d->selected) { | ||
1350 | case KReportRuler::Private::FirstLineIndent: | 1360 | case KReportRuler::Private::Selection::FirstLineIndent: | ||
1351 | if (d->rightToLeft) | 1361 | if (d->rightToLeft) | ||
1352 | d->firstLineIndent = d->effectiveActiveRangeEnd() - d->paragraphIndent - | 1362 | d->firstLineIndent = d->effectiveActiveRangeEnd() - d->paragraphIndent - | ||
1353 | d->viewConverter->viewToDocumentX(pos.x() + d->selectOffset - d->offset); | 1363 | d->viewConverter->viewToDocumentX(pos.x() + d->selectOffset - d->offset); | ||
1354 | else | 1364 | else | ||
1355 | d->firstLineIndent = d->viewConverter->viewToDocumentX(pos.x() + d->selectOffset | 1365 | d->firstLineIndent = d->viewConverter->viewToDocumentX(pos.x() + d->selectOffset | ||
1356 | - d->offset) - d->effectiveActiveRangeStart() - d->paragraphIndent; | 1366 | - d->offset) - d->effectiveActiveRangeStart() - d->paragraphIndent; | ||
1357 | if( ! (ev->modifiers() & Qt::ShiftModifier)) { | 1367 | if( ! (ev->modifiers() & Qt::ShiftModifier)) { | ||
1358 | d->firstLineIndent = d->doSnapping(d->firstLineIndent); | 1368 | d->firstLineIndent = d->doSnapping(d->firstLineIndent); | ||
1359 | d->paintingStrategy = d->normalPaintingStrategy; | 1369 | d->paintingStrategy = d->normalPaintingStrategy; | ||
1360 | } else { | 1370 | } else { | ||
1361 | if (d->orientation == Qt::Horizontal) | 1371 | if (d->orientation == Qt::Horizontal) | ||
1362 | d->paintingStrategy = d->distancesPaintingStrategy; | 1372 | d->paintingStrategy = d->distancesPaintingStrategy; | ||
1363 | } | 1373 | } | ||
1364 | 1374 | | |||
1365 | emit indentsChanged(false); | 1375 | emit indentsChanged(false); | ||
1366 | break; | 1376 | break; | ||
1367 | case KReportRuler::Private::ParagraphIndent: | 1377 | case KReportRuler::Private::Selection::ParagraphIndent: | ||
1368 | if (d->rightToLeft) | 1378 | if (d->rightToLeft) | ||
1369 | d->paragraphIndent = d->effectiveActiveRangeEnd() - | 1379 | d->paragraphIndent = d->effectiveActiveRangeEnd() - | ||
1370 | d->viewConverter->viewToDocumentX(pos.x() + d->selectOffset - d->offset); | 1380 | d->viewConverter->viewToDocumentX(pos.x() + d->selectOffset - d->offset); | ||
1371 | else | 1381 | else | ||
1372 | d->paragraphIndent = d->viewConverter->viewToDocumentX(pos.x() + d->selectOffset | 1382 | d->paragraphIndent = d->viewConverter->viewToDocumentX(pos.x() + d->selectOffset | ||
1373 | - d->offset) - d->effectiveActiveRangeStart(); | 1383 | - d->offset) - d->effectiveActiveRangeStart(); | ||
1374 | if( ! (ev->modifiers() & Qt::ShiftModifier)) { | 1384 | if( ! (ev->modifiers() & Qt::ShiftModifier)) { | ||
1375 | d->paragraphIndent = d->doSnapping(d->paragraphIndent); | 1385 | d->paragraphIndent = d->doSnapping(d->paragraphIndent); | ||
1376 | d->paintingStrategy = d->normalPaintingStrategy; | 1386 | d->paintingStrategy = d->normalPaintingStrategy; | ||
1377 | } else { | 1387 | } else { | ||
1378 | if (d->orientation == Qt::Horizontal) | 1388 | if (d->orientation == Qt::Horizontal) | ||
1379 | d->paintingStrategy = d->distancesPaintingStrategy; | 1389 | d->paintingStrategy = d->distancesPaintingStrategy; | ||
1380 | } | 1390 | } | ||
1381 | 1391 | | |||
1382 | if (d->paragraphIndent + d->endIndent > activeLength) | 1392 | if (d->paragraphIndent + d->endIndent > activeLength) | ||
1383 | d->paragraphIndent = activeLength - d->endIndent; | 1393 | d->paragraphIndent = activeLength - d->endIndent; | ||
1384 | emit indentsChanged(false); | 1394 | emit indentsChanged(false); | ||
1385 | break; | 1395 | break; | ||
1386 | case KReportRuler::Private::EndIndent: | 1396 | case KReportRuler::Private::Selection::EndIndent: | ||
1387 | if (d->rightToLeft) | 1397 | if (d->rightToLeft) | ||
1388 | d->endIndent = d->viewConverter->viewToDocumentX(pos.x() | 1398 | d->endIndent = d->viewConverter->viewToDocumentX(pos.x() | ||
1389 | + d->selectOffset - d->offset) - d->effectiveActiveRangeStart(); | 1399 | + d->selectOffset - d->offset) - d->effectiveActiveRangeStart(); | ||
1390 | else | 1400 | else | ||
1391 | d->endIndent = d->effectiveActiveRangeEnd() - d->viewConverter->viewToDocumentX(pos.x() | 1401 | d->endIndent = d->effectiveActiveRangeEnd() - d->viewConverter->viewToDocumentX(pos.x() | ||
1392 | + d->selectOffset - d->offset); | 1402 | + d->selectOffset - d->offset); | ||
1393 | if (!(ev->modifiers() & Qt::ShiftModifier)) { | 1403 | if (!(ev->modifiers() & Qt::ShiftModifier)) { | ||
1394 | d->endIndent = d->doSnapping(d->endIndent); | 1404 | d->endIndent = d->doSnapping(d->endIndent); | ||
1395 | d->paintingStrategy = d->normalPaintingStrategy; | 1405 | d->paintingStrategy = d->normalPaintingStrategy; | ||
1396 | } else { | 1406 | } else { | ||
1397 | if (d->orientation == Qt::Horizontal) | 1407 | if (d->orientation == Qt::Horizontal) | ||
1398 | d->paintingStrategy = d->distancesPaintingStrategy; | 1408 | d->paintingStrategy = d->distancesPaintingStrategy; | ||
1399 | } | 1409 | } | ||
1400 | 1410 | | |||
1401 | if (d->paragraphIndent + d->endIndent > activeLength) | 1411 | if (d->paragraphIndent + d->endIndent > activeLength) | ||
1402 | d->endIndent = activeLength - d->paragraphIndent; | 1412 | d->endIndent = activeLength - d->paragraphIndent; | ||
1403 | emit indentsChanged(false); | 1413 | emit indentsChanged(false); | ||
1404 | break; | 1414 | break; | ||
1405 | case KReportRuler::Private::Tab: | 1415 | case KReportRuler::Private::Selection::Tab: | ||
1406 | d->tabMoved = true; | 1416 | d->tabMoved = true; | ||
1407 | if (d->currentIndex < 0) { // tab is deleted. | 1417 | if (d->currentIndex < 0) { // tab is deleted. | ||
1408 | if (ev->pos().y() < height()) { // reinstante it. | 1418 | if (ev->pos().y() < height()) { // reinstante it. | ||
1409 | d->currentIndex = d->tabs.count(); | 1419 | d->currentIndex = d->tabs.count(); | ||
1410 | d->tabs.append(d->deletedTab); | 1420 | d->tabs.append(d->deletedTab); | ||
1411 | } else { | 1421 | } else { | ||
1412 | break; | 1422 | break; | ||
1413 | } | 1423 | } | ||
Show All 19 Lines | 1442 | if ( d->originalIndex == -1 ) | |||
1433 | emit guideLineCreated(d->orientation, | 1443 | emit guideLineCreated(d->orientation, | ||
1434 | d->orientation == Qt::Horizontal | 1444 | d->orientation == Qt::Horizontal | ||
1435 | ? d->viewConverter->viewToDocumentY(ev->pos().y()) | 1445 | ? d->viewConverter->viewToDocumentY(ev->pos().y()) | ||
1436 | : d->viewConverter->viewToDocumentX(ev->pos().x())); | 1446 | : d->viewConverter->viewToDocumentX(ev->pos().x())); | ||
1437 | } | 1447 | } | ||
1438 | 1448 | | |||
1439 | d->emitTabChanged(); | 1449 | d->emitTabChanged(); | ||
1440 | break; | 1450 | break; | ||
1441 | case KReportRuler::Private::HotSpot: | 1451 | case KReportRuler::Private::Selection::HotSpot: | ||
1442 | qreal newPos; | 1452 | qreal newPos; | ||
1443 | if (d->orientation == Qt::Horizontal) | 1453 | if (d->orientation == Qt::Horizontal) | ||
1444 | newPos= d->viewConverter->viewToDocumentX(pos.x() - d->offset); | 1454 | newPos= d->viewConverter->viewToDocumentX(pos.x() - d->offset); | ||
1445 | else | 1455 | else | ||
1446 | newPos= d->viewConverter->viewToDocumentY(pos.y() - d->offset); | 1456 | newPos= d->viewConverter->viewToDocumentY(pos.y() - d->offset); | ||
1447 | d->hotspots[d->currentIndex].position = newPos; | 1457 | d->hotspots[d->currentIndex].position = newPos; | ||
1448 | emit hotSpotChanged(d->hotspots[d->currentIndex].id, newPos); | 1458 | emit hotSpotChanged(d->hotspots[d->currentIndex].id, newPos); | ||
1449 | break; | 1459 | break; | ||
1450 | case KReportRuler::Private::None: | 1460 | case KReportRuler::Private::Selection::None: | ||
1451 | d->mouseCoordinate = (d->orientation == Qt::Horizontal ? pos.x() : pos.y()) - d->offset; | 1461 | d->mouseCoordinate = (d->orientation == Qt::Horizontal ? pos.x() : pos.y()) - d->offset; | ||
1452 | int hotSpotIndex = d->hotSpotIndex(pos); | 1462 | int hotSpotIndex = d->hotSpotIndex(pos); | ||
1453 | if (hotSpotIndex >= 0) { | 1463 | if (hotSpotIndex >= 0) { | ||
1454 | setCursor(QCursor( d->orientation == Qt::Horizontal ? Qt::SplitHCursor : Qt::SplitVCursor )); | 1464 | setCursor(QCursor( d->orientation == Qt::Horizontal ? Qt::SplitHCursor : Qt::SplitVCursor )); | ||
1455 | break; | 1465 | break; | ||
1456 | } | 1466 | } | ||
1457 | unsetCursor(); | 1467 | unsetCursor(); | ||
1458 | 1468 | | |||
1459 | KReportRuler::Private::Selection selection = d->selectionAtPosition(pos); | 1469 | KReportRuler::Private::Selection selection = d->selectionAtPosition(pos); | ||
1460 | QString text; | 1470 | QString text; | ||
1461 | switch(selection) { | 1471 | switch(selection) { | ||
1462 | case KReportRuler::Private::FirstLineIndent: text = tr("First line indent"); break; | 1472 | case KReportRuler::Private::Selection::FirstLineIndent: text = tr("First line indent"); break; | ||
1463 | case KReportRuler::Private::ParagraphIndent: text = tr("Left indent"); break; | 1473 | case KReportRuler::Private::Selection::ParagraphIndent: text = tr("Left indent"); break; | ||
1464 | case KReportRuler::Private::EndIndent: text = tr("Right indent"); break; | 1474 | case KReportRuler::Private::Selection::EndIndent: text = tr("Right indent"); break; | ||
1465 | case KReportRuler::Private::None: | 1475 | case KReportRuler::Private::Selection::None: | ||
1466 | if (ev->buttons() & Qt::LeftButton) { | 1476 | if (ev->buttons() & Qt::LeftButton) { | ||
1467 | if (d->orientation == Qt::Horizontal && ev->pos().y() > height() + OutsideRulerThreshold) | 1477 | if (d->orientation == Qt::Horizontal && ev->pos().y() > height() + OutsideRulerThreshold) | ||
1468 | emit guideLineCreated(d->orientation, d->viewConverter->viewToDocumentY(ev->pos().y())); | 1478 | emit guideLineCreated(d->orientation, d->viewConverter->viewToDocumentY(ev->pos().y())); | ||
1469 | else if (d->orientation == Qt::Vertical && ev->pos().x() > width() + OutsideRulerThreshold) | 1479 | else if (d->orientation == Qt::Vertical && ev->pos().x() > width() + OutsideRulerThreshold) | ||
1470 | emit guideLineCreated(d->orientation, d->viewConverter->viewToDocumentX(ev->pos().x())); | 1480 | emit guideLineCreated(d->orientation, d->viewConverter->viewToDocumentX(ev->pos().x())); | ||
1471 | } | 1481 | } | ||
1472 | break; | 1482 | break; | ||
1473 | default: | 1483 | default: | ||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |