-rw-r--r-- | noncore/apps/checkbook/traninfo.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/confedit/listviewconfdir.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/confedit/listviewitemconfigentry.cpp | 8 | ||||
-rw-r--r-- | noncore/apps/opie-bartender/bac.cpp | 1 | ||||
-rw-r--r-- | noncore/apps/opie-gutenbrowser/LibraryDialog.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-gutenbrowser/NetworkDialog.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-gutenbrowser/fontDialog.cpp | 40 | ||||
-rw-r--r-- | noncore/apps/opie-gutenbrowser/helpwindow.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/oxygen/kmolelements.cpp | 36 |
9 files changed, 48 insertions, 49 deletions
diff --git a/noncore/apps/checkbook/traninfo.cpp b/noncore/apps/checkbook/traninfo.cpp index 506f567..4833af9 100644 --- a/noncore/apps/checkbook/traninfo.cpp +++ b/noncore/apps/checkbook/traninfo.cpp | |||
@@ -1,227 +1,227 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. | 3 | =. |
4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> | 4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "traninfo.h" | 29 | #include "traninfo.h" |
30 | 30 | ||
31 | #include <qpe/config.h> | 31 | #include <qpe/config.h> |
32 | #include <qpe/timestring.h> | 32 | #include <qpe/timestring.h> |
33 | 33 | ||
34 | QString tempstr; | 34 | QString tempstr; |
35 | 35 | ||
36 | TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal, | 36 | TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal, |
37 | const QString &type, const QString &category, float amount, | 37 | const QString &type, const QString &category, float amount, |
38 | float fee, const QString &number, const QString ¬es, int next ) | 38 | float fee, const QString &number, const QString ¬es, int next ) |
39 | { | 39 | { |
40 | i = id; | 40 | i = id; |
41 | d = desc; | 41 | d = desc; |
42 | td = date; | 42 | td = date; |
43 | w = withdrawal; | 43 | w = withdrawal; |
44 | t = type; | 44 | t = type; |
45 | c = category; | 45 | c = category; |
46 | a = amount; | 46 | a = amount; |
47 | f = fee; | 47 | f = fee; |
48 | cn = number; | 48 | cn = number; |
49 | n = notes; | 49 | n = notes; |
50 | _next=next; | 50 | _next=next; |
51 | } | 51 | } |
52 | 52 | ||
53 | TranInfo::TranInfo( Config config, int entry ) | 53 | TranInfo::TranInfo( Config config, int entry ) |
54 | { | 54 | { |
55 | config.setGroup( QString::number( entry ) ); | 55 | config.setGroup( QString::number( entry ) ); |
56 | QString desc = config.readEntry( "Description", "Not Found" ); | 56 | QString desc = config.readEntry( "Description", "Not Found" ); |
57 | if ( desc != "Not Found" ) | 57 | if ( desc != "Not Found" ) |
58 | { | 58 | { |
59 | // ID | 59 | // ID |
60 | i = entry; | 60 | i = entry; |
61 | 61 | ||
62 | // Description | 62 | // Description |
63 | d = desc; | 63 | d = desc; |
64 | 64 | ||
65 | // Transaction date | 65 | // Transaction date |
66 | int yr, mn, dy; | 66 | int yr, mn, dy; |
67 | QString datestr = config.readEntry( "Date", "" ); | 67 | QString datestr = config.readEntry( "Date", "" ); |
68 | int begin, end; | 68 | int begin, end; |
69 | begin = datestr.find( '/' ); | 69 | begin = datestr.find( '/' ); |
70 | mn = datestr.left( begin ).toInt(); | 70 | mn = datestr.left( begin ).toInt(); |
71 | end = datestr.find( '/', ++begin ); | 71 | end = datestr.find( '/', ++begin ); |
72 | dy = datestr.mid( begin, end - begin ).toInt(); | 72 | dy = datestr.mid( begin, end - begin ).toInt(); |
73 | yr = datestr.right( datestr.length() - end - 1).toInt(); | 73 | yr = datestr.right( datestr.length() - end - 1).toInt(); |
74 | td.setYMD( yr, mn, dy ); | 74 | td.setYMD( yr, mn, dy ); |
75 | 75 | ||
76 | // Deposit/withdrawal indicator ( withdrawal == TRUE ) | 76 | // Deposit/withdrawal indicator ( withdrawal == TRUE ) |
77 | w = ( config.readEntry( "Payment", "false" ) == "true" ); | 77 | w = ( config.readEntry( "Payment", "false" ) == "true" ); |
78 | 78 | ||
79 | // Type | 79 | // Type |
80 | QString type = config.readEntry( "Type", "0" ); | 80 | QString type = config.readEntry( "Type", "0" ); |
81 | if ( w ) | 81 | if ( w ) |
82 | { // Withdrawal types | 82 | { // Withdrawal types |
83 | if( type == "0" ) | 83 | if( type == "0" ) |
84 | t = "Debit Charge"; | 84 | t = "Debit Charge"; |
85 | else if( type == "1" ) | 85 | else if( type == "1" ) |
86 | t = "Written Check"; | 86 | t = "Written Check"; |
87 | else if( type == "2" ) | 87 | else if( type == "2" ) |
88 | t = "Transfer"; | 88 | t = "Transfer"; |
89 | else if( type == "3" ) | 89 | else if( type == "3" ) |
90 | t = "Credit Card"; | 90 | t = "Credit Card"; |
91 | } | 91 | } |
92 | else | 92 | else |
93 | { | 93 | { |
94 | if( type == "0" ) | 94 | if( type == "0" ) |
95 | t = "Written Check"; | 95 | t = "Written Check"; |
96 | else if( type == "1" ) | 96 | else if( type == "1" ) |
97 | t = "Automatic Payment"; | 97 | t = "Automatic Payment"; |
98 | else if( type == "2" ) | 98 | else if( type == "2" ) |
99 | t = "Transfer"; | 99 | t = "Transfer"; |
100 | else if( type == "3" ) | 100 | else if( type == "3" ) |
101 | t = "Cash"; | 101 | t = "Cash"; |
102 | } | 102 | } |
103 | 103 | ||
104 | // Category | 104 | // Category |
105 | c = config.readEntry( "Category", "" ); | 105 | c = config.readEntry( "Category", "" ); |
106 | 106 | ||
107 | // Transaction amount | 107 | // Transaction amount |
108 | QString stramount = config.readEntry( "Amount", "0.00" ); | 108 | QString stramount = config.readEntry( "Amount", "0.00" ); |
109 | bool ok; | 109 | bool ok; |
110 | a = stramount.toFloat( &ok ); | 110 | a = stramount.toFloat( &ok ); |
111 | 111 | ||
112 | // Transaction fee | 112 | // Transaction fee |
113 | stramount = config.readEntry( "TransactionFee", "0.00" ); | 113 | stramount = config.readEntry( "TransactionFee", "0.00" ); |
114 | f = stramount.toFloat( &ok ); | 114 | f = stramount.toFloat( &ok ); |
115 | 115 | ||
116 | // Transaction number | 116 | // Transaction number |
117 | cn = config.readEntry( "CheckNumber", "" ); | 117 | cn = config.readEntry( "CheckNumber", "" ); |
118 | 118 | ||
119 | // Notes | 119 | // Notes |
120 | n = config.readEntry( "Comments", "" ); | 120 | n = config.readEntry( "Comments", "" ); |
121 | 121 | ||
122 | // next | 122 | // next |
123 | _next = config.readNumEntry("Next", -1); | 123 | _next = config.readNumEntry("Next", -1); |
124 | } | 124 | } |
125 | } | 125 | } |
126 | 126 | ||
127 | // --- datestr ---------------------------------------------------------------- | 127 | // --- datestr ---------------------------------------------------------------- |
128 | const QString &TranInfo::datestr(bool bDisplayDate) | 128 | const QString &TranInfo::datestr(bool bDisplayDate) |
129 | { | 129 | { |
130 | if( bDisplayDate ) { | 130 | if( bDisplayDate ) { |
131 | tempstr=TimeString::numberDateString( td ); | 131 | tempstr=TimeString::numberDateString( td ); |
132 | } else { | 132 | } else { |
133 | tempstr.sprintf( "%04d-%02d-%02d", td.year() ,td.month(), td.day() ); | 133 | tempstr.sprintf( "%04d-%02d-%02d", td.year() ,td.month(), td.day() ); |
134 | } | 134 | } |
135 | return(tempstr); | 135 | return(tempstr); |
136 | } | 136 | } |
137 | 137 | ||
138 | 138 | ||
139 | // --- getIdStr --------------------------------------------------------------- | 139 | // --- getIdStr --------------------------------------------------------------- |
140 | const QString &TranInfo::getIdStr() | 140 | const QString &TranInfo::getIdStr() |
141 | { | 141 | { |
142 | tempstr.sprintf("%04d", i); | 142 | tempstr.sprintf("%04d", i); |
143 | return( tempstr ); | 143 | return( tempstr ); |
144 | } | 144 | } |
145 | 145 | ||
146 | // --- write ------------------------------------------------------------------ | 146 | // --- write ------------------------------------------------------------------ |
147 | void TranInfo::write( Config *config ) | 147 | void TranInfo::write( Config *config ) |
148 | { | 148 | { |
149 | config->setGroup( QString::number( id() ) ); | 149 | config->setGroup( QString::number( id() ) ); |
150 | 150 | ||
151 | config->writeEntry( "Description", d ); | 151 | config->writeEntry( "Description", d ); |
152 | 152 | ||
153 | tempstr = QString::number( td.month() ); | 153 | tempstr = QString::number( td.month() ); |
154 | tempstr.append( '/' ); | 154 | tempstr.append( '/' ); |
155 | tempstr.append( QString::number( td.day() ) ); | 155 | tempstr.append( QString::number( td.day() ) ); |
156 | tempstr.append( '/' ); | 156 | tempstr.append( '/' ); |
157 | tempstr.append( QString::number( td.year() ) ); | 157 | tempstr.append( QString::number( td.year() ) ); |
158 | config->writeEntry( "Date", tempstr ); | 158 | config->writeEntry( "Date", tempstr ); |
159 | 159 | ||
160 | w ? tempstr = "true" | 160 | w ? tempstr = "true" |
161 | : tempstr = "false"; | 161 | : tempstr = "false"; |
162 | config->writeEntry( "Payment", tempstr ); | 162 | config->writeEntry( "Payment", tempstr ); |
163 | 163 | ||
164 | if ( t == "Debit Charge" || t == "Written Check" ) | 164 | if ( t == "Debit Charge" || t == "Written Check" ) |
165 | tempstr = "0"; | 165 | tempstr = "0"; |
166 | else if ( t == "Written Check" || t == "Automatic Payment" ) | 166 | else if ( t == "Written Check" || t == "Automatic Payment" ) |
167 | tempstr = "1"; | 167 | tempstr = "1"; |
168 | else if ( t == "Transfer" ) | 168 | else if ( t == "Transfer" ) |
169 | tempstr = "2"; | 169 | tempstr = "2"; |
170 | else if ( t == "Credit Card" || t == "Cash" ) | 170 | else if ( t == "Credit Card" || t == "Cash" ) |
171 | tempstr = "3"; | 171 | tempstr = "3"; |
172 | config->writeEntry( "Type", tempstr ); | 172 | config->writeEntry( "Type", tempstr ); |
173 | 173 | ||
174 | config->writeEntry( "Category", c ); | 174 | config->writeEntry( "Category", c ); |
175 | 175 | ||
176 | tempstr.setNum( a, 'f', 2 ); | 176 | tempstr.setNum( a, 'f', 2 ); |
177 | config->writeEntry( "Amount", tempstr ); | 177 | config->writeEntry( "Amount", tempstr ); |
178 | 178 | ||
179 | tempstr.setNum( f, 'f', 2 ); | 179 | tempstr.setNum( f, 'f', 2 ); |
180 | config->writeEntry( "TransactionFee", tempstr ); | 180 | config->writeEntry( "TransactionFee", tempstr ); |
181 | 181 | ||
182 | config->writeEntry( "CheckNumber", cn ); | 182 | config->writeEntry( "CheckNumber", cn ); |
183 | config->writeEntry( "Comments", n ); | 183 | config->writeEntry( "Comments", n ); |
184 | config->writeEntry( "Next", _next ); | 184 | config->writeEntry( "Next", _next ); |
185 | } | 185 | } |
186 | 186 | ||
187 | 187 | ||
188 | int TranInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 ) | 188 | int TranInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 ) |
189 | { | 189 | { |
190 | QDate d1 = ((TranInfo *)item1)->date(); | 190 | QDate d1 = ((TranInfo *)item1)->date(); |
191 | QDate d2 = ((TranInfo *)item2)->date(); | 191 | QDate d2 = ((TranInfo *)item2)->date(); |
192 | int r = -1; | 192 | int r = -1; |
193 | 193 | ||
194 | if ( d1 < d2 ) | 194 | if ( d1 < d2 ) |
195 | r = -1; | 195 | r = -1; |
196 | else if ( d1 == d2 ) | 196 | else if ( d1 == d2 ) |
197 | r = 0; | 197 | r = 0; |
198 | else if ( d1 > d2 ) | 198 | else if ( d1 > d2 ) |
199 | r = 1; | 199 | r = 1; |
200 | return( r ); | 200 | return( r ); |
201 | } | 201 | } |
202 | 202 | ||
203 | // --- toString --------------------------------------------------------------- | 203 | // --- toString --------------------------------------------------------------- |
204 | QString TranInfo::toString() | 204 | QString TranInfo::toString() |
205 | { | 205 | { |
206 | QString ret; | 206 | QString ret; |
207 | ret.sprintf("(%4d) %10s %4s %-10s %5.2f %5.2f", | 207 | ret.sprintf("(%4d) %10s %4s %-10s %5.2f %5.2f", |
208 | id(), | 208 | id(), |
209 | (const char *)datestr(), | 209 | (const char *)datestr(), |
210 | (const char *)number(), | 210 | (const char *)number(), |
211 | (const char *)desc(), | 211 | (const char *)desc(), |
212 | (withdrawal() ? -1 : 1) * amount(), | 212 | (withdrawal() ? -1 : 1) * amount(), |
213 | fee() | 213 | fee() |
214 | ); | 214 | ); |
215 | return(ret); | 215 | return(ret); |
216 | } | 216 | } |
217 | 217 | ||
218 | 218 | ||
219 | // --- findMostRecentByDesc --------------------------------------------------- | 219 | // --- findMostRecentByDesc --------------------------------------------------- |
220 | TranInfo *TranInfoList::findMostRecentByDesc( const QString &desc ) | 220 | TranInfo *TranInfoList::findMostRecentByDesc( const QString &desc ) |
221 | { | 221 | { |
222 | for(TranInfo *cur=last(); cur; cur=prev()) { | 222 | for(TranInfo *cur=last(); cur; cur=prev()) { |
223 | if( cur->desc()==desc ) | 223 | if( cur->desc()==desc ) |
224 | return( cur ); | 224 | return( cur ); |
225 | } | 225 | } |
226 | return(NULL); | 226 | return(NULL); |
227 | } \ No newline at end of file | 227 | } |
diff --git a/noncore/apps/confedit/listviewconfdir.cpp b/noncore/apps/confedit/listviewconfdir.cpp index 33bffe1..73eaae3 100644 --- a/noncore/apps/confedit/listviewconfdir.cpp +++ b/noncore/apps/confedit/listviewconfdir.cpp | |||
@@ -1,65 +1,65 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | * This program is free software; you can redistribute it and/or modify * |
4 | * it under the terms of the GNU General Public License as published by * | 4 | * it under the terms of the GNU General Public License as published by * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | // (c) 2002 Patrick S. Vogtp <tille@handhelds.org> | 9 | // (c) 2002 Patrick S. Vogtp <tille@handhelds.org> |
10 | 10 | ||
11 | #include "listviewconfdir.h" | 11 | #include "listviewconfdir.h" |
12 | #include "listviewitemconffile.h" | 12 | #include "listviewitemconffile.h" |
13 | 13 | ||
14 | /* OPIE */ | 14 | /* OPIE */ |
15 | #include <opie2/odebug.h> | 15 | #include <opie2/odebug.h> |
16 | using namespace Opie::Core; | 16 | using namespace Opie::Core; |
17 | 17 | ||
18 | /* QT */ | 18 | /* QT */ |
19 | #include <qmessagebox.h> | 19 | #include <qmessagebox.h> |
20 | 20 | ||
21 | ListViewConfDir::ListViewConfDir(QString settingsPath, QWidget *parent, const char *name ) | 21 | ListViewConfDir::ListViewConfDir(QString settingsPath, QWidget *parent, const char *name ) |
22 | : QListView(parent,name), confDir(settingsPath) | 22 | : QListView(parent,name), confDir(settingsPath) |
23 | { | 23 | { |
24 | 24 | ||
25 | setRootIsDecorated( true ); | 25 | setRootIsDecorated( true ); |
26 | addColumn(tr("Files")); | 26 | addColumn(tr("Files")); |
27 | 27 | ||
28 | if (!confDir.isReadable()) | 28 | if (!confDir.isReadable()) |
29 | QMessageBox::critical(this,tr("Could not open"),tr("The directory ")+settingsPath+tr(" could not be opened."),1,0); | 29 | QMessageBox::critical(this,tr("Could not open"),tr("The directory ")+settingsPath+tr(" could not be opened."),1,0); |
30 | readConfFiles(); | 30 | readConfFiles(); |
31 | 31 | ||
32 | connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*))); | 32 | connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*))); |
33 | } | 33 | } |
34 | 34 | ||
35 | 35 | ||
36 | ListViewConfDir::~ListViewConfDir() | 36 | ListViewConfDir::~ListViewConfDir() |
37 | { | 37 | { |
38 | } | 38 | } |
39 | 39 | ||
40 | void ListViewConfDir::readConfFiles() | 40 | void ListViewConfDir::readConfFiles() |
41 | { | 41 | { |
42 | 42 | ||
43 | confDir.setFilter( QDir::Files | QDir::NoSymLinks ); | 43 | confDir.setFilter( QDir::Files | QDir::NoSymLinks ); |
44 | confDir.setSorting( QDir::Name ); | 44 | confDir.setSorting( QDir::Name ); |
45 | confDir.setNameFilter("*.conf"); | 45 | confDir.setNameFilter("*.conf"); |
46 | const QFileInfoList *list = confDir.entryInfoList(); | 46 | const QFileInfoList *list = confDir.entryInfoList(); |
47 | QFileInfoListIterator it( *list ); | 47 | QFileInfoListIterator it( *list ); |
48 | QFileInfo *fi; | 48 | QFileInfo *fi; |
49 | 49 | ||
50 | ListViewItemConfFile *fileEntry; | 50 | ListViewItemConfFile *fileEntry; |
51 | 51 | ||
52 | while ( (fi=it.current()) ) | 52 | while ( (fi=it.current()) ) |
53 | { | 53 | { |
54 | odebug << "opening: >" << fi->fileName().data() << "<" << oendl; | 54 | odebug << "opening: >" << fi->fileName().data() << "<" << oendl; |
55 | fileEntry = new ListViewItemConfFile( fi, this ); | 55 | fileEntry = new ListViewItemConfFile( fi, this ); |
56 | QListViewItem *dummy = new QListViewItem(fileEntry, "dummy"); | 56 | (void)new QListViewItem(fileEntry, "dummy"); |
57 | ++it; | 57 | ++it; |
58 | } | 58 | } |
59 | } | 59 | } |
60 | 60 | ||
61 | void ListViewConfDir::expand(QListViewItem *item) | 61 | void ListViewConfDir::expand(QListViewItem *item) |
62 | { | 62 | { |
63 | ((ListViewItemConf*)item)->expand(); | 63 | ((ListViewItemConf*)item)->expand(); |
64 | } | 64 | } |
65 | 65 | ||
diff --git a/noncore/apps/confedit/listviewitemconfigentry.cpp b/noncore/apps/confedit/listviewitemconfigentry.cpp index 0970125..714a154 100644 --- a/noncore/apps/confedit/listviewitemconfigentry.cpp +++ b/noncore/apps/confedit/listviewitemconfigentry.cpp | |||
@@ -1,150 +1,150 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | * This program is free software; you can redistribute it and/or modify * |
4 | * it under the terms of the GNU General Public License as published by * | 4 | * it under the terms of the GNU General Public License as published by * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | // (c) 2002 Patrick S. Vogtp <tille@handhelds.org> | 9 | // (c) 2002 Patrick S. Vogtp <tille@handhelds.org> |
10 | 10 | ||
11 | #include "listviewitemconfigentry.h" | 11 | #include "listviewitemconfigentry.h" |
12 | #include <qtextstream.h> | 12 | #include <qtextstream.h> |
13 | 13 | ||
14 | ListViewItemConfigEntry::ListViewItemConfigEntry(ListViewItemConfFile *parent, QString group, QString key) | 14 | ListViewItemConfigEntry::ListViewItemConfigEntry(ListViewItemConfFile *parent, QString group, QString key) |
15 | : ListViewItemConf(parent) | 15 | : ListViewItemConf(parent) |
16 | { | 16 | { |
17 | _fileItem = parent; | 17 | _fileItem = parent; |
18 | _file = parent->fileName(); | 18 | _file = parent->fileName(); |
19 | _group = group; | 19 | _group = group; |
20 | setKey(key); | 20 | setKey(key); |
21 | _groupOrig = group; | 21 | _groupOrig = group; |
22 | _keyOrig = _key; | 22 | _keyOrig = _key; |
23 | _valueOrig = _value; | 23 | _valueOrig = _value; |
24 | } | 24 | } |
25 | 25 | ||
26 | ListViewItemConfigEntry::~ListViewItemConfigEntry() | 26 | ListViewItemConfigEntry::~ListViewItemConfigEntry() |
27 | { | 27 | { |
28 | } | 28 | } |
29 | 29 | ||
30 | bool ListViewItemConfigEntry::isGroup() | 30 | bool ListViewItemConfigEntry::isGroup() |
31 | { | 31 | { |
32 | return _key.isEmpty(); | 32 | return _key.isEmpty(); |
33 | } | 33 | } |
34 | 34 | ||
35 | bool ListViewItemConfigEntry::isKey() | 35 | bool ListViewItemConfigEntry::isKey() |
36 | { | 36 | { |
37 | return !_key.isEmpty(); | 37 | return !_key.isEmpty(); |
38 | } | 38 | } |
39 | 39 | ||
40 | QString ListViewItemConfigEntry::getFile() | 40 | QString ListViewItemConfigEntry::getFile() |
41 | { | 41 | { |
42 | return _file; | 42 | return _file; |
43 | } | 43 | } |
44 | 44 | ||
45 | void ListViewItemConfigEntry::setGroup(QString g) | 45 | void ListViewItemConfigEntry::setGroup(QString g) |
46 | { | 46 | { |
47 | if (g==_group) return; | 47 | if (g==_group) return; |
48 | _group = g; | 48 | _group = g; |
49 | changed(); | 49 | changed(); |
50 | } | 50 | } |
51 | 51 | ||
52 | QString ListViewItemConfigEntry::getGroup() | 52 | QString ListViewItemConfigEntry::getGroup() |
53 | { | 53 | { |
54 | return _group; | 54 | return _group; |
55 | } | 55 | } |
56 | 56 | ||
57 | void ListViewItemConfigEntry::setKey(QString key) | 57 | void ListViewItemConfigEntry::setKey(QString key) |
58 | { | 58 | { |
59 | int pos = key.find("="); | 59 | int pos = key.find("="); |
60 | _key = key.left(pos).stripWhiteSpace(); | 60 | _key = key.left(pos).stripWhiteSpace(); |
61 | _value = key.right(key.length() - pos - 1).stripWhiteSpace(); | 61 | _value = key.right(key.length() - pos - 1).stripWhiteSpace(); |
62 | displayText(); | 62 | displayText(); |
63 | } | 63 | } |
64 | 64 | ||
65 | QString ListViewItemConfigEntry::getKey() | 65 | QString ListViewItemConfigEntry::getKey() |
66 | { | 66 | { |
67 | return _key; | 67 | return _key; |
68 | } | 68 | } |
69 | 69 | ||
70 | QString ListViewItemConfigEntry::getValue() | 70 | QString ListViewItemConfigEntry::getValue() |
71 | { | 71 | { |
72 | return _value; | 72 | return _value; |
73 | } | 73 | } |
74 | 74 | ||
75 | void ListViewItemConfigEntry::keyChanged(QString k) | 75 | void ListViewItemConfigEntry::keyChanged(QString k) |
76 | { | 76 | { |
77 | if (k==_key) return; | 77 | if (k==_key) return; |
78 | _key = k; | 78 | _key = k; |
79 | changed(); | 79 | changed(); |
80 | } | 80 | } |
81 | 81 | ||
82 | void ListViewItemConfigEntry::valueChanged(QString v) | 82 | void ListViewItemConfigEntry::valueChanged(QString v) |
83 | { | 83 | { |
84 | if (v==_value) return; | 84 | if (v==_value) return; |
85 | _value = v; | 85 | _value = v; |
86 | changed(); | 86 | changed(); |
87 | } | 87 | } |
88 | 88 | ||
89 | void ListViewItemConfigEntry::displayText() | 89 | void ListViewItemConfigEntry::displayText() |
90 | { | 90 | { |
91 | QString s; | 91 | QString s; |
92 | if (_changed) s="*"; | 92 | if (_changed) s="*"; |
93 | if (isGroup()) | 93 | if (isGroup()) |
94 | { | 94 | { |
95 | s += "["+_group+"]"; | 95 | s += "["+_group+"]"; |
96 | _type = Group; | 96 | _type = Group; |
97 | }else{ | 97 | }else{ |
98 | s += _key+" = "+_value; | 98 | s += _key+" = "+_value; |
99 | _type = Key; | 99 | _type = Key; |
100 | } | 100 | } |
101 | setText(0,s); | 101 | setText(0,s); |
102 | } | 102 | } |
103 | 103 | ||
104 | void ListViewItemConfigEntry::changed() | 104 | void ListViewItemConfigEntry::changed() |
105 | { | 105 | { |
106 | _changed=true; | 106 | _changed=true; |
107 | displayText(); | 107 | displayText(); |
108 | _fileItem->changed(); | 108 | _fileItem->changed(); |
109 | } | 109 | } |
110 | 110 | ||
111 | 111 | ||
112 | void ListViewItemConfigEntry::remove() | 112 | void ListViewItemConfigEntry::remove() |
113 | { | 113 | { |
114 | delete this; | 114 | delete this; |
115 | } | 115 | } |
116 | 116 | ||
117 | void ListViewItemConfigEntry::save(QTextStream *t) | 117 | void ListViewItemConfigEntry::save(QTextStream *t) |
118 | { | 118 | { |
119 | QString s; | 119 | QString s; |
120 | if (isGroup()) | 120 | if (isGroup()) |
121 | { | 121 | { |
122 | s += "["+_group+"]"; | 122 | s += "["+_group+"]"; |
123 | _type = Group; | 123 | _type = Group; |
124 | }else{ | 124 | }else{ |
125 | s += _key+" = "+_value; | 125 | s += _key+" = "+_value; |
126 | _type = Key; | 126 | _type = Key; |
127 | } | 127 | } |
128 | s += "\n"; | 128 | s += "\n"; |
129 | (*t) << s; | 129 | (*t) << s; |
130 | _changed = false; | 130 | _changed = false; |
131 | for (QListViewItem *it = firstChild(); it!=0;it = it->nextSibling()) | 131 | for (QListViewItem *it = firstChild(); it!=0;it = it->nextSibling()) |
132 | { | 132 | { |
133 | ((ListViewItemConfigEntry*)it)->save(t); | 133 | ((ListViewItemConfigEntry*)it)->save(t); |
134 | } | 134 | } |
135 | } | 135 | } |
136 | 136 | ||
137 | void ListViewItemConfigEntry::revert() | 137 | void ListViewItemConfigEntry::revert() |
138 | { | 138 | { |
139 | _group = _groupOrig; | 139 | _group = _groupOrig; |
140 | _key = _keyOrig; | 140 | _key = _keyOrig; |
141 | _value = _valueOrig; | 141 | _value = _valueOrig; |
142 | _changed=false; | 142 | _changed=false; |
143 | displayText(); | 143 | displayText(); |
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
147 | void ListViewItemConfigEntry::expand() | 147 | void ListViewItemConfigEntry::expand() |
148 | { | 148 | { |
149 | 149 | ||
150 | } \ No newline at end of file | 150 | } |
diff --git a/noncore/apps/opie-bartender/bac.cpp b/noncore/apps/opie-bartender/bac.cpp index 2e74029..8dc7e88 100644 --- a/noncore/apps/opie-bartender/bac.cpp +++ b/noncore/apps/opie-bartender/bac.cpp | |||
@@ -1,184 +1,183 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** | 2 | ** |
3 | ** Created: Sun Jul 21 19:00:14 2002 | 3 | ** Created: Sun Jul 21 19:00:14 2002 |
4 | ** by: L.J. Potter <ljp@llornkcor.com> | 4 | ** by: L.J. Potter <ljp@llornkcor.com> |
5 | ** copyright : (C) 2002 by ljp | 5 | ** copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #include "bac.h" | 12 | #include "bac.h" |
13 | 13 | ||
14 | #include <qcombobox.h> | 14 | #include <qcombobox.h> |
15 | #include <qlabel.h> | 15 | #include <qlabel.h> |
16 | #include <qlcdnumber.h> | 16 | #include <qlcdnumber.h> |
17 | #include <qpushbutton.h> | 17 | #include <qpushbutton.h> |
18 | #include <qspinbox.h> | 18 | #include <qspinbox.h> |
19 | #include <qlayout.h> | 19 | #include <qlayout.h> |
20 | BacDialog::BacDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) | 20 | BacDialog::BacDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) |
21 | : QDialog( parent, name, modal, fl ) | 21 | : QDialog( parent, name, modal, fl ) |
22 | { | 22 | { |
23 | if ( !name ) | 23 | if ( !name ) |
24 | setName( "BacDialog" ); | 24 | setName( "BacDialog" ); |
25 | setCaption( tr( "Blood Alcohol Estimator" ) ); | 25 | setCaption( tr( "Blood Alcohol Estimator" ) ); |
26 | 26 | ||
27 | Layout7 = new QVBoxLayout( this); | 27 | Layout7 = new QVBoxLayout( this); |
28 | Layout7->setSpacing( 6 ); | 28 | Layout7->setSpacing( 6 ); |
29 | Layout7->setMargin( 0 ); | 29 | Layout7->setMargin( 0 ); |
30 | 30 | ||
31 | Layout1 = new QHBoxLayout; | 31 | Layout1 = new QHBoxLayout; |
32 | Layout1->setSpacing( 6 ); | 32 | Layout1->setSpacing( 6 ); |
33 | Layout1->setMargin( 0 ); | 33 | Layout1->setMargin( 0 ); |
34 | 34 | ||
35 | NumberSpinBox = new QSpinBox( this, "NumberSpinBox" ); | 35 | NumberSpinBox = new QSpinBox( this, "NumberSpinBox" ); |
36 | Layout1->addWidget( NumberSpinBox ); | 36 | Layout1->addWidget( NumberSpinBox ); |
37 | 37 | ||
38 | TextLabel1 = new QLabel(this, "TextLabel1" ); | 38 | TextLabel1 = new QLabel(this, "TextLabel1" ); |
39 | TextLabel1->setText( tr( "# Drinks Consumed" ) ); | 39 | TextLabel1->setText( tr( "# Drinks Consumed" ) ); |
40 | Layout1->addWidget( TextLabel1 ); | 40 | Layout1->addWidget( TextLabel1 ); |
41 | Layout7->addLayout( Layout1 ); | 41 | Layout7->addLayout( Layout1 ); |
42 | 42 | ||
43 | Layout2 = new QHBoxLayout; | 43 | Layout2 = new QHBoxLayout; |
44 | Layout2->setSpacing( 6 ); | 44 | Layout2->setSpacing( 6 ); |
45 | Layout2->setMargin( 0 ); | 45 | Layout2->setMargin( 0 ); |
46 | 46 | ||
47 | WeightSpinBox = new QSpinBox( this, "WeightSpinBox" ); | 47 | WeightSpinBox = new QSpinBox( this, "WeightSpinBox" ); |
48 | Layout2->addWidget( WeightSpinBox ); | 48 | Layout2->addWidget( WeightSpinBox ); |
49 | WeightSpinBox->setMaxValue(500); | 49 | WeightSpinBox->setMaxValue(500); |
50 | 50 | ||
51 | TextLabel2 = new QLabel( this, "TextLabel2" ); | 51 | TextLabel2 = new QLabel( this, "TextLabel2" ); |
52 | TextLabel2->setText( tr( "Weight" ) ); | 52 | TextLabel2->setText( tr( "Weight" ) ); |
53 | Layout2->addWidget( TextLabel2 ); | 53 | Layout2->addWidget( TextLabel2 ); |
54 | Layout7->addLayout( Layout2 ); | 54 | Layout7->addLayout( Layout2 ); |
55 | 55 | ||
56 | weightUnitsCombo =new QComboBox( FALSE, this, "unitComboBox" ); | 56 | weightUnitsCombo =new QComboBox( FALSE, this, "unitComboBox" ); |
57 | weightUnitsCombo->insertItem( tr( "Kilos" ) ); | 57 | weightUnitsCombo->insertItem( tr( "Kilos" ) ); |
58 | weightUnitsCombo->insertItem( tr( "Pounds" ) ); | 58 | weightUnitsCombo->insertItem( tr( "Pounds" ) ); |
59 | Layout2->addWidget( weightUnitsCombo ); | 59 | Layout2->addWidget( weightUnitsCombo ); |
60 | 60 | ||
61 | weightUnitsLabel = new QLabel(this, "unitsTextLabel" ); | 61 | weightUnitsLabel = new QLabel(this, "unitsTextLabel" ); |
62 | weightUnitsLabel->setText( tr( "Units" ) ); | 62 | weightUnitsLabel->setText( tr( "Units" ) ); |
63 | Layout2->addWidget( weightUnitsLabel ); | 63 | Layout2->addWidget( weightUnitsLabel ); |
64 | 64 | ||
65 | Layout3 = new QHBoxLayout; | 65 | Layout3 = new QHBoxLayout; |
66 | Layout3->setSpacing( 6 ); | 66 | Layout3->setSpacing( 6 ); |
67 | Layout3->setMargin( 0 ); | 67 | Layout3->setMargin( 0 ); |
68 | 68 | ||
69 | TimeSpinBox = new QSpinBox( this, "TimeSpinBox" ); | 69 | TimeSpinBox = new QSpinBox( this, "TimeSpinBox" ); |
70 | Layout3->addWidget( TimeSpinBox ); | 70 | Layout3->addWidget( TimeSpinBox ); |
71 | TimeSpinBox->setMaxValue(24); | 71 | TimeSpinBox->setMaxValue(24); |
72 | 72 | ||
73 | TextLabel3 = new QLabel( this, "TextLabel3" ); | 73 | TextLabel3 = new QLabel( this, "TextLabel3" ); |
74 | TextLabel3->setText( tr( "Period of Time (hours)" ) ); | 74 | TextLabel3->setText( tr( "Period of Time (hours)" ) ); |
75 | Layout3->addWidget( TextLabel3 ); | 75 | Layout3->addWidget( TextLabel3 ); |
76 | Layout7->addLayout( Layout3 ); | 76 | Layout7->addLayout( Layout3 ); |
77 | 77 | ||
78 | Layout4 = new QHBoxLayout; | 78 | Layout4 = new QHBoxLayout; |
79 | Layout4->setSpacing( 6 ); | 79 | Layout4->setSpacing( 6 ); |
80 | Layout4->setMargin( 0 ); | 80 | Layout4->setMargin( 0 ); |
81 | 81 | ||
82 | GenderComboBox = new QComboBox( FALSE, this, "GenderComboBox" ); | 82 | GenderComboBox = new QComboBox( FALSE, this, "GenderComboBox" ); |
83 | GenderComboBox->insertItem( tr( "Male" ) ); | 83 | GenderComboBox->insertItem( tr( "Male" ) ); |
84 | GenderComboBox->insertItem( tr( "Female" ) ); | 84 | GenderComboBox->insertItem( tr( "Female" ) ); |
85 | GenderComboBox->insertItem( tr( "Unknown" ) ); | 85 | GenderComboBox->insertItem( tr( "Unknown" ) ); |
86 | Layout4->addWidget( GenderComboBox ); | 86 | Layout4->addWidget( GenderComboBox ); |
87 | 87 | ||
88 | TextLabel4 = new QLabel( this, "TextLabel4" ); | 88 | TextLabel4 = new QLabel( this, "TextLabel4" ); |
89 | TextLabel4->setText( tr( "Gender" ) ); | 89 | TextLabel4->setText( tr( "Gender" ) ); |
90 | Layout4->addWidget( TextLabel4 ); | 90 | Layout4->addWidget( TextLabel4 ); |
91 | Layout7->addLayout( Layout4 ); | 91 | Layout7->addLayout( Layout4 ); |
92 | 92 | ||
93 | Layout6 = new QHBoxLayout; | 93 | Layout6 = new QHBoxLayout; |
94 | Layout6->setSpacing( 6 ); | 94 | Layout6->setSpacing( 6 ); |
95 | Layout6->setMargin( 0 ); | 95 | Layout6->setMargin( 0 ); |
96 | 96 | ||
97 | TypeDrinkComboBox = new QComboBox( FALSE,this, "TypeDrinkComboBox" ); | 97 | TypeDrinkComboBox = new QComboBox( FALSE,this, "TypeDrinkComboBox" ); |
98 | TypeDrinkComboBox->insertItem( tr( "Beer" ) ); | 98 | TypeDrinkComboBox->insertItem( tr( "Beer" ) ); |
99 | TypeDrinkComboBox->insertItem( tr( "Wine" ) ); | 99 | TypeDrinkComboBox->insertItem( tr( "Wine" ) ); |
100 | TypeDrinkComboBox->insertItem( tr( "Shot" ) ); | 100 | TypeDrinkComboBox->insertItem( tr( "Shot" ) ); |
101 | Layout6->addWidget( TypeDrinkComboBox ); | 101 | Layout6->addWidget( TypeDrinkComboBox ); |
102 | 102 | ||
103 | TextLabel1_2 = new QLabel( this, "TextLabel1_2" ); | 103 | TextLabel1_2 = new QLabel( this, "TextLabel1_2" ); |
104 | TextLabel1_2->setText( tr( "Type of drink" ) ); | 104 | TextLabel1_2->setText( tr( "Type of drink" ) ); |
105 | Layout6->addWidget( TextLabel1_2 ); | 105 | Layout6->addWidget( TextLabel1_2 ); |
106 | Layout7->addLayout( Layout6 ); | 106 | Layout7->addLayout( Layout6 ); |
107 | 107 | ||
108 | PushButton1 = new QPushButton( this, "PushButton1" ); | 108 | PushButton1 = new QPushButton( this, "PushButton1" ); |
109 | PushButton1->setText( tr( "Calculate" ) ); | 109 | PushButton1->setText( tr( "Calculate" ) ); |
110 | Layout7->addWidget( PushButton1 ); | 110 | Layout7->addWidget( PushButton1 ); |
111 | connect(PushButton1,SIGNAL( clicked()), this, SLOT( calculate())); | 111 | connect(PushButton1,SIGNAL( clicked()), this, SLOT( calculate())); |
112 | 112 | ||
113 | LCDNumber1 = new QLCDNumber( this, "LCDNumber1" ); | 113 | LCDNumber1 = new QLCDNumber( this, "LCDNumber1" ); |
114 | LCDNumber1->setMaximumHeight( 50); | 114 | LCDNumber1->setMaximumHeight( 50); |
115 | LCDNumber1->setNumDigits(6); | 115 | LCDNumber1->setNumDigits(6); |
116 | LCDNumber1->setSmallDecimalPoint(TRUE); | 116 | LCDNumber1->setSmallDecimalPoint(TRUE); |
117 | LCDNumber1->setFrameStyle(QFrame::Box); | 117 | LCDNumber1->setFrameStyle(QFrame::Box); |
118 | LCDNumber1->setLineWidth(2); | 118 | LCDNumber1->setLineWidth(2); |
119 | LCDNumber1->setSegmentStyle( QLCDNumber::Filled); | 119 | LCDNumber1->setSegmentStyle( QLCDNumber::Filled); |
120 | QPalette palette = LCDNumber1->palette(); | 120 | QPalette palette = LCDNumber1->palette(); |
121 | palette.setColor(QPalette::Normal, QColorGroup::Foreground, Qt::red); | 121 | palette.setColor(QPalette::Normal, QColorGroup::Foreground, Qt::red); |
122 | palette.setColor(QPalette::Normal, QColorGroup::Light, Qt::black); | 122 | palette.setColor(QPalette::Normal, QColorGroup::Light, Qt::black); |
123 | palette.setColor(QPalette::Normal, QColorGroup::Dark, Qt::darkGreen); | 123 | palette.setColor(QPalette::Normal, QColorGroup::Dark, Qt::darkGreen); |
124 | LCDNumber1->setPalette(palette); | 124 | LCDNumber1->setPalette(palette); |
125 | 125 | ||
126 | Layout7->addWidget( LCDNumber1 ); | 126 | Layout7->addWidget( LCDNumber1 ); |
127 | NumberSpinBox->setFocus(); | 127 | NumberSpinBox->setFocus(); |
128 | } | 128 | } |
129 | 129 | ||
130 | BacDialog::~BacDialog() | 130 | BacDialog::~BacDialog() |
131 | {} | 131 | {} |
132 | 132 | ||
133 | void BacDialog::calculate() | 133 | void BacDialog::calculate() |
134 | { | 134 | { |
135 | 135 | ||
136 | float weight,genderDiff, bac, typeDrink=0, drinkOz=0, bodyWater, milliliters, oz, gram, gramsMil, alc, metab, bac1; | 136 | float weight,genderDiff, bac, typeDrink=0, drinkOz=0, bodyWater, milliliters, oz, gram, gramsMil, alc, metab, bac1; |
137 | float weightunitDifference, massunitdiff; | ||
138 | QString estBac; | 137 | QString estBac; |
139 | 138 | ||
140 | if( GenderComboBox->currentItem()==0) | 139 | if( GenderComboBox->currentItem()==0) |
141 | genderDiff = .58; | 140 | genderDiff = .58; |
142 | else | 141 | else |
143 | genderDiff = .49; | 142 | genderDiff = .49; |
144 | 143 | ||
145 | switch(TypeDrinkComboBox->currentItem()) { | 144 | switch(TypeDrinkComboBox->currentItem()) { |
146 | case 0: { //beer | 145 | case 0: { //beer |
147 | typeDrink = .045; | 146 | typeDrink = .045; |
148 | drinkOz = 12; | 147 | drinkOz = 12; |
149 | } | 148 | } |
150 | break; | 149 | break; |
151 | case 1: { | 150 | case 1: { |
152 | typeDrink = .2; | 151 | typeDrink = .2; |
153 | drinkOz = 4; | 152 | drinkOz = 4; |
154 | } | 153 | } |
155 | break; | 154 | break; |
156 | case 2: { | 155 | case 2: { |
157 | typeDrink = .5; | 156 | typeDrink = .5; |
158 | drinkOz = 1.5; | 157 | drinkOz = 1.5; |
159 | } | 158 | } |
160 | break; | 159 | break; |
161 | }; | 160 | }; |
162 | 161 | ||
163 | if( weightUnitsCombo->currentItem() == 0 ) { | 162 | if( weightUnitsCombo->currentItem() == 0 ) { |
164 | weight = WeightSpinBox->value(); // kilos | 163 | weight = WeightSpinBox->value(); // kilos |
165 | } else { | 164 | } else { |
166 | weight = WeightSpinBox->value() / 2.2046; // convert to kilograms | 165 | weight = WeightSpinBox->value() / 2.2046; // convert to kilograms |
167 | } | 166 | } |
168 | bodyWater = weight * genderDiff; | 167 | bodyWater = weight * genderDiff; |
169 | milliliters = bodyWater * 1000; | 168 | milliliters = bodyWater * 1000; |
170 | oz = 23.36/milliliters; | 169 | oz = 23.36/milliliters; |
171 | gram = oz * .806; | 170 | gram = oz * .806; |
172 | gramsMil = gram * 100; | 171 | gramsMil = gram * 100; |
173 | alc = drinkOz*NumberSpinBox->value() * typeDrink; | 172 | alc = drinkOz*NumberSpinBox->value() * typeDrink; |
174 | metab = TimeSpinBox->value() * .012; | 173 | metab = TimeSpinBox->value() * .012; |
175 | bac1 = gramsMil * alc; | 174 | bac1 = gramsMil * alc; |
176 | bac = bac1 - metab; | 175 | bac = bac1 - metab; |
177 | 176 | ||
178 | // weightDrink= (nDrinks * .79) / (weight * genderDiff*1000); | 177 | // weightDrink= (nDrinks * .79) / (weight * genderDiff*1000); |
179 | // (ounces * percent * 0.075 / weight) - (hours * 0.015); | 178 | // (ounces * percent * 0.075 / weight) - (hours * 0.015); |
180 | // bac = (((weightDrink * .806) * 100) * .54);// - (time * .012); // assuming beer of 4.5% | 179 | // bac = (((weightDrink * .806) * 100) * .54);// - (time * .012); // assuming beer of 4.5% |
181 | estBac.sprintf("%f",bac); | 180 | estBac.sprintf("%f",bac); |
182 | LCDNumber1->display(bac); | 181 | LCDNumber1->display(bac); |
183 | // BACTextLabel->setText(estBac ); | 182 | // BACTextLabel->setText(estBac ); |
184 | } | 183 | } |
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp index 124b6f3..020a116 100644 --- a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp +++ b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp | |||
@@ -1,422 +1,422 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | // LibraryDialog.cpp - description | 2 | // LibraryDialog.cpp - description |
3 | // ------------------- | 3 | // ------------------- |
4 | // begin : Sat Aug 19 2000 | 4 | // begin : Sat Aug 19 2000 |
5 | // copyright : (C) 2000 - 2004 by llornkcor | 5 | // copyright : (C) 2000 - 2004 by llornkcor |
6 | // email : ljp@llornkcor.com | 6 | // email : ljp@llornkcor.com |
7 | // ***************************************************/ | 7 | // ***************************************************/ |
8 | // /*************************************************************************** | 8 | // /*************************************************************************** |
9 | // * This program is free software; you can redistribute it and/or modify * | 9 | // * This program is free software; you can redistribute it and/or modify * |
10 | // * it under the terms of the GNU General Public License as published by * | 10 | // * it under the terms of the GNU General Public License as published by * |
11 | // * the Free Software Foundation; either version 2 of the License, or * | 11 | // * the Free Software Foundation; either version 2 of the License, or * |
12 | // * (at your option) any later version. * | 12 | // * (at your option) any later version. * |
13 | // ***************************************************************************/ | 13 | // ***************************************************************************/ |
14 | //ftp://ibiblio.org/pub/docs/books/gutenberg/GUTINDEX.ALL | 14 | //ftp://ibiblio.org/pub/docs/books/gutenberg/GUTINDEX.ALL |
15 | 15 | ||
16 | #include "LibraryDialog.h" | 16 | #include "LibraryDialog.h" |
17 | #include "output.h" | 17 | #include "output.h" |
18 | 18 | ||
19 | /* OPIE */ | 19 | /* OPIE */ |
20 | #include <qpe/applnk.h> | 20 | #include <qpe/applnk.h> |
21 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | #include <qpe/qpedialog.h> | 22 | #include <qpe/qpedialog.h> |
23 | #include <opie2/odebug.h> | 23 | #include <opie2/odebug.h> |
24 | 24 | ||
25 | /* QT */ | 25 | /* QT */ |
26 | #include <qpushbutton.h> | 26 | #include <qpushbutton.h> |
27 | #include <qmultilineedit.h> | 27 | #include <qmultilineedit.h> |
28 | //#include <qlayout.h> | 28 | //#include <qlayout.h> |
29 | 29 | ||
30 | /* STD */ | 30 | /* STD */ |
31 | #include <unistd.h> | 31 | #include <unistd.h> |
32 | #include <stdio.h> | 32 | #include <stdio.h> |
33 | #include <stdlib.h> | 33 | #include <stdlib.h> |
34 | 34 | ||
35 | /* | 35 | /* |
36 | * The dialog will by default be modeless, unless you set 'modal' to | 36 | * The dialog will by default be modeless, unless you set 'modal' to |
37 | * TRUE to construct a modal dialog. */ | 37 | * TRUE to construct a modal dialog. */ |
38 | LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool modal, WFlags fl ) | 38 | LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool /*modal*/, WFlags fl ) |
39 | : QDialog( parent, name, true/* modal*/, fl ) | 39 | : QDialog( parent, name, true/* modal*/, fl ) |
40 | { | 40 | { |
41 | if ( !name ) | 41 | if ( !name ) |
42 | setName( "LibraryDialog" ); | 42 | setName( "LibraryDialog" ); |
43 | indexLoaded=false; | 43 | indexLoaded=false; |
44 | initDialog(); | 44 | initDialog(); |
45 | 45 | ||
46 | // this->setMaximumWidth(240); | 46 | // this->setMaximumWidth(240); |
47 | 47 | ||
48 | index = "GUTINDEX.ALL"; | 48 | index = "GUTINDEX.ALL"; |
49 | local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; | 49 | local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; |
50 | local_index = local_library + index; | 50 | local_index = local_library + index; |
51 | 51 | ||
52 | QString iniFile ; | 52 | QString iniFile ; |
53 | iniFile = QPEApplication::qpeDir()+"/etc/gutenbrowser/gutenbrowserrc"; | 53 | iniFile = QPEApplication::qpeDir()+"/etc/gutenbrowser/gutenbrowserrc"; |
54 | 54 | ||
55 | new_index =QPEApplication::qpeDir()+"/etc/gutenbrowser/PGWHOLE.TXT"; | 55 | new_index =QPEApplication::qpeDir()+"/etc/gutenbrowser/PGWHOLE.TXT"; |
56 | 56 | ||
57 | old_index = QPEApplication::qpeDir()+"/etc/gutenbrowser/GUTINDEX.ALL"; | 57 | old_index = QPEApplication::qpeDir()+"/etc/gutenbrowser/GUTINDEX.ALL"; |
58 | // old_index = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; | 58 | // old_index = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; |
59 | 59 | ||
60 | // iniFile = local_library+"gutenbrowserrc"; | 60 | // iniFile = local_library+"gutenbrowserrc"; |
61 | // new_index = local_library + "PGWHOLE.TXT"; | 61 | // new_index = local_library + "PGWHOLE.TXT"; |
62 | // old_index = local_library + "GUTINDEX.ALL"; | 62 | // old_index = local_library + "GUTINDEX.ALL"; |
63 | 63 | ||
64 | Config config("Gutenbrowser"); | 64 | Config config("Gutenbrowser"); |
65 | 65 | ||
66 | config.setGroup( "HttpServer" ); | 66 | config.setGroup( "HttpServer" ); |
67 | proxy_http = config.readEntry("Preferred", "http://sailor.gutenbook.org"); | 67 | proxy_http = config.readEntry("Preferred", "http://sailor.gutenbook.org"); |
68 | 68 | ||
69 | config.setGroup( "FTPsite" ); | 69 | config.setGroup( "FTPsite" ); |
70 | ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org"); | 70 | ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org"); |
71 | odebug << "Library Dialog: ftp_host is "+ftp_host << oendl; | 71 | odebug << "Library Dialog: ftp_host is "+ftp_host << oendl; |
72 | // ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,TRUE)+1) ); | 72 | // ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,TRUE)+1) ); |
73 | // ftp_host=ftp_host.stripWhiteSpace(); | 73 | // ftp_host=ftp_host.stripWhiteSpace(); |
74 | ftp_base_dir= config.readEntry("base", "/pub/gutenberg"); | 74 | ftp_base_dir= config.readEntry("base", "/pub/gutenberg"); |
75 | 75 | ||
76 | i_binary = 0; | 76 | i_binary = 0; |
77 | 77 | ||
78 | config.setGroup("SortAuth"); | 78 | config.setGroup("SortAuth"); |
79 | if( config.readEntry("authSort", "FALSE") == "TRUE") | 79 | if( config.readEntry("authSort", "FALSE") == "TRUE") |
80 | authBox->setChecked(TRUE); | 80 | authBox->setChecked(TRUE); |
81 | 81 | ||
82 | config.setGroup("General"); | 82 | config.setGroup("General"); |
83 | downDir =config.readEntry( "DownloadDirectory",local_library); | 83 | downDir =config.readEntry( "DownloadDirectory",local_library); |
84 | odebug << "downDir is "+downDir << oendl; | 84 | odebug << "downDir is "+downDir << oendl; |
85 | newindexLib.setName( old_index); | 85 | newindexLib.setName( old_index); |
86 | indexLib.setName( old_index); | 86 | indexLib.setName( old_index); |
87 | 87 | ||
88 | new QPEDialogListener(this); | 88 | new QPEDialogListener(this); |
89 | QTimer::singleShot( 1000, this, SLOT( FindLibrary()) ); | 89 | QTimer::singleShot( 1000, this, SLOT( FindLibrary()) ); |
90 | 90 | ||
91 | } | 91 | } |
92 | 92 | ||
93 | LibraryDialog::~LibraryDialog() | 93 | LibraryDialog::~LibraryDialog() |
94 | { | 94 | { |
95 | // delete QList_Item2; | 95 | // delete QList_Item2; |
96 | // delete QList_Item1; | 96 | // delete QList_Item1; |
97 | // delete QList_Item3; | 97 | // delete QList_Item3; |
98 | // delete QList_Item4; | 98 | // delete QList_Item4; |
99 | // delete QList_Item5; | 99 | // delete QList_Item5; |
100 | 100 | ||
101 | // saveConfig(); | 101 | // saveConfig(); |
102 | } | 102 | } |
103 | 103 | ||
104 | /*This groks using PGWHOLE.TXT */ | 104 | /*This groks using PGWHOLE.TXT */ |
105 | void LibraryDialog::Newlibrary() | 105 | void LibraryDialog::Newlibrary() |
106 | { | 106 | { |
107 | #ifndef Q_WS_QWS //sorry embedded gutenbrowser cant use zip files | 107 | #ifndef Q_WS_QWS //sorry embedded gutenbrowser cant use zip files |
108 | //odebug << "Opening new library index " << newindexLib << "" << oendl; | 108 | //odebug << "Opening new library index " << newindexLib << "" << oendl; |
109 | if ( newindexLib.open( IO_ReadOnly) ) { | 109 | if ( newindexLib.open( IO_ReadOnly) ) { |
110 | setCaption( tr( "Library Index - using master pg index." ) );// file opened successfully | 110 | setCaption( tr( "Library Index - using master pg index." ) );// file opened successfully |
111 | QTextStream indexStream( &newindexLib ); | 111 | QTextStream indexStream( &newindexLib ); |
112 | QString indexLine; | 112 | QString indexLine; |
113 | while ( !indexStream.atEnd() ) { // until end of file.. | 113 | while ( !indexStream.atEnd() ) { // until end of file.. |
114 | indexLine = indexStream.readLine(); | 114 | indexLine = indexStream.readLine(); |
115 | if ( ( indexLine.mid(4,4)).toInt() && !( indexLine.left(3)).toInt()) { | 115 | if ( ( indexLine.mid(4,4)).toInt() && !( indexLine.left(3)).toInt()) { |
116 | year = indexLine.mid(4,4); | 116 | year = indexLine.mid(4,4); |
117 | year = year.stripWhiteSpace(); | 117 | year = year.stripWhiteSpace(); |
118 | file = indexLine.mid( indexLine.find( "[", 0, TRUE )+1, 12 ); | 118 | file = indexLine.mid( indexLine.find( "[", 0, TRUE )+1, 12 ); |
119 | file = file.stripWhiteSpace(); | 119 | file = file.stripWhiteSpace(); |
120 | number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); | 120 | number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); |
121 | if( year.toInt() < 1984) | 121 | if( year.toInt() < 1984) |
122 | number = number.left( number.length() -1 ); | 122 | number = number.left( number.length() -1 ); |
123 | number = number.stripWhiteSpace(); | 123 | number = number.stripWhiteSpace(); |
124 | title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); | 124 | title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); |
125 | title = title.stripWhiteSpace(); | 125 | title = title.stripWhiteSpace(); |
126 | 126 | ||
127 | getAuthor(); // groks author | 127 | getAuthor(); // groks author |
128 | author = author.stripWhiteSpace(); | 128 | author = author.stripWhiteSpace(); |
129 | if (authBox->isChecked()) { // this reverses the first name and last name of the author | 129 | if (authBox->isChecked()) { // this reverses the first name and last name of the author |
130 | // odebug << "Sorting last name first" << oendl; | 130 | // odebug << "Sorting last name first" << oendl; |
131 | QString lastName, firstName=""; | 131 | QString lastName, firstName=""; |
132 | int finder=author.findRev( ' ', -1, TRUE); | 132 | int finder=author.findRev( ' ', -1, TRUE); |
133 | lastName=author.right( author.length()-finder); | 133 | lastName=author.right( author.length()-finder); |
134 | firstName=author.left(finder); | 134 | firstName=author.left(finder); |
135 | lastName=lastName.stripWhiteSpace(); | 135 | lastName=lastName.stripWhiteSpace(); |
136 | firstName=firstName.stripWhiteSpace(); | 136 | firstName=firstName.stripWhiteSpace(); |
137 | 137 | ||
138 | if( lastName.find( firstName, 0, true) == -1) // this avoids dup names | 138 | if( lastName.find( firstName, 0, true) == -1) // this avoids dup names |
139 | author=lastName+", "+firstName; | 139 | author=lastName+", "+firstName; |
140 | } | 140 | } |
141 | 141 | ||
142 | if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) && (file.find( "]",0, TRUE) == -1) ) { | 142 | if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) && (file.find( "]",0, TRUE) == -1) ) { |
143 | 143 | ||
144 | // fill string list or something to be able to resort the whole library | 144 | // fill string list or something to be able to resort the whole library |
145 | if( author.isEmpty() ) | 145 | if( author.isEmpty() ) |
146 | QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); | 146 | QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); |
147 | else { | 147 | else { |
148 | 148 | ||
149 | if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || | 149 | if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || |
150 | (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) | 150 | (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) |
151 | QList_Item1 = new QListViewItem( ListView1,/* number,*/ title, author, year, file ); | 151 | QList_Item1 = new QListViewItem( ListView1,/* number,*/ title, author, year, file ); |
152 | 152 | ||
153 | else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || | 153 | else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || |
154 | (author.left(1) >= QString("g") && author.left(1) <= QString("m")) ) | 154 | (author.left(1) >= QString("g") && author.left(1) <= QString("m")) ) |
155 | QList_Item2 = new QListViewItem( ListView2, /*number, */title, author, year, file ); | 155 | QList_Item2 = new QListViewItem( ListView2, /*number, */title, author, year, file ); |
156 | 156 | ||
157 | else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) || | 157 | else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) || |
158 | (author.left(1) >= QString("n") && author.left(1) <= QString("r")) ) | 158 | (author.left(1) >= QString("n") && author.left(1) <= QString("r")) ) |
159 | QList_Item3 = new QListViewItem( ListView3, /*number,*/ title, author, year, file ); | 159 | QList_Item3 = new QListViewItem( ListView3, /*number,*/ title, author, year, file ); |
160 | 160 | ||
161 | else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || | 161 | else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || |
162 | (author.left(1) >= QString("s") && author.left(1) <= QString("z")) ) | 162 | (author.left(1) >= QString("s") && author.left(1) <= QString("z")) ) |
163 | QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file ); | 163 | QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file ); |
164 | 164 | ||
165 | else | 165 | else |
166 | QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); | 166 | QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); |
167 | } | 167 | } |
168 | } | 168 | } |
169 | }// end if | 169 | }// end if |
170 | }// end while | 170 | }// end while |
171 | newindexLib.close(); | 171 | newindexLib.close(); |
172 | } | 172 | } |
173 | #ifndef Q_WS_QWS | 173 | #ifndef Q_WS_QWS |
174 | setCursor( arrowCursor); | 174 | setCursor( arrowCursor); |
175 | #endif | 175 | #endif |
176 | #endif | 176 | #endif |
177 | } // end Newlibrary() | 177 | } // end Newlibrary() |
178 | 178 | ||
179 | 179 | ||
180 | void LibraryDialog::Library() | 180 | void LibraryDialog::Library() |
181 | {// old library groking method | 181 | {// old library groking method |
182 | 182 | ||
183 | ListView1->clear(); | 183 | ListView1->clear(); |
184 | ListView2->clear(); | 184 | ListView2->clear(); |
185 | ListView3->clear(); | 185 | ListView3->clear(); |
186 | ListView4->clear(); | 186 | ListView4->clear(); |
187 | ListView5->clear(); | 187 | ListView5->clear(); |
188 | 188 | ||
189 | odebug << "opening GUTINDEX.ALL file" << oendl; | 189 | odebug << "opening GUTINDEX.ALL file" << oendl; |
190 | IDontKnowWhy = ""; | 190 | IDontKnowWhy = ""; |
191 | if ( indexLib.open( IO_ReadOnly) ) { // file opened successfully | 191 | if ( indexLib.open( IO_ReadOnly) ) { // file opened successfully |
192 | QTextStream indexStream( &indexLib ); | 192 | QTextStream indexStream( &indexLib ); |
193 | QString indexLine; | 193 | QString indexLine; |
194 | qApp->processEvents(); | 194 | qApp->processEvents(); |
195 | // int jig; | 195 | // int jig; |
196 | while ( !indexStream.eof() ) { | 196 | while ( !indexStream.eof() ) { |
197 | 197 | ||
198 | indexLine = indexStream.readLine(); | 198 | indexLine = indexStream.readLine(); |
199 | if ( indexLine != "") { | 199 | if ( indexLine != "") { |
200 | if( (indexLine.mid(4,4)).toInt() /* && !( indexLine.left(3)).toInt()*/ ) { | 200 | if( (indexLine.mid(4,4)).toInt() /* && !( indexLine.left(3)).toInt()*/ ) { |
201 | // month = indexLine.left( 3); | 201 | // month = indexLine.left( 3); |
202 | year = indexLine.mid(4,4); | 202 | year = indexLine.mid(4,4); |
203 | // title = indexLine.mid( 9, 50); | 203 | // title = indexLine.mid( 9, 50); |
204 | file = indexLine.mid(60,12); | 204 | file = indexLine.mid(60,12); |
205 | if(file.left(1).find("[",0,TRUE) != -1) | 205 | if(file.left(1).find("[",0,TRUE) != -1) |
206 | file.remove(1,1); | 206 | file.remove(1,1); |
207 | if( file.find("]",0,TRUE) != -1) | 207 | if( file.find("]",0,TRUE) != -1) |
208 | file = file.left( file.find("]",0,TRUE)); | 208 | file = file.left( file.find("]",0,TRUE)); |
209 | //odebug << "file is "+file << oendl; | 209 | //odebug << "file is "+file << oendl; |
210 | /// number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); | 210 | /// number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); |
211 | number = indexLine.mid(55,5); | 211 | number = indexLine.mid(55,5); |
212 | number = number.stripWhiteSpace(); | 212 | number = number.stripWhiteSpace(); |
213 | // title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); | 213 | // title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); |
214 | title = indexLine.mid( 9, 50 ); | 214 | title = indexLine.mid( 9, 50 ); |
215 | title = title.stripWhiteSpace(); | 215 | title = title.stripWhiteSpace(); |
216 | //odebug << "title is "+title << oendl; | 216 | //odebug << "title is "+title << oendl; |
217 | getAuthor(); // grok author | 217 | getAuthor(); // grok author |
218 | author = author.stripWhiteSpace(); | 218 | author = author.stripWhiteSpace(); |
219 | //odebug << "author is "+author << oendl; | 219 | //odebug << "author is "+author << oendl; |
220 | if (authBox->isChecked() == TRUE) { // this reverses the first name and last name of the author | 220 | if (authBox->isChecked() == TRUE) { // this reverses the first name and last name of the author |
221 | QString lastName, firstName=""; | 221 | QString lastName, firstName=""; |
222 | int finder=author.findRev( ' ', -1, TRUE); | 222 | int finder=author.findRev( ' ', -1, TRUE); |
223 | lastName=author.right( author.length()-finder); | 223 | lastName=author.right( author.length()-finder); |
224 | firstName=author.left(finder); | 224 | firstName=author.left(finder); |
225 | lastName=lastName.stripWhiteSpace(); | 225 | lastName=lastName.stripWhiteSpace(); |
226 | firstName=firstName.stripWhiteSpace(); | 226 | firstName=firstName.stripWhiteSpace(); |
227 | 227 | ||
228 | if( lastName.find( firstName, 0, true) == -1) // this avoids dup names | 228 | if( lastName.find( firstName, 0, true) == -1) // this avoids dup names |
229 | author=lastName+", "+firstName; | 229 | author=lastName+", "+firstName; |
230 | } | 230 | } |
231 | 231 | ||
232 | if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) /*&& (file.find( "]",0, TRUE))*/ ) { | 232 | if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) /*&& (file.find( "]",0, TRUE))*/ ) { |
233 | // fill string list or something to be able to sort by Author | 233 | // fill string list or something to be able to sort by Author |
234 | if( author.isEmpty() ) | 234 | if( author.isEmpty() ) |
235 | QList_Item5 = new QListViewItem( ListView5, /*number, */title, author, year, file ); | 235 | QList_Item5 = new QListViewItem( ListView5, /*number, */title, author, year, file ); |
236 | else { | 236 | else { |
237 | if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || | 237 | if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || |
238 | (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) | 238 | (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) |
239 | QList_Item1 = new QListViewItem( ListView1, /* number,*/ title, author, year, file ); | 239 | QList_Item1 = new QListViewItem( ListView1, /* number,*/ title, author, year, file ); |
240 | 240 | ||
241 | else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || | 241 | else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || |
242 | (author.left(1) >= QString("g") && author.left(1) <= QString("m")) ) | 242 | (author.left(1) >= QString("g") && author.left(1) <= QString("m")) ) |
243 | QList_Item2 = new QListViewItem( ListView2, /* number,*/ title, author, year, file ); | 243 | QList_Item2 = new QListViewItem( ListView2, /* number,*/ title, author, year, file ); |
244 | 244 | ||
245 | else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) || | 245 | else if( (author.left(1) >= QString("N") && author.left(1) <= QString("R")) || |
246 | (author.left(1) >= QString("n") && author.left(1) <= QString("r")) ) | 246 | (author.left(1) >= QString("n") && author.left(1) <= QString("r")) ) |
247 | QList_Item3 = new QListViewItem( ListView3, /* number,*/ title, author, year, file ); | 247 | QList_Item3 = new QListViewItem( ListView3, /* number,*/ title, author, year, file ); |
248 | 248 | ||
249 | else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || | 249 | else if( (author.left(1) >= QString("S") && author.left(1) <= QString("Z")) || |
250 | (author.left(1) >= QString("s") && author.left(1) <= QString("z")) ) | 250 | (author.left(1) >= QString("s") && author.left(1) <= QString("z")) ) |
251 | QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file ); | 251 | QList_Item4 = new QListViewItem( ListView4, /* number,*/ title, author, year, file ); |
252 | } | 252 | } |
253 | } | 253 | } |
254 | } | 254 | } |
255 | } | 255 | } |
256 | } | 256 | } |
257 | indexLib.close(); | 257 | indexLib.close(); |
258 | } else { | 258 | } else { |
259 | QString sMsg; | 259 | QString sMsg; |
260 | sMsg = ( tr("<p>Error opening local library index:</P> "))+local_index; | 260 | sMsg = ( tr("<p>Error opening local library index:</P> "))+local_index; |
261 | QMessageBox::message( "Error",sMsg); | 261 | QMessageBox::message( "Error",sMsg); |
262 | } | 262 | } |
263 | 263 | ||
264 | } //end Library() | 264 | } //end Library() |
265 | 265 | ||
266 | 266 | ||
267 | /* | 267 | /* |
268 | Groks the author out of the title */ | 268 | Groks the author out of the title */ |
269 | bool LibraryDialog::getAuthor() | 269 | bool LibraryDialog::getAuthor() |
270 | { | 270 | { |
271 | if( title.contains( ", by", TRUE)) { | 271 | if( title.contains( ", by", TRUE)) { |
272 | int auth; | 272 | int auth; |
273 | auth = title.find(", by", 0, TRUE); | 273 | auth = title.find(", by", 0, TRUE); |
274 | author = title.right(title.length() - (auth + 4) ); | 274 | author = title.right(title.length() - (auth + 4) ); |
275 | if( int finder = author.find("[", 0, TRUE)) { | 275 | if( int finder = author.find("[", 0, TRUE)) { |
276 | author = author.left(finder); | 276 | author = author.left(finder); |
277 | } | 277 | } |
278 | } | 278 | } |
279 | else if ( title.contains( "by, ", TRUE) ) { | 279 | else if ( title.contains( "by, ", TRUE) ) { |
280 | int auth; | 280 | int auth; |
281 | auth = title.find("by, ", 0, TRUE); | 281 | auth = title.find("by, ", 0, TRUE); |
282 | author = title.right(title.length() - (auth + 4) ); | 282 | author = title.right(title.length() - (auth + 4) ); |
283 | if( int finder = author.find("[", 0, TRUE)) { | 283 | if( int finder = author.find("[", 0, TRUE)) { |
284 | author = author.left( finder); | 284 | author = author.left( finder); |
285 | } | 285 | } |
286 | } | 286 | } |
287 | else if ( title.contains( " by", TRUE) ) { | 287 | else if ( title.contains( " by", TRUE) ) { |
288 | int auth; | 288 | int auth; |
289 | auth = title.find(" by", 0, TRUE); | 289 | auth = title.find(" by", 0, TRUE); |
290 | author = title.right(title.length() - (auth + 3) ); | 290 | author = title.right(title.length() - (auth + 3) ); |
291 | if( int finder = author.find("[", 0, TRUE)) { | 291 | if( int finder = author.find("[", 0, TRUE)) { |
292 | author = author.left( finder); | 292 | author = author.left( finder); |
293 | } | 293 | } |
294 | } | 294 | } |
295 | else if ( title.contains( "by ", TRUE) ) { | 295 | else if ( title.contains( "by ", TRUE) ) { |
296 | int auth; | 296 | int auth; |
297 | auth = title.find("by ", 0, TRUE); | 297 | auth = title.find("by ", 0, TRUE); |
298 | author = title.right(title.length() - (auth + 3) ); | 298 | author = title.right(title.length() - (auth + 3) ); |
299 | if( int finder = author.find("[", 0, TRUE)) { | 299 | if( int finder = author.find("[", 0, TRUE)) { |
300 | author = author.left( finder); | 300 | author = author.left( finder); |
301 | } | 301 | } |
302 | } | 302 | } |
303 | else if ( title.contains( ",", TRUE) ) { | 303 | else if ( title.contains( ",", TRUE) ) { |
304 | int auth; | 304 | int auth; |
305 | auth = title.find(",", 0, TRUE); | 305 | auth = title.find(",", 0, TRUE); |
306 | author = title.right( title.length() - (auth + 1) ); | 306 | author = title.right( title.length() - (auth + 1) ); |
307 | if ( author.contains( ",", TRUE) ) { | 307 | if ( author.contains( ",", TRUE) ) { |
308 | int auth; | 308 | int auth; |
309 | auth = author.find(",", 0, TRUE); | 309 | auth = author.find(",", 0, TRUE); |
310 | author = author.right( author.length() - (auth + 1) ); | 310 | author = author.right( author.length() - (auth + 1) ); |
311 | } | 311 | } |
312 | if( int finder = author.find("[", 0, TRUE)) { | 312 | if( int finder = author.find("[", 0, TRUE)) { |
313 | author = author.left( finder); | 313 | author = author.left( finder); |
314 | } | 314 | } |
315 | } | 315 | } |
316 | else if ( title.contains( "/", TRUE) ) { | 316 | else if ( title.contains( "/", TRUE) ) { |
317 | int auth; | 317 | int auth; |
318 | auth = title.find("/", 0, TRUE); | 318 | auth = title.find("/", 0, TRUE); |
319 | author = title.right(title.length() - (auth + 1) ); | 319 | author = title.right(title.length() - (auth + 1) ); |
320 | if( int finder = author.find("[", 0, TRUE)) { | 320 | if( int finder = author.find("[", 0, TRUE)) { |
321 | author = author.left( finder); | 321 | author = author.left( finder); |
322 | } | 322 | } |
323 | } | 323 | } |
324 | else if ( title.contains( "of", TRUE) ) { | 324 | else if ( title.contains( "of", TRUE) ) { |
325 | int auth; | 325 | int auth; |
326 | auth = title.find("of", 0, TRUE); | 326 | auth = title.find("of", 0, TRUE); |
327 | author = title.right(title.length() - (auth + 2) ); | 327 | author = title.right(title.length() - (auth + 2) ); |
328 | if( int finder = author.find("[", 0, TRUE)) | 328 | if( int finder = author.find("[", 0, TRUE)) |
329 | { | 329 | { |
330 | author = author.left( finder); | 330 | author = author.left( finder); |
331 | } | 331 | } |
332 | } else { | 332 | } else { |
333 | author = ""; | 333 | author = ""; |
334 | } | 334 | } |
335 | if ( author.contains("et. al")) { | 335 | if ( author.contains("et. al")) { |
336 | int auth; | 336 | int auth; |
337 | auth = author.find("et. al", 0, TRUE); | 337 | auth = author.find("et. al", 0, TRUE); |
338 | author = author.left( auth ); | 338 | author = author.left( auth ); |
339 | } | 339 | } |
340 | if ( author.contains("#")) { | 340 | if ( author.contains("#")) { |
341 | int auth; | 341 | int auth; |
342 | auth = author.find("#", 0, TRUE); | 342 | auth = author.find("#", 0, TRUE); |
343 | author = author.left( auth); | 343 | author = author.left( auth); |
344 | } | 344 | } |
345 | if ( author.contains("(")) { | 345 | if ( author.contains("(")) { |
346 | int auth; | 346 | int auth; |
347 | auth = author.find("(", 0, TRUE); | 347 | auth = author.find("(", 0, TRUE); |
348 | author = author.left( auth); | 348 | author = author.left( auth); |
349 | } | 349 | } |
350 | if ( author.contains("et al")) { | 350 | if ( author.contains("et al")) { |
351 | int auth; | 351 | int auth; |
352 | auth = author.find("et al", 0, TRUE); | 352 | auth = author.find("et al", 0, TRUE); |
353 | author = author.left( auth ); | 353 | author = author.left( auth ); |
354 | } | 354 | } |
355 | QRegExp r = QRegExp("[0-9]", TRUE, FALSE); | 355 | QRegExp r = QRegExp("[0-9]", TRUE, FALSE); |
356 | if ( author.left(2).find( r) != -1 ) { | 356 | if ( author.left(2).find( r) != -1 ) { |
357 | author = ""; | 357 | author = ""; |
358 | } | 358 | } |
359 | // if( author.contains(" ", TRUE)) { | 359 | // if( author.contains(" ", TRUE)) { |
360 | // int suth = author.findRev(" ", -1, TRUE); | 360 | // int suth = author.findRev(" ", -1, TRUE); |
361 | // author = author.right( author.length() - suth); | 361 | // author = author.right( author.length() - suth); |
362 | // } | 362 | // } |
363 | 363 | ||
364 | // title | 364 | // title |
365 | // author | 365 | // author |
366 | return true; | 366 | return true; |
367 | }////// end getAuthor() | 367 | }////// end getAuthor() |
368 | 368 | ||
369 | /* | 369 | /* |
370 | selected one etext*/ | 370 | selected one etext*/ |
371 | void LibraryDialog::select_title( QListViewItem * item) | 371 | void LibraryDialog::select_title( QListViewItem * item) |
372 | { | 372 | { |
373 | if(item != NULL) { | 373 | if(item != NULL) { |
374 | i++; | 374 | i++; |
375 | int index = tabWidget->currentPageIndex(); | 375 | int index = tabWidget->currentPageIndex(); |
376 | DlglistItemTitle = item->text(0); | 376 | DlglistItemTitle = item->text(0); |
377 | DlglistItemYear = item->text(2); | 377 | DlglistItemYear = item->text(2); |
378 | DlglistItemFile = item->text(3); | 378 | DlglistItemFile = item->text(3); |
379 | switch (index) { | 379 | switch (index) { |
380 | case 0: { | 380 | case 0: { |
381 | ListView1->clearSelection(); | 381 | ListView1->clearSelection(); |
382 | } | 382 | } |
383 | break; | 383 | break; |
384 | case 1: { | 384 | case 1: { |
385 | ListView2->clearSelection(); | 385 | ListView2->clearSelection(); |
386 | } | 386 | } |
387 | break; | 387 | break; |
388 | case 2: { | 388 | case 2: { |
389 | ListView3->clearSelection(); | 389 | ListView3->clearSelection(); |
390 | } | 390 | } |
391 | break; | 391 | break; |
392 | case 3: { | 392 | case 3: { |
393 | ListView4->clearSelection(); | 393 | ListView4->clearSelection(); |
394 | } | 394 | } |
395 | break; | 395 | break; |
396 | case 4: { | 396 | case 4: { |
397 | ListView5->clearSelection(); | 397 | ListView5->clearSelection(); |
398 | } | 398 | } |
399 | break; | 399 | break; |
400 | }; | 400 | }; |
401 | } | 401 | } |
402 | 402 | ||
403 | if(DlglistItemTitle.length()>2) { | 403 | if(DlglistItemTitle.length()>2) { |
404 | // DlglistItemNumber = item->text(0); | 404 | // DlglistItemNumber = item->text(0); |
405 | item = 0; | 405 | item = 0; |
406 | odebug << "string from librarydialog is:" << DlglistItemYear << " " << DlglistItemFile << " " << DlglistItemNumber << "" << oendl; | 406 | odebug << "string from librarydialog is:" << DlglistItemYear << " " << DlglistItemFile << " " << DlglistItemNumber << "" << oendl; |
407 | odebug << "Title is "+DlglistItemTitle << oendl; | 407 | odebug << "Title is "+DlglistItemTitle << oendl; |
408 | 408 | ||
409 | // check for connection here | 409 | // check for connection here |
410 | // if( get_extext()) | 410 | // if( get_extext()) |
411 | 411 | ||
412 | if(download_Etext()) { | 412 | if(download_Etext()) { |
413 | // odebug << "get here 2" << oendl; | 413 | // odebug << "get here 2" << oendl; |
414 | if(i_binary == 1) { | 414 | if(i_binary == 1) { |
415 | 415 | ||
416 | } | 416 | } |
417 | if(checkBox->isChecked () ) { | 417 | if(checkBox->isChecked () ) { |
418 | accept(); | 418 | accept(); |
419 | } | 419 | } |
420 | } | 420 | } |
421 | } | 421 | } |
422 | } | 422 | } |
diff --git a/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp b/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp index af14aac..a321952 100644 --- a/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp +++ b/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp | |||
@@ -1,279 +1,279 @@ | |||
1 | // /*************************************************************************** | 1 | // /*************************************************************************** |
2 | // NetworkDialog.cpp - description | 2 | // NetworkDialog.cpp - description |
3 | // begin : Sun Aug 27 2000 | 3 | // begin : Sun Aug 27 2000 |
4 | // copyright : (C) 2000 - 2004 by L.J. Potter | 4 | // copyright : (C) 2000 - 2004 by L.J. Potter |
5 | // email : ljp@llornkcor.com | 5 | // email : ljp@llornkcor.com |
6 | // * This program is free software; you can redistribute it and/or modify * | 6 | // * This program is free software; you can redistribute it and/or modify * |
7 | // * it under the terms of the GNU General Public License as published by * | 7 | // * it under the terms of the GNU General Public License as published by * |
8 | // * the Free Software Foundation; either version 2 of the License, or * | 8 | // * the Free Software Foundation; either version 2 of the License, or * |
9 | // * (at your option) any later version. * | 9 | // * (at your option) any later version. * |
10 | // ***************************************************************************/ | 10 | // ***************************************************************************/ |
11 | // // half-assed attempt at providing a network dialog. | 11 | // // half-assed attempt at providing a network dialog. |
12 | // /* Created: Sun Aug 27 15:24:52 2000*/ | 12 | // /* Created: Sun Aug 27 15:24:52 2000*/ |
13 | 13 | ||
14 | 14 | ||
15 | #include "NetworkDialog.h" | 15 | #include "NetworkDialog.h" |
16 | #include "gutenbrowser.h" | 16 | #include "gutenbrowser.h" |
17 | 17 | ||
18 | /* OPIE */ | 18 | /* OPIE */ |
19 | #include <opie2/odebug.h> | 19 | #include <opie2/odebug.h> |
20 | 20 | ||
21 | /* QT */ | 21 | /* QT */ |
22 | #include <qprogressbar.h> | 22 | #include <qprogressbar.h> |
23 | #include <qstringlist.h> | 23 | #include <qstringlist.h> |
24 | #include <qpe/config.h> | 24 | #include <qpe/config.h> |
25 | #include <qvaluelist.h> | 25 | #include <qvaluelist.h> |
26 | #include <qapplication.h> | 26 | #include <qapplication.h> |
27 | #include <qfile.h> | 27 | #include <qfile.h> |
28 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | #include <qlayout.h> | 31 | #include <qlayout.h> |
32 | 32 | ||
33 | /* STD */ | 33 | /* STD */ |
34 | #include <unistd.h> | 34 | #include <unistd.h> |
35 | extern "C" { | 35 | extern "C" { |
36 | #include <ftplib.h> | 36 | #include <ftplib.h> |
37 | } | 37 | } |
38 | 38 | ||
39 | QProgressBar* ProgressBar1; | 39 | QProgressBar* ProgressBar1; |
40 | QPushButton* buttonCancel; | 40 | QPushButton* buttonCancel; |
41 | static netbuf *conn = NULL; | 41 | static netbuf *conn = NULL; |
42 | 42 | ||
43 | static int log_progress(netbuf *ctl, int xfered, void *arg) { | 43 | static int log_progress(netbuf *, int xfered, void *arg) { |
44 | int fsz = *(int *)arg; | 44 | int fsz = *(int *)arg; |
45 | int pct = (xfered * 100) / fsz; | 45 | int pct = (xfered * 100) / fsz; |
46 | printf("%3d%%\r", pct); | 46 | printf("%3d%%\r", pct); |
47 | fflush(stdout); | 47 | fflush(stdout); |
48 | ProgressBar1->setProgress(xfered); | 48 | ProgressBar1->setProgress(xfered); |
49 | qApp->processEvents(); | 49 | qApp->processEvents(); |
50 | 50 | ||
51 | return 1; | 51 | return 1; |
52 | } | 52 | } |
53 | 53 | ||
54 | NetworkDialog::NetworkDialog( QWidget* parent, const char* name, bool modal, WFlags fl, const QStringList netL) | 54 | NetworkDialog::NetworkDialog( QWidget* parent, const char* name, bool modal, WFlags fl, const QStringList netL) |
55 | : QDialog( parent, name, modal, fl ) | 55 | : QDialog( parent, name, modal, fl ) |
56 | { | 56 | { |
57 | 57 | ||
58 | ftp_host = netL[0]; | 58 | ftp_host = netL[0]; |
59 | networkUrl = strUrl = netL[0]; | 59 | networkUrl = strUrl = netL[0]; |
60 | 60 | ||
61 | dir = ftp_base_dir = netL[1]; | 61 | dir = ftp_base_dir = netL[1]; |
62 | localFileName = netL[2]; | 62 | localFileName = netL[2]; |
63 | s_partialFileName = netL[3]; | 63 | s_partialFileName = netL[3]; |
64 | 64 | ||
65 | resize(240,120); | 65 | resize(240,120); |
66 | 66 | ||
67 | local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; | 67 | local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; |
68 | // autoOk = autoDownload; | 68 | // autoOk = autoDownload; |
69 | // if( networkUrl.find("ftp",0,false)== -1 ) { | 69 | // if( networkUrl.find("ftp",0,false)== -1 ) { |
70 | // if ( !name ) | 70 | // if ( !name ) |
71 | // setName( "HTTP NetworkDialog" ); | 71 | // setName( "HTTP NetworkDialog" ); |
72 | // setCaption( tr( "HTTP Download ) ); | 72 | // setCaption( tr( "HTTP Download ) ); |
73 | // qInitNetworkProtocols(); // registers ftp protocol // for now | 73 | // qInitNetworkProtocols(); // registers ftp protocol // for now |
74 | // QNetworkProtocol::registerNetworkProtocol( "http", new QNetworkProtocolFactory<Http> ); | 74 | // QNetworkProtocol::registerNetworkProtocol( "http", new QNetworkProtocolFactory<Http> ); |
75 | // } else { | 75 | // } else { |
76 | if ( !name ) | 76 | if ( !name ) |
77 | setName( "FTP NetworkDialog" ); | 77 | setName( "FTP NetworkDialog" ); |
78 | setCaption(tr("FTP Download")); | 78 | setCaption(tr("FTP Download")); |
79 | // } | 79 | // } |
80 | initDialog(); //opens file to be written | 80 | initDialog(); //opens file to be written |
81 | } | 81 | } |
82 | 82 | ||
83 | NetworkDialog::~NetworkDialog() { | 83 | NetworkDialog::~NetworkDialog() { |
84 | } | 84 | } |
85 | 85 | ||
86 | void NetworkDialog::initDialog() { | 86 | void NetworkDialog::initDialog() { |
87 | 87 | ||
88 | QGridLayout *layout = new QGridLayout( this ); | 88 | QGridLayout *layout = new QGridLayout( this ); |
89 | totalBytesDownloaded=0; | 89 | totalBytesDownloaded=0; |
90 | warnLabel = new QLabel( this, "TextLabel" ); | 90 | warnLabel = new QLabel( this, "TextLabel" ); |
91 | warnLabel ->setText( tr( "Download should start shortly" ) ); | 91 | warnLabel ->setText( tr( "Download should start shortly" ) ); |
92 | TextLabel3 = new QLabel( this, "TextLabel3" ); | 92 | TextLabel3 = new QLabel( this, "TextLabel3" ); |
93 | TextLabel3->setText( ""); | 93 | TextLabel3->setText( ""); |
94 | layout->addMultiCellWidget( warnLabel, 0, 0, 0, 5 ); | 94 | layout->addMultiCellWidget( warnLabel, 0, 0, 0, 5 ); |
95 | layout->addMultiCellWidget( TextLabel3, 1, 1, 0, 5 ); | 95 | layout->addMultiCellWidget( TextLabel3, 1, 1, 0, 5 ); |
96 | 96 | ||
97 | ProgressBar1 = new QProgressBar( this, "ProgressBar1" ); | 97 | ProgressBar1 = new QProgressBar( this, "ProgressBar1" ); |
98 | ProgressBar1->setProgress(0); | 98 | ProgressBar1->setProgress(0); |
99 | layout->addMultiCellWidget( ProgressBar1, 3, 3, 0, 4 ); | 99 | layout->addMultiCellWidget( ProgressBar1, 3, 3, 0, 4 ); |
100 | 100 | ||
101 | // hbox->addStretch(1); | 101 | // hbox->addStretch(1); |
102 | buttonCancel = new QPushButton( this, "buttonCancel" ); | 102 | buttonCancel = new QPushButton( this, "buttonCancel" ); |
103 | buttonCancel->setText( tr( "&Cancel" ) ); | 103 | buttonCancel->setText( tr( "&Cancel" ) ); |
104 | buttonCancel->setAutoDefault( TRUE ); | 104 | buttonCancel->setAutoDefault( TRUE ); |
105 | buttonCancel->setDefault( TRUE ); | 105 | buttonCancel->setDefault( TRUE ); |
106 | layout->addMultiCellWidget( buttonCancel, 3, 3, 5, 5 ); | 106 | layout->addMultiCellWidget( buttonCancel, 3, 3, 5, 5 ); |
107 | 107 | ||
108 | connect(buttonCancel,SIGNAL(clicked()),this,SLOT(reject())); | 108 | connect(buttonCancel,SIGNAL(clicked()),this,SLOT(reject())); |
109 | QTimer::singleShot( 1000, this, SLOT( doOk() )); | 109 | QTimer::singleShot( 1000, this, SLOT( doOk() )); |
110 | 110 | ||
111 | } | 111 | } |
112 | 112 | ||
113 | /* | 113 | /* |
114 | downloads the file networkUrl */ | 114 | downloads the file networkUrl */ |
115 | bool NetworkDialog::downloadFile( QString networkUrl ) | 115 | bool NetworkDialog::downloadFile( QString networkUrl ) |
116 | { | 116 | { |
117 | int fsz; | 117 | int fsz; |
118 | warnLabel ->setText( ""); | 118 | warnLabel ->setText( ""); |
119 | qApp->processEvents(); | 119 | qApp->processEvents(); |
120 | odebug << "Downloading: " << networkUrl << "" << oendl; | 120 | odebug << "Downloading: " << networkUrl << "" << oendl; |
121 | odebug << "Into: " << localFileName << "" << oendl; | 121 | odebug << "Into: " << localFileName << "" << oendl; |
122 | if( networkUrl.length() > 5) { | 122 | if( networkUrl.length() > 5) { |
123 | QString ftp_user = "anonymous"; | 123 | QString ftp_user = "anonymous"; |
124 | QString ftp_pass = "zaurus@gutenbrowser.com"; | 124 | QString ftp_pass = "zaurus@gutenbrowser.com"; |
125 | // ftp_host= networkUrl.mid(networkUrl.find("ftp://",0, TRUE), | 125 | // ftp_host= networkUrl.mid(networkUrl.find("ftp://",0, TRUE), |
126 | if(ftp_host.length() < 2) { | 126 | if(ftp_host.length() < 2) { |
127 | odebug << "Please select an ftp host" << oendl; | 127 | odebug << "Please select an ftp host" << oendl; |
128 | successDownload=false; | 128 | successDownload=false; |
129 | QMessageBox::message("Note","You need to select an ftp host"); | 129 | QMessageBox::message("Note","You need to select an ftp host"); |
130 | return false; | 130 | return false; |
131 | } | 131 | } |
132 | QString msg; | 132 | QString msg; |
133 | odebug << ftp_host << oendl; | 133 | odebug << ftp_host << oendl; |
134 | odebug << "Opening ftp connection." << oendl; | 134 | odebug << "Opening ftp connection." << oendl; |
135 | warnLabel->setText("connecting to: "+ftp_host ); | 135 | warnLabel->setText("connecting to: "+ftp_host ); |
136 | qApp->processEvents(); | 136 | qApp->processEvents(); |
137 | /////////// Open FTP connection | 137 | /////////// Open FTP connection |
138 | if (!FtpConnect( ftp_host.latin1(), &conn)) { | 138 | if (!FtpConnect( ftp_host.latin1(), &conn)) { |
139 | i=0; | 139 | i=0; |
140 | successDownload=false; | 140 | successDownload=false; |
141 | QMessageBox::message("Note","Unable to connect to\n"+ftp_host); | 141 | QMessageBox::message("Note","Unable to connect to\n"+ftp_host); |
142 | return false; | 142 | return false; |
143 | } | 143 | } |
144 | TextLabel3->setText("Opening ftp connection."); | 144 | TextLabel3->setText("Opening ftp connection."); |
145 | qApp->processEvents(); | 145 | qApp->processEvents(); |
146 | if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { | 146 | if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { |
147 | FtpQuit(conn); | 147 | FtpQuit(conn); |
148 | successDownload=false; | 148 | successDownload=false; |
149 | msg.sprintf("Unable to log in\n%s",FtpLastResponse(conn)); | 149 | msg.sprintf("Unable to log in\n%s",FtpLastResponse(conn)); |
150 | QMessageBox::message("Note",msg); | 150 | QMessageBox::message("Note",msg); |
151 | return false; | 151 | return false; |
152 | } | 152 | } |
153 | odebug << "Changing directories." << oendl; | 153 | odebug << "Changing directories." << oendl; |
154 | TextLabel3->setText("Changing directories."); | 154 | TextLabel3->setText("Changing directories."); |
155 | qApp->processEvents(); | 155 | qApp->processEvents(); |
156 | if (!FtpChdir( dir.latin1(), conn )) { | 156 | if (!FtpChdir( dir.latin1(), conn )) { |
157 | successDownload=false; | 157 | successDownload=false; |
158 | msg.sprintf("Unable to change directories "+dir+"\n%s",FtpLastResponse(conn)); | 158 | msg.sprintf("Unable to change directories "+dir+"\n%s",FtpLastResponse(conn)); |
159 | QMessageBox::message("Note",msg); | 159 | QMessageBox::message("Note",msg); |
160 | FtpQuit(conn); | 160 | FtpQuit(conn); |
161 | return false; | 161 | return false; |
162 | } | 162 | } |
163 | // if (!FtpNlst( "./.guten_temp", dir, conn)) { | 163 | // if (!FtpNlst( "./.guten_temp", dir, conn)) { |
164 | // successDownload=false; | 164 | // successDownload=false; |
165 | // msg.sprintf("Unable to change directories "+dir+"\n%s",FtpLastResponse(conn)); | 165 | // msg.sprintf("Unable to change directories "+dir+"\n%s",FtpLastResponse(conn)); |
166 | // QMessageBox::message("Note",msg); | 166 | // QMessageBox::message("Note",msg); |
167 | // FtpQuit(conn); | 167 | // FtpQuit(conn); |
168 | // return false; | 168 | // return false; |
169 | // } | 169 | // } |
170 | odebug << "Requesting directory list." << oendl; | 170 | odebug << "Requesting directory list." << oendl; |
171 | TextLabel3->setText("Getting directory list."); | 171 | TextLabel3->setText("Getting directory list."); |
172 | qApp->processEvents(); | 172 | qApp->processEvents(); |
173 | if (!FtpDir( "./.guten_temp", dir.latin1(), conn) ) { | 173 | if (!FtpDir( "./.guten_temp", dir.latin1(), conn) ) { |
174 | msg.sprintf("Unable to list the directory\n"+dir+"\n%s",FtpLastResponse(conn)); | 174 | msg.sprintf("Unable to list the directory\n"+dir+"\n%s",FtpLastResponse(conn)); |
175 | QMessageBox::message("Note",msg); | 175 | QMessageBox::message("Note",msg); |
176 | successDownload=false; | 176 | successDownload=false; |
177 | FtpQuit(conn); | 177 | FtpQuit(conn); |
178 | return false; | 178 | return false; |
179 | } | 179 | } |
180 | QFile tmp("./.guten_temp"); | 180 | QFile tmp("./.guten_temp"); |
181 | QString s, File_Name; | 181 | QString s, File_Name; |
182 | 182 | ||
183 | if (tmp.open(IO_ReadOnly)) { | 183 | if (tmp.open(IO_ReadOnly)) { |
184 | QTextStream t( &tmp ); // use a text stream | 184 | QTextStream t( &tmp ); // use a text stream |
185 | odebug << "Finding partial filename "+s_partialFileName << oendl; | 185 | odebug << "Finding partial filename "+s_partialFileName << oendl; |
186 | while ( !t.eof()) { | 186 | while ( !t.eof()) { |
187 | s = t.readLine(); | 187 | s = t.readLine(); |
188 | 188 | ||
189 | if (s.contains(s_partialFileName, FALSE)) { | 189 | if (s.contains(s_partialFileName, FALSE)) { |
190 | QString str = s.right( (s.length()) - (s.find(s_partialFileName, FALSE)) ); | 190 | QString str = s.right( (s.length()) - (s.find(s_partialFileName, FALSE)) ); |
191 | 191 | ||
192 | if (str.contains(".txt")) { | 192 | if (str.contains(".txt")) { |
193 | File_Name = str; | 193 | File_Name = str; |
194 | odebug << "Found file_name "+ File_Name << oendl; | 194 | odebug << "Found file_name "+ File_Name << oendl; |
195 | break; | 195 | break; |
196 | } | 196 | } |
197 | // if (str.contains(".zip")) { | 197 | // if (str.contains(".zip")) { |
198 | // File_Name = str; | 198 | // File_Name = str; |
199 | // odebug << "Found file_name "+ File_Name << oendl; | 199 | // odebug << "Found file_name "+ File_Name << oendl; |
200 | // break; | 200 | // break; |
201 | // } | 201 | // } |
202 | 202 | ||
203 | } | 203 | } |
204 | } //end of while loop | 204 | } //end of while loop |
205 | tmp.close(); | 205 | tmp.close(); |
206 | // tmp.remove(); ///TODO this is for release version Zaurus | 206 | // tmp.remove(); ///TODO this is for release version Zaurus |
207 | } | 207 | } |
208 | else | 208 | else |
209 | odebug << "Error opening temp file." << oendl; | 209 | odebug << "Error opening temp file." << oendl; |
210 | 210 | ||
211 | Config cfg("Gutenbrowser"); | 211 | Config cfg("Gutenbrowser"); |
212 | cfg.setGroup("General"); | 212 | cfg.setGroup("General"); |
213 | QString temp=cfg.readEntry("DownloadDirectory",local_library); | 213 | QString temp=cfg.readEntry("DownloadDirectory",local_library); |
214 | 214 | ||
215 | localFileName = temp+File_Name; | 215 | localFileName = temp+File_Name; |
216 | odebug << "Requesting file "+ File_Name << oendl; | 216 | odebug << "Requesting file "+ File_Name << oendl; |
217 | odebug << "Saving as "+localFileName << oendl; | 217 | odebug << "Saving as "+localFileName << oendl; |
218 | msg="Requesting file "+ File_Name; | 218 | msg="Requesting file "+ File_Name; |
219 | TextLabel3->setText(msg); | 219 | TextLabel3->setText(msg); |
220 | qApp->processEvents(); | 220 | qApp->processEvents(); |
221 | if( File_Name.length()>3) { | 221 | if( File_Name.length()>3) { |
222 | if (!FtpSize( File_Name.latin1(), &fsz, FTPLIB_ASCII, conn)) | 222 | if (!FtpSize( File_Name.latin1(), &fsz, FTPLIB_ASCII, conn)) |
223 | fsz = 0; | 223 | fsz = 0; |
224 | QString temp; | 224 | QString temp; |
225 | temp.sprintf( File_Name+" "+" %dkb", fsz); | 225 | temp.sprintf( File_Name+" "+" %dkb", fsz); |
226 | TextLabel3->setText(temp); | 226 | TextLabel3->setText(temp); |
227 | 227 | ||
228 | ProgressBar1->setTotalSteps(fsz); | 228 | ProgressBar1->setTotalSteps(fsz); |
229 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); | 229 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); |
230 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); | 230 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); |
231 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); | 231 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); |
232 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); | 232 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); |
233 | 233 | ||
234 | if (!FtpGet( localFileName.latin1(), File_Name.latin1(), FTPLIB_ASCII, conn)) { | 234 | if (!FtpGet( localFileName.latin1(), File_Name.latin1(), FTPLIB_ASCII, conn)) { |
235 | msg.sprintf("Could not download "+ File_Name+"\n%s",FtpLastResponse(conn)); | 235 | msg.sprintf("Could not download "+ File_Name+"\n%s",FtpLastResponse(conn)); |
236 | successDownload=false; | 236 | successDownload=false; |
237 | QMessageBox::message("Note",msg); | 237 | QMessageBox::message("Note",msg); |
238 | update(); | 238 | update(); |
239 | } | 239 | } |
240 | } else { | 240 | } else { |
241 | QMessageBox::message("Note","Could not download file "+ File_Name); | 241 | QMessageBox::message("Note","Could not download file "+ File_Name); |
242 | successDownload=false; | 242 | successDownload=false; |
243 | FtpQuit(conn); | 243 | FtpQuit(conn); |
244 | return false; | 244 | return false; |
245 | } | 245 | } |
246 | odebug << "Ftp session successful" << oendl; | 246 | odebug << "Ftp session successful" << oendl; |
247 | successDownload=TRUE; | 247 | successDownload=TRUE; |
248 | FtpQuit(conn); | 248 | FtpQuit(conn); |
249 | return true; | 249 | return true; |
250 | } //no network url | 250 | } //no network url |
251 | return false; | 251 | return false; |
252 | } | 252 | } |
253 | 253 | ||
254 | void NetworkDialog::doOk() { | 254 | void NetworkDialog::doOk() { |
255 | owarn << "Do OK" << oendl; | 255 | owarn << "Do OK" << oendl; |
256 | QString loginStr; | 256 | QString loginStr; |
257 | loginStr = "gutenbrowser"; | 257 | loginStr = "gutenbrowser"; |
258 | if ( !ftp_host.isEmpty() ) { | 258 | if ( !ftp_host.isEmpty() ) { |
259 | if( ftp_host.find( "/", ftp_host.length() - 1,TRUE) != -1 && ftp_host.find("ftp://",0, TRUE) != -1) { | 259 | if( ftp_host.find( "/", ftp_host.length() - 1,TRUE) != -1 && ftp_host.find("ftp://",0, TRUE) != -1) { |
260 | TextLabel3->setText( tr( "List remote dir:\n" + ftp_host) ); | 260 | TextLabel3->setText( tr( "List remote dir:\n" + ftp_host) ); |
261 | // TextLabel2->setText( tr( "local file to download into: " +localFileName ) ); | 261 | // TextLabel2->setText( tr( "local file to download into: " +localFileName ) ); |
262 | 262 | ||
263 | if( downloadFile(ftp_host)) | 263 | if( downloadFile(ftp_host)) |
264 | successDownload = true; | 264 | successDownload = true; |
265 | else { | 265 | else { |
266 | successDownload = false; | 266 | successDownload = false; |
267 | reject(); | 267 | reject(); |
268 | } | 268 | } |
269 | } else { | 269 | } else { |
270 | if(downloadFile(ftp_host)) | 270 | if(downloadFile(ftp_host)) |
271 | successDownload = true; | 271 | successDownload = true; |
272 | else { | 272 | else { |
273 | successDownload = false; | 273 | successDownload = false; |
274 | reject(); | 274 | reject(); |
275 | } | 275 | } |
276 | } | 276 | } |
277 | } | 277 | } |
278 | accept(); | 278 | accept(); |
279 | } | 279 | } |
diff --git a/noncore/apps/opie-gutenbrowser/fontDialog.cpp b/noncore/apps/opie-gutenbrowser/fontDialog.cpp index fa964a6..c6d0fe6 100644 --- a/noncore/apps/opie-gutenbrowser/fontDialog.cpp +++ b/noncore/apps/opie-gutenbrowser/fontDialog.cpp | |||
@@ -1,260 +1,260 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** Created: Sun Jan 27 11:03:24 2002 | 2 | ** Created: Sun Jan 27 11:03:24 2002 |
3 | copyright 2002 by L.J. Potter ljp@llornkcor.com | 3 | copyright 2002 by L.J. Potter ljp@llornkcor.com |
4 | copyright : (C) 2000 -2004 by llornkcor | 4 | copyright : (C) 2000 -2004 by llornkcor |
5 | email : ljp@llornkcor.com | 5 | email : ljp@llornkcor.com |
6 | ****************************************************************************/ | 6 | ****************************************************************************/ |
7 | #include "fontDialog.h" | 7 | #include "fontDialog.h" |
8 | #include "optionsDialog.h" | 8 | #include "optionsDialog.h" |
9 | 9 | ||
10 | #include <qpe/fontdatabase.h> | 10 | #include <qpe/fontdatabase.h> |
11 | #include <qpe/config.h> | 11 | #include <qpe/config.h> |
12 | 12 | ||
13 | #include <qstringlist.h> | 13 | #include <qstringlist.h> |
14 | #include <qfontinfo.h> | 14 | #include <qfontinfo.h> |
15 | #include <qvaluelist.h> | 15 | #include <qvaluelist.h> |
16 | #include <qpe/qpeapplication.h> | 16 | #include <qpe/qpeapplication.h> |
17 | 17 | ||
18 | #include <qgroupbox.h> | 18 | #include <qgroupbox.h> |
19 | #include <qlabel.h> | 19 | #include <qlabel.h> |
20 | #include <qlistbox.h> | 20 | #include <qlistbox.h> |
21 | #include <qmultilineedit.h> | 21 | #include <qmultilineedit.h> |
22 | #include <qpushbutton.h> | 22 | #include <qpushbutton.h> |
23 | #include <qlayout.h> | 23 | #include <qlayout.h> |
24 | #include <qvariant.h> | 24 | #include <qvariant.h> |
25 | #include <qtooltip.h> | 25 | #include <qtooltip.h> |
26 | #include <qwhatsthis.h> | 26 | #include <qwhatsthis.h> |
27 | #include <qcombobox.h> | 27 | #include <qcombobox.h> |
28 | 28 | ||
29 | //#define BUGGY_SHARP_ZAURUS 0 | 29 | //#define BUGGY_SHARP_ZAURUS 0 |
30 | 30 | ||
31 | static const int nfontsizes = 9; | 31 | static const int nfontsizes = 9; |
32 | static const int fontsize[nfontsizes] = {8,9,10,11,12,13,14,18,24}; | 32 | static const int fontsize[nfontsizes] = {8,9,10,11,12,13,14,18,24}; |
33 | 33 | ||
34 | 34 | ||
35 | FontDialog::FontDialog( QWidget * parent, const char* name /*, bool modal, WFlags fl */) | 35 | FontDialog::FontDialog( QWidget * parent, const char* name /*, bool modal, WFlags fl */) |
36 | :/* QDialog*/ QWidget( parent, name /*, modal, fl */) | 36 | :/* QDialog*/ QWidget( parent, name /*, modal, fl */) |
37 | { | 37 | { |
38 | if ( !name ) | 38 | if ( !name ) |
39 | setName( "FontDialog" ); | 39 | setName( "FontDialog" ); |
40 | setCaption( tr( "Font Dialog" ) ); | 40 | setCaption( tr( "Font Dialog" ) ); |
41 | 41 | ||
42 | QGridLayout *layout = new QGridLayout( this ); | 42 | QGridLayout *layout = new QGridLayout( this ); |
43 | layout->setSpacing(2); | 43 | layout->setSpacing(2); |
44 | layout->setMargin(2); | 44 | layout->setMargin(2); |
45 | 45 | ||
46 | familyListBox = new QListBox( this, "familyListBox" ); | 46 | familyListBox = new QListBox( this, "familyListBox" ); |
47 | layout->addMultiCellWidget( familyListBox, 0, 2, 0, 0); | 47 | layout->addMultiCellWidget( familyListBox, 0, 2, 0, 0); |
48 | 48 | ||
49 | QBoxLayout * hbox = new QHBoxLayout(this); | 49 | QBoxLayout * hbox = new QHBoxLayout(this); |
50 | QBoxLayout * vbox = new QVBoxLayout(this); | 50 | QBoxLayout * vbox = new QVBoxLayout(this); |
51 | 51 | ||
52 | styleListBox = new QListBox( this, "styleListBox" ); | 52 | styleListBox = new QListBox( this, "styleListBox" ); |
53 | vbox->addWidget( styleListBox, 0); | 53 | vbox->addWidget( styleListBox, 0); |
54 | 54 | ||
55 | FontTextLabel4 = new QLabel( this, "TextLabel4" ); | 55 | FontTextLabel4 = new QLabel( this, "TextLabel4" ); |
56 | FontTextLabel4->setText( tr( "Size" ) ); | 56 | FontTextLabel4->setText( tr( "Size" ) ); |
57 | hbox->addWidget( FontTextLabel4,0); | 57 | hbox->addWidget( FontTextLabel4,0); |
58 | 58 | ||
59 | sizeComboBox = new QComboBox( FALSE, this, "SizeCombo"); | 59 | sizeComboBox = new QComboBox( FALSE, this, "SizeCombo"); |
60 | // sizeComboBox->setMaximumWidth(60); | 60 | // sizeComboBox->setMaximumWidth(60); |
61 | hbox->addWidget( sizeComboBox, 0); | 61 | hbox->addWidget( sizeComboBox, 0); |
62 | 62 | ||
63 | vbox->addLayout(hbox,0); | 63 | vbox->addLayout(hbox,0); |
64 | layout->addLayout( vbox,0,3); | 64 | layout->addLayout( vbox,0,3); |
65 | 65 | ||
66 | MultiLineEdit1 = new QMultiLineEdit( this, "MultiLineEdit1" ); | 66 | MultiLineEdit1 = new QMultiLineEdit( this, "MultiLineEdit1" ); |
67 | MultiLineEdit1->setText( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" ) ); | 67 | MultiLineEdit1->setText( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" ) ); |
68 | MultiLineEdit1->setWordWrap( QMultiLineEdit::WidgetWidth); | 68 | MultiLineEdit1->setWordWrap( QMultiLineEdit::WidgetWidth); |
69 | 69 | ||
70 | layout->addMultiCellWidget( MultiLineEdit1, 4, 4, 0, 3); | 70 | layout->addMultiCellWidget( MultiLineEdit1, 4, 4, 0, 3); |
71 | 71 | ||
72 | connect(familyListBox,SIGNAL(highlighted(const QString &)),SLOT(familyListBoxSlot(const QString &))); | 72 | connect(familyListBox,SIGNAL(highlighted(const QString &)),SLOT(familyListBoxSlot(const QString &))); |
73 | connect(styleListBox,SIGNAL(highlighted(const QString &)),SLOT(styleListBoxSlot(const QString &))); | 73 | connect(styleListBox,SIGNAL(highlighted(const QString &)),SLOT(styleListBoxSlot(const QString &))); |
74 | connect(sizeComboBox,SIGNAL(activated(const QString &)),SLOT(sizeComboBoxSlot(const QString &))); | 74 | connect(sizeComboBox,SIGNAL(activated(const QString &)),SLOT(sizeComboBoxSlot(const QString &))); |
75 | 75 | ||
76 | populateLists(); | 76 | populateLists(); |
77 | 77 | ||
78 | } | 78 | } |
79 | 79 | ||
80 | FontDialog::~FontDialog() | 80 | FontDialog::~FontDialog() |
81 | { | 81 | { |
82 | } | 82 | } |
83 | 83 | ||
84 | void FontDialog::familyListBoxSlot(const QString & text) | 84 | void FontDialog::familyListBoxSlot(const QString & text) |
85 | { | 85 | { |
86 | int styleInt = styleListBox->currentItem(); | 86 | int styleInt = styleListBox->currentItem(); |
87 | int sizeInt = sizeComboBox->currentText().toInt(); | 87 | int sizeInt = sizeComboBox->currentText().toInt(); |
88 | 88 | ||
89 | sizeComboBox->clear(); | 89 | sizeComboBox->clear(); |
90 | styleListBox->clear(); | 90 | styleListBox->clear(); |
91 | // clearListBoxes(); | 91 | // clearListBoxes(); |
92 | family = text; | 92 | family = text; |
93 | // odebug << family << oendl; | 93 | // odebug << family << oendl; |
94 | QStringList styles = fdb.styles( family ); // string list of styles of our current font family | 94 | QStringList styles = fdb.styles( family ); // string list of styles of our current font family |
95 | styleListBox->insertStringList( styles); | 95 | styleListBox->insertStringList( styles); |
96 | QString dstyle;// = "\t" + style + " ("; | 96 | QString dstyle;// = "\t" + style + " ("; |
97 | 97 | ||
98 | #ifdef BUGGY_SHARP_ZAURUS | 98 | #ifdef BUGGY_SHARP_ZAURUS |
99 | 99 | ||
100 | QValueList<int> smoothies = fdb.smoothSizes( family, styleListBox->text(0) ); | 100 | QValueList<int> smoothies = fdb.smoothSizes( family, styleListBox->text(0) ); |
101 | for ( QValueList<int>::Iterator points = smoothies.begin(); points != smoothies.end(); ++points ) { | 101 | for ( QValueList<int>::Iterator points = smoothies.begin(); points != smoothies.end(); ++points ) { |
102 | dstyle = QString::number( *points ); | 102 | dstyle = QString::number( *points ); |
103 | odebug << dstyle << oendl; | 103 | odebug << dstyle << oendl; |
104 | sizeComboBox->insertItem( dstyle.left( dstyle.length() - 1 )); | 104 | sizeComboBox->insertItem( dstyle.left( dstyle.length() - 1 )); |
105 | } | 105 | } |
106 | #else | 106 | #else |
107 | 107 | ||
108 | for (int i=0; i<nfontsizes; i++) { | 108 | for (int i=0; i<nfontsizes; i++) { |
109 | sizeComboBox->insertItem( QString::number(fontsize[i])); | 109 | sizeComboBox->insertItem( QString::number(fontsize[i])); |
110 | if(fontsize[i] == sizeInt) { | 110 | if(fontsize[i] == sizeInt) { |
111 | sizeComboBox->setCurrentItem(i); | 111 | sizeComboBox->setCurrentItem(i); |
112 | } | 112 | } |
113 | } | 113 | } |
114 | #endif | 114 | #endif |
115 | 115 | ||
116 | if(styleInt == -1 || styleInt > styleListBox->count() ) | 116 | if(styleInt == -1 || styleInt > static_cast<int>(styleListBox->count()) ) |
117 | styleListBox->setCurrentItem(0); | 117 | styleListBox->setCurrentItem(0); |
118 | else | 118 | else |
119 | styleListBox->setCurrentItem(styleInt); | 119 | styleListBox->setCurrentItem(styleInt); |
120 | 120 | ||
121 | changeText(); | 121 | changeText(); |
122 | } | 122 | } |
123 | 123 | ||
124 | void FontDialog::styleListBoxSlot(const QString &text) | 124 | void FontDialog::styleListBoxSlot(const QString &) |
125 | { | 125 | { |
126 | changeText(); | 126 | changeText(); |
127 | } | 127 | } |
128 | 128 | ||
129 | void FontDialog::sizeComboBoxSlot(const QString & text) | 129 | void FontDialog::sizeComboBoxSlot(const QString &) |
130 | { | 130 | { |
131 | changeText(); | 131 | changeText(); |
132 | } | 132 | } |
133 | 133 | ||
134 | void FontDialog::populateLists() | 134 | void FontDialog::populateLists() |
135 | { | 135 | { |
136 | // QFont defaultFont=MultiLineEdit1->font(); | 136 | // QFont defaultFont=MultiLineEdit1->font(); |
137 | // QFont defaultFont=Lview->font(); | 137 | // QFont defaultFont=Lview->font(); |
138 | // QFontInfo fontInfo(defaultFont); | 138 | // QFontInfo fontInfo(defaultFont); |
139 | Config config("Gutenbrowser"); | 139 | Config config("Gutenbrowser"); |
140 | config.setGroup("Font"); | 140 | config.setGroup("Font"); |
141 | QString familyStr = config.readEntry("Family", "fixed"); | 141 | QString familyStr = config.readEntry("Family", "fixed"); |
142 | QString styleStr = config.readEntry("Style", "Regular"); | 142 | QString styleStr = config.readEntry("Style", "Regular"); |
143 | QString sizeStr = config.readEntry("Size", "10"); | 143 | QString sizeStr = config.readEntry("Size", "10"); |
144 | QString charSetStr = config.readEntry("CharSet", "iso10646-1" ); | 144 | QString charSetStr = config.readEntry("CharSet", "iso10646-1" ); |
145 | bool ok; | 145 | bool ok; |
146 | int i_size = sizeStr.toInt(&ok,10); | 146 | int i_size = sizeStr.toInt(&ok,10); |
147 | selectedFont = fdb.font(familyStr,styleStr,i_size,charSetStr); | 147 | selectedFont = fdb.font(familyStr,styleStr,i_size,charSetStr); |
148 | // defaultFont.setItalic(TRUE); | 148 | // defaultFont.setItalic(TRUE); |
149 | families = fdb.families(); | 149 | families = fdb.families(); |
150 | 150 | ||
151 | for ( QStringList::Iterator f = families.begin(); f != families.end();++f ) { | 151 | for ( QStringList::Iterator f = families.begin(); f != families.end();++f ) { |
152 | QString family = *f; | 152 | QString family = *f; |
153 | // if(family == defaultFont.family()) | 153 | // if(family == defaultFont.family()) |
154 | // odebug << family << oendl; | 154 | // odebug << family << oendl; |
155 | familyListBox->insertItem( family); | 155 | familyListBox->insertItem( family); |
156 | 156 | ||
157 | if( familyListBox->text(0) == family) { | 157 | if( familyListBox->text(0) == family) { |
158 | QStringList styles = fdb.styles( family ); | 158 | QStringList styles = fdb.styles( family ); |
159 | // string list of styles of our current font family | 159 | // string list of styles of our current font family |
160 | styleListBox->insertStringList( styles); | 160 | styleListBox->insertStringList( styles); |
161 | 161 | ||
162 | for ( QStringList::Iterator s = styles.begin(); s != styles.end();++s ) { // for each font style | 162 | for ( QStringList::Iterator s = styles.begin(); s != styles.end();++s ) { // for each font style |
163 | style = *s; | 163 | style = *s; |
164 | QString dstyle;// = "\t" + style + " ("; | 164 | QString dstyle;// = "\t" + style + " ("; |
165 | if(styleListBox->text(0) == style) { | 165 | if(styleListBox->text(0) == style) { |
166 | 166 | ||
167 | QValueList<int> smoothies = fdb.smoothSizes( family, style ); | 167 | QValueList<int> smoothies = fdb.smoothSizes( family, style ); |
168 | for ( QValueList<int>::Iterator points = smoothies.begin(); points != smoothies.end(); ++points ) { | 168 | for ( QValueList<int>::Iterator points = smoothies.begin(); points != smoothies.end(); ++points ) { |
169 | dstyle = QString::number( *points ) + " "; | 169 | dstyle = QString::number( *points ) + " "; |
170 | sizeComboBox ->insertItem( dstyle.left( dstyle.length() - 1 )); | 170 | sizeComboBox ->insertItem( dstyle.left( dstyle.length() - 1 )); |
171 | } | 171 | } |
172 | dstyle = dstyle.left( dstyle.length() - 1 ) + ")"; | 172 | dstyle = dstyle.left( dstyle.length() - 1 ) + ")"; |
173 | } | 173 | } |
174 | } // styles | 174 | } // styles |
175 | } | 175 | } |
176 | } | 176 | } |
177 | for(int i=0;i < familyListBox->count();i++) { | 177 | for(uint i=0;i < familyListBox->count();i++) { |
178 | if( familyListBox->text(i) == familyStr) | 178 | if( familyListBox->text(i) == familyStr) |
179 | familyListBox->setSelected( i, TRUE); | 179 | familyListBox->setSelected( i, TRUE); |
180 | } | 180 | } |
181 | 181 | ||
182 | for(int i=0;i < styleListBox->count();i++) { | 182 | for(uint i=0;i < styleListBox->count();i++) { |
183 | if( styleListBox->text(i) == styleStr) | 183 | if( styleListBox->text(i) == styleStr) |
184 | styleListBox->setSelected( i, TRUE); | 184 | styleListBox->setSelected( i, TRUE); |
185 | } | 185 | } |
186 | 186 | ||
187 | for (int i=0; i<sizeComboBox->count(); i++) { | 187 | for (int i=0; i<sizeComboBox->count(); i++) { |
188 | 188 | ||
189 | #ifdef BUGGY_SHARP_ZAURUS | 189 | #ifdef BUGGY_SHARP_ZAURUS |
190 | if(sizeComboBox->text(i) == sizeStr) | 190 | if(sizeComboBox->text(i) == sizeStr) |
191 | #else | 191 | #else |
192 | if(fontsize[i] == i_size) | 192 | if(fontsize[i] == i_size) |
193 | #endif | 193 | #endif |
194 | sizeComboBox->setCurrentItem(i); | 194 | sizeComboBox->setCurrentItem(i); |
195 | } | 195 | } |
196 | changeText(); | 196 | changeText(); |
197 | } | 197 | } |
198 | 198 | ||
199 | void FontDialog::clearListBoxes() { | 199 | void FontDialog::clearListBoxes() { |
200 | familyListBox->clear(); | 200 | familyListBox->clear(); |
201 | sizeComboBox->clear(); | 201 | sizeComboBox->clear(); |
202 | styleListBox->clear(); | 202 | styleListBox->clear(); |
203 | } | 203 | } |
204 | 204 | ||
205 | void FontDialog::changeText() | 205 | void FontDialog::changeText() |
206 | { | 206 | { |
207 | if( familyListBox->currentItem() == -1) | 207 | if( familyListBox->currentItem() == -1) |
208 | family= familyListBox->text(0); | 208 | family= familyListBox->text(0); |
209 | else { | 209 | else { |
210 | family = familyListBox->currentText(); | 210 | family = familyListBox->currentText(); |
211 | } | 211 | } |
212 | // odebug << "Font family is "+family << oendl; | 212 | // odebug << "Font family is "+family << oendl; |
213 | if( styleListBox->currentItem() == -1) | 213 | if( styleListBox->currentItem() == -1) |
214 | style=styleListBox->text(0); | 214 | style=styleListBox->text(0); |
215 | else { | 215 | else { |
216 | style = styleListBox->currentText(); | 216 | style = styleListBox->currentText(); |
217 | } | 217 | } |
218 | // odebug << "font style is "+style << oendl; | 218 | // odebug << "font style is "+style << oendl; |
219 | 219 | ||
220 | if( sizeComboBox->currentItem() == -1 ) | 220 | if( sizeComboBox->currentItem() == -1 ) |
221 | size = sizeComboBox->text(0); | 221 | size = sizeComboBox->text(0); |
222 | else { | 222 | else { |
223 | size = sizeComboBox->currentText(); | 223 | size = sizeComboBox->currentText(); |
224 | } | 224 | } |
225 | 225 | ||
226 | // odebug << "Font size is "+size << oendl; | 226 | // odebug << "Font size is "+size << oendl; |
227 | bool ok; | 227 | bool ok; |
228 | int i_size = size.toInt(&ok,10); | 228 | int i_size = size.toInt(&ok,10); |
229 | QStringList charSetList = fdb.charSets(family); | 229 | QStringList charSetList = fdb.charSets(family); |
230 | // QStringList styles = fdb.styles( family ); // string list of styles of our current font family | 230 | // QStringList styles = fdb.styles( family ); // string list of styles of our current font family |
231 | QString charSet; | 231 | QString charSet; |
232 | for ( QStringList::Iterator s = charSetList.begin(); s != charSetList.end();++s ) { // for each font style | 232 | for ( QStringList::Iterator s = charSetList.begin(); s != charSetList.end();++s ) { // for each font style |
233 | charSet = *s; | 233 | charSet = *s; |
234 | // odebug << charSet << oendl; | 234 | // odebug << charSet << oendl; |
235 | } | 235 | } |
236 | selectedFont = fdb.font(family,style,i_size,charSet); | 236 | selectedFont = fdb.font(family,style,i_size,charSet); |
237 | QFontInfo fontInfo( selectedFont); | 237 | QFontInfo fontInfo( selectedFont); |
238 | // if(fontInfo.italic() ) odebug << "italic" << oendl; | 238 | // if(fontInfo.italic() ) odebug << "italic" << oendl; |
239 | selectedFont.setWeight(fontInfo.weight() ); | 239 | selectedFont.setWeight(fontInfo.weight() ); |
240 | // odebug << "Style are "+style+" " << fontInfo.weight() << " " << oendl; | 240 | // odebug << "Style are "+style+" " << fontInfo.weight() << " " << oendl; |
241 | Config cfg("Gutenbrowser"); | 241 | Config cfg("Gutenbrowser"); |
242 | cfg.setGroup("Font"); | 242 | cfg.setGroup("Font"); |
243 | cfg.writeEntry("Family",family); | 243 | cfg.writeEntry("Family",family); |
244 | cfg.writeEntry("Style",style); | 244 | cfg.writeEntry("Style",style); |
245 | cfg.writeEntry("Size",size); | 245 | cfg.writeEntry("Size",size); |
246 | cfg.writeEntry("CharSet",charSet); | 246 | cfg.writeEntry("CharSet",charSet); |
247 | 247 | ||
248 | if(style.find("Italic",0,TRUE) != -1) { | 248 | if(style.find("Italic",0,TRUE) != -1) { |
249 | selectedFont = fdb.font(family,"Regular",i_size,charSet); | 249 | selectedFont = fdb.font(family,"Regular",i_size,charSet); |
250 | selectedFont.setItalic(TRUE); //ya right | 250 | selectedFont.setItalic(TRUE); //ya right |
251 | cfg.writeEntry("Italic","TRUE"); | 251 | cfg.writeEntry("Italic","TRUE"); |
252 | // odebug << "Style is "+styleListBox->currentText() << oendl; | 252 | // odebug << "Style is "+styleListBox->currentText() << oendl; |
253 | } else | 253 | } else |
254 | cfg.writeEntry("Italic","FALSE"); | 254 | cfg.writeEntry("Italic","FALSE"); |
255 | 255 | ||
256 | MultiLineEdit1->setFont( selectedFont); | 256 | MultiLineEdit1->setFont( selectedFont); |
257 | MultiLineEdit1->update(); | 257 | MultiLineEdit1->update(); |
258 | changedFonts=TRUE; | 258 | changedFonts=TRUE; |
259 | } | 259 | } |
260 | 260 | ||
diff --git a/noncore/apps/opie-gutenbrowser/helpwindow.cpp b/noncore/apps/opie-gutenbrowser/helpwindow.cpp index e86ca49..ffdc9f0 100644 --- a/noncore/apps/opie-gutenbrowser/helpwindow.cpp +++ b/noncore/apps/opie-gutenbrowser/helpwindow.cpp | |||
@@ -1,326 +1,326 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** $Id$ | 2 | ** $Id$ |
3 | ** | 3 | ** |
4 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. | 4 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. |
5 | ** | 5 | ** |
6 | ** This file is part of an example program for Qt. This example | 6 | ** This file is part of an example program for Qt. This example |
7 | ** program may be used, distributed and modified without limitation. | 7 | ** program may be used, distributed and modified without limitation. |
8 | ** | 8 | ** |
9 | copyright : (C) 2000 -2004 by llornkcor | 9 | copyright : (C) 2000 -2004 by llornkcor |
10 | email : ljp@llornkcor.com | 10 | email : ljp@llornkcor.com |
11 | *****************************************************************************/ | 11 | *****************************************************************************/ |
12 | 12 | ||
13 | #include "helpwindow.h" | 13 | #include "helpwindow.h" |
14 | #include <qstatusbar.h> | 14 | #include <qstatusbar.h> |
15 | 15 | ||
16 | #include <qmenubar.h> | 16 | #include <qmenubar.h> |
17 | #include <qtoolbar.h> | 17 | #include <qtoolbar.h> |
18 | #include <qtoolbutton.h> | 18 | #include <qtoolbutton.h> |
19 | #include <qcombobox.h> | 19 | #include <qcombobox.h> |
20 | 20 | ||
21 | #include <ctype.h> | 21 | #include <ctype.h> |
22 | 22 | ||
23 | HelpWindow::HelpWindow( const QString& home_, const QString& _path, QWidget* parent, const char *name ) | 23 | HelpWindow::HelpWindow( const QString& home_, const QString&, QWidget* parent, const char *name ) |
24 | : QMainWindow( parent, name, WDestructiveClose ), pathCombo( 0 ), selectedURL() | 24 | : QMainWindow( parent, name, WDestructiveClose ), pathCombo( 0 ), selectedURL() |
25 | { | 25 | { |
26 | QString local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; | 26 | QString local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; |
27 | // readHistory(); | 27 | // readHistory(); |
28 | // readBookmarks(); | 28 | // readBookmarks(); |
29 | 29 | ||
30 | browser = new QTextBrowser( this ); | 30 | browser = new QTextBrowser( this ); |
31 | QStringList Strlist; | 31 | QStringList Strlist; |
32 | Strlist.append( home_); | 32 | Strlist.append( home_); |
33 | browser->mimeSourceFactory()->setFilePath( Strlist ); | 33 | browser->mimeSourceFactory()->setFilePath( Strlist ); |
34 | 34 | ||
35 | browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 35 | browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
36 | 36 | ||
37 | connect(browser,SIGNAL(textChanged()),this,SLOT(textChanged())); | 37 | connect(browser,SIGNAL(textChanged()),this,SLOT(textChanged())); |
38 | 38 | ||
39 | setCentralWidget( browser ); | 39 | setCentralWidget( browser ); |
40 | 40 | ||
41 | if ( !home_.isEmpty() ) | 41 | if ( !home_.isEmpty() ) |
42 | 42 | ||
43 | //////////////////////////////// | 43 | //////////////////////////////// |
44 | browser->setSource( home_ ); | 44 | browser->setSource( home_ ); |
45 | 45 | ||
46 | //////////////////////////////// | 46 | //////////////////////////////// |
47 | connect( browser, SIGNAL( highlighted( const QString&) ), | 47 | connect( browser, SIGNAL( highlighted( const QString&) ), |
48 | statusBar(), SLOT( message( const QString&)) ); | 48 | statusBar(), SLOT( message( const QString&)) ); |
49 | 49 | ||
50 | // resize( 640,600 ); | 50 | // resize( 640,600 ); |
51 | #ifdef Q_WS_QWS | 51 | #ifdef Q_WS_QWS |
52 | setGeometry( 0,0,236,280); | 52 | setGeometry( 0,0,236,280); |
53 | #else | 53 | #else |
54 | setGeometry( 10,30,520,420 ); | 54 | setGeometry( 10,30,520,420 ); |
55 | // resize(520,420); | 55 | // resize(520,420); |
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | QPopupMenu* file = new QPopupMenu( this ); | 58 | QPopupMenu* file = new QPopupMenu( this ); |
59 | // file->insertItem( tr("&New Window"), this, SLOT( newWindow() ), ALT | Key_N ); | 59 | // file->insertItem( tr("&New Window"), this, SLOT( newWindow() ), ALT | Key_N ); |
60 | file->insertItem( tr("&Open File"), this, SLOT( openFile() ), ALT | Key_O ); | 60 | file->insertItem( tr("&Open File"), this, SLOT( openFile() ), ALT | Key_O ); |
61 | // file->insertItem( tr("&Print"), this, SLOT( print() ), ALT | Key_P ); | 61 | // file->insertItem( tr("&Print"), this, SLOT( print() ), ALT | Key_P ); |
62 | file->insertSeparator(); | 62 | file->insertSeparator(); |
63 | file->insertItem( tr("&Close"), this, SLOT( close() ), ALT | Key_Q ); | 63 | file->insertItem( tr("&Close"), this, SLOT( close() ), ALT | Key_Q ); |
64 | // file->insertItem( tr("E&xit"), qApp, SLOT( closeAllWindows() ), ALT | Key_X ); | 64 | // file->insertItem( tr("E&xit"), qApp, SLOT( closeAllWindows() ), ALT | Key_X ); |
65 | 65 | ||
66 | // The same three icons are used twice each. | 66 | // The same three icons are used twice each. |
67 | ////F FIXME | 67 | ////F FIXME |
68 | QString pixs=(QDir::homeDirPath ()) +"/Applications/gutenbrowser/pix/"; | 68 | QString pixs=(QDir::homeDirPath ()) +"/Applications/gutenbrowser/pix/"; |
69 | QIconSet icon_back( QPixmap(pixs+"back.png") ); | 69 | QIconSet icon_back( QPixmap(pixs+"back.png") ); |
70 | QIconSet icon_forward( QPixmap(pixs+"forward.png") ); | 70 | QIconSet icon_forward( QPixmap(pixs+"forward.png") ); |
71 | QIconSet icon_home( QPixmap(pixs+"home.png") ); | 71 | QIconSet icon_home( QPixmap(pixs+"home.png") ); |
72 | 72 | ||
73 | QPopupMenu* go = new QPopupMenu( this ); | 73 | QPopupMenu* go = new QPopupMenu( this ); |
74 | backwardId = go->insertItem( icon_back, tr("&Backward"), browser, SLOT( backward() ), ALT | Key_Left ); | 74 | backwardId = go->insertItem( icon_back, tr("&Backward"), browser, SLOT( backward() ), ALT | Key_Left ); |
75 | forwardId = go->insertItem( icon_forward, tr("&Forward"), browser, SLOT( forward() ), ALT | Key_Right ); | 75 | forwardId = go->insertItem( icon_forward, tr("&Forward"), browser, SLOT( forward() ), ALT | Key_Right ); |
76 | go->insertItem( icon_home, tr("&Home"), browser, SLOT( home() ) ); | 76 | go->insertItem( icon_home, tr("&Home"), browser, SLOT( home() ) ); |
77 | 77 | ||
78 | // QPopupMenu* help = new QPopupMenu( this ); | 78 | // QPopupMenu* help = new QPopupMenu( this ); |
79 | // help->insertItem( tr("&About ..."), this, SLOT( about() ) ); | 79 | // help->insertItem( tr("&About ..."), this, SLOT( about() ) ); |
80 | // help->insertItem( tr("About &Qt ..."), this, SLOT( aboutQt() ) ); | 80 | // help->insertItem( tr("About &Qt ..."), this, SLOT( aboutQt() ) ); |
81 | 81 | ||
82 | 82 | ||
83 | hist = new QPopupMenu( this ); | 83 | hist = new QPopupMenu( this ); |
84 | QStringList::Iterator it = history.begin(); | 84 | QStringList::Iterator it = history.begin(); |
85 | for ( ; it != history.end(); ++it ) | 85 | for ( ; it != history.end(); ++it ) |
86 | mHistory[ hist->insertItem( *it ) ] = *it; | 86 | mHistory[ hist->insertItem( *it ) ] = *it; |
87 | connect( hist, SIGNAL( activated( int ) ), this, SLOT( histChosen( int ) ) ); | 87 | connect( hist, SIGNAL( activated( int ) ), this, SLOT( histChosen( int ) ) ); |
88 | 88 | ||
89 | bookm = new QPopupMenu( this ); | 89 | bookm = new QPopupMenu( this ); |
90 | bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) ); | 90 | bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) ); |
91 | bookm->insertSeparator(); | 91 | bookm->insertSeparator(); |
92 | 92 | ||
93 | QStringList::Iterator it2 = bookmarks.begin(); | 93 | QStringList::Iterator it2 = bookmarks.begin(); |
94 | for ( ; it2 != bookmarks.end(); ++it2 ) | 94 | for ( ; it2 != bookmarks.end(); ++it2 ) |
95 | mBookmarks[ bookm->insertItem( *it2 ) ] = *it2; | 95 | mBookmarks[ bookm->insertItem( *it2 ) ] = *it2; |
96 | connect( bookm, SIGNAL( activated( int ) ), | 96 | connect( bookm, SIGNAL( activated( int ) ), |
97 | this, SLOT( bookmChosen( int ) ) ); | 97 | this, SLOT( bookmChosen( int ) ) ); |
98 | 98 | ||
99 | menuBar()->insertItem( tr("&File"), file ); | 99 | menuBar()->insertItem( tr("&File"), file ); |
100 | menuBar()->insertItem( tr("&Go"), go ); | 100 | menuBar()->insertItem( tr("&Go"), go ); |
101 | menuBar()->insertItem( tr( "History" ), hist ); | 101 | menuBar()->insertItem( tr( "History" ), hist ); |
102 | menuBar()->insertItem( tr( "Bookmarks" ), bookm ); | 102 | menuBar()->insertItem( tr( "Bookmarks" ), bookm ); |
103 | // menuBar()->insertSeparator(); | 103 | // menuBar()->insertSeparator(); |
104 | // menuBar()->insertItem( tr("&Help"), help ); | 104 | // menuBar()->insertItem( tr("&Help"), help ); |
105 | 105 | ||
106 | menuBar()->setItemEnabled( forwardId, FALSE); | 106 | menuBar()->setItemEnabled( forwardId, FALSE); |
107 | menuBar()->setItemEnabled( backwardId, FALSE); | 107 | menuBar()->setItemEnabled( backwardId, FALSE); |
108 | connect( browser, SIGNAL( backwardAvailable( bool ) ), this, SLOT( setBackwardAvailable( bool ) ) ); | 108 | connect( browser, SIGNAL( backwardAvailable( bool ) ), this, SLOT( setBackwardAvailable( bool ) ) ); |
109 | connect( browser, SIGNAL( forwardAvailable( bool ) ), this, SLOT( setForwardAvailable( bool ) ) ); | 109 | connect( browser, SIGNAL( forwardAvailable( bool ) ), this, SLOT( setForwardAvailable( bool ) ) ); |
110 | 110 | ||
111 | 111 | ||
112 | QToolBar* toolbar = new QToolBar( this ); | 112 | QToolBar* toolbar = new QToolBar( this ); |
113 | addToolBar( toolbar, "Toolbar"); | 113 | addToolBar( toolbar, "Toolbar"); |
114 | QToolButton* button; | 114 | QToolButton* button; |
115 | 115 | ||
116 | button = new QToolButton( icon_back, tr("Backward"), "", browser, SLOT(backward()), toolbar ); | 116 | button = new QToolButton( icon_back, tr("Backward"), "", browser, SLOT(backward()), toolbar ); |
117 | connect( browser, SIGNAL( backwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) ); | 117 | connect( browser, SIGNAL( backwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) ); |
118 | button->setEnabled( FALSE ); | 118 | button->setEnabled( FALSE ); |
119 | button = new QToolButton( icon_forward, tr("Forward"), "", browser, SLOT(forward()), toolbar ); | 119 | button = new QToolButton( icon_forward, tr("Forward"), "", browser, SLOT(forward()), toolbar ); |
120 | connect( browser, SIGNAL( forwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) ); | 120 | connect( browser, SIGNAL( forwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) ); |
121 | button->setEnabled( FALSE ); | 121 | button->setEnabled( FALSE ); |
122 | button = new QToolButton( icon_home, tr("Home"), "", browser, SLOT(home()), toolbar ); | 122 | button = new QToolButton( icon_home, tr("Home"), "", browser, SLOT(home()), toolbar ); |
123 | 123 | ||
124 | toolbar->addSeparator(); | 124 | toolbar->addSeparator(); |
125 | 125 | ||
126 | pathCombo = new QComboBox( TRUE, toolbar ); | 126 | pathCombo = new QComboBox( TRUE, toolbar ); |
127 | connect( pathCombo, SIGNAL( activated( const QString & ) ), this, SLOT( pathSelected( const QString & ) ) ); | 127 | connect( pathCombo, SIGNAL( activated( const QString & ) ), this, SLOT( pathSelected( const QString & ) ) ); |
128 | toolbar->setStretchableWidget( pathCombo ); | 128 | toolbar->setStretchableWidget( pathCombo ); |
129 | 129 | ||
130 | // pathCombo->setMaximumWidth(190); | 130 | // pathCombo->setMaximumWidth(190); |
131 | // setRightJustification( TRUE ); | 131 | // setRightJustification( TRUE ); |
132 | // setDockEnabled( Left, FALSE ); | 132 | // setDockEnabled( Left, FALSE ); |
133 | // setDockEnabled( Right, FALSE ); | 133 | // setDockEnabled( Right, FALSE ); |
134 | 134 | ||
135 | pathCombo->insertItem( home_ ); | 135 | pathCombo->insertItem( home_ ); |
136 | 136 | ||
137 | browser->setFocus(); | 137 | browser->setFocus(); |
138 | 138 | ||
139 | 139 | ||
140 | } | 140 | } |
141 | 141 | ||
142 | 142 | ||
143 | void HelpWindow::setBackwardAvailable( bool b) | 143 | void HelpWindow::setBackwardAvailable( bool b) |
144 | { | 144 | { |
145 | menuBar()->setItemEnabled( backwardId, b); | 145 | menuBar()->setItemEnabled( backwardId, b); |
146 | } | 146 | } |
147 | 147 | ||
148 | void HelpWindow::setForwardAvailable( bool b) | 148 | void HelpWindow::setForwardAvailable( bool b) |
149 | { | 149 | { |
150 | menuBar()->setItemEnabled( forwardId, b); | 150 | menuBar()->setItemEnabled( forwardId, b); |
151 | } | 151 | } |
152 | 152 | ||
153 | 153 | ||
154 | void HelpWindow::textChanged() | 154 | void HelpWindow::textChanged() |
155 | { | 155 | { |
156 | if ( browser->documentTitle().isNull() ) { | 156 | if ( browser->documentTitle().isNull() ) { |
157 | setCaption( "Gutenbrowser - Helpviewer - " + browser->context() ); | 157 | setCaption( "Gutenbrowser - Helpviewer - " + browser->context() ); |
158 | selectedURL = browser->context(); | 158 | selectedURL = browser->context(); |
159 | } | 159 | } |
160 | else { | 160 | else { |
161 | setCaption( "Gutenbrowser - Helpviewer - " + browser->documentTitle() ) ; | 161 | setCaption( "Gutenbrowser - Helpviewer - " + browser->documentTitle() ) ; |
162 | selectedURL = browser->documentTitle(); | 162 | selectedURL = browser->documentTitle(); |
163 | } | 163 | } |
164 | 164 | ||
165 | if ( !selectedURL.isEmpty() && pathCombo ) { | 165 | if ( !selectedURL.isEmpty() && pathCombo ) { |
166 | bool exists = FALSE; | 166 | bool exists = FALSE; |
167 | int i; | 167 | int i; |
168 | for ( i = 0; i < pathCombo->count(); ++i ) { | 168 | for ( i = 0; i < pathCombo->count(); ++i ) { |
169 | if ( pathCombo->text( i ) == selectedURL ) { | 169 | if ( pathCombo->text( i ) == selectedURL ) { |
170 | exists = TRUE; | 170 | exists = TRUE; |
171 | break; | 171 | break; |
172 | } | 172 | } |
173 | } | 173 | } |
174 | if ( !exists ) { | 174 | if ( !exists ) { |
175 | pathCombo->insertItem( selectedURL, 0 ); | 175 | pathCombo->insertItem( selectedURL, 0 ); |
176 | pathCombo->setCurrentItem( 0 ); | 176 | pathCombo->setCurrentItem( 0 ); |
177 | mHistory[ hist->insertItem( selectedURL ) ] = selectedURL; | 177 | mHistory[ hist->insertItem( selectedURL ) ] = selectedURL; |
178 | } else | 178 | } else |
179 | pathCombo->setCurrentItem( i ); | 179 | pathCombo->setCurrentItem( i ); |
180 | selectedURL = QString::null; | 180 | selectedURL = QString::null; |
181 | } | 181 | } |
182 | } | 182 | } |
183 | 183 | ||
184 | HelpWindow::~HelpWindow() | 184 | HelpWindow::~HelpWindow() |
185 | { | 185 | { |
186 | history.clear(); | 186 | history.clear(); |
187 | QMap<int, QString>::Iterator it = mHistory.begin(); | 187 | QMap<int, QString>::Iterator it = mHistory.begin(); |
188 | for ( ; it != mHistory.end(); ++it ) | 188 | for ( ; it != mHistory.end(); ++it ) |
189 | history.append( *it ); | 189 | history.append( *it ); |
190 | 190 | ||
191 | QFile f( QDir::currentDirPath() + "/.history" ); | 191 | QFile f( QDir::currentDirPath() + "/.history" ); |
192 | f.open( IO_WriteOnly ); | 192 | f.open( IO_WriteOnly ); |
193 | QDataStream s( &f ); | 193 | QDataStream s( &f ); |
194 | s << history; | 194 | s << history; |
195 | f.close(); | 195 | f.close(); |
196 | 196 | ||
197 | bookmarks.clear(); | 197 | bookmarks.clear(); |
198 | QMap<int, QString>::Iterator it2 = mBookmarks.begin(); | 198 | QMap<int, QString>::Iterator it2 = mBookmarks.begin(); |
199 | for ( ; it2 != mBookmarks.end(); ++it2 ) | 199 | for ( ; it2 != mBookmarks.end(); ++it2 ) |
200 | bookmarks.append( *it2 ); | 200 | bookmarks.append( *it2 ); |
201 | 201 | ||
202 | QFile f2( QDir::currentDirPath() + "/.bookmarks" ); | 202 | QFile f2( QDir::currentDirPath() + "/.bookmarks" ); |
203 | f2.open( IO_WriteOnly ); | 203 | f2.open( IO_WriteOnly ); |
204 | QDataStream s2( &f2 ); | 204 | QDataStream s2( &f2 ); |
205 | s2 << bookmarks; | 205 | s2 << bookmarks; |
206 | f2.close(); | 206 | f2.close(); |
207 | } | 207 | } |
208 | 208 | ||
209 | // void HelpWindow::about() | 209 | // void HelpWindow::about() |
210 | // { | 210 | // { |
211 | // QMessageBox::about( this, "Gutenbrowser", "<p>Thanks to Trolltech for this</p>" ); | 211 | // QMessageBox::about( this, "Gutenbrowser", "<p>Thanks to Trolltech for this</p>" ); |
212 | // } | 212 | // } |
213 | 213 | ||
214 | // void HelpWindow::aboutQt() | 214 | // void HelpWindow::aboutQt() |
215 | // { | 215 | // { |
216 | // QMessageBox::aboutQt( this, "QBrowser" ); | 216 | // QMessageBox::aboutQt( this, "QBrowser" ); |
217 | // } | 217 | // } |
218 | 218 | ||
219 | void HelpWindow::openFile() | 219 | void HelpWindow::openFile() |
220 | { | 220 | { |
221 | #ifndef QT_NO_FILEDIALOG | 221 | #ifndef QT_NO_FILEDIALOG |
222 | QString fn = QFileDialog::getOpenFileName( QString::null, QString::null, this ); | 222 | QString fn = QFileDialog::getOpenFileName( QString::null, QString::null, this ); |
223 | if ( !fn.isEmpty() ) | 223 | if ( !fn.isEmpty() ) |
224 | browser->setSource( fn ); | 224 | browser->setSource( fn ); |
225 | #endif | 225 | #endif |
226 | } | 226 | } |
227 | 227 | ||
228 | void HelpWindow::newWindow() | 228 | void HelpWindow::newWindow() |
229 | { | 229 | { |
230 | ( new HelpWindow(browser->source(), "qbrowser") )->show(); | 230 | ( new HelpWindow(browser->source(), "qbrowser") )->show(); |
231 | } | 231 | } |
232 | 232 | ||
233 | void HelpWindow::print() | 233 | void HelpWindow::print() |
234 | { | 234 | { |
235 | #ifndef QT_NO_PRINTER | 235 | #ifndef QT_NO_PRINTER |
236 | QPrinter printer; | 236 | QPrinter printer; |
237 | printer.setFullPage(TRUE); | 237 | printer.setFullPage(TRUE); |
238 | if ( printer.setup() ) { | 238 | if ( printer.setup() ) { |
239 | QPainter p( &printer ); | 239 | QPainter p( &printer ); |
240 | QPaintDeviceMetrics metrics(p.device()); | 240 | QPaintDeviceMetrics metrics(p.device()); |
241 | int dpix = metrics.logicalDpiX(); | 241 | int dpix = metrics.logicalDpiX(); |
242 | int dpiy = metrics.logicalDpiY(); | 242 | int dpiy = metrics.logicalDpiY(); |
243 | const int margin = 72; // pt | 243 | const int margin = 72; // pt |
244 | QRect body(margin*dpix/72, margin*dpiy/72, | 244 | QRect body(margin*dpix/72, margin*dpiy/72, |
245 | metrics.width()-margin*dpix/72*2, | 245 | metrics.width()-margin*dpix/72*2, |
246 | metrics.height()-margin*dpiy/72*2 ); | 246 | metrics.height()-margin*dpiy/72*2 ); |
247 | QFont font("times", 10); | 247 | QFont font("times", 10); |
248 | QSimpleRichText richText( browser->text(), font, browser->context(), browser->styleSheet(), | 248 | QSimpleRichText richText( browser->text(), font, browser->context(), browser->styleSheet(), |
249 | browser->mimeSourceFactory(), body.height() ); | 249 | browser->mimeSourceFactory(), body.height() ); |
250 | richText.setWidth( &p, body.width() ); | 250 | richText.setWidth( &p, body.width() ); |
251 | QRect view( body ); | 251 | QRect view( body ); |
252 | int page = 1; | 252 | int page = 1; |
253 | do { | 253 | do { |
254 | p.setClipRect( body ); | 254 | p.setClipRect( body ); |
255 | richText.draw( &p, body.left(), body.top(), view, colorGroup() ); | 255 | richText.draw( &p, body.left(), body.top(), view, colorGroup() ); |
256 | p.setClipping( FALSE ); | 256 | p.setClipping( FALSE ); |
257 | view.moveBy( 0, body.height() ); | 257 | view.moveBy( 0, body.height() ); |
258 | p.translate( 0 , -body.height() ); | 258 | p.translate( 0 , -body.height() ); |
259 | p.setFont( font ); | 259 | p.setFont( font ); |
260 | p.drawText( view.right() - p.fontMetrics().width( QString::number(page) ), | 260 | p.drawText( view.right() - p.fontMetrics().width( QString::number(page) ), |
261 | view.bottom() + p.fontMetrics().ascent() + 5, QString::number(page) ); | 261 | view.bottom() + p.fontMetrics().ascent() + 5, QString::number(page) ); |
262 | if ( view.top() >= richText.height() ) | 262 | if ( view.top() >= richText.height() ) |
263 | break; | 263 | break; |
264 | printer.newPage(); | 264 | printer.newPage(); |
265 | page++; | 265 | page++; |
266 | } while (TRUE); | 266 | } while (TRUE); |
267 | } | 267 | } |
268 | #endif | 268 | #endif |
269 | } | 269 | } |
270 | 270 | ||
271 | void HelpWindow::pathSelected( const QString &_path ) | 271 | void HelpWindow::pathSelected( const QString &_path ) |
272 | { | 272 | { |
273 | browser->setSource( _path ); | 273 | browser->setSource( _path ); |
274 | QMap<int, QString>::Iterator it = mHistory.begin(); | 274 | QMap<int, QString>::Iterator it = mHistory.begin(); |
275 | bool exists = FALSE; | 275 | bool exists = FALSE; |
276 | for ( ; it != mHistory.end(); ++it ) { | 276 | for ( ; it != mHistory.end(); ++it ) { |
277 | if ( *it == _path ) { | 277 | if ( *it == _path ) { |
278 | exists = TRUE; | 278 | exists = TRUE; |
279 | break; | 279 | break; |
280 | } | 280 | } |
281 | } | 281 | } |
282 | if ( !exists ) | 282 | if ( !exists ) |
283 | mHistory[ hist->insertItem( _path ) ] = _path; | 283 | mHistory[ hist->insertItem( _path ) ] = _path; |
284 | } | 284 | } |
285 | 285 | ||
286 | void HelpWindow::readHistory() | 286 | void HelpWindow::readHistory() |
287 | { | 287 | { |
288 | if ( QFile::exists( QDir::currentDirPath() + "/.history" ) ) { | 288 | if ( QFile::exists( QDir::currentDirPath() + "/.history" ) ) { |
289 | QFile f( QDir::currentDirPath() + "/.history" ); | 289 | QFile f( QDir::currentDirPath() + "/.history" ); |
290 | f.open( IO_ReadOnly ); | 290 | f.open( IO_ReadOnly ); |
291 | QDataStream s( &f ); | 291 | QDataStream s( &f ); |
292 | s >> history; | 292 | s >> history; |
293 | f.close(); | 293 | f.close(); |
294 | while ( history.count() > 20 ) | 294 | while ( history.count() > 20 ) |
295 | history.remove( history.begin() ); | 295 | history.remove( history.begin() ); |
296 | } | 296 | } |
297 | } | 297 | } |
298 | 298 | ||
299 | void HelpWindow::readBookmarks() | 299 | void HelpWindow::readBookmarks() |
300 | { | 300 | { |
301 | if ( QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) { | 301 | if ( QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) { |
302 | QFile f( QDir::currentDirPath() + "/.bookmarks" ); | 302 | QFile f( QDir::currentDirPath() + "/.bookmarks" ); |
303 | f.open( IO_ReadOnly ); | 303 | f.open( IO_ReadOnly ); |
304 | QDataStream s( &f ); | 304 | QDataStream s( &f ); |
305 | s >> bookmarks; | 305 | s >> bookmarks; |
306 | f.close(); | 306 | f.close(); |
307 | } | 307 | } |
308 | } | 308 | } |
309 | 309 | ||
310 | void HelpWindow::histChosen( int i ) | 310 | void HelpWindow::histChosen( int i ) |
311 | { | 311 | { |
312 | if ( mHistory.contains( i ) ) | 312 | if ( mHistory.contains( i ) ) |
313 | browser->setSource( mHistory[ i ] ); | 313 | browser->setSource( mHistory[ i ] ); |
314 | } | 314 | } |
315 | 315 | ||
316 | void HelpWindow::bookmChosen( int i ) | 316 | void HelpWindow::bookmChosen( int i ) |
317 | { | 317 | { |
318 | if ( mBookmarks.contains( i ) ) | 318 | if ( mBookmarks.contains( i ) ) |
319 | browser->setSource( mBookmarks[ i ] ); | 319 | browser->setSource( mBookmarks[ i ] ); |
320 | } | 320 | } |
321 | 321 | ||
322 | void HelpWindow::addBookmark() | 322 | void HelpWindow::addBookmark() |
323 | { | 323 | { |
324 | mBookmarks[ bookm->insertItem( caption() ) ] = caption(); | 324 | mBookmarks[ bookm->insertItem( caption() ) ] = caption(); |
325 | } | 325 | } |
326 | 326 | ||
diff --git a/noncore/apps/oxygen/kmolelements.cpp b/noncore/apps/oxygen/kmolelements.cpp index ce8f9c1..e76461b 100644 --- a/noncore/apps/oxygen/kmolelements.cpp +++ b/noncore/apps/oxygen/kmolelements.cpp | |||
@@ -1,238 +1,238 @@ | |||
1 | /* | 1 | /* |
2 | * kmolelements.cpp | 2 | * kmolelements.cpp |
3 | * | 3 | * |
4 | * Copyright (C) 2000 Tomislav Gountchev <tomi@idiom.com> | 4 | * Copyright (C) 2000 Tomislav Gountchev <tomi@idiom.com> |
5 | */ | 5 | */ |
6 | 6 | ||
7 | // classes that store and manipulate chemical formulas represented as | 7 | // classes that store and manipulate chemical formulas represented as |
8 | // lists of elements | 8 | // lists of elements |
9 | 9 | ||
10 | #include <stdio.h> | 10 | #include <stdio.h> |
11 | #include "kmolelements.h" | 11 | #include "kmolelements.h" |
12 | 12 | ||
13 | /** | 13 | /** |
14 | * A generic chemical entity. Can be an element or a group. | 14 | * A generic chemical entity. Can be an element or a group. |
15 | */ | 15 | */ |
16 | SubUnit::SubUnit () {} | 16 | SubUnit::SubUnit () {} |
17 | 17 | ||
18 | SubUnit::~SubUnit () {} | 18 | SubUnit::~SubUnit () {} |
19 | 19 | ||
20 | /** | 20 | /** |
21 | * Construct a subunit and return a pointer to it. The syntax of LINE is | 21 | * Construct a subunit and return a pointer to it. The syntax of LINE is |
22 | * the one used in the element definition file. | 22 | * the one used in the element definition file. |
23 | */ | 23 | */ |
24 | SubUnit* SubUnit::makeSubUnit(QString line) { | 24 | SubUnit* SubUnit::makeSubUnit(QString line) { |
25 | QString name, grpname, weight, coef; | 25 | QString name, grpname, weight, coef; |
26 | QTextStream str (line, IO_ReadOnly); | 26 | QTextStream str (line, IO_ReadOnly); |
27 | str >> name; | 27 | str >> name; |
28 | if (name != "-group") { // not a group - must be represented as Element | 28 | if (name != "-group") { // not a group - must be represented as Element |
29 | str >> weight >> ws; | 29 | str >> weight >> ws; |
30 | return new Element(name, weight.toDouble()); | 30 | return new Element(name, weight.toDouble()); |
31 | } | 31 | } |
32 | else { | 32 | else { |
33 | str >> grpname; | 33 | str >> grpname; |
34 | ElementList* els = new ElementList(grpname); // group - make an ElementList | 34 | ElementList* els = new ElementList(grpname); // group - make an ElementList |
35 | while (!str.eof()) { | 35 | while (!str.eof()) { |
36 | str >> name >> ws; | 36 | str >> name >> ws; |
37 | str >> coef >> ws; | 37 | str >> coef >> ws; |
38 | els->addElement(name, coef.toDouble()); | 38 | els->addElement(name, coef.toDouble()); |
39 | } | 39 | } |
40 | return els; | 40 | return els; |
41 | } | 41 | } |
42 | } | 42 | } |
43 | 43 | ||
44 | QString SubUnit::getName() const { | 44 | QString SubUnit::getName() const { |
45 | return QString("None"); | 45 | return QString("None"); |
46 | } | 46 | } |
47 | 47 | ||
48 | /** | 48 | /** |
49 | * Get the molecular weight of THIS, based on the data from ELSTABLE. | 49 | * Get the molecular weight of THIS, based on the data from ELSTABLE. |
50 | */ | 50 | */ |
51 | double SubUnit::getWeight(QDict<SubUnit>* elstable) const { | 51 | double SubUnit::getWeight(QDict<SubUnit>* ) const { |
52 | return -1; | 52 | return -1; |
53 | } | 53 | } |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * A group of elements. | 56 | * A group of elements. |
57 | */ | 57 | */ |
58 | ElementList::ElementList () { | 58 | ElementList::ElementList () { |
59 | elements = new QList<ElementCoef>; | 59 | elements = new QList<ElementCoef>; |
60 | } | 60 | } |
61 | 61 | ||
62 | ElementList::~ElementList () { | 62 | ElementList::~ElementList () { |
63 | delete elements; | 63 | delete elements; |
64 | } | 64 | } |
65 | 65 | ||
66 | 66 | ||
67 | /** | 67 | /** |
68 | * A group of elements. | 68 | * A group of elements. |
69 | */ | 69 | */ |
70 | ElementList::ElementList (QString name) { | 70 | ElementList::ElementList (QString name) { |
71 | this->name = name; | 71 | this->name = name; |
72 | elements = new QList<ElementCoef>; | 72 | elements = new QList<ElementCoef>; |
73 | } | 73 | } |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * Write THIS to LINE, in a format suitable for the element definition file. | 76 | * Write THIS to LINE, in a format suitable for the element definition file. |
77 | */ | 77 | */ |
78 | void ElementList::writeOut(QString& line) { | 78 | void ElementList::writeOut(QString& line) { |
79 | QString coef; | 79 | QString coef; |
80 | line = "-group " + name; | 80 | line = "-group " + name; |
81 | ElementCoef* current = elements->first(); | 81 | ElementCoef* current = elements->first(); |
82 | while (current != 0) { | 82 | while (current != 0) { |
83 | line += " " + current->name + " " + coef.setNum(current->coef, 'g', 10); | 83 | line += " " + current->name + " " + coef.setNum(current->coef, 'g', 10); |
84 | // precision set to 10 digits | 84 | // precision set to 10 digits |
85 | current = elements->next(); | 85 | current = elements->next(); |
86 | } | 86 | } |
87 | } | 87 | } |
88 | 88 | ||
89 | /** | 89 | /** |
90 | * Get the molecular weight of THIS, based on the data from ELSTABLE. | 90 | * Get the molecular weight of THIS, based on the data from ELSTABLE. |
91 | */ | 91 | */ |
92 | double ElementList::getWeight(QDict<SubUnit>* elstable) const { | 92 | double ElementList::getWeight(QDict<SubUnit>* elstable) const { |
93 | double weight = 0; | 93 | double weight = 0; |
94 | ElementCoef* current = elements->first(); | 94 | ElementCoef* current = elements->first(); |
95 | while (current != 0) { | 95 | while (current != 0) { |
96 | SubUnit* e = elstable->find(current->name); | 96 | SubUnit* e = elstable->find(current->name); |
97 | if (e != 0) { | 97 | if (e != 0) { |
98 | weight += (current->coef) * (e->getWeight(elstable)); | 98 | weight += (current->coef) * (e->getWeight(elstable)); |
99 | } else return -1; //ERROR | 99 | } else return -1; //ERROR |
100 | current = elements->next(); | 100 | current = elements->next(); |
101 | } | 101 | } |
102 | return weight; | 102 | return weight; |
103 | } | 103 | } |
104 | 104 | ||
105 | /** | 105 | /** |
106 | * Return a string representing the elemental composition of THIS, as | 106 | * Return a string representing the elemental composition of THIS, as |
107 | * a tab-separated element - percentage pairs, separated by newlines. | 107 | * a tab-separated element - percentage pairs, separated by newlines. |
108 | */ | 108 | */ |
109 | QString ElementList::getEA(QDict<SubUnit>* elstable, double mw) const { | 109 | QString ElementList::getEA(QDict<SubUnit>* elstable, double mw) const { |
110 | if (mw == 0) mw = getWeight(elstable); | 110 | if (mw == 0) mw = getWeight(elstable); |
111 | QString ea; | 111 | QString ea; |
112 | QString temp; | 112 | QString temp; |
113 | ElementCoef* current = elements->first(); | 113 | ElementCoef* current = elements->first(); |
114 | while (current != 0) { | 114 | while (current != 0) { |
115 | SubUnit* e = elstable->find(current->name); | 115 | SubUnit* e = elstable->find(current->name); |
116 | if (e != 0) { | 116 | if (e != 0) { |
117 | double current_percent = 100 * (current->coef) * | 117 | double current_percent = 100 * (current->coef) * |
118 | (e->getWeight(elstable)) | 118 | (e->getWeight(elstable)) |
119 | / mw; | 119 | / mw; |
120 | ea += current->name + "\t" + | 120 | ea += current->name + "\t" + |
121 | temp.setNum(current_percent) + "\n"; | 121 | temp.setNum(current_percent) + "\n"; |
122 | } else return QString("ERROR!\n"); //ERROR | 122 | } else return QString("ERROR!\n"); //ERROR |
123 | current = elements->next(); | 123 | current = elements->next(); |
124 | } | 124 | } |
125 | return ea; | 125 | return ea; |
126 | } | 126 | } |
127 | 127 | ||
128 | /** | 128 | /** |
129 | * Return a string representing THIS as an empirical chemical formula. | 129 | * Return a string representing THIS as an empirical chemical formula. |
130 | */ | 130 | */ |
131 | QString ElementList::getEmpFormula() const { | 131 | QString ElementList::getEmpFormula() const { |
132 | QString ef; | 132 | QString ef; |
133 | QString temp; | 133 | QString temp; |
134 | ElementCoef* current = elements->first(); | 134 | ElementCoef* current = elements->first(); |
135 | while (current != 0) { | 135 | while (current != 0) { |
136 | ef += current->name + temp.setNum(current->coef); | 136 | ef += current->name + temp.setNum(current->coef); |
137 | current = elements->next(); | 137 | current = elements->next(); |
138 | } | 138 | } |
139 | return ef; | 139 | return ef; |
140 | } | 140 | } |
141 | 141 | ||
142 | /** | 142 | /** |
143 | * Multiply THIS (i.e. the coefficient of each element) by coef. | 143 | * Multiply THIS (i.e. the coefficient of each element) by coef. |
144 | */ | 144 | */ |
145 | void ElementList::multiplyBy(double coef) { | 145 | void ElementList::multiplyBy(double coef) { |
146 | ElementCoef* current = elements->first(); | 146 | ElementCoef* current = elements->first(); |
147 | while (current != 0) { | 147 | while (current != 0) { |
148 | (current->coef) *= coef; | 148 | (current->coef) *= coef; |
149 | current = elements->next(); | 149 | current = elements->next(); |
150 | } | 150 | } |
151 | } | 151 | } |
152 | 152 | ||
153 | /** | 153 | /** |
154 | * Add THIS to ELS. THIS is not modified; ELS is. | 154 | * Add THIS to ELS. THIS is not modified; ELS is. |
155 | */ | 155 | */ |
156 | void ElementList::addTo(ElementList& els, double coef) { | 156 | void ElementList::addTo(ElementList& els, double coef) { |
157 | ElementCoef* current = elements->first(); | 157 | ElementCoef* current = elements->first(); |
158 | while (current != 0) { | 158 | while (current != 0) { |
159 | els.addElement(current->name, (current->coef) * coef); | 159 | els.addElement(current->name, (current->coef) * coef); |
160 | current = elements->next(); | 160 | current = elements->next(); |
161 | } | 161 | } |
162 | } | 162 | } |
163 | 163 | ||
164 | /** | 164 | /** |
165 | * Add an element to THIS, with a coefficient COEF. If THIS already contains | 165 | * Add an element to THIS, with a coefficient COEF. If THIS already contains |
166 | * an element with the same name, adjust its coefficient only; if not, create | 166 | * an element with the same name, adjust its coefficient only; if not, create |
167 | * a new ElementCoef pair and add to THIS. | 167 | * a new ElementCoef pair and add to THIS. |
168 | */ | 168 | */ |
169 | void ElementList::addElement(const QString& name, double coef) { | 169 | void ElementList::addElement(const QString& name, double coef) { |
170 | ElementCoef* current = elements->first(); | 170 | ElementCoef* current = elements->first(); |
171 | while (current != 0) { | 171 | while (current != 0) { |
172 | if (current->name == name) { | 172 | if (current->name == name) { |
173 | current->coef += coef; | 173 | current->coef += coef; |
174 | return; | 174 | return; |
175 | } | 175 | } |
176 | current = elements->next(); | 176 | current = elements->next(); |
177 | } | 177 | } |
178 | elements->append(new ElementCoef(name, coef)); | 178 | elements->append(new ElementCoef(name, coef)); |
179 | } | 179 | } |
180 | 180 | ||
181 | /** | 181 | /** |
182 | * True iff THIS contains element named NAME. | 182 | * True iff THIS contains element named NAME. |
183 | */ | 183 | */ |
184 | bool ElementList::contains(const QString& name) { | 184 | bool ElementList::contains(const QString& name) { |
185 | ElementCoef* current = elements->first(); | 185 | ElementCoef* current = elements->first(); |
186 | while (current != 0) { | 186 | while (current != 0) { |
187 | if (current->name == name) | 187 | if (current->name == name) |
188 | return true; | 188 | return true; |
189 | current = elements->next(); | 189 | current = elements->next(); |
190 | } | 190 | } |
191 | return false; | 191 | return false; |
192 | } | 192 | } |
193 | 193 | ||
194 | bool ElementList::isEmpty() { | 194 | bool ElementList::isEmpty() { |
195 | return elements->isEmpty(); | 195 | return elements->isEmpty(); |
196 | } | 196 | } |
197 | 197 | ||
198 | QString ElementList::getName() const { | 198 | QString ElementList::getName() const { |
199 | return name; | 199 | return name; |
200 | } | 200 | } |
201 | 201 | ||
202 | /** | 202 | /** |
203 | * A chemical element. | 203 | * A chemical element. |
204 | */ | 204 | */ |
205 | Element::Element(const QString& n, double w) | 205 | Element::Element(const QString& n, double w) |
206 | : weight(w), name(n) { } | 206 | : weight(w), name(n) { } |
207 | 207 | ||
208 | 208 | ||
209 | Element::~Element() { | 209 | Element::~Element() { |
210 | } | 210 | } |
211 | 211 | ||
212 | 212 | ||
213 | /** | 213 | /** |
214 | * Write THIS to LINE, in a format suitable for the element definition file. | 214 | * Write THIS to LINE, in a format suitable for the element definition file. |
215 | */ | 215 | */ |
216 | void Element::writeOut(QString& line) { | 216 | void Element::writeOut(QString& line) { |
217 | line.setNum(weight); | 217 | line.setNum(weight); |
218 | line = name + " " + line; | 218 | line = name + " " + line; |
219 | } | 219 | } |
220 | 220 | ||
221 | double Element::getWeight(QDict<SubUnit>* elstable) const { | 221 | double Element::getWeight(QDict<SubUnit>* ) const { |
222 | return weight; | 222 | return weight; |
223 | } | 223 | } |
224 | 224 | ||
225 | void Element::addTo(ElementList& els, double coef) { | 225 | void Element::addTo(ElementList& els, double coef) { |
226 | els.addElement(name, coef); | 226 | els.addElement(name, coef); |
227 | } | 227 | } |
228 | 228 | ||
229 | QString Element::getName() const { | 229 | QString Element::getName() const { |
230 | return name; | 230 | return name; |
231 | } | 231 | } |
232 | 232 | ||
233 | /** | 233 | /** |
234 | * An element - coefficient pair. Used to represent elements within an | 234 | * An element - coefficient pair. Used to represent elements within an |
235 | * element list. | 235 | * element list. |
236 | */ | 236 | */ |
237 | ElementCoef::ElementCoef(const QString& n, double c) : name(n), coef(c) {} | 237 | ElementCoef::ElementCoef(const QString& n, double c) : name(n), coef(c) {} |
238 | 238 | ||