00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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 }