1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827
|
/***************************************************************************
* Copyright (C) 2000-2019 by Johan Maes *
* on4qz@telenet.be *
* http://users.telenet.be/on4qz *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <QtGui>
#include "editorscene.h"
#include "gradientdialog.h"
#include "appglobal.h"
#include "ui_textform.h"
#include "imageviewer.h"
#ifndef STANDALONE
#include "gallerywidget.h"
#include "txwidget.h"
#endif
#undef ENABLETEMPLATEVIEWER
#ifdef ENABLETEMPLATEVIEWER
#include "templateviewer.h"
#endif
editorScene::editorScene(QGraphicsView *parent) : QGraphicsScene(parent)
{
contextMenu=new QMenu();
arrange = new QMenu( "Arrange");
arrange->setTearOffEnabled(true);
arrange->addAction("Forward",this,SLOT(slotSendForward()));
arrange->addAction("Backward",this,SLOT(slotSendBackward()));
arrange->addAction("Bring to front",this,SLOT(slotBringToFront()));
arrange->addAction("Send to back",this,SLOT(slotSendToBack()));
contextMenu->addMenu(arrange);
contextMenu->addSeparator();
contextMenu->addAction("Change Text",this,SLOT(slotChangeText()));
contextMenu->addSeparator();
contextMenu->addAction("Delete",this,SLOT(slotDeleteItem()));
contextMenu->addAction("Expand",this,SLOT(slotExpand()));
contextMenu->addAction("Lock",this,SLOT(slotLock()));
contextMenu->addAction("Unlock",this,SLOT(slotUnlock()));
#ifndef QT_NO_DEBUG
contextMenu->addAction("Properties",this,SLOT(slotProperties()));
#endif
zMax=0;
pasted=false;
copyItem=NULL;
mode=MOVE;
imageType=NONE;
localImage=NULL;
rotate=0;
vShear=0;
hShear=0;
border=QRectF(0,0,0,0);
borderItemPtr=NULL;
penWidth=1;
}
editorScene::~editorScene()
{
if(localImage!=NULL) delete localImage;
if((!pasted) &&(copyItem!=NULL)) delete copyItem;
delete arrange;
delete contextMenu;
}
bool editorScene::load(QFile &f)
{
bool borderSet=false;
QImage im;
graphItemBase *item;
quint32 magic;
QString version;
quint16 streamVersion;
int type;
if(f.fileName().isEmpty()) return false;
if(!f.open(QIODevice::ReadOnly)) return false;
QDataStream str(&f);
str >> magic;
if (magic != MAGICNUMBER)
{
// qDebug() << QChar((MAGICNUMBER>>24)&0xFF)
// << QChar((MAGICNUMBER>>16)&0xFF)
// << QChar((MAGICNUMBER>>8)&0xFF)
// << QChar((MAGICNUMBER)&0xFF);
// qDebug() << QChar((magic>>24)&0xFF)
// << QChar((magic>>16)&0xFF)
// << QChar((magic>>8)&0xFF)
// << QChar((magic)&0xFF);
//try to load an image
f.reset();
if(im.load(&f,0))
{
addToLog("image loaded",LOGEDIT);
imageType=FLATIMAGE;
setImage(&im);
border=QRect(0,0,im.width(),im.height());
f.close();
return true;
}
else
{
addToLog("image failed to load",LOGEDIT);
f.close();
return false;
}
}
imageType=TEMPLATE;
str >> version; // at this moment we do not use the version
str >> streamVersion;
str.setVersion(streamVersion);
while (!str.atEnd())
{
str >> type;
switch (type)
{
case graphItemBase::RECTANGLE:
item=new itemRectangle(contextMenu);
break;
case graphItemBase::ELLIPSE:
item=new itemEllipse(contextMenu);
break;
case graphItemBase::LINE:
item=new itemLine(contextMenu);
break;
case graphItemBase::TEXT:
item=new itemText(contextMenu);
break;
case graphItemBase::IMAGE:
item=new itemImage(contextMenu);
break;
case graphItemBase::REPLAY:
item=new itemReplayImage(contextMenu);
break;
case graphItemBase::SBORDER:
borderSet=true;
item=new itemImage(contextMenu);
item->load(str);
border=item->rect();
delete item;
continue;
break;
default:
addToLog("Error in datastream",LOGEDIT);
f.close();
return false;
break;
}
item->load(str);
addItem(item);
}
optimizeDepth();
if(!borderSet) border=QRectF(0,0,320,256);
addToLog(QString("border position %1,%2 size: %3 x %4 border set=%5")
.arg(border.topLeft().x()).arg(border.topLeft().y())
.arg(border.width()).arg(border.height()).arg(borderSet),LOGEDIT);
f.close();
setSceneRect(border);
return true;
}
QImage *editorScene::renderImage(int w,int h)
{
clearSelection();
if (localImage!=NULL) delete localImage;
if(w==0)
{
localImage=new QImage(border.width(),border.height(),QImage::Format_ARGB32_Premultiplied);
}
else
{
localImage=new QImage(w,h,QImage::Format_ARGB32_Premultiplied);
}
addToLog(QString("editorScene: pre-render size: %1 x %2").arg(localImage->size().width()).arg(localImage->size().height()),LOGEDIT);
QPainter painter(localImage);
painter.setRenderHint(QPainter::Antialiasing);
localImage->fill(0);
render(&painter);
addToLog(QString("editor: post-render size: %1 x %2").arg(localImage->size().width()).arg(localImage->size().height()),LOGEDIT);
#ifdef ENABLETEMPLATEVIEWER
templateViewer tv;
qDebug() << "items" << items().count()<<sceneRect();
dumpItems();
tv.setImage(localImage);
tv.exec();
#endif
return localImage;
}
void editorScene::overlay(QImage *ima)
{
clearSelection();
setSceneRect(border);
if (localImage!=NULL) delete localImage;
localImage=new QImage(ima->copy());
addToLog(QString("localImageSize %1,%2").arg(localImage->width()).arg(localImage->height()),LOGEDIT);
convertText();
convertReplayImage();
QPainter painter(localImage);
painter.setRenderHint(QPainter::Antialiasing);
render(&painter,QRectF(),QRectF(),Qt::IgnoreAspectRatio);
#ifdef ENABLETEMPLATEVIEWER
templateViewer tv;
qDebug() << "items" << items().count()<<sceneRect();
tv.setImage(localImage);
tv.exec();
#endif
}
bool editorScene::save(QFile &f,bool templ)
{
QImage im(border.width(),border.height(),QImage::Format_ARGB32_Premultiplied);
im.fill(0);
setSceneRect(border);
#ifndef QT_NO_DEBUG
qDebug()<<"dumping";
dumpItems();
#endif
clearSelection();
QList<QGraphicsItem *> itemList = items(border, Qt::IntersectsItemBoundingRect);
// qDebug() << "itemList.count()" << itemList.count();
addToLog(QString("editorscene:save %1x%2 %3,%4")
.arg(sceneRect().width()).arg(sceneRect().height())
.arg(sceneRect().x()).arg(sceneRect().y())
,LOGEDIT);
if(!templ)
{
QPainter painter(&im);
painter.setRenderHint(QPainter::Antialiasing);
render(&painter);
#ifdef ENABLETEMPLATEVIEWER
templateViewer tv;
qDebug() << "items" << items().count()<<sceneRect();
tv.setImage(&im);
tv.exec();
#endif
im.save(&f,"PNG");
return true;
}
if(!f.open(QIODevice::WriteOnly)) return false;
QDataStream str(&f);
str.setVersion(QDataStream::Qt_4_4);
// Header with a "magic number" and a version
str << (quint32) MAGICNUMBER;
str << CONFIGVERSION;
str << (quint16) QDataStream::Qt_4_4;
graphItemBase *it;
foreach(QGraphicsItem *t,items())
{
it=qgraphicsitem_cast<graphItemBase *>(t);
if(t->type()>graphItemBase::BASE)
{
it->save(str);
}
}
f.close();
return true;
}
void editorScene::flattenImage(int w,int h)
{
if (localImage!=NULL) delete localImage;
setSceneRect(border);
localImage=new QImage(w,h,QImage::Format_ARGB32_Premultiplied);
convertText();
convertReplayImage();
QPainter painter(localImage);
painter.setRenderHint(QPainter::Antialiasing);
localImage->fill(0);
render(&painter);
}
void editorScene::convertReplayImage()
{
#ifndef STANDALONE
QString fn;
imageViewer imv;
fn=txWidgetPtr->getPreviewFilename();
if(fn.isEmpty()) return;
if(imv.openImage(fn,false,false,false,false))
{
foreach(QGraphicsItem *t,items())
{
if(t->type()==graphItemBase::REPLAY)
{
itemReplayImage *itt=qgraphicsitem_cast<itemReplayImage *>(t);
itt->setImage(*imv.getImagePtr());
}
}
}
#endif
}
void editorScene::convertText()
{
foreach(QGraphicsItem *t,items())
{
if(t->type()==graphItemBase::TEXT)
{
itemText *itt=qgraphicsitem_cast<itemText *>(t);
itt->setText(mexp.convert(itt->text()));
}
}
}
void editorScene::setMode(eMode m)
{
mode = m;
if(mode==INSERT) clearSelection () ;
}
void editorScene::setItemType(graphItemBase::egraphType tp)
{
itemType = tp;
}
void editorScene::apply(changeFlags cf)
{
QPen p;
graphItemBase *it;
if(selectedItems().isEmpty()) return; // nothing to do
foreach(QGraphicsItem *t,selectedItems())
{
it=qgraphicsitem_cast<graphItemBase *>(t);
if(cf & DFILLCOLOR)
{
it->setBrush(fillColor);
}
if(cf & DLINECOLOR)
{
p=it->pen();
p.setColor(lineColor);
it->setPen(p);
}
if(cf & DPEN)
{
p=it->pen();
p.setWidth(penWidth);
it->setPen(p);
}
if(cf & DGRADIENT)
{
gradientDialog gd;
sgradientParam tmp;
tmp=gd.param();
it->setGradient(tmp);
it->update();
}
if(cf & DTRANSFORM)
{
it->setTransform(rotate,hShear,vShear);
}
if(t->type()==graphItemBase::TEXT)
{
itemText *itt=qgraphicsitem_cast<itemText *>(t);
if(cf & DFONT) itt->setFont(font);
if(cf & DTEXT) itt->setText(text);
}
it->update();
}
}
void editorScene::clearAll()
{
graphItemBase *r;
foreach(QGraphicsItem *t,items())
{
r=qgraphicsitem_cast<graphItemBase *>(t);
if((r->getParamPtr()->type>graphItemBase::BASE) && (r->getParamPtr()->type!=graphItemBase::SBORDER))
{
// remove the correct graphics item
r->markedForDeletion=true;
removeItem(r);
// qDebug() << "after remove";
delete r;
}
}
}
void editorScene::itemSetup(graphItemBase *item)
{
QPen p;
gradientDialog gd;
sgradientParam tmp;
tmp=gd.param();
item->setGradient(tmp);
item->setTransform(rotate,hShear,vShear);
p=item->pen();
p.setColor(lineColor);
p.setWidth(penWidth);
item->setPen(p);
item->setBrush(fillColor);
item->setZValue(zMax);
zMax+=1;
addItem(item);
}
void editorScene::setImage(QImage *im)
{
graphItemBase *item;
item=new itemImage(contextMenu);
item->setImage(*im);
item->setRect(0,0,im->width(),im->height());
itemSetup(item);
item->setPos(QPointF(0,0));
item->setSelected(true);
emit changeSize(im->width(),im->height());
}
void editorScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
graphItemBase *item;
QImage im;
if (mouseEvent->button() == Qt::LeftButton)
{
switch(mode)
{
case INSERT:
switch(itemType)
{
case graphItemBase::RECTANGLE:
item=new itemRectangle(contextMenu);
itemSetup(item);
item->setPos(mouseEvent->scenePos());
break;
case graphItemBase::LINE:
item=new itemLine(contextMenu);
itemSetup(item);
item->setPos(mouseEvent->scenePos());
break;
case graphItemBase::ELLIPSE:
item=new itemEllipse(contextMenu);
itemSetup(item);
item->setPos(mouseEvent->scenePos());
break;
case graphItemBase::TEXT:
if (!text.isEmpty())
{
item=new itemText(contextMenu);
item->setFont(font);
item->setText(text);
itemSetup(item);
item->setPos(mouseEvent->scenePos());
}
break;
case graphItemBase::IMAGE:
if (fl.isEmpty()) break;
if(im.load(fl))
{
item=new itemImage(contextMenu);
item->setImage(im);
itemSetup(item);
item->setPos(mouseEvent->scenePos());
}
break;
case graphItemBase::REPLAY:
item=new itemReplayImage(contextMenu);
itemSetup(item);
item->setPos(mouseEvent->scenePos());
break;
case graphItemBase::SBORDER:
case graphItemBase::BASE:
break;
}
break;
case MOVE:
// if(!selectedItems().isEmpty())
// {
// item=qgraphicsitem_cast<graphItemBase *>(selectedItems().first());
// }
break;
}
}
QGraphicsScene::mousePressEvent(mouseEvent);
update();
}
void editorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
QGraphicsScene::mouseMoveEvent(mouseEvent);
}
void editorScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
graphItemBase *item;
if(mode==MOVE)
{
if(!selectedItems().isEmpty())
{
item=qgraphicsitem_cast<graphItemBase *>(selectedItems().first());
emit itemSelected(item);
}
}
mode=MOVE;
QGraphicsScene::mouseReleaseEvent(mouseEvent);
}
void editorScene::slotCopy()
{
graphItemBase *item;
if((!pasted) &&(copyItem!=NULL)) delete copyItem;
if(selectedItems().isEmpty()) return; // nothing to do
item=qgraphicsitem_cast<graphItemBase *>(selectedItems().first());
makeCopy(item);
}
void editorScene::makeCopy(graphItemBase *it)
{
graphItemBase *item=it;
graphItemBase::egraphType type=(graphItemBase::egraphType)item->type();
switch(type)
{
case graphItemBase::RECTANGLE:
copyItem=new itemRectangle(item->getParam().menu);
break;
case graphItemBase::LINE:
copyItem=new itemLine(item->getParam().menu);
break;
case graphItemBase::ELLIPSE:
copyItem=new itemEllipse(item->getParam().menu);
break;
case graphItemBase::TEXT:
copyItem=new itemText(item->getParam().menu);
break;
case graphItemBase::IMAGE:
copyItem=new itemImage(item->getParam().menu);
break;
case graphItemBase::REPLAY:
copyItem=new itemReplayImage(item->getParam().menu);
break;
default:
return;
}
copyItem->setParam(item->getParam());
copyItem->setPos(item->pos()+QPointF(10,10));
pasted=false;
}
void editorScene::slotPaste()
{
clearSelection();
copyItem->setZValue(zMax+1);
zMax+=1;
addItem(copyItem);
pasted=true,
makeCopy(copyItem);
clearSelection();
}
void editorScene::slotExpand()
{
graphItemBase *it;
if(selectedItems().isEmpty()) return; // nothing to do
foreach(QGraphicsItem *t,selectedItems())
{
it=qgraphicsitem_cast<graphItemBase *>(t);
if(it->type()!=graphItemBase::TEXT)
{
it->setRect(border);
it->setPos(0,0);
}
}
}
void editorScene::slotChangeText()
{
if(selectedItems().isEmpty()) return; // nothing to do
itemText *item=qgraphicsitem_cast<itemText *>(selectedItems().first());
if(!item)
{
return;
}
if(item->type()!=graphItemBase::TEXT) return;
QDialog d(0);
Ui::textForm t;
t.setupUi(&d);
t.plainTextEdit->setPlainText(item->text());
if(d.exec()==QDialog::Accepted)
{
item->setText(t.plainTextEdit->toPlainText());
}
}
#ifndef QT_NO_DEBUG
void editorScene::slotProperties()
{
sitemParam *paramPtr;
if(selectedItems().isEmpty()) return; // nothing to do
itemText *item=qgraphicsitem_cast<itemText *>(selectedItems().first());
if(!item)
{
return;
}
paramPtr=item->getParamPtr();
QFont font=paramPtr->font;
QString txt=paramPtr->txt;
sgradientParam gr=paramPtr->gradient;
// qDebug() << "font" << font.family() << "size" << font.pointSize();
QString gradientType;
switch (gr.type)
{
case sgradientParam::LINEAR :
gradientType="LinearGradient";
break;
case sgradientParam::RADIAL:
gradientType="RadialGradient";
break;
case sgradientParam::CONICAL :
gradientType="ConicalGradient";
break;
case sgradientParam::NONE:
gradientType="NoGradient";
break;
}
// qDebug() << "gradient" << gradientType;
// qDebug() << "rotation" << gr.direction;
// qDebug() << gr.color1 << gr.pos1;
// qDebug() << gr.color2 << gr.pos2;
// qDebug() << gr.color3 << gr.pos3;
// qDebug() << gr.color4 << gr.pos4;
}
#endif
void editorScene::slotDeleteItem()
{
graphItemBase *r;
if(selectedItems().isEmpty()) return; // nothing to do
foreach(QGraphicsItem *t,selectedItems())
{
r=qgraphicsitem_cast<graphItemBase *>(t);
if((r->getParamPtr()->type>graphItemBase::BASE) && (r->getParamPtr()->type!=graphItemBase::SBORDER))
{
// remove the correct graphics item
r->markedForDeletion=true;
removeItem(r);
delete r;
}
}
}
void editorScene::slotLock()
{
graphItemBase *it;
if(selectedItems().isEmpty()) return; // nothing to do
foreach(QGraphicsItem *t,selectedItems())
{
it=qgraphicsitem_cast<graphItemBase *>(t);
it->setLocked(true);
}
}
void editorScene::slotUnlock()
{
graphItemBase *it;
if(selectedItems().isEmpty()) return; // nothing to do
foreach(QGraphicsItem *t,selectedItems())
{
it=qgraphicsitem_cast<graphItemBase *>(t);
it->setLocked(false);
}
}
void editorScene::slotBringToFront()
{
if(selectedItems().isEmpty()) return; // nothing to do
foreach(QGraphicsItem *t,selectedItems())
{
zMax+=1;
t->setZValue(zMax);
}
optimizeDepth();
}
void editorScene::slotSendToBack()
{
if(selectedItems().isEmpty()) return; // nothing to do
foreach(QGraphicsItem *t,selectedItems())
{
t->setZValue(0.5);
}
optimizeDepth();
}
void editorScene::slotSendBackward()
{
if(selectedItems().isEmpty()) return; // nothing to do
foreach(QGraphicsItem *t,selectedItems())
{
t->setZValue(t->zValue()-1.5);
}
optimizeDepth();
}
void editorScene::slotSendForward()
{
if(selectedItems().isEmpty()) return; // nothing to do
foreach(QGraphicsItem *t,selectedItems())
{
t->setZValue(t->zValue()+1.5);
}
optimizeDepth();
}
void editorScene::optimizeDepth()
{
graphItemBase *it;
zMax=items().count();
qreal i=0;
// foreach(QGraphicsItem *t,items(itemsBoundingRect ()))
foreach(QGraphicsItem *t,items())
{
it=qgraphicsitem_cast<graphItemBase *>(t);
if(it->type()==graphItemBase::SBORDER)
{
it->setZValue(0.1);
}
else if(it->type()>graphItemBase::BASE)
{
it->setZValue(zMax-i);
i+=1;
}
}
}
void editorScene::addBorder(int w,int h)
{
if (borderItemPtr==NULL)
{
borderItemPtr=new itemBorder(contextMenu);
itemSetup(borderItemPtr);
}
setSceneRect(0,0,w,h);
borderItemPtr->setPos(0,0);
borderItemPtr->setRect(0,0,w,h);
border=QRectF(0,0,w,h);
slotSendToBack();
}
void editorScene::addConversion(QChar tag,QString value,bool clear)
{
if(clear) mexp.clear();
mexp.addConversion(tag,value);
}
#ifndef QT_NO_DEBUG
void editorScene::dumpItems()
{
QString t;
int i;
QList<QGraphicsItem *> l=items();
graphItemBase *b;
addToLog(QString("dump editorView of items: %1").arg(l.count()),LOGEDIT); //exclude border
for(i=0;i<l.count();i++)
{
// if(l.at(i)->type()>=BASE)
{
b=qgraphicsitem_cast<graphItemBase *>(l.at(i));
int index=b->type();
if((index>graphItemBase::SBORDER) ||(index<graphItemBase::BASE))
{
t=QString("Illegal item type: %1").arg(l.at(i)->type());
}
t=itemTypeStr[index-graphItemBase::BASE];
addToLog(QString("editorViewItems %1 pos=%2,%3 rectxy=%4,%5 size=%6x%7 depth=%8 txt=%9")
.arg(t)
.arg(b->pos().x()).arg(b->pos().y())
.arg(b->rect().x()).arg(b->rect().y())
.arg(b->rect().width()).arg(b->rect().height())
.arg(b->zValue())
.arg(b->text())
,LOGEDIT);
}
}
}
#endif
|