24 : QAbstractListModel( parent )
29 QgsQuickMessageLogModel::LogMessage QgsQuickMessageLogModel::logMessage(
const QString &tag,
const QString &message,
Qgis::MessageLevel level )
33 msg.message = message;
41 QHash<int, QByteArray> roles = QAbstractListModel::roleNames();
42 roles[MessageRole] = QByteArrayLiteral(
"Message" );
43 roles[MessageTagRole] = QByteArrayLiteral(
"MessageTag" );
44 roles[MessageLevelRole] = QByteArrayLiteral(
"MessageLevel" );
52 return mMessages.size();
57 if ( index.row() >= mMessages.size() )
60 if ( role == MessageRole )
61 return mMessages.at( index.row() ).message;
62 else if ( role == MessageTagRole )
63 return mMessages.at( index.row() ).tag;
64 else if ( role == MessageLevelRole )
65 return mMessages.at( index.row() ).level;
70 void QgsQuickMessageLogModel::onMessageReceived(
const QString &message,
const QString &tag,
Qgis::MessageLevel level )
72 beginInsertRows( QModelIndex(), 0, 0 );
73 mMessages.prepend( logMessage( tag, message, level ) );
74 QgsDebugMsg( QStringLiteral(
"Next message %1 : %2" ).arg( tag, message ) );
void messageReceived(const QString &message, const QString &tag, Qgis::MessageLevel level)
Emitted whenever the log receives a message.
MessageLevel
Level for messages This will be used both for message log and message bar in application.
static QgsMessageLog * messageLog()
Returns the application's message log.
QgsQuickMessageLogModel(QObject *parent=nullptr)
Create new message log model.
QVariant data(const QModelIndex &index, int role) const override
int rowCount(const QModelIndex &parent) const override
QHash< int, QByteArray > roleNames() const override
Interface for logging messages from QGIS in GUI independent way.