示例#1
0
AccountWindow::AccountWindow(QWidget* parent, const QString &name, Qt::WindowFlags wflags)
	:TableWindow(parent, name, wflags)
{
	QStringList nameList;
	QTableWidget *pTable;
	QAction* pAction;

  pTable = TableWindow::getTable();
	m_pDb = ISql::pInstance();

	pAction = new QAction(tr("&New..."), this);
	connect(pAction, SIGNAL(triggered()), this, SLOT(file_new()));
	MDIWindow::addAction(pAction);

	pAction = new QAction(tr("&Edit..."), this);
	connect(pAction, SIGNAL(triggered()), this, SLOT(file_edit()));
	MDIWindow::addAction(pAction, true);

	pAction = new QAction(tr("&Delete"), this);
	connect(pAction, SIGNAL(triggered()), this, SLOT(file_delete()));
	MDIWindow::addAction(pAction);

	pAction = new QAction(this);
	pAction->setSeparator(true);
	MDIWindow::addAction(pAction);

	pAction = new QAction(tr("&Export all..."), this);
	connect(pAction, SIGNAL(triggered()), this, SLOT(exportTable()));
	MDIWindow::addAction(pAction);

	// configure the table
	TableWindow::setWindowIcon(QIcon(":/document.xpm"));
	pTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
	pTable->setSelectionMode(QAbstractItemView::SingleSelection);

	// header
  nameList += tr("Username");
  nameList += tr("Contest");
  nameList += tr("Description");

	setupHeader(nameList);

  pTable->setColumnWidth(Username, 100);
  pTable->setColumnWidth(Contest, 100);
  pTable->setColumnWidth(Description, 200);

  connect(m_pDb, SIGNAL(accountsChanged()), this, SLOT(file_update()));

	file_update();
}
示例#2
0
int sfx_play(context_t* p_Ctx, const std::string & p_FileName, int p_Channel,
		int p_Loops)
{
	auto l_It = g_SoundList.find(p_FileName);

	if (l_It != g_SoundList.end())
	{
		return Mix_PlayChannel(p_Channel, l_It->second, p_Loops);
	}

	const std::string l_TableFilename = std::string(SFX_TABLE)
			+ std::string("/") + p_FileName;
	const std::string l_FullName = std::string(base_directory) + "/"
			+ l_TableFilename;

	file_lock(l_TableFilename.c_str());

	SDL_RWops * l_pFileDesc = SDL_RWFromFile(l_FullName.c_str(), "r");
	if (l_pFileDesc == nullptr)
	{
		std::string l_Err = std::string("sfx_play: cannot open ")
				+ l_FullName.c_str();
		werr(LOGDESIGNER, l_Err.c_str());
		file_update(p_Ctx, l_TableFilename.c_str());
		file_unlock(l_TableFilename.c_str());
		return -1;
	}

	Mix_Chunk * l_pChunk = Mix_LoadWAV_RW(l_pFileDesc, 1);
	if (l_pChunk == nullptr)
	{
		std::string l_Err = std::string("sfx_play: cannot read ")
				+ l_FullName.c_str();
		werr(LOGDESIGNER, l_Err.c_str());
		file_update(p_Ctx, l_TableFilename.c_str());
		file_unlock(l_TableFilename.c_str());
		return -1;
	}

	g_SoundList[p_FileName] = l_pChunk;

	file_unlock(l_TableFilename.c_str());

	return Mix_PlayChannel(p_Channel, l_pChunk, p_Loops);
}
示例#3
0
/*********************
returned config should not be freed
*********************/
static const config_t * get_config(const char * table, const char * file)
{
	char * filename;
	const config_t * config;

	if( table == NULL ) {
		filename = strdup(file);
	} else {
		filename = strconcat(table,"/",file,NULL);
	}

//	wlog(LOGDEBUG,"Entry get : %s",filename);

	config = (config_t*)list_find(entry_list,filename);

	if(config) {
//		wlog(LOGDEBUG,"Entry found : %s",filename);
		free(filename);
		return config;
	}

	file_lock(filename);

//	wlog(LOGDEBUG,"Entry asked : %s",filename);
	file_update(context_get_player(),filename);

	if( (config=load_config(filename)) == NULL ) {
		file_unlock(filename);
		free(filename);
		return NULL;
	}
	file_unlock(filename);

//	wlog(LOGDEBUG,"Entry loaded : %s",filename);
	list_update(&entry_list,filename,(config_t*)config);
	free(filename);

	return config;
}
示例#4
0
AirSpaceWindow::AirSpaceWindow(QWidget* parent, const QString &name, Qt::WindowFlags wflags, IDataBase::SourceType src)
  :TableWindow(parent, name, wflags)
{
  QStringList nameList;
  QAction* pAction;
  QTableWidget *pTable;

  pTable = TableWindow::getTable();
  m_pWebMapView = NULL;
  m_pAirSpaceView = NULL;
  m_externSelect = false;

  switch(src)
  {
    case IDataBase::SqlDB:
      m_pDb = ISql::pInstance();

      connect(m_pDb, SIGNAL(airSpacesChanged()), this, SLOT(file_update()));

      pAction = new QAction(tr("&Edit"), this);
      connect(pAction, SIGNAL(triggered()), this, SLOT(file_edit()));
      MDIWindow::addAction(pAction, true);

      pAction = new QAction(tr("&Delete"), this);
      connect(pAction, SIGNAL(triggered()), this, SLOT(file_delete()));
      MDIWindow::addAction(pAction);

      pAction = new QAction(tr("&Add to GPS..."), this);
      connect(pAction, SIGNAL(triggered()), this, SLOT(file_AddToGPS()));
      MDIWindow::addAction(pAction, true);
    break;
    case IDataBase::GPSdevice:
    {
      m_pDb = IGPSDevice::pInstance();

      connect(m_pDb, SIGNAL(airSpacesChanged()), this, SLOT(file_update()));

      pAction = new QAction(tr("&Delete"), this);
      connect(pAction, SIGNAL(triggered()), this, SLOT(file_delete()));
      MDIWindow::addAction(pAction);

      pAction = new QAction(tr("&Update"), this);
      connect(pAction, SIGNAL(triggered()), this, SLOT(file_update()));
      MDIWindow::addAction(pAction);
    }
    break;
    case IDataBase::File:
    {
      m_pDb = NULL;

      pAction = new QAction(tr("&Add to GPS..."), this);
      connect(pAction, SIGNAL(triggered()), this, SLOT(file_AddToGPS()));
      MDIWindow::addAction(pAction, true);
    }
    break;
  }

  if(src != IDataBase::SqlDB)
  {
    pAction = new QAction(tr("Add to DB..."), this);
    connect(pAction, SIGNAL(triggered()), this, SLOT(file_AddToSqlDB()));
    MDIWindow::addAction(pAction, true);

    pAction = new QAction(tr("&Update"), this);
    connect(pAction, SIGNAL(triggered()), this, SLOT(file_update()));
    MDIWindow::addAction(pAction);
  }

  // import/export
  pAction = new QAction(this);
  pAction->setSeparator(true);
  MDIWindow::addAction(pAction);

  if(src == IDataBase::File)
  {
    pAction = new QAction(tr("&Import..."), this);
    connect(pAction, SIGNAL(triggered()), this, SLOT(file_open()));
    MDIWindow::addAction(pAction);
  }

  pAction = new QAction(tr("&Export all..."), this);
  connect(pAction, SIGNAL(triggered()), this, SLOT(exportTable()));
  MDIWindow::addAction(pAction);

  // view
  pAction = new QAction(this);
  pAction->setSeparator(true);
  MDIWindow::addAction(pAction);

  pAction = new QAction(tr("&View..."), this);
  connect(pAction, SIGNAL(triggered()), this, SLOT(file_viewAirSpace()));
  MDIWindow::addAction(pAction);

  pAction = new QAction(tr("View &Web Map..."), this);
  connect(pAction, SIGNAL(triggered()), this, SLOT(file_viewWebMap()));
  MDIWindow::addAction(pAction, true);

  TableWindow::setWindowIcon(QIcon(":/document.xpm"));

  // configure the table
  pTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
  pTable->setSelectionMode(QAbstractItemView::ExtendedSelection);

  // header
  nameList += tr("Name");
  nameList += tr("Low [m]");
  nameList += tr("High [m]");
  nameList += tr("Class");
  nameList += tr("Comment");
  setupHeader(nameList);

  pTable->setColumnWidth(Name, 200);
  pTable->setColumnWidth(High, 100);
  pTable->setColumnWidth(Low, 100);
  pTable->setColumnWidth(Class, 80);
  pTable->setColumnWidth(Comment, 750);

  connect(m_pDb, SIGNAL(airSpacesChanged()), this, SLOT(file_update()));

  if(src == IDataBase::File)
  {
    file_open();
  }
  else
  {
    file_update();
  }
}