diff options
| author | Arno <am@disconnect.de> | 2010-10-16 12:47:49 +0200 | 
|---|---|---|
| committer | Arno <am@disconnect.de> | 2010-10-16 12:47:49 +0200 | 
| commit | f10a0a63e699288f1288c193c49795cae9cb3b40 (patch) | |
| tree | a4bd7c83440223a2eeec787f8f50c070e34fbe72 /seriestreewidget.cpp | |
| parent | 101cc9ec266a2d3b5168ab5053efbf868be7e25b (diff) | |
| download | SheMov-f10a0a63e699288f1288c193c49795cae9cb3b40.tar.gz SheMov-f10a0a63e699288f1288c193c49795cae9cb3b40.tar.bz2 SheMov-f10a0a63e699288f1288c193c49795cae9cb3b40.zip | |
Created general purpose HoverWidget
This commit outsources the HoverWindow to a seperate file and makes it
possible to set a pixmap to the window. Also the cursor offset is only
calculated once in SmGlobals.
Diffstat (limited to 'seriestreewidget.cpp')
| -rw-r--r-- | seriestreewidget.cpp | 42 | 
1 files changed, 4 insertions, 38 deletions
| diff --git a/seriestreewidget.cpp b/seriestreewidget.cpp index 791fb9e..b5a3feb 100644 --- a/seriestreewidget.cpp +++ b/seriestreewidget.cpp @@ -24,12 +24,6 @@  #include <QFile>  #include <QEvent>  #include <QHoverEvent> -#include <QPaintEvent> -#include <QPainter> - -#include <QX11Info> -#include <X11/Xlib.h> -#include <X11/extensions/Xfixes.h>  #include "seriestreewidget.h"  #include "smtreemodel.h" @@ -37,6 +31,7 @@  #include "seriestreemodel.h"  #include "filestreemodel.h"  #include "helper.h" +#include "hoverwindow.h"  SeriesTreeWidget::SeriesTreeWidget(QWidget *parent) : QWidget(parent){  	//filter bar @@ -318,12 +313,9 @@ void SeriesTreeWidget::addCover(){  	}  } -SeriesTreeView::SeriesTreeView(QWidget *parent) : QTreeView(parent), mCursorOffset(0) { +SeriesTreeView::SeriesTreeView(QWidget *parent) : QTreeView(parent) {  	setAttribute(Qt::WA_Hover); -	mHoverWin = new SeriesTreeHoverWindow; -	XFixesCursorImage *curImage = XFixesGetCursorImage(QX11Info::display()); -	mCursorOffset = curImage->height; -	XFree(curImage); +	mHoverWin = new HoverWindow;  }  void SeriesTreeView::contextMenuEvent(QContextMenuEvent *e){ @@ -337,7 +329,7 @@ void SeriesTreeView::contextMenuEvent(QContextMenuEvent *e){  bool SeriesTreeView::event(QEvent *e){  	QModelIndex curIdx;  	QHoverEvent *hEvent = static_cast<QHoverEvent*>(e); -	QPoint hotSpot(hEvent->pos().x(), hEvent->pos().y() - mCursorOffset); +	QPoint hotSpot(hEvent->pos().x(), hEvent->pos().y() - SmGlobals::instance()->cursorOffset());  	QPoint globalPos = mapToGlobal(hotSpot);  	QPoint where = globalPos + QPoint(30, 30); @@ -393,32 +385,6 @@ QStringList SeriesTreeView::children(const QModelIndex &idx) const{  	return retval;  } -SeriesTreeHoverWindow::SeriesTreeHoverWindow(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f){ -	setVisible(false); -	setWindowOpacity(0.7); -	setStyleSheet("QLabel { background-color: #D6A583; color: black; border-width: 2px; border-style: solid; padding: 4px; }"); -	QHBoxLayout *mainLayout = new QHBoxLayout; -	mainLayout->setContentsMargins(4, 4, 4, 4); -	mLabel = new QLabel; -	mainLayout->addWidget(mLabel); -	setLayout(mainLayout); -} - -void SeriesTreeHoverWindow::setContent(const QString &parent, const QStringList &children){ -	QString curText = QString("<p style=\"align: center; text-decoration: underline; font-weight: bold; margin-bottom: 0;\">%1</p>").arg(parent); -	curText.append("<ul style=\"margin-left: -25; margin-top: 0px;\">"); -	int count = qMin(6, children.size()); -	int i = 0; -	for(i = 0; i < count; ++i){ -		curText.append(QString("<li>%1</li>").arg(children.at(i))); -	} -	if(i < children.count()){ -		curText.append("<li>...</li>"); -	} -	curText.append("</ul>"); -	mLabel->setText(curText); -} -  SeriesTreeSortModel::SeriesTreeSortModel(QObject *parent) : QSortFilterProxyModel(parent) {}  bool SeriesTreeSortModel::lessThan(const QModelIndex &left, const QModelIndex &right) const{ | 
