Skip to content

Commit

Permalink
If adding channel for the first time, select and set as default
Browse files Browse the repository at this point in the history
  • Loading branch information
bmcdorman committed Jan 24, 2013
1 parent 8362d16 commit a60abf1
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/ChannelConfigurationsWidget.cpp
Expand Up @@ -131,17 +131,29 @@ void ChannelConfigurationsWidget::add()
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" << QString::fromStdString(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);
}
}

void ChannelConfigurationsWidget::remove()
{
QItemSelection selection = ui->configs->selectionModel()->selection();
if(selection.indexes().size() != 1) return;
QFile::remove(m_model->filePath(selection.indexes()[0]));
currentChanged(QModelIndex());
}

void ChannelConfigurationsWidget::currentChanged(const QModelIndex &index)
Expand Down

0 comments on commit a60abf1

Please sign in to comment.