Fix functionality broken by commit fc06df3

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/8/head
Michele Calgaro 1 year ago
parent fc06df3386
commit 6ca861bdae
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -204,7 +204,7 @@ void BarCodeDialog::copy()
BarcodeItem* item = new BarcodeItem( bc ); BarcodeItem* item = new BarcodeItem( bc );
DocumentItemList list; DocumentItemList list;
list.append( item ); list.push_back( item );
DocumentItemDrag* drag = new DocumentItemDrag(); DocumentItemDrag* drag = new DocumentItemDrag();
drag->setDocumentItem( &list ); drag->setDocumentItem( &list );

@ -999,7 +999,6 @@ void BatchWizard::fillVarList()
XMLUtils util; XMLUtils util;
DocumentItemList list; DocumentItemList list;
list.setAutoDelete( true );
TokenProvider token( TQT_TQPAINTDEVICE(this) ); TokenProvider token( TQT_TQPAINTDEVICE(this) );
Definition* def = NULL; Definition* def = NULL;

@ -20,7 +20,6 @@
#include <xmlutils.h> #include <xmlutils.h>
#include <tqobject.h> #include <tqobject.h>
#include <tqptrlist.h>
#include <tqstring.h> #include <tqstring.h>
#include <tqtextstream.h> #include <tqtextstream.h>
@ -224,7 +223,5 @@ const TQString DocumentItem::visibilityScript() const
return m_visibilityScript; return m_visibilityScript;
} }
typedef TQPtrList<DocumentItem> DocumentItemList;
#endif //DOCUMENTITEM_H #endif //DOCUMENTITEM_H

@ -29,7 +29,6 @@ DocumentItemDlg::DocumentItemDlg( TokenProvider* token, DocumentItem* item, KCom
{ {
m_item = item; m_item = item;
m_history = history; m_history = history;
//m_list.setAutoDelete( false );
TQVBox* boxBorder = addVBoxPage(i18n("&Position && Size"), TQString(), TQPixmap() ); TQVBox* boxBorder = addVBoxPage(i18n("&Position && Size"), TQString(), TQPixmap() );
addPage( new PropertySize( boxBorder ) ); addPage( new PropertySize( boxBorder ) );

@ -15,6 +15,8 @@
* * * *
***************************************************************************/ ***************************************************************************/
#include <algorithm>
#include "label.h" #include "label.h"
#include "measurements.h" #include "measurements.h"
#include "kbarcode.h" #include "kbarcode.h"
@ -72,6 +74,13 @@ Label::Label( Definition* _def, TQIODevice* device, TQString labelname, TQPaintD
Label::~Label() Label::~Label()
{ {
for (DocumentItem *item : m_list)
{
if (item)
{
delete item;
}
}
} }
void Label::epcl( TQTextStream* stream ) void Label::epcl( TQTextStream* stream )
@ -79,7 +88,7 @@ void Label::epcl( TQTextStream* stream )
*stream << EPCLUtils::header(); *stream << EPCLUtils::header();
DocumentItem* item; DocumentItem* item;
for( item = m_list.first();item;item=m_list.next()) for (DocumentItem *item : m_list)
if( drawThisItem( item ) ) if( drawThisItem( item ) )
item->drawEPcl( stream ); item->drawEPcl( stream );
@ -92,7 +101,7 @@ void Label::ipl( TQTextStream* stream )
*stream << utils.header(); *stream << utils.header();
DocumentItem* item; DocumentItem* item;
for( item = m_list.first();item;item=m_list.next()) for (DocumentItem *item : m_list)
if( drawThisItem( item ) ) if( drawThisItem( item ) )
item->drawIpl( stream, &utils ); item->drawIpl( stream, &utils );
@ -105,7 +114,7 @@ void Label::zpl( TQTextStream* stream )
*stream << ZPLUtils::header(); *stream << ZPLUtils::header();
DocumentItem* item; DocumentItem* item;
for( item = m_list.first();item;item=m_list.next()) for (DocumentItem *item : m_list)
if( drawThisItem( item ) ) if( drawThisItem( item ) )
item->drawZpl( stream ); item->drawZpl( stream );
@ -117,7 +126,7 @@ void Label::InitBarcodes()
bool firstbarcode = true; bool firstbarcode = true;
DocumentItem* item; DocumentItem* item;
for( item = m_list.first();item;item=m_list.next()) for (DocumentItem *item : m_list)
{ {
if( item->rtti() == eRtti_Barcode ) if( item->rtti() == eRtti_Barcode )
{ {
@ -155,7 +164,7 @@ void Label::draw( TQPainter* painter, int x, int y )
InitBarcodes(); InitBarcodes();
DocumentItem* item; DocumentItem* item;
for( item = m_list.first();item;item=m_list.next()) for (DocumentItem *item : m_list)
if( drawThisItem( item ) ) if( drawThisItem( item ) )
{ {
// add x and y to clip coordinates // add x and y to clip coordinates
@ -231,13 +240,12 @@ void Label::load( TQIODevice* device )
delete definition; delete definition;
readDocumentItems( &m_list, &doc, NULL, kbarcode18 ); readDocumentItems( &m_list, &doc, NULL, kbarcode18 );
m_list.setAutoDelete( true );
// sort the list by z index // sort the list by z index
m_list.sort(); std::sort(m_list.begin(), m_list.end(), [](DocumentItem *a, DocumentItem *b) { return *a < *b; });
DocumentItem* item; DocumentItem* item;
for( item = m_list.first();item;item=m_list.next()) for (DocumentItem *item : m_list)
{ {
// set the paint device for all items // set the paint device for all items
item->setPaintDevice( m_printer ); item->setPaintDevice( m_printer );
@ -295,7 +303,7 @@ bool Label::drawThisItem( const DocumentItem* item )
bool Label::update() bool Label::update()
{ {
DocumentItem* item; DocumentItem* item;
for( item = m_list.first();item;item=m_list.next()) for (DocumentItem *item : m_list)
if( !item->visibilityScript().isEmpty() && item->visibilityScript() != "true" ) if( !item->visibilityScript().isEmpty() && item->visibilityScript() != "true" )
return true; return true;

@ -390,7 +390,7 @@ bool LabelEditor::openUrl( const TQString & url )
DocumentItemList list; DocumentItemList list;
readDocumentItems( &list, &doc, m_token, kbarcode18 ); readDocumentItems( &list, &doc, m_token, kbarcode18 );
for( unsigned int i=0;i<list.count();i++ ) for( unsigned int i=0;i<list.size();i++ )
{ {
TCanvasItem* citem = new TCanvasItem( cv ); TCanvasItem* citem = new TCanvasItem( cv );
citem->setItem( list.at( i ) ); citem->setItem( list.at( i ) );
@ -625,9 +625,6 @@ void LabelEditor::insertText()
void LabelEditor::insertDataText() void LabelEditor::insertDataText()
{ {
// DocumentItemList list = cv->getAllItems();
// TQStringList vars = m_token->listUserVars( &list );
TokenDialog dlg( m_token, this, "dlg" ); TokenDialog dlg( m_token, this, "dlg" );
if( dlg.exec() == TQDialog::Accepted ) if( dlg.exec() == TQDialog::Accepted )
insertText( dlg.token() ); insertText( dlg.token() );
@ -974,7 +971,7 @@ void LabelEditor::copy()
DocumentItemList items; DocumentItemList items;
for( unsigned int i=0;i<list.count();i++) for( unsigned int i=0;i<list.count();i++)
items.append( (list[i])->item() ); items.push_back( (list[i])->item() );
DocumentItemDrag* drag = new DocumentItemDrag(); DocumentItemDrag* drag = new DocumentItemDrag();
drag->setDocumentItem( &items ); drag->setDocumentItem( &items );

@ -67,7 +67,7 @@ void DocumentItemDrag::setDocumentItem( DocumentItemList* list )
doc.appendChild( root ); doc.appendChild( root );
XMLUtils xml; XMLUtils xml;
for( unsigned int i=0;i<list->count();i++) for( unsigned int i=0;i<list->size();i++)
{ {
DocumentItem* item = list->at( i ); DocumentItem* item = list->at( i );
xml.writeXMLDocumentItem( &root, &item ); xml.writeXMLDocumentItem( &root, &item );

@ -529,7 +529,7 @@ DocumentItemList MyCanvasView::getAllItems()
TQCanvasItemList list = canvas()->allItems(); TQCanvasItemList list = canvas()->allItems();
for( unsigned int i = 0; i < list.count(); i++ ) for( unsigned int i = 0; i < list.count(); i++ )
l.append( ((TCanvasItem*)list[i])->item() ); l.push_back( ((TCanvasItem*)list[i])->item() );
return l; return l;
} }

@ -401,7 +401,7 @@ TQStringList TokenProvider::listUserVars()
m_findUserVarsList = &lst; m_findUserVarsList = &lst;
for( i=0;i<m_document_items.count();i++ ) for( i=0;i<m_document_items.size();i++ )
{ {
item = m_document_items.at(i); item = m_document_items.at(i);
t = TQString(); t = TQString();

@ -121,7 +121,6 @@ void XMLUtils::writeXMLHeader( TQDomNode* root, const TQString & description, De
void XMLUtils::readDocumentItems( DocumentItemList* list, TQDomDocument* doc, TokenProvider* token, bool kbarcode18 ) void XMLUtils::readDocumentItems( DocumentItemList* list, TQDomDocument* doc, TokenProvider* token, bool kbarcode18 )
{ {
TQDomNode n = doc->documentElement().firstChild(); TQDomNode n = doc->documentElement().firstChild();
list->setAutoDelete( false );
if( kbarcode18 ) if( kbarcode18 )
{ {
@ -136,7 +135,7 @@ void XMLUtils::readDocumentItems( DocumentItemList* list, TQDomDocument* doc, To
bcode->updateBarcode(); bcode->updateBarcode();
bcode->setZ( e.attribute( "z", "0" ).toInt() ); bcode->setZ( e.attribute( "z", "0" ).toInt() );
list->append( bcode ); list->push_back( bcode );
} else if( e.tagName() == "textfield" ) { } else if( e.tagName() == "textfield" ) {
TextItem* t = new TextItem(); TextItem* t = new TextItem();
t->setTokenProvider( token ); t->setTokenProvider( token );
@ -157,7 +156,7 @@ void XMLUtils::readDocumentItems( DocumentItemList* list, TQDomDocument* doc, To
n = n.nextSibling(); n = n.nextSibling();
} }
list->append( t ); list->push_back( t );
} else if( e.tagName() == "picture" ) { } else if( e.tagName() == "picture" ) {
ImageItem* r = new ImageItem(); ImageItem* r = new ImageItem();
@ -169,7 +168,7 @@ void XMLUtils::readDocumentItems( DocumentItemList* list, TQDomDocument* doc, To
r->setPixmap( pix ); r->setPixmap( pix );
r->setRotation( e.attribute("rotation", "0.0" ).toDouble() ); r->setRotation( e.attribute("rotation", "0.0" ).toDouble() );
r->setZ( e.attribute( "z", "0" ).toInt() ); r->setZ( e.attribute( "z", "0" ).toInt() );
list->append( r ); list->push_back( r );
} else if( e.tagName() == "rect" ) { } else if( e.tagName() == "rect" ) {
RectItem* r = new RectItem(); RectItem* r = new RectItem();
@ -181,7 +180,7 @@ void XMLUtils::readDocumentItems( DocumentItemList* list, TQDomDocument* doc, To
r->setPen( TQPen(readXMLColor( &e, "bordercolor", TQt::black ),e.attribute( "borderwidth", "1" ).toInt(),(TQt::PenStyle)e.attribute( "borderstyle", "1" ).toInt() )); r->setPen( TQPen(readXMLColor( &e, "bordercolor", TQt::black ),e.attribute( "borderwidth", "1" ).toInt(),(TQt::PenStyle)e.attribute( "borderstyle", "1" ).toInt() ));
r->setColor( readXMLColor( &e, "color", TQt::black ) ); r->setColor( readXMLColor( &e, "color", TQt::black ) );
list->append( r ); list->push_back( r );
} else if( e.tagName() == "line" ) { } else if( e.tagName() == "line" ) {
#warning "TODO: test legacy loading of lines" #warning "TODO: test legacy loading of lines"
LineItem* cl = new LineItem(); LineItem* cl = new LineItem();
@ -192,7 +191,7 @@ void XMLUtils::readDocumentItems( DocumentItemList* list, TQDomDocument* doc, To
cl->setZ( e.attribute( "z", "0" ).toInt() ); cl->setZ( e.attribute( "z", "0" ).toInt() );
cl->setPen( TQPen( readXMLColor( &e, "color", TQt::black ), cl->setPen( TQPen( readXMLColor( &e, "color", TQt::black ),
e.attribute( "width", "0" ).toInt(), (TQPen::PenStyle)e.attribute( "style", "0" ).toInt() ) ); e.attribute( "width", "0" ).toInt(), (TQPen::PenStyle)e.attribute( "style", "0" ).toInt() ) );
list->append( cl ); list->push_back( cl );
} }
n = n.nextSibling(); n = n.nextSibling();
} }
@ -205,7 +204,7 @@ void XMLUtils::readDocumentItems( DocumentItemList* list, TQDomDocument* doc, To
{ {
DocumentItem* item = NULL; DocumentItem* item = NULL;
if( readXMLDocumentItem( &e, &item, token ) ) if( readXMLDocumentItem( &e, &item, token ) )
list->append( item ); list->push_back( item );
} }
n = n.nextSibling(); n = n.nextSibling();
} }

@ -19,7 +19,7 @@
#define XMLUTILS_H #define XMLUTILS_H
#include <tqmap.h> #include <tqmap.h>
#include <tqptrlist.h> #include <vector>
class DocumentItem; class DocumentItem;
class BarcodeItem; class BarcodeItem;
@ -34,7 +34,7 @@ class TQDomNode;
class TQRect; class TQRect;
class TQString; class TQString;
class TQWidget; class TQWidget;
typedef TQPtrList<DocumentItem> DocumentItemList; typedef std::vector<DocumentItem*> DocumentItemList;
/** This class provides helper function for saving and reading to XML files. /** This class provides helper function for saving and reading to XML files.
* *

Loading…
Cancel
Save