[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/phonon
From:       Matthias Kretz <kretz () kde ! org>
Date:       2007-02-01 15:25:13
Message-ID: 1170343513.958279.18001.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 629141 by mkretz:

- add a convenience ctor to ObjectDescriptionModel that takes the data in
  the ctor
- guitest now shows the available audio output devices in a combobox and
  switches the device on a selection change


 M  +9 -0      objectdescriptionmodel.cpp  
 M  +11 -5     objectdescriptionmodel.h  
 M  +19 -2     ui/tests/guitest.cpp  
 M  +3 -0      ui/tests/guitest.h  


--- trunk/KDE/kdelibs/phonon/objectdescriptionmodel.cpp #629140:629141
@@ -141,6 +141,15 @@
 }
 
 template<ObjectDescriptionType type>
+ObjectDescriptionModel<type>::ObjectDescriptionModel(const \
QList<ObjectDescription<type> > &data, QObject *parent) +    : \
QAbstractListModel(parent), +    d_ptr(new ObjectDescriptionModelPrivate<type>)
+{
+    d_ptr->q_ptr = this;
+    setModelData(data);
+}
+
+template<ObjectDescriptionType type>
 ObjectDescriptionModel<type>::~ObjectDescriptionModel()
 {
 	delete d_ptr;
--- trunk/KDE/kdelibs/phonon/objectdescriptionmodel.h #629140:629141
@@ -80,12 +80,18 @@
             void *qt_metacast(const char *_clname);
             //int qt_metacall(QMetaObject::Call _c, int _id, void **_a);
 
-			/**
-			 * Constructs a ObjectDescription model with the
-			 * given \p parent.
-			 */
-			ObjectDescriptionModel( QObject* parent = 0 );
+            /**
+             * Constructs a ObjectDescription model with the
+             * given \p parent.
+             */
+            explicit ObjectDescriptionModel(QObject *parent = 0);
 
+            /**
+             * Constructs a ObjectDescription model with the
+             * given \p parent and the given \p data.
+             */
+            explicit ObjectDescriptionModel(const QList<ObjectDescription<type> > \
&data, QObject *parent = 0); +
 			virtual ~ObjectDescriptionModel();
 
 			/**
--- trunk/KDE/kdelibs/phonon/ui/tests/guitest.cpp #629140:629141
@@ -49,6 +49,8 @@
 #include <QMouseEvent>
 #include <QPaintEvent>
 #include <QPainter>
+#include <QComboBox>
+#include <phonon/objectdescriptionmodel.h>
 
 using namespace Phonon;
 
@@ -61,13 +63,28 @@
 
 	m_output->setName( "GUI-Test" );
 
-	QHBoxLayout *hlayout = new QHBoxLayout( this );
+	QVBoxLayout *vlayout = new QVBoxLayout( this );
 
+    QComboBox *deviceComboBox = new QComboBox(this);
+    vlayout->addWidget(deviceComboBox);
+    QList<AudioOutputDevice> deviceList = \
BackendCapabilities::availableAudioOutputDevices(); +    deviceComboBox->setModel(new \
AudioOutputDeviceModel(deviceList, deviceComboBox)); +    \
deviceComboBox->setCurrentIndex(deviceList.indexOf(m_output->outputDevice())); +    \
connect(deviceComboBox, SIGNAL(currentIndexChanged(int)), SLOT(deviceChange(int))); +
 	m_volslider = new VolumeSlider( this );
 	m_volslider->setAudioOutput( m_output );
-	hlayout->addWidget( m_volslider );
+	vlayout->addWidget( m_volslider );
 }
 
+void OutputWidget::deviceChange(int modelIndex)
+{
+    QList<AudioOutputDevice> deviceList = \
BackendCapabilities::availableAudioOutputDevices(); +    if (modelIndex >= 0 && \
modelIndex < deviceList.size()) { +        \
m_output->setOutputDevice(deviceList[modelIndex]); +    }
+}
+
 PathWidget::PathWidget( QWidget *parent )
 	: QFrame( parent )
 	, m_path( new AudioPath( this ) )
--- trunk/KDE/kdelibs/phonon/ui/tests/guitest.h #629140:629141
@@ -95,6 +95,9 @@
 
 		AudioOutput *output() const { return m_output; }
 
+    private Q_SLOTS:
+        void deviceChange(int);
+
 	private:
 		VolumeSlider *m_volslider;
 		AudioOutput *m_output;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic