63 lines
1.5 KiB
C++
63 lines
1.5 KiB
C++
#ifndef lint
|
|
static char rcsid[] = "@(#$Id: pvmain.cpp,v 1.5 2005-11-24 07:16:16 dockes Exp $ (C) 2005 J.F.Dockes";
|
|
#endif
|
|
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
|
|
#include <string>
|
|
#include <list>
|
|
|
|
#ifndef NO_NAMESPACES
|
|
using std::string;
|
|
using std::list;
|
|
using std::pair;
|
|
#endif /* NO_NAMESPACES */
|
|
|
|
#include <qapplication.h>
|
|
#include <qobject.h>
|
|
#include <qtextedit.h>
|
|
#include <qtabwidget.h>
|
|
#include <qlayout.h>
|
|
|
|
#include "preview.h"
|
|
#include "../plaintorich.h"
|
|
#include "readfile.h"
|
|
|
|
const char *filename = "/home/dockes/tmp/tstpv-utf8.txt";
|
|
int recollNeedsExit;
|
|
int main( int argc, char ** argv )
|
|
{
|
|
QApplication a(argc, argv);
|
|
Preview w;
|
|
|
|
string text;
|
|
if (!file_to_string(filename, text)) {
|
|
fprintf(stderr, "Could not read %s\n", filename);
|
|
exit(1);
|
|
}
|
|
list<string> terms;
|
|
list<pair<int, int> > termoffs;
|
|
string rich = plaintorich(text, terms, termoffs);
|
|
QString str = QString::fromUtf8(rich.c_str(), rich.length());
|
|
w.pvEdit->setText(str);
|
|
|
|
// QVBoxLayout *unnamedLayout =
|
|
// new QVBoxLayout(0, 11, 6, "unnamedLayout");
|
|
QWidget *anon = new QWidget(w.pvTab);
|
|
QVBoxLayout *anonLayout = new QVBoxLayout(anon, 11, 6, "unnamedLayout");
|
|
QTextEdit *newEd = new QTextEdit(anon, "pvEdit");
|
|
anonLayout->addWidget(newEd);
|
|
fprintf(stderr, "pvEdit %p newEd: %p\n", w.pvEdit, newEd);
|
|
newEd->setReadOnly( TRUE );
|
|
newEd->setUndoRedoEnabled( FALSE );
|
|
newEd->setText(str);
|
|
|
|
w.pvTab->addTab(anon, "Tab 2");
|
|
#if QT_VERSION < 0x040000
|
|
a.setMainWidget(&w);
|
|
#endif
|
|
w.show();
|
|
return a.exec();
|
|
}
|