LeechCraft
0.6.70-19214-g121e5318a7
Modular cross-platform feature rich live environment.
Toggle main menu visibility
Loading...
Searching...
No Matches
modelsanitizer.cpp
Go to the documentation of this file.
1
/**********************************************************************
2
* LeechCraft - modular cross-platform feature rich internet client.
3
* Copyright (C) 2006-2014 Georg Rudoy
4
*
5
* Distributed under the Boost Software License, Version 1.0.
6
* (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7
**********************************************************************/
8
9
#include "
modelsanitizer.h
"
10
11
#ifdef WITH_MODEL_SANITIZER
12
#include <optional>
13
#include <QAbstractItemModelTester>
14
#include <QByteArray>
15
#endif
16
#include <QtDebug>
17
18
namespace
LC::Util
19
{
20
void
InstallModelSanitizer
([[maybe_unused]] QAbstractItemModel& model)
21
{
22
#ifdef WITH_MODEL_SANITIZER
23
static
const
auto
mode = [] -> std::optional<QAbstractItemModelTester::FailureReportingMode>
24
{
25
const
auto
& str = qgetenv (
"LC_MODEL_SANITIZER_MODE"
);
26
if
(str.isEmpty ())
27
return
{};
28
29
using
enum QAbstractItemModelTester::FailureReportingMode;
30
if
(str ==
"fatal"
)
31
return
Fatal;
32
if
(str ==
"warning"
)
33
return
Warning
;
34
35
qCritical () <<
"unknown model sanitizer mode"
<< str;
36
return
{};
37
} ();
38
39
if
(mode)
40
new
QAbstractItemModelTester { &model, *mode, &model };
41
#else
42
static
const
auto
requested = !qEnvironmentVariableIsEmpty (
"LC_MODEL_SANITIZER_MODE"
);
43
if
(requested)
44
qWarning () <<
"model sanitizer is not supported"
;
45
#endif
46
}
47
}
modelsanitizer.h
LC::Util
Definition
icoreproxy.h:34
LC::Util::InstallModelSanitizer
void InstallModelSanitizer(QAbstractItemModel &model)
Definition
modelsanitizer.cpp:20
LC::Priority::Warning
@ Warning
Definition
structures.h:193
src
util
models
modelsanitizer.cpp
Generated by
1.18.0