Source Code (Use browser search to find items of interest.)
Class Index
kcontrol'KLocaleConfigTime (./kdebase/kcontrol/locale/localetime.h:36)
class KLocaleConfigTime : public QWidget
{
Q_OBJECT
public:
KLocaleConfigTime( QWidget *parent=0, const char *name=0);
~KLocaleConfigTime( );
void load();
void save();
void defaults();
public slots:
void reset();
void reTranslate();
private slots:
// Time & dates
void slotTimeFmtChanged(const QString &t);
void slotDateFmtChanged(const QString &t);
void slotDateFmtShortChanged(const QString &t);
signals:
void translate();
void resample();
private:
// Time & dates
QLineEdit *edTimeFmt;
QLineEdit *edDateFmt;
QLineEdit *edDateFmtShort;
};
kcontrol'KLocaleConfigTime::KLocaleConfigTime() (./kdebase/kcontrol/locale/localetime.cpp:45)
KLocaleConfigTime::KLocaleConfigTime(QWidget *parent, const char*name)
: QWidget(parent, name)
{
QLabel *label;
// Time
QGridLayout *tl1 = new QGridLayout(this, 1, 1, 10, 5);
tl1->setColStretch(2, 1);
label = new QLabel(this, I18N_NOOP("Time format"));
edTimeFmt = new QLineEdit(this);
connect( edTimeFmt, SIGNAL( textChanged(const QString &) ), this, SLOT( slotTimeFmtChanged(const QString &) ) );
tl1->addWidget(label, 0, 1);
tl1->addWidget(edTimeFmt, 0, 2);
label = new QLabel(this, I18N_NOOP("Date format"));
edDateFmt = new QLineEdit(this);
connect( edDateFmt, SIGNAL( textChanged(const QString &) ), this, SLOT( slotDateFmtChanged(const QString &) ) );
tl1->addWidget(label, 1, 1);
tl1->addWidget(edDateFmt, 1, 2);
label = new QLabel(this, I18N_NOOP("Short date format"));
edDateFmtShort = new QLineEdit(this);
connect( edDateFmtShort, SIGNAL( textChanged(const QString &) ), this, SLOT( slotDateFmtShortChanged(const QString &) ) );
tl1->addWidget(label, 2, 1);
tl1->addWidget(edDateFmtShort, 2, 2);
tl1->setRowStretch(3, 1);
}
kcontrol'KLocaleConfigTime::~KLocaleConfigTime() (./kdebase/kcontrol/locale/localetime.cpp:75)
KLocaleConfigTime::~KLocaleConfigTime()
{
}
/**
* Load stored configuration.
*/
kcontrol'KLocaleConfigTime::load() (./kdebase/kcontrol/locale/localetime.cpp:82)
void KLocaleConfigTime::load()
{
KConfig *config = KGlobal::config();
KConfigGroupSaver saver(config, QString::fromLatin1("Locale"));
KSimpleConfig ent(locate("locale", QString::fromLatin1("l10n/") + locale->time() + QString::fromLatin1("/entry.desktop")), true);
ent.setGroup(QString::fromLatin1("KCM Locale"));
// different tmp variables
QString str;
// TimeFormat
str = config->readEntry(QString::fromLatin1("TimeFormat"));
if (str.isNull())
str = ent.readEntry(QString::fromLatin1("TimeFormat"), QString::fromLatin1("%I:%M:%S %p"));
locale->setTimeFormat(str);
// DateFormat
str = config->readEntry(QString::fromLatin1("DateFormat"));
if (str.isNull())
str = ent.readEntry(QString::fromLatin1("DateFormat"), QString::fromLatin1("%A %d %B %Y"));
locale->setDateFormat(str);
// DateFormatShort
str = config->readEntry(QString::fromLatin1("DateFormatShort"));
if (str.isNull())
str = ent.readEntry(QString::fromLatin1("DateFormatShort"), QString::fromLatin1("%m/%d/%y"));
locale->setDateFormatShort(str);
// update the widgets
edTimeFmt->setText(locale->timeFormat());
edDateFmt->setText(locale->dateFormat());
edDateFmtShort->setText(locale->dateFormatShort());
}
kcontrol'KLocaleConfigTime::save() (./kdebase/kcontrol/locale/localetime.cpp:116)
void KLocaleConfigTime::save()
{
KSimpleConfig *c = new KSimpleConfig(QString::fromLatin1("kdeglobals"), false);
c->setGroup(QString::fromLatin1("Locale"));
// Write something to the file to make it dirty
c->writeEntry(QString::fromLatin1("TimeFormat"), QString::null);
c->deleteEntry(QString::fromLatin1("TimeFormat"), false);
c->deleteEntry(QString::fromLatin1("DateFormat"), false);
c->deleteEntry(QString::fromLatin1("DateFormatShort"), false);
delete c;
KConfigBase *config = new KConfig;
config->setGroup(QString::fromLatin1("Locale"));
KSimpleConfig ent(locate("locale", QString::fromLatin1("l10n/") + locale->time() + QString::fromLatin1("/entry.desktop")), true);
ent.setGroup(QString::fromLatin1("KCM Locale"));
QString str;
str = ent.readEntry(QString::fromLatin1("TimeFormat"), QString::fromLatin1("%I:%M:%S %p"));
str = config->readEntry(QString::fromLatin1("TimeFormat"), str);
if (str != locale->timeFormat())
config->writeEntry(QString::fromLatin1("TimeFormat"), locale->timeFormat(), true, true);
str = ent.readEntry(QString::fromLatin1("DateFormat"), QString::fromLatin1("%A %d %B %Y"));
str = config->readEntry(QString::fromLatin1("DateFormat"), str);
if (str != locale->dateFormat())
config->writeEntry(QString::fromLatin1("DateFormat"), locale->dateFormat(), true, true);
str = ent.readEntry(QString::fromLatin1("DateFormatShort"), QString::fromLatin1("%m/%d/%y"));
str = config->readEntry(QString::fromLatin1("DateFormatShort"), str);
if (str != locale->dateFormatShort())
config->writeEntry(QString::fromLatin1("DateFormatShort"), locale->dateFormatShort(), true, true);
delete config;
}
kcontrol'KLocaleConfigTime::defaults() (./kdebase/kcontrol/locale/localetime.cpp:154)
void KLocaleConfigTime::defaults()
{
reset();
}
kcontrol'KLocaleConfigTime::slotTimeFmtChanged() (./kdebase/kcontrol/locale/localetime.cpp:159)
void KLocaleConfigTime::slotTimeFmtChanged(const QString &t)
{
locale->setTimeFormat(t);
emit resample();
}
kcontrol'KLocaleConfigTime::slotDateFmtChanged() (./kdebase/kcontrol/locale/localetime.cpp:165)
void KLocaleConfigTime::slotDateFmtChanged(const QString &t)
{
locale->setDateFormat(t);
emit resample();
}
kcontrol'KLocaleConfigTime::slotDateFmtShortChanged() (./kdebase/kcontrol/locale/localetime.cpp:171)
void KLocaleConfigTime::slotDateFmtShortChanged(const QString &t)
{
locale->setDateFormatShort(t);
emit resample();
}
kcontrol'KLocaleConfigTime::reset() (./kdebase/kcontrol/locale/localetime.cpp:177)
void KLocaleConfigTime::reset()
{
KSimpleConfig ent(locate("locale", QString::fromLatin1("l10n/") + locale->time() + QString::fromLatin1("/entry.desktop")), true);
ent.setGroup(QString::fromLatin1("KCM Locale"));
locale->setTimeFormat(ent.readEntry(QString::fromLatin1("TimeFormat"), QString::fromLatin1("%I:%M:%S %p")));
locale->setDateFormat(ent.readEntry(QString::fromLatin1("DateFormat"), QString::fromLatin1("%A %d %B %Y")));
locale->setDateFormatShort(ent.readEntry(QString::fromLatin1("DateFormatShort"), QString::fromLatin1("%m/%d/%y")));
edTimeFmt->setText(locale->timeFormat());
edDateFmt->setText(locale->dateFormat());
edDateFmtShort->setText(locale->dateFormatShort());
}
kcontrol'KLocaleConfigTime::reTranslate() (./kdebase/kcontrol/locale/localetime.cpp:191)
void KLocaleConfigTime::reTranslate()
{
QToolTip::add(edTimeFmt, locale->translate(
"The text in this textbox will be used to format\n"
"time strings. The sequences below will be replaced:\n"
"\n"
"%H The hour as a decimal number using a 24-hour clock\n"
" (00-23).\n"
"%k The hour (24-hour clock) as a decimal number (0-23).\n"
"%I The hour as a decimal number using a 12-hour clock\n"
" (01-12).\n"
"%l The hour (12-hour clock) as a decimal number (1-12).\n"
"%M The minute as a decimal number (00-59).\n"
"%S The second as a decimal number (00-59).\n"
"%p Either AM or PM according to the given time\n"
" value. Noon is treated as Pm and midnight as Am."));
QString datecodes = locale->translate(
"\n"
"%Y\tThe year with century as a decimal number.\n"
"%y\tThe year without century as a decimal number (00-99).\n"
"%m\tThe month as a decimal number (01-12).\n"
"%n\tThe month as a decimal number (1-12).\n"
"%b\tThe first three characters of the month name.\n"
"%B\tThe full month name.\n"
"%d\tThe day of month as a decimal number (01-31).\n"
"%e\tThe day of month as a decimal number (1-31).\n"
"%a\tThe first three characters of the weekday name.\n"
"%A\tThe full weekday name.");
QToolTip::add(edDateFmt, locale->translate(
"The text in this textbox will be used to format long\n"
"dates. The sequences below will be replaced:\n") + datecodes);
QToolTip::add(edDateFmtShort, locale->translate(
"The text in this textbox will be used to format short\n"
"dates. This is for instance used when listing files.\n"
"The sequences below will be replaced:\n") + datecodes);
}