Exemple #1
0
void MainWindow::connectSlots(){
    //QObject::connect(MainWindow::createSm, SIGNAL(clicked()), this, SLOT(startScript()));
    QObject::connect(loadDataFile, SIGNAL(clicked()), this, SLOT(openDataFile()));
    QObject::connect(loadUtteranceFile, SIGNAL(clicked()), this, SLOT(openUtteranceFile()));
    QObject::connect(loadSm, SIGNAL(clicked()),this, SLOT(open()) );
    QObject::connect(firstUseBox, SIGNAL(clicked()), this, SLOT(openDataFile()));
    QObject::connect(createSm, SIGNAL(clicked()), this, SLOT(startScript()));
    QObject::connect(agentAdapterCombo, SIGNAL(activated(QString)),this, SLOT(setAdapter(QString)));
}
Exemple #2
0
QList<int> KCharSelectData::sectionContents(int section)
{
    if(!openDataFile()) {
        return QList<int>();
    }


    const char* data = charselect->dataFile;
    const uint32_t offsetBegin = FromLittleEndian32(data+28);
    const uint32_t offsetEnd = FromLittleEndian32(data+32);

    int max = ((offsetEnd - offsetBegin) / 4) - 1;

    QList<int> res;

    if(section > max)
        return res;

    for(int i = 0; i <= max; i++) {
        const uint16_t currSection = FromLittleEndian16(data + offsetBegin + i*4);
        if(currSection == section) {
            res.append( FromLittleEndian16(data + offsetBegin + i*4 + 2) );
        }
    }

    return res;
}
Exemple #3
0
int main(void)
{
    ifstream gradeDataFile;
    char fileName[FILENAME_SIZE];
    int recordNumber;
    int numGrades;
    char studentName[25];
    int studentGrades[100];
    
    recordNumber = 1;
    
    system("cls");

    getFileName( fileName );
    openDataFile( gradeDataFile, fileName );
    setGradeCount( gradeDataFile, numGrades );

    while( gradeDataFile.peek() != EOF )
    {
        cout << setw(3) << recordNumber << "  ";
        readRecord( gradeDataFile, studentName, studentGrades, numGrades );
        cout << studentName << "  ";
        cout << setw(6) << fixed << setprecision(2) << showpoint << avgForRecord( studentGrades, numGrades ) << "  ";
        cout << setw(6) << fixed << setprecision(2) << showpoint << devForRecord( studentGrades, numGrades ) << endl;
        recordNumber++;
    }
    
    gradeDataFile.close();
}
Exemple #4
0
QList<QChar> KCharSelectData::blockContents(int block)
{
    if(!openDataFile()) {
        return QList<QChar>();
    }


    const char* data = charselect->dataFile;
    const uint32_t offsetBegin = FromLittleEndian32(data+20);
    const uint32_t offsetEnd = FromLittleEndian32(data+24);

    int max = ((offsetEnd - offsetBegin) / 4) - 1;

    QList<QChar> res;

    if(block > max)
        return res;

    uint16_t unicodeBegin = FromLittleEndian16(data + offsetBegin + block*4);
    uint16_t unicodeEnd = FromLittleEndian16(data + offsetBegin + block*4 + 2);

    while(unicodeBegin < unicodeEnd) {
        res.append(unicodeBegin);
        unicodeBegin++;
    }
    res.append(unicodeBegin); // Be carefull when unicodeEnd==0xffff

    return res;
}
Exemple #5
0
QChar::Category KCharSelectData::category(CharSelectData* charselect, uint16_t unicode)
{
    if(!openDataFile()) {
        return c.category();
    }

    uint16_t unicode = c.unicode();


    const char* data = charselect->dataFile;
    const uint32_t offsetBegin = FromLittleEndian32(data+4);
    const uint32_t offsetEnd = FromLittleEndian32(data+8);

    int min = 0;
    int mid;
    int max = ((offsetEnd - offsetBegin) / 6) - 1;
    QString s;

    while (max >= min) {
        mid = (min + max) / 2;
        const uint16_t midUnicode = FromLittleEndian16(data + offsetBegin + mid*6);
        if (unicode > midUnicode)
            min = mid + 1;
        else if (unicode < midUnicode)
            max = mid - 1;
        else {
            uint32_t offset = FromLittleEndian32(data + offsetBegin + mid*6 + 2);
            const uint8_t categoryCode = * (uint8_t *)(data + offset);
            return QChar::Category(categoryCode);
        }
    }

    return c.category();
}
bool C45Reader::setFile(const string& fileName) {

	renew();

	if (!checkFileExist(fileName)) {
		return false;
	}

	if (readAllDataFromNamesFile(fileName + ".names") != 0) {
		return false;
	}

	mNamesLoaded = true;

	string f = fileName + ".data";
	if (openDataFile(f) != 0) {
		return false;
	}

	// read first row
	if (readData() != 0) {
		return false;
	}

	return true;
}
Exemple #7
0
void Resource::readStaticText() {
	Common::File *labTextFile = openDataFile("Lab:Rooms/LabText");

	for (int i = 0; i < 48; i++)
		_staticText[i] = labTextFile->readLine();

	delete labTextFile;
}
Exemple #8
0
QueueView::QueueView(QWidget* parent) : QTreeWidget(parent), m_status(0)
{
	if(getSettingsValue("css").toBool())
	{
		QFile file;
		if(openDataFile(&file, "/data/css/queueview.css"))
			setStyleSheet(file.readAll());
	}
}
Exemple #9
0
DeepStarComponent::DeepStarComponent( SkyComposite *parent, QString fileName, float trigMag, bool staticstars ) :
    ListComponent(parent),
    m_reindexNum( J2000 ),
    triggerMag( trigMag ),
    m_FaintMagnitude(-5.0),
    staticStars( staticstars ),
    dataFileName( fileName )
{
    fileOpened = false;
    openDataFile();
    if( staticStars )
        loadStaticStars();
    qDebug() << "Loaded DSO catalog file: " << dataFileName;
}
Exemple #10
0
InventoryData *Resource::readInventory(const Common::String fileName) {
	Common::File *dataFile = openDataFile(fileName, MKTAG('I', 'N', 'V', '1'));

	_vm->_numInv = dataFile->readUint16LE();
	InventoryData *inventory = new InventoryData[_vm->_numInv + 1];

	for (int i = 1; i <= _vm->_numInv; i++) {
		inventory[i]._quantity = dataFile->readUint16LE();
		inventory[i]._name = readString(dataFile);
		inventory[i]._bitmapName = readString(dataFile);
	}

	delete dataFile;
	return inventory;
}
Exemple #11
0
void Resource::readViews(uint16 roomNum) {
	Common::String fileName = "LAB:Rooms/" + Common::String::format("%d", roomNum);
	Common::File *dataFile = openDataFile(fileName, MKTAG('R', 'O', 'M', '4'));

	RoomData *curRoom = &_vm->_rooms[roomNum];

	curRoom->_roomMsg = readString(dataFile);
	readView(dataFile, curRoom->_view[kDirectionNorth]);
	readView(dataFile, curRoom->_view[kDirectionSouth]);
	readView(dataFile, curRoom->_view[kDirectionEast]);
	readView(dataFile, curRoom->_view[kDirectionWest]);
	readRule(dataFile, curRoom->_rules);

	delete dataFile;
}
Exemple #12
0
void DetailTask::run()
{
    if(isRun)
        return;
    isRun = true;
    qDebug()<<Q_FUNC_INFO<<Global::mylog->detaildata<<Global::mylog->detaildata_linNum<<fileQueue.size();
    if(!authon_db.isOpen())
        open_authonSql();
    if(!fileQueue.isEmpty())
    {
        openDataFile(fileQueue.at(0));
        while(!dataFile.atEnd())
        {
            QByteArray line = dataFile.readLine();
            if(linNum <= Global::mylog->detaildata_linNum)
            {
                linNum++;
                if(Global::mylog->detaildata_linNum == 0)
                {
                    process_line(line);
                    Global::mylog->detaildata_linNum++;
                    linNum++;
                }
                continue;
            }
            process_line(line);
            Global::mylog->detaildata_linNum++;
            linNum++;
        }
        Global::mylog->detaildata=QFileInfo(dataFile.fileName()).fileName();
        Global::saveLog();
        linNum =1;

        if(fileQueue.size()>1)
        {
            fileQueue.dequeue();
            if(!fileQueue.isEmpty())
            {
                qDebug()<<"1111111111";
                Global::mylog->detaildata = fileQueue.at(0);
                Global::mylog->detaildata_linNum =0;
            }
        }
    }
    isRun = false;
}
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: firstUse((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 1: showWindow(); break;
        case 2: open(); break;
        case 3: startScript(); break;
        case 4: openDataFile(); break;
        default: ;
        }
        _id -= 5;
    }
    return _id;
}
Exemple #14
0
Common::String Resource::getText(const Common::String fileName) {
	Common::File *dataFile = openDataFile(fileName);

	uint32 count = dataFile->size();
	byte *buffer = new byte[count];
	byte *text = buffer;
	dataFile->read(buffer, count);

	while (text && (*text != '\0'))
		*text++ -= (byte)95;

	delete dataFile;

	Common::String str = (char *)buffer;
	delete[] buffer;

	return str;
}
Exemple #15
0
void Resource::readRoomData(const Common::String fileName) {
	Common::File *dataFile = openDataFile(fileName, MKTAG('D', 'O', 'R', '1'));

	_vm->_manyRooms = dataFile->readUint16LE();
	_vm->_highestCondition = dataFile->readUint16LE();
	_vm->_rooms = new RoomData[_vm->_manyRooms + 1];

	for (int i = 1; i <= _vm->_manyRooms; i++) {
		RoomData *curRoom = &_vm->_rooms[i];
		curRoom->_doors[kDirectionNorth] = dataFile->readUint16LE();
		curRoom->_doors[kDirectionSouth] = dataFile->readUint16LE();
		curRoom->_doors[kDirectionEast] = dataFile->readUint16LE();
		curRoom->_doors[kDirectionWest] = dataFile->readUint16LE();
		curRoom->_transitionType = dataFile->readByte();
	}

	delete dataFile;
}
Exemple #16
0
static void
processConfigurationFile (
  OptionProcessingInformation *info,
  const char *path,
  int optional
) {
  FILE *file = openDataFile(path, "r", optional);

  if (file) {
    ConfigurationFileProcessingData conf;

    conf.info = info;
      ;
    if ((conf.settings = malloc(info->optionCount * sizeof(*conf.settings)))) {
      int processed;
      unsigned int index;

      for (index=0; index<info->optionCount; index+=1) conf.settings[index] = NULL;
      processed = processLines(file, processConfigurationLine, &conf);

      for (index=0; index<info->optionCount; index+=1) {
        char *setting = conf.settings[index];

        if (setting) {
          ensureSetting(info, &info->optionTable[index], setting);
          free(setting);
        }
      }

      if (!processed) {
        logMessage(LOG_ERR, gettext("file '%s' processing error."), path);
        info->warning = 1;
      }

      free(conf.settings);
    } else {
      logMallocError();
    }

    fclose(file);
  } else if (!optional || (errno != ENOENT)) {
    info->warning = 1;
  }
}
Exemple #17
0
static FILE *
cpbOpenFile (const char *mode) {
  const char *file = "clipboard";
  const char *directory = STATE_DIRECTORY;

  if (directory) {
    char *path = makePath(directory, file);

    if (path) {
      FILE *stream = openDataFile(path, mode, 0);

      free(path);
      path = NULL;

      if (stream) return stream;
    }
  }

  return NULL;
}
Exemple #18
0
TextFont *Resource::getFont(const Common::String fileName) {
	// TODO: Add support for the font format of the Amiga version
	Common::File *dataFile = openDataFile(fileName, MKTAG('V', 'G', 'A', 'F'));

	uint32 headerSize = 4 + 2 + 256 * 3 + 4;
	uint32 fileSize = dataFile->size();
	if (fileSize <= headerSize)
		return nullptr;

	TextFont *textfont = new TextFont();
	textfont->_dataLength = fileSize - headerSize;
	textfont->_height = dataFile->readUint16LE();
	dataFile->read(textfont->_widths, 256);
	for (int i = 0; i < 256; i++)
		textfont->_offsets[i] = dataFile->readUint16LE();
	dataFile->skip(4);
	textfont->_data = new byte[textfont->_dataLength + 4];
	dataFile->read(textfont->_data, textfont->_dataLength);
	delete dataFile;
	return textfont;
}
Exemple #19
0
UT_array* KCharSelectData::sectionList()
{
    if(!openDataFile()) {
        return fcitx_utils_new_string_list();
    }


    const char* data = charselect->dataFile;
    const uint32_t stringBegin = FromLittleEndian32(data+24);
    const uint32_t stringEnd = FromLittleEndian32(data+28);

    const char* data = dataFile.constData();
    UT_array* list;
    uint32_t i = stringBegin;
    while(i < stringEnd) {
        list.append(i18nc("KCharSelect section name", data + i));
        i += strlen(data + i) + 1;
    }

    return list;
}
Exemple #20
0
int KCharSelectData::sectionIndex(int block)
{
    if(!openDataFile()) {
        return 0;
    }


    const char* data = charselect->dataFile;
    const uint32_t offsetBegin = FromLittleEndian32(data+28);
    const uint32_t offsetEnd = FromLittleEndian32(data+32);

    int max = ((offsetEnd - offsetBegin) / 4) - 1;

    for(int i = 0; i <= max; i++) {
        if( FromLittleEndian16(data + offsetBegin + i*4 + 2) == block) {
            return FromLittleEndian16(data + offsetBegin + i*4);
        }
    }

    return 0;
}
Exemple #21
0
QString KCharSelectData::sectionName(int index)
{
    if(!openDataFile()) {
        return QString();
    }


    const char* data = charselect->dataFile;
    const uint32_t stringBegin = FromLittleEndian32(data+24);
    const uint32_t stringEnd = FromLittleEndian32(data+28);

    uint32_t i = stringBegin;
    int currIndex = 0;

    const char* data = dataFile.constData();
    while(i < stringEnd && currIndex < index) {
        i += strlen(data + i) + 1;
        currIndex++;
    }

    return i18nc("KCharselect unicode section name", data + i);
}
Exemple #22
0
int KCharSelectData::blockIndex(CharSelectData* charselect, uint16_t unicode)
{
    if(!openDataFile()) {
        return 0;
    }


    const char* data = charselect->dataFile;
    const uint32_t offsetBegin = FromLittleEndian32(data+20);
    const uint32_t offsetEnd = FromLittleEndian32(data+24);
    const uint16_t unicode = c.unicode();

    int max = ((offsetEnd - offsetBegin) / 4) - 1;

    int i = 0;

    while (unicode > FromLittleEndian16(data + offsetBegin + i*4 + 2) && i < max) {
        i++;
    }

    return i;
}