diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2023-06-29 18:48:31 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2023-06-29 18:48:31 +0900 |
commit | 6ca861bdae50e0c0fdbdbda45e2e9b6402d8b2de (patch) | |
tree | 1552df0d7041a08628fd6233e013392fd963005e | |
parent | fc06df3386aadde97693e8f0062d25d3b49afc7a (diff) | |
download | kbarcode-6ca861bdae50e0c0fdbdbda45e2e9b6402d8b2de.tar.gz kbarcode-6ca861bdae50e0c0fdbdbda45e2e9b6402d8b2de.zip |
Fix functionality broken by commit fc06df3
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
-rw-r--r-- | kbarcode/barcodedialog.cpp | 2 | ||||
-rw-r--r-- | kbarcode/batchwizard.cpp | 5 | ||||
-rw-r--r-- | kbarcode/documentitem.h | 3 | ||||
-rw-r--r-- | kbarcode/documentitemdlg.cpp | 1 | ||||
-rw-r--r-- | kbarcode/label.cpp | 26 | ||||
-rw-r--r-- | kbarcode/labeleditor.cpp | 9 | ||||
-rw-r--r-- | kbarcode/mimesources.cpp | 2 | ||||
-rw-r--r-- | kbarcode/mycanvasview.cpp | 2 | ||||
-rw-r--r-- | kbarcode/mycanvasview.h | 6 | ||||
-rw-r--r-- | kbarcode/tokenprovider.cpp | 2 | ||||
-rw-r--r-- | kbarcode/xmlutils.cpp | 13 | ||||
-rw-r--r-- | kbarcode/xmlutils.h | 4 |
12 files changed, 37 insertions, 38 deletions
diff --git a/kbarcode/barcodedialog.cpp b/kbarcode/barcodedialog.cpp index 3919f74..cff4777 100644 --- a/kbarcode/barcodedialog.cpp +++ b/kbarcode/barcodedialog.cpp @@ -204,7 +204,7 @@ void BarCodeDialog::copy() BarcodeItem* item = new BarcodeItem( bc ); DocumentItemList list; - list.append( item ); + list.push_back( item ); DocumentItemDrag* drag = new DocumentItemDrag(); drag->setDocumentItem( &list ); diff --git a/kbarcode/batchwizard.cpp b/kbarcode/batchwizard.cpp index 09c2fe4..c128e36 100644 --- a/kbarcode/batchwizard.cpp +++ b/kbarcode/batchwizard.cpp @@ -999,7 +999,6 @@ void BatchWizard::fillVarList() XMLUtils util; DocumentItemList list; - list.setAutoDelete( true ); TokenProvider token( TQT_TQPAINTDEVICE(this) ); Definition* def = NULL; @@ -1017,8 +1016,8 @@ void BatchWizard::fillVarList() m_varTable->setNumCols( vars.count() ); for( unsigned int i = 0; i < vars.count(); i++ ) { - vars[i] = vars[i].right( vars[i].length() - 1 ); - m_varTable->horizontalHeader()->setLabel( i, vars[i] ); + vars[i] = vars[i].right( vars[i].length() - 1 ); + m_varTable->horizontalHeader()->setLabel( i, vars[i] ); } delete def; diff --git a/kbarcode/documentitem.h b/kbarcode/documentitem.h index 9255266..642c385 100644 --- a/kbarcode/documentitem.h +++ b/kbarcode/documentitem.h @@ -20,7 +20,6 @@ #include <xmlutils.h> #include <tqobject.h> -#include <tqptrlist.h> #include <tqstring.h> #include <tqtextstream.h> @@ -224,7 +223,5 @@ const TQString DocumentItem::visibilityScript() const return m_visibilityScript; } -typedef TQPtrList<DocumentItem> DocumentItemList; - #endif //DOCUMENTITEM_H diff --git a/kbarcode/documentitemdlg.cpp b/kbarcode/documentitemdlg.cpp index 672273b..0a3f245 100644 --- a/kbarcode/documentitemdlg.cpp +++ b/kbarcode/documentitemdlg.cpp @@ -29,7 +29,6 @@ DocumentItemDlg::DocumentItemDlg( TokenProvider* token, DocumentItem* item, KCom { m_item = item; m_history = history; - //m_list.setAutoDelete( false ); TQVBox* boxBorder = addVBoxPage(i18n("&Position && Size"), TQString(), TQPixmap() ); addPage( new PropertySize( boxBorder ) ); diff --git a/kbarcode/label.cpp b/kbarcode/label.cpp index b109347..9102740 100644 --- a/kbarcode/label.cpp +++ b/kbarcode/label.cpp @@ -15,6 +15,8 @@ * * ***************************************************************************/ +#include <algorithm> + #include "label.h" #include "measurements.h" #include "kbarcode.h" @@ -72,6 +74,13 @@ Label::Label( Definition* _def, TQIODevice* device, TQString labelname, TQPaintD Label::~Label() { + for (DocumentItem *item : m_list) + { + if (item) + { + delete item; + } + } } void Label::epcl( TQTextStream* stream ) @@ -79,7 +88,7 @@ void Label::epcl( TQTextStream* stream ) *stream << EPCLUtils::header(); DocumentItem* item; - for( item = m_list.first();item;item=m_list.next()) + for (DocumentItem *item : m_list) if( drawThisItem( item ) ) item->drawEPcl( stream ); @@ -92,7 +101,7 @@ void Label::ipl( TQTextStream* stream ) *stream << utils.header(); DocumentItem* item; - for( item = m_list.first();item;item=m_list.next()) + for (DocumentItem *item : m_list) if( drawThisItem( item ) ) item->drawIpl( stream, &utils ); @@ -105,7 +114,7 @@ void Label::zpl( TQTextStream* stream ) *stream << ZPLUtils::header(); DocumentItem* item; - for( item = m_list.first();item;item=m_list.next()) + for (DocumentItem *item : m_list) if( drawThisItem( item ) ) item->drawZpl( stream ); @@ -117,7 +126,7 @@ void Label::InitBarcodes() bool firstbarcode = true; DocumentItem* item; - for( item = m_list.first();item;item=m_list.next()) + for (DocumentItem *item : m_list) { if( item->rtti() == eRtti_Barcode ) { @@ -155,7 +164,7 @@ void Label::draw( TQPainter* painter, int x, int y ) InitBarcodes(); DocumentItem* item; - for( item = m_list.first();item;item=m_list.next()) + for (DocumentItem *item : m_list) if( drawThisItem( item ) ) { // add x and y to clip coordinates @@ -231,13 +240,12 @@ void Label::load( TQIODevice* device ) delete definition; readDocumentItems( &m_list, &doc, NULL, kbarcode18 ); - m_list.setAutoDelete( true ); // 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; - for( item = m_list.first();item;item=m_list.next()) + for (DocumentItem *item : m_list) { // set the paint device for all items item->setPaintDevice( m_printer ); @@ -295,7 +303,7 @@ bool Label::drawThisItem( const DocumentItem* item ) bool Label::update() { DocumentItem* item; - for( item = m_list.first();item;item=m_list.next()) + for (DocumentItem *item : m_list) if( !item->visibilityScript().isEmpty() && item->visibilityScript() != "true" ) return true; diff --git a/kbarcode/labeleditor.cpp b/kbarcode/labeleditor.cpp index 6471527..41f58d5 100644 --- a/kbarcode/labeleditor.cpp +++ b/kbarcode/labeleditor.cpp @@ -390,11 +390,11 @@ bool LabelEditor::openUrl( const TQString & url ) DocumentItemList list; 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 ); citem->setItem( list.at( i ) ); - citem->addRef(); + citem->addRef(); } list.clear(); @@ -625,9 +625,6 @@ void LabelEditor::insertText() void LabelEditor::insertDataText() { -// DocumentItemList list = cv->getAllItems(); -// TQStringList vars = m_token->listUserVars( &list ); - TokenDialog dlg( m_token, this, "dlg" ); if( dlg.exec() == TQDialog::Accepted ) insertText( dlg.token() ); @@ -974,7 +971,7 @@ void LabelEditor::copy() DocumentItemList items; for( unsigned int i=0;i<list.count();i++) - items.append( (list[i])->item() ); + items.push_back( (list[i])->item() ); DocumentItemDrag* drag = new DocumentItemDrag(); drag->setDocumentItem( &items ); diff --git a/kbarcode/mimesources.cpp b/kbarcode/mimesources.cpp index 4767f3f..3213c4a 100644 --- a/kbarcode/mimesources.cpp +++ b/kbarcode/mimesources.cpp @@ -67,7 +67,7 @@ void DocumentItemDrag::setDocumentItem( DocumentItemList* list ) doc.appendChild( root ); 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 ); xml.writeXMLDocumentItem( &root, &item ); diff --git a/kbarcode/mycanvasview.cpp b/kbarcode/mycanvasview.cpp index 2c7c7ef..8657080 100644 --- a/kbarcode/mycanvasview.cpp +++ b/kbarcode/mycanvasview.cpp @@ -529,7 +529,7 @@ DocumentItemList MyCanvasView::getAllItems() TQCanvasItemList list = canvas()->allItems(); for( unsigned int i = 0; i < list.count(); i++ ) - l.append( ((TCanvasItem*)list[i])->item() ); + l.push_back( ((TCanvasItem*)list[i])->item() ); return l; } diff --git a/kbarcode/mycanvasview.h b/kbarcode/mycanvasview.h index ec917e7..4370373 100644 --- a/kbarcode/mycanvasview.h +++ b/kbarcode/mycanvasview.h @@ -90,9 +90,9 @@ class MyCanvasView : public TQCanvasView MyCanvasView( Definition* d, MyCanvas *c, TQWidget* parent=0, const char* name=0, WFlags f=0); ~MyCanvasView(); - /** return a list of all DocumentItems on the canvas - */ - DocumentItemList getAllItems(); + /** return a list of all DocumentItems on the canvas + */ + DocumentItemList getAllItems(); TCanvasItemList getSelected(); diff --git a/kbarcode/tokenprovider.cpp b/kbarcode/tokenprovider.cpp index 7cdc774..90e2853 100644 --- a/kbarcode/tokenprovider.cpp +++ b/kbarcode/tokenprovider.cpp @@ -401,7 +401,7 @@ TQStringList TokenProvider::listUserVars() 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); t = TQString(); diff --git a/kbarcode/xmlutils.cpp b/kbarcode/xmlutils.cpp index 6095574..51e2c20 100644 --- a/kbarcode/xmlutils.cpp +++ b/kbarcode/xmlutils.cpp @@ -121,7 +121,6 @@ void XMLUtils::writeXMLHeader( TQDomNode* root, const TQString & description, De void XMLUtils::readDocumentItems( DocumentItemList* list, TQDomDocument* doc, TokenProvider* token, bool kbarcode18 ) { TQDomNode n = doc->documentElement().firstChild(); - list->setAutoDelete( false ); if( kbarcode18 ) { @@ -136,7 +135,7 @@ void XMLUtils::readDocumentItems( DocumentItemList* list, TQDomDocument* doc, To bcode->updateBarcode(); bcode->setZ( e.attribute( "z", "0" ).toInt() ); - list->append( bcode ); + list->push_back( bcode ); } else if( e.tagName() == "textfield" ) { TextItem* t = new TextItem(); t->setTokenProvider( token ); @@ -157,7 +156,7 @@ void XMLUtils::readDocumentItems( DocumentItemList* list, TQDomDocument* doc, To n = n.nextSibling(); } - list->append( t ); + list->push_back( t ); } else if( e.tagName() == "picture" ) { ImageItem* r = new ImageItem(); @@ -169,7 +168,7 @@ void XMLUtils::readDocumentItems( DocumentItemList* list, TQDomDocument* doc, To r->setPixmap( pix ); r->setRotation( e.attribute("rotation", "0.0" ).toDouble() ); r->setZ( e.attribute( "z", "0" ).toInt() ); - list->append( r ); + list->push_back( r ); } else if( e.tagName() == "rect" ) { 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->setColor( readXMLColor( &e, "color", TQt::black ) ); - list->append( r ); + list->push_back( r ); } else if( e.tagName() == "line" ) { #warning "TODO: test legacy loading of lines" LineItem* cl = new LineItem(); @@ -192,7 +191,7 @@ void XMLUtils::readDocumentItems( DocumentItemList* list, TQDomDocument* doc, To cl->setZ( e.attribute( "z", "0" ).toInt() ); cl->setPen( TQPen( readXMLColor( &e, "color", TQt::black ), e.attribute( "width", "0" ).toInt(), (TQPen::PenStyle)e.attribute( "style", "0" ).toInt() ) ); - list->append( cl ); + list->push_back( cl ); } n = n.nextSibling(); } @@ -205,7 +204,7 @@ void XMLUtils::readDocumentItems( DocumentItemList* list, TQDomDocument* doc, To { DocumentItem* item = NULL; if( readXMLDocumentItem( &e, &item, token ) ) - list->append( item ); + list->push_back( item ); } n = n.nextSibling(); } diff --git a/kbarcode/xmlutils.h b/kbarcode/xmlutils.h index 1a4c9b6..5788acf 100644 --- a/kbarcode/xmlutils.h +++ b/kbarcode/xmlutils.h @@ -19,7 +19,7 @@ #define XMLUTILS_H #include <tqmap.h> -#include <tqptrlist.h> +#include <vector> class DocumentItem; class BarcodeItem; @@ -34,7 +34,7 @@ class TQDomNode; class TQRect; class TQString; class TQWidget; -typedef TQPtrList<DocumentItem> DocumentItemList; +typedef std::vector<DocumentItem*> DocumentItemList; /** This class provides helper function for saving and reading to XML files. * |