[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/kphotoalbum/browser-rework
From:       Jesper Pedersen <blackie () blackie ! dk>
Date:       2009-06-07 20:13:38
Message-ID: 1244405618.897376.24696.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 978667 by blackie:

Moved CatrgoryImage from Settings::SettingsData to DB::Category

 M  +2 -2      AnnotationDialog/ListSelect.cpp  
 M  +1 -1      Browser/AbstractCategoryModel.cpp  
 M  +67 -0     DB/Category.cpp  
 M  +6 -0      DB/Category.h  
 M  +1 -1      DB/CategoryItem.h  
 M  +0 -60     Settings/SettingsData.cpp  
 M  +0 -5      Settings/SettingsData.h  
 M  +2 -2      Viewer/CategoryImageConfig.cpp  


--- branches/kphotoalbum/browser-rework/AnnotationDialog/ListSelect.cpp \
#978666:978667 @@ -376,8 +376,8 @@
                 checkItem( newStr, checked );
 
                 // rename the category image too
-                QString oldFile = \
                Settings::SettingsData::instance()->fileForCategoryImage( category(), \
                oldStr );
-                QString newFile = \
Settings::SettingsData::instance()->fileForCategoryImage( category(), newStr ); +     \
QString oldFile = _category->fileForCategoryImage( category(), oldStr ); +            \
QString newFile = _category->fileForCategoryImage( category(), newStr );  KIO::move( \
KUrl(oldFile), KUrl(newFile) );  }
         }
--- branches/kphotoalbum/browser-rework/Browser/AbstractCategoryModel.cpp \
#978666:978667 @@ -72,7 +72,7 @@
         }
     }
     else {
-        return Settings::SettingsData::instance()->categoryImage( _category->name(), \
name, _category->thumbnailSize() ); +        return _category->categoryImage( \
_category->name(), name, _category->thumbnailSize() );  }
 }
 
--- branches/kphotoalbum/browser-rework/DB/Category.cpp #978666:978667
@@ -16,6 +16,11 @@
    Boston, MA 02110-1301, USA.
 */
 #include "Category.h"
+#include <kmessagebox.h>
+#include <QDir>
+#include <QFileInfo>
+#include <Settings/SettingsData.h>
+#include <QPixmapCache>
 #include <kglobal.h>
 #include <kiconloader.h>
 #include <klocale.h>
@@ -24,6 +29,7 @@
 #include "CategoryItem.h"
 #include <QPixmap>
 #include <KIcon>
+#include <Utilities/Util.h>
 
 using Utilities::StringSet;
 
@@ -156,4 +162,65 @@
     return QString();
 }
 
+QPixmap DB::Category::categoryImage( const QString& category, QString member, int \
size ) const +{
+    QString fileName = fileForCategoryImage( category, member );
+    QString key = QString::fromLatin1( "%1-%2" ).arg(size).arg(fileName);
+    QPixmap res;
+    if ( QPixmapCache::find( key, res ) )
+        return res;
+
+    QImage img;
+    bool ok = img.load( fileName, "JPEG" );
+    if ( ! ok ) {
+        if ( DB::ImageDB::instance()->memberMap().isGroup( category, member ) )
+            img = KIconLoader::global()->loadIcon( QString::fromLatin1( "kuser" ), \
KIconLoader::Desktop, size ).toImage(); +        else
+            img = DB::ImageDB::instance()->categoryCollection()->categoryForName( \
category )->icon().toImage(); +    }
+    res = QPixmap::fromImage( Utilities::scaleImage(img, size, size, \
Qt::KeepAspectRatio) ); +
+    QPixmapCache::insert( key, res );
+    return res;
+}
+
+
+
+void DB::Category::setCategoryImage( const QString& category, QString member, const \
QImage& image ) +{
+    QString dir = Settings::SettingsData::instance()->imageDirectory() + \
QString::fromLatin1("CategoryImages" ); +    QFileInfo fi( dir );
+    bool ok;
+    if ( !fi.exists() ) {
+        bool ok = QDir().mkdir( dir );
+        if ( !ok ) {
+            KMessageBox::error( 0, i18n("Unable to create directory '%1'.", dir ), \
i18n("Unable to Create Directory") ); +            return;
+        }
+    }
+    QString fileName = fileForCategoryImage( category, member );
+    ok = image.save( fileName, "JPEG" );
+    if ( !ok ) {
+        KMessageBox::error( 0, i18n("Error when saving image '%1'.",fileName), \
i18n("Error Saving Image") ); +        return;
+    }
+
+    // PENDING(blackie) HACK ALERT: Remove all images rather than just these \
resolutions. +    QString key = QString::fromLatin1( "64-%2" ).arg(fileName);
+    QPixmapCache::remove( key );
+
+    key = QString::fromLatin1( "128-%2" ).arg(fileName);
+    QPixmapCache::remove( key );
+}
+
+QString DB::Category::fileForCategoryImage( const QString& category, QString member \
) const +{
+    QString dir = Settings::SettingsData::instance()->imageDirectory() + \
QString::fromLatin1("CategoryImages" ); +    member.replace( QChar::fromLatin1(' '), \
QChar::fromLatin1('_') ); +    member.replace( QChar::fromLatin1('/'), \
QChar::fromLatin1('_') ); +    QString fileName = dir + \
QString::fromLatin1("/%1-%2.jpg").arg( category ).arg( member ); +    return \
fileName; +}
+
+
 #include "Category.moc"
