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

List:       kde-commits
Subject:    [kphotoalbum/category_l10n_removal] /: Introduced a "tokenCategory" config key which will point to t
From:       Tobias Leupold <tobias.leupold () web ! de>
Date:       2015-11-29 17:40:25
Message-ID: E1a35xZ-0001Yo-TU () scm ! kde ! org
[Download RAW message or body]

Git commit d96128e13e43fe5d8de62c9d18636de0e34dc321 by Tobias Leupold.
Committed on 29/11/2015 at 17:39.
Pushed by tleupold into branch 'category_l10n_removal'.

Introduced a "tokenCategory" config key which will point to the "Tokens" category's \
real name, so that this is robust against locale changes.

M  +1    -1    AndroidRemoteControl/RemoteInterface.cpp
M  +4    -4    ImageManager/ExtractOneVideoFrame.cpp
M  +3    -2    MainWindow/TokenEditor.cpp
M  +2    -2    RemoteControl/RemoteInterface.cpp
M  +3    -2    Settings/SettingsData.cpp
M  +1    -0    Settings/SettingsData.h
M  +5    -4    ThumbnailView/KeyboardEventHandler.cpp
M  +4    -5    Viewer/ViewerWidget.cpp
M  +15   -5    XMLDB/FileReader.cpp

http://commits.kde.org/kphotoalbum/d96128e13e43fe5d8de62c9d18636de0e34dc321

diff --git a/AndroidRemoteControl/RemoteInterface.cpp \
b/AndroidRemoteControl/RemoteInterface.cpp index 23084cc..4ff0361 100644
--- a/AndroidRemoteControl/RemoteInterface.cpp
+++ b/AndroidRemoteControl/RemoteInterface.cpp
@@ -235,7 +235,7 @@ QString RemoteInterface::networkAddress() const
 
 QStringList RemoteInterface::tokens() const
 {
-    return ImageDetails::instance().itemsOfCategory(QStringLiteral("Tokens"));
+    return ImageDetails::instance().itemsOfCategory(Settings::SettingsData::instance()->tokensCategory());
  }
 
 void RemoteInterface::requestInitialData()
