Switch to unified view

a/src/qtgui/rclmain_w.cpp b/src/qtgui/rclmain_w.cpp
...
...
1190
    LOGDEB(("Old preview closed\n"));
1190
    LOGDEB(("Old preview closed\n"));
1191
    }
1191
    }
1192
    delete w;
1192
    delete w;
1193
}
1193
}
1194
1194
1195
// Document up to date check. The main problem we try to solve is
1196
// displaying the wrong message from a compacted mail folder.
1197
//
1198
// Also we should re-run the query after updating the index because
1199
// the ipaths may be wrong in the current result list. For now, the
1200
// user does this by clicking search again once the indexing is done
1201
//
1202
// We only do this for the main index, else jump and prey (cant update
1203
// anyway, even the makesig() call might not make sense for our base
1204
// config)
1205
bool RclMain::containerUpToDate(Rcl::Doc& doc)
1206
{
1207
    // If ipath is empty, we decide we don't care. Also, we need an index, 
1208
    if (doc.ipath.empty() || rcldb == 0)
1209
        return true;
1210
1211
    string udi;
1212
    doc.getmeta(Rcl::Doc::keyudi, &udi);
1213
    if (udi.empty()) {
1214
        // Whatever...
1215
        return true;
1216
    }
1217
1218
    string sig;
1219
    if (!FileInterner::makesig(theconfig, doc, sig)) {
1220
        QMessageBox::warning(0, "Recoll", tr("Can't access file: ") + 
1221
                             QString::fromLocal8Bit(doc.url.c_str()));
1222
        // Let's try the preview anyway...
1223
        return true;
1224
    }
1225
1226
    if (!rcldb->needUpdate(udi, sig)) {
1227
        // Alles ist in ordnung
1228
        return true;
1229
    }
1230
1231
    // We can only run indexing on the main index (dbidx 0)
1232
    bool ismainidx = rcldb->whatDbIdx(doc) == 0;
1233
    // Indexer already running?
1234
    bool ixnotact = (m_indexerState == IXST_NOTRUNNING);
1235
1236
    QString msg = tr("Index not up to date for this file. "
1237
                     "Refusing to risk showing the wrong entry. ");
1238
    if (ixnotact && ismainidx) {
1239
        msg += tr("Click Ok to update the "
1240
                  "index for this file, then you will need to "
1241
                  "re-run the query when indexing is done. ");
1242
    } else if (ismainidx) {
1243
        msg += tr("The indexer is running so things should "
1244
                  "improve when it's done. ");
1245
    } else if (ixnotact) {
1246
        // Not main index
1247
        msg += tr("The document belongs to an external index"
1248
                  "which I can't update. ");
1249
    }
1250
    msg += tr("Click Cancel to return to the list. "
1251
              "Click Ignore to show the preview anyway. ");
1252
1253
    QMessageBox::StandardButtons bts = 
1254
        QMessageBox::Ignore | QMessageBox::Cancel;
1255
1256
    if (ixnotact &&ismainidx)
1257
        bts |= QMessageBox::Ok;
1258
1259
    int rep = 
1260
        QMessageBox::warning(0, tr("Warning"), msg, bts,
1261
                             (ixnotact && ismainidx) ? 
1262
                             QMessageBox::Cancel : QMessageBox::NoButton);
1263
1264
    if (m_indexerState == IXST_NOTRUNNING && rep == QMessageBox::Ok) {
1265
        LOGDEB(("Requesting index update for %s\n", doc.url.c_str()));
1266
        vector<Rcl::Doc> docs(1, doc);
1267
        updateIdxForDocs(docs);
1268
    }
1269
    if (rep != QMessageBox::Ignore)
1270
        return false;
1271
    return true;
1272
}
1273
1195
/** 
1274
/** 
1196
 * Open a preview window for a given document, or load it into new tab of 
1275
 * Open a preview window for a given document, or load it into new tab of 
1197
 * existing window.
1276
 * existing window.
1198
 *
1277
 *
1199
 * @param docnum db query index
1278
 * @param docnum db query index
...
...
1201
 */
1280
 */
