knotes
knotehostdlg.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include <QLabel>
00034 #include <QString>
00035 #include <QLineEdit>
00036
00037 #include <kconfig.h>
00038 #include <kdebug.h>
00039 #include <kglobal.h>
00040 #include <khistorycombobox.h>
00041 #include <klocale.h>
00042 #include <kstandarddirs.h>
00043 #include <kvbox.h>
00044
00045 #include "knotehostdlg.h"
00046 #include "knotesglobalconfig.h"
00047
00048
00049 KNoteHostDlg::KNoteHostDlg( const QString &caption, QWidget *parent )
00050 : KDialog( parent )
00051 {
00052 setCaption( caption );
00053 setButtons( Ok|Cancel );
00054 KVBox *page = new KVBox( this );
00055 setMainWidget( page );
00056 ( void ) new QLabel( i18n("Hostname or IP address:"), page );
00057
00058 m_hostCombo = new KHistoryComboBox( true, page );
00059 m_hostCombo->setMinimumWidth( fontMetrics().maxWidth() * 15 );
00060 m_hostCombo->setDuplicatesEnabled( false );
00061
00062
00063 m_hostCombo->setHistoryItems( KNotesGlobalConfig::knownHosts(), true );
00064 m_hostCombo->setFocus();
00065
00066
00067 connect( m_hostCombo->lineEdit(), SIGNAL( textChanged ( const QString & ) ),
00068 this, SLOT( slotTextChanged( const QString & ) ) );
00069 slotTextChanged( m_hostCombo->lineEdit()->text() );
00070 }
00071
00072 KNoteHostDlg::~KNoteHostDlg()
00073 {
00074 if ( result() == Accepted ) {
00075 m_hostCombo->addToHistory( m_hostCombo->currentText().trimmed() );
00076 }
00077
00078
00079 KNotesGlobalConfig::setKnownHosts( m_hostCombo->historyItems() );
00080
00081
00082 KNotesGlobalConfig::self()->writeConfig();
00083 }
00084
00085 void KNoteHostDlg::slotTextChanged( const QString &text )
00086 {
00087 enableButton( Ok, !text.isEmpty() );
00088 }
00089
00090 QString KNoteHostDlg::host() const
00091 {
00092 return m_hostCombo->currentText();
00093 }
00094
00095
00096 #include "knotehostdlg.moc"