diff --git a/ImageManager/ExtractOneVideoFrame.cpp \
b/ImageManager/ExtractOneVideoFrame.cpp index 2c1bc59..2860fc2 100644
--- a/ImageManager/ExtractOneVideoFrame.cpp
+++ b/ImageManager/ExtractOneVideoFrame.cpp
@@ -1,5 +1,5 @@
 /* Copyright 2012 Jesper K. Pedersen <blackie@kde.org>
-  
+
    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 the Free Software Foundation; either version 2 of
@@ -7,12 +7,12 @@
    accepted by the membership of KDE e.V. (or its successor approved
    by the membership of KDE e.V.), which shall act as a proxy
    defined in Section 14 of version 3 of the license.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
@@ -140,7 +140,7 @@ void ExtractOneVideoFrame::markShortVideo(const DB::FileName \
&fileName)  }
 
     DB::ImageInfoPtr info = DB::ImageDB::instance()->info(fileName);
-    info->addCategoryInfo(QString::fromUtf8("Tokens"), s_tokenForShortVideos);
+    info->addCategoryInfo(Settings::SettingsData::instance()->tokensCategory(), \
s_tokenForShortVideos);  MainWindow::DirtyIndicator::markDirty();
 }
 
diff --git a/MainWindow/TokenEditor.cpp b/MainWindow/TokenEditor.cpp
index 391f9d0..a2741f9 100644
--- a/MainWindow/TokenEditor.cpp
+++ b/MainWindow/TokenEditor.cpp
@@ -29,6 +29,7 @@
 #include "DB/CategoryCollection.h"
 #include "DB/Category.h"
 #include "DB/ImageSearchInfo.h"
+#include "Settings/SettingsData.h"
 
 using namespace MainWindow;
 
@@ -105,7 +106,7 @@ QStringList TokenEditor::tokensInUse()
 {
     QStringList res;
     QMap<QString,uint> map =
-        DB::ImageDB::instance()->classify( DB::ImageSearchInfo(), \
QString::fromLatin1( "Tokens" ), DB::anyMediaType ); +        \
DB::ImageDB::instance()->classify( DB::ImageSearchInfo(), \
                Settings::SettingsData::instance()->tokensCategory(), \
                DB::anyMediaType );
     for( QMap<QString,uint>::Iterator it = map.begin(); it != map.end(); ++it ) {
         if ( it.value() > 0 )
             res.append( it.key() );
@@ -118,7 +119,7 @@ void TokenEditor::accept()
      for( QList<QCheckBox*>::Iterator it = m_checkBoxes.begin(); it != \
m_checkBoxes.end(); ++it ) {  if ( (*it)->isChecked() && (*it)->isEnabled() ) {
             QString txt = (*it)->text().remove( QString::fromLatin1("&") );
-            DB::ImageDB::instance()->categoryCollection()->categoryForName( \
QString::fromLatin1( "Tokens" ) )->removeItem( txt ); +            \
DB::ImageDB::instance()->categoryCollection()->categoryForName(Settings::SettingsData::instance()->tokensCategory())->removeItem( \
txt );  }
     }
     KDialog::accept();
diff --git a/RemoteControl/RemoteInterface.cpp b/RemoteControl/RemoteInterface.cpp
index 7abef2d..2f8bf63 100644
--- a/RemoteControl/RemoteInterface.cpp
+++ b/RemoteControl/RemoteInterface.cpp
@@ -267,8 +267,8 @@ void RemoteInterface::setToken(const ToggleTokenRequest& command)
     const DB::FileName fileName = m_imageNameStore[command.imageId];
     DB::ImageInfoPtr info = DB::ImageDB::instance()->info(fileName);
     if (command.state == ToggleTokenRequest::On)
-        info->addCategoryInfo(QString::fromUtf8("Tokens"), command.token);
+        info->addCategoryInfo(Settings::SettingsData::instance()->tokensCategory(), \
command.token);  else
-        info->removeCategoryInfo(QString::fromUtf8("Tokens"), command.token);
+        info->removeCategoryInfo(Settings::SettingsData::instance()->tokensCategory(), \
command.token);  MainWindow::DirtyIndicator::markDirty();
 }
diff --git a/Settings/SettingsData.cpp b/Settings/SettingsData.cpp
index 5d8bd5c..9fee7da 100644
--- a/Settings/SettingsData.cpp
+++ b/Settings/SettingsData.cpp
@@ -350,9 +350,10 @@ QString SettingsData::albumCategory() const
     return category;
 }
 
-property_ref( untaggedCategory, setUntaggedCategory, QString, General, "Events")
-property_ref( untaggedTag,      setUntaggedTag,      QString, General, "untagged")
+property_ref( untaggedCategory, setUntaggedCategory, QString, General, \
i18n("Events")) +property_ref( untaggedTag,      setUntaggedTag,      QString, \
General, i18n("untagged"))  property_copy( untaggedImagesTagVisible, \
setUntaggedImagesTagVisible, bool, General, false); +property_ref(tokensCategory, \
setTokensCategory, QString, General, i18n("Tokens"))  
 //////////////
 //// Exif ////
diff --git a/Settings/SettingsData.h b/Settings/SettingsData.h
index 8a5473d..a70d5fb 100644
--- a/Settings/SettingsData.h
+++ b/Settings/SettingsData.h
@@ -162,6 +162,7 @@ public:
     property_ref( untaggedTag, setUntaggedTag, QString );
     bool hasUntaggedCategoryFeatureConfigured() const;
     property_copy( untaggedImagesTagVisible, setUntaggedImagesTagVisible, bool);
+    property_ref(tokensCategory, setTokensCategory, QString);
 
     //////////////
     //// Exif ////
diff --git a/ThumbnailView/KeyboardEventHandler.cpp \
b/ThumbnailView/KeyboardEventHandler.cpp index 09aa746..d522621 100644
--- a/ThumbnailView/KeyboardEventHandler.cpp
+++ b/ThumbnailView/KeyboardEventHandler.cpp
@@ -24,6 +24,7 @@
 #include "DB/ImageDB.h"
 #include "ThumbnailModel.h"
 #include "VideoThumbnailCycler.h"
+#include "Settings/SettingsData.h"
 
 ThumbnailView::KeyboardEventHandler::KeyboardEventHandler( ThumbnailFactory* factory \
)  : ThumbnailComponent( factory )
@@ -42,19 +43,19 @@ bool ThumbnailView::KeyboardEventHandler::keyPressEvent( \
QKeyEvent* event )  Q_FOREACH( const DB::FileName& fileName, selection ) {
             DB::ImageInfoPtr info = fileName.info();
             if ( ! hadHit ) {
-                mustRemoveToken = info->hasCategoryInfo( \
QString::fromLatin1("Tokens"), token ); +                mustRemoveToken = \
info->hasCategoryInfo(Settings::SettingsData::instance()->tokensCategory(), token );  \
hadHit = true;  }
 
             if ( mustRemoveToken )
-                info->removeCategoryInfo( QString::fromLatin1("Tokens"), token );
+                info->removeCategoryInfo(Settings::SettingsData::instance()->tokensCategory(), \
token );  else
-                info->addCategoryInfo( QString::fromLatin1("Tokens"), token );
+                info->addCategoryInfo(Settings::SettingsData::instance()->tokensCategory(), \
token );  
             model()->updateCell(fileName);
         }
 
-        DB::ImageDB::instance()->categoryCollection()->categoryForName( \
QString::fromLatin1("Tokens") )->addItem( token ); +        \
DB::ImageDB::instance()->categoryCollection()->categoryForName(Settings::SettingsData::instance()->tokensCategory())->addItem( \
token );  MainWindow::DirtyIndicator::markDirty();
         return true;
     }
diff --git a/Viewer/ViewerWidget.cpp b/Viewer/ViewerWidget.cpp
index e90cbc4..bc9863b 100644
--- a/Viewer/ViewerWidget.cpp
+++ b/Viewer/ViewerWidget.cpp
@@ -84,7 +84,7 @@ Viewer::ViewerWidget* Viewer::ViewerWidget::latest()
 
 // Notice the parent is zero to allow other windows to come on top of it.
 Viewer::ViewerWidget::ViewerWidget( UsageType type, QMap<Qt::Key, \
                QPair<QString,QString> > *macroStore )
-    :QStackedWidget( nullptr ), m_current(0), m_popup(nullptr), m_showingFullScreen( \
false ), m_forward( true ), m_isRunningSlideShow( false ), \
m_videoPlayerStoppedManually(false), m_type(type), \
m_currentCategory(QString::fromLatin1("Tokens")), m_inputMacros(macroStore),  \
m_myInputMacros(nullptr) +    :QStackedWidget( nullptr ), m_current(0), \
m_popup(nullptr), m_showingFullScreen( false ), m_forward( true ), \
m_isRunningSlideShow( false ), m_videoPlayerStoppedManually(false), m_type(type), \
m_currentCategory(Settings::SettingsData::instance()->tokensCategory()), \
m_inputMacros(macroStore),  m_myInputMacros(nullptr)  {
     if ( type == ViewerWindow ) {
         setWindowFlags( Qt::Window );
@@ -806,7 +806,7 @@ void Viewer::ViewerWidget::resizeEvent( QResizeEvent* e )
 void Viewer::ViewerWidget::updateInfoBox()
 {
     if ( currentInfo() || !m_currentInput.isEmpty() ||
-         (!m_currentCategory.isEmpty() && m_currentCategory != \
QString::fromLatin1("Tokens"))) { +         (!m_currentCategory.isEmpty() && \
m_currentCategory != Settings::SettingsData::instance()->tokensCategory())) {  \
QMap<int, QPair<QString,QString> > map;  QString text = Utilities::createInfoText( \
currentInfo(), &map );  QString selecttext = QString::fromLatin1("");
@@ -817,8 +817,7 @@ void Viewer::ViewerWidget::updateInfoBox()
                     QString::fromLatin1("}");
             }
         } else if ( ( !m_currentInput.isEmpty() &&
-                   m_currentCategory != QString::fromLatin1("Tokens") ) ||
-                   m_currentCategory != QString::fromLatin1("Tokens")) {
+                   m_currentCategory != \
                Settings::SettingsData::instance()->tokensCategory())) {
             selecttext = i18nc("Basically 'enter a tag name'","<b>Assigning: </b>") \
+ m_currentCategory +  QString::fromLatin1("/")  + m_currentInput;
             if (m_currentInputList.length() > 0) {
@@ -826,7 +825,7 @@ void Viewer::ViewerWidget::updateInfoBox()
                     QString::fromLatin1("}");
             }
         } else if ( !m_currentInput.isEmpty() &&
-                   m_currentCategory == QString::fromLatin1("Tokens") ) {
+                   m_currentCategory == \
Settings::SettingsData::instance()->tokensCategory()) {  m_currentInput = \
QString::fromLatin1("");  }
         if (!selecttext.isEmpty())
diff --git a/XMLDB/FileReader.cpp b/XMLDB/FileReader.cpp
index d5652c6..f3df6e6 100644
--- a/XMLDB/FileReader.cpp
+++ b/XMLDB/FileReader.cpp
@@ -120,6 +120,8 @@ void XMLDB::FileReader::readTopNodeInConfigDocument( const \
QString& configFile,  
 void XMLDB::FileReader::createSpecialCategories()
 {
+    // Setup the "Folder" category
+
     m_folderCategory = m_db->m_categoryCollection.categoryForName(i18n("Folder"));
     if( m_folderCategory.isNull() ) {
         m_folderCategory = new XMLCategory(i18n("Folder"), \
QString::fromLatin1("folder"), @@ -129,18 +131,26 @@ void \
XMLDB::FileReader::createSpecialCategories()  m_folderCategory->setSpecialCategory( \
                true );
     dynamic_cast<XMLCategory*>( m_folderCategory.data() )->setShouldSave( false );
 
-    DB::CategoryPtr tokenCat = \
m_db->m_categoryCollection.categoryForName(i18n("Tokens")); +    // Setup the \
"Tokens" category +
+    DB::CategoryPtr tokenCat = \
m_db->m_categoryCollection.categoryForName(Settings::SettingsData::instance()->tokensCategory());
 +
     if (! tokenCat) {
         tokenCat = new XMLCategory(i18n("Tokens"), QString::fromUtf8("flag-blue"),
                                    DB::Category::TreeView, 32, true);
         m_db->m_categoryCollection.addCategory(tokenCat);
+        Settings::SettingsData::instance()->setTokensCategory(i18n("Tokens"));
     }
+
     tokenCat->setSpecialCategory(true);
 
-    // KPhotoAlbum 2.2 did not write the tokens to the category section, so unless \
                we do this small trick they
-    // will not show up when importing.
-    for ( char ch = 'A'; ch < 'Z'; ++ch )
-        tokenCat->addItem( QString::fromLatin1("%1").arg( QChar::fromLatin1( ch) ) \
); +    // KPhotoAlbum 2.2 did not write the tokens to the category section,
+    // so unless we do this small trick they will not show up when importing.
+    for (char ch = 'A'; ch < 'Z'; ++ch) {
+        tokenCat->addItem(QString::fromUtf8("%1").arg(QChar::fromLatin1(ch)));
+    }
+
+    // Setup the "Media Type" category
 
     DB::CategoryPtr mediaCat = \
m_db->m_categoryCollection.categoryForName(i18n("Media Type"));  if ( !mediaCat ) {


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

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