AppMessages.h 1.05 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 16
#include <QObject>
#include <QStringListModel>
#include <QUrl>

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

22 23 24 25 26
class AppLogModel : public QStringListModel
{
    Q_OBJECT
public:
    Q_INVOKABLE void writeMessages(const QUrl dest_file);
27
    static void log(const QString message);
28 29

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

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

_LOG_CTOR_ACCESS_:
38 39 40
    AppLogModel();
};

41

42
class AppMessages
43 44 45
{
public:
    static void installHandler();
46
    static AppLogModel* getModel();
47
};