Commit 6b869ad8 authored by WINTZ Julien's avatar WINTZ Julien

Adding doom delegate to widgets tag cloud framework.

parent bdf69ebb
......@@ -96,6 +96,12 @@ void dtkComposerNodeFactoryView::setDark(void)
d->view->setDark();
}
void dtkComposerNodeFactoryView::setDoom(void)
{
d->scope->setDoom();
d->view->setDoom();
}
dtkWidgetsTagCloudView *dtkComposerNodeFactoryView::itemView(void) const
{
return d->view;
......
......@@ -46,6 +46,7 @@ public:
public:
void setDark(void);
void setDoom(void);
public:
dtkWidgetsTagCloudView *itemView(void) const;
......
/* dtkWidgetsTagCloudItem.cpp ---
*
* Author: Julien Wintz
* Created: Mon Apr 15 14:10:33 2013 (+0200)
* Version:
* Last-Updated: Mon Apr 15 14:12:03 2013 (+0200)
* By: Julien Wintz
* Update #: 4
*/
/* Change Log:
*
*/
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#include "dtkWidgetsTagCloudItem.h"
......@@ -94,3 +94,6 @@ QString dtkWidgetsTagCloudItem::type(void) const
{
return d->type;
}
//
// dtkWidgetsTagCloudItem.cpp ends here
/* dtkWidgetsTagCloudItem.h ---
*
* Author: Julien Wintz
* Created: Mon Apr 15 14:02:19 2013 (+0200)
*/
// Version: $Id$
//
//
/* Change Log:
*
*/
// Commentary:
//
//
// Change Log:
//
//
// Code:
#pragma once
......@@ -18,11 +22,11 @@ class dtkWidgetsTagCloudItemPrivate;
class DTKWIDGETS_EXPORT dtkWidgetsTagCloudItem : public QListWidgetItem
{
public:
dtkWidgetsTagCloudItem(QString name);
dtkWidgetsTagCloudItem(QString name, QString description);
dtkWidgetsTagCloudItem(QString name, QString description, QStringList tags);
dtkWidgetsTagCloudItem(QString name, QString description, QStringList tags, QString kind, QString type);
dtkWidgetsTagCloudItem(const dtkWidgetsTagCloudItem& item);
dtkWidgetsTagCloudItem(QString name);
dtkWidgetsTagCloudItem(QString name, QString description);
dtkWidgetsTagCloudItem(QString name, QString description, QStringList tags);
dtkWidgetsTagCloudItem(QString name, QString description, QStringList tags, QString kind, QString type);
dtkWidgetsTagCloudItem(const dtkWidgetsTagCloudItem& item);
~dtkWidgetsTagCloudItem(void);
public:
......@@ -35,3 +39,6 @@ public:
protected:
dtkWidgetsTagCloudItemPrivate *d;
};
//
// dtkWidgetsTagCloudItem.h ends here
/* dtkWidgetsTagCloudList.cpp ---
*
* Author: Julien Wintz
* Created: Mon Apr 15 14:15:07 2013 (+0200)
* Version:
* Last-Updated: Mon Apr 15 15:48:15 2013 (+0200)
* By: Julien Wintz
* Update #: 40
*/
/* Change Log:
*
*/
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#include "dtkWidgetsTagCloudList.h"
......@@ -52,6 +52,25 @@ protected:
dtkWidgetsTagCloudList *list;
};
// /////////////////////////////////////////////////////////////////
// dtkWidgetsTagCloudListDoomDelegate
// /////////////////////////////////////////////////////////////////
class dtkWidgetsTagCloudListDoomDelegate: public QStyledItemDelegate
{
public:
dtkWidgetsTagCloudListDoomDelegate(dtkWidgetsTagCloudList *list);
public:
virtual void paint(QPainter *painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
public:
virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
protected:
dtkWidgetsTagCloudList *list;
};
// ///////////////////////////////////////////////////////////////////
// dtkWidgetsTagCloudListPrivate
// ///////////////////////////////////////////////////////////////////
......@@ -131,6 +150,11 @@ void dtkWidgetsTagCloudList::setDark(void)
this->setItemDelegate(new dtkWidgetsTagCloudListDarkDelegate(this));
}
void dtkWidgetsTagCloudList::setDoom(void)
{
this->setItemDelegate(new dtkWidgetsTagCloudListDoomDelegate(this));
}
void dtkWidgetsTagCloudList::onItemClicked(QListWidgetItem *item)
{
dtkWidgetsTagCloudItem *i = dynamic_cast<dtkWidgetsTagCloudItem *>(item);
......@@ -286,8 +310,8 @@ void dtkWidgetsTagCloudListDarkDelegate::paint(QPainter *painter, const QStyleOp
int t = option.rect.top();
int r = option.rect.right();
QRect name_rect = QRect(m, t + 1 * m, w - 2 * m, h1);
QRect desc_rect = QRect(m, t + 2 * m + h1, w - 6 * m, h2);
QRect name_rect = QRect(m, t + 1 * m, w - 2 * m, h1);
QRect desc_rect = QRect(m, t + 2 * m + h1, w - 6 * m, h2);
QRect tags_rect = QRect(m, t + 3 * m + h1 + h2, w - 2 * m, h3);
QFontMetrics metrics = QFontMetrics(painter->font());
......@@ -317,3 +341,70 @@ QSize dtkWidgetsTagCloudListDarkDelegate::sizeHint(const QStyleOptionViewItem& o
return QSize(100, 80);
}
// ///////////////////////////////////////////////////////////////////
// dtkWidgetsTagCloudListDoomDelegate
// ///////////////////////////////////////////////////////////////////
dtkWidgetsTagCloudListDoomDelegate::dtkWidgetsTagCloudListDoomDelegate(dtkWidgetsTagCloudList *list) : QStyledItemDelegate(list)
{
this->list = list;
}
void dtkWidgetsTagCloudListDoomDelegate::paint(QPainter *painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
dtkWidgetsTagCloudItem *item = dynamic_cast<dtkWidgetsTagCloudItem *>(list->itemFromIndex(index));
if (!item)
return;
painter->fillRect(option.rect, QColor("#282C34"));
painter->setPen(QColor(055, 055, 055));
painter->drawLine(option.rect.topLeft() + QPoint(0, 1), option.rect.topRight() + QPoint(0, 1));
static QPixmap arrow = QPixmap(":dtkWidgetsTagCloud/dtkWidgetsTagCloudList-arrow.png");
static QPixmap tags = QPixmap(":dtkWidgetsTagCloud/dtkWidgetsTagCloudList-tags.png");
static int m = 5;
static int h1 = 20;
static int h2 = 20;
static int h3 = 20;
int w = option.rect.width();
int h = option.rect.height();
int t = option.rect.top();
int r = option.rect.right();
QRect name_rect = QRect(m, t + 1 * m, w - 2 * m, h1);
QRect desc_rect = QRect(m, t + 2 * m + h1, w - 6 * m, h2);
QRect tags_rect = QRect(m, t + 3 * m + h1 + h2, w - 2 * m, h3);
QFontMetrics metrics = QFontMetrics(painter->font());
painter->setPen(Qt::lightGray);
painter->drawText(name_rect, Qt::AlignLeft | Qt::AlignTop, item->name());
painter->setPen(Qt::darkGray);
painter->drawText(desc_rect, Qt::AlignLeft | Qt::AlignTop, metrics.elidedText(dtkWidgetsTagCloudListDelegateUnhtmlize(item->description()), Qt::ElideRight, desc_rect.width()));
painter->setPen(QColor("#6a769d"));
painter->drawText(tags_rect.adjusted(m + tags.width(), 0, -tags.width(), 0), Qt::AlignLeft | Qt::AlignTop, item->tags().join(", "));
painter->setPen(Qt::black);
painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight());
QPointF arrow_pos = QPointF(r - m - arrow.width(), t + h / 2 - arrow.height() / 2);
painter->drawPixmap(arrow_pos, arrow);
painter->drawPixmap(tags_rect.topLeft(), tags);
}
QSize dtkWidgetsTagCloudListDoomDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const
{
Q_UNUSED(option);
Q_UNUSED(index);
return QSize(100, 80);
}
//
// dtkWidgetsTagCloudList.cpp ends here
/* dtkWidgetsTagCloudList.h ---
*
* Author: Julien Wintz
* Created: Mon Apr 15 14:12:29 2013 (+0200)
*/
// Version: $Id$
//
//
/* Change Log:
*
*/
// Commentary:
//
//
// Change Log:
//
//
// Code:
#pragma once
......@@ -35,6 +39,7 @@ public:
public:
void setDark(void);
void setDoom(void);
signals:
void itemClicked(const QString& description);
......@@ -52,4 +57,8 @@ protected:
protected:
friend class dtkWidgetsTagCloudListLightDelegate;
friend class dtkWidgetsTagCloudListDarkDelegate;
friend class dtkWidgetsTagCloudListDoomDelegate;
};
//
// dtkWidgetsTagCloudList.h ends here
......@@ -39,6 +39,7 @@ public:
public:
bool light;
bool doom;
};
dtkWidgetsTagCloudScope::dtkWidgetsTagCloudScope(QWidget *parent) : QFrame(parent)
......@@ -46,6 +47,7 @@ dtkWidgetsTagCloudScope::dtkWidgetsTagCloudScope(QWidget *parent) : QFrame(paren
d = new dtkWidgetsTagCloudScopePrivate;
d->light = true;
d->doom = false;
d->completer_model = new QStringListModel(this);
......@@ -123,6 +125,11 @@ void dtkWidgetsTagCloudScope::setDark(void)
d->light = false;
}
void dtkWidgetsTagCloudScope::setDoom(void)
{
d->doom = true;
}
void dtkWidgetsTagCloudScope::toggle(void)
{
d->switsh->toggle();
......@@ -142,6 +149,9 @@ void dtkWidgetsTagCloudScope::render(void)
if (!d->light)
tag->setDark();
if(d->doom)
tag->setDoom();
tag->setText(filter);
if (d->counts.contains(filter))
......
......@@ -39,6 +39,7 @@ public:
void setTags(const QStringList& tags);
void setDark(void);
void setDoom(void);
signals:
void tagSet(QString tag);
......
/* dtkWidgetsTagCloudScopeItem.cpp ---
*
* Author: Julien Wintz
* Created: Mon Apr 15 12:35:27 2013 (+0200)
* Version:
* Last-Updated: Mon Apr 15 15:44:01 2013 (+0200)
* By: Julien Wintz
* Update #: 10
*/
/* Change Log:
*
*/
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#include "dtkWidgetsTagCloudScopeItem.h"
......@@ -82,6 +82,16 @@ void dtkWidgetsTagCloudScopeItem::setDark(void)
"border-left: 10px transparent;");
}
void dtkWidgetsTagCloudScopeItem::setDoom(void)
{
d->fg->setStyleSheet(
"border-image: url(:dtkWidgetsTagCloud/dtkWidgetsTagCloudScopeItem-fg-dark.png) 3 10 3 10;"
"border-top: 3px transparent;"
"border-bottom: 3px transparent;"
"border-right: 10px transparent;"
"border-left: 10px transparent;");
}
QSize dtkWidgetsTagCloudScopeItem::sizeHint(void) const
{
return QSize(d->width + d->offset_max, d->height);
......@@ -148,3 +158,6 @@ void dtkWidgetsTagCloudScopeItem::mouseReleaseEvent(QMouseEvent *)
{
emit clicked();
}
//
// dtkWidgetsTagCloudScopeItem.cpp ends here
/* dtkWidgetsTagCloudScopeItem.h ---
*
* Author: Julien Wintz
* Created: Mon Apr 15 12:33:21 2013 (+0200)
*/
// Version: $Id$
//
//
/* Change Log:
*
*/
// Commentary:
//
//
// Change Log:
//
//
// Code:
#pragma once
......@@ -20,7 +24,7 @@ class DTKWIDGETS_EXPORT dtkWidgetsTagCloudScopeItem : public QWidget
Q_OBJECT
public:
dtkWidgetsTagCloudScopeItem(QWidget *parent = 0);
dtkWidgetsTagCloudScopeItem(QWidget *parent = 0);
~dtkWidgetsTagCloudScopeItem(void);
signals:
......@@ -34,6 +38,7 @@ public:
public:
void setDark(void);
void setDoom(void);
public slots:
void setText(const QString& text);
......@@ -49,3 +54,6 @@ protected:
protected:
dtkWidgetsTagCloudScopeItemPrivate *d;
};
//
// dtkWidgetsTagCloudScopeItem.h ends here
/* dtkWidgetsTagCloudView.cpp ---
*
* Author: Julien Wintz
* Created: Mon Apr 15 14:39:34 2013 (+0200)
* Version:
* Last-Updated: Mon Apr 15 14:44:56 2013 (+0200)
* By: Julien Wintz
* Update #: 7
*/
/* Change Log:
*
*/
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#include "dtkWidgetsTagCloudDesc.h"
#include "dtkWidgetsTagCloudList.h"
......@@ -90,6 +90,11 @@ void dtkWidgetsTagCloudView::setDark(void)
d->list->setDark();
}
void dtkWidgetsTagCloudView::setDoom(void)
{
d->list->setDoom();
}
void dtkWidgetsTagCloudView::onItemClicked(const QString& description)
{
d->desc->setDescription(description);
......@@ -231,3 +236,6 @@ void dtkWidgetsTagCloudView::animationDoneSlot(void)
emit animationFinished();
}
//
// dtkWidgetsTagCloudView.cpp ends here
/* dtkWidgetsTagCloudView.h ---
*
* Author: Julien Wintz
* Created: Mon Apr 15 14:33:29 2013 (+0200)
*/
// Version: $Id$
//
//
/* Change Log:
*
*/
// Commentary:
//
//
// Change Log:
//
//
// Code:
#pragma once
......@@ -41,6 +45,7 @@ public:
public:
void setDark(void);
void setDoom(void);
public slots:
void onItemClicked(const QString& description);
......@@ -68,3 +73,6 @@ protected:
protected:
dtkWidgetsTagCloudViewPrivate *d;
};
//
// dtkWidgetsTagCloudView.h ends here
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