From kde-commits Thu Jan 31 22:20:20 2013 From: Nick Shaforostoff Date: Thu, 31 Jan 2013 22:20:20 +0000 To: kde-commits Subject: KDE/kdesdk/lokalize/src Message-Id: <20130131222020.56136AC86C () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=135967082916589 SVN commit 1336639 by shaforo: cheap optimizations for models (keep data in qvariant from the start) M +18 -8 cataloglistview/catalogmodel.cpp M +3 -1 cataloglistview/catalogmodel.h M +1 -1 common/languagelistmodel.cpp M +1 -1 main.cpp M +1 -1 project/projectmodel.cpp M +5 -5 project/projectmodel.h M +2 -2 tm/qamodel.cpp --- trunk/KDE/kdesdk/lokalize/src/cataloglistview/catalogmodel.cpp #1336638:1336639 @@ -1,7 +1,7 @@ /* **************************************************************************** This file is part of Lokalize - Copyright (C) 2007-2009 by Nick Shaforostoff + Copyright (C) 2007-2013 by Nick Shaforostoff This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -35,11 +35,27 @@ #define DYNAMICFILTER_LIMIT 256 +QVector CatalogTreeModel::m_fonts; + + CatalogTreeModel::CatalogTreeModel(QObject* parent, Catalog* catalog) : QAbstractItemModel(parent) , m_catalog(catalog) , m_ignoreAccel(true) { + if (m_fonts.isEmpty()) + { + QVector fonts(4, QApplication::font()); + fonts[1].setItalic(true); //fuzzy + + fonts[2].setBold(true); //modified + + fonts[3].setItalic(true); //fuzzy + fonts[3].setBold(true); //modified + + m_fonts.reserve(4); + for(int i=0;i<4;i++) m_fonts<isApproved(index.row()); bool modified=m_catalog->isModified(index.row()); - if (fuzzy || modified) - { - QFont font=QApplication::font(); - font.setItalic(fuzzy); - font.setBold(modified); - return font; + return m_fonts.at(fuzzy*1 | modified*2); } - } else if (role==Qt::ForegroundRole) { if (m_catalog->isBookmarked(index.row())) --- trunk/KDE/kdesdk/lokalize/src/cataloglistview/catalogmodel.h #1336638:1336639 @@ -1,7 +1,7 @@ /* **************************************************************************** This file is part of Lokalize - Copyright (C) 2007-2009 by Nick Shaforostoff + Copyright (C) 2007-2013 by Nick Shaforostoff This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -81,6 +81,8 @@ private: Catalog* m_catalog; bool m_ignoreAccel; + + static QVector m_fonts; //DocPos m_prevChanged; }; --- trunk/KDE/kdesdk/lokalize/src/common/languagelistmodel.cpp #1336638:1336639 @@ -77,7 +77,7 @@ { if (role==Qt::DecorationRole) { - static QMap iconCache; + static QMap iconCache; QString langCode=stringList().at(index.row()); if (!iconCache.contains(langCode)) --- trunk/KDE/kdesdk/lokalize/src/main.cpp #1336638:1336639 @@ -58,7 +58,7 @@ int main(int argc, char **argv) { KAboutData about("lokalize", 0, ki18nc("@title", "Lokalize"), version, ki18n(description), - KAboutData::License_GPL, ki18nc("@info:credit", "(c) 2007-2012 Nick Shaforostoff\n(c) 1999-2006 The KBabel developers") /*, KLocalizedString(), 0, "shafff@ukr.net"*/); + KAboutData::License_GPL, ki18nc("@info:credit", "(c) 2007-2013 Nick Shaforostoff\n(c) 1999-2006 The KBabel developers") /*, KLocalizedString(), 0, "shafff@ukr.net"*/); about.addAuthor( ki18n("Nick Shaforostoff"), KLocalizedString(), "shaforostoff@kde.ru" ); about.addCredit (ki18n("Google Inc."), ki18n("sponsored development as part of Google Summer Of Code program"), QByteArray(), "http://google.com"); about.addCredit (ki18n("Translate-toolkit"), ki18n("provided excellent cross-format converting scripts"), QByteArray(), "http://translate.sourceforge.net"); --- trunk/KDE/kdesdk/lokalize/src/project/projectmodel.cpp #1336638:1336639 @@ -1,7 +1,7 @@ /* **************************************************************************** This file is part of Lokalize - Copyright (C) 2007-2012 by Nick Shaforostoff + Copyright (C) 2007-2013 by Nick Shaforostoff Copyright (C) 2009 by Viesturs Zarins This program is free software; you can redistribute it and/or --- trunk/KDE/kdesdk/lokalize/src/project/projectmodel.h #1336638:1336639 @@ -1,7 +1,7 @@ /* **************************************************************************** This file is part of Lokalize - Copyright (C) 2007-2012 by Nick Shaforostoff + Copyright (C) 2007-2013 by Nick Shaforostoff Copyright (C) 2009 by Viesturs Zarins This program is free software; you can redistribute it and/or @@ -220,10 +220,10 @@ ProjectNode m_rootNode; - KIcon m_dirIcon; - KIcon m_poIcon; - KIcon m_poComplIcon; - KIcon m_potIcon; + QVariant m_dirIcon; + QVariant m_poIcon; + QVariant m_poComplIcon; + QVariant m_potIcon; //for updating stats QSet m_dirsWaitingForMetadata; --- trunk/KDE/kdesdk/lokalize/src/tm/qamodel.cpp #1336638:1336639 @@ -1,6 +1,6 @@ /* - - Copyright (C) 2011-2012 nick + This file is part of Lokalize + Copyright (C) 2011-2012 Nick Shaforostoff This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by