gui connected to rcldb (init)

This commit is contained in:
dockes
2005-01-25 14:37:35 +00:00
parent 5210139b85
commit 15855b018f
17 changed files with 621 additions and 265 deletions
+59 -2
View File
@@ -1,11 +1,68 @@
#include <signal.h>
#include <qapplication.h>
#include "form1.h"
#include <qmessagebox.h>
#include "recollmain.h"
#include "rcldb.h"
#include "rclconfig.h"
RclConfig *rclconfig;
Rcl::Db *rcldb;
static void cleanup()
{
delete rcldb;
rcldb = 0;
delete rclconfig;
rclconfig = 0;
}
static void sigcleanup(int sig)
{
fprintf(stderr, "sigcleanup\n");
cleanup();
exit(1);
}
int main( int argc, char ** argv )
{
QApplication a( argc, argv );
Form1 w;
RecollMain w;
w.show();
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
rclconfig = new RclConfig;
if (!rclconfig || !rclconfig->ok()) {
QMessageBox::critical(0, "Recoll",
QString("Could not find configuration"));
exit(1);
}
string dbdir;
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
QMessageBox::critical(0, "Recoll",
QString("No db directory in configuration"));
exit(1);
}
rcldb = new Rcl::Db;
if (!rcldb->open(dbdir, Rcl::Db::DbRO)) {
QMessageBox::critical(0, "Recoll",
QString("Could not open database in ") +
QString(dbdir));
exit(1);
}
atexit(cleanup);
if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
signal(SIGHUP, sigcleanup);
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
signal(SIGINT, sigcleanup);
if (signal(SIGQUIT, SIG_IGN) != SIG_IGN)
signal(SIGQUIT, sigcleanup);
if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
signal(SIGTERM, sigcleanup);
return a.exec();
}
+30
View File
@@ -0,0 +1,30 @@
TEMPLATE = app
LANGUAGE = C++
CONFIG += qt warn_on release
SOURCES += main.cpp
FORMS = recollmain.ui
IMAGES = images/filenew \
images/fileopen \
images/filesave \
images/print \
images/undo \
images/redo \
images/editcut \
images/editcopy \
images/editpaste \
images/searchfind
unix {
UI_DIR = .ui
MOC_DIR = .moc
OBJECTS_DIR = .obj
LIBS += ../lib/librcl.a -L/usr/local/lib -lxapian -liconv
INCLUDEPATH += ../common ../index ../query ../unac ../utils
}
+245
View File
@@ -0,0 +1,245 @@
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>RecollMain</class>
<widget class="QMainWindow">
<property name="name">
<cstring>RecollMain</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>774</width>
<height>619</height>
</rect>
</property>
<property name="caption">
<string>recoll</string>
</property>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout7</cstring>
</property>
<property name="geometry">
<rect>
<x>11</x>
<y>11</y>
<width>752</width>
<height>41</height>
</rect>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLineEdit">
<property name="name">
<cstring>queryText</cstring>
</property>
<property name="frameShape">
<enum>LineEditPanel</enum>
</property>
<property name="frameShadow">
<enum>Sunken</enum>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>Search</cstring>
</property>
<property name="text">
<string>pushButton1</string>
</property>
</widget>
<spacer>
<property name="name">
<cstring>spacer1</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</hbox>
</widget>
<widget class="QSplitter">
<property name="name">
<cstring>splitter9</cstring>
</property>
<property name="geometry">
<rect>
<x>11</x>
<y>58</y>
<width>752</width>
<height>491</height>
</rect>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<widget class="QTextEdit">
<property name="name">
<cstring>resTextEdit</cstring>
</property>
</widget>
<widget class="QSplitter">
<property name="name">
<cstring>splitter8</cstring>
</property>
<property name="orientation">
<enum>Vertical</enum>
</property>
<widget class="QTextEdit">
<property name="name">
<cstring>textEdit12</cstring>
</property>
</widget>
<widget class="QTextEdit">
<property name="name">
<cstring>textEdit13</cstring>
</property>
</widget>
</widget>
</widget>
</widget>
<menubar>
<property name="name">
<cstring>MenuBar</cstring>
</property>
<item text="&amp;File" name="fileMenu">
<separator/>
<separator/>
<action name="fileExitAction"/>
</item>
<item text="&amp;Help" name="helpMenu">
<action name="helpContentsAction"/>
<action name="helpIndexAction"/>
<separator/>
<action name="helpAboutAction"/>
</item>
</menubar>
<toolbars>
</toolbars>
<actions>
<action>
<property name="name">
<cstring>fileExitAction</cstring>
</property>
<property name="text">
<string>Exit</string>
</property>
<property name="menuText">
<string>E&amp;xit</string>
</property>
<property name="accel">
<string></string>
</property>
</action>
<action>
<property name="name">
<cstring>helpContentsAction</cstring>
</property>
<property name="text">
<string>Contents</string>
</property>
<property name="menuText">
<string>&amp;Contents...</string>
</property>
<property name="accel">
<string></string>
</property>
</action>
<action>
<property name="name">
<cstring>helpIndexAction</cstring>
</property>
<property name="text">
<string>Index</string>
</property>
<property name="menuText">
<string>&amp;Index...</string>
</property>
<property name="accel">
<string></string>
</property>
</action>
<action>
<property name="name">
<cstring>helpAboutAction</cstring>
</property>
<property name="text">
<string>About</string>
</property>
<property name="menuText">
<string>&amp;About</string>
</property>
<property name="accel">
<string></string>
</property>
</action>
</actions>
<connections>
<connection>
<sender>fileExitAction</sender>
<signal>activated()</signal>
<receiver>RecollMain</receiver>
<slot>fileExit()</slot>
</connection>
<connection>
<sender>helpIndexAction</sender>
<signal>activated()</signal>
<receiver>RecollMain</receiver>
<slot>helpIndex()</slot>
</connection>
<connection>
<sender>helpContentsAction</sender>
<signal>activated()</signal>
<receiver>RecollMain</receiver>
<slot>helpContents()</slot>
</connection>
<connection>
<sender>helpAboutAction</sender>
<signal>activated()</signal>
<receiver>RecollMain</receiver>
<slot>helpAbout()</slot>
</connection>
<connection>
<sender>resTextEdit</sender>
<signal>clicked(int,int)</signal>
<receiver>RecollMain</receiver>
<slot>resTextEdit_clicked(int,int)</slot>
</connection>
<connection>
<sender>resTextEdit</sender>
<signal>returnPressed()</signal>
<receiver>RecollMain</receiver>
<slot>resTextEdit_returnPressed()</slot>
</connection>
<connection>
<sender>fileExitAction</sender>
<signal>activated()</signal>
<receiver>RecollMain</receiver>
<slot>fileExit()</slot>
</connection>
</connections>
<includes>
<include location="local" impldecl="in implementation">recollmain.ui.h</include>
</includes>
<slots>
<slot>fileExit()</slot>
<slot>helpIndex()</slot>
<slot>helpContents()</slot>
<slot>helpAbout()</slot>
<slot>resTextEdit_clicked( int par, int car )</slot>
<slot>resTextEdit_returnPressed()</slot>
</slots>
<pixmapinproject/>
<layoutdefaults spacing="6" margin="11"/>
</UI>
+61
View File
@@ -0,0 +1,61 @@
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you want to add, delete, or rename functions or slots, use
** Qt Designer to update this file, preserving your code.
**
** You should not define a constructor or destructor in this file.
** Instead, write your code in functions called init() and destroy().
** These will automatically be called by the form's constructor and
** destructor.
*****************************************************************************/
void RecollMain::fileExit()
{
exit(0);
}
void RecollMain::helpIndex()
{
}
void RecollMain::helpContents()
{
}
void RecollMain::helpAbout()
{
}
void RecollMain::resTextEdit_clicked( int par, int car )
{
fprintf(stderr, "Clicked at paragraph %d, char %d\n", par, car);
}
#include "qfontdialog.h"
#define BS 200000
void RecollMain::resTextEdit_returnPressed()
{
fprintf(stderr, "ReturnPressed()\n");
resTextEdit->setFont( QFontDialog::getFont( 0, resTextEdit->font() ) );
const char *fname = "utf8.txt";
FILE *fp = fopen(fname, "r");
if (fp) {
char buf[BS];
memset(buf,0, sizeof(buf));
int n = fread(buf, 1, BS-1, fp);
fclose(fp);
QString str = QString::fromUtf8(buf, n);
resTextEdit->setTextFormat(RichText);
resTextEdit->setText(str);
}
}