diff --git a/sflphone-client-kde/src/CMakeLists.txt b/sflphone-client-kde/src/CMakeLists.txt index 0d71a14d5c3e6b32874df54db4d44e29ea5d71e6..1513094c6247e19af0d06a12d5c57d0874592765 100644 --- a/sflphone-client-kde/src/CMakeLists.txt +++ b/sflphone-client-kde/src/CMakeLists.txt @@ -54,9 +54,9 @@ SET( sflphone_client_kde_SRCS conf/dlghooks.cpp conf/ConfigurationSkeleton.cpp Dialpad.cpp -# Codec.cpp -# CodecListModel.cpp -# SortableCodecListWidget.cpp + Codec.cpp + CodecListModel.cpp + SortableCodecListWidget.cpp Item.cpp ) diff --git a/sflphone-client-kde/src/Codec.cpp b/sflphone-client-kde/src/Codec.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0ce75a9824a4c99f518a1508a646a3ca10d31d13 --- /dev/null +++ b/sflphone-client-kde/src/Codec.cpp @@ -0,0 +1,64 @@ +/*************************************************************************** + * 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 "Codec.h" + +#include "configurationmanager_interface_singleton.h" +#include "sflphone_const.h" + +Codec::Codec(int payload, bool enabled) +{ + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + QStringList details = configurationManager.getCodecDetails(payload); + this->payload = payload; + this->enabled = enabled; + this->name = details[CODEC_NAME]; + this->frequency = details[CODEC_SAMPLE_RATE]; + this->bitrate = details[CODEC_BIT_RATE]; + this->bandwidth = details[CODEC_BANDWIDTH]; +} + +QString Codec::getPayload() const +{ return payload; } +QString Codec::getName() const +{ return name; } +QString Codec::getFrequency() const +{ return frequency; } +QString Codec::getBitrate() const +{ return bitrate; } +QString Codec::getBandwidth() const +{ return bandwidth; } +bool Codec::isEnabled() const +{ return enabled; } + +void Codec::setPayload(QString payload) +{ this->payload = payload; } +void Codec::setName(QString name) +{ this->name = name; } +void Codec::setFrequency(QString frequency) +{ this->frequency = frequency; } +void Codec::setBitrate(QString bitrate) +{ this->bitrate = bitrate; } +void Codec::setBandwidth(QString bandwidth) +{ this->bandwidth = bandwidth; } +void Codec::setEnabled(bool enabled) +{ this->enabled = enabled; } + + diff --git a/sflphone-client-kde/src/Codec.h b/sflphone-client-kde/src/Codec.h new file mode 100644 index 0000000000000000000000000000000000000000..9a86d604d5a9a293cf7a1e9b2a9b59cd463d86e8 --- /dev/null +++ b/sflphone-client-kde/src/Codec.h @@ -0,0 +1,66 @@ +/*************************************************************************** + * 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 CODEC_H +#define CODEC_H + +#include <QObject> +#include <QtCore/QString> + +/** + @author Jérémy Quentin <jeremy.quentin@gmail.com> +*/ +class Codec : public QObject +{ +Q_OBJECT +private: + QString payload; + QString name; + QString frequency; + QString bitrate; + QString bandwidth; + bool enabled; + +public: + Codec(int payload, bool enabled); +// Codec(const Codec & codec); + +// ~Codec(); + + QString getPayload() const; + QString getName() const; + QString getFrequency() const; + QString getBitrate() const; + QString getBandwidth() const; + bool isEnabled() const; + + void setPayload(QString payload); + void setName(QString name); + void setFrequency(QString frequency); + void setBitrate(QString bitrate); + void setBandwidth(QString bandwidth); + void setEnabled(bool enabled); + + Codec & operator=(const Codec&); + + +}; + +#endif diff --git a/sflphone-client-kde/src/CodecListModel.cpp b/sflphone-client-kde/src/CodecListModel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..72e6f815f581cc295f37360bac5d8023586091a8 --- /dev/null +++ b/sflphone-client-kde/src/CodecListModel.cpp @@ -0,0 +1,257 @@ +/*************************************************************************** + * 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 "CodecListModel.h" + +#include <QtCore/QSize> +#include <QtCore/QDebug> +#include "configurationmanager_interface_singleton.h" + +CodecListModel::CodecListModel(QObject *parent) + : QAbstractTableModel(parent) +{ + this->codecs = QList<Codec *>(); + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); +// QStringList codecList = configurationManager.getCodecList(); + QStringList activeCodecList = configurationManager.getActiveCodecList(); + setActiveCodecList(activeCodecList); +// #if QT_VERSION >= 0x040500 +// activeCodecList.removeDuplicates(); +// #else +// for (int i = 0 ; i < activeCodecList.size() ; i++) +// { +// if(activeCodecList.lastIndexOf(activeCodecList[i]) != i || ! codecList.contains(activeCodecList[i])) +// { +// activeCodecList.removeAt(i); +// i--; +// } +// } +// #endif +// +// QStringList codecListToDisplay = activeCodecList; +// for (int i=0 ; i<codecList.size() ; i++) +// { +// if(! activeCodecList.contains(codecList[i])) +// { +// codecListToDisplay << codecList[i]; +// } +// } +// for(int i=0 ; i<codecListToDisplay.size() ; i++) +// { +// bool ok; +// qDebug() << codecListToDisplay[i]; +// QString payloadStr = QString(codecListToDisplay[i]); +// int payload = payloadStr.toInt(&ok); +// if(!ok) +// qDebug() << "The codec's payload sent by the configurationManager is not a number : " << codecListToDisplay[i]; +// else +// { +// codecs << new Codec(payload, activeCodecList.contains(codecListToDisplay[i])); +// } +// } + +} + + +CodecListModel::~CodecListModel() +{ +} + +// void CodecListModel::setCodecs(QList<Codec *> codecs) +// { +// this->codecs = QList<Codec *>(); +// this->codecs.append(new Codec(8,false)); +// } + + +QVariant CodecListModel::data ( const QModelIndex & index, int role) const +{ + if (!index.isValid()) + return QVariant(); + + const Codec * codec = codecs[index.row()]; + if(index.column() == 0 && role == Qt::DisplayRole) + { + return QVariant(codec->getName()); + } + else if(index.column() == 0 && role == Qt::CheckStateRole) + { + return QVariant(codec->isEnabled() ? Qt::Checked : Qt::Unchecked); + } + else if(index.column() == 1 && role == Qt::DisplayRole) + { + return QVariant(codec->getFrequency()); + } + else if(index.column() == 2 && role == Qt::DisplayRole) + { + return QVariant(codec->getBitrate()); + } + else if(index.column() == 3 && role == Qt::DisplayRole) + { + return QVariant(codec->getBandwidth()); + } + + return QVariant(); +} + + +int CodecListModel::rowCount(const QModelIndex & parent) const +{ + return codecs.count(); +} + +int CodecListModel::columnCount(const QModelIndex & parent) const +{ + return 4; +} + +// bool CodecListModel::insertRows(int position, int rows, const QModelIndex &parent) +// { +// beginInsertRows(QModelIndex(), position, position+rows-1); +// +// for (int row = 0; row < rows; ++row) { +// codecs.insert(position, new Codec("payload")); +// } +// +// endInsertRows(); +// return true; +// } + +QVariant CodecListModel::headerData(int section , Qt::Orientation orientation, int role) const +{ + if (section == 0 && orientation == Qt::Horizontal && role == Qt::DisplayRole) + { + return QVariant("Codec"); + } + else if (section == 1 && orientation == Qt::Horizontal && role == Qt::DisplayRole) + { + return QVariant("Frequency"); + } + else if (section == 2 && orientation == Qt::Horizontal && role == Qt::DisplayRole) + { + return QVariant("Bitrate"); + } + else if (section == 3 && orientation == Qt::Horizontal && role == Qt::DisplayRole) + { + return QVariant("Bandwidth"); + } + return QVariant(); +} + +Qt::ItemFlags CodecListModel::flags(const QModelIndex & index) const +{ + if (index.column() == 0) + { + return QAbstractItemModel::flags(index) | Qt::ItemIsUserCheckable; + } + return QAbstractItemModel::flags(index); +} + +bool CodecListModel::setData ( const QModelIndex & index, const QVariant &value, int role) +{ + qDebug() << "setData"; + if (index.isValid() && index.column() == 0 && role == Qt::CheckStateRole) { + codecs[index.row()]->setEnabled(value.toBool()); + emit dataChanged(index, index); + return true; + } + return false; +} + +bool CodecListModel::codecUp( int index ) +{ + if(index > 0 && index <= rowCount()) + { + codecs.swap(index - 1, index); + emit dataChanged(this->index(index - 1, 0, QModelIndex()), this->index(index, columnCount(), QModelIndex())); + return true; + } + return false; +} + +bool CodecListModel::codecDown( int index ) +{ + if(index >= 0 && index < rowCount()) + { + codecs.swap(index + 1, index); + emit dataChanged(this->index(index, 0, QModelIndex()), this->index(index + 1, columnCount(), QModelIndex())); + return true; + } + return false; +} + +QStringList CodecListModel::getActiveCodecList() const +{ + QStringList codecList; + for(int i = 0 ; i < rowCount() ; i++) + if(codecs[i]->isEnabled()) + codecList.append(codecs[i]->getPayload()); + return codecList; +} + +void CodecListModel::setActiveCodecList(const QStringList & activeCodecListToSet) +{ +// for(int i = 0 ; i < rowCount() ; i++) +// codecs[i]->setEnabled(activeCodecList.contains(codecs[i]->getPayload())); + + this->codecs = QList<Codec *>(); + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + QStringList codecList = configurationManager.getCodecList(); + QStringList activeCodecList = activeCodecListToSet; + #if QT_VERSION >= 0x040500 + activeCodecList.removeDuplicates(); + #else + for (int i = 0 ; i < activeCodecList.size() ; i++) + { + if(activeCodecList.lastIndexOf(activeCodecList[i]) != i || ! codecList.contains(activeCodecList[i])) + { + activeCodecList.removeAt(i); + i--; + } + } + #endif + + QStringList codecListToDisplay = activeCodecList; + for (int i=0 ; i<codecList.size() ; i++) + { + if(! activeCodecList.contains(codecList[i])) + { + codecListToDisplay << codecList[i]; + } + } + for(int i=0 ; i<codecListToDisplay.size() ; i++) + { + bool ok; + qDebug() << codecListToDisplay[i]; + QString payloadStr = QString(codecListToDisplay[i]); + int payload = payloadStr.toInt(&ok); + if(!ok) + qDebug() << "The codec's payload sent by the configurationManager is not a number : " << codecListToDisplay[i]; + else + { + codecs << new Codec(payload, activeCodecList.contains(codecListToDisplay[i])); + } + } + + + + + emit dataChanged(this->index(0, 0, QModelIndex()), this->index(rowCount(), columnCount(), QModelIndex())); +} \ No newline at end of file diff --git a/sflphone-client-kde/src/CodecListModel.h b/sflphone-client-kde/src/CodecListModel.h new file mode 100644 index 0000000000000000000000000000000000000000..d4881e81b7b724d1715dddbb6536db83ae82eed7 --- /dev/null +++ b/sflphone-client-kde/src/CodecListModel.h @@ -0,0 +1,57 @@ +/*************************************************************************** + * 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 CODECLISTMODEL_H +#define CODECLISTMODEL_H + +#include <QAbstractItemModel> +#include "Codec.h" + +/** + @author Jérémy Quentin <jeremy.quentin@gmail.com> +*/ +class CodecListModel : public QAbstractTableModel +{ +Q_OBJECT +private: + QList<Codec *> codecs; + +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); + + bool codecUp( int index ); + bool codecDown( int index ); + QStringList getActiveCodecList() const ; + void setActiveCodecList(const QStringList & activeCodecListToSet); + +}; + +#endif diff --git a/sflphone-client-kde/src/SortableCodecListWidget.cpp b/sflphone-client-kde/src/SortableCodecListWidget.cpp new file mode 100644 index 0000000000000000000000000000000000000000..352f736acb56fe99bcfcd66ec455bf8f15e1644f --- /dev/null +++ b/sflphone-client-kde/src/SortableCodecListWidget.cpp @@ -0,0 +1,174 @@ +/*************************************************************************** + * 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 "SortableCodecListWidget.h" + +#include "CodecListModel.h" +#include <QHBoxLayout> +#include <QVBoxLayout> +#include <QDebug> + +SortableCodecListWidget::SortableCodecListWidget(QWidget *parent) + : QWidget(parent) +{ + codecTable = new QTableView(this); + codecTable->setObjectName("codecTable"); + CodecListModel * model = new CodecListModel(); + codecTable->setModel(model); + codecTable->resizeColumnsToContents(); + codecTable->resizeRowsToContents(); + codecTable->setSelectionBehavior(QAbstractItemView::SelectRows); + + codecUpButton = new KPushButton(this); + codecUpButton->setObjectName("codecUpButton"); + codecUpButton->setIcon(KIcon("go-up")); + + codecDownButton = new KPushButton(this); + codecDownButton->setObjectName("codecDownButton"); + codecDownButton->setIcon(KIcon("go-down")); + + QHBoxLayout * mainLayout = new QHBoxLayout(this); + QVBoxLayout * buttonsLayout = new QVBoxLayout(this); + + buttonsLayout->addWidget(codecUpButton); + buttonsLayout->addWidget(codecDownButton); + + mainLayout->addWidget(codecTable); + mainLayout->addLayout(buttonsLayout); + + this->setLayout(mainLayout); + + QMetaObject::connectSlotsByName(this); +} + +void SortableCodecListWidget::on_codecTable_currentCellChanged(int currentRow) +{ + qDebug() << "on_codecTable_currentCellChanged"; +// int nbCol = codecTable->model()->columnCount(); +// for(int i = 0 ; i < nbCol ; i++) +// { +// codecTable->setRangeSelected(QTableWidgetSelectionRange(currentRow, 0, currentRow, nbCol - 1), true); +// } + updateCommands(); +} + +void SortableCodecListWidget::on_codecUpButton_clicked() +{ + qDebug() << "on_toolButton_codecUpButton_clicked"; + CodecListModel * model = (CodecListModel *) codecTable->model(); + int currentRow = selectedRow(); + model->codecUp(currentRow); + setSelectedRow(currentRow - 1); + +// int currentCol = codecTable->currentColumn(); +// int currentRow = codecTable->currentRow(); +// int nbCol = codecTable->columnCount(); +// for(int i = 0 ; i < nbCol ; i++) +// { +// QTableWidgetItem * item1 = tableWidget_codecs->takeItem(currentRow, i); +// QTableWidgetItem * item2 = tableWidget_codecs->takeItem(currentRow - 1, i); +// tableWidget_codecs->setItem(currentRow - 1, i , item1); +// tableWidget_codecs->setItem(currentRow, i , item2); +// } +// QTableWidgetItem * item1 = tableWidget_codecs->takeVerticalHeaderItem(currentRow); +// QTableWidgetItem * item2 = tableWidget_codecs->takeVerticalHeaderItem(currentRow - 1); +// tableWidget_codecs->setVerticalHeaderItem(currentRow - 1, item1); +// tableWidget_codecs->setVerticalHeaderItem(currentRow, item2); +// tableWidget_codecs->setCurrentCell(currentRow - 1, currentCol); +} + +void SortableCodecListWidget::on_codecDownButton_clicked() +{ + qDebug() << "on_codecDownButton_clicked"; + CodecListModel * model = (CodecListModel *) codecTable->model(); + int currentRow = selectedRow(); + model->codecDown(currentRow); + setSelectedRow(currentRow + 1); + +// int currentCol = tableWidget_codecs->currentColumn(); +// int currentRow = tableWidget_codecs->currentRow(); +// int nbCol = tableWidget_codecs->columnCount(); +// for(int i = 0 ; i < nbCol ; i++) +// { +// QTableWidgetItem * item1 = tableWidget_codecs->takeItem(currentRow, i); +// QTableWidgetItem * item2 = tableWidget_codecs->takeItem(currentRow + 1, i); +// tableWidget_codecs->setItem(currentRow + 1, i , item1); +// tableWidget_codecs->setItem(currentRow, i , item2); +// } +// QTableWidgetItem * item1 = tableWidget_codecs->takeVerticalHeaderItem(currentRow); +// QTableWidgetItem * item2 = tableWidget_codecs->takeVerticalHeaderItem(currentRow + 1); +// tableWidget_codecs->setVerticalHeaderItem(currentRow + 1, item1); +// tableWidget_codecs->setVerticalHeaderItem(currentRow, item2); +// tableWidget_codecs->setCurrentCell(currentRow + 1, currentCol); +} + +void SortableCodecListWidget::updateCommands() +{ + qDebug() << "SortableCodecListWidget::updateCommands"; + bool buttonsEnabled[2] = {true,true}; + if(selectedRow() == -1) + { + buttonsEnabled[0] = false; + buttonsEnabled[1] = false; + } + else + { + if(selectedRow() == 0) + { + buttonsEnabled[0] = false; + } + if(selectedRow() == codecTable->model()->rowCount() - 1) + { + buttonsEnabled[1] = false; + } + } + codecUpButton->setEnabled(buttonsEnabled[0]); + codecDownButton->setEnabled(buttonsEnabled[1]); +} + +QModelIndex SortableCodecListWidget::selectedIndex() +{ + QItemSelectionModel *selection = codecTable->selectionModel(); + const QModelIndexList selectedIndexes = selection->selectedIndexes(); + if ( !selectedIndexes.isEmpty() && selectedIndexes[0].isValid() ) + return selectedIndexes[0]; + else + return QModelIndex(); + } + +int SortableCodecListWidget::selectedRow() +{ + QModelIndex index = selectedIndex(); + if(index.isValid()) + return index.row(); + else + return -1; +} + +void SortableCodecListWidget::setSelectedRow(int row) +{ + QItemSelectionModel * selection = codecTable->selectionModel(); + QAbstractItemModel * model = codecTable->model(); + QItemSelection newSelection = QItemSelection(model->index(row, 0, QModelIndex()), model->index(row, model->columnCount(), QModelIndex())); + selection->clear(); +// selection->select(newSelection , QItemSelectionModel::Select); + selection->select(model->index(row, model->columnCount()-1, QModelIndex()) , QItemSelectionModel::Select); +// listView->selectionModel()->select(belowIndex, QItemSelectionModel::Select); +} \ No newline at end of file diff --git a/sflphone-client-kde/src/SortableCodecListWidget.h b/sflphone-client-kde/src/SortableCodecListWidget.h new file mode 100644 index 0000000000000000000000000000000000000000..92105e71c42c8bf7388edce67a8865d7b038e7fa --- /dev/null +++ b/sflphone-client-kde/src/SortableCodecListWidget.h @@ -0,0 +1,58 @@ +/*************************************************************************** + * 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 SORTABLECODECLISTWIDGET_H +#define SORTABLECODECLISTWIDGET_H + +#include <QWidget> +#include <KPushButton> +#include <QTableView> + +/** + @author Jérémy Quentin <jeremy.quentin@gmail.com> +*/ +class SortableCodecListWidget : public QWidget +{ +Q_OBJECT +private: + KPushButton * codecUpButton; + KPushButton * codecDownButton; + QTableView * codecTable; + +public: + SortableCodecListWidget(QWidget *parent = 0); + +private slots: + void on_codecTable_currentCellChanged(int currentRow); + void on_codecUpButton_clicked(); + void on_codecDownButton_clicked(); + +public slots: + void updateCommands(); + +private: + QModelIndex selectedIndex(); + int selectedRow(); + + void setSelectedRow(int row); + +}; + +#endif diff --git a/sflphone-client-kde/src/conf/ConfigurationSkeleton.cpp b/sflphone-client-kde/src/conf/ConfigurationSkeleton.cpp index e6f89cdd33ebc64d95def2231e93725d69c011fe..3f5e19935e30ba50730605a622cd1f3ea6a0b0b4 100644 --- a/sflphone-client-kde/src/conf/ConfigurationSkeleton.cpp +++ b/sflphone-client-kde/src/conf/ConfigurationSkeleton.cpp @@ -26,9 +26,10 @@ ConfigurationSkeleton::ConfigurationSkeleton() : ConfigurationSkeletonBase() { - qDebug() << "Yoooooooouuuuupppppppiiiiii"; + qDebug() << "Building ConfigurationSkeleton"; + codecList = new CodecListModel(); readConfig(); - isImmutable( QString::fromLatin1 ( "alsaPlugin" ) ); + } ConfigurationSkeleton * ConfigurationSkeleton::instance = NULL; @@ -285,4 +286,12 @@ void ConfigurationSkeleton::writeConfig() readConfig(); } +QStringList ConfigurationSkeleton::activeCodecList() const +{ + codecList->getActiveCodecList(); +} +void ConfigurationSkeleton::setActiveCodecList(const QStringList & v) +{ + codecList->setActiveCodecList(v); +} diff --git a/sflphone-client-kde/src/conf/ConfigurationSkeleton.h b/sflphone-client-kde/src/conf/ConfigurationSkeleton.h index a7f31d68b405aac9198aba9312aa939291bebc32..73160c3d3280955755a1c64e8a677201ea3adf96 100644 --- a/sflphone-client-kde/src/conf/ConfigurationSkeleton.h +++ b/sflphone-client-kde/src/conf/ConfigurationSkeleton.h @@ -24,6 +24,7 @@ #include <QWidget> #include "kcfg_settings.h" +#include "CodecListModel.h" /** @author Jérémy Quentin <jeremy.quentin@gmail.com> @@ -34,6 +35,8 @@ Q_OBJECT private: static ConfigurationSkeleton * instance; + + CodecListModel * codecList; public: ConfigurationSkeleton(); @@ -47,6 +50,8 @@ public: static ConfigurationSkeleton * self(); + QStringList activeCodecList() const; + void setActiveCodecList(const QStringList & v); // protected: diff --git a/sflphone-client-kde/src/conf/dlgaudio.cpp b/sflphone-client-kde/src/conf/dlgaudio.cpp index 0700c61bfb418e8ea04748dbbd78a302157c8f5d..449da93d6a38acab3d91c2c73649ba238b9160f9 100644 --- a/sflphone-client-kde/src/conf/dlgaudio.cpp +++ b/sflphone-client-kde/src/conf/dlgaudio.cpp @@ -76,9 +76,16 @@ void DlgAudio::updateWidgets() ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); QStringList codecList = configurationManager.getCodecList(); QStringList activeCodecList = skeleton->activeCodecList(); + + qDebug() << "loadCodecs1"; #if QT_VERSION >= 0x040500 + qDebug() << "loadCodecs1b"; activeCodecList.removeDuplicates(); + + qDebug() << "loadCodecs1c"; #else + + qDebug() << "loadCodecs1d"; for (int i = 0 ; i < activeCodecList.size() ; i++) { if(activeCodecList.lastIndexOf(activeCodecList[i]) != i || ! codecList.contains(activeCodecList[i])) @@ -87,16 +94,29 @@ void DlgAudio::updateWidgets() i--; } } + + qDebug() << "loadCodecs1e"; #endif - + + qDebug() << "loadCodecs2"; QStringList codecListToDisplay = activeCodecList; + qDebug() << "loadCodecs2b"; + codecList.size(); + + qDebug() << "loadCodecs2c"; for (int i=0 ; i<codecList.size() ; i++) { + + qDebug() << "loadCodecs3"; if(! activeCodecList.contains(codecList[i])) { + + qDebug() << "loadCodecs4"; codecListToDisplay << codecList[i]; } } + + qDebug() << "loadCodecs5"; qDebug() << "codecList = " << codecList; qDebug() << "activeCodecList" << activeCodecList; qDebug() << "codecListToDisplay" << codecListToDisplay; diff --git a/sflphone-client-kde/src/conf/sflphone-client-kde.kcfg b/sflphone-client-kde/src/conf/sflphone-client-kde.kcfg index c90d937a82b9467862627d82d0798fc2287ed8e0..f8b904e1e64a15c65218d7991c177680ce9435fb 100644 --- a/sflphone-client-kde/src/conf/sflphone-client-kde.kcfg +++ b/sflphone-client-kde/src/conf/sflphone-client-kde.kcfg @@ -54,9 +54,11 @@ <entry name="ringtone" type="Path"> <label>Defines which ringtone is used.</label> </entry> + <!-- <entry name="activeCodecList" type="StringList"> <label>Defines which ALSA plugin to use.</label> </entry> + --> <entry name="alsaPlugin" type="String"> <label>Defines which ALSA plugin to use.</label> </entry> diff --git a/sflphone-client-kde/src/main.cpp b/sflphone-client-kde/src/main.cpp index 23853b339751d74b5fcc37be72497c252f6a15aa..75e6b85c140e5c074ffda6b6f770177c7d4f138d 100644 --- a/sflphone-client-kde/src/main.cpp +++ b/sflphone-client-kde/src/main.cpp @@ -16,6 +16,11 @@ #include "conf/ConfigurationDialog.h" +#include <QTableView> +#include <QListView> +#include "CodecListModel.h" +#include "SortableCodecListWidget.h" + static const char description[] = "A KDE 4 Client for SFLphone"; @@ -55,6 +60,18 @@ int main(int argc, char **argv) InstanceInterface & instance = InstanceInterfaceSingleton::getInstance(); instance.Register(getpid(), APP_NAME); + +// QTableView * table = new QTableView(); +// QListView * table = new QListView(); +// CodecListModel * model = new CodecListModel(); +// model->setCodecs(QList<Codec * >()); +// table->setModel(model); +// table->resizeColumnsToContents(); +// table->resizeRowsToContents(); +// table->show(); +// model->setActiveCodecList(QStringList("8")); +// SortableCodecListWidget * cl = new SortableCodecListWidget(); +// cl->show(); return app.exec(); }