summaryrefslogtreecommitdiffstats
path: root/kdevdesigner/designer
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-24 11:40:58 +0900
commit2c9b915b8d6b3fb0bf21cc8b3bd7d91308691e9f (patch)
tree7d78d8cbb9fcf31bf4760e1d75979e9ae247e884 /kdevdesigner/designer
parent8a04ff90bd798531ed0af82aa34b11d6190202d5 (diff)
downloadtdevelop-2c9b915b8d6b3fb0bf21cc8b3bd7d91308691e9f.tar.gz
tdevelop-2c9b915b8d6b3fb0bf21cc8b3bd7d91308691e9f.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>
Diffstat (limited to 'kdevdesigner/designer')
-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 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<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;
};