From 2c9b915b8d6b3fb0bf21cc8b3bd7d91308691e9f Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Mon, 24 Jan 2022 11:40:58 +0900 Subject: Designer: use global includes instead of includehints and remove duplicated include directives if found in UI files. Signed-off-by: Michele Calgaro --- kdevdesigner/designer/resource.cpp | 64 ++++++++++++++++++++++++++++---------- kdevdesigner/designer/resource.h | 2 -- 2 files changed, 48 insertions(+), 18 deletions(-) diff --git a/kdevdesigner/designer/resource.cpp b/kdevdesigner/designer/resource.cpp index f86490c4..d674b5f1 100644 --- a/kdevdesigner/designer/resource.cpp +++ b/kdevdesigner/designer/resource.cpp @@ -429,7 +429,20 @@ bool Resource::load( FormFile *ff, TQIODevice* dev, Project *defProject ) inc.implDecl = "in implementation"; inc.header = e.firstChild().toText().data(); if ( inc.header.right( 5 ) != ".ui.h" ) { - metaIncludes.append( inc ); + bool found = false; + TQValueList::Iterator it; + for ( it = metaIncludes.begin(); it != metaIncludes.end(); ++it ) { + MetaDataBase::Include currInc = *it; + if ( currInc.location == inc.location && currInc.implDecl == inc.implDecl && + currInc.header == inc.header) { + found = true; + break; + } + } + if ( !found ) + { + metaIncludes.append( inc ); + } } else { if ( formwindow->formFile() ) formwindow->formFile()->setCodeFileState( FormFile::Ok ); @@ -509,7 +522,20 @@ bool Resource::load( FormFile *ff, TQIODevice* dev, Project *defProject ) inc.implDecl = "in implementation"; inc.header = n.firstChild().toText().data(); if ( inc.header.right( 5 ) != ".ui.h" ) { - metaIncludes.append( inc ); + bool found = false; + TQValueList::Iterator it; + for ( it = metaIncludes.begin(); it != metaIncludes.end(); ++it ) { + MetaDataBase::Include currInc = *it; + if ( currInc.location == inc.location && currInc.implDecl == inc.implDecl && + currInc.header == inc.header) { + found = true; + break; + } + } + if ( !found ) + { + metaIncludes.append( inc ); + } } else { if ( formwindow->formFile() ) formwindow->formFile()->setCodeFileState( FormFile::Ok ); @@ -718,7 +744,6 @@ bool Resource::save( TQIODevice* dev ) saveConnections( ts, 0 ); saveTabOrder( ts, 0 ); saveMetaInfoAfter( ts, 0 ); - saveIncludeHints( ts, 0 ); ts << "" << endl; bool ok = saveFormCode( formwindow->formFile(), langIface ); images.clear(); @@ -843,7 +868,26 @@ void Resource::saveObject( TQObject *obj, QDesignerGridLayout* grid, TQTextStrea if ( obj->isWidgetType() ) { if ( obj->isA("CustomWidget") || isPlugin ) { usedCustomWidgets << TQString( className ); - includeHints << WidgetDatabase::includeFile( classID ); + MetaDataBase::Include inc; + inc.location = "global"; + inc.implDecl = "in implementation"; + inc.header = WidgetDatabase::includeFile( classID ); + bool found = false; + TQValueList includes = MetaDataBase::includes( TQT_TQOBJECT(formwindow) ); + TQValueList::Iterator it; + for ( it = includes.begin(); it != includes.end(); ++it ) { + MetaDataBase::Include currInc = *it; + if ( currInc.location == inc.location && currInc.implDecl == inc.implDecl && + currInc.header == inc.header) { + found = true; + break; + } + } + if ( !found ) + { + includes << inc; + } + MetaDataBase::setIncludes( TQT_TQOBJECT(formwindow), includes ); } if ( TQT_BASE_OBJECT(obj) != TQT_BASE_OBJECT(formwindow) && !formwindow->widgets()->find( (TQWidget*)obj ) ) @@ -2905,18 +2949,6 @@ void Resource::saveMetaInfoAfter( TQTextStream &ts, int indent ) } } -void Resource::saveIncludeHints( TQTextStream &ts, int indent ) -{ - if ( includeHints.isEmpty() ) - return; - ts << makeIndent( indent ) << "" << endl; - indent++; - for ( TQStringList::Iterator it = includeHints.begin(); it != includeHints.end(); ++it ) - ts << makeIndent( indent ) << "" << *it << "" << endl; - indent--; - ts << makeIndent( indent ) << "" << endl; -} - TQColorGroup Resource::loadColorGroup( const TQDomElement &e ) { TQColorGroup cg; diff --git a/kdevdesigner/designer/resource.h b/kdevdesigner/designer/resource.h index 06598254..4926e004 100644 --- a/kdevdesigner/designer/resource.h +++ b/kdevdesigner/designer/resource.h @@ -103,7 +103,6 @@ private: void saveColor( TQTextStream &ts, int indent, const TQColor &c ); void saveMetaInfoBefore( TQTextStream &ts, int indent ); void saveMetaInfoAfter( TQTextStream &ts, int indent ); - void saveIncludeHints( TQTextStream &ts, int indent ); void savePixmap( const TQPixmap &p, TQTextStream &ts, int indent, const TQString &tagname = "pixmap" ); void saveActions( const TQPtrList &actions, TQTextStream &ts, int indent ); void saveChildActions( TQAction *a, TQTextStream &ts, int indent ); @@ -157,7 +156,6 @@ private: TQString currFileName; LanguageInterface *langIface; bool hasFunctions; - TQStringList includeHints; TQString uiFileVersion; }; -- cgit v1.2.3