Exemple #1
0
bool TestCase::load(const char* filePath)
{
    char* buf = 0;
    FILE* fp = fopen(filePath, "rb");
    if (!fp)
        return false;
    fseek(fp, 0, SEEK_END);
    int bufSize = ftell(fp);
    fseek(fp, 0, SEEK_SET);
    buf = new char[bufSize];
    if (!buf)
    {
        fclose(fp);
        return false;
    }
    fread(buf, bufSize, 1, fp);
    fclose(fp);

    char* src = buf;
    char* srcEnd = buf + bufSize;
    char row[512];
    while (src < srcEnd)
    {
        // Parse one row
        row[0] = '\0';
        src = parseRow(src, srcEnd, row, sizeof(row)/sizeof(char));
        if (row[0] == 's')
        {
            // Sample name.
            copyName(m_sampleName, row+1);
        }
        else if (row[0] == 'f')
        {
            // File name.
            copyName(m_geomFileName, row+1);
        }
        else if (row[0] == 'p' && row[1] == 'f')
        {
            // Pathfind test.
            Test* test = new Test;
            memset(test, 0, sizeof(Test));
            test->type = TEST_PATHFIND;
            test->expand = false;
            test->next = m_tests;
            m_tests = test;
            sscanf(row+2, "%f %f %f %f %f %f %x %x",
                   &test->spos[0], &test->spos[1], &test->spos[2],
                   &test->epos[0], &test->epos[1], &test->epos[2],
                   &test->includeFlags, &test->excludeFlags);
        }
    }
    
    delete [] buf;

    return true;
}
void FLogTextBrowser::contextMenuEvent(QContextMenuEvent *event)
{
	flist_copylink = anchorAt(event->pos());
	QTextCursor cursor = textCursor();
	QMenu *menu = new QMenu;
	QAction *action;
	if(flist_copylink.isEmpty()) {
		//Plain text selected
	} else if(flist_copylink.startsWith("https://www.f-list.net/c/")) {
		flist_copyname = flist_copylink.mid(QString("https://www.f-list.net/c/").length());
		if(flist_copyname.endsWith("/")) {
			flist_copyname = flist_copyname.left(flist_copyname.length() - 1);
		}
		menu->addAction(QString("Open Profile"), this, SLOT(openProfile()));
		//todo: Get the list of available sessions. Create a submenu with all available characters if there is more than one (or this session isn't vlaid).
		menu->addAction(QString("Open PM"), this, SLOT(openPrivateMessage()));
		menu->addAction(QString("Copy Profile Link"), this, SLOT(copyLink()));
		menu->addAction(QString("Copy Name"), this, SLOT(copyName()));
		menu->addSeparator();
	} else if(flist_copylink.startsWith("#AHI-")) {
		flist_copyname = flist_copylink.mid(5);
		//todo: Get the list of available sessions. Create a submenu with all available characters if there is more than one (or this session isn't vlaid).
		menu->addAction(QString("Join Channel"), this, SLOT(joinChannel()));
		//todo: Maybe get the name the plain text of the link and make that available for copying?
		menu->addAction(QString("Copy Channel ID"), this, SLOT(copyName()));
		menu->addSeparator();
	} else if(flist_copylink.startsWith("#CSA-")) {
		flist_copyname = flist_copylink.mid(5);
		//todo: If possible, get which session this actually came from and use that.
		menu->addAction(QString("Confirm Staff Report"), this, SLOT(confirmReport()));
		menu->addAction(QString("Copy Call ID"), this, SLOT(copyName()));
		menu->addSeparator();
	} else {
		menu->addAction(QString("Copy Link"), this, SLOT(copyLink()));
		menu->addSeparator();
	}
	action = menu->addAction(QString("Copy Selection"), this, SLOT(copy()));
	action->setEnabled(cursor.hasSelection());
	menu->addAction(QString("Select All"), this, SLOT(selectAll()));

	menu->exec(event->globalPos());
	delete menu;
}
Exemple #3
0
int rlIniFile::read(const char *filename)
{
  FILE *fp;
  char line[rl_PRINTF_LENGTH],
       name_section[rl_PRINTF_LENGTH],
       name_name[rl_PRINTF_LENGTH],
       name_param[rl_PRINTF_LENGTH],
       *cptr;
  rlSection *s, *s_old;

  // delete old content
  s = _firstSection;
  while(s != NULL)
  {
    deleteSectionNames(s);
    s_old = s;
    s = s->nextSection;
    delete s_old;
  }

  // read the file
  fname.setText(filename);
  _firstSection = new rlSection;      // first section holds names with section name = null_string
  _firstSection->nextSection = NULL;
  _firstSection->firstName = NULL;
  _firstSection->name = new char[1];
  _firstSection->name[0] = '\0';
  fp = fopen(filename,"r");
  if(fp == NULL) return -1;
  name_section[0] = name_name[0] = name_param[0] = '\0';
  while(fgets(line,sizeof(line)-1,fp) != NULL)
  {
    cptr = strchr(line,0x0d);
    if(cptr != NULL) *cptr = '\0';
    cptr = strchr(line,0x0a);
    if(cptr != NULL) *cptr = '\0';
    if(line[0] == '[') // section identifier
    {
      copyIdentifier(name_section,line);
      setText(name_section, NULL, NULL);
    }
    else if(line[0] > ' ' && line[0] != '\t' && line[0] != '#') // name identifier
    {
      copyName(name_name,line);
      copyParam(name_param,line);
      setText(name_section, name_name, name_param);
    }
    else // it must be a comment line
    {
      setText(name_section, line, NULL);
    }
  }
  fclose(fp);
  return 0;
}
Exemple #4
0
void DreamWebEngine::openOb() {
	uint8 commandLine[64] = "OBJECT NAME ONE                         ";

	copyName(_openedType, _openedOb, commandLine);

	printMessage(kInventx, kInventy+86, 62, 240, false);

	printDirect(commandLine, _lastXPos + 5, kInventy+86, 220, false);

	fillOpen();
	_openChangeSize = getOpenedSlotCount() * kItempicsize + kInventx;
}
Exemple #5
0
PythonBrowserView::PythonBrowserView(PythonEngine *pythonEngine, PythonScriptingConsole *console, QWidget *parent)
    : QDockWidget(tr("Browser"), parent), pythonEngine(pythonEngine), console(console)
{
    setMinimumWidth(280);
    setObjectName("BrowserView");

    connect(pythonEngine, SIGNAL(executedExpression()), this, SLOT(executed()));
    connect(pythonEngine, SIGNAL(executedScript()), this, SLOT(executed()));

    trvBrowser = new QTreeWidget(this);
    trvBrowser->setContextMenuPolicy(Qt::CustomContextMenu);
    trvBrowser->setColumnCount(3);
    trvBrowser->setIndentation(18);
    trvBrowser->setColumnWidth(0, 200);
    trvBrowser->setColumnWidth(0, 200);

    QStringList headers;
    headers << tr("Name") << tr("Type") << tr("Value");
    trvBrowser->setHeaderLabels(headers);

    trvVariables = NULL;
    trvFunctions = NULL;
    trvClasses = NULL;
    trvOther = NULL;

    variableExpanded = true;
    functionExpanded = true;
    classExpanded = true;
    otherExpanded = false;

    executed();
    trvBrowser->sortItems(0, Qt::AscendingOrder);

    connect(trvBrowser, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(executeCommand(QTreeWidgetItem *, int)));
    connect(trvBrowser, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(doContextMenu(const QPoint &)));

    actCopyName = new QAction(icon(""), tr("Copy name"), this);
    connect(actCopyName, SIGNAL(triggered()), this, SLOT(copyName()));

    actCopyValue = new QAction(icon(""), tr("Copy value"), this);
    connect(actCopyValue, SIGNAL(triggered()), this, SLOT(copyValue()));

    actDelete = new QAction(icon(""), tr("&Delete"), this);
    connect(actDelete, SIGNAL(triggered()), this, SLOT(deleteVariable()));

    mnuContext = new QMenu(trvBrowser);
    mnuContext->addAction(actCopyName);
    mnuContext->addAction(actCopyValue);
    mnuContext->addSeparator();
    mnuContext->addAction(actDelete);

    setWidget(trvBrowser);
}
Exemple #6
0
static int readTagLineRaw(tagFile * const file)
{
	int result = 1;
	int reReadLine;

	/*  If reading the line places any character other than a null or a
	 *  newline at the last character position in the buffer (one less than
	 *  the buffer size), then we must resize the buffer and reattempt to read
	 *  the line.
	 */
	do
	{
		char *const pLastChar = file->line.buffer + file->line.size - 2;
		char *line;

		file->pos = ftell(file->fp);
		reReadLine = 0;
		*pLastChar = '\0';
		line = fgets(file->line.buffer, (int) file->line.size, file->fp);
		if (line == NULL)
		{
			/* read error */
			if (!feof(file->fp))
				perror("readTagLine");
			result = 0;
		}
		else if (*pLastChar != '\0' && *pLastChar != '\n' && *pLastChar != '\r')
		{
			/*  buffer overflow */
			growString(&file->line);
			fseek(file->fp, file->pos, SEEK_SET);
			reReadLine = 1;
		}
		else
		{
			size_t i = strlen(file->line.buffer);
			while (i > 0 &&
			        (file->line.buffer[i - 1] == '\n'
			         || file->line.buffer[i - 1] == '\r'))
			{
				file->line.buffer[i - 1] = '\0';
				--i;
			}
		}
	}
	while (reReadLine && result);
	if (result)
		copyName(file);
	return result;
}