Skip to content
Snippets Groups Projects
Commit 56031e4f authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Merge branch 'qt-client'

parents 47f116f2 710790c9
Branches
Tags
No related merge requests found
Showing
with 282 additions and 68 deletions
...@@ -7,4 +7,9 @@ MESSAGE(FATAL_ERROR "Please install msgmerge binary") ...@@ -7,4 +7,9 @@ MESSAGE(FATAL_ERROR "Please install msgmerge binary")
endif (NOT GETTEXT_MSGFMT_EXECUTABLE) endif (NOT GETTEXT_MSGFMT_EXECUTABLE)
add_subdirectory(fr) add_subdirectory(fr)
add_subdirectory(es)
add_subdirectory(de)
add_subdirectory(ru)
add_subdirectory(zh_CN)
add_subdirectory(zh_HK)
...@@ -134,7 +134,7 @@ bool Account::isChecked() const ...@@ -134,7 +134,7 @@ bool Account::isChecked() const
return itemWidget->getEnabled(); return itemWidget->getEnabled();
} }
QString & Account::getAccountId() const QString & Account::getAccountId() const
{ {
if (isNew()) if (isNew())
{ {
...@@ -187,7 +187,7 @@ QString Account::getAccountDetail(QString param) const ...@@ -187,7 +187,7 @@ QString Account::getAccountDetail(QString param) const
return (*accountDetails)[param]; return (*accountDetails)[param];
} }
QString Account::getAlias() QString Account::getAlias() const
{ {
return getAccountDetail(ACCOUNT_ALIAS); return getAccountDetail(ACCOUNT_ALIAS);
} }
...@@ -221,6 +221,16 @@ void Account::setEnabled(bool checked) ...@@ -221,6 +221,16 @@ void Account::setEnabled(bool checked)
setAccountDetail(ACCOUNT_ENABLED, checked ? ACCOUNT_ENABLED_TRUE : ACCOUNT_ENABLED_FALSE); setAccountDetail(ACCOUNT_ENABLED, checked ? ACCOUNT_ENABLED_TRUE : ACCOUNT_ENABLED_FALSE);
} }
bool Account::isEnabled() const
{
return (getAccountDetail(ACCOUNT_ENABLED) == ACCOUNT_ENABLED_TRUE);
}
bool Account::isRegistered() const
{
return (getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_REGISTERED);
}
void Account::updateState() void Account::updateState()
{ {
qDebug() << "updateState"; qDebug() << "updateState";
......
...@@ -54,7 +54,7 @@ public: ...@@ -54,7 +54,7 @@ public:
//Getters //Getters
bool isNew() const; bool isNew() const;
bool isChecked() const; bool isChecked() const;
QString & getAccountId(); const QString & getAccountId() const;
MapStringString & getAccountDetails() const; MapStringString & getAccountDetails() const;
QListWidgetItem * getItem(); QListWidgetItem * getItem();
AccountItemWidget * getItemWidget(); AccountItemWidget * getItemWidget();
...@@ -62,7 +62,9 @@ public: ...@@ -62,7 +62,9 @@ public:
QColor getStateColor(); QColor getStateColor();
QString getStateColorName(); QString getStateColorName();
QString getAccountDetail(QString param) const; QString getAccountDetail(QString param) const;
QString getAlias(); QString getAlias() const;
bool isEnabled() const;
bool isRegistered() const;
//Setters //Setters
void setAccountId(QString id); void setAccountId(QString id);
...@@ -77,7 +79,7 @@ public: ...@@ -77,7 +79,7 @@ public:
//Operators //Operators
bool operator==(const Account&)const; bool operator==(const Account&)const;
private slots: public slots:
void setEnabled(bool checked); void setEnabled(bool checked);
......
...@@ -81,9 +81,9 @@ void AccountList::upAccount(int index) ...@@ -81,9 +81,9 @@ void AccountList::upAccount(int index)
qDebug() << "Error : index or future index out of range in upAccount."; qDebug() << "Error : index or future index out of range in upAccount.";
return; return;
} }
Account & account = getAccount(index); Account * account = getAccountAt(index);
accounts->remove(index); accounts->remove(index);
accounts->insert(index - 1, & account); accounts->insert(index - 1, account);
} }
void AccountList::downAccount(int index) void AccountList::downAccount(int index)
...@@ -93,18 +93,18 @@ void AccountList::downAccount(int index) ...@@ -93,18 +93,18 @@ void AccountList::downAccount(int index)
qDebug() << "Error : index or future index out of range in upAccount."; qDebug() << "Error : index or future index out of range in upAccount.";
return; return;
} }
Account & account = getAccount(index); Account * account = getAccountAt(index);
accounts->remove(index); accounts->remove(index);
accounts->insert(index + 1, & account); accounts->insert(index + 1, account);
} }
QString AccountList::getOrderedList() QString AccountList::getOrderedList() const
{ {
QString order; QString order;
for( int i = 0 ; i < size() ; i++) for( int i = 0 ; i < size() ; i++)
{ {
order += getAccount(i).getAccountId() + "/"; order += getAccountAt(i)->getAccountId() + "/";
} }
return order; return order;
} }
...@@ -150,14 +150,14 @@ QVector<Account *> & AccountList::getAccounts() ...@@ -150,14 +150,14 @@ QVector<Account *> & AccountList::getAccounts()
return *accounts; return *accounts;
} }
const Account & AccountList::getAccount (int i) const const Account * AccountList::getAccountAt (int i) const
{ {
return *((*accounts)[i]); return (*accounts)[i];
} }
Account & AccountList::getAccount (int i) Account * AccountList::getAccountAt (int i)
{ {
return *((*accounts)[i]); return (*accounts)[i];
} }
Account * AccountList::getAccountById(const QString & id) const Account * AccountList::getAccountById(const QString & id) const
...@@ -194,7 +194,7 @@ Account * AccountList::getAccountByItem(QListWidgetItem * item) ...@@ -194,7 +194,7 @@ Account * AccountList::getAccountByItem(QListWidgetItem * item)
return NULL; return NULL;
} }
int AccountList::size() int AccountList::size() const
{ {
return accounts->size(); return accounts->size();
} }
...@@ -222,12 +222,12 @@ void AccountList::removeAccount(Account * account) ...@@ -222,12 +222,12 @@ void AccountList::removeAccount(Account * account)
accounts->remove(accounts->indexOf(account)); accounts->remove(accounts->indexOf(account));
} }
const Account & AccountList::operator[] (int i) const const Account * AccountList::operator[] (int i) const
{ {
return *((*accounts)[i]); return (*accounts)[i];
} }
Account & AccountList::operator[] (int i) Account * AccountList::operator[] (int i)
{ {
return *((*accounts)[i]); return (*accounts)[i];
} }
...@@ -49,14 +49,14 @@ public: ...@@ -49,14 +49,14 @@ public:
//Getters //Getters
QVector<Account *> & getAccounts(); QVector<Account *> & getAccounts();
Account & getAccount (int i); Account * getAccountAt (int i);
const Account & getAccount (int i) const; const Account * getAccountAt (int i) const;
Account * getAccountById(const QString & id) const; Account * getAccountById(const QString & id) const;
QVector<Account *> getAccountByState(QString & state); QVector<Account *> getAccountByState(QString & state);
Account * getAccountByItem(QListWidgetItem * item); Account * getAccountByItem(QListWidgetItem * item);
int size(); int size() const;
Account * firstRegisteredAccount() const; Account * firstRegisteredAccount() const;
QString getOrderedList(); QString getOrderedList() const;
//Setters //Setters
Account * addAccount(QString & alias); Account * addAccount(QString & alias);
...@@ -66,8 +66,8 @@ public: ...@@ -66,8 +66,8 @@ public:
void downAccount(int index); void downAccount(int index);
//Operators //Operators
Account & operator[] (int i); Account * operator[] (int i);
const Account & operator[] (int i) const; const Account * operator[] (int i) const;
QVector<Account *> registeredAccounts() const; QVector<Account *> registeredAccounts() const;
public slots: public slots:
......
/***************************************************************************
* Copyright (C) 2009 by Savoir-Faire Linux *
* Author : Jérémy Quentin *
* jeremy.quentin@savoirfairelinux.com *
* *
* 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, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "AccountListModel.h"
#include "sflphone_const.h"
#include <QDebug>
AccountListModel::AccountListModel(QObject *parent)
: QAbstractListModel(parent)
{
this->accounts = new AccountList();
}
AccountListModel::~AccountListModel()
{
}
QVariant AccountListModel::data ( const QModelIndex & index, int role) const
{
if (!index.isValid() || index.row() < 0 || index.row() >= rowCount())
return QVariant();
const Account * account = (*accounts)[index.row()];
if(index.column() == 0 && role == Qt::DisplayRole)
{
return QVariant(account->getAlias());
}
else if(index.column() == 0 && role == Qt::CheckStateRole)
{
return QVariant(account->isEnabled() ? Qt::Checked : Qt::Unchecked);
}
else if(index.column() == 0 && role == Qt::DecorationRole)
{
if(! account->isEnabled())
{
return QVariant(QIcon(ICON_ACCOUNT_LED_GRAY));
}
else if(account->isRegistered())
{
return QVariant(QIcon(ICON_ACCOUNT_LED_GREEN));
}
else
{
return QVariant(QIcon(ICON_ACCOUNT_LED_RED));
}
}
return QVariant();
}
Qt::ItemFlags AccountListModel::flags(const QModelIndex & index) const
{
if (index.column() == 0)
{
return QAbstractItemModel::flags(index) | Qt::ItemIsUserCheckable;
}
return QAbstractItemModel::flags(index);
}
bool AccountListModel::setData ( const QModelIndex & index, const QVariant &value, int role)
{
qDebug() << "setData";
if (index.isValid() && index.column() == 0 && role == Qt::CheckStateRole) {
(*accounts)[index.row()]->setEnabled(value.toBool());
emit dataChanged(index, index);
return true;
}
return false;
}
bool AccountListModel::accountUp( int index )
{
if(index > 0 && index <= rowCount())
{
accounts->upAccount(index);
emit dataChanged(this->index(index - 1, 0, QModelIndex()), this->index(index, 0, QModelIndex()));
return true;
}
return false;
}
bool AccountListModel::accountDown( int index )
{
if(index >= 0 && index < rowCount())
{
accounts->downAccount(index);
emit dataChanged(this->index(index, 0, QModelIndex()), this->index(index + 1, 0, QModelIndex()));
return true;
}
return false;
}
bool AccountListModel::removeAccount( int index )
{
if(index >= 0 && index < rowCount())
{
accounts->removeAccount(accounts->getAccountAt(index));
emit dataChanged(this->index(index, 0, QModelIndex()), this->index(rowCount(), 0, QModelIndex()));
return true;
}
return false;
}
bool AccountListModel::addAccount( QString alias )
{
accounts->addAccount(alias);
emit dataChanged(this->index(0, 0, QModelIndex()), this->index(rowCount(), 0, QModelIndex()));
return true;
}
int AccountListModel::rowCount(const QModelIndex & parent) const
{
return accounts->size();
}
QString AccountListModel::getOrderedList() const
{
return accounts->getOrderedList();
}
/***************************************************************************
* Copyright (C) 2009 by Savoir-Faire Linux *
* Author : Jérémy Quentin *
* jeremy.quentin@savoirfairelinux.com *
* *
* 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, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef ACCOUNTLISTMODEL_H
#define ACCOUNTLISTMODEL_H
#include <QAbstractListModel>
#include "AccountList.h"
/**
@author Jérémy Quentin <jeremy.quentin@gmail.com>
*/
class AccountListModel : public QAbstractListModel
{
Q_OBJECT
private:
AccountList * accounts;
public:
AccountListModel(QObject *parent = 0);
~AccountListModel();
QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
int rowCount(const QModelIndex & parent = QModelIndex()) const;
// int columnCount(const QModelIndex & parent = QModelIndex()) const;
// QVariant headerData(int section , Qt::Orientation orientation, int role) const;
Qt::ItemFlags flags(const QModelIndex & index) const;
virtual bool setData ( const QModelIndex & index, const QVariant &value, int role);
bool accountUp( int index );
bool accountDown( int index );
bool removeAccount( int index );
bool addAccount( QString alias );
QString getOrderedList() const;
// QStringList getActiveCodecList() const ;
// void setActiveCodecList(const QStringList & activeCodecListToSet);
};
#endif
...@@ -58,6 +58,7 @@ SET( sflphone_client_kde_SRCS ...@@ -58,6 +58,7 @@ SET( sflphone_client_kde_SRCS
CodecListModel.cpp CodecListModel.cpp
SortableCodecListWidget.cpp SortableCodecListWidget.cpp
Item.cpp Item.cpp
AccountListModel.cpp
) )
......
...@@ -125,13 +125,10 @@ bool CodecListModel::setData ( const QModelIndex & index, const QVariant &value, ...@@ -125,13 +125,10 @@ bool CodecListModel::setData ( const QModelIndex & index, const QVariant &value,
bool CodecListModel::codecUp( int index ) bool CodecListModel::codecUp( int index )
{ {
qDebug() << getActiveCodecList();
if(index > 0 && index <= rowCount()) if(index > 0 && index <= rowCount())
{ {
codecs.swap(index - 1, index); codecs.swap(index - 1, index);
qDebug() << getActiveCodecList();
emit dataChanged(this->index(index - 1, 0, QModelIndex()), this->index(index, columnCount(), QModelIndex())); emit dataChanged(this->index(index - 1, 0, QModelIndex()), this->index(index, columnCount(), QModelIndex()));
qDebug() << getActiveCodecList();
return true; return true;
} }
return false; return false;
......
...@@ -37,12 +37,10 @@ public: ...@@ -37,12 +37,10 @@ public:
CodecListModel(QObject *parent = 0); CodecListModel(QObject *parent = 0);
~CodecListModel(); ~CodecListModel();
void setCodecs(QList<Codec *> codecs);
QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const; QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
int rowCount(const QModelIndex & parent = QModelIndex()) const; int rowCount(const QModelIndex & parent = QModelIndex()) const;
int columnCount(const QModelIndex & parent = QModelIndex()) const; int columnCount(const QModelIndex & parent = QModelIndex()) const;
// bool insertRows(int position, int rows, const QModelIndex &parent);
QVariant headerData(int section , Qt::Orientation orientation, int role) const; QVariant headerData(int section , Qt::Orientation orientation, int role) const;
Qt::ItemFlags flags(const QModelIndex & index) const; Qt::ItemFlags flags(const QModelIndex & index) const;
virtual bool setData ( const QModelIndex & index, const QVariant &value, int role); virtual bool setData ( const QModelIndex & index, const QVariant &value, int role);
...@@ -53,7 +51,7 @@ public: ...@@ -53,7 +51,7 @@ public:
void setActiveCodecList(const QStringList & activeCodecListToSet); void setActiveCodecList(const QStringList & activeCodecListToSet);
signals: signals:
void dataChanged(const QModelIndex &, const QModelIndex &); // void dataChanged(const QModelIndex &, const QModelIndex &);
}; };
#endif #endif
...@@ -42,6 +42,14 @@ class sflphone_kdeView; ...@@ -42,6 +42,14 @@ class sflphone_kdeView;
/** /**
@author Jérémy Quentin <jeremy.quentin@gmail.com> @author Jérémy Quentin <jeremy.quentin@gmail.com>
This class represents the config dialog for sflphone.
It uses the ConfigurationSkeleton class to handle most of the settings.
It inherits KConfigDialog with the pages defined in dlg... files.
A few complicated settings are handled directly by its pages.
Some custom behaviors have been added to handle specific cases,
as this config dialog is not the usual kind.
A few things might be done a cleaner way by passing the handling
to the skeleton like it has been done with codecs.
*/ */
class ConfigurationDialogKDE : public KConfigDialog class ConfigurationDialogKDE : public KConfigDialog
{ {
......
...@@ -28,8 +28,8 @@ ConfigurationSkeleton::ConfigurationSkeleton() ...@@ -28,8 +28,8 @@ ConfigurationSkeleton::ConfigurationSkeleton()
{ {
qDebug() << "Building ConfigurationSkeleton"; qDebug() << "Building ConfigurationSkeleton";
codecListModel = new CodecListModel(); codecListModel = new CodecListModel();
accountListModel = new AccountListModel();
readConfig(); readConfig();
} }
ConfigurationSkeleton * ConfigurationSkeleton::instance = NULL; ConfigurationSkeleton * ConfigurationSkeleton::instance = NULL;
......
...@@ -25,9 +25,18 @@ ...@@ -25,9 +25,18 @@
#include "kcfg_settings.h" #include "kcfg_settings.h"
#include "CodecListModel.h" #include "CodecListModel.h"
#include "AccountListModel.h"
/** /**
@author Jérémy Quentin <jeremy.quentin@gmail.com> @author Jérémy Quentin <jeremy.quentin@gmail.com>
This class represents the config skeleton for the config dialog.
It inherits the KConfigSkeleton "ConfigurationSkeletonBase"generated
by sflphone-client-kde.kcfg which handles most of the settings.
This class handles the codec list.
A few complicated settings are handled directly by the config dialog
and its pages (accounts, sound managers).
This class reimplements the writeConfig and readConfig functions to ask the
daemon instead of the normal behavior (read and write in a kconfig file).
*/ */
class ConfigurationSkeleton : public ConfigurationSkeletonBase class ConfigurationSkeleton : public ConfigurationSkeletonBase
{ {
...@@ -38,6 +47,8 @@ private: ...@@ -38,6 +47,8 @@ private:
CodecListModel * codecListModel; CodecListModel * codecListModel;
AccountListModel * accountListModel;
public: public:
ConfigurationSkeleton(); ConfigurationSkeleton();
...@@ -55,12 +66,6 @@ public: ...@@ -55,12 +66,6 @@ public:
CodecListModel * getCodecListModel(); CodecListModel * getCodecListModel();
// protected:
// virtual void usrReadConfig();
}; };
#endif #endif
...@@ -85,29 +85,29 @@ void DlgAccounts::saveAccountList() ...@@ -85,29 +85,29 @@ void DlgAccounts::saveAccountList()
QStringList accountIds= QStringList(configurationManager.getAccountList().value()); QStringList accountIds= QStringList(configurationManager.getAccountList().value());
//create or update each account from accountList //create or update each account from accountList
for (int i = 0; i < accountList->size(); i++){ for (int i = 0; i < accountList->size(); i++){
Account & current = (*accountList)[i]; Account * current = (*accountList)[i];
QString currentId; QString currentId;
//if the account has no instanciated id, it has just been created in the client //if the account has no instanciated id, it has just been created in the client
if(current.isNew()) if(current->isNew())
{ {
MapStringString details = current.getAccountDetails(); MapStringString details = current->getAccountDetails();
currentId = configurationManager.addAccount(details); currentId = configurationManager.addAccount(details);
current.setAccountId(currentId); current->setAccountId(currentId);
} }
//if the account has an instanciated id but it's not in configurationManager //if the account has an instanciated id but it's not in configurationManager
else{ else{
if(! accountIds.contains(current.getAccountId())) if(! accountIds.contains(current->getAccountId()))
{ {
qDebug() << "The account with id " << current.getAccountId() << " doesn't exist. It might have been removed by another SFLphone client."; qDebug() << "The account with id " << current->getAccountId() << " doesn't exist. It might have been removed by another SFLphone client.";
currentId = QString(); currentId = QString();
} }
else else
{ {
configurationManager.setAccountDetails(current.getAccountId(), current.getAccountDetails()); configurationManager.setAccountDetails(current->getAccountId(), current->getAccountDetails());
currentId = QString(current.getAccountId()); currentId = QString(current->getAccountId());
} }
} }
qDebug() << currentId << " : " << current.isChecked(); qDebug() << currentId << " : " << current->isChecked();
} }
//remove accounts that are in the configurationManager but not in the client //remove accounts that are in the configurationManager but not in the client
for (int i = 0; i < accountIds.size(); i++) for (int i = 0; i < accountIds.size(); i++)
...@@ -190,7 +190,7 @@ void DlgAccounts::loadAccountList() ...@@ -190,7 +190,7 @@ void DlgAccounts::loadAccountList()
//initialize the QListWidget object with the AccountList //initialize the QListWidget object with the AccountList
listWidget_accountList->clear(); listWidget_accountList->clear();
for (int i = 0; i < accountList->size(); ++i){ for (int i = 0; i < accountList->size(); ++i){
addAccountToAccountList(&(*accountList)[i]); addAccountToAccountList((*accountList)[i]);
} }
if (listWidget_accountList->count() > 0 && listWidget_accountList->currentItem() == NULL) if (listWidget_accountList->count() > 0 && listWidget_accountList->currentItem() == NULL)
listWidget_accountList->setCurrentRow(0); listWidget_accountList->setCurrentRow(0);
...@@ -343,8 +343,8 @@ void DlgAccounts::updateAccountStates() ...@@ -343,8 +343,8 @@ void DlgAccounts::updateAccountStates()
qDebug() << accountList->size(); qDebug() << accountList->size();
for (int i = 0; i < accountList->size(); i++) for (int i = 0; i < accountList->size(); i++)
{ {
Account & current = accountList->getAccount(i); Account * current = accountList->getAccountAt(i);
current.updateState(); current->updateState();
} }
qDebug() << accountList->size(); qDebug() << accountList->size();
} }
......
...@@ -18,8 +18,7 @@ ...@@ -18,8 +18,7 @@
#include <QTableView> #include <QTableView>
#include <QListView> #include <QListView>
#include "CodecListModel.h" #include "AccountListModel.h"
#include "SortableCodecListWidget.h"
static const char description[] = "A KDE 4 Client for SFLphone"; static const char description[] = "A KDE 4 Client for SFLphone";
...@@ -63,6 +62,11 @@ int main(int argc, char **argv) ...@@ -63,6 +62,11 @@ int main(int argc, char **argv)
// SortableCodecListWidget * cl = new SortableCodecListWidget(); // SortableCodecListWidget * cl = new SortableCodecListWidget();
// cl->show(); // cl->show();
QListView * v = new QListView();
v->setFlow(QListView::TopToBottom);
v->setModel(new AccountListModel());
v->show();
return app.exec(); return app.exec();
} }
catch(const char * msg) catch(const char * msg)
......
...@@ -29,24 +29,9 @@ ...@@ -29,24 +29,9 @@
#define APP_NAME "SFLphone KDE Client" #define APP_NAME "SFLphone KDE Client"
/** Locale */
// #define _(STRING) gettext( STRING )
/** Warnings unused variables **/
// #define UNUSED_VAR(var) (void*)var
// #define UNUSED __attribute__((__unused__))
#define SIP 0 #define SIP 0
#define IAX 1 #define IAX 1
#define PAGE_GENERAL 0
#define PAGE_DISPLAY 1
#define PAGE_ACCOUNTS 2
#define PAGE_AUDIO 3
#define TOOLBAR_SIZE 22 #define TOOLBAR_SIZE 22
#define CONTACT_ITEM_HEIGHT 40 #define CONTACT_ITEM_HEIGHT 40
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment