[Digikam-devel] [Bug 134224] prefix for image filename in camera dialog not working

Marcel Wiesweg marcel.wiesweg at gmx.de
Wed Sep 20 21:07:13 BST 2006


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=134224         
marcel.wiesweg gmx de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From marcel.wiesweg gmx de  2006-09-20 22:07 -------
SVN commit 586866 by mwiesweg:

Allow to configure date & time format.
Choice is Standard (previous default), Iso, User readable, Local settings, Advanced.
Advanced allows to specify the format in QDateTime syntax.

BUG: 134224


 M  +154 -12   renamecustomizer.cpp  
 M  +4 -1      renamecustomizer.h  


--- trunk/extragear/graphics/digikam/utilities/cameragui/renamecustomizer.cpp #586865:586866
 @ -30,6 +30,7  @
 #include <qcombobox.h>
 #include <qhbox.h>
 #include <qlabel.h>
+#include <qpushbutton.h>
 #include <qtimer.h>
 #include <qwhatsthis.h>
 
 @ -38,9 +39,15  @
 #include <klocale.h>
 #include <kconfig.h>
 #include <kapplication.h>
+#include <kiconloader.h>
 #include <klineedit.h>
 #include <knuminput.h>
 #include <kdialogbase.h>
+#if KDE_IS_VERSION(3,2,0)
+#include <kinputdialog.h>
+#else
+#include <klineeditdlg.h>
+#endif
 
 // Local includes.
 
 @ -53,6 +60,15  @
 {
 public:
 
+    enum DateFormatOptions
+    {
+        DigikamStandard = 0,
+        IsoDateFormat,
+        TextDateFormat,
+        LocalDateFormat,
+        Advanced
+    };
+
     RenameCustomizerPriv()
     {
         renameDefault         = 0;
 @ -66,11 +82,14  @
         addSeqNumberBox       = 0;
         changedTimer          = 0;
         renameCustomPrefix    = 0;
-        renameCustomSuffix   = 0;
+        renameCustomSuffix    = 0;
         startIndexLabel       = 0;
         startIndexInput       = 0;
         focusedWidget         = 0;
-    }
+        dateTimeButton        = 0;
+        dateTimeLabel         = 0;
+        dateTimeFormat        = 0;
+}
 
     QWidget      *focusedWidget;
 
 @ -84,13 +103,18  @
     
     QLabel       *renameDefaultCase;
     QLabel       *startIndexLabel;
+    QLabel       *dateTimeLabel;
 
     QComboBox    *renameDefaultCaseType;
+    QComboBox    *dateTimeFormat;
 
     QCheckBox    *addDateTimeBox;
     QCheckBox    *addCameraNameBox;
     QCheckBox    *addSeqNumberBox;
 
+    QPushButton  *dateTimeButton;
+    QString       dateTimeFormatString;
+
     QTimer       *changedTimer;
 
     KLineEdit    *renameCustomPrefix;
 @ -134,10 +158,10  @
     QWhatsThis::add( d->renameDefaultCaseType, i18n("<p>Set here the method to use to change case "
                                                     "of image filenames."));
                                            
-    QHBoxLayout* boxLayout = new QHBoxLayout( d->renameDefaultBox->layout() );
-    boxLayout->addSpacing( 10 );
-    boxLayout->addWidget( d->renameDefaultCase );
-    boxLayout->addWidget( d->renameDefaultCaseType );
+    QHBoxLayout* boxLayout1 = new QHBoxLayout( d->renameDefaultBox->layout() );
+    boxLayout1->addSpacing( 10 );
+    boxLayout1->addWidget( d->renameDefaultCase );
+    boxLayout1->addWidget( d->renameDefaultCaseType );
 
     mainLayout->addMultiCellWidget(d->renameDefaultBox, 1, 1, 0, 1);
 
 @ -154,7 +178,7  @
     d->renameCustomBox->setColumnLayout(0, Qt::Vertical);
 
     QGridLayout* renameCustomBoxLayout = new QGridLayout(d->renameCustomBox->layout(), 
-                                                         5, 2, KDialogBase::spacingHint());
+                                                         6, 2, KDialogBase::spacingHint());
     renameCustomBoxLayout->setColSpacing( 0, 10 );
 
     QLabel* prefixLabel = new QLabel(i18n("Prefix:"), d->renameCustomBox);
 @ -176,12 +200,40  @
     renameCustomBoxLayout->addMultiCellWidget(d->addDateTimeBox, 2, 2, 1, 2);
     QWhatsThis::add( d->addDateTimeBox, i18n("<p>Set this option to add the camera provided date and time."));
 
