Skip to content
Snippets Groups Projects
Commit 6e4d4cad authored by Jérémy Quentin's avatar Jérémy Quentin
Browse files

[#1526] Set accounts order

+ doc
parent d83cc0ee
Branches
Tags
No related merge requests found
......@@ -44,6 +44,41 @@ void AccountList::update()
}
}
void AccountList::upAccount(int index)
{
if(index <= 0 || index >= size())
{
qDebug() << "Error : index or future index out of range in upAccount.";
return;
}
Account & account = getAccount(index);
accounts->remove(index);
accounts->insert(index - 1, & account);
}
void AccountList::downAccount(int index)
{
if(index < 0 || index >= size() - 1)
{
qDebug() << "Error : index or future index out of range in upAccount.";
return;
}
Account & account = getAccount(index);
accounts->remove(index);
accounts->insert(index + 1, & account);
}
QString AccountList::getOrderedList()
{
QString order;
for( int i = 0 ; i < size() ; i++)
{
order += getAccount(i).getAccountId() + "/";
}
return order;
}
QVector<Account *> AccountList::registeredAccounts() const
{
qDebug() << "registeredAccounts";
......@@ -94,6 +129,16 @@ QVector<Account *> & AccountList::getAccounts()
return *accounts;
}
const Account & AccountList::getAccount (int i) const
{
return *((*accounts)[i]);
}
Account & AccountList::getAccount (int i)
{
return *((*accounts)[i]);
}
Account * AccountList::getAccountById(const QString & id) const
{
for (int i = 0; i < accounts->size(); ++i)
......@@ -114,7 +159,6 @@ QVector<Account *> AccountList::getAccountByState(QString & state)
v += (*accounts)[i];
}
return v;
}
/*
Account AccountList::getAccountByRow(int row)
......
......@@ -22,17 +22,22 @@ public:
//Getters
QVector<Account *> & getAccounts();
Account & getAccount (int i);
const Account & getAccount (int i) const;
Account * getAccountById(const QString & id) const;
QVector<Account *> getAccountByState(QString & state);
Account * getAccountByItem(QListWidgetItem * item);
int size();
Account * firstRegisteredAccount() const;
QString getOrderedList();
//Setters
Account * addAccount(QString & alias);
void removeAccount(Account * account);
void removeAccount(QListWidgetItem * item);
void setAccountFirst(Account * account);
void upAccount(int index);
void downAccount(int index);
//Operators
Account & operator[] (int i);
......
......@@ -363,6 +363,7 @@ void ConfigurationDialog::loadAccountList()
frame2_editAccounts->setEnabled(false);
}
void ConfigurationDialog::saveAccountList()
{
//get the configurationManager instance
......@@ -408,6 +409,7 @@ void ConfigurationDialog::saveAccountList()
configurationManager.removeAccount(accountIds[i]);
}
}
configurationManager.setAccountsOrder(accountList->getOrderedList());
}
void ConfigurationDialog::loadAccount(QListWidgetItem * item)
......@@ -649,6 +651,7 @@ void ConfigurationDialog::on_button_accountUp_clicked()
Account * account = accountList->getAccountByItem(prevItem);
//we need to build a new item to set the itemWidget back
QListWidgetItem * item = account->renewItem();
accountList->upAccount(currentRow);
delete prevItem;
listWidget_accountList->insertItem(currentRow - 1 , item);
listWidget_accountList->setItemWidget(item, account->getItemWidget());
......@@ -661,6 +664,7 @@ void ConfigurationDialog::on_button_accountDown_clicked()
QListWidgetItem * prevItem = listWidget_accountList->takeItem(currentRow);
Account * account = accountList->getAccountByItem(prevItem);
QListWidgetItem * item = account->renewItem();
accountList->downAccount(currentRow);
delete prevItem;
listWidget_accountList->insertItem(currentRow + 1 , item);
listWidget_accountList->setItemWidget(item, account->getItemWidget());
......
......@@ -27,7 +27,7 @@ To switch between those windows, click on the history and address book buttons.
<sect1 id="basic-use-call">
<title>Calling somebody</title>
<title>Making a call</title>
<sect2 id="basic-use-call-current">
<title>Dialing one's number</title>
......@@ -103,4 +103,14 @@ To switch between those windows, click on the history and address book buttons.
<sect1 id="basic-use-config">
<title>Configuration panel</title>
<para>The configuration panel is built in accordance with KDE specifications. It is divided by options type. The panel at left shows the different option pages you can reach. Click on one of them to acceed to the corresponding page. The changes you make are not applied until you click OK or Apply. Clicking Cancel will cancel and forget every change you made since the last Apply or OK command. Be careful not to forget some changes you made in some other pages if you wanted to Cancel it. </para>
<para>There is also a specific Apply button just for the account list which is useful to manage these accounts and valid your changes to see if the accounts are well registered. </para>
</sect1>
</chapter>
......@@ -16,6 +16,8 @@
#include "instance_interface_singleton.h"
#include "sflphone_const.h"
static const char description[] = I18N_NOOP("A KDE 4 Client for SFLPhone");
static const char version[] = "0.9.5";
......
......@@ -2176,6 +2176,7 @@ ManagerImpl::setConfig(const std::string& section, const std::string& name, int
void ManagerImpl::setAccountsOrder (const std::string& order)
{
_debug("Set accounts order : %s\n", order.c_str() );
// Set the new config
setConfig (PREFERENCES, CONFIG_ACCOUNTS_ORDER, order);
}
......
......@@ -42,7 +42,7 @@ class AudioRtp;
#define RANDOM_SIP_PORT rand() % 64000 + 1024
// To set the verbosity. From 0 (min) to 6 (max)
#define PJ_LOG_LEVEL 6
#define PJ_LOG_LEVEL 0
/**
* @file sipvoiplink.h
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment