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

opentextdlg.cpp

Go to the documentation of this file.
00001 /*
00002 Dagger - A Bible study program utilizing the Sword library.
00003 Copyright (c) 2004 Dan Williams <drw@handhelds.org>
00004 
00005 This file is free software; you can redistribute it and/or modify it under
00006 the terms of the GNU General Public License as published by the Free Software
00007 Foundation; either version 2 of the License, or (at your option) any later version.
00008 
00009 This file is distributed in the hope that it will be useful, but WITHOUT ANY
00010 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
00011 PARTICULAR PURPOSE. See the GNU General Public License for more details.
00012 
00013 You should have received a copy of the GNU General Public License along with this
00014 file; see the file COPYING. If not, write to the Free Software Foundation, Inc.,
00015 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00016 */
00017 
00018 #include "opentextdlg.h"
00019 
00020 #include <qpe/applnk.h>
00021 
00022 #include <qheader.h>
00023 #include <qlayout.h>
00024 #include <qpixmap.h>
00025 
00026 OpenTextDlg::OpenTextDlg( QWidget *parent, sword::SWMgr *swordMgr, QPixmap *bibleIcon,
00027                           QPixmap *commentaryIcon, QPixmap *lexiconIcon )
00028     : QDialog( parent, QString::null, true )
00029     , m_textList( this )
00030 {
00031     setCaption( tr( "Open text" ) );
00032 
00033     QVBoxLayout *layout = new QVBoxLayout( this );
00034     layout->setMargin( 4 );
00035     layout->addWidget( &m_textList );
00036 
00037     m_textList.setRootIsDecorated( true );
00038     m_textList.addColumn( tr( "Icon" ) );
00039     m_textList.addColumn( tr( "Text" ) );
00040     m_textList.header()->hide();
00041     m_textList.setAllColumnsShowFocus( true );
00042     m_textList.setSorting( 1 );
00043 
00044     m_commentaries = new QListViewItem( &m_textList, QString::null, tr( "Commentaries" ) );
00045     m_commentaries->setPixmap( 0, *commentaryIcon );
00046     m_textList.insertItem( m_commentaries );
00047     m_lexicons = new QListViewItem( &m_textList, QString::null, tr( "Lexicons/Dictionaries" ) );
00048     m_lexicons->setPixmap( 0, *lexiconIcon );
00049     m_textList.insertItem( m_lexicons );
00050     m_bibles = new QListViewItem( &m_textList, QString::null, tr( "Biblical Texts" ) );
00051     m_bibles->setPixmap( 0, *bibleIcon );
00052     m_textList.insertItem( m_bibles );
00053     connect( &m_textList, SIGNAL(clicked(QListViewItem*)), this, SLOT(slotItemClicked(QListViewItem*)) );
00054 
00055     if ( swordMgr )
00056     {
00057         sword::ModMap::iterator it;
00058         QString type;
00059         QPixmap *icon = 0x0;
00060         QListViewItem *parent = 0x0;
00061 
00062         for ( it = swordMgr->Modules.begin(); it != swordMgr->Modules.end(); it++ )
00063         {
00064             if ( it->second )
00065             {
00066                 type = it->second->Type();
00067                 if ( type == "Biblical Texts" )
00068                 {
00069                     icon = bibleIcon;
00070                     parent = m_bibles;
00071                 }
00072                 else if ( type == "Commentaries" )
00073                 {
00074                     icon = commentaryIcon;
00075                     parent = m_commentaries;
00076                 }
00077                 else if ( type == "Lexicons / Dictionaries" )
00078                 {
00079                     icon = lexiconIcon;
00080                     parent = m_lexicons;
00081                 }
00082     
00083                 parent->insertItem( new QListViewItem( parent, QString::null, it->first.c_str() ) );
00084             }
00085         }
00086     }
00087 
00088     m_textList.sort();
00089 }
00090 
00091 void OpenTextDlg::slotItemClicked( QListViewItem *item )
00092 {
00093     if ( item == m_bibles || item == m_lexicons || item == m_commentaries )
00094     {
00095         m_textList.clearSelection();
00096         if ( item->childCount() > 0 )
00097         {
00098             item->setOpen( !item->isOpen() );
00099         }
00100     }
00101 }

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