--- branches/kphotoalbum/browser-rework/DB/Category.h #978666:978667
@@ -70,9 +70,15 @@
     virtual QStringList itemsInclCategories() const;
     KSharedPtr<CategoryItem> itemsCategories() const;
 
+    QPixmap categoryImage( const QString& category, QString, int size ) const;
+    void setCategoryImage( const QString& category, QString, const QImage& image );
+    QString fileForCategoryImage ( const QString& category, QString member ) const;
+
+
 private:
     QString defaultIconName() const;
 
+
 signals:
     void changed();
     void itemRenamed( const QString& oldName, const QString& newName );
--- branches/kphotoalbum/browser-rework/DB/CategoryItem.h #978666:978667
@@ -38,7 +38,7 @@
 
 public:
     QString _name;
-     QList< CategoryItem* > _subcategories;
+    QList< CategoryItem* > _subcategories;
     bool _isTop;
 };
 
--- branches/kphotoalbum/browser-rework/Settings/SettingsData.cpp #978666:978667
@@ -306,67 +306,7 @@
     return category;
 }
 
-// PENDING(blackie) move this function to Category
-QString SettingsData::fileForCategoryImage( const QString& category, QString member \
                ) const
-{
-    QString dir = imageDirectory() + STR("CategoryImages" );
-    member.replace( QChar::fromLatin1(' '), QChar::fromLatin1('_') );
-    member.replace( QChar::fromLatin1('/'), QChar::fromLatin1('_') );
-    QString fileName = dir + STR("/%1-%2.jpg").arg( category ).arg( member );
-    return fileName;
-}
 
-// PENDING(blackie) moved this function to Category
-QPixmap SettingsData::categoryImage( const QString& category, QString member, int \
                size ) const
-{
-    QString fileName = fileForCategoryImage( category, member );
-    QString key = STR( "%1-%2" ).arg(size).arg(fileName);
-    QPixmap res;
-    if ( QPixmapCache::find( key, res ) )
-        return res;
-
-    QImage img;
-    bool ok = img.load( fileName, "JPEG" );
-    if ( ! ok ) {
-        if ( DB::ImageDB::instance()->memberMap().isGroup( category, member ) )
-            img = KIconLoader::global()->loadIcon( STR( "kuser" ), \
                KIconLoader::Desktop, size ).toImage();
-        else
-            img = DB::ImageDB::instance()->categoryCollection()->categoryForName( \
                category )->icon().toImage();
-    }
-    res = QPixmap::fromImage( Utilities::scaleImage(img, size, size, \
                Qt::KeepAspectRatio) );
-
-    QPixmapCache::insert( key, res );
-    return res;
-}
-
-// PENDING(blackie) move this function to Category
-void SettingsData::setCategoryImage( const QString& category, QString member, const \
                QImage& image )
-{
-    QString dir = imageDirectory() + STR("CategoryImages" );
-    QFileInfo fi( dir );
-    bool ok;
-    if ( !fi.exists() ) {
-        bool ok = QDir().mkdir( dir );
-        if ( !ok ) {
-            KMessageBox::error( 0, i18n("Unable to create directory '%1'.", dir ), \
                i18n("Unable to Create Directory") );
-            return;
-        }
-    }
-    QString fileName = fileForCategoryImage( category, member );
-    ok = image.save( fileName, "JPEG" );
-    if ( !ok ) {
-        KMessageBox::error( 0, i18n("Error when saving image '%1'.",fileName), \
                i18n("Error Saving Image") );
-        return;
-    }
-
-    // PENDING(blackie) HACK ALERT: Remove all images rather than just these \
                resolutions.
-    QString key = STR( "64-%2" ).arg(fileName);
-    QPixmapCache::remove( key );
-
-    key = STR( "128-%2" ).arg(fileName);
-    QPixmapCache::remove( key );
-}
-
 //////////////
 //// Exif ////
 //////////////
--- branches/kphotoalbum/browser-rework/Settings/SettingsData.h #978666:978667
@@ -145,11 +145,6 @@
 
     property_ref( albumCategory, setAlbumCategory , QString);
 
-    QString fileForCategoryImage ( const QString& category, QString member ) const;
-
-    QPixmap categoryImage( const QString& category, QString, int size ) const;
-    void setCategoryImage( const QString& category, QString, const QImage& image );
-
     //////////////
     //// Exif ////
     //////////////
--- branches/kphotoalbum/browser-rework/Viewer/CategoryImageConfig.cpp #978666:978667
@@ -120,7 +120,7 @@
     if (categoryName.isNull())
         return;
     QPixmap pix =
-        Settings::SettingsData::instance()->
+        DB::ImageDB::instance()->categoryCollection()->categoryForName( categoryName \
)->  categoryImage(categoryName, _member->currentText(), 128);
     _current->setPixmap( pix );
 }
@@ -130,7 +130,7 @@
     QString categoryName = currentGroup();
     if (categoryName.isNull())
         return;
-    Settings::SettingsData::instance()->
+    DB::ImageDB::instance()->categoryCollection()->categoryForName( categoryName )->
         setCategoryImage(categoryName, _member->currentText(), _image);
     memberChanged();
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic