qt main program cleanup
This commit is contained in:
parent
eed200a4bd
commit
bc73c05b7a
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.20 2006-01-20 10:01:59 dockes Exp $ (C) 2004 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.21 2006-01-20 14:58:57 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -175,15 +175,29 @@ string RclConfig::getMimeViewerDef(const string &mtype)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return icon name
|
* Return icon name and path
|
||||||
*/
|
*/
|
||||||
string RclConfig::getMimeIconName(const string &mtype)
|
string RclConfig::getMimeIconName(const string &mtype, string *path)
|
||||||
{
|
{
|
||||||
string hs;
|
string iconname;
|
||||||
mimeconf->get(mtype, hs, "icons");
|
mimeconf->get(mtype, iconname, "icons");
|
||||||
return hs;
|
if (iconname.empty())
|
||||||
|
iconname = "document";
|
||||||
|
|
||||||
|
if (path) {
|
||||||
|
string iconsdir;
|
||||||
|
getConfParam("iconsdir", iconsdir);
|
||||||
|
if (iconsdir.empty()) {
|
||||||
|
iconsdir = path_cat(m_datadir, "images");
|
||||||
|
} else {
|
||||||
|
iconsdir = path_tildexpand(iconsdir);
|
||||||
|
}
|
||||||
|
*path = path_cat(iconsdir, iconname) + ".png";
|
||||||
|
}
|
||||||
|
return iconname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Look up an executable filter. We look in $RECOLL_FILTERSDIR,
|
// Look up an executable filter. We look in $RECOLL_FILTERSDIR,
|
||||||
// filtersdir in config file, then let the system use the PATH
|
// filtersdir in config file, then let the system use the PATH
|
||||||
string RclConfig::findFilter(const string &icmd)
|
string RclConfig::findFilter(const string &icmd)
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
#ifndef _RCLCONFIG_H_INCLUDED_
|
#ifndef _RCLCONFIG_H_INCLUDED_
|
||||||
#define _RCLCONFIG_H_INCLUDED_
|
#define _RCLCONFIG_H_INCLUDED_
|
||||||
/* @(#$Id: rclconfig.h,v 1.13 2006-01-20 10:01:59 dockes Exp $ (C) 2004 J.F.Dockes */
|
/* @(#$Id: rclconfig.h,v 1.14 2006-01-20 14:58:57 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ class RclConfig {
|
|||||||
std::string getMimeViewerDef(const std::string &mimetype);
|
std::string getMimeViewerDef(const std::string &mimetype);
|
||||||
|
|
||||||
/** Get icon name from mimeconf for mimetype */
|
/** Get icon name from mimeconf for mimetype */
|
||||||
string getMimeIconName(const string &mtype);
|
string getMimeIconName(const string &mtype, string *path = 0);
|
||||||
|
|
||||||
/** Get a list of all indexable mime types defined in mimemap */
|
/** Get a list of all indexable mime types defined in mimemap */
|
||||||
std::list<string> getAllMimeTypes();
|
std::list<string> getAllMimeTypes();
|
||||||
|
|||||||
@ -1,11 +1,14 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: main.cpp,v 1.31 2006-01-20 12:46:50 dockes Exp $ (C) 2005 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: main.cpp,v 1.32 2006-01-20 14:58:57 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <qapplication.h>
|
#include <qapplication.h>
|
||||||
|
//#define WITH_KDE
|
||||||
|
#ifdef WITH_KDE
|
||||||
|
#include <kapplication.h>
|
||||||
|
#endif
|
||||||
#include <qtranslator.h>
|
#include <qtranslator.h>
|
||||||
#include <qtextcodec.h>
|
#include <qtextcodec.h>
|
||||||
#include <qthread.h>
|
#include <qthread.h>
|
||||||
@ -23,9 +26,7 @@ using Rcl::AdvSearchData;
|
|||||||
#include "pathut.h"
|
#include "pathut.h"
|
||||||
#include "recoll.h"
|
#include "recoll.h"
|
||||||
#include "smallut.h"
|
#include "smallut.h"
|
||||||
#include "wipedir.h"
|
|
||||||
#include "rclinit.h"
|
#include "rclinit.h"
|
||||||
#include "history.h"
|
|
||||||
#include "debuglog.h"
|
#include "debuglog.h"
|
||||||
|
|
||||||
#include "rclmain.h"
|
#include "rclmain.h"
|
||||||
@ -35,9 +36,6 @@ static const char *recoll_datadir = RECOLL_DATADIR;
|
|||||||
RclConfig *rclconfig;
|
RclConfig *rclconfig;
|
||||||
Rcl::Db *rcldb;
|
Rcl::Db *rcldb;
|
||||||
int recollNeedsExit;
|
int recollNeedsExit;
|
||||||
string tmpdir;
|
|
||||||
string iconsdir;
|
|
||||||
RclDHistory *history;
|
|
||||||
static string dbdir;
|
static string dbdir;
|
||||||
static RclMainBase *mainWindow;
|
static RclMainBase *mainWindow;
|
||||||
static string recollsharedir;
|
static string recollsharedir;
|
||||||
@ -102,7 +100,7 @@ bool maybeOpenDb(string &reason)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void recollCleanup()
|
static void recollCleanup()
|
||||||
{
|
{
|
||||||
rwSettings(true);
|
rwSettings(true);
|
||||||
stop_idxthread();
|
stop_idxthread();
|
||||||
@ -110,11 +108,6 @@ void recollCleanup()
|
|||||||
rcldb = 0;
|
rcldb = 0;
|
||||||
delete rclconfig;
|
delete rclconfig;
|
||||||
rclconfig = 0;
|
rclconfig = 0;
|
||||||
if (tmpdir.length()) {
|
|
||||||
wipedir(tmpdir);
|
|
||||||
rmdir(tmpdir.c_str());
|
|
||||||
tmpdir.erase();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sigcleanup(int)
|
static void sigcleanup(int)
|
||||||
@ -129,7 +122,11 @@ static void sigcleanup(int)
|
|||||||
|
|
||||||
int main( int argc, char ** argv )
|
int main( int argc, char ** argv )
|
||||||
{
|
{
|
||||||
|
#ifdef WITH_KDE
|
||||||
|
KApplication a(argc, argv, "recoll");
|
||||||
|
#else
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
#endif
|
||||||
|
|
||||||
// translation file for Qt
|
// translation file for Qt
|
||||||
QTranslator qt( 0 );
|
QTranslator qt( 0 );
|
||||||
@ -146,13 +143,6 @@ int main( int argc, char ** argv )
|
|||||||
|
|
||||||
rwSettings(false);
|
rwSettings(false);
|
||||||
|
|
||||||
// Create main window and set its size to previous session's
|
|
||||||
RclMain w;
|
|
||||||
mainWindow = &w;
|
|
||||||
QSize s(prefs_mainwidth, prefs_mainheight);
|
|
||||||
w.resize(s);
|
|
||||||
|
|
||||||
w.allTermsCB->setChecked(prefs_ssall);
|
|
||||||
string reason;
|
string reason;
|
||||||
rclconfig = recollinit(recollCleanup, sigcleanup, reason);
|
rclconfig = recollinit(recollCleanup, sigcleanup, reason);
|
||||||
if (!rclconfig || !rclconfig->ok()) {
|
if (!rclconfig || !rclconfig->ok()) {
|
||||||
@ -162,6 +152,14 @@ int main( int argc, char ** argv )
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create main window and set its size to previous session's
|
||||||
|
RclMain w;
|
||||||
|
mainWindow = &w;
|
||||||
|
QSize s(prefs_mainwidth, prefs_mainheight);
|
||||||
|
w.resize(s);
|
||||||
|
|
||||||
|
w.allTermsCB->setChecked(prefs_ssall);
|
||||||
|
|
||||||
if (rclconfig->getConfParam(string("dbdir"), dbdir) == 0) {
|
if (rclconfig->getConfParam(string("dbdir"), dbdir) == 0) {
|
||||||
// Note: this will have to be replaced by a call to a
|
// Note: this will have to be replaced by a call to a
|
||||||
// configuration buildin dialog for initial configuration
|
// configuration buildin dialog for initial configuration
|
||||||
@ -172,24 +170,6 @@ int main( int argc, char ** argv )
|
|||||||
}
|
}
|
||||||
dbdir = path_tildexpand(dbdir);
|
dbdir = path_tildexpand(dbdir);
|
||||||
|
|
||||||
rclconfig->getConfParam("iconsdir", iconsdir);
|
|
||||||
if (iconsdir.empty()) {
|
|
||||||
iconsdir = path_cat(recoll_datadir, "images");
|
|
||||||
} else {
|
|
||||||
iconsdir = path_tildexpand(iconsdir);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!maketmpdir(tmpdir)) {
|
|
||||||
QMessageBox::critical(0, "Recoll",
|
|
||||||
a.translate("Main",
|
|
||||||
"Cannot create temporary directory"));
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
string historyfile = path_cat(rclconfig->getConfDir(), "history");
|
|
||||||
history = new RclDHistory(historyfile);
|
|
||||||
|
|
||||||
|
|
||||||
rcldb = new Rcl::Db;
|
rcldb = new Rcl::Db;
|
||||||
|
|
||||||
// Connect exit handlers etc..
|
// Connect exit handlers etc..
|
||||||
|
|||||||
@ -27,8 +27,8 @@ using std::pair;
|
|||||||
#include "internfile.h"
|
#include "internfile.h"
|
||||||
#include "recoll.h"
|
#include "recoll.h"
|
||||||
#include "plaintorich.h"
|
#include "plaintorich.h"
|
||||||
|
#include "smallut.h"
|
||||||
extern int recollNeedsExit;
|
#include "wipedir.h"
|
||||||
|
|
||||||
// We keep a list of data associated to each tab
|
// We keep a list of data associated to each tab
|
||||||
class TabData {
|
class TabData {
|
||||||
@ -327,21 +327,33 @@ class LoadThread : public QThread {
|
|||||||
string filename;
|
string filename;
|
||||||
string ipath;
|
string ipath;
|
||||||
string *mtype;
|
string *mtype;
|
||||||
|
string tmpdir;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LoadThread(int *stp, Rcl::Doc *odoc, string fn, string ip, string *mt)
|
LoadThread(int *stp, Rcl::Doc *odoc, string fn, string ip, string *mt)
|
||||||
: statusp(stp), out(odoc), filename(fn), ipath(ip), mtype(mt)
|
: statusp(stp), out(odoc), filename(fn), ipath(ip), mtype(mt)
|
||||||
{}
|
{}
|
||||||
virtual void run()
|
~LoadThread() {
|
||||||
{
|
if (tmpdir.length()) {
|
||||||
DebugLog::getdbl()->setloglevel(DEBDEB1);
|
wipedir(tmpdir);
|
||||||
FileInterner interner(filename, rclconfig, tmpdir, mtype);
|
rmdir(tmpdir.c_str());
|
||||||
if (interner.internfile(*out, ipath) != FileInterner::FIDone) {
|
}
|
||||||
*statusp = -1;
|
}
|
||||||
} else {
|
virtual void run() {
|
||||||
*statusp = 0;
|
DebugLog::getdbl()->setloglevel(DEBDEB1);
|
||||||
}
|
if (!maketmpdir(tmpdir)) {
|
||||||
}
|
QMessageBox::critical(0, "Recoll",
|
||||||
|
Preview::tr("Cannot create temporary directory"));
|
||||||
|
*statusp = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FileInterner interner(filename, rclconfig, tmpdir, mtype);
|
||||||
|
if (interner.internfile(*out, ipath) != FileInterner::FIDone) {
|
||||||
|
*statusp = -1;
|
||||||
|
} else {
|
||||||
|
*statusp = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* A thread to convert to rich text (mark search terms) */
|
/* A thread to convert to rich text (mark search terms) */
|
||||||
|
|||||||
@ -88,6 +88,8 @@ void RclMain::init()
|
|||||||
QFont nfont(prefs_reslistfontfamily, prefs_reslistfontsize);
|
QFont nfont(prefs_reslistfontfamily, prefs_reslistfontsize);
|
||||||
reslistTE->setFont(nfont);
|
reslistTE->setFont(nfont);
|
||||||
}
|
}
|
||||||
|
string historyfile = path_cat(rclconfig->getConfDir(), "history");
|
||||||
|
m_history = new RclDHistory(historyfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We also want to get rid of the advanced search form and previews
|
// We also want to get rid of the advanced search form and previews
|
||||||
@ -517,11 +519,7 @@ void RclMain::showResultPage()
|
|||||||
gotone = true;
|
gotone = true;
|
||||||
|
|
||||||
// Result list entry display: this must be exactly one paragraph
|
// Result list entry display: this must be exactly one paragraph
|
||||||
// TOBEDONE
|
// We should probably display the size too - size ?
|
||||||
// - move abstract/keywords to Detail window ?
|
|
||||||
// - keywords matched ?
|
|
||||||
// - language ?
|
|
||||||
// - size ?
|
|
||||||
|
|
||||||
string result;
|
string result;
|
||||||
if (!sh.empty())
|
if (!sh.empty())
|
||||||
@ -531,13 +529,11 @@ void RclMain::showResultPage()
|
|||||||
|
|
||||||
string img_name;
|
string img_name;
|
||||||
if (prefs_showicons) {
|
if (prefs_showicons) {
|
||||||
string iconname = rclconfig->getMimeIconName(doc.mimetype);
|
string iconpath;
|
||||||
if (iconname.empty())
|
string iconname = rclconfig->getMimeIconName(doc.mimetype,
|
||||||
iconname = "document";
|
&iconpath);
|
||||||
string imgfile = iconsdir + "/" + iconname + ".png";
|
LOGDEB1(("Img file; %s\n", iconpath.c_str()));
|
||||||
|
QImage image(iconpath.c_str());
|
||||||
LOGDEB1(("Img file; %s\n", imgfile.c_str()));
|
|
||||||
QImage image(imgfile.c_str());
|
|
||||||
if (!image.isNull()) {
|
if (!image.isNull()) {
|
||||||
img_name = string("img_") + iconname;
|
img_name = string("img_") + iconname;
|
||||||
QMimeSourceFactory::defaultFactory()->
|
QMimeSourceFactory::defaultFactory()->
|
||||||
@ -726,7 +722,7 @@ void RclMain::startPreview(int docnum)
|
|||||||
}
|
}
|
||||||
(void)curPreview->addEditorTab();
|
(void)curPreview->addEditorTab();
|
||||||
}
|
}
|
||||||
history->enterDocument(fn, doc.ipath);
|
m_history->enterDocument(fn, doc.ipath);
|
||||||
curPreview->loadFileInCurrentTab(fn, st.st_size, doc);
|
curPreview->loadFileInCurrentTab(fn, st.st_size, doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -779,7 +775,7 @@ void RclMain::startNativeViewer(int docnum)
|
|||||||
stb->repaint(false);
|
stb->repaint(false);
|
||||||
XFlush(qt_xdisplay());
|
XFlush(qt_xdisplay());
|
||||||
}
|
}
|
||||||
history->enterDocument(fn, doc.ipath);
|
m_history->enterDocument(fn, doc.ipath);
|
||||||
system(ncmd.c_str());
|
system(ncmd.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -805,11 +801,11 @@ void RclMain::showDocHistory()
|
|||||||
delete docsource;
|
delete docsource;
|
||||||
|
|
||||||
if (sortwidth > 0) {
|
if (sortwidth > 0) {
|
||||||
DocSequenceHistory myseq(rcldb, history, tr("Document history"));
|
DocSequenceHistory myseq(rcldb, m_history, tr("Document history"));
|
||||||
docsource = new DocSeqSorted(myseq, sortwidth, sortspecs,
|
docsource = new DocSeqSorted(myseq, sortwidth, sortspecs,
|
||||||
tr("Document history (sorted)"));
|
tr("Document history (sorted)"));
|
||||||
} else {
|
} else {
|
||||||
docsource = new DocSequenceHistory(rcldb, history,
|
docsource = new DocSequenceHistory(rcldb, m_history,
|
||||||
tr("Document history"));
|
tr("Document history"));
|
||||||
}
|
}
|
||||||
currentQueryData.erase();
|
currentQueryData.erase();
|
||||||
|
|||||||
@ -68,7 +68,7 @@ protected:
|
|||||||
RclSortSpec sortspecs;
|
RclSortSpec sortspecs;
|
||||||
DocSequence *docsource;
|
DocSequence *docsource;
|
||||||
std::map<int,int> pageParaToReldocnums;
|
std::map<int,int> pageParaToReldocnums;
|
||||||
|
RclDHistory *m_history;
|
||||||
private:
|
private:
|
||||||
virtual void init();
|
virtual void init();
|
||||||
virtual bool eventFilter( QObject * target, QEvent * event );
|
virtual bool eventFilter( QObject * target, QEvent * event );
|
||||||
|
|||||||
@ -1,25 +1,18 @@
|
|||||||
#ifndef _RECOLL_H_INCLUDED_
|
#ifndef _RECOLL_H_INCLUDED_
|
||||||
#define _RECOLL_H_INCLUDED_
|
#define _RECOLL_H_INCLUDED_
|
||||||
/* @(#$Id: recoll.h,v 1.10 2006-01-04 11:33:44 dockes Exp $ (C) 2004 J.F.Dockes */
|
/* @(#$Id: recoll.h,v 1.11 2006-01-20 14:58:57 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
|
||||||
|
|
||||||
#include "rclconfig.h"
|
#include "rclconfig.h"
|
||||||
#include "rcldb.h"
|
#include "rcldb.h"
|
||||||
#include "idxthread.h"
|
#include "idxthread.h"
|
||||||
#include "history.h"
|
|
||||||
#include "docseq.h"
|
|
||||||
|
|
||||||
// Misc declarations in need of sharing between the UI files
|
// Misc declarations in need of sharing between the UI files
|
||||||
extern void recollCleanup();
|
|
||||||
extern bool maybeOpenDb(std::string &reason);
|
extern bool maybeOpenDb(std::string &reason);
|
||||||
extern bool startHelpBrowser(const string& url = "");
|
extern bool startHelpBrowser(const string& url = "");
|
||||||
|
|
||||||
extern RclConfig *rclconfig;
|
extern RclConfig *rclconfig;
|
||||||
extern Rcl::Db *rcldb;
|
extern Rcl::Db *rcldb;
|
||||||
extern std::string tmpdir;
|
|
||||||
extern string iconsdir;
|
|
||||||
extern RclDHistory *history;
|
|
||||||
extern int recollNeedsExit;
|
extern int recollNeedsExit;
|
||||||
|
|
||||||
class QString;
|
class QString;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user