device chooser populates with devices finally (Qt::ToolTip is evil?)

git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/trunk@753 6778bc44-b910-0410-a7a0-be141de4315d
This commit is contained in:
w1z7ard
2008-01-19 17:45:29 +00:00
parent 450ede190d
commit 9fc7cfd691
5 changed files with 16 additions and 35 deletions

View File

@ -1,5 +1,6 @@
#include "QPulseAudioDeviceChooser.hpp"
#include <QSettings>
#include <QtDebug>
void QPulseAudioDeviceChooser::writeSettings() {
@ -21,14 +22,15 @@ this->tryFirstPlayBackMonitorCheckBox->setCheckState
QPulseAudioDeviceChooser::QPulseAudioDeviceChooser(const QHash<int, QString> & devices, QWidget * parent = 0, Qt::WindowFlags f) : QDialog(parent, f), m_qpulseAudioDeviceModel(devices, this) {
setupUi(this);
readSettings();
readSettings();
qDebug() << "setting model";
this->devicesListView->setModel(&m_qpulseAudioDeviceModel);
}
void QPulseAudioDeviceChooser::open() {
this->show();
this->devicesListView->show();
//this->devicesListView->show()
}

View File

@ -6,47 +6,26 @@
QPulseAudioDeviceModel::QPulseAudioDeviceModel(const QHash<int, QString> & _devices, QObject * parent = 0):
devices(_devices) {}
void QPulseAudioDeviceModel::updateItemHighlights()
{
if ( rowCount() == 0 )
return;
emit ( dataChanged ( this->index ( 0,0 ), this->index ( rowCount()-1) ) )
;
}
QVariant QPulseAudioDeviceModel::data ( const QModelIndex & index, int role = Qt::DisplayRole ) const
{
if (!index.isValid())
if (!index.isValid())
return QVariant();
if (index.row() >= rowCount())
return QVariant();
QHash<int, QString>::const_iterator pos;
qDebug() << "role: " << role;
switch ( role )
{
case Qt::DisplayRole:
pos = devices.begin() + index.row();
return *pos;
case Qt::ToolTip:
return QString("These never show up.");
case Qt::DecorationRole:
return QVariant();
case Qt::BackgroundRole:
// return Qt::red;
// return Qt::green;
return Qt::white;
default:
return QVariant();
}
}
int QPulseAudioDeviceModel::rowCount ( const QModelIndex & parent) const
{
{
return devices.count();
}

View File

@ -38,8 +38,6 @@
QVariant data ( const QModelIndex & index, int role) const;
int rowCount ( const QModelIndex & parent = QModelIndex()) const ;
public slots:
void updateItemHighlights();
private:
const QHash<int, QString> & devices;
};

View File

@ -4,7 +4,7 @@
#include <QString>
#include <QVector>
QPulseAudioThread::SourceContainer QPulseAudioThread::sourceList;
/* $Id: pacat.c 1426 2007-02-13 15:35:19Z ossman $ */
@ -72,6 +72,7 @@ static pa_channel_map channel_map;
static int channel_map_set = 0;
static pa_sample_spec sample_spec ;
QPulseAudioThread::SourceContainer QPulseAudioThread::sourceList;
QPulseAudioThread::QPulseAudioThread ( int _argc, char **_argv, projectM * _projectM, QObject * parent ) : QThread ( parent ), argc ( _argc ), argv ( _argv ), m_projectM ( _projectM ), sourceIndex ( -1 ) {
@ -151,20 +152,21 @@ void QPulseAudioThread::connectSource ( int index )
return;
}
index = 0;
index = -1;
for ( SourceContainer::const_iterator pos = sourceList.begin(); pos != sourceList.end(); ++pos )
{
index++;
qDebug() << "Scanning " << *pos;
if ( ( *pos).contains ( "monitor" ) )
{
qDebug() << "connecting to monitor device" << *pos;
break;
}
index++;
}
}
assert ( !sourceList.empty() );
}
assert (index < sourceList.count());
int r;
if ( ( ( r = pa_stream_connect_record ( stream, sourceList[index].toStdString().c_str(), NULL, flags ) ) ) < 0 )
{

View File

@ -96,7 +96,6 @@ int main ( int argc, char*argv[] )
QProjectM_MainWindow * mainWindow = new QProjectM_MainWindow ( config_file );
QAction pulseAction("Pulse audio settings...", mainWindow);
@ -119,7 +118,8 @@ int main ( int argc, char*argv[] )
mainWindow->unregisterSettingsAction(&pulseAction);
delete(mainWindow);
/// @bug this blows up the program!
//delete(mainWindow);
return ret;
}