menu entry to reset document history

This commit is contained in:
dockes 2007-06-20 13:16:11 +00:00
parent 66b4dd7ff5
commit 9d42648511
6 changed files with 56 additions and 16 deletions

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: preview_w.cpp,v 1.21 2007-06-19 08:36:24 dockes Exp $ (C) 2005 J.F.Dockes"; static char rcsid[] = "@(#$Id: preview_w.cpp,v 1.22 2007-06-20 13:15:57 dockes Exp $ (C) 2005 J.F.Dockes";
#endif #endif
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -772,6 +772,9 @@ bool Preview::loadFileInCurrentTab(string fn, size_t sz, const Rcl::Doc &idoc,
canBeep = ocanbeep; canBeep = ocanbeep;
#endif #endif
} }
// Enter document in document history
g_dynconf->enterDoc(fn, doc.ipath);
editor->setFocus(); editor->setFocus();
emit(previewExposed(m_searchId, docnum)); emit(previewExposed(m_searchId, docnum));
return true; return true;

View File

@ -78,6 +78,8 @@
<item text="&amp;File" name="fileMenu"> <item text="&amp;File" name="fileMenu">
<action name="fileStart_IndexingAction"/> <action name="fileStart_IndexingAction"/>
<separator/> <separator/>
<action name="fileEraseDocHistoryAction"/>
<separator/>
<action name="fileExitAction"/> <action name="fileExitAction"/>
</item> </item>
<item text="&amp;Tools" name="Tools"> <item text="&amp;Tools" name="Tools">
@ -174,6 +176,14 @@
<string>Update &amp;index</string> <string>Update &amp;index</string>
</property> </property>
</action> </action>
<action>
<property name="name">
<cstring>fileEraseDocHistoryAction</cstring>
</property>
<property name="menuText">
<string>&amp;Erase document history</string>
</property>
</action>
<action> <action>
<property name="name"> <property name="name">
<cstring>helpAbout_RecollAction</cstring> <cstring>helpAbout_RecollAction</cstring>

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.30 2007-06-19 16:19:24 dockes Exp $ (C) 2005 J.F.Dockes"; static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.31 2007-06-20 13:15:58 dockes Exp $ (C) 2005 J.F.Dockes";
#endif #endif
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -139,6 +139,8 @@ void RclMain::init()
connect(fileExitAction, SIGNAL(activated() ), this, SLOT(fileExit() ) ); connect(fileExitAction, SIGNAL(activated() ), this, SLOT(fileExit() ) );
connect(fileStart_IndexingAction, SIGNAL(activated()), connect(fileStart_IndexingAction, SIGNAL(activated()),
this, SLOT(startIndexing())); this, SLOT(startIndexing()));
connect(fileEraseDocHistoryAction, SIGNAL(activated()),
this, SLOT(eraseDocHistory()));
connect(helpAbout_RecollAction, SIGNAL(activated()), connect(helpAbout_RecollAction, SIGNAL(activated()),
this, SLOT(showAboutDialog())); this, SLOT(showAboutDialog()));
connect(userManualAction, SIGNAL(activated()), this, SLOT(startManual())); connect(userManualAction, SIGNAL(activated()), this, SLOT(startManual()));
@ -485,8 +487,6 @@ void RclMain::startPreview(int docnum, int mod)
} }
(void)curPreview->addEditorTab(); (void)curPreview->addEditorTab();
} }
// Enter document in document history
g_dynconf->enterDoc(fn, doc.ipath);
if (!curPreview->loadFileInCurrentTab(fn, st.st_size, doc, docnum)) if (!curPreview->loadFileInCurrentTab(fn, st.st_size, doc, docnum))
curPreview->closeCurrentTab(); curPreview->closeCurrentTab();
} }
@ -519,7 +519,6 @@ void RclMain::startPreview(Rcl::Doc doc)
preview->setSId(0, HiliteData()); preview->setSId(0, HiliteData());
connect(preview, SIGNAL(wordSelect(QString)), connect(preview, SIGNAL(wordSelect(QString)),
this, SLOT(ssearchAddTerm(QString))); this, SLOT(ssearchAddTerm(QString)));
g_dynconf->enterDoc(fn, doc.ipath);
preview->show(); preview->show();
if (!preview->loadFileInCurrentTab(fn, st.st_size, doc, 0)) if (!preview->loadFileInCurrentTab(fn, st.st_size, doc, 0))
preview->closeCurrentTab(); preview->closeCurrentTab();
@ -821,6 +820,7 @@ void RclMain::showDocHistory()
m_searchId++; m_searchId++;
// If you change the title, also change it in eraseDocHistory()
DocSequenceHistory *src = DocSequenceHistory *src =
new DocSequenceHistory(rcldb, g_dynconf, new DocSequenceHistory(rcldb, g_dynconf,
string(tr("Document history").utf8())); string(tr("Document history").utf8()));
@ -829,6 +829,16 @@ void RclMain::showDocHistory()
setDocSequence(); setDocSequence();
} }
void RclMain::eraseDocHistory()
{
g_dynconf->eraseAll(RclHistory::docSubkey);
// We want to reset the displayed history if it is currently shown. Using
// the title value is an ugly hack
if (m_docSource->title() ==
string((const char *)tr("Document history").utf8())) {
showDocHistory();
}
}
void RclMain::sortDataChanged(DocSeqSortSpec spec) void RclMain::sortDataChanged(DocSeqSortSpec spec)
{ {

View File

@ -96,6 +96,7 @@ public slots:
virtual void previewPrevInTab(int sid, int docnum); virtual void previewPrevInTab(int sid, int docnum);
virtual void previewExposed(int sid, int docnum); virtual void previewExposed(int sid, int docnum);
virtual void resetSearch(); virtual void resetSearch();
virtual void eraseDocHistory();
protected: protected:
virtual void closeEvent( QCloseEvent * ); virtual void closeEvent( QCloseEvent * );

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: history.cpp,v 1.7 2006-09-11 12:05:39 dockes Exp $ (C) 2005 J.F.Dockes"; static char rcsid[] = "@(#$Id: history.cpp,v 1.8 2007-06-20 13:16:11 dockes Exp $ (C) 2005 J.F.Dockes";
#endif #endif
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -31,7 +31,6 @@ static char rcsid[] = "@(#$Id: history.cpp,v 1.7 2006-09-11 12:05:39 dockes Exp
using namespace std; using namespace std;
#endif #endif
static const char *docSubkey = "docs";
// Encode/decode document history entry: Unix time + base64 of fn + // Encode/decode document history entry: Unix time + base64 of fn +
// base64 of ipath separated by a space. If ipath is not set, there // base64 of ipath separated by a space. If ipath is not set, there
@ -182,6 +181,8 @@ list<string> RclHistory::getStringList(const string sk)
return sl; return sl;
} }
string RclHistory::docSubkey = "docs";
/// *************** History entries specific methods /// *************** History entries specific methods
bool RclHistory::enterDoc(const string fn, const string ipath) bool RclHistory::enterDoc(const string fn, const string ipath)
{ {
@ -213,8 +214,11 @@ using namespace std;
static string thisprog; static string thisprog;
static string usage = static string usage =
" [-e] [-s <subkey>]" "trhist [opts] <filename>\n"
" \n\n" " [-s <subkey>]: specify subkey (default: RclHistory::docSubkey)\n"
" [-e] : erase all\n"
" [-a <string>] enter string (needs -s, no good for history entries\n"
"\n"
; ;
static void static void
@ -227,10 +231,12 @@ Usage(void)
static int op_flags; static int op_flags;
#define OPT_e 0x2 #define OPT_e 0x2
#define OPT_s 0x4 #define OPT_s 0x4
#define OPT_a 0x8
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
string sk = "docs"; string sk = RclHistory::docSubkey;
string value;
thisprog = argv[0]; thisprog = argv[0];
argc--; argv++; argc--; argv++;
@ -242,24 +248,31 @@ int main(int argc, char **argv)
Usage(); Usage();
while (**argv) while (**argv)
switch (*(*argv)++) { switch (*(*argv)++) {
case 'a': op_flags |= OPT_a; if (argc < 2) Usage();
value = *(++argv); argc--;
goto b1;
case 's': op_flags |= OPT_s; if (argc < 2) Usage(); case 's': op_flags |= OPT_s; if (argc < 2) Usage();
sk = *(++argv); sk = *(++argv); argc--;
argc--;
goto b1; goto b1;
case 'e': op_flags |= OPT_e; break; case 'e': op_flags |= OPT_e; break;
default: Usage(); break; default: Usage(); break;
} }
b1: argc--; argv++; b1: argc--; argv++;
} }
if (argc != 0) if (argc != 1)
Usage(); Usage();
string filename = *argv++;argc--;
RclHistory hist("toto", 5); RclHistory hist(filename, 5);
DebugLog::getdbl()->setloglevel(DEBDEB1); DebugLog::getdbl()->setloglevel(DEBDEB1);
DebugLog::setfilename("stderr"); DebugLog::setfilename("stderr");
if (op_flags & OPT_e) { if (op_flags & OPT_e) {
hist.eraseAll(sk); hist.eraseAll(sk);
} else if (op_flags & OPT_a) {
if (!(op_flags & OPT_s))
Usage();
hist.enterString(sk, value);
} else { } else {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
char docname[100]; char docname[100];

View File

@ -16,7 +16,7 @@
*/ */
#ifndef _HISTORY_H_INCLUDED_ #ifndef _HISTORY_H_INCLUDED_
#define _HISTORY_H_INCLUDED_ #define _HISTORY_H_INCLUDED_
/* @(#$Id: history.h,v 1.6 2006-10-02 12:33:13 dockes Exp $ (C) 2004 J.F.Dockes */ /* @(#$Id: history.h,v 1.7 2007-06-20 13:16:11 dockes Exp $ (C) 2004 J.F.Dockes */
/** /**
* Dynamic configuration storage * Dynamic configuration storage
@ -94,7 +94,8 @@ class RclHistory {
: m_mlen(maxsize), m_data(fn.c_str()) {} : m_mlen(maxsize), m_data(fn.c_str()) {}
bool ok() {return m_data.getStatus() == ConfSimple::STATUS_RW;} bool ok() {return m_data.getStatus() == ConfSimple::STATUS_RW;}
// Specific methods for history entries // Specific methods for history entries. These are for convenience, they
// just call regular methods with key RclHistory::docSubkey;
bool enterDoc(const string fn, const string ipath); bool enterDoc(const string fn, const string ipath);
list<RclDHistoryEntry> getDocHistory(); list<RclDHistoryEntry> getDocHistory();
@ -104,6 +105,8 @@ class RclHistory {
bool eraseAll(const string& sk); bool eraseAll(const string& sk);
bool truncate(const string& sk, unsigned int n); bool truncate(const string& sk, unsigned int n);
static string docSubkey;
private: private:
unsigned int m_mlen; unsigned int m_mlen;
ConfSimple m_data; ConfSimple m_data;