Commit 62b69203 authored by Emmanuel Lepage Vallee's avatar Emmanuel Lepage Vallee
Browse files

[ #13801 ] Code cleanup (1/2)

parent 7ed9c78a
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "lib/sflphone_const.h" #include "lib/sflphone_const.h"
///Constructor
ConfigurationDialog::ConfigurationDialog(SFLPhoneView *parent) ConfigurationDialog::ConfigurationDialog(SFLPhoneView *parent)
:KConfigDialog(parent, SETTINGS_NAME, ConfigurationSkeleton::self()) :KConfigDialog(parent, SETTINGS_NAME, ConfigurationSkeleton::self())
{ {
...@@ -52,39 +53,40 @@ ConfigurationDialog::ConfigurationDialog(SFLPhoneView *parent) ...@@ -52,39 +53,40 @@ ConfigurationDialog::ConfigurationDialog(SFLPhoneView *parent)
dlgVideo = new DlgVideo (this); dlgVideo = new DlgVideo (this);
#endif #endif
addPage( dlgGeneral , i18nc("General settings","General") , "sflphone-client-kde" ); addPage( dlgGeneral , i18nc("General settings","General") , "sflphone-client-kde" );
addPage( dlgAccounts , i18n("Accounts") , "user-identity" ); addPage( dlgAccounts , i18n("Accounts") , "user-identity" );
addPage( dlgAudio , i18n("Audio") , "audio-headset" ); addPage( dlgAudio , i18n("Audio") , "audio-headset" );
addPage( dlgAddressBook , i18n("Address Book") , "x-office-address-book" ); addPage( dlgAddressBook , i18n("Address Book") , "x-office-address-book" );
addPage( dlgHooks , i18n("Hooks") , "insert-link" ); addPage( dlgHooks , i18n("Hooks") , "insert-link" );
addPage( dlgAccessibility , i18n("Accessibility") , "preferences-desktop-accessibility" ); addPage( dlgAccessibility , i18n("Accessibility") , "preferences-desktop-accessibility" );
#ifdef ENABLE_VIDEO #ifdef ENABLE_VIDEO
addPage( dlgVideo , i18nc("Video conversation","Video") , "camera-web" ); addPage( dlgVideo , i18nc("Video conversation","Video") , "camera-web" );
#endif #endif
addPage( dlgDisplay , i18nc("User interterface settings","Display") , "applications-graphics" ); addPage( dlgDisplay , i18nc("User interterface settings","Display"), "applications-graphics" );
connect(this, SIGNAL(applyClicked()), this, SLOT(applyCustomSettings())); connect(this, SIGNAL(applyClicked()) , this, SLOT(applyCustomSettings()));
connect(this, SIGNAL(okClicked()), this, SLOT(applyCustomSettings())); connect(this, SIGNAL(okClicked()) , this, SLOT(applyCustomSettings()));
connect(this, SIGNAL(cancelClicked()), this, SLOT(cancelSettings() )); connect(this, SIGNAL(cancelClicked()), this, SLOT(cancelSettings() ));
connect(dlgGeneral, SIGNAL(clearCallHistoryAsked()), this, SIGNAL(clearCallHistoryAsked())); connect(dlgGeneral, SIGNAL(clearCallHistoryAsked()), this, SIGNAL(clearCallHistoryAsked()));
} //ConfigurationDialog } //ConfigurationDialog
///Destructor
ConfigurationDialog::~ConfigurationDialog() ConfigurationDialog::~ConfigurationDialog()
{ {
delete dlgGeneral; delete dlgGeneral ;
delete dlgDisplay; delete dlgDisplay ;
delete dlgAccounts; delete dlgAccounts ;
delete dlgAudio; delete dlgAudio ;
delete dlgAddressBook; delete dlgAddressBook ;
delete dlgHooks; delete dlgHooks ;
delete dlgAccessibility; delete dlgAccessibility;
#ifdef ENABLE_VIDEO #ifdef ENABLE_VIDEO
delete dlgVideo; delete dlgVideo ;
#endif #endif
} }
///Update all widgets when something is reloaded
void ConfigurationDialog::updateWidgets() void ConfigurationDialog::updateWidgets()
{ {
dlgAudio->updateWidgets (); dlgAudio->updateWidgets ();
...@@ -94,6 +96,7 @@ void ConfigurationDialog::updateWidgets() ...@@ -94,6 +96,7 @@ void ConfigurationDialog::updateWidgets()
dlgAccessibility->updateWidgets(); dlgAccessibility->updateWidgets();
} }
///Save all settings when apply is clicked
void ConfigurationDialog::updateSettings() void ConfigurationDialog::updateSettings()
{ {
dlgAudio->updateSettings (); dlgAudio->updateSettings ();
...@@ -103,23 +106,27 @@ void ConfigurationDialog::updateSettings() ...@@ -103,23 +106,27 @@ void ConfigurationDialog::updateSettings()
dlgAccessibility->updateSettings(); dlgAccessibility->updateSettings();
} }
///Cancel current modification
void ConfigurationDialog::cancelSettings() void ConfigurationDialog::cancelSettings()
{ {
dlgAccounts->cancel(); dlgAccounts->cancel();
} }
///If the account changed
bool ConfigurationDialog::hasChanged() bool ConfigurationDialog::hasChanged()
{ {
bool res = dlgAudio->hasChanged() || dlgAccounts->hasChanged() || dlgGeneral->hasChanged(); bool res = dlgAudio->hasChanged() || dlgAccounts->hasChanged() || dlgGeneral->hasChanged();
return res; return res;
} }
///Update the buttons
void ConfigurationDialog::updateButtons() void ConfigurationDialog::updateButtons()
{ {
bool changed = hasChanged(); bool changed = hasChanged();
enableButtonApply( changed ); enableButtonApply( changed );
} }
///Apply settings
void ConfigurationDialog::applyCustomSettings() void ConfigurationDialog::applyCustomSettings()
{ {
if(hasChanged()) { if(hasChanged()) {
...@@ -131,6 +138,7 @@ void ConfigurationDialog::applyCustomSettings() ...@@ -131,6 +138,7 @@ void ConfigurationDialog::applyCustomSettings()
emit changesApplied(); emit changesApplied();
} }
///Reload the pages
void ConfigurationDialog::reload() void ConfigurationDialog::reload()
{ {
kDebug() << "Reloading config"; kDebug() << "Reloading config";
......
...@@ -16,19 +16,18 @@ ...@@ -16,19 +16,18 @@
* You should have received a copy of the GNU General Public License * * You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. * * along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/ ***************************************************************************/
#ifndef CONFIGURATIONDIALOG_H #ifndef CONFIGURATIONDIALOG_H
#define CONFIGURATIONDIALOG_H #define CONFIGURATIONDIALOG_H
//Base
#include <kconfigdialog.h> #include <kconfigdialog.h>
#include "klib/kcfg_settings.h" #include "klib/kcfg_settings.h"
#include "SFLPhoneView.h" #include "SFLPhoneView.h"
#define SETTINGS_NAME "settings" #define SETTINGS_NAME "settings"
//SFLPhone
class DlgGeneral; class DlgGeneral;
class DlgDisplay; class DlgDisplay;
class DlgAccounts; class DlgAccounts;
...@@ -38,7 +37,6 @@ class DlgRecord; ...@@ -38,7 +37,6 @@ class DlgRecord;
class DlgHooks; class DlgHooks;
class DlgAccessibility; class DlgAccessibility;
class DlgVideo; class DlgVideo;
class SFLPhoneView; class SFLPhoneView;
/** /**
...@@ -80,6 +78,7 @@ public slots: ...@@ -80,6 +78,7 @@ public slots:
*/ */
void updateSettings(); void updateSettings();
/** /**
* @author Jérémy Quentin <jeremy.quentin@gmail.com>
* Is implemented in KConfigDialog only from KDE4.3 * Is implemented in KConfigDialog only from KDE4.3
* It it implemented here for KDE4.2 users. * It it implemented here for KDE4.2 users.
* I didn't test with KDE4.3 so I leave it even for 4.3 users. * I didn't test with KDE4.3 so I leave it even for 4.3 users.
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
* You should have received a copy of the GNU General Public License * * You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. * * along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/ ***************************************************************************/
#ifndef DLGACCESSIBILITY_H #ifndef DLGACCESSIBILITY_H
#define DLGACCESSIBILITY_H #define DLGACCESSIBILITY_H
......
...@@ -16,10 +16,8 @@ ...@@ -16,10 +16,8 @@
* You should have received a copy of the GNU General Public License * * You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. * * along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/ ***************************************************************************/
#include "dlgaccounts.h" #include "dlgaccounts.h"
//Qt //Qt
#include <QtCore/QString> #include <QtCore/QString>
#include <QtGui/QInputDialog> #include <QtGui/QInputDialog>
...@@ -121,13 +119,13 @@ DlgAccounts::DlgAccounts(KConfigDialog* parent) ...@@ -121,13 +119,13 @@ DlgAccounts::DlgAccounts(KConfigDialog* parent)
/**/connect(AccountList::getInstance(), SIGNAL(accountEnabledChanged(Account*)), this , SLOT(otherAccountChanged()) ); /**/connect(AccountList::getInstance(), SIGNAL(accountEnabledChanged(Account*)), this , SLOT(otherAccountChanged()) );
/* */ /* */
connect(listView_accountList->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(accountListChanged(QModelIndex,QModelIndex))); connect(listView_accountList->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(accountListChanged(QModelIndex,QModelIndex)) );
connect(listView_accountList->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(updateAccountListCommands())); connect(listView_accountList->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(updateAccountListCommands()) );
//Disable control //Disable control
connect(radioButton_pa_same_as_local, SIGNAL(clicked(bool)) , this , SLOT(enablePublished())); connect(radioButton_pa_same_as_local, SIGNAL(clicked(bool)) , this , SLOT(enablePublished()));
connect(radioButton_pa_custom, SIGNAL(clicked(bool)) , this , SLOT(enablePublished())); connect(radioButton_pa_custom, SIGNAL(clicked(bool)) , this , SLOT(enablePublished()));
if (AccountList::getInstance()->index(0,0).isValid()) { if (AccountList::getInstance()->index(0,0).isValid()) {
...@@ -296,7 +294,7 @@ void DlgAccounts::loadAccount(QModelIndex item) ...@@ -296,7 +294,7 @@ void DlgAccounts::loadAccount(QModelIndex item)
break; break;
} }
// WIDGET VALUE VALUE / // WIDGET VALUE VALUE /
/**/edit2_protocol->setCurrentIndex ( (protocolIndex < 0) ? 0 : protocolIndex ); /**/edit2_protocol->setCurrentIndex ( (protocolIndex < 0) ? 0 : protocolIndex );
/**/edit3_server->setText ( account->getAccountHostname ()); /**/edit3_server->setText ( account->getAccountHostname ());
/**/edit4_user->setText ( account->getAccountUsername ()); /**/edit4_user->setText ( account->getAccountUsername ());
...@@ -328,44 +326,44 @@ void DlgAccounts::loadAccount(QModelIndex item) ...@@ -328,44 +326,44 @@ void DlgAccounts::loadAccount(QModelIndex item)
/**/check_tls_requier_cert->setChecked ( account->isTlsRequireClientCertificate ()); /**/check_tls_requier_cert->setChecked ( account->isTlsRequireClientCertificate ());
/**/group_security_tls->setChecked ( account->isTlsEnable ()); /**/group_security_tls->setChecked ( account->isTlsEnable ());
/**/combo_security_STRP->setCurrentIndex ( account->getTlsMethod ()); /**/combo_security_STRP->setCurrentIndex ( account->getTlsMethod ());
/* */ /* */
m_pDefaultAccount->setChecked(account == AccountList::getInstance()->getDefaultAccount()); m_pDefaultAccount->setChecked(account == AccountList::getInstance()->getDefaultAccount());
account->getVideoCodecModel()->reload(); account->getVideoCodecModel()->reload();
disconnect(list_credential->selectionModel(),SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(selectCredential(QModelIndex,QModelIndex))); disconnect(list_credential->selectionModel(),SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(selectCredential(QModelIndex,QModelIndex)) );
list_credential->setModel(account->getCredentialsModel()); list_credential->setModel(account->getCredentialsModel());
connect(list_credential->selectionModel() ,SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(selectCredential(QModelIndex,QModelIndex))); connect(list_credential->selectionModel() ,SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(selectCredential(QModelIndex,QModelIndex)) );
disconnect(list_audiocodec->selectionModel(),SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(selectedCodecChanged(QModelIndex,QModelIndex))); disconnect(list_audiocodec->selectionModel(),SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(selectedCodecChanged(QModelIndex,QModelIndex)) );
disconnect(list_audiocodec->model(),SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(changedAccountList())); disconnect(list_audiocodec->model() ,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(changedAccountList()) );
list_audiocodec->setModel(account->getAudioCodecModel()); list_audiocodec->setModel(account->getAudioCodecModel());
connect(list_audiocodec->model(),SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(changedAccountList())); connect(list_audiocodec->model() ,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(changedAccountList()) );
connect(list_audiocodec->selectionModel() ,SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(selectedCodecChanged(QModelIndex,QModelIndex))); connect(list_audiocodec->selectionModel() ,SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(selectedCodecChanged(QModelIndex,QModelIndex)) );
#ifdef ENABLE_VIDEO #ifdef ENABLE_VIDEO
disconnect(m_pCodecsLW->selectionModel(),SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(loadVidCodecDetails(QModelIndex,QModelIndex))); disconnect(m_pCodecsLW->selectionModel() ,SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(loadVidCodecDetails(QModelIndex,QModelIndex)) );
disconnect(m_pCodecsLW->model(),SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(changedAccountList())); disconnect(m_pCodecsLW->model() ,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(changedAccountList()) );
m_pCodecsLW->setModel(account->getVideoCodecModel()); m_pCodecsLW->setModel(account->getVideoCodecModel());
connect(m_pCodecsLW->model(),SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(changedAccountList())); connect(m_pCodecsLW->model() ,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(changedAccountList()) );
connect(m_pCodecsLW->selectionModel() ,SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(loadVidCodecDetails(QModelIndex,QModelIndex))); connect(m_pCodecsLW->selectionModel() ,SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(loadVidCodecDetails(QModelIndex,QModelIndex)) );
#endif #endif
if (account->getAccountAlias() == "IP2IP") { if (account->getAccountAlias() == "IP2IP") {
frame2_editAccounts->setTabEnabled(0,false); frame2_editAccounts->setTabEnabled( 0, false );
frame2_editAccounts->setTabEnabled(1,false); frame2_editAccounts->setTabEnabled( 1, false );
frame2_editAccounts->setTabEnabled(2,true ); frame2_editAccounts->setTabEnabled( 2, true );
frame2_editAccounts->setTabEnabled(3,false); frame2_editAccounts->setTabEnabled( 3, false );
frame2_editAccounts->setTabEnabled(4,false); frame2_editAccounts->setTabEnabled( 4, false );
frame2_editAccounts->setTabEnabled(5,true ); frame2_editAccounts->setTabEnabled( 5, true );
} }
else { else {
frame2_editAccounts->setTabEnabled(0,true); frame2_editAccounts->setTabEnabled( 0, true );
frame2_editAccounts->setTabEnabled(1,true); frame2_editAccounts->setTabEnabled( 1, true );
frame2_editAccounts->setTabEnabled(3,true); frame2_editAccounts->setTabEnabled( 3, true );
frame2_editAccounts->setTabEnabled(4,true); frame2_editAccounts->setTabEnabled( 4, true );
frame2_editAccounts->setCurrentIndex(0); frame2_editAccounts->setCurrentIndex(0);
} }
...@@ -374,8 +372,8 @@ void DlgAccounts::loadAccount(QModelIndex item) ...@@ -374,8 +372,8 @@ void DlgAccounts::loadAccount(QModelIndex item)
m_pRingTonePath->setUrl( ringtonePath ); m_pRingTonePath->setUrl( ringtonePath );
combo_tls_method->setCurrentIndex ( account->getTlsMethod() ); combo_tls_method->setCurrentIndex( account->getTlsMethod() );
ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); ConfigurationManagerInterface& configurationManager = ConfigurationManagerInterfaceSingleton::getInstance();
m_pRingtoneListLW->clear(); m_pRingtoneListLW->clear();
m_hRingtonePath = configurationManager.getRingtoneList(); m_hRingtonePath = configurationManager.getRingtoneList();
...@@ -383,14 +381,15 @@ void DlgAccounts::loadAccount(QModelIndex item) ...@@ -383,14 +381,15 @@ void DlgAccounts::loadAccount(QModelIndex item)
bool found = false; bool found = false;
while (iter.hasNext()) { while (iter.hasNext()) {
iter.next(); iter.next();
QListWidgetItem* item = new QListWidgetItem(); QListWidgetItem* item = new QListWidgetItem();
RingToneListItem* item_widget = new RingToneListItem(iter.key(),iter.value()); RingToneListItem* item_widget = new RingToneListItem(iter.key(),iter.value());
m_pRingtoneListLW->addItem(item); m_pRingtoneListLW->addItem ( item );
m_pRingtoneListLW->setItemWidget(item,item_widget); m_pRingtoneListLW->setItemWidget( item, item_widget );
if (KStandardDirs::realFilePath(iter.key()) == ringtonePath) { if (KStandardDirs::realFilePath(iter.key()) == ringtonePath) {
m_pUseCustomFileCK->setChecked(false); m_pUseCustomFileCK->setChecked( false );
m_pRingTonePath->setDisabled(true); m_pRingTonePath->setDisabled ( true );
item->setSelected(true); item->setSelected ( true );
found = true; found = true;
} }
} }
...@@ -412,17 +411,16 @@ void DlgAccounts::loadAccount(QModelIndex item) ...@@ -412,17 +411,16 @@ void DlgAccounts::loadAccount(QModelIndex item)
line_stun->setText( account->getAccountSipStunServer() ); line_stun->setText( account->getAccountSipStunServer() );
//checkbox_zrtp->setChecked(account->getAccountDetail(ACCOUNT_SRTP_ENABLED) == REGISTRATION_ENABLED_TRUE); //checkbox_zrtp->setChecked(account->getAccountDetail(ACCOUNT_SRTP_ENABLED) == REGISTRATION_ENABLED_TRUE);
tab_advanced->setEnabled(true); tab_advanced-> setEnabled ( true );
line_stun->setEnabled(checkbox_stun->isChecked()); line_stun-> setEnabled ( checkbox_stun->isChecked() );
radioButton_pa_same_as_local->setDisabled(checkbox_stun->isChecked()); radioButton_pa_same_as_local->setDisabled( checkbox_stun->isChecked() );
radioButton_pa_custom->setDisabled(checkbox_stun->isChecked()); radioButton_pa_custom-> setDisabled( checkbox_stun->isChecked() );
} }
else { else {
checkbox_stun->setChecked(false); checkbox_stun->setChecked(false);
tab_advanced->setEnabled (false);
line_stun->setText( account->getAccountSipStunServer() ); line_stun->setText( account->getAccountSipStunServer() );
//checkbox_zrtp->setChecked(false); //checkbox_zrtp->setChecked(false);
tab_advanced->setEnabled(false);
} }
updateStatusLabel(account); updateStatusLabel(account);
...@@ -438,10 +436,8 @@ void DlgAccounts::loadAccountList() ...@@ -438,10 +436,8 @@ void DlgAccounts::loadAccountList()
AccountList::getInstance()->updateAccounts(); AccountList::getInstance()->updateAccounts();
if (listView_accountList->model()->rowCount() > 0 && !listView_accountList->currentIndex().isValid()) if (listView_accountList->model()->rowCount() > 0 && !listView_accountList->currentIndex().isValid())
listView_accountList->setCurrentIndex(listView_accountList->model()->index(0,0)); listView_accountList->setCurrentIndex(listView_accountList->model()->index(0,0));
else if (listView_accountList->currentIndex().isValid())
frame2_editAccounts->setEnabled(true);
else else
frame2_editAccounts->setEnabled(false); frame2_editAccounts->setEnabled(listView_accountList->currentIndex().isValid());
} }
///Called when one of the child widget is modified ///Called when one of the child widget is modified
...@@ -449,9 +445,8 @@ void DlgAccounts::changedAccountList() ...@@ -449,9 +445,8 @@ void DlgAccounts::changedAccountList()
{ {
if (!m_IsLoading) { if (!m_IsLoading) {
Account* acc = AccountList::getInstance()->getAccountByModelIndex(listView_accountList->currentIndex()); Account* acc = AccountList::getInstance()->getAccountByModelIndex(listView_accountList->currentIndex());
if (acc) { if (acc)
acc->performAction(MODIFY); acc->performAction(MODIFY);
}
accountListHasChanged = true; accountListHasChanged = true;
emit updateButtons(); emit updateButtons();
} }
...@@ -475,27 +470,27 @@ void DlgAccounts::accountListChanged(QModelIndex current, QModelIndex previous) ...@@ -475,27 +470,27 @@ void DlgAccounts::accountListChanged(QModelIndex current, QModelIndex previous)
//updateAccountListCommands(); //updateAccountListCommands();
} }
///Move account up
void DlgAccounts::on_button_accountUp_clicked() void DlgAccounts::on_button_accountUp_clicked()
{ {
kDebug() << "on_button_accountUp_clicked";
QModelIndex index = listView_accountList->currentIndex(); QModelIndex index = listView_accountList->currentIndex();
Account* acc = AccountList::getInstance()->getAccountByModelIndex(index); Account* acc = AccountList::getInstance()->getAccountByModelIndex(index);
AccountList::getInstance()->accountUp(index.row()); AccountList::getInstance()->accountUp(index.row());
listView_accountList->setCurrentIndex(acc->getIndex()); listView_accountList->setCurrentIndex(acc->getIndex());
} }
///Move account down
void DlgAccounts::on_button_accountDown_clicked() void DlgAccounts::on_button_accountDown_clicked()
{ {
kDebug() << "on_button_accountDown_clicked";
QModelIndex index = listView_accountList->currentIndex(); QModelIndex index = listView_accountList->currentIndex();
Account* acc = AccountList::getInstance()->getAccountByModelIndex(index); Account* acc = AccountList::getInstance()->getAccountByModelIndex(index);
AccountList::getInstance()->accountDown(index.row()); AccountList::getInstance()->accountDown(index.row());
listView_accountList->setCurrentIndex(acc->getIndex()); listView_accountList->setCurrentIndex(acc->getIndex());
} }
///Add new account
void DlgAccounts::on_button_accountAdd_clicked() void DlgAccounts::on_button_accountAdd_clicked()
{ {
kDebug() << "on_button_accountAdd_clicked";
QString itemName = QInputDialog::getText(this, "New account", "Enter new account's alias"); QString itemName = QInputDialog::getText(this, "New account", "Enter new account's alias");
itemName = itemName.simplified(); itemName = itemName.simplified();
if (!itemName.isEmpty()) { if (!itemName.isEmpty()) {
...@@ -506,27 +501,27 @@ void DlgAccounts::on_button_accountAdd_clicked() ...@@ -506,27 +501,27 @@ void DlgAccounts::on_button_accountAdd_clicked()
} }
} //on_button_accountAdd_clicked } //on_button_accountAdd_clicked
///Remove selected account
void DlgAccounts::on_button_accountRemove_clicked() void DlgAccounts::on_button_accountRemove_clicked()
{ {
kDebug() << "on_button_accountRemove_clicked";
AccountList::getInstance()->removeAccount(listView_accountList->currentIndex()); AccountList::getInstance()->removeAccount(listView_accountList->currentIndex());
listView_accountList->setCurrentIndex(listView_accountList->model()->index(0,0)); listView_accountList->setCurrentIndex(listView_accountList->model()->index(0,0));
} }
///Update account list
void DlgAccounts::updateAccountListCommands() void DlgAccounts::updateAccountListCommands()
{ {
kDebug() << "updateAccountListCommands";
bool buttonsEnabled[4] = {true,true,true,true}; bool buttonsEnabled[4] = {true,true,true,true};
if(! listView_accountList->currentIndex().isValid()) { if(! listView_accountList->currentIndex().isValid()) {
buttonsEnabled[0] = false; buttonsEnabled[0] = false;
buttonsEnabled[1] = false; buttonsEnabled[1] = false;
buttonsEnabled[3] = false; buttonsEnabled[3] = false;
} }
else if(listView_accountList->currentIndex().row() == 0) { else if(listView_accountList->currentIndex().row() == 0) {
buttonsEnabled[0] = false; buttonsEnabled[0] = false;
} }
if(listView_accountList->currentIndex().row() == listView_accountList->model()->rowCount() - 1) { if(listView_accountList->currentIndex().row() == listView_accountList->model()->rowCount() - 1) {
buttonsEnabled[1] = false; buttonsEnabled[1] = false;
} }
button_accountUp->setEnabled ( buttonsEnabled[0] ); button_accountUp->setEnabled ( buttonsEnabled[0] );
...@@ -535,12 +530,13 @@ void DlgAccounts::updateAccountListCommands() ...@@ -535,12 +530,13 @@ void DlgAccounts::updateAccountListCommands()
button_accountRemove->setEnabled ( buttonsEnabled[3] ); button_accountRemove->setEnabled ( buttonsEnabled[3] );
} }
///Password changed
void DlgAccounts::main_password_field_changed() void DlgAccounts::main_password_field_changed()
{ {
list_credential->model()->setData(list_credential->model()->index(0,0),edit5_password->text(),CredentialModel::PASSWORD_ROLE); list_credential->model()->setData(list_credential->model()->index(0,0),edit5_password->text(),CredentialModel::PASSWORD_ROLE);
} }
///Credential changed
void DlgAccounts::main_credential_password_changed() void DlgAccounts::main_credential_password_changed()
{ {
if (list_credential->currentIndex().row() == 0) { if (list_credential->currentIndex().row() == 0) {
...@@ -548,30 +544,35 @@ void DlgAccounts::main_credential_password_changed() ...@@ -548,30 +544,35 @@ void DlgAccounts::main_credential_password_changed()
} }
} }