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\ ...@@ -66,7 +66,6 @@ SOURCES += main.cpp\
smartlist.cpp \ smartlist.cpp \
mainwindowtoolbar.cpp \ mainwindowtoolbar.cpp \
ringcontactlineedit.cpp \ ringcontactlineedit.cpp \
smartlistscrollbar.cpp \
pixbufmanipulator.cpp \ pixbufmanipulator.cpp \
qualitydialog.cpp qualitydialog.cpp
...@@ -102,7 +101,6 @@ HEADERS += mainwindow.h \ ...@@ -102,7 +101,6 @@ HEADERS += mainwindow.h \
smartlist.h \ smartlist.h \
mainwindowtoolbar.h \ mainwindowtoolbar.h \
ringcontactlineedit.h \ ringcontactlineedit.h \
smartlistscrollbar.h \
pixbufmanipulator.h \ pixbufmanipulator.h \
qualitydialog.h qualitydialog.h
......
...@@ -19,28 +19,17 @@ ...@@ -19,28 +19,17 @@
#include <QStyledItemDelegate> #include <QStyledItemDelegate>
#include <qevent.h> #include <qevent.h>
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
#include <QScrollBar>
#include "smartlistdelegate.h" #include "smartlistdelegate.h"
#include "combar.h" #include "combar.h"
#include "smartlistscrollbar.h"
#include "smartlist.h" #include "smartlist.h"
SmartList::SmartList(QWidget *parent) : SmartList::SmartList(QWidget *parent) :
QTreeView(parent), QTreeView(parent),
comBar_(new ComBar(this)), comBar_(new ComBar(this))
smartListScrollBar_(new SmartListScrollBar(this))
{ {
setMouseTracking(true); verticalScrollBar()->hide();
setHeaderHidden(true);
setVerticalScrollBar(smartListScrollBar_);
connect(smartListScrollBar_
, &SmartListScrollBar::enterSignal
, [=]()
{
smartListDelegate_->setRowHighlighted(-1);
currentRow_ = -1;
});
} }
SmartList::~SmartList() SmartList::~SmartList()
...@@ -52,11 +41,7 @@ void ...@@ -52,11 +41,7 @@ void
SmartList::enterEvent(QEvent* event) SmartList::enterEvent(QEvent* event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
verticalScrollBar()->show();
setStyleSheet(
"QScrollBar:vertical { background: rgb(242, 242, 242); width:10px; }"
"QScrollBar::handle:vertical { background: rgb(77, 77, 77) }"
);
repaint(0, 0, width(), height()); repaint(0, 0, width(), height());
} }
...@@ -73,10 +58,7 @@ SmartList::leaveEvent(QEvent* event) ...@@ -73,10 +58,7 @@ SmartList::leaveEvent(QEvent* event)
if (smartListDelegate_) if (smartListDelegate_)
smartListDelegate_->setRowHighlighted(currentRow_); smartListDelegate_->setRowHighlighted(currentRow_);
setStyleSheet( verticalScrollBar()->hide();
"QScrollBar:vertical { background:white; width:10px; }"
"QScrollBar::handle:vertical { background: rgb(255, 255, 255) }"
);
comBar_->hide(); comBar_->hide();
} }
...@@ -90,11 +72,6 @@ SmartList::wheelEvent(QWheelEvent* event) ...@@ -90,11 +72,6 @@ SmartList::wheelEvent(QWheelEvent* event)
smartListDelegate_->setRowHighlighted(currentRow_); 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()); repaint(0, 0, width(), height());
QTreeView::wheelEvent(event); QTreeView::wheelEvent(event);
...@@ -116,11 +93,6 @@ SmartList::mouseMoveEvent(QMouseEvent* event) ...@@ -116,11 +93,6 @@ SmartList::mouseMoveEvent(QMouseEvent* event)
{ {
QModelIndex index = indexAt(event->pos()); 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()); repaint(0, 0, width(), height());
currentRow_ = index.row(); currentRow_ = index.row();
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
class SmartListDelegate; class SmartListDelegate;
class ComBar; class ComBar;
class SmartListScrollBar;
class SmartList : public QTreeView class SmartList : public QTreeView
{ {
...@@ -43,6 +42,5 @@ private: ...@@ -43,6 +42,5 @@ private:
int currentRow_ = -1; int currentRow_ = -1;
SmartListDelegate* smartListDelegate_; SmartListDelegate* smartListDelegate_;
ComBar* comBar_; 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{ ...@@ -125,3 +125,12 @@ QPushButton#qualityButton{
border-radius: 18px; border-radius: 18px;
border:solid 1px; 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