-rw-r--r-- | kaddressbook/addresseeeditordialog.cpp | 1 | ||||
-rw-r--r-- | kaddressbook/addresseeeditorwidget.cpp | 6 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 2 | ||||
-rw-r--r-- | korganizer/kowhatsnextview.cpp | 10 | ||||
-rw-r--r-- | microkde/kdecore/klocale.cpp | 39 | ||||
-rw-r--r-- | microkde/kdecore/klocale.h | 14 |
6 files changed, 33 insertions, 39 deletions
diff --git a/kaddressbook/addresseeeditordialog.cpp b/kaddressbook/addresseeeditordialog.cpp index d8c1aca..5e42640 100644 --- a/kaddressbook/addresseeeditordialog.cpp +++ b/kaddressbook/addresseeeditordialog.cpp @@ -49,25 +49,24 @@ AddresseeEditorDialog::AddresseeEditorDialog( KABCore *core, QWidget *parent, connect( mEditorWidget, SIGNAL( modified( const KABC::Addressee::List& ) ), SLOT( widgetModified() ) ); layout->addWidget( mEditorWidget ); enableButton( KDialogBase::Apply, false ); if ( QApplication::desktop()->width() < 480 ) { hideButtons(); } } AddresseeEditorDialog::~AddresseeEditorDialog() { - qDebug("AddresseeEditorDialog::~AddresseeEditorDialog()"); //emit editorDestroyed( mEditorWidget->addressee().uid() ); } void AddresseeEditorDialog::setAddressee( const KABC::Addressee &addr ) { enableButton( KDialogBase::Apply, false ); mEditorWidget->setAddressee( addr ); } KABC::Addressee AddresseeEditorDialog::addressee() { diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp index 4365ee5..3cfc1f2 100644 --- a/kaddressbook/addresseeeditorwidget.cpp +++ b/kaddressbook/addresseeeditorwidget.cpp @@ -1056,29 +1056,25 @@ void AddresseeEditorWidget::save() // save custom fields mAddressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", mIMAddressEdit->text() ); mAddressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", mSpouseEdit->text() ); mAddressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", mManagerEdit->text() ); mAddressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", mAssistantEdit->text() ); mAddressee.insertCustom( "KADDRESSBOOK", "X-Department", mDepartmentEdit->text() ); mAddressee.insertCustom( "KADDRESSBOOK", "X-Office", mOfficeEdit->text() ); mAddressee.insertCustom( "KADDRESSBOOK", "X-Profession", mProfessionEdit->text() ); if ( mAnniversaryPicker->inputIsValid() ) { //US mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", //US mAnniversaryPicker->date().toString( Qt::ISODate ) ); - int orgformat = KGlobal::locale()->getIntDateFormat(); - QDate da = mAnniversaryPicker->date(); - KGlobal::locale()->setIntDateFormat( 2 ); // = Qt::ISODate - QString dt = KGlobal::locale()->formatDate(da, true); - KGlobal::locale()->setIntDateFormat(orgformat ); + QString dt = KGlobal::locale()->formatDate(mAnniversaryPicker->date(), true, KLocale::ISODate); mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); } else mAddressee.removeCustom( "KADDRESSBOOK", "X-Anniversary" ); // Save the email addresses QStringList emails = mAddressee.emails(); QStringList::Iterator iter; for ( iter = emails.begin(); iter != emails.end(); ++iter ) mAddressee.removeEmail( *iter ); emails = mEmailWidget->emails(); diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index c3c3d47..58b3d70 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -1767,25 +1767,25 @@ void CalendarView::goNextMonth() { mNavigator->selectNextMonth(); } void CalendarView::goPreviousMonth() { mNavigator->selectPreviousMonth(); } void CalendarView::writeLocale() { KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); - KGlobal::locale()->setIntDateFormat( KOPrefs::instance()->mPreferredDate ); + KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); QString dummy = KOPrefs::instance()->mUserDateFormatLong; KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); dummy = KOPrefs::instance()->mUserDateFormatShort; KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, KOPrefs::instance()->mDaylightsavingStart, KOPrefs::instance()->mDaylightsavingEnd ); KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); } void CalendarView::updateConfig() { diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp index 0547a2e..b2001ec 100644 --- a/korganizer/kowhatsnextview.cpp +++ b/korganizer/kowhatsnextview.cpp @@ -441,30 +441,27 @@ void KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed ) } } else { mText += i18n("Allday:"); } } else { mTodos.append( ev ); mText += i18n("ToDo:"); if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) { // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; QString dfs = KGlobal::locale()->dateFormatShort(); - KGlobal::locale()->setIntDateFormat( 3 ); KGlobal::locale()->setDateFormatShort("%d.%b"); - mText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true) + "</font>"; - + mText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>"; KGlobal::locale()->setDateFormatShort(dfs); - KGlobal::locale()->setIntDateFormat( KOPrefs::instance()->mPreferredDate ); } else { if (!ev->doesFloat() ) if( ( (Todo*)ev)->dtDue() < cdt ) { mText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>"; } else mText +=((Todo*)ev)->dtDueTimeStr(); mTodos.append( ev ); } } mText += "</b></td><td>"; @@ -558,30 +555,27 @@ bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) mText += "] "; if ( ev->cancelled() ) mText += "</font>"; mText += "<a href=\"todo:" + ev->uid() + "\">"; mText += ev->summary(); mText += "</a>"; if ( ((Todo*)ev)->hasDueDate () ) { QString year = ""; int ye = ((Todo*)ev)->dtDue().date().year(); if ( QDateTime::currentDateTime().date().year() != ye ) year = QString::number( ye ); QString dfs = KGlobal::locale()->dateFormatShort(); - KGlobal::locale()->setIntDateFormat( 3 ); KGlobal::locale()->setDateFormatShort("%d.%b"); - mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true) + "."+ year +"]</font>"; - + mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; KGlobal::locale()->setDateFormatShort(dfs); - KGlobal::locale()->setIntDateFormat( KOPrefs::instance()->mPreferredDate ); } if ( KOPrefs::instance()->mWNViewShowLocation ) if ( !ev->location().isEmpty() ) mText += " ("+ev->location() +")"; if ( !isSub ) { if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) mText += " ["+ev->relatedTo()->summary() +"]"; mText += "</p>\n"; } else { ind += "-"; mText += "</li>\n"; diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp index d77e251..9d7e60b 100644 --- a/microkde/kdecore/klocale.cpp +++ b/microkde/kdecore/klocale.cpp @@ -77,25 +77,25 @@ KLocale::KLocale() : mCalendarSystem( 0 ) { m_decimalSymbol = "."; m_positiveSign = ""; m_negativeSign = "-"; m_thousandsSeparator = ","; mWeekStartsMonday = true; mHourF24Format = true; - mIntDateFormat = 0; + mIntDateFormat = Default; mLanguage = 0; mDateFormat = "%a %Y %b %d"; mDateFormatShort = "%Y-%m-%d"; mTimeZoneList << i18n ("-11:00 US/Samoa") << i18n ("-10:00 US/Hawaii") << i18n ("-09:00 US/Alaska") << i18n ("-08:00 US/Pacific") << i18n ("-07:00 US/Mountain") << i18n ("-06:00 US/Central") << i18n ("-05:00 US/Eastern") << i18n ("-04:00 Brazil/West") << i18n ("-03:00 Brazil/East") @@ -130,30 +130,30 @@ void KLocale::setDateFormatShort( QString s ) { mDateFormatShort = s; } void KLocale::setHore24Format ( bool b ) { mHourF24Format = b; } void KLocale::setWeekStartMonday( bool b ) { mWeekStartsMonday = b; } -int KLocale::getIntDateFormat( ) +KLocale::IntDateFormat KLocale::getIntDateFormat( ) { - return mIntDateFormat ; + return mIntDateFormat; } -void KLocale::setIntDateFormat( int i ) +void KLocale::setIntDateFormat( KLocale::IntDateFormat i ) { mIntDateFormat = i; } void KLocale::setLanguage( int i ) { mLanguage = i; } QString KLocale::translate( const char *index ) const { return i18n( index ); } @@ -232,27 +232,27 @@ QString KLocale::formatTime(const QTime &pTime, bool includeSecs) const default: buffer[index++] = rst.at( format_index ); break; } escape = false; } } QString ret( buffer, index ); delete [] buffer; return ret; } -QString KLocale::formatDate(const QDate &pDate, bool shortFormat) const +QString KLocale::formatDate(const QDate &pDate, bool shortFormat, IntDateFormat intIntDateFormat) const { - const QString rst = shortFormat?dateFormatShort():dateFormat(); + const QString rst = shortFormat?dateFormatShort(intIntDateFormat):dateFormat(intIntDateFormat); // I'm rather safe than sorry QChar *buffer = new QChar[rst.length() * 3 / 2 + 50]; unsigned int index = 0; bool escape = false; int number = 0; for ( uint format_index = 0; format_index < rst.length(); ++format_index ) { if ( !escape ) { @@ -635,53 +635,56 @@ QString KLocale::monthName(int i,bool shortName) const case 11: return i18n("November"); case 12: return i18n("December"); } return QString::null; } QString KLocale::country() const { return QString::null; } -QString KLocale::dateFormat() const -{ +QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const +{ + const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; + if ( QApplication::desktop()->width() < 480 ) { - if ( mIntDateFormat == 0 ) + if ( dformat == Default ) return "%a %d %b %Y"; - else if ( mIntDateFormat == 1 ) + else if ( dformat == Format1 ) return "%a %b %d %Y"; - else if ( mIntDateFormat == 2 ) + else if ( dformat == ISODate ) return "%a %Y %b %d"; } else { - if ( mIntDateFormat == 0 ) + if ( dformat == Default ) return "%A %d %B %Y"; - else if ( mIntDateFormat == 1 ) + else if ( dformat == Format1 ) return "%A %B %d %Y"; - else if ( mIntDateFormat == 2 ) + else if ( dformat == ISODate ) return "%A %Y %B %d"; } return mDateFormat ; } -QString KLocale::dateFormatShort() const +QString KLocale::dateFormatShort(IntDateFormat intIntDateFormat) const { + const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; - if ( mIntDateFormat == 0 ) + if ( dformat == Default ) return "%d.%m.%Y"; - else if ( mIntDateFormat == 1 ) + else if ( dformat == Format1 ) return "%m.%d.%Y"; - else if ( mIntDateFormat == 2 ) + else if ( dformat == ISODate ) // = Qt::ISODate return "%Y-%m-%d"; return mDateFormatShort ; } QString KLocale::timeFormat() const { if ( mHourF24Format) return "%H:%M:%S"; return "%I:%M:%S%p"; } diff --git a/microkde/kdecore/klocale.h b/microkde/kdecore/klocale.h index 7470cd2..f6c0253 100644 --- a/microkde/kdecore/klocale.h +++ b/microkde/kdecore/klocale.h @@ -32,79 +32,81 @@ class KLocale QString formatNumber(const QString &numStr) const; double readNumber(const QString &numStr, bool * ok = 0) const; QString decimalSymbol() const; QString thousandsSeparator() const; QString positiveSign() const; QString negativeSign() const; QString translate( const char *index ) const; QString translate( const char *index, const char *fallback) const; - QString formatDate(const QDate &pDate, bool shortFormat = false) const; + enum IntDateFormat { Undefined=-1, Default=0, Format1=1, ISODate=2, Userdefined=3 }; + + QString formatDate(const QDate &pDate, bool shortFormat = false, IntDateFormat intIntDateFormat = Undefined) const; QString formatTime(const QTime &pTime, bool includeSecs = false) const; QString formatDateTime(const QDateTime &pDateTime) const; QString formatDateTime(const QDateTime &pDateTime, bool shortFormat, bool includeSecs = false) const; QDate readDate(const QString &str, bool* ok = 0) const; QDate readDate( const QString &intstr, const QString &fmt, bool* ok = 0) const; QTime readTime(const QString &str, bool* ok = 0) const; bool use12Clock() const; bool weekStartsMonday() const; int weekStartDay() const; QString weekDayName(int,bool=false) const; QString monthName(int,bool=false) const; QString country() const; - QString dateFormat() const; - QString dateFormatShort() const; + QString dateFormat(IntDateFormat intIntDateFormat = Undefined) const; + QString dateFormatShort(IntDateFormat intIntDateFormat = Undefined) const; QString timeFormat() const; void insertCatalogue ( const QString & ); KCalendarSystem *calendar(); void setHore24Format ( bool ); void setWeekStartMonday( bool ); - void setIntDateFormat( int ); - int getIntDateFormat( ); + void setIntDateFormat( IntDateFormat ); + IntDateFormat getIntDateFormat( ); void setLanguage( int ); void setDateFormat( QString ); void setDateFormatShort( QString ); QString m_decimalSymbol; QString m_thousandsSeparator; QString m_currencySymbol; QString m_monetaryDecimalSymbol; QString m_monetaryThousandsSeparator; QString m_positiveSign; QString m_negativeSign; int timezoneOffset( QString ); QStringList timeZoneList() const; void setDaylightSaving( bool, int , int ); int localTimeOffset(const QDateTime &); void setTimezone( const QString &timeZone ); private: QTime readTime(const QString &str, bool seconds, bool *ok) const; QDate readDate(const QString &str, bool shortFormat, bool *ok) const; KCalendarSystem *mCalendarSystem; bool mWeekStartsMonday; bool mHourF24Format; - int mIntDateFormat; + IntDateFormat mIntDateFormat; int mLanguage; QString mDateFormat; QString mDateFormatShort; QStringList mTimeZoneList; bool daylightEnabled; int mDaylightTZoffset; int mNondaylightTZoffset; bool mSouthDaylight; int daylightStart, daylightEnd, mTimeZoneOffset; }; #endif |