forked from blue/squawk
Merge branch 'master' into fileUpload
This commit is contained in:
commit
09749bac51
100 changed files with 6396 additions and 551 deletions
|
@ -10,6 +10,8 @@ set(CMAKE_AUTOUIC ON)
|
|||
find_package(Qt5Widgets CONFIG REQUIRED)
|
||||
find_package(Qt5DBus CONFIG REQUIRED)
|
||||
|
||||
add_subdirectory(widgets)
|
||||
|
||||
set(squawkUI_SRC
|
||||
squawk.cpp
|
||||
models/accounts.cpp
|
||||
|
@ -22,27 +24,20 @@ set(squawkUI_SRC
|
|||
models/room.cpp
|
||||
models/abstractparticipant.cpp
|
||||
models/participant.cpp
|
||||
widgets/conversation.cpp
|
||||
widgets/chat.cpp
|
||||
widgets/room.cpp
|
||||
widgets/newcontact.cpp
|
||||
widgets/accounts.cpp
|
||||
widgets/account.cpp
|
||||
widgets/joinconference.cpp
|
||||
utils/messageline.cpp
|
||||
utils//message.cpp
|
||||
utils/resizer.cpp
|
||||
utils/image.cpp
|
||||
utils/flowlayout.cpp
|
||||
utils/badge.cpp
|
||||
utils/progress.cpp
|
||||
utils/comboboxdelegate.cpp
|
||||
)
|
||||
|
||||
# Tell CMake to create the helloworld executable
|
||||
add_library(squawkUI ${squawkUI_SRC})
|
||||
|
||||
# Use the Widgets module from Qt 5.
|
||||
target_link_libraries(squawkUI squawkWidgets)
|
||||
target_link_libraries(squawkUI Qt5::Widgets)
|
||||
target_link_libraries(squawkUI Qt5::DBus)
|
||||
|
||||
# Install the executable
|
||||
install(TARGETS squawkUI DESTINATION lib)
|
||||
|
|
|
@ -32,6 +32,15 @@ Models::AbstractParticipant::AbstractParticipant(Models::Item::Type p_type, cons
|
|||
}
|
||||
}
|
||||
|
||||
Models::AbstractParticipant::AbstractParticipant(const Models::AbstractParticipant& other):
|
||||
Item(other),
|
||||
availability(other.availability),
|
||||
lastActivity(other.lastActivity),
|
||||
status(other.status)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Models::AbstractParticipant::~AbstractParticipant()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ class AbstractParticipant : public Models::Item
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit AbstractParticipant(Type p_type, const QMap<QString, QVariant> &data, Item *parentItem = 0);
|
||||
AbstractParticipant(const AbstractParticipant& other);
|
||||
~AbstractParticipant();
|
||||
|
||||
virtual int columnCount() const override;
|
||||
|
|
|
@ -26,6 +26,7 @@ Models::Account::Account(const QMap<QString, QVariant>& data, Models::Item* pare
|
|||
server(data.value("server").toString()),
|
||||
resource(data.value("resource").toString()),
|
||||
error(data.value("error").toString()),
|
||||
avatarPath(data.value("avatarPath").toString()),
|
||||
state(Shared::disconnected),
|
||||
availability(Shared::offline)
|
||||
{
|
||||
|
@ -151,7 +152,7 @@ QVariant Models::Account::data(int column) const
|
|||
case 1:
|
||||
return server;
|
||||
case 2:
|
||||
return Shared::connectionStateNames[state];
|
||||
return QCoreApplication::translate("Global", Shared::connectionStateNames[state].toLatin1());
|
||||
case 3:
|
||||
return error;
|
||||
case 4:
|
||||
|
@ -159,9 +160,11 @@ QVariant Models::Account::data(int column) const
|
|||
case 5:
|
||||
return password;
|
||||
case 6:
|
||||
return Shared::availabilityNames[availability];
|
||||
return QCoreApplication::translate("Global", Shared::availabilityNames[availability].toLatin1());
|
||||
case 7:
|
||||
return resource;
|
||||
case 8:
|
||||
return avatarPath;
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -169,7 +172,7 @@ QVariant Models::Account::data(int column) const
|
|||
|
||||
int Models::Account::columnCount() const
|
||||
{
|
||||
return 8;
|
||||
return 9;
|
||||
}
|
||||
|
||||
void Models::Account::update(const QString& field, const QVariant& value)
|
||||
|
@ -190,6 +193,8 @@ void Models::Account::update(const QString& field, const QVariant& value)
|
|||
setResource(value.toString());
|
||||
} else if (field == "error") {
|
||||
setError(value.toString());
|
||||
} else if (field == "avatarPath") {
|
||||
setAvatarPath(value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,3 +229,24 @@ void Models::Account::toOfflineState()
|
|||
setAvailability(Shared::offline);
|
||||
Item::toOfflineState();
|
||||
}
|
||||
|
||||
QString Models::Account::getAvatarPath()
|
||||
{
|
||||
return avatarPath;
|
||||
}
|
||||
|
||||
void Models::Account::setAvatarPath(const QString& path)
|
||||
{
|
||||
avatarPath = path;
|
||||
changed(8); //it's uncoditional because the path doesn't change when one avatar of the same type replaces another, sha1 sums checks are on the backend
|
||||
}
|
||||
|
||||
QString Models::Account::getBareJid() const
|
||||
{
|
||||
return login + "@" + server;
|
||||
}
|
||||
|
||||
QString Models::Account::getFullJid() const
|
||||
{
|
||||
return getBareJid() + "/" + resource;
|
||||
}
|
||||
|
|
|
@ -50,6 +50,9 @@ namespace Models {
|
|||
void setError(const QString& p_resource);
|
||||
QString getError() const;
|
||||
|
||||
void setAvatarPath(const QString& path);
|
||||
QString getAvatarPath();
|
||||
|
||||
void setAvailability(Shared::Availability p_avail);
|
||||
void setAvailability(unsigned int p_avail);
|
||||
Shared::Availability getAvailability() const;
|
||||
|
@ -61,12 +64,16 @@ namespace Models {
|
|||
|
||||
void update(const QString& field, const QVariant& value);
|
||||
|
||||
QString getBareJid() const;
|
||||
QString getFullJid() const;
|
||||
|
||||
private:
|
||||
QString login;
|
||||
QString password;
|
||||
QString server;
|
||||
QString resource;
|
||||
QString error;
|
||||
QString avatarPath;
|
||||
Shared::ConnectionState state;
|
||||
Shared::Availability availability;
|
||||
|
||||
|
|
|
@ -20,13 +20,9 @@
|
|||
#include "../../global.h"
|
||||
|
||||
#include <QIcon>
|
||||
#include <QDebug>
|
||||
|
||||
std::deque<QString> Models::Accounts::columns = {
|
||||
"name",
|
||||
"server",
|
||||
"state",
|
||||
"error"
|
||||
};
|
||||
std::deque<QString> Models::Accounts::columns = {"Name", "Server", "State", "Error"};
|
||||
|
||||
Models::Accounts::Accounts(QObject* parent):
|
||||
QAbstractTableModel(parent),
|
||||
|
@ -72,7 +68,7 @@ int Models::Accounts::rowCount ( const QModelIndex& parent ) const
|
|||
QVariant Models::Accounts::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
|
||||
return columns[section];
|
||||
return tr(columns[section].toLatin1());
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -81,8 +77,19 @@ QVariant Models::Accounts::headerData(int section, Qt::Orientation orientation,
|
|||
void Models::Accounts::addAccount(Account* account)
|
||||
{
|
||||
beginInsertRows(QModelIndex(), accs.size(), accs.size());
|
||||
accs.push_back(account);
|
||||
connect(account, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(onAccountChanged(Models::Item*, int, int)));
|
||||
int index = 0;
|
||||
std::deque<Account*>::const_iterator before = accs.begin();
|
||||
while (before != accs.end()) {
|
||||
Account* bfr = *before;
|
||||
if (bfr->getDisplayedName() > account->getDisplayedName()) {
|
||||
break;
|
||||
}
|
||||
index++;
|
||||
before++;
|
||||
}
|
||||
|
||||
accs.insert(before, account);
|
||||
connect(account, &Account::childChanged, this, &Accounts::onAccountChanged);
|
||||
endInsertRows();
|
||||
|
||||
emit sizeChanged(accs.size());
|
||||
|
@ -96,8 +103,32 @@ void Models::Accounts::onAccountChanged(Item* item, int row, int col)
|
|||
return; //it means the signal is emitted by one of accounts' children, not exactly him, this model has no interest in that
|
||||
}
|
||||
|
||||
if (col == 0) {
|
||||
int newRow = 0;
|
||||
std::deque<Account*>::const_iterator before = accs.begin();
|
||||
while (before != accs.end()) {
|
||||
Item* bfr = *before;
|
||||
if (bfr->getDisplayedName() > item->getDisplayedName()) {
|
||||
break;
|
||||
}
|
||||
newRow++;
|
||||
before++;
|
||||
}
|
||||
|
||||
if (newRow != row || (before != accs.end() && *before != item)) {
|
||||
emit beginMoveRows(createIndex(row, 0), row, row, createIndex(newRow, 0), newRow);
|
||||
std::deque<Account*>::const_iterator old = accs.begin();
|
||||
old += row;
|
||||
accs.erase(old);
|
||||
accs.insert(before, acc);
|
||||
emit endMoveRows();
|
||||
|
||||
row = newRow;
|
||||
}
|
||||
}
|
||||
|
||||
if (col < columnCount(QModelIndex())) {
|
||||
emit dataChanged(createIndex(row, col, this), createIndex(row, col, this));
|
||||
emit dataChanged(createIndex(row, col), createIndex(row, col));
|
||||
}
|
||||
emit changed();
|
||||
}
|
||||
|
@ -112,7 +143,7 @@ void Models::Accounts::removeAccount(int index)
|
|||
{
|
||||
Account* account = accs[index];
|
||||
beginRemoveRows(QModelIndex(), index, index);
|
||||
disconnect(account, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(onAccountChanged(Models::Item*, int, int)));
|
||||
disconnect(account, &Account::childChanged, this, &Accounts::onAccountChanged);
|
||||
accs.erase(accs.begin() + index);
|
||||
endRemoveRows();
|
||||
|
||||
|
|
|
@ -25,14 +25,26 @@ Models::Contact::Contact(const QString& p_jid ,const QMap<QString, QVariant> &da
|
|||
jid(p_jid),
|
||||
availability(Shared::offline),
|
||||
state(Shared::none),
|
||||
avatarState(Shared::Avatar::empty),
|
||||
presences(),
|
||||
messages(),
|
||||
childMessages(0)
|
||||
childMessages(0),
|
||||
status(),
|
||||
avatarPath()
|
||||
{
|
||||
QMap<QString, QVariant>::const_iterator itr = data.find("state");
|
||||
if (itr != data.end()) {
|
||||
setState(itr.value().toUInt());
|
||||
}
|
||||
|
||||
itr = data.find("avatarState");
|
||||
if (itr != data.end()) {
|
||||
setAvatarState(itr.value().toUInt());
|
||||
}
|
||||
itr = data.find("avatarPath");
|
||||
if (itr != data.end()) {
|
||||
setAvatarPath(itr.value().toString());
|
||||
}
|
||||
}
|
||||
|
||||
Models::Contact::~Contact()
|
||||
|
@ -100,7 +112,7 @@ void Models::Contact::setStatus(const QString& p_state)
|
|||
|
||||
int Models::Contact::columnCount() const
|
||||
{
|
||||
return 6;
|
||||
return 8;
|
||||
}
|
||||
|
||||
QVariant Models::Contact::data(int column) const
|
||||
|
@ -118,6 +130,10 @@ QVariant Models::Contact::data(int column) const
|
|||
return getMessagesCount();
|
||||
case 5:
|
||||
return getStatus();
|
||||
case 6:
|
||||
return static_cast<quint8>(getAvatarState());
|
||||
case 7:
|
||||
return getAvatarPath();
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -142,6 +158,10 @@ void Models::Contact::update(const QString& field, const QVariant& value)
|
|||
setAvailability(value.toUInt());
|
||||
} else if (field == "state") {
|
||||
setState(value.toUInt());
|
||||
} else if (field == "avatarState") {
|
||||
setAvatarState(value.toUInt());
|
||||
} else if (field == "avatarPath") {
|
||||
setAvatarPath(value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -209,7 +229,7 @@ void Models::Contact::refresh()
|
|||
void Models::Contact::_removeChild(int index)
|
||||
{
|
||||
Item* child = childItems[index];
|
||||
disconnect(child, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(refresh()));
|
||||
disconnect(child, &Item::childChanged, this, &Contact::refresh);
|
||||
Item::_removeChild(index);
|
||||
refresh();
|
||||
}
|
||||
|
@ -217,7 +237,7 @@ void Models::Contact::_removeChild(int index)
|
|||
void Models::Contact::appendChild(Models::Item* child)
|
||||
{
|
||||
Item::appendChild(child);
|
||||
connect(child, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(refresh()));
|
||||
connect(child, &Item::childChanged, this, &Contact::refresh);
|
||||
refresh();
|
||||
}
|
||||
|
||||
|
@ -304,7 +324,7 @@ void Models::Contact::toOfflineState()
|
|||
emit childIsAboutToBeRemoved(this, 0, childItems.size());
|
||||
for (int i = 0; i < childItems.size(); ++i) {
|
||||
Item* item = childItems[i];
|
||||
disconnect(item, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(refresh()));
|
||||
disconnect(item, &Item::childChanged, this, &Contact::refresh);
|
||||
Item::_removeChild(i);
|
||||
item->deleteLater();
|
||||
}
|
||||
|
@ -313,3 +333,74 @@ void Models::Contact::toOfflineState()
|
|||
emit childRemoved();
|
||||
refresh();
|
||||
}
|
||||
|
||||
QString Models::Contact::getDisplayedName() const
|
||||
{
|
||||
return getContactName();
|
||||
}
|
||||
|
||||
bool Models::Contact::columnInvolvedInDisplay(int col)
|
||||
{
|
||||
return Item::columnInvolvedInDisplay(col) && col == 1;
|
||||
}
|
||||
|
||||
Models::Contact * Models::Contact::copy() const
|
||||
{
|
||||
Contact* cnt = new Contact(*this);
|
||||
return cnt;
|
||||
}
|
||||
|
||||
Models::Contact::Contact(const Models::Contact& other):
|
||||
Item(other),
|
||||
jid(other.jid),
|
||||
availability(other.availability),
|
||||
state(other.state),
|
||||
presences(),
|
||||
messages(other.messages),
|
||||
childMessages(0)
|
||||
{
|
||||
for (const Presence* pres : other.presences) {
|
||||
Presence* pCopy = new Presence(*pres);
|
||||
presences.insert(pCopy->getName(), pCopy);
|
||||
Item::appendChild(pCopy);
|
||||
connect(pCopy, &Item::childChanged, this, &Contact::refresh);
|
||||
}
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
QString Models::Contact::getAvatarPath() const
|
||||
{
|
||||
return avatarPath;
|
||||
}
|
||||
|
||||
Shared::Avatar Models::Contact::getAvatarState() const
|
||||
{
|
||||
return avatarState;
|
||||
}
|
||||
|
||||
void Models::Contact::setAvatarPath(const QString& path)
|
||||
{
|
||||
if (path != avatarPath) {
|
||||
avatarPath = path;
|
||||
changed(7);
|
||||
}
|
||||
}
|
||||
|
||||
void Models::Contact::setAvatarState(Shared::Avatar p_state)
|
||||
{
|
||||
if (avatarState != p_state) {
|
||||
avatarState = p_state;
|
||||
changed(6);
|
||||
}
|
||||
}
|
||||
|
||||
void Models::Contact::setAvatarState(unsigned int p_state)
|
||||
{
|
||||
if (p_state <= static_cast<quint8>(Shared::Avatar::valid)) {
|
||||
Shared::Avatar state = static_cast<Shared::Avatar>(p_state);
|
||||
setAvatarState(state);
|
||||
} else {
|
||||
qDebug() << "An attempt to set invalid avatar state" << p_state << "to the contact" << jid << ", skipping";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,11 +34,14 @@ class Contact : public Item
|
|||
public:
|
||||
typedef std::deque<Shared::Message> Messages;
|
||||
Contact(const QString& p_jid, const QMap<QString, QVariant> &data, Item *parentItem = 0);
|
||||
Contact(const Contact& other);
|
||||
~Contact();
|
||||
|
||||
QString getJid() const;
|
||||
Shared::Availability getAvailability() const;
|
||||
Shared::SubscriptionState getState() const;
|
||||
Shared::Avatar getAvatarState() const;
|
||||
QString getAvatarPath() const;
|
||||
QIcon getStatusIcon(bool big = false) const;
|
||||
|
||||
int columnCount() const override;
|
||||
|
@ -57,9 +60,13 @@ public:
|
|||
unsigned int getMessagesCount() const;
|
||||
void dropMessages();
|
||||
void getMessages(Messages& container) const;
|
||||
QString getDisplayedName() const override;
|
||||
|
||||
Contact* copy() const;
|
||||
|
||||
protected:
|
||||
void _removeChild(int index) override;
|
||||
bool columnInvolvedInDisplay(int col) override;
|
||||
|
||||
protected slots:
|
||||
void refresh();
|
||||
|
@ -70,6 +77,9 @@ protected:
|
|||
void setAvailability(unsigned int p_state);
|
||||
void setState(Shared::SubscriptionState p_state);
|
||||
void setState(unsigned int p_state);
|
||||
void setAvatarState(Shared::Avatar p_state);
|
||||
void setAvatarState(unsigned int p_state);
|
||||
void setAvatarPath(const QString& path);
|
||||
void setJid(const QString p_jid);
|
||||
void setStatus(const QString& p_state);
|
||||
|
||||
|
@ -77,10 +87,12 @@ private:
|
|||
QString jid;
|
||||
Shared::Availability availability;
|
||||
Shared::SubscriptionState state;
|
||||
Shared::Avatar avatarState;
|
||||
QMap<QString, Presence*> presences;
|
||||
Messages messages;
|
||||
unsigned int childMessages;
|
||||
QString status;
|
||||
QString avatarPath;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ Models::Group::~Group()
|
|||
void Models::Group::appendChild(Models::Item* child)
|
||||
{
|
||||
Item::appendChild(child);
|
||||
connect(child, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(refresh()));
|
||||
connect(child, &Item::childChanged, this, &Group::refresh);
|
||||
changed(1);
|
||||
refresh();
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ QVariant Models::Group::data(int column) const
|
|||
void Models::Group::_removeChild(int index)
|
||||
{
|
||||
Item* child = childItems[index];
|
||||
disconnect(child, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(refresh()));
|
||||
disconnect(child, &Item::childChanged, this, &Group::refresh);
|
||||
Item::_removeChild(index);
|
||||
changed(1);
|
||||
refresh();
|
||||
|
@ -103,3 +103,16 @@ unsigned int Models::Group::getOnlineContacts() const
|
|||
|
||||
return amount;
|
||||
}
|
||||
|
||||
bool Models::Group::hasContact(const QString& jid) const
|
||||
{
|
||||
for (Models::Item* item : childItems) {
|
||||
if (item->type == Item::contact) {
|
||||
const Contact* cnt = static_cast<const Contact*>(item);
|
||||
if (cnt->getJid() == jid) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@ public:
|
|||
|
||||
unsigned int getUnreadMessages() const;
|
||||
unsigned int getOnlineContacts() const;
|
||||
|
||||
bool hasContact(const QString& jid) const;
|
||||
|
||||
protected:
|
||||
void _removeChild(int index) override;
|
||||
|
|
|
@ -34,6 +34,15 @@ Models::Item::Item(Type p_type, const QMap<QString, QVariant> &p_data, Item *p_p
|
|||
}
|
||||
}
|
||||
|
||||
Models::Item::Item(const Models::Item& other):
|
||||
QObject(),
|
||||
type(other.type),
|
||||
name(other.name),
|
||||
childItems(),
|
||||
parent(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
Models::Item::~Item()
|
||||
{
|
||||
std::deque<Item*>::const_iterator itr = childItems.begin();
|
||||
|
@ -55,25 +64,37 @@ void Models::Item::setName(const QString& p_name)
|
|||
void Models::Item::appendChild(Models::Item* child)
|
||||
{
|
||||
bool moving = false;
|
||||
int oldRow = child->row();
|
||||
int newRow = this->childCount();
|
||||
int newRow = 0;
|
||||
std::deque<Item*>::const_iterator before = childItems.begin();
|
||||
while (before != childItems.end()) {
|
||||
Item* bfr = *before;
|
||||
if (bfr->type > child->type) {
|
||||
break;
|
||||
} else if (bfr->type == child->type && bfr->getDisplayedName() > child->getDisplayedName()) {
|
||||
break;
|
||||
}
|
||||
newRow++;
|
||||
before++;
|
||||
}
|
||||
|
||||
if (child->parent != 0) {
|
||||
int oldRow = child->row();
|
||||
moving = true;
|
||||
emit childIsAboutToBeMoved(child->parent, oldRow, oldRow, this, newRow);
|
||||
child->parent->_removeChild(oldRow);
|
||||
} else {
|
||||
emit childIsAboutToBeInserted(this, newRow, newRow);
|
||||
}
|
||||
childItems.push_back(child);
|
||||
childItems.insert(before, child);
|
||||
child->parent = this;
|
||||
|
||||
QObject::connect(child, SIGNAL(childChanged(Models::Item*, int, int)), this, SIGNAL(childChanged(Models::Item*, int, int)));
|
||||
QObject::connect(child, SIGNAL(childIsAboutToBeInserted(Item*, int, int)), this, SIGNAL(childIsAboutToBeInserted(Item*, int, int)));
|
||||
QObject::connect(child, SIGNAL(childInserted()), this, SIGNAL(childInserted()));
|
||||
QObject::connect(child, SIGNAL(childIsAboutToBeRemoved(Item*, int, int)), this, SIGNAL(childIsAboutToBeRemoved(Item*, int, int)));
|
||||
QObject::connect(child, SIGNAL(childRemoved()), this, SIGNAL(childRemoved()));
|
||||
QObject::connect(child, SIGNAL(childIsAboutToBeMoved(Item*, int, int, Item*, int)), this, SIGNAL(childIsAboutToBeMoved(Item*, int, int, Item*, int)));
|
||||
QObject::connect(child, SIGNAL(childMoved()), this, SIGNAL(childMoved()));
|
||||
QObject::connect(child, &Item::childChanged, this, &Item::childChanged);
|
||||
QObject::connect(child, &Item::childIsAboutToBeInserted, this, &Item::childIsAboutToBeInserted);
|
||||
QObject::connect(child, &Item::childInserted, this, &Item::childInserted);
|
||||
QObject::connect(child, &Item::childIsAboutToBeRemoved, this, &Item::childIsAboutToBeRemoved);
|
||||
QObject::connect(child, &Item::childRemoved, this, &Item::childRemoved);
|
||||
QObject::connect(child, &Item::childIsAboutToBeMoved, this, &Item::childIsAboutToBeMoved);
|
||||
QObject::connect(child, &Item::childMoved, this, &Item::childMoved);
|
||||
|
||||
if (moving) {
|
||||
emit childMoved();
|
||||
|
@ -120,7 +141,7 @@ const Models::Item * Models::Item::parentItemConst() const
|
|||
|
||||
int Models::Item::columnCount() const
|
||||
{
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
QString Models::Item::getName() const
|
||||
|
@ -147,13 +168,13 @@ void Models::Item::_removeChild(int index)
|
|||
{
|
||||
Item* child = childItems[index];
|
||||
|
||||
QObject::disconnect(child, SIGNAL(childChanged(Models::Item*, int, int)), this, SIGNAL(childChanged(Models::Item*, int, int)));
|
||||
QObject::disconnect(child, SIGNAL(childIsAboutToBeInserted(Item*, int, int)), this, SIGNAL(childIsAboutToBeInserted(Item*, int, int)));
|
||||
QObject::disconnect(child, SIGNAL(childInserted()), this, SIGNAL(childInserted()));
|
||||
QObject::disconnect(child, SIGNAL(childIsAboutToBeRemoved(Item*, int, int)), this, SIGNAL(childIsAboutToBeRemoved(Item*, int, int)));
|
||||
QObject::disconnect(child, SIGNAL(childRemoved()), this, SIGNAL(childRemoved()));
|
||||
QObject::disconnect(child, SIGNAL(childIsAboutToBeMoved(Item*, int, int, Item*, int)), this, SIGNAL(childIsAboutToBeMoved(Item*, int, int, Item*, int)));
|
||||
QObject::disconnect(child, SIGNAL(childMoved()), this, SIGNAL(childMoved()));
|
||||
QObject::disconnect(child, &Item::childChanged, this, &Item::childChanged);
|
||||
QObject::disconnect(child, &Item::childIsAboutToBeInserted, this, &Item::childIsAboutToBeInserted);
|
||||
QObject::disconnect(child, &Item::childInserted, this, &Item::childInserted);
|
||||
QObject::disconnect(child, &Item::childIsAboutToBeRemoved, this, &Item::childIsAboutToBeRemoved);
|
||||
QObject::disconnect(child, &Item::childRemoved, this, &Item::childRemoved);
|
||||
QObject::disconnect(child, &Item::childIsAboutToBeMoved, this, &Item::childIsAboutToBeMoved);
|
||||
QObject::disconnect(child, &Item::childMoved, this, &Item::childMoved);
|
||||
|
||||
childItems.erase(childItems.begin() + index);
|
||||
child->parent = 0;
|
||||
|
@ -212,3 +233,62 @@ QString Models::Item::getAccountName() const
|
|||
}
|
||||
return acc->getName();
|
||||
}
|
||||
|
||||
Shared::Availability Models::Item::getAccountAvailability() const
|
||||
{
|
||||
const Account* acc = static_cast<const Account*>(getParentAccount());
|
||||
if (acc == 0) {
|
||||
return Shared::offline;
|
||||
}
|
||||
return acc->getAvailability();
|
||||
}
|
||||
|
||||
Shared::ConnectionState Models::Item::getAccountConnectionState() const
|
||||
{
|
||||
const Account* acc = static_cast<const Account*>(getParentAccount());
|
||||
if (acc == 0) {
|
||||
return Shared::disconnected;
|
||||
}
|
||||
return acc->getState();
|
||||
}
|
||||
|
||||
QString Models::Item::getDisplayedName() const
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
void Models::Item::onChildChanged(Models::Item* item, int row, int col)
|
||||
{
|
||||
Item* parent = item->parentItem();
|
||||
if (parent != 0 && parent == this) {
|
||||
if (item->columnInvolvedInDisplay(col)) {
|
||||
int newRow = 0;
|
||||
std::deque<Item*>::const_iterator before = childItems.begin();
|
||||
while (before != childItems.end()) {
|
||||
Item* bfr = *before;
|
||||
if (bfr->type > item->type) {
|
||||
break;
|
||||
} else if (bfr->type == item->type && bfr->getDisplayedName() > item->getDisplayedName()) {
|
||||
break;
|
||||
}
|
||||
newRow++;
|
||||
before++;
|
||||
}
|
||||
|
||||
if (newRow != row || (before != childItems.end() && *before != item)) {
|
||||
emit childIsAboutToBeMoved(this, row, row, this, newRow);
|
||||
std::deque<Item*>::const_iterator old = childItems.begin();
|
||||
old += row;
|
||||
childItems.erase(old);
|
||||
childItems.insert(before, item);
|
||||
emit childMoved();
|
||||
}
|
||||
}
|
||||
}
|
||||
emit childChanged(item, row, col);
|
||||
}
|
||||
|
||||
bool Models::Item::columnInvolvedInDisplay(int col)
|
||||
{
|
||||
return col == 0;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include <deque>
|
||||
|
||||
#include "../../global.h"
|
||||
|
||||
namespace Models {
|
||||
|
||||
class Item : public QObject{
|
||||
|
@ -41,6 +43,7 @@ class Item : public QObject{
|
|||
};
|
||||
|
||||
explicit Item(Type p_type, const QMap<QString, QVariant> &data, Item *parentItem = 0);
|
||||
Item(const Item& other);
|
||||
~Item();
|
||||
|
||||
signals:
|
||||
|
@ -55,6 +58,7 @@ class Item : public QObject{
|
|||
public:
|
||||
virtual void appendChild(Item *child);
|
||||
virtual void removeChild(int index);
|
||||
virtual QString getDisplayedName() const;
|
||||
QString getName() const;
|
||||
void setName(const QString& name);
|
||||
|
||||
|
@ -70,14 +74,20 @@ class Item : public QObject{
|
|||
QString getAccountName() const;
|
||||
QString getAccountJid() const;
|
||||
QString getAccountResource() const;
|
||||
Shared::ConnectionState getAccountConnectionState() const;
|
||||
Shared::Availability getAccountAvailability() const;
|
||||
|
||||
const Type type;
|
||||
|
||||
protected:
|
||||
virtual void changed(int col);
|
||||
virtual void _removeChild(int index);
|
||||
virtual bool columnInvolvedInDisplay(int col);
|
||||
const Item* getParentAccount() const;
|
||||
|
||||
protected slots:
|
||||
void onChildChanged(Models::Item* item, int row, int col);
|
||||
|
||||
protected:
|
||||
QString name;
|
||||
std::deque<Item*> childItems;
|
||||
|
|
|
@ -24,6 +24,13 @@ Models::Presence::Presence(const QMap<QString, QVariant>& data, Item* parentItem
|
|||
{
|
||||
}
|
||||
|
||||
Models::Presence::Presence(const Models::Presence& other):
|
||||
AbstractParticipant(other),
|
||||
messages(other.messages)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Models::Presence::~Presence()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ class Presence : public Models::AbstractParticipant
|
|||
public:
|
||||
typedef std::deque<Shared::Message> Messages;
|
||||
explicit Presence(const QMap<QString, QVariant> &data, Item *parentItem = 0);
|
||||
Presence(const Presence& other);
|
||||
~Presence();
|
||||
|
||||
int columnCount() const override;
|
||||
|
|
|
@ -193,15 +193,15 @@ QString Models::Room::getStatusText() const
|
|||
{
|
||||
if (autoJoin) {
|
||||
if (joined) {
|
||||
return "Subscribed";
|
||||
return tr("Subscribed");
|
||||
} else {
|
||||
return "Temporarily unsubscribed";
|
||||
return tr("Temporarily unsubscribed");
|
||||
}
|
||||
} else {
|
||||
if (joined) {
|
||||
return "Temporarily subscribed";
|
||||
return tr("Temporarily subscribed");
|
||||
} else {
|
||||
return "Unsubscribed";
|
||||
return tr("Unsubscribed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -238,7 +238,6 @@ void Models::Room::toOfflineState()
|
|||
emit childIsAboutToBeRemoved(this, 0, childItems.size());
|
||||
for (int i = 0; i < childItems.size(); ++i) {
|
||||
Item* item = childItems[i];
|
||||
disconnect(item, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(refresh()));
|
||||
Item::_removeChild(i);
|
||||
item->deleteLater();
|
||||
}
|
||||
|
@ -309,3 +308,13 @@ void Models::Room::setSubject(const QString& sub)
|
|||
changed(6);
|
||||
}
|
||||
}
|
||||
|
||||
QString Models::Room::getDisplayedName() const
|
||||
{
|
||||
return getRoomName();
|
||||
}
|
||||
|
||||
bool Models::Room::columnInvolvedInDisplay(int col)
|
||||
{
|
||||
return Item::columnInvolvedInDisplay(col) && col == 1;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "item.h"
|
||||
#include "participant.h"
|
||||
#include "../global.h"
|
||||
#include "../../global.h"
|
||||
|
||||
namespace Models {
|
||||
|
||||
|
@ -68,10 +68,14 @@ public:
|
|||
void removeParticipant(const QString& name);
|
||||
|
||||
void toOfflineState() override;
|
||||
QString getDisplayedName() const override;
|
||||
|
||||
private:
|
||||
void handleParticipantUpdate(std::map<QString, Participant*>::const_iterator itr, const QMap<QString, QVariant>& data);
|
||||
|
||||
protected:
|
||||
bool columnInvolvedInDisplay(int col) override;
|
||||
|
||||
private:
|
||||
bool autoJoin;
|
||||
bool joined;
|
||||
|
|
|
@ -21,8 +21,6 @@
|
|||
#include <QIcon>
|
||||
#include <QFont>
|
||||
|
||||
using namespace Models;
|
||||
|
||||
Models::Roster::Roster(QObject* parent):
|
||||
QAbstractItemModel(parent),
|
||||
accountsModel(new Accounts()),
|
||||
|
@ -31,17 +29,14 @@ Models::Roster::Roster(QObject* parent):
|
|||
groups(),
|
||||
contacts()
|
||||
{
|
||||
connect(accountsModel,
|
||||
SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)),
|
||||
this,
|
||||
SLOT(onAccountDataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)));
|
||||
connect(root, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(onChildChanged(Models::Item*, int, int)));
|
||||
connect(root, SIGNAL(childIsAboutToBeInserted(Item*, int, int)), this, SLOT(onChildIsAboutToBeInserted(Item*, int, int)));
|
||||
connect(root, SIGNAL(childInserted()), this, SLOT(onChildInserted()));
|
||||
connect(root, SIGNAL(childIsAboutToBeRemoved(Item*, int, int)), this, SLOT(onChildIsAboutToBeRemoved(Item*, int, int)));
|
||||
connect(root, SIGNAL(childRemoved()), this, SLOT(onChildRemoved()));
|
||||
connect(root, SIGNAL(childIsAboutToBeMoved(Item*, int, int, Item*, int)), this, SLOT(onChildIsAboutToBeMoved(Item*, int, int, Item*, int)));
|
||||
connect(root, SIGNAL(childMoved()), this, SLOT(onChildMoved()));
|
||||
connect(accountsModel, &Accounts::dataChanged, this, &Roster::onAccountDataChanged);
|
||||
connect(root, &Item::childChanged, this, &Roster::onChildChanged);
|
||||
connect(root, &Item::childIsAboutToBeInserted, this, &Roster::onChildIsAboutToBeInserted);
|
||||
connect(root, &Item::childInserted, this, &Roster::onChildInserted);
|
||||
connect(root, &Item::childIsAboutToBeRemoved, this, &Roster::onChildIsAboutToBeRemoved);
|
||||
connect(root, &Item::childRemoved, this, &Roster::onChildRemoved);
|
||||
connect(root, &Item::childIsAboutToBeMoved, this, &Roster::onChildIsAboutToBeMoved);
|
||||
connect(root, &Item::childMoved, this, &Roster::onChildMoved);
|
||||
}
|
||||
|
||||
Models::Roster::~Roster()
|
||||
|
@ -70,6 +65,10 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
|
|||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
{
|
||||
if (index.column() != 0) {
|
||||
result = "";
|
||||
break;
|
||||
}
|
||||
switch (item->type) {
|
||||
case Item::group: {
|
||||
Group* gr = static_cast<Group*>(item);
|
||||
|
@ -78,7 +77,7 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
|
|||
str += gr->getName();
|
||||
unsigned int amount = gr->getUnreadMessages();
|
||||
if (amount > 0) {
|
||||
str += QString(" (") + "New messages" + ")";
|
||||
str += QString(" (") + tr("New messages") + ")";
|
||||
}
|
||||
|
||||
result = str;
|
||||
|
@ -93,26 +92,51 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
|
|||
case Qt::DecorationRole:
|
||||
switch (item->type) {
|
||||
case Item::account: {
|
||||
quint8 col = index.column();
|
||||
Account* acc = static_cast<Account*>(item);
|
||||
result = acc->getStatusIcon(false);
|
||||
if (col == 0) {
|
||||
result = acc->getStatusIcon(false);
|
||||
} else if (col == 1) {
|
||||
QString path = acc->getAvatarPath();
|
||||
|
||||
if (path.size() > 0) {
|
||||
result = QIcon(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Item::contact: {
|
||||
Contact* contact = static_cast<Contact*>(item);
|
||||
result = contact->getStatusIcon(false);
|
||||
quint8 col = index.column();
|
||||
if (col == 0) {
|
||||
result = contact->getStatusIcon(false);
|
||||
} else if (col == 1) {
|
||||
if (contact->getAvatarState() != Shared::Avatar::empty) {
|
||||
result = QIcon(contact->getAvatarPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Item::presence: {
|
||||
if (index.column() != 0) {
|
||||
break;
|
||||
}
|
||||
Presence* presence = static_cast<Presence*>(item);
|
||||
result = presence->getStatusIcon(false);
|
||||
}
|
||||
break;
|
||||
case Item::room: {
|
||||
if (index.column() != 0) {
|
||||
break;
|
||||
}
|
||||
Room* room = static_cast<Room*>(item);
|
||||
result = room->getStatusIcon(false);
|
||||
}
|
||||
break;
|
||||
case Item::participant: {
|
||||
if (index.column() != 0) {
|
||||
break;
|
||||
}
|
||||
Participant* p = static_cast<Participant*>(item);
|
||||
result = p->getStatusIcon(false);
|
||||
}
|
||||
|
@ -143,7 +167,7 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
|
|||
switch (item->type) {
|
||||
case Item::account: {
|
||||
Account* acc = static_cast<Account*>(item);
|
||||
result = QString(Shared::availabilityNames[acc->getAvailability()]);
|
||||
result = QCoreApplication::translate("Global", Shared::availabilityNames[acc->getAvailability()].toLatin1());
|
||||
}
|
||||
break;
|
||||
case Item::contact: {
|
||||
|
@ -151,22 +175,22 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
|
|||
QString str("");
|
||||
int mc = contact->getMessagesCount();
|
||||
if (mc > 0) {
|
||||
str += QString("New messages: ") + std::to_string(mc).c_str() + "\n";
|
||||
str += QString(tr("New messages: ")) + std::to_string(mc).c_str() + "\n";
|
||||
}
|
||||
str += "Jabber ID: " + contact->getJid() + "\n";
|
||||
str += tr("Jabber ID: ") + contact->getJid() + "\n";
|
||||
Shared::SubscriptionState ss = contact->getState();
|
||||
if (ss == Shared::both) {
|
||||
Shared::Availability av = contact->getAvailability();
|
||||
str += "Availability: " + Shared::availabilityNames[av];
|
||||
str += tr("Availability: ") + QCoreApplication::translate("Global", Shared::availabilityNames[av].toLatin1());
|
||||
if (av != Shared::offline) {
|
||||
QString s = contact->getStatus();
|
||||
if (s.size() > 0) {
|
||||
str += "\nStatus: " + s;
|
||||
str += "\n" + tr("Status: ") + s;
|
||||
}
|
||||
}
|
||||
str += "\nSubscription: " + Shared::subscriptionStateNames[ss];
|
||||
str += "\n" + tr("Subscription: ") + QCoreApplication::translate("Global", Shared::subscriptionStateNames[ss].toLatin1());
|
||||
} else {
|
||||
str += "Subscription: " + Shared::subscriptionStateNames[ss];
|
||||
str += tr("Subscription: ") + QCoreApplication::translate("Global", Shared::subscriptionStateNames[ss].toLatin1());
|
||||
}
|
||||
|
||||
result = str;
|
||||
|
@ -177,13 +201,13 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
|
|||
QString str("");
|
||||
int mc = contact->getMessagesCount();
|
||||
if (mc > 0) {
|
||||
str += QString("New messages: ") + std::to_string(mc).c_str() + "\n";
|
||||
str += tr("New messages: ") + std::to_string(mc).c_str() + "\n";
|
||||
}
|
||||
Shared::Availability av = contact->getAvailability();
|
||||
str += "Availability: " + Shared::availabilityNames[av];
|
||||
str += tr("Availability: ") + QCoreApplication::translate("Global", Shared::availabilityNames[av].toLatin1());
|
||||
QString s = contact->getStatus();
|
||||
if (s.size() > 0) {
|
||||
str += "\nStatus: " + s;
|
||||
str += "\n" + tr("Status: ") + s;
|
||||
}
|
||||
|
||||
result = str;
|
||||
|
@ -193,14 +217,18 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
|
|||
Participant* p = static_cast<Participant*>(item);
|
||||
QString str("");
|
||||
Shared::Availability av = p->getAvailability();
|
||||
str += "Availability: " + Shared::availabilityNames[av] + "\n";
|
||||
str += tr("Availability: ") + QCoreApplication::translate("Global", Shared::availabilityNames[av].toLatin1()) + "\n";
|
||||
QString s = p->getStatus();
|
||||
if (s.size() > 0) {
|
||||
str += "Status: " + s + "\n";
|
||||
str += tr("Status: ") + s + "\n";
|
||||
}
|
||||
|
||||
str += "Affiliation: " + Shared::affiliationNames[static_cast<unsigned int>(p->getAffiliation())] + "\n";
|
||||
str += "Role: " + Shared::roleNames[static_cast<unsigned int>(p->getRole())];
|
||||
str += tr("Affiliation: ") +
|
||||
QCoreApplication::translate("Global",
|
||||
Shared::affiliationNames[static_cast<unsigned int>(p->getAffiliation())].toLatin1()) + "\n";
|
||||
str += tr("Role: ") +
|
||||
QCoreApplication::translate("Global",
|
||||
Shared::roleNames[static_cast<unsigned int>(p->getRole())].toLatin1());
|
||||
|
||||
result = str;
|
||||
}
|
||||
|
@ -210,10 +238,10 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
|
|||
unsigned int count = gr->getUnreadMessages();
|
||||
QString str("");
|
||||
if (count > 0) {
|
||||
str += QString("New messages: ") + std::to_string(count).c_str() + "\n";
|
||||
str += tr("New messages: ") + std::to_string(count).c_str() + "\n";
|
||||
}
|
||||
str += QString("Online contacts: ") + std::to_string(gr->getOnlineContacts()).c_str() + "\n";
|
||||
str += QString("Total contacts: ") + std::to_string(gr->childCount()).c_str();
|
||||
str += tr("Online contacts: ") + std::to_string(gr->getOnlineContacts()).c_str() + "\n";
|
||||
str += tr("Total contacts: ") + std::to_string(gr->childCount()).c_str();
|
||||
result = str;
|
||||
}
|
||||
break;
|
||||
|
@ -222,11 +250,11 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
|
|||
unsigned int count = rm->getUnreadMessagesCount();
|
||||
QString str("");
|
||||
if (count > 0) {
|
||||
str += QString("New messages: ") + std::to_string(count).c_str() + "\n";
|
||||
str += tr("New messages: ") + std::to_string(count).c_str() + "\n";
|
||||
}
|
||||
str += QString("Subscription: ") + rm->getStatusText();
|
||||
str += tr("Subscription: ") + rm->getStatusText();
|
||||
if (rm->getJoined()) {
|
||||
str += QString("\nMembers: ") + std::to_string(rm->childCount()).c_str();
|
||||
str += QString("\n") + tr("Members: ") + std::to_string(rm->childCount()).c_str();
|
||||
}
|
||||
result = str;
|
||||
}
|
||||
|
@ -383,50 +411,52 @@ void Models::Roster::addContact(const QString& account, const QString& jid, cons
|
|||
{
|
||||
Item* parent;
|
||||
Account* acc;
|
||||
Contact* contact;
|
||||
Contact* sample = 0;
|
||||
ElId id(account, jid);
|
||||
|
||||
{
|
||||
std::map<QString, Account*>::iterator itr = accounts.find(account);
|
||||
if (itr == accounts.end()) {
|
||||
qDebug() << "An attempt to add a contact " << jid << " to non existing account " << account << ", skipping";
|
||||
qDebug() << "An attempt to add a contact" << jid << "to non existing account" << account << ", skipping";
|
||||
return;
|
||||
}
|
||||
acc = itr->second;
|
||||
}
|
||||
|
||||
if (group == "") {
|
||||
std::multimap<ElId, Contact*>::iterator itr = contacts.lower_bound(id);
|
||||
std::multimap<ElId, Contact*>::iterator eItr = contacts.upper_bound(id);
|
||||
while (itr != eItr) {
|
||||
if (itr->second->parentItem() == acc) {
|
||||
qDebug() << "An attempt to add a contact " << jid << " ungrouped to non the account " << account << " for the second time, skipping";
|
||||
return;
|
||||
}
|
||||
itr++;
|
||||
for (std::multimap<ElId, Contact*>::iterator itr = contacts.lower_bound(id), eItr = contacts.upper_bound(id); itr != eItr; ++itr) {
|
||||
sample = itr->second; //need to find if this contact is already added somewhere
|
||||
break; //so one iteration is enough
|
||||
}
|
||||
|
||||
if (group == "") { //this means this contact is already added somewhere and there is no sense to add it ungrouped
|
||||
if (sample != 0) {
|
||||
qDebug() << "An attempt to add a contact" << jid << "to the ungrouped contact set of account" << account << "for the second time, skipping";
|
||||
return;
|
||||
} else {
|
||||
parent = acc;
|
||||
}
|
||||
parent = acc;
|
||||
} else {
|
||||
std::map<ElId, Group*>::iterator itr = groups.find({account, group});
|
||||
if (itr == groups.end()) {
|
||||
qDebug() << "An attempt to add a contact " << jid << " to non existing group " << group << ", skipping";
|
||||
return;
|
||||
qDebug() << "An attempt to add a contact" << jid << "to non existing group" << group << ", adding group";
|
||||
addGroup(account, group);
|
||||
itr = groups.find({account, group});
|
||||
}
|
||||
|
||||
parent = itr->second;
|
||||
|
||||
for (int i = 0; i < parent->childCount(); ++i) {
|
||||
for (int i = 0; i < parent->childCount(); ++i) { //checking if the contact is already added to that group
|
||||
Item* item = parent->child(i);
|
||||
if (item->type == Item::contact) {
|
||||
Contact* ca = static_cast<Contact*>(item);
|
||||
if (ca->getJid() == jid) {
|
||||
qDebug() << "An attempt to add a contact " << jid << " to the group " << group << " for the second time, skipping";
|
||||
qDebug() << "An attempt to add a contact" << jid << "to the group" << group << "for the second time, skipping";
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < acc->childCount(); ++i) {
|
||||
for (int i = 0; i < acc->childCount(); ++i) { //checking if that contact is among ugrouped
|
||||
Item* item = acc->child(i);
|
||||
if (item->type == Item::contact) {
|
||||
Contact* ca = static_cast<Contact*>(item);
|
||||
|
@ -440,7 +470,12 @@ void Models::Roster::addContact(const QString& account, const QString& jid, cons
|
|||
}
|
||||
|
||||
}
|
||||
contact = new Contact(jid, data);
|
||||
Contact* contact;
|
||||
if (sample == 0) {
|
||||
contact = new Contact(jid, data);
|
||||
} else {
|
||||
contact = sample->copy();
|
||||
}
|
||||
contacts.insert(std::make_pair(id, contact));
|
||||
parent->appendChild(contact);
|
||||
}
|
||||
|
@ -548,36 +583,67 @@ void Models::Roster::removeContact(const QString& account, const QString& jid, c
|
|||
qDebug() << "An attempt to remove contact " << jid << " from non existing group " << group << " of account " << account <<", skipping";
|
||||
return;
|
||||
}
|
||||
Account* acc = accounts.find(account)->second; //I assume the account is found, otherwise there will be no groups with that ElId;
|
||||
Group* gr = gItr->second;
|
||||
Contact* cont = 0;
|
||||
|
||||
std::multimap<ElId, Contact*>::iterator cBeg = contacts.lower_bound(contactId);
|
||||
std::multimap<ElId, Contact*>::iterator cEnd = contacts.upper_bound(contactId);
|
||||
for (;cBeg != cEnd; ++cBeg) {
|
||||
if (cBeg->second->parentItem() == gr) {
|
||||
cont = cBeg->second;
|
||||
contacts.erase(cBeg);
|
||||
break;
|
||||
unsigned int entries(0);
|
||||
unsigned int ungroupped(0);
|
||||
for (std::multimap<ElId, Contact*>::iterator cBeg = contacts.lower_bound(contactId), cEnd = contacts.upper_bound(contactId); cBeg != cEnd; ++cBeg) {
|
||||
++entries;
|
||||
Contact* elem = cBeg->second;
|
||||
if (elem->parentItem() == acc) {
|
||||
++ungroupped;
|
||||
}
|
||||
}
|
||||
|
||||
if (cont == 0) {
|
||||
qDebug() << "An attempt to remove contact " << jid << " of account " << account << " from group " << group <<", but there is no such contact in that group, skipping";
|
||||
return;
|
||||
}
|
||||
|
||||
gr->removeChild(cont->row());
|
||||
cont->deleteLater();
|
||||
|
||||
if (gr->childCount() == 0) {
|
||||
removeGroup(account, group);
|
||||
if (ungroupped == 0 && entries == 1) {
|
||||
for (std::multimap<ElId, Contact*>::iterator cBeg = contacts.lower_bound(contactId), cEnd = contacts.upper_bound(contactId); cBeg != cEnd; ++cBeg) {
|
||||
if (cBeg->second->parentItem() == gr) {
|
||||
cont = cBeg->second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (cont == 0) {
|
||||
qDebug() << "An attempt to remove contact " << jid << " of account " << account << " from group " << group <<", but there is no such contact in that group, skipping";
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "An attempt to remove last instance of contact" << jid << "from the group" << group << ", contact will be moved to ungrouped contacts of" << account;
|
||||
acc->appendChild(cont);
|
||||
|
||||
if (gr->childCount() == 0) {
|
||||
removeGroup(account, group);
|
||||
}
|
||||
} else {
|
||||
for (std::multimap<ElId, Contact*>::iterator cBeg = contacts.lower_bound(contactId), cEnd = contacts.upper_bound(contactId); cBeg != cEnd; ++cBeg) {
|
||||
if (cBeg->second->parentItem() == gr) {
|
||||
cont = cBeg->second;
|
||||
contacts.erase(cBeg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (cont == 0) {
|
||||
qDebug() << "An attempt to remove contact" << jid << "of account" << account << "from group" << group <<", but there is no such contact in that group, skipping";
|
||||
return;
|
||||
}
|
||||
|
||||
gr->removeChild(cont->row());
|
||||
cont->deleteLater();
|
||||
|
||||
if (gr->childCount() == 0) {
|
||||
removeGroup(account, group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Models::Roster::onChildChanged(Models::Item* item, int row, int col)
|
||||
{
|
||||
QModelIndex index = createIndex(row, 0, item);
|
||||
emit dataChanged(index, index);
|
||||
QModelIndex index2 = createIndex(row, 1, item);
|
||||
emit dataChanged(index, index2);
|
||||
}
|
||||
|
||||
void Models::Roster::onChildIsAboutToBeInserted(Models::Item* parent, int first, int last)
|
||||
|
@ -738,7 +804,7 @@ QString Models::Roster::getContactName(const QString& account, const QString& ji
|
|||
if (rItr == rooms.end()) {
|
||||
qDebug() << "An attempt to get a name of non existing contact/room " << account << ":" << jid << ", skipping";
|
||||
} else {
|
||||
name = rItr->second->getName();
|
||||
name = rItr->second->getRoomName();
|
||||
}
|
||||
} else {
|
||||
name = cItr->second->getContactName();
|
||||
|
@ -844,3 +910,47 @@ void Models::Roster::removeRoomParticipant(const QString& account, const QString
|
|||
itr->second->removeParticipant(name);
|
||||
}
|
||||
}
|
||||
|
||||
std::deque<QString> Models::Roster::groupList(const QString& account) const
|
||||
{
|
||||
std::deque<QString> answer;
|
||||
for (std::pair<ElId, Group*> pair : groups) {
|
||||
if (pair.first.account == account) {
|
||||
answer.push_back(pair.first.name);
|
||||
}
|
||||
}
|
||||
|
||||
return answer;
|
||||
}
|
||||
|
||||
bool Models::Roster::groupHasContact(const QString& account, const QString& group, const QString& contact) const
|
||||
{
|
||||
ElId grId({account, group});
|
||||
std::map<ElId, Group*>::const_iterator gItr = groups.find(grId);
|
||||
if (gItr == groups.end()) {
|
||||
return false;
|
||||
} else {
|
||||
const Group* gr = gItr->second;
|
||||
return gr->hasContact(contact);
|
||||
}
|
||||
}
|
||||
|
||||
QString Models::Roster::getContactIconPath(const QString& account, const QString& jid)
|
||||
{
|
||||
ElId id(account, jid);
|
||||
std::multimap<ElId, Contact*>::const_iterator cItr = contacts.find(id);
|
||||
QString path = "";
|
||||
if (cItr == contacts.end()) {
|
||||
std::map<ElId, Room*>::const_iterator rItr = rooms.find(id);
|
||||
if (rItr == rooms.end()) {
|
||||
qDebug() << "An attempt to get an icon path of non existing contact" << account << ":" << jid << ", returning empty value";
|
||||
} else {
|
||||
//path = rItr->second->getRoomName();
|
||||
}
|
||||
} else {
|
||||
if (cItr->second->getAvatarState() != Shared::Avatar::empty) {
|
||||
path = cItr->second->getAvatarPath();
|
||||
}
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
|
|
@ -71,6 +71,10 @@ public:
|
|||
QModelIndex parent ( const QModelIndex& child ) const override;
|
||||
QModelIndex index ( int row, int column, const QModelIndex& parent ) const override;
|
||||
|
||||
std::deque<QString> groupList(const QString& account) const;
|
||||
bool groupHasContact(const QString& account, const QString& group, const QString& contactJID) const;
|
||||
QString getContactIconPath(const QString& account, const QString& jid);
|
||||
|
||||
Accounts* accountsModel;
|
||||
|
||||
private:
|
||||
|
|
240
ui/squawk.cpp
240
ui/squawk.cpp
|
@ -20,6 +20,7 @@
|
|||
#include "ui_squawk.h"
|
||||
#include <QDebug>
|
||||
#include <QIcon>
|
||||
#include <QInputDialog>
|
||||
|
||||
Squawk::Squawk(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
|
@ -28,27 +29,35 @@ Squawk::Squawk(QWidget *parent) :
|
|||
rosterModel(),
|
||||
conversations(),
|
||||
contextMenu(new QMenu()),
|
||||
dbus("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", QDBusConnection::sessionBus())
|
||||
dbus("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", QDBusConnection::sessionBus()),
|
||||
requestedFiles(),
|
||||
vCards()
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->roster->setModel(&rosterModel);
|
||||
m_ui->roster->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
m_ui->roster->setColumnWidth(1, 20);
|
||||
m_ui->roster->setIconSize(QSize(20, 20));
|
||||
m_ui->roster->header()->setStretchLastSection(false);
|
||||
m_ui->roster->header()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
|
||||
for (unsigned int i = Shared::availabilityLowest; i < Shared::availabilityHighest + 1; ++i) {
|
||||
Shared::Availability av = static_cast<Shared::Availability>(i);
|
||||
m_ui->comboBox->addItem(Shared::availabilityIcon(av), Shared::availabilityNames[av]);
|
||||
m_ui->comboBox->addItem(Shared::availabilityIcon(av), QCoreApplication::translate("Global", Shared::availabilityNames[av].toLatin1()));
|
||||
}
|
||||
m_ui->comboBox->setCurrentIndex(Shared::offline);
|
||||
|
||||
connect(m_ui->actionAccounts, SIGNAL(triggered()), this, SLOT(onAccounts()));
|
||||
connect(m_ui->actionAddContact, SIGNAL(triggered()), this, SLOT(onNewContact()));
|
||||
connect(m_ui->actionAddConference, SIGNAL(triggered()), this, SLOT(onNewConference()));
|
||||
connect(m_ui->comboBox, SIGNAL(activated(int)), this, SLOT(onComboboxActivated(int)));
|
||||
connect(m_ui->roster, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(onRosterItemDoubleClicked(const QModelIndex&)));
|
||||
connect(m_ui->roster, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(onRosterContextMenu(const QPoint&)));
|
||||
connect(m_ui->actionAccounts, &QAction::triggered, this, &Squawk::onAccounts);
|
||||
connect(m_ui->actionAddContact, &QAction::triggered, this, &Squawk::onNewContact);
|
||||
connect(m_ui->actionAddConference, &QAction::triggered, this, &Squawk::onNewConference);
|
||||
connect(m_ui->comboBox, qOverload<int>(&QComboBox::activated), this, &Squawk::onComboboxActivated);
|
||||
connect(m_ui->roster, &QTreeView::doubleClicked, this, &Squawk::onRosterItemDoubleClicked);
|
||||
connect(m_ui->roster, &QTreeView::customContextMenuRequested, this, &Squawk::onRosterContextMenu);
|
||||
|
||||
connect(rosterModel.accountsModel, SIGNAL(sizeChanged(unsigned int)), this, SLOT(onAccountsSizeChanged(unsigned int)));
|
||||
connect(rosterModel.accountsModel, &Models::Accounts::sizeChanged, this, &Squawk::onAccountsSizeChanged);
|
||||
//m_ui->mainToolBar->addWidget(m_ui->comboBox);
|
||||
|
||||
setWindowTitle(tr("Contact list"));
|
||||
}
|
||||
|
||||
Squawk::~Squawk() {
|
||||
|
@ -60,12 +69,12 @@ void Squawk::onAccounts()
|
|||
if (accounts == 0) {
|
||||
accounts = new Accounts(rosterModel.accountsModel, this);
|
||||
accounts->setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(accounts, SIGNAL(destroyed(QObject*)), this, SLOT(onAccountsClosed(QObject*)));
|
||||
connect(accounts, SIGNAL(newAccount(const QMap<QString, QVariant>&)), this, SIGNAL(newAccountRequest(const QMap<QString, QVariant>&)));
|
||||
connect(accounts, SIGNAL(changeAccount(const QString&, const QMap<QString, QVariant>&)), this, SIGNAL(modifyAccountRequest(const QString&, const QMap<QString, QVariant>&)));
|
||||
connect(accounts, SIGNAL(connectAccount(const QString&)), this, SIGNAL(connectAccount(const QString&)));
|
||||
connect(accounts, SIGNAL(disconnectAccount(const QString&)), this, SIGNAL(disconnectAccount(const QString&)));
|
||||
connect(accounts, SIGNAL(removeAccount(const QString&)), this, SIGNAL(removeAccountRequest(const QString&)));
|
||||
connect(accounts, &Accounts::destroyed, this, &Squawk::onAccountsClosed);
|
||||
connect(accounts, &Accounts::newAccount, this, &Squawk::newAccountRequest);
|
||||
connect(accounts, &Accounts::changeAccount, this, &Squawk::modifyAccountRequest);
|
||||
connect(accounts, &Accounts::connectAccount, this, &Squawk::connectAccount);
|
||||
connect(accounts, &Accounts::disconnectAccount, this, &Squawk::disconnectAccount);
|
||||
connect(accounts, &Accounts::removeAccount, this, &Squawk::removeAccountRequest);
|
||||
|
||||
accounts->show();
|
||||
} else {
|
||||
|
@ -90,8 +99,8 @@ void Squawk::onNewContact()
|
|||
{
|
||||
NewContact* nc = new NewContact(rosterModel.accountsModel, this);
|
||||
|
||||
connect(nc, SIGNAL(accepted()), this, SLOT(onNewContactAccepted()));
|
||||
connect(nc, SIGNAL(rejected()), nc, SLOT(deleteLater()));
|
||||
connect(nc, &NewContact::accepted, this, &Squawk::onNewContactAccepted);
|
||||
connect(nc, &NewContact::rejected, nc, &NewContact::deleteLater);
|
||||
|
||||
nc->exec();
|
||||
}
|
||||
|
@ -100,8 +109,8 @@ void Squawk::onNewConference()
|
|||
{
|
||||
JoinConference* jc = new JoinConference(rosterModel.accountsModel, this);
|
||||
|
||||
connect(jc, SIGNAL(accepted()), this, SLOT(onJoinConferenceAccepted()));
|
||||
connect(jc, SIGNAL(rejected()), jc, SLOT(deleteLater()));
|
||||
connect(jc, &JoinConference::accepted, this, &Squawk::onJoinConferenceAccepted);
|
||||
connect(jc, &JoinConference::rejected, jc, &JoinConference::deleteLater);
|
||||
|
||||
jc->exec();
|
||||
}
|
||||
|
@ -131,12 +140,19 @@ void Squawk::closeEvent(QCloseEvent* event)
|
|||
if (accounts != 0) {
|
||||
accounts->close();
|
||||
}
|
||||
|
||||
for (Conversations::const_iterator itr = conversations.begin(), end = conversations.end(); itr != end; ++itr) {
|
||||
disconnect(itr->second, SIGNAL(destroyed(QObject*)), this, SLOT(onConversationClosed(QObject*)));
|
||||
disconnect(itr->second, &Conversation::destroyed, this, &Squawk::onConversationClosed);
|
||||
itr->second->close();
|
||||
}
|
||||
conversations.clear();
|
||||
|
||||
for (std::map<QString, VCard*>::const_iterator itr = vCards.begin(), end = vCards.end(); itr != end; ++itr) {
|
||||
disconnect(itr->second, &VCard::destroyed, this, &Squawk::onVCardClosed);
|
||||
itr->second->close();
|
||||
}
|
||||
vCards.clear();
|
||||
|
||||
QMainWindow::closeEvent(event);
|
||||
}
|
||||
|
||||
|
@ -283,13 +299,14 @@ void Squawk::onRosterItemDoubleClicked(const QModelIndex& item)
|
|||
if (created) {
|
||||
conv->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
connect(conv, SIGNAL(destroyed(QObject*)), this, SLOT(onConversationClosed(QObject*)));
|
||||
connect(conv, SIGNAL(sendMessage(const Shared::Message&)), this, SLOT(onConversationMessage(const Shared::Message&)));
|
||||
connect(conv, SIGNAL(sendMessage(const Shared::Message&, const QString&)), this, SLOT(onConversationMessage(const Shared::Message&, const QString&)));
|
||||
connect(conv, SIGNAL(requestArchive(const QString&)), this, SLOT(onConversationRequestArchive(const QString&)));
|
||||
connect(conv, SIGNAL(requestLocalFile(const QString&, const QString&)), this, SLOT(onConversationRequestLocalFile(const QString&, const QString&)));
|
||||
connect(conv, SIGNAL(downloadFile(const QString&, const QString&)), this, SLOT(onConversationDownloadFile(const QString&, const QString&)));
|
||||
connect(conv, SIGNAL(shown()), this, SLOT(onConversationShown()));
|
||||
connect(conv, &Conversation::destroyed, this, &Squawk::onConversationClosed);
|
||||
connect(conv, qOverload<const Shared::Message&>(&Conversation::sendMessage), this, qOverload<const Shared::Message&>(&Squawk::onConversationMessage));
|
||||
connect(conv, qOverload<const Shared::Message&, const QString&>(&Conversation::sendMessage),
|
||||
this, qOverload<const Shared::Message&, const QString&>(&Squawk::onConversationMessage));
|
||||
connect(conv, &Conversation::requestArchive, this, &Squawk::onConversationRequestArchive);
|
||||
connect(conv, &Conversation::requestLocalFile, this, &Squawk::onConversationRequestLocalFile);
|
||||
connect(conv, &Conversation::downloadFile, this, &Squawk::onConversationDownloadFile);
|
||||
connect(conv, &Conversation::shown, this, &Squawk::onConversationShown);
|
||||
|
||||
conversations.insert(std::make_pair(*id, conv));
|
||||
|
||||
|
@ -449,11 +466,16 @@ void Squawk::accountMessage(const QString& account, const Shared::Message& data)
|
|||
|
||||
void Squawk::notify(const QString& account, const Shared::Message& msg)
|
||||
{
|
||||
QString name = QString(rosterModel.getContactName(account, msg.getPenPalJid()));;
|
||||
QString name = QString(rosterModel.getContactName(account, msg.getPenPalJid()));
|
||||
QString path = QString(rosterModel.getContactIconPath(account, msg.getPenPalJid()));
|
||||
QVariantList args;
|
||||
args << QString(QCoreApplication::applicationName());
|
||||
args << QVariant(QVariant::UInt); //TODO some normal id
|
||||
args << QString("mail-message"); //TODO icon
|
||||
if (path.size() > 0) {
|
||||
args << path;
|
||||
} else {
|
||||
args << QString("mail-message");
|
||||
}
|
||||
if (msg.getType() == Shared::Message::groupChat) {
|
||||
args << msg.getFromResource() + " from " + name;
|
||||
} else {
|
||||
|
@ -502,10 +524,9 @@ void Squawk::removeAccount(const QString& account)
|
|||
Conversations::const_iterator lItr = itr;
|
||||
++itr;
|
||||
Conversation* conv = lItr->second;
|
||||
disconnect(conv, SIGNAL(destroyed(QObject*)), this, SLOT(onConversationClosed(QObject*)));
|
||||
disconnect(conv, SIGNAL(sendMessage(const Shared::Message&)), this, SLOT(onConversationMessage(const Shared::Message&)));
|
||||
disconnect(conv, SIGNAL(requestArchive(const QString&)), this, SLOT(onConversationRequestArchive(const QString&)));
|
||||
disconnect(conv, SIGNAL(shown()), this, SLOT(onConversationShown()));
|
||||
disconnect(conv, &Conversation::destroyed, this, &Squawk::onConversationClosed);
|
||||
disconnect(conv, &Conversation::requestArchive, this, &Squawk::onConversationRequestArchive);
|
||||
disconnect(conv, &Conversation::shown, this, &Squawk::onConversationShown);
|
||||
conv->close();
|
||||
conversations.erase(lItr);
|
||||
} else {
|
||||
|
@ -523,6 +544,7 @@ void Squawk::onRosterContextMenu(const QPoint& point)
|
|||
|
||||
contextMenu->clear();
|
||||
bool hasMenu = false;
|
||||
bool active = item->getAccountConnectionState() == Shared::connected;
|
||||
switch (item->type) {
|
||||
case Models::Item::account: {
|
||||
Models::Account* acc = static_cast<Models::Account*>(item);
|
||||
|
@ -530,18 +552,24 @@ void Squawk::onRosterContextMenu(const QPoint& point)
|
|||
QString name = acc->getName();
|
||||
|
||||
if (acc->getState() != Shared::disconnected) {
|
||||
QAction* con = contextMenu->addAction(Shared::icon("network-disconnect"), "Disconnect");
|
||||
QAction* con = contextMenu->addAction(Shared::icon("network-disconnect"), tr("Disconnect"));
|
||||
con->setEnabled(active);
|
||||
connect(con, &QAction::triggered, [this, name]() {
|
||||
emit disconnectAccount(name);
|
||||
});
|
||||
} else {
|
||||
QAction* con = contextMenu->addAction(Shared::icon("network-connect"), "Connect");
|
||||
QAction* con = contextMenu->addAction(Shared::icon("network-connect"), tr("Connect"));
|
||||
connect(con, &QAction::triggered, [this, name]() {
|
||||
emit connectAccount(name);
|
||||
});
|
||||
}
|
||||
|
||||
QAction* remove = contextMenu->addAction(Shared::icon("edit-delete"), "Remove");
|
||||
QAction* card = contextMenu->addAction(Shared::icon("user-properties"), tr("VCard"));
|
||||
card->setEnabled(active);
|
||||
connect(card, &QAction::triggered, std::bind(&Squawk::onActivateVCard, this, name, acc->getBareJid(), true));
|
||||
|
||||
QAction* remove = contextMenu->addAction(Shared::icon("edit-delete"), tr("Remove"));
|
||||
remove->setEnabled(active);
|
||||
connect(remove, &QAction::triggered, [this, name]() {
|
||||
emit removeAccount(name);
|
||||
});
|
||||
|
@ -552,7 +580,8 @@ void Squawk::onRosterContextMenu(const QPoint& point)
|
|||
Models::Contact* cnt = static_cast<Models::Contact*>(item);
|
||||
hasMenu = true;
|
||||
|
||||
QAction* dialog = contextMenu->addAction(Shared::icon("mail-message"), "Open dialog");
|
||||
QAction* dialog = contextMenu->addAction(Shared::icon("mail-message"), tr("Open dialog"));
|
||||
dialog->setEnabled(active);
|
||||
connect(dialog, &QAction::triggered, [this, index]() {
|
||||
onRosterItemDoubleClicked(index);
|
||||
});
|
||||
|
@ -561,7 +590,8 @@ void Squawk::onRosterContextMenu(const QPoint& point)
|
|||
switch (state) {
|
||||
case Shared::both:
|
||||
case Shared::to: {
|
||||
QAction* unsub = contextMenu->addAction(Shared::icon("news-unsubscribe"), "Unsubscribe");
|
||||
QAction* unsub = contextMenu->addAction(Shared::icon("news-unsubscribe"), tr("Unsubscribe"));
|
||||
unsub->setEnabled(active);
|
||||
connect(unsub, &QAction::triggered, [this, cnt]() {
|
||||
emit unsubscribeContact(cnt->getAccountName(), cnt->getJid(), "");
|
||||
});
|
||||
|
@ -570,14 +600,74 @@ void Squawk::onRosterContextMenu(const QPoint& point)
|
|||
case Shared::from:
|
||||
case Shared::unknown:
|
||||
case Shared::none: {
|
||||
QAction* sub = contextMenu->addAction(Shared::icon("news-subscribe"), "Subscribe");
|
||||
QAction* sub = contextMenu->addAction(Shared::icon("news-subscribe"), tr("Subscribe"));
|
||||
sub->setEnabled(active);
|
||||
connect(sub, &QAction::triggered, [this, cnt]() {
|
||||
emit subscribeContact(cnt->getAccountName(), cnt->getJid(), "");
|
||||
});
|
||||
}
|
||||
}
|
||||
QString accName = cnt->getAccountName();
|
||||
QString cntJID = cnt->getJid();
|
||||
QString cntName = cnt->getName();
|
||||
|
||||
QAction* remove = contextMenu->addAction(Shared::icon("edit-delete"), "Remove");
|
||||
QAction* rename = contextMenu->addAction(Shared::icon("edit-rename"), tr("Rename"));
|
||||
rename->setEnabled(active);
|
||||
connect(rename, &QAction::triggered, [this, cntName, accName, cntJID]() {
|
||||
QInputDialog* dialog = new QInputDialog(this);
|
||||
connect(dialog, &QDialog::accepted, [this, dialog, cntName, accName, cntJID]() {
|
||||
QString newName = dialog->textValue();
|
||||
if (newName != cntName) {
|
||||
emit renameContactRequest(accName, cntJID, newName);
|
||||
}
|
||||
dialog->deleteLater();
|
||||
});
|
||||
connect(dialog, &QDialog::rejected, dialog, &QObject::deleteLater);
|
||||
dialog->setInputMode(QInputDialog::TextInput);
|
||||
dialog->setLabelText(tr("Input new name for %1\nor leave it empty for the contact \nto be displayed as %1").arg(cntJID));
|
||||
dialog->setWindowTitle(tr("Renaming %1").arg(cntJID));
|
||||
dialog->setTextValue(cntName);
|
||||
dialog->exec();
|
||||
});
|
||||
|
||||
|
||||
QMenu* groupsMenu = contextMenu->addMenu(Shared::icon("group"), tr("Groups"));
|
||||
std::deque<QString> groupList = rosterModel.groupList(accName);
|
||||
for (QString groupName : groupList) {
|
||||
QAction* gr = groupsMenu->addAction(groupName);
|
||||
gr->setCheckable(true);
|
||||
gr->setChecked(rosterModel.groupHasContact(accName, groupName, cntJID));
|
||||
gr->setEnabled(active);
|
||||
connect(gr, &QAction::toggled, [this, accName, groupName, cntJID](bool checked) {
|
||||
if (checked) {
|
||||
emit addContactToGroupRequest(accName, cntJID, groupName);
|
||||
} else {
|
||||
emit removeContactFromGroupRequest(accName, cntJID, groupName);
|
||||
}
|
||||
});
|
||||
}
|
||||
QAction* newGroup = groupsMenu->addAction(Shared::icon("group-new"), tr("New group"));
|
||||
newGroup->setEnabled(active);
|
||||
connect(newGroup, &QAction::triggered, [this, accName, cntJID]() {
|
||||
QInputDialog* dialog = new QInputDialog(this);
|
||||
connect(dialog, &QDialog::accepted, [this, dialog, accName, cntJID]() {
|
||||
emit addContactToGroupRequest(accName, cntJID, dialog->textValue());
|
||||
dialog->deleteLater();
|
||||
});
|
||||
connect(dialog, &QDialog::rejected, dialog, &QObject::deleteLater);
|
||||
dialog->setInputMode(QInputDialog::TextInput);
|
||||
dialog->setLabelText(tr("New group name"));
|
||||
dialog->setWindowTitle(tr("Add %1 to a new group").arg(cntJID));
|
||||
dialog->exec();
|
||||
});
|
||||
|
||||
|
||||
QAction* card = contextMenu->addAction(Shared::icon("user-properties"), tr("VCard"));
|
||||
card->setEnabled(active);
|
||||
connect(card, &QAction::triggered, std::bind(&Squawk::onActivateVCard, this, accName, cnt->getJid(), false));
|
||||
|
||||
QAction* remove = contextMenu->addAction(Shared::icon("edit-delete"), tr("Remove"));
|
||||
remove->setEnabled(active);
|
||||
connect(remove, &QAction::triggered, [this, cnt]() {
|
||||
emit removeContactRequest(cnt->getAccountName(), cnt->getJid());
|
||||
});
|
||||
|
@ -588,7 +678,8 @@ void Squawk::onRosterContextMenu(const QPoint& point)
|
|||
Models::Room* room = static_cast<Models::Room*>(item);
|
||||
hasMenu = true;
|
||||
|
||||
QAction* dialog = contextMenu->addAction(Shared::icon("mail-message"), "Open conversation");
|
||||
QAction* dialog = contextMenu->addAction(Shared::icon("mail-message"), tr("Open conversation"));
|
||||
dialog->setEnabled(active);
|
||||
connect(dialog, &QAction::triggered, [this, index]() {
|
||||
onRosterItemDoubleClicked(index);
|
||||
});
|
||||
|
@ -596,7 +687,8 @@ void Squawk::onRosterContextMenu(const QPoint& point)
|
|||
|
||||
Models::Roster::ElId id(room->getAccountName(), room->getJid());
|
||||
if (room->getAutoJoin()) {
|
||||
QAction* unsub = contextMenu->addAction(Shared::icon("news-unsubscribe"), "Unsubscribe");
|
||||
QAction* unsub = contextMenu->addAction(Shared::icon("news-unsubscribe"), tr("Unsubscribe"));
|
||||
unsub->setEnabled(active);
|
||||
connect(unsub, &QAction::triggered, [this, id]() {
|
||||
emit setRoomAutoJoin(id.account, id.name, false);
|
||||
if (conversations.find(id) == conversations.end()) { //to leave the room if it's not opened in a conversation window
|
||||
|
@ -604,7 +696,8 @@ void Squawk::onRosterContextMenu(const QPoint& point)
|
|||
}
|
||||
});
|
||||
} else {
|
||||
QAction* unsub = contextMenu->addAction(Shared::icon("news-subscribe"), "Subscribe");
|
||||
QAction* unsub = contextMenu->addAction(Shared::icon("news-subscribe"), tr("Subscribe"));
|
||||
unsub->setEnabled(active);
|
||||
connect(unsub, &QAction::triggered, [this, id]() {
|
||||
emit setRoomAutoJoin(id.account, id.name, true);
|
||||
if (conversations.find(id) == conversations.end()) { //to join the room if it's not already joined
|
||||
|
@ -613,7 +706,8 @@ void Squawk::onRosterContextMenu(const QPoint& point)
|
|||
});
|
||||
}
|
||||
|
||||
QAction* remove = contextMenu->addAction(Shared::icon("edit-delete"), "Remove");
|
||||
QAction* remove = contextMenu->addAction(Shared::icon("edit-delete"), tr("Remove"));
|
||||
remove->setEnabled(active);
|
||||
connect(remove, &QAction::triggered, [this, id]() {
|
||||
emit removeRoomRequest(id.account, id.name);
|
||||
});
|
||||
|
@ -657,3 +751,61 @@ void Squawk::removeRoomParticipant(const QString& account, const QString& jid, c
|
|||
{
|
||||
rosterModel.removeRoomParticipant(account, jid, name);
|
||||
}
|
||||
|
||||
void Squawk::responseVCard(const QString& jid, const Shared::VCard& card)
|
||||
{
|
||||
std::map<QString, VCard*>::const_iterator itr = vCards.find(jid);
|
||||
if (itr != vCards.end()) {
|
||||
itr->second->setVCard(card);
|
||||
itr->second->hideProgress();
|
||||
}
|
||||
}
|
||||
|
||||
void Squawk::onVCardClosed()
|
||||
{
|
||||
VCard* vCard = static_cast<VCard*>(sender());
|
||||
|
||||
std::map<QString, VCard*>::const_iterator itr = vCards.find(vCard->getJid());
|
||||
if (itr == vCards.end()) {
|
||||
qDebug() << "VCard has been closed but can not be found among other opened vCards, application is most probably going to crash";
|
||||
return;
|
||||
}
|
||||
vCards.erase(itr);
|
||||
}
|
||||
|
||||
void Squawk::onActivateVCard(const QString& account, const QString& jid, bool edition)
|
||||
{
|
||||
std::map<QString, VCard*>::const_iterator itr = vCards.find(jid);
|
||||
VCard* card;
|
||||
Models::Contact::Messages deque;
|
||||
if (itr != vCards.end()) {
|
||||
card = itr->second;
|
||||
} else {
|
||||
card = new VCard(jid, edition);
|
||||
if (edition) {
|
||||
card->setWindowTitle(tr("%1 account card").arg(account));
|
||||
} else {
|
||||
card->setWindowTitle(tr("%1 contact card").arg(jid));
|
||||
}
|
||||
card->setAttribute(Qt::WA_DeleteOnClose);
|
||||
vCards.insert(std::make_pair(jid, card));
|
||||
|
||||
connect(card, &VCard::destroyed, this, &Squawk::onVCardClosed);
|
||||
connect(card, &VCard::saveVCard, std::bind( &Squawk::onVCardSave, this, std::placeholders::_1, account));
|
||||
}
|
||||
|
||||
card->show();
|
||||
card->raise();
|
||||
card->activateWindow();
|
||||
card->showProgress(tr("Downloading vCard"));
|
||||
|
||||
emit requestVCard(account, jid);
|
||||
}
|
||||
|
||||
void Squawk::onVCardSave(const Shared::VCard& card, const QString& account)
|
||||
{
|
||||
VCard* widget = static_cast<VCard*>(sender());
|
||||
emit uploadVCard(account, card);
|
||||
|
||||
widget->deleteLater();
|
||||
}
|
||||
|
|
13
ui/squawk.h
13
ui/squawk.h
|
@ -34,8 +34,9 @@
|
|||
#include "widgets/newcontact.h"
|
||||
#include "widgets/joinconference.h"
|
||||
#include "models/roster.h"
|
||||
#include "widgets/vcard/vcard.h"
|
||||
|
||||
#include "../global.h"
|
||||
#include "global.h"
|
||||
|
||||
namespace Ui {
|
||||
class Squawk;
|
||||
|
@ -63,12 +64,17 @@ signals:
|
|||
void unsubscribeContact(const QString& account, const QString& jid, const QString& reason);
|
||||
void removeContactRequest(const QString& account, const QString& jid);
|
||||
void addContactRequest(const QString& account, const QString& jid, const QString& name, const QSet<QString>& groups);
|
||||
void addContactToGroupRequest(const QString& account, const QString& jid, const QString& groupName);
|
||||
void removeContactFromGroupRequest(const QString& account, const QString& jid, const QString& groupName);
|
||||
void renameContactRequest(const QString& account, const QString& jid, const QString& newName);
|
||||
void setRoomJoined(const QString& account, const QString& jid, bool joined);
|
||||
void setRoomAutoJoin(const QString& account, const QString& jid, bool joined);
|
||||
void addRoomRequest(const QString& account, const QString& jid, const QString& nick, const QString& password, bool autoJoin);
|
||||
void removeRoomRequest(const QString& account, const QString& jid);
|
||||
void fileLocalPathRequest(const QString& messageId, const QString& url);
|
||||
void downloadFileRequest(const QString& messageId, const QString& url);
|
||||
void requestVCard(const QString& account, const QString& jid);
|
||||
void uploadVCard(const QString& account, const Shared::VCard& card);
|
||||
|
||||
public slots:
|
||||
void newAccount(const QMap<QString, QVariant>& account);
|
||||
|
@ -94,6 +100,7 @@ public slots:
|
|||
void fileLocalPathResponse(const QString& messageId, const QString& path);
|
||||
void downloadFileError(const QString& messageId, const QString& error);
|
||||
void downloadFileProgress(const QString& messageId, qreal value);
|
||||
void responseVCard(const QString& jid, const Shared::VCard& card);
|
||||
|
||||
private:
|
||||
typedef std::map<Models::Roster::ElId, Conversation*> Conversations;
|
||||
|
@ -105,6 +112,7 @@ private:
|
|||
QMenu* contextMenu;
|
||||
QDBusInterface dbus;
|
||||
std::map<QString, std::set<Models::Roster::ElId>> requestedFiles;
|
||||
std::map<QString, VCard*> vCards;
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent * event) override;
|
||||
|
@ -119,6 +127,9 @@ private slots:
|
|||
void onAccountsSizeChanged(unsigned int size);
|
||||
void onAccountsClosed(QObject* parent = 0);
|
||||
void onConversationClosed(QObject* parent = 0);
|
||||
void onVCardClosed();
|
||||
void onVCardSave(const Shared::VCard& card, const QString& account);
|
||||
void onActivateVCard(const QString& account, const QString& jid, bool edition = false);
|
||||
void onComboboxActivated(int index);
|
||||
void onRosterItemDoubleClicked(const QModelIndex& item);
|
||||
void onConversationMessage(const Shared::Message& msg);
|
||||
|
|
|
@ -51,6 +51,9 @@
|
|||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="uniformRowHeights">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="expandsOnDoubleClick">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
|
@ -122,7 +125,8 @@
|
|||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="resource-group-new"/>
|
||||
<iconset theme="resource-group-new">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add conference</string>
|
||||
|
|
|
@ -42,7 +42,7 @@ Badge::Badge(const QString& p_id, const QString& p_text, const QIcon& icon, QWid
|
|||
|
||||
layout->setContentsMargins(2, 2, 2, 2);
|
||||
|
||||
connect(closeButton, SIGNAL(clicked()), this, SIGNAL(close()));
|
||||
connect(closeButton, &QPushButton::clicked, this, &Badge::close);
|
||||
}
|
||||
|
||||
Badge::~Badge()
|
||||
|
|
85
ui/utils/comboboxdelegate.cpp
Normal file
85
ui/utils/comboboxdelegate.cpp
Normal file
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* Squawk messenger.
|
||||
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
|
||||
*
|
||||
* 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 "QTimer"
|
||||
|
||||
#include "comboboxdelegate.h"
|
||||
|
||||
ComboboxDelegate::ComboboxDelegate(QObject *parent):
|
||||
QStyledItemDelegate(parent),
|
||||
entries(),
|
||||
ff(new FocusFilter())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ComboboxDelegate::~ComboboxDelegate()
|
||||
{
|
||||
delete ff;
|
||||
}
|
||||
|
||||
|
||||
QWidget* ComboboxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
QComboBox *cb = new QComboBox(parent);
|
||||
|
||||
for (const std::pair<QString, QIcon> pair : entries) {
|
||||
cb->addItem(pair.second, pair.first);
|
||||
}
|
||||
|
||||
return cb;
|
||||
}
|
||||
|
||||
|
||||
void ComboboxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
|
||||
{
|
||||
QComboBox *cb = static_cast<QComboBox*>(editor);
|
||||
int currentIndex = index.data(Qt::EditRole).toInt();
|
||||
if (currentIndex >= 0) {
|
||||
cb->setCurrentIndex(currentIndex);
|
||||
cb->installEventFilter(ff);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ComboboxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
|
||||
{
|
||||
QComboBox *cb = static_cast<QComboBox *>(editor);
|
||||
model->setData(index, cb->currentIndex(), Qt::EditRole);
|
||||
}
|
||||
|
||||
void ComboboxDelegate::addEntry(const QString& title, const QIcon& icon)
|
||||
{
|
||||
entries.emplace_back(title, icon);
|
||||
}
|
||||
|
||||
bool ComboboxDelegate::FocusFilter::eventFilter(QObject* src, QEvent* evt)
|
||||
{
|
||||
if (evt->type() == QEvent::FocusIn) {
|
||||
QComboBox* cb = static_cast<QComboBox*>(src);
|
||||
cb->removeEventFilter(this);
|
||||
QTimer* timer = new QTimer; //TODO that is ridiculous! I refuse to believe there is no better way than that one!
|
||||
QObject::connect(timer, &QTimer::timeout, [timer, cb]() {
|
||||
cb->showPopup();
|
||||
timer->deleteLater();
|
||||
});
|
||||
|
||||
timer->setSingleShot(true);
|
||||
timer->start(100);
|
||||
}
|
||||
return QObject::eventFilter(src, evt);
|
||||
}
|
57
ui/utils/comboboxdelegate.h
Normal file
57
ui/utils/comboboxdelegate.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Squawk messenger.
|
||||
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef COMBOBOXDELEGATE_H
|
||||
#define COMBOBOXDELEGATE_H
|
||||
|
||||
#include <QStyledItemDelegate>
|
||||
#include <QComboBox>
|
||||
#include <QFocusEvent>
|
||||
|
||||
#include <deque>
|
||||
|
||||
/**
|
||||
* @todo write docs
|
||||
*/
|
||||
class ComboboxDelegate : public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
class FocusFilter : public QObject {
|
||||
public:
|
||||
bool eventFilter(QObject *src, QEvent *evt) override;
|
||||
};
|
||||
|
||||
public:
|
||||
ComboboxDelegate(QObject *parent = nullptr);
|
||||
~ComboboxDelegate();
|
||||
|
||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
void setEditorData(QWidget *editor, const QModelIndex &index) const override;
|
||||
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
|
||||
|
||||
void addEntry(const QString& title, const QIcon& icon = QIcon());
|
||||
|
||||
private:
|
||||
std::deque<std::pair<QString, QIcon>> entries;
|
||||
FocusFilter* ff;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // COMBOBOXDELEGATE_H
|
|
@ -19,19 +19,14 @@
|
|||
#include <QDebug>
|
||||
#include "image.h"
|
||||
|
||||
Image::Image(const QString& path, QWidget* parent):
|
||||
Image::Image(const QString& path, quint16 p_minWidth, QWidget* parent):
|
||||
QLabel(parent),
|
||||
pixmap(path),
|
||||
aspectRatio(0)
|
||||
aspectRatio(0),
|
||||
minWidth(p_minWidth)
|
||||
{
|
||||
|
||||
qreal height = pixmap.height();
|
||||
qreal width = pixmap.width();
|
||||
aspectRatio = width / height;
|
||||
setPixmap(pixmap);
|
||||
setScaledContents(true);
|
||||
setMinimumHeight(50 / aspectRatio);
|
||||
setMinimumWidth(50);
|
||||
recalculateAspectRatio();
|
||||
}
|
||||
|
||||
Image::~Image()
|
||||
|
@ -42,11 +37,39 @@ Image::~Image()
|
|||
int Image::heightForWidth(int width) const
|
||||
{
|
||||
int height = width / aspectRatio;
|
||||
//qDebug() << height << width << aspectRatio;
|
||||
return height;
|
||||
}
|
||||
|
||||
int Image::widthForHeight(int height) const
|
||||
{
|
||||
return height * aspectRatio;
|
||||
}
|
||||
|
||||
bool Image::hasHeightForWidth() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void Image::recalculateAspectRatio()
|
||||
{
|
||||
qreal height = pixmap.height();
|
||||
qreal width = pixmap.width();
|
||||
aspectRatio = width / height;
|
||||
setPixmap(pixmap);
|
||||
setMinimumHeight(minWidth / aspectRatio);
|
||||
setMinimumWidth(minWidth);
|
||||
}
|
||||
|
||||
void Image::setMinWidth(quint16 p_minWidth)
|
||||
{
|
||||
if (minWidth != p_minWidth) {
|
||||
minWidth = p_minWidth;
|
||||
recalculateAspectRatio();
|
||||
}
|
||||
}
|
||||
|
||||
void Image::setPath(const QString& path)
|
||||
{
|
||||
pixmap = QPixmap(path);
|
||||
recalculateAspectRatio();
|
||||
}
|
||||
|
|
|
@ -28,34 +28,23 @@
|
|||
class Image : public QLabel
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
Image(const QString& path, QWidget* parent = nullptr);
|
||||
Image(const QString& path, quint16 minWidth = 50, QWidget* parent = nullptr);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~Image();
|
||||
|
||||
/**
|
||||
* @todo write docs
|
||||
*
|
||||
* @param TODO
|
||||
* @return TODO
|
||||
*/
|
||||
int heightForWidth(int width) const override;
|
||||
|
||||
/**
|
||||
* @todo write docs
|
||||
*
|
||||
* @return TODO
|
||||
*/
|
||||
virtual bool hasHeightForWidth() const;
|
||||
int widthForHeight(int height) const;
|
||||
bool hasHeightForWidth() const override;
|
||||
void setPath(const QString& path);
|
||||
void setMinWidth(quint16 minWidth);
|
||||
|
||||
private:
|
||||
QPixmap pixmap;
|
||||
qreal aspectRatio;
|
||||
quint16 minWidth;
|
||||
|
||||
private:
|
||||
void recalculateAspectRatio();
|
||||
};
|
||||
|
||||
#endif // IMAGE_H
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <QFileInfo>
|
||||
#include "message.h"
|
||||
|
||||
const QRegExp urlReg("^(?!<img\\ssrc=\")((?:https?|ftp)://\\S+)");
|
||||
const QRegExp urlReg("(?!<img\\ssrc=\")((?:https?|ftp)://\\S+)");
|
||||
const QRegExp imgReg("((?:https?|ftp)://\\S+\\.(?:jpg|jpeg|png|svg|gif))");
|
||||
|
||||
Message::Message(const Shared::Message& source, bool outgoing, const QString& p_sender, QWidget* parent):
|
||||
|
@ -63,7 +63,6 @@ Message::Message(const Shared::Message& source, bool outgoing, const QString& p_
|
|||
dFont.setItalic(true);
|
||||
dFont.setPointSize(dFont.pointSize() - 2);
|
||||
date->setFont(dFont);
|
||||
date->setForegroundRole(QPalette::ToolTipText);
|
||||
|
||||
QFont f;
|
||||
f.setBold(true);
|
||||
|
@ -117,16 +116,16 @@ void Message::addDownloadDialog()
|
|||
text->setText("");
|
||||
text->hide();
|
||||
}
|
||||
downloadButton = new QPushButton(QIcon::fromTheme("download"), "Download");
|
||||
downloadButton = new QPushButton(QIcon::fromTheme("download"), tr("Download"));
|
||||
downloadButton->setToolTip("<a href=\"" + msg.getOutOfBandUrl() + "\">" + msg.getOutOfBandUrl() + "</a>");
|
||||
if (errorDownloadingFile) {
|
||||
fileComment->setWordWrap(true);
|
||||
fileComment->setText("Error downloading file: " + errorText + "\nYou can try again");
|
||||
fileComment->setText(tr("Error downloading file: %1\nYou can try again").arg(QCoreApplication::translate("NetworkErrors", errorText.toLatin1())));
|
||||
} else {
|
||||
fileComment->setText(sender->text() + " is offering you to download a file");
|
||||
fileComment->setText(tr("%1 is offering you to download a file").arg(sender->text()));
|
||||
}
|
||||
fileComment->show();
|
||||
connect(downloadButton, SIGNAL(clicked()), this, SLOT(onDownload()));
|
||||
connect(downloadButton, &QPushButton::clicked, this, &Message::onDownload);
|
||||
bodyLayout->insertWidget(2, fileComment);
|
||||
bodyLayout->insertWidget(3, downloadButton);
|
||||
hasDownloadButton = true;
|
||||
|
@ -188,7 +187,7 @@ void Message::showFile(const QString& path)
|
|||
fileComment->show();
|
||||
}
|
||||
file->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
QAction* openAction = new QAction(QIcon::fromTheme("document-new-from-template"), "Open", file);
|
||||
QAction* openAction = new QAction(QIcon::fromTheme("document-new-from-template"), tr("Open"), file);
|
||||
connect(openAction, &QAction::triggered, [path]() { //TODO need to get rid of this shame
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
|
||||
});
|
||||
|
|
|
@ -31,35 +31,11 @@ MessageLine::MessageLine(bool p_room, QWidget* parent):
|
|||
palNames(),
|
||||
views(),
|
||||
room(p_room),
|
||||
busyPixmap(new QGraphicsPixmapItem(Shared::icon("view-refresh", true).pixmap(70))),
|
||||
busyScene(),
|
||||
busyLabel(&busyScene),
|
||||
busyLayout(),
|
||||
busyShown(false),
|
||||
rotation()
|
||||
progress()
|
||||
{
|
||||
setBackgroundRole(QPalette::Base);
|
||||
layout->addStretch();
|
||||
|
||||
busyScene.addItem(busyPixmap);
|
||||
busyLayout.addStretch();
|
||||
busyLayout.addWidget(&busyLabel);
|
||||
busyLayout.addStretch();
|
||||
busyLabel.setMaximumSize(70, 70);
|
||||
busyLabel.setMinimumSize(70, 70);
|
||||
busyLabel.setSceneRect(0, 0, 70, 70);
|
||||
busyLabel.setFrameStyle(0);
|
||||
busyLabel.setContentsMargins(0, 0, 0, 0);
|
||||
busyLabel.setInteractive(false);
|
||||
busyPixmap->setTransformOriginPoint(35, 35);
|
||||
busyPixmap->setTransformationMode(Qt::SmoothTransformation);
|
||||
busyPixmap->setOffset(0, 0);;
|
||||
|
||||
rotation.setDuration(500);
|
||||
rotation.setStartValue(0.0f);
|
||||
rotation.setEndValue(180.0f);
|
||||
rotation.setLoopCount(-1);
|
||||
connect(&rotation, SIGNAL(valueChanged(const QVariant&)), this, SLOT(onAnimationValueChanged(const QVariant&)));
|
||||
}
|
||||
|
||||
MessageLine::~MessageLine()
|
||||
|
@ -151,7 +127,7 @@ MessageLine::Position MessageLine::message(const Shared::Message& msg)
|
|||
|
||||
if (msg.hasOutOfBandUrl()) {\
|
||||
emit requestLocalFile(msg.getId(), msg.getOutOfBandUrl());
|
||||
connect(message, SIGNAL(downloadFile(const QString&, const QString&)), this, SIGNAL(downloadFile(const QString&, const QString&)));
|
||||
connect(message, &Message::downloadFile, this, &MessageLine::downloadFile);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
@ -201,28 +177,21 @@ QString MessageLine::firstMessageId() const
|
|||
void MessageLine::showBusyIndicator()
|
||||
{
|
||||
if (!busyShown) {
|
||||
layout->insertLayout(0, &busyLayout);
|
||||
layout->insertWidget(0, &progress);
|
||||
progress.start();
|
||||
busyShown = true;
|
||||
rotation.start();
|
||||
busyLabel.show();
|
||||
}
|
||||
}
|
||||
|
||||
void MessageLine::hideBusyIndicator()
|
||||
{
|
||||
if (busyShown) {
|
||||
busyLabel.hide();
|
||||
rotation.stop();
|
||||
layout->removeItem(&busyLayout);
|
||||
progress.stop();
|
||||
layout->removeWidget(&progress);
|
||||
busyShown = false;
|
||||
}
|
||||
}
|
||||
|
||||
void MessageLine::onAnimationValueChanged(const QVariant& value)
|
||||
{
|
||||
busyPixmap->setRotation(value.toReal());
|
||||
}
|
||||
|
||||
void MessageLine::responseDownloadProgress(const QString& messageId, qreal progress)
|
||||
{
|
||||
Index::const_iterator itr = messageIndex.find(messageId);
|
||||
|
|
|
@ -25,13 +25,10 @@
|
|||
#include <QLabel>
|
||||
#include <QResizeEvent>
|
||||
#include <QIcon>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsView>
|
||||
#include <QGraphicsPixmapItem>
|
||||
#include <QVariantAnimation>
|
||||
|
||||
#include "../global.h"
|
||||
#include "../../global.h"
|
||||
#include "message.h"
|
||||
#include "progress.h"
|
||||
|
||||
class MessageLine : public QWidget
|
||||
{
|
||||
|
@ -85,15 +82,8 @@ private:
|
|||
std::map<QString, QString> palNames;
|
||||
std::deque<QHBoxLayout*> views;
|
||||
bool room;
|
||||
QGraphicsPixmapItem* busyPixmap;
|
||||
QGraphicsScene busyScene;
|
||||
QGraphicsView busyLabel;
|
||||
QHBoxLayout busyLayout;
|
||||
bool busyShown;
|
||||
QVariantAnimation rotation;
|
||||
|
||||
private slots:
|
||||
void onAnimationValueChanged(const QVariant& value);
|
||||
Progress progress;
|
||||
};
|
||||
|
||||
#endif // MESSAGELINE_H
|
||||
|
|
85
ui/utils/progress.cpp
Normal file
85
ui/utils/progress.cpp
Normal file
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* Squawk messenger.
|
||||
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
|
||||
*
|
||||
* 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 "progress.h"
|
||||
|
||||
Progress::Progress(quint16 p_size, QWidget* parent):
|
||||
QWidget(parent),
|
||||
pixmap(new QGraphicsPixmapItem(Shared::icon("view-refresh", true).pixmap(p_size))),
|
||||
scene(),
|
||||
label(&scene),
|
||||
progress(false),
|
||||
animation(),
|
||||
size(p_size)
|
||||
{
|
||||
scene.addItem(pixmap);
|
||||
label.setMaximumSize(size, size);
|
||||
label.setMinimumSize(size, size);
|
||||
label.setSceneRect(0, 0, size, size);
|
||||
label.setFrameStyle(0);
|
||||
label.setContentsMargins(0, 0, 0, 0);
|
||||
label.setInteractive(false);
|
||||
label.setStyleSheet("background: transparent");
|
||||
pixmap->setTransformOriginPoint(size / 2, size / 2);
|
||||
pixmap->setTransformationMode(Qt::SmoothTransformation);
|
||||
pixmap->setOffset(0, 0);
|
||||
|
||||
animation.setDuration(500);
|
||||
animation.setStartValue(0.0f);
|
||||
animation.setEndValue(180.0f);
|
||||
animation.setLoopCount(-1);
|
||||
connect(&animation, &QVariantAnimation::valueChanged, this, &Progress::onValueChanged);
|
||||
|
||||
QGridLayout* layout = new QGridLayout();
|
||||
setLayout(layout);
|
||||
layout->setMargin(0);
|
||||
layout->setVerticalSpacing(0);
|
||||
layout->setHorizontalSpacing(0);
|
||||
|
||||
setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
layout->addWidget(&label, 0, 0, 1, 1);
|
||||
label.hide();
|
||||
}
|
||||
|
||||
Progress::~Progress()
|
||||
{
|
||||
}
|
||||
|
||||
void Progress::onValueChanged(const QVariant& value)
|
||||
{
|
||||
pixmap->setRotation(value.toReal());
|
||||
}
|
||||
|
||||
void Progress::start()
|
||||
{
|
||||
if (!progress) {
|
||||
label.show();
|
||||
animation.start();
|
||||
progress = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Progress::stop()
|
||||
{
|
||||
if (progress) {
|
||||
label.hide();
|
||||
animation.stop();
|
||||
progress = false;
|
||||
}
|
||||
}
|
57
ui/utils/progress.h
Normal file
57
ui/utils/progress.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Squawk messenger.
|
||||
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef PROGRESS_H
|
||||
#define PROGRESS_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QGraphicsScene>
|
||||
#include <QIcon>
|
||||
#include <QGraphicsView>
|
||||
#include <QGraphicsPixmapItem>
|
||||
#include <QVariantAnimation>
|
||||
#include <QGridLayout>
|
||||
|
||||
#include "../../global.h"
|
||||
|
||||
/**
|
||||
* @todo write docs
|
||||
*/
|
||||
class Progress : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Progress(quint16 p_size = 70, QWidget* parent = nullptr);
|
||||
~Progress();
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
private slots:
|
||||
void onValueChanged(const QVariant& value);
|
||||
|
||||
private:
|
||||
QGraphicsPixmapItem* pixmap;
|
||||
QGraphicsScene scene;
|
||||
QGraphicsView label;
|
||||
bool progress;
|
||||
QVariantAnimation animation;
|
||||
quint16 size;
|
||||
};
|
||||
|
||||
#endif // PROGRESS_H
|
29
ui/widgets/CMakeLists.txt
Normal file
29
ui/widgets/CMakeLists.txt
Normal file
|
@ -0,0 +1,29 @@
|
|||
cmake_minimum_required(VERSION 3.0)
|
||||
project(squawkWidgets)
|
||||
|
||||
# Instruct CMake to run moc automatically when needed.
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
# Instruct CMake to create code from Qt designer ui files
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
|
||||
# Find the QtWidgets library
|
||||
find_package(Qt5Widgets CONFIG REQUIRED)
|
||||
|
||||
add_subdirectory(vcard)
|
||||
|
||||
set(squawkWidgets_SRC
|
||||
conversation.cpp
|
||||
chat.cpp
|
||||
room.cpp
|
||||
newcontact.cpp
|
||||
accounts.cpp
|
||||
account.cpp
|
||||
joinconference.cpp
|
||||
)
|
||||
|
||||
# Tell CMake to create the helloworld executable
|
||||
add_library(squawkWidgets ${squawkWidgets_SRC})
|
||||
|
||||
# Use the Widgets module from Qt 5.
|
||||
target_link_libraries(squawkWidgets vCardUI)
|
||||
target_link_libraries(squawkWidgets Qt5::Widgets)
|
|
@ -39,6 +39,9 @@
|
|||
<property name="toolTip">
|
||||
<string>Your account login</string>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>john_smith1987</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
|
@ -53,6 +56,9 @@
|
|||
<property name="toolTip">
|
||||
<string>A server address of your account. Like 404.city or macaw.me</string>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>macaw.me</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
|
@ -83,6 +89,9 @@
|
|||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
|
@ -100,6 +109,9 @@
|
|||
<property name="toolTip">
|
||||
<string>Just a name how would you call this account, doesn't affect anything</string>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>John</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
|
|
|
@ -29,14 +29,13 @@ Accounts::Accounts(Models::Accounts* p_model, QWidget *parent) :
|
|||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->addButton, SIGNAL(clicked(bool)), this, SLOT(onAddButton(bool)));
|
||||
connect(m_ui->editButton, SIGNAL(clicked(bool)), this, SLOT(onEditButton(bool)));
|
||||
connect(m_ui->connectButton, SIGNAL(clicked(bool)), this, SLOT(onConnectButton(bool)));
|
||||
connect(m_ui->deleteButton, SIGNAL(clicked(bool)), this, SLOT(onDeleteButton(bool)));
|
||||
connect(m_ui->addButton, &QPushButton::clicked, this, &Accounts::onAddButton);
|
||||
connect(m_ui->editButton, &QPushButton::clicked, this, &Accounts::onEditButton);
|
||||
connect(m_ui->connectButton, &QPushButton::clicked, this, &Accounts::onConnectButton);
|
||||
connect(m_ui->deleteButton, &QPushButton::clicked, this, &Accounts::onDeleteButton);
|
||||
m_ui->tableView->setModel(model);
|
||||
connect(m_ui->tableView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
|
||||
this, SLOT(onSelectionChanged(const QItemSelection&, const QItemSelection&)));
|
||||
connect(p_model, SIGNAL(changed()), this, SLOT(updateConnectButton()));
|
||||
connect(m_ui->tableView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &Accounts::onSelectionChanged);
|
||||
connect(p_model, &Models::Accounts::changed, this, &Accounts::updateConnectButton);
|
||||
}
|
||||
|
||||
Accounts::~Accounts() = default;
|
||||
|
@ -44,8 +43,8 @@ Accounts::~Accounts() = default;
|
|||
void Accounts::onAddButton(bool clicked)
|
||||
{
|
||||
Account* acc = new Account();
|
||||
connect(acc, SIGNAL(accepted()), this, SLOT(onAccountAccepted()));
|
||||
connect(acc, SIGNAL(rejected()), this, SLOT(onAccountRejected()));
|
||||
connect(acc, &Account::accepted, this, &Accounts::onAccountAccepted);
|
||||
connect(acc, &Account::rejected, this, &Accounts::onAccountRejected);
|
||||
acc->exec();
|
||||
}
|
||||
|
||||
|
@ -84,8 +83,8 @@ void Accounts::onEditButton(bool clicked)
|
|||
{"resource", mAcc->getResource()}
|
||||
});
|
||||
acc->lockId();
|
||||
connect(acc, SIGNAL(accepted()), this, SLOT(onAccountAccepted()));
|
||||
connect(acc, SIGNAL(rejected()), this, SLOT(onAccountRejected()));
|
||||
connect(acc, &Account::accepted, this, &Accounts::onAccountAccepted);
|
||||
connect(acc, &Account::rejected, this, &Accounts::onAccountRejected);
|
||||
editing = true;
|
||||
acc->exec();
|
||||
}
|
||||
|
@ -120,13 +119,13 @@ void Accounts::updateConnectButton()
|
|||
}
|
||||
if (allConnected) {
|
||||
toDisconnect = true;
|
||||
m_ui->connectButton->setText("Disconnect");
|
||||
m_ui->connectButton->setText(tr("Disconnect"));
|
||||
} else {
|
||||
toDisconnect = false;
|
||||
m_ui->connectButton->setText("Connect");
|
||||
m_ui->connectButton->setText(tr("Connect"));
|
||||
}
|
||||
} else {
|
||||
m_ui->connectButton->setText("Connect");
|
||||
m_ui->connectButton->setText(tr("Connect"));
|
||||
toDisconnect = false;
|
||||
m_ui->connectButton->setEnabled(false);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ Chat::Chat(Models::Contact* p_contact, QWidget* parent):
|
|||
updateState();
|
||||
setStatus(p_contact->getStatus());
|
||||
|
||||
connect(contact, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(onContactChanged(Models::Item*, int, int)));
|
||||
connect(contact, &Models::Contact::childChanged, this, &Chat::onContactChanged);
|
||||
|
||||
line->setMyName(p_contact->getAccountName());
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ void Chat::updateState()
|
|||
{
|
||||
Shared::Availability av = contact->getAvailability();
|
||||
statusIcon->setPixmap(Shared::availabilityIcon(av, true).pixmap(40));
|
||||
statusIcon->setToolTip(Shared::availabilityNames[av]);
|
||||
statusIcon->setToolTip(QCoreApplication::translate("Global", Shared::availabilityNames[av].toLatin1()));
|
||||
}
|
||||
|
||||
void Chat::handleSendMessage(const QString& text)
|
||||
|
|
|
@ -59,15 +59,15 @@ Conversation::Conversation(bool muc, const QString& mJid, const QString mRes, co
|
|||
statusIcon = m_ui->statusIcon;
|
||||
statusLabel = m_ui->statusLabel;
|
||||
|
||||
connect(&ker, SIGNAL(enterPressed()), this, SLOT(onEnterPressed()));
|
||||
connect(&res, SIGNAL(resized()), this, SLOT(onScrollResize()));
|
||||
connect(&vis, SIGNAL(shown()), this, SLOT(onScrollResize()));
|
||||
connect(&vis, SIGNAL(hidden()), this, SLOT(onScrollResize()));
|
||||
connect(m_ui->sendButton, SIGNAL(clicked(bool)), this, SLOT(onEnterPressed()));
|
||||
connect(line, SIGNAL(resize(int)), this, SLOT(onMessagesResize(int)));
|
||||
connect(line, SIGNAL(downloadFile(const QString&, const QString&)), this, SIGNAL(downloadFile(const QString&, const QString&)));
|
||||
connect(line, SIGNAL(requestLocalFile(const QString&, const QString&)), this, SIGNAL(requestLocalFile(const QString&, const QString&)));
|
||||
connect(m_ui->attachButton, SIGNAL(clicked(bool)), this, SLOT(onAttach()));
|
||||
connect(&ker, &KeyEnterReceiver::enterPressed, this, &Conversation::onEnterPressed);
|
||||
connect(&res, &Resizer::resized, this, &Conversation::onScrollResize);
|
||||
connect(&vis, &VisibilityCatcher::shown, this, &Conversation::onScrollResize);
|
||||
connect(&vis, &VisibilityCatcher::hidden, this, &Conversation::onScrollResize);
|
||||
connect(m_ui->sendButton, &QPushButton::clicked, this, &Conversation::onEnterPressed);
|
||||
connect(line, &MessageLine::resize, this, &Conversation::onMessagesResize);
|
||||
connect(line, &MessageLine::downloadFile, this, &Conversation::downloadFile);
|
||||
connect(line, &MessageLine::requestLocalFile, this, &Conversation::requestLocalFile);
|
||||
connect(m_ui->attachButton, &QPushButton::clicked, this, &Conversation::onAttach);
|
||||
|
||||
m_ui->messageEditor->installEventFilter(&ker);
|
||||
|
||||
|
@ -76,7 +76,7 @@ Conversation::Conversation(bool muc, const QString& mJid, const QString mRes, co
|
|||
vs->installEventFilter(&vis);
|
||||
vs->setBackgroundRole(QPalette::Base);
|
||||
vs->setAutoFillBackground(true);
|
||||
connect(vs, SIGNAL(valueChanged(int)), this, SLOT(onSliderValueChanged(int)));
|
||||
connect(vs, &QScrollBar::valueChanged, this, &Conversation::onSliderValueChanged);
|
||||
m_ui->scrollArea->installEventFilter(&res);
|
||||
|
||||
applyVisualEffects();
|
||||
|
@ -257,11 +257,11 @@ void Conversation::showEvent(QShowEvent* event)
|
|||
|
||||
void Conversation::onAttach()
|
||||
{
|
||||
QFileDialog* d = new QFileDialog(this, "Chose a file to send");
|
||||
QFileDialog* d = new QFileDialog(this, tr("Chose a file to send"));
|
||||
d->setFileMode(QFileDialog::ExistingFile);
|
||||
|
||||
connect(d, SIGNAL(accepted()), this, SLOT(onFileSelected()));
|
||||
connect(d, SIGNAL(rejected()), d, SLOT(deleteLater()));
|
||||
connect(d, &QFileDialog::accepted, this, &Conversation::onFileSelected);
|
||||
connect(d, &QFileDialog::rejected, d, &QFileDialog::deleteLater);
|
||||
|
||||
d->show();
|
||||
}
|
||||
|
@ -317,7 +317,7 @@ void Conversation::addAttachedFile(const QString& path)
|
|||
|
||||
Badge* badge = new Badge(path, info.fileName(), QIcon::fromTheme(type.iconName()));
|
||||
|
||||
connect(badge, SIGNAL(close()), this, SLOT(onBadgeClose()));
|
||||
connect(badge, &Badge::close, this, &Conversation::onBadgeClose);
|
||||
filesToAttach.push_back(badge); //TODO neet to check if there are any duplicated ids
|
||||
filesLayout->addWidget(badge);
|
||||
if (filesLayout->count() == 1) {
|
||||
|
|
|
@ -445,6 +445,9 @@
|
|||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Type your message here...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
@ -26,7 +26,7 @@ Room::Room(Models::Room* p_room, QWidget* parent):
|
|||
line->setMyName(room->getNick());
|
||||
setStatus(room->getSubject());
|
||||
|
||||
connect(room, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(onRoomChanged(Models::Item*, int, int)));
|
||||
connect(room, &Models::Room::childChanged, this, &Room::onRoomChanged);
|
||||
}
|
||||
|
||||
Room::~Room()
|
||||
|
|
22
ui/widgets/vcard/CMakeLists.txt
Normal file
22
ui/widgets/vcard/CMakeLists.txt
Normal file
|
@ -0,0 +1,22 @@
|
|||
cmake_minimum_required(VERSION 3.0)
|
||||
project(vCardUI)
|
||||
|
||||
# Instruct CMake to run moc automatically when needed.
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
# Instruct CMake to create code from Qt designer ui files
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
|
||||
# Find the QtWidgets library
|
||||
find_package(Qt5Widgets CONFIG REQUIRED)
|
||||
|
||||
set(vCardUI_SRC
|
||||
vcard.cpp
|
||||
emailsmodel.cpp
|
||||
phonesmodel.cpp
|
||||
)
|
||||
|
||||
# Tell CMake to create the helloworld executable
|
||||
add_library(vCardUI ${vCardUI_SRC})
|
||||
|
||||
# Use the Widgets module from Qt 5.
|
||||
target_link_libraries(vCardUI Qt5::Widgets)
|
205
ui/widgets/vcard/emailsmodel.cpp
Normal file
205
ui/widgets/vcard/emailsmodel.cpp
Normal file
|
@ -0,0 +1,205 @@
|
|||
/*
|
||||
* Squawk messenger.
|
||||
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
|
||||
*
|
||||
* 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 "emailsmodel.h"
|
||||
|
||||
UI::VCard::EMailsModel::EMailsModel(bool p_edit, QObject* parent):
|
||||
QAbstractTableModel(parent),
|
||||
edit(p_edit),
|
||||
deque()
|
||||
{
|
||||
}
|
||||
|
||||
int UI::VCard::EMailsModel::columnCount(const QModelIndex& parent) const
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
int UI::VCard::EMailsModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
return deque.size();
|
||||
}
|
||||
|
||||
QVariant UI::VCard::EMailsModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (index.isValid()) {
|
||||
int col = index.column();
|
||||
switch (col) {
|
||||
case 0:
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
case Qt::EditRole:
|
||||
return deque[index.row()].address;
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
return QCoreApplication::translate("Global", Shared::VCard::Email::roleNames[deque[index.row()].role].toStdString().c_str());
|
||||
case Qt::EditRole:
|
||||
return deque[index.row()].role;
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
return QVariant();
|
||||
case Qt::DecorationRole:
|
||||
if (deque[index.row()].prefered) {
|
||||
return Shared::icon("favorite", false);
|
||||
}
|
||||
return QVariant();
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
Qt::ItemFlags UI::VCard::EMailsModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
Qt::ItemFlags f = QAbstractTableModel::flags(index);
|
||||
if (edit && index.column() != 2) {
|
||||
f = Qt::ItemIsEditable | f;
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
bool UI::VCard::EMailsModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||
{
|
||||
if (role == Qt::EditRole && checkIndex(index)) {
|
||||
Shared::VCard::Email& item = deque[index.row()];
|
||||
switch (index.column()) {
|
||||
case 0:
|
||||
item.address = value.toString();
|
||||
return true;
|
||||
case 1: {
|
||||
quint8 newRole = value.toUInt();
|
||||
if (newRole > Shared::VCard::Email::work) {
|
||||
return false;
|
||||
}
|
||||
item.role = static_cast<Shared::VCard::Email::Role>(newRole);
|
||||
return true;
|
||||
}
|
||||
case 2: {
|
||||
bool newDef = value.toBool();
|
||||
if (newDef != item.prefered) {
|
||||
if (newDef) {
|
||||
//dropPrefered();
|
||||
}
|
||||
item.prefered = newDef;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool UI::VCard::EMailsModel::dropPrefered()
|
||||
{
|
||||
bool dropped = false;
|
||||
int i = 0;
|
||||
for (Shared::VCard::Email& email : deque) {
|
||||
if (email.prefered) {
|
||||
email.prefered = false;
|
||||
QModelIndex ci = createIndex(i, 2, &email);
|
||||
emit dataChanged(ci, ci);
|
||||
dropped = true;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return dropped;
|
||||
}
|
||||
|
||||
QModelIndex UI::VCard::EMailsModel::addNewEmptyLine()
|
||||
{
|
||||
beginInsertRows(QModelIndex(), deque.size(), deque.size());
|
||||
deque.emplace_back("");
|
||||
endInsertRows();
|
||||
return createIndex(deque.size() - 1, 0, &(deque.back()));
|
||||
}
|
||||
|
||||
bool UI::VCard::EMailsModel::isPreferred(int row) const
|
||||
{
|
||||
if (row < deque.size()) {
|
||||
return deque[row].prefered;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void UI::VCard::EMailsModel::removeLines(int index, int count)
|
||||
{
|
||||
if (index < deque.size()) {
|
||||
int maxCount = deque.size() - index;
|
||||
if (count > maxCount) {
|
||||
count = maxCount;
|
||||
}
|
||||
|
||||
if (count > 0) {
|
||||
beginRemoveRows(QModelIndex(), index, index + count - 1);
|
||||
std::deque<Shared::VCard::Email>::const_iterator itr = deque.begin() + index;
|
||||
std::deque<Shared::VCard::Email>::const_iterator end = itr + count;
|
||||
deque.erase(itr, end);
|
||||
endRemoveRows();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UI::VCard::EMailsModel::getEmails(std::deque<Shared::VCard::Email>& emails) const
|
||||
{
|
||||
for (const Shared::VCard::Email& my : deque) {
|
||||
emails.emplace_back(my);
|
||||
}
|
||||
}
|
||||
|
||||
void UI::VCard::EMailsModel::setEmails(const std::deque<Shared::VCard::Email>& emails)
|
||||
{
|
||||
if (deque.size() > 0) {
|
||||
removeLines(0, deque.size());
|
||||
}
|
||||
|
||||
if (emails.size() > 0) {
|
||||
beginInsertRows(QModelIndex(), 0, emails.size() - 1);
|
||||
for (const Shared::VCard::Email& comming : emails) {
|
||||
deque.emplace_back(comming);
|
||||
}
|
||||
endInsertRows();
|
||||
}
|
||||
}
|
||||
|
||||
void UI::VCard::EMailsModel::revertPreferred(int row)
|
||||
{
|
||||
setData(createIndex(row, 2), !isPreferred(row));
|
||||
}
|
||||
|
||||
QString UI::VCard::EMailsModel::getEmail(int row) const
|
||||
{
|
||||
return deque[row].address;
|
||||
}
|
64
ui/widgets/vcard/emailsmodel.h
Normal file
64
ui/widgets/vcard/emailsmodel.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Squawk messenger.
|
||||
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef UI_VCARD_EMAILSMODEL_H
|
||||
#define UI_VCARD_EMAILSMODEL_H
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include <QIcon>
|
||||
|
||||
#include <deque>
|
||||
|
||||
#include "global.h"
|
||||
|
||||
namespace UI {
|
||||
namespace VCard {
|
||||
|
||||
class EMailsModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
EMailsModel(bool edit = false, QObject *parent = nullptr);
|
||||
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
bool isPreferred(int row) const;
|
||||
|
||||
void removeLines(int index, int count);
|
||||
void setEmails(const std::deque<Shared::VCard::Email>& emails);
|
||||
void getEmails(std::deque<Shared::VCard::Email>& emails) const;
|
||||
QString getEmail(int row) const;
|
||||
|
||||
public slots:
|
||||
QModelIndex addNewEmptyLine();
|
||||
void revertPreferred(int row);
|
||||
|
||||
private:
|
||||
bool edit;
|
||||
std::deque<Shared::VCard::Email> deque;
|
||||
|
||||
private:
|
||||
bool dropPrefered();
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif // UI_VCARD_EMAILSMODEL_H
|
222
ui/widgets/vcard/phonesmodel.cpp
Normal file
222
ui/widgets/vcard/phonesmodel.cpp
Normal file
|
@ -0,0 +1,222 @@
|
|||
/*
|
||||
* Squawk messenger.
|
||||
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
|
||||
*
|
||||
* 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 "phonesmodel.h"
|
||||
|
||||
UI::VCard::PhonesModel::PhonesModel(bool p_edit, QObject* parent):
|
||||
QAbstractTableModel(parent),
|
||||
edit(p_edit),
|
||||
deque()
|
||||
{
|
||||
}
|
||||
|
||||
int UI::VCard::PhonesModel::columnCount(const QModelIndex& parent) const
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
int UI::VCard::PhonesModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
return deque.size();
|
||||
}
|
||||
|
||||
QVariant UI::VCard::PhonesModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (index.isValid()) {
|
||||
int col = index.column();
|
||||
switch (col) {
|
||||
case 0:
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
case Qt::EditRole:
|
||||
return deque[index.row()].number;
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
return QCoreApplication::translate("Global", Shared::VCard::Phone::roleNames[deque[index.row()].role].toStdString().c_str());
|
||||
case Qt::EditRole:
|
||||
return deque[index.row()].role;
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
return QCoreApplication::translate("Global", Shared::VCard::Phone::typeNames[deque[index.row()].type].toStdString().c_str());
|
||||
case Qt::EditRole:
|
||||
return deque[index.row()].type;
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
return QVariant();
|
||||
case Qt::DecorationRole:
|
||||
if (deque[index.row()].prefered) {
|
||||
return Shared::icon("favorite", false);
|
||||
}
|
||||
return QVariant();
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QModelIndex UI::VCard::PhonesModel::addNewEmptyLine()
|
||||
{
|
||||
beginInsertRows(QModelIndex(), deque.size(), deque.size());
|
||||
deque.emplace_back("", Shared::VCard::Phone::other);
|
||||
endInsertRows();
|
||||
return createIndex(deque.size() - 1, 0, &(deque.back()));
|
||||
}
|
||||
|
||||
Qt::ItemFlags UI::VCard::PhonesModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
Qt::ItemFlags f = QAbstractTableModel::flags(index);
|
||||
if (edit && index.column() != 3) {
|
||||
f = Qt::ItemIsEditable | f;
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
bool UI::VCard::PhonesModel::dropPrefered()
|
||||
{
|
||||
bool dropped = false;
|
||||
int i = 0;
|
||||
for (Shared::VCard::Phone& phone : deque) {
|
||||
if (phone.prefered) {
|
||||
phone.prefered = false;
|
||||
QModelIndex ci = createIndex(i, 2, &phone);
|
||||
emit dataChanged(ci, ci);
|
||||
dropped = true;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return dropped;
|
||||
}
|
||||
|
||||
void UI::VCard::PhonesModel::getPhones(std::deque<Shared::VCard::Phone>& phones) const
|
||||
{
|
||||
for (const Shared::VCard::Phone& my : deque) {
|
||||
phones.emplace_back(my);
|
||||
}
|
||||
}
|
||||
|
||||
bool UI::VCard::PhonesModel::isPreferred(int row) const
|
||||
{
|
||||
if (row < deque.size()) {
|
||||
return deque[row].prefered;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void UI::VCard::PhonesModel::removeLines(int index, int count)
|
||||
{
|
||||
if (index < deque.size()) {
|
||||
int maxCount = deque.size() - index;
|
||||
if (count > maxCount) {
|
||||
count = maxCount;
|
||||
}
|
||||
|
||||
if (count > 0) {
|
||||
beginRemoveRows(QModelIndex(), index, index + count - 1);
|
||||
std::deque<Shared::VCard::Phone>::const_iterator itr = deque.begin() + index;
|
||||
std::deque<Shared::VCard::Phone>::const_iterator end = itr + count;
|
||||
deque.erase(itr, end);
|
||||
endRemoveRows();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UI::VCard::PhonesModel::revertPreferred(int row)
|
||||
{
|
||||
setData(createIndex(row, 3), !isPreferred(row));
|
||||
}
|
||||
|
||||
bool UI::VCard::PhonesModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||
{
|
||||
if (role == Qt::EditRole && checkIndex(index)) {
|
||||
Shared::VCard::Phone& item = deque[index.row()];
|
||||
switch (index.column()) {
|
||||
case 0:
|
||||
item.number = value.toString();
|
||||
return true;
|
||||
case 1: {
|
||||
quint8 newRole = value.toUInt();
|
||||
if (newRole > Shared::VCard::Phone::work) {
|
||||
return false;
|
||||
}
|
||||
item.role = static_cast<Shared::VCard::Phone::Role>(newRole);
|
||||
return true;
|
||||
}
|
||||
case 2: {
|
||||
quint8 newType = value.toUInt();
|
||||
if (newType > Shared::VCard::Phone::other) {
|
||||
return false;
|
||||
}
|
||||
item.type = static_cast<Shared::VCard::Phone::Type>(newType);
|
||||
return true;
|
||||
}
|
||||
case 3: {
|
||||
bool newDef = value.toBool();
|
||||
if (newDef != item.prefered) {
|
||||
if (newDef) {
|
||||
//dropPrefered();
|
||||
}
|
||||
item.prefered = newDef;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void UI::VCard::PhonesModel::setPhones(const std::deque<Shared::VCard::Phone>& phones)
|
||||
{
|
||||
if (deque.size() > 0) {
|
||||
removeLines(0, deque.size());
|
||||
}
|
||||
|
||||
if (phones.size() > 0) {
|
||||
beginInsertRows(QModelIndex(), 0, phones.size() - 1);
|
||||
for (const Shared::VCard::Phone& comming : phones) {
|
||||
deque.emplace_back(comming);
|
||||
}
|
||||
endInsertRows();
|
||||
}
|
||||
}
|
||||
|
||||
QString UI::VCard::PhonesModel::getPhone(int row) const
|
||||
{
|
||||
return deque[row].number;
|
||||
}
|
65
ui/widgets/vcard/phonesmodel.h
Normal file
65
ui/widgets/vcard/phonesmodel.h
Normal file
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Squawk messenger.
|
||||
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef UI_VCARD_PHONESMODEL_H
|
||||
#define UI_VCARD_PHONESMODEL_H
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include <QIcon>
|
||||
|
||||
#include "global.h"
|
||||
|
||||
namespace UI {
|
||||
namespace VCard {
|
||||
|
||||
/**
|
||||
* @todo write docs
|
||||
*/
|
||||
class PhonesModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PhonesModel(bool edit = false, QObject *parent = nullptr);
|
||||
|
||||
QVariant data(const QModelIndex& index, int role) const override;
|
||||
int columnCount(const QModelIndex& parent) const override;
|
||||
int rowCount(const QModelIndex& parent) const override;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
bool isPreferred(int row) const;
|
||||
|
||||
void removeLines(int index, int count);
|
||||
void setPhones(const std::deque<Shared::VCard::Phone>& phones);
|
||||
void getPhones(std::deque<Shared::VCard::Phone>& phones) const;
|
||||
QString getPhone(int row) const;
|
||||
|
||||
public slots:
|
||||
QModelIndex addNewEmptyLine();
|
||||
void revertPreferred(int row);
|
||||
|
||||
private:
|
||||
bool edit;
|
||||
std::deque<Shared::VCard::Phone> deque;
|
||||
|
||||
private:
|
||||
bool dropPrefered();
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif // UI_VCARD_PHONESMODEL_H
|
460
ui/widgets/vcard/vcard.cpp
Normal file
460
ui/widgets/vcard/vcard.cpp
Normal file
|
@ -0,0 +1,460 @@
|
|||
/*
|
||||
* Squawk messenger.
|
||||
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
|
||||
*
|
||||
* 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 "vcard.h"
|
||||
#include "ui_vcard.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
const std::set<QString> VCard::supportedTypes = {"image/jpeg", "image/png"};
|
||||
|
||||
VCard::VCard(const QString& jid, bool edit, QWidget* parent):
|
||||
QWidget(parent),
|
||||
m_ui(new Ui::VCard()),
|
||||
avatarButtonMargins(),
|
||||
avatarMenu(nullptr),
|
||||
editable(edit),
|
||||
currentAvatarType(Shared::Avatar::empty),
|
||||
currentAvatarPath(""),
|
||||
progress(new Progress(100)),
|
||||
progressLabel(new QLabel()),
|
||||
overlay(new QWidget()),
|
||||
contextMenu(new QMenu()),
|
||||
emails(edit),
|
||||
phones(edit),
|
||||
roleDelegate(new ComboboxDelegate()),
|
||||
phoneTypeDelegate(new ComboboxDelegate())
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->jabberID->setText(jid);
|
||||
m_ui->jabberID->setReadOnly(true);
|
||||
|
||||
QAction* setAvatar = m_ui->actionSetAvatar;
|
||||
QAction* clearAvatar = m_ui->actionClearAvatar;
|
||||
|
||||
connect(setAvatar, &QAction::triggered, this, &VCard::onSetAvatar);
|
||||
connect(clearAvatar, &QAction::triggered, this, &VCard::onClearAvatar);
|
||||
|
||||
setAvatar->setEnabled(true);
|
||||
clearAvatar->setEnabled(false);
|
||||
|
||||
roleDelegate->addEntry(QCoreApplication::translate("Global", Shared::VCard::Email::roleNames[0].toStdString().c_str()));
|
||||
roleDelegate->addEntry(QCoreApplication::translate("Global", Shared::VCard::Email::roleNames[1].toStdString().c_str()));
|
||||
roleDelegate->addEntry(QCoreApplication::translate("Global", Shared::VCard::Email::roleNames[2].toStdString().c_str()));
|
||||
|
||||
phoneTypeDelegate->addEntry(QCoreApplication::translate("Global", Shared::VCard::Phone::typeNames[0].toStdString().c_str()));
|
||||
phoneTypeDelegate->addEntry(QCoreApplication::translate("Global", Shared::VCard::Phone::typeNames[1].toStdString().c_str()));
|
||||
phoneTypeDelegate->addEntry(QCoreApplication::translate("Global", Shared::VCard::Phone::typeNames[2].toStdString().c_str()));
|
||||
phoneTypeDelegate->addEntry(QCoreApplication::translate("Global", Shared::VCard::Phone::typeNames[3].toStdString().c_str()));
|
||||
phoneTypeDelegate->addEntry(QCoreApplication::translate("Global", Shared::VCard::Phone::typeNames[4].toStdString().c_str()));
|
||||
phoneTypeDelegate->addEntry(QCoreApplication::translate("Global", Shared::VCard::Phone::typeNames[5].toStdString().c_str()));
|
||||
phoneTypeDelegate->addEntry(QCoreApplication::translate("Global", Shared::VCard::Phone::typeNames[6].toStdString().c_str()));
|
||||
|
||||
m_ui->emailsView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
m_ui->emailsView->setModel(&emails);
|
||||
m_ui->emailsView->setItemDelegateForColumn(1, roleDelegate);
|
||||
m_ui->emailsView->setColumnWidth(2, 25);
|
||||
m_ui->emailsView->horizontalHeader()->setStretchLastSection(false);
|
||||
m_ui->emailsView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
|
||||
m_ui->phonesView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
m_ui->phonesView->setModel(&phones);
|
||||
m_ui->phonesView->setItemDelegateForColumn(1, roleDelegate);
|
||||
m_ui->phonesView->setItemDelegateForColumn(2, phoneTypeDelegate);
|
||||
m_ui->phonesView->setColumnWidth(3, 25);
|
||||
m_ui->phonesView->horizontalHeader()->setStretchLastSection(false);
|
||||
m_ui->phonesView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
|
||||
connect(m_ui->phonesView, &QWidget::customContextMenuRequested, this, &VCard::onContextMenu);
|
||||
connect(m_ui->emailsView, &QWidget::customContextMenuRequested, this, &VCard::onContextMenu);
|
||||
|
||||
if (edit) {
|
||||
avatarMenu = new QMenu();
|
||||
m_ui->avatarButton->setMenu(avatarMenu);
|
||||
avatarMenu->addAction(setAvatar);
|
||||
avatarMenu->addAction(clearAvatar);
|
||||
m_ui->title->setText(tr("Account %1 card").arg(jid));
|
||||
} else {
|
||||
m_ui->buttonBox->hide();
|
||||
m_ui->fullName->setReadOnly(true);
|
||||
m_ui->firstName->setReadOnly(true);
|
||||
m_ui->middleName->setReadOnly(true);
|
||||
m_ui->lastName->setReadOnly(true);
|
||||
m_ui->nickName->setReadOnly(true);
|
||||
m_ui->birthday->setReadOnly(true);
|
||||
m_ui->organizationName->setReadOnly(true);
|
||||
m_ui->organizationDepartment->setReadOnly(true);
|
||||
m_ui->organizationTitle->setReadOnly(true);
|
||||
m_ui->organizationRole->setReadOnly(true);
|
||||
m_ui->description->setReadOnly(true);
|
||||
m_ui->url->setReadOnly(true);
|
||||
m_ui->title->setText(tr("Contact %1 card").arg(jid));
|
||||
}
|
||||
|
||||
connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &VCard::onButtonBoxAccepted);
|
||||
connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &VCard::close);
|
||||
|
||||
avatarButtonMargins = m_ui->avatarButton->size();
|
||||
|
||||
int height = m_ui->personalForm->minimumSize().height() - avatarButtonMargins.height();
|
||||
m_ui->avatarButton->setIconSize(QSize(height, height));
|
||||
|
||||
QGridLayout* gr = static_cast<QGridLayout*>(layout());
|
||||
gr->addWidget(overlay, 0, 0, 4, 1);
|
||||
QVBoxLayout* nl = new QVBoxLayout();
|
||||
QGraphicsOpacityEffect* opacity = new QGraphicsOpacityEffect();
|
||||
opacity->setOpacity(0.8);
|
||||
overlay->setLayout(nl);
|
||||
overlay->setBackgroundRole(QPalette::Base);
|
||||
overlay->setAutoFillBackground(true);
|
||||
overlay->setGraphicsEffect(opacity);
|
||||
progressLabel->setAlignment(Qt::AlignCenter);
|
||||
progressLabel->setStyleSheet("font: 16pt");
|
||||
nl->addStretch();
|
||||
nl->addWidget(progress);
|
||||
nl->addWidget(progressLabel);
|
||||
nl->addStretch();
|
||||
overlay->hide();
|
||||
}
|
||||
|
||||
VCard::~VCard()
|
||||
{
|
||||
if (editable) {
|
||||
avatarMenu->deleteLater();
|
||||
}
|
||||
|
||||
phoneTypeDelegate->deleteLater();
|
||||
roleDelegate->deleteLater();
|
||||
contextMenu->deleteLater();
|
||||
}
|
||||
|
||||
void VCard::setVCard(const QString& jid, const Shared::VCard& card)
|
||||
{
|
||||
m_ui->jabberID->setText(jid);
|
||||
setVCard(card);
|
||||
}
|
||||
|
||||
void VCard::setVCard(const Shared::VCard& card)
|
||||
{
|
||||
m_ui->fullName->setText(card.getFullName());
|
||||
m_ui->firstName->setText(card.getFirstName());
|
||||
m_ui->middleName->setText(card.getMiddleName());
|
||||
m_ui->lastName->setText(card.getLastName());
|
||||
m_ui->nickName->setText(card.getNickName());
|
||||
m_ui->birthday->setDate(card.getBirthday());
|
||||
m_ui->organizationName->setText(card.getOrgName());
|
||||
m_ui->organizationDepartment->setText(card.getOrgUnit());
|
||||
m_ui->organizationTitle->setText(card.getOrgTitle());
|
||||
m_ui->organizationRole->setText(card.getOrgRole());
|
||||
m_ui->description->setText(card.getDescription());
|
||||
m_ui->url->setText(card.getUrl());
|
||||
|
||||
QDateTime receivingTime = card.getReceivingTime();
|
||||
m_ui->receivingTimeLabel->setText(tr("Received %1 at %2").arg(receivingTime.date().toString()).arg(receivingTime.time().toString()));
|
||||
currentAvatarType = card.getAvatarType();
|
||||
currentAvatarPath = card.getAvatarPath();
|
||||
|
||||
updateAvatar();
|
||||
|
||||
const std::deque<Shared::VCard::Email>& ems = card.getEmails();
|
||||
const std::deque<Shared::VCard::Phone>& phs = card.getPhones();
|
||||
emails.setEmails(ems);
|
||||
phones.setPhones(phs);
|
||||
}
|
||||
|
||||
QString VCard::getJid() const
|
||||
{
|
||||
return m_ui->jabberID->text();
|
||||
}
|
||||
|
||||
void VCard::onButtonBoxAccepted()
|
||||
{
|
||||
Shared::VCard card;
|
||||
card.setFullName(m_ui->fullName->text());
|
||||
card.setFirstName(m_ui->firstName->text());
|
||||
card.setMiddleName(m_ui->middleName->text());
|
||||
card.setLastName(m_ui->lastName->text());
|
||||
card.setNickName(m_ui->nickName->text());
|
||||
card.setBirthday(m_ui->birthday->date());
|
||||
card.setDescription(m_ui->description->toPlainText());
|
||||
card.setUrl(m_ui->url->text());
|
||||
card.setOrgName(m_ui->organizationName->text());
|
||||
card.setOrgUnit(m_ui->organizationDepartment->text());
|
||||
card.setOrgRole(m_ui->organizationRole->text());
|
||||
card.setOrgTitle(m_ui->organizationTitle->text());
|
||||
card.setAvatarPath(currentAvatarPath);
|
||||
card.setAvatarType(currentAvatarType);
|
||||
|
||||
emails.getEmails(card.getEmails());
|
||||
phones.getPhones(card.getPhones());
|
||||
|
||||
emit saveVCard(card);
|
||||
}
|
||||
|
||||
void VCard::onClearAvatar()
|
||||
{
|
||||
currentAvatarType = Shared::Avatar::empty;
|
||||
currentAvatarPath = "";
|
||||
|
||||
updateAvatar();
|
||||
}
|
||||
|
||||
void VCard::onSetAvatar()
|
||||
{
|
||||
QFileDialog* d = new QFileDialog(this, tr("Chose your new avatar"));
|
||||
d->setFileMode(QFileDialog::ExistingFile);
|
||||
d->setNameFilter(tr("Images (*.png *.jpg *.jpeg)"));
|
||||
|
||||
connect(d, &QFileDialog::accepted, this, &VCard::onAvatarSelected);
|
||||
connect(d, &QFileDialog::rejected, d, &QFileDialog::deleteLater);
|
||||
|
||||
d->show();
|
||||
}
|
||||
|
||||
void VCard::updateAvatar()
|
||||
{
|
||||
int height = m_ui->personalForm->minimumSize().height() - avatarButtonMargins.height();
|
||||
switch (currentAvatarType) {
|
||||
case Shared::Avatar::empty:
|
||||
m_ui->avatarButton->setIcon(Shared::icon("user", true));
|
||||
m_ui->avatarButton->setIconSize(QSize(height, height));
|
||||
m_ui->actionClearAvatar->setEnabled(false);
|
||||
break;
|
||||
case Shared::Avatar::autocreated:
|
||||
case Shared::Avatar::valid:
|
||||
QPixmap pixmap(currentAvatarPath);
|
||||
qreal h = pixmap.height();
|
||||
qreal w = pixmap.width();
|
||||
qreal aspectRatio = w / h;
|
||||
m_ui->avatarButton->setIconSize(QSize(height * aspectRatio, height));
|
||||
m_ui->avatarButton->setIcon(QIcon(currentAvatarPath));
|
||||
m_ui->actionClearAvatar->setEnabled(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void VCard::onAvatarSelected()
|
||||
{
|
||||
QFileDialog* d = static_cast<QFileDialog*>(sender());
|
||||
QMimeDatabase db;
|
||||
QString path = d->selectedFiles().front();
|
||||
QMimeType type = db.mimeTypeForFile(path);
|
||||
d->deleteLater();
|
||||
|
||||
if (supportedTypes.find(type.name()) == supportedTypes.end()) {
|
||||
qDebug() << "Selected for avatar file is not supported, skipping";
|
||||
} else {
|
||||
QImage src(path);
|
||||
QImage dst;
|
||||
if (src.width() > 160 || src.height() > 160) {
|
||||
dst = src.scaled(160, 160, Qt::KeepAspectRatio);
|
||||
}
|
||||
QString path = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/" + m_ui->jabberID->text() + ".temp." + type.preferredSuffix();
|
||||
QFile oldTemp(path);
|
||||
if (oldTemp.exists()) {
|
||||
if (!oldTemp.remove()) {
|
||||
qDebug() << "Error removing old temp avatar" << path;
|
||||
return;
|
||||
}
|
||||
}
|
||||
bool success = dst.save(path);
|
||||
if (success) {
|
||||
currentAvatarPath = path;
|
||||
currentAvatarType = Shared::Avatar::valid;
|
||||
|
||||
updateAvatar();
|
||||
} else {
|
||||
qDebug() << "couldn't save avatar" << path << ", skipping";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VCard::showProgress(const QString& line)
|
||||
{
|
||||
progressLabel->setText(line);
|
||||
overlay->show();
|
||||
progress->start();
|
||||
}
|
||||
|
||||
void VCard::hideProgress()
|
||||
{
|
||||
overlay->hide();
|
||||
progress->stop();
|
||||
}
|
||||
|
||||
void VCard::onContextMenu(const QPoint& point)
|
||||
{
|
||||
contextMenu->clear();
|
||||
bool hasMenu = false;
|
||||
QAbstractItemView* snd = static_cast<QAbstractItemView*>(sender());
|
||||
if (snd == m_ui->emailsView) {
|
||||
hasMenu = true;
|
||||
if (editable) {
|
||||
QAction* add = contextMenu->addAction(Shared::icon("list-add"), tr("Add email address"));
|
||||
connect(add, &QAction::triggered, this, &VCard::onAddEmail);
|
||||
|
||||
QItemSelectionModel* sm = m_ui->emailsView->selectionModel();
|
||||
int selectionSize = sm->selectedRows().size();
|
||||
|
||||
if (selectionSize > 0) {
|
||||
if (selectionSize == 1) {
|
||||
int row = sm->selectedRows().at(0).row();
|
||||
if (emails.isPreferred(row)) {
|
||||
QAction* rev = contextMenu->addAction(Shared::icon("unfavorite"), tr("Unset this email as preferred"));
|
||||
connect(rev, &QAction::triggered, std::bind(&UI::VCard::EMailsModel::revertPreferred, &emails, row));
|
||||
} else {
|
||||
QAction* rev = contextMenu->addAction(Shared::icon("favorite"), tr("Set this email as preferred"));
|
||||
connect(rev, &QAction::triggered, std::bind(&UI::VCard::EMailsModel::revertPreferred, &emails, row));
|
||||
}
|
||||
}
|
||||
|
||||
QAction* del = contextMenu->addAction(Shared::icon("edit-delete"), tr("Remove selected email addresses"));
|
||||
connect(del, &QAction::triggered, this, &VCard::onRemoveEmail);
|
||||
}
|
||||
}
|
||||
|
||||
QAction* cp = contextMenu->addAction(Shared::icon("edit-copy"), tr("Copy selected emails to clipboard"));
|
||||
connect(cp, &QAction::triggered, this, &VCard::onCopyEmail);
|
||||
} else if (snd == m_ui->phonesView) {
|
||||
hasMenu = true;
|
||||
if (editable) {
|
||||
QAction* add = contextMenu->addAction(Shared::icon("list-add"), tr("Add phone number"));
|
||||
connect(add, &QAction::triggered, this, &VCard::onAddPhone);
|
||||
|
||||
QItemSelectionModel* sm = m_ui->phonesView->selectionModel();
|
||||
int selectionSize = sm->selectedRows().size();
|
||||
|
||||
if (selectionSize > 0) {
|
||||
if (selectionSize == 1) {
|
||||
int row = sm->selectedRows().at(0).row();
|
||||
if (phones.isPreferred(row)) {
|
||||
QAction* rev = contextMenu->addAction(Shared::icon("view-media-favorite"), tr("Unset this phone as preferred"));
|
||||
connect(rev, &QAction::triggered, std::bind(&UI::VCard::PhonesModel::revertPreferred, &phones, row));
|
||||
} else {
|
||||
QAction* rev = contextMenu->addAction(Shared::icon("favorite"), tr("Set this phone as preferred"));
|
||||
connect(rev, &QAction::triggered, std::bind(&UI::VCard::PhonesModel::revertPreferred, &phones, row));
|
||||
}
|
||||
}
|
||||
|
||||
QAction* del = contextMenu->addAction(Shared::icon("edit-delete"), tr("Remove selected phone numbers"));
|
||||
connect(del, &QAction::triggered, this, &VCard::onRemovePhone);
|
||||
}
|
||||
}
|
||||
|
||||
QAction* cp = contextMenu->addAction(Shared::icon("edit-copy"), tr("Copy selected phones to clipboard"));
|
||||
connect(cp, &QAction::triggered, this, &VCard::onCopyPhone);
|
||||
}
|
||||
|
||||
if (hasMenu) {
|
||||
contextMenu->popup(snd->viewport()->mapToGlobal(point));
|
||||
}
|
||||
}
|
||||
|
||||
void VCard::onAddEmail()
|
||||
{
|
||||
QModelIndex index = emails.addNewEmptyLine();
|
||||
m_ui->emailsView->setCurrentIndex(index);
|
||||
m_ui->emailsView->edit(index);
|
||||
}
|
||||
|
||||
void VCard::onAddAddress()
|
||||
{
|
||||
|
||||
}
|
||||
void VCard::onAddPhone()
|
||||
{
|
||||
QModelIndex index = phones.addNewEmptyLine();
|
||||
m_ui->phonesView->setCurrentIndex(index);
|
||||
m_ui->phonesView->edit(index);
|
||||
}
|
||||
void VCard::onRemoveAddress()
|
||||
{
|
||||
}
|
||||
void VCard::onRemoveEmail()
|
||||
{
|
||||
QItemSelection selection(m_ui->emailsView->selectionModel()->selection());
|
||||
|
||||
QList<int> rows;
|
||||
for (const QModelIndex& index : selection.indexes()) {
|
||||
rows.append(index.row());
|
||||
}
|
||||
|
||||
std::sort(rows.begin(), rows.end());
|
||||
|
||||
int prev = -1;
|
||||
for (int i = rows.count() - 1; i >= 0; i -= 1) {
|
||||
int current = rows[i];
|
||||
if (current != prev) {
|
||||
emails.removeLines(current, 1);
|
||||
prev = current;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VCard::onRemovePhone()
|
||||
{
|
||||
QItemSelection selection(m_ui->phonesView->selectionModel()->selection());
|
||||
|
||||
QList<int> rows;
|
||||
for (const QModelIndex& index : selection.indexes()) {
|
||||
rows.append(index.row());
|
||||
}
|
||||
|
||||
std::sort(rows.begin(), rows.end());
|
||||
|
||||
int prev = -1;
|
||||
for (int i = rows.count() - 1; i >= 0; i -= 1) {
|
||||
int current = rows[i];
|
||||
if (current != prev) {
|
||||
phones.removeLines(current, 1);
|
||||
prev = current;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VCard::onCopyEmail()
|
||||
{
|
||||
QList<QModelIndex> selection(m_ui->emailsView->selectionModel()->selectedRows());
|
||||
|
||||
QList<QString> addrs;
|
||||
for (const QModelIndex& index : selection) {
|
||||
addrs.push_back(emails.getEmail(index.row()));
|
||||
}
|
||||
|
||||
QString list = addrs.join("\n");
|
||||
|
||||
QClipboard* cb = QApplication::clipboard();
|
||||
cb->setText(list);
|
||||
}
|
||||
|
||||
void VCard::onCopyPhone()
|
||||
{
|
||||
QList<QModelIndex> selection(m_ui->phonesView->selectionModel()->selectedRows());
|
||||
|
||||
QList<QString> phs;
|
||||
for (const QModelIndex& index : selection) {
|
||||
phs.push_back(phones.getPhone(index.row()));
|
||||
}
|
||||
|
||||
QString list = phs.join("\n");
|
||||
|
||||
QClipboard* cb = QApplication::clipboard();
|
||||
cb->setText(list);
|
||||
}
|
106
ui/widgets/vcard/vcard.h
Normal file
106
ui/widgets/vcard/vcard.h
Normal file
|
@ -0,0 +1,106 @@
|
|||
/*
|
||||
* Squawk messenger.
|
||||
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef VCARD_H
|
||||
#define VCARD_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QScopedPointer>
|
||||
#include <QPixmap>
|
||||
#include <QMenu>
|
||||
#include <QFileDialog>
|
||||
#include <QMimeDatabase>
|
||||
#include <QImage>
|
||||
#include <QStandardPaths>
|
||||
#include <QLabel>
|
||||
#include <QGraphicsOpacityEffect>
|
||||
#include <QVBoxLayout>
|
||||
#include <QMenu>
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "global.h"
|
||||
#include "emailsmodel.h"
|
||||
#include "phonesmodel.h"
|
||||
#include "ui/utils/progress.h"
|
||||
#include "ui/utils/comboboxdelegate.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class VCard;
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo write docs
|
||||
*/
|
||||
class VCard : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VCard(const QString& jid, bool edit = false, QWidget* parent = nullptr);
|
||||
~VCard();
|
||||
|
||||
void setVCard(const Shared::VCard& card);
|
||||
void setVCard(const QString& jid, const Shared::VCard& card);
|
||||
QString getJid() const;
|
||||
void showProgress(const QString& = "");
|
||||
void hideProgress();
|
||||
|
||||
signals:
|
||||
void saveVCard(const Shared::VCard& card);
|
||||
|
||||
private slots:
|
||||
void onButtonBoxAccepted();
|
||||
void onClearAvatar();
|
||||
void onSetAvatar();
|
||||
void onAvatarSelected();
|
||||
void onAddAddress();
|
||||
void onRemoveAddress();
|
||||
void onAddEmail();
|
||||
void onCopyEmail();
|
||||
void onRemoveEmail();
|
||||
void onAddPhone();
|
||||
void onCopyPhone();
|
||||
void onRemovePhone();
|
||||
void onContextMenu(const QPoint& point);
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::VCard> m_ui;
|
||||
QSize avatarButtonMargins;
|
||||
QMenu* avatarMenu;
|
||||
bool editable;
|
||||
Shared::Avatar currentAvatarType;
|
||||
QString currentAvatarPath;
|
||||
Progress* progress;
|
||||
QLabel* progressLabel;
|
||||
QWidget* overlay;
|
||||
QMenu* contextMenu;
|
||||
UI::VCard::EMailsModel emails;
|
||||
UI::VCard::PhonesModel phones;
|
||||
ComboboxDelegate* roleDelegate;
|
||||
ComboboxDelegate* phoneTypeDelegate;
|
||||
|
||||
static const std::set<QString> supportedTypes;
|
||||
|
||||
private:
|
||||
void updateAvatar();
|
||||
};
|
||||
|
||||
#endif // VCARD_H
|
892
ui/widgets/vcard/vcard.ui
Normal file
892
ui/widgets/vcard/vcard.ui
Normal file
|
@ -0,0 +1,892 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>VCard</class>
|
||||
<widget class="QWidget" name="VCard">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>578</width>
|
||||
<height>671</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="title">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">font: 16pt </string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Contact john@dow.org card</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="receivingTimeLabel">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">font: italic 8pt;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Received 12.07.2007 at 17.35</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::TabFocus</enum>
|
||||
</property>
|
||||
<property name="tabPosition">
|
||||
<enum>QTabWidget::North</enum>
|
||||
</property>
|
||||
<property name="tabShape">
|
||||
<enum>QTabWidget::Rounded</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="elideMode">
|
||||
<enum>Qt::ElideNone</enum>
|
||||
</property>
|
||||
<property name="documentMode">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="tabBarAutoHide">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="General">
|
||||
<attribute name="title">
|
||||
<string>General</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_2" columnstretch="1,2,2,1">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="horizontalSpacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="6" column="1" colspan="2">
|
||||
<widget class="QLabel" name="organizationHeading">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">font: 600 16pt;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Organization</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<layout class="QFormLayout" name="personalForm">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<property name="formAlignment">
|
||||
<set>Qt::AlignHCenter|Qt::AlignTop</set>
|
||||
</property>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="middleName">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>350</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="firstName">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>350</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="middleNameLabel">
|
||||
<property name="text">
|
||||
<string>Middle name</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>middleName</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="firstNameLabel">
|
||||
<property name="text">
|
||||
<string>First name</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>firstName</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lastNameLabel">
|
||||
<property name="text">
|
||||
<string>Last name</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>lastName</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="lastName">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>350</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="nickNameLabel">
|
||||
<property name="text">
|
||||
<string>Nick name</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>nickName</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="nickName">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>350</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="birthdayLabel">
|
||||
<property name="text">
|
||||
<string>Birthday</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>birthday</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QDateEdit" name="birthday"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="7" column="1" colspan="2">
|
||||
<layout class="QFormLayout" name="organizationForm">
|
||||
<property name="formAlignment">
|
||||
<set>Qt::AlignHCenter|Qt::AlignTop</set>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="organizationNameLabel">
|
||||
<property name="text">
|
||||
<string>Organization name</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>organizationName</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="organizationName">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>350</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="organizationDepartmentLabel">
|
||||
<property name="text">
|
||||
<string>Unit / Department</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>organizationDepartment</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="organizationDepartment">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>350</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="roleLabel">
|
||||
<property name="text">
|
||||
<string>Role / Profession</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>organizationRole</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="organizationRole">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>350</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="organizationTitleLabel">
|
||||
<property name="text">
|
||||
<string>Job title</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>organizationTitle</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="organizationTitle">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>350</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="8" column="1" colspan="2">
|
||||
<widget class="Line" name="organizationLine">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<layout class="QFormLayout" name="commonForm">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="fullName"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="fullNameLabel">
|
||||
<property name="text">
|
||||
<string>Full name</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>fullName</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0" rowspan="7">
|
||||
<spacer name="generalLeftHSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="2">
|
||||
<widget class="Line" name="personalLine">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="4">
|
||||
<widget class="QLabel" name="generalHeading">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">font: 600 24pt ;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>General</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3" rowspan="7">
|
||||
<spacer name="generalRightHSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QLabel" name="personalHeading">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">font: 600 16pt;</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Personal information</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QToolButton" name="avatarButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="user">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="popupMode">
|
||||
<enum>QToolButton::InstantPopup</enum>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonIconOnly</enum>
|
||||
</property>
|
||||
<property name="arrowType">
|
||||
<enum>Qt::NoArrow</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="Contact">
|
||||
<attribute name="title">
|
||||
<string>Contact</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="contactHeading">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">font: 600 24pt ;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Contact</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="contactScrollArea">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>566</width>
|
||||
<height>498</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3" columnstretch="1,3,1">
|
||||
<item row="7" column="1">
|
||||
<widget class="Line" name="phonesLine">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QTableView" name="emailsView">
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="showGrid">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<widget class="Line" name="addressesLine">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" rowspan="12">
|
||||
<spacer name="contactLeftSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="Line" name="contactFormLine">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="Line" name="emailsLine">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="1">
|
||||
<spacer name="contactBottomSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QLabel" name="addressesHeading">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">font: 600 16pt;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Addresses</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QTableView" name="phonesView">
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="showGrid">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="emailsHeading">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">font: 600 16pt;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>E-Mail addresses</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QFormLayout" name="contactForm">
|
||||
<property name="formAlignment">
|
||||
<set>Qt::AlignHCenter|Qt::AlignTop</set>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="jabberID">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="jabberIDLabel">
|
||||
<property name="text">
|
||||
<string>Jabber ID</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>jabberID</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="url">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="urlLabel">
|
||||
<property name="text">
|
||||
<string>Web site</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>url</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="2" rowspan="12">
|
||||
<spacer name="contactRightSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLabel" name="phenesHeading">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">font: 600 16pt;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Phone numbers</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<widget class="QTableView" name="addressesView">
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="showGrid">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="Description">
|
||||
<attribute name="title">
|
||||
<string>Description</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="horizontalSpacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="descriptionHeading">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">font: 600 24pt ;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Description</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QTextEdit" name="description">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextEditable|Qt::TextEditorInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close|QDialogButtonBox::Save</set>
|
||||
</property>
|
||||
<property name="centerButtons">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
<action name="actionSetAvatar">
|
||||
<property name="icon">
|
||||
<iconset theme="photo">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Set avatar</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionClearAvatar">
|
||||
<property name="icon">
|
||||
<iconset theme="edit-clear-all">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Clear avatar</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>fullName</tabstop>
|
||||
<tabstop>firstName</tabstop>
|
||||
<tabstop>middleName</tabstop>
|
||||
<tabstop>lastName</tabstop>
|
||||
<tabstop>nickName</tabstop>
|
||||
<tabstop>birthday</tabstop>
|
||||
<tabstop>avatarButton</tabstop>
|
||||
<tabstop>organizationName</tabstop>
|
||||
<tabstop>organizationDepartment</tabstop>
|
||||
<tabstop>organizationRole</tabstop>
|
||||
<tabstop>organizationTitle</tabstop>
|
||||
<tabstop>jabberID</tabstop>
|
||||
<tabstop>url</tabstop>
|
||||
<tabstop>description</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="../../resources/resources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Add table
Add a link
Reference in a new issue