Commit 645e4c37 authored by Edric Milaret's avatar Edric Milaret

ui: hide non-displayable character in smartlist

- Also move the video button to the right

Change-Id: Ib1f862ca923a6600457248d672f0b973e3834366
Tuleap: #148
parent a13b48c3
...@@ -24,9 +24,6 @@ ComBar::ComBar(QWidget* parent) : ...@@ -24,9 +24,6 @@ ComBar::ComBar(QWidget* parent) :
ui(new Ui::ComBar) ui(new Ui::ComBar)
{ {
ui->setupUi(this); ui->setupUi(this);
// [jn] these buttons are for further uses
ui->btncontactinfo->hide();
} }
ComBar::~ComBar() ComBar::~ComBar()
...@@ -37,6 +34,6 @@ ComBar::~ComBar() ...@@ -37,6 +34,6 @@ ComBar::~ComBar()
void void
ComBar::moveToRow(const QRect& rect) ComBar::moveToRow(const QRect& rect)
{ {
move(rect.right() - width(), move(rect.right() - width() - 5,
rect.bottom() - height() - (rect.height()/4)); rect.bottom() - height() - (rect.height()/4));
} }
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>116</width> <width>30</width>
<height>37</height> <height>30</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
...@@ -16,12 +16,6 @@ ...@@ -16,12 +16,6 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="maximumSize">
<size>
<width>116</width>
<height>37</height>
</size>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string/> <string/>
</property> </property>
...@@ -33,13 +27,13 @@ ...@@ -33,13 +27,13 @@
<number>0</number> <number>0</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>7</number> <number>0</number>
</property> </property>
<property name="rightMargin"> <property name="rightMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>7</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QPushButton" name="btnvideo"> <widget class="QPushButton" name="btnvideo">
...@@ -66,25 +60,6 @@ ...@@ -66,25 +60,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="btncontactinfo">
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>
......
...@@ -41,9 +41,11 @@ SmartListDelegate::paint(QPainter* painter ...@@ -41,9 +41,11 @@ SmartListDelegate::paint(QPainter* painter
{ {
QStyleOptionViewItem opt(option); QStyleOptionViewItem opt(option);
painter->setRenderHint(QPainter::Antialiasing); painter->setRenderHint(QPainter::Antialiasing);
opt.decorationSize = QSize(sizeImage_, sizeImage_); opt.decorationSize = QSize(sizeImage_, sizeImage_);
opt.decorationPosition = QStyleOptionViewItem::Left; opt.decorationPosition = QStyleOptionViewItem::Left;
opt.decorationAlignment = Qt::AlignCenter; opt.decorationAlignment = Qt::AlignCenter;
if (opt.state & QStyle::State_HasFocus) if (opt.state & QStyle::State_HasFocus)
opt.state ^= QStyle::State_HasFocus; opt.state ^= QStyle::State_HasFocus;
...@@ -53,12 +55,15 @@ SmartListDelegate::paint(QPainter* painter ...@@ -53,12 +55,15 @@ SmartListDelegate::paint(QPainter* painter
QRect rect = opt.rect; QRect rect = opt.rect;
rect.setLeft(0); rect.setLeft(0);
QRect rectTexts(16 + rect.left() + dx_+sizeImage_, rect.top(), rect.width(), rect.height()/2); QRect rectTexts(16 + rect.left() + dx_ + sizeImage_,
rect.top(),
rect.width(),
rect.height() / 2);
QRect rectAvatar(16 + rect.left(), rect.top() + dy_, sizeImage_, sizeImage_); QRect rectAvatar(16 + rect.left(), rect.top() + dy_, sizeImage_, sizeImage_);
drawDecoration(painter, opt, rectAvatar, QPixmap::fromImage(index.data(Qt::DecorationRole).value<QImage>())); drawDecoration(painter, opt, rectAvatar,
QPixmap::fromImage(index.data(Qt::DecorationRole).value<QImage>()));
const int currentRow = index.row(); const int currentRow = index.row();
if (currentRow == rowHighlighted_) if (currentRow == rowHighlighted_)
emit rowSelected(opt.rect); emit rowSelected(opt.rect);
...@@ -85,7 +90,16 @@ SmartListDelegate::paint(QPainter* painter ...@@ -85,7 +90,16 @@ SmartListDelegate::paint(QPainter* painter
painter->setPen(pen); painter->setPen(pen);
font.setBold(true); font.setBold(true);
painter->setFont(font); painter->setFont(font);
painter->drawText(rectTexts, Qt::AlignBottom | Qt::AlignLeft, name.toString()); QFontMetrics fontMetrics(font);
QString nameStr = name.toString();
auto realRect = fontMetrics.boundingRect(rect, Qt::AlignBottom | Qt::AlignLeft, nameStr);
if (realRect.width() > (rect.width() - rectTexts.left() - 30)) {
/* 30 here is the size of the video button */
auto charToChop = (realRect.width() - (rect.width() - rectTexts.left())) / fontMetrics.averageCharWidth();
nameStr.chop(charToChop + 8);
nameStr.append(QStringLiteral("..."));
}
painter->drawText(rectTexts, Qt::AlignBottom | Qt::AlignLeft, nameStr);
} }
QVariant state = index.data(static_cast<int>(Ring::Role::FormattedState)); QVariant state = index.data(static_cast<int>(Ring::Role::FormattedState));
...@@ -126,6 +140,5 @@ SmartListDelegate::sizeHint(const QStyleOptionViewItem& option ...@@ -126,6 +140,5 @@ SmartListDelegate::sizeHint(const QStyleOptionViewItem& option
{ {
QSize size = QItemDelegate::sizeHint(option, index); QSize size = QItemDelegate::sizeHint(option, index);
size.setHeight(cellHeight_); size.setHeight(cellHeight_);
size.setWidth(cellWidth_);
return size; return size;
} }
...@@ -37,7 +37,6 @@ protected: ...@@ -37,7 +37,6 @@ protected:
private: private:
constexpr static int sizeImage_ = 48; constexpr static int sizeImage_ = 48;
constexpr static int cellHeight_ = 60; constexpr static int cellHeight_ = 60;
constexpr static int cellWidth_ = 324;
constexpr static int dy_ = 6; constexpr static int dy_ = 6;
constexpr static int dx_ = 12; constexpr static int dx_ = 12;
constexpr static int fontSize_ = 10; constexpr static int fontSize_ = 10;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment