Ejemplo n.º 1
0
void ResTable::addColumn()
{
    if (!m_model)
	return;
    QAction *action = (QAction *)sender();
    LOGDEB(("addColumn: text %s, data %s\n", qs2utf8s(action->text()).c_str(), 
	    qs2utf8s(action->data().toString()).c_str()));
    m_model->addColumn(m_popcolumn, qs2utf8s(action->data().toString()));
}
Ejemplo n.º 2
0
void ResTable::menuOpenWith(QAction *act)
{
    if (act == 0)
        return;
    string cmd = qs2utf8s(act->data().toString());
    if (m_detaildocnum >= 0) 
	emit openWithRequested(m_detaildoc, cmd);
}
Ejemplo n.º 3
0
void DirBrowser::serverSearch()
{
    QString text = ui->searchCMB->lineEdit()->text();
    int i = ui->propsCMB->currentIndex();
    string prop = qs2utf8s(ui->propsCMB->itemData(i).toString());
    if (text != "") {
        string iss = qs2utf8s(text);
        string ss(prop);
        ss += " contains \"";
        for (unsigned i = 0; i < iss.size(); i++) {
            if (iss[i] == '"' || iss[i] == '\\')
                ss += string("\\");
            ss += iss[i];
        }
        ss += '"';
        CDBrowser *cdb = currentBrowser();
        if (cdb)
            cdb->search(ss);
    }
}
Ejemplo n.º 4
0
string PrefsPack::stemlang()
{
    string stemLang(qs2utf8s(prefs.queryStemLang));
    if (stemLang == "ALL") {
	if (theconfig)
	    theconfig->getConfParam("indexstemminglanguages", stemLang);
	else
	    stemLang = "";
    }
    return stemLang;
}
Ejemplo n.º 5
0
void ResTable::linkWasClicked(const QUrl &url)
{
    if (m_detaildocnum < 0) {
	return;
    }
    QString s = url.toString();
    const char *ascurl = s.toUtf8();
    LOGDEB(("ResTable::linkWasClicked: [%s]\n", ascurl));

    int i = atoi(ascurl+1) -1;
    int what = ascurl[0];
    switch (what) {
    // Open abstract/snippets window
    case 'A':
	if (m_detaildocnum >= 0)
	    emit(showSnippets(m_detaildoc));
	break;
    case 'D':
	{
	    vector<Rcl::Doc> dups;
	    if (m_detaildocnum >= 0 && m_rclmain && 
		m_model->getDocSource()->docDups(m_detaildoc, dups)) {
		m_rclmain->newDupsW(m_detaildoc, dups);
	    }
	}
    // Open parent folder
    case 'F':
    {
        emit editRequested(ResultPopup::getParent(RefCntr<DocSequence>(),
                                                  m_detaildoc));
    }
    break;

    case 'P': 
    case 'E': 
    {
	if (what == 'P')
	    emit docPreviewClicked(i, m_detaildoc, 0);
	else
	    emit editRequested(m_detaildoc);
    }
    break;

	// Run script. Link format Rnn|Script Name
    case 'R':
    {
	int bar = s.indexOf("|");
	if (bar == -1 || bar >= s.size()-1)
            break;
        string cmdname = qs2utf8s(s.right(s.size() - (bar + 1)));
        DesktopDb ddb(path_cat(theconfig->getConfDir(), "scripts"));
        DesktopDb::AppDef app;
        if (ddb.appByName(cmdname, app)) {
            QAction act(QString::fromUtf8(app.name.c_str()), this);
            QVariant v(QString::fromUtf8(app.command.c_str()));
            act.setData(v);
            menuOpenWith(&act);
        }
    }
    break;

    default: 
	LOGERR(("ResTable::linkWasClicked: bad link [%s]\n", ascurl));
	break;// ?? 
    }
}
Ejemplo n.º 6
0
    virtual string startMatch(unsigned int) 
    {
	return string("<span style='color: ")
	    + qs2utf8s(prefs.qtermcolor) + string("'>");
    }
