fix(app): coding style

This commit is contained in:
Ronan Abhamon 2016-12-19 14:54:32 +01:00
parent 7a3d0f2c02
commit 2df59f19ee
10 changed files with 49 additions and 43 deletions

View file

@ -58,7 +58,7 @@ App::App (int &argc, char **argv) : QApplication(argc, argv) {
m_engine.addImportPath(":/ui/views"); m_engine.addImportPath(":/ui/views");
} }
// ------------------------------------------------------------------- // -----------------------------------------------------------------------------
void App::initContentApp () { void App::initContentApp () {
qInfo() << "Initializing core manager..."; qInfo() << "Initializing core manager...";

View file

@ -11,7 +11,7 @@
class Notifier; class Notifier;
// =================================================================== // =============================================================================
class App : public QApplication { class App : public QApplication {
Q_OBJECT; Q_OBJECT;

View file

@ -1,11 +1,9 @@
#include <QtDebug>
#include "Database.hpp" #include "Database.hpp"
#include "../utils.hpp" #include "../utils.hpp"
#include "AvatarProvider.hpp" #include "AvatarProvider.hpp"
// =================================================================== // =============================================================================
const QString AvatarProvider::PROVIDER_ID = "avatar"; const QString AvatarProvider::PROVIDER_ID = "avatar";

View file

@ -3,7 +3,7 @@
#include <QQuickImageProvider> #include <QQuickImageProvider>
// =================================================================== // =============================================================================
class AvatarProvider : public QQuickImageProvider { class AvatarProvider : public QQuickImageProvider {
public: public:
@ -17,6 +17,7 @@ public:
) override; ) override;
static const QString PROVIDER_ID; static const QString PROVIDER_ID;
private: private:
QString m_avatars_path; QString m_avatars_path;
}; };

View file

@ -7,12 +7,12 @@
#include "Database.hpp" #include "Database.hpp"
#ifdef _WIN32 #ifdef _WIN32
#define DATABASES_PATH \ #define DATABASES_PATH \
QStandardPaths::writableLocation(QStandardPaths::DataLocation) QStandardPaths::writableLocation(QStandardPaths::DataLocation)
#else #else
#define DATABASES_PATH \ #define DATABASES_PATH \
QStandardPaths::writableLocation(QStandardPaths::HomeLocation) QStandardPaths::writableLocation(QStandardPaths::HomeLocation)
#endif #endif // ifdef _WIN32
#define DATABASE_PATH_AVATARS ".linphone/avatars/" #define DATABASE_PATH_AVATARS ".linphone/avatars/"
#define DATABASE_PATH_CALL_HISTORY_LIST ".linphone-call-history.db" #define DATABASE_PATH_CALL_HISTORY_LIST ".linphone-call-history.db"
@ -21,7 +21,7 @@
using namespace std; using namespace std;
// =================================================================== // =============================================================================
inline bool ensureDatabaseFilePathExists (const QString &path) { inline bool ensureDatabaseFilePathExists (const QString &path) {
QDir dir(DATABASES_PATH); QDir dir(DATABASES_PATH);
@ -47,9 +47,9 @@ string Database::getAvatarsPath () {
inline string getDatabaseFilePath (const QString &filename) { inline string getDatabaseFilePath (const QString &filename) {
QString path(DATABASES_PATH + "/"); QString path(DATABASES_PATH + "/");
path += filename; path += filename;
return ensureDatabaseFilePathExists(path) return ensureDatabaseFilePathExists(path) ? Utils::qStringToLinphoneString(
? Utils::qStringToLinphoneString(QDir::toNativeSeparators(path)) QDir::toNativeSeparators(path)
: ""; ) : "";
} }
string Database::getCallHistoryPath () { string Database::getCallHistoryPath () {

View file

@ -3,7 +3,7 @@
#include <string> #include <string>
// =================================================================== // =============================================================================
namespace Database { namespace Database {
// Returns the databases paths. // Returns the databases paths.
@ -14,6 +14,6 @@ namespace Database {
std::string getCallHistoryPath (); std::string getCallHistoryPath ();
std::string getFriendsListPath (); std::string getFriendsListPath ();
std::string getMessageHistoryPath (); std::string getMessageHistoryPath ();
}; }
#endif // DATABASE_H_ #endif // DATABASE_H_

View file

@ -3,7 +3,7 @@
#include "DefaultTranslator.hpp" #include "DefaultTranslator.hpp"
// =================================================================== // =============================================================================
DefaultTranslator::DefaultTranslator () { DefaultTranslator::DefaultTranslator () {
QDirIterator it(":", QDirIterator::Subdirectories); QDirIterator it(":", QDirIterator::Subdirectories);

View file

@ -4,7 +4,7 @@
#include <QSet> #include <QSet>
#include <QTranslator> #include <QTranslator>
// =================================================================== // =============================================================================
class DefaultTranslator : public QTranslator { class DefaultTranslator : public QTranslator {
public: public:
@ -22,4 +22,4 @@ private:
QSet<QString> m_contexts; QSet<QString> m_contexts;
}; };
#endif #endif // DEFAULT_TRANSLATOR_H_

View file

@ -14,9 +14,9 @@
#define PURPLE "" #define PURPLE ""
#define RED "" #define RED ""
#define RESET "" #define RESET ""
#endif #endif // ifdef __linux__
// =================================================================== // =============================================================================
void logger (QtMsgType type, const QMessageLogContext &context, const QString &msg) { void logger (QtMsgType type, const QMessageLogContext &context, const QString &msg) {
QByteArray local_msg = msg.toLocal8Bit(); QByteArray local_msg = msg.toLocal8Bit();
@ -31,26 +31,31 @@ void logger (QtMsgType type, const QMessageLogContext &context, const QString &m
context_line = context.line; context_line = context.line;
} }
switch (type) { if (type == QtDebugMsg)
case QtDebugMsg: fprintf(
fprintf(stderr, GREEN "[%s][Debug]" PURPLE "%s:%u: " RESET "%s\n", stderr, GREEN "[%s][Debug]" PURPLE "%s:%u: " RESET "%s\n",
date_time.constData(), context_file, context_line, local_msg.constData()); date_time.constData(), context_file, context_line, local_msg.constData()
break; );
case QtInfoMsg: else if (type == QtInfoMsg)
fprintf(stderr, BLUE "[%s][Info]" PURPLE "%s:%u: " RESET "%s\n", fprintf(
date_time.constData(), context_file, context_line, local_msg.constData()); stderr, BLUE "[%s][Info]" PURPLE "%s:%u: " RESET "%s\n",
break; date_time.constData(), context_file, context_line, local_msg.constData()
case QtWarningMsg: );
fprintf(stderr, RED "[%s][Warning]" PURPLE "%s:%u: " RESET "%s\n", else if (type == QtWarningMsg)
date_time.constData(), context_file, context_line, local_msg.constData()); fprintf(
break; stderr, RED "[%s][Warning]" PURPLE "%s:%u: " RESET "%s\n",
case QtCriticalMsg: date_time.constData(), context_file, context_line, local_msg.constData()
fprintf(stderr, RED "[%s][Critical]" PURPLE "%s:%u: " RESET "%s\n", );
date_time.constData(), context_file, context_line, local_msg.constData()); else if (type == QtCriticalMsg)
break; fprintf(
case QtFatalMsg: stderr, RED "[%s][Critical]" PURPLE "%s:%u: " RESET "%s\n",
fprintf(stderr, RED "[%s][Fatal]" PURPLE "%s:%u: " RESET "%s\n", date_time.constData(), context_file, context_line, local_msg.constData()
date_time.constData(), context_file, context_line, local_msg.constData()); );
else if (type == QtFatalMsg) {
fprintf(
stderr, RED "[%s][Fatal]" PURPLE "%s:%u: " RESET "%s\n",
date_time.constData(), context_file, context_line, local_msg.constData()
);
abort(); abort();
} }
} }

View file

@ -3,6 +3,8 @@
#include <QtGlobal> #include <QtGlobal>
// =============================================================================
void logger (QtMsgType type, const QMessageLogContext &context, const QString &msg); void logger (QtMsgType type, const QMessageLogContext &context, const QString &msg);
#endif // LOGGER_H_ #endif // LOGGER_H_