tools/assistant/lib/qhelpcollectionhandler.cpp
changeset 30 5dc02b23752f
parent 18 2f34d5167611
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
   112         QSqlDatabase::removeDatabase(m_connectionName);
   112         QSqlDatabase::removeDatabase(m_connectionName);
   113         emit error(tr("Cannot open collection file: %1").arg(collectionFile()));
   113         emit error(tr("Cannot open collection file: %1").arg(collectionFile()));
   114         return false;
   114         return false;
   115     }
   115     }
   116 
   116 
       
   117     m_query.exec(QLatin1String("PRAGMA synchronous=OFF"));
       
   118     m_query.exec(QLatin1String("PRAGMA cache_size=3000"));
       
   119 
   117     m_query.exec(QLatin1String("SELECT COUNT(*) FROM sqlite_master WHERE TYPE=\'table\'"
   120     m_query.exec(QLatin1String("SELECT COUNT(*) FROM sqlite_master WHERE TYPE=\'table\'"
   118                                "AND Name=\'NamespaceTable\'"));
   121                                "AND Name=\'NamespaceTable\'"));
   119     m_query.next();
   122     m_query.next();
   120     if (m_query.value(0).toInt() < 1) {
   123     if (m_query.value(0).toInt() < 1) {
   121         if (!createTables(&m_query)) {
   124         if (!createTables(&m_query)) {
   160 
   163 
   161     if (!openingOk) {
   164     if (!openingOk) {
   162         emit error(tr("Cannot open collection file: %1").arg(colFile));
   165         emit error(tr("Cannot open collection file: %1").arg(colFile));
   163         return false;
   166         return false;
   164     }
   167     }
       
   168 
       
   169     copyQuery->exec(QLatin1String("PRAGMA synchronous=OFF"));
       
   170     copyQuery->exec(QLatin1String("PRAGMA cache_size=3000"));
   165 
   171 
   166     if (!createTables(copyQuery)) {
   172     if (!createTables(copyQuery)) {
   167         emit error(tr("Cannot copy collection file: %1").arg(colFile));
   173         emit error(tr("Cannot copy collection file: %1").arg(colFile));
   168         return false;
   174         return false;
   169     }
   175     }
   306 
   312 
   307     int nameId = -1;
   313     int nameId = -1;
   308     m_query.prepare(QLatin1String("SELECT Id FROM FilterNameTable WHERE Name=?"));
   314     m_query.prepare(QLatin1String("SELECT Id FROM FilterNameTable WHERE Name=?"));
   309     m_query.bindValue(0, filterName);
   315     m_query.bindValue(0, filterName);
   310     m_query.exec();
   316     m_query.exec();
   311     while (m_query.next()) {
   317     if (m_query.next())
   312         nameId = m_query.value(0).toInt();
   318         nameId = m_query.value(0).toInt();
   313         break;
       
   314     }
       
   315 
   319 
   316     m_query.exec(QLatin1String("SELECT Id, Name FROM FilterAttributeTable"));
   320     m_query.exec(QLatin1String("SELECT Id, Name FROM FilterAttributeTable"));
   317     QStringList idsToInsert = attributes;
   321     QStringList idsToInsert = attributes;
   318     QMap<QString, int> attributeMap;
   322     QMap<QString, int> attributeMap;
   319     while (m_query.next()) {
   323     while (m_query.next()) {
   582             emit error(tr("Cannot open database '%1' to optimize!").arg(fileName));
   586             emit error(tr("Cannot open database '%1' to optimize!").arg(fileName));
   583             return;
   587             return;
   584         }
   588         }
   585 
   589 
   586         QSqlQuery query(db);
   590         QSqlQuery query(db);
       
   591         db.exec(QLatin1String("PRAGMA synchronous=OFF"));
       
   592         db.exec(QLatin1String("PRAGMA cache_size=3000"));
   587         db.exec(QLatin1String("CREATE INDEX IF NOT EXISTS NameIndex ON IndexTable(Name)"));
   593         db.exec(QLatin1String("CREATE INDEX IF NOT EXISTS NameIndex ON IndexTable(Name)"));
   588         db.exec(QLatin1String("CREATE INDEX IF NOT EXISTS FileNameIndex ON FileNameTable(Name)"));
   594         db.exec(QLatin1String("CREATE INDEX IF NOT EXISTS FileNameIndex ON FileNameTable(Name)"));
   589         db.exec(QLatin1String("CREATE INDEX IF NOT EXISTS FileIdIndex ON FileNameTable(FileId)"));
   595         db.exec(QLatin1String("CREATE INDEX IF NOT EXISTS FileIdIndex ON FileNameTable(FileId)"));
   590 
   596 
   591         db.close();
   597         db.close();