textbrowsertab.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 /*
00003   Phrasehunter - index and query text corpora
00004   Copyright (C) 2006  Torsten Marek (shlomme@gmx.de) &
00005   Armin Schmidt (armin.sch@gmail.com)
00006   
00007   This program is free software; you can redistribute it and/or
00008   modify it under the terms of the GNU General Public License
00009   as published by the Free Software Foundation; either version 2
00010   of the License, or (at your option) any later version.
00011   
00012   This program is distributed in the hope that it will be useful,
00013   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015   GNU General Public License for more details.
00016   
00017   You should have received a copy of the GNU General Public License
00018   along with this program; if not, write to the Free Software
00019   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00020 */
00021 
00022 #ifndef TEXTBROWSERTAB_H
00023 #define TEXTBROWSERTAB_H TEXTBROWSERTAB_H
00024 
00025 #include <QtGui/QWidget>
00026 #include <QtGui/QHBoxLayout>
00027 #include <QtGui/QTextBrowser>
00028 
00029 #include "phrasehunter/tokencontext.h"
00030 
00031 #include "qt_utils.h"
00032 
00033 //! Tab in the main window for browsing text documents.
00034 class TextBrowserTab: public QWidget 
00035 {
00036     Q_OBJECT
00037     
00038 public:
00039     TextBrowserTab(QWidget* parent, PhraseHunter::TokenContextPtr output): 
00040         QWidget(parent)
00041     {
00042         setupUi();
00043         
00044         QString sourceText("%1<font color='#00C000'><b>%2</b></font> %3");
00045             
00046         textBrowser->setHtml(sourceText
00047                              .arg(icuToQString(output->leftContext()))
00048                              .arg(icuToQString(output->token()))
00049                              .arg(icuToQString(output->rightContext())));
00050         ;
00051     }
00052     
00053     void setupUi() 
00054     {
00055         QHBoxLayout* layout = new QHBoxLayout(this);
00056         textBrowser = new QTextBrowser(this);
00057         layout->addWidget(textBrowser);
00058     }
00059 
00060 private:
00061     QTextBrowser* textBrowser;
00062 };
00063 
00064 
00065 #endif // TEXTBROWSERTAB_H

Generated on Thu Dec 21 16:14:41 2006 for The Phrasehunter by  doxygen 1.5.1