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.

133 lines
4.2KB

  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 "algorithmdialog.h"
  16. #include "algorithmcombo.h"
  17. #include "collectioncombo.h"
  18. #include <tqhbox.h>
  19. #include <tqlabel.h>
  20. #include <tqlayout.h>
  21. #include <tqscrollview.h>
  22. #include <tqvbox.h>
  23. #include <tqvgroupbox.h>
  24. #include <klocale.h>
  25. using namespace KMrml;
  26. class ScrollView : public TQScrollView
  27. {
  28. public:
  29. ScrollView(TQWidget* parent = 0, const char* name = 0)
  30. : TQScrollView(parent, name)
  31. {
  32. setFrameStyle(TQFrame::NoFrame);
  33. m_frame = new TQFrame(viewport(), "ScrollView::m_frame");
  34. m_frame->setFrameStyle(TQFrame::NoFrame);
  35. addChild(m_frame, 0, 0);
  36. };
  37. TQFrame* frame() {return m_frame;};
  38. protected:
  39. virtual void viewportResizeEvent(TQResizeEvent* ev)
  40. {
  41. TQScrollView::viewportResizeEvent(ev);
  42. m_frame->resize( kMax(m_frame->sizeHint().width(), ev->size().width()),
  43. kMax(m_frame->sizeHint().height(), ev->size().height()));
  44. };
  45. private:
  46. TQFrame* m_frame;
  47. };
  48. AlgorithmDialog::AlgorithmDialog( const AlgorithmList& algorithms,
  49. const CollectionList& collections,
  50. const Collection& currentColl,
  51. TQWidget *parent, const char *name )
  52. : KDialogBase( parent, name, false, i18n("Configure Query Algorithms"),
  53. Ok | Cancel, Ok, false ),
  54. m_allAlgorithms( algorithms ),
  55. m_collections( collections )
  56. {
  57. TQWidget *box = makeMainWidget();
  58. TQVBoxLayout *mainLayout = new TQVBoxLayout( box, 0, KDialog::spacingHint(),
  59. "mainLayout");
  60. TQHBoxLayout *collectionLayout = new TQHBoxLayout( 0L, 0, 0, "coll layout");
  61. collectionLayout->addWidget( new TQLabel( i18n("Collection: "), box ));
  62. m_collectionCombo = new CollectionCombo( box, "collection combo" );
  63. m_collectionCombo->setCollections( &m_collections );
  64. collectionLayout->addWidget( m_collectionCombo );
  65. mainLayout->addLayout( collectionLayout );
  66. mainLayout->addSpacing( 14 );
  67. TQHBox *algoHLayout = new TQHBox( box );
  68. (void) new TQLabel( i18n("Algorithm: "), algoHLayout);
  69. m_algoCombo = new AlgorithmCombo( algoHLayout, "algo combo" );
  70. TQVGroupBox *groupBox = new TQVGroupBox( box, "groupBox" );
  71. mainLayout->addWidget( groupBox );
  72. algoHLayout->raise();
  73. ScrollView *scrollView = new ScrollView( groupBox, "scroll view" );
  74. m_view = scrollView->frame();
  75. TQVBoxLayout *viewLayout = new TQVBoxLayout( scrollView );
  76. viewLayout->setSpacing( KDialog::spacingHint() );
  77. collectionChanged( currentColl );
  78. connect( m_algoCombo, TQT_SIGNAL( selected( const Algorithm& ) ),
  79. TQT_SLOT( initGUI( const Algorithm& ) ));
  80. connect( m_collectionCombo, TQT_SIGNAL( selected( const Collection& ) ),
  81. TQT_SLOT( collectionChanged( const Collection& ) ));
  82. algoHLayout->adjustSize();
  83. mainLayout->activate();
  84. algoHLayout->move( groupBox->x() + 10, groupBox->y() - 12 );
  85. box->setMinimumWidth( algoHLayout->sizeHint().width() +
  86. 4 * KDialog::spacingHint() );
  87. }
  88. AlgorithmDialog::~AlgorithmDialog()
  89. {
  90. }
  91. void AlgorithmDialog::collectionChanged( const Collection& coll )
  92. {
  93. m_algosForCollection = m_allAlgorithms.algorithmsForCollection( coll );
  94. m_algoCombo->setAlgorithms( &m_algosForCollection );
  95. initGUI( m_algoCombo->current() );
  96. }
  97. void AlgorithmDialog::initGUI( const Algorithm& algo )
  98. {
  99. m_algo = algo;
  100. }
  101. #include "algorithmdialog.moc"