Commit 05de2a5c authored by Jan Kundrát's avatar Jan Kundrát
Browse files

Merge branch 'ascii'

REVIEW: 118648
parents 17919f6f 2ff305e1
......@@ -600,10 +600,12 @@ set_source_files_properties(${version_files}
HEADER_FILE_ONLY TRUE)
add_library(Common STATIC ${libCommon_SOURCES})
set_property(TARGET Common APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
add_dependencies(Common version)
target_link_libraries(Common ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
add_library(AppVersion STATIC ${libAppVersion_SOURCES})
set_property(TARGET AppVersion APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
add_dependencies(AppVersion version)
target_link_libraries(AppVersion Common ${QT_QTCORE_LIBRARY})
......@@ -614,6 +616,7 @@ else()
set_property(TARGET Plugins APPEND PROPERTY COMPILE_DEFINITIONS QT_STATICPLUGIN)
endif()
set_target_properties(Plugins PROPERTIES OUTPUT_NAME trojita_plugins)
set_property(TARGET Plugins APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
if(WITH_QT5)
qt5_use_modules(Plugins Core)
else()
......@@ -621,9 +624,11 @@ else()
endif()
add_library(UiUtils STATIC ${libUiUtils_SOURCES})
set_property(TARGET UiUtils APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
target_link_libraries(UiUtils Plugins ${QT_QTCORE_LIBRARY})
add_library(Streams STATIC ${libStreams_SOURCES})
set_property(TARGET Streams APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
target_link_libraries(Streams ${QT_QTNETWORK_LIBRARY} ${QT_QTCORE_LIBRARY})
if(WITH_ZLIB)
target_link_libraries(Streams ${ZLIB_LIBRARIES})
......@@ -633,15 +638,18 @@ add_library(qwwsmtpclient STATIC ${libqwwsmtpclient_SOURCES})
target_link_libraries(qwwsmtpclient ${QT_QTNETWORK_LIBRARY} ${QT_QTCORE_LIBRARY})
add_library(MSA STATIC ${libMSA_SOURCES})
set_property(TARGET MSA APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
target_link_libraries(MSA Imap Streams qwwsmtpclient ${QT_QTCORE_LIBRARY})
add_library(Composer STATIC ${libComposer_SOURCES})
set_property(TARGET Composer APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
target_link_libraries(Composer Common MSA Streams qwwsmtpclient ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
if(NOT WITH_QT5)
target_link_libraries(Composer MimetypesQt4)
endif()
add_library(Imap STATIC ${libImap_SOURCES})
set_property(TARGET Imap APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
target_link_libraries(Imap Common Streams UiUtils ${QT_QTNETWORK_LIBRARY} ${QT_QTSQL_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
if(WITH_ZLIB)
target_link_libraries(Imap ${ZLIB_LIBRARIES})
......@@ -701,9 +709,11 @@ if(WITH_DESKTOP)
endif()
add_library(AbookAddressbook STATIC ${libAbookAddressbook_SOURCES} ${libAbookAddressbook_UI_OUT})
set_property(TARGET AbookAddressbook APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
target_link_libraries(AbookAddressbook ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
add_library(DesktopGui STATIC ${libDesktopGui_SOURCES} ${libDesktopGui_UI_OUT} ${libDesktopGui_RESOURCES_OUT})
set_property(TARGET DesktopGui APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
# The following is needed for the LineEdit widget within the .ui files.
# The ${path_DesktopGui} is needed so that the generated ui_*.h file can find the headers of the custom widgets
if(SUPPORTS_TARGET_INCLUDES)
......@@ -714,6 +724,7 @@ if(WITH_DESKTOP)
# On Windows build a real Win32 GUI application without console window
# On other platforms WIN32 flag is ignored
add_executable(trojita WIN32 ${trojita_desktop_SOURCES} ${trojita_QM})
set_property(TARGET trojita APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
target_link_libraries(trojita AppVersion Common UiUtils DesktopGui ${STATIC_PLUGINS} ${QT_QTMAIN_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
if(NOT WITH_QT5)
target_link_libraries(trojita MimetypesQt4)
......@@ -723,10 +734,12 @@ if(WITH_DESKTOP)
endif()
add_executable(be.contacts ${be_contacts_SOURCES})
set_property(TARGET be.contacts APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
target_link_libraries(be.contacts AbookAddressbook ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
elseif(WITH_HARMATTAN)
add_library(trojitaqnamwebviewplugin SHARED ${libQNAMWebView_SOURCES})
add_executable(trojita-tp ${trojitaHarmattan_SOURCES})
set_property(TARGET trojita-tp APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
if(SUPPORTS_TARGET_INCLUDES)
set_property(TARGET trojita-tp APPEND PROPERTY INCLUDE_DIRECTORIES
${QT_MKSPECS_DIR}/default ${CMAKE_CURRENT_SOURCE_DIR}/src/Harmattan/qmlapplicationviewer)
......
......@@ -63,7 +63,7 @@ AbookAddressbook::AbookAddressbook(): m_updateTimer(0)
readAbook(false);
m_filesystemWatcher = new QFileSystemWatcher(this);
m_filesystemWatcher->addPath(QDir::homePath() + "/.abook/addressbook");
m_filesystemWatcher->addPath(QDir::homePath() + QLatin1String("/.abook/addressbook"));
connect (m_filesystemWatcher, SIGNAL(fileChanged(QString)), SLOT(scheduleAbookUpdate()));
}
......@@ -78,36 +78,36 @@ QStandardItemModel *AbookAddressbook::model() const
void AbookAddressbook::remonitorAdressbook()
{
m_filesystemWatcher->addPath(QDir::homePath() + "/.abook/addressbook");
m_filesystemWatcher->addPath(QDir::homePath() + QLatin1String("/.abook/addressbook"));
}
void AbookAddressbook::ensureAbookPath()
{
if (!QDir::home().exists(".abook")) {
QDir::home().mkdir(".abook");
if (!QDir::home().exists(QLatin1String(".abook"))) {
QDir::home().mkdir(QLatin1String(".abook"));
}
QDir abook(QDir::homePath() + "/.abook/");
QDir abook(QDir::homePath() + QLatin1String("/.abook/"));
QStringList abookrc;
QFile file(QDir::homePath() + "/.abook/abookrc");
QFile file(QDir::homePath() + QLatin1String("/.abook/abookrc"));
if (file.exists() && file.open(QIODevice::ReadWrite|QIODevice::Text)) {
abookrc = QString::fromLocal8Bit(file.readAll()).split('\n');
abookrc = QString::fromLocal8Bit(file.readAll()).split(QLatin1String("\n"));
bool havePhoto = false;
for (QStringList::iterator it = abookrc.begin(), end = abookrc.end(); it != end; ++it) {
if (it->contains("preserve_fields"))
*it = "set preserve_fields=all";
else if (it->contains("photo") && it->contains("field"))
if (it->contains(QLatin1String("preserve_fields")))
*it = QLatin1String("set preserve_fields=all");
else if (it->contains(QLatin1String("photo")) && it->contains(QLatin1String("field")))
havePhoto = true;
}
if (!havePhoto)
abookrc << "field photo = Photo";
abookrc << QLatin1String("field photo = Photo");
} else {
abookrc << "field photo = Photo" << "set preserve_fields=all";
abookrc << QLatin1String("field photo = Photo") << QLatin1String("set preserve_fields=all");
file.open(QIODevice::WriteOnly|QIODevice::Text);
}
if (file.isOpen()) {
if (file.isWritable()) {
file.seek(0);
file.write(abookrc.join("\n").toLocal8Bit());
file.write(abookrc.join(QLatin1String("\n")).toLocal8Bit());
}
file.close();
}
......@@ -132,14 +132,14 @@ void AbookAddressbook::updateAbook()
{
readAbook(true);
// QFileSystemWatcher will usually unhook from the file when it's re/written - the entire watcher ain't so great :-(
m_filesystemWatcher->addPath(QDir::homePath() + "/.abook/addressbook");
m_filesystemWatcher->addPath(QDir::homePath() + QLatin1String("/.abook/addressbook"));
}
void AbookAddressbook::readAbook(bool update)
{
// QElapsedTimer profile;
// profile.start();
QSettings abook(QDir::homePath() + "/.abook/addressbook", QSettings::IniFormat);
QSettings abook(QDir::homePath() + QLatin1String("/.abook/addressbook"), QSettings::IniFormat);
abook.setIniCodec("UTF-8");
QStringList contacts = abook.childGroups();
foreach (const QString &contact, contacts) {
......@@ -147,12 +147,12 @@ void AbookAddressbook::readAbook(bool update)
QStandardItem *item = 0;
QStringList mails;
if (update) {
QList<QStandardItem*> list = m_contacts->findItems(abook.value("name").toString());
QList<QStandardItem*> list = m_contacts->findItems(abook.value(QLatin1String("name")).toString());
if (list.count() == 1)
item = list.at(0);
else if (list.count() > 1) {
mails = abook.value("email", QString()).toStringList();
const QString mailString = mails.join("\n");
mails = abook.value(QLatin1String("email"), QString()).toStringList();
const QString mailString = mails.join(QLatin1String("\n"));
foreach (QStandardItem *it, list) {
if (it->data(Mail).toString() == mailString) {
item = it;
......@@ -182,7 +182,7 @@ void AbookAddressbook::readAbook(bool update)
else if (field->first == Mail) {
if (mails.isEmpty())
mails = abook.value(field->second, QString()).toStringList(); // to fix the name field
item->setData( mails.join("\n"), Mail );
item->setData( mails.join(QLatin1String("\n")), Mail );
}
else
item->setData( abook.value(field->second, QString()), field->first );
......@@ -210,7 +210,7 @@ void AbookAddressbook::readAbook(bool update)
void AbookAddressbook::saveContacts()
{
m_filesystemWatcher->blockSignals(true);
QSettings abook(QDir::homePath() + "/.abook/addressbook", QSettings::IniFormat);
QSettings abook(QDir::homePath() + QLatin1String("/.abook/addressbook"), QSettings::IniFormat);
abook.setIniCodec("UTF-8");
abook.clear();
for (int i = 0; i < m_contacts->rowCount(); ++i) {
......@@ -219,7 +219,7 @@ void AbookAddressbook::saveContacts()
for (QList<QPair<Type,QString> >::const_iterator it = m_fields.constBegin(),
end = m_fields.constEnd(); it != end; ++it) {
if (it->first == Mail)
abook.setValue("email", item->data(Mail).toString().split('\n'));
abook.setValue(QLatin1String("email"), item->data(Mail).toString().split(QLatin1String("\n")));
else {
const QVariant v = item->data(it->first);
if (!v.toString().isEmpty())
......
......@@ -74,7 +74,7 @@ public:
BE::Contacts::Contacts(Gui::AbookAddressbook *abook): m_abook(abook), m_dirty(false)
{
m_currentContact = 0;
QImage img(QDir::homePath() + "/.abook/incognito.png");
QImage img(QDir::homePath() + QLatin1String("/.abook/incognito.png"));
if (!img.isNull())
m_incognitoPic = QPixmap::fromImage(img.scaled(160,160,Qt::KeepAspectRatio,Qt::SmoothTransformation));
m_ui = new Ui::Contacts;
......@@ -85,14 +85,14 @@ BE::Contacts::Contacts(Gui::AbookAddressbook *abook): m_abook(abook), m_dirty(fa
m_ui2 = new Ui::OneContact;
m_ui2->setupUi(m_ui->oneContact);
fields << Field(Gui::AbookAddressbook::Name, m_ui2->name, "name") << Field(Gui::AbookAddressbook::Mail, m_ui2->mail, "email") <<
Field(Gui::AbookAddressbook::Address, m_ui2->address, "address") << Field(Gui::AbookAddressbook::City, m_ui2->city, "city") <<
Field(Gui::AbookAddressbook::State, m_ui2->state, "state") << Field(Gui::AbookAddressbook::ZIP, m_ui2->zip, "zip") <<
Field(Gui::AbookAddressbook::Country, m_ui2->country, "country") << Field(Gui::AbookAddressbook::Phone, m_ui2->phone, "phone") <<
Field(Gui::AbookAddressbook::Workphone, m_ui2->workphone, "workphone") << Field(Gui::AbookAddressbook::Fax, m_ui2->fax, "fax") <<
Field(Gui::AbookAddressbook::Mobile, m_ui2->mobile, "mobile") << Field(Gui::AbookAddressbook::Nick, m_ui2->nick, "nick") <<
Field(Gui::AbookAddressbook::URL, m_ui2->url, "url") << Field(Gui::AbookAddressbook::Notes, m_ui2->notes, "notes") <<
Field(Gui::AbookAddressbook::Anniversary, m_ui2->anniversary, "anniversary") << Field(Gui::AbookAddressbook::Photo, m_ui2->photo, "photo");
fields << Field(Gui::AbookAddressbook::Name, m_ui2->name, QLatin1String("name")) << Field(Gui::AbookAddressbook::Mail, m_ui2->mail, QLatin1String("email")) <<
Field(Gui::AbookAddressbook::Address, m_ui2->address, QLatin1String("address")) << Field(Gui::AbookAddressbook::City, m_ui2->city, QLatin1String("city")) <<
Field(Gui::AbookAddressbook::State, m_ui2->state, QLatin1String("state")) << Field(Gui::AbookAddressbook::ZIP, m_ui2->zip, QLatin1String("zip")) <<
Field(Gui::AbookAddressbook::Country, m_ui2->country, QLatin1String("country")) << Field(Gui::AbookAddressbook::Phone, m_ui2->phone, QLatin1String("phone")) <<
Field(Gui::AbookAddressbook::Workphone, m_ui2->workphone, QLatin1String("workphone")) << Field(Gui::AbookAddressbook::Fax, m_ui2->fax, QLatin1String("fax")) <<
Field(Gui::AbookAddressbook::Mobile, m_ui2->mobile, QLatin1String("mobile")) << Field(Gui::AbookAddressbook::Nick, m_ui2->nick, QLatin1String("nick")) <<
Field(Gui::AbookAddressbook::URL, m_ui2->url, QLatin1String("url")) << Field(Gui::AbookAddressbook::Notes, m_ui2->notes, QLatin1String("notes")) <<
Field(Gui::AbookAddressbook::Anniversary, m_ui2->anniversary, QLatin1String("anniversary")) << Field(Gui::AbookAddressbook::Photo, m_ui2->photo, QLatin1String("photo"));
m_sortFilterProxy = new QSortFilterProxyModel(this);
m_sortFilterProxy->setFilterCaseSensitivity(Qt::CaseInsensitive);
......@@ -158,7 +158,7 @@ static void setText(QLabel *l, const QString &text)
{
if (QTextDocument *t = l->findChild<QTextDocument*>())
t->setPlainText(text);
l->setText("");
l->setText(QString());
l->setText(text);
}
......@@ -245,9 +245,9 @@ void BE::Contacts::importPhoto(const QString &path)
#else
QDateTime::currentMSecsSinceEpoch()
#endif
) + "." + QFileInfo(path).suffix();
) + QLatin1Char('.') + QFileInfo(path).suffix();
const QString file = QDir::homePath() + "/.abook/" + photo;
const QString file = QDir::homePath() + QLatin1String("/.abook/") + photo;
if (QFile::copy(path, file)) {
m_currentContact->setData(photo, Gui::AbookAddressbook::Photo);
setPhoto(file);
......@@ -257,12 +257,12 @@ void BE::Contacts::importPhoto(const QString &path)
void BE::Contacts::addContact()
{
m_dirty = true;
QStandardItem *item = new QStandardItem("[New Contact]");
QStandardItem *item = new QStandardItem(tr("[New Contact]"));
for (QList<Field>::const_iterator it = fields.constBegin(),
end = fields.constEnd(); it != end; ++it) {
if (it->type == Gui::AbookAddressbook::Name || it->type == Gui::AbookAddressbook::Photo)
continue;
item->setData( "[" + it->key + "]", it->type );
item->setData( QLatin1Char('[') + it->key + QLatin1Char(']'), it->type );
}
if (m_currentContact)
m_abook->model()->insertRow(m_currentContact->index().row() + 1, item);
......@@ -295,7 +295,7 @@ void BE::Contacts::setContact(const QModelIndex &index)
end = fields.constEnd(); it != end; ++it) {
if (it->type != Gui::AbookAddressbook::Photo) {
QString s = lifeText(it->label);
if (s.startsWith("["))
if (s.startsWith(QLatin1String("[")))
s.clear();
if (m_currentContact->data(it->type).toString() != s) {
m_currentContact->setData( true, Gui::AbookAddressbook::Dirty );
......@@ -321,7 +321,7 @@ void BE::Contacts::setContact(const QModelIndex &index)
if (v.isValid())
s = v.toString();
else
s = "[" + it->key + "]";
s = QLatin1Char('[') + it->key + QLatin1Char(']');
setText(it->label, s);
}
}
......@@ -329,7 +329,7 @@ void BE::Contacts::setContact(const QModelIndex &index)
QString photo = m_currentContact->data(Gui::AbookAddressbook::Photo).toString();
if (!photo.isEmpty()) {
if (QDir::isRelativePath(photo))
photo = QDir::homePath() + "/.abook/" + photo;
photo = QDir::homePath() + QLatin1String("/.abook/") + photo;
if (QFile::exists(photo) && setPhoto(photo))
return;
}
......@@ -438,6 +438,6 @@ void BE::Contacts::manageContact(const QString &mail, const QString &prettyName)
m_ui2->name->setText(prettyName);
m_currentContact->setText(prettyName);
} else {
m_ui2->name->setText("[name]");
m_ui2->name->setText(tr("[name]"));
}
}
......@@ -61,8 +61,8 @@ FileLogger::~FileLogger()
void FileLogger::escapeCrLf(QString &s)
{
s.replace(QChar('\r'), 0x240d /* SYMBOL FOR CARRIAGE RETURN */)
.replace(QChar('\n'), 0x240a /* SYMBOL FOR LINE FEED */);
s.replace(QLatin1Char('\r'), 0x240d /* SYMBOL FOR CARRIAGE RETURN */)
.replace(QLatin1Char('\n'), 0x240a /* SYMBOL FOR LINE FEED */);
}
void FileLogger::slotImapLogged(uint parser, Common::LogMessage message)
......
......@@ -306,10 +306,9 @@ AttachmentItem::ContentTransferEncoding ImapMessageAttachmentItem::suggestedCTE(
QByteArray ImapMessageAttachmentItem::imapUrl() const
{
return QString::fromUtf8("/%1;UIDVALIDITY=%2/;UID=%3").arg(
QUrl::toPercentEncoding(index.data(RoleMailboxName).toString().toUtf8()),
index.data(RoleMailboxUidValidity).toString(),
index.data(RoleMessageUid).toString()).toUtf8();
return "/" + QUrl::toPercentEncoding(index.data(RoleMailboxName).toString())
+ ";UIDVALIDITY=" + index.data(RoleMailboxUidValidity).toByteArray()
+ "/;UID=" + index.data(RoleMessageUid).toByteArray();
}
void ImapMessageAttachmentItem::preload() const
......@@ -325,7 +324,7 @@ void ImapMessageAttachmentItem::asDroppableMimeData(QDataStream &stream) const
ImapPartAttachmentItem::ImapPartAttachmentItem(Model *model, const QString &mailbox, const uint uidValidity, const uint uid,
const QString &trojitaPath)
const QByteArray &trojitaPath)
{
TreeItemMailbox *mboxPtr = model->findMailboxByName(mailbox);
if (!mboxPtr)
......@@ -423,11 +422,10 @@ bool ImapPartAttachmentItem::isAvailableLocally() const
QByteArray ImapPartAttachmentItem::imapUrl() const
{
Q_ASSERT(index.isValid());
return QString::fromUtf8("/%1;UIDVALIDITY=%2/;UID=%3/;SECTION=%4").arg(
QUrl::toPercentEncoding(index.data(RoleMailboxName).toString().toUtf8()),
index.data(RoleMailboxUidValidity).toString(),
index.data(RoleMessageUid).toString(),
index.data(RolePartId).toString()).toUtf8();
return "/" + QUrl::toPercentEncoding(index.data(RoleMailboxName).toString())
+ ";UIDVALIDITY=" + index.data(RoleMailboxUidValidity).toByteArray()
+ "/;UID=" + index.data(RoleMessageUid).toByteArray()
+ "/;SECTION=" + index.data(RolePartId).toByteArray();
}
void ImapPartAttachmentItem::preload() const
......
......@@ -131,7 +131,7 @@ private:
/** @short Part of a message stored in an IMAP server */
class ImapPartAttachmentItem: public AttachmentItem {
public:
ImapPartAttachmentItem(Imap::Mailbox::Model *model, const QString &mailbox, const uint uidValidity, const uint uid, const QString &trojitaPath);
ImapPartAttachmentItem(Imap::Mailbox::Model *model, const QString &mailbox, const uint uidValidity, const uint uid, const QByteArray &trojitaPath);
~ImapPartAttachmentItem();
virtual QString caption() const;
......
......@@ -75,7 +75,7 @@ QVariant MessageComposer::data(const QModelIndex &index, int role) const
{
// This is more or less copy-pasted from Gui/AttachmentView.cpp. Unfortunately, sharing the implementation
// is not trivial due to the way how the static libraries are currently built.
QMimeType mimeType = QMimeDatabase().mimeTypeForName(m_attachments[index.row()]->mimeType());
QMimeType mimeType = QMimeDatabase().mimeTypeForName(QString::fromUtf8(m_attachments[index.row()]->mimeType()));
if (mimeType.isValid() && !mimeType.isDefault()) {
return QIcon::fromTheme(mimeType.iconName(), Gui::loadIcon(QLatin1String("mail-attachment")));
} else {
......@@ -242,7 +242,7 @@ bool MessageComposer::dropAttachmentList(QDataStream &stream)
QString mailbox;
uint uidValidity;
uint uid;
QString trojitaPath;
QByteArray trojitaPath;
if (!validateDropImapPart(stream, mailbox, uidValidity, uid, trojitaPath))
return false;
try {
......@@ -347,7 +347,7 @@ bool MessageComposer::dropImapMessage(QDataStream &stream)
}
/** @short Check that the data representing a single message part are correct */
bool MessageComposer::validateDropImapPart(QDataStream &stream, QString &mailbox, uint &uidValidity, uint &uid, QString &trojitaPath) const
bool MessageComposer::validateDropImapPart(QDataStream &stream, QString &mailbox, uint &uidValidity, uint &uid, QByteArray &trojitaPath) const
{
stream >> mailbox >> uidValidity >> uid >> trojitaPath;
if (stream.status() != QDataStream::Ok) {
......@@ -378,7 +378,7 @@ bool MessageComposer::dropImapPart(QDataStream &stream)
QString mailbox;
uint uidValidity;
uint uid;
QString trojitaPath;
QByteArray trojitaPath;
if (!validateDropImapPart(stream, mailbox, uidValidity, uid, trojitaPath))
return false;
if (!stream.atEnd()) {
......@@ -548,21 +548,19 @@ void MessageComposer::writeCommonMessageBeginning(QIODevice *target, const QByte
target->write(recipientHeaders);
// Other message metadata
target->write(encodeHeaderField(QLatin1String("Subject: ") + m_subject).append("\r\n").
append("Date: ").append(Imap::dateTimeToRfc2822(m_timestamp)).append("\r\n").
append("User-Agent: ").append(
QString::fromUtf8("Trojita/%1; %2")
.arg(Common::Application::version, Imap::Mailbox::systemPlatformVersion()).toUtf8()
).append("\r\n").
append("MIME-Version: 1.0\r\n"));
target->write(encodeHeaderField(QLatin1String("Subject: ") + m_subject) + "\r\n" +
"Date: " + Imap::dateTimeToRfc2822(m_timestamp).toUtf8() + "\r\n" +
QString::fromUtf8("User-Agent: Trojita/%1; %2\r\n").arg(
Common::Application::version, Imap::Mailbox::systemPlatformVersion()).toUtf8() +
"MIME-Version: 1.0\r\n");
QByteArray messageId = generateMessageId(m_from);
if (!messageId.isEmpty()) {
target->write(QByteArray("Message-ID: <").append(messageId).append(">\r\n"));
target->write("Message-ID: <" + messageId + ">\r\n");
}
writeHeaderWithMsgIds(target, QByteArray("In-Reply-To"), m_inReplyTo);
writeHeaderWithMsgIds(target, QByteArray("References"), m_references);
writeHeaderWithMsgIds(target, "In-Reply-To", m_inReplyTo);
writeHeaderWithMsgIds(target, "References", m_references);
if (!m_organization.isEmpty()) {
target->write(encodeHeaderField(QLatin1String("Organization: ") + m_organization).append("\r\n"));
target->write(encodeHeaderField(QLatin1String("Organization: ") + m_organization) + "\r\n");
}
// Headers depending on actual message body data
......
......@@ -98,7 +98,7 @@ private:
void writeHeaderWithMsgIds(QIODevice *target, const QByteArray &headerName, const QList<QByteArray> &messageIds) const;
bool validateDropImapMessage(QDataStream &stream, QString &mailbox, uint &uidValidity, QList<uint> &uids) const;
bool validateDropImapPart(QDataStream &stream, QString &mailbox, uint &uidValidity, uint &uid, QString &trojitaPath) const;
bool validateDropImapPart(QDataStream &stream, QString &mailbox, uint &uidValidity, uint &uid, QByteArray &trojitaPath) const;
bool dropImapMessage(QDataStream &stream);
bool dropImapPart(QDataStream &stream);
bool dropAttachmentList(QDataStream &stream);
......
......@@ -41,9 +41,9 @@ QString helperHtmlifySingleLine(QString line)
{
// Static regexps for the engine construction.
// Warning, these operate on the *escaped* HTML!
static QString intro("(^|[\\s\\(\\[\\{])");
static QString extro("($|[\\s\\),;.\\]\\}])");
static const QRegExp patternRe(
#define HTML_RE_INTRO "(^|[\\s\\(\\[\\{])"
#define HTML_RE_EXTRO "($|[\\s\\),;.\\]\\}])"
static const QRegExp patternRe(QLatin1String(
// hyperlinks
"(" // cap(1)
"https?://" // scheme prefix
......@@ -59,16 +59,16 @@ QString helperHtmlifySingleLine(QString line)
// formatting markup
"(" // cap(3)
// bold text
+ intro /* cap(4) */ + "\\*((?!\\*)\\S+)\\*" /* cap(5) */ + extro /* cap(6) */
+ "|"
HTML_RE_INTRO /* cap(4) */ "\\*((?!\\*)\\S+)\\*" /* cap(5) */ HTML_RE_EXTRO /* cap(6) */
"|"
// italics
+ intro /* cap(7) */ + "/((?!/)\\S+)/" /* cap(8) */ + extro /* cap(9) */
+ "|"
HTML_RE_INTRO /* cap(7) */ "/((?!/)\\S+)/" /* cap(8) */ HTML_RE_EXTRO /* cap(9) */
"|"
// underline
+ intro /* cap(10) */ + "_((?!_)\\S+)_" /* cap(11) */ + extro /* cap(12) */
+ ")"
HTML_RE_INTRO /* cap(10) */ "_((?!_)\\S+)_" /* cap(11) */ HTML_RE_EXTRO /* cap(12) */
")"
// end of the formatting markup
, Qt::CaseSensitive, QRegExp::RegExp2
), Qt::CaseSensitive, QRegExp::RegExp2
);
// RE instances to work on
......@@ -158,7 +158,7 @@ QString firstNLines(const QString &input, int numLines, const int charsPerLine)
/** @short Helper for closing blockquotes and adding the interactive control elements at the right places */
void closeQuotesUpTo(QStringList &markup, QStack<QPair<int, int> > &controlStack, int &quoteLevel, const int finalQuoteLevel)
{
static QString closingLabel("<label for=\"q%1\"></label>");
static QString closingLabel(QLatin1String("<label for=\"q%1\"></label>"));
static QLatin1String closeSingleQuote("</blockquote>");
static QLatin1String closeQuoteBlock("</span></span>");
......@@ -197,7 +197,7 @@ struct TextInfo {
QString plainTextToHtml(const QString &plaintext, const FlowedFormat flowed)
{
static QRegExp quotemarks("^>[>\\s]*");
static QRegExp quotemarks(QLatin1String("^>[>\\s]*"));
const int SIGNATURE_SEPARATOR = -2;
QList<TextInfo> lineBuffer;
......@@ -205,7 +205,7 @@ QString plainTextToHtml(const QString &plaintext, const FlowedFormat flowed)
// First pass: determine the quote level for each source line.
// The quote level is ignored for the signature.
bool signatureSeparatorSeen = false;
Q_FOREACH(QString line, plaintext.split('\n')) {
Q_FOREACH(QString line, plaintext.split(QLatin1Char('\n'))) {
// Fast path for empty lines
if (line.isEmpty()) {
......@@ -222,11 +222,11 @@ QString plainTextToHtml(const QString &plaintext, const FlowedFormat flowed)
// Determine the quoting level
int quoteLevel = 0;
if (!signatureSeparatorSeen && line.at(0) == '>') {
if (!signatureSeparatorSeen && line.at(0) == QLatin1Char('>')) {
int j = 1;
quoteLevel = 1;
while (j < line.length() && (line.at(j) == '>' || line.at(j) == ' '))
quoteLevel += line.at(j++) == '>';
while (j < line.length() && (line.at(j) == QLatin1Char('>') || line.at(j) == QLatin1Char(' ')))
quoteLevel += line.at(j++) == QLatin1Char('>');
}
lineBuffer << TextInfo(quoteLevel, line);
......@@ -523,10 +523,10 @@ QStringList quoteText(QStringList inputLines)
// rewrap - we need to keep the quotes at < 79 chars, yet the grow with every level
if (line->length() < 79-2) {
// this line is short enough, prepend quote mark and continue
if (line->isEmpty() || line->at(0) == '>')
line->prepend(">");
if (line->isEmpty() || line->at(0) == QLatin1Char('>'))
line->prepend(QLatin1Char('>'));
else
line->prepend("> ");
line->prepend(QLatin1String("> "));
quote << *line;
continue;
}
......@@ -534,25 +534,25 @@ QStringList quoteText(QStringList inputLines)
// 1st, detect the quote depth and eventually stript the quotes from the line
int quoteLevel = 0;
int contentStart = 0;
if (line->at(0) == '>') {
if (line->at(0) == QLatin1Char('>')) {
quoteLevel = 1;
while (quoteLevel < line->length() && line->at(quoteLevel) == '>')
while (quoteLevel < line->length() && line->at(quoteLevel) == QLatin1Char('>'))
++quoteLevel;
contentStart = quoteLevel;
if (quoteLevel < line->length() && line->at(quoteLevel) == ' ')
if (quoteLevel < line->length() && line->at(quoteLevel) == QLatin1Char(' '))
++contentStart;
}
// 2nd, build a quote string
QString quotemarks;
for (int i = 0; i < quoteLevel; ++i)
quotemarks += ">";
quotemarks += "> ";
quotemarks += QLatin1Char('>');
quotemarks += QLatin1String("> ");
// 3rd, wrap the line, prepend the quotemarks to each line and add it to the quote text
int space(contentStart), lastSpace(contentStart), pos(contentStart), length(0);
while (pos < line->length()) {
if (line->at(pos) == ' ')
if (line->at(pos) == QLatin1Char(' '))
space = pos+1;
++length;
if (length > 65-quotemarks.length() && space != lastSpace) {
......
......@@ -242,7 +242,7 @@ void EmbeddedWebView::findScrollParent()
}
QWidget *p = runner->parentWidget();
if (p && qobject_cast<MessageView*>(runner) && // is this a MessageView?
p->objectName() == "qt_scrollarea_viewport" && // in a viewport?
p->objectName() == QLatin1String("qt_scrollarea_viewport") && // in a viewport?
qobject_cast<QAbstractScrollArea*>(p->parentWidget())) { // that is used?
p->getContentsMargins(&left, &top, &right, &bottom);
m_scrollParentPadding += left + right + 4;
......
......@@ -46,9 +46,9 @@ void LineEdit::init()
connect(this, SIGNAL(textChanged(QString)), this, SLOT(updateClearButton(QString)));
const int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
m_clearButton->setStyleSheet(QString("QToolButton { border: none; padding-left: 1px; padding-top: %1px; padding-bottom: %1px; padding-right: %1px; }")
m_clearButton->setStyleSheet(QString::fromUtf8("QToolButton { border: none; padding-left: 1px; padding-top: %1px; padding-bottom: %1px; padding-right: %1px; }")
.arg(frameWidth + 1));