std::vector<std::pair<int, int> > ReadStageFile(const std::string & fileName) { int count = 0; std::ifstream stageFile(fileName.c_str()); if(!stageFile) { throw std::runtime_error("cannot open stage file"); } if(!(stageFile >> count)) { throw std::runtime_error("cannot read stage file"); } if(count < 0) { throw std::runtime_error("number of stages must be nonnegative"); } std::vector<std::pair<int, int> > ret(count); for(int i = 0; i < count; i++) { if(!(stageFile >> ret[i].first >> ret[i].second)) { throw std::runtime_error("too few records in the stage file"); } if(ret[i].first < 2) { throw std::runtime_error("vertex size in stage record must be at least 2"); } if(ret[i].second < 0) { throw std::runtime_error("minimum branch size in stage record must be nonnegative"); } } return ret; }
void MainWindow::setupActions() { KStandardAction::quit(KApplication::instance(), SLOT(quit()), actionCollection()); // commit KAction *commitAction = actionCollection()->addAction("commit", ui->stageWidget, SLOT(commit())); commitAction->setText(i18n("Commit")); commitAction->setIcon(KIcon("git-commit")); commitAction->setShortcut(Qt::CTRL + Qt::Key_Return); KAction *stageFileAction = actionCollection()->addAction("file_stage", ui->stageWidget, SLOT(stageFile())); stageFileAction->setText(i18n("Stage File to Commit")); stageFileAction->setIcon(KIcon("git-file-stage")); stageFileAction->setShortcut(Qt::CTRL + Qt::Key_S); KAction *unstageFileAction = actionCollection()->addAction("file_unstage", ui->stageWidget, SLOT(unstageFile())); unstageFileAction->setText(i18n("Unstage File from Commit")); unstageFileAction->setIcon(KIcon("git-file-unstage")); unstageFileAction->setShortcut(Qt::CTRL + Qt::Key_U); // repository KAction *openRepoAction = actionCollection()->addAction("repository_open", this, SLOT(open())); openRepoAction->setText(i18n("Open repository")); openRepoAction->setIcon(KIcon("git-repo-open")); openRepoAction->setShortcut(Qt::CTRL + Qt::Key_O); KAction *reloadRepoAction = actionCollection()->addAction("repository_reload", this, SLOT(reload())); reloadRepoAction->setText(i18n("Reload repository")); reloadRepoAction->setIcon(KIcon("git-repo-reload")); reloadRepoAction->setShortcut(Qt::Key_F5); }