Menu

[2179ca]: / treedelegate.cpp  Maximize  Restore  History

Download this file

58 lines (44 with data), 1.5 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "treedelegate.h"
#include <QDebug>
#include <QPainter>
#include "treeitem.h"
#include "treemodel.h"
TreeDelegate::TreeDelegate(QObject *)
{
}
/*
*/
#include <QTextDocument>
#include "noteobj.h"
QString TreeDelegate::displayText (const QVariant & value, const QLocale & ) const // FIXME-3 Ugly, but works...
{
QString s=value.toString();
if (Qt::mightBeRichText (s))
{
NoteObj no (s);
s=no.getNoteASCII();
}
return s.trimmed().replace ('\n',' ').replace ('\t',' ');
}
/*
void TreeDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QStyledItemDelegate::paint(painter, option, index); //FIXME use own pant method to convert richtext 2 plaintext
return;
painter->save();
QRectF rect=option.rect;
QString text; //= qVariantValue <QString> (index.data());
TreeItem *ti=((TreeModel*)index.model())->getItem(index);
text=ti->getHeadingPlain();
// Paint highlighted, if selected //FIXME not as nice as original implementation with bright borders and gradient
if (option.state & QStyle::State_Selected)
painter->fillRect(option.rect, option.palette.highlight() );
painter->drawText(rect, Qt::AlignLeft, text );
painter->restore();
}
QSize TreeDelegate::sizeHint(const QStyleOptionViewItem &option,
const QModelIndex &index ) const
{
return QStyledItemDelegate::sizeHint(option, index); //FIXME sizeHint incorrect for RichText
}
*/
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.