diff --git a/sflphone-client-kde/src/AccountList.cpp b/sflphone-client-kde/src/AccountList.cpp index 3f53f475fdb6502359b1db9726ce391bd7364772..82f2afd0bb2c8f3083269455565b58dd6d2eca05 100644 --- a/sflphone-client-kde/src/AccountList.cpp +++ b/sflphone-client-kde/src/AccountList.cpp @@ -40,7 +40,10 @@ AccountList::AccountList(bool fill) { qDebug() << "AccountList()"; accounts = new QVector<Account *>(); - updateAccounts(); + if(fill) + { + updateAccounts(); + } } void AccountList::update() diff --git a/sflphone-client-kde/src/Call.cpp b/sflphone-client-kde/src/Call.cpp index 5539577e4f1e8c408083326099d7b3c35a4636ff..8b235c5cf5d7e9b03eda78b54f067622c89d5fc2 100644 --- a/sflphone-client-kde/src/Call.cpp +++ b/sflphone-client-kde/src/Call.cpp @@ -164,24 +164,20 @@ Call::Call(call_state startState, QString callId, QString peerName, QString peer this->stopTime = NULL; } -Call::Call(QString callId) +Call * Call::buildExistingCall(QString callId) { CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); MapStringString details = callManager.getCallDetails(callId).value(); qDebug() << "Constructing existing call with details : " << details; - this->callId = callId; - this->peerPhoneNumber = details[CALL_PEER_NUMBER]; - this->peerName = details[CALL_PEER_NAME]; - initCallItem(); + QString peerNumber = details[CALL_PEER_NUMBER]; + QString peerName = details[CALL_PEER_NAME]; call_state startState = getStartStateFromDaemonCallState(details[CALL_STATE], details[CALL_TYPE]); - changeCurrentState(startState); - this->historyState = getHistoryStateFromDaemonCallState(details[CALL_STATE], details[CALL_TYPE]); - this->account = details[CALL_ACCOUNTID]; - this->recording = false; - this->startTime = new QDateTime(QDateTime::currentDateTime()); - this->stopTime = NULL; - this->historyItem = NULL; - this->historyItemWidget = NULL; + QString account = details[CALL_ACCOUNTID]; + Call * call = new Call(startState, callId, peerName, peerNumber, account); + call->startTime = new QDateTime(QDateTime::currentDateTime()); + call->recording = callManager.getIsRecording(callId); + call->historyState = getHistoryStateFromDaemonCallState(details[CALL_STATE], details[CALL_TYPE]); + return call; } Call::~Call() @@ -251,6 +247,7 @@ history_state Call::getHistoryStateFromType(QString type) { return INCOMING; } + return NONE; } call_state Call::getStartStateFromDaemonCallState(QString daemonCallState, QString daemonCallType) @@ -587,8 +584,8 @@ void Call::call() qDebug() << "account = " << account; if(account.isEmpty()) { - qDebug() << "account is empty"; - this->account = sflphone_kdeView::firstRegisteredAccount()->getAccountId(); + qDebug() << "account is empty, taking the first registered."; + this->account = sflphone_kdeView::firstRegisteredAccountId(); } if(!account.isEmpty()) { @@ -662,7 +659,6 @@ void Call::warning() void Call::appendItemText(QString text) { - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); QLabel * editNumber; switch(currentState) { diff --git a/sflphone-client-kde/src/Call.h b/sflphone-client-kde/src/Call.h index 8ec2ca9a0f6c4b57aaa56506b816355f063ae522..3d3ae20fc7de786f9c040bd9c78f0309f115dc63 100644 --- a/sflphone-client-kde/src/Call.h +++ b/sflphone-client-kde/src/Call.h @@ -113,6 +113,31 @@ class Call; typedef void (Call::*function)(); + +/** + * This class represents a call either actual (in the call list + * displayed in main window), either past (in the call history). + * A call is represented by an automate, with a list of states + * (enum call_state) and 2 lists of transition signals + * (call_action when the user performs an action on the UI and + * daemon_call_state when the daemon sends a stateChanged signal) + * When a transition signal is received, the automate calls a + * function then go to a new state according to the previous state + * of the call and the signal received. + * The functions to call and the new states to go to are placed in + * the maps actionPerformedStateMap, actionPerformedFunctionMap, + * stateChangedStateMap and stateChangedFunctionMap. + * Those maps are used by actionPerformed and stateChanged functions + * to handle the behavior of the automate. + * When an actual call goes to the state OVER, it becomes part of + * the call history. + * + * It may be better to handle call list and call history separately, + * and to use the class Item to handle their display, or a model/view + * way. For this it needs to handle the becoming of a call to a past call + * keeping the information gathered by the call and needed by the history + * call (history state, start time...). +**/ class Call { private: @@ -144,9 +169,34 @@ private: //Automate attributes + /** + * actionPerformedStateMap[orig_state][action] + * Map of the states to go to when the action action is + * performed on a call in state orig_state. + **/ static const call_state actionPerformedStateMap [11][5]; + + /** + * actionPerformedFunctionMap[orig_state][action] + * Map of the functions to call when the action action is + * performed on a call in state orig_state. + **/ static const function actionPerformedFunctionMap [11][5]; + + /** + * stateChangedStateMap[orig_state][daemon_new_state] + * Map of the states to go to when the daemon sends the signal + * callStateChanged with arg daemon_new_state + * on a call in state orig_state. + **/ static const call_state stateChangedStateMap [11][6]; + + /** + * stateChangedFunctionMap[orig_state][daemon_new_state] + * Map of the functions to call when the daemon sends the signal + * callStateChanged with arg daemon_new_state + * on a call in state orig_state. + **/ static const function stateChangedFunctionMap [11][6]; static const char * historyIcons[3]; @@ -161,6 +211,8 @@ private: static daemon_call_state toDaemonCallState(const QString & stateName); //Automate functions + // See actionPerformedFunctionMap and stateChangedFunctionMap + // to know when it is called. void nothing(); void accept(); void refuse(); @@ -181,13 +233,14 @@ private: public: //Constructors & Destructors - Call(QString callId); ~Call(); void initCallItem(); static Call * buildDialingCall(QString callId, const QString & peerName, QString account = ""); - static Call * buildIncomingCall(const QString & callId/*, const QString & from, const QString & account*/); + static Call * buildIncomingCall(const QString & callId); static Call * buildRingingCall(const QString & callId); static Call * buildHistoryCall(const QString & callId, uint startTimeStamp, uint stopTimeStamp, QString account, QString name, QString number, QString type); + static Call * buildExistingCall(QString callId); + static history_state getHistoryStateFromType(QString type); static call_state getStartStateFromDaemonCallState(QString daemonCallState, QString daemonCallType); static history_state getHistoryStateFromDaemonCallState(QString daemonCallState, QString daemonCallType); diff --git a/sflphone-client-kde/src/CallList.cpp b/sflphone-client-kde/src/CallList.cpp index d3415983fbec25f2f037a9654ec968851c1bee41..9f2cb774456cb3f812375a2e78fd720d19bb9e64 100644 --- a/sflphone-client-kde/src/CallList.cpp +++ b/sflphone-client-kde/src/CallList.cpp @@ -34,7 +34,7 @@ CallList::CallList() calls = new QVector<Call *>(); for(int i = 0 ; i < callList.size() ; i++) { - calls->append(new Call(callList[i])); + calls->append(Call::buildExistingCall(callList[i])); } MapStringString historyMap = configurationManager.getHistory().value(); qDebug() << "Call History = " << historyMap; diff --git a/sflphone-client-kde/src/conf/dlgaudio.cpp b/sflphone-client-kde/src/conf/dlgaudio.cpp index dba951041646efb354ad4631e262db625021f71c..0700c61bfb418e8ea04748dbbd78a302157c8f5d 100644 --- a/sflphone-client-kde/src/conf/dlgaudio.cpp +++ b/sflphone-client-kde/src/conf/dlgaudio.cpp @@ -33,8 +33,6 @@ DlgAudio::DlgAudio(KConfigDialog *parent) { setupUi(this); - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - QStyle * style = QApplication::style(); KUrlRequester_ringtone->setMode(KFile::File | KFile::ExistingOnly); KUrlRequester_ringtone->lineEdit()->setObjectName("kcfg_ringtone"); KUrlRequester_ringtone->lineEdit()->setReadOnly(true); @@ -46,12 +44,19 @@ DlgAudio::DlgAudio(KConfigDialog *parent) tableWidget_codecs->setSelectionBehavior(QAbstractItemView::SelectRows); updateAlsaSettings(); - connect(box_alsaPlugin, SIGNAL(currentIndexChanged(int)), parent, SLOT(updateButtons())); - connect(tableWidget_codecs, SIGNAL(itemChanged(QTableWidgetItem *)), this, SLOT(codecTableChanged())); - connect(toolButton_codecUp, SIGNAL(clicked()), this, SLOT(codecTableChanged())); - connect(toolButton_codecDown, SIGNAL(clicked()), this, SLOT(codecTableChanged())); + 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(this, SIGNAL(updateButtons()), parent, SLOT(updateButtons())); + connect(this, SIGNAL(updateButtons()), + parent, SLOT(updateButtons())); } @@ -76,7 +81,7 @@ void DlgAudio::updateWidgets() #else for (int i = 0 ; i < activeCodecList.size() ; i++) { - if(activeCodecList.lastIndexOf(activeCodecList[i]) != i) + if(activeCodecList.lastIndexOf(activeCodecList[i]) != i || ! codecList.contains(activeCodecList[i])) { activeCodecList.removeAt(i); i--; @@ -84,14 +89,6 @@ void DlgAudio::updateWidgets() } #endif - for (int i=0 ; i<activeCodecList.size() ; i++) - { - if(! codecList.contains(activeCodecList[i])) - { - activeCodecList.removeAt(i); - i--; - } - } QStringList codecListToDisplay = activeCodecList; for (int i=0 ; i<codecList.size() ; i++) { @@ -210,34 +207,28 @@ 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; - } - else if(tableWidget_codecs->currentRow() == tableWidget_codecs->rowCount() - 1) + else { - buttonsEnabled[1] = false; + 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_tableWidget_codecs_currentCellChanged(int currentRow) -{ - qDebug() << "on_tableWidget_codecs_currentCellChanged"; - int nbCol = tableWidget_codecs->columnCount(); - for(int i = 0 ; i < nbCol ; i++) - { - tableWidget_codecs->setRangeSelected(QTableWidgetSelectionRange(currentRow, 0, currentRow, nbCol - 1), true); - } - updateCodecListCommands(); -} void DlgAudio::on_toolButton_codecUp_clicked() { diff --git a/sflphone-client-kde/src/conf/dlgaudio.h b/sflphone-client-kde/src/conf/dlgaudio.h index 15c1f8f70b26d0d6dbaf22772282e9ccd9d651b8..cad1b9ee65a39f0e20183a3616e353115d6c04a1 100644 --- a/sflphone-client-kde/src/conf/dlgaudio.h +++ b/sflphone-client-kde/src/conf/dlgaudio.h @@ -49,7 +49,6 @@ public slots: private slots: void updateCodecListCommands(); - void on_tableWidget_codecs_currentCellChanged(int currentRow); void on_toolButton_codecUp_clicked(); void on_toolButton_codecDown_clicked(); void codecTableChanged(); diff --git a/sflphone-client-kde/src/conf/dlgaudiobase.ui b/sflphone-client-kde/src/conf/dlgaudiobase.ui index 08c842887c2194360655e7bf54787777bd6f6ed9..3679d8c79da33d1f7d00ba9924d287776ea97c8d 100644 --- a/sflphone-client-kde/src/conf/dlgaudiobase.ui +++ b/sflphone-client-kde/src/conf/dlgaudiobase.ui @@ -202,32 +202,15 @@ <string>ALSA settings</string> </property> <layout class="QFormLayout" name="formLayout_4"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::ExpandingFieldsGrow</enum> + </property> <property name="verticalSpacing"> <number>5</number> </property> <property name="leftMargin"> <number>9</number> </property> - <item row="3" column="0"> - <widget class="QLabel" name="label2_in"> - <property name="text"> - <string>In</string> - </property> - <property name="buddy"> - <cstring>kcfg_alsaInputDevice</cstring> - </property> - </widget> - </item> - <item row="5" column="0"> - <widget class="QLabel" name="label3_out"> - <property name="text"> - <string>Out</string> - </property> - <property name="buddy"> - <cstring>kcfg_alsaOutputDevice</cstring> - </property> - </widget> - </item> <item row="0" column="0"> <widget class="QLabel" name="label1_alsaPugin"> <property name="text"> @@ -245,14 +228,34 @@ </property> </widget> </item> - <item row="3" column="1"> + <item row="2" column="0"> + <widget class="QLabel" name="label2_in"> + <property name="text"> + <string>In</string> + </property> + <property name="buddy"> + <cstring>kcfg_alsaInputDevice</cstring> + </property> + </widget> + </item> + <item row="2" column="1"> <widget class="KComboBox" name="kcfg_alsaInputDevice"> <property name="sizeAdjustPolicy"> <enum>QComboBox::AdjustToContents</enum> </property> </widget> </item> - <item row="5" column="1"> + <item row="4" column="0"> + <widget class="QLabel" name="label3_out"> + <property name="text"> + <string>Out</string> + </property> + <property name="buddy"> + <cstring>kcfg_alsaOutputDevice</cstring> + </property> + </widget> + </item> + <item row="4" column="1"> <widget class="KComboBox" name="kcfg_alsaOutputDevice"> <property name="sizeAdjustPolicy"> <enum>QComboBox::AdjustToContents</enum>