mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-12-18 01:54:25 -05:00
fixed conflicts in merging upstream/master to v0.6-FTEncryption
This commit is contained in:
commit
8c7c7647b0
173 changed files with 2701 additions and 13742 deletions
|
|
@ -52,7 +52,9 @@ ElidedLabel::ElidedLabel(const QString &text, QWidget *parent)
|
|||
, mElided(false)
|
||||
, mOnlyPlainText(false)
|
||||
, mContent(text)
|
||||
, mTextColor(QColor())
|
||||
{
|
||||
setStyleSheet("background-color: rgba(0,0,0,0%)");
|
||||
mRectElision = QRect();
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
}
|
||||
|
|
@ -62,7 +64,9 @@ ElidedLabel::ElidedLabel(QWidget *parent)
|
|||
, mElided(false)
|
||||
, mOnlyPlainText(false)
|
||||
, mContent("")
|
||||
, mTextColor(QColor())
|
||||
{
|
||||
setStyleSheet("background-color: rgba(0,0,0,0%)");
|
||||
mRectElision = QRect();
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
}
|
||||
|
|
@ -94,7 +98,7 @@ void ElidedLabel::paintEvent(QPaintEvent *event)
|
|||
QFontMetrics fontMetrics = painter.fontMetrics();
|
||||
QRect cr = contentsRect();
|
||||
cr.adjust(margin(), margin(), -margin(), -margin());
|
||||
|
||||
|
||||
bool didElide = false;
|
||||
QChar ellipsisChar(0x2026);//= "…"
|
||||
int lineSpacing = fontMetrics.lineSpacing();
|
||||
|
|
@ -225,3 +229,11 @@ void ElidedLabel::mousePressEvent(QMouseEvent *ev)
|
|||
}
|
||||
QLabel::mousePressEvent(ev);
|
||||
}
|
||||
|
||||
void ElidedLabel::setTextColor(const QColor &color)
|
||||
{
|
||||
QPalette tmpPalette = palette();
|
||||
tmpPalette.setColor(foregroundRole(), color);
|
||||
setPalette(tmpPalette);
|
||||
mTextColor = color;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ class ElidedLabel : public QLabel
|
|||
Q_PROPERTY(QString text READ text WRITE setText)
|
||||
Q_PROPERTY(bool isElided READ isElided)
|
||||
Q_PROPERTY(bool isOnlyPlainText READ isOnlyPlainText WRITE setOnlyPlainText)
|
||||
Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor)
|
||||
|
||||
public:
|
||||
ElidedLabel(const QString &text, QWidget *parent = 0);
|
||||
|
|
@ -62,6 +63,9 @@ public:
|
|||
bool isElided() const { return mElided; }
|
||||
bool isOnlyPlainText() const { return mOnlyPlainText; }
|
||||
|
||||
QColor textColor() const { return mTextColor; }
|
||||
void setTextColor(const QColor &color);
|
||||
|
||||
public slots:
|
||||
void setText(const QString &text);
|
||||
void setOnlyPlainText(const bool &value);
|
||||
|
|
@ -79,6 +83,7 @@ private:
|
|||
bool mOnlyPlainText;
|
||||
QString mContent;
|
||||
QRect mRectElision;
|
||||
QColor mTextColor;
|
||||
};
|
||||
|
||||
#endif // ELIDEDLABEL_H
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
#include "util/HandleRichText.h"
|
||||
|
||||
static QHash<QString, QString> Smileys;
|
||||
static QVector<QString> order;
|
||||
|
||||
void Emoticons::load()
|
||||
{
|
||||
|
|
@ -115,6 +116,7 @@ void Emoticons::load()
|
|||
} else {
|
||||
Smileys.insert(smcode, smfile);
|
||||
}
|
||||
order.append(smcode);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -174,15 +176,15 @@ void Emoticons::showSmileyWidget(QWidget *parent, QWidget *button, const char *s
|
|||
x = 0;
|
||||
y = 0;
|
||||
|
||||
QHashIterator<QString, QString> i(Smileys);
|
||||
QVectorIterator<QString> i(order);
|
||||
while(i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
QString key = i.next();
|
||||
QPushButton *smButton = new QPushButton("", smWidget);
|
||||
smButton->setGeometry(x*buttonWidth, y*buttonHeight, buttonWidth, buttonHeight);
|
||||
smButton->setIconSize(QSize(buttonWidth, buttonHeight));
|
||||
smButton->setIcon(QPixmap(i.value()));
|
||||
smButton->setToolTip(i.key());
|
||||
smButton->setIcon(QPixmap(Smileys.value(key)));
|
||||
smButton->setToolTip(key);
|
||||
smButton->setStyleSheet("QPushButton:hover {border: 3px solid white; border-radius: 2px;}");
|
||||
smButton->setFlat(true);
|
||||
++x;
|
||||
|
|
|
|||
|
|
@ -510,6 +510,7 @@ static void getNameWidget(QTreeWidget *treeWidget, QTreeWidgetItem *item, Elided
|
|||
|
||||
if (!widget) {
|
||||
widget = new QWidget;
|
||||
widget->setAttribute(Qt::WA_TranslucentBackground);
|
||||
nameLabel = new ElidedLabel(widget);
|
||||
textLabel = new ElidedLabel(widget);
|
||||
|
||||
|
|
|
|||
|
|
@ -18,20 +18,22 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include <QMenu>
|
||||
#include <QToolButton>
|
||||
#include <QLabel>
|
||||
#include <QMovie>
|
||||
|
||||
#include "retroshare/rsgxsflags.h"
|
||||
#include "GroupTreeWidget.h"
|
||||
#include "ui_GroupTreeWidget.h"
|
||||
|
||||
#include "RSItemDelegate.h"
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QMenu>
|
||||
#include <QMovie>
|
||||
#include <QToolButton>
|
||||
|
||||
#include "retroshare/rsgxsflags.h"
|
||||
|
||||
#include "PopularityDefs.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "RSItemDelegate.h"
|
||||
#include "RSTreeWidgetItem.h"
|
||||
#include "gui/common/ElidedLabel.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "util/QtVersion.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
|
@ -55,6 +57,9 @@
|
|||
#define FILTER_NAME_INDEX 0
|
||||
#define FILTER_DESC_INDEX 1
|
||||
|
||||
Q_DECLARE_METATYPE(ElidedLabel*)
|
||||
Q_DECLARE_METATYPE(QLabel*)
|
||||
|
||||
GroupTreeWidget::GroupTreeWidget(QWidget *parent) :
|
||||
QWidget(parent), ui(new Ui::GroupTreeWidget)
|
||||
{
|
||||
|
|
@ -116,6 +121,38 @@ GroupTreeWidget::~GroupTreeWidget()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
static void getNameWidget(QTreeWidget *treeWidget, QTreeWidgetItem *item, ElidedLabel *&nameLabel, QLabel *&waitLabel)
|
||||
{
|
||||
QWidget *widget = treeWidget->itemWidget(item, COLUMN_NAME);
|
||||
|
||||
if (!widget) {
|
||||
widget = new QWidget;
|
||||
widget->setAttribute(Qt::WA_TranslucentBackground);
|
||||
nameLabel = new ElidedLabel(widget);
|
||||
waitLabel = new QLabel(widget);
|
||||
QMovie *movie = new QMovie(":/images/loader/circleball-16.gif");
|
||||
waitLabel->setMovie(movie);
|
||||
waitLabel->setHidden(true);
|
||||
|
||||
widget->setProperty("nameLabel", qVariantFromValue(nameLabel));
|
||||
widget->setProperty("waitLabel", qVariantFromValue(waitLabel));
|
||||
|
||||
QHBoxLayout *layout = new QHBoxLayout;
|
||||
layout->setSpacing(0);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
layout->addWidget(nameLabel);
|
||||
layout->addWidget(waitLabel);
|
||||
|
||||
widget->setLayout(layout);
|
||||
|
||||
treeWidget->setItemWidget(item, COLUMN_NAME, widget);
|
||||
} else {
|
||||
nameLabel = widget->property("nameLabel").value<ElidedLabel*>();
|
||||
waitLabel = widget->property("waitLabel").value<QLabel*>();
|
||||
}
|
||||
}
|
||||
|
||||
void GroupTreeWidget::changeEvent(QEvent *e)
|
||||
{
|
||||
QWidget::changeEvent(e);
|
||||
|
|
@ -229,7 +266,7 @@ void GroupTreeWidget::initDisplayMenu(QToolButton *toolButton)
|
|||
actionSortByLastPost = displayMenu->addAction(QIcon(), tr("Sort by Last Post"), this, SLOT(sort()));
|
||||
actionSortByLastPost->setCheckable(true);
|
||||
actionSortByLastPost->setActionGroup(actionGroup);
|
||||
|
||||
|
||||
actionSortByPosts = displayMenu->addAction(QIcon(), tr("Sort by Posts"), this, SLOT(sort()));
|
||||
actionSortByPosts->setCheckable(true);
|
||||
actionSortByPosts->setActionGroup(actionGroup);
|
||||
|
|
@ -255,6 +292,11 @@ void GroupTreeWidget::updateColors()
|
|||
}
|
||||
|
||||
item->setForeground(COLUMN_NAME, brush);
|
||||
|
||||
ElidedLabel *nameLabel = NULL;
|
||||
QLabel *waitLabel = NULL;
|
||||
getNameWidget(ui->treeWidget, item, nameLabel, waitLabel);
|
||||
nameLabel->setTextColor(brush.color());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -293,21 +335,27 @@ QTreeWidgetItem *GroupTreeWidget::addCategoryItem(const QString &name, const QIc
|
|||
{
|
||||
QFont font;
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||
ui->treeWidget->addTopLevelItem(item);
|
||||
|
||||
ElidedLabel *nameLabel = NULL;
|
||||
QLabel *waitLabel = NULL;
|
||||
getNameWidget(ui->treeWidget, item, nameLabel, waitLabel);
|
||||
|
||||
nameLabel->setText(name);
|
||||
item->setData(COLUMN_DATA, ROLE_NAME, name);
|
||||
font = item->font(COLUMN_NAME);
|
||||
font.setBold(true);
|
||||
item->setText(COLUMN_NAME, name);
|
||||
item->setData(COLUMN_DATA, ROLE_NAME, name);
|
||||
item->setFont(COLUMN_NAME, font);
|
||||
nameLabel->setFont(font);
|
||||
item->setIcon(COLUMN_NAME, icon);
|
||||
|
||||
int S = QFontMetricsF(font).height();
|
||||
int S = QFontMetricsF(font).height();
|
||||
|
||||
item->setSizeHint(COLUMN_NAME, QSize(S*1.1, S*1.1));
|
||||
item->setSizeHint(COLUMN_NAME, QSize(S*1.1, S*1.1));
|
||||
item->setForeground(COLUMN_NAME, QBrush(textColorCategory()));
|
||||
nameLabel->setTextColor(textColorCategory());
|
||||
item->setData(COLUMN_DATA, ROLE_COLOR, GROUPTREEWIDGET_COLOR_CATEGORY);
|
||||
|
||||
ui->treeWidget->addTopLevelItem(item);
|
||||
|
||||
item->setExpanded(expand);
|
||||
|
||||
return item;
|
||||
|
|
@ -334,114 +382,119 @@ QString GroupTreeWidget::itemIdAt(QPoint &point)
|
|||
|
||||
void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList<GroupItemInfo> &itemList)
|
||||
{
|
||||
if (categoryItem == NULL) {
|
||||
return;
|
||||
}
|
||||
if (categoryItem == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
QString filterText = ui->filterLineEdit->text();
|
||||
QString filterText = ui->filterLineEdit->text();
|
||||
|
||||
/* Iterate all items */
|
||||
QList<GroupItemInfo>::const_iterator it;
|
||||
for (it = itemList.begin(); it != itemList.end(); ++it) {
|
||||
const GroupItemInfo &itemInfo = *it;
|
||||
/* Iterate all items */
|
||||
QList<GroupItemInfo>::const_iterator it;
|
||||
for (it = itemList.begin(); it != itemList.end(); ++it) {
|
||||
const GroupItemInfo &itemInfo = *it;
|
||||
|
||||
QTreeWidgetItem *item = NULL;
|
||||
QTreeWidgetItem *item = NULL;
|
||||
|
||||
/* Search exisiting item */
|
||||
int childCount = categoryItem->childCount();
|
||||
for (int child = 0; child < childCount; ++child) {
|
||||
QTreeWidgetItem *childItem = categoryItem->child(child);
|
||||
if (childItem->data(COLUMN_DATA, ROLE_ID).toString() == itemInfo.id) {
|
||||
/* Found child */
|
||||
item = childItem;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Search exisiting item */
|
||||
int childCount = categoryItem->childCount();
|
||||
for (int child = 0; child < childCount; ++child) {
|
||||
QTreeWidgetItem *childItem = categoryItem->child(child);
|
||||
if (childItem->data(COLUMN_DATA, ROLE_ID).toString() == itemInfo.id) {
|
||||
/* Found child */
|
||||
item = childItem;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (item == NULL) {
|
||||
item = new RSTreeWidgetItem(compareRole);
|
||||
item->setData(COLUMN_DATA, ROLE_ID, itemInfo.id);
|
||||
categoryItem->addChild(item);
|
||||
}
|
||||
if (item == NULL) {
|
||||
item = new RSTreeWidgetItem(compareRole);
|
||||
item->setData(COLUMN_DATA, ROLE_ID, itemInfo.id);
|
||||
categoryItem->addChild(item);
|
||||
}
|
||||
|
||||
item->setText(COLUMN_NAME, itemInfo.name);
|
||||
item->setData(COLUMN_DATA, ROLE_NAME, itemInfo.name);
|
||||
item->setData(COLUMN_DATA, ROLE_DESCRIPTION, itemInfo.description);
|
||||
ElidedLabel *nameLabel = NULL;
|
||||
QLabel *waitLabel = NULL;
|
||||
getNameWidget(ui->treeWidget, item, nameLabel, waitLabel);
|
||||
|
||||
/* Set last post */
|
||||
qlonglong lastPost = itemInfo.lastpost.toTime_t();
|
||||
item->setData(COLUMN_DATA, ROLE_LASTPOST, -lastPost); // negative for correct sorting
|
||||
nameLabel->setText(itemInfo.name);
|
||||
item->setData(COLUMN_DATA, ROLE_NAME, itemInfo.name);
|
||||
item->setData(COLUMN_DATA, ROLE_DESCRIPTION, itemInfo.description);
|
||||
|
||||
/* Set visible posts */
|
||||
item->setData(COLUMN_DATA, ROLE_POSTS, -itemInfo.max_visible_posts);// negative for correct sorting
|
||||
/* Set last post */
|
||||
qlonglong lastPost = itemInfo.lastpost.toTime_t();
|
||||
item->setData(COLUMN_DATA, ROLE_LASTPOST, -lastPost); // negative for correct sorting
|
||||
|
||||
/* Set icon */
|
||||
if (ui->treeWidget->itemWidget(item, COLUMN_NAME)) {
|
||||
/* Item is waiting, save icon in role */
|
||||
item->setData(COLUMN_DATA, ROLE_SAVED_ICON, itemInfo.icon);
|
||||
} else {
|
||||
item->setIcon(COLUMN_NAME, itemInfo.icon);
|
||||
}
|
||||
/* Set visible posts */
|
||||
item->setData(COLUMN_DATA, ROLE_POSTS, -itemInfo.max_visible_posts);// negative for correct sorting
|
||||
|
||||
/* Set popularity */
|
||||
QString tooltip = PopularityDefs::tooltip(itemInfo.popularity);
|
||||
/* Set icon */
|
||||
if (waitLabel->isVisible()) {
|
||||
/* Item is waiting, save icon in role */
|
||||
item->setData(COLUMN_DATA, ROLE_SAVED_ICON, itemInfo.icon);
|
||||
} else {
|
||||
item->setIcon(COLUMN_NAME, itemInfo.icon);
|
||||
}
|
||||
|
||||
item->setIcon(COLUMN_POPULARITY, PopularityDefs::icon(itemInfo.popularity));
|
||||
item->setData(COLUMN_DATA, ROLE_POPULARITY, -itemInfo.popularity); // negative for correct sorting
|
||||
/* Set popularity */
|
||||
QString tooltip = PopularityDefs::tooltip(itemInfo.popularity);
|
||||
|
||||
/* Set tooltip */
|
||||
if (itemInfo.adminKey)
|
||||
tooltip += "\n" + tr("You are admin (modify names and description using Edit menu)");
|
||||
else if (itemInfo.publishKey)
|
||||
tooltip += "\n" + tr("You have been granted as publisher (you can post here!)");
|
||||
item->setIcon(COLUMN_POPULARITY, PopularityDefs::icon(itemInfo.popularity));
|
||||
item->setData(COLUMN_DATA, ROLE_POPULARITY, -itemInfo.popularity); // negative for correct sorting
|
||||
|
||||
if(!IS_GROUP_SUBSCRIBED(itemInfo.subscribeFlags))
|
||||
{
|
||||
tooltip += "\n" + QString::number(itemInfo.max_visible_posts) + " messages available" ;
|
||||
tooltip += "\n" + tr("Subscribe to download and read messages") ;
|
||||
}
|
||||
/* Set tooltip */
|
||||
if (itemInfo.adminKey)
|
||||
tooltip += "\n" + tr("You are admin (modify names and description using Edit menu)");
|
||||
else if (itemInfo.publishKey)
|
||||
tooltip += "\n" + tr("You have been granted as publisher (you can post here!)");
|
||||
|
||||
item->setToolTip(COLUMN_NAME, tooltip);
|
||||
item->setToolTip(COLUMN_POPULARITY, tooltip);
|
||||
if(!IS_GROUP_SUBSCRIBED(itemInfo.subscribeFlags))
|
||||
{
|
||||
tooltip += "\n" + QString::number(itemInfo.max_visible_posts) + " messages available" ;
|
||||
tooltip += "\n" + tr("Subscribe to download and read messages") ;
|
||||
}
|
||||
|
||||
item->setData(COLUMN_DATA, ROLE_SUBSCRIBE_FLAGS, itemInfo.subscribeFlags);
|
||||
item->setToolTip(COLUMN_NAME, tooltip);
|
||||
item->setToolTip(COLUMN_POPULARITY, tooltip);
|
||||
|
||||
/* Set color */
|
||||
QBrush brush;
|
||||
if (itemInfo.publishKey) {
|
||||
brush = QBrush(textColorPrivateKey());
|
||||
item->setData(COLUMN_DATA, ROLE_COLOR, GROUPTREEWIDGET_COLOR_PRIVATEKEY);
|
||||
} else {
|
||||
brush = ui->treeWidget->palette().color(QPalette::Text);
|
||||
item->setData(COLUMN_DATA, ROLE_COLOR, GROUPTREEWIDGET_COLOR_STANDARD);
|
||||
}
|
||||
item->setForeground(COLUMN_NAME, brush);
|
||||
item->setData(COLUMN_DATA, ROLE_SUBSCRIBE_FLAGS, itemInfo.subscribeFlags);
|
||||
|
||||
/* Calculate score */
|
||||
calculateScore(item, filterText);
|
||||
}
|
||||
/* Set color */
|
||||
QBrush brush;
|
||||
if (itemInfo.publishKey) {
|
||||
brush = QBrush(textColorPrivateKey());
|
||||
item->setData(COLUMN_DATA, ROLE_COLOR, GROUPTREEWIDGET_COLOR_PRIVATEKEY);
|
||||
} else {
|
||||
brush = ui->treeWidget->palette().color(QPalette::Text);
|
||||
item->setData(COLUMN_DATA, ROLE_COLOR, GROUPTREEWIDGET_COLOR_STANDARD);
|
||||
}
|
||||
item->setForeground(COLUMN_NAME, brush);
|
||||
nameLabel->setTextColor(brush.color());
|
||||
|
||||
/* Remove all items not in list */
|
||||
int child = 0;
|
||||
int childCount = categoryItem->childCount();
|
||||
while (child < childCount) {
|
||||
QString id = categoryItem->child(child)->data(COLUMN_DATA, ROLE_ID).toString();
|
||||
/* Calculate score */
|
||||
calculateScore(item, filterText);
|
||||
}
|
||||
|
||||
for (it = itemList.begin(); it != itemList.end(); ++it) {
|
||||
if (it->id == id) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Remove all items not in list */
|
||||
int child = 0;
|
||||
int childCount = categoryItem->childCount();
|
||||
while (child < childCount) {
|
||||
QString id = categoryItem->child(child)->data(COLUMN_DATA, ROLE_ID).toString();
|
||||
|
||||
if (it == itemList.end()) {
|
||||
delete(categoryItem->takeChild(child));
|
||||
childCount = categoryItem->childCount();
|
||||
} else {
|
||||
++child;
|
||||
}
|
||||
}
|
||||
for (it = itemList.begin(); it != itemList.end(); ++it) {
|
||||
if (it->id == id) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
resort(categoryItem);
|
||||
if (it == itemList.end()) {
|
||||
delete(categoryItem->takeChild(child));
|
||||
childCount = categoryItem->childCount();
|
||||
} else {
|
||||
++child;
|
||||
}
|
||||
}
|
||||
|
||||
resort(categoryItem);
|
||||
}
|
||||
|
||||
void GroupTreeWidget::setUnreadCount(QTreeWidgetItem *item, int unreadCount)
|
||||
|
|
@ -449,19 +502,22 @@ void GroupTreeWidget::setUnreadCount(QTreeWidgetItem *item, int unreadCount)
|
|||
if (item == NULL) {
|
||||
return;
|
||||
}
|
||||
ElidedLabel *nameLabel = NULL;
|
||||
QLabel *waitLabel = NULL;
|
||||
getNameWidget(ui->treeWidget, item, nameLabel, waitLabel);
|
||||
|
||||
QString name = item->data(COLUMN_DATA, ROLE_NAME).toString();
|
||||
QFont font = item->font(COLUMN_NAME);
|
||||
QFont font = nameLabel->font();
|
||||
|
||||
if (unreadCount) {
|
||||
name += QString(" (%1)").arg(unreadCount);
|
||||
name = QString("(%1) ").arg(unreadCount) + name;
|
||||
font.setBold(true);
|
||||
} else {
|
||||
font.setBold(false);
|
||||
}
|
||||
|
||||
item->setText(COLUMN_NAME, name);
|
||||
item->setFont(COLUMN_NAME, font);
|
||||
nameLabel->setText(name);
|
||||
nameLabel->setFont(font);
|
||||
}
|
||||
|
||||
QTreeWidgetItem *GroupTreeWidget::getItemFromId(const QString &id)
|
||||
|
|
@ -507,9 +563,11 @@ bool GroupTreeWidget::setWaiting(const QString &id, bool wait)
|
|||
return false;
|
||||
}
|
||||
|
||||
QWidget *w = ui->treeWidget->itemWidget(item, COLUMN_NAME);
|
||||
ElidedLabel *nameLabel = NULL;
|
||||
QLabel *waitLabel = NULL;
|
||||
getNameWidget(ui->treeWidget, item, nameLabel, waitLabel);
|
||||
if (wait) {
|
||||
if (w) {
|
||||
if (waitLabel->isVisible()) {
|
||||
/* Allready waiting */
|
||||
} else {
|
||||
/* Save icon in role */
|
||||
|
|
@ -519,21 +577,19 @@ bool GroupTreeWidget::setWaiting(const QString &id, bool wait)
|
|||
/* Create empty icon of the same size */
|
||||
QPixmap pixmap(ui->treeWidget->iconSize());
|
||||
pixmap.fill(Qt::transparent);
|
||||
|
||||
item->setIcon(COLUMN_NAME, QIcon(pixmap));
|
||||
|
||||
QLabel *label = new QLabel(this);
|
||||
QMovie *movie = new QMovie(":/images/loader/circleball-16.gif");
|
||||
label->setMovie(movie);
|
||||
|
||||
ui->treeWidget->setItemWidget(item, COLUMN_NAME, label);
|
||||
|
||||
movie->start();
|
||||
/* Show waitLabel and hide nameLabel */
|
||||
nameLabel->setHidden(true);
|
||||
waitLabel->setVisible(true);
|
||||
waitLabel->movie()->start();
|
||||
}
|
||||
} else {
|
||||
if (w) {
|
||||
ui->treeWidget->setItemWidget(item, COLUMN_NAME, NULL);
|
||||
delete(w);
|
||||
if (waitLabel->isVisible()) {
|
||||
/* Show nameLabel and hide waitLabel */
|
||||
waitLabel->movie()->stop();
|
||||
waitLabel->setHidden(true);
|
||||
nameLabel->setVisible(true);
|
||||
|
||||
/* Set icon saved in role */
|
||||
item->setIcon(COLUMN_NAME, item->data(COLUMN_DATA, ROLE_SAVED_ICON).value<QIcon>());
|
||||
|
|
|
|||
|
|
@ -393,10 +393,12 @@ void RSGraphWidget::paintData()
|
|||
paintLine(points, getColor(i));
|
||||
}
|
||||
if(_maxValue > 0.0f)
|
||||
{
|
||||
if(_flags & RSGRAPH_FLAGS_LOG_SCALE_Y)
|
||||
_y_scale = _rec.height()*0.8 / log(_maxValue) ;
|
||||
else
|
||||
_y_scale = _rec.height()*0.8/_maxValue ;
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns a list of points on the bandwidth graph based on the supplied set
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
#include <iostream>
|
||||
|
||||
#include <QDir>
|
||||
#include <QDesktopServices>
|
||||
#include <QDir>
|
||||
#include <QPainter>
|
||||
#include <QTextDocumentFragment>
|
||||
|
||||
#include "RSTextBrowser.h"
|
||||
#include "RSImageBlockWidget.h"
|
||||
|
|
@ -19,7 +20,7 @@ RSTextBrowser::RSTextBrowser(QWidget *parent) :
|
|||
mImageBlockWidget = NULL;
|
||||
mLinkClickActive = true;
|
||||
|
||||
highliter = new RsSyntaxHighlighter(this);
|
||||
highlighter = new RsSyntaxHighlighter(this);
|
||||
|
||||
connect(this, SIGNAL(anchorClicked(QUrl)), this, SLOT(linkClicked(QUrl)));
|
||||
}
|
||||
|
|
@ -73,6 +74,23 @@ void RSTextBrowser::paintEvent(QPaintEvent *event)
|
|||
|
||||
painter.drawText(QRect(QPoint(), vieportWidget->size()), Qt::AlignHCenter | Qt::AlignVCenter | Qt::TextWordWrap, mPlaceholderText);
|
||||
}
|
||||
#ifdef RSTEXTBROWSER_CHECKIMAGE_DEBUG
|
||||
QPainter painter(viewport());
|
||||
QPen pen = painter.pen();
|
||||
pen.setWidth(2);
|
||||
pen.setColor(QColor(qRgba(255,0,0,128)));
|
||||
painter.setPen(pen);
|
||||
painter.drawRect(mCursorRectStart);
|
||||
pen.setColor(QColor(qRgba(0,255,0,128)));
|
||||
painter.setPen(pen);
|
||||
painter.drawRect(mCursorRectLeft);
|
||||
pen.setColor(QColor(qRgba(0,0,255,128)));
|
||||
painter.setPen(pen);
|
||||
painter.drawRect(mCursorRectRight);
|
||||
pen.setColor(QColor(qRgba(0,0,0,128)));
|
||||
painter.setPen(pen);
|
||||
painter.drawRect(mCursorRectEnd);
|
||||
#endif
|
||||
}
|
||||
|
||||
QVariant RSTextBrowser::loadResource(int type, const QUrl &name)
|
||||
|
|
@ -103,6 +121,11 @@ QVariant RSTextBrowser::loadResource(int type, const QUrl &name)
|
|||
if (mImageBlockWidget)
|
||||
mImageBlockWidget->show();
|
||||
|
||||
return getBlockedImage();
|
||||
}
|
||||
|
||||
QPixmap RSTextBrowser::getBlockedImage()
|
||||
{
|
||||
return QPixmap(":/images/imageblocked_24.png");
|
||||
}
|
||||
|
||||
|
|
@ -159,3 +182,61 @@ void RSTextBrowser::activateLinkClick(bool active)
|
|||
{
|
||||
mLinkClickActive = active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief RSTextBrowser::checkImage
|
||||
* @param pos where to check if image is shown in viewport coordinate
|
||||
* @param imageStr return html source of cursor
|
||||
* @return True if an image is under cursor
|
||||
*/
|
||||
bool RSTextBrowser::checkImage(QPoint pos, QString &imageStr)
|
||||
{
|
||||
//Get text cursor under pos. But if pos is under text browser end line this return last cursor.
|
||||
QTextCursor cursor = cursorForPosition(pos);
|
||||
//First get rect of cursor (could be at left or right of image)
|
||||
QRect cursorRectStart = cursorRect(cursor);
|
||||
//Second get text
|
||||
cursor.movePosition(QTextCursor::Left, QTextCursor::MoveAnchor, 1);//To get character just before
|
||||
QRect cursorRectLeft = cursorRect(cursor);
|
||||
cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, 2);
|
||||
QRect cursorRectRight = cursorRect(cursor);
|
||||
imageStr = cursor.selection().toHtml();
|
||||
#ifdef RSTEXTBROWSER_CHECKIMAGE_DEBUG
|
||||
mCursorRectStart = cursorRectStart;
|
||||
mCursorRectLeft = cursorRectLeft;
|
||||
mCursorRectRight = cursorRectRight;
|
||||
|
||||
std::cerr << "cursorRect LTRB :" << cursorRectStart.left() << ";" << cursorRectStart.top() << ";" << cursorRectStart.right() << ";" << cursorRectStart.bottom() << std::endl;
|
||||
std::cerr << "cursorRectLeft :" << cursorRectLeft.left() << ";" << cursorRectLeft.top() << ";" << cursorRectLeft.right() << ";" << cursorRectLeft.bottom() << std::endl;
|
||||
std::cerr << "cursorRectRight :" << cursorRectRight.left() << ";" << cursorRectRight.top() << ";" << cursorRectRight.right() << ";" << cursorRectRight.bottom() << std::endl;
|
||||
std::cerr << "pos XY :" << pos.x() << ";" << pos.y() << std::endl;
|
||||
#endif
|
||||
QRect cursorRectEnd = cursorRectStart;
|
||||
//Finally set left with right of precedent character.
|
||||
if (cursorRectEnd.top() < cursorRectLeft.bottom())
|
||||
{
|
||||
cursorRectEnd.setLeft(cursorRectLeft.right());
|
||||
} else {
|
||||
//Image on new line
|
||||
cursorRectEnd.setLeft(0);
|
||||
}
|
||||
//And set Right with left of next character.
|
||||
if (cursorRectEnd.bottom() > cursorRectRight.top())
|
||||
{
|
||||
cursorRectEnd.setRight(cursorRectRight.left());
|
||||
} else {
|
||||
//New line after Image.
|
||||
}
|
||||
#ifdef RSTEXTBROWSER_CHECKIMAGE_DEBUG
|
||||
mCursorRectEnd = cursorRectEnd;
|
||||
|
||||
std::cerr << "final cursorRect:" << cursorRectEnd.left() << ";" << cursorRectEnd.top() << ";" << cursorRectEnd.right() << ";" << cursorRectEnd.bottom() << std::endl;
|
||||
viewport()->update();
|
||||
#endif
|
||||
//If pos is on text rect
|
||||
if (cursorRectEnd.contains(pos))
|
||||
{
|
||||
return imageStr.indexOf("base64,") != -1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
#include <QTextBrowser>
|
||||
#include "util/RsSyntaxHighlighter.h"
|
||||
|
||||
//#define RSTEXTBROWSER_CHECKIMAGE_DEBUG 1
|
||||
|
||||
class RSImageBlockWidget;
|
||||
|
||||
class RSTextBrowser : public QTextBrowser
|
||||
|
|
@ -18,16 +20,20 @@ public:
|
|||
void setPlaceholderText(const QString &text);
|
||||
void setImageBlockWidget(RSImageBlockWidget *widget);
|
||||
void resetImagesStatus(bool load);
|
||||
QPixmap getBlockedImage();
|
||||
bool checkImage(QPoint pos, QString &imageStr);
|
||||
bool checkImage(QPoint pos) {QString imageStr; return checkImage(pos, imageStr); }
|
||||
|
||||
void activateLinkClick(bool active);
|
||||
|
||||
virtual QVariant loadResource(int type, const QUrl &name);
|
||||
|
||||
QColor textColorQuote() const { return highliter->textColorQuote();}
|
||||
QColor textColorQuote() const { return highlighter->textColorQuote();}
|
||||
bool getShowImages() const { return mShowImages; }
|
||||
|
||||
public slots:
|
||||
void showImages();
|
||||
void setTextColorQuote(QColor textColorQuote) { highliter->setTextColorQuote(textColorQuote);}
|
||||
void setTextColorQuote(QColor textColorQuote) { highlighter->setTextColorQuote(textColorQuote);}
|
||||
|
||||
private slots:
|
||||
void linkClicked(const QUrl &url);
|
||||
|
|
@ -41,7 +47,13 @@ private:
|
|||
bool mShowImages;
|
||||
RSImageBlockWidget *mImageBlockWidget;
|
||||
bool mLinkClickActive;
|
||||
RsSyntaxHighlighter *highliter;
|
||||
RsSyntaxHighlighter *highlighter;
|
||||
#ifdef RSTEXTBROWSER_CHECKIMAGE_DEBUG
|
||||
QRect mCursorRectStart;
|
||||
QRect mCursorRectLeft;
|
||||
QRect mCursorRectRight;
|
||||
QRect mCursorRectEnd;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // RSTEXTBROWSER_H
|
||||
|
|
|
|||
|
|
@ -25,19 +25,24 @@
|
|||
|
||||
/** Constructor */
|
||||
StyledElidedLabel::StyledElidedLabel(QWidget *parent)
|
||||
: ElidedLabel(parent)
|
||||
: ElidedLabel(parent), _lastFactor(-1)
|
||||
{
|
||||
}
|
||||
|
||||
StyledElidedLabel::StyledElidedLabel(const QString &text, QWidget *parent)
|
||||
: ElidedLabel(text, parent)
|
||||
: ElidedLabel(text, parent), _lastFactor(-1)
|
||||
{
|
||||
}
|
||||
|
||||
void StyledElidedLabel::setFontSizeFactor(int factor)
|
||||
{
|
||||
QFont f = font();
|
||||
qreal fontSize = factor * f.pointSizeF() / 100;
|
||||
f.setPointSizeF(fontSize);
|
||||
setFont(f);
|
||||
int newFactor = factor;
|
||||
if (factor > 0) {
|
||||
if (_lastFactor > 0) newFactor = 100 + factor - _lastFactor;
|
||||
_lastFactor = factor;
|
||||
QFont f = font();
|
||||
qreal fontSize = newFactor * f.pointSizeF() / 100;
|
||||
f.setPointSizeF(fontSize);
|
||||
setFont(f);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@ public:
|
|||
StyledElidedLabel(const QString &text, QWidget *parent = NULL);
|
||||
|
||||
void setFontSizeFactor(int factor);
|
||||
|
||||
private:
|
||||
int _lastFactor;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue