diff --git a/sflphone-client-kde/po/CMakeLists.txt b/sflphone-client-kde/po/CMakeLists.txt index 7addefd5a57ceaee920dfac5a20a78da5ab50474..8618944166c9c62bc031ce4f7e2e32b873be2a90 100644 --- a/sflphone-client-kde/po/CMakeLists.txt +++ b/sflphone-client-kde/po/CMakeLists.txt @@ -7,4 +7,9 @@ MESSAGE(FATAL_ERROR "Please install msgmerge binary") endif (NOT GETTEXT_MSGFMT_EXECUTABLE) add_subdirectory(fr) +add_subdirectory(es) +add_subdirectory(de) +add_subdirectory(ru) +add_subdirectory(zh_CN) +add_subdirectory(zh_HK) diff --git a/sflphone-client-kde/src/Account.cpp b/sflphone-client-kde/src/Account.cpp index aee3cb2c54bb9c4f32ee35664061412287230629..138b9d4554699aab5f72a260496c22ba6a6e61f1 100644 --- a/sflphone-client-kde/src/Account.cpp +++ b/sflphone-client-kde/src/Account.cpp @@ -134,7 +134,7 @@ bool Account::isChecked() const return itemWidget->getEnabled(); } -QString & Account::getAccountId() +const QString & Account::getAccountId() const { if (isNew()) { @@ -187,7 +187,7 @@ QString Account::getAccountDetail(QString param) const return (*accountDetails)[param]; } -QString Account::getAlias() +QString Account::getAlias() const { return getAccountDetail(ACCOUNT_ALIAS); } @@ -221,6 +221,16 @@ void Account::setEnabled(bool checked) 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() { qDebug() << "updateState"; diff --git a/sflphone-client-kde/src/Account.h b/sflphone-client-kde/src/Account.h index 37f11f4b23fcdae36e7e90ced18adfe25b4f8eeb..8760c9e6b055dff7537e591396e38329bdae9df2 100644 --- a/sflphone-client-kde/src/Account.h +++ b/sflphone-client-kde/src/Account.h @@ -54,7 +54,7 @@ public: //Getters bool isNew() const; bool isChecked() const; - QString & getAccountId(); + const QString & getAccountId() const; MapStringString & getAccountDetails() const; QListWidgetItem * getItem(); AccountItemWidget * getItemWidget(); @@ -62,7 +62,9 @@ public: QColor getStateColor(); QString getStateColorName(); QString getAccountDetail(QString param) const; - QString getAlias(); + QString getAlias() const; + bool isEnabled() const; + bool isRegistered() const; //Setters void setAccountId(QString id); @@ -77,7 +79,7 @@ public: //Operators bool operator==(const Account&)const; -private slots: +public slots: void setEnabled(bool checked); diff --git a/sflphone-client-kde/src/AccountList.cpp b/sflphone-client-kde/src/AccountList.cpp index 82f2afd0bb2c8f3083269455565b58dd6d2eca05..61ddb535fd46a8052c2b823b215eb040f1a699be 100644 --- a/sflphone-client-kde/src/AccountList.cpp +++ b/sflphone-client-kde/src/AccountList.cpp @@ -81,9 +81,9 @@ void AccountList::upAccount(int index) qDebug() << "Error : index or future index out of range in upAccount."; return; } - Account & account = getAccount(index); + Account * account = getAccountAt(index); accounts->remove(index); - accounts->insert(index - 1, & account); + accounts->insert(index - 1, account); } 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."; return; } - Account & account = getAccount(index); + Account * account = getAccountAt(index); accounts->remove(index); - accounts->insert(index + 1, & account); + accounts->insert(index + 1, account); } -QString AccountList::getOrderedList() +QString AccountList::getOrderedList() const { QString order; for( int i = 0 ; i < size() ; i++) { - order += getAccount(i).getAccountId() + "/"; + order += getAccountAt(i)->getAccountId() + "/"; } return order; } @@ -150,14 +150,14 @@ QVector<Account *> & AccountList::getAccounts() 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 @@ -194,7 +194,7 @@ Account * AccountList::getAccountByItem(QListWidgetItem * item) return NULL; } -int AccountList::size() +int AccountList::size() const { return accounts->size(); } @@ -222,12 +222,12 @@ void AccountList::removeAccount(Account * 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]; } diff --git a/sflphone-client-kde/src/AccountList.h b/sflphone-client-kde/src/AccountList.h index e1b00e77bb7d62ef68a8713644f06b8608e43f22..48032d89a3b3d5253ee7917fac7fdd0dc0abe705 100644 --- a/sflphone-client-kde/src/AccountList.h +++ b/sflphone-client-kde/src/AccountList.h @@ -49,14 +49,14 @@ public: //Getters QVector<Account *> & getAccounts(); - Account & getAccount (int i); - const Account & getAccount (int i) const; + Account * getAccountAt (int i); + const Account * getAccountAt (int i) const; Account * getAccountById(const QString & id) const; QVector<Account *> getAccountByState(QString & state); Account * getAccountByItem(QListWidgetItem * item); - int size(); + int size() const; Account * firstRegisteredAccount() const; - QString getOrderedList(); + QString getOrderedList() const; //Setters Account * addAccount(QString & alias); @@ -66,8 +66,8 @@ public: void downAccount(int index); //Operators - Account & operator[] (int i); - const Account & operator[] (int i) const; + Account * operator[] (int i); + const Account * operator[] (int i) const; QVector<Account *> registeredAccounts() const; public slots: diff --git a/sflphone-client-kde/src/AccountListModel.cpp b/sflphone-client-kde/src/AccountListModel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7dcb09a39c246584527fed46d328fe9f78eaf9bb --- /dev/null +++ b/sflphone-client-kde/src/AccountListModel.cpp @@ -0,0 +1,139 @@ +/*************************************************************************** + * 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(); +} + diff --git a/sflphone-client-kde/src/AccountListModel.h b/sflphone-client-kde/src/AccountListModel.h new file mode 100644 index 0000000000000000000000000000000000000000..dc4a9b40e6267b35b0cedf08db76b0df5a62e780 --- /dev/null +++ b/sflphone-client-kde/src/AccountListModel.h @@ -0,0 +1,60 @@ +/*************************************************************************** + * 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 diff --git a/sflphone-client-kde/src/CMakeLists.txt b/sflphone-client-kde/src/CMakeLists.txt index 1513094c6247e19af0d06a12d5c57d0874592765..778aabb808e79ecc36e232dbdefa9530e5747700 100644 --- a/sflphone-client-kde/src/CMakeLists.txt +++ b/sflphone-client-kde/src/CMakeLists.txt @@ -58,6 +58,7 @@ SET( sflphone_client_kde_SRCS CodecListModel.cpp SortableCodecListWidget.cpp Item.cpp + AccountListModel.cpp ) diff --git a/sflphone-client-kde/src/CodecListModel.cpp b/sflphone-client-kde/src/CodecListModel.cpp index f048655c6243be788ba876486f2f679011e5c4e6..4acf8a05662df40dc63f3ac612ac74a21952db4f 100644 --- a/sflphone-client-kde/src/CodecListModel.cpp +++ b/sflphone-client-kde/src/CodecListModel.cpp @@ -125,13 +125,10 @@ bool CodecListModel::setData ( const QModelIndex & index, const QVariant &value, bool CodecListModel::codecUp( int index ) { - qDebug() << getActiveCodecList(); if(index > 0 && index <= rowCount()) { codecs.swap(index - 1, index); - qDebug() << getActiveCodecList(); emit dataChanged(this->index(index - 1, 0, QModelIndex()), this->index(index, columnCount(), QModelIndex())); - qDebug() << getActiveCodecList(); return true; } return false; diff --git a/sflphone-client-kde/src/CodecListModel.h b/sflphone-client-kde/src/CodecListModel.h index 26b63b642c12baa619abed2dedaf1054f0bf1673..bf2082c443cf4407c61129b7a152192feae46708 100644 --- a/sflphone-client-kde/src/CodecListModel.h +++ b/sflphone-client-kde/src/CodecListModel.h @@ -37,12 +37,10 @@ public: CodecListModel(QObject *parent = 0); ~CodecListModel(); - void setCodecs(QList<Codec *> codecs); QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const; int rowCount(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; Qt::ItemFlags flags(const QModelIndex & index) const; virtual bool setData ( const QModelIndex & index, const QVariant &value, int role); @@ -53,7 +51,7 @@ public: void setActiveCodecList(const QStringList & activeCodecListToSet); signals: - void dataChanged(const QModelIndex &, const QModelIndex &); +// void dataChanged(const QModelIndex &, const QModelIndex &); }; #endif diff --git a/sflphone-client-kde/src/conf/ConfigurationDialog.h b/sflphone-client-kde/src/conf/ConfigurationDialog.h index 7fc0009b9caeb04a68cf32a5099a349c86a83ba1..4c3b1c26b9610f1391fe7d34be6f33423ce9916b 100644 --- a/sflphone-client-kde/src/conf/ConfigurationDialog.h +++ b/sflphone-client-kde/src/conf/ConfigurationDialog.h @@ -42,6 +42,14 @@ class sflphone_kdeView; /** @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 { diff --git a/sflphone-client-kde/src/conf/ConfigurationSkeleton.cpp b/sflphone-client-kde/src/conf/ConfigurationSkeleton.cpp index f73b8de984f9cff49cd3004f30c4fab72c76e368..e29869eaff2f627cc0ba8244afed2be026911441 100644 --- a/sflphone-client-kde/src/conf/ConfigurationSkeleton.cpp +++ b/sflphone-client-kde/src/conf/ConfigurationSkeleton.cpp @@ -28,8 +28,8 @@ ConfigurationSkeleton::ConfigurationSkeleton() { qDebug() << "Building ConfigurationSkeleton"; codecListModel = new CodecListModel(); + accountListModel = new AccountListModel(); readConfig(); - } ConfigurationSkeleton * ConfigurationSkeleton::instance = NULL; diff --git a/sflphone-client-kde/src/conf/ConfigurationSkeleton.h b/sflphone-client-kde/src/conf/ConfigurationSkeleton.h index 71386a50701c0e72979caeadd154a15cd5973b5b..05f20e579ad11bb14b99a4344342d8cda330f248 100644 --- a/sflphone-client-kde/src/conf/ConfigurationSkeleton.h +++ b/sflphone-client-kde/src/conf/ConfigurationSkeleton.h @@ -25,9 +25,18 @@ #include "kcfg_settings.h" #include "CodecListModel.h" +#include "AccountListModel.h" /** @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 { @@ -37,6 +46,8 @@ private: static ConfigurationSkeleton * instance; CodecListModel * codecListModel; + + AccountListModel * accountListModel; public: ConfigurationSkeleton(); @@ -54,12 +65,6 @@ public: void setActiveCodecList(const QStringList & v); CodecListModel * getCodecListModel(); - -// protected: - -// virtual void usrReadConfig(); - - }; diff --git a/sflphone-client-kde/src/conf/dlgaccounts.cpp b/sflphone-client-kde/src/conf/dlgaccounts.cpp index 9179626e67969216fa06de7aea74777ac15c4c81..9653ad01b1210ac6bf01e0578ae717c18f89ff39 100644 --- a/sflphone-client-kde/src/conf/dlgaccounts.cpp +++ b/sflphone-client-kde/src/conf/dlgaccounts.cpp @@ -85,29 +85,29 @@ void DlgAccounts::saveAccountList() QStringList accountIds= QStringList(configurationManager.getAccountList().value()); //create or update each account from accountList for (int i = 0; i < accountList->size(); i++){ - Account & current = (*accountList)[i]; + Account * current = (*accountList)[i]; QString currentId; //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); - current.setAccountId(currentId); + current->setAccountId(currentId); } //if the account has an instanciated id but it's not in configurationManager 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(); } else { - configurationManager.setAccountDetails(current.getAccountId(), current.getAccountDetails()); - currentId = QString(current.getAccountId()); + configurationManager.setAccountDetails(current->getAccountId(), current->getAccountDetails()); + currentId = QString(current->getAccountId()); } } - qDebug() << currentId << " : " << current.isChecked(); + qDebug() << currentId << " : " << current->isChecked(); } //remove accounts that are in the configurationManager but not in the client for (int i = 0; i < accountIds.size(); i++) @@ -190,7 +190,7 @@ void DlgAccounts::loadAccountList() //initialize the QListWidget object with the AccountList listWidget_accountList->clear(); for (int i = 0; i < accountList->size(); ++i){ - addAccountToAccountList(&(*accountList)[i]); + addAccountToAccountList((*accountList)[i]); } if (listWidget_accountList->count() > 0 && listWidget_accountList->currentItem() == NULL) listWidget_accountList->setCurrentRow(0); @@ -343,8 +343,8 @@ void DlgAccounts::updateAccountStates() qDebug() << accountList->size(); for (int i = 0; i < accountList->size(); i++) { - Account & current = accountList->getAccount(i); - current.updateState(); + Account * current = accountList->getAccountAt(i); + current->updateState(); } qDebug() << accountList->size(); } diff --git a/sflphone-client-kde/src/main.cpp b/sflphone-client-kde/src/main.cpp index c6de33b710fe18315102c533ab8832d3b38d7251..d9f9d7493c3f99f34f5259e714003865babf402b 100644 --- a/sflphone-client-kde/src/main.cpp +++ b/sflphone-client-kde/src/main.cpp @@ -18,8 +18,7 @@ #include <QTableView> #include <QListView> -#include "CodecListModel.h" -#include "SortableCodecListWidget.h" +#include "AccountListModel.h" static const char description[] = "A KDE 4 Client for SFLphone"; @@ -62,6 +61,11 @@ int main(int argc, char **argv) // SortableCodecListWidget * cl = new SortableCodecListWidget(); // cl->show(); + + QListView * v = new QListView(); + v->setFlow(QListView::TopToBottom); + v->setModel(new AccountListModel()); + v->show(); return app.exec(); } diff --git a/sflphone-client-kde/src/sflphone_const.h b/sflphone-client-kde/src/sflphone_const.h index a83da4179e695884d174944bec111db0634922b9..8829799acf68f9384cd2de9191db585ee6b756a2 100644 --- a/sflphone-client-kde/src/sflphone_const.h +++ b/sflphone-client-kde/src/sflphone_const.h @@ -29,24 +29,9 @@ #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 IAX 1 -#define PAGE_GENERAL 0 -#define PAGE_DISPLAY 1 -#define PAGE_ACCOUNTS 2 -#define PAGE_AUDIO 3 - #define TOOLBAR_SIZE 22 #define CONTACT_ITEM_HEIGHT 40