ChannelConfigurationsWidget::ChannelConfigurationsWidget(Device *device, QWidget *parent) : StandardWidget(device, parent), ui(new Ui::ChannelConfigurationsWidget), m_model(new ChannelConfigurationsModel(this)), m_import(new QAction(tr("Import"), this)), m_defaultPath("") { ui->setupUi(this); performStandardSetup(tr("Channel Configurations")); menuBar()->addAction(m_import); ui->configs->setModel(m_model); ui->configs->setItemDelegate(new ConfigItemDelegate(this)); ui->configs->setRootIndex(m_model->index(m_model->rootPath())); connect(ui->edit, SIGNAL(clicked()), SLOT(edit())); connect(ui->rename, SIGNAL(clicked()), SLOT(rename())); connect(ui->default_, SIGNAL(clicked()), SLOT(default_())); connect(ui->add, SIGNAL(clicked()), SLOT(add())); connect(ui->remove, SIGNAL(clicked()), SLOT(remove())); connect(ui->configs->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), SLOT(currentChanged(QModelIndex))); m_defaultPath = m_model->filePath(m_model->defaultConfiguration()); currentChanged(QModelIndex()); }
TEST(SwitchAny, canUseLambdaDirectlyForEmptyCase) { boost::any a; int result = switchAny<int>(a, [] { return 2; }, default_([] { return 1; }) ); EXPECT_EQ(2, result); }
TEST(SwitchAny, canUseLambdaDirectlyForTypedCase) { boost::any a = 3; int result = switchAny<int>(a, [] { return 2; }, default_([] { return 1; }), [](int& i) { return i; } ); EXPECT_EQ(3, result); }
/* Returns index if a sentence matches, 0 otherwise */ int switch_(int index) { if(nextTok(index) == SWITCH_START) { if(nextTok(index)==OPENTOK) { if(index = cases(index)) { if(index = default_(index)) { if(nextTok(index) == CLOSETOK) return index; } } } } return 0; }
void ChannelConfigurationsWidget::add() { KeyboardDialog keyboard(tr("Create New Configuration")); RootController::ref().presentDialog(&keyboard); Config blank; std::string savePath = Camera::ConfigPath::path(keyboard.input().toStdString()); QString qSavePath = QString::fromStdString(savePath); if(!blank.save(savePath)) { qWarning() << "Error saving" << qSavePath; return; } // Select it and set as default if it's the first one QDir saves = QDir(QFileInfo(qSavePath).path(), "*." + QString::fromStdString( Camera::ConfigPath::extension())); if(saves.entryList(QDir::Files).size() == 1) { QModelIndex index = m_model->index(qSavePath); ui->configs->selectionModel()->select(index, QItemSelectionModel::Select); default_(); currentChanged(index); } }
static boost::optional< boost::posix_time::ptime > cast( const boost::optional< std::string >& s ) { if( !s ) { return default_(); } try { return boost::posix_time::from_iso_string( *s ); } catch( ... ) { } return default_(); }