kwicmodels.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 KWICMODELS_H
00023 #define KWICMODELS_H KWICMODELS_H
00024 
00025 #include <QtCore/QAbstractTableModel>
00026 
00027 #include "phrasehunter/searchengine.h"
00028 
00029 //! Model for table in gui holding the results of a query.
00030 class KwicTableModel: public QAbstractTableModel
00031 {
00032 public:
00033     KwicTableModel(QObject* parent, PhraseHunter::ContextReader* reader);
00034     ~KwicTableModel() {}
00035 
00036     void setData(PhraseHunter::TokenPtr token);
00037     void setData(const PhraseHunter::TokenVector& token);
00038     
00039     int columnCount(const QModelIndex& parent = QModelIndex()) const;
00040     int rowCount(const QModelIndex& parent = QModelIndex()) const;
00041     QVariant headerData(int, Qt::Orientation, int) const;
00042     QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
00043     QVariant getContextString(PhraseHunter::TokenContextPtr, const QModelIndex&) const;
00044     
00045     
00046     inline PhraseHunter::TokenContextPtr getContext(const QModelIndex& index) const 
00047     {
00048         return (index.isValid()) 
00049             ? entries[index.row()]
00050             : PhraseHunter::TokenContextPtr();
00051     }
00052 
00053     inline void setContextWidth(unsigned int width) 
00054     {
00055         m_width = width;
00056     }    
00057 
00058 private:
00059     PhraseHunter::ContextReader* m_reader;
00060 
00061     std::vector<PhraseHunter::TokenContextPtr> entries;
00062 
00063     unsigned int m_width;
00064 };
00065 
00066 
00067 #endif // KWICMODELS_H

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