]> Git trees. - libqmvoc.git/commitdiff
make use of .ui-files for the spectrum
authorCarsten Niehaus <cniehaus@gmx.de>
Tue, 26 Jul 2005 13:44:11 +0000 (13:44 +0000)
committerCarsten Niehaus <cniehaus@gmx.de>
Tue, 26 Jul 2005 13:44:11 +0000 (13:44 +0000)
svn path=/trunk/KDE/kdeedu/kalzium/src/spectrum.h; revision=438889

kalzium/src/spectrum.cpp
kalzium/src/spectrum.h

index 64b404186de3e730aa79c9eb9b0f6e200f90eaef..a46a9120ddb22e45f2ced725fa57fe7d6ca55aa5 100644 (file)
 #include "spectrum.h"
 #include "spectrumwidget.h"
 #include "exporter.h"
+#include "spectrumview.h"
 
 #include <qlayout.h>
 #include <qlabel.h>
 #include <qpopupmenu.h>
+#include <qtooltip.h>
 
 #include <kaction.h>
 #include <kactioncollection.h>
@@ -163,85 +165,4 @@ QString Spectrum::BandsAsHtml()
        return html;
 }
 
-SpectrumView::SpectrumView( Spectrum *spec, QWidget *parent, const char* name )
-       : QWidget( parent, name )
-{
-       QVBoxLayout *spectrumLayout = new QVBoxLayout( this, 0, KDialog::spacingHint(), "spectrumLayout" );
-
-       m_spectrum = spec->adjustToWavelength( 100.0, 1000.0 );
-       m_spectrum->adjustMinMax();
-       
-       m_spectrumWidget = new SpectrumWidget( this, "spectrum" );
-       m_spectrumWidget->setSpectrum( m_spectrum );
-       
-       //m_spectrumWidget->setBorders( m_spectrum->min(), m_spectrum->max() );
-       
-       spectrumLayout->addWidget( m_spectrumWidget );
-
-       QHBoxLayout *hbox = new QHBoxLayout( this, 0, KDialog::spacingHint() );
-       QHBoxLayout *hbox1 = new QHBoxLayout( this, 0, KDialog::spacingHint() );
-       QHBoxLayout *hbox2 = new QHBoxLayout( this, 0, KDialog::spacingHint() );
-//X    m_spinbox_left = new QSpinBox( m_spectrum->min(), m_spectrum->max()-1, 1, this );
-//X    m_spinbox_right = new QSpinBox( m_spectrum->min()+1, m_spectrum->max(), 1, this );i
-       m_spinbox_left = new QSpinBox( 100, 1000, 1, this );
-       m_spinbox_right = new QSpinBox( 100, 1000, 1, this );
-//X    m_spinbox_left->setValue(  ( double ) m_spectrum->min() );
-//X    m_spinbox_right->setValue( ( double ) m_spectrum->max() );
-       m_button_save = new KPushButton( KGuiItem( i18n( "Export spectrum as..." ), "fileexport" ), this, "button_save" );
-       QPopupMenu *pp = new QPopupMenu( m_button_save );
-       m_button_save->setPopup( pp );
-       KActionCollection *coll = new KActionCollection( this );
-       KAction *actExpImage = new KAction( i18n( "Image" ), "image", 0,
-                                 this, SLOT( slotExportAsImage() ), coll, "export_image" );
-       actExpImage->plug( pp );
-
-       connect( m_spinbox_right, SIGNAL( valueChanged( int ) ), m_spectrumWidget, SLOT( setRightBorder( int ) ) );
-       connect( m_spinbox_left, SIGNAL( valueChanged( int ) ), m_spectrumWidget, SLOT( setLeftBorder( int ) ) );
-       connect( m_spectrumWidget, SIGNAL( bordersChanged( int, int ) ), this, SLOT( slotBordersChanged( int, int ) ) );        
-
-       m_spectrumbox = new KComboBox( this, "combobox" );
-       m_spectrumbox->insertItem( i18n( "Emission Spectrum" ) );
-       m_spectrumbox->insertItem( i18n( "Absorption Spectrum" ) );
-       connect( m_spectrumbox, SIGNAL( activated( int ) ), m_spectrumWidget, SLOT( slotActivateSpectrum( int ) ) );
-       
-       m_spinbox_left->setValue( 100 );
-       m_spinbox_right->setValue( 1000 );
-       m_spectrumWidget->setBorders( 100, 1000 );
-
-       hbox->addWidget( new QLabel( i18n( "Minimum Value:" ), this ) );
-       hbox->addWidget( m_spinbox_left );
-       hbox->addWidget( new QLabel( i18n( "Maximum Value:" ), this ) );
-       hbox->addWidget( m_spinbox_right );
-
-       hbox1->addWidget( new QLabel( i18n( "Type of Spectrum:" ), this ) );
-       hbox1->addWidget( m_spectrumbox );
-
-       hbox2->addItem( new QSpacerItem( 10, 10, QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-       hbox2->addWidget( m_button_save );
-
-       spectrumLayout->addLayout( hbox );
-       spectrumLayout->addLayout( hbox1 );
-       spectrumLayout->addLayout( hbox2 );
-}
-
-void SpectrumView::slotBordersChanged( int left, int right )
-{
-       m_spinbox_left->setValue( left );
-       m_spinbox_right->setValue( right );
-}
-
-void SpectrumView::slotExportAsImage()
-{
-       Exporter* exporter = new Exporter();
-       QString fileName = KFileDialog::getSaveFileName(
-                               QString::null, exporter->supportedImageFormats(),
-                               this, i18n( "Save Spectrum" ) );
-       if( !fileName.isEmpty() )
-       {
-               if ( !exporter->saveAsImage( &m_spectrumWidget->pixmap(), fileName ) )
-                       KMessageBox::error( this, i18n( "The spectrum could not be saved" ), i18n( "Image could not be saved") );
-       }       
-       delete exporter;
-}
-
 #include "spectrum.moc"
index 2606c18251368820529623382d9daba5abaddb54..35c22a7f80e63b93f55afc18ee987041888fdac6 100644 (file)
@@ -36,6 +36,7 @@
 
 class SpectrumWidget;
 class KPushButton;
+class SpectrumView;
 
 /**
  * @author Carsten Niehaus
@@ -186,32 +187,4 @@ class Spectrum
 
                Element* m_parentElement;
 };
-
-/**
- * @author Carsten Niehaus
- */
-class SpectrumView : public QWidget
-{
-       Q_OBJECT
-
-       public: 
-               SpectrumView( Spectrum *spec, QWidget* parent, const char* name );
-
-       private:
-               SpectrumWidget *m_spectrumWidget;
-
-               Spectrum* m_spectrum;
-
-               QSpinBox *m_spinbox_left, *m_spinbox_right;
-
-               KComboBox *m_spectrumbox;
-
-               KPushButton *m_button_save;
-
-       public slots:
-               void slotBordersChanged( int, int );
-               void slotExportAsImage();
-};
-
 #endif // SPECTRUM_H
-