Commit 1d289809 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(app/DefaultTranslator): check linphone contexts

parent e689cb46
......@@ -38,6 +38,7 @@ public slots:
private:
App (int &argc, char **argv);
~App () = default;
void initContentApp ();
......
#include <QDirIterator>
#include <QtDebug>
#include "DefaultTranslator.hpp"
// ===================================================================
DefaultTranslator::DefaultTranslator () {
QDirIterator it(":", QDirIterator::Subdirectories);
while (it.hasNext()) {
QFileInfo info(it.next());
if (info.suffix() == "qml") {
QString basename = info.baseName();
if (m_contexts.contains(basename))
qWarning() << QStringLiteral("QML file `%1` already exists in context list.").arg(basename);
else
m_contexts << basename;
}
}
}
QString DefaultTranslator::translate (
const char *context,
const char *source_text,
const char *disambiguation,
int n
) const {
if (!m_contexts.contains(context))
return "";
QString translation = QTranslator::translate(context, source_text, disambiguation, n);
if (translation.length() == 0)
......
#ifndef DEFAULT_TRANSLATOR_H_
#define DEFAULT_TRANSLATOR_H_
#include <QSet>
#include <QTranslator>
// ===================================================================
class DefaultTranslator : public QTranslator {
public:
DefaultTranslator ();
~DefaultTranslator () = default;
QString translate (
const char *context,
const char *source_text,
const char *disambiguation = Q_NULLPTR,
int n = -1
) const override;
private:
QSet<QString> m_contexts;
};
#endif
#include <algorithm>
#include <QDateTime>
#include <QSet>
#include <linphone++/linphone.hh>
#include "../../utils.hpp"
......@@ -89,17 +90,17 @@ void TimelineModel::init_entries () {
}
// Insert calls events.
QHash<QString, bool> address_done;
QSet<QString> address_done;
for (const auto &call_log : core->getCallLogs()) {
// Get a sip uri to check.
QString address = Utils::linphoneStringToQString(
call_log->getRemoteAddress()->asString()
);
if (address_done.value(address))
if (address_done.contains(address))
continue; // Already used.
address_done[address] = true;
address_done << address;
// Make a new map.
QVariantMap map;
......
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