예제 #1
0
파일: album.cpp 프로젝트: UIKit0/digikam
void PAlbum::setDate(const QDate& date)
{
    m_date = date;

    DatabaseAccess access;
    access.db()->setAlbumDate(id(), m_date);
}
예제 #2
0
파일: album.cpp 프로젝트: UIKit0/digikam
void PAlbum::setCategory(const QString& category)
{
    m_category = category;

    DatabaseAccess access;
    access.db()->setAlbumCategory(id(), m_category);
}
예제 #3
0
파일: album.cpp 프로젝트: UIKit0/digikam
void PAlbum::setCaption(const QString& caption)
{
    m_caption = caption;

    DatabaseAccess access;
    access.db()->setAlbumCaption(id(), m_caption);
}
예제 #4
0
DatabaseTransaction::~DatabaseTransaction()
{
    if (m_access)
    {
        m_access->backend()->commitTransaction();
    }
    else
    {
        DatabaseAccess access;
        access.backend()->commitTransaction();
    }
}
예제 #5
0
bool ImageScanner::copyFromSource(qlonglong srcId)
{
    DatabaseAccess access;

    // some basic validity checking
    if (srcId == m_scanInfo.id)
    {
        return false;
    }

    ItemScanInfo info = access.db()->getItemScanInfo(srcId);

    if (!info.id)
    {
        return false;
    }

    kDebug() << "Recognized" << m_fileInfo.filePath() << "as copied from" << srcId;
    access.db()->copyImageAttributes(srcId, m_scanInfo.id);
    return true;
}
예제 #6
0
void ScanController::run()
{
    while (d->running)
    {
        bool doInit = false, doScan = false, doPartialScan = false, doUpdateUniqueHash = false;
        QString task;
        {
            QMutexLocker lock(&d->mutex);

            if (d->needsInitialization)
            {
                d->needsInitialization = false;
                doInit                 = true;
            }
            else if (d->needsCompleteScan)
            {
                d->needsCompleteScan = false;
                doScan               = true;
            }
            else if (d->needsUpdateUniqueHash)
            {
                d->needsUpdateUniqueHash = false;
                doUpdateUniqueHash       = true;
            }
            else if (!d->scanTasks.isEmpty() && !d->scanSuspended)
            {
                doPartialScan = true;
                task          = d->scanTasks.takeFirst();
            }
            else
            {
                d->idle = true;
                d->condVar.wait(&d->mutex);
                d->idle = false;
            }
        }

        if (doInit)
        {
            d->continueInitialization = true;
            // pass "this" as InitializationObserver
            bool success = DatabaseAccess::checkReadyForUse(this);

            // If d->advice has not been adjusted to a value indicating failure, do this here
            if (!success && d->advice == Success)
            {
                d->advice = ContinueWithoutDatabase;
            }

            emit databaseInitialized(success);
        }
        else if (doScan)
        {
            CollectionScanner scanner;
            connectCollectionScanner(&scanner);
            scanner.setNeedFileCount(d->needTotalFiles);
            scanner.recordHints(d->albumHints);
            scanner.recordHints(d->itemHints);
            scanner.recordHints(d->itemChangeHints);
            SimpleCollectionScannerObserver observer(&d->continueScan);
            scanner.setObserver(&observer);
            scanner.completeScan();
            emit completeScanDone();
        }
        else if (doPartialScan)
        {
            CollectionScanner scanner;
            scanner.recordHints(d->albumHints);
            scanner.recordHints(d->itemHints);
            scanner.recordHints(d->itemChangeHints);
            //connectCollectionScanner(&scanner);
            SimpleCollectionScannerObserver observer(&d->continuePartialScan);
            scanner.setObserver(&observer);
            scanner.partialScan(task);
        }
        else if (doUpdateUniqueHash)
        {
            DatabaseAccess access;
            SchemaUpdater updater(access.db(), access.backend(), access.parameters());
            updater.setDatabaseAccess(&access);
            updater.setObserver(this);
            updater.updateUniqueHash();
            emit completeScanDone();
        }
    }
}
예제 #7
0
DatabaseTransaction::DatabaseTransaction()
    : m_access(0)
{
    DatabaseAccess access;
    access.backend()->beginTransaction();
}