/* ============================================================
*
* This file is a part of digiKam project
* http://www.digikam.org
*
* Date : 2004-09-19
* Description : a options group to set renaming files
* operations during camera downloading
*
* Copyright (C) 2004-2005 by Renchi Raju Turn on this option to use camera "
"provided image filenames without modifications."));
mainLayout->addMultiCellWidget(d->renameDefault, 0, 0, 0, 1);
d->renameDefaultBox = new TQGroupBox( this );
d->renameDefaultBox->setFrameStyle(TQFrame::NoFrame|TQFrame::Plain);
d->renameDefaultBox->setInsideMargin(0);
d->renameDefaultBox->setColumnLayout(0, TQt::Vertical);
d->renameDefaultCase = new TQLabel( i18n("Change case to:"), d->renameDefaultBox );
d->renameDefaultCase->setSizePolicy( TQSizePolicy::Minimum, TQSizePolicy::Preferred );
d->renameDefaultCaseType = new TQComboBox( d->renameDefaultBox );
d->renameDefaultCaseType->insertItem(i18n("Leave as Is"), 0);
d->renameDefaultCaseType->insertItem(i18n("Upper"), 1);
d->renameDefaultCaseType->insertItem(i18n("Lower"), 2);
d->renameDefaultCaseType->setSizePolicy(TQSizePolicy::Minimum, TQSizePolicy::Preferred);
TQWhatsThis::add( d->renameDefaultCaseType, i18n(" Set the method to use to change the case "
"of image filenames."));
TQHBoxLayout* boxLayout1 = new TQHBoxLayout( d->renameDefaultBox->layout() );
boxLayout1->addSpacing( 10 );
boxLayout1->addWidget( d->renameDefaultCase );
boxLayout1->addWidget( d->renameDefaultCaseType );
mainLayout->addMultiCellWidget(d->renameDefaultBox, 1, 1, 0, 1);
// -------------------------------------------------------------
d->renameCustom = new TQRadioButton(i18n("Customize"), this);
mainLayout->addMultiCellWidget(d->renameCustom, 2, 2, 0, 1);
TQWhatsThis::add( d->renameCustom, i18n(" Turn on this option to customize image filenames "
"during download."));
d->renameCustomBox = new TQGroupBox(this);
d->renameCustomBox->setFrameStyle(TQFrame::NoFrame|TQFrame::Plain);
d->renameCustomBox->setInsideMargin(0);
d->renameCustomBox->setColumnLayout(0, TQt::Vertical);
TQGridLayout* renameCustomBoxLayout = new TQGridLayout(d->renameCustomBox->layout(),
6, 2, KDialogBase::spacingHint());
renameCustomBoxLayout->setColSpacing( 0, 10 );
TQLabel* prefixLabel = new TQLabel(i18n("Prefix:"), d->renameCustomBox);
renameCustomBoxLayout->addMultiCellWidget(prefixLabel, 0, 0, 1, 1);
d->renameCustomPrefix = new KLineEdit(d->renameCustomBox);
d->focusedWidget = d->renameCustomPrefix;
renameCustomBoxLayout->addMultiCellWidget(d->renameCustomPrefix, 0, 0, 2, 2);
TQWhatsThis::add( d->renameCustomPrefix, i18n(" Set the prefix which will be added to "
"image filenames."));
TQLabel* suffixLabel = new TQLabel(i18n("Suffix:"), d->renameCustomBox);
renameCustomBoxLayout->addMultiCellWidget(suffixLabel, 1, 1, 1, 1);
d->renameCustomSuffix = new KLineEdit(d->renameCustomBox);
renameCustomBoxLayout->addMultiCellWidget(d->renameCustomSuffix, 1, 1, 2, 2);
TQWhatsThis::add( d->renameCustomSuffix, i18n(" Set the suffix which will be added to "
"image filenames."));
d->addDateTimeBox = new TQCheckBox( i18n("Add Date && Time"), d->renameCustomBox );
renameCustomBoxLayout->addMultiCellWidget(d->addDateTimeBox, 2, 2, 1, 2);
TQWhatsThis::add( d->addDateTimeBox, i18n(" Set this option to add the camera provided date and time."));
TQWidget *dateTimeWidget = new TQWidget(d->renameCustomBox);
d->dateTimeLabel = new TQLabel(i18n("Date format:"), dateTimeWidget);
d->dateTimeFormat = new TQComboBox(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);
TQWhatsThis::add( d->dateTimeFormat, i18n(" Select your preferred date format for "
"creating new albums. The options available are: Standard: the date format that has been used as a standard by digiKam. "
"E.g.: 20060824T142618
Full Text: the date format is a user-readable string. " "E.g.: Thu Aug 24 14:26:18 2006
" "Local Settings: the date format depending on TDE control panel settings.
" "Advanced: allows the user to specify a custom date format.
")); d->dateTimeButton = new TQPushButton(SmallIcon("configure"), TQString(), dateTimeWidget); TQSizePolicy policy = d->dateTimeButton->sizePolicy(); policy.setHorData(TQSizePolicy::Maximum); d->dateTimeButton->setSizePolicy(policy); TQHBoxLayout *boxLayout2 = new TQHBoxLayout(dateTimeWidget); boxLayout2->addWidget(d->dateTimeLabel); boxLayout2->addWidget(d->dateTimeFormat); boxLayout2->addWidget(d->dateTimeButton); renameCustomBoxLayout->addMultiCellWidget(dateTimeWidget, 3, 3, 1, 2); d->addCameraNameBox = new TQCheckBox( i18n("Add Camera Name"), d->renameCustomBox ); renameCustomBoxLayout->addMultiCellWidget(d->addCameraNameBox, 4, 4, 1, 2); TQWhatsThis::add( d->addCameraNameBox, i18n("Set this option to add the camera name.")); d->addSeqNumberBox = new TQCheckBox( i18n("Add Sequence Number"), d->renameCustomBox ); renameCustomBoxLayout->addMultiCellWidget(d->addSeqNumberBox, 5, 5, 1, 2); TQWhatsThis::add( d->addSeqNumberBox, i18n("
Set this option to add a sequence number " "starting with the index set below.")); d->startIndexLabel = new TQLabel( i18n("Start Index:"), d->renameCustomBox ); d->startIndexInput = new KIntNumInput(1, d->renameCustomBox); d->startIndexInput->setRange(1, 900000, 1, false); TQWhatsThis::add( d->startIndexInput, i18n("
Set the starting index value used to rename "
"files with a sequence number."));
renameCustomBoxLayout->addMultiCellWidget(d->startIndexLabel, 6, 6, 1, 1);
renameCustomBoxLayout->addMultiCellWidget(d->startIndexInput, 6, 6, 2, 2);
mainLayout->addMultiCellWidget(d->renameCustomBox, 3, 3, 0, 1);
mainLayout->setRowStretch(4, 10);
// -- setup connections -------------------------------------------------
connect(this, TQ_SIGNAL(clicked(int)),
this, TQ_SLOT(slotRadioButtonClicked(int)));
connect(d->renameCustomPrefix, TQ_SIGNAL(textChanged(const TQString&)),
this, TQ_SLOT(slotRenameOptionsChanged()));
connect(d->renameCustomSuffix, TQ_SIGNAL(textChanged(const TQString&)),
this, TQ_SLOT(slotRenameOptionsChanged()));
connect(d->addDateTimeBox, TQ_SIGNAL(toggled(bool)),
this, TQ_SLOT(slotRenameOptionsChanged()));
connect(d->addCameraNameBox, TQ_SIGNAL(toggled(bool)),
this, TQ_SLOT(slotRenameOptionsChanged()));
connect(d->addSeqNumberBox, TQ_SIGNAL(toggled(bool)),
this, TQ_SLOT(slotRenameOptionsChanged()));
connect(d->renameDefaultCaseType, TQ_SIGNAL(activated(const TQString&)),
this, TQ_SLOT(slotRenameOptionsChanged()));
connect(d->startIndexInput, TQ_SIGNAL(valueChanged (int)),
this, TQ_SLOT(slotRenameOptionsChanged()));
connect(d->changedTimer, TQ_SIGNAL(timeout()),
this, TQ_SIGNAL(signalChanged()));
connect(d->dateTimeButton, TQ_SIGNAL(clicked()),
this, TQ_SLOT(slotDateTimeButtonClicked()));
connect(d->dateTimeFormat, TQ_SIGNAL(activated(int)),
this, TQ_SLOT(slotDateTimeFormatChanged(int)));
connect(d->addDateTimeBox, TQ_SIGNAL(toggled(bool)),
this, TQ_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()
{
delete d->changedTimer;
saveSettings();
delete d;
}
bool RenameCustomizer::useDefault() const
{
return d->renameDefault->isChecked();
}
int RenameCustomizer::startIndex() const
{
return d->startIndexInput->value();
}
TQString RenameCustomizer::newName(const TQDateTime &dateTime, int index, const TQString &extension) const
{
if (d->renameDefault->isChecked())
return TQString();
else
{
TQString name(d->renameCustomPrefix->text());
// use the "T" as a delimiter between date and time
TQString date;
switch (d->dateTimeFormat->currentItem())
{
case RenameCustomizerPriv::DigikamStandard:
date = dateTime.toString("yyyyMMddThhmmss");
break;
case RenameCustomizerPriv::TextDateFormat:
date = dateTime.toString(TQt::TextDate);
break;
case RenameCustomizerPriv::LocalDateFormat:
date = dateTime.toString(TQt::LocalDate);
break;
case RenameCustomizerPriv::IsoDateFormat:
date = dateTime.toString(TQt::ISODate);
break;
case RenameCustomizerPriv::Advanced:
date = dateTime.toString(d->dateTimeFormatString);
break;
}
// it seems that TQString::number does not support padding with zeros
TQString seq;
seq.sprintf("-%06d", index);
if (d->addDateTimeBox->isChecked())
name += date;
if (d->addSeqNumberBox->isChecked())
name += seq;
if (d->addCameraNameBox->isChecked())
name += TQString("-%1").arg(d->cameraTitle.simplifyWhiteSpace().replace(" ", ""));
name += d->renameCustomSuffix->text();
name += extension;
return name;
}
}
RenameCustomizer::Case RenameCustomizer::changeCase() const
{
RenameCustomizer::Case type = NONE;
if (d->renameDefaultCaseType->currentItem() == 1)
type=UPPER;
if (d->renameDefaultCaseType->currentItem() == 2)
type=LOWER;
return type;
}
void RenameCustomizer::slotRadioButtonClicked(int)
{
TQRadioButton* btn = dynamic_cast Enter the format for date and time. Use dd for the day, "
"MM for the month, "
"yyyy for the year, "
"hh for the hour, "
"mm for the minute, "
"ss for the second. Examples: yyyyMMddThhmmss "
"for 20060824T142418,
"
"yyyy-MM-dd hh:mm:ss "
"for 2006-08-24 14:24:18.