Ejemplo n.º 1
0
void WriteIncludes::insertIncludeForClass(const QString &className, QString header, bool global)
{
    if (debugWriteIncludes)
        qDebug() << "WriteIncludes::insertIncludeForClass" << className << header  << global;

    do {
        if (!header.isEmpty())
            break;

        // Known class
        const StringMap::const_iterator it = m_classToHeader.constFind(className);
        if (it != m_classToHeader.constEnd()) {
            header = it.value();
            global =  true;
            break;
        }

        // Quick check by class name to detect includehints provided for custom widgets
        const QString lowerClassName = className.toLower();
        if (m_includeBaseNames.contains(lowerClassName)) {
            header.clear();
            break;
        }

        // Last resort: Create default header
        header = lowerClassName;
        header += QLatin1String(".h");
        global = true;
    } while (false);

    if (!header.isEmpty())
        insertInclude(header, global);
}
Ejemplo n.º 2
0
PostJob::PostJob(PlatformDependent *internals, const QNetworkRequest &request, const StringMap &parameters)
    : BaseJob(internals), m_ioDevice(0), m_request(request)
{
    // Create post data
    int j = 0;
    for (StringMap::const_iterator i = parameters.begin(); i != parameters.end(); ++i) {
        if (j++ > 0) {
            m_byteArray.append('&');
        }
        m_byteArray.append(QUrl::toPercentEncoding(i.key()));
        m_byteArray.append('=');
        m_byteArray.append(QUrl::toPercentEncoding(i.value()));
    }
}
Ejemplo n.º 3
0
void WriteIncludes::writeHeaders(const OrderedSet &headers, bool global)
{
    const QChar openingQuote = global ? QLatin1Char('<') : QLatin1Char('"');
    const QChar closingQuote = global ? QLatin1Char('>') : QLatin1Char('"');

    const OrderedSet::const_iterator cend = headers.constEnd();
    for ( OrderedSet::const_iterator sit = headers.constBegin(); sit != cend; ++sit) {
        const StringMap::const_iterator hit = m_oldHeaderToNewHeader.constFind(sit.key());
        const bool mapped =  hit != m_oldHeaderToNewHeader.constEnd();
        const  QString header =  mapped ? hit.value() : sit.key();
        if (!header.trimmed().isEmpty()) {
            m_output << "#include " << openingQuote << header << closingQuote << QLatin1Char('\n');
        }
    }
}
Ejemplo n.º 4
0
void WriteIncludes::insertIncludeForClass(const QString &className, QString header, bool global)
{
    if (debugWriteIncludes)
        fprintf(stderr, "%s %s '%s' %d\n", Q_FUNC_INFO, qPrintable(className), qPrintable(header), global);

    do {
        if (!header.isEmpty())
            break;

        // Known class        
        const StringMap::const_iterator it = m_classToHeader.constFind(className);
        if (it != m_classToHeader.constEnd()) {
            header = it.value();
            global =  true;
            break;
        }

        // Quick check by class name to detect includehints provided for custom widgets.
        // Remove namespaces
        QString lowerClassName = className.toLower();
        static const QString namespaceSeparator = QLatin1String("::");
        const int namespaceIndex = lowerClassName.lastIndexOf(namespaceSeparator);
        if (namespaceIndex != -1)
            lowerClassName.remove(0, namespaceIndex + namespaceSeparator.size());
        if (m_includeBaseNames.contains(lowerClassName)) {
            header.clear();
            break;
        }

        // Last resort: Create default header
        if (!m_uic->option().implicitIncludes)
            break;
        header = lowerClassName;
        header += QLatin1String(".h");
        if (warnHeaderGeneration) {
            qWarning("%s: Warning: generated header '%s' for class '%s'.",
                     qPrintable(m_uic->option().messagePrefix()),
                     qPrintable(header), qPrintable(className));

        }

        global = true;
    } while (false);

    if (!header.isEmpty())
        insertInclude(header, global);
}
Ejemplo n.º 5
0
void ImageScanThread<DBFS>::run()
{
    RunProlog();

    setPriority(QThread::LowPriority);

    do
    {
        // Process all clears before scanning
        while (ClearsPending())
        {
            m_mutexQueue.lock();
            if (m_clearQueue.isEmpty())
                break;
            ClearTask task = m_clearQueue.takeFirst();
            m_mutexQueue.unlock();

            int devId      = task.first;
            QString action = task.second;

            LOG(VB_GENERAL, LOG_INFO,
                QString("Clearing Filesystem: %1 %2").arg(action).arg(devId));

            // Clear Db
            m_dbfs.ClearDb(devId, action);

            // Pass on to thumb generator now scanning has stopped
            m_thumb.ClearThumbs(devId, action);
        }

        // Scan requested ?
        if (IsScanning())
        {
            LOG(VB_GENERAL, LOG_INFO,  "Starting scan");

            // Load known directories and files from the database
            if (!m_dbfs.ReadAllImages(m_dbFileMap, m_dbDirMap))
                // Abort on any Db error
                break;

            bool firstScan = m_dbFileMap.isEmpty();

            // Pause thumb generator so that scans are fast as possible
            m_thumb.PauseBackground(true);

            // Adapter determines list of dirs to scan
            StringMap paths = m_dbfs.GetScanDirs();

            CountFiles(paths.values());

            // Now start the actual syncronization
            m_seenFile.clear();
            m_changedImages.clear();
            StringMap::const_iterator i = paths.constBegin();
            while (i != paths.constEnd() && IsScanning())
            {
                SyncSubTree(QFileInfo(i.value()), GALLERY_DB_ID, i.key(), i.value());
                ++i;
            }

            // Release thumb generator asap
            m_thumb.PauseBackground(false);

            // Adding or updating directories has been completed.
            // The maps now only contain old directories & files that are not
            // in the filesystem anymore. Remove them from the database
            m_dbfs.RemoveFromDB(m_dbDirMap.values());
            m_dbfs.RemoveFromDB(m_dbFileMap.values());

            // Cleanup thumbnails
            QStringList mesg(m_thumb.DeleteThumbs(m_dbFileMap.values()));
            mesg << m_changedImages.join(",");

            // Cleanup dirs
            m_dbFileMap.clear();
            m_dbDirMap.clear();
            m_seenDir.clear();

            m_mutexProgress.lock();
            // (count == total) signals scan end
            Broadcast(m_progressTotalCount);
            // Must reset counts for scan queries
            m_progressCount = m_progressTotalCount = 0;
            m_mutexProgress.unlock();

            LOG(VB_GENERAL, LOG_INFO,  "Finished scan");

            // For initial scans pause briefly to give thumb generator a headstart
            // before being deluged by client requests
            if (firstScan)
                msleep(1000);

            // Notify clients of completion with removed & changed images
            m_dbfs.Notify("IMAGE_DB_CHANGED", mesg);

            ChangeState(false);
        }
    }
    while (ClearsPending());

    RunEpilog();
}