SVN commit 616500 by mwiesweg:
Share world map pixmaps between GPS widgets of each sidebar. Saves >5MB memory. Note (1): This memory for a pixmap is counted for the X.org server process, not the digikam process. Note (2): These megabytes were mentioned by someone on digikam-user when I removed the WDestructiveClose flag from ImageWindow. Here are the missing megabytes back. CCMAIL: [hidden email] M +21 -9 worldmapwidget.cpp M +2 -0 worldmapwidget.h --- trunk/extragear/graphics/digikam/libs/widgets/metadata/worldmapwidget.cpp #616499:616500 @@ -30,6 +30,7 @@ #include <kstandarddirs.h> #include <kcursor.h> #include <klocale.h> +#include <kstaticdeleter.h> // Local includes. @@ -60,26 +61,26 @@ double longitude; QLabel *latLonPos; - - QPixmap worldMap; + + static QPixmap *worldMap; }; +static KStaticDeleter<QPixmap> pixmapDeleter; + +QPixmap *WorldMapWidgetPriv::worldMap = 0; + WorldMapWidget::WorldMapWidget(int w, int h, QWidget *parent) : QScrollView(parent, 0, Qt::WDestructiveClose) { d = new WorldMapWidgetPriv; - - KGlobal::dirs()->addResourceType("worldmap", KGlobal::dirs()->kde_default("data") + "digikam/data"); - QString directory = KGlobal::dirs()->findResourceDir("worldmap", "worldmap.jpg"); - d->worldMap = QPixmap(directory + "worldmap.jpg"); - + setVScrollBarMode(QScrollView::AlwaysOff); setHScrollBarMode(QScrollView::AlwaysOff); viewport()->setMouseTracking(true); viewport()->setPaletteBackgroundColor(colorGroup().background()); setMinimumWidth(w); setMaximumHeight(h); - resizeContents(d->worldMap.width(), d->worldMap.height()); + resizeContents(worldMapPixmap().width(), worldMapPixmap().height()); d->latLonPos = new QLabel(viewport()); d->latLonPos->setMaximumHeight(fontMetrics().height()); @@ -93,6 +94,17 @@ delete d; } +QPixmap &WorldMapWidget::worldMapPixmap() +{ + if (!d->worldMap) + { + KGlobal::dirs()->addResourceType("worldmap", KGlobal::dirs()->kde_default("data") + "digikam/data"); + QString directory = KGlobal::dirs()->findResourceDir("worldmap", "worldmap.jpg"); + pixmapDeleter.setObject(d->worldMap, new QPixmap(directory + "worldmap.jpg")); + } + return *d->worldMap; +} + double WorldMapWidget::getLatitude(void) { return d->latitude; @@ -141,7 +153,7 @@ { if (isEnabled()) { - p->drawPixmap(x, y, d->worldMap, x, y, w, h); + p->drawPixmap(x, y, worldMapPixmap(), x, y, w, h); p->setPen(QPen(Qt::white, 0, Qt::SolidLine)); p->drawLine(d->xPos, 0, d->xPos, contentsHeight()); p->drawLine(0, d->yPos, contentsWidth(), d->yPos); --- trunk/extragear/graphics/digikam/libs/widgets/metadata/worldmapwidget.h #616499:616500 @@ -56,6 +56,8 @@ void contentsMouseReleaseEvent ( QMouseEvent * e ); void contentsMouseMoveEvent( QMouseEvent * e ); + QPixmap &worldMapPixmap(); + private: WorldMapWidgetPriv *d; _______________________________________________ Digikam-devel mailing list [hidden email] https://mail.kde.org/mailman/listinfo/digikam-devel |
Free forum by Nabble | Edit this page |