AppMessages.h 1.1 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
9 10 11 12


#pragma once

13 14 15
#include <QObject>
#include <QStringListModel>
#include <QUrl>
16
#include <QFile>
17

18 19 20 21 22
// Hackish way to force only this translation unit to have public ctor access
#ifndef _LOG_CTOR_ACCESS_
#define _LOG_CTOR_ACCESS_ private
#endif

23 24 25 26
class AppLogModel : public QStringListModel
{
    Q_OBJECT
public:
DonLakeFlyer's avatar
DonLakeFlyer committed
27
    Q_INVOKABLE void writeMessages(const QString dest_file);
28
    static void log(const QString message);
29 30

signals:
31
    void emitLog(const QString message);
32 33 34
    void writeStarted();
    void writeFinished(bool success);

35 36 37
private slots:
    void threadsafeLog(const QString message);

38 39 40
private:
    QFile _logFile;

41
_LOG_CTOR_ACCESS_:
42 43 44
    AppLogModel();
};

45

46
class AppMessages
47 48 49
{
public:
    static void installHandler();
50
    static AppLogModel* getModel();
51
};