Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

tvbrowseview.cpp

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2000 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/ 
00020 #include "tvbrowseview.h"
00021 #include "browsekeyentry.h"
00022 #include <qtoolbutton.h>
00023 #include <qtextview.h>
00024 #include <qtextbrowser.h>
00025 #include <qlayout.h>
00026 #include "../xmlencodeattr.h"
00027 
00041 TVBrowseView::TVBrowseView(TableState *t, QWidget* parent, const char *name, 
00042   WFlags fl )
00043 {
00044     if (!name) 
00045   setName("BrowseView");
00046 
00047 //      setSizePolicy(QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding, 0, 0, sizePolicy().hasHeightForWidth() ) );
00048     QVBoxLayout *vlayout = new QVBoxLayout(this);
00049     textViewDisplay = new QTextBrowser(this, "textViewDisplay");
00050     vlayout->addWidget( textViewDisplay );
00051 
00052     keyEntry = new TVBrowseKeyEntry(this, "keyEntry");
00053     vlayout->addWidget( keyEntry );
00054 
00055     /* connect the signals down */
00056 
00057     connect(keyEntry, SIGNAL(searchOnKey(int,TVVariant)),
00058         this, SIGNAL(searchOnKey(int,TVVariant)));
00059     connect(keyEntry, SIGNAL(sortChanged(int)),
00060         this, SIGNAL(sortChanged(int)));
00061 
00062     ts = t;
00063     keyEntry->setTableState(t); 
00064 }
00065 
00069 TVBrowseView::~TVBrowseView()
00070 {
00071 }
00072 
00073 void TVBrowseView::rebuildData()
00074 {
00075     if(!ts)
00076         return;
00077     if(!ts->current_elem) {
00078     /* also disable buttons */
00079     textViewDisplay->setText("");
00080         return;
00081   }
00082 
00083     setDisplayText(ts->current_elem);
00084 }
00085 
00086 /* Reset to initial state */
00087 void TVBrowseView::reset()
00088 {
00089     textViewDisplay->setText("");
00090     keyEntry->reset();
00091 }
00092 
00096 void TVBrowseView::setDisplayText(const DataElem *element)
00097 {
00098     QString rep = "";
00099 
00100     KeyListIterator it(*ts->kRep);
00101 
00102     while (it.current()) {
00103         if (element->hasValidValue(it.currentKey())) {
00104             if(it.currentKey() == ts->current_column) {
00105                 rep += "<A name=\"ckey\"></A><B><FONT COLOR=#FF0000>" 
00106                     + encodeAttr(it.current()->name())
00107                     + ":</FONT></B> ";
00108             } else {
00109                 rep += "<B>" + encodeAttr(it.current()->name()) + ":</B> ";
00110             }
00111             rep += encodeAttr(element->toQString(it.currentKey())) + "<BR>";
00112         }
00113         ++it;
00114     }
00115 
00116     textViewDisplay->setText(rep);
00117     textViewDisplay->scrollToAnchor("ckey");
00118 }
00119 
00120 void TVBrowseView::rebuildKeys() 
00121 {
00122     keyEntry->rebuildKeys();
00123 }

Generated on Sat Nov 5 16:17:08 2005 for OPIE by  doxygen 1.4.2