qt main program cleanup
This commit is contained in:
parent
eed200a4bd
commit
bc73c05b7a
@ -1,5 +1,5 @@
|
||||
#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
|
||||
#include <unistd.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;
|
||||
mimeconf->get(mtype, hs, "icons");
|
||||
return hs;
|
||||
string iconname;
|
||||
mimeconf->get(mtype, iconname, "icons");
|
||||
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,
|
||||
// filtersdir in config file, then let the system use the PATH
|
||||
string RclConfig::findFilter(const string &icmd)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#ifndef _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>
|
||||
|
||||
@ -70,7 +70,7 @@ class RclConfig {
|
||||
std::string getMimeViewerDef(const std::string &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 */
|
||||
std::list<string> getAllMimeTypes();
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
#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
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <qapplication.h>
|
||||
|
||||
//#define WITH_KDE
|
||||
#ifdef WITH_KDE
|
||||
#include <kapplication.h>
|
||||
#endif
|
||||
#include <qtranslator.h>
|
||||
#include <qtextcodec.h>
|
||||
#include <qthread.h>
|
||||
@ -23,9 +26,7 @@ using Rcl::AdvSearchData;
|
||||
#include "pathut.h"
|
||||
#include "recoll.h"
|
||||
#include "smallut.h"
|
||||
#include "wipedir.h"
|
||||
#include "rclinit.h"
|
||||
#include "history.h"
|
||||
#include "debuglog.h"
|
||||
|
||||
#include "rclmain.h"
|
||||
@ -35,9 +36,6 @@ static const char *recoll_datadir = RECOLL_DATADIR;
|
||||
RclConfig *rclconfig;
|
||||
Rcl::Db *rcldb;
|
||||
int recollNeedsExit;
|
||||
string tmpdir;
|
||||
string iconsdir;
|
||||
RclDHistory *history;
|
||||
static string dbdir;
|
||||
static RclMainBase *mainWindow;
|
||||
static string recollsharedir;
|
||||
@ -102,7 +100,7 @@ bool maybeOpenDb(string &reason)
|
||||
return true;
|
||||
}
|
||||
|
||||
void recollCleanup()
|
||||
static void recollCleanup()
|
||||
{
|
||||
rwSettings(true);
|
||||
stop_idxthread();
|
||||
@ -110,11 +108,6 @@ void recollCleanup()
|
||||
rcldb = 0;
|
||||
delete rclconfig;
|
||||
rclconfig = 0;
|
||||
if (tmpdir.length()) {
|
||||
wipedir(tmpdir);
|
||||
rmdir(tmpdir.c_str());
|
||||
tmpdir.erase();
|
||||
}
|
||||
}
|
||||
|
||||
static void sigcleanup(int)
|
||||
@ -129,7 +122,11 @@ static void sigcleanup(int)
|
||||
|
||||
int main( int argc, char ** argv )
|
||||
{
|
||||
#ifdef WITH_KDE
|
||||
KApplication a(argc, argv, "recoll");
|
||||
#else
|
||||
QApplication a(argc, argv);
|
||||
#endif
|
||||
|
||||
// translation file for Qt
|
||||
QTranslator qt( 0 );
|
||||
@ -146,13 +143,6 @@ int main( int argc, char ** argv )
|
||||
|
||||
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;
|
||||
rclconfig = recollinit(recollCleanup, sigcleanup, reason);
|
||||
if (!rclconfig || !rclconfig->ok()) {
|
||||
@ -162,6 +152,14 @@ int main( int argc, char ** argv )
|
||||
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) {
|
||||
// Note: this will have to be replaced by a call to a
|
||||
// configuration buildin dialog for initial configuration
|
||||
@ -172,24 +170,6 @@ int main( int argc, char ** argv )
|
||||
}
|
||||
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;
|
||||
|
||||
// Connect exit handlers etc..
|
||||
|
||||
@ -27,8 +27,8 @@ using std::pair;
|
||||
#include "internfile.h"
|
||||
#include "recoll.h"
|
||||
#include "plaintorich.h"
|
||||
|
||||
extern int recollNeedsExit;
|
||||
#include "smallut.h"
|
||||
#include "wipedir.h"
|
||||
|
||||
// We keep a list of data associated to each tab
|
||||
class TabData {
|
||||
@ -327,21 +327,33 @@ class LoadThread : public QThread {
|
||||
string filename;
|
||||
string ipath;
|
||||
string *mtype;
|
||||
string tmpdir;
|
||||
|
||||
public:
|
||||
LoadThread(int *stp, Rcl::Doc *odoc, string fn, string ip, string *mt)
|
||||
: statusp(stp), out(odoc), filename(fn), ipath(ip), mtype(mt)
|
||||
{}
|
||||
virtual void run()
|
||||
{
|
||||
DebugLog::getdbl()->setloglevel(DEBDEB1);
|
||||
FileInterner interner(filename, rclconfig, tmpdir, mtype);
|
||||
if (interner.internfile(*out, ipath) != FileInterner::FIDone) {
|
||||
*statusp = -1;
|
||||
} else {
|
||||
*statusp = 0;
|
||||
}
|
||||
}
|
||||
{}
|
||||
~LoadThread() {
|
||||
if (tmpdir.length()) {
|
||||
wipedir(tmpdir);
|
||||
rmdir(tmpdir.c_str());
|
||||
}
|
||||
}
|
||||
virtual void run() {
|
||||
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) */
|
||||
|
||||
@ -88,6 +88,8 @@ void RclMain::init()
|
||||
QFont nfont(prefs_reslistfontfamily, prefs_reslistfontsize);
|
||||
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
|
||||
@ -517,11 +519,7 @@ void RclMain::showResultPage()
|
||||
gotone = true;
|
||||
|
||||
// Result list entry display: this must be exactly one paragraph
|
||||
// TOBEDONE
|
||||
// - move abstract/keywords to Detail window ?
|
||||
// - keywords matched ?
|
||||
// - language ?
|
||||
// - size ?
|
||||
// We should probably display the size too - size ?
|
||||
|
||||
string result;
|
||||
if (!sh.empty())
|
||||
@ -531,13 +529,11 @@ void RclMain::showResultPage()
|
||||
|
||||
string img_name;
|
||||
if (prefs_showicons) {
|
||||
string iconname = rclconfig->getMimeIconName(doc.mimetype);
|
||||
if (iconname.empty())
|
||||
iconname = "document";
|
||||
string imgfile = iconsdir + "/" + iconname + ".png";
|
||||
|
||||
LOGDEB1(("Img file; %s\n", imgfile.c_str()));
|
||||
QImage image(imgfile.c_str());
|
||||
string iconpath;
|
||||
string iconname = rclconfig->getMimeIconName(doc.mimetype,
|
||||
&iconpath);
|
||||
LOGDEB1(("Img file; %s\n", iconpath.c_str()));
|
||||
QImage image(iconpath.c_str());
|
||||
if (!image.isNull()) {
|
||||
img_name = string("img_") + iconname;
|
||||
QMimeSourceFactory::defaultFactory()->
|
||||
@ -726,7 +722,7 @@ void RclMain::startPreview(int docnum)
|
||||
}
|
||||
(void)curPreview->addEditorTab();
|
||||
}
|
||||
history->enterDocument(fn, doc.ipath);
|
||||
m_history->enterDocument(fn, doc.ipath);
|
||||
curPreview->loadFileInCurrentTab(fn, st.st_size, doc);
|
||||
}
|
||||
|
||||
@ -779,7 +775,7 @@ void RclMain::startNativeViewer(int docnum)
|
||||
stb->repaint(false);
|
||||
XFlush(qt_xdisplay());
|
||||
}
|
||||
history->enterDocument(fn, doc.ipath);
|
||||
m_history->enterDocument(fn, doc.ipath);
|
||||
system(ncmd.c_str());
|
||||
}
|
||||
|
||||
@ -805,11 +801,11 @@ void RclMain::showDocHistory()
|
||||
delete docsource;
|
||||
|
||||
if (sortwidth > 0) {
|
||||
DocSequenceHistory myseq(rcldb, history, tr("Document history"));
|
||||
DocSequenceHistory myseq(rcldb, m_history, tr("Document history"));
|
||||
docsource = new DocSeqSorted(myseq, sortwidth, sortspecs,
|
||||
tr("Document history (sorted)"));
|
||||
} else {
|
||||
docsource = new DocSequenceHistory(rcldb, history,
|
||||
docsource = new DocSequenceHistory(rcldb, m_history,
|
||||
tr("Document history"));
|
||||
}
|
||||
currentQueryData.erase();
|
||||
|
||||
@ -68,7 +68,7 @@ protected:
|
||||
RclSortSpec sortspecs;
|
||||
DocSequence *docsource;
|
||||
std::map<int,int> pageParaToReldocnums;
|
||||
|
||||
RclDHistory *m_history;
|
||||
private:
|
||||
virtual void init();
|
||||
virtual bool eventFilter( QObject * target, QEvent * event );
|
||||
|
||||
@ -1,25 +1,18 @@
|
||||
#ifndef _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 <list>
|
||||
|
||||
#include "rclconfig.h"
|
||||
#include "rcldb.h"
|
||||
#include "idxthread.h"
|
||||
#include "history.h"
|
||||
#include "docseq.h"
|
||||
|
||||
// Misc declarations in need of sharing between the UI files
|
||||
extern void recollCleanup();
|
||||
extern bool maybeOpenDb(std::string &reason);
|
||||
extern bool startHelpBrowser(const string& url = "");
|
||||
|
||||
extern RclConfig *rclconfig;
|
||||
extern Rcl::Db *rcldb;
|
||||
extern std::string tmpdir;
|
||||
extern string iconsdir;
|
||||
extern RclDHistory *history;
|
||||
extern int recollNeedsExit;
|
||||
|
||||
class QString;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user