1 /* ============================================================
2 *
3 * This file is a part of digiKam project
4 * https://www.digikam.org
5 *
6 * Date : 2008-11-05
7 * Description : simple text labels to display item
8 * properties meta infos
9 *
10 * Copyright (C) 2008-2021 by Gilles Caulier <caulier dot gilles at gmail dot com>
11 *
12 * This program is free software; you can redistribute it
13 * and/or modify it under the terms of the GNU General
14 * Public License as published by the Free Software Foundation;
15 * either version 2, or (at your option)
16 * any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * ============================================================ */
24
25 #include "itempropertiestxtlabel.h"
26
27 // Qt includes
28
29 #include <QMargins>
30 #include <QPalette>
31 #include <QColor>
32 #include <QFontMetrics>
33 #include <QFontDatabase>
34
35 namespace Digikam
36 {
37
DTextLabelName(const QString & name,QWidget * const parent)38 DTextLabelName::DTextLabelName(const QString& name, QWidget* const parent)
39 : DAdjustableLabel(parent)
40 {
41 setAdjustedText(name);
42 QFont fnt;
43 fnt.setItalic(true);
44 setFont(fnt);
45 setAlignment(Qt::AlignRight | Qt::AlignTop);
46 setWordWrap(false);
47 }
48
~DTextLabelName()49 DTextLabelName::~DTextLabelName()
50 {
51 }
52
53 // -------------------------------------------------------------------
54
DTextLabelValue(const QString & value,QWidget * const parent)55 DTextLabelValue::DTextLabelValue(const QString& value, QWidget* const parent)
56 : DAdjustableLabel(parent)
57 {
58 setAdjustedText(value);
59 setAlignment(Qt::AlignLeft | Qt::AlignTop);
60 setWordWrap(false);
61 setElideMode(Qt::ElideRight);
62 }
63
~DTextLabelValue()64 DTextLabelValue::~DTextLabelValue()
65 {
66 }
67
68 // -------------------------------------------------------------------
69
DTextBrowser(const QString & text,QWidget * const parent)70 DTextBrowser::DTextBrowser(const QString& text, QWidget* const parent)
71 : QTextBrowser(parent)
72 {
73 setOpenExternalLinks(false);
74 setOpenLinks(false);
75 setText(text);
76 setLinesNumber(3);
77 setFocusPolicy(Qt::NoFocus);
78 }
79
~DTextBrowser()80 DTextBrowser::~DTextBrowser()
81 {
82 }
83
setLinesNumber(int l)84 void DTextBrowser::setLinesNumber(int l)
85 {
86 QFont fnt;
87 document()->setDefaultFont(fnt);
88 QMargins m = contentsMargins();
89 setFixedHeight(m.top() + m.bottom() + frameWidth() + fontMetrics().lineSpacing()*l);
90 }
91
92 // -------------------------------------------------------------------
93
DTextList(const QStringList & list,QWidget * const parent)94 DTextList::DTextList(const QStringList& list, QWidget* const parent)
95 : QListWidget(parent)
96 {
97 addItems(list);
98 setLinesNumber(6);
99 setFocusPolicy(Qt::NoFocus);
100 sortItems();
101 }
102
~DTextList()103 DTextList::~DTextList()
104 {
105 }
106
setLinesNumber(int l)107 void DTextList::setLinesNumber(int l)
108 {
109 QFont fnt;
110 setFont(fnt);
111 QMargins m = contentsMargins();
112 setFixedHeight(m.top() + m.bottom() + frameWidth() + fontMetrics().lineSpacing()*l);
113 }
114
115 } // namespace Digikam
116