TDE personal information management applications
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

91 lines
3.3 KiB

  1. /*******************************************************************
  2. KNotes -- Notes for the KDE project
  3. Copyright (c) 2003, Daniel Martin <daniel.martin@pirack.com>
  4. 2004, Michael Brade <brade@kde.org>
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. In addition, as a special exception, the copyright holders give
  17. permission to link the code of this program with any edition of
  18. the TQt library by Trolltech AS, Norway (or with modified versions
  19. of TQt that use the same license as TQt), and distribute linked
  20. combinations including the two. You must obey the GNU General
  21. Public License in all respects for all of the code used other than
  22. TQt. If you modify this file, you may extend this exception to
  23. your version of the file, but you are not obligated to do so. If
  24. you do not wish to do so, delete this exception statement from
  25. your version.
  26. *******************************************************************/
  27. #include <tqstring.h>
  28. #include <tqstringlist.h>
  29. #include <tqlabel.h>
  30. #include <tqvbox.h>
  31. #include <kdebug.h>
  32. #include <tdeglobal.h>
  33. #include <tdelocale.h>
  34. #include <kstandarddirs.h>
  35. #include <ksimpleconfig.h>
  36. #include <kcombobox.h>
  37. #include "knotehostdlg.h"
  38. #include "knotesglobalconfig.h"
  39. KNoteHostDlg::KNoteHostDlg( const TQString &caption, TQWidget *parent, const char *name )
  40. : KDialogBase( parent, name, true, caption, Ok|Cancel, Ok, true )
  41. {
  42. TQVBox *page = makeVBoxMainWidget();
  43. (void)new TQLabel( i18n("Hostname or IP address:"), page );
  44. m_hostCombo = new KHistoryCombo( true, page );
  45. m_hostCombo->setMinimumWidth( fontMetrics().maxWidth() * 15 );
  46. m_hostCombo->setDuplicatesEnabled( false );
  47. // Read known hosts from configfile
  48. m_hostCombo->setHistoryItems( KNotesGlobalConfig::knownHosts(), true );
  49. m_hostCombo->setFocus();
  50. //m_hostCombo->completionObject()->setItems( KNotesGlobalConfig::hostCompletions() );
  51. connect( m_hostCombo->lineEdit(), TQT_SIGNAL( textChanged ( const TQString & ) ),
  52. this, TQT_SLOT( slotTextChanged( const TQString & ) ) );
  53. slotTextChanged( m_hostCombo->lineEdit()->text() );
  54. }
  55. KNoteHostDlg::~KNoteHostDlg()
  56. {
  57. if ( result() == Accepted )
  58. m_hostCombo->addToHistory( m_hostCombo->currentText().stripWhiteSpace() );
  59. // Write known hosts to configfile
  60. KNotesGlobalConfig::setKnownHosts( m_hostCombo->historyItems() );
  61. //KNotesGlobalConfig::setHostCompletions( m_hostCombo->completionObject()->items() );
  62. KNotesGlobalConfig::writeConfig();
  63. }
  64. void KNoteHostDlg::slotTextChanged( const TQString& text )
  65. {
  66. enableButtonOK( !text.isEmpty() );
  67. }
  68. TQString KNoteHostDlg::host() const
  69. {
  70. return m_hostCombo->currentText();
  71. }
  72. #include "knotehostdlg.moc"