allow indexing individual files. Fix pb with preview and charsets (local defcharset ignored)
This commit is contained in:
@@ -399,6 +399,8 @@ void Preview::loadFileInCurrentTab(string fn, size_t sz, const Rcl::Doc &idoc)
|
||||
|
||||
// Load and convert file
|
||||
Rcl::Doc fdoc;
|
||||
// Need to setup config to retrieve possibly local parameters
|
||||
rclconfig->setKeyDir(path_getfather(fn));
|
||||
int status = 1;
|
||||
LoadThread lthr(&status, &fdoc, fn, doc.ipath, &doc.mimetype);
|
||||
lthr.start();
|
||||
@@ -419,6 +421,8 @@ void Preview::loadFileInCurrentTab(string fn, size_t sz, const Rcl::Doc &idoc)
|
||||
doc.mimetype.c_str());
|
||||
return;
|
||||
}
|
||||
// Reset config just in case.
|
||||
rclconfig->setKeyDir("");
|
||||
|
||||
// Highlight search terms:
|
||||
progress.setLabelText(tr("Creating preview text"));
|
||||
|
||||
+47
-9
@@ -22,7 +22,7 @@
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>466</width>
|
||||
<width>362</width>
|
||||
<height>190</height>
|
||||
</size>
|
||||
</property>
|
||||
@@ -62,6 +62,9 @@
|
||||
<property name="accel">
|
||||
<string>Ctrl+S</string>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Erase search entry</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
@@ -73,6 +76,9 @@
|
||||
<property name="text">
|
||||
<string>Search</string>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Start query</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox">
|
||||
<property name="name">
|
||||
@@ -84,6 +90,12 @@
|
||||
<property name="accel">
|
||||
<string>Alt+A</string>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Do documents have to contain all terms in query?</string>
|
||||
</property>
|
||||
<property name="whatsThis" stdset="0">
|
||||
<string>If this is set, each returned document will contain all the terms in the query. Else documents will be ordered by relevance, but may not contain all the terms.</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit">
|
||||
<property name="name">
|
||||
@@ -109,6 +121,9 @@
|
||||
<property name="frameShadow">
|
||||
<enum>Sunken</enum>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Enter search terms here</string>
|
||||
</property>
|
||||
</widget>
|
||||
</hbox>
|
||||
</widget>
|
||||
@@ -181,6 +196,14 @@
|
||||
<action name="prevPageAction"/>
|
||||
<action name="nextPageAction"/>
|
||||
</toolbar>
|
||||
<toolbar dock="2">
|
||||
<property name="name">
|
||||
<cstring>HelpToolbar</cstring>
|
||||
</property>
|
||||
<property name="label">
|
||||
<string>Toolbar_2</string>
|
||||
</property>
|
||||
</toolbar>
|
||||
</toolbars>
|
||||
<actions>
|
||||
<action>
|
||||
@@ -224,10 +247,13 @@
|
||||
<iconset>history</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Doc History</string>
|
||||
<string>Document &History</string>
|
||||
</property>
|
||||
<property name="menuText">
|
||||
<string>Doc &History</string>
|
||||
<string>Document &History</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Document History</string>
|
||||
</property>
|
||||
</action>
|
||||
<action>
|
||||
@@ -241,7 +267,10 @@
|
||||
<string>Advanced Search</string>
|
||||
</property>
|
||||
<property name="menuText">
|
||||
<string>Advanced Search</string>
|
||||
<string>&Advanced Search</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Advanced/complex Search</string>
|
||||
</property>
|
||||
</action>
|
||||
<action>
|
||||
@@ -252,9 +281,12 @@
|
||||
<iconset>sortparms</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Sort parameters</string>
|
||||
<string>&Sort parameters</string>
|
||||
</property>
|
||||
<property name="menuText">
|
||||
<string>&Sort parameters</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Sort parameters</string>
|
||||
</property>
|
||||
</action>
|
||||
@@ -262,7 +294,7 @@
|
||||
<property name="name">
|
||||
<cstring>nextPageAction</cstring>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="iconSet">
|
||||
@@ -271,12 +303,15 @@
|
||||
<property name="text">
|
||||
<string>Next page</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Next page of results</string>
|
||||
</property>
|
||||
</action>
|
||||
<action>
|
||||
<property name="name">
|
||||
<cstring>prevPageAction</cstring>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="iconSet">
|
||||
@@ -285,6 +320,9 @@
|
||||
<property name="text">
|
||||
<string>Previous page</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Previous page of results</string>
|
||||
</property>
|
||||
</action>
|
||||
</actions>
|
||||
<connections>
|
||||
@@ -383,7 +421,6 @@
|
||||
</includes>
|
||||
<variables>
|
||||
<variable>int reslist_winfirst;</variable>
|
||||
<variable>int reslist_current;</variable>
|
||||
<variable>bool reslist_mouseDrag;</variable>
|
||||
<variable>bool reslist_mouseDown;</variable>
|
||||
<variable>int reslist_par;</variable>
|
||||
@@ -425,8 +462,9 @@
|
||||
<function access="private">init()</function>
|
||||
<function returnType="bool">close( bool )</function>
|
||||
<function access="private" returnType="bool">eventFilter( QObject * target, QEvent * event )</function>
|
||||
<function access="private">startPreview( int docnum )</function>
|
||||
<function access="private" returnType="int">reldocnumfromparnum( int parnum )</function>
|
||||
<function access="private">startPreview( int docnum )</function>
|
||||
<function access="private">startNativeViewer( int docnum )</function>
|
||||
</functions>
|
||||
<pixmapinproject/>
|
||||
<layoutdefaults spacing="6" margin="11"/>
|
||||
|
||||
+66
-56
@@ -54,7 +54,6 @@ static const int respagesize = 8;
|
||||
void RecollMain::init()
|
||||
{
|
||||
reslist_winfirst = -1;
|
||||
reslist_current = -1;
|
||||
reslist_mouseDrag = false;
|
||||
reslist_mouseDown = false;
|
||||
reslist_par = -1;
|
||||
@@ -73,6 +72,8 @@ void RecollMain::init()
|
||||
reslistTE->viewport()->installEventFilter(this);
|
||||
// reslistTE->viewport()->setFocusPolicy(QWidget::NoFocus);
|
||||
|
||||
// Set the focus to the search terms entry:
|
||||
queryText->setFocus();
|
||||
}
|
||||
|
||||
// We also want to get rid of the advanced search form and previews
|
||||
@@ -279,53 +280,10 @@ void RecollMain::reslistTE_doubleClicked(int par, int)
|
||||
{
|
||||
LOGDEB(("RecollMain::reslistTE_doubleClicked: par %d\n", par));
|
||||
reslist_dblclck = true;
|
||||
|
||||
Rcl::Doc doc;
|
||||
int reldocnum = reldocnumfromparnum(par);
|
||||
if (!docsource->getDoc(reslist_winfirst + reldocnum, doc, 0, 0))
|
||||
if (reldocnum < 0)
|
||||
return;
|
||||
|
||||
// Look for appropriate viewer
|
||||
string cmd = rclconfig->getMimeViewerDef(doc.mimetype);
|
||||
if (cmd.length() == 0) {
|
||||
QMessageBox::warning(0, "Recoll",
|
||||
tr("No external viewer configured for mime type ")
|
||||
+ doc.mimetype.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
string fn = urltolocalpath(doc.url);
|
||||
|
||||
// Substitute %u (url) and %f (file name) inside prototype command
|
||||
string ncmd;
|
||||
string::const_iterator it1;
|
||||
for (it1 = cmd.begin(); it1 != cmd.end();it1++) {
|
||||
if (*it1 == '%') {
|
||||
if (++it1 == cmd.end()) {
|
||||
ncmd += '%';
|
||||
break;
|
||||
}
|
||||
if (*it1 == '%')
|
||||
ncmd += '%';
|
||||
if (*it1 == 'u')
|
||||
ncmd += "'" + doc.url + "'";
|
||||
if (*it1 == 'f')
|
||||
ncmd += "'" + fn + "'";
|
||||
} else {
|
||||
ncmd += *it1;
|
||||
}
|
||||
}
|
||||
|
||||
ncmd += " &";
|
||||
QStatusBar *stb = statusBar();
|
||||
if (stb) {
|
||||
QString msg = tr("Executing: [") + ncmd.c_str() + "]";
|
||||
stb->message(msg, 5000);
|
||||
stb->repaint(false);
|
||||
XFlush(qt_xdisplay());
|
||||
}
|
||||
history->enterDocument(fn, doc.ipath);
|
||||
system(ncmd.c_str());
|
||||
startNativeViewer(reslist_winfirst + reldocnum);
|
||||
}
|
||||
|
||||
|
||||
@@ -337,7 +295,7 @@ void RecollMain::reslistTE_clicked(int par, int car)
|
||||
{
|
||||
if (reslist_waitingdbl)
|
||||
return;
|
||||
LOGDEB(("RecollMain::reslistTE_clckd:winfirst %d par %d char %d drg %d\n",
|
||||
LOGDEB(("RecollMain::reslistTE_clicked:wfirst %d par %d char %d drg %d\n",
|
||||
reslist_winfirst, par, car, reslist_mouseDrag));
|
||||
if (reslist_winfirst == -1 || reslist_mouseDrag)
|
||||
return;
|
||||
@@ -356,28 +314,32 @@ void RecollMain::reslistTE_clicked(int par, int car)
|
||||
// requested a native viewer by double-clicking
|
||||
void RecollMain::reslistTE_delayedclick()
|
||||
{
|
||||
LOGDEB(("RecollMain::reslistTE_delayedclick:\n"));
|
||||
reslist_waitingdbl = false;
|
||||
if (reslist_dblclck) {
|
||||
LOGDEB1(("RecollMain::reslistTE_delayedclick: dbleclick\n"));
|
||||
reslist_dblclck = false;
|
||||
return;
|
||||
}
|
||||
|
||||
int par = reslist_par;
|
||||
|
||||
// Erase everything back to white
|
||||
{
|
||||
QColor color("white");
|
||||
for (int i = 1; i < reslistTE->paragraphs(); i++)
|
||||
reslistTE->setParagraphBackgroundColor(i, color);
|
||||
}
|
||||
|
||||
// Color the new active paragraph
|
||||
QColor color("lightblue");
|
||||
reslistTE->setParagraphBackgroundColor(par, color);
|
||||
|
||||
// Document number
|
||||
int reldocnum = reldocnumfromparnum(par);
|
||||
if (curPreview && reslist_current == reldocnum)
|
||||
// Bad number or already displayed. Forget it
|
||||
if (reldocnum < 0)
|
||||
return;
|
||||
|
||||
reslist_current = reldocnum;
|
||||
startPreview(reslist_winfirst + reldocnum);
|
||||
}
|
||||
|
||||
@@ -412,7 +374,6 @@ void RecollMain::startAdvSearch(Rcl::AdvSearchData sdata)
|
||||
if (stemlang.empty())
|
||||
getQueryStemming(dostem, stemlang);
|
||||
|
||||
reslist_current = -1;
|
||||
reslist_winfirst = -1;
|
||||
|
||||
if (!rcldb->setQuery(sdata, dostem ?
|
||||
@@ -594,8 +555,6 @@ void RecollMain::showResultPage()
|
||||
pageParaToReldocnums[reslistTE->paragraphs()-1] = i;
|
||||
}
|
||||
|
||||
reslist_current = -1;
|
||||
|
||||
if (gotone) {
|
||||
reslistTE->append("</body></qt>");
|
||||
reslistTE->setCursorPosition(0,0);
|
||||
@@ -702,8 +661,7 @@ void RecollMain::startPreview(int docnum)
|
||||
string fn = urltolocalpath(doc.url);
|
||||
struct stat st;
|
||||
if (stat(fn.c_str(), &st) < 0) {
|
||||
QMessageBox::warning(0, "Recoll",
|
||||
tr("Cannot access document file: ") +
|
||||
QMessageBox::warning(0, "Recoll", tr("Cannot access document file: ") +
|
||||
fn.c_str());
|
||||
return;
|
||||
}
|
||||
@@ -733,6 +691,59 @@ void RecollMain::startPreview(int docnum)
|
||||
curPreview->loadFileInCurrentTab(fn, st.st_size, doc);
|
||||
}
|
||||
|
||||
void RecollMain::startNativeViewer(int docnum)
|
||||
{
|
||||
Rcl::Doc doc;
|
||||
if (!docsource->getDoc(docnum, doc, 0, 0)) {
|
||||
QMessageBox::warning(0, "Recoll",
|
||||
tr("Cannot retrieve document info"
|
||||
" from database"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Look for appropriate viewer
|
||||
string cmd = rclconfig->getMimeViewerDef(doc.mimetype);
|
||||
if (cmd.length() == 0) {
|
||||
QMessageBox::warning(0, "Recoll",
|
||||
tr("No external viewer configured for mime type ")
|
||||
+ doc.mimetype.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
string fn = urltolocalpath(doc.url);
|
||||
|
||||
// Substitute %u (url) and %f (file name) inside prototype command
|
||||
string ncmd;
|
||||
string::const_iterator it1;
|
||||
for (it1 = cmd.begin(); it1 != cmd.end();it1++) {
|
||||
if (*it1 == '%') {
|
||||
if (++it1 == cmd.end()) {
|
||||
ncmd += '%';
|
||||
break;
|
||||
}
|
||||
if (*it1 == '%')
|
||||
ncmd += '%';
|
||||
if (*it1 == 'u')
|
||||
ncmd += "'" + doc.url + "'";
|
||||
if (*it1 == 'f')
|
||||
ncmd += "'" + fn + "'";
|
||||
} else {
|
||||
ncmd += *it1;
|
||||
}
|
||||
}
|
||||
|
||||
ncmd += " &";
|
||||
QStatusBar *stb = statusBar();
|
||||
if (stb) {
|
||||
QString msg = tr("Executing: [") + ncmd.c_str() + "]";
|
||||
stb->message(msg, 5000);
|
||||
stb->repaint(false);
|
||||
XFlush(qt_xdisplay());
|
||||
}
|
||||
history->enterDocument(fn, doc.ipath);
|
||||
system(ncmd.c_str());
|
||||
}
|
||||
|
||||
|
||||
void RecollMain::showAboutDialog()
|
||||
{
|
||||
@@ -745,7 +756,6 @@ void RecollMain::showAboutDialog()
|
||||
void RecollMain::showDocHistory()
|
||||
{
|
||||
LOGDEB(("RecollMain::showDocHistory\n"));
|
||||
reslist_current = -1;
|
||||
reslist_winfirst = -1;
|
||||
curPreview = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user