Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
10e1a4e5
Commit
10e1a4e5
authored
Feb 26, 2021
by
Christoph Cullmann
🐮
Browse files
read/write right role
parent
b53085ab
Changes
2
Hide whitespace changes
Inline
Side-by-side
kate/kateoutputview.cpp
View file @
10e1a4e5
...
...
@@ -53,9 +53,10 @@ void KateOutputView::slotMessage(const QVariantMap &message)
/**
* body column, formatted text
* we just set the full message as attribute
* we have our KateOutputMessageStyledDelegate to render this!
*/
auto
bodyColumn
=
new
QStandardItem
();
bodyColumn
->
setData
(
QVariant
::
fromValue
(
message
));
bodyColumn
->
setData
(
QVariant
::
fromValue
(
message
)
,
KateOutputMessageStyledDelegate
::
MessageRole
);
/**
* add new message to model as one row
...
...
kate/kateoutputview.h
View file @
10e1a4e5
...
...
@@ -22,22 +22,24 @@ class KateOutputMessageStyledDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
/**
* the role for the message
*/
static
constexpr
int
MessageRole
=
Qt
::
UserRole
+
1
;
private:
/**
* setup text document from data
*/
static
void
setupText
(
QTextDocument
&
doc
,
const
Q
Variant
&
data
)
static
void
setupText
(
QTextDocument
&
doc
,
const
Q
ModelIndex
&
index
)
{
const
auto
message
=
data
.
toMap
();
printf
(
"MUHH
\n
"
);
const
auto
message
=
index
.
data
(
KateOutputMessageStyledDelegate
::
MessageRole
).
toMap
();
if
(
message
.
contains
(
QStringLiteral
(
"plainText"
)))
{
printf
(
"MUHH1
\n
"
);
doc
.
setPlainText
(
message
.
value
(
QStringLiteral
(
"plainText"
)).
toString
());
}
else
if
(
message
.
contains
(
QStringLiteral
(
"markDown"
)))
{
printf
(
"MUHH2
\n
"
);
doc
.
setMarkdown
(
message
.
value
(
QStringLiteral
(
"markDown"
)).
toString
());
}
else
if
(
message
.
contains
(
QStringLiteral
(
"html"
)))
{
printf
(
"MUHH4
\n
"
);
doc
.
setHtml
(
message
.
value
(
QStringLiteral
(
"html"
)).
toString
());
}
}
...
...
@@ -48,14 +50,14 @@ public:
void
paint
(
QPainter
*
painter
,
const
QStyleOptionViewItem
&
,
const
QModelIndex
&
index
)
const
override
{
QTextDocument
doc
;
setupText
(
doc
,
index
.
data
()
);
setupText
(
doc
,
index
);
doc
.
drawContents
(
painter
);
}
QSize
sizeHint
(
const
QStyleOptionViewItem
&
,
const
QModelIndex
&
index
)
const
override
{
QTextDocument
doc
;
setupText
(
doc
,
index
.
data
()
);
setupText
(
doc
,
index
);
return
doc
.
size
().
toSize
();
}
};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment