Added new class StyledElidedLabel and used it for nick name and channel label.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7757 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2014-12-14 17:05:43 +00:00
parent 2036f379de
commit 78c71ab011
11 changed files with 186 additions and 53 deletions

View file

@ -27,6 +27,7 @@
#include "UIStateHelper.h"
#include "RSTreeWidget.h"
#include "RSTextBrowser.h"
#include "ElidedLabel.h"
class UIStateHelperObject
{
@ -36,6 +37,11 @@ public:
init();
mLabel = widget;
}
UIStateHelperObject(ElidedLabel *widget)
{
init();
mElidedLabel = widget;
}
UIStateHelperObject(QLineEdit *widget)
{
init();
@ -58,6 +64,10 @@ public:
mLabel->setText(text);
}
if (mElidedLabel) {
mElidedLabel->setText(text);
}
if (mLineEdit) {
if (loading && clear) {
mLineEdit->clear();
@ -93,6 +103,10 @@ public:
mLabel->clear();
}
if (mElidedLabel) {
mElidedLabel->clear();
}
if (mLineEdit) {
mLineEdit->clear();
}
@ -112,6 +126,10 @@ public:
return mLabel;
}
if (mElidedLabel) {
return mElidedLabel;
}
if (mLineEdit) {
return mLineEdit;
}
@ -133,6 +151,10 @@ public:
return true;
}
if (mElidedLabel == widget) {
return true;
}
if (mLineEdit == widget) {
return true;
}
@ -151,9 +173,10 @@ public:
bool operator ==(const UIStateHelperObject &data) const
{
if (mLabel == data.mLabel &&
mLineEdit == data.mLineEdit &&
mTreeWidget == data.mTreeWidget &&
mRSTextBrowser == data.mRSTextBrowser) {
mElidedLabel == data.mElidedLabel &&
mLineEdit == data.mLineEdit &&
mTreeWidget == data.mTreeWidget &&
mRSTextBrowser == data.mRSTextBrowser) {
return true;
}
@ -163,9 +186,10 @@ public:
bool operator <(const UIStateHelperObject &data) const
{
if (mLabel < data.mLabel ||
mLineEdit < data.mLineEdit ||
mTreeWidget < data.mTreeWidget ||
mRSTextBrowser < data.mRSTextBrowser) {
mElidedLabel < data.mElidedLabel ||
mLineEdit < data.mLineEdit ||
mTreeWidget < data.mTreeWidget ||
mRSTextBrowser < data.mRSTextBrowser) {
return true;
}
@ -176,6 +200,7 @@ private:
void init()
{
mLabel = NULL;
mElidedLabel = NULL;
mLineEdit = NULL;
mTreeWidget = NULL;
mRSTextBrowser = NULL;
@ -183,6 +208,7 @@ private:
private:
QLabel *mLabel;
ElidedLabel *mElidedLabel;
QLineEdit *mLineEdit;
RSTreeWidget *mTreeWidget;
RSTextBrowser *mRSTextBrowser;
@ -247,6 +273,12 @@ void UIStateHelper::addLoadPlaceholder(int index, QLabel *widget, bool clear, co
data->mLoad.insert(UIStateHelperObject(widget), QPair<QString, bool>(text.isEmpty() ? tr("Loading") : text, clear));
}
void UIStateHelper::addLoadPlaceholder(int index, ElidedLabel *widget, bool clear, const QString &text)
{
UIStateHelperData *data = findData(index, true);
data->mLoad.insert(UIStateHelperObject(widget), QPair<QString, bool>(text.isEmpty() ? tr("Loading") : text, clear));
}
void UIStateHelper::addLoadPlaceholder(int index, QLineEdit *widget, bool clear, const QString &text)
{
UIStateHelperData *data = findData(index, true);