本文整理汇总了C++中KLocale类的典型用法代码示例。如果您正苦于以下问题:C++ KLocale类的具体用法?C++ KLocale怎么用?C++ KLocale使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KLocale类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: alarmTimeText
/******************************************************************************
* Return the alarm time text in the form "date time".
*/
QString AlarmListViewItem::alarmTimeText(const DateTime &dateTime) const
{
KLocale *locale = KGlobal::locale();
QString dateTimeText = locale->formatDate(dateTime.date(), true);
if(!dateTime.isDateOnly())
{
dateTimeText += ' ';
QString time = locale->formatTime(dateTime.time());
if(mTimeHourPos == -2)
{
// Initialise the position of the hour within the time string, if leading
// zeroes are omitted, so that displayed times can be aligned with each other.
mTimeHourPos = -1; // default = alignment isn't possible/sensible
if(!QApplication::reverseLayout()) // don't try to align right-to-left languages
{
QString fmt = locale->timeFormat();
int i = fmt.find(QRegExp("%[kl]")); // check if leading zeroes are omitted
if(i >= 0 && i == fmt.find('%')) // and whether the hour is first
mTimeHourPos = i; // yes, so need to align
}
}
if(mTimeHourPos >= 0 && (int)time.length() > mTimeHourPos + 1
&& time[mTimeHourPos].isDigit() && !time[mTimeHourPos + 1].isDigit())
dateTimeText += '~'; // improve alignment of times with no leading zeroes
dateTimeText += time;
}
return dateTimeText + ' ';
}
示例2: m_xmlLoader
//------------------------------------
Part::Part( QWidget *parentWidget, QObject *parent, const QVariantList & /*args*/ )
: KParts::ReadWritePart( parent ),
m_xmlLoader(),
m_modified( false ),
m_loadingFromProjectStore( false ),
m_undostack( new QUndoStack( this ) )
{
setComponentData( Factory::global() );
// Add library translation files
KLocale *locale = KGlobal::locale();
if ( locale ) {
locale->insertCatalog( "kplatolibs" );
locale->insertCatalog( "kabc" );
}
if ( isReadWrite() ) {
setXMLFile( "kplatowork.rc" );
} else {
setXMLFile( "kplatowork_readonly.rc" );
}
View *v = new View( this, parentWidget, actionCollection() );
setWidget( v );
connect( v, SIGNAL( viewDocument( Document* ) ), SLOT( viewWorkpackageDocument( Document* ) ) );
loadWorkPackages();
connect( m_undostack, SIGNAL( cleanChanged( bool ) ), SLOT( setDocumentClean( bool ) ) );
}
示例3: kDebug
void KraftView::slotLanguageSettings()
{
kDebug() << "Language Settings" << endl;
DocLocaleDialog dia( this );
KLocale *l = m_doc->locale();
if ( m_doc ) {
dia.setLocale( l->country(), l->language() );
if ( dia.exec() == QDialog::Accepted ) {
QString c = dia.locale().country();
if ( c != m_doc->locale()->country() ) {
KConfig *cfg = KGlobal::config().data();
m_doc->locale()->setCountry( c, cfg );
m_doc->locale()->setLanguage( dia.locale().language(), cfg );
PositionViewWidgetListIterator it( mPositionWidgetList );
while( it.hasNext() ) {
PositionViewWidget *w = it.next(); // = 0;
w->setLocale( m_doc->locale() );
w->repaint();
}
refreshPostCard();
}
}
}
}
示例4: KLocale
void KMoneyThingHomeView::doHTML()
{
KLocale *locale = new KLocale("KMoneyThing");
khtmlPart->begin();
khtmlPart->write("<html>");
khtmlPart->write("<head><style type='text/css'>th, tr { text-align: left; padding-right: 1em }</style></head>");
khtmlPart->write("<body><h1>");
khtmlPart->write(i18n("Welcome to KMoneyThing") + " pre0.1");
khtmlPart->write("</h1><hr><p>");
khtmlPart->write(i18n("This application is still under development, and is not yet suitable for general use."));
khtmlPart->write("</p>");
khtmlPart->write("<h2>" + i18n("Summary") + "</h2>");
khtmlPart->write("<table>");
khtmlPart->write("<tr><th>" + i18n("Account") + "</th><th>" + i18n("Balance") + "</th></tr>");
// TODO: International accounts
// TODO: Adding up balances with suport for internationalisation
for (Q_UINT32 i = 0; i < mCurrentFile->accounts(); i++)
{
locale->setCountry(mCurrentFile->getAccount(i)->locale());
QString accountName = mCurrentFile->getAccount(i)->name();
QString accountBalance = locale->formatMoney(mCurrentFile->getAccount(i)->balance());
khtmlPart->write(QString("<tr><td>%1</td><td>%2</td></tr>").arg(accountName).arg(accountBalance));
}
locale->setCountry(mCurrentFile->locale());
QString totalBalance = locale->formatMoney(0.0);
khtmlPart->write("<tr><th>" + i18n("Total:") + "</th><th>" + totalBalance + "</th></tr>");
khtmlPart->write("</table>");
khtmlPart->write("</body></html>");
khtmlPart->end();
delete locale;
}
示例5: kDebug
void KdeObservatory::engineError(const QString &source, const QString &error)
{
kDebug() << "Source:" << source << "Error:" << error;
if (source == "fatal" && m_sourceCounter > 0)
{
m_viewTransitionTimer->stop();
foreach(QGraphicsWidget *widget, m_views)
widget->hide();
m_views.clear();
graphicsWidget();
m_updateLabel->setStyleSheet(QString("QLabel{color:rgb(255, 0, 0);}"));
m_updateLabel->setText(error);
setBusy(false);
return;
}
--m_sourceCounter;
if (m_sourceCounter == 0)
{
KDateTime currentTime = KDateTime::currentLocalDateTime();
KLocale *locale = KGlobal::locale();
m_updateLabel->setStyleSheet(QString("QLabel{color:rgb(0, 0, 0);}"));
m_updateLabel->setText(i18n("Last update: %1 %2", currentTime.toString(locale->dateFormatShort()), currentTime.toString(locale->timeFormat())));
setBusy(false);
updateViews();
}
}
示例6: if
void KdeObservatory::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data)
{
// Prevent for being updated from another instance update request
if (data["appletId"].toUInt() != id())
return;
QString project = data["project"].toString();
if (sourceName != "topActiveProjects" && !data.contains(project) && !data.contains("error"))
return;
if (sourceName == "topActiveProjects")
m_viewProviders[i18n("Top Active Projects")]->updateViews(data);
else if (sourceName == "topProjectDevelopers" && !project.isEmpty())
m_viewProviders[i18n("Top Developers")]->updateViews(data);
else if (sourceName == "commitHistory" && !project.isEmpty())
m_viewProviders[i18n("Commit History")]->updateViews(data);
else if (sourceName == "krazyReport" && !project.isEmpty())
m_viewProviders[i18n("Krazy Report")]->updateViews(data);
--m_sourceCounter;
m_collectorProgress->setValue(m_collectorProgress->maximum() - m_sourceCounter);
if (m_sourceCounter == 0)
{
KDateTime currentTime = KDateTime::currentLocalDateTime();
KLocale *locale = KGlobal::locale();
m_updateLabel->setStyleSheet(QString("QLabel{color:rgb(0, 0, 0);}"));
m_updateLabel->setText(i18n("Last update: %1 %2", currentTime.toString(locale->dateFormatShort()), currentTime.toString(locale->timeFormat())));
setBusy(false);
updateViews();
}
}
示例7: DoubleSpinbox_qDebug
QString DoubleSpinBox::textFromValue(double value) const
{
DoubleSpinbox_qDebug() << Q_FUNC_INFO << " value = " << value;
// int leftDigits = (int)floor( log10( abs( value ) ) ) + 1;
// if ( leftDigits < 0 ) {
// leftDigits = 0;
// } else if ( leftDigits > 3 ) {
// leftDigits = 3;
// }
double multiplier = Item::getMultiplier( value );
double toDisplayNr = value / multiplier;
DoubleSpinbox_qDebug() << Q_FUNC_INFO << "toDisplayNr = " << toDisplayNr;
KLocale * locale = KGlobal::locale();
QString numberStr = locale->formatNumber( toDisplayNr, 0 /* 3-leftDigits */ );
QString magStr = Item::getNumberMag( value );
QString toRet = numberStr + " " + magStr + m_unit;
DoubleSpinbox_qDebug() << Q_FUNC_INFO << " text = " << toRet;
return toRet;
}
示例8: dateChanged
void KOEditorGeneralTodo::dateChanged()
{
KLocale *l = KGlobal::locale();
QString dateTimeStr = "";
if(mStartCheck->isChecked())
{
dateTimeStr += i18n("Start: %1").arg(
l->formatDate(mStartDateEdit->date()));
if(mTimeButton->isChecked())
dateTimeStr += QString(" %1").arg(
l->formatTime(mStartTimeEdit->getTime()));
}
if(mDueCheck->isChecked())
{
dateTimeStr += i18n(" Due: %1").arg(
l->formatDate(mDueDateEdit->date()));
if(mTimeButton->isChecked())
dateTimeStr += QString(" %1").arg(
l->formatTime(mDueTimeEdit->getTime()));
}
emit dateTimeStrChanged(dateTimeStr);
QDateTime endDt(mDueDateEdit->date(), mDueTimeEdit->getTime());
emit signalDateTimeChanged(endDt, endDt);
}
示例9: group
QStringList KSwitchLanguageDialogPrivate::applicationLanguageList()
{
KSharedConfigPtr config = KGlobal::config();
QStringList languagesList;
if (config->hasGroup("Locale"))
{
KConfigGroup group(config, "Locale");
if (group.hasKey("Language"))
{
languagesList = group.readEntry("Language", QString()).split(':');
}
}
if (languagesList.isEmpty())
{
languagesList = KGlobal::locale()->languageList();
}
KLocale *locale = KGlobal::locale();
for (int i = 0; i < languagesList.count();)
{
if (!locale->isApplicationTranslatedInto(languagesList[i]))
languagesList.removeAt(i);
else
++i;
}
return languagesList;
}
示例10:
PlanTJPlugin::PlanTJPlugin( QObject * parent, const QVariantList & )
: KPlato::SchedulerPlugin(parent)
{
KLocale *locale = KGlobal::locale();
if ( locale ) {
locale->insertCatalog( "plantjplugin" );
}
m_granularities << (long unsigned int) 5 * 60 * 1000
<< (long unsigned int) 15 * 60 * 1000
<< (long unsigned int) 30 * 60 * 1000
<< (long unsigned int) 60 * 60 * 1000;
}
示例11: fillApplicationLanguages
void KSwitchLanguageDialogPrivate::fillApplicationLanguages(KLanguageButton *button)
{
KLocale *locale = KGlobal::locale();
const QStringList allLanguages = locale->allLanguagesList();
for ( int i = 0, count = allLanguages.count(); i < count; ++i )
{
QString languageCode = allLanguages[i];
if (locale->isApplicationTranslatedInto(languageCode))
{
button->insertLanguage(languageCode);
}
}
}
示例12: kDebug
KPlatoRCPSPlugin::KPlatoRCPSPlugin( QObject * parent, const QVariantList & )
: KPlato::SchedulerPlugin(parent)
{
kDebug(planDbg())<<rcps_version();
KLocale *locale = KGlobal::locale();
if ( locale ) {
locale->insertCatalog( "planrcpsplugin" );
}
m_granularities << (long unsigned int) 1 * 60 * 1000
<< (long unsigned int) 15 * 60 * 1000
<< (long unsigned int) 30 * 60 * 1000
<< (long unsigned int) 60 * 60 * 1000;
}
示例13: if
QVariant DocumentModel::data(const QModelIndex &idx, int role) const
{
if(role == Qt::DisplayRole)
{
if(idx.column() == Document_LastModified ) {
KLocale *locale = KGlobal::locale();
QDateTime date = QSqlQueryModel::data(idx, role).toDateTime();
return locale->formatDateTime( date, KLocale::ShortDate );
} else if( idx.column() == Document_CreationDate ) {
KLocale *locale = KGlobal::locale();
QDate date = QSqlQueryModel::data( idx, role ).toDate();
return locale->formatDate( date, KLocale::ShortDate );
} else if(idx.column() == Document_ClientId ) {
const QString uid = QSqlQueryModel::data( idx, role ).toString();
return uid;
} else if( idx.column() == Document_ClientName ) {
QModelIndex uidIdx = idx.sibling( idx.row(), Document_ClientId );
const QString uid = QSqlQueryModel::data( uidIdx, role ).toString();
// kDebug() << "Checking for UID " << uid;
if( uid.isEmpty() ) return "";
if( mAddresses.contains( uid ) ) {
if( mAddresses.value(uid).isEmpty() ) {
// empty address means that there is no valid entry in this addressbook
return i18n("not found");
}
const QString realName = mAddresses.value(uid).realName();
// kDebug() << "returning " << realName;
return realName;
} else {
mAddressProvider->getAddressee( uid );
}
return i18n("retrieving...");
}
} else if( role == RawTypes ) {
if(idx.column() == Document_LastModified ) {
return QSqlQueryModel::data( idx, Qt::DisplayRole ).toDateTime();
} else if( idx.column() == Document_CreationDate ) {
return QSqlQueryModel::data( idx, Qt::DisplayRole ).toDate();
}
} else if( role == Qt::SizeHintRole ) {
QFont f = QSqlQueryModel::data(idx, Qt::FontRole ).value<QFont>();
QFontMetrics fm(f);
int h = fm.height();
return QSize( 0, h + 4 );
}
return QSqlQueryModel::data(idx, role);
}
示例14: m_config
KdePlatformDependent::KdePlatformDependent()
: m_config(KSharedConfig::openConfig("atticarc")), m_accessManager(0), m_wallet(0)
{
// when a plain Qt application loads this plugin, it needs a valid KGlobal object
if (!KGlobal::hasMainComponent()) {
KComponentData componentData("attica_kde");
}
KLocale* locale = KGlobal::locale();
if (locale) {
locale->insertCatalog("attica_kde");
}
m_accessManager = new KIO::Integration::AccessManager(this);
}
示例15: insertLibraryCatalogues
void insertLibraryCatalogues()
{
static const char * const catalogs[] = {
"libkdepim",
"kabc",
"libakonadi",
"kabcakonadi",
"akonadicontact",
"libpimcommon"
};
KLocale * l = KGlobal::locale();
for ( unsigned int i = 0 ; i < sizeof catalogs / sizeof *catalogs ; ++i ) {
l->insertCatalog( catalogs[i] );
}
}