TDE graphics utilities
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.

67 lines
1.8KB

  1. /* This file is part of the KDE project
  2. Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public
  5. License as published by the Free Software Foundation, version 2.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  9. General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program; see the file COPYING. If not, write to
  12. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  13. Boston, MA 02110-1301, USA.
  14. */
  15. #include "algorithmcombo.h"
  16. #include <kdatastream.h>
  17. using namespace KMrml;
  18. // ### copycat of CollectionCombo... moc can't handle templates unfortunately..
  19. // could use base-class MrmlElement....
  20. AlgorithmCombo::AlgorithmCombo( TQWidget *parent, const char *name )
  21. : KComboBox( false, parent, name ),
  22. m_algorithms( 0L )
  23. {
  24. connect( this, TQT_SIGNAL( activated( const TQString& ) ),
  25. TQT_SLOT( slotActivated( const TQString& ) ));
  26. }
  27. AlgorithmCombo::~AlgorithmCombo()
  28. {
  29. }
  30. void AlgorithmCombo::setAlgorithms( const AlgorithmList *algorithms )
  31. {
  32. assert( algorithms != 0L );
  33. clear();
  34. m_algorithms = algorithms;
  35. insertStringList( algorithms->itemNames() );
  36. // #### block signals here?
  37. }
  38. void AlgorithmCombo::setCurrent( const Algorithm& coll )
  39. {
  40. setCurrentItem( coll.name() );
  41. }
  42. Algorithm AlgorithmCombo::current() const
  43. {
  44. return m_algorithms->findByName( currentText() );
  45. }
  46. void AlgorithmCombo::slotActivated( const TQString& name )
  47. {
  48. Algorithm coll = m_algorithms->findByName( name );
  49. emit selected( coll );
  50. }
  51. #include "algorithmcombo.moc"