1202
void RclMain::startPreview(int docnum, Rcl::Doc doc, int mod)
1281
void RclMain::startPreview(int docnum, Rcl::Doc doc, int mod)
1203
{
1282
{
1204
    LOGDEB(("startPreview(%d, doc, %d)\n", docnum, mod));
1283
    LOGDEB(("startPreview(%d, doc, %d)\n", docnum, mod));
1205
1284
1206
    // Document up to date check. We do this only if ipath is not
1285
    if (!containerUpToDate(doc))
1207
    // empty as this does not appear to be a serious issue for single
1208
    // docs (the main actual problem is displaying the wrong message
1209
    // from a compacted mail folder)
1210
    //
1211
    // !! NOTE: there is one case where doing a partial index update
1212
    // will not work: if the search result does not exist in the new
1213
    // version of the file, it won't be purged from the index because
1214
    // a partial index pass does no purge, so its ref date will stay
1215
    // the same and you keep getting the message about the index being
1216
    // out of date. The only way to fix this is to run a normal
1217
    // indexing pass (common case: the mbox was shortened and the
1218
    // result msgnum is beyond the new end)
1219
    // Also we should re-run the query after updating the index
1220
    // because the ipaths may be wrong in the current result list We
1221
    // only do this for the main index, else jump and prey (cant
1222
    // update anyway, even the makesig() call might not make sense for
1223
    // our base config)
1224
    if (!doc.ipath.empty() && rcldb && rcldb->whatDbIdx(doc) == 0) {
1225
  string udi;
1226
  doc.getmeta(Rcl::Doc::keyudi, &udi);
1227
  if (!udi.empty()) {
1228
      string sig;
1229
      if (!FileInterner::makesig(theconfig, doc, sig)) {
1230
      QMessageBox::warning(0, "Recoll", 
1231
                   tr("Can't access file: ") + 
1232
                   QString::fromLocal8Bit(doc.url.c_str()));
1233
      return;
1234
      }
1235
      if (rcldb->needUpdate(udi, sig)) {
1236
      QString msg = 
1237
          tr("Index not up to date for this file. "
1238
             "Refusing to risk showing the wrong entry. ");
1239
      bool ixnotact = (m_indexerState == IXST_NOTRUNNING);
1240
      if (ixnotact) {
1241
          msg += tr("Click Ok to update the "
1242
                "index for this file, then you will need to "
1243
                "re-run the query when indexing is done. ");
1244
      } else {
1245
          msg += tr("The indexer is running so things should "
1246
                "improve when it's done. ");
1247
      } 
1248
      msg += tr("Click Cancel to return to the list. "
1249
            "Click Ignore to show the preview anyway. ");
1250
      QMessageBox::StandardButtons bts = 
1251
          QMessageBox::Ignore | QMessageBox::Cancel;
1252
      if (ixnotact)
1253
          bts |= QMessageBox::Ok;
1254
      int rep = 
1255
          QMessageBox::warning(0, tr("Warning"), 
1256
                   msg, bts,
1257
                   ixnotact? QMessageBox::Cancel : 
1258
                   QMessageBox::NoButton);
1259
      if (m_indexerState == IXST_NOTRUNNING && 
1260
          rep == QMessageBox::Ok) {
1261
          LOGDEB(("Requesting index update for %s\n", 
1262
              doc.url.c_str()));
1263
          vector<Rcl::Doc> docs(1, doc);
1264
          updateIdxForDocs(docs);
1265
      }
1266
      if (rep != QMessageBox::Ignore)
1267
          return;
1286
        return;
1268
      }
1287
1269
  }
1270
    }
1271
    // Do the zeitgeist thing
1288
    // Do the zeitgeist thing
1272
    zg_send_event(ZGSEND_PREVIEW, doc);
1289
    zg_send_event(ZGSEND_PREVIEW, doc);
1273
1290
1274
    if (mod & Qt::ShiftModifier) {
1291
    if (mod & Qt::ShiftModifier) {
1275
    // User wants new preview window
1292
    // User wants new preview window
...
...
1320
    vector<string> paths;
1337
    vector<string> paths;
1321
    if (ConfIndexer::docsToPaths(docs, paths)) {
1338
    if (ConfIndexer::docsToPaths(docs, paths)) {
1322
    vector<string> args;
1339
    vector<string> args;
1323
    args.push_back("-c");
1340
    args.push_back("-c");
1324
    args.push_back(theconfig->getConfDir());
1341
    args.push_back(theconfig->getConfDir());
1342
  args.push_back("-e");
1325
    args.push_back("-i");
1343
    args.push_back("-i");
1326
    args.insert(args.end(), paths.begin(), paths.end());
1344
    args.insert(args.end(), paths.begin(), paths.end());
1327
    m_idxproc = new ExecCmd;
1345
    m_idxproc = new ExecCmd;
1328
    m_idxproc->startExec("recollindex", args, false, false);
1346
    m_idxproc->startExec("recollindex", args, false, false);
1329
    fileToggleIndexingAction->setText(tr("Stop &Indexing"));
1347
    fileToggleIndexingAction->setText(tr("Stop &Indexing"));