Commit f5b730a3 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Make it compile with QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII

parent 772e6b8d
......@@ -3,8 +3,8 @@ project(kalarm)
add_definitions(-DKDE_DEFAULT_DEBUG_AREA=5950)
add_definitions(-DQT_STRICT_ITERATORS)
#add_definitions( -DQT_NO_CAST_FROM_ASCII )
#add_definitions( -DQT_NO_CAST_TO_ASCII )
add_definitions( -DQT_NO_CAST_FROM_ASCII )
add_definitions( -DQT_NO_CAST_TO_ASCII )
option(KALARM_USE_AKONADI "Build to use Akonadi" ON)
......
......@@ -114,11 +114,11 @@ AkonadiModel::AkonadiModel(ChangeRecorder* monitor, QObject* parent)
if (!mTextIcon)
{
mTextIcon = new QPixmap(SmallIcon("dialog-information"));
mFileIcon = new QPixmap(SmallIcon("document-open"));
mCommandIcon = new QPixmap(SmallIcon("system-run"));
mEmailIcon = new QPixmap(SmallIcon("mail-message-unread"));
mAudioIcon = new QPixmap(SmallIcon("audio-x-generic"));
mTextIcon = new QPixmap(SmallIcon(QLatin1String("dialog-information")));
mFileIcon = new QPixmap(SmallIcon(QLatin1String("document-open")));
mCommandIcon = new QPixmap(SmallIcon(QLatin1String("system-run")));
mEmailIcon = new QPixmap(SmallIcon(QLatin1String("mail-message-unread")));
mAudioIcon = new QPixmap(SmallIcon(QLatin1String("audio-x-generic")));
mIconSize = mTextIcon->size().expandedTo(mFileIcon->size()).expandedTo(mCommandIcon->size()).expandedTo(mEmailIcon->size()).expandedTo(mAudioIcon->size());
}
......@@ -370,7 +370,7 @@ QVariant AkonadiModel::data(const QModelIndex& index, int role) const
{
unsigned i = (event.actionTypes() == KAEvent::ACT_DISPLAY)
? event.bgColour().rgb() : 0;
return QString("%1").arg(i, 6, 10, QLatin1Char('0'));
return QString::fromLatin1("%1").arg(i, 6, 10, QLatin1Char('0'));
}
default:
break;
......@@ -400,7 +400,7 @@ QVariant AkonadiModel::data(const QModelIndex& index, int role) const
case ValueRole:
return static_cast<int>(event.actionSubType());
case SortRole:
return QString("%1").arg(event.actionSubType(), 2, 10, QLatin1Char('0'));
return QString::fromLatin1("%1").arg(event.actionSubType(), 2, 10, QLatin1Char('0'));
}
break;
case TextColumn:
......@@ -881,9 +881,9 @@ QString AkonadiModel::storageType(const Akonadi::Collection& collection) const
*/
QString AkonadiModel::tooltip(const Collection& collection, CalEvent::Types types) const
{
QString name = '@' + collection.displayName(); // insert markers for stripping out name
QString name = QLatin1Char('@') + collection.displayName(); // insert markers for stripping out name
KUrl url = collection.remoteId();
QString type = '@' + storageType(collection); // file/directory/URL etc.
QString type = QLatin1Char('@') + storageType(collection); // file/directory/URL etc.
QString locn = url.pathOrUrl();
bool inactive = !collection.hasAttribute<CollectionAttribute>()
|| !(collection.attribute<CollectionAttribute>()->enabled() & types);
......@@ -975,7 +975,7 @@ QString AkonadiModel::repeatOrder(const KAEvent& event) const
break;
}
}
return QString("%1%2").arg(static_cast<char>('0' + repeatOrder)).arg(repeatInterval, 8, 10, QLatin1Char('0'));
return QString::fromLatin1("%1%2").arg(static_cast<char>('0' + repeatOrder)).arg(repeatInterval, 8, 10, QLatin1Char('0'));
}
/******************************************************************************
......
......@@ -148,8 +148,8 @@ void AkonadiResourceCreator::agentInstanceCreated(KJob* j)
template <class Settings>
void AkonadiResourceCreator::setResourceAlarmType()
{
Settings iface("org.freedesktop.Akonadi.Resource." + mAgentInstance.identifier(),
"/Settings", QDBusConnection::sessionBus(), this);
Settings iface(QLatin1String("org.freedesktop.Akonadi.Resource.") + mAgentInstance.identifier(),
QLatin1String("/Settings"), QDBusConnection::sessionBus(), this);
if (!iface.isValid())
kError() << "Error creating D-Bus interface for" << mAgentInstance.identifier() << "resource configuration.";
else
......
......@@ -55,7 +55,7 @@ int main(int argc, char *argv[])
KCmdLineArgs::addCmdLineOptions(options);
AutostartApp app;
KGlobal::locale()->insertCatalog("kalarm");
KGlobal::locale()->insertCatalog(QLatin1String("kalarm"));
return app.exec();
}
......@@ -76,7 +76,7 @@ AutostartApp::AutostartApp()
void AutostartApp::slotAutostart()
{
QDBusReply<bool> reply = QDBusConnection::sessionBus().interface()->isServiceRegistered(KALARM_DBUS_SERVICE);
QDBusReply<bool> reply = QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String(KALARM_DBUS_SERVICE));
if (reply.isValid() && reply.value())
kDebug(5900) << "KAlarm already running";
else
......
......@@ -499,8 +499,8 @@ template <class Interface> bool CalendarMigrator::updateStorageFormat(const Agen
*/
template <class Interface> Interface* CalendarMigrator::getAgentInterface(const AgentInstance& agent, QString& errorMessage, QObject* parent)
{
Interface* iface = new Interface("org.freedesktop.Akonadi.Resource." + agent.identifier(),
"/Settings", QDBusConnection::sessionBus(), parent);
Interface* iface = new Interface(QLatin1String("org.freedesktop.Akonadi.Resource.") + agent.identifier(),
QLatin1String("/Settings"), QDBusConnection::sessionBus(), parent);
if (!iface->isValid())
{
errorMessage = iface->lastError().message();
......@@ -542,7 +542,7 @@ CalendarCreator::CalendarCreator(const QString& resourceType, const KConfigGroup
kError() << "Invalid resource type:" << resourceType;
return;
}
mPath = config.readPathEntry(pathKey, "");
mPath = config.readPathEntry(pathKey, QLatin1String(""));
switch (config.readEntry("AlarmType", (int)0))
{
case 1: mAlarmType = CalEvent::ACTIVE; break;
......@@ -755,7 +755,7 @@ void CalendarCreator::collectionFetchResult(KJob* j)
Collection collection = collections[0];
collection.setContentMimeTypes(CalEvent::mimeTypes(mAlarmType));
EntityDisplayAttribute* dattr = collection.attribute<EntityDisplayAttribute>(Collection::AddIfMissing);
dattr->setIconName("kalarm");
dattr->setIconName(QLatin1String("kalarm"));
CollectionAttribute* attr = collection.attribute<CollectionAttribute>(Entity::AddIfMissing);
attr->setEnabled(mEnabled ? mAlarmType : CalEvent::EMPTY);
if (mStandard)
......
......@@ -599,11 +599,11 @@ bool CollectionView::viewportEvent(QEvent* e)
if (qVariantCanConvert<QString>(value))
{
QString toolTip = value.toString();
int i = toolTip.indexOf('@');
int i = toolTip.indexOf(QLatin1Char('@'));
if (i > 0)
{
int j = toolTip.indexOf(QRegExp("<(nl|br)", Qt::CaseInsensitive), i + 1);
int k = toolTip.indexOf('@', j);
int j = toolTip.indexOf(QRegExp(QLatin1String("<(nl|br)"), Qt::CaseInsensitive), i + 1);
int k = toolTip.indexOf(QLatin1Char('@'), j);
QString name = toolTip.mid(i + 1, j - i - 1);
value = model()->data(index, Qt::FontRole);
QFontMetrics fm(qvariant_cast<QFont>(value).resolve(viewOptions().font));
......
......@@ -31,7 +31,7 @@
EventId::EventId(const QString& resourceEventId)
{
bool resourceOk = false;
QRegExp rx("^\\w+:");
QRegExp rx(QLatin1String("^\\w+:"));
if (rx.indexIn(resourceEventId) == 0)
{
// A resource ID has been supplied, so use it
......
......@@ -31,16 +31,16 @@
RtcWakeAction::RtcWakeAction()
{
KGlobal::locale()->insertCatalog("kalarm");
KGlobal::locale()->insertCatalog(QLatin1String("kalarm"));
}
ActionReply RtcWakeAction::settimer(const QVariantMap& args)
{
unsigned t = args["time"].toUInt();
unsigned t = args[QLatin1String("time")].toUInt();
qDebug() << "RtcWakeAction::settimer(" << t << ")";
// Find the rtcwake executable
QString exe("/usr/sbin/rtcwake"); // default location
QString exe(QLatin1String("/usr/sbin/rtcwake")); // default location
FILE* wh = popen("whereis -b rtcwake", "r");
if (wh)
{
......@@ -77,7 +77,7 @@ ActionReply RtcWakeAction::settimer(const QVariantMap& args)
// If 't' is zero, the current wakeup is cancelled by setting a new wakeup
// time 2 seconds from now, which will then expire.
unsigned now = KDateTime::currentUtcDateTime().toTime_t();
proc << exe << "-m" << "no" << "-s" << QString::number(t ? t - now : 2);
proc << exe << QLatin1String("-m") << QLatin1String("no") << QLatin1String("-s") << QString::number(t ? t - now : 2);
result = proc.execute(5000); // allow a timeout of 5 seconds
}
QString errmsg;
......@@ -86,10 +86,10 @@ ActionReply RtcWakeAction::settimer(const QVariantMap& args)
case 0:
return ActionReply::SuccessReply;
case -2:
errmsg = i18nc("@text/plain", "Could not run <command>%1</command> to set wake from suspend", "rtcwake");
errmsg = i18nc("@text/plain", "Could not run <command>%1</command> to set wake from suspend", QLatin1String("rtcwake"));
break;
default:
errmsg = i18nc("@text/plain", "Error setting wake from suspend.<nl/>Command was: <command>%1</command><nl/>Error code: %2.", proc.program().join(" "), result);
errmsg = i18nc("@text/plain", "Error setting wake from suspend.<nl/>Command was: <command>%1</command><nl/>Error code: %2.", proc.program().join(QLatin1String(" ")), result);
break;
}
ActionReply reply(ActionReply::HelperError);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment