File indexing completed on 2024-04-14 15:05:34

0001 /***************************************************************************
0002     The configuration page for the authentication settings of Smb4K
0003                              -------------------
0004     begin                : Sa Nov 15 2003
0005     copyright            : (C) 2003-2019 by Alexander Reinholdt
0006     email                : alexander.reinholdt@kdemail.net
0007  ***************************************************************************/
0008 
0009 /***************************************************************************
0010  *   This program is free software; you can redistribute it and/or modify  *
0011  *   it under the terms of the GNU General Public License as published by  *
0012  *   the Free Software Foundation; either version 2 of the License, or     *
0013  *   (at your option) any later version.                                   *
0014  *                                                                         *
0015  *   This program is distributed in the hope that it will be useful, but   *
0016  *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
0017  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
0018  *   General Public License for more details.                              *
0019  *                                                                         *
0020  *   You should have received a copy of the GNU General Public License     *
0021  *   along with this program; if not, write to the                         *
0022  *   Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston,*
0023  *   MA 02110-1335, USA                                                    *
0024  ***************************************************************************/
0025 
0026 #ifdef HAVE_CONFIG_H
0027 #include <config.h>
0028 #endif
0029 
0030 // application specific includes
0031 #include "smb4kconfigpageauthentication.h"
0032 #include "core/smb4ksettings.h"
0033 
0034 // Qt includes
0035 #include <QMouseEvent>
0036 #include <QHeaderView>
0037 #include <QListWidgetItem>
0038 #include <QCheckBox>
0039 #include <QGroupBox>
0040 #include <QGridLayout>
0041 #include <QPushButton>
0042 #include <QTableWidget>
0043 #include <QAction>
0044 
0045 // KDE includes
0046 #include <KI18n/KLocalizedString>
0047 #include <KIconThemes/KIconLoader>
0048 #include <KWidgetsAddons/KCollapsibleGroupBox>
0049 
0050 
0051 Smb4KConfigPageAuthentication::Smb4KConfigPageAuthentication(QWidget *parent) : QWidget(parent)
0052 {
0053   m_entries_displayed = false;
0054   m_maybe_changed = false;
0055   
0056   //
0057   // Layout 
0058   // 
0059   QVBoxLayout *layout = new QVBoxLayout(this);
0060   layout->setSpacing(5);
0061   layout->setMargin(0);
0062   
0063   //
0064   // Settings group box
0065   // 
0066   QGroupBox *settingsBox = new QGroupBox(i18n("Settings"), this);
0067   QVBoxLayout *settingsBoxLayout = new QVBoxLayout(settingsBox);
0068   settingsBoxLayout->setSpacing(5);
0069   
0070   // Wallet usage
0071   QCheckBox *useWallet = new QCheckBox(Smb4KSettings::self()->useWalletItem()->label(), settingsBox);
0072   useWallet->setObjectName("kcfg_UseWallet");
0073   
0074   connect(useWallet, SIGNAL(toggled(bool)), this, SLOT(slotKWalletButtonToggled(bool)));
0075 
0076   settingsBoxLayout->addWidget(useWallet, 0);
0077 
0078   // Default login
0079   QCheckBox *defaultAuth  = new QCheckBox(Smb4KSettings::self()->useDefaultLoginItem()->label(), settingsBox);
0080   defaultAuth->setObjectName("kcfg_UseDefaultLogin");
0081   
0082   connect(defaultAuth, SIGNAL(toggled(bool)), this, SLOT(slotDefaultLoginToggled(bool)));
0083 
0084   settingsBoxLayout->addWidget(defaultAuth, 0);
0085 
0086   layout->addWidget(settingsBox, 0);
0087 
0088   //
0089   // Wallet Entries group box
0090   // 
0091   QGroupBox *walletEntriesBox = new QGroupBox(i18n("Wallet Entries"), this);
0092   QVBoxLayout *walletEntriesBoxLayout = new QVBoxLayout(walletEntriesBox);
0093   walletEntriesBoxLayout->setSpacing(5);
0094   
0095   //
0096   // Wallet Entries editor
0097   // 
0098   QWidget *walletEntriesEditor = new QWidget(walletEntriesBox);
0099   walletEntriesEditor->setObjectName("WalletEntriesEditor");
0100   QGridLayout *walletEntriesEditorLayout= new QGridLayout(walletEntriesEditor);
0101   walletEntriesEditorLayout->setSpacing(5);
0102   
0103   // 
0104   // The list view 
0105   // 
0106   QListWidget *walletEntriesWidget = new QListWidget(walletEntriesEditor);
0107   walletEntriesWidget->setObjectName("WalletEntriesWidget");
0108   walletEntriesWidget->setDragDropMode(QListWidget::NoDragDrop);
0109   walletEntriesWidget->setSelectionMode(QListWidget::SingleSelection);
0110   walletEntriesWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
0111   walletEntriesWidget->viewport()->installEventFilter(this);
0112 
0113   // Edit action
0114   QAction *editAction = new QAction(KDE::icon("edit-rename"), i18n("Edit"), walletEntriesWidget);
0115   editAction->setObjectName("EditAction");
0116   editAction->setEnabled(false);
0117   connect(editAction, SIGNAL(triggered(bool)), this, SLOT(slotEditClicked()));
0118   walletEntriesWidget->addAction(editAction);
0119   
0120   // Remove action
0121   QAction *removeAction = new QAction(KDE::icon("edit-delete"), i18n("Remove"), walletEntriesWidget);
0122   removeAction->setObjectName("RemoveAction");
0123   removeAction->setEnabled(false);
0124   connect(removeAction, SIGNAL(triggered(bool)), this, SLOT(slotRemoveClicked()));
0125   walletEntriesWidget->addAction(removeAction);
0126   
0127   // Clear action
0128   QAction *clearAction = new QAction(KDE::icon("edit-clear-list"), i18n("Clear"), walletEntriesWidget);
0129   clearAction->setObjectName("ClearAction");
0130   clearAction->setEnabled(false);
0131   connect(clearAction, SIGNAL(triggered(bool)), this, SLOT(slotClearClicked()));
0132   walletEntriesWidget->addAction(clearAction);  
0133   
0134   connect(walletEntriesWidget, SIGNAL(itemSelectionChanged()), this, SLOT(slotItemSelectionChanged()));
0135   
0136   walletEntriesEditorLayout->addWidget(walletEntriesWidget, 0, 0, 7, 1, 0);
0137   
0138   // 
0139   // Load button
0140   // 
0141   QPushButton *loadButton = new QPushButton(walletEntriesEditor);
0142   loadButton->setObjectName("LoadButton");
0143   loadButton->setText(i18n("Load"));
0144   loadButton->setIcon(KDE::icon("document-open"));
0145   loadButton->setWhatsThis(i18n("The login information that was stored by Smb4K will be loaded from the wallet."));
0146   
0147   connect(loadButton, SIGNAL(clicked(bool)), this, SIGNAL(loadWalletEntries()));
0148   
0149   walletEntriesEditorLayout->addWidget(loadButton, 0, 1, 0);
0150   
0151   // 
0152   // Save button
0153   // 
0154   QPushButton *saveButton = new QPushButton(walletEntriesEditor);
0155   saveButton->setObjectName("SaveButton");
0156   saveButton->setText(i18n("Save"));
0157   saveButton->setIcon(KDE::icon("document-save-all"));
0158   saveButton->setWhatsThis(i18n("All modifications you applied are saved to the wallet."));
0159   saveButton->setEnabled(false);
0160   
0161   connect(saveButton, SIGNAL(clicked(bool)), this, SIGNAL(saveWalletEntries()));
0162   connect(saveButton, SIGNAL(clicked(bool)), this, SLOT(slotSaveClicked(bool)));
0163   
0164   walletEntriesEditorLayout->addWidget(saveButton, 1, 1, 0);
0165   walletEntriesEditorLayout->addItem(new QSpacerItem(0, 10, QSizePolicy::Fixed, QSizePolicy::Fixed), 2, 1);
0166   
0167   //
0168   // The details widget
0169   // 
0170   KCollapsibleGroupBox *detailsBox = new KCollapsibleGroupBox(walletEntriesEditor);
0171   detailsBox->setObjectName("DetailsBox");
0172   detailsBox->setTitle(i18n("Details"));
0173   detailsBox->setEnabled(false);
0174   QVBoxLayout *detailsBoxLayout = new QVBoxLayout(detailsBox);
0175   detailsBoxLayout->setSpacing(5);
0176   
0177   QTableWidget *detailsWidget = new QTableWidget(detailsBox);
0178   detailsWidget->setObjectName("DetailsWidget");
0179   detailsWidget->horizontalHeader()->setVisible(false);
0180   detailsWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
0181   detailsWidget->verticalHeader()->setVisible(false);
0182   detailsWidget->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
0183   detailsWidget->viewport()->installEventFilter(this);
0184   
0185   detailsBoxLayout->addWidget(detailsWidget, 0);
0186   
0187   walletEntriesEditorLayout->addWidget(detailsBox, 5, 1, 0);
0188   walletEntriesEditorLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::MinimumExpanding), 6, 1);
0189   
0190   walletEntriesBoxLayout->addWidget(walletEntriesEditor, 0);
0191   
0192   layout->addWidget(walletEntriesBox, 0);
0193   
0194   // 
0195   // Adjustments
0196   // 
0197   slotKWalletButtonToggled(useWallet->isChecked());
0198   slotDefaultLoginToggled(defaultAuth->isChecked());
0199      
0200   //
0201   // Set focus
0202   // 
0203   loadButton->setFocus();
0204 }
0205 
0206 
0207 Smb4KConfigPageAuthentication::~Smb4KConfigPageAuthentication()
0208 {
0209 }
0210 
0211 
0212 void Smb4KConfigPageAuthentication::insertWalletEntries(const QList<Smb4KAuthInfo *> &list)
0213 {
0214   //
0215   // Insert the list of authentication information
0216   // 
0217   m_entriesList = list;
0218   
0219   //
0220   // Reset the changed flag, since we are (re)loading the information
0221   // 
0222   m_maybe_changed = false;
0223   emit walletEntriesModified();
0224   
0225   //
0226   // Get the list wirdget
0227   // 
0228   QListWidget *walletEntriesWidget = findChild<QListWidget *>("WalletEntriesWidget");
0229   
0230   
0231   //
0232   // Clear the list widget
0233   // 
0234   walletEntriesWidget->clear();
0235   
0236   //
0237   // Insert the authentication information entries into the
0238   // list widget
0239   // 
0240   for (Smb4KAuthInfo *authInfo : m_entriesList)
0241   {
0242     switch (authInfo->type())
0243     {
0244       case UnknownNetworkItem:
0245       {
0246         (void) new QListWidgetItem(KDE::icon("dialog-password"), i18n("Default Login"), walletEntriesWidget);
0247         break;
0248       }
0249       default:
0250       {
0251         (void) new QListWidgetItem(KDE::icon("dialog-password"), authInfo->displayString(), walletEntriesWidget);
0252         break;
0253       }
0254     }
0255   }
0256   
0257   //
0258   // Sort the entries
0259   // 
0260   walletEntriesWidget->sortItems();
0261   
0262   //
0263   // Set the display flag to true
0264   // 
0265   m_entries_displayed = true;
0266   
0267   //
0268   // Enable buttons and actions
0269   // 
0270   findChild<QPushButton *>("SaveButton")->setEnabled(walletEntriesWidget->count() != 0);
0271   findChild<QAction *>("ClearAction")->setEnabled(walletEntriesWidget->count() != 0);
0272 }
0273 
0274 
0275 bool Smb4KConfigPageAuthentication::eventFilter(QObject *object, QEvent *e)
0276 {
0277   //
0278   // Get the list widget
0279   // 
0280   QListWidget *walletEntriesWidget = findChild<QListWidget *>("WalletEntriesWidget");
0281   
0282   //
0283   // Process the events in the list widget
0284   // 
0285   if (object == walletEntriesWidget->viewport())
0286   {
0287     // If the user clicked on the viewport of the entries view, clear 
0288     // the details widget and the "Details" button, if no item 
0289     // is under the mouse.
0290     if (e->type() == QEvent::MouseButtonPress)
0291     {
0292       QMouseEvent *event = static_cast<QMouseEvent *>(e);
0293       QPoint pos = walletEntriesWidget->mapFromGlobal(event->globalPos());
0294         
0295       if (!walletEntriesWidget->itemAt(pos))
0296       {
0297         clearDetails();
0298         walletEntriesWidget->clearSelection();
0299         findChild<QAction *>("EditAction")->setEnabled(false);
0300         findChild<QAction *>("RemoveAction")->setEnabled(false);
0301       }
0302     }
0303     
0304     return walletEntriesWidget->viewport()->eventFilter(object, e);
0305   }
0306   
0307   return QWidget::eventFilter(object, e);
0308 }
0309 
0310 
0311 void Smb4KConfigPageAuthentication::loadDetails(Smb4KAuthInfo *authInfo)
0312 {
0313   //
0314   // Get the widgets
0315   // 
0316   QTableWidget *detailsWidget = findChild<QTableWidget *>("DetailsWidget");
0317   KCollapsibleGroupBox *detailsGroupBox = findChild<KCollapsibleGroupBox *>("DetailsBox");
0318   QListWidget *walletEntriesWidget = findChild<QListWidget *>("WalletEntriesWidget");
0319   
0320   //
0321   // Fill the details table widget with the information
0322   // 
0323   switch (authInfo->type())
0324   {
0325     case Host:
0326     case Share:
0327     {
0328       detailsWidget->setColumnCount(2);
0329       detailsWidget->setRowCount(4);
0330           
0331       QTableWidgetItem *entry_label = new QTableWidgetItem(i18n("Entry"));
0332       entry_label->setFlags(entry_label->flags() & Qt::ItemIsEditable);
0333       entry_label->setForeground(palette().text());
0334           
0335       QTableWidgetItem *entry = new QTableWidgetItem(authInfo->displayString());
0336       entry->setFlags(entry->flags() & Qt::ItemIsEditable);
0337       entry->setForeground(palette().text());
0338           
0339       QTableWidgetItem *workgroup_label = new QTableWidgetItem(i18n("Workgroup"));
0340       workgroup_label->setFlags(workgroup_label->flags() & Qt::ItemIsEditable);
0341       workgroup_label->setForeground(palette().text());
0342           
0343       QTableWidgetItem *login_label = new QTableWidgetItem(i18n("Login"));
0344       login_label->setFlags(login_label->flags() & Qt::ItemIsEditable);
0345       login_label->setForeground(palette().text());
0346           
0347       QTableWidgetItem *password_label = new QTableWidgetItem(i18n("Password"));
0348       password_label->setFlags(password_label->flags() & Qt::ItemIsEditable);
0349       password_label->setForeground(palette().text());
0350           
0351       detailsWidget->setItem(0, 0, entry_label);
0352       detailsWidget->setItem(0, 1, entry);
0353       detailsWidget->setItem(1, 0, workgroup_label);
0354       detailsWidget->setItem(1, 1, new QTableWidgetItem(authInfo->workgroupName()));
0355       detailsWidget->setItem(2, 0, login_label);
0356       detailsWidget->setItem(2, 1, new QTableWidgetItem(authInfo->userName()));
0357       detailsWidget->setItem(3, 0, password_label);
0358       detailsWidget->setItem(3, 1, new QTableWidgetItem(authInfo->password()));
0359           
0360       break;
0361     }
0362     default:
0363     {
0364       detailsWidget->setColumnCount(2);
0365       detailsWidget->setRowCount(3);
0366           
0367       QTableWidgetItem *entry_label = new QTableWidgetItem(i18n("Entry"));
0368       entry_label->setFlags(entry_label->flags() & Qt::ItemIsEditable);
0369       entry_label->setForeground(palette().text());
0370           
0371       QTableWidgetItem *entry = new QTableWidgetItem(i18n("Default Login"));
0372       entry->setFlags(entry->flags() & Qt::ItemIsEditable);
0373       entry->setForeground(palette().text());
0374           
0375       QTableWidgetItem *login_label = new QTableWidgetItem(i18n("Login"));
0376       login_label->setFlags(login_label->flags() & Qt::ItemIsEditable);
0377       login_label->setForeground(palette().text());
0378           
0379       QTableWidgetItem *password_label = new QTableWidgetItem(i18n("Password"));
0380       password_label->setFlags(password_label->flags() & Qt::ItemIsEditable);
0381       password_label->setForeground(palette().text());
0382           
0383       detailsWidget->setItem(0, 0, entry_label);
0384       detailsWidget->setItem(0, 1, entry);
0385       detailsWidget->setItem(1, 0, login_label);
0386       detailsWidget->setItem(1, 1, new QTableWidgetItem(authInfo->userName()));
0387       detailsWidget->setItem(2, 0, password_label);
0388       detailsWidget->setItem(2, 1, new QTableWidgetItem(authInfo->password()));
0389           
0390       break;
0391     }
0392   }
0393   
0394   //
0395   // Connect signals
0396   // 
0397   connect(detailsWidget, SIGNAL(cellChanged(int,int)), this, SLOT(slotDetailsChanged(int,int)));  
0398   
0399   //
0400   // Enable the details box
0401   // 
0402   detailsGroupBox->setEnabled(!walletEntriesWidget->selectedItems().isEmpty());
0403 }
0404 
0405 
0406 void Smb4KConfigPageAuthentication::clearDetails()
0407 {
0408   //
0409   // Get the widgets
0410   // 
0411   QTableWidget *detailsWidget = findChild<QTableWidget *>("DetailsWidget");
0412   KCollapsibleGroupBox *detailsGroupBox = findChild<KCollapsibleGroupBox *>("DetailsBox");
0413   QListWidget *walletEntriesWidget = findChild<QListWidget *>("WalletEntriesWidget");
0414   
0415   //
0416   // Disconnect signals
0417   // 
0418   disconnect(detailsWidget, SIGNAL(cellChanged(int,int)), this, SLOT(slotDetailsChanged(int,int)));
0419   
0420   //
0421   // Collapse the details box and disable it.
0422   // 
0423   detailsGroupBox->setExpanded(false);
0424   detailsGroupBox->setEnabled(!walletEntriesWidget->selectedItems().isEmpty());
0425   
0426   // 
0427   // Clear the table widget
0428   // 
0429   if (detailsWidget->rowCount() != 0 && detailsWidget->columnCount() != 0)
0430   {
0431     detailsWidget->clear();
0432     detailsWidget->setRowCount(0);
0433     detailsWidget->setColumnCount(0);
0434   }
0435 }
0436 
0437 
0438 /////////////////////////////////////////////////////////////////////////////
0439 // SLOT IMPLEMENTATIONS
0440 /////////////////////////////////////////////////////////////////////////////
0441 
0442 void Smb4KConfigPageAuthentication::slotKWalletButtonToggled(bool checked)
0443 {
0444   findChild<QCheckBox *>("kcfg_UseDefaultLogin")->setEnabled(checked);
0445   findChild<QWidget *>("WalletEntriesEditor")->setEnabled(checked);
0446 }
0447 
0448 
0449 void Smb4KConfigPageAuthentication::slotDefaultLoginToggled(bool checked)
0450 {
0451   if (checked && !Smb4KSettings::useDefaultLogin())
0452   {
0453     emit setDefaultLogin();
0454   }
0455 }
0456 
0457 
0458 void Smb4KConfigPageAuthentication::slotItemSelectionChanged()
0459 {
0460   //
0461   // Get the list widget
0462   // 
0463   QListWidget *walletEntriesWidget = findChild<QListWidget *>("WalletEntriesWidget");
0464   
0465   // 
0466   // Clear details widget
0467   // 
0468   clearDetails();
0469 
0470   //
0471   // Get the authentication information and load its
0472   // details into the details widget
0473   // 
0474   if (walletEntriesWidget->currentItem())
0475   {
0476     for (Smb4KAuthInfo *authInfo : m_entriesList)
0477     {
0478       if (walletEntriesWidget->currentItem()->text() == authInfo->displayString() ||
0479           (walletEntriesWidget->currentItem()->text() == i18n("Default Login") && authInfo->type() == UnknownNetworkItem))
0480       {
0481         loadDetails(authInfo);
0482         break;
0483       }
0484     }
0485     
0486     // Enable actions
0487     findChild<QAction *>("EditAction")->setEnabled(true);
0488     findChild<QAction *>("RemoveAction")->setEnabled(true);
0489   }
0490 }
0491 
0492 
0493 void Smb4KConfigPageAuthentication::slotDetailsChanged(int row, int column)
0494 {
0495   //
0496   // Get the widget
0497   // 
0498   QTableWidget *detailsWidget = findChild<QTableWidget *>("DetailsWidget");
0499   
0500   //
0501   // Find the right authentication information and pass the modifications
0502   // 
0503   for (Smb4KAuthInfo *authInfo : m_entriesList)
0504   {
0505     if (QString::compare(detailsWidget->item(0, 1)->text(), authInfo->displayString()) == 0 ||
0506         (QString::compare(detailsWidget->item(0, 1)->text(), i18n("Default Login")) == 0 && authInfo->type() == UnknownNetworkItem))
0507     {
0508       switch (authInfo->type())
0509       {
0510         case Host:
0511         case Share:
0512         {
0513           if (column == 1)
0514           {
0515             switch (row)
0516             {
0517               case 1: // Workgroup
0518               {
0519                 authInfo->setWorkgroupName(detailsWidget->item(row, column)->text());
0520                 break;
0521               }
0522               case 2: // Login
0523               {
0524                 authInfo->setUserName(detailsWidget->item(row, column)->text());
0525                 break;
0526               }
0527               case 3: // Password
0528               {
0529                 authInfo->setPassword(detailsWidget->item(row, column)->text());
0530                 break;
0531               }
0532               default:
0533               {
0534                 break;
0535               }
0536             }
0537           }
0538             
0539           break;
0540         }
0541         default:
0542         {
0543           if (column == 1)
0544           {
0545             switch (row)
0546             {
0547               case 1: // Login
0548               {
0549                 authInfo->setUserName(detailsWidget->item(row, column)->text());
0550                 break;
0551               }
0552               case 2: // Password
0553               {
0554                 authInfo->setPassword(detailsWidget->item(row, column)->text());
0555                 break;
0556               }
0557               default:
0558               {
0559                 break;
0560               }
0561             }
0562           }
0563             
0564           break;
0565         }
0566       }
0567         
0568       break;
0569     }
0570   }
0571   
0572   //
0573   // Tell the program that the authentication information may be changed
0574   // and emit the appropriate signal
0575   // 
0576   m_maybe_changed = true;
0577   emit walletEntriesModified();
0578 }
0579 
0580 
0581 void Smb4KConfigPageAuthentication::slotEditClicked()
0582 {
0583   //
0584   // Get the widgets
0585   // 
0586   KCollapsibleGroupBox *detailsGroupBox = findChild<KCollapsibleGroupBox *>("DetailsBox");
0587   QListWidget *walletEntriesWidget = findChild<QListWidget *>("WalletEntriesWidget");
0588   
0589   if (walletEntriesWidget->currentItem())
0590   {
0591     //
0592     // Since the details have been loaded to the details widget already
0593     // by slotItemSelectionChanged(), only open the details widget here.
0594     // 
0595     if (!detailsGroupBox->isExpanded())
0596     {
0597       detailsGroupBox->setExpanded(true);
0598     }
0599   }
0600 }
0601 
0602 
0603 
0604 void Smb4KConfigPageAuthentication::slotRemoveClicked()
0605 {
0606   //
0607   // Get the list widget
0608   // 
0609   QListWidget *walletEntriesWidget = findChild<QListWidget *>("WalletEntriesWidget");
0610   
0611   //
0612   // Clear the details widget
0613   // 
0614   clearDetails();
0615 
0616   // 
0617   // Remove the appropriate entry from the list of authentication information
0618   // 
0619   for (int i = 0; i < m_entriesList.size(); ++i)
0620   {
0621     if (QString::compare(walletEntriesWidget->currentItem()->text(), m_entriesList.at(i)->displayString()) == 0 ||
0622         (QString::compare(walletEntriesWidget->currentItem()->text(), i18n("Default Login")) == 0 && m_entriesList.at(i)->type() == UnknownNetworkItem))
0623     {
0624       switch (m_entriesList.at(i)->type())
0625       {
0626         case UnknownNetworkItem:
0627         {
0628           QCheckBox *default_login = findChild<QCheckBox *>("kcfg_UseDefaultLogin");
0629           default_login->setChecked(false);
0630           break;
0631         }
0632         default:
0633         {
0634           break;
0635         }
0636       }
0637       
0638       delete m_entriesList.takeAt(i);
0639       break;
0640     }
0641     else
0642     {
0643       continue;
0644     }
0645   }
0646 
0647   //
0648   // Remove the current item
0649   // 
0650   delete walletEntriesWidget->currentItem();
0651   
0652   //
0653   // Enable actions
0654   // 
0655   findChild<QAction *>("ClearAction")->setEnabled((walletEntriesWidget->count() != 0));
0656   
0657   //
0658   // Tell the program that the authentication information may be changed
0659   // and emit the appropriate signal
0660   // 
0661   m_maybe_changed = true;
0662   emit walletEntriesModified();
0663 }
0664 
0665 
0666 void Smb4KConfigPageAuthentication::slotClearClicked()
0667 {
0668   //
0669   // Get the list widget
0670   // 
0671   QListWidget *walletEntriesWidget = findChild<QListWidget *>("WalletEntriesWidget");
0672   
0673   //
0674   // Clear the details widget
0675   // 
0676   clearDetails();
0677   
0678   //
0679   // Remove all entries from the view
0680   // 
0681   while (walletEntriesWidget->count() != 0)
0682   {
0683     delete walletEntriesWidget->item(0);
0684   }
0685   
0686   //
0687   // Remove all entries from the list off authentication information
0688   // 
0689   while(!m_entriesList.isEmpty())
0690   {
0691     delete m_entriesList.takeFirst();
0692   }
0693   
0694   //
0695   // Enabled widgets
0696   // 
0697   findChild<QAction *>("ClearAction")->setEnabled(false);
0698   
0699   //
0700   // Uncheck the Default Login checkbox
0701   // 
0702   findChild<QCheckBox *>("kcfg_UseDefaultLogin")->setChecked(false);
0703   
0704   //
0705   // Tell the program that the authentication information may be changed
0706   // and emit the appropriate signal
0707   // 
0708   m_maybe_changed = true;
0709   emit walletEntriesModified();
0710 }
0711 
0712 
0713 void Smb4KConfigPageAuthentication::slotSaveClicked(bool /*checked*/)
0714 {
0715   //
0716   // Get the list widget
0717   // 
0718   QListWidget *walletEntriesWidget = findChild<QListWidget *>("WalletEntriesWidget");
0719   
0720   //
0721   // Disable buttons
0722   // 
0723   findChild<QAction *>("EditAction")->setEnabled(false);
0724   findChild<QAction *>("RemoveAction")->setEnabled(false);
0725   findChild<QAction *>("ClearAction")->setEnabled((walletEntriesWidget->count() != 0));
0726   
0727   //
0728   // Clear the selection in the list view
0729   // 
0730   walletEntriesWidget->clearSelection();
0731  
0732   //
0733   // Tell the program that the authentication information may be changed
0734   // and emit the appropriate signal
0735   // 
0736   m_maybe_changed = false;
0737   emit walletEntriesModified();
0738 }
0739