예제 #1
0
void MenuBar::setupActions()
{
    newCompetitionAction->setIcon(QIcon(":/images/new.png"));
    newCompetitionAction->setShortcut(QKeySequence::New);
    newCompetitionAction->setStatusTip(QApplication::tr("Create a new competition"));
    QObject::connect(newCompetitionAction, SIGNAL(triggered()), mainwindow, SLOT(newCompetition()));

    loadCompetitionAction->setIcon(QIcon(":/images/load.png"));
    loadCompetitionAction->setShortcut(QKeySequence::Open);
    loadCompetitionAction->setStatusTip(QApplication::tr("Load a competition"));
    QObject::connect(loadCompetitionAction, SIGNAL(triggered()), mainwindow, SLOT(loadCompetition()));

    saveCompetitionAction->setIcon(QIcon(":/images/save.png"));
    saveCompetitionAction->setShortcut(QKeySequence::Save);
    saveCompetitionAction->setStatusTip(QApplication::tr("Save a competition"));
    QObject::connect(saveCompetitionAction, SIGNAL(triggered()), mainwindow, SLOT(saveCompetition()));

    quitAction->setIcon(QIcon(":/images/quit.png"));
    quitAction->setShortcut(QKeySequence("CTRL+Q"));
    quitAction->setStatusTip(QApplication::tr("Quit application"));
    QObject::connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));

    helpAction->setIcon(QIcon(":/images/help.png"));
    helpAction->setShortcut(QKeySequence::HelpContents);
    helpAction->setStatusTip(QApplication::tr("Show help dialog"));
    QObject::connect(helpAction, SIGNAL(triggered()), mainwindow, SLOT(showHelp()));

    aboutAction->setIcon(QIcon(":/images/about.png"));
    aboutAction->setShortcut(QKeySequence("SHIFT+F1"));
    aboutAction->setStatusTip(QApplication::tr("About this application"));
    QObject::connect(aboutAction, SIGNAL(triggered()), mainwindow, SLOT(showAbout()));

    aboutQtAction->setIcon(QIcon(":/images/about.png"));
    aboutQtAction->setShortcut(QKeySequence("SHIFT+F2"));
    aboutQtAction->setStatusTip(QApplication::tr("About Qt"));
    QObject::connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
}
예제 #2
0
//Load a (new) competition from the server.
bool oEvent::readSynchronize(const CompetitionInfo &ci)
{
  if (ci.Id<=0)
    throw std::exception("help:12290");

  if (isThreadReconnecting())
    return false;

  HasDBConnection=false;

#ifdef BUILD_DB_DLL
  if (!msConnectToServer)
    return false;
#endif

  MySQLServer=ci.Server;
  MySQLPassword=ci.ServerPassword;
  MySQLPort=ci.ServerPort;
  MySQLUser=ci.ServerUser;

  //Delete non-server competitions.
  list<CompetitionInfo> saved;
  list<CompetitionInfo>::iterator it;
  for (it=cinfo.begin(); it!=cinfo.end(); ++it) {
    if (it->Server.empty())
      saved.push_back(*it);
  }
  cinfo=saved;

  if (!msConnectToServer(this)) {
    char bf[256];
    msGetErrorState(bf);
    throw std::exception(bf);
    return false;
  }

  for (it=cinfo.begin(); it!=cinfo.end(); ++it) {
    if (it->Name.size() > 1 && it->Name[0] == '%')
      it->Name = lang.tl(it->Name.substr(1));
  }

  newCompetition("");
  Id=ci.Id;
  strcpy_s(CurrentNameId, ci.FullPath.c_str());

  char file[260];
  sprintf_s(file, "%s.dbmeos", CurrentNameId);
  getUserFile(CurrentFile, file);
  if ( !msOpenDatabase(this) ) {
    char bf[256];
    msGetErrorState(bf);
    throw std::exception(bf);
  }

  updateFreeId();
  HasDBConnection=false;

  openRunnerDatabase(CurrentNameId);

  int ret = msSynchronizeRead(this);
  if (ret == 0) {
    char bf[256];
    msGetErrorState(bf);

    string err = string("Kunde inte öppna tävlingen (X)#") + bf;
    throw std::exception(err.c_str());
  }
  else if (ret == 1) {
    // Warning
    char bf[256];
    msGetErrorState(bf);
    string info = "Databasvarning: X#" + lang.tl(bf);
    gdibase.addInfoBox("sqlerror", info, 15000);
  }

  // Cache database locally
  saveRunnerDatabase(CurrentNameId, false);

  HasDBConnection=true;

  // Setup multirunner links
  for (oRunnerList::iterator it = Runners.begin(); it != Runners.end(); ++it)
    it->createMultiRunner(false,false);

  // Remove incorrect references
  for (oRunnerList::iterator it = Runners.begin(); it != Runners.end(); ++it) {
    if (it->multiRunner.size() > 0 ) {
      vector<pRunner> &pr = it->multiRunner;
      for (size_t k=0; k<pr.size(); k++) {
        if (pr[k]==0 || pr[k]->tParentRunner != &*it) {
          it->multiRunner.clear();
          it->updateChanged();
          it->synchronize();
          break;
        }
      }
    }
  }

  // Check duplicates
  vector<bool> usedInTeam(qFreeRunnerId+1);
  bool teamCorrected = false;

  for (oTeamList::iterator it = Teams.begin(); it != Teams.end(); ++it) {
    if (it->correctionNeeded) {
      it->updateChanged();
      teamCorrected = true;
    }

    for (size_t i = 0; i < it->Runners.size(); i++) {
      pRunner r = it->Runners[i];

      if (r != 0) {
        int expectedIndex = -1;
        if (it->Class)
          expectedIndex = it->Class->getLegRunnerIndex(i);

        if (expectedIndex>=0 && expectedIndex != r->getMultiIndex()) {
          int baseLeg = it->Class->getLegRunner(i);
          it->setRunner(baseLeg, r->getMultiRunner(0), true);
          teamCorrected = true;
        }
      }
    }

    for (size_t i = 0; i < it->Runners.size(); i++) {
      pRunner r = it->Runners[i];
      if (r != 0) {
        if (usedInTeam[r->Id]) {
          it->Runners[i] = 0; // Reset duplicate runners
          it->updateChanged();
          teamCorrected = true;
          if (r->tInTeam == &*it)
            r->tInTeam = 0;
        }
        else
          usedInTeam[r->Id] = true;
      }
    }
  }
  usedInTeam.clear();

  if (teamCorrected) {
    for (oTeamList::iterator it = Teams.begin(); it != Teams.end(); ++it) {
      it->apply(true, 0, false);
    }
  }

  reEvaluateAll(set<int>(), false);
  vector<string> out;
  checkChanged(out);
  assert(out.empty());

  for (oRunnerList::iterator it = Runners.begin(); it != Runners.end(); ++it) {
    if (it->correctionNeeded) {
      it->createMultiRunner(true, true);
      if (it->tInTeam && it->Class) {
        pTeam t = it->tInTeam;
        int nr = min(int(it->Class->getNumStages())-1, int(it->multiRunner.size()));
        t->setRunner(0, &*it, true);
        for (int k=0; k<nr; k++)
          t->setRunner(k+1, it->multiRunner[k], true);
        t->updateChanged();
        t->synchronize();
      }
      it->synchronizeAll();
    }
  }

  return true;
}
예제 #3
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
	ui(new Ui::MainWindow)
{
    QSettings set;
    myMainWindow = this;
    localTimeOffset_ms = 0;

    ui->setupUi(this);

	showMaximized();

	dialogNewCompetition = new DialogNewCompetition(this);
	dialogGeneralSettings = new DialogGeneralSettings(this);
	dialogDisplaySettings = new DialogDisplaySettings(this);
	dialogCsvUploadCommand = new DialogCsvUploadCommand(this);
	dialogTimeStampGenerator = 0;
	dialogTimeStampGenerator2 = new DialogTimeStampGenerator2(this);
	formTimeStampList = 0;
	serverConnected = false;
    myCompetition=0;
    publisher=0;
    udpSocket = 0;


    boxStatesView = new BoxStatesView(&boxStates, 0);
    if(boxStatesView){
        ui->scrollArea_boxStates->setWidget(boxStatesView);

    }else{
        qDebug("Error on creating boxStatesView");
        qApp->exit();
    }

	connect(dialogNewCompetition, SIGNAL(accepted()), this, SLOT(newCompetition()));

	// show default images on the flipdot displays
	QImage im1(":/flipdot1_default.bmp");
	ui->flipdotDisplayWidget_1->setImage(im1);
	QImage im2(":/flipdot2_default.bmp");
	ui->flipdotDisplayWidget_2->setImage(im2);


	connect(ui->actionAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));


	connect(&boxStates, SIGNAL(receivedNewTimeStamp(TimeStamp*)), this, SLOT(addNewTimeStamp(TimeStamp*)));
	
    renderer = new DisplayRenderer(ui->flipdotDisplayWidget_1,
                                   ui->flipdotDisplayWidget_2,
                                   dialogDisplaySettings, this);
    if(renderer == 0){
        qDebug("Error on creating renderer-object in MainWindow-contructor");
        qApp->exit();
    }
	publisher=new Publisher(this);
    if(publisher == 0){
        qDebug("Error on creating publisher-object in MainWindow-contructor");
        qApp->exit();
    }
	
    connect(publisher, SIGNAL(publishRunNow(RunData*)), renderer, SLOT(render(RunData*)));
	connect(renderer, SIGNAL(sendDatagram(QByteArray)), this, SLOT(sendPC2TB_Packet(QByteArray)));
	connect(dialogDisplaySettings->getRenderer(), SIGNAL(sendDatagram(QByteArray)), this, SLOT(sendPC2TB_Packet(QByteArray)));

    // show second screen (public)
    publicWidget = new PublicWidget();
    if(publisher == 0){
        qDebug("Error on creating publicWideget in MainWindow-contructor");
        qApp->exit();
    }
    QRect screenres = QApplication::desktop()->screenGeometry(1); // get coordinates of the external monitor
    publicWidget->move(QPoint(screenres.x(), screenres.y()));
    //publicWidget->showFullScreen();
	publicWidget->showMaximized();
    publicWidget->setWindowTitle(tr("Öffentlicher Monitor"));
    // use closeEvent for closing this widget

    currentFile = QFileInfo(set.value(SS_RECENT_PATH).toString() + "/"); // set current file to the recent path, with no filename
    newCompetition(); // create new competition with standard values from the dialogNewCompetition
	ui->infoscreen->clear();

	connect(ui->timeline, SIGNAL(selectionChanged(TimeStamp*)), ui->tableWidget_main, SLOT(selectRun(TimeStamp*)));
	connect(ui->tableWidget_main, SIGNAL(runSelectionChanged(RunData*)), ui->timeline, SLOT(selectRun(RunData*)));
	connect(ui->tableWidget_main, SIGNAL(selectTimeStamp(TimeStamp*)), ui->timeline, SLOT(selectTimeStamp(TimeStamp*)));
	connect(ui->timeline, SIGNAL(selectionChanged(TimeStamp*)), ui->tableWidget_timeStamps, SLOT(selectTimeStamp(TimeStamp*)));
	connect(&assignmentManager, SIGNAL(unassignedTimeStamp(TimeStamp*)), ui->tableWidget_timeStamps, SLOT(selectTimeStamp(TimeStamp*)));
	connect(ui->tableWidget_timeStamps, SIGNAL(selectionChanged(TimeStamp*)), ui->timeline, SLOT(selectTimeStamp(TimeStamp*)));
	connect(ui->tableWidget_timeStamps, SIGNAL(assign()), this, SLOT(on_pushButton_assignTime_clicked()));
	
	connect(this, SIGNAL(showFoundRun(RunData*)), ui->tableWidget_main, SLOT(selectRun(RunData*)));
	connect(this, SIGNAL(showFoundRun(RunData*)), ui->timeline, SLOT(selectRun(RunData*)));

    connect(&backupTimer, SIGNAL(timeout()), this, SLOT(backupCurrentCompetition()));

	ui->tableWidget_timeStamps->init();
	ui->tableWidget_main->regenerateTable();
	
	manualTrigger=new QShortcut(QKeySequence("CTRL+Space"), this);
	connect(manualTrigger, SIGNAL(activated()), this, SLOT(on_pushButton_manualTrigger_clicked()));
#ifndef Q_OS_WIN
	connect(&fdisk, SIGNAL(finished()), this, SLOT(writeBetweenRating()));
#endif

    setOnlineMode(false);
	
	ui->infoscreen->appendInfo(tr("Willkommen!"));

    // show welcome-screen:
    WelcomeScreen* w = new WelcomeScreen(this);
    w->show();
}