+    QWidget *dateTimeWidget = new QWidget(d->renameCustomBox);
+    d->dateTimeLabel    = new QLabel(i18n("Date format:"), dateTimeWidget);
+    d->dateTimeFormat   = new QComboBox(dateTimeWidget);
+    d->dateTimeFormat->insertItem(i18n("Standard"),       RenameCustomizerPriv::DigikamStandard);
+    d->dateTimeFormat->insertItem(i18n("ISO"),            RenameCustomizerPriv::IsoDateFormat);
+    d->dateTimeFormat->insertItem(i18n("Full Text"),      RenameCustomizerPriv::TextDateFormat);
+    d->dateTimeFormat->insertItem(i18n("Local Settings"), RenameCustomizerPriv::LocalDateFormat);
+    d->dateTimeFormat->insertItem(i18n("Advanced..."),    RenameCustomizerPriv::Advanced);
+    QWhatsThis::add( d->dateTimeFormat, i18n("<p>Select here your preferred date format used to "
+                    "create new albums. The options available are:</p>"
+                    "<p><b>Standard</b>: the date format that has been used as a standard by digiKam."
+                    "Ex.: <i>20060824T142618</i></p>"
+                    "<p/><b>ISO</b>: the date format is in accordance with ISO 8601 "
+                    "(YYYY-MM-DD). Ex.: <i>2006-08-24T14:26:18</i></p>"
+                    "<p><b>Full Text</b>: the date format is in a user-readable string. "
+                    "Ex.: <i>Thu Aug 24 14:26:18 2006</i></p>"
+                    "<p><b>Local Settings</b>: the date format depending on KDE control panel settings.</p>"
+                    "<p><b>Advanced:</b> allows to specify a custom date format.</p>"));
+    d->dateTimeButton = new QPushButton(SmallIcon("configure"), QString(), dateTimeWidget);
+    QSizePolicy policy = d->dateTimeButton->sizePolicy();
+    policy.setHorData(QSizePolicy::Maximum);
+    d->dateTimeButton->setSizePolicy(policy);
+    QHBoxLayout *boxLayout2 = new QHBoxLayout(dateTimeWidget);
+    boxLayout2->addWidget(d->dateTimeLabel);
+    boxLayout2->addWidget(d->dateTimeFormat);
+    boxLayout2->addWidget(d->dateTimeButton);
+    renameCustomBoxLayout->addMultiCellWidget(dateTimeWidget, 3, 3, 1, 2);
+
     d->addCameraNameBox = new QCheckBox( i18n("Add Camera Name"), d->renameCustomBox );
-    renameCustomBoxLayout->addMultiCellWidget(d->addCameraNameBox, 3, 3, 1, 2);
+    renameCustomBoxLayout->addMultiCellWidget(d->addCameraNameBox, 4, 4, 1, 2);
     QWhatsThis::add( d->addCameraNameBox, i18n("<p>Set this option to add the camera name."));
 
     d->addSeqNumberBox = new QCheckBox( i18n("Add Sequence Number"), d->renameCustomBox );
