/[svn]/qsampler/trunk/src/qsamplerChannel.cpp
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerChannel.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1367 by capela, Mon Oct 1 22:03:35 2007 UTC revision 1461 by schoenebeck, Sun Oct 28 23:30:36 2007 UTC
# Line 19  Line 19 
19    
20  *****************************************************************************/  *****************************************************************************/
21    
22    #include "qsamplerUtilities.h"
23  #include "qsamplerAbout.h"  #include "qsamplerAbout.h"
24  #include "qsamplerChannel.h"  #include "qsamplerChannel.h"
25    
# Line 34  Line 35 
35    
36  #define QSAMPLER_INSTRUMENT_MAX 100  #define QSAMPLER_INSTRUMENT_MAX 100
37    
38    using namespace QSampler;
39    
40  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
41  // qsamplerChannel - Sampler channel structure.  // qsamplerChannel - Sampler channel structure.
# Line 70  qsamplerChannel::~qsamplerChannel (void) Line 72  qsamplerChannel::~qsamplerChannel (void)
72  // Create a new sampler channel, if not already.  // Create a new sampler channel, if not already.
73  bool qsamplerChannel::addChannel (void)  bool qsamplerChannel::addChannel (void)
74  {  {
75          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm* pMainForm = MainForm::getInstance();
76          if (pMainForm == NULL)          if (pMainForm == NULL)
77                  return false;                  return false;
78          if (pMainForm->client() == NULL)          if (pMainForm->client() == NULL)
# Line 95  bool qsamplerChannel::addChannel (void) Line 97  bool qsamplerChannel::addChannel (void)
97  // Remove sampler channel.  // Remove sampler channel.
98  bool qsamplerChannel::removeChannel (void)  bool qsamplerChannel::removeChannel (void)
99  {  {
100          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
101          if (pMainForm == NULL)          if (pMainForm == NULL)
102                  return false;                  return false;
103          if (pMainForm->client() == NULL)          if (pMainForm->client() == NULL)
# Line 145  const QString& qsamplerChannel::engineNa Line 147  const QString& qsamplerChannel::engineNa
147    
148  bool qsamplerChannel::loadEngine ( const QString& sEngineName )  bool qsamplerChannel::loadEngine ( const QString& sEngineName )
149  {  {
150          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
151          if (pMainForm == NULL)          if (pMainForm == NULL)
152                  return false;                  return false;
153          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 192  int qsamplerChannel::instrumentStatus (v Line 194  int qsamplerChannel::instrumentStatus (v
194  // Instrument file loader.  // Instrument file loader.
195  bool qsamplerChannel::loadInstrument ( const QString& sInstrumentFile, int iInstrumentNr )  bool qsamplerChannel::loadInstrument ( const QString& sInstrumentFile, int iInstrumentNr )
196  {  {
197          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
198          if (pMainForm == NULL)          if (pMainForm == NULL)
199                  return false;                  return false;
200          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 202  bool qsamplerChannel::loadInstrument ( c Line 204  bool qsamplerChannel::loadInstrument ( c
204          if (m_iInstrumentStatus == 100 && m_sInstrumentFile == sInstrumentFile && m_iInstrumentNr == iInstrumentNr)          if (m_iInstrumentStatus == 100 && m_sInstrumentFile == sInstrumentFile && m_iInstrumentNr == iInstrumentNr)
205                  return true;                  return true;
206    
207          if (::lscp_load_instrument_non_modal(pMainForm->client(), sInstrumentFile.latin1(), iInstrumentNr, m_iChannelID) != LSCP_OK) {          if (
208                    ::lscp_load_instrument_non_modal(
209                            pMainForm->client(),
210                            qsamplerUtilities::lscpEscapePath(sInstrumentFile).latin1(),
211                            iInstrumentNr, m_iChannelID
212                    ) != LSCP_OK
213            ) {
214                  appendMessagesClient("lscp_load_instrument");                  appendMessagesClient("lscp_load_instrument");
215                  return false;                  return false;
216          }          }
# Line 238  const QString& qsamplerChannel::midiDriv Line 246  const QString& qsamplerChannel::midiDriv
246    
247  bool qsamplerChannel::setMidiDriver ( const QString& sMidiDriver )  bool qsamplerChannel::setMidiDriver ( const QString& sMidiDriver )
248  {  {
249          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
250          if (pMainForm == NULL)          if (pMainForm == NULL)
251                  return false;                  return false;
252          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 266  int qsamplerChannel::midiDevice (void) c Line 274  int qsamplerChannel::midiDevice (void) c
274    
275  bool qsamplerChannel::setMidiDevice ( int iMidiDevice )  bool qsamplerChannel::setMidiDevice ( int iMidiDevice )
276  {  {
277          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
278          if (pMainForm == NULL)          if (pMainForm == NULL)
279                  return false;                  return false;
280          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 294  int qsamplerChannel::midiPort (void) con Line 302  int qsamplerChannel::midiPort (void) con
302    
303  bool qsamplerChannel::setMidiPort ( int iMidiPort )  bool qsamplerChannel::setMidiPort ( int iMidiPort )
304  {  {
305          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
306          if (pMainForm == NULL)          if (pMainForm == NULL)
307                  return false;                  return false;
308          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 322  int qsamplerChannel::midiChannel (void) Line 330  int qsamplerChannel::midiChannel (void)
330    
331  bool qsamplerChannel::setMidiChannel ( int iMidiChannel )  bool qsamplerChannel::setMidiChannel ( int iMidiChannel )
332  {  {
333          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
334          if (pMainForm == NULL)          if (pMainForm == NULL)
335                  return false;                  return false;
336          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 350  int qsamplerChannel::midiMap (void) cons Line 358  int qsamplerChannel::midiMap (void) cons
358    
359  bool qsamplerChannel::setMidiMap ( int iMidiMap )  bool qsamplerChannel::setMidiMap ( int iMidiMap )
360  {  {
361          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
362          if (pMainForm == NULL)          if (pMainForm == NULL)
363                  return false;                  return false;
364          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 378  int qsamplerChannel::audioDevice (void) Line 386  int qsamplerChannel::audioDevice (void)
386    
387  bool qsamplerChannel::setAudioDevice ( int iAudioDevice )  bool qsamplerChannel::setAudioDevice ( int iAudioDevice )
388  {  {
389          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
390          if (pMainForm == NULL)          if (pMainForm == NULL)
391                  return false;                  return false;
392          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 406  const QString& qsamplerChannel::audioDri Line 414  const QString& qsamplerChannel::audioDri
414    
415  bool qsamplerChannel::setAudioDriver ( const QString& sAudioDriver )  bool qsamplerChannel::setAudioDriver ( const QString& sAudioDriver )
416  {  {
417          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
418          if (pMainForm == NULL)          if (pMainForm == NULL)
419                  return false;                  return false;
420          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 434  float qsamplerChannel::volume (void) con Line 442  float qsamplerChannel::volume (void) con
442    
443  bool qsamplerChannel::setVolume ( float fVolume )  bool qsamplerChannel::setVolume ( float fVolume )
444  {  {
445          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
446          if (pMainForm == NULL)          if (pMainForm == NULL)
447                  return false;                  return false;
448          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 462  bool qsamplerChannel::channelMute (void) Line 470  bool qsamplerChannel::channelMute (void)
470    
471  bool qsamplerChannel::setChannelMute ( bool bMute )  bool qsamplerChannel::setChannelMute ( bool bMute )
472  {  {
473          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
474          if (pMainForm == NULL)          if (pMainForm == NULL)
475                  return false;                  return false;
476          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 492  bool qsamplerChannel::channelSolo (void) Line 500  bool qsamplerChannel::channelSolo (void)
500    
501  bool qsamplerChannel::setChannelSolo ( bool bSolo )  bool qsamplerChannel::setChannelSolo ( bool bSolo )
502  {  {
503          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
504          if (pMainForm == NULL)          if (pMainForm == NULL)
505                  return false;                  return false;
506          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 522  int qsamplerChannel::audioChannel ( int Line 530  int qsamplerChannel::audioChannel ( int
530    
531  bool qsamplerChannel::setAudioChannel ( int iAudioOut, int iAudioIn )  bool qsamplerChannel::setAudioChannel ( int iAudioOut, int iAudioIn )
532  {  {
533          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
534          if (pMainForm == NULL)          if (pMainForm == NULL)
535                  return false;                  return false;
536          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 564  void qsamplerChannel::updateInstrumentNa Line 572  void qsamplerChannel::updateInstrumentNa
572  // Update whole channel info state.  // Update whole channel info state.
573  bool qsamplerChannel::updateChannelInfo (void)  bool qsamplerChannel::updateChannelInfo (void)
574  {  {
575          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
576          if (pMainForm == NULL)          if (pMainForm == NULL)
577                  return false;                  return false;
578          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 580  bool qsamplerChannel::updateChannelInfo Line 588  bool qsamplerChannel::updateChannelInfo
588    
589  #ifdef CONFIG_INSTRUMENT_NAME  #ifdef CONFIG_INSTRUMENT_NAME
590          // We got all actual instrument datum...          // We got all actual instrument datum...
591          m_sInstrumentFile = pChannelInfo->instrument_file;          m_sInstrumentFile =
592                    qsamplerUtilities::lscpEscapedPathToPosix(pChannelInfo->instrument_file);
593          m_iInstrumentNr   = pChannelInfo->instrument_nr;          m_iInstrumentNr   = pChannelInfo->instrument_nr;
594          m_sInstrumentName = pChannelInfo->instrument_name;          m_sInstrumentName =
595                    qsamplerUtilities::lscpEscapedTextToRaw(pChannelInfo->instrument_name);
596  #else  #else
597          // First, check if intrument name has changed,          // First, check if intrument name has changed,
598          // taking care that instrument name lookup might be expensive,          // taking care that instrument name lookup might be expensive,
# Line 656  bool qsamplerChannel::updateChannelInfo Line 666  bool qsamplerChannel::updateChannelInfo
666  // Reset channel method.  // Reset channel method.
667  bool qsamplerChannel::channelReset (void)  bool qsamplerChannel::channelReset (void)
668  {  {
669          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
670          if (pMainForm == NULL)          if (pMainForm == NULL)
671                  return false;                  return false;
672          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 677  bool qsamplerChannel::channelReset (void Line 687  bool qsamplerChannel::channelReset (void
687  bool qsamplerChannel::editChannel (void)  bool qsamplerChannel::editChannel (void)
688  {  {
689  #ifdef CONFIG_EDIT_INSTRUMENT  #ifdef CONFIG_EDIT_INSTRUMENT
690          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();  
691            MainForm *pMainForm = MainForm::getInstance();
692          if (pMainForm == NULL)          if (pMainForm == NULL)
693                  return false;                  return false;
694          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
695                  return false;                  return false;
696    
697          if (::lscp_edit_instrument(pMainForm->client(), m_iChannelID) != LSCP_OK) {          if (::lscp_edit_channel_instrument(pMainForm->client(), m_iChannelID)
698                  appendMessagesClient("lscp_edit_instrument");                  != LSCP_OK) {
699                    appendMessagesClient("lscp_edit_channel_instrument");
700                  appendMessagesError(QObject::tr(                  appendMessagesError(QObject::tr(
701                          "Could not launch an appropriate instrument editor "                          "Could not launch an appropriate instrument editor "
702                          "for the given instrument!\n"                          "for the given instrument!\n"
703                          "Make sure you have an appropriate instrument editor like"                          "Make sure you have an appropriate "
704                          "'gigedit' installed and that it placed its mandatory "                          "instrument editor like 'gigedit' installed\n"
705                          "DLL file into the sampler's plugin directory.")                          "and that it placed its mandatory DLL file "
706                            "into the sampler's plugin directory.")
707                  );                  );
708                  return false;                  return false;
709          }          }
# Line 698  bool qsamplerChannel::editChannel (void) Line 711  bool qsamplerChannel::editChannel (void)
711          appendMessages(QObject::tr("edit instrument."));          appendMessages(QObject::tr("edit instrument."));
712    
713          return true;          return true;
714    
715  #else  #else
716    
717          appendMessagesError(QObject::tr(          appendMessagesError(QObject::tr(
718                  "Sorry, QSampler was compiled for a version of liblscp "                  "Sorry, QSampler was compiled for a version of liblscp "
719                  "which lacks this feature.\n"                  "which lacks this feature.\n"
720                  "You may want to update liblscp and recompile QSampler afterwards.")                  "You may want to update liblscp and recompile QSampler afterwards.")
721          );          );
722    
723          return false;          return false;
724    
725  #endif  #endif
726  }  }
727    
# Line 712  bool qsamplerChannel::editChannel (void) Line 729  bool qsamplerChannel::editChannel (void)
729  // Channel setup dialog form.  // Channel setup dialog form.
730  bool qsamplerChannel::channelSetup ( QWidget *pParent )  bool qsamplerChannel::channelSetup ( QWidget *pParent )
731  {  {
732          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
733          if (pMainForm == NULL)          if (pMainForm == NULL)
734                  return false;                  return false;
735    
# Line 720  bool qsamplerChannel::channelSetup ( QWi Line 737  bool qsamplerChannel::channelSetup ( QWi
737    
738          appendMessages(QObject::tr("setup..."));          appendMessages(QObject::tr("setup..."));
739    
740          qsamplerChannelForm *pChannelForm = new qsamplerChannelForm(pParent);          ChannelForm *pChannelForm = new ChannelForm(pParent);
741          if (pChannelForm) {          if (pChannelForm) {
742                  pChannelForm->setup(this);                  pChannelForm->setup(this);
743                  bResult = pChannelForm->exec();                  bResult = pChannelForm->exec();
# Line 734  bool qsamplerChannel::channelSetup ( QWi Line 751  bool qsamplerChannel::channelSetup ( QWi
751  // Redirected messages output methods.  // Redirected messages output methods.
752  void qsamplerChannel::appendMessages( const QString& s ) const  void qsamplerChannel::appendMessages( const QString& s ) const
753  {  {
754          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
755          if (pMainForm)          if (pMainForm)
756                  pMainForm->appendMessages(channelName() + ' ' + s);                  pMainForm->appendMessages(channelName() + ' ' + s);
757  }  }
# Line 742  void qsamplerChannel::appendMessages( co Line 759  void qsamplerChannel::appendMessages( co
759  void qsamplerChannel::appendMessagesColor( const QString& s,  void qsamplerChannel::appendMessagesColor( const QString& s,
760          const QString& c ) const          const QString& c ) const
761  {  {
762          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
763          if (pMainForm)          if (pMainForm)
764                  pMainForm->appendMessagesColor(channelName() + ' ' + s, c);                  pMainForm->appendMessagesColor(channelName() + ' ' + s, c);
765  }  }
766    
767  void qsamplerChannel::appendMessagesText( const QString& s ) const  void qsamplerChannel::appendMessagesText( const QString& s ) const
768  {  {
769          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
770          if (pMainForm)          if (pMainForm)
771                  pMainForm->appendMessagesText(channelName() + ' ' + s);                  pMainForm->appendMessagesText(channelName() + ' ' + s);
772  }  }
773    
774  void qsamplerChannel::appendMessagesError( const QString& s ) const  void qsamplerChannel::appendMessagesError( const QString& s ) const
775  {  {
776          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
777          if (pMainForm)          if (pMainForm)
778                  pMainForm->appendMessagesError(channelName() + "\n\n" + s);                  pMainForm->appendMessagesError(channelName() + "\n\n" + s);
779  }  }
780    
781  void qsamplerChannel::appendMessagesClient( const QString& s ) const  void qsamplerChannel::appendMessagesClient( const QString& s ) const
782  {  {
783          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
784          if (pMainForm)          if (pMainForm)
785                  pMainForm->appendMessagesClient(channelName() + ' ' + s);                  pMainForm->appendMessagesClient(channelName() + ' ' + s);
786  }  }
# Line 772  void qsamplerChannel::appendMessagesClie Line 789  void qsamplerChannel::appendMessagesClie
789  // Context menu event handler.  // Context menu event handler.
790  void qsamplerChannel::contextMenuEvent( QContextMenuEvent *pEvent )  void qsamplerChannel::contextMenuEvent( QContextMenuEvent *pEvent )
791  {  {
792          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
793          if (pMainForm)          if (pMainForm)
794                  pMainForm->contextMenuEvent(pEvent);                  pMainForm->contextMenuEvent(pEvent);
795  }  }
# Line 883  QString qsamplerChannel::loadingInstrume Line 900  QString qsamplerChannel::loadingInstrume
900  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
901  // qsamplerChannelRoutingTable - Channel routing table.  // qsamplerChannelRoutingTable - Channel routing table.
902  //  //
903    #if 0
904  // Constructor.  // Constructor.
905  qsamplerChannelRoutingTable::qsamplerChannelRoutingTable (  qsamplerChannelRoutingTable::qsamplerChannelRoutingTable (
906          QWidget *pParent, const char *pszName )          QWidget *pParent, const char *pszName )
# Line 979  void qsamplerChannelRoutingTable::flush Line 996  void qsamplerChannelRoutingTable::flush
996          if (QTable::isEditing())          if (QTable::isEditing())
997              QTable::endEdit(QTable::currEditRow(), QTable::currEditCol(), true, true);              QTable::endEdit(QTable::currEditRow(), QTable::currEditCol(), true, true);
998  }  }
999    #endif
1000    
1001    ChannelRoutingModel::ChannelRoutingModel(QObject* parent) : QAbstractTableModel(parent), pDevice(NULL) {
1002    }
1003    
1004    int ChannelRoutingModel::rowCount(const QModelIndex& /*parent*/) const {
1005        return routing.size();
1006    }
1007    
1008    int ChannelRoutingModel::columnCount(const QModelIndex& /*parent*/) const {
1009        return 1;
1010    }
1011    
1012    QVariant ChannelRoutingModel::data(const QModelIndex &index, int role) const {
1013        if (!index.isValid())
1014            return QVariant();
1015        if (role != Qt::DisplayRole)
1016            return QVariant();
1017    
1018        ChannelRoutingItem item;
1019    
1020        // The common device port item list.
1021        qsamplerDevicePortList& ports = pDevice->ports();
1022        qsamplerDevicePort* pPort;
1023        for (pPort = ports.first(); pPort; pPort = ports.next()) {
1024            item.options.append(
1025                pDevice->deviceTypeName()
1026                + ' ' + pDevice->driverName()
1027                + ' ' + pPort->portName()
1028            );
1029        }
1030    
1031        item.selection = routing[index.column()];
1032    
1033        return QVariant::fromValue(item);
1034    }
1035    
1036    QVariant ChannelRoutingModel::headerData(int section, Qt::Orientation orientation, int role) const {
1037        if (role != Qt::DisplayRole) return QVariant();
1038    
1039        if (orientation == Qt::Horizontal)
1040            return QObject::tr("Device Channel");
1041    
1042        if (orientation == Qt::Vertical)
1043            return QObject::tr("Sampler Channel Output ") +
1044                   QString(section);
1045    
1046        return QVariant();
1047    }
1048    
1049    void ChannelRoutingModel::refresh ( qsamplerDevice *pDevice,
1050            const qsamplerChannelRoutingMap& routing )
1051    {
1052        this->pDevice = pDevice;
1053        this->routing = routing;
1054    }
1055    
1056    
1057    
1058    
1059    ChannelRoutingDelegate::ChannelRoutingDelegate(QObject *parent) : QItemDelegate(parent) {
1060    }
1061    
1062    QWidget* ChannelRoutingDelegate::createEditor(QWidget *parent,
1063            const QStyleOptionViewItem &/* option */,
1064            const QModelIndex& index) const
1065    {
1066        ChannelRoutingItem item = index.model()->data(index, Qt::DisplayRole).value<ChannelRoutingItem>();
1067    
1068        QComboBox* editor = new QComboBox(parent);
1069        editor->addItems(item.options);
1070        editor->setCurrentIndex(item.selection);
1071        editor->installEventFilter(const_cast<ChannelRoutingDelegate*>(this));
1072        return editor;
1073    }
1074    
1075    void ChannelRoutingDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const {
1076        ChannelRoutingItem item = index.model()->data(index, Qt::DisplayRole).value<ChannelRoutingItem>();
1077        QComboBox* comboBox = static_cast<QComboBox*>(editor);
1078        comboBox->setCurrentIndex(item.selection);
1079    }
1080    
1081    void ChannelRoutingDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const {
1082        QComboBox* comboBox = static_cast<QComboBox*>(editor);
1083        model->setData(index, comboBox->currentIndex());
1084    }
1085    
1086    void ChannelRoutingDelegate::updateEditorGeometry(QWidget *editor,
1087            const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
1088    {
1089        editor->setGeometry(option.rect);
1090    }
1091    
1092    
1093    
1094  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
1095  // qsamplerChannelRoutingComboBox - Custom combo box for routing table.  // qsamplerChannelRoutingComboBox - Custom combo box for routing table.
1096  //  //
1097    
1098    #if 0
1099  // Constructor.  // Constructor.
1100  qsamplerChannelRoutingComboBox::qsamplerChannelRoutingComboBox (  qsamplerChannelRoutingComboBox::qsamplerChannelRoutingComboBox (
1101          QTable *pTable, const QStringList& list, const QPixmap& pixmap )          QTable *pTable, const QStringList& list, const QPixmap& pixmap )
# Line 1031  void qsamplerChannelRoutingComboBox::set Line 1142  void qsamplerChannelRoutingComboBox::set
1142          else QTableItem::setContentFromEditor(pWidget);          else QTableItem::setContentFromEditor(pWidget);
1143  }  }
1144    
1145    #endif
 // end of qsamplerChannel.cpp  

Legend:
Removed from v.1367  
changed lines
  Added in v.1461

  ViewVC Help
Powered by ViewVC