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>
pull/16/head
Michele Calgaro 3 years ago
parent 8a04ff90bd
commit 2c9b915b8d
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -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;

@ -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;
};

Loading…
Cancel
Save