forked from blue/squawk
first attempt to remove accounts
This commit is contained in:
parent
8432a574b9
commit
234697050b
@ -738,4 +738,3 @@ void Core::Account::onClientError(QXmppClient::Error err)
|
|||||||
qDebug() << errorType << errorText;
|
qDebug() << errorType << errorText;
|
||||||
emit error(errorText);
|
emit error(errorText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include "squawk.h"
|
#include "squawk.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
|
||||||
Core::Squawk::Squawk(QObject* parent):
|
Core::Squawk::Squawk(QObject* parent):
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
@ -298,3 +300,31 @@ void Core::Squawk::onAccountError(const QString& text)
|
|||||||
Account* acc = static_cast<Account*>(sender());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
emit changeAccount(acc->getName(), {{"error", text}});
|
emit changeAccount(acc->getName(), {{"error", text}});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Core::Squawk::removeAccountRequest(const QString& name)
|
||||||
|
{
|
||||||
|
AccountsMap::const_iterator itr = amap.find(name);
|
||||||
|
if (itr == amap.end()) {
|
||||||
|
qDebug() << "An attempt to remove non existing account " << name << " from core, skipping";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Account* acc = itr->second;
|
||||||
|
|
||||||
|
for (Accounts::const_iterator aItr = accounts.begin(); aItr != accounts.end(); ++aItr) {
|
||||||
|
if (*aItr == acc) {
|
||||||
|
accounts.erase(aItr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
amap.erase(itr);
|
||||||
|
delete acc;
|
||||||
|
|
||||||
|
QString path(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
|
||||||
|
path += "/" + name;
|
||||||
|
QDir dir(path);
|
||||||
|
dir.removeRecursively();
|
||||||
|
|
||||||
|
emit removeAccount(name);
|
||||||
|
}
|
||||||
|
@ -25,6 +25,7 @@ signals:
|
|||||||
void quit();
|
void quit();
|
||||||
void newAccount(const QMap<QString, QVariant>&);
|
void newAccount(const QMap<QString, QVariant>&);
|
||||||
void changeAccount(const QString& account, const QMap<QString, QVariant>& data);
|
void changeAccount(const QString& account, const QMap<QString, QVariant>& data);
|
||||||
|
void removeAccount(const QString& account);
|
||||||
void addGroup(const QString& account, const QString& name);
|
void addGroup(const QString& account, const QString& name);
|
||||||
void removeGroup(const QString& account, const QString& name);
|
void removeGroup(const QString& account, const QString& name);
|
||||||
void addContact(const QString& account, const QString& jid, const QString& group, const QMap<QString, QVariant>& data);
|
void addContact(const QString& account, const QString& jid, const QString& group, const QMap<QString, QVariant>& data);
|
||||||
@ -42,6 +43,7 @@ public slots:
|
|||||||
void stop();
|
void stop();
|
||||||
void newAccountRequest(const QMap<QString, QVariant>& map);
|
void newAccountRequest(const QMap<QString, QVariant>& map);
|
||||||
void modifyAccountRequest(const QString& name, const QMap<QString, QVariant>& map);
|
void modifyAccountRequest(const QString& name, const QMap<QString, QVariant>& map);
|
||||||
|
void removeAccountRequest(const QString& name);
|
||||||
void connectAccount(const QString& account);
|
void connectAccount(const QString& account);
|
||||||
void disconnectAccount(const QString& account);
|
void disconnectAccount(const QString& account);
|
||||||
void changeState(int state);
|
void changeState(int state);
|
||||||
|
2
main.cpp
2
main.cpp
@ -34,6 +34,7 @@ int main(int argc, char *argv[])
|
|||||||
QObject::connect(&w, SIGNAL(newAccountRequest(const QMap<QString, QVariant>&)), squawk, SLOT(newAccountRequest(const QMap<QString, QVariant>&)));
|
QObject::connect(&w, SIGNAL(newAccountRequest(const QMap<QString, QVariant>&)), squawk, SLOT(newAccountRequest(const QMap<QString, QVariant>&)));
|
||||||
QObject::connect(&w, SIGNAL(modifyAccountRequest(const QString&, const QMap<QString, QVariant>&)),
|
QObject::connect(&w, SIGNAL(modifyAccountRequest(const QString&, const QMap<QString, QVariant>&)),
|
||||||
squawk, SLOT(modifyAccountRequest(const QString&, const QMap<QString, QVariant>&)));
|
squawk, SLOT(modifyAccountRequest(const QString&, const QMap<QString, QVariant>&)));
|
||||||
|
QObject::connect(&w, SIGNAL(removeAccountRequest(const QString&)), squawk, SLOT(removeAccountRequest(const QString&)));
|
||||||
QObject::connect(&w, SIGNAL(connectAccount(const QString&)), squawk, SLOT(connectAccount(const QString&)));
|
QObject::connect(&w, SIGNAL(connectAccount(const QString&)), squawk, SLOT(connectAccount(const QString&)));
|
||||||
QObject::connect(&w, SIGNAL(disconnectAccount(const QString&)), squawk, SLOT(disconnectAccount(const QString&)));
|
QObject::connect(&w, SIGNAL(disconnectAccount(const QString&)), squawk, SLOT(disconnectAccount(const QString&)));
|
||||||
QObject::connect(&w, SIGNAL(changeState(int)), squawk, SLOT(changeState(int)));
|
QObject::connect(&w, SIGNAL(changeState(int)), squawk, SLOT(changeState(int)));
|
||||||
@ -46,6 +47,7 @@ int main(int argc, char *argv[])
|
|||||||
&w, SLOT(addContact(const QString&, const QString&, const QString&, const QMap<QString, QVariant>&)));
|
&w, SLOT(addContact(const QString&, const QString&, const QString&, const QMap<QString, QVariant>&)));
|
||||||
QObject::connect(squawk, SIGNAL(changeAccount(const QString&, const QMap<QString, QVariant>&)),
|
QObject::connect(squawk, SIGNAL(changeAccount(const QString&, const QMap<QString, QVariant>&)),
|
||||||
&w, SLOT(changeAccount(const QString&, const QMap<QString, QVariant>&)));
|
&w, SLOT(changeAccount(const QString&, const QMap<QString, QVariant>&)));
|
||||||
|
QObject::connect(squawk, SIGNAL(removeAccount(const QString&)), &w, SLOT(removeAccount(const QString&)));
|
||||||
QObject::connect(squawk, SIGNAL(addGroup(const QString&, const QString&)), &w, SLOT(addGroup(const QString&, const QString&)));
|
QObject::connect(squawk, SIGNAL(addGroup(const QString&, const QString&)), &w, SLOT(addGroup(const QString&, const QString&)));
|
||||||
QObject::connect(squawk, SIGNAL(removeGroup(const QString&, const QString&)), &w, SLOT(removeGroup(const QString&, const QString&)));
|
QObject::connect(squawk, SIGNAL(removeGroup(const QString&, const QString&)), &w, SLOT(removeGroup(const QString&, const QString&)));
|
||||||
QObject::connect(squawk, SIGNAL(removeContact(const QString&, const QString&)), &w, SLOT(removeContact(const QString&, const QString&)));
|
QObject::connect(squawk, SIGNAL(removeContact(const QString&, const QString&)), &w, SLOT(removeContact(const QString&, const QString&)));
|
||||||
|
@ -6,15 +6,19 @@
|
|||||||
Accounts::Accounts(Models::Accounts* p_model, QWidget *parent) :
|
Accounts::Accounts(Models::Accounts* p_model, QWidget *parent) :
|
||||||
m_ui(new Ui::Accounts),
|
m_ui(new Ui::Accounts),
|
||||||
model(p_model),
|
model(p_model),
|
||||||
editing(false)
|
editing(false),
|
||||||
|
toDisconnect(false)
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
|
|
||||||
connect(m_ui->addButton, SIGNAL(clicked(bool)), this, SLOT(onAddButton(bool)));
|
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->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)));
|
||||||
m_ui->tableView->setModel(model);
|
m_ui->tableView->setModel(model);
|
||||||
connect(m_ui->tableView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
|
connect(m_ui->tableView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
|
||||||
this, SLOT(onSelectionChanged(const QItemSelection&, const QItemSelection&)));
|
this, SLOT(onSelectionChanged(const QItemSelection&, const QItemSelection&)));
|
||||||
|
connect(p_model, SIGNAL(changed()), this, SLOT(updateConnectButton()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Accounts::~Accounts() = default;
|
Accounts::~Accounts() = default;
|
||||||
@ -69,12 +73,66 @@ void Accounts::onEditButton(bool clicked)
|
|||||||
|
|
||||||
void Accounts::onSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected)
|
void Accounts::onSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected)
|
||||||
{
|
{
|
||||||
const QItemSelection& selection = m_ui->tableView->selectionModel()->selection();
|
int selectionSize = m_ui->tableView->selectionModel()->selection().size();
|
||||||
if (selection.size() == 0) {
|
if (selectionSize == 0) {
|
||||||
m_ui->editButton->setEnabled(false);
|
m_ui->editButton->setEnabled(false);
|
||||||
} else if (selection.size() == 1) {
|
m_ui->deleteButton->setEnabled(false);
|
||||||
|
} else if (selectionSize == 1) {
|
||||||
m_ui->editButton->setEnabled(true);
|
m_ui->editButton->setEnabled(true);
|
||||||
|
m_ui->deleteButton->setEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
m_ui->editButton->setEnabled(false);
|
m_ui->editButton->setEnabled(false);
|
||||||
|
m_ui->deleteButton->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateConnectButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Accounts::updateConnectButton()
|
||||||
|
{
|
||||||
|
QItemSelectionModel* sm = m_ui->tableView->selectionModel();
|
||||||
|
if (sm->hasSelection()) {
|
||||||
|
m_ui->connectButton->setEnabled(true);
|
||||||
|
int selectionSize = sm->selection().size();
|
||||||
|
bool allConnected = true;
|
||||||
|
for (int i = 0; i < selectionSize && allConnected; ++i) {
|
||||||
|
const Models::Account* mAcc = model->getAccount(sm->selectedRows().at(i).row());
|
||||||
|
allConnected = mAcc->getState() == Shared::connected;
|
||||||
|
}
|
||||||
|
if (allConnected) {
|
||||||
|
toDisconnect = true;
|
||||||
|
m_ui->connectButton->setText("Disconnect");
|
||||||
|
} else {
|
||||||
|
toDisconnect = false;
|
||||||
|
m_ui->connectButton->setText("Connect");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
m_ui->connectButton->setText("Connect");
|
||||||
|
toDisconnect = false;
|
||||||
|
m_ui->connectButton->setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Accounts::onConnectButton(bool clicked)
|
||||||
|
{
|
||||||
|
QItemSelectionModel* sm = m_ui->tableView->selectionModel();
|
||||||
|
int selectionSize = sm->selection().size();
|
||||||
|
for (int i = 0; i < selectionSize; ++i) {
|
||||||
|
const Models::Account* mAcc = model->getAccount(sm->selectedRows().at(i).row());
|
||||||
|
if (toDisconnect) {
|
||||||
|
emit disconnectAccount(mAcc->getName());
|
||||||
|
} else {
|
||||||
|
emit connectAccount(mAcc->getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Accounts::onDeleteButton(bool clicked)
|
||||||
|
{
|
||||||
|
QItemSelectionModel* sm = m_ui->tableView->selectionModel();
|
||||||
|
int selectionSize = sm->selection().size();
|
||||||
|
for (int i = 0; i < selectionSize; ++i) {
|
||||||
|
const Models::Account* mAcc = model->getAccount(sm->selectedRows().at(i).row());
|
||||||
|
emit removeAccount(mAcc->getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,18 +23,25 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void newAccount(const QMap<QString, QVariant>&);
|
void newAccount(const QMap<QString, QVariant>&);
|
||||||
void changeAccount(const QString&, const QMap<QString, QVariant>&);
|
void changeAccount(const QString&, const QMap<QString, QVariant>&);
|
||||||
|
void connectAccount(const QString&);
|
||||||
|
void disconnectAccount(const QString&);
|
||||||
|
void removeAccount(const QString&);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onAddButton(bool clicked = 0);
|
void onAddButton(bool clicked = 0);
|
||||||
void onEditButton(bool clicked = 0);
|
void onEditButton(bool clicked = 0);
|
||||||
|
void onConnectButton(bool clicked = 0);
|
||||||
|
void onDeleteButton(bool clicked = 0);
|
||||||
void onAccountAccepted();
|
void onAccountAccepted();
|
||||||
void onAccountRejected();
|
void onAccountRejected();
|
||||||
void onSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
|
void onSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
|
||||||
|
void updateConnectButton();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::Accounts> m_ui;
|
QScopedPointer<Ui::Accounts> m_ui;
|
||||||
Models::Accounts* model;
|
Models::Accounts* model;
|
||||||
bool editing;
|
bool editing;
|
||||||
|
bool toDisconnect;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ACCOUNTS_H
|
#endif // ACCOUNTS_H
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>539</width>
|
<width>598</width>
|
||||||
<height>249</height>
|
<height>249</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -121,7 +121,7 @@
|
|||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="1">
|
<item row="6" column="1">
|
||||||
<widget class="QPushButton" name="connect">
|
<widget class="QPushButton" name="connectButton">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
|
@ -78,9 +78,19 @@ void Models::Accounts::onAccountChanged(Item* item, int row, int col)
|
|||||||
if (col < columnCount(QModelIndex())) {
|
if (col < columnCount(QModelIndex())) {
|
||||||
emit dataChanged(createIndex(row, col, this), createIndex(row, col, this));
|
emit dataChanged(createIndex(row, col, this), createIndex(row, col, this));
|
||||||
}
|
}
|
||||||
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
Models::Account * Models::Accounts::getAccount(int index)
|
Models::Account * Models::Accounts::getAccount(int index)
|
||||||
{
|
{
|
||||||
return accs[index];
|
return accs[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)));
|
||||||
|
accs.erase(accs.begin() + index);
|
||||||
|
endRemoveRows();
|
||||||
|
}
|
||||||
|
@ -16,6 +16,7 @@ public:
|
|||||||
~Accounts();
|
~Accounts();
|
||||||
|
|
||||||
void addAccount(Account* account);
|
void addAccount(Account* account);
|
||||||
|
void removeAccount(int index);
|
||||||
|
|
||||||
QVariant data ( const QModelIndex& index, int role ) const override;
|
QVariant data ( const QModelIndex& index, int role ) const override;
|
||||||
int columnCount ( const QModelIndex& parent ) const override;
|
int columnCount ( const QModelIndex& parent ) const override;
|
||||||
@ -24,6 +25,9 @@ public:
|
|||||||
|
|
||||||
Account* getAccount(int index);
|
Account* getAccount(int index);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void changed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::deque<Account*> accs;
|
std::deque<Account*> accs;
|
||||||
static std::deque<QString> columns;
|
static std::deque<QString> columns;
|
||||||
|
@ -121,13 +121,13 @@ void Models::Item::_removeChild(int index)
|
|||||||
{
|
{
|
||||||
Item* child = childItems[index];
|
Item* child = childItems[index];
|
||||||
|
|
||||||
QObject::connect(child, SIGNAL(childChanged(Models::Item*, int, int)), this, SIGNAL(childChanged(Models::Item*, int, int)));
|
QObject::disconnect(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::disconnect(child, SIGNAL(childIsAboutToBeInserted(Item*, int, int)), this, SIGNAL(childIsAboutToBeInserted(Item*, int, int)));
|
||||||
QObject::connect(child, SIGNAL(childInserted()), this, SIGNAL(childInserted()));
|
QObject::disconnect(child, SIGNAL(childInserted()), this, SIGNAL(childInserted()));
|
||||||
QObject::connect(child, SIGNAL(childIsAboutToBeRemoved(Item*, int, int)), this, SIGNAL(childIsAboutToBeRemoved(Item*, int, int)));
|
QObject::disconnect(child, SIGNAL(childIsAboutToBeRemoved(Item*, int, int)), this, SIGNAL(childIsAboutToBeRemoved(Item*, int, int)));
|
||||||
QObject::connect(child, SIGNAL(childRemoved()), this, SIGNAL(childRemoved()));
|
QObject::disconnect(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::disconnect(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::disconnect(child, SIGNAL(childMoved()), this, SIGNAL(childMoved()));
|
||||||
|
|
||||||
childItems.erase(childItems.begin() + index);
|
childItems.erase(childItems.begin() + index);
|
||||||
child->parent = 0;
|
child->parent = 0;
|
||||||
|
@ -512,3 +512,41 @@ void Models::Roster::dropMessages(const QString& account, const QString& jid)
|
|||||||
cBeg->second->dropMessages();
|
cBeg->second->dropMessages();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Models::Roster::removeAccount(const QString& account)
|
||||||
|
{
|
||||||
|
std::map<QString, Account*>::const_iterator itr = accounts.find(account);
|
||||||
|
if (itr == accounts.end()) {
|
||||||
|
qDebug() << "An attempt to remove non existing account " << account << ", skipping";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Account* acc = itr->second;
|
||||||
|
int index = acc->row();
|
||||||
|
root->removeChild(index);
|
||||||
|
accountsModel->removeAccount(index);
|
||||||
|
|
||||||
|
std::multimap<ElId, Contact*>::const_iterator cItr = contacts.begin();
|
||||||
|
while (cItr != contacts.end()) {
|
||||||
|
if (cItr->first.account == account) {
|
||||||
|
std::multimap<ElId, Contact*>::const_iterator lItr = cItr;
|
||||||
|
++cItr;
|
||||||
|
contacts.erase(lItr);
|
||||||
|
} else {
|
||||||
|
++cItr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<ElId, Item*>::const_iterator gItr = groups.begin();
|
||||||
|
while (gItr != groups.end()) {
|
||||||
|
if (gItr->first.account == account) {
|
||||||
|
std::map<ElId, Item*>::const_iterator lItr = gItr;
|
||||||
|
++gItr;
|
||||||
|
groups.erase(lItr);
|
||||||
|
} else {
|
||||||
|
++gItr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delete acc;
|
||||||
|
}
|
||||||
|
@ -24,6 +24,7 @@ public:
|
|||||||
|
|
||||||
void addAccount(const QMap<QString, QVariant> &data);
|
void addAccount(const QMap<QString, QVariant> &data);
|
||||||
void updateAccount(const QString& account, const QString& field, const QVariant& value);
|
void updateAccount(const QString& account, const QString& field, const QVariant& value);
|
||||||
|
void removeAccount(const QString& account);
|
||||||
void addGroup(const QString& account, const QString& name);
|
void addGroup(const QString& account, const QString& name);
|
||||||
void removeGroup(const QString& account, const QString& name);
|
void removeGroup(const QString& account, const QString& name);
|
||||||
void addContact(const QString& account, const QString& jid, const QString& group, const QMap<QString, QVariant>& data);
|
void addContact(const QString& account, const QString& jid, const QString& group, const QMap<QString, QVariant>& data);
|
||||||
|
@ -36,6 +36,9 @@ void Squawk::onAccounts()
|
|||||||
connect(accounts, SIGNAL(destroyed(QObject*)), this, SLOT(onAccountsClosed(QObject*)));
|
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(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(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&)));
|
||||||
|
|
||||||
accounts->show();
|
accounts->show();
|
||||||
} else {
|
} else {
|
||||||
@ -249,3 +252,23 @@ void Squawk::responseArchive(const QString& account, const QString& jid, const s
|
|||||||
itr->second->responseArchive(list);
|
itr->second->responseArchive(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Squawk::removeAccount(const QString& account)
|
||||||
|
{
|
||||||
|
Conversations::const_iterator itr = conversations.begin();
|
||||||
|
while (itr != conversations.end()) {
|
||||||
|
if (itr->first.account == 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&)));
|
||||||
|
conv->close();
|
||||||
|
conversations.erase(lItr);
|
||||||
|
} else {
|
||||||
|
++itr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rosterModel.removeAccount(account);
|
||||||
|
}
|
||||||
|
@ -29,6 +29,7 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void newAccountRequest(const QMap<QString, QVariant>&);
|
void newAccountRequest(const QMap<QString, QVariant>&);
|
||||||
void modifyAccountRequest(const QString&, const QMap<QString, QVariant>&);
|
void modifyAccountRequest(const QString&, const QMap<QString, QVariant>&);
|
||||||
|
void removeAccountRequest(const QString&);
|
||||||
void connectAccount(const QString&);
|
void connectAccount(const QString&);
|
||||||
void disconnectAccount(const QString&);
|
void disconnectAccount(const QString&);
|
||||||
void changeState(int state);
|
void changeState(int state);
|
||||||
@ -38,6 +39,7 @@ signals:
|
|||||||
public slots:
|
public slots:
|
||||||
void newAccount(const QMap<QString, QVariant>& account);
|
void newAccount(const QMap<QString, QVariant>& account);
|
||||||
void changeAccount(const QString& account, const QMap<QString, QVariant>& data);
|
void changeAccount(const QString& account, const QMap<QString, QVariant>& data);
|
||||||
|
void removeAccount(const QString& account);
|
||||||
void addGroup(const QString& account, const QString& name);
|
void addGroup(const QString& account, const QString& name);
|
||||||
void removeGroup(const QString& account, const QString& name);
|
void removeGroup(const QString& account, const QString& name);
|
||||||
void addContact(const QString& account, const QString& jid, const QString& group, const QMap<QString, QVariant>& data);
|
void addContact(const QString& account, const QString& jid, const QString& group, const QMap<QString, QVariant>& data);
|
||||||
|
Loading…
Reference in New Issue
Block a user