Ejemplo n.º 7
0
void DirBrowser::onSortprefs()
{
    static map<string, string>  allSortCrits;
    static map<string, string>  allSortCritsRev;
    if (allSortCrits.empty()) {
        allSortCrits["Track Number"] = "upnp:originalTrackNumber";
        allSortCrits["Track Title"] = "dc:title";
        allSortCrits["Date"] = "dc:date";
        allSortCrits["Artist"] = "upnp:artist";
        allSortCrits["Album Title"] = "upnp:album";
        allSortCrits["URI"] = "uri";

        for (map<string, string>::iterator it = allSortCrits.begin(); 
             it != allSortCrits.end(); it++) {
            allSortCritsRev[it->second] = it->first;
        }
    }

    QStringList qcrits = CSettingsStorage::getInstance()->getSortCrits();
    vector<string> crits;
    if (qcrits.size() == 0) {
        qcrits.push_back("upnp:artist");
        qcrits.push_back("upnp:album");
        qcrits.push_back("upnp:originalTrackNumber");
        qcrits.push_back("dc:title");
        qcrits.push_back("dc:date");
        qcrits.push_back("uri");
    }

    for (int i = 0; i < qcrits.size(); i++) {
        string nm = allSortCritsRev[qs2utf8s(qcrits[i])];
        if (nm == "") {
            // Bummer. Limp along and hope for the best
            nm = qs2utf8s(qcrits[i]);
        }
        crits.push_back(nm);
    }

    int sortkind = CSettingsStorage::getInstance()->getSortKind();
    SortprefsDLG dlg(crits);
    switch (sortkind) {
    case CSettingsStorage::SK_NOSORT:
    default:
        dlg.noSortRB->setChecked(true);
        break;
    case CSettingsStorage::SK_MINIMFNORDER:
        dlg.minimfnRB->setChecked(true);
        break;
    case CSettingsStorage::SK_CUSTOM:
        dlg.sortRB->setChecked(true);
        break;
    }
        
    if (dlg.exec()) {
        sortkind = CSettingsStorage::SK_NOSORT;
        if (dlg.minimfnRB->isChecked()) {
            sortkind = CSettingsStorage::SK_MINIMFNORDER;
        } else if (dlg.sortRB->isChecked()) {
            sortkind = CSettingsStorage::SK_CUSTOM;
        }
        CSettingsStorage::getInstance()->setSortKind(sortkind);
        qcrits.clear();
        for (int i = 0; i < dlg.critsLW->count(); i++) {
            QString val = 
                dlg.critsLW->item(i)->data(Qt::DisplayRole).toString();
            //qDebug() << "Sort nm: " << val;
            val = u8s2qs(allSortCrits[qs2utf8s(val)]);
            if (val != "") {
                qcrits += val;
                //qDebug() << "Sort crit: " << val;
            }
        }
        CSettingsStorage::getInstance()->setSortCrits(qcrits);
        currentBrowser()->refresh();
    }        
}
Ejemplo n.º 8
0
void rwSettings(bool writing)
{
    LOGDEB1(("rwSettings: write %d\n", int(writing)));
    if (writing && !havereadsettings)
        return;
    QSettings settings("Recoll.org", "recoll");
    SETTING_RW(prefs.mainwidth, "/Recoll/geometry/width", Int, 0);
    SETTING_RW(prefs.mainheight, "/Recoll/geometry/height", Int, 0);
    SETTING_RW(prefs.pvwidth, "/Recoll/geometry/pvwidth", Int, 0);
    SETTING_RW(prefs.pvheight, "/Recoll/geometry/pvheight", Int, 0);
    SETTING_RW(prefs.toolArea, "/Recoll/geometry/toolArea", Int, 0);
    SETTING_RW(prefs.resArea, "/Recoll/geometry/resArea", Int, 0);
    SETTING_RW(prefs.ssearchTyp, "/Recoll/prefs/simpleSearchTyp", Int, 3);
    SETTING_RW(prefs.startWithAdvSearchOpen, 
	       "/Recoll/prefs/startWithAdvSearchOpen", Bool, false);
    SETTING_RW(prefs.previewHtml, 
	       "/Recoll/prefs/previewHtml", Bool, true);

    QString advSearchClauses;
    QString ascdflt;
    if (writing) {
	for (vector<int>::iterator it = prefs.advSearchClauses.begin();
	     it != prefs.advSearchClauses.end(); it++) {
	    char buf[20];
	    sprintf(buf, "%d ", *it);
	    advSearchClauses += QString::fromUtf8(buf);
	}
    }
    SETTING_RW(advSearchClauses, "/Recoll/prefs/adv/clauseList", String, ascdflt);
    if (!writing) {
	list<string> clauses;
	stringToStrings((const char *)advSearchClauses.toUtf8(), clauses);
	for (list<string>::iterator it = clauses.begin(); 
	     it != clauses.end(); it++) {
	    prefs.advSearchClauses.push_back(atoi(it->c_str()));
	}
    }

    SETTING_RW(prefs.ssearchOnWS, "/Recoll/prefs/reslist/autoSearchOnWS", 
	       Bool, false);
    SETTING_RW(prefs.ssearchNoComplete, 
	       "/Recoll/prefs/ssearch/noComplete", Bool, false);
    SETTING_RW(prefs.ssearchAsYouType, 
	       "/Recoll/prefs/ssearch/asYouType", Bool, false);
    SETTING_RW(prefs.filterCtlStyle, "/Recoll/prefs/filterCtlStyle", Int, 0);
    SETTING_RW(prefs.ssearchAutoPhrase, 
	       "/Recoll/prefs/ssearchAutoPhrase", Bool, true);
    SETTING_RW(prefs.ssearchAutoPhraseThreshPC, 
	       "/Recoll/prefs/ssearchAutoPhraseThreshPC", Double, 2.0);
    SETTING_RW(prefs.respagesize, "/Recoll/prefs/reslist/pagelen", Int, 8);
    SETTING_RW(prefs.collapseDuplicates, 
	       "/Recoll/prefs/reslist/collapseDuplicates", Bool, false);
    SETTING_RW(prefs.showResultsAsTable, 
	       "/Recoll/prefs/showResultsAsTable", Bool, false);
    SETTING_RW(prefs.maxhltextmbs, "/Recoll/prefs/preview/maxhltextmbs", Int, 3);

    SETTING_RW(prefs.previewPlainPre, 
	       "/Recoll/prefs/preview/plainPre", Int, PrefsPack::PP_PREWRAP);
    SETTING_RW(prefs.qtermcolor, "/Recoll/prefs/qtermcolor", String, "blue");
    if (!writing && prefs.qtermcolor == "")
	prefs.qtermcolor = "blue";

    // Abstract snippet separator
    SETTING_RW(prefs.abssep, "/Recoll/prefs/reslist/abssep", String,"&hellip;");
    if (!writing && prefs.abssep == "")
	prefs.abssep = "&hellip;";
    SETTING_RW(prefs.reslistdateformat, "/Recoll/prefs/reslist/dateformat", 
	       String,"&nbsp;%Y-%m-%d&nbsp;%H:%M:%S&nbsp;%z");
    if (!writing && prefs.reslistdateformat == "")
	prefs.reslistdateformat = "&nbsp;%Y-%m-%d&nbsp;%H:%M:%S&nbsp;%z";
    prefs.creslistdateformat = (const char*)prefs.reslistdateformat.toUtf8();

    SETTING_RW(prefs.reslistfontfamily, "/Recoll/prefs/reslist/fontFamily", 
	       String, "");
    SETTING_RW(prefs.reslistfontsize, "/Recoll/prefs/reslist/fontSize", Int, 
	       10);

    QString rlfDflt = QString::fromUtf8(prefs.dfltResListFormat);
    if (writing) {
	if (prefs.reslistformat.compare(rlfDflt)) {
	    settings.setValue("/Recoll/prefs/reslist/format", 
			      prefs.reslistformat);
	} else {
	    settings.remove("/Recoll/prefs/reslist/format");
	}
    } else {
	prefs.reslistformat = 
	    settings.value("/Recoll/prefs/reslist/format", rlfDflt).toString();
	prefs.creslistformat = qs2utf8s(prefs.reslistformat);
    }

    SETTING_RW(prefs.reslistheadertext, "/Recoll/prefs/reslist/headertext", 
	       String, "");
    SETTING_RW(prefs.qssFile, "/Recoll/prefs/stylesheet", String, "");
    SETTING_RW(prefs.snipCssFile, "/Recoll/prefs/snippets/cssfile", String, "");
    SETTING_RW(prefs.queryStemLang, "/Recoll/prefs/query/stemLang", String,
	       "english");
    SETTING_RW(prefs.useDesktopOpen, "/Recoll/prefs/useDesktopOpen", 
	       Bool, true);

    SETTING_RW(prefs.keepSort, 
	       "/Recoll/prefs/keepSort", Bool, false);
    SETTING_RW(prefs.sortField, "/Recoll/prefs/sortField", String, "");
    SETTING_RW(prefs.sortActive, 
	       "/Recoll/prefs/sortActive", Bool, false);
    SETTING_RW(prefs.sortDesc, 
	       "/Recoll/prefs/query/sortDesc", Bool, 0);
    if (!writing) {
	// Handle transition from older prefs which did not store sortColumn
	// (Active always meant sort by date).
	if (prefs.sortActive && prefs.sortField.isNull())
	    prefs.sortField = "mtime";
    }

    SETTING_RW(prefs.queryBuildAbstract, 
	       "/Recoll/prefs/query/buildAbstract", Bool, true);
    SETTING_RW(prefs.queryReplaceAbstract, 
	       "/Recoll/prefs/query/replaceAbstract", Bool, false);
    SETTING_RW(prefs.syntAbsLen, "/Recoll/prefs/query/syntAbsLen", 
	       Int, 250);
    SETTING_RW(prefs.syntAbsCtx, "/Recoll/prefs/query/syntAbsCtx", 
	       Int, 4);
    SETTING_RW(prefs.autoSuffs, "/Recoll/prefs/query/autoSuffs", String, "");
    SETTING_RW(prefs.autoSuffsEnable, 
	       "/Recoll/prefs/query/autoSuffsEnable", Bool, false);

    SETTING_RW(prefs.termMatchType, "/Recoll/prefs/query/termMatchType", 
	       Int, 0);
    // This is not really the current program version, just a value to
    // be used in case we have incompatible changes one day
    SETTING_RW(prefs.rclVersion, "/Recoll/prefs/rclVersion", Int, 1009);

    // Ssearch combobox history list
    if (writing) {
	settings.setValue("/Recoll/prefs/query/ssearchHistory",
			    prefs.ssearchHistory);
    } else {
	prefs.ssearchHistory = 
	    settings.value("/Recoll/prefs/query/ssearchHistory").toStringList();
    }

    // Ignored file types (advanced search)
    if (writing) {
	settings.setValue("/Recoll/prefs/query/asearchIgnFilTyps",
			    prefs.asearchIgnFilTyps);
    } else {
	prefs.asearchIgnFilTyps = 
	    settings.value("/Recoll/prefs/query/asearchIgnFilTyps").toStringList();
    }


    // Field list for the restable
    if (writing) {
	settings.setValue("/Recoll/prefs/query/restableFields",
			    prefs.restableFields);
    } else {
	prefs.restableFields = 
	    settings.value("/Recoll/prefs/query/restableFields").toStringList();
	if (prefs.restableFields.empty()) {
	    prefs.restableFields.push_back("date");
	    prefs.restableFields.push_back("title");
	    prefs.restableFields.push_back("filename");
	    prefs.restableFields.push_back("author");
	    prefs.restableFields.push_back("url");
	}
    }

    // restable col widths
    QString rtcw;
    if (writing) {
	for (vector<int>::iterator it = prefs.restableColWidths.begin();
	     it != prefs.restableColWidths.end(); it++) {
	    char buf[20];
	    sprintf(buf, "%d ", *it);
	    rtcw += QString::fromUtf8(buf);
	}
    }
    SETTING_RW(rtcw, "/Recoll/prefs/query/restableWidths", String, 
	       "83 253 132 172 130 ");
    if (!writing) {
	vector<string> widths;
	stringToStrings((const char *)rtcw.toUtf8(), widths);
	for (vector<string>::iterator it = widths.begin(); 
	     it != widths.end(); it++) {
	    prefs.restableColWidths.push_back(atoi(it->c_str()));
	}
    }

    SETTING_RW(prefs.fileTypesByCats, "/Recoll/prefs/query/asearchFilTypByCat",
	       Bool, false);
    SETTING_RW(prefs.showTrayIcon, "/Recoll/prefs/showTrayIcon", Bool, false);
    SETTING_RW(prefs.closeToTray, "/Recoll/prefs/closeToTray", Bool, false);

    if (g_dynconf == 0) {
        // Happens
        return;
    }
    // The extra databases settings. These are stored as a list of
    // xapian directory names, encoded in base64 to avoid any
    // binary/charset conversion issues. There are 2 lists for all
    // known dbs and active (searched) ones.
    // When starting up, we also add from the RECOLL_EXTRA_DBS environment
    // variable.
    // This are stored inside the dynamic configuration file (aka: history), 
    // as they are likely to depend on RECOLL_CONFDIR.
    if (writing) {
	g_dynconf->eraseAll(allEdbsSk);
	for (list<string>::const_iterator it = prefs.allExtraDbs.begin();
	     it != prefs.allExtraDbs.end(); it++) {
	    g_dynconf->enterString(allEdbsSk, *it);
	}

	g_dynconf->eraseAll(actEdbsSk);
	for (list<string>::const_iterator it = prefs.activeExtraDbs.begin();
	     it != prefs.activeExtraDbs.end(); it++) {
	    g_dynconf->enterString(actEdbsSk, *it);

	}
    } else {
	prefs.allExtraDbs = g_dynconf->getStringList(allEdbsSk);
	const char *cp;
	if ((cp = getenv("RECOLL_EXTRA_DBS")) != 0) {
	    vector<string> dbl;
	    stringToTokens(cp, dbl, ":");
	    for (vector<string>::iterator dit = dbl.begin(); dit != dbl.end();
		 dit++) {
		string dbdir = path_canon(*dit);
		path_catslash(dbdir);
		if (std::find(prefs.allExtraDbs.begin(), 
			      prefs.allExtraDbs.end(), dbdir) != 
		    prefs.allExtraDbs.end())
		    continue;
		bool stripped;
		if (!Rcl::Db::testDbDir(dbdir, &stripped)) {
		    LOGERR(("Not a xapian index: [%s]\n", dbdir.c_str()));
		    continue;
		}
		if (stripped != o_index_stripchars) {
		    LOGERR(("Incompatible character stripping: [%s]\n",
			    dbdir.c_str()));
		    continue;
		}
		prefs.allExtraDbs.push_back(dbdir);
	    }
	}

        // Get the remembered "active external indexes":
        prefs.activeExtraDbs = g_dynconf->getStringList(actEdbsSk);

	// Clean up the list: remove directories which are not
	// actually there: useful for removable volumes.
	for (list<string>::iterator it = prefs.activeExtraDbs.begin();
	     it != prefs.activeExtraDbs.end();) {
	    bool stripped;
	    if (!Rcl::Db::testDbDir(*it, &stripped) || 
		stripped != o_index_stripchars) {
		LOGINFO(("Not a Xapian index or char stripping differs: [%s]\n",
			 it->c_str()));
		it = prefs.activeExtraDbs.erase(it);
	    } else {
		it++;
	    }
	}

	// Get active db directives from the environment. This can only add to
	// the remembered and cleaned up list
        const char *cp4Act;
        if ((cp4Act = getenv("RECOLL_ACTIVE_EXTRA_DBS")) != 0) {
            vector<string> dbl;
            stringToTokens(cp4Act, dbl, ":");
            for (vector<string>::iterator dit = dbl.begin(); dit != dbl.end();
                 dit++) {
                string dbdir = path_canon(*dit);
                path_catslash(dbdir);
                if (std::find(prefs.activeExtraDbs.begin(),
                              prefs.activeExtraDbs.end(), dbdir) !=
                    prefs.activeExtraDbs.end())
                    continue;
		bool strpd;
                if (!Rcl::Db::testDbDir(dbdir, &strpd) || 
		    strpd != o_index_stripchars) {
                    LOGERR(("Not a Xapian dir or diff. char stripping: [%s]\n",
			    dbdir.c_str()));
                    continue;
                }
                prefs.activeExtraDbs.push_back(dbdir);
            } //for
        } //if
    }

#if 0
    {
	list<string>::const_iterator it;
	fprintf(stderr, "All extra Dbs:\n");
	for (it = prefs.allExtraDbs.begin(); 
	     it != prefs.allExtraDbs.end(); it++) {
	    fprintf(stderr, "    [%s]\n", it->c_str());
	}
	fprintf(stderr, "Active extra Dbs:\n");
	for (it = prefs.activeExtraDbs.begin(); 
	     it != prefs.activeExtraDbs.end(); it++) {
	    fprintf(stderr, "    [%s]\n", it->c_str());
	}
    }
#endif


    const string asbdSk = "asearchSbd";
    if (writing) {
	while (prefs.asearchSubdirHist.size() > 20)
	    prefs.asearchSubdirHist.pop_back();
	g_dynconf->eraseAll(asbdSk);
	for (QStringList::iterator it = prefs.asearchSubdirHist.begin();
	     it != prefs.asearchSubdirHist.end(); it++) {
	    g_dynconf->enterString(asbdSk, (const char *)((*it).toUtf8()));
	}
    } else {
	list<string> tl = g_dynconf->getStringList(asbdSk);
	for (list<string>::iterator it = tl.begin(); it != tl.end(); it++)
	    prefs.asearchSubdirHist.push_front(QString::fromUtf8(it->c_str()));
    }
    if (!writing)
        havereadsettings = true;
}