forked from blue/squawk
deprecation fix about qxmpp, beginning of adding email addresses in VCards
This commit is contained in:
parent
c067835b00
commit
9d491e9e93
@ -9,6 +9,7 @@ set(CMAKE_AUTOUIC ON)
|
|||||||
set(CMAKE_AUTORCC ON)
|
set(CMAKE_AUTORCC ON)
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
include_directories(.)
|
||||||
|
|
||||||
find_package(Qt5Widgets CONFIG REQUIRED)
|
find_package(Qt5Widgets CONFIG REQUIRED)
|
||||||
find_package(Qt5LinguistTools)
|
find_package(Qt5LinguistTools)
|
||||||
|
@ -36,6 +36,8 @@ Account::Account(const QString& p_login, const QString& p_server, const QString&
|
|||||||
am(new QXmppMamManager()),
|
am(new QXmppMamManager()),
|
||||||
mm(new QXmppMucManager()),
|
mm(new QXmppMucManager()),
|
||||||
bm(new QXmppBookmarkManager()),
|
bm(new QXmppBookmarkManager()),
|
||||||
|
rm(client.findExtension<QXmppRosterManager>()),
|
||||||
|
vm(client.findExtension<QXmppVCardManager>()),
|
||||||
contacts(),
|
contacts(),
|
||||||
conferences(),
|
conferences(),
|
||||||
maxReconnectTimes(0),
|
maxReconnectTimes(0),
|
||||||
@ -57,12 +59,10 @@ Account::Account(const QString& p_login, const QString& p_server, const QString&
|
|||||||
QObject::connect(&client, &QXmppClient::messageReceived, this, &Account::onMessageReceived);
|
QObject::connect(&client, &QXmppClient::messageReceived, this, &Account::onMessageReceived);
|
||||||
QObject::connect(&client, &QXmppClient::error, this, &Account::onClientError);
|
QObject::connect(&client, &QXmppClient::error, this, &Account::onClientError);
|
||||||
|
|
||||||
QXmppRosterManager& rm = client.rosterManager();
|
QObject::connect(rm, &QXmppRosterManager::rosterReceived, this, &Account::onRosterReceived);
|
||||||
|
QObject::connect(rm, &QXmppRosterManager::itemAdded, this, &Account::onRosterItemAdded);
|
||||||
QObject::connect(&rm, &QXmppRosterManager::rosterReceived, this, &Account::onRosterReceived);
|
QObject::connect(rm, &QXmppRosterManager::itemRemoved, this, &Account::onRosterItemRemoved);
|
||||||
QObject::connect(&rm, &QXmppRosterManager::itemAdded, this, &Account::onRosterItemAdded);
|
QObject::connect(rm, &QXmppRosterManager::itemChanged, this, &Account::onRosterItemChanged);
|
||||||
QObject::connect(&rm, &QXmppRosterManager::itemRemoved, this, &Account::onRosterItemRemoved);
|
|
||||||
QObject::connect(&rm, &QXmppRosterManager::itemChanged, this, &Account::onRosterItemChanged);
|
|
||||||
//QObject::connect(&rm, &QXmppRosterManager::presenceChanged, this, &Account::onRosterPresenceChanged);
|
//QObject::connect(&rm, &QXmppRosterManager::presenceChanged, this, &Account::onRosterPresenceChanged);
|
||||||
|
|
||||||
client.addExtension(cm);
|
client.addExtension(cm);
|
||||||
@ -82,8 +82,7 @@ Account::Account(const QString& p_login, const QString& p_server, const QString&
|
|||||||
client.addExtension(bm);
|
client.addExtension(bm);
|
||||||
QObject::connect(bm, &QXmppBookmarkManager::bookmarksReceived, this, &Account::bookmarksReceived);
|
QObject::connect(bm, &QXmppBookmarkManager::bookmarksReceived, this, &Account::bookmarksReceived);
|
||||||
|
|
||||||
QXmppVCardManager& vm = client.vCardManager();
|
QObject::connect(vm, &QXmppVCardManager::vCardReceived, this, &Account::onVCardReceived);
|
||||||
QObject::connect(&vm, &QXmppVCardManager::vCardReceived, this, &Account::onVCardReceived);
|
|
||||||
//QObject::connect(&vm, &QXmppVCardManager::clientVCardReceived, this, &Account::onOwnVCardReceived); //for some reason it doesn't work, launching from common handler
|
//QObject::connect(&vm, &QXmppVCardManager::clientVCardReceived, this, &Account::onOwnVCardReceived); //for some reason it doesn't work, launching from common handler
|
||||||
|
|
||||||
QString path(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
|
QString path(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
|
||||||
@ -240,11 +239,10 @@ QString Core::Account::getServer() const
|
|||||||
|
|
||||||
void Core::Account::onRosterReceived()
|
void Core::Account::onRosterReceived()
|
||||||
{
|
{
|
||||||
client.vCardManager().requestClientVCard(); //TODO need to make sure server actually supports vCards
|
vm->requestClientVCard(); //TODO need to make sure server actually supports vCards
|
||||||
ownVCardRequestInProgress = true;
|
ownVCardRequestInProgress = true;
|
||||||
|
|
||||||
QXmppRosterManager& rm = client.rosterManager();
|
QStringList bj = rm->getRosterBareJids();
|
||||||
QStringList bj = rm.getRosterBareJids();
|
|
||||||
for (int i = 0; i < bj.size(); ++i) {
|
for (int i = 0; i < bj.size(); ++i) {
|
||||||
const QString& jid = bj[i];
|
const QString& jid = bj[i];
|
||||||
addedAccount(jid);
|
addedAccount(jid);
|
||||||
@ -264,8 +262,7 @@ void Core::Account::onRosterItemAdded(const QString& bareJid)
|
|||||||
addedAccount(bareJid);
|
addedAccount(bareJid);
|
||||||
std::map<QString, QString>::const_iterator itr = queuedContacts.find(bareJid);
|
std::map<QString, QString>::const_iterator itr = queuedContacts.find(bareJid);
|
||||||
if (itr != queuedContacts.end()) {
|
if (itr != queuedContacts.end()) {
|
||||||
QXmppRosterManager& rm = client.rosterManager();
|
rm->subscribe(bareJid, itr->second);
|
||||||
rm.subscribe(bareJid, itr->second);
|
|
||||||
queuedContacts.erase(itr);
|
queuedContacts.erase(itr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -278,8 +275,7 @@ void Core::Account::onRosterItemChanged(const QString& bareJid)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Contact* contact = itr->second;
|
Contact* contact = itr->second;
|
||||||
QXmppRosterManager& rm = client.rosterManager();
|
QXmppRosterIq::Item re = rm->getRosterEntry(bareJid);
|
||||||
QXmppRosterIq::Item re = rm.getRosterEntry(bareJid);
|
|
||||||
|
|
||||||
Shared::SubscriptionState state = castSubscriptionState(re.subscriptionType());
|
Shared::SubscriptionState state = castSubscriptionState(re.subscriptionType());
|
||||||
|
|
||||||
@ -308,9 +304,8 @@ void Core::Account::onRosterItemRemoved(const QString& bareJid)
|
|||||||
|
|
||||||
void Core::Account::addedAccount(const QString& jid)
|
void Core::Account::addedAccount(const QString& jid)
|
||||||
{
|
{
|
||||||
QXmppRosterManager& rm = client.rosterManager();
|
|
||||||
std::map<QString, Contact*>::const_iterator itr = contacts.find(jid);
|
std::map<QString, Contact*>::const_iterator itr = contacts.find(jid);
|
||||||
QXmppRosterIq::Item re = rm.getRosterEntry(jid);
|
QXmppRosterIq::Item re = rm->getRosterEntry(jid);
|
||||||
Contact* contact;
|
Contact* contact;
|
||||||
bool newContact = false;
|
bool newContact = false;
|
||||||
if (itr == contacts.end()) {
|
if (itr == contacts.end()) {
|
||||||
@ -410,13 +405,13 @@ void Core::Account::onPresenceReceived(const QXmppPresence& p_presence)
|
|||||||
break;
|
break;
|
||||||
case QXmppPresence::VCardUpdateNoPhoto: //there is no photo, need to drop if any
|
case QXmppPresence::VCardUpdateNoPhoto: //there is no photo, need to drop if any
|
||||||
if (avatarType.size() > 0) {
|
if (avatarType.size() > 0) {
|
||||||
client.vCardManager().requestClientVCard();
|
vm->requestClientVCard();
|
||||||
ownVCardRequestInProgress = true;
|
ownVCardRequestInProgress = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case QXmppPresence::VCardUpdateValidPhoto: //there is a photo, need to load
|
case QXmppPresence::VCardUpdateValidPhoto: //there is a photo, need to load
|
||||||
if (avatarHash != p_presence.photoHash()) {
|
if (avatarHash != p_presence.photoHash()) {
|
||||||
client.vCardManager().requestClientVCard();
|
vm->requestClientVCard();
|
||||||
ownVCardRequestInProgress = true;
|
ownVCardRequestInProgress = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -493,7 +488,7 @@ void Core::Account::onRosterPresenceChanged(const QString& bareJid, const QStrin
|
|||||||
{
|
{
|
||||||
//not used for now;
|
//not used for now;
|
||||||
qDebug() << "presence changed for " << bareJid << " resource " << resource;
|
qDebug() << "presence changed for " << bareJid << " resource " << resource;
|
||||||
const QXmppPresence& presence = client.rosterManager().getPresence(bareJid, resource);
|
const QXmppPresence& presence = rm->getPresence(bareJid, resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Account::setLogin(const QString& p_login)
|
void Core::Account::setLogin(const QString& p_login)
|
||||||
@ -1053,8 +1048,7 @@ void Core::Account::onClientError(QXmppClient::Error err)
|
|||||||
void Core::Account::subscribeToContact(const QString& jid, const QString& reason)
|
void Core::Account::subscribeToContact(const QString& jid, const QString& reason)
|
||||||
{
|
{
|
||||||
if (state == Shared::connected) {
|
if (state == Shared::connected) {
|
||||||
QXmppRosterManager& rm = client.rosterManager();
|
rm->subscribe(jid, reason);
|
||||||
rm.subscribe(jid, reason);
|
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "An attempt to subscribe account " << name << " to contact " << jid << " but the account is not in the connected state, skipping";
|
qDebug() << "An attempt to subscribe account " << name << " to contact " << jid << " but the account is not in the connected state, skipping";
|
||||||
}
|
}
|
||||||
@ -1063,8 +1057,7 @@ void Core::Account::subscribeToContact(const QString& jid, const QString& reason
|
|||||||
void Core::Account::unsubscribeFromContact(const QString& jid, const QString& reason)
|
void Core::Account::unsubscribeFromContact(const QString& jid, const QString& reason)
|
||||||
{
|
{
|
||||||
if (state == Shared::connected) {
|
if (state == Shared::connected) {
|
||||||
QXmppRosterManager& rm = client.rosterManager();
|
rm->unsubscribe(jid, reason);
|
||||||
rm.unsubscribe(jid, reason);
|
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "An attempt to unsubscribe account " << name << " from contact " << jid << " but the account is not in the connected state, skipping";
|
qDebug() << "An attempt to unsubscribe account " << name << " from contact " << jid << " but the account is not in the connected state, skipping";
|
||||||
}
|
}
|
||||||
@ -1078,8 +1071,7 @@ void Core::Account::removeContactRequest(const QString& jid)
|
|||||||
outOfRosterContacts.erase(itr);
|
outOfRosterContacts.erase(itr);
|
||||||
onRosterItemRemoved(jid);
|
onRosterItemRemoved(jid);
|
||||||
} else {
|
} else {
|
||||||
QXmppRosterManager& rm = client.rosterManager();
|
rm->removeItem(jid);
|
||||||
rm.removeItem(jid);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "An attempt to remove contact " << jid << " from account " << name << " but the account is not in the connected state, skipping";
|
qDebug() << "An attempt to remove contact " << jid << " from account " << name << " but the account is not in the connected state, skipping";
|
||||||
@ -1095,8 +1087,7 @@ void Core::Account::addContactRequest(const QString& jid, const QString& name, c
|
|||||||
qDebug() << "An attempt to add contact " << jid << " to account " << name << " but the account is already queued for adding, skipping";
|
qDebug() << "An attempt to add contact " << jid << " to account " << name << " but the account is already queued for adding, skipping";
|
||||||
} else {
|
} else {
|
||||||
queuedContacts.insert(std::make_pair(jid, "")); //TODO need to add reason here;
|
queuedContacts.insert(std::make_pair(jid, "")); //TODO need to add reason here;
|
||||||
QXmppRosterManager& rm = client.rosterManager();
|
rm->addItem(jid, name, groups);
|
||||||
rm.addItem(jid, name, groups);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "An attempt to add contact " << jid << " to account " << name << " but the account is not in the connected state, skipping";
|
qDebug() << "An attempt to add contact " << jid << " to account " << name << " but the account is not in the connected state, skipping";
|
||||||
@ -1273,8 +1264,7 @@ void Core::Account::addContactToGroupRequest(const QString& jid, const QString&
|
|||||||
if (itr == contacts.end()) {
|
if (itr == contacts.end()) {
|
||||||
qDebug() << "An attempt to add non existing contact" << jid << "of account" << name << "to the group" << groupName << ", skipping";
|
qDebug() << "An attempt to add non existing contact" << jid << "of account" << name << "to the group" << groupName << ", skipping";
|
||||||
} else {
|
} else {
|
||||||
QXmppRosterManager& rm = client.rosterManager();
|
QXmppRosterIq::Item item = rm->getRosterEntry(jid);
|
||||||
QXmppRosterIq::Item item = rm.getRosterEntry(jid);
|
|
||||||
QSet<QString> groups = item.groups();
|
QSet<QString> groups = item.groups();
|
||||||
if (groups.find(groupName) == groups.end()) { //TODO need to change it, I guess that sort of code is better in qxmpp lib
|
if (groups.find(groupName) == groups.end()) { //TODO need to change it, I guess that sort of code is better in qxmpp lib
|
||||||
groups.insert(groupName);
|
groups.insert(groupName);
|
||||||
@ -1296,8 +1286,7 @@ void Core::Account::removeContactFromGroupRequest(const QString& jid, const QStr
|
|||||||
if (itr == contacts.end()) {
|
if (itr == contacts.end()) {
|
||||||
qDebug() << "An attempt to remove non existing contact" << jid << "of account" << name << "from the group" << groupName << ", skipping";
|
qDebug() << "An attempt to remove non existing contact" << jid << "of account" << name << "from the group" << groupName << ", skipping";
|
||||||
} else {
|
} else {
|
||||||
QXmppRosterManager& rm = client.rosterManager();
|
QXmppRosterIq::Item item = rm->getRosterEntry(jid);
|
||||||
QXmppRosterIq::Item item = rm.getRosterEntry(jid);
|
|
||||||
QSet<QString> groups = item.groups();
|
QSet<QString> groups = item.groups();
|
||||||
QSet<QString>::const_iterator gItr = groups.find(groupName);
|
QSet<QString>::const_iterator gItr = groups.find(groupName);
|
||||||
if (gItr != groups.end()) {
|
if (gItr != groups.end()) {
|
||||||
@ -1320,8 +1309,7 @@ void Core::Account::renameContactRequest(const QString& jid, const QString& newN
|
|||||||
if (itr == contacts.end()) {
|
if (itr == contacts.end()) {
|
||||||
qDebug() << "An attempt to rename non existing contact" << jid << "of account" << name << ", skipping";
|
qDebug() << "An attempt to rename non existing contact" << jid << "of account" << name << ", skipping";
|
||||||
} else {
|
} else {
|
||||||
QXmppRosterManager& rm = client.rosterManager();
|
rm->renameItem(jid, newName);
|
||||||
rm.renameItem(jid, newName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1519,11 +1507,11 @@ void Core::Account::requestVCard(const QString& jid)
|
|||||||
if (pendingVCardRequests.find(jid) == pendingVCardRequests.end()) {
|
if (pendingVCardRequests.find(jid) == pendingVCardRequests.end()) {
|
||||||
if (jid == getLogin() + "@" + getServer()) {
|
if (jid == getLogin() + "@" + getServer()) {
|
||||||
if (!ownVCardRequestInProgress) {
|
if (!ownVCardRequestInProgress) {
|
||||||
client.vCardManager().requestClientVCard();
|
vm->requestClientVCard();
|
||||||
ownVCardRequestInProgress = true;
|
ownVCardRequestInProgress = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
client.vCardManager().requestVCard(jid);
|
vm->requestVCard(jid);
|
||||||
pendingVCardRequests.insert(jid);
|
pendingVCardRequests.insert(jid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1596,6 +1584,6 @@ void Core::Account::uploadVCard(const Shared::VCard& card)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
client.vCardManager().setClientVCard(iq);
|
vm->setClientVCard(iq);
|
||||||
onOwnVCardReceived(iq);
|
onOwnVCardReceived(iq);
|
||||||
}
|
}
|
||||||
|
@ -125,6 +125,8 @@ private:
|
|||||||
QXmppMamManager* am;
|
QXmppMamManager* am;
|
||||||
QXmppMucManager* mm;
|
QXmppMucManager* mm;
|
||||||
QXmppBookmarkManager* bm;
|
QXmppBookmarkManager* bm;
|
||||||
|
QXmppRosterManager* rm;
|
||||||
|
QXmppVCardManager* vm;
|
||||||
std::map<QString, Contact*> contacts;
|
std::map<QString, Contact*> contacts;
|
||||||
std::map<QString, Conference*> conferences;
|
std::map<QString, Conference*> conferences;
|
||||||
unsigned int maxReconnectTimes;
|
unsigned int maxReconnectTimes;
|
||||||
|
@ -538,6 +538,8 @@ QDateTime Shared::VCard::getReceivingTime() const
|
|||||||
return receivingTime;
|
return receivingTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::deque<QString>Shared::VCard::Contact::roleNames = {"Not specified", "Personal", "Business"};
|
||||||
|
|
||||||
QIcon Shared::availabilityIcon(Shared::Availability av, bool big)
|
QIcon Shared::availabilityIcon(Shared::Availability av, bool big)
|
||||||
{
|
{
|
||||||
const std::deque<QString>& fallback = QApplication::palette().window().color().lightnessF() > 0.5 ?
|
const std::deque<QString>& fallback = QApplication::palette().window().color().lightnessF() > 0.5 ?
|
||||||
|
1
global.h
1
global.h
@ -223,6 +223,7 @@ class VCard {
|
|||||||
home,
|
home,
|
||||||
work
|
work
|
||||||
};
|
};
|
||||||
|
static const std::deque<QString> roleNames;
|
||||||
|
|
||||||
Contact(Role p_role = none, bool p_prefered = false);
|
Contact(Role p_role = none, bool p_prefered = false);
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@ set(CMAKE_AUTOUIC ON)
|
|||||||
find_package(Qt5Widgets CONFIG REQUIRED)
|
find_package(Qt5Widgets CONFIG REQUIRED)
|
||||||
find_package(Qt5DBus CONFIG REQUIRED)
|
find_package(Qt5DBus CONFIG REQUIRED)
|
||||||
|
|
||||||
|
add_subdirectory(widgets)
|
||||||
|
|
||||||
set(squawkUI_SRC
|
set(squawkUI_SRC
|
||||||
squawk.cpp
|
squawk.cpp
|
||||||
models/accounts.cpp
|
models/accounts.cpp
|
||||||
@ -22,14 +24,6 @@ set(squawkUI_SRC
|
|||||||
models/room.cpp
|
models/room.cpp
|
||||||
models/abstractparticipant.cpp
|
models/abstractparticipant.cpp
|
||||||
models/participant.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
|
|
||||||
widgets/vcard.cpp
|
|
||||||
utils/messageline.cpp
|
utils/messageline.cpp
|
||||||
utils//message.cpp
|
utils//message.cpp
|
||||||
utils/resizer.cpp
|
utils/resizer.cpp
|
||||||
@ -37,11 +31,13 @@ set(squawkUI_SRC
|
|||||||
utils/flowlayout.cpp
|
utils/flowlayout.cpp
|
||||||
utils/badge.cpp
|
utils/badge.cpp
|
||||||
utils/progress.cpp
|
utils/progress.cpp
|
||||||
|
utils/comboboxdelegate.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# Tell CMake to create the helloworld executable
|
# Tell CMake to create the helloworld executable
|
||||||
add_library(squawkUI ${squawkUI_SRC})
|
add_library(squawkUI ${squawkUI_SRC})
|
||||||
|
|
||||||
# Use the Widgets module from Qt 5.
|
# Use the Widgets module from Qt 5.
|
||||||
|
target_link_libraries(squawkUI squawkWidgets)
|
||||||
target_link_libraries(squawkUI Qt5::Widgets)
|
target_link_libraries(squawkUI Qt5::Widgets)
|
||||||
target_link_libraries(squawkUI Qt5::DBus)
|
target_link_libraries(squawkUI Qt5::DBus)
|
||||||
|
@ -47,14 +47,14 @@ Squawk::Squawk(QWidget *parent) :
|
|||||||
}
|
}
|
||||||
m_ui->comboBox->setCurrentIndex(Shared::offline);
|
m_ui->comboBox->setCurrentIndex(Shared::offline);
|
||||||
|
|
||||||
connect(m_ui->actionAccounts, SIGNAL(triggered()), this, SLOT(onAccounts()));
|
connect(m_ui->actionAccounts, &QAction::triggered, this, &Squawk::onAccounts);
|
||||||
connect(m_ui->actionAddContact, SIGNAL(triggered()), this, SLOT(onNewContact()));
|
connect(m_ui->actionAddContact, &QAction::triggered, this, &Squawk::onNewContact);
|
||||||
connect(m_ui->actionAddConference, SIGNAL(triggered()), this, SLOT(onNewConference()));
|
connect(m_ui->actionAddConference, &QAction::triggered, this, &Squawk::onNewConference);
|
||||||
connect(m_ui->comboBox, SIGNAL(activated(int)), this, SLOT(onComboboxActivated(int)));
|
connect(m_ui->comboBox, qOverload<int>(&QComboBox::activated), this, &Squawk::onComboboxActivated);
|
||||||
connect(m_ui->roster, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(onRosterItemDoubleClicked(const QModelIndex&)));
|
connect(m_ui->roster, &QTreeView::doubleClicked, this, &Squawk::onRosterItemDoubleClicked);
|
||||||
connect(m_ui->roster, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(onRosterContextMenu(const QPoint&)));
|
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);
|
//m_ui->mainToolBar->addWidget(m_ui->comboBox);
|
||||||
|
|
||||||
setWindowTitle(tr("Contact list"));
|
setWindowTitle(tr("Contact list"));
|
||||||
|
@ -33,10 +33,10 @@
|
|||||||
#include "widgets/room.h"
|
#include "widgets/room.h"
|
||||||
#include "widgets/newcontact.h"
|
#include "widgets/newcontact.h"
|
||||||
#include "widgets/joinconference.h"
|
#include "widgets/joinconference.h"
|
||||||
#include "widgets/vcard.h"
|
|
||||||
#include "models/roster.h"
|
#include "models/roster.h"
|
||||||
|
#include "widgets/vcard/vcard.h"
|
||||||
|
|
||||||
#include "../global.h"
|
#include "global.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class Squawk;
|
class Squawk;
|
||||||
|
64
ui/utils/comboboxdelegate.cpp
Normal file
64
ui/utils/comboboxdelegate.cpp
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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "comboboxdelegate.h"
|
||||||
|
|
||||||
|
ComboboxDelegate::ComboboxDelegate(QObject *parent):
|
||||||
|
QStyledItemDelegate(parent),
|
||||||
|
entries()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ComboboxDelegate::~ComboboxDelegate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
47
ui/utils/comboboxdelegate.h
Normal file
47
ui/utils/comboboxdelegate.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* 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 <deque>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo write docs
|
||||||
|
*/
|
||||||
|
class ComboboxDelegate : public QStyledItemDelegate
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // COMBOBOXDELEGATE_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)
|
21
ui/widgets/vcard/CMakeLists.txt
Normal file
21
ui/widgets/vcard/CMakeLists.txt
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
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
|
||||||
|
)
|
||||||
|
|
||||||
|
# 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)
|
145
ui/widgets/vcard/emailsmodel.cpp
Normal file
145
ui/widgets/vcard/emailsmodel.cpp
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
/*
|
||||||
|
* 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:
|
||||||
|
return deque[index.row()].address;
|
||||||
|
default:
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
switch (role) {
|
||||||
|
case Qt::DisplayRole:
|
||||||
|
return tr(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()));
|
||||||
|
}
|
57
ui/widgets/vcard/emailsmodel.h
Normal file
57
ui/widgets/vcard/emailsmodel.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 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;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
QModelIndex addNewEmptyLine();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool edit;
|
||||||
|
std::deque<Shared::VCard::Email> deque;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool dropPrefered();
|
||||||
|
};
|
||||||
|
|
||||||
|
}}
|
||||||
|
|
||||||
|
#endif // UI_VCARD_EMAILSMODEL_H
|
@ -33,7 +33,10 @@ VCard::VCard(const QString& jid, bool edit, QWidget* parent):
|
|||||||
currentAvatarPath(""),
|
currentAvatarPath(""),
|
||||||
progress(new Progress(100)),
|
progress(new Progress(100)),
|
||||||
progressLabel(new QLabel()),
|
progressLabel(new QLabel()),
|
||||||
overlay(new QWidget())
|
overlay(new QWidget()),
|
||||||
|
contextMenu(new QMenu()),
|
||||||
|
emails(edit),
|
||||||
|
roleDelegate(new ComboboxDelegate())
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
m_ui->jabberID->setText(jid);
|
m_ui->jabberID->setText(jid);
|
||||||
@ -48,6 +51,18 @@ VCard::VCard(const QString& jid, bool edit, QWidget* parent):
|
|||||||
setAvatar->setEnabled(true);
|
setAvatar->setEnabled(true);
|
||||||
clearAvatar->setEnabled(false);
|
clearAvatar->setEnabled(false);
|
||||||
|
|
||||||
|
roleDelegate->addEntry(tr(Shared::VCard::Email::roleNames[0].toStdString().c_str()));
|
||||||
|
roleDelegate->addEntry(tr(Shared::VCard::Email::roleNames[1].toStdString().c_str()));
|
||||||
|
roleDelegate->addEntry(tr(Shared::VCard::Email::roleNames[2].toStdString().c_str()));
|
||||||
|
|
||||||
|
m_ui->emailsView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
m_ui->emailsView->setModel(&emails);
|
||||||
|
m_ui->emailsView->setItemDelegateForColumn(1, roleDelegate);
|
||||||
|
m_ui->emailsView->horizontalHeader()->setStretchLastSection(false);
|
||||||
|
m_ui->emailsView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||||
|
|
||||||
|
connect(m_ui->emailsView, &QWidget::customContextMenuRequested, this, &VCard::onContextMenu);
|
||||||
|
|
||||||
if (edit) {
|
if (edit) {
|
||||||
avatarMenu = new QMenu();
|
avatarMenu = new QMenu();
|
||||||
m_ui->avatarButton->setMenu(avatarMenu);
|
m_ui->avatarButton->setMenu(avatarMenu);
|
||||||
@ -69,10 +84,6 @@ VCard::VCard(const QString& jid, bool edit, QWidget* parent):
|
|||||||
m_ui->description->setReadOnly(true);
|
m_ui->description->setReadOnly(true);
|
||||||
m_ui->url->setReadOnly(true);
|
m_ui->url->setReadOnly(true);
|
||||||
m_ui->title->setText(tr("Contact %1 card").arg(jid));
|
m_ui->title->setText(tr("Contact %1 card").arg(jid));
|
||||||
|
|
||||||
m_ui->addAddressButton->hide();
|
|
||||||
m_ui->addPhoneButton->hide();
|
|
||||||
m_ui->addEmailButton->hide();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &VCard::onButtonBoxAccepted);
|
connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &VCard::onButtonBoxAccepted);
|
||||||
@ -106,6 +117,9 @@ VCard::~VCard()
|
|||||||
if (editable) {
|
if (editable) {
|
||||||
avatarMenu->deleteLater();
|
avatarMenu->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
roleDelegate->deleteLater();
|
||||||
|
contextMenu->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VCard::setVCard(const QString& jid, const Shared::VCard& card)
|
void VCard::setVCard(const QString& jid, const Shared::VCard& card)
|
||||||
@ -253,3 +267,46 @@ void VCard::hideProgress()
|
|||||||
overlay->hide();
|
overlay->hide();
|
||||||
progress->stop();
|
progress->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VCard::onContextMenu(const QPoint& point)
|
||||||
|
{
|
||||||
|
contextMenu->clear();
|
||||||
|
bool hasMenu = false;
|
||||||
|
QAbstractItemView* snd = static_cast<QAbstractItemView*>(sender());
|
||||||
|
if (snd == m_ui->emailsView) {
|
||||||
|
if (editable) {
|
||||||
|
hasMenu = true;
|
||||||
|
QAction* add = contextMenu->addAction(Shared::icon("list-add"), tr("Add email address"));
|
||||||
|
connect(add, &QAction::triggered, this, &VCard::onAddEmail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void VCard::onRemoveAddress()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void VCard::onRemoveEmail()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void VCard::onRemovePhone()
|
||||||
|
{
|
||||||
|
}
|
@ -30,11 +30,14 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QGraphicsOpacityEffect>
|
#include <QGraphicsOpacityEffect>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include "../../global.h"
|
#include "global.h"
|
||||||
#include "../utils/progress.h"
|
#include "emailsmodel.h"
|
||||||
|
#include "ui/utils/progress.h"
|
||||||
|
#include "ui/utils/comboboxdelegate.h"
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
@ -65,6 +68,13 @@ private slots:
|
|||||||
void onClearAvatar();
|
void onClearAvatar();
|
||||||
void onSetAvatar();
|
void onSetAvatar();
|
||||||
void onAvatarSelected();
|
void onAvatarSelected();
|
||||||
|
void onAddAddress();
|
||||||
|
void onRemoveAddress();
|
||||||
|
void onAddEmail();
|
||||||
|
void onRemoveEmail();
|
||||||
|
void onAddPhone();
|
||||||
|
void onRemovePhone();
|
||||||
|
void onContextMenu(const QPoint& point);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::VCard> m_ui;
|
QScopedPointer<Ui::VCard> m_ui;
|
||||||
@ -76,6 +86,9 @@ private:
|
|||||||
Progress* progress;
|
Progress* progress;
|
||||||
QLabel* progressLabel;
|
QLabel* progressLabel;
|
||||||
QWidget* overlay;
|
QWidget* overlay;
|
||||||
|
QMenu* contextMenu;
|
||||||
|
UI::VCard::EMailsModel emails;
|
||||||
|
ComboboxDelegate* roleDelegate;
|
||||||
|
|
||||||
static const std::set<QString> supportedTypes;
|
static const std::set<QString> supportedTypes;
|
||||||
|
|
@ -9,8 +9,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>526</width>
|
<width>578</width>
|
||||||
<height>662</height>
|
<height>671</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_4">
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
@ -84,7 +84,7 @@
|
|||||||
<enum>QTabWidget::Rounded</enum>
|
<enum>QTabWidget::Rounded</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="elideMode">
|
<property name="elideMode">
|
||||||
<enum>Qt::ElideNone</enum>
|
<enum>Qt::ElideNone</enum>
|
||||||
@ -560,42 +560,72 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>514</width>
|
<width>566</width>
|
||||||
<height>488</height>
|
<height>497</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_3" columnstretch="1,2,2,1">
|
<layout class="QGridLayout" name="gridLayout_3" columnstretch="1,3,1,0">
|
||||||
<item row="2" column="2">
|
<item row="7" column="1">
|
||||||
<widget class="QPushButton" name="addEmailButton">
|
<widget class="Line" name="phonesLine">
|
||||||
<property name="sizePolicy">
|
<property name="orientation">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<enum>Qt::Horizontal</enum>
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset theme="list-add"/>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="1" colspan="2">
|
<item row="3" column="1">
|
||||||
<layout class="QVBoxLayout" name="phonesLayout">
|
<widget class="QTableView" name="emailsView">
|
||||||
<item>
|
<property name="selectionMode">
|
||||||
<widget class="QLabel" name="emptyPhonesPlaceholder">
|
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||||
<property name="text">
|
</property>
|
||||||
<string><html><head/><body><p><span style=" font-style:italic;">User has no contact e-mail addresses</span></p></body></html></string>
|
<property name="selectionBehavior">
|
||||||
</property>
|
<enum>QAbstractItemView::SelectRows</enum>
|
||||||
<property name="alignment">
|
</property>
|
||||||
<set>Qt::AlignCenter</set>
|
<property name="showGrid">
|
||||||
</property>
|
<bool>false</bool>
|
||||||
</widget>
|
</property>
|
||||||
</item>
|
<attribute name="horizontalHeaderVisible">
|
||||||
</layout>
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="verticalHeaderVisible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="11" column="1" colspan="2">
|
<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">
|
<spacer name="contactBottomSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
@ -608,21 +638,43 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="9" column="1" colspan="2">
|
<item row="8" column="1">
|
||||||
<layout class="QVBoxLayout" name="addressesLayout">
|
<widget class="QLabel" name="addressesHeading">
|
||||||
<item>
|
<property name="text">
|
||||||
<widget class="QLabel" name="emptyAddressesPlaceholder">
|
<string><html><head/><body><p><span style=" font-size:16pt; font-weight:600;">Addresses</span></p></body></html></string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string><html><head/><body><p><span style=" font-style:italic;">User has no contact e-mail addresses</span></p></body></html></string>
|
<property name="alignment">
|
||||||
</property>
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||||
<property name="alignment">
|
</property>
|
||||||
<set>Qt::AlignCenter</set>
|
</widget>
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1" colspan="2">
|
<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="text">
|
||||||
|
<string><html><head/><body><p><span style=" font-size:16pt; font-weight:600;">E-Mail addresses</span></p></body></html></string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
<layout class="QFormLayout" name="contactForm">
|
<layout class="QFormLayout" name="contactForm">
|
||||||
<property name="formAlignment">
|
<property name="formAlignment">
|
||||||
<set>Qt::AlignHCenter|Qt::AlignTop</set>
|
<set>Qt::AlignHCenter|Qt::AlignTop</set>
|
||||||
@ -681,124 +733,7 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="1">
|
<item row="0" column="2" rowspan="12">
|
||||||
<widget class="QLabel" name="addressesHeading">
|
|
||||||
<property name="text">
|
|
||||||
<string><html><head/><body><p><span style=" font-size:16pt; font-weight:600;">Addresses</span></p></body></html></string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1" colspan="2">
|
|
||||||
<widget class="Line" name="contactFormLine">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="8" column="2">
|
|
||||||
<widget class="QPushButton" name="addAddressButton">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset theme="list-add"/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="10" column="1" colspan="2">
|
|
||||||
<widget class="Line" name="addressesLine">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="5" column="2">
|
|
||||||
<widget class="QPushButton" name="addPhoneButton">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset theme="list-add"/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="QLabel" name="emailsHeading">
|
|
||||||
<property name="text">
|
|
||||||
<string><html><head/><body><p><span style=" font-size:16pt; font-weight:600;">E-Mail addresses</span></p></body></html></string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="5" column="1">
|
|
||||||
<widget class="QLabel" name="phenesHeading">
|
|
||||||
<property name="text">
|
|
||||||
<string><html><head/><body><p><span style=" font-size:16pt; font-weight:600;">Phone numbers</span></p></body></html></string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="1" colspan="2">
|
|
||||||
<widget class="Line" name="emailsLine">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="1" colspan="2">
|
|
||||||
<layout class="QVBoxLayout" name="emailsLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="emptyEmailsPlaceholder">
|
|
||||||
<property name="text">
|
|
||||||
<string><html><head/><body><p><span style=" font-style:italic;">User has no contact e-mail addresses</span></p></body></html></string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="7" column="1" colspan="2">
|
|
||||||
<widget class="Line" name="phonesLine">
|
|
||||||
<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="0" column="3" rowspan="12">
|
|
||||||
<spacer name="contactRightSpacer">
|
<spacer name="contactRightSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
@ -811,6 +746,32 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
|
<widget class="QLabel" name="phenesHeading">
|
||||||
|
<property name="text">
|
||||||
|
<string><html><head/><body><p><span style=" font-size:16pt; font-weight:600;">Phone numbers</span></p></body></html></string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</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>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
@ -905,7 +866,6 @@
|
|||||||
<tabstop>jabberID</tabstop>
|
<tabstop>jabberID</tabstop>
|
||||||
<tabstop>url</tabstop>
|
<tabstop>url</tabstop>
|
||||||
<tabstop>description</tabstop>
|
<tabstop>description</tabstop>
|
||||||
<tabstop>scrollArea</tabstop>
|
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../../resources/resources.qrc"/>
|
<include location="../../resources/resources.qrc"/>
|
Loading…
Reference in New Issue
Block a user