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

List:       kde-commits
Subject:    digikam_0_8_branch: kdeextragear-3/digikam/digikam
From:       Tom Albers <tomalbers () kde ! nl>
Date:       2005-04-28 16:42:21
Message-ID: 20050428164221.DE4AC666 () office ! kde ! org
[Download RAW message or body]

CVS commit by toma: 

Extra table to store the settings for the album + two routines to store and fetch \
info from it. For now the table is used to store the DBVersion and the date of the \
fullscan. Todos:
- store the locale in there
- when the user switches the path of the album, it should trigger a new scan if the \
autoscan function is enabled in the settings (added that yesterday) and the database \
                is not scanned before 
CCMAIL: digikam-devel@lists.sourceforge.net


  M +35 -1     albumdb.cpp   1.17.2.9
  M +15 -0     albumdb.h   1.9.2.6
  M +4 -0      scanlib.cpp   1.1.2.12


--- kdeextragear-3/digikam/digikam/albumdb.cpp  #1.17.2.8:1.17.2.9
@@ -181,4 +181,16 @@ void AlbumDB::initDB()
     }
     
+    // Before 0.8 this table did not exist, so we have to check
+    // and add it seperately.
+    if (!values.contains("settings"))
+    {
+        if (!execSql( QString("CREATE TABLE settings "
+                              "(keyword TEXT NOT NULL UNIQUE,"
+                              "value TEXT);") ))
+            return;
+        else
+            setSetting("DBVersion","1");
+    }
+
     m_valid = true;
 }
@@ -417,4 +429,12 @@ void AlbumDB::setDate(PAlbum *album)
 }
 
+void AlbumDB::setSetting(const QString& keyword,
+                           const QString& value )
+{
+    execSql( QString("REPLACE into settings VALUES ('%1','%2');")
+            .arg( escapeString(keyword) )
+            .arg( escapeString(value) ));
+}
+
 bool AlbumDB::importXML(PAlbum *album)
 {
@@ -733,4 +753,18 @@ QDateTime AlbumDB::getItemDate(PAlbum *a
 }
 
+QString AlbumDB::getSetting(const QString& keyword)
+{
+    QStringList values;
+    execSql( QString("SELECT value FROM settings "
+                     "WHERE keyword='%1';")
+            .arg(escapeString(keyword)),
+            &values );
+
+    if (!values.isEmpty())
+        return QString::null;
+    else
+        return values[0];
+}
+
 QStringList AlbumDB::getItemTagNames(PAlbum *album, const QString& name)
 {

--- kdeextragear-3/digikam/digikam/albumdb.h  #1.9.2.5:1.9.2.6
@@ -79,4 +79,12 @@ public:
     void setCollection(PAlbum *album);
     void setDate(PAlbum *album);
+    /**
+     * This adds a keyword-value combination to the database settings table 
+     * if the keyword already exists, the value will be replaced with the new
+     * value.
+     * @param keyword The keyword
+     * @param value The value
+     */
+    void setSetting(const QString& keyword, const QString& value);
     void setIcon(TAlbum *album, const QString& icon);
     void setIcon(PAlbum *album, const QString& icon);    
@@ -84,4 +92,11 @@ public:
     QString     getItemCaption(PAlbum *album, const QString& name);
     QDateTime   getItemDate(PAlbum *album, const QString& name);
+    /**
+     * This function returns the value which is stored in the database
+     * (table settings).
+     * @param keyword The keyword for which the value has to be returned.
+     * @return The values which belongs to the keyword.
+     */
+    QString     getSetting(const QString& keyword);
     QStringList getItemTagNames(PAlbum *album, const QString& name);
     IntList     getItemTagIDs(PAlbum *album, const QString& name);

--- kdeextragear-3/digikam/digikam/scanlib.cpp  #1.1.2.11:1.1.2.12
@@ -87,4 +87,8 @@ void ScanLib::findMissingItems()
     gettimeofday(&tv3, 0);
 
+    AlbumDB* db = AlbumManager::instance()->albumDB();
+    db->setSetting("Scanned",
+                     QDateTime::currentDateTime().toString(Qt::ISODate));
+
     kdDebug() << "Count all files took: time taken: "
               << (((tv2.tv_sec-tv1.tv_sec)*1000000 + 


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

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