-    renameCustomBoxLayout->addMultiCellWidget(d->addSeqNumberBox, 4, 4, 1, 2);
+    renameCustomBoxLayout->addMultiCellWidget(d->addSeqNumberBox, 5, 5, 1, 2);
     QWhatsThis::add( d->addSeqNumberBox, i18n("<p>Set this option to add a sequence number starting with the index set below."));
 
     d->startIndexLabel = new QLabel( i18n("Start Index:"), d->renameCustomBox );
 @ -190,8 +242,8  @
     QWhatsThis::add( d->startIndexInput, i18n("<p>Set here the start index value used to rename picture "
                                               "files with a sequence number."));
 
-    renameCustomBoxLayout->addMultiCellWidget(d->startIndexLabel, 5, 5, 1, 1);
-    renameCustomBoxLayout->addMultiCellWidget(d->startIndexInput, 5, 5, 2, 2);
+    renameCustomBoxLayout->addMultiCellWidget(d->startIndexLabel, 6, 6, 1, 1);
+    renameCustomBoxLayout->addMultiCellWidget(d->startIndexInput, 6, 6, 2, 2);
 
     mainLayout->addMultiCellWidget(d->renameCustomBox, 3, 3, 0, 1);
 
 @ -224,9 +276,21  @
     connect(d->changedTimer, SIGNAL(timeout()),
             this, SIGNAL(signalChanged()));
 
+    connect(d->dateTimeButton, SIGNAL(clicked()),
+            this, SLOT(slotDateTimeButtonClicked()));
+
+    connect(d->dateTimeFormat, SIGNAL(activated(int)),
+            this, SLOT(slotDateTimeFormatChanged(int)));
+
+    connect(d->addDateTimeBox, SIGNAL(toggled(bool)),
+            this, SLOT(slotDateTimeBoxToggled(bool)));
+
     // -- initial values ---------------------------------------------------
 
     readSettings();
+
+    // signal to this not yet connected when readSettings is called? Don't know
+    slotDateTimeBoxToggled(d->addDateTimeBox->isChecked());
 }
 
 RenameCustomizer::~RenameCustomizer()
 @ -255,7 +319,25  @
         QString name(d->renameCustomPrefix->text());
 
         // use the "T" as a delimiter between date and time
-        QString date = dateTime.toString("yyyyMMddThhmmss");
+        QString date;
+        switch (d->dateTimeFormat->currentItem())
+        {
+            case RenameCustomizerPriv::DigikamStandard:
+                date = dateTime.toString("yyyyMMddThhmmss");
+                break;
+            case RenameCustomizerPriv::TextDateFormat:
+                date = dateTime.toString(Qt::TextDate);
+                break;
+            case RenameCustomizerPriv::LocalDateFormat:
+                date = dateTime.toString(Qt::LocalDate);
+                break;
+            case RenameCustomizerPriv::IsoDateFormat:
+                date = dateTime.toString(Qt::ISODate);
+                break;
+            case RenameCustomizerPriv::Advanced:
+                date = dateTime.toString(d->dateTimeFormatString);
+                break;
+         }
 
         // it seems that QString::number does not support padding with zeros
         QString seq;
 @ -318,6 +400,60  @
     d->changedTimer->start(500, true);
 }
 
+void RenameCustomizer::slotDateTimeBoxToggled(bool on)
+{
+    d->dateTimeLabel->setEnabled(on);
+    d->dateTimeFormat->setEnabled(on);
+    d->dateTimeButton->setEnabled(on
+            && d->dateTimeFormat->currentItem() == RenameCustomizerPriv::Advanced);
+    slotRenameOptionsChanged();
+}
+
+void RenameCustomizer::slotDateTimeFormatChanged(int index)
+{
+    if (index == RenameCustomizerPriv::Advanced)
+    {
+        d->dateTimeButton->setEnabled(true);
+        //d->dateTimeButton->show();
+        //slotDateTimeButtonClicked();
+    }
+    else
+    {
+        d->dateTimeButton->setEnabled(false);
+        //d->dateTimeButton->hide();
+    }
+    slotRenameOptionsChanged();
+}
+
+void RenameCustomizer::slotDateTimeButtonClicked()
+{
+    bool ok;
+
+#if KDE_IS_VERSION(3,2,0)
+    QString newFormat = KInputDialog::getText(i18n("Change Date & Time Format"),
+                                              i18n("<p>Enter the format for date and time.</p>"
+                                                      "<p>Use <i>dd</i> for the day, <i>MM</i> for the month, <i>yyyy</i> for the year, "
+                                                   "<i>hh</i> for the hour, <i>mm</i> for the minute, <i>ss</i> for the second.</p>"
+                                                   "<p>Examples: <i>yyyyMMddThhmmss</i> for 20060824T142418,<br>"
+                                                   "<i>yyyy-MM-dd hh:mm:ss</i> for 2006-08-24 14:24:18.</p>"),
+                                              d->dateTimeFormatString, &ok, this);
+#else
+    QString newFormat = KLineEditDlg::getText(i18n("Change Date & Time Format"),
+                                              i18n("<p>Enter the format for date and time.</p>"
+                                                   "<p>Use <i>dd</i> for the day, <i>MM</i> for the month, <i>yyyy</i> for the year, "
+                                                   "<i>hh</i> for the hour, <i>mm</i> for the minute, <i>ss</i> for the second.</p>"
+                                                   "<p>Examples: <i>yyyyMMddThhmmss</i> for 20060824T142418,<br>"
+                                                   "<i>yyyy-MM-dd hh:mm:ss</i> for 2006-08-24 14:24:18.</p>"),
+                                              d->dateTimeFormatString, &ok, this);
+#endif
+
+    if (!ok)
+        return;
+
+    d->dateTimeFormatString = newFormat;
+    slotRenameOptionsChanged();
+}
+
 void RenameCustomizer::readSettings()
 {
     KConfig* config = kapp->config();
 @ -331,6 +467,8  @
     QString prefix   = config->readEntry("Rename Prefix", i18n("photo"));
     QString suffix   = config->readEntry("Rename Postfix", QString());
     int startIndex   = config->readNumEntry("Rename Start Index", 1);
+    int dateTime     = config->readNumEntry("Date Time Format", RenameCustomizerPriv::IsoDateFormat);
+    QString format   = config->readEntry("Date Time Format String", "yyyyMMddThhmmss");
 
     if (def)
     {
 @ -354,6 +492,8  @
     d->renameCustomPrefix->setText(prefix);
     d->renameCustomSuffix->setText(suffix);
     d->startIndexInput->setValue(startIndex);
+    d->dateTimeFormat->setCurrentItem(dateTime);
+    d->dateTimeFormatString = format;
     slotRenameOptionsChanged();
 }
 
 @ -370,6 +510,8  @
     config->writeEntry("Rename Prefix", d->renameCustomPrefix->text());
     config->writeEntry("Rename Suffix", d->renameCustomSuffix->text());
     config->writeEntry("Rename Start Index", d->startIndexInput->value());
+    config->writeEntry("Date Time Format", d->dateTimeFormat->currentItem());
+    config->writeEntry("Date Time Format String", d->dateTimeFormatString);
     config->sync();
 }
 
--- trunk/extragear/graphics/digikam/utilities/cameragui/renamecustomizer.h #586865:586866
 @ -53,7 +53,7  @
 
     void    setUseDefault(bool val);
     bool    useDefault() const;
-    QString newName(const QDateTime &date, int index, const QString &suffix) const;
+    QString newName(const QDateTime &date, int index, const QString &extension) const;
     Case    changeCase() const;
     int     startIndex() const;
 
 @ -74,6 +74,9  @
 
     void slotRadioButtonClicked(int);
     void slotRenameOptionsChanged();
+    void slotDateTimeBoxToggled(bool);
+    void slotDateTimeFormatChanged(int);
+    void slotDateTimeButtonClicked();
 
 private:



More information about the Digikam-devel mailing list