Exemplo n.º 1
0
TableGenerator::TableGenerator() : m_state(NoErrors),
    m_systemComposeDir(QString())
{
    initPossibleLocations();
    findComposeFile();
    orderComposeTable();
#ifdef DEBUG_GENERATOR
    printComposeTable();
#endif
}
Exemplo n.º 2
0
TableGenerator::TableGenerator() : m_state(NoErrors),
    m_systemComposeDir(QString())
{
    initPossibleLocations();
    QString composeFilePath = findComposeFile();
#ifdef DEBUG_GENERATOR
// don't use cache when in debug mode.
    if (!composeFilePath.isEmpty())
        qDebug() << "Using Compose file from: " << composeFilePath;
#else
    QComposeCacheFileHeader fileInfo = readFileMetadata(composeFilePath);
    if (fileInfo.fileSize != 0)
        m_composeTable = loadCache(fileInfo);
#endif
    if (m_composeTable.isEmpty() && cleanState()) {
        if (composeFilePath.isEmpty()) {
            m_state = MissingComposeFile;
        } else {
            QFile composeFile(composeFilePath);
            composeFile.open(QIODevice::ReadOnly);
            parseComposeFile(&composeFile);
            orderComposeTable();
            if (m_composeTable.isEmpty()) {
                m_state = EmptyTable;
#ifndef DEBUG_GENERATOR
// don't save cache when in debug mode
            } else {
                fileInfo.cacheVersion = SupportedCacheVersion;
                saveCache(fileInfo, m_composeTable);
#endif
            }
        }
    }
#ifdef DEBUG_GENERATOR
    printComposeTable();
#endif
}