summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2022-01-21 23:32:30 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2022-01-24 10:18:32 +0900
commitc7f76b122a08ba789ed0f50984651744dc084ae7 (patch)
tree5792fc9dac9576755f12e7f69638231b2ba331a2
parentca53f5edfe7adcfd998100ae2e0ebcb28f738de6 (diff)
downloadtqt3-c7f76b122a08ba789ed0f50984651744dc084ae7.tar.gz
tqt3-c7f76b122a08ba789ed0f50984651744dc084ae7.zip
TQt 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 09659a5623bcb28a6234c0fe2357b8eca56c240f)
-rw-r--r--qmake/generators/makefile.cpp9
-rw-r--r--tools/designer/designer/resource.cpp64
-rw-r--r--tools/designer/designer/resource.h2
3 files changed, 49 insertions, 26 deletions
diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp
index 45bed0184..83b682a13 100644
--- a/qmake/generators/makefile.cpp
+++ b/qmake/generators/makefile.cpp
@@ -359,14 +359,7 @@ MakefileGenerator::generateDependencies(TQPtrList<MakefileDependDir> &dirs, cons
x++;
if(*(big_buffer + x) == '<') {
x++;
- if(total_size_read >= x + 12 && !strncmp(big_buffer + x, "includehint", 11) &&
- (*(big_buffer + x + 11) == ' ' || *(big_buffer + x + 11) == '>')) {
- for(x += 11; *(big_buffer + x) != '>'; x++);
- int inc_len = 0;
- for(x += 1 ; *(big_buffer + x + inc_len) != '<'; inc_len++);
- *(big_buffer + x + inc_len) = '\0';
- inc = big_buffer + x;
- } else if(total_size_read >= x + 13 && !strncmp(big_buffer + x, "customwidget", 12) &&
+ if(total_size_read >= x + 13 && !strncmp(big_buffer + x, "customwidget", 12) &&
(*(big_buffer + x + 12) == ' ' || *(big_buffer + x + 12) == '>')) {
for(x += 13; *(big_buffer + x) != '>'; x++); //skip up to >
while(x < total_size_read) {
diff --git a/tools/designer/designer/resource.cpp b/tools/designer/designer/resource.cpp
index 2866e4037..e4fd8f3a7 100644
--- a/tools/designer/designer/resource.cpp
+++ b/tools/designer/designer/resource.cpp
@@ -435,7 +435,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 );
@@ -515,7 +528,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 );
@@ -724,7 +750,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();
@@ -849,7 +874,26 @@ void Resource::saveObject( TQObject *obj, TQDesignerGridLayout* grid, TQTextStre
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( 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( formwindow, includes );
}
if ( obj != formwindow && !formwindow->widgets()->find( (TQWidget*)obj ) )
@@ -2942,18 +2986,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/tools/designer/designer/resource.h b/tools/designer/designer/resource.h
index 3d196a45e..f16344dbe 100644
--- a/tools/designer/designer/resource.h
+++ b/tools/designer/designer/resource.h
@@ -110,7 +110,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 );
@@ -164,7 +163,6 @@ private:
TQString currFileName;
LanguageInterface *langIface;
bool hasFunctions;
- TQStringList includeHints;
TQString uiFileVersion;
};