author | llornkcor <llornkcor> | 2003-07-10 02:40:10 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-07-10 02:40:10 (UTC) |
commit | 155d68c1e7d7dc0fed2534ac43d6d77ce2781f55 (patch) (side-by-side diff) | |
tree | e6edaa5a7040fe6c224c3943d1094dcf02e4f74c /qmake/tools/qgpluginmanager.cpp | |
parent | 86703e8a5527ef114facd02c005b6b3a7e62e263 (diff) | |
download | opie-155d68c1e7d7dc0fed2534ac43d6d77ce2781f55.zip opie-155d68c1e7d7dc0fed2534ac43d6d77ce2781f55.tar.gz opie-155d68c1e7d7dc0fed2534ac43d6d77ce2781f55.tar.bz2 |
update qmake to 1.05a
Diffstat (limited to 'qmake/tools/qgpluginmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | qmake/tools/qgpluginmanager.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/qmake/tools/qgpluginmanager.cpp b/qmake/tools/qgpluginmanager.cpp index 46c85f5..72246ac 100644 --- a/qmake/tools/qgpluginmanager.cpp +++ b/qmake/tools/qgpluginmanager.cpp @@ -1,102 +1,102 @@ /**************************************************************************** ** $Id$ ** ** Implementation of QGPluginManager class ** -** Copyright (C) 2000-2001 Trolltech AS. All rights reserved. +** Copyright (C) 2000-2003 Trolltech AS. All rights reserved. ** ** This file is part of the tools module of the Qt GUI Toolkit. ** ** This file may be distributed under the terms of the Q Public License ** as defined by Trolltech AS of Norway and appearing in the file ** LICENSE.QPL included in the packaging of this file. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition ** licenses may use this file in accordance with the Qt Commercial License ** Agreement provided with the Software. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for ** information about Qt Commercial License Agreements. ** See http://www.trolltech.com/qpl/ for QPL licensing information. ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "qgpluginmanager_p.h" #ifndef QT_NO_COMPONENT #include "qcomlibrary_p.h" #include "qmap.h" #include "qdir.h" /* The following co-occurrence code is borrowed from Qt Linguist. How similar are two texts? The approach used here relies on co-occurrence matrices and is very efficient. Let's see with an example: how similar are "here" and "hither"? The co-occurrence matrix M for "here" is M[h,e] = 1, M[e,r] = 1, M[r,e] = 1 and 0 elsewhere; the matrix N for "hither" is N[h,i] = 1, N[i,t] = 1, ..., N[h,e] = 1, N[e,r] = 1 and 0 elsewhere. The union U of both matrices is the matrix U[i,j] = max { M[i,j], N[i,j] }, and the intersection V is V[i,j] = min { M[i,j], N[i,j] }. The score for a pair of texts is score = (sum of V[i,j] over all i, j) / (sum of U[i,j] over all i, j), a formula suggested by Arnt Gulbrandsen. Here we have score = 2 / 6, or one third. The implementation differs from this in a few details. Most importantly, repetitions are ignored; for input "xxx", M[x,x] equals 1, not 2. */ /* Every character is assigned to one of 20 buckets so that the co-occurrence matrix requires only 20 * 20 = 400 bits, not 256 * 256 = 65536 bits or even more if we want the whole Unicode. Which character falls in which bucket is arbitrary. The second half of the table is a replica of the first half, because of laziness. */ static const char indexOf[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // ! " # $ % & ' ( ) * + , - . / 0, 2, 6, 7, 10, 12, 15, 19, 2, 6, 7, 10, 12, 15, 19, 0, // 0 1 2 3 4 5 6 7 8 9 : ; < = > ? 1, 3, 4, 5, 8, 9, 11, 13, 14, 16, 2, 6, 7, 10, 12, 15, // @ A B C D E F G H I J K L M N O 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 6, 10, 11, 12, 13, 14, // P Q R S T U V W X Y Z [ \ ] ^ _ 15, 12, 16, 17, 18, 19, 2, 10, 15, 7, 19, 2, 6, 7, 10, 0, // ` a b c d e f g h i j k l m n o 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 6, 10, 11, 12, 13, 14, // p q r s t u v w x y z { | } ~ 15, 12, 16, 17, 18, 19, 2, 10, 15, 7, 19, 2, 6, 7, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 6, 7, 10, 12, 15, 19, 2, 6, 7, 10, 12, 15, 19, 0, 1, 3, 4, 5, 8, 9, 11, 13, 14, 16, 2, 6, 7, 10, 12, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 6, 10, 11, 12, 13, 14, 15, 12, 16, 17, 18, 19, 2, 10, 15, 7, 19, 2, 6, 7, 10, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 6, 10, 11, 12, 13, 14, 15, 12, 16, 17, 18, 19, 2, 10, 15, 7, 19, 2, 6, 7, 10, 0 }; @@ -382,163 +382,163 @@ const QLibrary* QGPluginManager::library( const QString& feature ) const ++git; } if ( sameBasename.isEmpty() ) { that->addLibrary( new QComLibrary( lib ) ); } else { QPtrList<QComLibrary> same; same.setAutoDelete( TRUE ); for ( QStringList::ConstIterator bit = sameBasename.begin(); bit != sameBasename.end(); ++bit ) same.append( new QComLibrary( *bit ) ); QComLibrary* bestMatch = 0; for ( QComLibrary* candidate = same.first(); candidate; candidate = same.next() ) if ( candidate->qtVersion() && candidate->qtVersion() <= QT_VERSION && ( !bestMatch || candidate->qtVersion() > bestMatch->qtVersion() ) ) bestMatch = candidate; if ( bestMatch ) { same.find( bestMatch ); that->addLibrary( same.take() ); } } if ( ( library = that->plugDict[feature] ) ) return library; } } return 0; } QStringList QGPluginManager::featureList() const { QStringList features; if ( !enabled() ) return features; QGPluginManager *that = (QGPluginManager*)this; QStringList theLibs = libList; QStringList phase2Libs; QStringList phase2Deny; /* In order to get the feature list we need to add all interesting libraries. If there are libraries with the same base name, we prioritze the one that fits our Qt version number and ignore the others */ QStringList::Iterator it; for ( it = theLibs.begin(); it != theLibs.end(); ++it ) { if ( (*it).isEmpty() || libDict[*it] ) continue; QComLibrary* library = new QComLibrary( *it ); if ( library->qtVersion() == QT_VERSION ) { that->addLibrary( library ); phase2Deny << QFileInfo( *it ).baseName(); } else { delete library; phase2Libs << *it; } } for ( it = phase2Libs.begin(); it != phase2Libs.end(); ++it ) if ( !phase2Deny.contains( QFileInfo( *it ).baseName() ) ) that->addLibrary( new QComLibrary( *it ) ); for ( QDictIterator<QLibrary> pit( plugDict ); pit.current(); ++pit ) features << pit.currentKey(); return features; } bool QGPluginManager::addLibrary( QLibrary* lib ) { if ( !enabled() || !lib ) return FALSE; QComLibrary* plugin = (QComLibrary*)lib; bool useful = FALSE; QUnknownInterface* iFace = 0; plugin->queryInterface( interfaceId, &iFace ); if ( iFace ) { QFeatureListInterface *fliFace = 0; QComponentInformationInterface *cpiFace = 0; iFace->queryInterface( IID_QFeatureList, (QUnknownInterface**)&fliFace ); if ( !fliFace ) plugin->queryInterface( IID_QFeatureList, (QUnknownInterface**)&fliFace ); if ( !fliFace ) { iFace->queryInterface( IID_QComponentInformation, (QUnknownInterface**)&cpiFace ); if ( !cpiFace ) plugin->queryInterface( IID_QComponentInformation, (QUnknownInterface**)&cpiFace ); } QStringList fl; if ( fliFace ) // Map all found features to the library fl = fliFace->featureList(); else if ( cpiFace ) fl << cpiFace->name(); - for ( QStringList::Iterator f = fl.begin(); f != fl.end(); f++ ) { + for ( QStringList::Iterator f = fl.begin(); f != fl.end(); ++f ) { QLibrary *old = plugDict[*f]; if ( !old ) { useful = TRUE; plugDict.replace( *f, plugin ); } else { // we have old *and* plugin, which one to pick? QComLibrary* first = (QComLibrary*)old; QComLibrary* second = (QComLibrary*)plugin; bool takeFirst = TRUE; if ( first->qtVersion() != QT_VERSION ) { if ( second->qtVersion() == QT_VERSION ) takeFirst = FALSE; else if ( second->qtVersion() < QT_VERSION && first->qtVersion() > QT_VERSION ) takeFirst = FALSE; } if ( !takeFirst ) { useful = TRUE; plugDict.replace( *f, plugin ); qWarning("%s: Discarding feature %s in %s!", (const char*) QFile::encodeName( plugin->library()), (*f).latin1(), (const char*) QFile::encodeName( old->library() ) ); } else { qWarning("%s: Feature %s already defined in %s!", (const char*) QFile::encodeName( old->library() ), (*f).latin1(), (const char*) QFile::encodeName( plugin->library() ) ); } } } if ( fliFace ) fliFace->release(); if ( cpiFace ) cpiFace->release(); iFace->release(); } if ( useful ) { libDict.replace( plugin->library(), plugin ); if ( !libList.contains( plugin->library() ) ) libList.append( plugin->library() ); return TRUE; } delete plugin; return FALSE; } bool QGPluginManager::enabled() const { #ifdef QT_SHARED return TRUE; #else return FALSE; #endif } QRESULT QGPluginManager::queryUnknownInterface(const QString& feature, QUnknownInterface** iface) const { QComLibrary* plugin = 0; plugin = (QComLibrary*)library( feature ); return plugin ? plugin->queryInterface( interfaceId, (QUnknownInterface**)iface ) : QE_NOINTERFACE; } #endif //QT_NO_COMPONENT |