summaryrefslogtreecommitdiffstats
path: root/kdevdesigner
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2022-01-24 11:40:58 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2022-01-27 00:25:38 +0900
commit88faa384d4c64abedd4e2e79b9da582426a57c83 (patch)
tree620d5499f6a155001101794121d9c20859b4e518 /kdevdesigner
parente9f0abffad1db42069f80b5a6cef796e47801046 (diff)
downloadtdevelop-88faa384d4c64abedd4e2e79b9da582426a57c83.tar.gz
tdevelop-88faa384d4c64abedd4e2e79b9da582426a57c83.zip
Designer: use global includes instead of includehints and remove duplicated include directives if found in UI files.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it> (cherry picked from commit 2c9b915b8d6b3fb0bf21cc8b3bd7d91308691e9f)
Diffstat (limited to 'kdevdesigner')
-rw-r--r--kdevdesigner/designer/resource.cpp64
-rw-r--r--kdevdesigner/designer/resource.h2
2 files changed, 48 insertions, 18 deletions
diff --git a/kdevdesigner/designer/resource.cpp b/kdevdesigner/designer/resource.cpp
index a6285db5..b4e2cb8e 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<MetaDataBase::Include>::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<MetaDataBase::Include>::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 << "</UI>" << 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<MetaDataBase::Include> includes = MetaDataBase::includes( TQT_TQOBJECT(formwindow) );
+ TQValueList<MetaDataBase::Include>::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 ) << "<includehints>" << endl;
- indent++;
- for ( TQStringList::Iterator it = includeHints.begin(); it != includeHints.end(); ++it )
- ts << makeIndent( indent ) << "<includehint>" << *it << "</includehint>" << endl;
- indent--;
- ts << makeIndent( indent ) << "</includehints>" << 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<TQAction> &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;
};