forked from blue/squawk
Roster model, account model, connection commena, connection report
This commit is contained in:
parent
6823b41f24
commit
3d947a0748
12 changed files with 551 additions and 15 deletions
|
@ -5,11 +5,14 @@ Squawk::Squawk(QWidget *parent) :
|
|||
QMainWindow(parent),
|
||||
m_ui(new Ui::Squawk),
|
||||
accounts(0),
|
||||
accountsCache()
|
||||
accountsCache(),
|
||||
rosterModel()
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->roster->setModel(&rosterModel);
|
||||
|
||||
connect(m_ui->actionAccounts, SIGNAL(triggered()), this, SLOT(onAccounts()));
|
||||
connect(m_ui->comboBox, SIGNAL(activated(int)), this, SLOT(onComboboxActivated(int)));
|
||||
//m_ui->mainToolBar->addWidget(m_ui->comboBox);
|
||||
}
|
||||
|
||||
Squawk::~Squawk() {
|
||||
|
@ -57,7 +60,42 @@ void Squawk::onAccountsClosed(QObject* parent)
|
|||
void Squawk::newAccount(const QMap<QString, QVariant>& account)
|
||||
{
|
||||
accountsCache.push_back(account);
|
||||
rosterModel.addAccount(account);
|
||||
if (accounts != 0) {
|
||||
accounts->addAccount(account);
|
||||
}
|
||||
}
|
||||
|
||||
void Squawk::onComboboxActivated(int index)
|
||||
{
|
||||
if (index == 0) {
|
||||
if (accountsCache.size() > 0) {
|
||||
AC::const_iterator itr = accountsCache.begin();
|
||||
AC::const_iterator end = accountsCache.end();
|
||||
|
||||
for (; itr != end; ++itr) {
|
||||
const QMap<QString, QVariant>& acc = *itr;
|
||||
if (acc.value("state").toInt() == Shared::disconnected) {
|
||||
emit connectAccount(acc.value("name").toString());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
m_ui->comboBox->setCurrentIndex(1);
|
||||
}
|
||||
} else if (index == 1) {
|
||||
AC::const_iterator itr = accountsCache.begin();
|
||||
AC::const_iterator end = accountsCache.end();
|
||||
|
||||
for (; itr != end; ++itr) {
|
||||
const QMap<QString, QVariant>& acc = *itr;
|
||||
if (acc.value("state").toInt() != Shared::disconnected) {
|
||||
emit disconnectAccount(acc.value("name").toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Squawk::accountConnectionStateChanged(const QString& account, int state)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue