codeclistmodel + asynchronous loading of address book + enable/disable address book

This commit is contained in:
Jérémy Quentin
2009-07-09 19:56:47 -04:00
parent 1a92099638
commit 3aaf3fefc0
22 changed files with 1238 additions and 1134 deletions

File diff suppressed because it is too large Load Diff

View File

@ -27,7 +27,7 @@ Codec::Codec(int payload, bool enabled)
{
ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance();
QStringList details = configurationManager.getCodecDetails(payload);
this->payload = payload;
this->payload = QString::number(payload);
this->enabled = enabled;
this->name = details[CODEC_NAME];
this->frequency = details[CODEC_SAMPLE_RATE];

View File

@ -29,44 +29,8 @@ CodecListModel::CodecListModel(QObject *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]));
// }
// }
}
@ -74,12 +38,6 @@ 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
{
@ -122,17 +80,6 @@ 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
{
@ -177,10 +124,13 @@ 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;
@ -201,16 +151,15 @@ 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();
@ -249,9 +198,6 @@ void CodecListModel::setActiveCodecList(const QStringList & activeCodecListToSet
codecs << new Codec(payload, activeCodecList.contains(codecListToDisplay[i]));
}
}
emit dataChanged(this->index(0, 0, QModelIndex()), this->index(rowCount(), columnCount(), QModelIndex()));
}
}

View File

@ -51,7 +51,9 @@ public:
bool codecDown( int index );
QStringList getActiveCodecList() const ;
void setActiveCodecList(const QStringList & activeCodecListToSet);
signals:
void dataChanged(const QModelIndex &, const QModelIndex &);
};
#endif

View File

@ -20,7 +20,6 @@
***************************************************************************/
#include "SortableCodecListWidget.h"
#include "CodecListModel.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QDebug>
@ -30,10 +29,10 @@ SortableCodecListWidget::SortableCodecListWidget(QWidget *parent)
{
codecTable = new QTableView(this);
codecTable->setObjectName("codecTable");
CodecListModel * model = new CodecListModel();
codecTable->setModel(model);
codecTable->resizeColumnsToContents();
codecTable->resizeRowsToContents();
// CodecListModel * model = new CodecListModel();
// codecTable->setModel(model);
// codecTable->resizeColumnsToContents();
// codecTable->resizeRowsToContents();
codecTable->setSelectionBehavior(QAbstractItemView::SelectRows);
codecUpButton = new KPushButton(this);
@ -45,7 +44,7 @@ SortableCodecListWidget::SortableCodecListWidget(QWidget *parent)
codecDownButton->setIcon(KIcon("go-down"));
QHBoxLayout * mainLayout = new QHBoxLayout(this);
QVBoxLayout * buttonsLayout = new QVBoxLayout(this);
QVBoxLayout * buttonsLayout = new QVBoxLayout();
buttonsLayout->addWidget(codecUpButton);
buttonsLayout->addWidget(codecDownButton);
@ -53,20 +52,23 @@ SortableCodecListWidget::SortableCodecListWidget(QWidget *parent)
mainLayout->addWidget(codecTable);
mainLayout->addLayout(buttonsLayout);
this->setLayout(mainLayout);
QMetaObject::connectSlotsByName(this);
}
void SortableCodecListWidget::on_codecTable_currentCellChanged(int currentRow)
void SortableCodecListWidget::setModel(CodecListModel * model)
{
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();
codecTable->setModel(model);
codecTable->resizeColumnsToContents();
codecTable->resizeRowsToContents();
connect(codecTable->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
this, SLOT(updateCommands()));
connect(codecTable->model(), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)),
this, SIGNAL(dataChanged()));
}
CodecListModel * SortableCodecListWidget::model()
{
return (CodecListModel *) codecTable->model();
}
void SortableCodecListWidget::on_codecUpButton_clicked()
@ -76,22 +78,6 @@ void SortableCodecListWidget::on_codecUpButton_clicked()
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()
@ -101,22 +87,6 @@ void SortableCodecListWidget::on_codecDownButton_clicked()
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()
@ -166,9 +136,10 @@ 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()));
QItemSelection newSelection = QItemSelection(model->index(row, 0, QModelIndex()), model->index(row +1 , 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);
for(int i = 0 ; i < model->columnCount() ; i++)
{
selection->select(model->index(row, i, QModelIndex()) , QItemSelectionModel::Select);
}
}

View File

@ -24,6 +24,7 @@
#include <QWidget>
#include <KPushButton>
#include <QTableView>
#include "CodecListModel.h"
/**
@author Jérémy Quentin <jeremy.quentin@gmail.com>
@ -39,8 +40,10 @@ private:
public:
SortableCodecListWidget(QWidget *parent = 0);
virtual void setModel(CodecListModel * model);
virtual CodecListModel * model();
private slots:
void on_codecTable_currentCellChanged(int currentRow);
void on_codecUpButton_clicked();
void on_codecDownButton_clicked();
@ -52,6 +55,9 @@ private:
int selectedRow();
void setSelectedRow(int row);
signals:
void dataChanged();
};

View File

@ -102,12 +102,14 @@ void ConfigurationDialogKDE::updateButtons()
void ConfigurationDialogKDE::applyCustomSettings()
{
qDebug() << "applyCustomSettings";
dlgAccounts->applyCustomSettings();
// if(hasChanged())
// {
ConfigurationSkeleton::self()->writeConfig();
// }
dlgAccounts->applyCustomSettings();
dlgAudio->applyCustomSettings();
updateButtons();
emit changesApplied();
}
void ConfigurationDialogKDE::reload()
@ -115,5 +117,6 @@ void ConfigurationDialogKDE::reload()
qDebug() << "reload";
ConfigurationSkeleton::self()->readConfig();
updateWidgets();
applyCustomSettings();
updateButtons();
}

View File

@ -103,6 +103,7 @@ private slots:
signals:
void clearCallHistoryAsked();
void changesApplied();
};

View File

@ -27,7 +27,7 @@ ConfigurationSkeleton::ConfigurationSkeleton()
: ConfigurationSkeletonBase()
{
qDebug() << "Building ConfigurationSkeleton";
codecList = new CodecListModel();
codecListModel = new CodecListModel();
readConfig();
}
@ -46,6 +46,11 @@ ConfigurationSkeleton::~ConfigurationSkeleton()
{
}
CodecListModel * ConfigurationSkeleton::getCodecListModel()
{
return codecListModel;
}
void ConfigurationSkeleton::readConfig()
{
qDebug() << "\nReading config";
@ -152,6 +157,7 @@ void ConfigurationSkeleton::readConfig()
MapStringInt addressBookSettings = configurationManager.getAddressbookSettings().value();
qDebug() << "getAddressbookSettings() : " << addressBookSettings;
setEnableAddressBook(addressBookSettings[ADDRESSBOOK_ENABLE]);
setMaxResults(addressBookSettings[ADDRESSBOOK_MAX_RESULTS]);
setDisplayPhoto(addressBookSettings[ADDRESSBOOK_DISPLAY_CONTACT_PHOTO]);
setBusiness(addressBookSettings[ADDRESSBOOK_DISPLAY_BUSINESS]);
@ -182,6 +188,8 @@ void ConfigurationSkeleton::writeConfig()
////General settings////
////////////////////////
qDebug() << "Writing General settings";
//Call history settings
if(enableHistory() != configurationManager.getHistoryEnabled()) configurationManager.setHistoryEnabled();
configurationManager.setHistoryLimit(historyMax());
@ -193,6 +201,8 @@ void ConfigurationSkeleton::writeConfig()
////Display settings////
////////////////////////
qDebug() << "Writing Display settings";
//Notification settings
if(notifOnCalls() != configurationManager.getNotify()) configurationManager.setNotify();
if(notifOnMessages() != configurationManager.getMailNotify()) configurationManager.setMailNotify();
@ -206,6 +216,8 @@ void ConfigurationSkeleton::writeConfig()
////Accounts settings////
/////////////////////////
qDebug() << "Writing Accounts settings";
// saveAccountList();
@ -217,6 +229,8 @@ void ConfigurationSkeleton::writeConfig()
////Audio settings////
//////////////////////
qDebug() << "Writing Audio settings";
//Audio Interface settings
int prevManager = configurationManager.getAudioManager();
int newManager = interface();
@ -230,6 +244,7 @@ void ConfigurationSkeleton::writeConfig()
configurationManager.setRingtoneChoice(ringtone());
//codecs settings
qDebug() << "activeCodecList = " << activeCodecList();
configurationManager.setActiveCodecList(activeCodecList());
@ -253,6 +268,8 @@ void ConfigurationSkeleton::writeConfig()
////Record settings////
///////////////////////
qDebug() << "Writing Record settings";
QString destination = destinationFolder();
qDebug() << destination ;
configurationManager.setRecordPath(destination);
@ -262,7 +279,10 @@ void ConfigurationSkeleton::writeConfig()
////Address Book settings////
/////////////////////////////
qDebug() << "Writing Address Book settings";
MapStringInt addressBookSettings = MapStringInt();
addressBookSettings[ADDRESSBOOK_ENABLE] = enableAddressBook();
addressBookSettings[ADDRESSBOOK_MAX_RESULTS] = maxResults();
addressBookSettings[ADDRESSBOOK_DISPLAY_CONTACT_PHOTO] = displayPhoto();
addressBookSettings[ADDRESSBOOK_DISPLAY_BUSINESS] = business();
@ -274,6 +294,8 @@ void ConfigurationSkeleton::writeConfig()
///////Hooks settings////////
/////////////////////////////
qDebug() << "Writing Hooks settings";
MapStringString hooksSettings = MapStringString();
hooksSettings[HOOKS_ENABLED] = addPrefix() ? "1" : "0";
hooksSettings[HOOKS_ADD_PREFIX] = prepend();
@ -288,10 +310,10 @@ void ConfigurationSkeleton::writeConfig()
QStringList ConfigurationSkeleton::activeCodecList() const
{
codecList->getActiveCodecList();
return codecListModel->getActiveCodecList();
}
void ConfigurationSkeleton::setActiveCodecList(const QStringList & v)
{
codecList->setActiveCodecList(v);
codecListModel->setActiveCodecList(v);
}

View File

@ -36,7 +36,7 @@ Q_OBJECT
private:
static ConfigurationSkeleton * instance;
CodecListModel * codecList;
CodecListModel * codecListModel;
public:
ConfigurationSkeleton();
@ -53,6 +53,8 @@ public:
QStringList activeCodecList() const;
void setActiveCodecList(const QStringList & v);
CodecListModel * getCodecListModel();
// protected:
// virtual void usrReadConfig();

View File

@ -296,7 +296,7 @@ void DlgAccounts::on_toolButton_accountsApply_clicked()
void DlgAccounts::applyCustomSettings()
{
qDebug() << "applyCustomSettings";
qDebug() << "DlgAccounts::applyCustomSettings";
if(hasChanged())
{
toolButton_accountsApply->setEnabled(false);

View File

@ -14,16 +14,38 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="kcfg_enableAddressBook">
<property name="text">
<string>Enable address book</string>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_configAddressBookGeneral" native="true">
<property name="enabled">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="widget_maxResults" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="spacing">
<number>-1</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
@ -68,34 +90,34 @@
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_displayTypes">
<property name="title">
<string>Display phone numbers of these &amp;types :</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QCheckBox" name="kcfg_business">
<property name="text">
<string>&amp;Work</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_mobile">
<property name="text">
<string>&amp;Mobile</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_home">
<property name="text">
<string>&amp;Home</string>
<widget class="QGroupBox" name="groupBox_displayTypes">
<property name="title">
<string>Display phone numbers of these &amp;types :</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QCheckBox" name="kcfg_business">
<property name="text">
<string>&amp;Work</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_mobile">
<property name="text">
<string>&amp;Mobile</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_home">
<property name="text">
<string>&amp;Home</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
@ -132,12 +154,12 @@
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel">
<x>223</x>
<y>35</y>
<x>265</x>
<y>67</y>
</hint>
<hint type="destinationlabel">
<x>301</x>
<y>33</y>
<x>326</x>
<y>70</y>
</hint>
</hints>
</connection>
@ -148,12 +170,28 @@
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel">
<x>294</x>
<y>36</y>
<x>326</x>
<y>70</y>
</hint>
<hint type="destinationlabel">
<x>215</x>
<y>33</y>
<x>265</x>
<y>67</y>
</hint>
</hints>
</connection>
<connection>
<sender>kcfg_enableAddressBook</sender>
<signal>toggled(bool)</signal>
<receiver>widget_configAddressBookGeneral</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>92</x>
<y>25</y>
</hint>
<hint type="destinationlabel">
<x>91</x>
<y>39</y>
</hint>
</hints>
</connection>

View File

@ -38,25 +38,33 @@ DlgAudio::DlgAudio(KConfigDialog *parent)
KUrlRequester_ringtone->lineEdit()->setReadOnly(true);
codecTableHasChanged = false;
toolButton_codecUp->setIcon(KIcon("go-up"));
toolButton_codecDown->setIcon(KIcon("go-down"));
tableWidget_codecs->verticalHeader()->hide();
tableWidget_codecs->setSelectionBehavior(QAbstractItemView::SelectRows);
// toolButton_codecUp->setIcon(KIcon("go-up"));
// toolButton_codecDown->setIcon(KIcon("go-down"));
// tableWidget_codecs->verticalHeader()->hide();
// tableWidget_codecs->setSelectionBehavior(QAbstractItemView::SelectRows);
ConfigurationSkeleton * skeleton = ConfigurationSkeleton::self();
CodecListModel * model = skeleton->getCodecListModel();
sortableCodecList->setModel(model);
updateAlsaSettings();
connect(box_alsaPlugin, SIGNAL(currentIndexChanged(int)),
parent, SLOT(updateButtons()));
connect(tableWidget_codecs, SIGNAL(itemChanged(QTableWidgetItem *)),
this, SLOT(codecTableChanged()));
connect(tableWidget_codecs, SIGNAL(currentCellChanged(int, int, int, int)),
this, SLOT(updateCodecListCommands()));
connect(toolButton_codecUp, SIGNAL(clicked()),
this, SLOT(codecTableChanged()));
connect(toolButton_codecDown, SIGNAL(clicked()),
this, SLOT(codecTableChanged()));
// connect(tableWidget_codecs, SIGNAL(itemChanged(QTableWidgetItem *)),
// this, SLOT(codecTableChanged()));
// connect(tableWidget_codecs, SIGNAL(currentCellChanged(int, int, int, int)),
// this, SLOT(updateCodecListCommands()));
// connect(toolButton_codecUp, SIGNAL(clicked()),
// this, SLOT(codecTableChanged()));
// connect(toolButton_codecDown, SIGNAL(clicked()),
// this, SLOT(codecTableChanged()));
connect(this, SIGNAL(updateButtons()),
parent, SLOT(updateButtons()));
connect(sortableCodecList, SIGNAL(dataChanged()),
this, SLOT(codecTableChanged()));
}
@ -72,108 +80,108 @@ void DlgAudio::updateWidgets()
box_alsaPlugin->setCurrentIndex(box_alsaPlugin->findText(skeleton->alsaPlugin()));
//codecList
qDebug() << "loadCodecs";
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]))
{
activeCodecList.removeAt(i);
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;
tableWidget_codecs->setRowCount(0);
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
{
QStringList details = configurationManager.getCodecDetails(payload);
tableWidget_codecs->insertRow(i);
tableWidget_codecs->setVerticalHeaderItem (i, new QTableWidgetItem());
tableWidget_codecs->verticalHeaderItem (i)->setText(payloadStr);
tableWidget_codecs->setItem(i,0,new QTableWidgetItem(""));
tableWidget_codecs->setItem(i,1,new QTableWidgetItem(details[CODEC_NAME]));
tableWidget_codecs->setItem(i,2,new QTableWidgetItem(details[CODEC_SAMPLE_RATE]));
tableWidget_codecs->setItem(i,3,new QTableWidgetItem(details[CODEC_BIT_RATE]));
tableWidget_codecs->setItem(i,4,new QTableWidgetItem(details[CODEC_BANDWIDTH]));
tableWidget_codecs->item(i,0)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled);
tableWidget_codecs->item(i,0)->setCheckState(activeCodecList.contains(codecListToDisplay[i]) ? Qt::Checked : Qt::Unchecked);
tableWidget_codecs->item(i,1)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
tableWidget_codecs->item(i,2)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
tableWidget_codecs->item(i,3)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
tableWidget_codecs->item(i,4)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
qDebug() << "Added to codecs : " << payloadStr << " , " << details[CODEC_NAME];
}
}
tableWidget_codecs->resizeColumnsToContents();
tableWidget_codecs->resizeRowsToContents();
// qDebug() << "loadCodecs";
// 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]))
// {
// activeCodecList.removeAt(i);
// 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;
// tableWidget_codecs->setRowCount(0);
// 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
// {
// QStringList details = configurationManager.getCodecDetails(payload);
// tableWidget_codecs->insertRow(i);
// tableWidget_codecs->setVerticalHeaderItem (i, new QTableWidgetItem());
// tableWidget_codecs->verticalHeaderItem (i)->setText(payloadStr);
// tableWidget_codecs->setItem(i,0,new QTableWidgetItem(""));
// tableWidget_codecs->setItem(i,1,new QTableWidgetItem(details[CODEC_NAME]));
// tableWidget_codecs->setItem(i,2,new QTableWidgetItem(details[CODEC_SAMPLE_RATE]));
// tableWidget_codecs->setItem(i,3,new QTableWidgetItem(details[CODEC_BIT_RATE]));
// tableWidget_codecs->setItem(i,4,new QTableWidgetItem(details[CODEC_BANDWIDTH]));
// tableWidget_codecs->item(i,0)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled);
// tableWidget_codecs->item(i,0)->setCheckState(activeCodecList.contains(codecListToDisplay[i]) ? Qt::Checked : Qt::Unchecked);
// tableWidget_codecs->item(i,1)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
// tableWidget_codecs->item(i,2)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
// tableWidget_codecs->item(i,3)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
// tableWidget_codecs->item(i,4)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
//
// qDebug() << "Added to codecs : " << payloadStr << " , " << details[CODEC_NAME];
// }
// }
// tableWidget_codecs->resizeColumnsToContents();
// tableWidget_codecs->resizeRowsToContents();
codecTableHasChanged = false;
}
void DlgAudio::updateSettings()
{
// qDebug() << "DlgAudio::updateSettings";
qDebug() << "DlgAudio::updateSettings";
//alsaPlugin
ConfigurationSkeleton * skeleton = ConfigurationSkeleton::self();
skeleton->setAlsaPlugin(box_alsaPlugin->currentText());
//codecList
QStringList activeCodecs;
for(int i = 0 ; i < tableWidget_codecs->rowCount() ; i++)
{
if(tableWidget_codecs->item(i,0)->checkState() == Qt::Checked)
{
activeCodecs << tableWidget_codecs->verticalHeaderItem(i)->text();
}
}
qDebug() << "Calling setActiveCodecList with list : " << activeCodecs ;
skeleton->setActiveCodecList(activeCodecs);
// QStringList activeCodecs;
// for(int i = 0 ; i < tableWidget_codecs->rowCount() ; i++)
// {
// if(tableWidget_codecs->item(i,0)->checkState() == Qt::Checked)
// {
// activeCodecs << tableWidget_codecs->verticalHeaderItem(i)->text();
// }
// }
// qDebug() << "Calling setActiveCodecList with list : " << activeCodecs ;
// skeleton->setActiveCodecList(activeCodecs);
codecTableHasChanged = false;
}
@ -225,69 +233,75 @@ void DlgAudio::updateAlsaSettings()
}
}
void DlgAudio::updateCodecListCommands()
{
qDebug() << "updateCodecListCommands";
bool buttonsEnabled[2] = {true,true};
if(! tableWidget_codecs->currentItem())
{
buttonsEnabled[0] = false;
buttonsEnabled[1] = false;
}
else
{
if(tableWidget_codecs->currentRow() == 0)
{
buttonsEnabled[0] = false;
}
if(tableWidget_codecs->currentRow() == tableWidget_codecs->rowCount() - 1)
{
buttonsEnabled[1] = false;
}
}
toolButton_codecUp->setEnabled(buttonsEnabled[0]);
toolButton_codecDown->setEnabled(buttonsEnabled[1]);
}
// void DlgAudio::updateCodecListCommands()
// {
// qDebug() << "updateCodecListCommands";
// bool buttonsEnabled[2] = {true,true};
// if(! tableWidget_codecs->currentItem())
// {
// buttonsEnabled[0] = false;
// buttonsEnabled[1] = false;
// }
// else
// {
// if(tableWidget_codecs->currentRow() == 0)
// {
// buttonsEnabled[0] = false;
// }
// if(tableWidget_codecs->currentRow() == tableWidget_codecs->rowCount() - 1)
// {
// buttonsEnabled[1] = false;
// }
// }
// toolButton_codecUp->setEnabled(buttonsEnabled[0]);
// toolButton_codecDown->setEnabled(buttonsEnabled[1]);
// }
void DlgAudio::on_toolButton_codecUp_clicked()
{
qDebug() << "on_toolButton_codecUp_clicked";
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 DlgAudio::on_toolButton_codecUp_clicked()
// {
// qDebug() << "on_toolButton_codecUp_clicked";
// 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 DlgAudio::on_toolButton_codecDown_clicked()
// {
// qDebug() << "on_toolButton_codecDown_clicked";
// 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 DlgAudio::on_toolButton_codecDown_clicked()
void DlgAudio::applyCustomSettings()
{
qDebug() << "on_toolButton_codecDown_clicked";
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);
codecTableHasChanged = false;
}

View File

@ -46,11 +46,12 @@ public slots:
void updateSettings();
bool hasChanged();
void updateAlsaSettings();
void applyCustomSettings();
private slots:
void updateCodecListCommands();
void on_toolButton_codecUp_clicked();
void on_toolButton_codecDown_clicked();
// void updateCodecListCommands();
// void on_toolButton_codecUp_clicked();
// void on_toolButton_codecDown_clicked();
void codecTableChanged();
signals:

View File

@ -95,87 +95,7 @@
<number>2</number>
</property>
<item>
<widget class="QTableWidget" name="tableWidget_codecs">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>100</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="textElideMode">
<enum>Qt::ElideRight</enum>
</property>
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
<property name="horizontalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
<column>
<property name="text">
<string>Active</string>
</property>
</column>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Frequency</string>
</property>
</column>
<column>
<property name="text">
<string>Bitrate</string>
</property>
</column>
<column>
<property name="text">
<string>Bandwidth</string>
</property>
</column>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_codecsOrder">
<property name="leftMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="toolButton_codecUp">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_codecDown">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
<widget class="SortableCodecListWidget" name="sortableCodecList" native="true"/>
</item>
</layout>
</widget>
@ -311,6 +231,12 @@
<extends>QFrame</extends>
<header>kurlrequester.h</header>
</customwidget>
<customwidget>
<class>SortableCodecListWidget</class>
<extends>QWidget</extends>
<header>SortableCodecListWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>

View File

@ -29,6 +29,7 @@ DlgRecord::DlgRecord(QWidget *parent)
KUrlRequester_destinationFolder->setMode(KFile::Directory|KFile::ExistingOnly|KFile::LocalOnly);
KUrlRequester_destinationFolder->setUrl(KUrl(QDir::home().path()));
KUrlRequester_destinationFolder->lineEdit()->setObjectName("kcfg_destinationFolder");
KUrlRequester_destinationFolder->lineEdit()->setReadOnly(true);
}

View File

@ -2,7 +2,10 @@
<!DOCTYPE kcfg SYSTEM "http://www.kde.org/standards/kcfg/1.0/kcfg.dtd">
<kcfg>
<kcfgfile name="ConfigDialogKDE" />
<group name="main">
<group name="main">
<!-- General Settings -->
<entry name="SIPPort" type="Int">
<label>Defines the port that will be used for SIP communication.</label>
<min> 1025 </min>
@ -18,6 +21,9 @@
<max> 99 </max>
<default> 30 </default>
</entry>
<!-- Display Settings -->
<entry name="notifOnCalls" type="Bool">
<label>Defines whether user should be notified when receiving a call.</label>
</entry>
@ -30,6 +36,9 @@
<entry name="displayOnCalls" type="Bool">
<label>Defines whether the main window should be displayed when receiving a message.</label>
</entry>
<!-- Accounts Settings -->
<!--
<entry name="accountList" type="StringList">
<label>Defines the list of accounts to register, in order of preference (first registered used by default).</label>
@ -41,6 +50,9 @@
<entry name="stunServer" type="String">
<label>Defines the Stun server to use.</label>
</entry>
<!-- Audio Settings -->
<entry name="interface" type="Enum">
<label>Defines the Stun server to use.</label>
<choices>
@ -71,6 +83,12 @@
<entry name="pulseAudioVolumeAlter" type="Bool">
<label>Defines whether pulse audio can mute other applications during a call.</label>
</entry>
<!-- Address Book Settings -->
<entry name="enableAddressBook" type="Bool">
<label>Defines whether the search in KDE Address Book is enabled</label>
</entry>
<entry name="maxResults" type="Int">
<label>Defines the max number of contacts to display during a search in address book.</label>
</entry>
@ -86,9 +104,15 @@
<entry name="home" type="Bool">
<label>Defines whether to display personnal phone numbers.</label>
</entry>
<!-- Record Settings -->
<entry name="destinationFolder" type="Path">
<label>Defines the destination directory for call recordings.</label>
</entry>
<!-- Hooks Settings -->
<entry name="enableHooksSIP" type="Bool">
<label>Defines whether to enable hooks for SIP accounts.</label>
</entry>

View File

@ -55,21 +55,11 @@ int main(int argc, char **argv)
//configuration dbus
registerCommTypes();
SFLPhone * fenetre = new SFLPhone();
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();

View File

@ -184,6 +184,7 @@
#define ADDRESSBOOK_DISPLAY_BUSINESS "ADDRESSBOOK_DISPLAY_PHONE_BUSINESS"
#define ADDRESSBOOK_DISPLAY_HOME "ADDRESSBOOK_DISPLAY_PHONE_HOME"
#define ADDRESSBOOK_DISPLAY_MOBILE "ADDRESSBOOK_DISPLAY_PHONE_MOBILE"
#define ADDRESSBOOK_ENABLE "ADDRESSBOOK_ENABLE"
/** Hooks settings */
#define HOOKS_ADD_PREFIX "PHONE_NUMBER_HOOK_ADD_PREFIX"
@ -208,38 +209,4 @@
/** Error while opening capture device */
#define ALSA_CAPTURE_DEVICE 0x0001
/** Error while opening playback device */
#define ALSA_PLAYBACK_DEVICE 0x0010
/** Error pulseaudio */
#define PULSEAUDIO_NOT_RUNNING 0x0100
/** Tone to play when no voice mails */
#define TONE_WITHOUT_MESSAGE 0
/** Tone to play when voice mails */
#define TONE_WITH_MESSAGE 1
/** Notification levels */
#define __NOTIF_LEVEL_MIN 0
#define __NOTIF_LEVEL_MED 1
#define __NOTIF_LEVEL_HIGH 2
/** Messages ID for the status bar - Incoming calls */
#define __MSG_INCOMING_CALL 0
/** Messages ID for the status bar - Calling */
#define __MSG_CALLING 1
/** Messages ID for the status bar - Voice mails notification */
#define __MSG_VOICE_MAILS 2
/** Messages ID for the status bar - Current account */
#define __MSG_ACCOUNT_DEFAULT 3
/** Desktop notifications - Time before to close the notification*/
#define __TIMEOUT_MODE "default"
/** Desktop notifications - Time before to close the notification*/
#define __TIMEOUT_TIME 18000 // 30 secondes
#endif

View File

@ -105,13 +105,16 @@ sflphone_kdeView::sflphone_kdeView(QWidget *parent)
connect(configDialog, SIGNAL(clearCallHistoryAsked()),
callList, SLOT(clearHistory()));
connect(configDialog, SIGNAL(changesApplied()),
this, SLOT(loadWindow()));
connect(accountList, SIGNAL(accountListUpdated()),
this, SLOT(updateStatusMessage()));
this, SLOT(updateStatusMessage()));
connect(accountList, SIGNAL(accountListUpdated()),
this, SLOT(updateWindowCallState()));
this, SLOT(updateWindowCallState()));
accountList->updateAccounts();
QPalette pal = QPalette(palette());
pal.setColor(QPalette::AlternateBase, Qt::lightGray);
setPalette(pal);
@ -148,6 +151,9 @@ void sflphone_kdeView::loadWindow()
updateVolumeControls();
updateDialpad();
updateSearchHistory();
updateAddressBookButton();
updateAddressBook();
if(! isAddressBookEnabled() && stackedWidget_screen->currentWidget() == page_addressBook) stackedWidget_screen->setCurrentWidget(page_callList);
}
@ -498,7 +504,7 @@ void sflphone_kdeView::updateWindowCallState()
buttonIconFiles[0] = ICON_ACCEPT;
buttonIconFiles[1] = ICON_REFUSE;
actionTexts[0] = ACTION_LABEL_ACCEPT;
actionTexts[0] = ACTION_LABEL_REFUSE;
actionTexts[1] = ACTION_LABEL_REFUSE;
break;
case CALL_STATE_RINGING:
qDebug() << "Reached CALL_STATE_RINGING with call " << (*callList)[item]->getCallId();
@ -684,22 +690,41 @@ void sflphone_kdeView::updateAddressBook()
QListWidgetItem * item = listWidget_addressBook->takeItem(0);
qDebug() << "take item " << item->text();
}
QString textSearched = lineEdit_addressBook->text();
if(textSearched.isEmpty())
if(!isAddressBookEnabled())
{
lineEdit_addressBook->setText(i18n("Address book has been disabled"));
lineEdit_addressBook->setEnabled(false);
label_addressBookFull->setVisible(false);
return;
}
bool full = false;
QVector<Contact *> contactsFound = findContactsInKAddressBook(textSearched, full);
qDebug() << "Full : " << full;
label_addressBookFull->setVisible(full);
for(int i = 0 ; i < contactsFound.size() ; i++)
else
{
Contact * contact = contactsFound[i];
addContactToContactList(contact);
if(loadAddressBook())
{
QString textSearched = lineEdit_addressBook->text();
if(textSearched.isEmpty())
{
label_addressBookFull->setVisible(false);
return;
}
bool full = false;
QVector<Contact *> contactsFound = findContactsInKAddressBook(textSearched, full);
qDebug() << "Full : " << full;
label_addressBookFull->setVisible(full);
for(int i = 0 ; i < contactsFound.size() ; i++)
{
Contact * contact = contactsFound[i];
addContactToContactList(contact);
}
alternateColors(listWidget_addressBook);
}
else
{
lineEdit_addressBook->setText(i18n("Address book loading..."));
lineEdit_addressBook->setEnabled(false);
label_addressBookFull->setVisible(false);
}
}
alternateColors(listWidget_addressBook);
}
void sflphone_kdeView::alternateColors(QListWidget * listWidget)
@ -722,8 +747,7 @@ QVector<Contact *> sflphone_kdeView::findContactsInKAddressBook(QString textSear
int maxResults = addressBookSettings[ADDRESSBOOK_MAX_RESULTS];
int typesDisplayed = phoneNumberTypesDisplayed();
bool displayPhoto = addressBookSettings[ADDRESSBOOK_DISPLAY_CONTACT_PHOTO];
AddressBook * ab = KABC::StdAddressBook::self();
AddressBook * ab = KABC::StdAddressBook::self(true);
QVector<Contact *> results = QVector<Contact *>();
AddressBook::Iterator it;
full = false;
@ -1433,6 +1457,42 @@ void sflphone_kdeView::on1_volumeChanged(const QString &device, double value)
updateVolumeBar();
}
void sflphone_kdeView::enableAddressBook()
{
qDebug() << "\nenableAddressBook\n";
lineEdit_addressBook->clear();
lineEdit_addressBook->setEnabled(true);
}
bool sflphone_kdeView::loadAddressBook()
{
qDebug() << "loadAddressBook";
AddressBook * ab = StdAddressBook::self(true);
if(ab->loadingHasFinished())
{
return true;
}
else
{
connect(ab, SIGNAL(addressBookChanged(AddressBook *)),
this, SLOT(enableAddressBook()));
return false;
}
}
void sflphone_kdeView::updateAddressBookButton()
{
action_addressBook->setVisible(isAddressBookEnabled());
}
bool sflphone_kdeView::isAddressBookEnabled()
{
ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance();
MapStringInt addressBookSettings = configurationManager.getAddressbookSettings().value();
return addressBookSettings[ADDRESSBOOK_ENABLE];
}
#include "sflphone_kdeview.moc"

View File

@ -81,11 +81,6 @@ public:
//Constructors & Destructors
sflphone_kdeView(QWidget *parent);
virtual ~sflphone_kdeView();
/**
* Called at construction. Updates all the display
* according to the settings.
*/
void loadWindow();
//Getters
/**
@ -118,6 +113,12 @@ public:
*/
int phoneNumberTypesDisplayed();
/**
*
* @return true if the address book is enabled in config
*/
bool isAddressBookEnabled();
//Updates
QVector<Contact *> findContactsInKAddressBook(QString textSearched, bool & full);
@ -227,7 +228,32 @@ private slots:
void updateDialpad();
public slots:
/**
* Updates all the display
* according to the settings.
*/
void loadWindow();
void updateStatusMessage();
/**
* Enable the address book search line edit.
* To be called once the address book loading has finished.
*/
void enableAddressBook();
/**
* Loads the address book asynchronously.
* Calls enableAddressBook() once the address book
* loading has finished if it is not allready loaded.
* @return true if address book has finished loading
*/
bool loadAddressBook();
/**
* choose to enable/disable the address book button
* according to the configuration's setting.
*/
void updateAddressBookButton();
virtual void keyPressEvent(QKeyEvent *event)

View File

@ -66,6 +66,12 @@
</item>
<item>
<widget class="KLineEdit" name="lineEdit_addressBook">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Address book loading...</string>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>