Commit 540a5114 authored by Nicolas Jager's avatar Nicolas Jager Committed by Edric Milaret

ui: smartlist code cleanup

- Smartlist some properties moved from code to .ui

- Smartlistscrollbar replaced QScrollBar

Change-Id: I0570fb2cc1a4ab0d7c003fad22d7297bc0ca7393
Tuleap: #148
parent b98066a7
......@@ -66,7 +66,6 @@ SOURCES += main.cpp\
smartlist.cpp \
mainwindowtoolbar.cpp \
ringcontactlineedit.cpp \
smartlistscrollbar.cpp \
pixbufmanipulator.cpp \
qualitydialog.cpp
......@@ -102,7 +101,6 @@ HEADERS += mainwindow.h \
smartlist.h \
mainwindowtoolbar.h \
ringcontactlineedit.h \
smartlistscrollbar.h \
pixbufmanipulator.h \
qualitydialog.h
......
/***************************************************************************
* Copyright (C) 2015-2016 by Savoir-faire Linux *
* Copyright (C) 2015-2016 by Savoir-faire Linux *
* Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> *
* *
* This program is free software; you can redistribute it and/or modify *
......@@ -19,28 +19,17 @@
#include <QStyledItemDelegate>
#include <qevent.h>
#include <QTreeWidgetItem>
#include <QScrollBar>
#include "smartlistdelegate.h"
#include "combar.h"
#include "smartlistscrollbar.h"
#include "smartlist.h"
SmartList::SmartList(QWidget *parent) :
QTreeView(parent),
comBar_(new ComBar(this)),
smartListScrollBar_(new SmartListScrollBar(this))
comBar_(new ComBar(this))
{
setMouseTracking(true);
setHeaderHidden(true);
setVerticalScrollBar(smartListScrollBar_);
connect(smartListScrollBar_
, &SmartListScrollBar::enterSignal
, [=]()
{
smartListDelegate_->setRowHighlighted(-1);
currentRow_ = -1;
});
verticalScrollBar()->hide();
}
SmartList::~SmartList()
......@@ -52,11 +41,7 @@ void
SmartList::enterEvent(QEvent* event)
{
Q_UNUSED(event);
setStyleSheet(
"QScrollBar:vertical { background: rgb(242, 242, 242); width:10px; }"
"QScrollBar::handle:vertical { background: rgb(77, 77, 77) }"
);
verticalScrollBar()->show();
repaint(0, 0, width(), height());
}
......@@ -73,10 +58,7 @@ SmartList::leaveEvent(QEvent* event)
if (smartListDelegate_)
smartListDelegate_->setRowHighlighted(currentRow_);
setStyleSheet(
"QScrollBar:vertical { background:white; width:10px; }"
"QScrollBar::handle:vertical { background: rgb(255, 255, 255) }"
);
verticalScrollBar()->hide();
comBar_->hide();
}
......@@ -90,11 +72,6 @@ SmartList::wheelEvent(QWheelEvent* event)
smartListDelegate_->setRowHighlighted(currentRow_);
setStyleSheet(
"QScrollBar:vertical { background: rgb(242, 242, 242); width:10px; }"
"QScrollBar::handle:vertical { background: rgb(77, 77, 77) }"
);
repaint(0, 0, width(), height());
QTreeView::wheelEvent(event);
......@@ -116,11 +93,6 @@ SmartList::mouseMoveEvent(QMouseEvent* event)
{
QModelIndex index = indexAt(event->pos());
setStyleSheet(
"QScrollBar:vertical { background: rgb(242, 242, 242); width:10px; }"
"QScrollBar::handle:vertical { background: rgb(77, 77, 77) }"
);
repaint(0, 0, width(), height());
currentRow_ = index.row();
......
/***************************************************************************
* Copyright (C) 2015-2016 by Savoir-faire Linux *
* Copyright (C) 2015-2016 by Savoir-faire Linux *
* Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> *
* *
* This program is free software; you can redistribute it and/or modify *
......@@ -22,7 +22,6 @@
class SmartListDelegate;
class ComBar;
class SmartListScrollBar;
class SmartList : public QTreeView
{
......@@ -43,6 +42,5 @@ private:
int currentRow_ = -1;
SmartListDelegate* smartListDelegate_;
ComBar* comBar_;
SmartListScrollBar* smartListScrollBar_;
};
/***************************************************************************
* Copyright (C) 2015-2016 by Savoir-faire Linux *
* Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
**************************************************************************/
#include "smartlistscrollbar.h"
SmartListScrollBar::SmartListScrollBar(QWidget* parent) : QScrollBar(parent)
{
}
SmartListScrollBar::~SmartListScrollBar()
{
}
void
SmartListScrollBar::enterEvent(QEvent* event)
{
Q_UNUSED(event);
emit enterSignal();
}
/***************************************************************************
* Copyright (C) 2015-2016 by Savoir-faire Linux *
* Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
**************************************************************************/
#pragma once
#include <QScrollBar>
class SmartListScrollBar : public QScrollBar
{
Q_OBJECT
public:
SmartListScrollBar(QWidget* parent = 0);
~SmartListScrollBar();
protected:
void enterEvent(QEvent* event);
signals:
void enterSignal() const;
};
......@@ -125,3 +125,12 @@ QPushButton#qualityButton{
border-radius: 18px;
border:solid 1px;
}
QScrollBar:vertical{
background: rgb(242, 242, 242);
width:10px;
}
QScrollBar::handle:vertical{
background: rgb(77, 77, 77);
}
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