Rev 2603 | Rev 2626 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3 | paul | 1 | /*************************************************************************** |
2 | scribusview.cpp - description |
||
3 | ------------------- |
||
4 | begin : Fre Apr 6 21:47:55 CEST 2001 |
||
5 | copyright : (C) 2001 by Franz Schmid |
||
6 | email : Franz.Schmid@altmuehlnet.de |
||
7 | ***************************************************************************/ |
||
8 | |||
9 | /*************************************************************************** |
||
10 | * * |
||
11 | * This program is free software; you can redistribute it and/or modify * |
||
12 | * it under the terms of the GNU General Public License as published by * |
||
13 | * the Free Software Foundation; either version 2 of the License, or * |
||
14 | * (at your option) any later version. * |
||
15 | * * |
||
16 | ***************************************************************************/ |
||
17 | |||
18 | #include "scribusview.h" |
||
19 | #include "scribusview.moc" |
||
128 | Franz | 20 | |
617 | cbradney | 21 | #ifdef _MSC_VER |
22 | #if (_MSC_VER >= 1200) |
||
23 | #include "win-config.h" |
||
24 | #endif |
||
128 | Franz | 25 | #else |
26 | #include "config.h" |
||
27 | #endif |
||
28 | |||
3 | paul | 29 | #include <qcolor.h> |
30 | #include <qfont.h> |
||
31 | #include <qfontmetrics.h> |
||
32 | #include <qpixmap.h> |
||
33 | #include <qpointarray.h> |
||
34 | #include <qstringlist.h> |
||
1525 | cbradney | 35 | #include <qdragobject.h> |
3 | paul | 36 | #include <qimage.h> |
37 | #include <qcstring.h> |
||
173 | Franz | 38 | #include <qfileinfo.h> |
456 | fschmid | 39 | #include <qfile.h> |
307 | Franz | 40 | #include <cmath> |
456 | fschmid | 41 | #include <cstdio> |
42 | #include <cstdlib> |
||
43 | #include <unistd.h> |
||
44 | #include <qcursor.h> |
||
45 | #include <qurl.h> |
||
46 | #include <qdir.h> |
||
47 | #include <qevent.h> |
||
48 | #if QT_VERSION > 0x030102 |
||
49 | #define SPLITVC SplitHCursor |
||
50 | #define SPLITHC SplitVCursor |
||
51 | #else |
||
52 | #define SPLITVC SplitVCursor |
||
53 | #define SPLITHC SplitHCursor |
||
54 | #endif |
||
181 | Franz | 55 | #include "scribus.h" |
1427 | fschmid | 56 | #include "tree.h" |
456 | fschmid | 57 | #include "mpalette.h" |
58 | #include "scribusXml.h" |
||
59 | #include "serializer.h" |
||
60 | #include "insertTable.h" |
||
838 | cbradney | 61 | #include "hruler.h" |
62 | #include "vruler.h" |
||
1151 | fschmid | 63 | #include "filewatcher.h" |
1226 | tsoots | 64 | #include "undomanager.h" |
1525 | cbradney | 65 | #include "units.h" |
1633 | fschmid | 66 | #include "extimageprops.h" |
1655 | cbradney | 67 | #include "pageitemattributes.h" |
1693 | craig | 68 | #include "scpaths.h" |
2103 | cbradney | 69 | #include "actionmanager.h" |
456 | fschmid | 70 | #ifdef HAVE_TIFF |
71 | #include <tiffio.h> |
||
72 | #endif |
||
73 | #ifdef HAVE_CMS |
||
74 | #include CMS_INC |
||
75 | #endif |
||
68 | Franz | 76 | |
2529 | craig | 77 | #include "scfontmetrics.h" |
78 | #include "util.h" |
||
2495 | cbradney | 79 | #include "story.h" |
80 | |||
504 | cbradney | 81 | using namespace std; |
82 | |||
2529 | craig | 83 | extern ProfilesL InputProfiles; |
181 | Franz | 84 | extern ScribusApp* ScApp; |
3 | paul | 85 | |
1065 | cbradney | 86 | ScribusView::ScribusView(QWidget *parent, ScribusDoc *doc, ApplicationPrefs *prefs) : QScrollView(parent, "s", WRepaintNoErase | WNorthWestGravity) |
3 | paul | 87 | { |
88 | Ready = false; |
||
456 | fschmid | 89 | updateOn = true; |
3 | paul | 90 | Doc = doc; |
2142 | cbradney | 91 | Doc->pageCount = 0; |
240 | Franz | 92 | Prefs = prefs; |
3 | paul | 93 | setHScrollBarMode(QScrollView::AlwaysOn); |
94 | setVScrollBarMode(QScrollView::AlwaysOn); |
||
95 | setMargins(25, 25, 0, 0); |
||
96 | setResizePolicy(Manual); |
||
240 | Franz | 97 | viewport()->setBackgroundMode(PaletteBackground); |
3 | paul | 98 | QFont fo = QFont(font()); |
99 | fo.setPointSize(10); |
||
333 | Franz | 100 | LE = new MSpinBox( 10, 3200, this, 2 ); |
3 | paul | 101 | LE->setFont(fo); |
146 | Franz | 102 | LE->setValue( 100 ); |
3 | paul | 103 | LE->setFocusPolicy(QWidget::ClickFocus); |
1822 | cbradney | 104 | zoomOutToolbarButton = new QPushButton(this); |
105 | zoomOutToolbarButton->setPixmap(loadIcon("Klein.xpm")); |
||
106 | zoomOutToolbarButton->setFocusPolicy(QWidget::NoFocus); |
||
107 | zoomInToolbarButton = new QPushButton(this); |
||
108 | zoomInToolbarButton->setFocusPolicy(QWidget::NoFocus); |
||
109 | zoomInToolbarButton->setPixmap(loadIcon("Gross.xpm")); |
||
199 | Franz | 110 | PGS = new PageSelector(this, 1); |
160 | Franz | 111 | PGS->setFont(fo); |
170 | Franz | 112 | PGS->setFocusPolicy(QWidget::ClickFocus); |
3 | paul | 113 | LY = new QPushButton(this); |
114 | LY->setFont(fo); |
||
115 | Laymen = new QPopupMenu(this); |
||
116 | Laymen->setFont(fo); |
||
2199 | cbradney | 117 | |
3 | paul | 118 | LY->setPopup(Laymen); |
119 | LY->setFocusPolicy(QWidget::NoFocus); |
||
1612 | cbradney | 120 | horizRuler = new Hruler(this, Doc); |
121 | vertRuler = new Vruler(this, Doc); |
||
3 | paul | 122 | UN = new QToolButton(this); |
123 | Unitmen = new QPopupMenu(this); |
||
124 | UN->setPopup(Unitmen); |
||
125 | UN->setFocusPolicy(QWidget::NoFocus); |
||
126 | UN->setPopupDelay(10); |
||
127 | Ready = true; |
||
456 | fschmid | 128 | viewport()->setMouseTracking(true); |
129 | setAcceptDrops(true); |
||
130 | viewport()->setAcceptDrops(true); |
||
131 | setDragAutoScroll(false); |
||
132 | SelItem.clear(); |
||
133 | Doc->DragP = false; |
||
134 | Doc->leaveDrag = false; |
||
135 | Imoved = false; |
||
136 | Mpressed = false; |
||
137 | MidButt = false; |
||
138 | HaveSelRect = false; |
||
139 | Magnify = false; |
||
140 | FirstPoly = true; |
||
141 | EdPoints = true; |
||
142 | GroupSel = false; |
||
143 | DraggedGroup = false; |
||
144 | MoveGY = false; |
||
145 | MoveGX = false; |
||
146 | EditContour = false; |
||
147 | CursVis = false; |
||
1330 | fschmid | 148 | mCG = false; |
149 | MidButt = false; |
||
1874 | fschmid | 150 | previewMode = false; |
1330 | fschmid | 151 | Doc->SubMode = -1; |
456 | fschmid | 152 | GroupX = 0; |
153 | GroupY = 0; |
||
154 | GroupW = 0; |
||
155 | GroupH = 0; |
||
156 | DrHY = -1; |
||
157 | DrVX = -1; |
||
158 | GyM = 0; |
||
159 | GxM = 0; |
||
160 | ClRe = -1; |
||
161 | ClRe2 = -1; |
||
1254 | tsoots | 162 | _groupTransactionStarted = false; |
1341 | tsoots | 163 | _itemCreationTransactionStarted = false; |
1461 | tsoots | 164 | _isGlobalMode = true; |
1226 | tsoots | 165 | undoManager = UndoManager::instance(); |
2199 | cbradney | 166 | languageChange(); |
1822 | cbradney | 167 | connect(zoomOutToolbarButton, SIGNAL(clicked()), this, SLOT(slotZoomOut())); |
168 | connect(zoomInToolbarButton, SIGNAL(clicked()), this, SLOT(slotZoomIn())); |
||
68 | Franz | 169 | connect(LE, SIGNAL(valueChanged(int)), this, SLOT(Zval())); |
199 | Franz | 170 | connect(PGS, SIGNAL(GotoPage(int)), this, SLOT(GotoPa(int))); |
3 | paul | 171 | connect(Laymen, SIGNAL(activated(int)), this, SLOT(GotoLa(int))); |
172 | connect(Unitmen, SIGNAL(activated(int)), this, SLOT(ChgUnit(int))); |
||
173 | connect(this, SIGNAL(contentsMoving(int, int)), this, SLOT(setRulerPos(int, int))); |
||
1443 | tsoots | 174 | connect(this, SIGNAL(HaveSel(int)), this, SLOT(selectionChanged())); |
2171 | fschmid | 175 | evSpon = false; |
3 | paul | 176 | } |
177 | |||
2199 | cbradney | 178 | void ScribusView::languageChange() |
179 | { |
||
180 | LE->setSuffix( tr( " %" ) ); |
||
181 | LY->setText( tr("Layer")+" 0"); |
||
182 | //CB TODO Convert to actions later |
||
183 | UN->setText(unitGetStrFromIndex(Doc->docUnitIndex)); |
||
184 | Unitmen->clear(); |
||
185 | for (int i=0;i<=unitGetMaxIndex();++i) |
||
186 | Unitmen->insertItem(unitGetStrFromIndex(i)); |
||
187 | |||
188 | } |
||
189 | |||
2171 | fschmid | 190 | void ScribusView::viewportPaintEvent ( QPaintEvent * p ) |
191 | { |
||
192 | if (p->spontaneous()) |
||
193 | evSpon = true; |
||
194 | QScrollView::viewportPaintEvent(p); |
||
195 | } |
||
196 | |||
693 | fschmid | 197 | void ScribusView::drawContents(QPainter *, int clipx, int clipy, int clipw, int cliph) |
456 | fschmid | 198 | { |
1569 | fschmid | 199 | QPoint vr; |
456 | fschmid | 200 | if (Doc->loading) |
201 | return; |
||
202 | if (!updateOn) |
||
203 | return; |
||
204 | // QTime tim; |
||
205 | // tim.start(); |
||
206 | if ((clipw > 0) && (cliph > 0)) |
||
207 | { |
||
1624 | fschmid | 208 | vr = contentsToViewport(QPoint(clipx, clipy)); |
209 | ScPainter *painter = new ScPainter(viewport(), clipw, cliph, vr.x(), vr.y()); |
||
456 | fschmid | 210 | painter->clear(paletteBackgroundColor()); |
211 | painter->translate(-clipx, -clipy); |
||
212 | painter->setLineWidth(1); |
||
213 | painter->setFillMode(ScPainter::Solid); |
||
2538 | fschmid | 214 | // painter->translate(0.5, 0.5); |
456 | fschmid | 215 | painter->setZoomFactor(1.0); |
216 | /* Draw Page Outlines */ |
||
217 | if (!Doc->MasterP) |
||
218 | { |
||
219 | for (uint a = 0; a < Doc->Pages.count(); ++a) |
||
220 | { |
||
221 | int x = static_cast<int>(Doc->Pages.at(a)->Xoffset * Scale); |
||
222 | int y = static_cast<int>(Doc->Pages.at(a)->Yoffset * Scale); |
||
223 | int w = static_cast<int>(Doc->Pages.at(a)->Width * Scale); |
||
224 | int h = static_cast<int>(Doc->Pages.at(a)->Height * Scale); |
||
225 | if (QRect(x, y, w+5, h+5).intersects(QRect(clipx, clipy, clipw, cliph))) |
||
226 | { |
||
227 | painter->setFillMode(ScPainter::Solid); |
||
228 | painter->setPen(black, 1, SolidLine, FlatCap, MiterJoin); |
||
229 | painter->setBrush(QColor(128,128,128)); |
||
230 | painter->drawRect(x+5, y+5, w, h); |
||
1065 | cbradney | 231 | if (a == Doc->currentPage->PageNr) |
745 | fschmid | 232 | painter->setPen(red, 2, SolidLine, FlatCap, MiterJoin); |
233 | else |
||
234 | painter->setPen(black, 1, SolidLine, FlatCap, MiterJoin); |
||
456 | fschmid | 235 | painter->setBrush(Doc->papColor); |
236 | painter->drawRect(x, y, w, h); |
||
1187 | fschmid | 237 | if (Doc->guidesSettings.before) |
456 | fschmid | 238 | DrawPageMarks(painter, Doc->Pages.at(a), QRect(clipx, clipy, clipw, cliph)); |
239 | } |
||
240 | DrawMasterItems(painter, Doc->Pages.at(a), QRect(clipx, clipy, clipw, cliph)); |
||
241 | } |
||
242 | DrawPageItems(painter, QRect(clipx, clipy, clipw, cliph)); |
||
1187 | fschmid | 243 | if (!Doc->guidesSettings.before) |
456 | fschmid | 244 | { |
245 | for (uint a = 0; a < Doc->Pages.count(); ++a) |
||
246 | { |
||
247 | int x = static_cast<int>(Doc->Pages.at(a)->Xoffset * Scale); |
||
248 | int y = static_cast<int>(Doc->Pages.at(a)->Yoffset * Scale); |
||
249 | int w = static_cast<int>(Doc->Pages.at(a)->Width * Scale); |
||
250 | int h = static_cast<int>(Doc->Pages.at(a)->Height * Scale); |
||
251 | if (QRect(x, y, w+5, h+5).intersects(QRect(clipx, clipy, clipw, cliph))) |
||
252 | DrawPageMarks(painter, Doc->Pages.at(a), QRect(clipx, clipy, clipw, cliph)); |
||
253 | } |
||
254 | } |
||
255 | } |
||
256 | else |
||
257 | { |
||
258 | int x = static_cast<int>(Doc->ScratchLeft * Scale); |
||
259 | int y = static_cast<int>(Doc->ScratchTop * Scale); |
||
1065 | cbradney | 260 | int w = static_cast<int>(Doc->currentPage->Width * Scale); |
261 | int h = static_cast<int>(Doc->currentPage->Height * Scale); |
||
456 | fschmid | 262 | if (QRect(x, y, w+5, h+5).intersects(QRect(clipx, clipy, clipw, cliph))) |
263 | { |
||
264 | painter->setFillMode(ScPainter::Solid); |
||
265 | painter->setPen(black, 1, SolidLine, FlatCap, MiterJoin); |
||
266 | painter->setBrush(QColor(128,128,128)); |
||
267 | painter->drawRect(x+5, y+5, w, h); |
||
268 | painter->setBrush(Doc->papColor); |
||
269 | painter->drawRect(x, y, w, h); |
||
1187 | fschmid | 270 | if (Doc->guidesSettings.before) |
1065 | cbradney | 271 | DrawPageMarks(painter, Doc->currentPage, QRect(clipx, clipy, clipw, cliph)); |
456 | fschmid | 272 | } |
273 | DrawPageItems(painter, QRect(clipx, clipy, clipw, cliph)); |
||
1187 | fschmid | 274 | if ((!Doc->guidesSettings.before) && (QRect(x, y, w+5, h+5).intersects(QRect(clipx, clipy, clipw, cliph)))) |
1065 | cbradney | 275 | DrawPageMarks(painter, Doc->currentPage, QRect(clipx, clipy, clipw, cliph)); |
456 | fschmid | 276 | } |
705 | fschmid | 277 | if ((SelItem.count() != 0) || (linkedFramesToShow.count() != 0)) |
456 | fschmid | 278 | { |
279 | double z = painter->zoomFactor(); |
||
280 | painter->setZoomFactor(Scale); |
||
281 | painter->save(); |
||
1957 | cbradney | 282 | PageItem *currItem; |
879 | fschmid | 283 | if ((Doc->guidesSettings.linkShown) && (linkedFramesToShow.count() != 0)) |
1957 | cbradney | 284 | currItem = linkedFramesToShow.at(0); |
705 | fschmid | 285 | else |
808 | fschmid | 286 | { |
287 | if (linkedFramesToShow.count() != 0) |
||
1957 | cbradney | 288 | currItem = linkedFramesToShow.at(0); |
808 | fschmid | 289 | else |
1957 | cbradney | 290 | currItem = SelItem.at(0); |
808 | fschmid | 291 | } |
2603 | cbradney | 292 | if ((((Doc->appMode == modeLinkFrames) || (Doc->appMode == modeUnlinkFrames)) |
1957 | cbradney | 293 | && (currItem->itemType() == PageItem::TextFrame)) || (Doc->guidesSettings.linkShown)) |
456 | fschmid | 294 | { |
1957 | cbradney | 295 | PageItem *nextItem = currItem; |
879 | fschmid | 296 | if (Doc->guidesSettings.linkShown) |
456 | fschmid | 297 | { |
705 | fschmid | 298 | for (uint lks = 0; lks < linkedFramesToShow.count(); ++lks) |
299 | { |
||
1957 | cbradney | 300 | nextItem = linkedFramesToShow.at(lks); |
301 | while (nextItem != 0) |
||
705 | fschmid | 302 | { |
814 | cbradney | 303 | double x11, y11, x12, y12, x1mid, y1mid; |
304 | double x21, y21, x22, y22, x2mid, y2mid; |
||
1957 | cbradney | 305 | x11 = nextItem->Xpos; |
306 | y11 = nextItem->Ypos; |
||
307 | x12 = nextItem->Xpos+nextItem->Width; |
||
308 | y12 = nextItem->Ypos+nextItem->Height; |
||
814 | cbradney | 309 | x1mid = x11+(x12-x11)/2; |
310 | y1mid = y11+(y12-y11)/2; |
||
311 | |||
1957 | cbradney | 312 | if (nextItem->Rot!=0.000) |
814 | cbradney | 313 | { |
1957 | cbradney | 314 | FPoint tempPoint = transformPoint(FPoint(0,0), x11, y11, nextItem->Rot, 1, 1); |
814 | cbradney | 315 | x11=tempPoint.x(); |
316 | y11=tempPoint.y(); |
||
1957 | cbradney | 317 | tempPoint = transformPoint(FPoint(0,0), x12, y12, nextItem->Rot, 1, 1); |
814 | cbradney | 318 | x12=tempPoint.x(); |
319 | y12=tempPoint.y(); |
||
1957 | cbradney | 320 | tempPoint = transformPoint(FPoint(0,0), x1mid, y1mid, nextItem->Rot, 1, 1); |
814 | cbradney | 321 | x1mid=tempPoint.x(); |
322 | y1mid=tempPoint.y(); |
||
323 | } |
||
324 | |||
1485 | tsoots | 325 | |
814 | cbradney | 326 | double a1, b1, a2, b2; |
823 | fschmid | 327 | a1 = a2 = b1 = b2 = 0; |
1957 | cbradney | 328 | if (nextItem->NextBox!=NULL) |
814 | cbradney | 329 | { |
1957 | cbradney | 330 | x21 = nextItem->NextBox->Xpos; |
331 | y21 = nextItem->NextBox->Ypos; |
||
332 | x22 = nextItem->NextBox->Xpos+nextItem->NextBox->Width; |
||
333 | y22 = nextItem->NextBox->Ypos+nextItem->NextBox->Height; |
||
334 | x2mid = nextItem->NextBox->Xpos + nextItem->NextBox->Width/2; |
||
335 | y2mid = nextItem->NextBox->Ypos + nextItem->NextBox->Height/2; |
||
814 | cbradney | 336 | x2mid = x21+(x22-x21)/2; |
337 | y2mid = y21+(y22-y21)/2; |
||
338 | |||
1957 | cbradney | 339 | if (nextItem->NextBox->Rot!=0.000) |
814 | cbradney | 340 | { |
1957 | cbradney | 341 | FPoint tempPoint = transformPoint(FPoint(0,0), x21, y21, nextItem->NextBox->Rot, 1, 1); |
814 | cbradney | 342 | x21=tempPoint.x(); |
343 | y21=tempPoint.y(); |
||
1957 | cbradney | 344 | tempPoint = transformPoint(FPoint(0,0), x22, y22, nextItem->NextBox->Rot, 1, 1); |
814 | cbradney | 345 | x22=tempPoint.x(); |
346 | y22=tempPoint.y(); |
||
1957 | cbradney | 347 | tempPoint = transformPoint(FPoint(0,0), x2mid, y2mid, nextItem->NextBox->Rot, 1, 1); |
814 | cbradney | 348 | x2mid=tempPoint.x(); |
349 | y2mid=tempPoint.y(); |
||
350 | } |
||
1485 | tsoots | 351 | |
814 | cbradney | 352 | if (x22<x11) { a1 = x11; a2 = x22; } |
353 | if (x21>x12) { a1 = x12; a2 = x21; } |
||
354 | if (y22<y11) { b1 = y11; b2 = y22; } |
||
355 | if (y21>y12) { b1 = y12; b2 = y21; } |
||
356 | |||
357 | if (x21<x12 && x21>x11) { a1 = x1mid; a2 = x2mid; } |
||
358 | if (x21<x11 && x22>x11) { a1 = x1mid; a2 = x2mid; } |
||
359 | |||
360 | if (y21<y12 && y21>y11) { b1 = y1mid; b2 = y2mid; } |
||
361 | if (y21<y11 && y22>y11) { b1 = y1mid; b2 = y2mid; } |
||
362 | |||
363 | } |
||
364 | |||
1957 | cbradney | 365 | FPoint Start = transformPoint(FPoint(a1-nextItem->Xpos, b1-nextItem->Ypos), nextItem->Xpos, nextItem->Ypos, nextItem->Rot, 1, 1); |
366 | //FPoint Start = transformPoint(FPoint(nextItem->Width/2, nextItem->Height), nextItem->Xpos, nextItem->Ypos, nextItem->Rot, 1, 1); |
||
367 | nextItem = nextItem->NextBox; |
||
368 | if (nextItem != NULL) |
||
705 | fschmid | 369 | { |
1957 | cbradney | 370 | FPoint End = transformPoint(FPoint(a2-nextItem->Xpos, b2-nextItem->Ypos), nextItem->Xpos, nextItem->Ypos, nextItem->Rot, 1, 1); |
371 | //FPoint End = transformPoint(FPoint(nextItem->Width/2, 0), nextItem->Xpos, nextItem->Ypos, nextItem->Rot, 1, 1); |
||
705 | fschmid | 372 | painter->setPen(black, 5.0 / Scale, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
373 | painter->setPenOpacity(0.3); |
||
374 | painter->drawLine(Start, End); |
||
1795 | cbradney | 375 | double r = atan2(End.y()-Start.y(),End.x()-Start.x())*(180.0/M_PI); |
776 | fschmid | 376 | QWMatrix arrowTrans; |
377 | FPointArray arrow; |
||
378 | arrow.addQuadPoint(-12, 0, -12, 0, -12, 0, -12, 0); |
||
379 | arrow.addQuadPoint(-15, -5, -15, -5, -15, -5, -15, -5); |
||
380 | arrow.addQuadPoint(0, 0, 0, 0, 0, 0, 0, 0); |
||
381 | arrow.addQuadPoint(-15, 5, -15, 5, -15, 5, -15, 5); |
||
382 | arrow.addQuadPoint(-12, 0, -12, 0, -12, 0, -12, 0); |
||
383 | arrowTrans.translate(End.x(), End.y()); |
||
384 | arrowTrans.rotate(r); |
||
385 | arrowTrans.scale(2.5 / Scale, 2.5 / Scale); |
||
386 | arrow.map(arrowTrans); |
||
387 | painter->setBrush(painter->pen()); |
||
388 | painter->setBrushOpacity(0.3); |
||
389 | painter->setLineWidth(0); |
||
390 | painter->setFillMode(ScPainter::Solid); |
||
391 | painter->setupPolygon(&arrow); |
||
392 | painter->fillPath(); |
||
705 | fschmid | 393 | } |
394 | } |
||
395 | } |
||
456 | fschmid | 396 | } |
705 | fschmid | 397 | else |
456 | fschmid | 398 | { |
1957 | cbradney | 399 | while (nextItem != 0) |
456 | fschmid | 400 | { |
1957 | cbradney | 401 | if (nextItem->BackBox != 0) |
402 | nextItem = nextItem->BackBox; |
||
705 | fschmid | 403 | else |
404 | break; |
||
456 | fschmid | 405 | } |
1957 | cbradney | 406 | while (nextItem != 0) |
705 | fschmid | 407 | { |
1957 | cbradney | 408 | FPoint Start = transformPoint(FPoint(nextItem->Width/2, nextItem->Height), nextItem->Xpos, nextItem->Ypos, nextItem->Rot, 1, 1); |
409 | nextItem = nextItem->NextBox; |
||
410 | if (nextItem != 0) |
||
705 | fschmid | 411 | { |
1957 | cbradney | 412 | FPoint End = transformPoint(FPoint(nextItem->Width/2, 0), nextItem->Xpos, nextItem->Ypos, nextItem->Rot, 1, 1); |
705 | fschmid | 413 | painter->setPen(black, 5.0 / Scale, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
414 | painter->setPenOpacity(0.3); |
||
415 | painter->drawLine(Start, End); |
||
416 | } |
||
417 | } |
||
456 | fschmid | 418 | } |
419 | } |
||
420 | painter->setLineWidth(1); |
||
421 | painter->setPenOpacity(1.0); |
||
422 | painter->restore(); |
||
423 | painter->setZoomFactor(z); |
||
424 | } |
||
425 | painter->end(); |
||
426 | delete painter; |
||
427 | } |
||
428 | if (SelItem.count() != 0) |
||
429 | { |
||
1957 | cbradney | 430 | PageItem *currItem = SelItem.at(0); |
431 | currItem->paintObj(); |
||
432 | if ((Doc->EditClip) && (currItem->Select)) |
||
433 | MarkClip(currItem); |
||
456 | fschmid | 434 | if (GroupSel) |
435 | { |
||
436 | setGroupRect(); |
||
437 | paintGroupRect(); |
||
438 | } |
||
439 | } |
||
2603 | cbradney | 440 | if (Doc->appMode == modeEdit) |
456 | fschmid | 441 | slotDoCurs(true); |
2603 | cbradney | 442 | if (Doc->appMode == modeEditGradientVectors) |
735 | fschmid | 443 | { |
1957 | cbradney | 444 | PageItem *currItem = SelItem.at(0); |
735 | fschmid | 445 | QPainter p; |
446 | p.begin(viewport()); |
||
447 | ToView(&p); |
||
1957 | cbradney | 448 | Transform(currItem, &p); |
735 | fschmid | 449 | p.setPen(QPen(blue, 1, SolidLine, FlatCap, MiterJoin)); |
450 | p.setBrush(NoBrush); |
||
1957 | cbradney | 451 | p.drawLine(QPoint(qRound(currItem->GrStartX), qRound(currItem->GrStartY)), QPoint(qRound(currItem->GrEndX), qRound(currItem->GrEndY))); |
735 | fschmid | 452 | p.setPen(QPen(magenta, 8, SolidLine, RoundCap, MiterJoin)); |
1957 | cbradney | 453 | p.drawLine(QPoint(qRound(currItem->GrStartX), qRound(currItem->GrStartY)), QPoint(qRound(currItem->GrStartX), qRound(currItem->GrStartY))); |
454 | p.drawLine(QPoint(qRound(currItem->GrEndX), qRound(currItem->GrEndY)), QPoint(qRound(currItem->GrEndX), qRound(currItem->GrEndY))); |
||
735 | fschmid | 455 | p.end(); |
456 | } |
||
2171 | fschmid | 457 | evSpon = false; |
456 | fschmid | 458 | // qDebug( "Time elapsed: %d ms", tim.elapsed() ); |
459 | } |
||
460 | |||
461 | void ScribusView::DrawMasterItems(ScPainter *painter, Page *page, QRect clip) |
||
462 | { |
||
463 | QPainter p; |
||
464 | int Lnr; |
||
465 | struct Layer ll; |
||
1957 | cbradney | 466 | PageItem *currItem; |
1065 | cbradney | 467 | ll.isViewable = false; |
456 | fschmid | 468 | ll.LNr = 0; |
469 | double z = painter->zoomFactor(); |
||
470 | if (page->MPageNam != "") |
||
471 | { |
||
472 | Page* Mp = Doc->MasterPages.at(Doc->MasterNames[page->MPageNam]); |
||
473 | if (page->FromMaster.count() != 0) |
||
474 | { |
||
475 | Lnr = 0; |
||
476 | for (uint la = 0; la < Doc->Layers.count(); ++la) |
||
477 | { |
||
478 | Level2Layer(Doc, &ll, Lnr); |
||
1874 | fschmid | 479 | bool pr = true; |
480 | if ((previewMode) && (!ll.isPrintable)) |
||
481 | pr = false; |
||
482 | if ((ll.isViewable) && (pr)) |
||
456 | fschmid | 483 | { |
484 | for (uint a = 0; a < page->FromMaster.count(); ++a) |
||
485 | { |
||
1957 | cbradney | 486 | currItem = page->FromMaster.at(a); |
487 | if (currItem->LayerNr != ll.LNr) |
||
456 | fschmid | 488 | continue; |
1957 | cbradney | 489 | if ((currItem->OwnPage != -1) && (currItem->OwnPage != static_cast<int>(Mp->PageNr))) |
456 | fschmid | 490 | continue; |
2449 | cbradney | 491 | if ((previewMode) && (!currItem->printable())) |
1874 | fschmid | 492 | continue; |
1957 | cbradney | 493 | currItem->savedOwnPage = currItem->OwnPage; |
494 | double OldX = currItem->Xpos; |
||
495 | double OldY = currItem->Ypos; |
||
496 | double OldBX = currItem->BoundingX; |
||
497 | double OldBY = currItem->BoundingY; |
||
498 | currItem->OwnPage = page->PageNr; |
||
499 | if (!currItem->ChangedMasterItem) |
||
456 | fschmid | 500 | { |
1957 | cbradney | 501 | currItem->Xpos = OldX - Mp->Xoffset + page->Xoffset; |
502 | currItem->Ypos = OldY - Mp->Yoffset + page->Yoffset; |
||
503 | currItem->BoundingX = OldBX - Mp->Xoffset + page->Xoffset; |
||
504 | currItem->BoundingY = OldBY - Mp->Yoffset + page->Yoffset; |
||
456 | fschmid | 505 | } |
2171 | fschmid | 506 | if (evSpon) |
507 | currItem->Dirty = true; |
||
1957 | cbradney | 508 | QRect oldR = getRedrawBounding(currItem); |
537 | fschmid | 509 | if (clip.intersects(oldR)) |
1957 | cbradney | 510 | currItem->DrawObj(painter, clip); |
511 | currItem->OwnPage = currItem->savedOwnPage; |
||
512 | if (!currItem->ChangedMasterItem) |
||
456 | fschmid | 513 | { |
1957 | cbradney | 514 | currItem->Xpos = OldX; |
515 | currItem->Ypos = OldY; |
||
516 | currItem->BoundingX = OldBX; |
||
517 | currItem->BoundingY = OldBY; |
||
456 | fschmid | 518 | } |
519 | } |
||
520 | for (uint a = 0; a < page->FromMaster.count(); ++a) |
||
521 | { |
||
1957 | cbradney | 522 | currItem = page->FromMaster.at(a); |
523 | if (currItem->LayerNr != ll.LNr) |
||
456 | fschmid | 524 | continue; |
1957 | cbradney | 525 | if (!currItem->isTableItem) |
456 | fschmid | 526 | continue; |
1957 | cbradney | 527 | if ((currItem->OwnPage != -1) && (currItem->OwnPage != static_cast<int>(Mp->PageNr))) |
456 | fschmid | 528 | continue; |
1957 | cbradney | 529 | double OldX = currItem->Xpos; |
530 | double OldY = currItem->Ypos; |
||
531 | double OldBX = currItem->BoundingX; |
||
532 | double OldBY = currItem->BoundingY; |
||
533 | if (!currItem->ChangedMasterItem) |
||
456 | fschmid | 534 | { |
1957 | cbradney | 535 | currItem->Xpos = OldX - Mp->Xoffset + page->Xoffset; |
536 | currItem->Ypos = OldY - Mp->Yoffset + page->Yoffset; |
||
537 | currItem->BoundingX = OldBX - Mp->Xoffset + page->Xoffset; |
||
538 | currItem->BoundingY = OldBY - Mp->Yoffset + page->Yoffset; |
||
456 | fschmid | 539 | } |
1957 | cbradney | 540 | QRect oldR = getRedrawBounding(currItem); |
537 | fschmid | 541 | if (clip.intersects(oldR)) |
456 | fschmid | 542 | { |
543 | painter->setZoomFactor(Scale); |
||
544 | painter->save(); |
||
1957 | cbradney | 545 | painter->translate(currItem->Xpos*Scale, currItem->Ypos*Scale); |
546 | painter->rotate(currItem->Rot); |
||
547 | if (currItem->lineColor() != "None") |
||
456 | fschmid | 548 | { |
549 | QColor tmp; |
||
1957 | cbradney | 550 | currItem->SetFarbe(&tmp, currItem->lineColor(), currItem->lineShade()); |
551 | if ((currItem->TopLine) || (currItem->RightLine) || (currItem->BottomLine) || (currItem->LeftLine)) |
||
456 | fschmid | 552 | { |
1957 | cbradney | 553 | painter->setPen(tmp, currItem->Pwidth, currItem->PLineArt, Qt::SquareCap, currItem->PLineJoin); |
554 | if (currItem->TopLine) |
||
555 | painter->drawLine(FPoint(0.0, 0.0), FPoint(currItem->Width, 0.0)); |
||
556 | if (currItem->RightLine) |
||
557 | painter->drawLine(FPoint(currItem->Width, 0.0), FPoint(currItem->Width, currItem->Height)); |
||
558 | if (currItem->BottomLine) |
||
559 | painter->drawLine(FPoint(currItem->Width, currItem->Height), FPoint(0.0, currItem->Height)); |
||
560 | if (currItem->LeftLine) |
||
561 | painter->drawLine(FPoint(0.0, currItem->Height), FPoint(0.0, 0.0)); |
||
456 | fschmid | 562 | } |
563 | } |
||
564 | painter->restore(); |
||
565 | } |
||
1957 | cbradney | 566 | if (!currItem->ChangedMasterItem) |
456 | fschmid | 567 | { |
1957 | cbradney | 568 | currItem->Xpos = OldX; |
569 | currItem->Ypos = OldY; |
||
570 | currItem->BoundingX = OldBX; |
||
571 | currItem->BoundingY = OldBY; |
||
456 | fschmid | 572 | } |
573 | } |
||
574 | } |
||
575 | Lnr++; |
||
576 | } |
||
577 | } |
||
578 | } |
||
579 | painter->setZoomFactor(z); |
||
580 | } |
||
581 | |||
582 | void ScribusView::DrawPageItems(ScPainter *painter, QRect clip) |
||
583 | { |
||
584 | QPainter p; |
||
585 | int Lnr; |
||
586 | struct Layer ll; |
||
1957 | cbradney | 587 | PageItem *currItem; |
1065 | cbradney | 588 | ll.isViewable = false; |
456 | fschmid | 589 | ll.LNr = 0; |
705 | fschmid | 590 | linkedFramesToShow.clear(); |
456 | fschmid | 591 | double z = painter->zoomFactor(); |
592 | if (Doc->Items.count() != 0) |
||
593 | { |
||
594 | Lnr = 0; |
||
595 | for (uint la2 = 0; la2 < Doc->Layers.count(); ++la2) |
||
596 | { |
||
597 | Level2Layer(Doc, &ll, Lnr); |
||
1874 | fschmid | 598 | bool pr = true; |
599 | if ((previewMode) && (!ll.isPrintable)) |
||
600 | pr = false; |
||
601 | if ((ll.isViewable) && (pr)) |
||
456 | fschmid | 602 | { |
1485 | tsoots | 603 | QPtrListIterator<PageItem> docItem(Doc->Items); |
2538 | fschmid | 604 | while ( (currItem = docItem.current()) != 0) |
456 | fschmid | 605 | { |
2434 | fschmid | 606 | ++docItem; |
1957 | cbradney | 607 | if (currItem->LayerNr != ll.LNr) |
456 | fschmid | 608 | continue; |
2449 | cbradney | 609 | if ((previewMode) && (!currItem->printable())) |
1874 | fschmid | 610 | continue; |
1957 | cbradney | 611 | if ((Doc->MasterP) && ((currItem->OwnPage != -1) && (currItem->OwnPage != static_cast<int>(Doc->currentPage->PageNr)))) |
456 | fschmid | 612 | continue; |
1957 | cbradney | 613 | if ((!Doc->MasterP) && (currItem->OnMasterPage != "")) |
1781 | fschmid | 614 | { |
1957 | cbradney | 615 | if (currItem->OnMasterPage != Doc->currentPage->PageNam) |
1781 | fschmid | 616 | continue; |
617 | } |
||
1957 | cbradney | 618 | QRect oldR = getRedrawBounding(currItem); |
537 | fschmid | 619 | if (clip.intersects(oldR)) |
456 | fschmid | 620 | { |
2171 | fschmid | 621 | if (evSpon) |
622 | currItem->Dirty = true; |
||
456 | fschmid | 623 | if (!((Doc->EditClip) && (Mpressed))) |
1957 | cbradney | 624 | currItem->DrawObj(painter, clip); |
625 | currItem->Redrawn = true; |
||
626 | if ((currItem->itemType() == PageItem::TextFrame) && ((currItem->NextBox != 0) || (currItem->BackBox != 0))) |
||
705 | fschmid | 627 | { |
1957 | cbradney | 628 | PageItem *nextItem = currItem; |
629 | while (nextItem != 0) |
||
705 | fschmid | 630 | { |
1957 | cbradney | 631 | if (nextItem->BackBox != 0) |
632 | nextItem = nextItem->BackBox; |
||
705 | fschmid | 633 | else |
634 | break; |
||
635 | } |
||
1957 | cbradney | 636 | if (linkedFramesToShow.find(nextItem) == -1) |
637 | linkedFramesToShow.append(nextItem); |
||
705 | fschmid | 638 | } |
2603 | cbradney | 639 | if ((Doc->appMode == modeEdit) && (currItem->Select) && (currItem->itemType() == PageItem::TextFrame)) |
456 | fschmid | 640 | { |
1764 | cbradney | 641 | //CB 230305 Stop redrawing the horizontal ruler if it hasnt changed when typing text!!! |
1957 | cbradney | 642 | if ((qRound(horizRuler->ItemPos*10000) != qRound((currItem->Xpos - Doc->ScratchLeft)*10000)) || (qRound(horizRuler->ItemEndPos*10000) != qRound(((currItem->Xpos+currItem->Width) - Doc->ScratchLeft)*10000))) |
1764 | cbradney | 643 | { |
1957 | cbradney | 644 | horizRuler->ItemPos = currItem->Xpos - Doc->ScratchLeft; |
645 | horizRuler->ItemEndPos = (currItem->Xpos+currItem->Width) - Doc->ScratchLeft; |
||
646 | if (currItem->lineColor() != "None") |
||
647 | horizRuler->lineCorr = currItem->Pwidth / 2.0; |
||
1764 | cbradney | 648 | else |
649 | horizRuler->lineCorr = 0; |
||
1957 | cbradney | 650 | horizRuler->ColGap = currItem->ColGap; |
651 | horizRuler->Cols = currItem->Cols; |
||
652 | horizRuler->Extra = currItem->Extra; |
||
653 | horizRuler->RExtra = currItem->RExtra; |
||
1764 | cbradney | 654 | horizRuler->First = Doc->docParagraphStyles[Doc->currentParaStyle].First; |
655 | horizRuler->Indent = Doc->docParagraphStyles[Doc->currentParaStyle].Indent; |
||
1957 | cbradney | 656 | if (currItem->imageFlippedH() || (currItem->Reverse)) |
1764 | cbradney | 657 | horizRuler->Revers = true; |
658 | else |
||
659 | horizRuler->Revers = false; |
||
660 | horizRuler->ItemPosValid = true; |
||
661 | horizRuler->repX = false; |
||
662 | if (Doc->currentParaStyle < 5) |
||
1957 | cbradney | 663 | horizRuler->TabValues = currItem->TabValues; |
1764 | cbradney | 664 | else |
665 | horizRuler->TabValues = Doc->docParagraphStyles[Doc->currentParaStyle].TabValues; |
||
666 | horizRuler->repaint(); |
||
667 | } |
||
456 | fschmid | 668 | } |
669 | } |
||
670 | } |
||
1485 | tsoots | 671 | QPtrListIterator<PageItem> docItem2(Doc->Items); |
1957 | cbradney | 672 | while ( (currItem = docItem2.current()) != 0 ) |
456 | fschmid | 673 | { |
2538 | fschmid | 674 | ++docItem2; |
1957 | cbradney | 675 | if (currItem->LayerNr != ll.LNr) |
456 | fschmid | 676 | continue; |
1957 | cbradney | 677 | if (!currItem->isTableItem) |
456 | fschmid | 678 | continue; |
1957 | cbradney | 679 | QRect oldR = getRedrawBounding(currItem); |
537 | fschmid | 680 | if (clip.intersects(oldR)) |
456 | fschmid | 681 | { |
682 | painter->setZoomFactor(Scale); |
||
683 | painter->save(); |
||
1957 | cbradney | 684 | painter->translate(currItem->Xpos*Scale, currItem->Ypos*Scale); |
685 | painter->rotate(currItem->Rot); |
||
686 | if (currItem->lineColor() != "None") |
||
456 | fschmid | 687 | { |
688 | QColor tmp; |
||
1957 | cbradney | 689 | currItem->SetFarbe(&tmp, currItem->lineColor(), currItem->lineShade()); |
690 | if ((currItem->TopLine) || (currItem->RightLine) || (currItem->BottomLine) || (currItem->LeftLine)) |
||
456 | fschmid | 691 | { |
1957 | cbradney | 692 | painter->setPen(tmp, currItem->Pwidth, currItem->PLineArt, Qt::SquareCap, currItem->PLineJoin); |
693 | if (currItem->TopLine) |
||
694 | painter->drawLine(FPoint(0.0, 0.0), FPoint(currItem->Width, 0.0)); |
||
695 | if (currItem->RightLine) |
||
696 | painter->drawLine(FPoint(currItem->Width, 0.0), FPoint(currItem->Width, currItem->Height)); |
||
697 | if (currItem->BottomLine) |
||
698 | painter->drawLine(FPoint(currItem->Width, currItem->Height), FPoint(0.0, currItem->Height)); |
||
699 | if (currItem->LeftLine) |
||
700 | painter->drawLine(FPoint(0.0, currItem->Height), FPoint(0.0, 0.0)); |
||
456 | fschmid | 701 | } |
702 | } |
||
703 | painter->restore(); |
||
704 | } |
||
705 | } |
||
706 | } |
||
707 | Lnr++; |
||
708 | } |
||
709 | } |
||
710 | painter->setZoomFactor(z); |
||
711 | } |
||
712 | |||
693 | fschmid | 713 | void ScribusView::DrawPageMarks(ScPainter *p, Page *page, QRect) |
456 | fschmid | 714 | { |
715 | double lw = 1.0 / Scale; |
||
716 | double z = p->zoomFactor(); |
||
717 | p->save(); |
||
718 | p->setZoomFactor(Scale); |
||
719 | p->translate(page->Xoffset * Scale, page->Yoffset * Scale); |
||
720 | p->setLineWidth(lw); |
||
879 | fschmid | 721 | if (Doc->guidesSettings.marginsShown) |
456 | fschmid | 722 | { |
879 | fschmid | 723 | p->setPen(Doc->guidesSettings.margColor); |
1065 | cbradney | 724 | if (Doc->marginColored) |
456 | fschmid | 725 | { |
879 | fschmid | 726 | p->setBrush(Doc->guidesSettings.margColor); |
456 | fschmid | 727 | p->drawRect(0, 0, page->Width, page->Margins.Top); |
728 | p->drawRect(0, page->Margins.Top, page->Margins.Left, page->Height - page->Margins.Top); |
||
729 | p->drawRect(page->Margins.Left, page->Height - page->Margins.Bottom, page->Width - page->Margins.Right - page->Margins.Left, page->Margins.Bottom); |
||
1615 | fschmid | 730 | p->drawRect(page->Width - page->Margins.Right, page->Margins.Top, page->Margins.Right, page->Height-page->Margins.Top); |
456 | fschmid | 731 | } |
879 | fschmid | 732 | p->setPen(Doc->guidesSettings.margColor); |
456 | fschmid | 733 | p->drawLine(FPoint(0, page->Margins.Top), FPoint(page->Width, page->Margins.Top)); |
734 | p->drawLine(FPoint(0, page->Height - page->Margins.Bottom), FPoint(page->Width, page->Height - page->Margins.Bottom)); |
||
735 | p->drawLine(FPoint(page->Margins.Left, 0), FPoint(page->Margins.Left, page->Height)); |
||
736 | p->drawLine(FPoint(page->Width - page->Margins.Right, 0), FPoint(page->Width - page->Margins.Right, page->Height)); |
||
737 | } |
||
879 | fschmid | 738 | if (Doc->guidesSettings.baseShown) |
456 | fschmid | 739 | { |
879 | fschmid | 740 | p->setPen(Doc->guidesSettings.baseColor, lw, SolidLine, FlatCap, MiterJoin); |
823 | fschmid | 741 | for (double yg = Doc->typographicSetttings.offsetBaseGrid; yg < page->Height; yg += Doc->typographicSetttings.valueBaseGrid) |
456 | fschmid | 742 | p->drawLine(FPoint(0, yg), FPoint(page->Width, yg)); |
743 | } |
||
879 | fschmid | 744 | if (Doc->guidesSettings.gridShown) |
456 | fschmid | 745 | { |
746 | double stx = 0; |
||
747 | double endx = page->Width; |
||
748 | double sty = 0; |
||
749 | double endy = page->Height; |
||
1781 | fschmid | 750 | /* double stx = QMAX((clip.x() - page->Xoffset) / Scale, 0); |
456 | fschmid | 751 | double endx = QMIN(stx + clip.width() / Scale, page->Width); |
1781 | fschmid | 752 | double sty = QMAX((clip.y() - page->Yoffset) / Scale, 0); |
456 | fschmid | 753 | double endy = QMIN(sty + clip.height() / Scale, page->Height); */ |
754 | if (Scale > 0.49) |
||
755 | { |
||
756 | double i,start; |
||
879 | fschmid | 757 | i = Doc->guidesSettings.majorGrid; |
758 | p->setPen(Doc->guidesSettings.majorColor, lw, SolidLine, FlatCap, MiterJoin); |
||
456 | fschmid | 759 | start=floor(sty/i); |
760 | start*=i; |
||
761 | for (double b = start; b < endy; b+=i) |
||
762 | { |
||
763 | p->drawLine(FPoint(0, b), FPoint(page->Width, b)); |
||
764 | } |
||
765 | start=floor(stx/i); |
||
766 | start*=i; |
||
767 | for (double b = start; b <= endx; b+=i) |
||
768 | { |
||
769 | p->drawLine(FPoint(b, 0), FPoint(b, page->Height)); |
||
770 | } |
||
879 | fschmid | 771 | i = Doc->guidesSettings.minorGrid; |
772 | p->setPen(Doc->guidesSettings.minorColor, lw, DotLine, FlatCap, MiterJoin); |
||
456 | fschmid | 773 | start=floor(sty/i); |
774 | start*=i; |
||
775 | for (double b = start; b < endy; b+=i) |
||
776 | { |
||
777 | p->drawLine(FPoint(0, b), FPoint(page->Width, b)); |
||
778 | } |
||
779 | start=floor(stx/i); |
||
780 | start*=i; |
||
781 | for (double b = start; b <= endx; b+=i) |
||
782 | { |
||
783 | p->drawLine(FPoint(b, 0), FPoint(b, page->Height)); |
||
784 | } |
||
785 | } |
||
786 | } |
||
879 | fschmid | 787 | if (Doc->guidesSettings.guidesShown) |
456 | fschmid | 788 | { |
879 | fschmid | 789 | p->setPen(Doc->guidesSettings.guideColor, lw, DotLine, FlatCap, MiterJoin); |
456 | fschmid | 790 | if (page->XGuides.count() != 0) |
791 | { |
||
792 | for (uint xg = 0; xg < page->XGuides.count(); ++xg) |
||
793 | p->drawLine(FPoint(page->XGuides[xg], 0), FPoint(page->XGuides[xg], page->Height)); |
||
794 | } |
||
795 | if (page->YGuides.count() != 0) |
||
796 | { |
||
797 | for (uint yg = 0; yg < page->YGuides.count(); ++yg) |
||
798 | p->drawLine(FPoint(0, page->YGuides[yg]), FPoint(page->Width, page->YGuides[yg])); |
||
799 | } |
||
800 | } |
||
801 | p->restore(); |
||
802 | p->setZoomFactor(z); |
||
803 | } |
||
804 | |||
805 | void ScribusView::leaveEvent(QEvent *) |
||
806 | { |
||
807 | /* if (BlockLeave) |
||
808 | return; */ |
||
809 | if (!Mpressed) |
||
810 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
||
811 | /* else |
||
812 | { |
||
1065 | cbradney | 813 | if ((SelItem.count() != 0) && (Mpressed) && (!doku->DragP) && (doku->appMode == 1)) |
456 | fschmid | 814 | { |
1957 | cbradney | 815 | PageItem *currItem = SelItem.at(0); |
456 | fschmid | 816 | if ((b->Locked) || (b->Sizing)) |
817 | return; |
||
818 | doku->DragP = true; |
||
819 | doku->leaveDrag = true; |
||
820 | doku->DraggedElem = b; |
||
821 | doku->DragElements.clear(); |
||
822 | for (uint dre=0; dre<SelItem.count(); ++dre) |
||
823 | doku->DragElements.append(SelItem.at(dre)->ItemNr); |
||
824 | ScriXmlDoc *ss = new ScriXmlDoc(); |
||
825 | QDragObject *dr = new QTextDrag(ss->WriteElem(&SelItem, doku), this); |
||
826 | dr->setPixmap(loadIcon("DragPix.xpm")); |
||
827 | dr->drag(); |
||
828 | delete ss; |
||
829 | doku->DragP = false; |
||
830 | doku->leaveDrag = false; |
||
831 | Mpressed = false; |
||
832 | doku->DraggedElem = 0; |
||
833 | doku->DragElements.clear(); |
||
834 | } |
||
835 | } */ |
||
836 | } |
||
837 | |||
838 | void ScribusView::contentsDragEnterEvent(QDragEnterEvent *e) |
||
839 | { |
||
840 | QString text; |
||
841 | e->accept(QTextDrag::canDecode(e)); |
||
842 | if (QTextDrag::decode(e, text)) |
||
843 | { |
||
844 | double gx, gy, gw, gh; |
||
845 | setActiveWindow(); |
||
846 | raise(); |
||
847 | ScApp->newActWin(Doc->WinHan); |
||
848 | updateContents(); |
||
849 | // SeleItemPos(e->pos()); |
||
850 | QUrl ur(text); |
||
851 | QFileInfo fi = QFileInfo(ur.path()); |
||
852 | ScriXmlDoc *ss = new ScriXmlDoc(); |
||
853 | if (fi.exists()) |
||
854 | text = ur.path(); |
||
855 | if(ss->ReadElemHeader(text,fi.exists(), &gx, &gy, &gw, &gh)) |
||
856 | { |
||
857 | GroupX = e->pos().x() / Scale; |
||
858 | GroupY = e->pos().y() / Scale; |
||
859 | GroupW = gw; |
||
860 | GroupH = gh; |
||
861 | DraggedGroup = true; |
||
862 | DraggedGroupFirst = true; |
||
863 | GroupSel = false; |
||
864 | QPainter p; |
||
865 | p.begin(viewport()); |
||
866 | PaintSizeRect(&p, QRect()); |
||
867 | // QPoint pv = QPoint(qRound(gx), qRound(gy)); |
||
868 | // PaintSizeRect(&p, QRect(pv, QPoint(pv.x()+qRound(gw), pv.y()+qRound(gh)))); |
||
869 | p.end(); |
||
870 | } |
||
871 | delete ss; |
||
872 | } |
||
873 | } |
||
874 | |||
875 | void ScribusView::contentsDragMoveEvent(QDragMoveEvent *e) |
||
876 | { |
||
877 | QString text; |
||
1957 | cbradney | 878 | // PageItem *currItem; |
456 | fschmid | 879 | // bool img; |
880 | e->accept(QTextDrag::canDecode(e)); |
||
881 | if (QTextDrag::decode(e, text)) |
||
882 | { |
||
883 | if (DraggedGroup) |
||
884 | { |
||
885 | double gx, gy, gw, gh; |
||
886 | GroupX = e->pos().x() / Scale; |
||
887 | GroupY = e->pos().y() / Scale; |
||
888 | getGroupRectScreen(&gx, &gy, &gw, &gh); |
||
889 | QPainter p; |
||
890 | p.begin(viewport()); |
||
891 | QPoint pv = QPoint(qRound(gx), qRound(gy)); |
||
892 | if (!DraggedGroupFirst) |
||
893 | PaintSizeRect(&p, QRect(pv, QPoint(pv.x()+qRound(gw), pv.y()+qRound(gh)))); |
||
894 | DraggedGroupFirst = false; |
||
895 | p.end(); |
||
1065 | cbradney | 896 | emit MousePos(GroupX-Doc->currentPage->Xoffset, GroupY-Doc->currentPage->Yoffset); |
1612 | cbradney | 897 | horizRuler->Draw(e->pos().x()); |
898 | vertRuler->Draw(e->pos().y()); |
||
456 | fschmid | 899 | return; |
900 | } |
||
901 | /* QUrl ur(text); |
||
902 | QFileInfo fi = QFileInfo(ur.path()); |
||
903 | QString ext = fi.extension(false).upper(); |
||
904 | QStrList imfo = QImageIO::inputFormats(); |
||
905 | if (ext == "JPG") |
||
906 | ext = "JPEG"; |
||
907 | img = ((imfo.contains(ext))||(ext=="PS")||(ext=="EPS")||(ext=="TIF")); |
||
908 | if (!SeleItemPos(e->pos())) |
||
909 | { |
||
910 | if (SelItem.count() != 0) |
||
911 | Deselect(true); |
||
912 | } |
||
913 | else |
||
914 | { |
||
915 | b = SelItem.at(0); |
||
916 | if (img) |
||
917 | { |
||
918 | if (b->PType != 2) |
||
919 | Deselect(true); |
||
920 | } |
||
921 | else |
||
922 | { |
||
923 | if (b->PType != 4) |
||
924 | Deselect(true); |
||
925 | } |
||
926 | } */ |
||
927 | } |
||
928 | } |
||
929 | |||
632 | fschmid | 930 | void ScribusView::contentsDragLeaveEvent(QDragLeaveEvent *) |
456 | fschmid | 931 | { |
932 | if (DraggedGroup) |
||
933 | { |
||
934 | updateContents(); |
||
935 | DraggedGroup = false; |
||
936 | DraggedGroupFirst = false; |
||
937 | } |
||
938 | } |
||
939 | |||
940 | void ScribusView::contentsDropEvent(QDropEvent *e) |
||
941 | { |
||
942 | QString text; |
||
1957 | cbradney | 943 | PageItem *currItem; |
456 | fschmid | 944 | bool img = false; |
1065 | cbradney | 945 | // struct ScText *hg; |
456 | fschmid | 946 | // uint a; |
693 | fschmid | 947 | int re = 0; |
456 | fschmid | 948 | e->accept(QTextDrag::canDecode(e)); |
949 | DraggedGroupFirst = false; |
||
950 | if (QTextDrag::decode(e, text)) |
||
951 | { |
||
952 | QUrl ur(text); |
||
953 | QFileInfo fi = QFileInfo(ur.path()); |
||
954 | QString ext = fi.extension(false).upper(); |
||
955 | QStrList imfo = QImageIO::inputFormats(); |
||
956 | if (ext == "JPG") |
||
957 | ext = "JPEG"; |
||
958 | img = ((imfo.contains(ext))||(ext=="PS")||(ext=="EPS")||(ext=="PDF")||(ext=="TIF")); |
||
959 | /* if ((fi.exists()) && (img) && (!SeleItemPos(e->pos()))) |
||
960 | { |
||
961 | int z = PaintPict(qRound(e->pos().x()/doku->Scale), qRound(e->pos().y()/doku->Scale), 1, 1); |
||
962 | b = Items.at(z); |
||
963 | LoadPict(ur.path(), b->ItemNr); |
||
964 | b->Width = static_cast<double>(b->pixm.width()); |
||
965 | b->Height = static_cast<double>(b->pixm.height()); |
||
966 | b->OldB2 = b->Width; |
||
967 | b->OldH2 = b->Height; |
||
968 | UpdateClip(b); |
||
969 | emit DocChanged(); |
||
970 | update(); |
||
971 | return; |
||
972 | } */ |
||
973 | /* if ((SeleItemPos(e->pos())) && (!text.startsWith("<SCRIBUSELEM"))) |
||
974 | { |
||
975 | b = SelItem.at(0); |
||
1460 | cbradney | 976 | if (b->itemType() == PageItem::ImageFrame) |
456 | fschmid | 977 | { |
978 | if ((fi.exists()) && (img)) |
||
979 | { |
||
980 | LoadPict(ur.path(), b->ItemNr); |
||
981 | update(); |
||
982 | } |
||
983 | } |
||
984 | if (b->PType == 4) |
||
985 | { |
||
1065 | cbradney | 986 | if ((b->BackBox != 0) && (b->itemText.count() == 0)) |
456 | fschmid | 987 | return; |
988 | if ((fi.exists()) && (!img) && (fi.size() < 500000)) |
||
989 | { |
||
990 | Serializer *ss = new Serializer(ur.path()); |
||
991 | if (ss->Read()) |
||
992 | { |
||
1065 | cbradney | 993 | int st = doku->currentParaStyle; |
994 | ss->GetText(b, st, doku->docParagraphStyles[st].Font, doku->docParagraphStyles[st].FontSize, true); |
||
456 | fschmid | 995 | emit DocChanged(); |
996 | } |
||
997 | delete ss; |
||
998 | update(); |
||
999 | } |
||
1000 | else |
||
1001 | { |
||
1002 | slotDoCurs(false); |
||
1003 | slotSetCurs(e->pos().x(), e->pos().y()); |
||
1004 | if (text.startsWith("<SCRIBUSELEM")) |
||
1005 | return; |
||
1006 | for (a=0; a<text.length(); ++a) |
||
1007 | { |
||
1065 | cbradney | 1008 | hg = new ScText; |
456 | fschmid | 1009 | hg->ch = text.at(a); |
1010 | if (hg->ch == QChar(10)) |
||
1011 | hg->ch = QChar(13); |
||
1012 | if (hg->ch == QChar(4)) |
||
1013 | hg->ch = QChar(9); |
||
1014 | if (hg->ch == QChar(5)) |
||
1015 | hg->ch = QChar(13); |
||
1016 | hg->cfont = b->IFont; |
||
1017 | hg->csize = b->ISize; |
||
1018 | hg->ccolor = b->TxtFill; |
||
1019 | hg->cshade = b->ShTxtFill; |
||
1020 | hg->cstroke = b->TxtStroke; |
||
1021 | hg->cshade2 = b->ShTxtStroke; |
||
1022 | hg->cselect = false; |
||
1023 | hg->cscale = b->TxtScale; |
||
1024 | hg->cextra = 0; |
||
1025 | hg->cstyle = 0; |
||
1026 | hg->cab = 0; |
||
1027 | hg->xp = 0; |
||
1028 | hg->yp = 0; |
||
1029 | hg->PRot = 0; |
||
1030 | hg->PtransX = 0; |
||
1031 | hg->PtransY = 0; |
||
1065 | cbradney | 1032 | b->itemText.insert(b->CPos, hg); |
456 | fschmid | 1033 | b->CPos += 1; |
1034 | } |
||
1035 | emit DocChanged(); |
||
1036 | update(); |
||
1037 | } |
||
1038 | } |
||
1039 | } |
||
1040 | else |
||
1041 | { */ |
||
855 | fschmid | 1042 | for (uint as = 0; as < Doc->Items.count(); ++as) |
1043 | { |
||
1044 | Doc->Items.at(as)->Select = false; |
||
1045 | } |
||
456 | fschmid | 1046 | uint ac = Doc->Items.count(); |
1047 | if ((!img) && (Doc->DraggedElem == 0)) |
||
1163 | fschmid | 1048 | { |
1049 | if ((fi.exists()) && (!img)) |
||
1050 | emit LoadElem(ur.path(), qRound(e->pos().x()/Scale), qRound(e->pos().y()/Scale), true, false, Doc, this); |
||
1051 | else |
||
1052 | emit LoadElem(QString(text), qRound(e->pos().x()/Scale), qRound(e->pos().y()/Scale), false, false, Doc, this); |
||
2233 | fschmid | 1053 | SelItem.clear(); |
1054 | for (uint as = ac; as < Doc->Items.count(); ++as) |
||
1055 | { |
||
1056 | currItem = Doc->Items.at(as); |
||
1057 | if (currItem->isBookmark) |
||
1058 | emit AddBM(currItem); |
||
1059 | SelectItemNr(as); |
||
1060 | } |
||
1163 | fschmid | 1061 | } |
456 | fschmid | 1062 | else |
1063 | { |
||
1064 | if (Doc->DraggedElem != 0) |
||
1065 | { |
||
1066 | if (!Doc->leaveDrag) |
||
1067 | { |
||
1068 | QPopupMenu *pmen = new QPopupMenu(); |
||
1069 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
||
1070 | pmen->insertItem( tr("Copy Here")); |
||
1071 | pmen->insertItem( tr("Move Here")); |
||
1072 | pmen->insertItem( tr("Cancel")); |
||
1073 | re = pmen->indexOf(pmen->exec(QCursor::pos())); |
||
1074 | delete pmen; |
||
1075 | } |
||
1076 | else |
||
1077 | re = 1; |
||
1078 | if ((re == 2) || (re == -1)) |
||
1079 | { |
||
1080 | updateContents(); |
||
1081 | return; |
||
1082 | } |
||
1083 | if ((re == 1) || (Doc->leaveDrag)) |
||
1084 | { |
||
1085 | QPtrList<PageItem> pasted; |
||
1086 | emit LoadElem(QString(text), qRound(e->pos().x()/Scale), qRound(e->pos().y()/Scale), false, false, Doc, this); |
||
1087 | for (uint as = ac; as < Doc->Items.count(); ++as) |
||
1088 | { |
||
1089 | pasted.append(Doc->Items.at(as)); |
||
1090 | } |
||
1091 | SelItem.clear(); |
||
1092 | for (uint dre=0; dre<Doc->DragElements.count(); ++dre) |
||
1093 | { |
||
1094 | SelItem.append(Doc->Items.at(Doc->DragElements[dre])); |
||
1095 | } |
||
1096 | PageItem* bb; |
||
1097 | int fin; |
||
1098 | for (uint dre=0; dre<Doc->DragElements.count(); ++dre) |
||
1099 | { |
||
1100 | bb = pasted.at(dre); |
||
1957 | cbradney | 1101 | currItem = SelItem.at(dre); |
1102 | if ((currItem->itemType() == PageItem::TextFrame) && ((currItem->NextBox != 0) || (currItem->BackBox != 0))) |
||
456 | fschmid | 1103 | { |
1957 | cbradney | 1104 | if (currItem->BackBox != 0) |
456 | fschmid | 1105 | { |
1957 | cbradney | 1106 | bb->BackBox = currItem->BackBox; |
1107 | fin = SelItem.find(currItem->BackBox); |
||
456 | fschmid | 1108 | if (fin != -1) |
1109 | bb->BackBox = pasted.at(fin); |
||
1110 | bb->BackBox->NextBox = bb; |
||
1111 | } |
||
1957 | cbradney | 1112 | if (currItem->NextBox != 0) |
456 | fschmid | 1113 | { |
1957 | cbradney | 1114 | bb->NextBox = currItem->NextBox; |
1115 | fin = SelItem.find(currItem->NextBox); |
||
456 | fschmid | 1116 | if (fin != -1) |
1117 | bb->NextBox = pasted.at(fin); |
||
1118 | bb->NextBox->BackBox = bb; |
||
1119 | } |
||
1120 | } |
||
1121 | } |
||
1122 | for (uint dre=0; dre<Doc->DragElements.count(); ++dre) |
||
1123 | { |
||
1957 | cbradney | 1124 | currItem = SelItem.at(dre); |
1125 | currItem->NextBox = 0; |
||
1126 | currItem->BackBox = 0; |
||
456 | fschmid | 1127 | } |
1128 | pasted.clear(); |
||
1129 | DeleteItem(); |
||
1130 | } |
||
1131 | } |
||
1132 | if ((!img) && ((re == 0))) |
||
1133 | emit LoadElem(QString(text), qRound(e->pos().x()/Scale), qRound(e->pos().y()/Scale), false, false, Doc, this); |
||
1134 | Doc->DraggedElem = 0; |
||
1135 | Doc->DragElements.clear(); |
||
1136 | SelItem.clear(); |
||
1137 | for (uint as = ac; as < Doc->Items.count(); ++as) |
||
1138 | { |
||
2193 | fschmid | 1139 | currItem = Doc->Items.at(as); |
1140 | if (currItem->isBookmark) |
||
1141 | emit AddBM(currItem); |
||
456 | fschmid | 1142 | SelectItemNr(as); |
1143 | } |
||
1144 | updateContents(); |
||
1145 | } |
||
1146 | // } |
||
1147 | } |
||
1148 | } |
||
1149 | |||
1150 | void ScribusView::contentsMouseDoubleClickEvent(QMouseEvent *m) |
||
1151 | { |
||
1152 | m->accept(); |
||
1153 | Mpressed = false; |
||
1957 | cbradney | 1154 | PageItem *currItem = 0; |
456 | fschmid | 1155 | if (Doc->EditClip) |
1156 | { |
||
1157 | emit EndNodeEdit(); |
||
1158 | return; |
||
1159 | } |
||
2603 | cbradney | 1160 | if ((GroupSel) || (Doc->appMode != modeNormal)) |
456 | fschmid | 1161 | { |
2603 | cbradney | 1162 | if ((GroupSel) && (Doc->appMode == modeNormal)) |
456 | fschmid | 1163 | { |
1957 | cbradney | 1164 | if (GetItem(&currItem)) |
456 | fschmid | 1165 | { |
1957 | cbradney | 1166 | if (currItem->isTableItem) |
456 | fschmid | 1167 | { |
1168 | Deselect(false); |
||
1957 | cbradney | 1169 | SelItem.append(currItem); |
1170 | currItem->isSingleSel = true; |
||
1171 | currItem->Select = true; |
||
1172 | emit HaveSel(currItem->itemType()); |
||
1173 | EmitValues(currItem); |
||
1174 | currItem->paintObj(); |
||
456 | fschmid | 1175 | } |
1176 | } |
||
1177 | } |
||
1178 | else |
||
1179 | contentsMousePressEvent(m); |
||
1180 | return; |
||
1181 | } |
||
1957 | cbradney | 1182 | if (GetItem(&currItem)) |
456 | fschmid | 1183 | { |
1957 | cbradney | 1184 | if ((currItem->itemType() == PageItem::Polygon) || (currItem->itemType() == PageItem::PolyLine) || (currItem->itemType() == PageItem::ImageFrame) || (currItem->itemType() == PageItem::PathText)) |
456 | fschmid | 1185 | { |
1957 | cbradney | 1186 | if ((currItem->locked()) || (!currItem->ScaleType)) |
456 | fschmid | 1187 | { |
1188 | contentsMousePressEvent(m); |
||
1189 | return; |
||
1190 | } |
||
2318 | fschmid | 1191 | if ((currItem->itemType() == PageItem::ImageFrame) && (currItem->Pfile=="")) |
1192 | emit LoadPic(); |
||
1193 | else |
||
2603 | cbradney | 1194 | emit Amode(modeEdit); |
456 | fschmid | 1195 | } |
1196 | else |
||
1957 | cbradney | 1197 | if (currItem->itemType() == PageItem::TextFrame) |
837 | fschmid | 1198 | { |
2603 | cbradney | 1199 | emit currItem->isAnnotation ? AnnotProps() : Amode(modeEdit); |
837 | fschmid | 1200 | contentsMousePressEvent(m); |
1201 | } |
||
456 | fschmid | 1202 | } |
1203 | } |
||
1204 | |||
1205 | void ScribusView::contentsMouseReleaseEvent(QMouseEvent *m) |
||
1206 | { |
||
1957 | cbradney | 1207 | PageItem *currItem; |
456 | fschmid | 1208 | Mpressed = false; |
879 | fschmid | 1209 | if (Doc->guidesSettings.guidesShown) |
456 | fschmid | 1210 | { |
1211 | bool fg = false; |
||
1212 | double nx = m->x()/Scale; |
||
1213 | double ny = m->y()/Scale; |
||
1065 | cbradney | 1214 | if (Doc->currentPage->YGuides.count() != 0) |
456 | fschmid | 1215 | { |
1065 | cbradney | 1216 | for (uint yg = 0; yg < Doc->currentPage->YGuides.count(); ++yg) |
456 | fschmid | 1217 | { |
1485 | tsoots | 1218 | if ((Doc->currentPage->YGuides[yg]+Doc->currentPage->Yoffset < (ny+Doc->guidesSettings.grabRad)) && |
1065 | cbradney | 1219 | (Doc->currentPage->YGuides[yg]+Doc->currentPage->Yoffset > (ny-Doc->guidesSettings.grabRad))) |
456 | fschmid | 1220 | { |
1221 | fg = true; |
||
1222 | break; |
||
1223 | } |
||
1224 | } |
||
1225 | } |
||
1065 | cbradney | 1226 | if (Doc->currentPage->XGuides.count() != 0) |
456 | fschmid | 1227 | { |
1065 | cbradney | 1228 | for (uint xg = 0; xg < Doc->currentPage->XGuides.count(); ++xg) |
456 | fschmid | 1229 | { |
1485 | tsoots | 1230 | if ((Doc->currentPage->XGuides[xg]+Doc->currentPage->Xoffset < (nx+Doc->guidesSettings.grabRad)) && |
1065 | cbradney | 1231 | (Doc->currentPage->XGuides[xg]+Doc->currentPage->Xoffset > (nx-Doc->guidesSettings.grabRad))) |
456 | fschmid | 1232 | { |
1233 | fg = true; |
||
1234 | break; |
||
1235 | } |
||
1236 | } |
||
1237 | } |
||
1957 | cbradney | 1238 | if ((fg) && (m->button() == RightButton) && (!GetItem(&currItem))) |
456 | fschmid | 1239 | { |
1240 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
||
1241 | MoveGY = false; |
||
1242 | MoveGX = false; |
||
1243 | emit EditGuides(); |
||
1244 | return; |
||
1245 | } |
||
1246 | if (MoveGY) |
||
1247 | { |
||
1115 | tsoots | 1248 | SetYGuide(m, GyM); |
456 | fschmid | 1249 | MoveGY = false; |
1250 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
||
1251 | updateContents(); |
||
1252 | return; |
||
1253 | } |
||
1254 | if (MoveGX) |
||
1255 | { |
||
1115 | tsoots | 1256 | SetXGuide(m, GxM); |
456 | fschmid | 1257 | MoveGX = false; |
1258 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
||
1259 | updateContents(); |
||
1260 | return; |
||
1261 | } |
||
1262 | } |
||
2603 | cbradney | 1263 | if (Doc->appMode == modeEditGradientVectors) |
735 | fschmid | 1264 | return; |
2603 | cbradney | 1265 | if (Doc->appMode == modeCopyProperties) |
1840 | fschmid | 1266 | return; |
2603 | cbradney | 1267 | if (Doc->appMode == modeMeasurementTool) |
456 | fschmid | 1268 | { |
1269 | QPainter p; |
||
1270 | p.begin(viewport()); |
||
1271 | ToView(&p); |
||
1272 | p.setRasterOp(XorROP); |
||
1273 | p.setPen(QPen(white, 1, DotLine, FlatCap, MiterJoin)); |
||
1274 | p.drawLine(Dxp, Dyp, Mxp, Myp); |
||
1275 | p.end(); |
||
1276 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
||
1525 | cbradney | 1277 | //emit PaintingDone(); |
456 | fschmid | 1278 | return; |
1279 | } |
||
2603 | cbradney | 1280 | if (Doc->appMode == modePanning) |
456 | fschmid | 1281 | return; |
2603 | cbradney | 1282 | if (Doc->appMode == modeDrawTable) |
456 | fschmid | 1283 | { |
1284 | if ((SelItem.count() == 0) && (HaveSelRect) && (!MidButt)) |
||
1285 | { |
||
1286 | QRect AreaR = QRect(static_cast<int>(Mxp), static_cast<int>(Myp), static_cast<int>(SeRx-Mxp), static_cast<int>(SeRy-Myp)); |
||
1287 | QPainter p; |
||
1288 | p.begin(viewport()); |
||
1289 | ToView(&p); |
||
1290 | p.scale(Scale, Scale); |
||
1291 | p.setRasterOp(XorROP); |
||
1292 | p.setPen(QPen(white, 1, DotLine, FlatCap, MiterJoin)); |
||
1293 | if(Mxp > SeRx) |
||
1294 | { |
||
1295 | double tmp=SeRx; |
||
1296 | SeRx=static_cast<int>(Mxp); |
||
1297 | Mxp=static_cast<int>(tmp); |
||
1298 | } |
||
1299 | if(Myp > SeRy) |
||
1300 | { |
||
1301 | double tmp=SeRy; |
||
1302 | SeRy=static_cast<int>(Myp); |
||
1303 | Myp=static_cast<int>(tmp); |
||
1304 | } |
||
1305 | HaveSelRect = false; |
||
1306 | double Tx, Ty, Tw, Th; |
||
1307 | Tx = Mxp; |
||
1308 | Ty = Myp; |
||
1309 | Tw = SeRx-Mxp; |
||
1310 | Th = SeRy-Myp; |
||
1311 | int z; |
||
1312 | int Cols, Rows; |
||
1313 | double deltaX, deltaY, offX, offY; |
||
1314 | if ((Th < 6) || (Tw < 6)) |
||
1315 | { |
||
1316 | p.drawRect(AreaR); |
||
1317 | p.end(); |
||
2603 | cbradney | 1318 | Doc->appMode = modeNormal; |
456 | fschmid | 1319 | emit PaintingDone(); |
1320 | return; |
||
1321 | } |
||
1322 | InsertTable *dia = new InsertTable(this, static_cast<int>(Th / 6), static_cast<int>(Tw / 6)); |
||
1323 | if (!dia->exec()) |
||
1324 | { |
||
1325 | p.drawRect(AreaR); |
||
1326 | p.end(); |
||
2603 | cbradney | 1327 | Doc->appMode = modeNormal; |
456 | fschmid | 1328 | emit PaintingDone(); |
1329 | delete dia; |
||
1330 | return; |
||
1331 | } |
||
1332 | p.end(); |
||
1333 | Cols = dia->Cols->value(); |
||
1334 | Rows = dia->Rows->value(); |
||
1335 | delete dia; |
||
1336 | deltaX = Tw / Cols; |
||
1337 | deltaY = Th / Rows; |
||
1338 | offX = 0.0; |
||
1339 | offY = 0.0; |
||
1340 | SelItem.clear(); |
||
1396 | tsoots | 1341 | if (UndoManager::undoEnabled()) |
1342 | undoManager->beginTransaction(Doc->currentPage->getUName(), Um::ITable, Um::CreateTable, |
||
1343 | QString(Um::RowsCols).arg(Rows).arg(Cols), Um::ICreate); |
||
456 | fschmid | 1344 | for (int rc = 0; rc < Rows; ++rc) |
1345 | { |
||
1346 | for (int cc = 0; cc < Cols; ++cc) |
||
1347 | { |
||
1194 | fschmid | 1348 | z = PaintText(Tx + offX, Ty + offY, deltaX, deltaY, Doc->toolSettings.dWidth, Doc->toolSettings.dPenText); |
1957 | cbradney | 1349 | currItem = Doc->Items.at(z); |
1350 | currItem->isTableItem = true; |
||
1351 | SelItem.append(currItem); |
||
456 | fschmid | 1352 | offX += deltaX; |
1353 | } |
||
1354 | offY += deltaY; |
||
1355 | offX = 0.0; |
||
1356 | } |
||
1357 | for (int rc = 0; rc < Rows; ++rc) |
||
1358 | { |
||
1359 | for (int cc = 0; cc < Cols; ++cc) |
||
1360 | { |
||
1957 | cbradney | 1361 | currItem = SelItem.at((rc * Cols) + cc); |
456 | fschmid | 1362 | if (rc == 0) |
1957 | cbradney | 1363 | currItem->TopLink = 0; |
456 | fschmid | 1364 | else |
1957 | cbradney | 1365 | currItem->TopLink = SelItem.at(((rc-1)*Cols)+cc); |
456 | fschmid | 1366 | if (rc == Rows-1) |
1957 | cbradney | 1367 | currItem->BottomLink = 0; |
456 | fschmid | 1368 | else |
1957 | cbradney | 1369 | currItem->BottomLink = SelItem.at(((rc+1)*Cols)+cc); |
456 | fschmid | 1370 | if (cc == 0) |
1957 | cbradney | 1371 | currItem->LeftLink = 0; |
456 | fschmid | 1372 | else |
1957 | cbradney | 1373 | currItem->LeftLink = SelItem.at((rc*Cols)+cc-1); |
456 | fschmid | 1374 | if (cc == Cols-1) |
1957 | cbradney | 1375 | currItem->RightLink = 0; |
456 | fschmid | 1376 | else |
1957 | cbradney | 1377 | currItem->RightLink = SelItem.at((rc*Cols)+cc+1); |
456 | fschmid | 1378 | } |
1379 | } |
||
1380 | emit DoGroup(); |
||
1396 | tsoots | 1381 | if (UndoManager::undoEnabled()) |
1382 | undoManager->commit(); |
||
456 | fschmid | 1383 | } |
2603 | cbradney | 1384 | Doc->appMode = modeNormal; |
456 | fschmid | 1385 | emit PaintingDone(); |
1386 | emit DocChanged(); |
||
1387 | updateContents(); |
||
1388 | return; |
||
1389 | } |
||
2603 | cbradney | 1390 | if (Doc->appMode == modeDrawFreehandLine) |
456 | fschmid | 1391 | { |
2603 | cbradney | 1392 | Doc->appMode = modeNormal; |
456 | fschmid | 1393 | if (RecordP.size() > 1) |
1394 | { |
||
1194 | fschmid | 1395 | uint z = PaintPolyLine(0, 0, 1, 1, Doc->toolSettings.dWidth, "None", Doc->toolSettings.dPenLine); |
1957 | cbradney | 1396 | currItem = Doc->Items.at(z); |
1397 | currItem->PoLine.resize(0); |
||
1398 | currItem->PoLine.addPoint(RecordP.point(0)); |
||
1399 | currItem->PoLine.addPoint(RecordP.point(0)); |
||
456 | fschmid | 1400 | for (uint px = 1; px < RecordP.size()-1; ++px) |
1401 | { |
||
1957 | cbradney | 1402 | currItem->PoLine.addPoint(RecordP.point(px)); |
1403 | currItem->PoLine.addPoint(RecordP.point(px)); |
||
1404 | currItem->PoLine.addPoint(RecordP.point(px)); |
||
1405 | currItem->PoLine.addPoint(RecordP.point(px)); |
||
456 | fschmid | 1406 | } |
1957 | cbradney | 1407 | currItem->PoLine.addPoint(RecordP.point(RecordP.size()-1)); |
1408 | currItem->PoLine.addPoint(RecordP.point(RecordP.size()-1)); |
||
1409 | AdjustItemSize(currItem); |
||
456 | fschmid | 1410 | SelItem.clear(); |
1957 | cbradney | 1411 | SelItem.append(currItem); |
1412 | currItem->ClipEdited = true; |
||
1413 | currItem->Select = true; |
||
1414 | currItem->FrameType = 3; |
||
1415 | currItem->OwnPage = OnPage(currItem); |
||
1416 | emit ItemPos(currItem->Xpos, currItem->Ypos); |
||
1417 | emit SetSizeValue(currItem->Pwidth); |
||
1418 | emit SetLineArt(currItem->PLineArt, currItem->PLineEnd, currItem->PLineJoin); |
||
1419 | emit ItemFarben(currItem->lineColor(), currItem->fillColor(), currItem->lineShade(), currItem->fillShade()); |
||
1420 | emit ItemGradient(currItem->GrType); |
||
1421 | emit ItemTrans(currItem->fillTransparency(), currItem->lineTransparency()); |
||
1460 | cbradney | 1422 | emit HaveSel(PageItem::PolyLine); |
456 | fschmid | 1423 | } |
1424 | updateContents(); |
||
1425 | emit PaintingDone(); |
||
1426 | emit DocChanged(); |
||
1427 | return; |
||
1428 | } |
||
1429 | if ((Doc->EditClip) && (ClRe == -1) && (HaveSelRect)) |
||
1430 | { |
||
1431 | double sc = Scale; |
||
1432 | QPainter p; |
||
1433 | p.begin(viewport()); |
||
1434 | ToView(&p); |
||
1435 | p.scale(Scale, Scale); |
||
1436 | p.setRasterOp(XorROP); |
||
1437 | p.setPen(QPen(white, 1, DotLine, FlatCap, MiterJoin)); |
||
1438 | p.drawRect(Mxp, Myp, SeRx-Mxp, SeRy-Myp); |
||
1439 | p.end(); |
||
1440 | if(Mxp > SeRx) |
||
1441 | { |
||
1442 | double tmp=SeRx; |
||
1443 | SeRx=static_cast<int>(Mxp); |
||
1444 | Mxp=static_cast<int>(tmp); |
||
1445 | } |
||
1446 | if(Myp > SeRy) |
||
1447 | { |
||
1448 | double tmp=SeRy; |
||
1449 | SeRy=static_cast<int>(Myp); |
||
1450 | Myp=static_cast<int>(tmp); |
||
1451 | } |
||
1957 | cbradney | 1452 | currItem = SelItem.at(0); |
456 | fschmid | 1453 | SelNode.clear(); |
1454 | QRect Sele = QRect(static_cast<int>(Mxp*sc), static_cast<int>(Myp*sc), static_cast<int>((SeRx-Mxp)*sc), static_cast<int>((SeRy-Myp)*sc)); |
||
1455 | FPointArray Clip; |
||
1456 | if (EditContour) |
||
1957 | cbradney | 1457 | Clip = currItem->ContourLine; |
456 | fschmid | 1458 | else |
1957 | cbradney | 1459 | Clip = currItem->PoLine; |
1884 | fschmid | 1460 | for (uint a = 0; a < Clip.size(); ++a) |
456 | fschmid | 1461 | { |
1462 | if (Clip.point(a).x() > 900000) |
||
1463 | continue; |
||
1464 | p.begin(viewport()); |
||
1957 | cbradney | 1465 | Transform(currItem, &p); |
456 | fschmid | 1466 | QPoint npf = p.xForm(Clip.pointQ(a)); |
1467 | p.end(); |
||
1468 | if ((Sele.contains(npf)) && ((a == 0) || (((a-2) % 4) == 0))) |
||
1469 | { |
||
1470 | ClRe = a; |
||
1471 | SelNode.append(a); |
||
1472 | emit ClipPo(Clip.point(a).x(), Clip.point(a).y()); |
||
1473 | } |
||
1474 | } |
||
1475 | HaveSelRect = false; |
||
1957 | cbradney | 1476 | MarkClip(currItem); |
456 | fschmid | 1477 | return; |
1478 | } |
||
1479 | if ((Doc->EditClip) && (SegP1 == -1) && (SegP2 == -1)) |
||
1480 | { |
||
1481 | if (Imoved) |
||
1482 | { |
||
1957 | cbradney | 1483 | currItem = SelItem.at(0); |
1484 | currItem->OldB2 = currItem->Width; |
||
1485 | currItem->OldH2 = currItem->Height; |
||
456 | fschmid | 1486 | double nx = m->x()/Scale; |
1487 | double ny = m->y()/Scale; |
||
1488 | if (!ApplyGuides(&nx, &ny)) |
||
1489 | { |
||
1490 | FPoint npg = ApplyGridF(FPoint(nx, ny)); |
||
1491 | nx = npg.x(); |
||
1492 | ny = npg.y(); |
||
1493 | } |
||
1957 | cbradney | 1494 | FPoint np = transformPointI(FPoint(nx, ny), currItem->Xpos, currItem->Ypos, currItem->Rot, 1, 1); |
1495 | MoveClipPoint(currItem, np); |
||
456 | fschmid | 1496 | } |
1497 | updateContents(); |
||
1498 | Imoved = false; |
||
1499 | return; |
||
1500 | } |
||
1501 | if ((Doc->EditClip) && (SegP1 != -1) && (SegP2 != -1)) |
||
1502 | { |
||
1503 | SegP1 = -1; |
||
1504 | SegP2 = -1; |
||
1957 | cbradney | 1505 | currItem = SelItem.at(0); |
456 | fschmid | 1506 | Imoved = false; |
1507 | updateContents(); |
||
1508 | return; |
||
1509 | } |
||
2603 | cbradney | 1510 | if ((!GetItem(&currItem)) && (m->button() == RightButton) && (!Doc->DragP) && (Doc->appMode == modeNormal)) |
456 | fschmid | 1511 | { |
1512 | QPopupMenu *pmen = new QPopupMenu(); |
||
1513 | if (ScApp->Buffer2.startsWith("<SCRIBUSELEM")) |
||
1514 | { |
||
1515 | Mxp = m->x(); |
||
1516 | Myp = m->y(); |
||
1517 | pmen->insertItem( tr("&Paste") , this, SLOT(PasteToPage())); |
||
1518 | pmen->insertSeparator(); |
||
1519 | } |
||
1461 | tsoots | 1520 | setObjectUndoMode(); |
1521 | ScApp->scrActions["editUndoAction"]->addTo(pmen); |
||
1522 | ScApp->scrActions["editRedoAction"]->addTo(pmen); |
||
1523 | pmen->insertSeparator(); |
||
1334 | cbradney | 1524 | ScApp->scrActions["viewShowMargins"]->addTo(pmen); |
1525 | ScApp->scrActions["viewShowFrames"]->addTo(pmen); |
||
1526 | ScApp->scrActions["viewShowImages"]->addTo(pmen); |
||
1527 | ScApp->scrActions["viewShowGrid"]->addTo(pmen); |
||
1528 | ScApp->scrActions["viewShowGuides"]->addTo(pmen); |
||
1529 | ScApp->scrActions["viewShowBaseline"]->addTo(pmen); |
||
1530 | ScApp->scrActions["viewShowTextChain"]->addTo(pmen); |
||
456 | fschmid | 1531 | pmen->insertSeparator(); |
1334 | cbradney | 1532 | ScApp->scrActions["viewSnapToGrid"]->addTo(pmen); |
1533 | ScApp->scrActions["viewSnapToGuides"]->addTo(pmen); |
||
456 | fschmid | 1534 | pmen->exec(QCursor::pos()); |
1461 | tsoots | 1535 | setGlobalUndoMode(); |
456 | fschmid | 1536 | delete pmen; |
1537 | return; |
||
1538 | } |
||
2603 | cbradney | 1539 | if ((Doc->appMode != modeMagnifier) && (!Doc->EditClip) && (Doc->appMode != modeDrawBezierLine)) |
456 | fschmid | 1540 | { |
1957 | cbradney | 1541 | if ((GetItem(&currItem)) && (m->button() == RightButton) && (!Doc->DragP)) |
456 | fschmid | 1542 | { |
1543 | QPopupMenu *pmen = new QPopupMenu(); |
||
1544 | QPopupMenu *pmen2 = new QPopupMenu(); |
||
1545 | pmen3 = new QPopupMenu(); |
||
1546 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
||
1547 | QPopupMenu *pmen4 = new QPopupMenu(); |
||
1548 | QPopupMenu *pmenLevel = new QPopupMenu(); |
||
1549 | QPopupMenu *pmenPDF = new QPopupMenu(); |
||
2173 | fschmid | 1550 | pmenResolution = new QPopupMenu(); |
1461 | tsoots | 1551 | setObjectUndoMode(); |
1957 | cbradney | 1552 | if ((currItem->itemType() == PageItem::TextFrame) || (currItem->itemType() == PageItem::ImageFrame) || (currItem->itemType() == PageItem::PathText)) |
456 | fschmid | 1553 | { |
1554 | QButtonGroup *InfoGroup = new QButtonGroup( this, "InfoGroup" ); |
||
1555 | InfoGroup->setFrameShape( QButtonGroup::NoFrame ); |
||
1556 | InfoGroup->setFrameShadow( QButtonGroup::Plain ); |
||
1557 | InfoGroup->setTitle(""); |
||
1558 | InfoGroup->setExclusive( true ); |
||
1559 | InfoGroup->setColumnLayout(0, Qt::Vertical ); |
||
1560 | InfoGroup->layout()->setSpacing( 0 ); |
||
1561 | InfoGroup->layout()->setMargin( 0 ); |
||
1562 | QGridLayout *InfoGroupLayout = new QGridLayout( InfoGroup->layout() ); |
||
1563 | InfoGroupLayout->setAlignment( Qt::AlignTop ); |
||
1564 | InfoGroupLayout->setSpacing( 2 ); |
||
1565 | InfoGroupLayout->setMargin( 0 ); |
||
1566 | QString txtC, txtC2; |
||
1567 | QLabel *InfoT = new QLabel(InfoGroup, "ct"); |
||
1568 | QLabel *ParCT = new QLabel(InfoGroup, "pt"); |
||
1569 | QLabel *ParC = new QLabel(InfoGroup, "pc"); |
||
1570 | QLabel *WordCT = new QLabel(InfoGroup, "wt"); |
||
1571 | QLabel *WordC = new QLabel(InfoGroup, "wc"); |
||
1572 | QLabel *CharCT = new QLabel(InfoGroup, "ct"); |
||
1573 | QLabel *CharC = new QLabel(InfoGroup, "cc"); |
||
1574 | QLabel *PrintCT = new QLabel(InfoGroup, "nt"); // <a.l.e> |
||
1575 | QLabel *PrintC = new QLabel(InfoGroup, "nc"); // </a.l.e> |
||
1957 | cbradney | 1576 | if (currItem->itemType() == PageItem::ImageFrame) |
456 | fschmid | 1577 | { |
1957 | cbradney | 1578 | QFileInfo fi = QFileInfo(currItem->Pfile); |
456 | fschmid | 1579 | InfoT->setText( tr("Picture")); |
1580 | InfoGroupLayout->addMultiCellWidget( InfoT, 0, 0, 0, 1, Qt::AlignCenter ); |
||
1581 | ParCT->setText( tr("File: ")); |
||
1582 | InfoGroupLayout->addWidget( ParCT, 1, 0, Qt::AlignRight ); |
||
1583 | ParC->setText(fi.fileName()); |
||
1584 | InfoGroupLayout->addWidget( ParC, 1, 1 ); |
||
1585 | WordCT->setText( tr("Original PPI: ")); |
||
1586 | InfoGroupLayout->addWidget( WordCT, 2, 0, Qt::AlignRight ); |
||
2004 | fschmid | 1587 | WordC->setText(txtC.setNum(qRound(currItem->pixm.imgInfo.xres))+" x "+txtC2.setNum(qRound(currItem->pixm.imgInfo.yres))); |
456 | fschmid | 1588 | InfoGroupLayout->addWidget( WordC, 2, 1 ); |
1589 | CharCT->setText( tr("Actual PPI: ")); |
||
1590 | InfoGroupLayout->addWidget( CharCT, 3, 0, Qt::AlignRight ); |
||
1957 | cbradney | 1591 | CharC->setText(txtC.setNum(qRound(72.0 / currItem->LocalScX))+" x "+ |
1592 | txtC2.setNum(qRound(72.0 / currItem->LocalScY))); |
||
456 | fschmid | 1593 | InfoGroupLayout->addWidget( CharC, 3, 1 ); |
1594 | } |
||
1957 | cbradney | 1595 | if ((currItem->itemType() == PageItem::TextFrame) || (currItem->itemType() == PageItem::PathText)) |
456 | fschmid | 1596 | { |
1597 | int Parag = 0; |
||
1598 | int Words = 0; |
||
1599 | int Chara = 0; |
||
1600 | int ParagN = 0; |
||
1601 | int WordsN = 0; |
||
1602 | int CharaN = 0; |
||
1957 | cbradney | 1603 | if (currItem->itemType() == PageItem::TextFrame) |
456 | fschmid | 1604 | { |
1957 | cbradney | 1605 | if ((currItem->NextBox != 0) || (currItem->BackBox != 0)) |
456 | fschmid | 1606 | InfoT->setText( tr("Linked Text")); |
1607 | else |
||
1608 | InfoT->setText( tr("Text Frame")); |
||
1609 | } |
||
1610 | else |
||
1611 | InfoT->setText( tr("Text on a Path")); |
||
1612 | InfoGroupLayout->addMultiCellWidget( InfoT, 0, 0, 0, 1, Qt::AlignCenter ); |
||
1957 | cbradney | 1613 | WordAndPara(currItem, &Words, &Parag, &Chara, &WordsN, &ParagN, &CharaN); |
456 | fschmid | 1614 | ParCT->setText( tr("Paragraphs: ")); |
1615 | InfoGroupLayout->addWidget( ParCT, 1, 0, Qt::AlignRight ); |
||
1616 | if (ParagN != 0) |
||
1617 | ParC->setText(txtC.setNum(Parag+ParagN)+" ("+txtC2.setNum(ParagN)+")"); |
||
1618 | else |
||
1619 | ParC->setText(txtC.setNum(Parag)); |
||
1620 | InfoGroupLayout->addWidget( ParC, 1, 1 ); |
||
1621 | WordCT->setText( tr("Words: ")); |
||
1622 | InfoGroupLayout->addWidget( WordCT, 2, 0, Qt::AlignRight ); |
||
1623 | if (WordsN != 0) |
||
1624 | WordC->setText(txtC.setNum(Words+WordsN)+" ("+txtC2.setNum(WordsN)+")"); |
||
1625 | else |
||
1626 | WordC->setText(txtC.setNum(Words)); |
||
1627 | InfoGroupLayout->addWidget( WordC, 2, 1 ); |
||
1628 | CharCT->setText( tr("Chars: ")); |
||
1629 | InfoGroupLayout->addWidget( CharCT, 3, 0, Qt::AlignRight ); |
||
1630 | if (CharaN != 0) |
||
1631 | CharC->setText(txtC.setNum(Chara+CharaN)+" ("+txtC2.setNum(CharaN)+")"); |
||
1632 | else |
||
1633 | CharC->setText(txtC.setNum(Chara)); |
||
1634 | InfoGroupLayout->addWidget( CharC, 3, 1 ); |
||
1635 | } |
||
1636 | |||
1637 | int row = InfoGroupLayout->numRows(); // <a.l.e> |
||
1638 | |||
1639 | PrintCT->setText( tr("Print: ")); |
||
1640 | InfoGroupLayout->addWidget( PrintCT, row, 0, Qt::AlignRight ); |
||
2449 | cbradney | 1641 | if (currItem->printable()) |
456 | fschmid | 1642 | PrintC->setText( tr("Enabled")); |
1643 | else |
||
1644 | PrintC->setText( tr("Disabled")); |
||
1645 | InfoGroupLayout->addWidget( PrintC, row, 1 ); // </a.l.e> |
||
1646 | |||
1647 | pmen4->insertItem(InfoGroup); |
||
1648 | pmen->insertItem( tr("In&fo"), pmen4); |
||
1649 | } |
||
1461 | tsoots | 1650 | pmen->insertSeparator(); |
1651 | ScApp->scrActions["editUndoAction"]->addTo(pmen); |
||
1652 | ScApp->scrActions["editRedoAction"]->addTo(pmen); |
||
1653 | pmen->insertSeparator(); |
||
1644 | cbradney | 1654 | ScApp->scrActions["itemAttributes"]->addTo(pmen); |
1957 | cbradney | 1655 | if (currItem->itemType() == PageItem::ImageFrame) |
456 | fschmid | 1656 | { |
1267 | cbradney | 1657 | ScApp->scrActions["fileImportImage"]->addTo(pmen); |
2026 | cbradney | 1658 | ScApp->scrActions["itemImageIsVisible"]->addTo(pmen); |
2173 | fschmid | 1659 | pmen->insertItem( tr("Preview Settings"), pmenResolution); |
2256 | cbradney | 1660 | ScApp->scrActions["itemPreviewLow"]->addTo(pmenResolution); |
1661 | ScApp->scrActions["itemPreviewNormal"]->addTo(pmenResolution); |
||
1662 | ScApp->scrActions["itemPreviewFull"]->addTo(pmenResolution); |
||
2004 | fschmid | 1663 | if ((currItem->PicAvail) && (currItem->pixm.imgInfo.valid)) |
2260 | cbradney | 1664 | ScApp->scrActions["itemExtendedImageProperties"]->addTo(pmen); |
1957 | cbradney | 1665 | if (currItem->PicAvail) |
2260 | cbradney | 1666 | ScApp->scrActions["itemUpdateImage"]->addTo(pmen); |
1957 | cbradney | 1667 | if (currItem->PicAvail && currItem->isRaster) |
2259 | cbradney | 1668 | ScApp->scrActions["editEditWithImageEditor"]->addTo(pmen); |
1957 | cbradney | 1669 | if ((currItem->PicAvail) && (!currItem->isTableItem)) |
2259 | cbradney | 1670 | ScApp->scrActions["itemAdjustFrameToImage"]->addTo(pmen); |
456 | fschmid | 1671 | } |
1957 | cbradney | 1672 | if (currItem->itemType() == PageItem::TextFrame) |
456 | fschmid | 1673 | { |
1267 | cbradney | 1674 | ScApp->scrActions["fileImportText"]->addTo(pmen); |
1675 | ScApp->scrActions["fileImportAppendText"]->addTo(pmen); |
||
1981 | cbradney | 1676 | ScApp->scrActions["toolsEditWithStoryEditor"]->addTo(pmen); |
1065 | cbradney | 1677 | if (Doc->currentPage->PageNam == "") |
456 | fschmid | 1678 | { |
2103 | cbradney | 1679 | ScApp->scrActions["itemPDFIsAnnotation"]->addTo(pmenPDF); |
1680 | ScApp->scrActions["itemPDFIsBookmark"]->addTo(pmenPDF); |
||
1957 | cbradney | 1681 | if (currItem->isAnnotation) |
456 | fschmid | 1682 | { |
1957 | cbradney | 1683 | if ((currItem->AnType == 0) || (currItem->AnType == 1) || (currItem->AnType > 9)) |
2103 | cbradney | 1684 | ScApp->scrActions["itemPDFAnnotationProps"]->addTo(pmenPDF); |
456 | fschmid | 1685 | else |
2103 | cbradney | 1686 | ScApp->scrActions["itemPDFFieldProps"]->addTo(pmenPDF); |
456 | fschmid | 1687 | } |
1688 | } |
||
1689 | pmen->insertItem( tr("&PDF Options"), pmenPDF); |
||
1690 | } |
||
1957 | cbradney | 1691 | if (currItem->itemType() == PageItem::PathText) |
1981 | cbradney | 1692 | ScApp->scrActions["toolsEditWithStoryEditor"]->addTo(pmen); |
1858 | cbradney | 1693 | ScApp->scrActions["itemLock"]->addTo(pmen); |
1694 | ScApp->scrActions["itemLockSize"]->addTo(pmen); |
||
1957 | cbradney | 1695 | if (!currItem->isSingleSel) |
456 | fschmid | 1696 | { |
1981 | cbradney | 1697 | ScApp->scrActions["itemSendToScrapbook"]->addTo(pmen); |
456 | fschmid | 1698 | if (Doc->Layers.count() > 1) |
1699 | { |
||
2408 | cbradney | 1700 | for( QMap<QString, QGuardedPtr<ScrAction> >::Iterator it = ScApp->scrLayersActions.begin(); it!=ScApp->scrLayersActions.end(); ++it ) |
1701 | (*it)->addTo(pmen3); |
||
456 | fschmid | 1702 | pmen->insertItem( tr("Send to La&yer"), pmen3); |
1703 | } |
||
1704 | } |
||
1957 | cbradney | 1705 | if (!currItem->locked()) |
456 | fschmid | 1706 | { |
1707 | if (SelItem.count() > 1) |
||
1708 | { |
||
1709 | bool isGroup = true; |
||
1710 | int firstElem = -1; |
||
1957 | cbradney | 1711 | if (currItem->Groups.count() != 0) |
1712 | firstElem = currItem->Groups.top(); |
||
456 | fschmid | 1713 | for (uint bx = 0; bx < SelItem.count(); ++bx) |
1714 | { |
||
1715 | if (SelItem.at(bx)->Groups.count() != 0) |
||
1716 | { |
||
1717 | if (SelItem.at(bx)->Groups.top() != firstElem) |
||
1718 | isGroup = false; |
||
1719 | } |
||
1720 | else |
||
1721 | isGroup = false; |
||
1722 | } |
||
1723 | if (!isGroup) |
||
1858 | cbradney | 1724 | ScApp->scrActions["itemGroup"]->addTo(pmen); |
456 | fschmid | 1725 | } |
1957 | cbradney | 1726 | if (currItem->Groups.count() != 0) |
1858 | cbradney | 1727 | ScApp->scrActions["itemUngroup"]->addTo(pmen); |
1957 | cbradney | 1728 | if ((!currItem->isTableItem) && (!currItem->isSingleSel)) |
456 | fschmid | 1729 | { |
1730 | pmen->insertItem( tr("Le&vel"), pmenLevel); |
||
2104 | cbradney | 1731 | ScApp->scrActions["itemRaise"]->addTo(pmenLevel); |
1858 | cbradney | 1732 | ScApp->scrActions["itemLower"]->addTo(pmenLevel); |
2104 | cbradney | 1733 | ScApp->scrActions["itemRaiseToTop"]->addTo(pmenLevel); |
1734 | ScApp->scrActions["itemLowerToBottom"]->addTo(pmenLevel); |
||
456 | fschmid | 1735 | } |
1736 | } |
||
2603 | cbradney | 1737 | if (Doc->appMode != modeEdit) //Create convertTo Menu |
456 | fschmid | 1738 | { |
1858 | cbradney | 1739 | bool insertConvertToMenu=false; |
1957 | cbradney | 1740 | if (currItem->itemType() == PageItem::TextFrame) |
456 | fschmid | 1741 | { |
1858 | cbradney | 1742 | insertConvertToMenu=true; |
2538 | fschmid | 1743 | if (currItem->isTableItem) |
1744 | ScApp->scrActions["itemConvertToImageFrame"]->addTo(pmen2); |
||
1745 | if ((!currItem->isTableItem) && (currItem->BackBox == 0) && (currItem->NextBox == 0)) |
||
456 | fschmid | 1746 | { |
2538 | fschmid | 1747 | ScApp->scrActions["itemConvertToImageFrame"]->addTo(pmen2); |
1858 | cbradney | 1748 | ScApp->scrActions["itemConvertToOutlines"]->addTo(pmen2); |
1749 | ScApp->scrActions["itemConvertToPolygon"]->addTo(pmen2); |
||
456 | fschmid | 1750 | } |
1751 | } |
||
1957 | cbradney | 1752 | if (currItem->itemType() == PageItem::ImageFrame) |
456 | fschmid | 1753 | { |
1858 | cbradney | 1754 | insertConvertToMenu=true; |
1755 | ScApp->scrActions["itemConvertToTextFrame"]->addTo(pmen2); |
||
1957 | cbradney | 1756 | if (!currItem->isTableItem) |
1858 | cbradney | 1757 | ScApp->scrActions["itemConvertToPolygon"]->addTo(pmen2); |
456 | fschmid | 1758 | } |
1957 | cbradney | 1759 | if (currItem->itemType() == PageItem::Polygon) |
456 | fschmid | 1760 | { |
1858 | cbradney | 1761 | insertConvertToMenu=true; |
1762 | ScApp->scrActions["itemConvertToBezierCurve"]->addTo(pmen2); |
||
1763 | ScApp->scrActions["itemConvertToImageFrame"]->addTo(pmen2); |
||
1764 | ScApp->scrActions["itemConvertToTextFrame"]->addTo(pmen2); |
||
456 | fschmid | 1765 | } |
1858 | cbradney | 1766 | if (insertConvertToMenu) |
1767 | pmen->insertItem( tr("Conve&rt to"), pmen2); |
||
456 | fschmid | 1768 | } |
1769 | pmen->insertSeparator(); |
||
1957 | cbradney | 1770 | if (!currItem->locked() && !(currItem->isTableItem && currItem->isSingleSel)) |
1227 | cbradney | 1771 | ScApp->scrActions["editCut"]->addTo(pmen); |
1957 | cbradney | 1772 | if (!(currItem->isTableItem && currItem->isSingleSel)) |
1227 | cbradney | 1773 | ScApp->scrActions["editCopy"]->addTo(pmen); |
2603 | cbradney | 1774 | if ((Doc->appMode == modeEdit) && (ScApp->Buffer2.startsWith("<SCRIBUSTEXT")) && (currItem->itemType() == PageItem::TextFrame)) |
1227 | cbradney | 1775 | ScApp->scrActions["editPaste"]->addTo(pmen); |
1957 | cbradney | 1776 | if (!currItem->locked() && (Doc->appMode != 7) && (!(currItem->isTableItem && currItem->isSingleSel))) |
456 | fschmid | 1777 | pmen->insertItem( tr("&Delete"), this, SLOT(DeleteItem())); |
1957 | cbradney | 1778 | if ((currItem->itemType() == PageItem::ImageFrame) || (currItem->itemType() == PageItem::TextFrame)) |
1963 | cbradney | 1779 | ScApp->scrActions["editClearContents"]->addTo(pmen); |
456 | fschmid | 1780 | pmen->insertSeparator(); |
1525 | cbradney | 1781 | ScApp->scrActions["toolsProperties"]->addTo(pmen); |
1963 | cbradney | 1782 | |
456 | fschmid | 1783 | pmen->exec(QCursor::pos()); |
1461 | tsoots | 1784 | setGlobalUndoMode(); |
456 | fschmid | 1785 | delete pmen; |
1786 | delete pmen2; |
||
1787 | delete pmen3; |
||
1788 | delete pmen4; |
||
1789 | delete pmenLevel; |
||
1790 | delete pmenPDF; |
||
2173 | fschmid | 1791 | delete pmenResolution; |
456 | fschmid | 1792 | } |
2603 | cbradney | 1793 | if (Doc->appMode == modeLinkFrames) |
456 | fschmid | 1794 | { |
1795 | updateContents(); |
||
1796 | if (Doc->ElemToLink != 0) |
||
1797 | return; |
||
808 | fschmid | 1798 | else |
1799 | { |
||
2603 | cbradney | 1800 | Doc->appMode = modeNormal; |
808 | fschmid | 1801 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
1802 | emit PaintingDone(); |
||
1803 | return; |
||
1804 | } |
||
456 | fschmid | 1805 | } |
2603 | cbradney | 1806 | if (Doc->appMode == modeDrawRegularPolygon) |
456 | fschmid | 1807 | { |
1957 | cbradney | 1808 | &n |