Commit e41bb586 authored by Nicolas Jager's avatar Nicolas Jager Committed by Edric Milaret

fix: Video button appearing on many row

Change-Id: I1de8f75a1c71faaa82799d173aeb2705b37839eb
Tuleap: #441
parent 6cdeba95
......@@ -499,9 +499,6 @@ CallWidget::on_cancelButton_clicked()
void
CallWidget::on_smartList_doubleClicked(const QModelIndex& index)
{
ui->smartList->reset();
ui->smartList->setCurrentIndex(index);
auto realIndex = RecentModel::instance().peopleProxy()->mapToSource(index);
if (RecentModel::instance().hasActiveCall(realIndex))
return;
......@@ -562,7 +559,6 @@ CallWidget::placeCall()
void
CallWidget::settingsButtonClicked()
{
ui->smartList->reset();
emit NavigationRequested(ScreenEnum::ConfScreen);
}
......
......@@ -20,7 +20,6 @@
#include "combar.h"
ComBar::ComBar(QWidget* parent) :
QWidget(parent),
ui(new Ui::ComBar)
......
......@@ -28,19 +28,22 @@
SmartList::SmartList(QWidget *parent) :
QTreeView(parent)
{
verticalScrollBar()->hide();
connect(this, &QAbstractItemView::entered, [this](const QModelIndex & index) {
removeCombar();
if (auto widget = indexWidget(index)) {
widget->setVisible(true);
} else {
ComBar* bar = new ComBar();
setIndexWidget(index, bar);
connect(bar, &ComBar::btnVideoClicked, this, [=](){ emit btnVideoClicked(); });
}
hoveredRow_ = index;
auto widget = indexWidget(index);
if (!widget) {
ComBar* bar = new ComBar();
setIndexWidget(index, bar);
connect(bar, &ComBar::btnVideoClicked, this, [=](){ emit btnVideoClicked(); });
}
else if (index.isValid())
indexWidget(index)->setVisible(true);
if(hoveredRow_.isValid() and indexWidget(hoveredRow_))
indexWidget(hoveredRow_)->setVisible(false);
hoveredRow_ = index;
});
setVerticalScrollMode(ScrollPerPixel);
......@@ -48,7 +51,7 @@ SmartList::SmartList(QWidget *parent) :
SmartList::~SmartList()
{
reset();
}
void
......@@ -63,16 +66,14 @@ SmartList::leaveEvent(QEvent* event)
{
Q_UNUSED(event);
hoveredRow_ = QModelIndex();
verticalScrollBar()->hide();
removeCombar();
}
void
SmartList::setSmartListItemDelegate(SmartListDelegate* delegate)
{
if (delegate)
{
if (delegate) {
setItemDelegate(delegate);
smartListDelegate_ = delegate;
}
......@@ -83,27 +84,21 @@ SmartList::eventFilter(QObject* watched, QEvent* event)
{
if (qobject_cast<QScrollBar*>(watched) && event->type() == QEvent::Enter) {
removeCombar();
hoveredRow_ = QModelIndex();
return true;
}
return QObject::eventFilter(watched, event);
}
void
SmartList::removeCombar()
{
if(not hoveredRow_.isValid())
return;
if (auto widget = indexWidget(hoveredRow_)) {
widget->setVisible(false);
}
}
void
SmartList::resizeEvent(QResizeEvent* event)
SmartList::drawRow(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
reset();
QTreeView::resizeEvent(event);
if(index == hoveredRow_ && indexWidget(hoveredRow_))
indexWidget(index)->setVisible(true);
else if(indexWidget(index))
indexWidget(index)->setVisible(false);
QTreeView::drawRow(painter, option, index);
}
......@@ -34,7 +34,7 @@ protected:
void enterEvent(QEvent* event);
void leaveEvent(QEvent* event);
bool eventFilter(QObject* watched, QEvent* event);
void resizeEvent(QResizeEvent* event);
void drawRow(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
private:
SmartListDelegate* smartListDelegate_;
......
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