author | drw <drw> | 2005-08-09 22:24:10 (UTC) |
---|---|---|
committer | drw <drw> | 2005-08-09 22:24:10 (UTC) |
commit | 0c362cbc72dfbff246c0f11417d364b45b50ec94 (patch) (unidiff) | |
tree | 6e1fcdc99ff40752343d7b4c99822eba591a2f15 | |
parent | 873a383cfc4f9184adfe9257500df8c03648b0fd (diff) | |
download | opie-0c362cbc72dfbff246c0f11417d364b45b50ec94.zip opie-0c362cbc72dfbff246c0f11417d364b45b50ec94.tar.gz opie-0c362cbc72dfbff246c0f11417d364b45b50ec94.tar.bz2 |
Several updates to Dagger, see /noncore/apps/dagger/ChangeLog for more information
-rw-r--r-- | noncore/apps/dagger/ChangeLog | 8 | ||||
-rw-r--r-- | noncore/apps/dagger/README | 8 | ||||
-rw-r--r-- | noncore/apps/dagger/TODO | 7 | ||||
-rw-r--r-- | noncore/apps/dagger/mainwindow.cpp | 68 | ||||
-rw-r--r-- | noncore/apps/dagger/opie-dagger.control | 2 | ||||
-rw-r--r-- | noncore/apps/dagger/searchbar.cpp | 2 |
6 files changed, 51 insertions, 44 deletions
diff --git a/noncore/apps/dagger/ChangeLog b/noncore/apps/dagger/ChangeLog index 108419e..22b20d4 100644 --- a/noncore/apps/dagger/ChangeLog +++ b/noncore/apps/dagger/ChangeLog | |||
@@ -1,11 +1,19 @@ | |||
1 | 2005-08-09 Dan Williams <drw@handhelds.org> | ||
2 | |||
3 | * Released version 0.9.2 | ||
4 | * Added support for Sword v1.5.8 | ||
5 | * Implemented morph tag cross-referencing | ||
6 | * Fix crash when last module is closed | ||
7 | * Fix display of key when module is opened | ||
8 | |||
1 | 2004-04-22 Dan Williams <drw@handhelds.org> | 9 | 2004-04-22 Dan Williams <drw@handhelds.org> |
2 | 10 | ||
3 | * Released version 0.9.1 | 11 | * Released version 0.9.1 |
4 | * Fixed the disabling of screen blanking | 12 | * Fixed the disabling of screen blanking |
5 | * Implement previous/next page scrolling | 13 | * Implement previous/next page scrolling |
6 | * Animate search OWait | 14 | * Animate search OWait |
7 | 15 | ||
8 | 2004-04-06 Dan Williams <drw@handhelds.org> | 16 | 2004-04-06 Dan Williams <drw@handhelds.org> |
9 | 17 | ||
10 | * Released version 0.9.0 | 18 | * Released version 0.9.0 |
11 | * Initial check-in of new application | 19 | * Initial check-in of new application |
diff --git a/noncore/apps/dagger/README b/noncore/apps/dagger/README index 00e9eed..47b8eee 100644 --- a/noncore/apps/dagger/README +++ b/noncore/apps/dagger/README | |||
@@ -1,61 +1,61 @@ | |||
1 | /************************************************************************ | 1 | /************************************************************************ |
2 | /* | 2 | /* |
3 | /* Opie - Dagger | 3 | /* Opie - Dagger |
4 | /* =============== | 4 | /* =============== |
5 | /* Version 0.9.1 | 5 | /* Version 0.9.2 |
6 | /* | 6 | /* |
7 | /* A Bible study/reader application | 7 | /* A Bible study/reader application |
8 | /* | 8 | /* |
9 | /************************************************************************ | 9 | /************************************************************************ |
10 | 10 | ||
11 | --------------------------------------------- | 11 | --------------------------------------------- |
12 | Release Notes for Opie-Dagger - April, 2004 | 12 | Release Notes for Opie-Dagger - August, 2005 |
13 | --------------------------------------------- | 13 | --------------------------------------------- |
14 | 14 | ||
15 | ====================== | 15 | ====================== |
16 | = To-do = | 16 | = To-do = |
17 | ====================== | 17 | ====================== |
18 | 18 | ||
19 | - See $OPIEDIR/noncore/apps/dagger/TODO for more info. | 19 | - See $OPIEDIR/noncore/apps/dagger/TODO for more info. |
20 | 20 | ||
21 | ====================== | 21 | ====================== |
22 | = Build = | 22 | = Build = |
23 | ====================== | 23 | ====================== |
24 | 24 | ||
25 | In order to build opie-dagger, libsword needs to be present on | 25 | In order to build opie-dagger, libsword needs to be present on |
26 | the build system along with the appropriate headers. | 26 | the build system along with the appropriate headers. |
27 | 27 | ||
28 | - libsword source (best to use version 1.5.x or greater): | 28 | - libsword source (requires version 1.5.8 or greater): |
29 | - http://www.crosswire.org/sword/ | 29 | - http://www.crosswire.org/sword/ |
30 | 30 | ||
31 | - the Sword library headers need to be located in an appropriate | 31 | - the Sword library headers need to be located in an appropriate |
32 | include directory | 32 | include directory |
33 | 33 | ||
34 | ====================== | 34 | ====================== |
35 | = Run = | 35 | = Run = |
36 | ====================== | 36 | ====================== |
37 | 37 | ||
38 | - In order to use opie-dagger, libsword must be installed | 38 | - In order to use opie-dagger, libsword must be installed |
39 | on the system. | 39 | on the system. |
40 | - One or more Sword modules need to be installed, see | 40 | - One or more Sword modules need to be installed, see |
41 | http://www.crosswire.org/sword/ to download modules | 41 | http://www.crosswire.org/sword/ to download modules |
42 | - When run for the first time, the path needs to be set to the | 42 | - When run for the first time, the path needs to be set to the |
43 | directory where the Sword modules are located. Select 'Edit->Configure' | 43 | directory where the Sword modules are located. Select 'Edit->Configure' |
44 | from the menu bar and enter the path on the 'General' tab. Restart | 44 | from the menu bar and enter the path on the 'General' tab. Restart |
45 | Dagger. | 45 | Dagger. |
46 | 46 | ||
47 | ====================== | 47 | ====================== |
48 | = Credits = | 48 | = Credits = |
49 | ====================== | 49 | ====================== |
50 | 50 | ||
51 | - Opie-Dagger is (C) 2004 Dan Williams | 51 | - Opie-Dagger is (C) 2004, 2005 Dan Williams |
52 | 52 | ||
53 | ====================== | 53 | ====================== |
54 | = Links = | 54 | = Links = |
55 | ====================== | 55 | ====================== |
56 | 56 | ||
57 | - Opie Project: http://opie.handhelds.org | 57 | - Opie Project: http://opie.handhelds.org |
58 | - OpenZaurus Project: http://openzaurus.org | 58 | - OpenZaurus Project: http://openzaurus.org |
59 | - Familiar Project: http://familiar.handhelds.org | 59 | - Familiar Project: http://familiar.handhelds.org |
60 | - Crosswire Society http://www.crosswire.org/ | 60 | - Crosswire Society http://www.crosswire.org/ |
61 | - The Sword Project http://www.crosswire.org/sword/ | 61 | - The Sword Project http://www.crosswire.org/sword/ |
diff --git a/noncore/apps/dagger/TODO b/noncore/apps/dagger/TODO index 1530bd6..21426aa 100644 --- a/noncore/apps/dagger/TODO +++ b/noncore/apps/dagger/TODO | |||
@@ -1,25 +1,28 @@ | |||
1 | /************************************************************************ | 1 | /************************************************************************ |
2 | /* | 2 | /* |
3 | /* Opie - Dagger | 3 | /* Opie - Dagger |
4 | /* =============== | 4 | /* =============== |
5 | /* Version 0.9.1 | 5 | /* Version 0.9.2 |
6 | /* | 6 | /* |
7 | /* A Bible study/reader application | 7 | /* A Bible study/reader application |
8 | /* | 8 | /* |
9 | /************************************************************************ | 9 | /************************************************************************ |
10 | 10 | ||
11 | ------------------------------------ | 11 | ------------------------------------ |
12 | To-do for Opie-Dagger - April, 2004 | 12 | To-do for Opie-Dagger - August, 2005 |
13 | ------------------------------------ | 13 | ------------------------------------ |
14 | 14 | ||
15 | ====================== | 15 | ====================== |
16 | = Current release = | 16 | = Current release = |
17 | ====================== | 17 | ====================== |
18 | 18 | ||
19 | 1. Implement module installation | 19 | 1. Implement module installation |
20 | 2. Fix support for other languages | ||
21 | 3. Fix display sleep prevention | ||
22 | 4. Implement footnote cross-referencing | ||
20 | 23 | ||
21 | ====================== | 24 | ====================== |
22 | = Future releases = | 25 | = Future releases = |
23 | ====================== | 26 | ====================== |
24 | 27 | ||
25 | 1. Margin notes \ No newline at end of file | 28 | 1. Margin notes \ No newline at end of file |
diff --git a/noncore/apps/dagger/mainwindow.cpp b/noncore/apps/dagger/mainwindow.cpp index 1f2d521..f61df68 100644 --- a/noncore/apps/dagger/mainwindow.cpp +++ b/noncore/apps/dagger/mainwindow.cpp | |||
@@ -72,682 +72,678 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags /*fl*/ ) | |||
72 | QTimer::singleShot( 100, this, SLOT( initConfig() ) ); | 72 | QTimer::singleShot( 100, this, SLOT( initConfig() ) ); |
73 | } | 73 | } |
74 | 74 | ||
75 | MainWindow::~MainWindow() | 75 | MainWindow::~MainWindow() |
76 | { | 76 | { |
77 | // Re-enable screen blanking if it was disabled | 77 | // Re-enable screen blanking if it was disabled |
78 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 78 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
79 | 79 | ||
80 | // Save Sword options | 80 | // Save Sword options |
81 | m_config.setGroup( "Sword" ); | 81 | m_config.setGroup( "Sword" ); |
82 | m_config.writeEntry( "ModPath", m_modulePath ); | 82 | m_config.writeEntry( "ModPath", m_modulePath ); |
83 | 83 | ||
84 | for ( QAction *a = m_actionSwordOpts.first(); a; a = m_actionSwordOpts.next() ) | 84 | for ( QAction *a = m_actionSwordOpts.first(); a; a = m_actionSwordOpts.next() ) |
85 | m_config.writeEntry( a->text(), a->isOn() ); | 85 | m_config.writeEntry( a->text(), a->isOn() ); |
86 | 86 | ||
87 | // Save configuration options | 87 | // Save configuration options |
88 | m_config.setGroup( "Config" ); | 88 | m_config.setGroup( "Config" ); |
89 | m_config.writeEntry( "AlwaysOpenNew", m_alwaysOpenNew ); | 89 | m_config.writeEntry( "AlwaysOpenNew", m_alwaysOpenNew ); |
90 | m_config.writeEntry( "AutoScroll", m_navToolbar->autoScrollRate() ); | 90 | m_config.writeEntry( "AutoScroll", m_navToolbar->autoScrollRate() ); |
91 | m_config.writeEntry( "DisableScreenBlanking", m_disableScreenBlank ); | 91 | m_config.writeEntry( "DisableScreenBlanking", m_disableScreenBlank ); |
92 | m_config.writeEntry( "CopyFormat", m_copyFormat ); | 92 | m_config.writeEntry( "CopyFormat", m_copyFormat ); |
93 | m_config.writeEntry( "NavBar", m_actionViewNavToolbar->isOn() ); | 93 | m_config.writeEntry( "NavBar", m_actionViewNavToolbar->isOn() ); |
94 | m_config.writeEntry( "NumVerses", m_numVerses ); | 94 | m_config.writeEntry( "NumVerses", m_numVerses ); |
95 | m_config.writeEntry( "SearchBar", m_actionViewSearchToolbar->isOn() ); | 95 | m_config.writeEntry( "SearchBar", m_actionViewSearchToolbar->isOn() ); |
96 | 96 | ||
97 | // Save text font | 97 | // Save text font |
98 | m_config.setGroup( "Font"); | 98 | m_config.setGroup( "Font"); |
99 | m_config.writeEntry( "Family", m_textFont.family() ); | 99 | m_config.writeEntry( "Family", m_textFont.family() ); |
100 | m_config.writeEntry( "Italic", m_textFont.italic() ); | 100 | m_config.writeEntry( "Italic", m_textFont.italic() ); |
101 | m_config.writeEntry( "Size", m_textFont.pointSize() ); | 101 | m_config.writeEntry( "Size", m_textFont.pointSize() ); |
102 | m_config.writeEntry( "Weight", m_textFont.weight() ); | 102 | m_config.writeEntry( "Weight", m_textFont.weight() ); |
103 | 103 | ||
104 | // Save bookmarks | 104 | // Save bookmarks |
105 | m_config.setGroup( "Bookmarks"); | 105 | m_config.setGroup( "Bookmarks"); |
106 | m_config.clearGroup(); | 106 | m_config.clearGroup(); |
107 | int index = 3; | 107 | int index = 3; |
108 | int id = m_bookmarkMenu->idAt( index ); | 108 | int id = m_bookmarkMenu->idAt( index ); |
109 | while ( id != -1 ) | 109 | while ( id != -1 ) |
110 | { | 110 | { |
111 | QString bookmark = m_bookmarkMenu->text( id ); | 111 | QString bookmark = m_bookmarkMenu->text( id ); |
112 | int pos = bookmark.find( " (" ); | 112 | int pos = bookmark.find( " (" ); |
113 | QString key = bookmark.left( pos ); | 113 | QString key = bookmark.left( pos ); |
114 | pos += 2; | 114 | pos += 2; |
115 | QString module = bookmark.mid( pos, bookmark.find( ")", pos ) - pos ); | 115 | QString module = bookmark.mid( pos, bookmark.find( ")", pos ) - pos ); |
116 | QString modkey; | 116 | QString modkey; |
117 | modkey.sprintf( "%s/%s", module.latin1(), key.latin1() ); | 117 | modkey.sprintf( "%s/%s", module.latin1(), key.latin1() ); |
118 | m_config.writeEntry( QString::number( index - 2 ), modkey ); | 118 | m_config.writeEntry( QString::number( index - 2 ), modkey ); |
119 | 119 | ||
120 | ++index; | 120 | ++index; |
121 | id = m_bookmarkMenu->idAt( index ); | 121 | id = m_bookmarkMenu->idAt( index ); |
122 | } | 122 | } |
123 | 123 | ||
124 | // Save opened modules | 124 | // Save opened modules |
125 | m_config.setGroup( "Session"); | 125 | m_config.setGroup( "Session"); |
126 | m_config.clearGroup(); | 126 | m_config.clearGroup(); |
127 | QObjectList *childlist = queryList( "TextWidget" ); | 127 | QObjectList *childlist = queryList( "TextWidget" ); |
128 | QObjectListIt it( *childlist ); | 128 | QObjectListIt it( *childlist ); |
129 | TextWidget *module; | 129 | TextWidget *module; |
130 | int count = 1; | 130 | int count = 1; |
131 | while ( ( module = reinterpret_cast<TextWidget *>(it.current()) ) != 0 ) | 131 | while ( ( module = reinterpret_cast<TextWidget *>(it.current()) ) != 0 ) |
132 | { | 132 | { |
133 | QString modkey; | 133 | QString modkey; |
134 | modkey.sprintf( "%s/%s", module->getModuleName().latin1(), module->getAbbrevKey().latin1() ); | 134 | modkey.sprintf( "%s/%s", module->getModuleName().latin1(), module->getAbbrevKey().latin1() ); |
135 | m_config.writeEntry( QString::number( count ), modkey ); | 135 | m_config.writeEntry( QString::number( count ), modkey ); |
136 | ++count; | 136 | ++count; |
137 | ++it; | 137 | ++it; |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | bool MainWindow::eventFilter( QObject *obj, QEvent *event ) | 141 | bool MainWindow::eventFilter( QObject *obj, QEvent *event ) |
142 | { | 142 | { |
143 | if ( event->type() == QEvent::KeyPress ) | 143 | if ( event->type() == QEvent::KeyPress ) |
144 | { | 144 | { |
145 | QKeyEvent *keyev = reinterpret_cast<QKeyEvent *>(event); | 145 | QKeyEvent *keyev = reinterpret_cast<QKeyEvent *>(event); |
146 | if ( keyev->key() == Key_Up ) | 146 | if ( keyev->key() == Key_Up ) |
147 | { | 147 | { |
148 | slotNavPrevVerse(); | 148 | slotNavPrevVerse(); |
149 | return true; | 149 | return true; |
150 | } | 150 | } |
151 | else if ( keyev->key() == Key_Down ) | 151 | else if ( keyev->key() == Key_Down ) |
152 | { | 152 | { |
153 | slotNavNextVerse(); | 153 | slotNavNextVerse(); |
154 | return true; | 154 | return true; |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | return QWidget::eventFilter( obj, event ); | 158 | return QWidget::eventFilter( obj, event ); |
159 | } | 159 | } |
160 | 160 | ||
161 | void MainWindow::initUI() | 161 | void MainWindow::initUI() |
162 | { | 162 | { |
163 | setCentralWidget( &m_tabs ); | 163 | setCentralWidget( &m_tabs ); |
164 | m_tabs.installEventFilter( this ); | 164 | m_tabs.installEventFilter( this ); |
165 | 165 | ||
166 | setToolBarsMovable( false ); | 166 | setToolBarsMovable( false ); |
167 | m_barDock = new QToolBar( this ); | 167 | m_barDock = new QToolBar( this ); |
168 | m_barDock->setHorizontalStretchable( true ); | 168 | m_barDock->setHorizontalStretchable( true ); |
169 | 169 | ||
170 | m_menuBar = new QMenuBar( m_barDock ); | 170 | m_menuBar = new QMenuBar( m_barDock ); |
171 | m_menuBar->setMargin( 0 ); | 171 | m_menuBar->setMargin( 0 ); |
172 | 172 | ||
173 | // Allocate toolbars | 173 | // Allocate toolbars |
174 | m_navToolbar = new NavBar( this ); | 174 | m_navToolbar = new NavBar( this ); |
175 | m_navToolbar->navBtnsEnable( false ); | 175 | m_navToolbar->navBtnsEnable( false ); |
176 | connect( m_navToolbar, SIGNAL(prevPage()), this, SLOT(slotNavPrevPage()) ); | 176 | connect( m_navToolbar, SIGNAL(prevPage()), this, SLOT(slotNavPrevPage()) ); |
177 | connect( m_navToolbar, SIGNAL(prevVerse()), this, SLOT(slotNavPrevVerse()) ); | 177 | connect( m_navToolbar, SIGNAL(prevVerse()), this, SLOT(slotNavPrevVerse()) ); |
178 | connect( m_navToolbar, SIGNAL(keyChanged(const QString &)), this, SLOT(slotNavKeyChanged(const QString &)) ); | 178 | connect( m_navToolbar, SIGNAL(keyChanged(const QString &)), this, SLOT(slotNavKeyChanged(const QString &)) ); |
179 | connect( m_navToolbar, SIGNAL(nextVerse()), this, SLOT(slotNavNextVerse()) ); | 179 | connect( m_navToolbar, SIGNAL(nextVerse()), this, SLOT(slotNavNextVerse()) ); |
180 | connect( m_navToolbar, SIGNAL(nextPage()), this, SLOT(slotNavNextPage()) ); | 180 | connect( m_navToolbar, SIGNAL(nextPage()), this, SLOT(slotNavNextPage()) ); |
181 | connect( m_navToolbar, SIGNAL(autoScroll(bool)), this, SLOT(slotNavAutoScroll(bool)) ); | 181 | connect( m_navToolbar, SIGNAL(autoScroll(bool)), this, SLOT(slotNavAutoScroll(bool)) ); |
182 | connect( m_navToolbar, SIGNAL(scrollRateChanged(int)), this, SLOT(slotNavScrollRateChanged(int)) ); | 182 | connect( m_navToolbar, SIGNAL(scrollRateChanged(int)), this, SLOT(slotNavScrollRateChanged(int)) ); |
183 | 183 | ||
184 | m_searchToolbar = new SearchBar( this ); | 184 | m_searchToolbar = new SearchBar( this ); |
185 | connect( m_searchToolbar, SIGNAL(sigResultClicked(const QString &)), this, SLOT(slotSearchResultClicked(const QString &)) ); | 185 | connect( m_searchToolbar, SIGNAL(sigResultClicked(const QString &)), this, SLOT(slotSearchResultClicked(const QString &)) ); |
186 | 186 | ||
187 | // Text menu | 187 | // Text menu |
188 | QPopupMenu *popup = new QPopupMenu( this ); | 188 | QPopupMenu *popup = new QPopupMenu( this ); |
189 | 189 | ||
190 | QAction *a = new QAction( tr( "Open..." ), Opie::Core::OResource::loadPixmap( "fileopen", Opie::Core::OResource::SmallIcon ), | 190 | QAction *a = new QAction( tr( "Open..." ), Opie::Core::OResource::loadPixmap( "fileopen", Opie::Core::OResource::SmallIcon ), |
191 | QString::null, 0, this, 0 ); | 191 | QString::null, 0, this, 0 ); |
192 | connect( a, SIGNAL(activated()), this, SLOT(slotTextOpen()) ); | 192 | connect( a, SIGNAL(activated()), this, SLOT(slotTextOpen()) ); |
193 | a->addTo( popup ); | 193 | a->addTo( popup ); |
194 | 194 | ||
195 | m_actionTextClose = new QAction( tr( "Close" ), Opie::Core::OResource::loadPixmap( "close", Opie::Core::OResource::SmallIcon ), | 195 | m_actionTextClose = new QAction( tr( "Close" ), Opie::Core::OResource::loadPixmap( "close", Opie::Core::OResource::SmallIcon ), |
196 | QString::null, 0, this, 0 ); | 196 | QString::null, 0, this, 0 ); |
197 | connect( m_actionTextClose, SIGNAL(activated()), this, SLOT(slotTextClose()) ); | 197 | connect( m_actionTextClose, SIGNAL(activated()), this, SLOT(slotTextClose()) ); |
198 | m_actionTextClose->addTo( popup ); | 198 | m_actionTextClose->addTo( popup ); |
199 | 199 | ||
200 | popup->insertSeparator(); | 200 | popup->insertSeparator(); |
201 | 201 | ||
202 | // TODO - need to implent | 202 | // TODO - need to implent |
203 | a = new QAction( tr( "Install" ), Opie::Core::OResource::loadPixmap( "install", Opie::Core::OResource::SmallIcon ), | 203 | a = new QAction( tr( "Install" ), Opie::Core::OResource::loadPixmap( "install", Opie::Core::OResource::SmallIcon ), |
204 | QString::null, 0, this, 0 ); | 204 | QString::null, 0, this, 0 ); |
205 | a->setEnabled( false ); | 205 | a->setEnabled( false ); |
206 | connect( a, SIGNAL(activated()), this, SLOT(slotTextInstall()) ); | 206 | connect( a, SIGNAL(activated()), this, SLOT(slotTextInstall()) ); |
207 | a->addTo( popup ); | 207 | a->addTo( popup ); |
208 | 208 | ||
209 | m_menuBar->insertItem( tr( "Text" ), popup ); | 209 | m_menuBar->insertItem( tr( "Text" ), popup ); |
210 | 210 | ||
211 | // Edit menu | 211 | // Edit menu |
212 | popup = new QPopupMenu( this ); | 212 | popup = new QPopupMenu( this ); |
213 | 213 | ||
214 | m_actionEditCopy = new QAction( tr( "Copy" ), Opie::Core::OResource::loadPixmap( "copy", Opie::Core::OResource::SmallIcon ), | 214 | m_actionEditCopy = new QAction( tr( "Copy" ), Opie::Core::OResource::loadPixmap( "copy", Opie::Core::OResource::SmallIcon ), |
215 | QString::null, 0, this, 0 ); | 215 | QString::null, 0, this, 0 ); |
216 | connect( m_actionEditCopy, SIGNAL(activated()), this, SLOT(slotEditCopy()) ); | 216 | connect( m_actionEditCopy, SIGNAL(activated()), this, SLOT(slotEditCopy()) ); |
217 | m_actionEditCopy->addTo( popup ); | 217 | m_actionEditCopy->addTo( popup ); |
218 | 218 | ||
219 | popup->insertSeparator(); | 219 | popup->insertSeparator(); |
220 | 220 | ||
221 | a = new QAction( tr( "Configure" ), Opie::Core::OResource::loadPixmap( "SettingsIcon", Opie::Core::OResource::SmallIcon ), | 221 | a = new QAction( tr( "Configure" ), Opie::Core::OResource::loadPixmap( "SettingsIcon", Opie::Core::OResource::SmallIcon ), |
222 | QString::null, 0, this, 0 ); | 222 | QString::null, 0, this, 0 ); |
223 | connect( a, SIGNAL(activated()), this, SLOT(slotEditConfigure()) ); | 223 | connect( a, SIGNAL(activated()), this, SLOT(slotEditConfigure()) ); |
224 | a->addTo( popup ); | 224 | a->addTo( popup ); |
225 | 225 | ||
226 | m_menuBar->insertItem( tr( "Edit" ), popup ); | 226 | m_menuBar->insertItem( tr( "Edit" ), popup ); |
227 | 227 | ||
228 | // Bookmark menu | 228 | // Bookmark menu |
229 | m_bookmarkMenu = new QPopupMenu( this ); | 229 | m_bookmarkMenu = new QPopupMenu( this ); |
230 | 230 | ||
231 | m_actionBookmarkAdd = new QAction( tr( "Add" ), | 231 | m_actionBookmarkAdd = new QAction( tr( "Add" ), |
232 | Opie::Core::OResource::loadPixmap( "dagger/bookmarkadd", Opie::Core::OResource::SmallIcon ), | 232 | Opie::Core::OResource::loadPixmap( "dagger/bookmarkadd", Opie::Core::OResource::SmallIcon ), |
233 | QString::null, 0, this, 0 ); | 233 | QString::null, 0, this, 0 ); |
234 | connect( m_actionBookmarkAdd, SIGNAL(activated()), this, SLOT(slotBookmarkAdd()) ); | 234 | connect( m_actionBookmarkAdd, SIGNAL(activated()), this, SLOT(slotBookmarkAdd()) ); |
235 | m_actionBookmarkAdd->addTo( m_bookmarkMenu ); | 235 | m_actionBookmarkAdd->addTo( m_bookmarkMenu ); |
236 | 236 | ||
237 | m_actionBookmarkRemove = new QAction( tr( "Remove" ), | 237 | m_actionBookmarkRemove = new QAction( tr( "Remove" ), |
238 | Opie::Core::OResource::loadPixmap( "dagger/bookmarkremove", Opie::Core::OResource::SmallIcon ), | 238 | Opie::Core::OResource::loadPixmap( "dagger/bookmarkremove", Opie::Core::OResource::SmallIcon ), |
239 | QString::null, 0, this, 0 ); | 239 | QString::null, 0, this, 0 ); |
240 | connect( m_actionBookmarkRemove, SIGNAL(activated()), this, SLOT(slotBookmarkRemove()) ); | 240 | connect( m_actionBookmarkRemove, SIGNAL(activated()), this, SLOT(slotBookmarkRemove()) ); |
241 | m_actionBookmarkRemove->addTo( m_bookmarkMenu ); | 241 | m_actionBookmarkRemove->addTo( m_bookmarkMenu ); |
242 | 242 | ||
243 | m_bookmarkMenu->insertSeparator(); | 243 | m_bookmarkMenu->insertSeparator(); |
244 | 244 | ||
245 | m_menuBar->insertItem( tr( "Bookmark" ), m_bookmarkMenu ); | 245 | m_menuBar->insertItem( tr( "Bookmark" ), m_bookmarkMenu ); |
246 | 246 | ||
247 | // View menu | 247 | // View menu |
248 | popup = new QPopupMenu( this ); | 248 | popup = new QPopupMenu( this ); |
249 | 249 | ||
250 | // Retrieve list of available Sword module options (e.g. footnotes, Strong's numbers, etc.) | 250 | // Retrieve list of available Sword module options (e.g. footnotes, Strong's numbers, etc.) |
251 | for ( a = m_actionSwordOpts.first(); a; a = m_actionSwordOpts.next() ) | 251 | for ( a = m_actionSwordOpts.first(); a; a = m_actionSwordOpts.next() ) |
252 | { | 252 | { |
253 | a->setToggleAction( true ); | 253 | a->setToggleAction( true ); |
254 | connect( a, SIGNAL(toggled(bool)), this, SLOT(slotViewSwordOption(bool)) ); | 254 | connect( a, SIGNAL(toggled(bool)), this, SLOT(slotViewSwordOption(bool)) ); |
255 | a->addTo( popup ); | 255 | a->addTo( popup ); |
256 | } | 256 | } |
257 | 257 | ||
258 | popup->insertSeparator(); | 258 | popup->insertSeparator(); |
259 | 259 | ||
260 | m_actionViewNavToolbar = new QAction( tr( "Navigation toolbar" ), QString::null, 0, this, 0 ); | 260 | m_actionViewNavToolbar = new QAction( tr( "Navigation toolbar" ), QString::null, 0, this, 0 ); |
261 | m_actionViewNavToolbar->setToggleAction( true ); | 261 | m_actionViewNavToolbar->setToggleAction( true ); |
262 | connect( m_actionViewNavToolbar, SIGNAL(toggled(bool)), this, SLOT(slotViewNavToolbar(bool)) ); | 262 | connect( m_actionViewNavToolbar, SIGNAL(toggled(bool)), this, SLOT(slotViewNavToolbar(bool)) ); |
263 | m_actionViewNavToolbar->addTo( popup ); | 263 | m_actionViewNavToolbar->addTo( popup ); |
264 | 264 | ||
265 | m_actionViewSearchToolbar = new QAction( tr( "Search toolbar" ), QString::null, 0, this, 0 ); | 265 | m_actionViewSearchToolbar = new QAction( tr( "Search toolbar" ), QString::null, 0, this, 0 ); |
266 | m_actionViewSearchToolbar->setToggleAction( true ); | 266 | m_actionViewSearchToolbar->setToggleAction( true ); |
267 | connect( m_actionViewSearchToolbar, SIGNAL(toggled(bool)), this, SLOT(slotViewSearchToolbar(bool)) ); | 267 | connect( m_actionViewSearchToolbar, SIGNAL(toggled(bool)), this, SLOT(slotViewSearchToolbar(bool)) ); |
268 | m_actionViewSearchToolbar->addTo( popup ); | 268 | m_actionViewSearchToolbar->addTo( popup ); |
269 | 269 | ||
270 | m_menuBar->insertItem( tr( "View" ), popup ); | 270 | m_menuBar->insertItem( tr( "View" ), popup ); |
271 | } | 271 | } |
272 | 272 | ||
273 | void MainWindow::openModule( const QString &modulename, const QString &key ) | 273 | void MainWindow::openModule( const QString &modulename, const QString &key ) |
274 | { | 274 | { |
275 | sword::SWModule *module = m_swordMgr->Modules[ modulename.latin1() ]; | 275 | sword::SWModule *module = m_swordMgr->Modules[ modulename.latin1() ]; |
276 | if ( module ) | 276 | if ( module ) |
277 | { | 277 | { |
278 | TextWidget *tw = 0x0; | 278 | TextWidget *tw = 0x0; |
279 | 279 | ||
280 | if ( !m_alwaysOpenNew ) | 280 | if ( !m_alwaysOpenNew ) |
281 | { | 281 | { |
282 | // Try to find if the module is already opened, if so will use that TextWidget | 282 | // Try to find if the module is already opened, if so will use that TextWidget |
283 | QObjectList *childlist = queryList( "TextWidget" ); | 283 | QObjectList *childlist = queryList( "TextWidget" ); |
284 | QObjectListIt it( *childlist ); | 284 | QObjectListIt it( *childlist ); |
285 | while ( ( tw = reinterpret_cast<TextWidget *>(it.current()) ) != 0 && | 285 | while ( ( tw = reinterpret_cast<TextWidget *>(it.current()) ) != 0 && |
286 | tw->getModuleName() != modulename ) | 286 | tw->getModuleName() != modulename ) |
287 | ++it; | 287 | ++it; |
288 | if ( tw && tw->getModuleName() == modulename ) | 288 | if ( tw && tw->getModuleName() == modulename ) |
289 | { | 289 | { |
290 | // Set key if one is present | 290 | // Set key if one is present |
291 | if ( !key.isNull() ) | 291 | if ( !key.isNull() ) |
292 | tw->setKey( key ); | 292 | tw->setKey( key ); |
293 | 293 | ||
294 | // Raise tab | 294 | // Raise tab |
295 | m_tabs.setCurrentTab( tw ); | 295 | m_tabs.setCurrentTab( tw ); |
296 | } | 296 | } |
297 | } | 297 | } |
298 | 298 | ||
299 | if ( m_alwaysOpenNew || !tw ) | 299 | if ( m_alwaysOpenNew || !tw ) |
300 | { | 300 | { |
301 | // Open module in new tab | 301 | // Open module in new tab |
302 | QString icon; | 302 | QString icon; |
303 | QString type = module->Type(); | 303 | QString type = module->Type(); |
304 | 304 | ||
305 | if ( type == "Biblical Texts" ) | 305 | if ( type == "Biblical Texts" ) |
306 | icon = "dagger/bibletext"; | 306 | icon = "dagger/bibletext"; |
307 | else if ( type == "Commentaries" ) | 307 | else if ( type == "Commentaries" ) |
308 | icon = "dagger/commentary"; | 308 | icon = "dagger/commentary"; |
309 | else if ( type == "Lexicons / Dictionaries" ) | 309 | else if ( type == "Lexicons / Dictionaries" ) |
310 | icon = "dagger/lexicon"; | 310 | icon = "dagger/lexicon"; |
311 | 311 | ||
312 | tw = new TextWidget( this, module, m_numVerses, &m_textFont ); | 312 | tw = new TextWidget( this, module, m_numVerses, &m_textFont ); |
313 | connect( tw, SIGNAL(sigRefClicked(const QString &)), | 313 | connect( tw, SIGNAL(sigRefClicked(const QString &)), |
314 | this, SLOT(slotTextRefClicked(const QString &)) ); | 314 | this, SLOT(slotTextRefClicked(const QString &)) ); |
315 | connect( this, SIGNAL(sigNumVersesChanged(int)), tw, SLOT(slotNumVersesChanged(int)) ); | 315 | connect( this, SIGNAL(sigNumVersesChanged(int)), tw, SLOT(slotNumVersesChanged(int)) ); |
316 | connect( this, SIGNAL(sigFontChanged(const QFont *)), tw, SLOT(slotFontChanged(const QFont *)) ); | 316 | connect( this, SIGNAL(sigFontChanged(const QFont *)), tw, SLOT(slotFontChanged(const QFont *)) ); |
317 | connect( this, SIGNAL(sigOptionChanged()), tw, SLOT(slotOptionChanged()) ); | 317 | connect( this, SIGNAL(sigOptionChanged()), tw, SLOT(slotOptionChanged()) ); |
318 | 318 | ||
319 | m_tabs.addTab( tw, icon, modulename ); | 319 | m_tabs.addTab( tw, icon, modulename ); |
320 | 320 | ||
321 | m_actionTextClose->setEnabled( true ); | 321 | m_actionTextClose->setEnabled( true ); |
322 | m_actionEditCopy->setEnabled( true ); | 322 | m_actionEditCopy->setEnabled( true ); |
323 | m_actionBookmarkAdd->setEnabled( true ); | 323 | m_actionBookmarkAdd->setEnabled( true ); |
324 | 324 | ||
325 | // Set key if one is present | 325 | // Set key if one is present |
326 | if ( !key.isNull() ) | 326 | if ( !key.isNull() ) |
327 | tw->setKey( key ); | 327 | tw->setKey( key ); |
328 | setCaption( QString( "%1 - Dagger" ).arg( tw->getFullKey() ) ); | ||
329 | m_navToolbar->setKey( tw->getAbbrevKey() ); | ||
328 | } | 330 | } |
329 | } | 331 | } |
330 | } | 332 | } |
331 | 333 | ||
332 | int MainWindow::findBookmark( const QString &bookmark ) | 334 | int MainWindow::findBookmark( const QString &bookmark ) |
333 | { | 335 | { |
334 | int index = 3; | 336 | int index = 3; |
335 | int id = m_bookmarkMenu->idAt( index ); | 337 | int id = m_bookmarkMenu->idAt( index ); |
336 | while ( ( id != -1 ) && ( m_bookmarkMenu->text( id ) != bookmark ) ) | 338 | while ( ( id != -1 ) && ( m_bookmarkMenu->text( id ) != bookmark ) ) |
337 | { | 339 | { |
338 | ++index; | 340 | ++index; |
339 | id = m_bookmarkMenu->idAt( index ); | 341 | id = m_bookmarkMenu->idAt( index ); |
340 | } | 342 | } |
341 | 343 | ||
342 | return id; | 344 | return id; |
343 | } | 345 | } |
344 | 346 | ||
345 | void MainWindow::enableScreenBlanking( bool enable ) | 347 | void MainWindow::enableScreenBlanking( bool enable ) |
346 | { | 348 | { |
347 | enable ? QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable | 349 | enable ? QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable |
348 | : QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; | 350 | : QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; |
349 | } | 351 | } |
350 | 352 | ||
351 | void MainWindow::initConfig() | 353 | void MainWindow::initConfig() |
352 | { | 354 | { |
353 | bool show; | 355 | bool show; |
354 | 356 | ||
355 | m_config.setGroup( "Sword" ); | 357 | m_config.setGroup( "Sword" ); |
356 | for ( QAction *a = m_actionSwordOpts.first(); a; a = m_actionSwordOpts.next() ) | 358 | for ( QAction *a = m_actionSwordOpts.first(); a; a = m_actionSwordOpts.next() ) |
357 | { | 359 | { |
358 | show = m_config.readBoolEntry( a->text(), false ); | 360 | show = m_config.readBoolEntry( a->text(), false ); |
359 | a->setOn( show ); | 361 | a->setOn( show ); |
360 | m_swordMgr->setGlobalOption ( a->text(), show ? "On" : "Off" ); | 362 | m_swordMgr->setGlobalOption ( a->text(), show ? "On" : "Off" ); |
361 | } | 363 | } |
362 | 364 | ||
363 | // Display/hide toolbars based on last run | 365 | // Display/hide toolbars based on last run |
364 | m_config.setGroup( "Config" ); | 366 | m_config.setGroup( "Config" ); |
365 | 367 | ||
366 | m_alwaysOpenNew = m_config.readBoolEntry( "AlwaysOpenNew", false ); | 368 | m_alwaysOpenNew = m_config.readBoolEntry( "AlwaysOpenNew", false ); |
367 | m_navToolbar->setAutoScrollRate( m_config.readNumEntry( "AutoScroll", 50 ) ); | 369 | m_navToolbar->setAutoScrollRate( m_config.readNumEntry( "AutoScroll", 50 ) ); |
368 | m_disableScreenBlank = m_config.readBoolEntry( "DisableScreenBlanking", false ); | 370 | m_disableScreenBlank = m_config.readBoolEntry( "DisableScreenBlanking", false ); |
369 | enableScreenBlanking( !m_disableScreenBlank ); | 371 | enableScreenBlanking( !m_disableScreenBlank ); |
370 | m_copyFormat = m_config.readNumEntry( "CopyFormat", 0 ); | 372 | m_copyFormat = m_config.readNumEntry( "CopyFormat", 0 ); |
371 | 373 | ||
372 | show = m_config.readBoolEntry( "NavBar", false ); | 374 | show = m_config.readBoolEntry( "NavBar", false ); |
373 | m_actionViewNavToolbar->setOn( show ); | 375 | m_actionViewNavToolbar->setOn( show ); |
374 | slotViewNavToolbar( show ); | 376 | slotViewNavToolbar( show ); |
375 | 377 | ||
376 | m_numVerses = m_config.readNumEntry( "NumVerses", 5 ); | 378 | m_numVerses = m_config.readNumEntry( "NumVerses", 5 ); |
377 | 379 | ||
378 | show = m_config.readBoolEntry( "SearchBar", false ); | 380 | show = m_config.readBoolEntry( "SearchBar", false ); |
379 | m_actionViewSearchToolbar->setOn( show ); | 381 | m_actionViewSearchToolbar->setOn( show ); |
380 | slotViewSearchToolbar( show ); | 382 | slotViewSearchToolbar( show ); |
381 | 383 | ||
382 | // Set text font | 384 | // Set text font |
383 | m_config.setGroup( "Font" ); | 385 | m_config.setGroup( "Font" ); |
384 | QString fontFamily = m_config.readEntry( "Family", QString::null ); | 386 | QString fontFamily = m_config.readEntry( "Family", QString::null ); |
385 | !fontFamily.isNull() ? m_textFont = QFont( fontFamily, | 387 | !fontFamily.isNull() ? m_textFont = QFont( fontFamily, |
386 | m_config.readNumEntry( "Size", -1 ), | 388 | m_config.readNumEntry( "Size", -1 ), |
387 | m_config.readNumEntry( "Weight", QFont::Normal ), | 389 | m_config.readNumEntry( "Weight", QFont::Normal ), |
388 | m_config.readBoolEntry( "Italic", false ) ) | 390 | m_config.readBoolEntry( "Italic", false ) ) |
389 | : m_textFont = font(); // If font is not configured, set to default widget font | 391 | : m_textFont = font(); // If font is not configured, set to default widget font |
390 | 392 | ||
391 | // Load bookmarks | 393 | // Load bookmarks |
392 | m_config.setGroup( "Bookmarks"); | 394 | m_config.setGroup( "Bookmarks"); |
393 | int count = 1; | 395 | int count = 1; |
394 | QString key = m_config.readEntry( QString::number( count ), QString::null ); | 396 | QString key = m_config.readEntry( QString::number( count ), QString::null ); |
395 | while ( !key.isNull() ) | 397 | while ( !key.isNull() ) |
396 | { | 398 | { |
397 | int pos = key.find( "/" ); | 399 | int pos = key.find( "/" ); |
398 | if ( pos > -1 ) | 400 | if ( pos > -1 ) |
399 | { | 401 | { |
400 | QString bookmark; | 402 | QString bookmark; |
401 | bookmark.sprintf( "%s (%s)", key.right( key.length() - ( pos + 1 ) ).latin1(), | 403 | bookmark.sprintf( "%s (%s)", key.right( key.length() - ( pos + 1 ) ).latin1(), |
402 | key.left( pos ).latin1() ); | 404 | key.left( pos ).latin1() ); |
403 | QAction *a = new QAction( bookmark, QString::null, 0, this, 0 ); | 405 | QAction *a = new QAction( bookmark, QString::null, 0, this, 0 ); |
404 | a->addTo( m_bookmarkMenu ); | 406 | a->addTo( m_bookmarkMenu ); |
405 | connect( a, SIGNAL(activated()), this, SLOT(slotBookmarkSelected()) ); | 407 | connect( a, SIGNAL(activated()), this, SLOT(slotBookmarkSelected()) ); |
406 | } | 408 | } |
407 | 409 | ||
408 | ++count; | 410 | ++count; |
409 | key = m_config.readEntry( QString::number( count ), QString::null ); | 411 | key = m_config.readEntry( QString::number( count ), QString::null ); |
410 | } | 412 | } |
411 | m_actionBookmarkRemove->setEnabled( count > 1 ); | 413 | m_actionBookmarkRemove->setEnabled( count > 1 ); |
412 | 414 | ||
413 | // Load opened modules | 415 | // Load opened modules |
414 | m_config.setGroup( "Session"); | 416 | m_config.setGroup( "Session"); |
415 | QString first; | 417 | QString first; |
416 | count = 1; | 418 | count = 1; |
417 | key = m_config.readEntry( QString::number( count ), QString::null ); | 419 | key = m_config.readEntry( QString::number( count ), QString::null ); |
418 | while ( !key.isNull() ) | 420 | while ( !key.isNull() ) |
419 | { | 421 | { |
420 | int pos = key.find( "/" ); | 422 | int pos = key.find( "/" ); |
421 | if ( pos > -1 ) | 423 | if ( pos > -1 ) |
422 | { | 424 | { |
423 | if ( count == 1 ) | 425 | if ( count == 1 ) |
424 | first = key.left( pos ); | 426 | first = key.left( pos ); |
425 | openModule( key.left( pos ), key.right( key.length() - ( pos + 1 ) ) ); | 427 | openModule( key.left( pos ), key.right( key.length() - ( pos + 1 ) ) ); |
426 | } | 428 | } |
427 | 429 | ||
428 | ++count; | 430 | ++count; |
429 | key = m_config.readEntry( QString::number( count ), QString::null ); | 431 | key = m_config.readEntry( QString::number( count ), QString::null ); |
430 | } | 432 | } |
431 | m_tabs.setCurrentTab( first ); | 433 | m_tabs.setCurrentTab( first ); |
432 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); | 434 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); |
433 | if ( text ) | 435 | if ( text ) |
434 | { | 436 | { |
435 | setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) ); | 437 | setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) ); |
436 | m_navToolbar->setKey( text->getAbbrevKey() ); | 438 | m_navToolbar->setKey( text->getAbbrevKey() ); |
437 | } | 439 | } |
438 | m_actionTextClose->setEnabled( count > 1 ); | 440 | m_actionTextClose->setEnabled( count > 1 ); |
439 | m_actionEditCopy->setEnabled( count > 1 ); | 441 | m_actionEditCopy->setEnabled( count > 1 ); |
440 | } | 442 | } |
441 | 443 | ||
442 | void MainWindow::slotTextDisplayed( QWidget *textWidget ) | 444 | void MainWindow::slotTextDisplayed( QWidget *textWidget ) |
443 | { | 445 | { |
444 | TextWidget *text = reinterpret_cast<TextWidget *>(textWidget); | 446 | TextWidget *text = reinterpret_cast<TextWidget *>(textWidget); |
445 | setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) ); | 447 | setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) ); |
446 | 448 | ||
447 | m_navToolbar->setKey( text->getAbbrevKey() ); | 449 | m_navToolbar->setKey( text->getAbbrevKey() ); |
448 | m_navToolbar->navBtnsEnable( text->isBibleText() ); | 450 | m_navToolbar->navBtnsEnable( text->isBibleText() ); |
449 | 451 | ||
450 | m_searchToolbar->setCurrModule( text ); | 452 | m_searchToolbar->setCurrModule( text ); |
451 | } | 453 | } |
452 | 454 | ||
453 | void MainWindow::slotTextOpen() | 455 | void MainWindow::slotTextOpen() |
454 | { | 456 | { |
455 | OpenTextDlg dlg( this, m_swordMgr, m_bibleIcon, m_commentaryIcon, m_lexiconIcon ); | 457 | OpenTextDlg dlg( this, m_swordMgr, m_bibleIcon, m_commentaryIcon, m_lexiconIcon ); |
456 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) | 458 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) |
457 | { | 459 | { |
458 | openModule( dlg.selectedText() ); | 460 | openModule( dlg.selectedText() ); |
459 | } | 461 | } |
460 | } | 462 | } |
461 | 463 | ||
462 | void MainWindow::slotTextClose() | 464 | void MainWindow::slotTextClose() |
463 | { | 465 | { |
464 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); | 466 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); |
465 | if ( text ) | 467 | if ( text ) |
466 | { | 468 | { |
467 | m_tabs.removePage( text ); | 469 | m_tabs.removePage( text ); |
468 | delete text; | 470 | delete text; |
469 | 471 | ||
470 | // If no other modules are open, disable appropriate UI items | 472 | // If no other modules are open, disable appropriate UI items |
471 | if ( !m_tabs.currentWidget() ) | 473 | if ( !m_tabs.currentWidget() ) |
472 | { | 474 | { |
473 | m_navToolbar->navBtnsEnable( false ); | 475 | m_navToolbar->navBtnsEnable( false ); |
474 | m_navToolbar->setKey( QString::null ); | 476 | m_navToolbar->setKey( QString::null ); |
475 | m_searchToolbar->setCurrModule( 0x0 ); | 477 | m_searchToolbar->setCurrModule( 0x0 ); |
476 | m_actionTextClose->setEnabled( false ); | 478 | m_actionTextClose->setEnabled( false ); |
477 | m_actionEditCopy->setEnabled( false ); | 479 | m_actionEditCopy->setEnabled( false ); |
478 | m_actionBookmarkAdd->setEnabled( false ); | 480 | m_actionBookmarkAdd->setEnabled( false ); |
479 | m_actionBookmarkRemove->setEnabled( false ); | 481 | m_actionBookmarkRemove->setEnabled( false ); |
480 | } | 482 | } |
481 | } | 483 | } |
482 | } | 484 | } |
483 | 485 | ||
484 | void MainWindow::slotTextInstall() | 486 | void MainWindow::slotTextInstall() |
485 | { | 487 | { |
486 | } | 488 | } |
487 | 489 | ||
488 | void MainWindow::slotEditCopy() | 490 | void MainWindow::slotEditCopy() |
489 | { | 491 | { |
490 | TextWidget *currModule = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); | 492 | TextWidget *currModule = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); |
491 | if ( currModule ) | 493 | if ( currModule ) |
492 | { | 494 | { |
493 | QString text; | 495 | QString text; |
494 | 496 | ||
495 | switch( m_copyFormat ) | 497 | switch( m_copyFormat ) |
496 | { | 498 | { |
497 | case 0: text.sprintf( "%s (%s, %s)", currModule->getCurrVerse().latin1(), | 499 | case 0: text.sprintf( "%s (%s, %s)", currModule->getCurrVerse().latin1(), |
498 | currModule->getAbbrevKey().latin1(), | 500 | currModule->getAbbrevKey().latin1(), |
499 | currModule->getModuleName().latin1() ); | 501 | currModule->getModuleName().latin1() ); |
500 | break; | 502 | break; |
501 | case 1: text.sprintf( "%s (%s)", currModule->getCurrVerse().latin1(), | 503 | case 1: text.sprintf( "%s (%s)", currModule->getCurrVerse().latin1(), |
502 | currModule->getAbbrevKey().latin1() ); | 504 | currModule->getAbbrevKey().latin1() ); |
503 | break; | 505 | break; |
504 | case 2: text = currModule->getCurrVerse(); | 506 | case 2: text = currModule->getCurrVerse(); |
505 | break; | 507 | break; |
506 | case 3: text = currModule->getAbbrevKey(); | 508 | case 3: text = currModule->getAbbrevKey(); |
507 | break; | 509 | break; |
508 | default: text = QString::null; | 510 | default: text = QString::null; |
509 | }; | 511 | }; |
510 | 512 | ||
511 | if ( !text.isNull() ) | 513 | if ( !text.isNull() ) |
512 | QPEApplication::clipboard()->setText( text ); | 514 | QPEApplication::clipboard()->setText( text ); |
513 | } | 515 | } |
514 | } | 516 | } |
515 | 517 | ||
516 | void MainWindow::slotEditConfigure() | 518 | void MainWindow::slotEditConfigure() |
517 | { | 519 | { |
518 | ConfigureDlg dlg( this, m_modulePath, m_alwaysOpenNew, m_numVerses, m_disableScreenBlank, m_copyFormat, | 520 | ConfigureDlg dlg( this, m_modulePath, m_alwaysOpenNew, m_numVerses, m_disableScreenBlank, m_copyFormat, |
519 | &m_textFont ); | 521 | &m_textFont ); |
520 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) | 522 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) |
521 | { | 523 | { |
522 | m_modulePath = dlg.swordPath(); | 524 | m_modulePath = dlg.swordPath(); |
523 | m_alwaysOpenNew = dlg.alwaysOpenNew(); | 525 | m_alwaysOpenNew = dlg.alwaysOpenNew(); |
524 | if ( dlg.numVerses() != m_numVerses ) | 526 | if ( dlg.numVerses() != m_numVerses ) |
525 | { | 527 | { |
526 | m_numVerses = dlg.numVerses(); | 528 | m_numVerses = dlg.numVerses(); |
527 | emit sigNumVersesChanged( m_numVerses ); | 529 | emit sigNumVersesChanged( m_numVerses ); |
528 | } | 530 | } |
529 | m_disableScreenBlank = dlg.screenBlank(); | 531 | m_disableScreenBlank = dlg.screenBlank(); |
530 | enableScreenBlanking( !m_disableScreenBlank ); | 532 | enableScreenBlanking( !m_disableScreenBlank ); |
531 | m_copyFormat = dlg.copyFormat(); | 533 | m_copyFormat = dlg.copyFormat(); |
532 | m_textFont = dlg.selectedFont(); | 534 | m_textFont = dlg.selectedFont(); |
533 | emit sigFontChanged( &m_textFont ); | 535 | emit sigFontChanged( &m_textFont ); |
534 | } | 536 | } |
535 | } | 537 | } |
536 | 538 | ||
537 | void MainWindow::slotBookmarkAdd() | 539 | void MainWindow::slotBookmarkAdd() |
538 | { | 540 | { |
539 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); | 541 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); |
540 | if ( text ) | 542 | if ( text ) |
541 | { | 543 | { |
542 | // See if bookmark doesn't already exists | 544 | // See if bookmark doesn't already exists |
543 | QString bookmark = text->getFullKey(); | 545 | QString bookmark = text->getFullKey(); |
544 | int menuId = findBookmark( bookmark ); | 546 | int menuId = findBookmark( bookmark ); |
545 | if ( menuId == -1 ) | 547 | if ( menuId == -1 ) |
546 | { | 548 | { |
547 | // Bookmark not found, add | 549 | // Bookmark not found, add |
548 | QAction *a = new QAction( bookmark, QString::null, 0, this, 0 ); | 550 | QAction *a = new QAction( bookmark, QString::null, 0, this, 0 ); |
549 | a->addTo( m_bookmarkMenu ); | 551 | a->addTo( m_bookmarkMenu ); |
550 | connect( a, SIGNAL(activated()), this, SLOT(slotBookmarkSelected()) ); | 552 | connect( a, SIGNAL(activated()), this, SLOT(slotBookmarkSelected()) ); |
551 | 553 | ||
552 | // Make sure remove option is enabled | 554 | // Make sure remove option is enabled |
553 | m_actionBookmarkRemove->setEnabled( true ); | 555 | m_actionBookmarkRemove->setEnabled( true ); |
554 | 556 | ||
555 | } | 557 | } |
556 | } | 558 | } |
557 | } | 559 | } |
558 | 560 | ||
559 | void MainWindow::slotBookmarkRemove() | 561 | void MainWindow::slotBookmarkRemove() |
560 | { | 562 | { |
561 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); | 563 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); |
562 | if ( text ) | 564 | if ( text ) |
563 | { | 565 | { |
564 | // See if bookmark exists for current module key | 566 | // See if bookmark exists for current module key |
565 | int menuId = findBookmark( text->getFullKey() ); | 567 | int menuId = findBookmark( text->getFullKey() ); |
566 | if ( menuId != -1 ) | 568 | if ( menuId != -1 ) |
567 | { | 569 | { |
568 | // Bookmark found, remove | 570 | // Bookmark found, remove |
569 | m_bookmarkMenu->removeItem( menuId ); | 571 | m_bookmarkMenu->removeItem( menuId ); |
570 | 572 | ||
571 | //If this was the last bookmark, disable the remove option | 573 | //If this was the last bookmark, disable the remove option |
572 | if ( m_bookmarkMenu->idAt( 3 ) == -1 ) | 574 | if ( m_bookmarkMenu->idAt( 3 ) == -1 ) |
573 | m_actionBookmarkRemove->setEnabled( false ); | 575 | m_actionBookmarkRemove->setEnabled( false ); |
574 | } | 576 | } |
575 | } | 577 | } |
576 | } | 578 | } |
577 | 579 | ||
578 | void MainWindow::slotBookmarkSelected() | 580 | void MainWindow::slotBookmarkSelected() |
579 | { | 581 | { |
580 | const QAction *action = reinterpret_cast<const QAction *>(sender()); | 582 | const QAction *action = reinterpret_cast<const QAction *>(sender()); |
581 | if ( action ) | 583 | if ( action ) |
582 | { | 584 | { |
583 | QString bookmark = action->text(); | 585 | QString bookmark = action->text(); |
584 | int pos = bookmark.find( " (" ); | 586 | int pos = bookmark.find( " (" ); |
585 | QString key = bookmark.left( pos ); | 587 | QString key = bookmark.left( pos ); |
586 | pos += 2; | 588 | pos += 2; |
587 | QString module = bookmark.mid( pos, bookmark.find( ")", pos ) - pos ); | 589 | QString module = bookmark.mid( pos, bookmark.find( ")", pos ) - pos ); |
588 | 590 | ||
589 | openModule( module, key ); | 591 | openModule( module, key ); |
590 | } | 592 | } |
591 | } | 593 | } |
592 | 594 | ||
593 | void MainWindow::slotViewSwordOption( bool enabled ) | 595 | void MainWindow::slotViewSwordOption( bool enabled ) |
594 | { | 596 | { |
595 | const QAction *action = reinterpret_cast<const QAction*>(sender()); | 597 | const QAction *action = reinterpret_cast<const QAction*>(sender()); |
596 | m_swordMgr->setGlobalOption ( action->text(), enabled ? "On" : "Off" ); | 598 | m_swordMgr->setGlobalOption ( action->text(), enabled ? "On" : "Off" ); |
597 | 599 | ||
598 | emit sigOptionChanged(); | 600 | emit sigOptionChanged(); |
599 | } | 601 | } |
600 | 602 | ||
601 | void MainWindow::slotViewNavToolbar( bool enabled ) | 603 | void MainWindow::slotViewNavToolbar( bool enabled ) |
602 | { | 604 | { |
603 | enabled ? m_navToolbar->show() | 605 | enabled ? m_navToolbar->show() |
604 | : m_navToolbar->hide(); | 606 | : m_navToolbar->hide(); |
605 | } | 607 | } |
606 | 608 | ||
607 | void MainWindow::slotViewSearchToolbar( bool enabled ) | 609 | void MainWindow::slotViewSearchToolbar( bool enabled ) |
608 | { | 610 | { |
609 | enabled ? m_searchToolbar->show() | 611 | enabled ? m_searchToolbar->show() |
610 | : m_searchToolbar->hide(); | 612 | : m_searchToolbar->hide(); |
611 | } | 613 | } |
612 | 614 | ||
613 | void MainWindow::slotNavPrevPage() | 615 | void MainWindow::slotNavPrevPage() |
614 | { | 616 | { |
615 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); | 617 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); |
616 | if ( text ) | 618 | if ( text ) |
617 | { | 619 | { |
618 | text->prevPage(); | 620 | text->prevPage(); |
619 | setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) ); | 621 | setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) ); |
620 | m_navToolbar->setKey( text->getAbbrevKey() ); | 622 | m_navToolbar->setKey( text->getAbbrevKey() ); |
621 | } | 623 | } |
622 | } | 624 | } |
623 | 625 | ||
624 | void MainWindow::slotNavPrevVerse() | 626 | void MainWindow::slotNavPrevVerse() |
625 | { | 627 | { |
626 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); | 628 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); |
627 | if ( text ) | 629 | if ( text ) |
628 | { | 630 | { |
629 | text->prevVerse(); | 631 | text->prevVerse(); |
630 | setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) ); | 632 | setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) ); |
631 | m_navToolbar->setKey( text->getAbbrevKey() ); | 633 | m_navToolbar->setKey( text->getAbbrevKey() ); |
632 | } | 634 | } |
633 | } | 635 | } |
634 | 636 | ||
635 | void MainWindow::slotNavKeyChanged( const QString &newKey ) | 637 | void MainWindow::slotNavKeyChanged( const QString &newKey ) |
636 | { | 638 | { |
637 | QString key = newKey; | ||
638 | key.replace( QRegExp( "[-=.]" ), ":" ); | ||
639 | |||
640 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); | 639 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); |
641 | if ( text ) | 640 | if ( text ) |
642 | { | 641 | { |
642 | QString key = newKey; | ||
643 | if ( text->isBibleText() ) | ||
644 | key.replace( QRegExp( "[-=.]" ), ":" ); | ||
645 | |||
643 | text->setKey( key ); | 646 | text->setKey( key ); |
644 | setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) ); | 647 | setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) ); |
645 | } | 648 | } |
646 | } | 649 | } |
647 | 650 | ||
648 | void MainWindow::slotNavNextVerse() | 651 | void MainWindow::slotNavNextVerse() |
649 | { | 652 | { |
650 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); | 653 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); |
651 | if ( text ) | 654 | if ( text ) |
652 | { | 655 | { |
653 | text->nextVerse(); | 656 | text->nextVerse(); |
654 | setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) ); | 657 | setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) ); |
655 | m_navToolbar->setKey( text->getAbbrevKey() ); | 658 | m_navToolbar->setKey( text->getAbbrevKey() ); |
656 | } | 659 | } |
657 | } | 660 | } |
658 | 661 | ||
659 | void MainWindow::slotNavNextPage() | 662 | void MainWindow::slotNavNextPage() |
660 | { | 663 | { |
661 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); | 664 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); |
662 | if ( text ) | 665 | if ( text ) |
663 | { | 666 | { |
664 | text->nextPage(); | 667 | text->nextPage(); |
665 | setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) ); | 668 | setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) ); |
666 | m_navToolbar->setKey( text->getAbbrevKey() ); | 669 | m_navToolbar->setKey( text->getAbbrevKey() ); |
667 | } | 670 | } |
668 | } | 671 | } |
669 | 672 | ||
670 | void MainWindow::slotNavAutoScroll( bool enabled ) | 673 | void MainWindow::slotNavAutoScroll( bool enabled ) |
671 | { | 674 | { |
672 | m_autoScrollTimer.stop(); | 675 | m_autoScrollTimer.stop(); |
673 | 676 | ||
674 | if ( enabled ) | 677 | if ( enabled ) |
675 | m_autoScrollTimer.start( m_navToolbar->autoScrollRate() * 100 ); | 678 | m_autoScrollTimer.start( m_navToolbar->autoScrollRate() * 100 ); |
676 | } | 679 | } |
677 | 680 | ||
678 | void MainWindow::slotNavScrollRateChanged( int newRate ) | 681 | void MainWindow::slotNavScrollRateChanged( int newRate ) |
679 | { | 682 | { |
680 | if ( m_autoScrollTimer.isActive() ) | 683 | if ( m_autoScrollTimer.isActive() ) |
681 | { | 684 | { |
682 | m_autoScrollTimer.stop(); | 685 | m_autoScrollTimer.stop(); |
683 | m_autoScrollTimer.start( newRate * 100 ); | 686 | m_autoScrollTimer.start( newRate * 100 ); |
684 | } | 687 | } |
685 | } | 688 | } |
686 | 689 | ||
687 | void MainWindow::slotSearchResultClicked( const QString &key ) | 690 | void MainWindow::slotSearchResultClicked( const QString &key ) |
688 | { | 691 | { |
689 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); | 692 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); |
690 | if ( text ) | 693 | if ( text ) |
691 | { | 694 | { |
692 | text->setKey( key ); | 695 | text->setKey( key ); |
693 | setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) ); | 696 | setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) ); |
694 | m_navToolbar->setKey( text->getAbbrevKey() ); | 697 | m_navToolbar->setKey( text->getAbbrevKey() ); |
695 | } | 698 | } |
696 | } | 699 | } |
697 | 700 | ||
698 | void MainWindow::slotTextRefClicked( const QString &ref ) | 701 | void MainWindow::slotTextRefClicked( const QString &ref ) |
699 | { | 702 | { |
700 | //printf( "Ref clicked: '%s'\n", ref.latin1() ); | 703 | //printf( "Ref clicked: '%s'\n", ref.latin1() ); |
701 | /* | 704 | /* |
702 | Ref clicked: 'type=Strongs value=G3482' | 705 | Ref clicked: 'passagestudy.jsp?action=showStrongs&type=Hebrew&value=07225' |
703 | Ref clicked: 'type=Strongs value=H07225' | 706 | Ref clicked: 'passagestudy.jsp?action=showStrongs&type=Greek&value=602' |
704 | Ref clicked: 'type=morph class=x-Robinson:N-PRI value=N-PRI' | 707 | Ref clicked: 'passagestudy.jsp?action=showMorph&type=x-Robinson%3AN-NSF&value=N-NSF' |
705 | Ref clicked: 'type=morph class=x-StrongsMorph:TH8804 value=TH8804' | 708 | Ref clicked: 'passagestudy.jsp?action=showNote&type=n&value=1&module=KJV&passage=Genesis+1%3A5' |
706 | */ | 709 | */ |
707 | //owarn << "Reference: " << ref << oendl; | 710 | //owarn << "Reference: " << ref << oendl; |
708 | if ( !ref.isNull() ) | 711 | if ( !ref.isNull() ) |
709 | { | 712 | { |
710 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); | 713 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); |
711 | if ( text ) | 714 | if ( text ) |
712 | { | 715 | { |
716 | // Parse action | ||
717 | int pos = ref.find( '&', 28 ); | ||
718 | QString actionStr = ref.mid( 28, pos - 28 ); | ||
719 | |||
713 | // Parse type | 720 | // Parse type |
714 | int pos = ref.find( "type=", 0, false ) + 5; | 721 | pos = ref.find( "type=", pos, false ) + 5; |
715 | QString typeStr = ref.mid( pos, ref.find( ' ', pos ) - pos ); | 722 | QString typeStr = ref.mid( pos, ref.find( '&', pos ) - pos ); |
716 | 723 | ||
717 | // Parse class (for morph. only) | ||
718 | QString classStr; | ||
719 | if ( typeStr == "morph" ) | ||
720 | { | ||
721 | pos = ref.find( "class=", 0, false ) + 5; | ||
722 | QString classStr = ref.mid( pos, ref.find( ' ', pos ) - pos ); | ||
723 | |||
724 | // TODO - need to strip 'x-' from beginning and ':key' at end? | ||
725 | } | ||
726 | |||
727 | // Parse value | 724 | // Parse value |
728 | pos = ref.find( "value=", 0, false ) + 6; | 725 | pos = ref.find( "value=", 0, false ) + 6; |
729 | QString valueStr = ref.mid( pos, ref.find( ' ', pos ) - pos ); | 726 | QString valueStr = ref.mid( pos, ref.find( ' ', pos ) - pos ); |
730 | 727 | ||
731 | if ( typeStr == "Strongs" ) | 728 | if ( actionStr == "Strongs" ) |
729 | { | ||
730 | QString module = actionStr; | ||
731 | module.append( typeStr ); | ||
732 | |||
733 | // Open reference | ||
734 | openModule( module, valueStr ); | ||
735 | } | ||
736 | else if ( actionStr == "Morph" ) | ||
732 | { | 737 | { |
733 | //Determine if is a Hebrew or Greek reference | 738 | QString module = typeStr.mid( 2, typeStr.find( '%', 2 ) - 2 ); |
734 | QString module; | 739 | |
735 | if ( valueStr.at( 0 ) == 'H' ) | ||
736 | module = "StrongsHebrew"; | ||
737 | else | ||
738 | module = "StrongsGreek"; | ||
739 | |||
740 | // Get key | ||
741 | QString key( valueStr ); | ||
742 | key.remove( 0, 1 ); | ||
743 | // Open reference | 740 | // Open reference |
744 | openModule( module, key ); | 741 | openModule( module, valueStr ); |
745 | } | 742 | } |
746 | else if ( typeStr == "morph" ) | 743 | else if ( actionStr == "Note" ) |
747 | { | 744 | { |
748 | QMessageBox::information( this, tr( "Morphological Tags" ), | 745 | // TODO |
749 | tr( "Morphological tag cross-referencing not implemented yet." ) ); | ||
750 | } | 746 | } |
751 | } | 747 | } |
752 | } | 748 | } |
753 | } | 749 | } |
diff --git a/noncore/apps/dagger/opie-dagger.control b/noncore/apps/dagger/opie-dagger.control index 4ded1f2..e613ddb 100644 --- a/noncore/apps/dagger/opie-dagger.control +++ b/noncore/apps/dagger/opie-dagger.control | |||
@@ -1,9 +1,9 @@ | |||
1 | Package: opie-dagger | 1 | Package: opie-dagger |
2 | Files: plugins/application/libdagger.so* bin/dagger pics/dagger apps/Applications/dagger.desktop | 2 | Files: plugins/application/libdagger.so* bin/dagger pics/dagger apps/Applications/dagger.desktop |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/applications | 4 | Section: opie/applications |
5 | Depends: task-opie-minimal, libopiecore2, libopieui2 | 5 | Depends: task-opie-minimal, libopiecore2, libopieui2 |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Maintainer: Dan Williams (drw@handhelds.org) | 7 | Maintainer: Dan Williams (drw@handhelds.org) |
8 | Description: A Bible study program utilizing the Sword library. | 8 | Description: A Bible study program utilizing the Sword library. |
9 | Version: 0.9.1$EXTRAVERSION | 9 | Version: 0.9.2$EXTRAVERSION |
diff --git a/noncore/apps/dagger/searchbar.cpp b/noncore/apps/dagger/searchbar.cpp index b195f67..463a19f 100644 --- a/noncore/apps/dagger/searchbar.cpp +++ b/noncore/apps/dagger/searchbar.cpp | |||
@@ -1,182 +1,182 @@ | |||
1 | /* | 1 | /* |
2 | Dagger - A Bible study program utilizing the Sword library. | 2 | Dagger - A Bible study program utilizing the Sword library. |
3 | Copyright (c) 2004 Dan Williams <drw@handhelds.org> | 3 | Copyright (c) 2004 Dan Williams <drw@handhelds.org> |
4 | 4 | ||
5 | This file is free software; you can redistribute it and/or modify it under | 5 | This file is free software; you can redistribute it and/or modify it under |
6 | the terms of the GNU General Public License as published by the Free Software | 6 | the terms of the GNU General Public License as published by the Free Software |
7 | Foundation; either version 2 of the License, or (at your option) any later version. | 7 | Foundation; either version 2 of the License, or (at your option) any later version. |
8 | 8 | ||
9 | This file is distributed in the hope that it will be useful, but WITHOUT ANY | 9 | This file is distributed in the hope that it will be useful, but WITHOUT ANY |
10 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | 10 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
11 | PARTICULAR PURPOSE. See the GNU General Public License for more details. | 11 | PARTICULAR PURPOSE. See the GNU General Public License for more details. |
12 | 12 | ||
13 | You should have received a copy of the GNU General Public License along with this | 13 | You should have received a copy of the GNU General Public License along with this |
14 | file; see the file COPYING. If not, write to the Free Software Foundation, Inc., | 14 | file; see the file COPYING. If not, write to the Free Software Foundation, Inc., |
15 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 15 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include "searchbar.h" | 18 | #include "searchbar.h" |
19 | #include "textwidget.h" | 19 | #include "textwidget.h" |
20 | 20 | ||
21 | #include <opie2/oresource.h> | 21 | #include <opie2/oresource.h> |
22 | #include <opie2/owait.h> | 22 | #include <opie2/owait.h> |
23 | 23 | ||
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | 25 | ||
26 | #include <qaction.h> | 26 | #include <qaction.h> |
27 | #include <qcombobox.h> | 27 | #include <qcombobox.h> |
28 | #include <qlineedit.h> | 28 | #include <qlineedit.h> |
29 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
30 | 30 | ||
31 | #include <listkey.h> | 31 | #include <listkey.h> |
32 | #include <regex.h> | 32 | #include <regex.h> |
33 | #include <versekey.h> | 33 | #include <versekey.h> |
34 | 34 | ||
35 | void searchCallback( char /*percent*/, void */*userData*/ ) | 35 | void searchCallback( char /*percent*/, void */*userData*/ ) |
36 | { | 36 | { |
37 | qApp->processEvents(); | 37 | qApp->processEvents(); |
38 | } | 38 | } |
39 | 39 | ||
40 | SearchBar::SearchBar( QMainWindow *parent ) | 40 | SearchBar::SearchBar( QMainWindow *parent ) |
41 | : QToolBar( QString::null, parent, QMainWindow::Top, true ) | 41 | : QToolBar( QString::null, parent, QMainWindow::Top, true ) |
42 | , m_currText( 0x0 ) | 42 | , m_currText( 0x0 ) |
43 | { | 43 | { |
44 | // Initialize UI | 44 | // Initialize UI |
45 | m_searchText = new QLineEdit( this ); | 45 | m_searchText = new QLineEdit( this ); |
46 | setStretchableWidget( m_searchText ); | 46 | setStretchableWidget( m_searchText ); |
47 | QWhatsThis::add( m_searchText, tr( "Enter text to search for here." ) ); | 47 | QWhatsThis::add( m_searchText, tr( "Enter text to search for here." ) ); |
48 | connect(m_searchText, SIGNAL(textChanged(const QString &)), | 48 | connect(m_searchText, SIGNAL(textChanged(const QString &)), |
49 | this, SLOT(slotTextChanged(const QString &)) ); | 49 | this, SLOT(slotTextChanged(const QString &)) ); |
50 | 50 | ||
51 | m_actionFind = new QAction( tr( "Find" ), | 51 | m_actionFind = new QAction( tr( "Find" ), |
52 | Opie::Core::OResource::loadPixmap( "find", Opie::Core::OResource::SmallIcon ), | 52 | Opie::Core::OResource::loadPixmap( "find", Opie::Core::OResource::SmallIcon ), |
53 | QString::null, 0, this, 0 ); | 53 | QString::null, 0, this, 0 ); |
54 | m_actionFind->setEnabled( false ); | 54 | m_actionFind->setEnabled( false ); |
55 | m_actionFind->addTo( this ); | 55 | m_actionFind->addTo( this ); |
56 | m_actionFind->setWhatsThis( tr( "Tap here search the current module for the text entered to the left." ) ); | 56 | m_actionFind->setWhatsThis( tr( "Tap here search the current module for the text entered to the left." ) ); |
57 | connect( m_actionFind, SIGNAL(activated()), this, SLOT(slotFind()) ); | 57 | connect( m_actionFind, SIGNAL(activated()), this, SLOT(slotFind()) ); |
58 | 58 | ||
59 | addSeparator(); | 59 | addSeparator(); |
60 | 60 | ||
61 | m_actionPrev = new QAction( tr( "Previous result" ), | 61 | m_actionPrev = new QAction( tr( "Previous result" ), |
62 | Opie::Core::OResource::loadPixmap( "back", Opie::Core::OResource::SmallIcon ), | 62 | Opie::Core::OResource::loadPixmap( "back", Opie::Core::OResource::SmallIcon ), |
63 | QString::null, 0, this, 0 ); | 63 | QString::null, 0, this, 0 ); |
64 | m_actionPrev->setEnabled( false ); | 64 | m_actionPrev->setEnabled( false ); |
65 | m_actionPrev->addTo( this ); | 65 | m_actionPrev->addTo( this ); |
66 | m_actionPrev->setWhatsThis( tr( "Tap here to view the previous search result." ) ); | 66 | m_actionPrev->setWhatsThis( tr( "Tap here to view the previous search result." ) ); |
67 | connect( m_actionPrev, SIGNAL(activated()), this, SLOT(slotPrev()) ); | 67 | connect( m_actionPrev, SIGNAL(activated()), this, SLOT(slotPrev()) ); |
68 | 68 | ||
69 | m_resultList = new QComboBox( this ); | 69 | m_resultList = new QComboBox( this ); |
70 | m_resultList->setEnabled( false ); | 70 | m_resultList->setEnabled( false ); |
71 | QWhatsThis::add( m_resultList, tr( "Select the desired search result here." ) ); | 71 | QWhatsThis::add( m_resultList, tr( "Select the desired search result here." ) ); |
72 | connect( m_resultList, SIGNAL(activated(const QString &)), this, SIGNAL(sigResultClicked(const QString &)) ); | 72 | connect( m_resultList, SIGNAL(activated(const QString &)), this, SIGNAL(sigResultClicked(const QString &)) ); |
73 | 73 | ||
74 | m_actionNext = new QAction( tr( "Next result" ), | 74 | m_actionNext = new QAction( tr( "Next result" ), |
75 | Opie::Core::OResource::loadPixmap( "forward", Opie::Core::OResource::SmallIcon ), | 75 | Opie::Core::OResource::loadPixmap( "forward", Opie::Core::OResource::SmallIcon ), |
76 | QString::null, 0, this, 0 ); | 76 | QString::null, 0, this, 0 ); |
77 | m_actionNext->setEnabled( false ); | 77 | m_actionNext->setEnabled( false ); |
78 | m_actionNext->addTo( this ); | 78 | m_actionNext->addTo( this ); |
79 | m_actionNext->setWhatsThis( tr( "Tap here to view the next search result." ) ); | 79 | m_actionNext->setWhatsThis( tr( "Tap here to view the next search result." ) ); |
80 | connect( m_actionNext, SIGNAL(activated()), this, SLOT(slotNext()) ); | 80 | connect( m_actionNext, SIGNAL(activated()), this, SLOT(slotNext()) ); |
81 | 81 | ||
82 | if ( parent ) | 82 | if ( parent ) |
83 | { | 83 | { |
84 | installEventFilter( parent ); | 84 | installEventFilter( parent ); |
85 | // TODO - install for all controls | 85 | // TODO - install for all controls |
86 | m_searchText->installEventFilter( parent ); | 86 | m_searchText->installEventFilter( parent ); |
87 | } | 87 | } |
88 | } | 88 | } |
89 | 89 | ||
90 | void SearchBar::setCurrModule( TextWidget *currText ) | 90 | void SearchBar::setCurrModule( TextWidget *currText ) |
91 | { | 91 | { |
92 | m_actionFind->setEnabled( ( m_searchText->text() != "" ) && currText ); | 92 | m_actionFind->setEnabled( ( m_searchText->text() != "" ) && currText ); |
93 | 93 | ||
94 | if ( !m_currText || ( currText->getModuleName() != m_currText->getModuleName() ) ) | 94 | if ( !m_currText || !currText || ( currText->getModuleName() != m_currText->getModuleName() ) ) |
95 | { | 95 | { |
96 | m_actionPrev->setEnabled( false ); | 96 | m_actionPrev->setEnabled( false ); |
97 | m_resultList->clear(); | 97 | m_resultList->clear(); |
98 | m_resultList->setEnabled( false ); | 98 | m_resultList->setEnabled( false ); |
99 | m_actionNext->setEnabled( false ); | 99 | m_actionNext->setEnabled( false ); |
100 | } | 100 | } |
101 | 101 | ||
102 | m_currText = currText; | 102 | m_currText = currText; |
103 | } | 103 | } |
104 | 104 | ||
105 | void SearchBar::slotTextChanged( const QString &newText ) | 105 | void SearchBar::slotTextChanged( const QString &newText ) |
106 | { | 106 | { |
107 | m_actionFind->setEnabled( ( newText != "" ) && m_currText ); | 107 | m_actionFind->setEnabled( ( newText != "" ) && m_currText ); |
108 | } | 108 | } |
109 | 109 | ||
110 | void SearchBar::slotFind() | 110 | void SearchBar::slotFind() |
111 | { | 111 | { |
112 | m_resultList->clear(); | 112 | m_resultList->clear(); |
113 | 113 | ||
114 | // Change application title and display Opie wait dialog to indicate search is beginning | 114 | // Change application title and display Opie wait dialog to indicate search is beginning |
115 | QWidget *pWidget = reinterpret_cast<QWidget *>(parent()); | 115 | QWidget *pWidget = reinterpret_cast<QWidget *>(parent()); |
116 | QString caption = pWidget->caption(); | 116 | QString caption = pWidget->caption(); |
117 | pWidget->setCaption( "Searching..." ); | 117 | pWidget->setCaption( "Searching..." ); |
118 | 118 | ||
119 | Opie::Ui::OWait wait( pWidget ); | 119 | Opie::Ui::OWait wait( pWidget ); |
120 | wait.show(); | 120 | wait.show(); |
121 | qApp->processEvents(); | 121 | qApp->processEvents(); |
122 | 122 | ||
123 | // Perform search | 123 | // Perform search |
124 | // TODO - implement search callback function to animate wait cursor | 124 | // TODO - implement search callback function to animate wait cursor |
125 | sword::ListKey results = m_currText->getModule()->Search( m_searchText->text().latin1(), 0, REG_ICASE, 0, 0, | 125 | sword::ListKey results = m_currText->getModule()->Search( m_searchText->text().latin1(), 0, REG_ICASE, 0, 0, |
126 | &searchCallback ); | 126 | &searchCallback ); |
127 | 127 | ||
128 | // Process results | 128 | // Process results |
129 | int count = results.Count(); | 129 | int count = results.Count(); |
130 | bool found = count > 0; | 130 | bool found = count > 0; |
131 | if ( found ) | 131 | if ( found ) |
132 | { | 132 | { |
133 | // Populate results combo box | 133 | // Populate results combo box |
134 | sword::VerseKey key; | 134 | sword::VerseKey key; |
135 | for ( int i = 0; i < count; i++ ) | 135 | for ( int i = 0; i < count; i++ ) |
136 | { | 136 | { |
137 | key.setText( results.GetElement( i )->getText() ); | 137 | key.setText( results.GetElement( i )->getText() ); |
138 | m_resultList->insertItem( key.getShortText() ); | 138 | m_resultList->insertItem( key.getShortText() ); |
139 | } | 139 | } |
140 | 140 | ||
141 | // Goto first result in list | 141 | // Goto first result in list |
142 | m_resultList->setCurrentItem( 0 ); | 142 | m_resultList->setCurrentItem( 0 ); |
143 | emit sigResultClicked( m_resultList->currentText() ); | 143 | emit sigResultClicked( m_resultList->currentText() ); |
144 | } | 144 | } |
145 | else | 145 | else |
146 | { | 146 | { |
147 | // Reset application title | 147 | // Reset application title |
148 | pWidget->setCaption( caption ); | 148 | pWidget->setCaption( caption ); |
149 | } | 149 | } |
150 | 150 | ||
151 | // UI clean-up | 151 | // UI clean-up |
152 | wait.hide(); | 152 | wait.hide(); |
153 | 153 | ||
154 | m_actionPrev->setEnabled( false ); | 154 | m_actionPrev->setEnabled( false ); |
155 | m_resultList->setEnabled( found ); | 155 | m_resultList->setEnabled( found ); |
156 | m_actionNext->setEnabled( count > 1 ); | 156 | m_actionNext->setEnabled( count > 1 ); |
157 | } | 157 | } |
158 | 158 | ||
159 | void SearchBar::slotPrev() | 159 | void SearchBar::slotPrev() |
160 | { | 160 | { |
161 | int item = m_resultList->currentItem() - 1; | 161 | int item = m_resultList->currentItem() - 1; |
162 | m_resultList->setCurrentItem( item ); | 162 | m_resultList->setCurrentItem( item ); |
163 | emit sigResultClicked( m_resultList->currentText() ); | 163 | emit sigResultClicked( m_resultList->currentText() ); |
164 | 164 | ||
165 | m_actionPrev->setEnabled( item > 0 ); | 165 | m_actionPrev->setEnabled( item > 0 ); |
166 | m_actionNext->setEnabled( item < m_resultList->count() - 1 ); | 166 | m_actionNext->setEnabled( item < m_resultList->count() - 1 ); |
167 | } | 167 | } |
168 | 168 | ||
169 | void SearchBar::slotNext() | 169 | void SearchBar::slotNext() |
170 | { | 170 | { |
171 | int item = m_resultList->currentItem() + 1; | 171 | int item = m_resultList->currentItem() + 1; |
172 | m_resultList->setCurrentItem( item ); | 172 | m_resultList->setCurrentItem( item ); |
173 | emit sigResultClicked( m_resultList->currentText() ); | 173 | emit sigResultClicked( m_resultList->currentText() ); |
174 | 174 | ||
175 | m_actionPrev->setEnabled( true ); | 175 | m_actionPrev->setEnabled( true ); |
176 | m_actionNext->setEnabled( item < m_resultList->count() - 1 ); | 176 | m_actionNext->setEnabled( item < m_resultList->count() - 1 ); |
177 | } | 177 | } |
178 | 178 | ||
179 | void SearchBar::slotCloseBtn() | 179 | void SearchBar::slotCloseBtn() |
180 | { | 180 | { |
181 | hide(); | 181 | hide(); |
182 | } | 182 | } |