--- a/src/hbcore/cssparser/hbwidgetstyleloader_p.cpp Fri Sep 17 08:32:10 2010 +0300
+++ b/src/hbcore/cssparser/hbwidgetstyleloader_p.cpp Mon Oct 04 00:38:12 2010 +0300
@@ -44,6 +44,7 @@
static const QString CSS_EXTENSION = ".css";
static const QString PATTERN_WILDCARD = "%w";
static const QString HBWIDGETBASE_CLASSNAME = "HbWidgetBase";
+static QStringList FILEPATH_NAME_FILTERS = QStringList() << "*.css" << "*.widgetml";
/*!
\proto
@@ -123,13 +124,10 @@
QDir fileDir(filePath);
if( fileDir.exists() ) {
// go through all the style files in the directory
- QStringList nameFilters;
- nameFilters << "*.css";
- nameFilters << "*.widgetml";
- QFileInfoList files = fileDir.entryInfoList(nameFilters);
+ QFileInfoList files = fileDir.entryInfoList(FILEPATH_NAME_FILTERS);
if (files.count()) {
bool success( true );
- foreach(QFileInfo file, files) {
+ foreach(const QFileInfo &file, files) {
success &= addFilePath( file.absoluteFilePath(), concern, priority );
}
return success;
@@ -158,12 +156,9 @@
QDir fileDir(filePath);
if( fileDir.exists() ) {
// go through all the style files in the directory
- QStringList nameFilters;
- nameFilters << "*.css";
- nameFilters << "*.widgetml";
- QFileInfoList files = fileDir.entryInfoList(nameFilters);
+ QFileInfoList files = fileDir.entryInfoList(FILEPATH_NAME_FILTERS);
bool success( true );
- foreach(QFileInfo file, files) {
+ foreach(const QFileInfo &file, files) {
success &= removeFilePath( file.absoluteFilePath(), concern, priority );
}
return success;
@@ -223,16 +218,18 @@
const HbLayeredStyleLoader::Concern concern,
const HbLayeredStyleLoader::LayerPriority priority)
{
- for(int i=0; i<mFileSets.count(); i++){
- if(mFileSets.at(i).path == path){
+ int fileSetCount = mFileSets.count();
+ for(int i=0; i<fileSetCount; i++){
+ FileSet& fileSet = mFileSets[i];
+ if(fileSet.path == path){
#ifdef WIDGETSTYLELOADER_DEBUG
qDebug() << "Fileset already exists with path" << path;
#endif
- if ( mFileSets.at(i).concern == concern
- && mFileSets.at(i).priority == priority ) {
- mFileSets[i].referenceCount++;
+ if ( fileSet.concern == concern
+ && fileSet.priority == priority ) {
+ fileSet.referenceCount++;
#ifdef WIDGETSTYLELOADER_DEBUG
- qDebug() << "Increased reference count to" << mFileSets[i].referenceCount;
+ qDebug() << "Increased reference count to" << fileSet.referenceCount;
#endif
return true;
} else {
@@ -369,36 +366,39 @@
#ifdef WIDGETSTYLELOADER_DEBUG
qDebug() << "loadCssForWidget called for " << widget->metaObject()->className();
#endif
- for(int i=0; i<mFileSets.count(); i++){
- if ( !(mFileSets.at(i).type == FileSetType_Pattern
- || mFileSets.at(i).type == FileSetType_CSS ) ) {
+ int fileSetsCount = mFileSets.count();
+ for(int i=0; i<fileSetsCount; i++){
+ FileSet &fileSet = mFileSets[i];
+ FileSetType fileSetType = fileSet.type;
+ if ( !(fileSetType == FileSetType_Pattern
+ || fileSetType == FileSetType_CSS ) ) {
continue;
}
- if (mFileSets.at(i).type == FileSetType_Pattern
- && mFileSets.at(i).patternType != PatternType_CSS) {
+ if (fileSetType == FileSetType_Pattern
+ && fileSet.patternType != PatternType_CSS) {
continue;
}
- HbLayeredStyleLoader *stack = HbLayeredStyleLoader::getStack(mFileSets[i].concern);
+ HbLayeredStyleLoader *stack = HbLayeredStyleLoader::getStack(fileSet.concern);
if(!stack){
continue;
}
- if (mFileSets[i].type == FileSetType_CSS) {
- if (mFileSets[i].loadedCss.count() || mFileSets[i].missedCss.count()) {
+ if (fileSetType == FileSetType_CSS) {
+ if (fileSet.loadedCss.count() || fileSet.missedCss.count()) {
#ifdef WIDGETSTYLELOADER_DEBUG
- qDebug() << "Already loaded CSS from file" << mFileSets[i].path;
+ qDebug() << "Already loaded CSS from file" << fileSet.path;
#endif
} else {
- int hand = stack->load(mFileSets[i].path, mFileSets[i].priority);
+ int hand = stack->load(fileSet.path, fileSet.priority);
if (hand) {
#ifdef WIDGETSTYLELOADER_DEBUG
- qDebug() << "Successfully loaded CSS from file" << mFileSets[i].path;
+ qDebug() << "Successfully loaded CSS from file" << fileSet.path;
#endif
- mFileSets[i].loadedCss.insert(0, hand);
+ fileSet.loadedCss.insert(0, hand);
} else {
#ifdef WIDGETSTYLELOADER_DEBUG
qDebug() << "Failed to load CSS from file" << mFileSets[i].path;
#endif
- mFileSets[i].missedCss.append(0);
+ fileSet.missedCss.append(0);
}
}
continue;
@@ -413,34 +413,34 @@
if (!meta) {
break;
}
- if (mFileSets[i].loadedCss.contains(classNameHash)){
+ if (fileSet.loadedCss.contains(classNameHash)){
#ifdef WIDGETSTYLELOADER_DEBUG
qDebug() << "CSS already loaded for" << className;
#endif
continue;
}
- if (mFileSets[i].missedCss.contains(classNameHash)){
+ if (fileSet.missedCss.contains(classNameHash)){
#ifdef WIDGETSTYLELOADER_DEBUG
qDebug() << "CSS already searched but missed for" << className;
#endif
continue;
}
- QString filename = mFileSets[i].path;
+ QString filename = fileSet.path;
filename.replace(PATTERN_WILDCARD, className.toLatin1().toLower());
#ifdef WIDGETSTYLELOADER_DEBUG
qDebug() << "Loading CSS for widget" << className << "from file" << filename;
#endif
- int hand = stack->load(filename, mFileSets[i].priority);
+ int hand = stack->load(filename, fileSet.priority);
if (hand) {
#ifdef WIDGETSTYLELOADER_DEBUG
qDebug() << "Successfully loaded CSS for" << className;
#endif
- mFileSets[i].loadedCss.insert(classNameHash, hand);
+ fileSet.loadedCss.insert(classNameHash, hand);
} else {
#ifdef WIDGETSTYLELOADER_DEBUG
qDebug() << "Failed to load CSS for" << className;
#endif
- mFileSets[i].missedCss.append(classNameHash);
+ fileSet.missedCss.append(classNameHash);
}
}
}
@@ -480,23 +480,24 @@
// portrait)
int c = mFileSets.count();
while(c-- && !loaded){
- if ( !(mFileSets.at(c).type == FileSetType_Pattern
- || mFileSets.at(c).type == FileSetType_WidgetML ) ) {
+ const FileSet& fileSet = mFileSets.at(c);
+ if ( !(fileSet.type == FileSetType_Pattern
+ || fileSet.type == FileSetType_WidgetML ) ) {
continue;
}
- if (mFileSets.at(c).type == FileSetType_Pattern
- && mFileSets.at(c).patternType != PatternType_WidgetML) {
+ if (fileSet.type == FileSetType_Pattern
+ && fileSet.patternType != PatternType_WidgetML) {
continue;
}
const QMetaObject *meta = widget->metaObject();
QString className = meta->className();
#ifdef WIDGETSTYLELOADER_DEBUG
- qDebug() << "Checking fileset " << mFileSets[c].path;
+ qDebug() << "Checking fileset " << fileSet.path;
#endif
while(className != HBWIDGETBASE_CLASSNAME){
- QString filename = mFileSets[c].path;
+ QString filename = fileSet.path;
bool attemptToLoad(true);
- if ( mFileSets[c].type == FileSetType_Pattern ) {
+ if ( fileSet.type == FileSetType_Pattern ) {
filename.replace(PATTERN_WILDCARD, className.toLatin1().toLower());
} else {
QString classFilename( className.toLatin1().toLower() );
@@ -520,7 +521,7 @@
qDebug() << "Attempting to load file " << filename;
#endif
HbMemoryManager::MemoryType type =
- HbLayeredStyleLoader::sharingNeeded(mFileSets[c].priority)
+ HbLayeredStyleLoader::sharingNeeded(fileSet.priority)
? HbMemoryManager::SharedMemory
: HbMemoryManager::HeapMemory;
if(loader.load(widget, filename, layoutName, sectionName, type)) {
@@ -551,10 +552,12 @@
#ifdef WIDGETSTYLELOADER_DEBUG
qDebug() << "Clearing list for stack" << concern;
#endif
- for(int i=0; i<mFileSets.count(); i++){
- if(mFileSets.at(i).concern == concern){
- mFileSets[i].loadedCss.clear();
- mFileSets[i].missedCss.clear();
+ int fileSetCount = mFileSets.count();
+ for(int i=0; i<fileSetCount; i++){
+ FileSet& fileSet = mFileSets[i];
+ if(fileSet.concern == concern){
+ fileSet.loadedCss.clear();
+ fileSet.missedCss.clear();
#ifdef WIDGETSTYLELOADER_DEBUG
qDebug() << "Cleared fileset" << i;
#endif
@@ -579,10 +582,12 @@
#ifdef WIDGETSTYLELOADER_DEBUG
qDebug() << "Clearing list for stack" << concern << "and layer" << priority;
#endif
- for(int i=0; i<mFileSets.count(); i++){
- if(mFileSets.at(i).concern == concern && mFileSets.at(i).priority == priority){
- mFileSets[i].loadedCss.clear();
- mFileSets[i].missedCss.clear();
+ int fileSetCount = mFileSets.count();
+ for(int i=0; i<fileSetCount; i++){
+ FileSet& fileSet = mFileSets[i];
+ if(fileSet.concern == concern && fileSet.priority == priority){
+ fileSet.loadedCss.clear();
+ fileSet.missedCss.clear();
#ifdef WIDGETSTYLELOADER_DEBUG
qDebug() << "Cleared fileset" << i;
#endif