/**************************************************************************** ** ** Copyright (C) 2007 Aleksey Luzin. All rights reserved. ** ** This file is part of the qLabels project. ** ** This file may be used under the terms of the GNU General Public ** License version 2.0 as published by the Free Software Foundation ** and appearing in the file LICENSE.GPL included in the packaging of ** this file. Please review the following information to ensure GNU ** General Public Licensing requirements will be met: ** http://www.trolltech.com/products/qt/opensource.html ** ** If you are unsure which license is appropriate for your use, please ** review the following information: ** http://www.trolltech.com/products/qt/licensing.html or contact the ** sales department at sales@trolltech.com. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ****************************************************************************/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "canvas.h" #include #include #include "elements/textitem.h" #include "elements/pixmapitem.h" #include "elements.h" #include "itabs.h" #include "newlabel.h" #include "printpreview.h" extern QPen *tp; FigureEditor::FigureEditor(QGraphicsScene& c, QMainWindow* parent, const char* name, Qt::WindowFlags f) :QGraphicsView(&c,parent) { canvas = &c; setObjectName(name); setWindowFlags(f); start_draw = false; drawing = false; mparent = parent; // setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); } void FigureEditor::clear() { QList list = scene()->items(); QList::Iterator it = list.begin(); for (; it != list.end(); ++it) { if ( *it ) delete *it; } } void FigureEditor::mousePressEvent ( QMouseEvent * event ){ if (start_draw && (event->button() == Qt::LeftButton)) { start_draw = false; QPointF p = mapToScene(event->x(),event->y()); eitems.append(newitem); newitem->setBlock(true); newitem->to_node->setPos(int(p.x()), int(p.y())); newitem->from_node->setPos(int(p.x()), int(p.y())); newitem->setFromPoint(int(p.x()), int(p.y())); newitem->setToPoint(int(p.x()), int(p.y())); newitem->from_node->setFlag(QGraphicsItem::ItemIsMovable, false); canvas->addItem(newitem->from_node); canvas->addItem(newitem->to_node); qnewitem->setZValue(eitems.count()+3); canvas->addItem(qnewitem); newitem->setBlock(false); qnewitem->setSelected(true); drawing = true; } QGraphicsView::mousePressEvent(event); } void FigureEditor::mouseReleaseEvent ( QMouseEvent * event ){ if (drawing) { drawing = false; QPointF p = mapToScene(event->x(),event->y()); newitem->to_node->setPos(int(p.x()), int(p.y())); newitem->setToPoint(int(p.x()), int(p.y())); newitem->from_node->setFlag(QGraphicsItem::ItemIsMovable); qnewitem->setSelected(false); qnewitem->setSelected(true); setCursor(Qt::ArrowCursor); qnewitem->setFlag(QGraphicsItem::ItemIsMovable); } QGraphicsView::mouseReleaseEvent(event); } void FigureEditor::mouseMoveEvent ( QMouseEvent * event ){ if (drawing) { QPointF p = mapToScene(event->x(),event->y()); newitem->to_node->setPos(int(p.x()), int(p.y())); newitem->setToPoint(int(p.x()), int(p.y())); // qnewitem->setSelected(true); } QGraphicsView::mouseMoveEvent(event); } void FigureEditor::contextMenuEvent(QContextMenuEvent *event) { ((Main *)mparent)->edit->exec(event->globalPos()); } QSettings *conf = 0; Main::Main(QGraphicsScene& c, QWidget* parent, Qt::WindowFlags f) : QMainWindow(parent,f), canvas(c) { editor = new FigureEditor(canvas,this); QMenuBar* menu = menuBar(); conf = new QSettings (QString(QDir::homePath())+QString("/.qlabels/qlabels.conf"), QSettings::IniFormat); editor->setRenderHint(QPainter::Antialiasing, conf->value("antialiasing", false).toBool()); createToolBars(); QMenu* file = new QMenu( tr("&File"), menu ); file->addAction(tr("&New label"), this, SLOT(newLabel()), Qt::CTRL+Qt::Key_N); file->addAction(tr("&Open label"), this, SLOT(openLabel()), Qt::CTRL+Qt::Key_O); file->addAction(tr("&Save label"), this, SLOT(saveLabel()), Qt::CTRL+Qt::Key_S); file->addSeparator(); file->addAction(tr("&Print Preview..."), this, SLOT(print_preview())); file->addAction(tr("&Print..."), this, SLOT(print()), Qt::CTRL+Qt::Key_P); file->addSeparator(); file->addAction(tr("E&xit"), qApp, SLOT(quit()), Qt::CTRL+Qt::Key_Q); menu->addMenu(file); edit = new QMenu( tr("&Edit"), menu ); delAct = edit->addAction(tr("&Delete Item..."), this, SLOT(del_item()), Qt::Key_Delete); delAct->setEnabled(false); edit->addSeparator(); insimageAct = edit->addAction(tr("&Insert image..."), this, SLOT(ins_image()), Qt::CTRL+Qt::Key_I); menu->addMenu(edit); QMenu *options = new QMenu(tr("&Options"), menu); QMenu *poptions = new QMenu(tr("Print Options"), options); options->addMenu(poptions); poptions->addAction(pborder); poptions->addAction(pmarks); options->addAction(aaAct); menu->addMenu(options); QMenu* help = new QMenu( tr("&Help"), menu ); help->addAction(tr("&About"), this, SLOT(about())); menu->addMenu(help); // db = new QBrush( Qt::green ); // QColor color = db.color(); // color.setAlpha(128); // db.setColor(color); if ( !tp ) tp = new QPen( QBrush(Qt::black),1); statusBar(); zoominfo = new QLabel(""); zoominfo->setMinimumWidth(100); statusBar()->addPermanentWidget(zoominfo); properties = new QTabWidget; properties->setMaximumWidth(300); QSplitter *splitter = new QSplitter; splitter->addWidget(editor); splitter->addWidget(properties); setCentralWidget(splitter); cursor_line = QCursor(QPixmap(":images/cursor_line.png"),QPixmap(":images/cursor_line_mask.png"),7,7); cursor_rect = QCursor(QPixmap(":images/cursor_box.png"),QPixmap(":images/cursor_box_mask.png"),7,7); cursor_ellipse = QCursor(QPixmap(":images/cursor_ellipse.png"),QPixmap(":images/cursor_ellipse_mask.png"),7,7); cursor_text = QCursor(QPixmap(":images/cursor_text.png"),QPixmap(":images/cursor_text_mask.png"),7,7); cursor_image = QCursor(QPixmap(":images/cursor_image.png"),QPixmap(":images/cursor_image_mask.png"),7,7); printer = 0; resize(600,500); init(); } void Main::init() { clear(); scale_ = 1; editor->eitems.clear(); } void Main::del_item() { EdgeItem * eitem = editor->eitems.at(selected_item); editor->eitems.removeAt(selected_item); editor->canvas->removeItem(eitem->from_node); editor->canvas->removeItem(eitem->to_node); switch(eitem->item_type) { case 3: editor->canvas->removeItem((RectItem *) eitem);break; case 4: editor->canvas->removeItem((EllipseItem *) eitem);break; case 6: editor->canvas->removeItem((LineItem *) eitem);break; case 7: editor->canvas->removeItem((PixmapItem *) eitem);break; case 9: editor->canvas->removeItem((TextItem *) eitem);break; } item_selected(0); selected_item = -1; } void Main::ins_image() { qDebug("insert image"); QClipboard *clipboard = QApplication::clipboard(); QPixmap im = clipboard->pixmap(); qDebug("%i %i", im.width(), im.height()); NodeItem *el1 = new NodeItem; NodeItem *el2 = new NodeItem; PixmapItem *item = new PixmapItem(el1, el2); QGraphicsItem *qnewitem = item; editor->canvas->clearSelection (); int w,h; w = int(template_width);h = int(template_height); if((w>=im.width()) &&(h>=im.height())) { w = im.width(); h = im.height(); } else { qreal w1 = im.width(), h1 = im.height(); qreal ar = h1/w1; if(h>w*ar) { h = int(w*ar); } else { w = int(h/ar); } } item->orig_image = &im; item->scale_image = new QPixmap(im.scaled(w,h)); item->maxx = int(template_width); item->maxy = int(template_height); item->setSelected(true); item->setFromPoint(0,0); item->setToPoint(w,h); editor->eitems.append(item); editor->canvas->addItem(el1); editor->canvas->addItem(el2); qnewitem->setZValue(editor->eitems.count()+3); editor->canvas->addItem(qnewitem); connect(item, SIGNAL(item_selected(EdgeItem *)), this, SLOT(item_selected(EdgeItem *))); } void Main::createToolBars() { lineAct = new QAction(QIcon(":/images/stock_line_24.png"), tr("&Line"), this); lineAct->setShortcut(tr("Ctrl+L")); lineAct->setStatusTip(tr("Add Line")); connect(lineAct, SIGNAL(triggered()), this, SLOT(addLine())); ellipseAct = new QAction(QIcon(":/images/stock_ellipse_24.png"), tr("&Ellipse"), this); ellipseAct->setShortcut(tr("Ctrl+E")); ellipseAct->setStatusTip(tr("Add Ellipse")); connect(ellipseAct, SIGNAL(triggered()), this, SLOT(addEllipse())); boxAct = new QAction(QIcon(":/images/stock_box_24.png"), tr("&Rectangle"), this); boxAct->setShortcut(tr("Ctrl+R")); boxAct->setStatusTip(tr("Add Rectangle")); connect(boxAct, SIGNAL(triggered()), this, SLOT(addBox())); imageAct = new QAction(QIcon(":/images/stock_image_24.png"), tr("&Image"), this); imageAct->setShortcut(tr("Ctrl+I")); imageAct->setStatusTip(tr("Add Image")); connect(imageAct, SIGNAL(triggered()), this, SLOT(addImage())); textAct = new QAction(QIcon(":/images/stock_text_24.png"), tr("&Text"), this); textAct->setShortcut(tr("Ctrl+T")); textAct->setStatusTip(tr("Add Text")); connect(textAct, SIGNAL(triggered()), this, SLOT(addTextI())); aaAct = new QAction(tr("&AntiAliasing"), this); aaAct->setCheckable(true); aaAct->setChecked(conf->value("antialiasing", false).toBool()); aaAct->setShortcut(tr("Ctrl+A")); aaAct->setStatusTip(tr("toggle AntiAliasing")); connect(aaAct, SIGNAL(triggered()), this, SLOT(antiAliasing())); pmarks = new QAction(tr("Print Crop Marks"), this); pmarks->setCheckable(true); pmarks->setChecked(conf->value("printcrops", false).toBool()); pborder = new QAction(tr("Print Outlines"), this); pborder->setCheckable(true); pborder->setChecked(conf->value("printoutlines", false).toBool()); zoominAct = new QAction(QIcon(":/images/viewmag+.png"), tr("Zoom In"), this); connect(zoominAct, SIGNAL(triggered()), this, SLOT(zoomin())); zoomoutAct = new QAction(QIcon(":/images/viewmag-.png"), tr("Zoom Out"), this); connect(zoomoutAct, SIGNAL(triggered()), this, SLOT(zoomout())); zoomfitAct = new QAction(QIcon(":/images/viewmagfit.png"), tr("Zoom Fit"), this); connect(zoomfitAct, SIGNAL(triggered()), this, SLOT(zoomfit())); zoom1Act = new QAction(QIcon(":/images/viewmag1.png"), tr("Zoom 1:1"), this); connect(zoom1Act, SIGNAL(triggered()), this, SLOT(zoom1())); fileToolBar = addToolBar(tr("File")); fileToolBar->addAction(lineAct); fileToolBar->addAction(ellipseAct); fileToolBar->addAction(boxAct); fileToolBar->addAction(imageAct); fileToolBar->addAction(textAct); fileToolBar->addAction(zoominAct); fileToolBar->addAction(zoomoutAct); fileToolBar->addAction(zoomfitAct); fileToolBar->addAction(zoom1Act); } Main::~Main() { conf->setValue("printcrops", pmarks->isChecked()); conf->setValue("printoutlines", pborder->isChecked()); conf->sync(); delete printer; } void Main::saveLabel() { QString fileName = QFileDialog::getSaveFileName(this, tr("Save Label"), conf->value("lastdirectory", "").toString(), tr("qLabels files (*.xml);;All Files (*)")); if (fileName.isEmpty()) return; QFileInfo fi(fileName); conf->setValue("lastdirectory", fi.absolutePath()); QDomDocument doc; QDomElement root = doc.createElement("label"); doc.appendChild(root); root.appendChild(current_template); QDomElement rotate = doc.createElement("rotate"); rotate.setAttribute("value", is_rotated); root.appendChild(rotate); QDomElement items = doc.createElement("items"); root.appendChild(items); foreach (EdgeItem *item, editor->eitems) { QDomElement i = item->toXml(doc); items.appendChild(i); } QFile file(fileName); if ( file.open( QIODevice::WriteOnly ) ) { QTextStream stream( &file ); doc.save(stream,1); file.close(); } } void Main::openLabel() { QString fileName = QFileDialog::getOpenFileName(this, tr("Open Label"), conf->value("lastdirectory", "").toString(), tr("All Files (*);;qLabels files (*.xml)")); if (fileName.isEmpty()) return; QFileInfo fi(fileName); conf->setValue("lastdirectory", fi.absolutePath()); load_file(fileName); } void Main::newLabel() { NewLabel *newl = new NewLabel(); if(newl->exec()) { is_rotated = (newl->rotate->checkState () == Qt::Checked); current_template = newl->current_template; current_paper = newl->current_paper; clear(); draw_template(); // editor->scale( 0.5, 0.5 ); } } void Main::antiAliasing() { if(aaAct->isChecked()) { editor->setRenderHints(QPainter::Antialiasing); } else { editor->setRenderHint(QPainter::Antialiasing, false); } conf->setValue("antialiasing", aaAct->isChecked()); } void Main::load_file(QString fileName) { QFile file(fileName); QString errorStr; int errorLine; int errorColumn; QDomDocument domDocument; if (!domDocument.setContent(&file, true, &errorStr, &errorLine, &errorColumn)) { } QDomElement root = domDocument.firstChildElement("label"); QDomNodeList list = root.elementsByTagName ("Template"); QString c = list.at(0).toElement().attribute("description"); Papers *papers = new Papers(); QString size = list.at(0).toElement().attribute("size"); for(int i=0;ilist.count();i++) { QDomElement child = papers->list.at(i).toElement(); QString id = child.attribute("id"); if(id.compare(size, Qt::CaseInsensitive)==0) { current_paper = child; break; } } current_template = list.at(0).toElement(); list = root.elementsByTagName ("rotate"); is_rotated = list.at(0).toElement().attribute("value").toInt(); clear(); draw_template(); list = root.elementsByTagName ("items"); list = list.at(0).childNodes(); QList items_c; items_c << ""<< ""<< ""<< "rectangle"<< "ellipse" << ""<< "line" << "pixmap"<< ""<< "text"; for(int i=0;isetZValue(i+3); editor->canvas->addItem(qi); editor->canvas->addItem(ei->from_node); editor->canvas->addItem(ei->to_node); ei->from_node->hide(); ei->to_node->hide(); editor->eitems.append(ei); connect(ei, SIGNAL(item_selected(EdgeItem *)), this, SLOT(item_selected(EdgeItem *))); } } } void Main::draw_template() { // editor->setRenderHints(QPainter::Antialiasing); QDomNodeList items = current_template.childNodes(); if(items.isEmpty()) return; QDomElement label = items.at(0).toElement(); // qDebug() << label.tagName(); if(label.tagName().compare("Label-rectangle", Qt::CaseInsensitive)==0) { template_width = unit_to_point(label.attribute("width")); template_height = unit_to_point(label.attribute("height")); if(is_rotated) { double tmp = template_width; template_width = template_height; template_height = tmp; } canvas.setSceneRect(0,0,template_width, template_height); QAbstractGraphicsShapeItem *i = canvas.addRect( QRectF(0, 0, template_width, template_height)); i->setBrush( QColor(255,255,255) ); i->setPen( QPen(QColor(172,214,230), 2) ); i->setZValue(0); int j = 10; while (jsetPen( QPen(QColor(197,190,197), 0) ); i1->setZValue(1); j+=10; } j=10; while (j<=template_height) { QGraphicsLineItem *i1 = canvas.addLine( QLineF(0, j, template_width, j)); i1->setPen( QPen(QColor(197,190,197), 0) ); i1->setZValue(1); j+=10; } QDomNodeList items0 = label.childNodes(); for(int i0=0;i0setPen( QPen(QColor(197,0,0), 0) ); i1->setZValue(2); } } } else if(label.tagName().compare("Label-cd", Qt::CaseInsensitive)==0) { double radius = unit_to_point(label.attribute("radius")); double hole = unit_to_point(label.attribute("hole")); template_width = radius*2; template_height = radius*2; canvas.setSceneRect(0,0,template_width, template_height); QAbstractGraphicsShapeItem *i = canvas.addEllipse( QRectF(0, 0, template_width, template_height)); i->setBrush( QColor(255,255,255) ); i->setPen( QPen(QColor(172,214,230), 2) ); i->setZValue(1); QAbstractGraphicsShapeItem *hl = canvas.addEllipse( QRectF(radius-hole, radius-hole, hole*2, hole*2)); hl->setBrush( Qt::lightGray ); hl->setPen( QPen(QColor(172,214,230), 2) ); hl->setZValue(2); int j = 10; while (jsetPen( QPen(Qt::lightGray, 0) ); i1->setZValue(2); j+=10; } j=10; while (j<=template_height) { QGraphicsLineItem *i1 = canvas.addLine( QLineF(0, j, template_width, j)); i1->setPen( QPen(Qt::lightGray, 0) ); i1->setZValue(2); j+=10; } } } void Main::zoomin() { editor->scale( 2.0, 2.0 ); scale_*=2; zoominfo->setText(" "+QString::number(100*scale_)+"% "); } void Main::zoomout() { editor->scale( 0.5, 0.5 ); scale_*=0.5; zoominfo->setText(" "+QString::number(100*scale_)+"% "); } void Main::zoomfit() { qreal sc = (editor->width()-10)/template_width; qreal h1 = (editor->height()-10)/template_height; if(h1scale(sc/scale_,sc/scale_); scale_*=(sc/scale_); zoominfo->setText(" "+QString::number(100*scale_)+"% "); } void Main::zoom1() { editor->scale( 1/scale_, 1/scale_ ); scale_*= (1/scale_); zoominfo->setText(" "+QString::number(100*scale_)+"% "); } void Main::clear() { editor->clear(); } void Main::addLine() { NodeItem *el1 = new NodeItem; NodeItem *el2 = new NodeItem; LineItem *item = new LineItem(el1, el2); editor->canvas->clearSelection (); item->setSelected(true); editor->newitem = item; editor->qnewitem = item; editor->start_draw = true; editor->setCursor(cursor_line); connect(item, SIGNAL(item_selected(EdgeItem *)), this, SLOT(item_selected(EdgeItem *))); } void Main::addEllipse() { NodeItem *el1 = new NodeItem; NodeItem *el2 = new NodeItem; EllipseItem *item = new EllipseItem(el1, el2); editor->canvas->clearSelection (); item->setSelected(true); editor->newitem = item; editor->qnewitem = item; editor->start_draw = true; editor->setCursor(cursor_ellipse); connect(item, SIGNAL(item_selected(EdgeItem *)), this, SLOT(item_selected(EdgeItem *))); } void Main::addBox() { NodeItem *el1 = new NodeItem; NodeItem *el2 = new NodeItem; RectItem *item = new RectItem(el1, el2); editor->canvas->clearSelection (); item->setSelected(true); editor->newitem = item; editor->qnewitem = item; editor->start_draw = true; editor->setCursor(cursor_rect); connect(item, SIGNAL(item_selected(EdgeItem *)), this, SLOT(item_selected(EdgeItem *))); } void Main::addImage() { NodeItem *el1 = new NodeItem; NodeItem *el2 = new NodeItem; PixmapItem *item = new PixmapItem(el1, el2); editor->canvas->clearSelection (); item->maxx = int(template_width); item->maxy = int(template_height); item->setSelected(true); editor->newitem = item; editor->qnewitem = item; editor->start_draw = true; editor->setCursor(cursor_image); connect(item, SIGNAL(item_selected(EdgeItem *)), this, SLOT(item_selected(EdgeItem *))); } void Main::addTextI() { NodeItem *el1 = new NodeItem; NodeItem *el2 = new NodeItem; TextItem *item = new TextItem(el1, el2); editor->canvas->clearSelection (); item->setSelected(true); editor->newitem = item; editor->qnewitem = item; editor->start_draw = true; editor->setCursor(cursor_text); connect(item, SIGNAL(item_selected(EdgeItem *)), this, SLOT(item_selected(EdgeItem *))); } void Main::about() { QMessageBox::information(this, tr("About qLabels 0.2"), tr("qLabels v0.2.\n\n" "Copyright 2007 Aleksey Luzin.")); } void Main::print_preview() { if ( !printer ) printer = new QPrinter; printer->setResolution(72); double pwidth = unit_to_point(current_paper.attribute("width"), 1); double pheight = unit_to_point(current_paper.attribute("height"), 1); PrintPreview *preview = new PrintPreview(pwidth, pheight); connect(preview, SIGNAL(request_page(PrintPreview *, int, double, QPainter *)), this, SLOT(print_requested_page(PrintPreview *, int, double, QPainter *)),Qt::DirectConnection); if(preview->exec()) { print(); } delete preview; } void Main::print_requested_page(PrintPreview *preview, int page, double scale, QPainter *p) { print_page(scale, p, printer); preview->update_preview(); } void Main::print() { if ( !printer ) printer = new QPrinter; QPrintDialog printDialog(printer, this); if (printDialog.exec() == QDialog::Accepted) { printer->setResolution(72); printer->setFullPage(true); // QPrinter * pr = (QPrinter *)printDialog.printer(); double max_scale=1; foreach (EdgeItem *item, editor->eitems) { if(item->item_type==7) { PixmapItem *pix =(PixmapItem *)item; QRect r = pix->pixmap().rect(); QRect r1 = pix->orig_image->rect(); if(max_scalesetResolution(int(72*max_scale)); QPainter pp(printer); if(conf->value("antialiasing", false).toBool()) { pp.setRenderHints(QPainter::Antialiasing); } print_page(max_scale, &pp, printer); } } void Main::print_page(double scale, QPainter *pp, QPrinter *printer) { qreal max_scale = scale; QDomNodeList items = current_template.childNodes(); int i; for(i=0;ivalue("antialiasing", false).toBool()) { pn.setRenderHints(QPainter::Antialiasing); } if (tagname.compare("Label-cd", Qt::CaseInsensitive)==0) { QPainterPath clipPath; clipPath.addEllipse(0,0, rect_width, rect_height); clipPath.addEllipse(radius-hole,radius-hole, hole*2, hole*2); pn.setClipPath(clipPath); } print_label(0.0, 0.0, max_scale, &pn, printer); QPixmap im1; if(is_rotated) { QMatrix mm = im.trueMatrix(QMatrix(), int(rect_height), int(rect_width) ); mm.rotate(-90); im1 = im.transformed(mm); } else { im1 = im; } for(yi = 0;yidrawPixmap(QPoint(int(x0+xi*dx), int(y0+dy*yi)), im1); if(pmarks->isChecked()) { float pl[8] = {0,0, rect_width,0, rect_width, rect_height, 0,rect_height}; for(j=0;j<4;j++) { pp->drawLine(int(x0-10*max_scale+dx*xi+pl[j*2]), int(y0+dy*yi+pl[j*2+1]), int(x0+10*max_scale+dx*xi+pl[j*2]), int(y0+dy*yi+pl[j*2+1])); pp->drawLine(int(x0+dx*xi+pl[j*2]), int(y0-10*max_scale+dy*yi+pl[j*2+1]), int(x0+dx*xi+pl[j*2]), int(y0+10*max_scale+dy*yi+pl[j*2+1])); } } if(pborder->isChecked()) { if (tagname.compare("Label-cd", Qt::CaseInsensitive)==0) { pp->drawEllipse(int(x0+dx*xi), int(y0+dy*yi), int(rect_width), int(rect_height)); pp->drawEllipse(int(x0+dx*xi+radius-hole), int(y0+dy*yi+radius-hole), int(hole*2), int(hole*2)); } else { pp->drawRect(int(x0+dx*xi), int(y0+dy*yi), int(rect_width), int(rect_height)); } } } } } } } void Main::print_label(double x, double y, double scale, QPainter *pp, QPrinter *pp1) { int i; for(i=0;ieitems.count();i++) { EdgeItem *item = editor->eitems.at(i); if (item->item_type==9) { ((TextItem *)item)->paintItem(int(x),int(y),pp, pp1, scale); } else { item->paintItem(int(x),int(y),pp, scale); } } } void Main::item_selected(EdgeItem * item) { while(properties->count()>0) { properties->removeTab(0); } if(item) { item->setTabs(properties); delAct->setEnabled(true); selected_item = editor->eitems.indexOf(item); } else { delAct->setEnabled(false); selected_item = -1; } }