本文整理汇总了C++中DeviceList::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ DeviceList::begin方法的具体用法?C++ DeviceList::begin怎么用?C++ DeviceList::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DeviceList
的用法示例。
在下文中一共展示了DeviceList::begin方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getMetronome
void
ManageMetronomeDialog::slotPreviewPitch(int pitch)
{
RG_DEBUG << "ManageMetronomeDialog::slotPreviewPitch";
DeviceList *devices = m_doc->getStudio().getDevices();
DeviceListConstIterator it;
int count = 0;
Device *dev = 0;
for (it = devices->begin(); it != devices->end(); it++) {
dev = *it;
if (!isSuitable(dev)) continue;
if (count == m_metronomeDevice->currentIndex()) break;
count++;
}
if (!dev || !isSuitable(dev)) return;
const MidiMetronome *metronome = getMetronome(dev);
if (metronome == 0) return;
InstrumentList list = dev->getPresentationInstruments();
Instrument *inst =
list[m_metronomeInstrument->currentIndex()];
StudioControl::playPreviewNote(inst, pitch, MidiMaxValue, RealTime(0, 10000000));
}
示例2: readDevicesFile
RobotInterface::DeviceList RobotInterface::XMLReader::Private::readDevicesTag(TiXmlElement *devicesElem)
{
const std::string &valueStr = devicesElem->ValueStr();
if (valueStr.compare("devices") != 0) {
SYNTAX_ERROR(devicesElem->Row()) << "Expected \"devices\". Found" << valueStr;
}
std::string filename;
if (devicesElem->QueryStringAttribute("file", &filename) == TIXML_SUCCESS) {
// yDebug() << "Found devices file [" << filename << "]";
#ifdef WIN32
std::replace(filename.begin(), filename.end(), '/', '\\');
filename = path + "\\" + filename;
#else // WIN32
filename = path + "/" + filename;
#endif //WIN32
return readDevicesFile(filename);
}
std::string robotName;
if (devicesElem->QueryStringAttribute("robot", &robotName) != TIXML_SUCCESS) {
SYNTAX_WARNING(devicesElem->Row()) << "\"devices\" element should contain the \"robot\" attribute";
}
if (robotName != robot.name()) {
SYNTAX_WARNING(devicesElem->Row()) << "Trying to import a file for the wrong robot. Found" << robotName << "instead of" << robot.name();
}
unsigned int build;
#if TINYXML_UNSIGNED_INT_BUG
if (devicesElem->QueryUnsignedAttribute("build", &build()) != TIXML_SUCCESS) {
// No build attribute. Assuming build="0"
SYNTAX_WARNING(devicesElem->Row()) << "\"devices\" element should contain the \"build\" attribute [unsigned int]. Assuming 0";
}
#else
int tmp;
if (devicesElem->QueryIntAttribute("build", &tmp) != TIXML_SUCCESS || tmp < 0) {
// No build attribute. Assuming build="0"
SYNTAX_WARNING(devicesElem->Row()) << "\"devices\" element should contain the \"build\" attribute [unsigned int]. Assuming 0";
tmp = 0;
}
build = (unsigned)tmp;
#endif
if (build != robot.build()) {
SYNTAX_WARNING(devicesElem->Row()) << "Import a file for a different robot build. Found" << build << "instead of" << robot.build();
}
DeviceList devices;
for (TiXmlElement* childElem = devicesElem->FirstChildElement(); childElem != 0; childElem = childElem->NextSiblingElement()) {
DeviceList childDevices = readDevices(childElem);
for (DeviceList::const_iterator it = childDevices.begin(); it != childDevices.end(); ++it) {
devices.push_back(*it);
}
}
return devices;
}
示例3: listFreeDevices
//----------------------------------------------------------------------------//
DeviceList InputManager::listFreeDevices()
{
DeviceList list;
FactoryList::iterator i = mFactories.begin(), e = mFactories.end();
for( ; i != e; ++i )
{
DeviceList temp = (*i)->freeDeviceList();
list.insert(temp.begin(), temp.end());
}
return list;
}
示例4: readDevices
RobotInterface::Robot& RobotInterface::XMLReader::Private::readRobotTag(TiXmlElement *robotElem)
{
if (robotElem->ValueStr().compare("robot") != 0) {
SYNTAX_ERROR(robotElem->Row()) << "Root element should be \"robot\". Found" << robotElem->ValueStr();
}
if (robotElem->QueryStringAttribute("name", &robot.name()) != TIXML_SUCCESS) {
SYNTAX_ERROR(robotElem->Row()) << "\"robot\" element should contain the \"name\" attribute";
}
#if TINYXML_UNSIGNED_INT_BUG
if (robotElem->QueryUnsignedAttribute("build", &robot.build()) != TIXML_SUCCESS) {
// No build attribute. Assuming build="0"
SYNTAX_WARNING(robotElem->Row()) << "\"robot\" element should contain the \"build\" attribute [unsigned int]. Assuming 0";
}
#else
int tmp;
if (robotElem->QueryIntAttribute("build", &tmp) != TIXML_SUCCESS || tmp < 0) {
// No build attribute. Assuming build="0"
SYNTAX_WARNING(robotElem->Row()) << "\"robot\" element should contain the \"build\" attribute [unsigned int]. Assuming 0";
tmp = 0;
}
robot.build() = (unsigned)tmp;
#endif
if (robotElem->QueryStringAttribute("portprefix", &robot.portprefix()) != TIXML_SUCCESS) {
SYNTAX_WARNING(robotElem->Row()) << "\"robot\" element should contain the \"portprefix\" attribute. Using \"name\" attribute";
robot.portprefix() = robot.name();
}
// yDebug() << "Found robot [" << robot.name() << "] build [" << robot.build() << "] portprefix [" << robot.portprefix() << "]";
for (TiXmlElement* childElem = robotElem->FirstChildElement(); childElem != 0; childElem = childElem->NextSiblingElement()) {
if (childElem->ValueStr().compare("device") == 0 || childElem->ValueStr().compare("devices") == 0) {
DeviceList childDevices = readDevices(childElem);
for (DeviceList::const_iterator it = childDevices.begin(); it != childDevices.end(); ++it) {
robot.devices().push_back(*it);
}
} else {
ParamList childParams = readParams(childElem);
for (ParamList::const_iterator it = childParams.begin(); it != childParams.end(); ++it) {
robot.params().push_back(*it);
}
}
}
return robot;
}
示例5: fileDoc
bool
ImportDeviceDialog::importFromRG(QString fileName)
{
bool skipAutoload = true, clearCommandHistory = false;
RosegardenDocument fileDoc(RosegardenMainWindow::self(), 0,
skipAutoload, clearCommandHistory);
if (!fileDoc.openDocument(fileName, false)) {
return false;
}
for (int i = 0; i < (int)m_devices.size(); ++i) delete m_devices[i];
m_devices.clear();
DeviceList *list = fileDoc.getStudio().getDevices();
if (list->size() == 0) {
return true; // true because we successfully read the document
}
for (DeviceListIterator it = list->begin(); it != list->end(); ++it) {
MidiDevice *device = dynamic_cast<MidiDevice*>(*it);
if (device) {
std::vector<MidiBank> banks = device->getBanks();
// DMM - check for controllers too, because some users have
// created .rgd files that contain only controllers
// see bug #1183522
//
std::vector<ControlParameter> controllers =
device->getControlParameters();
// We've got a bank on a Device fom this file
// (or a device that contains controllers or key mappings)
//
if (banks.size() ||
controllers.size() ||
device->getKeyMappings().size()) {
m_devices.push_back(new MidiDevice(*device));
}
}
}
return true;
}
示例6: QDialog
SplitByRecordingSrcDialog::SplitByRecordingSrcDialog(QWidget *parent, RosegardenDocument *doc) :
QDialog(parent)
{
setModal(true);
setWindowTitle(tr("Split by Recording Source"));
QGridLayout *metagrid = new QGridLayout;
setLayout(metagrid);
QWidget *vBox = new QWidget(this);
QVBoxLayout *vBoxLayout = new QVBoxLayout;
metagrid->addWidget(vBox, 0, 0);
QGroupBox *groupBox = new QGroupBox( tr("Recording Source"), vBox );
groupBox->setContentsMargins(10, 10, 10, 10);
QGridLayout *layout = new QGridLayout(groupBox);
layout->setSpacing(5);
vBoxLayout->addWidget(groupBox);
vBox->setLayout(vBoxLayout);
layout->addWidget(new QLabel( tr("Channel:"), groupBox ), 0, 0);
m_channel = new QComboBox( groupBox );
m_channel->setMaxVisibleItems( 17 );
layout->addWidget(m_channel, 0, 1);
QSpacerItem *spacer = new QSpacerItem( 1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum );
layout->addItem( spacer, 0, 2 );
m_channel->addItem(tr("any"));
for (int i = 1; i < 17; ++i) {
m_channel->addItem(QString::number(i));
}
layout->addWidget(new QLabel( tr("Device:"), groupBox ), 1, 0);
m_device = new QComboBox( groupBox );
layout->addWidget( m_device, 1, 1, 0+1, 2 - 1+1);
m_deviceIds.clear();
m_deviceIds.push_back( -1);
m_device->addItem(tr("any"));
DeviceList *devices = doc->getStudio().getDevices();
DeviceListConstIterator it;
for (it = devices->begin(); it != devices->end(); it++) {
MidiDevice *dev =
dynamic_cast<MidiDevice*>(*it);
if (dev && dev->getDirection() == MidiDevice::Record) {
QString label = QString::number(dev->getId());
label += ": ";
label += strtoqstr(dev->getName());
QString connection = RosegardenSequencer::getInstance()->getConnection
(dev->getId());
label += " - ";
if (connection == "")
label += tr("No connection");
else
label += connection;
m_device->addItem(label);
m_deviceIds.push_back(dev->getId());
}
}
m_channel->setCurrentIndex(0);
m_device->setCurrentIndex(0);
groupBox->setLayout(layout);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
metagrid->addWidget(buttonBox, 1, 0);
metagrid->setRowStretch(0, 10);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
}
示例7: QDialog
ManageMetronomeDialog::ManageMetronomeDialog(QWidget *parent,
RosegardenDocument *doc) :
QDialog(parent),
m_doc(doc),
m_buttonBox(new QDialogButtonBox(QDialogButtonBox::Ok |
QDialogButtonBox::Close))
{
setModal(true);
setWindowTitle(tr("Metronome"));
QGridLayout *metagrid = new QGridLayout;
setLayout(metagrid);
QWidget *hbox = new QWidget(this);
QHBoxLayout *hboxLayout = new QHBoxLayout;
hboxLayout->setMargin(0);
metagrid->addWidget(hbox, 0, 0);
QWidget *vbox = new QWidget(hbox);
QVBoxLayout *vboxLayout = new QVBoxLayout;
vboxLayout->setMargin(0);
hboxLayout->addWidget(vbox);
QGroupBox *deviceBox = new QGroupBox( tr("Metronome Instrument"), vbox );
deviceBox->setContentsMargins(10, 10, 10, 10);
QGridLayout *deviceBoxLayout = new QGridLayout(deviceBox);
deviceBoxLayout->setSpacing(5);
vboxLayout->addWidget(deviceBox);
deviceBoxLayout->addWidget(new QLabel(tr("Device"), deviceBox), 0, 0);
m_metronomeDevice = new QComboBox(deviceBox);
m_metronomeDevice->setToolTip(tr("<qt>Choose the device you want to use to play the metronome</qt>"));
deviceBoxLayout->addWidget(m_metronomeDevice, 0, 1);
DeviceList *devices = doc->getStudio().getDevices();
DeviceListConstIterator it;
Studio &studio = m_doc->getStudio();
DeviceId deviceId = studio.getMetronomeDevice();
for (it = devices->begin(); it != devices->end(); it++) {
Device *dev = *it;
bool hasConnection = false;
if (!isSuitable(dev, &hasConnection)) continue;
QString label = QObject::tr(dev->getName().c_str());
// connections imply some untranslatable external string
QString connection = RosegardenSequencer::getInstance()->getConnection
(dev->getId());
if (hasConnection && connection != "") {
label = tr("%1 - %2").arg(label).arg(connection);
} else if (!hasConnection) {
label = tr("%1 - No connection").arg(label);
}
m_metronomeDevice->addItem(label);
if (dev->getId() == deviceId) {
m_metronomeDevice->setCurrentIndex(m_metronomeDevice->count() - 1);
}
}
deviceBoxLayout->addWidget(new QLabel(tr("Instrument"), deviceBox), 1, 0);
m_metronomeInstrument = new QComboBox(deviceBox);
m_metronomeInstrument->setToolTip(tr("<qt>Choose the instrument you want to use to play the metronome (typically #10)</qt>"));
connect(m_metronomeInstrument, SIGNAL(activated(int)), this, SLOT(slotSetModified()));
deviceBoxLayout->addWidget(m_metronomeInstrument, 1, 1);
deviceBox->setLayout(deviceBoxLayout);
QGroupBox *beatBox = new QGroupBox( tr("Beats"), vbox );
beatBox->setContentsMargins(10, 10, 10, 10);
QGridLayout *beatBoxLayout = new QGridLayout(beatBox);
beatBoxLayout->setSpacing(5);
vboxLayout->addWidget(beatBox);
beatBoxLayout->addWidget(new QLabel(tr("Resolution"), beatBox), 0, 0);
m_metronomeResolution = new QComboBox(beatBox);
m_metronomeResolution->setToolTip(tr("<qt>The metronome can sound bars only, bars and beats, or bars, beats and sub-beats. The latter mode can be particularly useful for playing in compound time signatures like 12/8.</qt>"));
m_metronomeResolution->addItem(tr("None"));
m_metronomeResolution->addItem(tr("Bars only"));
m_metronomeResolution->addItem(tr("Bars and beats"));
m_metronomeResolution->addItem(tr("Bars, beats, and sub-beats"));
connect(m_metronomeResolution, SIGNAL(activated(int)), this, SLOT(slotResolutionChanged(int)));
beatBoxLayout->addWidget(m_metronomeResolution, 0, 1);
beatBoxLayout->addWidget(new QLabel(tr("Bar velocity"), beatBox), 1, 0);
m_metronomeBarVely = new QSpinBox(beatBox);
m_metronomeBarVely->setToolTip(tr("<qt>Controls how forcefully the bar division notes will be struck. (These are typically the loudest of all.)</qt>"));
m_metronomeBarVely->setMinimum(0);
m_metronomeBarVely->setMaximum(127);
connect(m_metronomeBarVely, SIGNAL(valueChanged(int)), this, SLOT(slotSetModified()));
beatBoxLayout->addWidget(m_metronomeBarVely, 1, 1);
beatBoxLayout->addWidget(new QLabel(tr("Beat velocity"), beatBox), 2, 0);
m_metronomeBeatVely = new QSpinBox(beatBox);
m_metronomeBeatVely->setToolTip(tr("<qt>Controls how forcefully the beat division notes will be struck. (These are typically more quiet than beat division notes.)</qt>"));
m_metronomeBeatVely->setMinimum(0);
m_metronomeBeatVely->setMaximum(127);
connect(m_metronomeBeatVely, SIGNAL(valueChanged(int)), this, SLOT(slotSetModified()));
beatBoxLayout->addWidget(m_metronomeBeatVely, 2, 1);
//.........这里部分代码省略.........
示例8: metronome
void
ManageMetronomeDialog::slotApply()
{
Studio &studio = m_doc->getStudio();
DeviceList *devices = m_doc->getStudio().getDevices();
DeviceListConstIterator it;
int count = 0;
Device *dev = 0;
for (it = devices->begin(); it != devices->end(); it++) {
dev = *it;
if (!isSuitable(dev)) continue;
if (count == m_metronomeDevice->currentIndex()) break;
count++;
}
if (!dev || !isSuitable(dev)) {
RG_WARNING << "Warning: ManageMetronomeDialog::slotApply: no " << m_metronomeDevice->currentIndex() << "th device";
return ;
}
DeviceId deviceId = dev->getId();
studio.setMetronomeDevice(deviceId);
if (getMetronome(dev) == 0) {
RG_WARNING << "Warning: ManageMetronomeDialog::slotApply: unable to extract metronome from device " << deviceId;
return ;
}
MidiMetronome metronome(*getMetronome(dev));
// get instrument
InstrumentList list = dev->getPresentationInstruments();
Instrument *inst =
list[m_metronomeInstrument->currentIndex()];
if (inst) {
metronome.setInstrument(inst->getId());
}
metronome.setBarPitch(m_barPitch);
metronome.setBeatPitch(m_beatPitch);
metronome.setSubBeatPitch(m_subBeatPitch);
metronome.setDepth(
m_metronomeResolution->currentIndex());
metronome.setBarVelocity(
MidiByte(m_metronomeBarVely->value()));
metronome.setBeatVelocity(
MidiByte(m_metronomeBeatVely->value()));
metronome.setSubBeatVelocity(
MidiByte(m_metronomeSubBeatVely->value()));
setMetronome(dev, metronome);
m_doc->getComposition().setPlayMetronome(m_playEnabled->isChecked());
m_doc->getComposition().setRecordMetronome(m_recordEnabled->isChecked());
m_doc->getSequenceManager()->metronomeChanged(inst->getId(), true);
m_doc->slotDocumentModified();
setModified(false);
}
示例9: iname
void
ManageMetronomeDialog::populate(int deviceIndex)
{
m_metronomeInstrument->clear();
DeviceList *devices = m_doc->getStudio().getDevices();
DeviceListConstIterator it;
int count = 0;
Device *dev = 0;
for (it = devices->begin(); it != devices->end(); it++) {
dev = *it;
if (!isSuitable(dev)) continue;
if (count == deviceIndex) break;
count++;
}
// sanity
if (count < 0 || dev == 0 || !isSuitable(dev)) {
return ;
}
// populate instrument list
InstrumentList list = dev->getPresentationInstruments();
InstrumentList::iterator iit;
const MidiMetronome *metronome = getMetronome(dev);
// if we've got no metronome against this device then create one
if (metronome == 0) {
InstrumentId id = SystemInstrumentBase;
for (iit = list.begin(); iit != list.end(); ++iit) {
if ((*iit)->isPercussion()) {
id = (*iit)->getId();
break;
}
}
setMetronome(dev, MidiMetronome(id));
metronome = getMetronome(dev);
}
// metronome should now be set but we still check it
if (metronome) {
int position = 0;
int count = 0;
for (iit = list.begin(); iit != list.end(); ++iit) {
QString iname(QObject::tr((*iit)->getName().c_str()));
QString ipname((*iit)->getLocalizedPresentationName());
QString programName(QObject::tr((*iit)->getProgramName().c_str()));
QString text;
if ((*iit)->getType() == Instrument::SoftSynth) {
iname.replace(QObject::tr("Synth plugin "), "");
programName = "";
AudioPluginInstance *plugin = (*iit)->getPlugin
(Instrument::SYNTH_PLUGIN_POSITION);
if (plugin)
programName = strtoqstr(plugin->getDisplayName());
} else {
iname = ipname;
}
if (programName != "") {
text = tr("%1 (%2)").arg(iname).arg(programName);
} else {
text = iname;
}
m_metronomeInstrument->addItem(text);
if ((*iit)->getId() == metronome->getInstrument()) {
position = count;
}
count++;
}
m_metronomeInstrument->setCurrentIndex(position);
m_barPitch = metronome->getBarPitch();
m_beatPitch = metronome->getBeatPitch();
m_subBeatPitch = metronome->getSubBeatPitch();
slotPitchSelectorChanged(0);
m_metronomeResolution->setCurrentIndex(metronome->getDepth());
m_metronomeBarVely->setValue(metronome->getBarVelocity());
m_metronomeBeatVely->setValue(metronome->getBeatVelocity());
m_metronomeSubBeatVely->setValue(metronome->getSubBeatVelocity());
m_playEnabled->setChecked(m_doc->getComposition().usePlayMetronome());
m_recordEnabled->setChecked(m_doc->getComposition().useRecordMetronome());
slotResolutionChanged(metronome->getDepth());
//.........这里部分代码省略.........
示例10: cDebug
void
PartitionCoreModule::doInit()
{
FileSystemFactory::init();
using DeviceList = QList< Device* >;
CoreBackend* backend = CoreBackendManager::self()->backend();
DeviceList devices = backend->scanDevices( true );
cDebug() << "Winnowing" << devices.count() << "devices.";
// Remove the device which contains / from the list
for ( DeviceList::iterator it = devices.begin(); it != devices.end(); )
if ( ! (*it) || hasRootPartition( *it ) ||
(*it)->deviceNode().startsWith( "/dev/zram") ||
isIso9660( *it ) )
{
cDebug() << " .. Winnowing" << ( (*it) ? (*it)->deviceNode() : QString( "<null device>" ) );
it = devices.erase( it );
}
else
++it;
cDebug() << "LIST OF DETECTED DEVICES:";
cDebug() << "node\tcapacity\tname\tprettyName";
for ( auto device : devices )
{
auto deviceInfo = new DeviceInfo( device );
m_deviceInfos << deviceInfo;
cDebug() << device->deviceNode() << device->capacity() << device->name() << device->prettyName();
}
cDebug() << ".." << devices.count() << "devices detected.";
m_deviceModel->init( devices );
// The following PartUtils::runOsprober call in turn calls PartUtils::canBeResized,
// which relies on a working DeviceModel.
m_osproberLines = PartUtils::runOsprober( this );
// We perform a best effort of filling out filesystem UUIDs in m_osproberLines
// because we will need them later on in PartitionModel if partition paths
// change.
// It is a known fact that /dev/sda1-style device paths aren't persistent
// across reboots (and this doesn't affect us), but partition numbers can also
// change at runtime against our will just for shits and giggles.
// But why would that ever happen? What system could possibly be so poorly
// designed that it requires a partition path rearrangement at runtime?
// Logical partitions on an MSDOS disklabel of course.
// See DeletePartitionJob::updatePreview.
for ( auto deviceInfo : m_deviceInfos )
{
for ( auto it = PartitionIterator::begin( deviceInfo->device.data() );
it != PartitionIterator::end( deviceInfo->device.data() ); ++it )
{
Partition* partition = *it;
for ( auto jt = m_osproberLines.begin();
jt != m_osproberLines.end(); ++jt )
{
if ( jt->path == partition->partitionPath() &&
partition->fileSystem().supportGetUUID() != FileSystem::cmdSupportNone &&
!partition->fileSystem().uuid().isEmpty() )
{
jt->uuid = partition->fileSystem().uuid();
}
}
}
}
for ( auto deviceInfo : m_deviceInfos )
{
deviceInfo->partitionModel->init( deviceInfo->device.data(), m_osproberLines );
}
m_bootLoaderModel->init( devices );
if ( QDir( "/sys/firmware/efi/efivars" ).exists() )
scanForEfiSystemPartitions(); //FIXME: this should be removed in favor of
// proper KPM support for EFI
}