author | mickeyl <mickeyl> | 2003-10-27 19:51:32 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-10-27 19:51:32 (UTC) |
commit | 951d1d4125a80dc814f95d2956853bf53ca52e9a (patch) (unidiff) | |
tree | 46c7a70b80a7eebb54cd59c46204c28335f3821c | |
parent | f0a15a9866f9eddfe10596e63a1e6300b92b9e3f (diff) | |
download | opie-951d1d4125a80dc814f95d2956853bf53ca52e9a.zip opie-951d1d4125a80dc814f95d2956853bf53ca52e9a.tar.gz opie-951d1d4125a80dc814f95d2956853bf53ca52e9a.tar.bz2 |
merge noncore/apps/* except
- advancedfm (ljp, please...)
- odict (tille, please...)
55 files changed, 1595 insertions, 513 deletions
diff --git a/noncore/apps/checkbook/cbinfo.cpp b/noncore/apps/checkbook/cbinfo.cpp index 9fdc6b2..36dde04 100644 --- a/noncore/apps/checkbook/cbinfo.cpp +++ b/noncore/apps/checkbook/cbinfo.cpp | |||
@@ -1,196 +1,228 @@ | |||
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 "cbinfo.h" | 29 | #include "cbinfo.h" |
30 | #include "traninfo.h" | 30 | #include "traninfo.h" |
31 | 31 | ||
32 | #include <qpe/config.h> | 32 | #include <qpe/config.h> |
33 | 33 | ||
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | 35 | ||
36 | // --- CBInfo ----------------------------------------------------------------- | ||
36 | CBInfo::CBInfo() | 37 | CBInfo::CBInfo() |
37 | { | 38 | { |
38 | n = ""; | 39 | n = ""; |
39 | fn = ""; | 40 | fn = ""; |
40 | pw = QString::null; | 41 | pw = QString::null; |
41 | t = ""; | 42 | t = ""; |
42 | bn = ""; | 43 | bn = ""; |
43 | a = ""; | 44 | a = ""; |
44 | p = ""; | 45 | p = ""; |
45 | nt = ""; | 46 | nt = ""; |
46 | sb = 0.0; | 47 | sb = 0.0; |
48 | _sLastTab=""; | ||
49 | _first=-1; | ||
50 | _last=-1; | ||
47 | 51 | ||
48 | tl = new TranInfoList(); | 52 | tl = new TranInfoList(); |
49 | } | 53 | } |
50 | 54 | ||
55 | |||
56 | // --- CBInfo ----------------------------------------------------------------- | ||
51 | CBInfo::CBInfo( const QString &name, const QString &filename ) | 57 | CBInfo::CBInfo( const QString &name, const QString &filename ) |
52 | { | 58 | { |
53 | Config config( filename, Config::File ); | 59 | Config config( filename, Config::File ); |
54 | config.setGroup( "Account" ); | 60 | config.setGroup( "Account" ); |
55 | 61 | ||
56 | n = name; | 62 | n = name; |
57 | fn = filename; | 63 | fn = filename; |
58 | pw = config.readEntryCrypt( "Password", QString::null ); | 64 | pw = config.readEntryCrypt( "Password", QString::null ); |
59 | 65 | ||
60 | t = config.readEntry( "Type" ); | 66 | t = config.readEntry( "Type" ); |
61 | bn = config.readEntry( "Bank", "" ); | 67 | bn = config.readEntry( "Bank", "" ); |
62 | a = config.readEntryCrypt( "Number", "" ); | 68 | a = config.readEntryCrypt( "Number", "" ); |
63 | p = config.readEntryCrypt( "PINNumber", "" ); | 69 | p = config.readEntryCrypt( "PINNumber", "" ); |
64 | nt = config.readEntry( "Notes", "" ); | 70 | nt = config.readEntry( "Notes", "" ); |
71 | _sLastTab = config.readEntry("LastTab", ""); | ||
72 | _first=config.readNumEntry("First", -1); | ||
73 | _sSortOrder = config.readEntry( "SortOrder", QWidget::tr("Date") ); | ||
65 | 74 | ||
66 | bool ok; | 75 | bool ok; |
67 | sb = config.readEntry( "Balance", "0.0" ).toFloat( &ok ); | 76 | sb = config.readEntry( "Balance", "0.0" ).toFloat( &ok ); |
68 | 77 | ||
69 | loadTransactions(); | 78 | loadTransactions(); |
70 | } | 79 | } |
71 | 80 | ||
81 | // --- balance ---------------------------------------------------------------- | ||
72 | float CBInfo::balance() | 82 | float CBInfo::balance() |
73 | { | 83 | { |
74 | calcBalance(); | 84 | calcBalance(); |
75 | return b; | 85 | return b; |
76 | } | 86 | } |
77 | 87 | ||
88 | // --- write ------------------------------------------------------------------ | ||
78 | void CBInfo::write() | 89 | void CBInfo::write() |
79 | { | 90 | { |
80 | QFile f( fn ); | 91 | QFile f( fn ); |
81 | if ( f.exists() ) | 92 | if ( f.exists() ) |
82 | { | ||
83 | f.remove(); | 93 | f.remove(); |
84 | } | ||
85 | 94 | ||
86 | Config *config = new Config(fn, Config::File); | 95 | Config *config = new Config(fn, Config::File); |
87 | 96 | ||
88 | // Save info | 97 | |
98 | // fix transaction numbers | ||
99 | _first=-1; | ||
100 | TranInfo *prev=NULL; | ||
101 | for ( TranInfo *tran = tl->first(); tran; tran = tl->next() ) { | ||
102 | if( _first<0 ) _first=tran->id(); | ||
103 | if( prev ) prev->setNext( tran->id() ); | ||
104 | tran->setNext(-1); | ||
105 | prev=tran; | ||
106 | } | ||
107 | |||
108 | // Save transactions | ||
109 | for ( TranInfo *tran = tl->first(); tran; tran = tl->next() ) { | ||
110 | tran->write(config); | ||
111 | } | ||
112 | |||
113 | // Save info | ||
114 | if( _first<0 && _last>=0 ) _first=_last; | ||
89 | config->setGroup( "Account" ); | 115 | config->setGroup( "Account" ); |
90 | config->writeEntryCrypt( "Password", pw ); | 116 | config->writeEntryCrypt( "Password", pw ); |
91 | config->writeEntry( "Type", t ); | 117 | config->writeEntry( "Type", t ); |
92 | config->writeEntry( "Bank", bn ); | 118 | config->writeEntry( "Bank", bn ); |
93 | config->writeEntryCrypt( "Number", a ); | 119 | config->writeEntryCrypt( "Number", a ); |
94 | config->writeEntryCrypt( "PINNumber", p ); | 120 | config->writeEntryCrypt( "PINNumber", p ); |
95 | config->writeEntry( "Notes", nt ); | 121 | config->writeEntry( "Notes", nt ); |
122 | config->writeEntry( "LastTab", _sLastTab ); | ||
96 | QString balstr; | 123 | QString balstr; |
97 | balstr.setNum( sb, 'f', 2 ); | 124 | balstr.setNum( sb, 'f', 2 ); |
98 | config->writeEntry( "Balance", balstr ); | 125 | config->writeEntry( "Balance", balstr ); |
126 | config->writeEntry( "First", _first ); | ||
127 | config->writeEntry( "SortOrder", _sSortOrder ); | ||
99 | 128 | ||
100 | // Save transactions | 129 | config->write(); |
101 | int i = 1; | ||
102 | for ( TranInfo *tran = tl->first(); tran; tran = tl->next() ) | ||
103 | { | ||
104 | tran->write( config, i ); | ||
105 | i++; | ||
106 | } | ||
107 | config->write(); | ||
108 | |||
109 | delete config; | 130 | delete config; |
110 | } | 131 | } |
111 | 132 | ||
112 | TranInfo *CBInfo::findTransaction( const QString &checknum, const QString &date, | 133 | |
113 | const QString &desc ) | 134 | // --- findTransaction -------------------------------------------------------- |
135 | TranInfo *CBInfo::findTransaction( const QString &sId ) | ||
114 | { | 136 | { |
115 | TranInfo *traninfo = tl->first(); | 137 | bool bOk; |
116 | while ( traninfo ) | 138 | int id=sId.toInt( &bOk ); |
117 | { | 139 | if( !bOk ) |
118 | if ( traninfo->number() == checknum && traninfo->datestr() == date && | 140 | return(false); |
119 | traninfo->desc() == desc ) | 141 | TranInfo *traninfo; |
120 | break; | 142 | for(traninfo=tl->first(); traninfo; traninfo=tl->next()) { |
121 | traninfo = tl->next(); | 143 | if( traninfo->id() == id ) |
122 | } | 144 | break; |
123 | return( traninfo ); | 145 | } |
146 | return(traninfo); | ||
124 | } | 147 | } |
125 | 148 | ||
126 | void CBInfo::addTransaction( TranInfo *tran ) | 149 | void CBInfo::addTransaction( TranInfo *tran ) |
127 | { | 150 | { |
128 | tl->inSort( tran ); | 151 | tl->append( tran ); |
129 | calcBalance(); | 152 | calcBalance(); |
130 | } | 153 | } |
131 | 154 | ||
132 | void CBInfo::removeTransaction( TranInfo *tran ) | 155 | void CBInfo::removeTransaction( TranInfo *tran ) |
133 | { | 156 | { |
134 | tl->remove( tran ); | 157 | tl->removeRef( tran ); |
135 | delete tran; | 158 | delete tran; |
136 | calcBalance(); | 159 | calcBalance(); |
137 | } | 160 | } |
138 | 161 | ||
162 | |||
163 | // --- loadTransactions ------------------------------------------------------- | ||
164 | // Reads the transactions. Either the old way 1-n or as linked list. | ||
139 | void CBInfo::loadTransactions() | 165 | void CBInfo::loadTransactions() |
140 | { | 166 | { |
141 | TranInfo *tran; | 167 | TranInfo *tran; |
142 | QString trandesc = ""; | 168 | QString trandesc = ""; |
143 | 169 | ||
144 | tl = new TranInfoList(); | 170 | tl = new TranInfoList(); |
145 | 171 | ||
146 | Config config( fn, Config::File ); | 172 | Config config( fn, Config::File ); |
147 | 173 | int i=_first; | |
148 | for ( int i = 1; trandesc != QString::null; i++ ) | 174 | bool bOld=false; |
149 | { | 175 | if( i==-1 ) { |
150 | tran = new TranInfo( config, i ); | 176 | i=1; |
151 | trandesc = tran->desc(); | 177 | bOld=true; |
152 | if ( trandesc != QString::null ) | 178 | } |
153 | { | 179 | while( i>=0 ) { |
154 | tl->inSort( tran ); | 180 | _last=i; |
155 | } | 181 | tran=new TranInfo(config, i); |
156 | else | 182 | trandesc = tran->desc(); |
157 | { | 183 | if( trandesc==QString::null ) { |
158 | delete tran; | 184 | delete tran; |
159 | } | 185 | break; |
160 | } | 186 | } |
161 | 187 | tl->append(tran); | |
162 | calcBalance(); | 188 | i= bOld ? i+1 : tran->getNext(); |
189 | } | ||
190 | |||
191 | calcBalance(); | ||
163 | } | 192 | } |
164 | 193 | ||
194 | |||
195 | // --- calcBalance ------------------------------------------------------------ | ||
165 | void CBInfo::calcBalance() | 196 | void CBInfo::calcBalance() |
166 | { | 197 | { |
167 | float amount; | 198 | float amount; |
168 | 199 | ||
169 | b = sb; | 200 | b = sb; |
170 | 201 | ||
171 | for ( TranInfo *tran = tl->first(); tran; tran = tl->next() ) | 202 | for ( TranInfo *tran = tl->first(); tran; tran = tl->next() ) |
172 | { | 203 | { |
173 | b -= tran->fee(); | 204 | b -= tran->fee(); |
174 | amount = tran->amount(); | 205 | amount = tran->amount(); |
175 | if ( tran->withdrawal() ) | 206 | if ( tran->withdrawal() ) |
176 | { | 207 | { |
177 | amount *= -1; | 208 | amount *= -1; |
178 | } | 209 | } |
179 | b += amount; | 210 | b += amount; |
180 | } | 211 | } |
181 | } | 212 | } |
182 | 213 | ||
214 | |||
183 | int CBInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 ) | 215 | int CBInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 ) |
184 | { | 216 | { |
185 | QString n1 = ((CBInfo *)item1)->name(); | 217 | QString n1 = ((CBInfo *)item1)->name(); |
186 | QString n2 = ((CBInfo *)item2)->name(); | 218 | QString n2 = ((CBInfo *)item2)->name(); |
187 | int r = -1; | 219 | int r = -1; |
188 | 220 | ||
189 | if ( n1 < n2 ) | 221 | if ( n1 < n2 ) |
190 | r = -1; | 222 | r = -1; |
191 | else if ( n1 == n2 ) | 223 | else if ( n1 == n2 ) |
192 | r = 0; | 224 | r = 0; |
193 | else if ( n1 > n2 ) | 225 | else if ( n1 > n2 ) |
194 | r = 1; | 226 | r = 1; |
195 | return( r ); | 227 | return( r ); |
196 | } | 228 | } |
diff --git a/noncore/apps/checkbook/cbinfo.h b/noncore/apps/checkbook/cbinfo.h index 5e65db2..0b5b818 100644 --- a/noncore/apps/checkbook/cbinfo.h +++ b/noncore/apps/checkbook/cbinfo.h | |||
@@ -1,97 +1,115 @@ | |||
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 | #ifndef CBINFO_H | 29 | #ifndef CBINFO_H |
30 | #define CBINFO_H | 30 | #define CBINFO_H |
31 | 31 | ||
32 | #include <qwidget.h> | ||
32 | #include <qlist.h> | 33 | #include <qlist.h> |
33 | #include <qstring.h> | 34 | #include <qstring.h> |
34 | 35 | ||
35 | class Config; | 36 | class Config; |
36 | class TranInfo; | 37 | class TranInfo; |
37 | class TranInfoList; | 38 | class TranInfoList; |
38 | 39 | ||
39 | class CBInfo | 40 | class CBInfo |
40 | { | 41 | { |
41 | public: | 42 | public: |
42 | CBInfo(); | 43 | CBInfo(); |
43 | CBInfo( const QString &, const QString & ); | 44 | CBInfo( const QString &, const QString & ); |
44 | 45 | ||
45 | const QString &name() const { return n; } | 46 | const QString &name() const { return n; } |
46 | const QString &filename() const { return fn; } | 47 | const QString &filename() const { return fn; } |
47 | const QString &password() const { return pw; } | 48 | const QString &password() const { return pw; } |
48 | const QString &type() const { return t; } | 49 | const QString &type() const { return t; } |
49 | const QString &bank() const { return bn; } | 50 | const QString &bank() const { return bn; } |
50 | const QString &account() const { return a; } | 51 | const QString &account() const { return a; } |
51 | const QString &pin() const { return p; } | 52 | const QString &pin() const { return p; } |
52 | const QString ¬es() const { return nt; } | 53 | const QString ¬es() const { return nt; } |
53 | float startingBalance()const { return sb; } | 54 | float startingBalance()const { return sb; } |
54 | float balance(); | 55 | float balance(); |
55 | 56 | ||
56 | void setName( const QString &name ) { n = name; } | 57 | void setName( const QString &name ) { n = name; } |
57 | void setFilename( const QString &filename ){ fn = filename; } | 58 | void setFilename( const QString &filename ){ fn = filename; } |
58 | void setPassword( const QString &password ){ pw = password; } | 59 | void setPassword( const QString &password ){ pw = password; } |
59 | void setType( const QString &type ) { t = type; } | 60 | void setType( const QString &type ) { t = type; } |
60 | void setBank( const QString &bank ) { bn = bank; } | 61 | void setBank( const QString &bank ) { bn = bank; } |
61 | void setAccount( const QString &account ) { a = account; } | 62 | void setAccount( const QString &account ) { a = account; } |
62 | void setPin( const QString &pin ) { p = pin; } | 63 | void setPin( const QString &pin ) { p = pin; } |
63 | void setNotes( const QString ¬es ) { nt = notes; } | 64 | void setNotes( const QString ¬es ) { nt = notes; } |
64 | void setStartingBalance( float startbal ) { sb = startbal; } | 65 | void setStartingBalance( float startbal ) { sb = startbal; } |
65 | 66 | ||
67 | // write | ||
66 | void write(); | 68 | void write(); |
67 | 69 | ||
70 | // transactions | ||
68 | TranInfoList *transactions() const { return tl; } | 71 | TranInfoList *transactions() const { return tl; } |
69 | TranInfo *findTransaction( const QString &, const QString &, const QString & ); | 72 | TranInfo *findTransaction( const QString & ); |
70 | void addTransaction( TranInfo * ); | 73 | void addTransaction( TranInfo * ); |
71 | void removeTransaction( TranInfo * ); | 74 | void removeTransaction( TranInfo * ); |
75 | |||
76 | // lastTab | ||
77 | void setLastTab(const QString &sLastTab) { _sLastTab=sLastTab; } | ||
78 | QString &getLastTab() { return(_sLastTab); } | ||
79 | |||
80 | // getNextNumber | ||
81 | int getNextNumber() { return( ++_last ); } | ||
82 | |||
83 | // sortOrder | ||
84 | void setSortOrder(const QString &sSortOrder) { _sSortOrder=sSortOrder; } | ||
85 | QString &getSortOrder() { return(_sSortOrder); } | ||
72 | 86 | ||
73 | private: | 87 | private: |
74 | QString n; | 88 | QString n; |
75 | QString fn; | 89 | QString fn; |
76 | QString pw; | 90 | QString pw; |
77 | QString t; | 91 | QString t; |
78 | QString bn; | 92 | QString bn; |
79 | QString a; | 93 | QString a; |
80 | QString p; | 94 | QString p; |
81 | QString nt; | 95 | QString nt; |
82 | float sb; | 96 | float sb; |
83 | float b; | 97 | float b; |
98 | QString _sLastTab; | ||
99 | int _first; | ||
100 | int _last; | ||
101 | QString _sSortOrder; | ||
84 | 102 | ||
85 | TranInfoList *tl; | 103 | TranInfoList *tl; |
86 | 104 | ||
87 | void loadTransactions(); | 105 | void loadTransactions(); |
88 | void calcBalance(); | 106 | void calcBalance(); |
89 | }; | 107 | }; |
90 | 108 | ||
91 | class CBInfoList : public QList<CBInfo> | 109 | class CBInfoList : public QList<CBInfo> |
92 | { | 110 | { |
93 | protected: | 111 | protected: |
94 | int compareItems( QCollection::Item, QCollection::Item ); | 112 | int compareItems( QCollection::Item, QCollection::Item ); |
95 | }; | 113 | }; |
96 | 114 | ||
97 | #endif | 115 | #endif |
diff --git a/noncore/apps/checkbook/cfg.cpp b/noncore/apps/checkbook/cfg.cpp new file mode 100644 index 0000000..1e0ec5c --- a/dev/null +++ b/noncore/apps/checkbook/cfg.cpp | |||
@@ -0,0 +1,213 @@ | |||
1 | /* | ||
2 | This file is part of the OPIE Project | ||
3 | =. | ||
4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This file is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
11 | ._= =} : or (at your option) any later version. | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This file is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | ||
18 | ..}^=.= = ; Public License for more details. | ||
19 | ++= -. .` .: | ||
20 | : = ...= . :.=- You should have received a copy of the GNU | ||
21 | -. .:....=;==+<; General Public License along with this file; | ||
22 | -_. . . )=. = see the file COPYING. If not, write to the | ||
23 | -- :-=` Free Software Foundation, Inc., | ||
24 | 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #include <stdio.h> | ||
30 | |||
31 | #include <qstring.h> | ||
32 | #include <qstringlist.h> | ||
33 | #include <qwidget.h> | ||
34 | #include <qpe/resource.h> | ||
35 | #include <qpe/config.h> | ||
36 | |||
37 | #include "cfg.h" | ||
38 | |||
39 | // --- Cfg -------------------------------------------------------------------- | ||
40 | Cfg::Cfg() | ||
41 | { | ||
42 | _currencySymbol="$"; | ||
43 | _showLocks=FALSE; | ||
44 | _showBalances=FALSE; | ||
45 | _pCategories=new CategoryList(); | ||
46 | } | ||
47 | |||
48 | // --- readStringList --------------------------------------------------------- | ||
49 | // Reads the entries for the control from a configuration file and returns | ||
50 | // them in a StringList. Later this list can be used to create the control. It | ||
51 | // is assumed, that the group is already set. Key is used to enumerate the | ||
52 | // entries. | ||
53 | void Cfg::readStringList(Config &cfg, const char *sKey, QStringList &lst) | ||
54 | { | ||
55 | qDebug( "%s", sKey ); | ||
56 | |||
57 | QString sEntry; | ||
58 | int iCount; | ||
59 | |||
60 | // read count of elements | ||
61 | sEntry.sprintf("%s_Count", sKey); | ||
62 | iCount=cfg.readNumEntry(sEntry, 0); | ||
63 | |||
64 | // read entries | ||
65 | for(int i=1; i<=iCount; i++) { | ||
66 | sEntry.sprintf("%s%d", sKey, i); | ||
67 | QString sType=cfg.readEntry(sEntry); | ||
68 | if( sType!=NULL ) | ||
69 | lst.append(sType); | ||
70 | } | ||
71 | } | ||
72 | |||
73 | |||
74 | // --- readConfig ------------------------------------------------------------- | ||
75 | // Reads the member data from the given config file. It will also set the group | ||
76 | // "Config" | ||
77 | void Cfg::readConfig(Config &config) | ||
78 | { | ||
79 | // set group | ||
80 | config.setGroup( "Config" ); | ||
81 | |||
82 | // read scalars | ||
83 | _currencySymbol = config.readEntry( "CurrencySymbol", "$" ); | ||
84 | _showLocks = config.readBoolEntry( "ShowLocks", FALSE ); | ||
85 | _showBalances = config.readBoolEntry( "ShowBalances", FALSE ); | ||
86 | _openLastBook = config.readBoolEntry( "OpenLastBook", FALSE ); | ||
87 | _sLastBook = config.readEntry("LastBook", ""); | ||
88 | _showLastTab = config.readBoolEntry( "ShowLastTab", FALSE ); | ||
89 | |||
90 | // Account types | ||
91 | readStringList(config, "AccType", _AccountTypes); | ||
92 | if( _AccountTypes.isEmpty() ) { | ||
93 | _AccountTypes+= (const char *)QWidget::tr("Savings"); | ||
94 | _AccountTypes+= (const char *)QWidget::tr("Checking"); | ||
95 | _AccountTypes+= (const char *)QWidget::tr("CD"); | ||
96 | _AccountTypes+= (const char *)QWidget::tr("Money market"); | ||
97 | _AccountTypes+= (const char *)QWidget::tr("Mutual fund"); | ||
98 | _AccountTypes+= (const char *)QWidget::tr("Other"); | ||
99 | writeStringList(config, "AccType", _AccountTypes); | ||
100 | config.write(); | ||
101 | } | ||
102 | |||
103 | // Read Categories | ||
104 | QStringList lst; | ||
105 | readStringList(config, "Category", lst); | ||
106 | if( lst.isEmpty() ) { | ||
107 | QString type=QWidget::tr("Expense"); | ||
108 | lst += QWidget::tr( "Automobile" )+";"+type; | ||
109 | lst += QWidget::tr( "Bills" )+";"+type; | ||
110 | lst += QWidget::tr( "CDs" )+";"+type; | ||
111 | lst += QWidget::tr( "Clothing" )+";"+type; | ||
112 | lst += QWidget::tr( "Computer" )+";"+type; | ||
113 | lst += QWidget::tr( "DVDs" )+";"+type; | ||
114 | lst += QWidget::tr( "Electronics" )+";"+type; | ||
115 | lst += QWidget::tr( "Entertainment" )+";"+type; | ||
116 | lst += QWidget::tr( "Food" )+";"+type; | ||
117 | lst += QWidget::tr( "Gasoline" )+";"+type; | ||
118 | lst += QWidget::tr( "Misc" )+";"+type; | ||
119 | lst += QWidget::tr( "Movies" )+";"+type; | ||
120 | lst += QWidget::tr( "Rent" )+";"+type; | ||
121 | lst += QWidget::tr( "Travel" )+";"+type; | ||
122 | |||
123 | type=QWidget::tr( "Income" ); | ||
124 | lst += QWidget::tr( "Work" )+";"+type; | ||
125 | lst += QWidget::tr( "Family Member" )+";"+type; | ||
126 | lst += QWidget::tr( "Misc. Credit" )+";"+type; | ||
127 | |||
128 | setCategories(lst); | ||
129 | writeStringList(config, "Category", lst); | ||
130 | config.write(); | ||
131 | } else { | ||
132 | setCategories(lst); | ||
133 | } | ||
134 | } | ||
135 | |||
136 | |||
137 | // --- writeStringList -------------------------------------------------------- | ||
138 | // Writes the entries in the control in a configuration file. It is assumed, | ||
139 | // that the group is already set. Key is used to enumerate the entries | ||
140 | void Cfg::writeStringList(Config &cfg, const char *sKey, QStringList &lst) | ||
141 | { | ||
142 | QString sEntry; | ||
143 | int iCount=0; | ||
144 | QStringList::Iterator itr; | ||
145 | for(itr=lst.begin(); itr!=lst.end(); itr++) { | ||
146 | sEntry.sprintf("%s%d", sKey, ++iCount); | ||
147 | cfg.writeEntry(sEntry, *itr ); | ||
148 | } | ||
149 | sEntry.sprintf("%s_Count", sKey); | ||
150 | cfg.writeEntry(sEntry, iCount); | ||
151 | } | ||
152 | |||
153 | |||
154 | // --- writeConfig ----------------------------------------------------------- | ||
155 | // Writes all config data back to the config file. The group will be set to | ||
156 | // "Config" and the write be commited | ||
157 | void Cfg::writeConfig(Config &config) | ||
158 | { | ||
159 | // set the group | ||
160 | config.setGroup( "Config" ); | ||
161 | |||
162 | // write scalars | ||
163 | config.writeEntry( "CurrencySymbol", _currencySymbol ); | ||
164 | config.writeEntry( "ShowLocks", _showLocks ); | ||
165 | config.writeEntry( "ShowBalances", _showBalances ); | ||
166 | config.writeEntry( "OpenLastBook", _openLastBook ); | ||
167 | config.writeEntry( "LastBook", _sLastBook ); | ||
168 | config.writeEntry( "ShowLastTab", _showLastTab ); | ||
169 | |||
170 | // write account types | ||
171 | writeStringList(config, "AccType", _AccountTypes); | ||
172 | |||
173 | // write categories | ||
174 | QStringList lst=getCategories(); | ||
175 | writeStringList(config, "Category", lst ); | ||
176 | |||
177 | // commit write | ||
178 | config.write(); | ||
179 | } | ||
180 | |||
181 | |||
182 | // --- getCategories ---------------------------------------------------------- | ||
183 | QStringList Cfg::getCategories() | ||
184 | { | ||
185 | QStringList ret; | ||
186 | for(Category *itr=_pCategories->first(); itr; itr=_pCategories->next() ) { | ||
187 | QString sEntry; | ||
188 | sEntry.sprintf("%s;%s", (const char *)itr->getName(), (const char *)(itr->isIncome() ? QWidget::tr("Income") : QWidget::tr("Expense")) ); | ||
189 | ret.append(sEntry); | ||
190 | } | ||
191 | return(ret); | ||
192 | } | ||
193 | |||
194 | |||
195 | // --- setCategories ---------------------------------------------------------- | ||
196 | void Cfg::setCategories(QStringList &lst) | ||
197 | { | ||
198 | _pCategories->clear(); | ||
199 | QStringList::Iterator itr; | ||
200 | for(itr=lst.begin(); itr!=lst.end(); itr++) { | ||
201 | QStringList split=QStringList::split(";", *itr, true); | ||
202 | if( split.count()<2 ) continue; | ||
203 | bool bIncome= (split[1]==QWidget::tr("Income")); | ||
204 | _pCategories->append( new Category(split[0], bIncome) ); | ||
205 | } | ||
206 | } | ||
207 | |||
208 | |||
209 | // --- CategoryList ------------------------------------------------------------ | ||
210 | CategoryList::CategoryList() : QList<Category>() | ||
211 | { | ||
212 | setAutoDelete(true); | ||
213 | } | ||
diff --git a/noncore/apps/checkbook/cfg.h b/noncore/apps/checkbook/cfg.h new file mode 100644 index 0000000..2b69368 --- a/dev/null +++ b/noncore/apps/checkbook/cfg.h | |||
@@ -0,0 +1,120 @@ | |||
1 | /* | ||
2 | This file is part of the OPIE Project | ||
3 | =. | ||
4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This file is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
11 | ._= =} : or (at your option) any later version. | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This file is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | ||
18 | ..}^=.= = ; Public License for more details. | ||
19 | ++= -. .` .: | ||
20 | : = ...= . :.=- You should have received a copy of the GNU | ||
21 | -. .:....=;==+<; General Public License along with this file; | ||
22 | -_. . . )=. = see the file COPYING. If not, write to the | ||
23 | -- :-=` Free Software Foundation, Inc., | ||
24 | 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #ifndef CFG_H | ||
30 | #define CFG_H | ||
31 | |||
32 | #include <qstring.h> | ||
33 | #include <qlist.h> | ||
34 | #include <qstringlist.h> | ||
35 | class Config; | ||
36 | |||
37 | // --- Category --------------------------------------------------------------- | ||
38 | class Category | ||
39 | { | ||
40 | public: | ||
41 | // --- Constructor: | ||
42 | Category(QString &sName, bool bIncome=false) { _sName=sName; _bIncome=bIncome; } | ||
43 | |||
44 | // members | ||
45 | QString &getName() { return(_sName); } | ||
46 | bool isIncome() { return(_bIncome); } | ||
47 | void setName(QString &sName) { _sName=sName; } | ||
48 | void setIncome(bool bIncome) { _bIncome=bIncome; } | ||
49 | |||
50 | private: | ||
51 | QString _sName; | ||
52 | bool _bIncome; | ||
53 | }; | ||
54 | |||
55 | class CategoryList : public QList<Category> | ||
56 | { | ||
57 | public: | ||
58 | // --- Constructor | ||
59 | CategoryList(); | ||
60 | }; | ||
61 | |||
62 | |||
63 | // --- Cfg -------------------------------------------------------------------- | ||
64 | class Cfg | ||
65 | { | ||
66 | public: | ||
67 | // --- Constructor | ||
68 | Cfg(); | ||
69 | |||
70 | // --- members | ||
71 | bool getShowLocks() { return(_showLocks); } | ||
72 | void setShowLocks(bool n) { _showLocks=n; } | ||
73 | bool getShowBalances() { return(_showBalances); } | ||
74 | void setShowBalances(bool n) { _showBalances=n; } | ||
75 | QString &getCurrencySymbol() { return(_currencySymbol); } | ||
76 | void setCurrencySymbol(QString n) {_currencySymbol= n; } | ||
77 | void setCurrencySymbol(const char *n) { _currencySymbol=n; } | ||
78 | QStringList &getAccountTypes() { return(_AccountTypes); } | ||
79 | |||
80 | // --- Categories | ||
81 | QStringList getCategories(); | ||
82 | void setCategories(QStringList &lst); | ||
83 | CategoryList *getCategoryList() { return(_pCategories); } | ||
84 | |||
85 | // --- last book | ||
86 | void setOpenLastBook(bool openLastBook) { _openLastBook=openLastBook; } | ||
87 | bool isOpenLastBook() { return(_openLastBook); } | ||
88 | void setLastBook(const QString &lastBook) { _sLastBook=lastBook; } | ||
89 | QString &getLastBook() { return(_sLastBook); } | ||
90 | |||
91 | // --- last tab | ||
92 | void setShowLastTab(bool showLastTab) { _showLastTab=showLastTab; } | ||
93 | bool isShowLastTab() { return(_showLastTab); } | ||
94 | |||
95 | // --- reads data from config file | ||
96 | void readConfig(Config &cfg); | ||
97 | |||
98 | // --- writes data to config file | ||
99 | void writeConfig(Config &cfg); | ||
100 | |||
101 | // --- reads list from config file | ||
102 | static void readStringList(Config &cfg, const char *sKey, QStringList &lst); | ||
103 | |||
104 | // --- writes list in configuration file | ||
105 | static void writeStringList(Config &cfg, const char *sKey, QStringList &lst); | ||
106 | |||
107 | |||
108 | |||
109 | private: | ||
110 | QString _currencySymbol; | ||
111 | bool _showLocks; | ||
112 | bool _showBalances; | ||
113 | bool _openLastBook; | ||
114 | bool _showLastTab; | ||
115 | QString _sLastBook; | ||
116 | QStringList _AccountTypes; | ||
117 | CategoryList *_pCategories; | ||
118 | }; | ||
119 | |||
120 | #endif | ||
diff --git a/noncore/apps/checkbook/checkbook.cpp b/noncore/apps/checkbook/checkbook.cpp index 653ee4a..c53e889 100644 --- a/noncore/apps/checkbook/checkbook.cpp +++ b/noncore/apps/checkbook/checkbook.cpp | |||
@@ -1,654 +1,730 @@ | |||
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 "checkbook.h" | 29 | #include "checkbook.h" |
30 | #include "cbinfo.h" | 30 | #include "cbinfo.h" |
31 | #include "transaction.h" | 31 | #include "transaction.h" |
32 | #include "traninfo.h" | 32 | #include "traninfo.h" |
33 | #include "graph.h" | 33 | #include "graph.h" |
34 | #include "graphinfo.h" | 34 | #include "graphinfo.h" |
35 | #include "password.h" | 35 | #include "password.h" |
36 | #include "mainwindow.h" | ||
37 | #include "cfg.h" | ||
36 | 38 | ||
37 | #include <opie/otabwidget.h> | 39 | #include <opie/otabwidget.h> |
38 | #include <qpe/qpeapplication.h> | 40 | #include <qpe/qpeapplication.h> |
39 | #include <qpe/qpemessagebox.h> | 41 | #include <qpe/qpemessagebox.h> |
40 | #include <qpe/resource.h> | 42 | #include <qpe/resource.h> |
41 | 43 | ||
42 | #include <qcheckbox.h> | 44 | #include <qcheckbox.h> |
43 | #include <qcombobox.h> | 45 | #include <qcombobox.h> |
44 | #include <qlabel.h> | 46 | #include <qlabel.h> |
45 | #include <qlayout.h> | 47 | #include <qlayout.h> |
46 | #include <qlineedit.h> | 48 | #include <qlineedit.h> |
47 | #include <qmultilineedit.h> | 49 | #include <qmultilineedit.h> |
48 | #include <qpushbutton.h> | 50 | #include <qpushbutton.h> |
49 | #include <qwhatsthis.h> | 51 | #include <qwhatsthis.h> |
50 | 52 | ||
51 | Checkbook::Checkbook( QWidget *parent, CBInfo *i, const QString &symbol ) | 53 | #define COL_ID 0 |
54 | #define COL_NUM 1 | ||
55 | #define COL_DATE 2 | ||
56 | #define COL_DESC 3 | ||
57 | #define COL_AMOUNT 4 | ||
58 | #define COL_BAL 5 | ||
59 | |||
60 | // --- Checkbook -------------------------------------------------------------- | ||
61 | Checkbook::Checkbook( QWidget *parent, CBInfo *i, Cfg *cfg ) | ||
52 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) | 62 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) |
53 | { | 63 | { |
54 | info = i; | 64 | info = i; |
55 | currencySymbol = symbol; | 65 | _pCfg=cfg; |
56 | 66 | ||
67 | // Title bar | ||
57 | if ( info->name() != "" ) | 68 | if ( info->name() != "" ) |
58 | { | 69 | { |
59 | QString tempstr = info->name(); | 70 | QString tempstr = info->name(); |
60 | tempstr.append( " - " ); | 71 | tempstr.append( " - " ); |
61 | tempstr.append( tr( "Checkbook" ) ); | 72 | tempstr.append( tr( "Checkbook" ) ); |
62 | setCaption( tempstr ); | 73 | setCaption( tempstr ); |
63 | } | 74 | } |
64 | else | 75 | else |
65 | { | 76 | { |
66 | setCaption( tr( "New checkbook" ) ); | 77 | setCaption( tr( "New checkbook" ) ); |
67 | } | 78 | } |
68 | 79 | ||
80 | |||
69 | // Setup layout to make everything pretty | 81 | // Setup layout to make everything pretty |
70 | QVBoxLayout *layout = new QVBoxLayout( this ); | 82 | QVBoxLayout *layout = new QVBoxLayout( this ); |
71 | layout->setMargin( 2 ); | 83 | layout->setMargin( 2 ); |
72 | layout->setSpacing( 4 ); | 84 | layout->setSpacing( 4 ); |
73 | 85 | ||
74 | // Setup tabs for all info | 86 | // Setup tabs for all info |
75 | mainWidget = new OTabWidget( this ); | 87 | mainWidget = new OTabWidget( this ); |
76 | layout->addWidget( mainWidget ); | 88 | layout->addWidget( mainWidget ); |
77 | |||
78 | mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) ); | 89 | mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) ); |
79 | mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) ); | 90 | mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) ); |
80 | mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) ); | 91 | mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) ); |
81 | mainWidget->setCurrentTab( tr( "Info" ) ); | 92 | if( _pCfg->isShowLastTab() ) |
93 | mainWidget->setCurrentTab( info->getLastTab() ); | ||
94 | else | ||
95 | mainWidget->setCurrentTab( tr( "Info" ) ); | ||
96 | connect( mainWidget, SIGNAL( currentChanged(QWidget *) ), this, SLOT( slotTab(QWidget *) ) ); | ||
82 | 97 | ||
83 | // Load checkbook information | 98 | // Load checkbook information |
84 | loadCheckbook(); | 99 | loadCheckbook(); |
85 | } | 100 | } |
86 | 101 | ||
87 | Checkbook::~Checkbook() | 102 | Checkbook::~Checkbook() |
88 | { | 103 | { |
89 | } | 104 | } |
90 | 105 | ||
106 | // --- initInfo --------------------------------------------------------------- | ||
91 | QWidget *Checkbook::initInfo() | 107 | QWidget *Checkbook::initInfo() |
92 | { | 108 | { |
93 | QWidget *control = new QWidget( mainWidget ); | 109 | QWidget *control = new QWidget( mainWidget, tr("Info") ); |
94 | 110 | ||
95 | QVBoxLayout *vb = new QVBoxLayout( control ); | 111 | QVBoxLayout *vb = new QVBoxLayout( control ); |
96 | 112 | ||
97 | QScrollView *sv = new QScrollView( control ); | 113 | QScrollView *sv = new QScrollView( control ); |
98 | vb->addWidget( sv, 0, 0 ); | 114 | vb->addWidget( sv, 0, 0 ); |
99 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 115 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
100 | sv->setFrameStyle( QFrame::NoFrame ); | 116 | sv->setFrameStyle( QFrame::NoFrame ); |
101 | 117 | ||
102 | QWidget *container = new QWidget( sv->viewport() ); | 118 | QWidget *container = new QWidget( sv->viewport() ); |
103 | sv->addChild( container ); | 119 | sv->addChild( container ); |
104 | 120 | ||
105 | QGridLayout *layout = new QGridLayout( container ); | 121 | QGridLayout *layout = new QGridLayout( container ); |
106 | layout->setSpacing( 2 ); | 122 | layout->setSpacing( 2 ); |
107 | layout->setMargin( 4 ); | 123 | layout->setMargin( 4 ); |
108 | 124 | ||
109 | // Password protection | 125 | // Password protection |
110 | passwordCB = new QCheckBox( tr( "Password protect" ), container ); | 126 | passwordCB = new QCheckBox( tr( "Password protect" ), container ); |
111 | QWhatsThis::add( passwordCB, tr( "Click here to enable/disable password protection of this checkbook." ) ); | 127 | QWhatsThis::add( passwordCB, tr( "Click here to enable/disable password protection of this checkbook." ) ); |
112 | connect( passwordCB, SIGNAL( clicked() ), this, SLOT( slotPasswordClicked() ) ); | 128 | connect( passwordCB, SIGNAL( clicked() ), this, SLOT( slotPasswordClicked() ) ); |
113 | layout->addMultiCellWidget( passwordCB, 0, 0, 0, 1 ); | 129 | layout->addMultiCellWidget( passwordCB, 0, 0, 0, 1 ); |
114 | 130 | ||
115 | // Account name | 131 | // Account name |
116 | QLabel *label = new QLabel( tr( "Name:" ), container ); | 132 | QLabel *label = new QLabel( tr( "Name:" ), container ); |
117 | QWhatsThis::add( label, tr( "Enter name of checkbook here." ) ); | 133 | QWhatsThis::add( label, tr( "Enter name of checkbook here." ) ); |
118 | layout->addWidget( label, 1, 0 ); | 134 | layout->addWidget( label, 1, 0 ); |
119 | nameEdit = new QLineEdit( container ); | 135 | nameEdit = new QLineEdit( container ); |
120 | QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) ); | 136 | QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) ); |
121 | connect( nameEdit, SIGNAL( textChanged( const QString & ) ), | 137 | connect( nameEdit, SIGNAL( textChanged( const QString & ) ), |
122 | this, SLOT( slotNameChanged( const QString & ) ) ); | 138 | this, SLOT( slotNameChanged( const QString & ) ) ); |
123 | layout->addWidget( nameEdit, 1, 1 ); | 139 | layout->addWidget( nameEdit, 1, 1 ); |
124 | 140 | ||
125 | // Type of account | 141 | // Type of account |
126 | label = new QLabel( tr( "Type:" ), container ); | 142 | label = new QLabel( tr( "Type:" ), container ); |
127 | QWhatsThis::add( label, tr( "Select type of checkbook here." ) ); | 143 | QWhatsThis::add( label, tr( "Select type of checkbook here." ) ); |
128 | layout->addWidget( label, 2, 0 ); | 144 | layout->addWidget( label, 2, 0 ); |
129 | typeList = new QComboBox( container ); | 145 | typeList = new QComboBox( container ); |
130 | QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) ); | 146 | QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) ); |
131 | typeList->insertItem( tr( "Savings" ) ); // 0 | 147 | typeList->insertStringList( _pCfg->getAccountTypes() ); |
132 | typeList->insertItem( tr( "Checking" ) ); // 1 | 148 | layout->addWidget( typeList, 2, 1 ); |
133 | typeList->insertItem( tr( "CD" ) ); // 2 | ||
134 | typeList->insertItem( tr( "Money market" ) );// 3 | ||
135 | typeList->insertItem( tr( "Mutual fund" ) );// 4 | ||
136 | typeList->insertItem( tr( "Other" ) ); // 5 | ||
137 | layout->addWidget( typeList, 2, 1 ); | ||
138 | 149 | ||
139 | // Bank/institution name | 150 | // Bank/institution name |
140 | label = new QLabel( tr( "Bank:" ), container ); | 151 | label = new QLabel( tr( "Bank:" ), container ); |
141 | QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) ); | 152 | QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) ); |
142 | layout->addWidget( label, 3, 0 ); | 153 | layout->addWidget( label, 3, 0 ); |
143 | bankEdit = new QLineEdit( container ); | 154 | bankEdit = new QLineEdit( container ); |
144 | QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) ); | 155 | QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) ); |
145 | layout->addWidget( bankEdit, 3, 1 ); | 156 | layout->addWidget( bankEdit, 3, 1 ); |
146 | 157 | ||
147 | // Account number | 158 | // Account number |
148 | label = new QLabel( tr( "Account number:" ), container ); | 159 | label = new QLabel( tr( "Account number:" ), container ); |
149 | QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) ); | 160 | QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) ); |
150 | layout->addWidget( label, 4, 0 ); | 161 | layout->addWidget( label, 4, 0 ); |
151 | acctNumEdit = new QLineEdit( container ); | 162 | acctNumEdit = new QLineEdit( container ); |
152 | QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) ); | 163 | QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) ); |
153 | layout->addWidget( acctNumEdit, 4, 1 ); | 164 | layout->addWidget( acctNumEdit, 4, 1 ); |
154 | 165 | ||
155 | // PIN number | 166 | // PIN number |
156 | label = new QLabel( tr( "PIN number:" ), container ); | 167 | label = new QLabel( tr( "PIN number:" ), container ); |
157 | QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) ); | 168 | QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) ); |
158 | layout->addWidget( label, 5, 0 ); | 169 | layout->addWidget( label, 5, 0 ); |
159 | pinNumEdit = new QLineEdit( container ); | 170 | pinNumEdit = new QLineEdit( container ); |
160 | QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) ); | 171 | QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) ); |
161 | layout->addWidget( pinNumEdit, 5, 1 ); | 172 | layout->addWidget( pinNumEdit, 5, 1 ); |
162 | 173 | ||
163 | // Starting balance | 174 | // Starting balance |
164 | label = new QLabel( tr( "Starting balance:" ), container ); | 175 | label = new QLabel( tr( "Starting balance:" ), container ); |
165 | QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) ); | 176 | QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) ); |
166 | layout->addWidget( label, 6, 0 ); | 177 | layout->addWidget( label, 6, 0 ); |
167 | balanceEdit = new QLineEdit( container ); | 178 | balanceEdit = new QLineEdit( container ); |
168 | QWhatsThis::add( balanceEdit, tr( "Enter the initial balance for this checkbook here." ) ); | 179 | QWhatsThis::add( balanceEdit, tr( "Enter the initial balance for this checkbook here." ) ); |
169 | connect( balanceEdit, SIGNAL( textChanged( const QString & ) ), | 180 | connect( balanceEdit, SIGNAL( textChanged( const QString & ) ), |
170 | this, SLOT( slotStartingBalanceChanged( const QString & ) ) ); | 181 | this, SLOT( slotStartingBalanceChanged( const QString & ) ) ); |
171 | layout->addWidget( balanceEdit, 6, 1 ); | 182 | layout->addWidget( balanceEdit, 6, 1 ); |
172 | 183 | ||
173 | // Notes | 184 | // Notes |
174 | label = new QLabel( tr( "Notes:" ), container ); | 185 | label = new QLabel( tr( "Notes:" ), container ); |
175 | QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) ); | 186 | QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) ); |
176 | layout->addWidget( label, 7, 0 ); | 187 | layout->addWidget( label, 7, 0 ); |
177 | notesEdit = new QMultiLineEdit( container ); | 188 | notesEdit = new QMultiLineEdit( container ); |
178 | QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) ); | 189 | QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) ); |
179 | notesEdit->setMinimumHeight( 25 ); | 190 | notesEdit->setMinimumHeight( 25 ); |
180 | notesEdit->setMaximumHeight( 65 ); | 191 | notesEdit->setMaximumHeight( 65 ); |
181 | layout->addMultiCellWidget( notesEdit, 8, 8, 0, 1 ); | 192 | layout->addMultiCellWidget( notesEdit, 8, 8, 0, 1 ); |
182 | 193 | ||
183 | return control; | 194 | return control; |
184 | } | 195 | } |
185 | 196 | ||
197 | |||
198 | // --- initTransactions ------------------------------------------------------- | ||
186 | QWidget *Checkbook::initTransactions() | 199 | QWidget *Checkbook::initTransactions() |
187 | { | 200 | { |
188 | QWidget *control = new QWidget( mainWidget ); | 201 | QWidget *control = new QWidget( mainWidget, tr("Transactions") ); |
189 | 202 | ||
190 | QGridLayout *layout = new QGridLayout( control ); | 203 | QGridLayout *layout = new QGridLayout( control ); |
191 | layout->setSpacing( 2 ); | 204 | layout->setSpacing( 2 ); |
192 | layout->setMargin( 4 ); | 205 | layout->setMargin( 4 ); |
193 | 206 | ||
194 | balanceLabel = new QLabel( tr( "Current balance: %10.00" ).arg( currencySymbol ), | 207 | // Sort selector |
195 | control ); | 208 | QLabel *label = new QLabel( tr( "Sort by:" ), control ); |
196 | QWhatsThis::add( balanceLabel, tr( "This area shows the current balance in this checkbook." ) ); | 209 | QWhatsThis::add( label, tr( "Select checkbook sorting here." ) ); |
197 | layout->addMultiCellWidget( balanceLabel, 0, 0, 0, 2 ); | 210 | layout->addMultiCellWidget( label, 0, 0, 0, 1 ); |
198 | 211 | _cbSortType=new QComboBox( control ); | |
199 | tranTable = new QListView( control ); | 212 | _cbSortType->insertItem( tr("Entry Order") ); |
213 | _cbSortType->insertItem( tr("Date") ); | ||
214 | _cbSortType->insertItem( tr("Number") ); | ||
215 | layout->addMultiCellWidget( _cbSortType, 0, 0, 1, 2 ); | ||
216 | connect( _cbSortType, SIGNAL( activated(const QString &) ), this, SLOT( slotSortChanged( const QString & ) ) ); | ||
217 | |||
218 | // Table | ||
219 | tranTable = new QListView( control ); | ||
220 | QFont fnt(QPEApplication::font()); | ||
221 | fnt.setPointSize( fnt.pointSize()-1 ); | ||
222 | tranTable->setFont( fnt ); | ||
200 | QWhatsThis::add( tranTable, tr( "This is a listing of all transactions entered for this checkbook.\n\nTo sort entries by a specific field, click on the column name." ) ); | 223 | QWhatsThis::add( tranTable, tr( "This is a listing of all transactions entered for this checkbook.\n\nTo sort entries by a specific field, click on the column name." ) ); |
201 | tranTable->addColumn( tr( "Num" ) ); | 224 | tranTable->addColumn( tr( "Id" ) ); |
225 | tranTable->setColumnWidthMode( COL_ID, QListView::Manual ); | ||
226 | tranTable->setColumnWidth( COL_ID, 0); | ||
227 | tranTable->addColumn( tr( "Num" ) ); | ||
202 | tranTable->addColumn( tr( "Date" ) ); | 228 | tranTable->addColumn( tr( "Date" ) ); |
203 | //tranTable->addColumn( tr( "Cleared" ) ); | 229 | //tranTable->addColumn( tr( "Cleared" ) ); |
204 | tranTable->addColumn( tr( "Description" ) ); | 230 | tranTable->addColumn( tr( "Description" ) ); |
205 | int colnum = tranTable->addColumn( tr( "Amount" ) ); | 231 | int column = tranTable->addColumn( tr( "Amount" ) ); |
206 | tranTable->setColumnAlignment( colnum, Qt::AlignRight ); | 232 | tranTable->setColumnAlignment( column, Qt::AlignRight ); |
233 | column=tranTable->addColumn( tr("Balance") ); | ||
234 | tranTable->setColumnAlignment( column, Qt::AlignRight ); | ||
207 | tranTable->setAllColumnsShowFocus( TRUE ); | 235 | tranTable->setAllColumnsShowFocus( TRUE ); |
208 | tranTable->setSorting( 1 ); | 236 | tranTable->setSorting( -1 ); |
209 | layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); | 237 | layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); |
210 | QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); | 238 | QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); |
211 | connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 239 | connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), |
212 | this, SLOT( slotEditTran() ) ); | 240 | this, SLOT( slotEditTran() ) ); |
241 | _sortCol=COL_ID; | ||
213 | 242 | ||
243 | // Buttons | ||
214 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); | 244 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); |
215 | QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); | 245 | QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); |
216 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); | 246 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); |
217 | layout->addWidget( btn, 2, 0 ); | 247 | layout->addWidget( btn, 2, 0 ); |
218 | 248 | ||
219 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control ); | 249 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control ); |
220 | QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); | 250 | QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); |
221 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) ); | 251 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) ); |
222 | layout->addWidget( btn, 2, 1 ); | 252 | layout->addWidget( btn, 2, 1 ); |
223 | 253 | ||
224 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control ); | 254 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control ); |
225 | QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); | 255 | QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); |
226 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) ); | 256 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) ); |
227 | layout->addWidget( btn, 2, 2 ); | 257 | layout->addWidget( btn, 2, 2 ); |
228 | 258 | ||
229 | return( control ); | 259 | return( control ); |
230 | } | 260 | } |
231 | 261 | ||
262 | |||
263 | // --- initCharts ------------------------------------------------------------- | ||
232 | QWidget *Checkbook::initCharts() | 264 | QWidget *Checkbook::initCharts() |
233 | { | 265 | { |
234 | graphInfo = 0x0; | 266 | graphInfo = 0x0; |
235 | 267 | ||
236 | QWidget *control = new QWidget( mainWidget ); | 268 | QWidget *control = new QWidget( mainWidget, tr("Charts") ); |
237 | 269 | ||
238 | QGridLayout *layout = new QGridLayout( control ); | 270 | QGridLayout *layout = new QGridLayout( control ); |
239 | layout->setSpacing( 2 ); | 271 | layout->setSpacing( 2 ); |
240 | layout->setMargin( 4 ); | 272 | layout->setMargin( 4 ); |
241 | 273 | ||
242 | graphWidget = new Graph( control ); | 274 | graphWidget = new Graph( control ); |
243 | QWhatsThis::add( graphWidget, tr( "Select the desired chart below and then click on the Draw button." ) ); | 275 | QWhatsThis::add( graphWidget, tr( "Select the desired chart below and then click on the Draw button." ) ); |
244 | layout->addMultiCellWidget( graphWidget, 0, 0, 0, 2 ); | 276 | layout->addMultiCellWidget( graphWidget, 0, 0, 0, 2 ); |
245 | 277 | ||
246 | graphList = new QComboBox( control ); | 278 | graphList = new QComboBox( control ); |
247 | QWhatsThis::add( graphList, tr( "Click here to select the desired chart type." ) ); | 279 | QWhatsThis::add( graphList, tr( "Click here to select the desired chart type." ) ); |
248 | graphList->insertItem( tr( "Account balance" ) ); | 280 | graphList->insertItem( tr( "Account balance" ) ); |
249 | graphList->insertItem( tr( "Withdrawals by category" ) ); | 281 | graphList->insertItem( tr( "Withdrawals by category" ) ); |
250 | graphList->insertItem( tr( "Deposits by category" ) ); | 282 | graphList->insertItem( tr( "Deposits by category" ) ); |
251 | 283 | ||
252 | layout->addMultiCellWidget( graphList, 1, 1, 0, 1 ); | 284 | layout->addMultiCellWidget( graphList, 1, 1, 0, 1 ); |
253 | 285 | ||
254 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control ); | 286 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control ); |
255 | QWhatsThis::add( btn, tr( "Click here to draw the selected chart." ) ); | 287 | QWhatsThis::add( btn, tr( "Click here to draw the selected chart." ) ); |
256 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) ); | 288 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) ); |
257 | layout->addWidget( btn, 1, 2 ); | 289 | layout->addWidget( btn, 1, 2 ); |
258 | 290 | ||
259 | return control; | 291 | return control; |
260 | } | 292 | } |
261 | 293 | ||
294 | // --- loadCheckbook ---------------------------------------------------------- | ||
262 | void Checkbook::loadCheckbook() | 295 | void Checkbook::loadCheckbook() |
263 | { | 296 | { |
264 | if ( !info ) | 297 | if ( !info ) |
265 | { | 298 | { |
266 | return; | 299 | return; |
267 | } | 300 | } |
268 | 301 | ||
269 | tranList = info->transactions(); | 302 | tranList = info->transactions(); |
270 | 303 | ||
271 | passwordCB->setChecked( !info->password().isNull() ); | 304 | passwordCB->setChecked( !info->password().isNull() ); |
272 | nameEdit->setText( info->name() ); | 305 | nameEdit->setText( info->name() ); |
273 | QString temptext = info->type(); | 306 | QString temptext = info->type(); |
274 | int i = typeList->count(); | 307 | int i = typeList->count(); |
275 | while ( i > 0 ) | 308 | while ( i > 0 ) |
276 | { | 309 | { |
277 | i--; | 310 | i--; |
278 | typeList->setCurrentItem( i ); | 311 | typeList->setCurrentItem( i ); |
279 | if ( typeList->currentText() == temptext ) | 312 | if ( typeList->currentText() == temptext ) |
280 | { | 313 | { |
281 | break; | 314 | break; |
282 | } | 315 | } |
283 | } | 316 | } |
317 | if( i<=0 ) { | ||
318 | typeList->insertItem( temptext, 0 ); | ||
319 | typeList->setCurrentItem(0); | ||
320 | } | ||
284 | bankEdit->setText( info->bank() ); | 321 | bankEdit->setText( info->bank() ); |
285 | acctNumEdit->setText( info->account() ); | 322 | acctNumEdit->setText( info->account() ); |
286 | pinNumEdit->setText( info->pin() ); | 323 | pinNumEdit->setText( info->pin() ); |
287 | temptext.setNum( info->startingBalance(), 'f', 2 ); | 324 | temptext.setNum( info->startingBalance(), 'f', 2 ); |
288 | balanceEdit->setText( temptext ); | 325 | balanceEdit->setText( temptext ); |
289 | notesEdit->setText( info->notes() ); | 326 | notesEdit->setText( info->notes() ); |
290 | 327 | ||
291 | // Load transactions | 328 | // Load transactions |
292 | float amount; | 329 | float amount; |
293 | QString stramount; | 330 | QString stramount; |
294 | 331 | for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) | |
295 | for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) | ||
296 | { | 332 | { |
297 | amount = tran->amount(); | 333 | amount = tran->amount(); |
298 | if ( tran->withdrawal() ) | 334 | if ( tran->withdrawal() ) |
299 | { | 335 | { |
300 | amount *= -1; | 336 | amount *= -1; |
301 | } | 337 | } |
302 | stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount ); | 338 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); |
303 | ( void ) new CBListItem( tranTable, tran->number(), tran->datestr(), tran->desc(), stramount ); | 339 | ( void ) new CBListItem( tran, tranTable, tran->getIdStr(), tran->number(), tran->datestr(), tran->desc(), stramount ); |
304 | } | 340 | } |
305 | 341 | ||
306 | balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( info->balance(), 0, 'f', 2 ) ); | 342 | // set sort order |
307 | 343 | bool bOk=false; | |
308 | highTranNum = tranList->count(); | 344 | for(int i=0; i<_cbSortType->count(); i++) { |
345 | if( _cbSortType->text(i)==info->getSortOrder() ) { | ||
346 | _cbSortType->setCurrentItem(i); | ||
347 | slotSortChanged( info->getSortOrder() ); | ||
348 | bOk=true; | ||
349 | break; | ||
350 | } | ||
351 | } | ||
352 | if( !bOk ) { | ||
353 | _cbSortType->setCurrentItem(0); | ||
354 | slotSortChanged( _cbSortType->currentText() ); | ||
355 | } | ||
356 | |||
357 | // calc running balance | ||
358 | adjustBalance(); | ||
309 | } | 359 | } |
310 | 360 | ||
361 | // --- adjustBalance ---------------------------------------------------------- | ||
311 | void Checkbook::adjustBalance() | 362 | void Checkbook::adjustBalance() |
312 | { | 363 | { |
313 | balanceLabel->setText( tr( "Current balance: %1%2" ).arg( currencySymbol ).arg( info->balance(), 0, 'f', 2 ) ); | 364 | // update running balance in register |
365 | QString sRunning; | ||
366 | float bal=info->startingBalance(); | ||
367 | for(CBListItem *item=(CBListItem *)tranTable->firstChild(); item; item=(CBListItem *)item->nextSibling() ) { | ||
368 | TranInfo *tran=item->getTranInfo(); | ||
369 | bal=bal + (tran->withdrawal() ? -1 : 1)*tran->amount() - tran->fee(); | ||
370 | sRunning.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), bal ); | ||
371 | item->setText( COL_BAL, sRunning); | ||
372 | } | ||
314 | } | 373 | } |
315 | 374 | ||
316 | TranInfo *Checkbook::findTran( const QString &checknum, const QString &date, const QString &desc ) | 375 | // --- resort ----------------------------------------------------------------- |
376 | void Checkbook::resort() | ||
317 | { | 377 | { |
318 | TranInfo *traninfo = tranList->first(); | 378 | tranTable->setSorting(_sortCol); |
319 | while ( traninfo ) | 379 | tranTable->sort(); |
320 | { | 380 | tranTable->setSorting(-1); |
321 | if ( traninfo->number() == checknum && traninfo->datestr() == date && | ||
322 | traninfo->desc() == desc ) | ||
323 | break; | ||
324 | traninfo = tranList->next(); | ||
325 | } | ||
326 | return( traninfo ); | ||
327 | } | 381 | } |
328 | 382 | ||
383 | |||
384 | // --- accept ----------------------------------------------------------------- | ||
329 | void Checkbook::accept() | 385 | void Checkbook::accept() |
330 | { | 386 | { |
331 | info->setName( nameEdit->text() ); | 387 | info->setName( nameEdit->text() ); |
332 | info->setType( typeList->currentText() ); | 388 | info->setType( typeList->currentText() ); |
333 | info->setBank( bankEdit->text() ); | 389 | info->setBank( bankEdit->text() ); |
334 | info->setAccount( acctNumEdit->text() ); | 390 | info->setAccount( acctNumEdit->text() ); |
335 | info->setPin( pinNumEdit->text() ); | 391 | info->setPin( pinNumEdit->text() ); |
336 | bool ok; | 392 | bool ok; |
337 | info->setStartingBalance( balanceEdit->text().toFloat( &ok ) ); | 393 | info->setStartingBalance( balanceEdit->text().toFloat( &ok ) ); |
338 | info->setNotes( notesEdit->text() ); | 394 | info->setNotes( notesEdit->text() ); |
339 | 395 | ||
340 | QDialog::accept(); | 396 | QDialog::accept(); |
341 | } | 397 | } |
342 | 398 | ||
343 | void Checkbook::slotPasswordClicked() | 399 | void Checkbook::slotPasswordClicked() |
344 | { | 400 | { |
345 | if ( info->password().isNull() && passwordCB->isChecked() ) | 401 | if ( info->password().isNull() && passwordCB->isChecked() ) |
346 | { | 402 | { |
347 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); | 403 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); |
348 | if ( pw->exec() != QDialog::Accepted ) | 404 | if ( pw->exec() != QDialog::Accepted ) |
349 | { | 405 | { |
350 | passwordCB->setChecked( FALSE ); | 406 | passwordCB->setChecked( FALSE ); |
351 | delete pw; | 407 | delete pw; |
352 | return; | 408 | return; |
353 | } | 409 | } |
354 | info->setPassword( pw->password ); | 410 | info->setPassword( pw->password ); |
355 | delete pw; | 411 | delete pw; |
356 | 412 | ||
357 | pw = new Password( this, tr( "Confirm password" ), tr( "Please confirm your password:" ) ); | 413 | pw = new Password( this, tr( "Confirm password" ), tr( "Please confirm your password:" ) ); |
358 | if ( pw->exec() != QDialog::Accepted || pw->password != info->password() ) | 414 | if ( pw->exec() != QDialog::Accepted || pw->password != info->password() ) |
359 | { | 415 | { |
360 | passwordCB->setChecked( FALSE ); | 416 | passwordCB->setChecked( FALSE ); |
361 | info->setPassword( QString::null ); | 417 | info->setPassword( QString::null ); |
362 | } | 418 | } |
363 | 419 | ||
364 | delete pw; | 420 | delete pw; |
365 | } | 421 | } |
366 | else if ( !info->password().isNull() && !passwordCB->isChecked() ) | 422 | else if ( !info->password().isNull() && !passwordCB->isChecked() ) |
367 | { | 423 | { |
368 | Password *pw = new Password( this, tr( "Enter password" ), | 424 | Password *pw = new Password( this, tr( "Enter password" ), |
369 | tr( "Please enter your password to confirm removal of password protection:" ) ); | 425 | tr( "Please enter your password to confirm removal of password protection:" ) ); |
370 | if ( pw->exec() == QDialog::Accepted && pw->password == info->password() ) | 426 | if ( pw->exec() == QDialog::Accepted && pw->password == info->password() ) |
371 | { | 427 | { |
372 | info->setPassword( QString::null ); | 428 | info->setPassword( QString::null ); |
373 | delete pw; | 429 | delete pw; |
374 | return; | 430 | return; |
375 | } | 431 | } |
376 | else | 432 | else |
377 | { | 433 | { |
378 | passwordCB->setChecked( TRUE ); | 434 | passwordCB->setChecked( TRUE ); |
379 | } | 435 | } |
380 | 436 | ||
381 | delete pw; | 437 | delete pw; |
382 | } | 438 | } |
383 | } | 439 | } |
384 | 440 | ||
385 | void Checkbook::slotNameChanged( const QString &newname ) | 441 | void Checkbook::slotNameChanged( const QString &newname ) |
386 | { | 442 | { |
387 | info->setName( newname ); | 443 | info->setName( newname ); |
388 | 444 | ||
389 | // TODO - need filedir | 445 | // TODO - need filedir |
390 | //QString namestr = filedir; | 446 | //QString namestr = filedir; |
391 | //namestr.append( newname ); | 447 | //namestr.append( newname ); |
392 | //namestr.append( ".qcb" ); | 448 | //namestr.append( ".qcb" ); |
393 | //info->setFilename( namestr ); | 449 | //info->setFilename( namestr ); |
394 | 450 | ||
395 | QString namestr = newname; | 451 | QString namestr = newname; |
396 | namestr.append( " - " ); | 452 | namestr.append( " - " ); |
397 | namestr.append( tr( "Checkbook" ) ); | 453 | namestr.append( tr( "Checkbook" ) ); |
398 | setCaption( namestr ); | 454 | setCaption( namestr ); |
399 | } | 455 | } |
400 | 456 | ||
457 | |||
458 | // ---slotStartingBalanceChanged ---------------------------------------------- | ||
401 | void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) | 459 | void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) |
402 | { | 460 | { |
403 | bool ok; | 461 | bool ok; |
404 | info->setStartingBalance( newbalance.toFloat( &ok ) ); | 462 | info->setStartingBalance( newbalance.toFloat( &ok ) ); |
405 | adjustBalance(); | 463 | adjustBalance(); |
406 | } | 464 | } |
407 | 465 | ||
466 | |||
408 | void Checkbook::slotNewTran() | 467 | void Checkbook::slotNewTran() |
409 | { | 468 | { |
410 | highTranNum++; | 469 | TranInfo *traninfo = new TranInfo( info->getNextNumber() ); |
411 | TranInfo *traninfo = new TranInfo( highTranNum ); | 470 | if( !_dLastNew.isNull() ) |
471 | traninfo->setDate(_dLastNew); | ||
412 | 472 | ||
413 | Transaction *currtran = new Transaction( this, info->name(), | 473 | Transaction *currtran = new Transaction( this, info->name(), |
414 | traninfo, | 474 | traninfo, |
415 | currencySymbol ); | 475 | _pCfg ); |
416 | currtran->showMaximized(); | 476 | currtran->showMaximized(); |
417 | if ( currtran->exec() == QDialog::Accepted ) | 477 | if ( currtran->exec() == QDialog::Accepted ) |
418 | { | 478 | { |
419 | // Add to transaction list | 479 | // Add to transaction list |
420 | info->addTransaction( traninfo ); | 480 | info->addTransaction( traninfo ); |
421 | 481 | ||
422 | // Add to transaction table | 482 | // Add to transaction table |
423 | float amount; | 483 | float amount; |
424 | QString stramount; | 484 | QString stramount; |
425 | 485 | amount = (traninfo->withdrawal() ? -1 : 1)*traninfo->amount(); | |
426 | amount = traninfo->amount(); | 486 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); |
427 | if ( traninfo->withdrawal() ) | 487 | ( void ) new CBListItem( traninfo, tranTable, traninfo->getIdStr(), |
428 | { | 488 | traninfo->number(), traninfo->datestr(), traninfo->desc(), |
429 | amount *= -1; | 489 | stramount ); |
430 | } | 490 | resort(); |
431 | stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount ); | ||
432 | |||
433 | ( void ) new CBListItem( tranTable, traninfo->number(), traninfo->datestr(), traninfo->desc(), | ||
434 | stramount ); | ||
435 | |||
436 | adjustBalance(); | 491 | adjustBalance(); |
492 | |||
493 | // save last date | ||
494 | _dLastNew = traninfo->date(); | ||
437 | } | 495 | } |
438 | else | 496 | else |
439 | { | 497 | { |
440 | highTranNum--; | ||
441 | delete traninfo; | 498 | delete traninfo; |
442 | } | 499 | } |
443 | } | 500 | } |
444 | 501 | ||
445 | void Checkbook::slotEditTran() | 502 | void Checkbook::slotEditTran() |
446 | { | 503 | { |
447 | QListViewItem *curritem = tranTable->currentItem(); | 504 | QListViewItem *curritem = tranTable->currentItem(); |
448 | if ( !curritem ) | 505 | if ( !curritem ) |
449 | { | ||
450 | return; | 506 | return; |
451 | } | 507 | |
452 | 508 | TranInfo *traninfo=info->findTransaction( curritem->text(COL_ID) ); | |
453 | TranInfo *traninfo = info->findTransaction( curritem->text( 0 ), curritem->text( 1 ), | ||
454 | curritem->text( 2 ) ); | ||
455 | 509 | ||
456 | Transaction *currtran = new Transaction( this, info->name(), | 510 | Transaction *currtran = new Transaction( this, info->name(), |
457 | traninfo, | 511 | traninfo, |
458 | currencySymbol ); | 512 | _pCfg ); |
459 | currtran->showMaximized(); | 513 | currtran->showMaximized(); |
460 | if ( currtran->exec() == QDialog::Accepted ) | 514 | if ( currtran->exec() == QDialog::Accepted ) |
461 | { | 515 | { |
462 | curritem->setText( 0, traninfo->number() ); | 516 | curritem->setText( COL_NUM, traninfo->number() ); |
463 | curritem->setText( 1, traninfo->datestr() ); | 517 | curritem->setText( COL_DATE, traninfo->datestr() ); |
464 | curritem->setText( 2, traninfo->desc() ); | 518 | curritem->setText( COL_DESC, traninfo->desc() ); |
465 | 519 | ||
466 | float amount = traninfo->amount(); | 520 | float amount = traninfo->amount(); |
467 | if ( traninfo->withdrawal() ) | 521 | if ( traninfo->withdrawal() ) |
468 | { | 522 | { |
469 | amount *= -1; | 523 | amount *= -1; |
470 | } | 524 | } |
471 | QString stramount; | 525 | QString stramount; |
472 | stramount.sprintf( "%s%.2f", currencySymbol.latin1(), amount ); | 526 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); |
473 | curritem->setText( 3, stramount ); | 527 | curritem->setText( COL_AMOUNT, stramount ); |
474 | 528 | resort(); | |
475 | adjustBalance(); | 529 | adjustBalance(); |
476 | } | 530 | } |
477 | 531 | ||
478 | delete currtran; | 532 | delete currtran; |
479 | } | 533 | } |
480 | 534 | ||
481 | void Checkbook::slotDeleteTran() | 535 | void Checkbook::slotDeleteTran() |
482 | { | 536 | { |
483 | QListViewItem *curritem = tranTable->currentItem(); | 537 | QListViewItem *curritem = tranTable->currentItem(); |
484 | if ( !curritem ) | 538 | if ( !curritem ) |
485 | { | ||
486 | return; | 539 | return; |
487 | } | ||
488 | 540 | ||
489 | TranInfo *traninfo = findTran( curritem->text( 0 ), curritem->text( 1 ), curritem->text( 2 ) ); | 541 | TranInfo *traninfo = info->findTransaction( curritem->text(COL_ID) ); |
490 | 542 | ||
491 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) ) | 543 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) ) |
492 | { | 544 | { |
493 | info->removeTransaction( traninfo ); | 545 | info->removeTransaction( traninfo ); |
494 | delete curritem; | 546 | delete curritem; |
495 | adjustBalance(); | 547 | adjustBalance(); |
496 | } | 548 | } |
497 | } | 549 | } |
498 | 550 | ||
499 | void Checkbook::slotDrawGraph() | 551 | void Checkbook::slotDrawGraph() |
500 | { | 552 | { |
501 | if ( graphInfo ) | 553 | if ( graphInfo ) |
502 | { | 554 | { |
503 | delete graphInfo; | 555 | delete graphInfo; |
504 | } | 556 | } |
505 | 557 | ||
506 | switch ( graphList->currentItem() ) | 558 | switch ( graphList->currentItem() ) |
507 | { | 559 | { |
508 | case 0 : drawBalanceChart(); | 560 | case 0 : drawBalanceChart(); |
509 | break; | 561 | break; |
510 | case 1 : drawCategoryChart( TRUE ); | 562 | case 1 : drawCategoryChart( TRUE ); |
511 | break; | 563 | break; |
512 | case 2 : drawCategoryChart( FALSE ); | 564 | case 2 : drawCategoryChart( FALSE ); |
513 | break; | 565 | break; |
514 | }; | 566 | }; |
515 | 567 | ||
516 | graphWidget->setGraphInfo( graphInfo ); | 568 | graphWidget->setGraphInfo( graphInfo ); |
517 | graphWidget->drawGraph( TRUE ); | 569 | graphWidget->drawGraph( TRUE ); |
518 | } | 570 | } |
519 | 571 | ||
520 | void Checkbook::drawBalanceChart() | 572 | void Checkbook::drawBalanceChart() |
521 | { | 573 | { |
522 | DataPointList *list = new DataPointList(); | 574 | DataPointList *list = new DataPointList(); |
523 | 575 | ||
524 | float balance = info->startingBalance(); | 576 | float balance = info->startingBalance(); |
525 | float amount; | 577 | float amount; |
526 | QString label; | 578 | QString label; |
527 | int i = 0; | 579 | int i = 0; |
528 | int count = tranList->count(); | 580 | int count = tranList->count(); |
529 | 581 | ||
530 | for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) | 582 | for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) |
531 | { | 583 | { |
532 | i++; | 584 | i++; |
533 | balance -= tran->fee(); | 585 | balance -= tran->fee(); |
534 | amount = tran->amount(); | 586 | amount = tran->amount(); |
535 | if ( tran->withdrawal() ) | 587 | if ( tran->withdrawal() ) |
536 | { | 588 | { |
537 | amount *= -1; | 589 | amount *= -1; |
538 | } | 590 | } |
539 | balance += amount; | 591 | balance += amount; |
540 | if ( i == 1 || i == count / 2 || i == count ) | 592 | if ( i == 1 || i == count / 2 || i == count ) |
541 | { | 593 | { |
542 | label = tran->datestr(); | 594 | label = tran->datestr(); |
543 | } | 595 | } |
544 | else | 596 | else |
545 | { | 597 | { |
546 | label = ""; | 598 | label = ""; |
547 | } | 599 | } |
548 | list->append( new DataPointInfo( label, balance ) ); | 600 | list->append( new DataPointInfo( label, balance ) ); |
549 | } | 601 | } |
550 | 602 | ||
551 | graphInfo = new GraphInfo( GraphInfo::BarChart, list ); | 603 | graphInfo = new GraphInfo( GraphInfo::BarChart, list ); |
552 | } | 604 | } |
553 | 605 | ||
554 | void Checkbook::drawCategoryChart( bool withdrawals ) | 606 | void Checkbook::drawCategoryChart( bool withdrawals ) |
555 | { | 607 | { |
556 | DataPointList *list = new DataPointList(); | 608 | DataPointList *list = new DataPointList(); |
557 | 609 | ||
558 | TranInfo *tran = tranList->first(); | 610 | TranInfo *tran = tranList->first(); |
559 | if ( tran && tran->withdrawal() == withdrawals ) | 611 | if ( tran && tran->withdrawal() == withdrawals ) |
560 | { | 612 | { |
561 | list->append( new DataPointInfo( tran->category(), tran->amount() ) ); | 613 | list->append( new DataPointInfo( tran->category(), tran->amount() ) ); |
562 | } | 614 | } |
563 | tran = tranList->next(); | 615 | tran = tranList->next(); |
564 | 616 | ||
565 | DataPointInfo *cat; | 617 | DataPointInfo *cat; |
566 | for ( ; tran; tran = tranList->next() ) | 618 | for ( ; tran; tran = tranList->next() ) |
567 | { | 619 | { |
568 | if ( tran->withdrawal() == withdrawals ) | 620 | if ( tran->withdrawal() == withdrawals ) |
569 | { | 621 | { |
570 | // Find category in list | 622 | // Find category in list |
571 | for ( cat = list->first(); cat; cat = list->next() ) | 623 | for ( cat = list->first(); cat; cat = list->next() ) |
572 | { | 624 | { |
573 | if ( cat->label() == tran->category() ) | 625 | if ( cat->label() == tran->category() ) |
574 | { | 626 | { |
575 | break; | 627 | break; |
576 | } | 628 | } |
577 | } | 629 | } |
578 | if ( cat && cat->label() == tran->category() ) | 630 | if ( cat && cat->label() == tran->category() ) |
579 | { // Found category, add to transaction to category total | 631 | { // Found category, add to transaction to category total |
580 | cat->addToValue( tran->amount() ); | 632 | cat->addToValue( tran->amount() ); |
581 | } | 633 | } |
582 | else | 634 | else |
583 | { // Didn't find category, add category to list | 635 | { // Didn't find category, add category to list |
584 | list->append( new DataPointInfo( tran->category(), tran->amount() ) ); | 636 | list->append( new DataPointInfo( tran->category(), tran->amount() ) ); |
585 | } | 637 | } |
586 | } | 638 | } |
587 | } | 639 | } |
588 | 640 | ||
589 | graphInfo = new GraphInfo( GraphInfo::PieChart, list ); | 641 | graphInfo = new GraphInfo( GraphInfo::PieChart, list ); |
590 | } | 642 | } |
591 | 643 | ||
592 | CBListItem::CBListItem( QListView *parent, QString label1, QString label2, | 644 | CBListItem::CBListItem( TranInfo *pTran, QListView *parent, QString label1, QString label2, |
593 | QString label3, QString label4, QString label5, QString label6, QString label7, | 645 | QString label3, QString label4, QString label5, QString label6, QString label7, |
594 | QString label8 ) | 646 | QString label8 ) |
595 | : QListViewItem( parent, label1, label2, label3, label4, label5, label6, label7, label8 ) | 647 | : QListViewItem( parent, label1, label2, label3, label4, label5, label6, label7, label8 ) |
596 | { | 648 | { |
649 | _pTran=pTran; | ||
597 | m_known = FALSE; | 650 | m_known = FALSE; |
598 | owner = parent; | 651 | owner = parent; |
599 | } | 652 | } |
600 | 653 | ||
601 | void CBListItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align ) | 654 | void CBListItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align ) |
602 | { | 655 | { |
603 | QColorGroup _cg = cg; | 656 | QColorGroup _cg = cg; |
604 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); | 657 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); |
605 | if ( pm && !pm->isNull() ) | 658 | if ( pm && !pm->isNull() ) |
606 | { | 659 | { |
607 | _cg.setBrush( QColorGroup::Base, QBrush( cg.base(), *pm ) ); | 660 | _cg.setBrush( QColorGroup::Base, QBrush( cg.base(), *pm ) ); |
608 | p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); | 661 | p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); |
609 | } | 662 | } |
610 | else if ( isAltBackground() ) | 663 | else if ( isAltBackground() ) |
611 | _cg.setColor(QColorGroup::Base, cg.background() ); | 664 | _cg.setColor(QColorGroup::Base, cg.background() ); |
612 | 665 | ||
613 | QListViewItem::paintCell(p, _cg, column, width, align); | 666 | QListViewItem::paintCell(p, _cg, column, width, align); |
614 | } | 667 | } |
615 | 668 | ||
616 | bool CBListItem::isAltBackground() | 669 | bool CBListItem::isAltBackground() |
617 | { | 670 | { |
618 | QListView *lv = static_cast<QListView *>( listView() ); | 671 | QListView *lv = static_cast<QListView *>( listView() ); |
619 | if ( lv ) | 672 | if ( lv ) |
620 | { | 673 | { |
621 | CBListItem *above = 0; | 674 | CBListItem *above = 0; |
622 | above = (CBListItem *)( itemAbove() ); | 675 | above = (CBListItem *)( itemAbove() ); |
623 | m_known = above ? above->m_known : true; | 676 | m_known = above ? above->m_known : true; |
624 | if ( m_known ) | 677 | if ( m_known ) |
625 | { | 678 | { |
626 | m_odd = above ? !above->m_odd : false; | 679 | m_odd = above ? !above->m_odd : false; |
627 | } | 680 | } |
628 | else | 681 | else |
629 | { | 682 | { |
630 | CBListItem *item; | 683 | CBListItem *item; |
631 | bool previous = true; | 684 | bool previous = true; |
632 | if ( parent() ) | 685 | if ( parent() ) |
633 | { | 686 | { |
634 | item = (CBListItem *)( parent() ); | 687 | item = (CBListItem *)( parent() ); |
635 | if ( item ) | 688 | if ( item ) |
636 | previous = item->m_odd; | 689 | previous = item->m_odd; |
637 | item = (CBListItem *)( parent()->firstChild() ); | 690 | item = (CBListItem *)( parent()->firstChild() ); |
638 | } | 691 | } |
639 | else | 692 | else |
640 | { | 693 | { |
641 | item = (CBListItem *)( lv->firstChild() ); | 694 | item = (CBListItem *)( lv->firstChild() ); |
642 | } | 695 | } |
643 | 696 | ||
644 | while(item) | 697 | while(item) |
645 | { | 698 | { |
646 | item->m_odd = previous = !previous; | 699 | item->m_odd = previous = !previous; |
647 | item->m_known = true; | 700 | item->m_known = true; |
648 | item = (CBListItem *)( item->nextSibling() ); | 701 | item = (CBListItem *)( item->nextSibling() ); |
649 | } | 702 | } |
650 | } | 703 | } |
651 | return m_odd; | 704 | return m_odd; |
652 | } | 705 | } |
653 | return false; | 706 | return false; |
654 | } | 707 | } |
708 | |||
709 | |||
710 | // --- slotTab ---------------------------------------------------------------- | ||
711 | void Checkbook::slotTab(QWidget *tab) | ||
712 | { | ||
713 | if( !tab || !info ) return; | ||
714 | info->setLastTab( tab->name() ); | ||
715 | } | ||
716 | |||
717 | |||
718 | // --- slotSortChanged --------------------------------------------------------- | ||
719 | void Checkbook::slotSortChanged( const QString &selc ) | ||
720 | { | ||
721 | if( selc==tr("Entry Order") ) { | ||
722 | _sortCol=COL_ID; | ||
723 | } else if( selc==tr("Number") ) { | ||
724 | _sortCol=COL_NUM; | ||
725 | } else if( selc==tr("Date") ) { | ||
726 | _sortCol=COL_DATE; | ||
727 | } | ||
728 | info->setSortOrder( selc ); | ||
729 | resort(); | ||
730 | } | ||
diff --git a/noncore/apps/checkbook/checkbook.h b/noncore/apps/checkbook/checkbook.h index 4a5011b..1b6a2d3 100644 --- a/noncore/apps/checkbook/checkbook.h +++ b/noncore/apps/checkbook/checkbook.h | |||
@@ -1,126 +1,142 @@ | |||
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 | #ifndef CHECKBOOK_H | 29 | #ifndef CHECKBOOK_H |
30 | #define CHECKBOOK_H | 30 | #define CHECKBOOK_H |
31 | 31 | ||
32 | #include <qdatetime.h> | ||
32 | #include <qdialog.h> | 33 | #include <qdialog.h> |
33 | #include <qlistview.h> | 34 | #include <qlistview.h> |
34 | 35 | ||
35 | class OTabWidget; | 36 | class OTabWidget; |
36 | 37 | ||
37 | class CBInfo; | 38 | class CBInfo; |
38 | class Graph; | 39 | class Graph; |
39 | class GraphInfo; | 40 | class GraphInfo; |
40 | class QCheckBox; | 41 | class QCheckBox; |
41 | class QComboBox; | 42 | class QComboBox; |
42 | class QLabel; | 43 | class QLabel; |
43 | class QLineEdit; | 44 | class QLineEdit; |
44 | class QListView; | 45 | class QListView; |
45 | class QMultiLineEdit; | 46 | class QMultiLineEdit; |
46 | class QString; | 47 | class QString; |
47 | class TranInfo; | 48 | class TranInfo; |
48 | class TranInfoList; | 49 | class TranInfoList; |
50 | class Cfg; | ||
49 | 51 | ||
52 | |||
53 | // --- Checkbook -------------------------------------------------------------- | ||
50 | class Checkbook : public QDialog | 54 | class Checkbook : public QDialog |
51 | { | 55 | { |
52 | Q_OBJECT | 56 | Q_OBJECT |
53 | 57 | ||
54 | public: | 58 | public: |
55 | Checkbook( QWidget * = 0x0, CBInfo * = 0x0, const QString & = "$" ); | 59 | Checkbook( QWidget *, CBInfo *, Cfg *cfg ); |
56 | ~Checkbook(); | 60 | ~Checkbook(); |
57 | 61 | ||
62 | // resort | ||
63 | void resort(); | ||
64 | |||
58 | private: | 65 | private: |
59 | CBInfo *info; | 66 | CBInfo *info; |
60 | TranInfoList *tranList; | 67 | TranInfoList *tranList; |
61 | QString currencySymbol; | 68 | Cfg *_pCfg; |
62 | int highTranNum; | ||
63 | 69 | ||
64 | OTabWidget *mainWidget; | 70 | OTabWidget *mainWidget; |
65 | void loadCheckbook(); | 71 | void loadCheckbook(); |
66 | void adjustBalance(); | 72 | void adjustBalance(); |
67 | TranInfo *findTran( const QString &, const QString &, const QString & ); | ||
68 | 73 | ||
69 | // Info tab | 74 | // Info tab |
70 | QWidget *initInfo(); | 75 | QWidget *initInfo(); |
71 | QCheckBox *passwordCB; | 76 | QCheckBox *passwordCB; |
72 | QLineEdit *nameEdit; | 77 | QLineEdit *nameEdit; |
73 | QComboBox *typeList; | 78 | QComboBox *typeList; |
74 | QLineEdit *bankEdit; | 79 | QLineEdit *bankEdit; |
75 | QLineEdit *acctNumEdit; | 80 | QLineEdit *acctNumEdit; |
76 | QLineEdit *pinNumEdit; | 81 | QLineEdit *pinNumEdit; |
77 | QLineEdit *balanceEdit; | 82 | QLineEdit *balanceEdit; |
78 | QMultiLineEdit *notesEdit; | 83 | QMultiLineEdit *notesEdit; |
84 | int _sortCol; | ||
79 | 85 | ||
80 | // Transactions tab | 86 | // Transactions tab |
81 | QWidget *initTransactions(); | 87 | QWidget *initTransactions(); |
82 | QListView *tranTable; | 88 | QListView *tranTable; |
83 | QLabel *balanceLabel; | 89 | QComboBox *_cbSortType; |
90 | QDate _dLastNew; | ||
84 | 91 | ||
85 | // Charts tab | 92 | // Charts tab |
86 | QWidget *initCharts(); | 93 | QWidget *initCharts(); |
87 | GraphInfo *graphInfo; | 94 | GraphInfo *graphInfo; |
88 | QComboBox *graphList; | 95 | QComboBox *graphList; |
89 | Graph *graphWidget; | 96 | Graph *graphWidget; |
90 | 97 | ||
91 | void drawBalanceChart(); | 98 | void drawBalanceChart(); |
92 | void drawCategoryChart( bool = TRUE ); | 99 | void drawCategoryChart( bool = TRUE ); |
93 | 100 | ||
101 | |||
94 | protected slots: | 102 | protected slots: |
95 | void accept(); | 103 | void accept(); |
104 | void slotTab(QWidget *tab); | ||
96 | 105 | ||
97 | private slots: | 106 | private slots: |
98 | void slotPasswordClicked(); | 107 | void slotPasswordClicked(); |
99 | void slotNameChanged( const QString & ); | 108 | void slotNameChanged( const QString & ); |
100 | void slotStartingBalanceChanged( const QString & ); | 109 | void slotStartingBalanceChanged( const QString & ); |
101 | void slotNewTran(); | 110 | void slotNewTran(); |
102 | void slotEditTran(); | 111 | void slotEditTran(); |
103 | void slotDeleteTran(); | 112 | void slotDeleteTran(); |
104 | void slotDrawGraph(); | 113 | void slotDrawGraph(); |
114 | void slotSortChanged( const QString & ); | ||
105 | }; | 115 | }; |
106 | 116 | ||
117 | // --- CBListItem ------------------------------------------------------------- | ||
107 | class CBListItem : public QListViewItem | 118 | class CBListItem : public QListViewItem |
108 | { | 119 | { |
109 | //Q_OBJECT | 120 | //Q_OBJECT |
110 | 121 | ||
111 | public: | 122 | public: |
112 | CBListItem( QListView *, QString = QString::null, QString = QString::null, | 123 | CBListItem( TranInfo *, QListView *, QString = QString::null, QString = QString::null, |
113 | QString = QString::null, QString = QString::null, QString = QString::null, | 124 | QString = QString::null, QString = QString::null, QString = QString::null, |
114 | QString = QString::null, QString = QString::null, QString = QString::null ); | 125 | QString = QString::null, QString = QString::null, QString = QString::null ); |
115 | 126 | ||
116 | void paintCell( QPainter *, const QColorGroup &, int, int, int ); | 127 | void paintCell( QPainter *, const QColorGroup &, int, int, int ); |
117 | 128 | ||
129 | // --- members | ||
130 | TranInfo *getTranInfo() { return(_pTran); } | ||
131 | |||
118 | private: | 132 | private: |
133 | TranInfo *_pTran; | ||
119 | QListView *owner; | 134 | QListView *owner; |
120 | bool m_known; | 135 | bool m_known; |
121 | bool m_odd; | 136 | bool m_odd; |
122 | 137 | ||
123 | bool isAltBackground(); | 138 | bool isAltBackground(); |
124 | }; | 139 | }; |
125 | 140 | ||
141 | |||
126 | #endif | 142 | #endif |
diff --git a/noncore/apps/checkbook/checkbook.pro b/noncore/apps/checkbook/checkbook.pro index 9a16a56..c574aff 100644 --- a/noncore/apps/checkbook/checkbook.pro +++ b/noncore/apps/checkbook/checkbook.pro | |||
@@ -1,49 +1,53 @@ | |||
1 | TEMPLATE = app | 1 | CONFIG = qt warn_on release quick-app |
2 | CONFIG = qt warn_on release | ||
3 | HEADERS = mainwindow.h \ | 2 | HEADERS = mainwindow.h \ |
4 | cbinfo.h \ | 3 | cbinfo.h \ |
5 | traninfo.h \ | 4 | traninfo.h \ |
6 | graphinfo.h \ | 5 | graphinfo.h \ |
7 | configuration.h \ | 6 | configuration.h \ |
8 | password.h \ | 7 | password.h \ |
9 | checkbook.h \ | 8 | checkbook.h \ |
10 | transaction.h \ | 9 | transaction.h \ |
10 | tabledef.h \ | ||
11 | listedit.h \ | ||
12 | cfg.h \ | ||
11 | graph.h | 13 | graph.h |
12 | SOURCES = main.cpp \ | 14 | SOURCES = main.cpp \ |
13 | mainwindow.cpp \ | 15 | mainwindow.cpp \ |
14 | cbinfo.cpp \ | 16 | cbinfo.cpp \ |
15 | traninfo.cpp \ | 17 | traninfo.cpp \ |
16 | graphinfo.cpp \ | 18 | graphinfo.cpp \ |
17 | configuration.cpp \ | 19 | configuration.cpp \ |
18 | password.cpp \ | 20 | password.cpp \ |
19 | checkbook.cpp \ | 21 | checkbook.cpp \ |
20 | transaction.cpp \ | 22 | transaction.cpp \ |
23 | tabledef.cpp \ | ||
24 | listedit.cpp \ | ||
25 | cfg.cpp \ | ||
21 | graph.cpp | 26 | graph.cpp |
22 | INCLUDEPATH += $(OPIEDIR)/include | 27 | INCLUDEPATH += $(OPIEDIR)/include |
23 | DEPENDPATH += $(OPIEDIR)/include | 28 | DEPENDPATH += $(OPIEDIR)/include |
24 | LIBS += -lqpe -lopie | 29 | LIBS += -lqpe -lopie |
25 | TARGET = checkbook | 30 | TARGET = checkbook |
26 | DESTDIR = $(OPIEDIR)/bin | ||
27 | 31 | ||
28 | TRANSLATIONS = ../../../i18n/de/checkbook.ts \ | 32 | TRANSLATIONS = ../../../i18n/de/checkbook.ts \ |
29 | ../../../i18n/nl/checkbook.ts \ | 33 | ../../../i18n/nl/checkbook.ts \ |
30 | ../../../i18n/da/checkbook.ts \ | 34 | ../../../i18n/da/checkbook.ts \ |
31 | ../../../i18n/xx/checkbook.ts \ | 35 | ../../../i18n/xx/checkbook.ts \ |
32 | ../../../i18n/en/checkbook.ts \ | 36 | ../../../i18n/en/checkbook.ts \ |
33 | ../../../i18n/es/checkbook.ts \ | 37 | ../../../i18n/es/checkbook.ts \ |
34 | ../../../i18n/fr/checkbook.ts \ | 38 | ../../../i18n/fr/checkbook.ts \ |
35 | ../../../i18n/hu/checkbook.ts \ | 39 | ../../../i18n/hu/checkbook.ts \ |
36 | ../../../i18n/ja/checkbook.ts \ | 40 | ../../../i18n/ja/checkbook.ts \ |
37 | ../../../i18n/ko/checkbook.ts \ | 41 | ../../../i18n/ko/checkbook.ts \ |
38 | ../../../i18n/no/checkbook.ts \ | 42 | ../../../i18n/no/checkbook.ts \ |
39 | ../../../i18n/pl/checkbook.ts \ | 43 | ../../../i18n/pl/checkbook.ts \ |
40 | ../../../i18n/pt/checkbook.ts \ | 44 | ../../../i18n/pt/checkbook.ts \ |
41 | ../../../i18n/pt_BR/checkbook.ts \ | 45 | ../../../i18n/pt_BR/checkbook.ts \ |
42 | ../../../i18n/sl/checkbook.ts \ | 46 | ../../../i18n/sl/checkbook.ts \ |
43 | ../../../i18n/zh_CN/checkbook.ts \ | 47 | ../../../i18n/zh_CN/checkbook.ts \ |
44 | ../../../i18n/zh_TW/checkbook.ts \ | 48 | ../../../i18n/zh_TW/checkbook.ts \ |
45 | ../../../i18n/it/checkbook.ts | 49 | ../../../i18n/it/checkbook.ts |
46 | 50 | ||
47 | 51 | ||
48 | 52 | ||
49 | include ( $(OPIEDIR)/include.pro ) | 53 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/checkbook/configuration.cpp b/noncore/apps/checkbook/configuration.cpp index 7731cf3..3f5662d 100644 --- a/noncore/apps/checkbook/configuration.cpp +++ b/noncore/apps/checkbook/configuration.cpp | |||
@@ -1,74 +1,161 @@ | |||
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 "configuration.h" | 29 | #include "configuration.h" |
30 | #include "mainwindow.h" | ||
31 | #include "listedit.h" | ||
32 | #include "tabledef.h" | ||
30 | 33 | ||
31 | #include <qcheckbox.h> | 34 | #include <qcheckbox.h> |
32 | #include <qlabel.h> | 35 | #include <qlabel.h> |
33 | #include <qlayout.h> | 36 | #include <qlayout.h> |
34 | #include <qlineedit.h> | 37 | #include <qlineedit.h> |
35 | #include <qwhatsthis.h> | 38 | #include <qwhatsthis.h> |
39 | #include <qlistview.h> | ||
40 | #include <qpushbutton.h> | ||
41 | #include <qtabwidget.h> | ||
42 | #include <qpe/resource.h> | ||
36 | 43 | ||
37 | Configuration::Configuration( QWidget *parent, const QString &cs, bool sl, bool sb ) | 44 | Configuration::Configuration( QWidget *parent, Cfg &cfg ) |
38 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) | 45 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) |
39 | { | 46 | { |
40 | setCaption( tr( "Configure Checkbook" ) ); | 47 | setCaption( tr( "Configure Checkbook" ) ); |
41 | 48 | ||
42 | QFontMetrics fm = fontMetrics(); | 49 | // Setup layout to make everything pretty |
50 | QVBoxLayout *layout = new QVBoxLayout( this ); | ||
51 | layout->setMargin( 2 ); | ||
52 | layout->setSpacing( 4 ); | ||
53 | |||
54 | // Setup tabs for all info | ||
55 | _mainWidget = new QTabWidget( this ); | ||
56 | layout->addWidget( _mainWidget ); | ||
57 | |||
58 | // Settings tab | ||
59 | _mainWidget->addTab( initSettings(cfg), tr( "&Settings" ) ); | ||
60 | |||
61 | // Account Types tab | ||
62 | ColumnDef *d; | ||
63 | _listEditTypes=new ListEdit(_mainWidget, "TYPES" ); | ||
64 | d=new ColumnDef( tr("Type"), (ColumnDef::ColumnType)(ColumnDef::typeString | ColumnDef::typeUnique), tr("New Account Type")); | ||
65 | _listEditTypes->addColumnDef( d ); | ||
66 | _listEditTypes->addData( cfg.getAccountTypes() ); | ||
67 | _mainWidget->addTab( _listEditTypes, tr( "&Account Types" ) ); | ||
68 | |||
69 | // Categories tab | ||
70 | _listEditCategories=new ListEdit(_mainWidget, "CATEGORIES" ); | ||
71 | _listEditCategories->addColumnDef( new ColumnDef( tr("Category"), (ColumnDef::ColumnType)(ColumnDef::typeString | ColumnDef::typeUnique), tr("New Category")) ); | ||
72 | d=new ColumnDef( tr("Type"), ColumnDef::typeList, tr("Expense") ); | ||
73 | d->addColumnValue( tr("Expense") ); | ||
74 | d->addColumnValue( tr("Income") ); | ||
75 | _listEditCategories->addColumnDef( d ); | ||
76 | QStringList lst=cfg.getCategories(); | ||
77 | _listEditCategories->addData( lst ); | ||
78 | _mainWidget->addTab( _listEditCategories, tr( "&Categories" ) ); | ||
79 | } | ||
80 | |||
81 | Configuration::~Configuration() | ||
82 | { | ||
83 | } | ||
84 | |||
85 | // ---- initSettings ---------------------------------------------------------- | ||
86 | QWidget *Configuration::initSettings(Cfg &cfg) | ||
87 | { | ||
88 | QWidget *control = new QWidget( _mainWidget ); | ||
89 | |||
90 | QFontMetrics fm = fontMetrics(); | ||
43 | int fh = fm.height(); | 91 | int fh = fm.height(); |
44 | 92 | ||
45 | QGridLayout *layout = new QGridLayout( this ); | 93 | QVBoxLayout *vb = new QVBoxLayout( control ); |
94 | |||
95 | QScrollView *sv = new QScrollView( control ); | ||
96 | vb->addWidget( sv, 0, 0 ); | ||
97 | sv->setResizePolicy( QScrollView::AutoOneFit ); | ||
98 | sv->setFrameStyle( QFrame::NoFrame ); | ||
99 | |||
100 | QWidget *container = new QWidget( sv->viewport() ); | ||
101 | sv->addChild( container ); | ||
102 | |||
103 | QGridLayout *layout = new QGridLayout( container ); | ||
46 | layout->setSpacing( 4 ); | 104 | layout->setSpacing( 4 ); |
47 | layout->setMargin( 4 ); | 105 | layout->setMargin( 4 ); |
48 | 106 | ||
49 | QLabel *label = new QLabel( tr( "Enter currency symbol:" ), this ); | 107 | QLabel *label = new QLabel( tr( "Enter currency symbol:" ), container ); |
50 | QWhatsThis::add( label, tr( "Enter your local currency symbol here." ) ); | 108 | QWhatsThis::add( label, tr( "Enter your local currency symbol here." ) ); |
51 | label->setMaximumHeight( fh + 3 ); | 109 | label->setMaximumHeight( fh + 3 ); |
52 | layout->addWidget( label, 0, 0 ); | 110 | layout->addWidget( label, 0, 0 ); |
53 | 111 | ||
54 | symbolEdit = new QLineEdit( cs, this ); | 112 | symbolEdit = new QLineEdit( cfg.getCurrencySymbol(), container ); |
55 | QWhatsThis::add( symbolEdit, tr( "Enter your local currency symbol here." ) ); | 113 | QWhatsThis::add( symbolEdit, tr( "Enter your local currency symbol here." ) ); |
56 | symbolEdit->setMaximumHeight( fh + 5 ); | 114 | symbolEdit->setMaximumHeight( fh + 5 ); |
57 | symbolEdit->setFocus(); | 115 | symbolEdit->setFocus(); |
58 | layout->addWidget( symbolEdit, 0, 1 ); | 116 | layout->addWidget( symbolEdit, 0, 1 ); |
59 | 117 | ||
60 | lockCB = new QCheckBox( tr( "Show whether checkbook is password\nprotected" ), this ); | 118 | lockCB = new QCheckBox( tr( "Show whether checkbook is password\nprotected" ), container ); |
61 | QWhatsThis::add( lockCB, tr( "Click here to select whether or not the main window will display that the checkbook is protected with a password." ) ); | 119 | QWhatsThis::add( lockCB, tr( "Click here to select whether or not the main window will display that the checkbook is protected with a password." ) ); |
62 | lockCB->setChecked( sl ); | 120 | lockCB->setChecked( cfg.getShowLocks() ); |
63 | layout->addMultiCellWidget( lockCB, 1, 1, 0, 1 ); | 121 | layout->addMultiCellWidget( lockCB, 1, 1, 0, 1 ); |
64 | 122 | ||
65 | balCB = new QCheckBox( tr( "Show checkbook balances" ), this ); | 123 | balCB = new QCheckBox( tr( "Show checkbook balances" ), container ); |
66 | QWhatsThis::add( balCB, tr( "Click here to select whether or not the main window will display the current balance for each checkbook." ) ); | 124 | QWhatsThis::add( balCB, tr( "Click here to select whether or not the main window will display the current balance for each checkbook." ) ); |
67 | balCB->setMaximumHeight( fh + 5 ); | 125 | balCB->setMaximumHeight( fh + 5 ); |
68 | balCB->setChecked( sb ); | 126 | balCB->setChecked( cfg.getShowBalances() ); |
69 | layout->addMultiCellWidget( balCB, 2, 2, 0, 1 ); | 127 | layout->addMultiCellWidget( balCB, 2, 2, 0, 1 ); |
128 | |||
129 | openLastBookCB = new QCheckBox( tr("Open last checkbook" ), container ); | ||
130 | QWhatsThis::add( openLastBookCB, tr("Click here to select whether the last open checkbook will be opened at startup.") ); | ||
131 | openLastBookCB->setMaximumHeight(fh+5); | ||
132 | openLastBookCB->setChecked( cfg.isOpenLastBook() ); | ||
133 | layout->addMultiCellWidget( openLastBookCB, 3, 3, 0, 1 ); | ||
134 | |||
135 | lastTabCB = new QCheckBox( tr("Show last checkbook tab" ), container ); | ||
136 | QWhatsThis::add( lastTabCB, tr("Click here to select whether the last tab in a checkbook should be displayed.") ); | ||
137 | lastTabCB->setMaximumHeight(fh+5); | ||
138 | lastTabCB->setChecked( cfg.isShowLastTab() ); | ||
139 | layout->addMultiCellWidget( lastTabCB, 4, 4, 0, 1 ); | ||
140 | |||
141 | return(control); | ||
70 | } | 142 | } |
71 | 143 | ||
72 | Configuration::~Configuration() | 144 | // --- saveConfig ------------------------------------------------------------- |
145 | void Configuration::saveConfig(Cfg &cfg) | ||
73 | { | 146 | { |
147 | // Settings | ||
148 | cfg.setCurrencySymbol( symbolEdit->text() ); | ||
149 | cfg.setShowLocks( lockCB->isChecked() ); | ||
150 | cfg.setShowBalances( balCB->isChecked() ); | ||
151 | cfg.setOpenLastBook( openLastBookCB->isChecked() ); | ||
152 | cfg.setShowLastTab( lastTabCB->isChecked() ); | ||
153 | |||
154 | // Typelist | ||
155 | _listEditTypes->storeInList( cfg.getAccountTypes() ); | ||
156 | |||
157 | // Category list | ||
158 | QStringList lst; | ||
159 | _listEditCategories->storeInList( lst ); | ||
160 | cfg.setCategories( lst ); | ||
74 | } | 161 | } |
diff --git a/noncore/apps/checkbook/configuration.h b/noncore/apps/checkbook/configuration.h index 9a8de02..5893502 100644 --- a/noncore/apps/checkbook/configuration.h +++ b/noncore/apps/checkbook/configuration.h | |||
@@ -1,51 +1,67 @@ | |||
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 | #ifndef CONFIGURATION_H | 29 | #ifndef CONFIGURATION_H |
30 | #define CONFIGURATION_H | 30 | #define CONFIGURATION_H |
31 | 31 | ||
32 | #include <qdialog.h> | 32 | #include <qdialog.h> |
33 | #include "cfg.h" | ||
33 | 34 | ||
34 | class QCheckBox; | 35 | class QCheckBox; |
35 | class QLineEdit; | 36 | class QLineEdit; |
36 | class QString; | 37 | class QString; |
38 | class QTabWidget; | ||
39 | class ListEdit; | ||
37 | 40 | ||
38 | class Configuration : public QDialog | 41 | class Configuration : public QDialog |
39 | { | 42 | { |
40 | Q_OBJECT | 43 | Q_OBJECT |
41 | 44 | ||
42 | public: | 45 | public: |
43 | Configuration( QWidget * = 0x0, const QString & = "$", bool = FALSE, bool = FALSE ); | 46 | // Constructor |
47 | Configuration( QWidget *, Cfg &cfg); | ||
44 | ~Configuration(); | 48 | ~Configuration(); |
45 | 49 | ||
46 | QLineEdit *symbolEdit; | 50 | QLineEdit *symbolEdit; |
47 | QCheckBox *lockCB; | 51 | QCheckBox *lockCB; |
48 | QCheckBox *balCB; | 52 | QCheckBox *balCB; |
53 | QCheckBox *openLastBookCB; | ||
54 | QCheckBox *lastTabCB; | ||
55 | QTabWidget *_mainWidget; | ||
56 | ListEdit *_listEditTypes; | ||
57 | ListEdit *_listEditCategories; | ||
58 | |||
59 | // saves settings in config struct | ||
60 | void saveConfig(Cfg &cfg); | ||
61 | |||
62 | protected: | ||
63 | // creates settings tap from configuration | ||
64 | QWidget *initSettings(Cfg &cfg); | ||
49 | }; | 65 | }; |
50 | 66 | ||
51 | #endif | 67 | #endif |
diff --git a/noncore/apps/checkbook/listedit.cpp b/noncore/apps/checkbook/listedit.cpp new file mode 100644 index 0000000..99a6531 --- a/dev/null +++ b/noncore/apps/checkbook/listedit.cpp | |||
@@ -0,0 +1,340 @@ | |||
1 | /* | ||
2 | This file is part of the OPIE Project | ||
3 | =. | ||
4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This file is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
11 | ._= =} : or (at your option) any later version. | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This file is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | ||
18 | ..}^=.= = ; Public License for more details. | ||
19 | ++= -. .` .: | ||
20 | : = ...= . :.=- You should have received a copy of the GNU | ||
21 | -. .:....=;==+<; General Public License along with this file; | ||
22 | -_. . . )=. = see the file COPYING. If not, write to the | ||
23 | -- :-=` Free Software Foundation, Inc., | ||
24 | 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #include "listedit.h" | ||
30 | #include <qlayout.h> | ||
31 | #include <qlineedit.h> | ||
32 | #include <qlistview.h> | ||
33 | #include <qwidgetstack.h> | ||
34 | #include <qcombobox.h> | ||
35 | #include <qpushbutton.h> | ||
36 | #include <qpe/resource.h> | ||
37 | |||
38 | |||
39 | // --- ListEdit --------------------------------------------------------------- | ||
40 | ListEdit::ListEdit( QWidget *parent, const char *sName ) | ||
41 | : QWidget(parent, sName), TableDef(sName) | ||
42 | { | ||
43 | // get font height | ||
44 | int fh = fontMetrics().height(); | ||
45 | |||
46 | // create layout | ||
47 | QGridLayout *layout=new QGridLayout(this); | ||
48 | layout->setSpacing( 2 ); | ||
49 | layout->setMargin( 4 ); | ||
50 | |||
51 | // type table | ||
52 | _typeTable = new QListView( this ); | ||
53 | ColumnDef *def=first(); | ||
54 | while( def ) { | ||
55 | _typeTable->addColumn( def->getName() ); | ||
56 | def=next(); | ||
57 | } | ||
58 | connect( _typeTable, SIGNAL( clicked(QListViewItem *, const QPoint &, int) ), this, SLOT( slotClick(QListViewItem *, const QPoint &, int ) ) ); | ||
59 | layout->addMultiCellWidget(_typeTable, 0,4,0,4); | ||
60 | _currentItem=NULL; | ||
61 | |||
62 | // edit field | ||
63 | _stack=new QWidgetStack( this ); | ||
64 | _stack->setMaximumHeight(fh+5); | ||
65 | layout->addMultiCellWidget(_stack, 5,5,0,2); | ||
66 | _typeEdit = new QLineEdit( _stack ); | ||
67 | _stack->raiseWidget(_typeEdit ); | ||
68 | connect( _typeEdit, SIGNAL( textChanged(const QString &) ), this, SLOT( slotEditChanged(const QString &) ) ); | ||
69 | |||
70 | // combo box | ||
71 | _box=new QComboBox( _stack ); | ||
72 | connect( _box, SIGNAL( activated(const QString &) ), this, SLOT( slotActivated(const QString &) ) ); | ||
73 | |||
74 | |||
75 | // add button | ||
76 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/add" ), tr( "Add" ), this ); | ||
77 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotAdd() ) ); | ||
78 | layout->addWidget( btn, 5, 3 ); | ||
79 | |||
80 | // delete button | ||
81 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), this ); | ||
82 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDel() ) ); | ||
83 | layout->addWidget( btn, 5, 4 ); | ||
84 | } | ||
85 | |||
86 | // --- ~ListEdit -------------------------------------------------------------- | ||
87 | ListEdit::~ListEdit() | ||
88 | { | ||
89 | } | ||
90 | |||
91 | |||
92 | // --- slotEditTypeChanged ---------------------------------------------------- | ||
93 | void ListEdit::slotEditChanged(const QString &str) | ||
94 | { | ||
95 | if( !_currentItem || _currentColumn<0 ) return; | ||
96 | _currentItem->setText(_currentColumn, str); | ||
97 | } | ||
98 | |||
99 | // --- slotAddType ------------------------------------------------------------ | ||
100 | void ListEdit::slotAdd() | ||
101 | { | ||
102 | // construct new row | ||
103 | QString args[8]; | ||
104 | ColumnDef *pCol=this->first(); | ||
105 | int i=0; | ||
106 | while( pCol && i<8 ) { | ||
107 | args[i++]=pCol->getNewValue(); | ||
108 | pCol=this->next(); | ||
109 | } | ||
110 | _currentItem=new QListViewItem(_typeTable, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7] ); | ||
111 | |||
112 | // fix uniques | ||
113 | fixTypes(); | ||
114 | |||
115 | // display col 0 of new value | ||
116 | QPoint pnt; | ||
117 | slotClick(_currentItem, pnt, 0); | ||
118 | _typeTable->setSelected( _currentItem, true ); | ||
119 | } | ||
120 | |||
121 | // --- slotDel ------------------------------------------------------------- | ||
122 | void ListEdit::slotDel() | ||
123 | { | ||
124 | if( !_currentItem ) return; | ||
125 | delete _currentItem; | ||
126 | _currentItem=NULL; | ||
127 | _typeEdit->setText(""); | ||
128 | _stack->raiseWidget(_typeEdit); | ||
129 | } | ||
130 | |||
131 | |||
132 | // --- fixTypes ---------------------------------------------------------------- | ||
133 | // Makes sure all entries have a unique name and empty entries are replaced | ||
134 | // by a generic string. The first version performs the operation on a particular | ||
135 | // column, whereas the 2nd does it for all unique columns. | ||
136 | class ColMap { | ||
137 | public: | ||
138 | ColMap(QString sValue, QListViewItem *pEntry) { | ||
139 | _sValue=sValue; | ||
140 | _pEntry=pEntry; | ||
141 | } | ||
142 | QString &getValue() { return(_sValue); } | ||
143 | QListViewItem *getItem() { return(_pEntry); } | ||
144 | |||
145 | protected: | ||
146 | QString _sValue; | ||
147 | QListViewItem *_pEntry; | ||
148 | }; | ||
149 | |||
150 | class ColList : public QList<QString> | ||
151 | { | ||
152 | public: | ||
153 | ColList() : QList<QString>() { } | ||
154 | |||
155 | protected: | ||
156 | int compareItems(QCollection::Item, QCollection::Item); | ||
157 | }; | ||
158 | |||
159 | int ColList::compareItems(QCollection::Item i1, QCollection::Item i2) { | ||
160 | return( ((QString *)i1)->compare(*(QString *)i2) ); | ||
161 | } | ||
162 | |||
163 | void ListEdit::fixTypes(int iColumn) | ||
164 | { | ||
165 | // get column def | ||
166 | ColumnDef *pDef=this->at(iColumn); | ||
167 | |||
168 | // create map of entries | ||
169 | if( !_typeTable->childCount() ) return; | ||
170 | ColMap **colMap=new (ColMap *)[_typeTable->childCount()]; | ||
171 | QListViewItem *cur=_typeTable->firstChild(); | ||
172 | ColList lst; | ||
173 | for(int i=0; i<_typeTable->childCount(); i++) { | ||
174 | colMap[i]=new ColMap(cur->text(iColumn), cur); | ||
175 | lst.append( &(colMap[i]->getValue()) ); | ||
176 | cur=cur->nextSibling(); | ||
177 | } | ||
178 | |||
179 | // fix empty entries | ||
180 | int i=0; | ||
181 | for(QString *ptr=lst.first(); ptr; ptr=lst.next()) { | ||
182 | *ptr=ptr->stripWhiteSpace(); | ||
183 | if( ptr->isEmpty() ) { | ||
184 | i++; | ||
185 | if( i==1 ) *ptr=pDef->getNewValue(); | ||
186 | else ptr->sprintf("%s %d", (const char *)pDef->getNewValue(), i); | ||
187 | } | ||
188 | } | ||
189 | |||
190 | // fix dups | ||
191 | lst.sort(); | ||
192 | QString repl; | ||
193 | for(uint iCur=0; iCur<lst.count()-1; iCur++) { | ||
194 | QString *current=lst.at(iCur); | ||
195 | for(uint iNext=iCur+1; iNext<lst.count(); iNext++ ) { | ||
196 | if( *current!=*lst.at(iNext) ) continue; | ||
197 | for(int i=2; ; i++) { | ||
198 | repl.sprintf("%s %d", (const char *)*current, i); | ||
199 | bool bDup=false; | ||
200 | uint iChk=iNext+1; | ||
201 | while( iChk<lst.count() ) { | ||
202 | QString *chk=lst.at(iChk); | ||
203 | if( !chk->startsWith(*current) ) break; | ||
204 | if( *chk==repl ) { | ||
205 | bDup=true; | ||
206 | break; | ||
207 | } | ||
208 | iChk++; | ||
209 | } | ||
210 | if( !bDup ) { | ||
211 | *lst.at(iNext)=repl; | ||
212 | break; | ||
213 | } | ||
214 | } | ||
215 | } | ||
216 | } | ||
217 | lst.sort(); | ||
218 | |||
219 | // copy back clean up col map | ||
220 | for(int i=0; i<_typeTable->childCount(); i++) { | ||
221 | colMap[i]->getItem()->setText(iColumn, colMap[i]->getValue()); | ||
222 | delete colMap[i]; | ||
223 | } | ||
224 | delete colMap; | ||
225 | } | ||
226 | |||
227 | void ListEdit::fixTypes() | ||
228 | { | ||
229 | int i; | ||
230 | ColumnDef *pDef; | ||
231 | for(pDef=this->first(), i=0; pDef; pDef=this->next(), i++) { | ||
232 | if( pDef->hasFlag(ColumnDef::typeUnique) ) | ||
233 | fixTypes(i); | ||
234 | } | ||
235 | _typeTable->sort(); | ||
236 | } | ||
237 | |||
238 | |||
239 | // --- storeInList ------------------------------------------------------------ | ||
240 | void ListEdit::storeInList(QStringList &lst) | ||
241 | { | ||
242 | // delete old content | ||
243 | lst.clear(); | ||
244 | |||
245 | // add new one | ||
246 | fixTypes(); | ||
247 | QListViewItem *itm=_typeTable->firstChild(); | ||
248 | while( itm ) { | ||
249 | int i=0; | ||
250 | QString sAdd; | ||
251 | ColumnDef *pDef; | ||
252 | for(pDef=this->first(), i=0; pDef; pDef=this->next(), i++) { | ||
253 | if( i>=1 ) sAdd+=";"; | ||
254 | sAdd += itm->text(i); | ||
255 | } | ||
256 | lst.append( sAdd ); | ||
257 | itm=itm->nextSibling(); | ||
258 | } | ||
259 | } | ||
260 | |||
261 | |||
262 | // --- slotClicked ------------------------------------------------------------ | ||
263 | void ListEdit::slotClick(QListViewItem *itm, const QPoint &pnt, int col) | ||
264 | { | ||
265 | (void)pnt; // get rid of unused warning; | ||
266 | |||
267 | // save values | ||
268 | _currentItem=itm; | ||
269 | _currentColumn=col; | ||
270 | if( itm==NULL ) { | ||
271 | _typeEdit->setText(""); | ||
272 | _stack->raiseWidget(_typeEdit); | ||
273 | return; | ||
274 | } | ||
275 | |||
276 | // display value | ||
277 | if( _currentColumn<0 ) _currentColumn=0; | ||
278 | ColumnDef *pDef=this->at(_currentColumn); | ||
279 | if( pDef->isType(ColumnDef::typeString) ) { | ||
280 | _typeEdit->setText( _currentItem->text(_currentColumn) ); | ||
281 | _stack->raiseWidget(_typeEdit); | ||
282 | } else if( pDef->isType(ColumnDef::typeList) ){ | ||
283 | _box->clear(); | ||
284 | _box->insertStringList( pDef->getValueList() ); | ||
285 | QStringList::Iterator itr; | ||
286 | int i=0; | ||
287 | for(itr=pDef->getValueList().begin(); itr!=pDef->getValueList().end(); itr++) { | ||
288 | if( (*itr)==_currentItem->text(_currentColumn) ) { | ||
289 | _box->setCurrentItem(i); | ||
290 | i=-1; | ||
291 | break; | ||
292 | } | ||
293 | i++; | ||
294 | } | ||
295 | if( i>=0 ) { | ||
296 | _box->insertItem( _currentItem->text(_currentColumn) ); | ||
297 | _box->setCurrentItem(i); | ||
298 | } | ||
299 | _stack->raiseWidget(_box); | ||
300 | } else { | ||
301 | qDebug( "Unsupported column type for column %s", (const char *)pDef->getName() ); | ||
302 | _typeEdit->setText(""); | ||
303 | _stack->raiseWidget(_typeEdit); | ||
304 | } | ||
305 | } | ||
306 | |||
307 | |||
308 | // --- addColumnDef ----------------------------------------------------------- | ||
309 | void ListEdit::addColumnDef(ColumnDef *pDef) | ||
310 | { | ||
311 | _typeTable->addColumn( pDef->getName() ); | ||
312 | _vColumns.append(pDef); | ||
313 | } | ||
314 | |||
315 | // --- addData ---------------------------------------------------------------- | ||
316 | void ListEdit::addData(QStringList &lst) | ||
317 | { | ||
318 | // run through list | ||
319 | QStringList::Iterator itr; | ||
320 | for(itr=lst.begin(); itr!=lst.end(); itr++) { | ||
321 | QStringList split=QStringList::split(";", *itr, true); | ||
322 | QStringList::Iterator entry; | ||
323 | QString args[8]; | ||
324 | int i=0; | ||
325 | for(entry=split.begin(); entry!=split.end() && i<8; entry++, i++) { | ||
326 | args[i]= (*entry); | ||
327 | } | ||
328 | while(i<8) { | ||
329 | args[i++]=""; | ||
330 | } | ||
331 | new QListViewItem(_typeTable, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); | ||
332 | } | ||
333 | } | ||
334 | |||
335 | // --- slotActivated ---------------------------------------------------------- | ||
336 | void ListEdit::slotActivated(const QString &str) | ||
337 | { | ||
338 | if( _currentItem==NULL || _currentColumn<0 ) return; | ||
339 | _currentItem->setText(_currentColumn, str); | ||
340 | } | ||
diff --git a/noncore/apps/checkbook/listedit.h b/noncore/apps/checkbook/listedit.h new file mode 100644 index 0000000..d2135ea --- a/dev/null +++ b/noncore/apps/checkbook/listedit.h | |||
@@ -0,0 +1,78 @@ | |||
1 | /* | ||
2 | This file is part of the OPIE Project | ||
3 | =. | ||
4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This file is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
11 | ._= =} : or (at your option) any later version. | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This file is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | ||
18 | ..}^=.= = ; Public License for more details. | ||
19 | ++= -. .` .: | ||
20 | : = ...= . :.=- You should have received a copy of the GNU | ||
21 | -. .:....=;==+<; General Public License along with this file; | ||
22 | -_. . . )=. = see the file COPYING. If not, write to the | ||
23 | -- :-=` Free Software Foundation, Inc., | ||
24 | 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #ifndef LISTEDIT_H | ||
30 | #define LISTEDIT_H | ||
31 | |||
32 | #include <qwidget.h> | ||
33 | #include "tabledef.h" | ||
34 | class QListView; | ||
35 | class QLineEdit; | ||
36 | class QListViewItem; | ||
37 | class QPoint; | ||
38 | class QWidgetStack; | ||
39 | class QComboBox; | ||
40 | |||
41 | class ListEdit : public QWidget, public TableDef | ||
42 | { | ||
43 | Q_OBJECT | ||
44 | |||
45 | public: | ||
46 | ListEdit( QWidget *, const char *sName); | ||
47 | virtual ~ListEdit(); | ||
48 | |||
49 | QListView *_typeTable; | ||
50 | QLineEdit *_typeEdit; | ||
51 | QWidgetStack *_stack; | ||
52 | QComboBox *_box; | ||
53 | QListViewItem *_currentItem; | ||
54 | int _currentColumn; | ||
55 | |||
56 | // resolves dups and empty entries | ||
57 | void fixTypes(); | ||
58 | void fixTypes(int iColumn); | ||
59 | |||
60 | // stores content in string list | ||
61 | void storeInList(QStringList &lst); | ||
62 | |||
63 | // adds a column definition | ||
64 | virtual void addColumnDef(ColumnDef *pDef); | ||
65 | |||
66 | // adds data to table | ||
67 | void addData(QStringList &lst); | ||
68 | |||
69 | |||
70 | public slots: | ||
71 | void slotClick(QListViewItem *, const QPoint &pnt, int col); | ||
72 | void slotEditChanged(const QString &); | ||
73 | void slotAdd(); | ||
74 | void slotDel(); | ||
75 | void slotActivated(const QString &); | ||
76 | }; | ||
77 | |||
78 | #endif | ||
diff --git a/noncore/apps/checkbook/main.cpp b/noncore/apps/checkbook/main.cpp index abfa633..dcaab4a 100644 --- a/noncore/apps/checkbook/main.cpp +++ b/noncore/apps/checkbook/main.cpp | |||
@@ -1,42 +1,34 @@ | |||
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 "mainwindow.h" | ||
30 | |||
31 | #include <qpe/qpeapplication.h> | 29 | #include <qpe/qpeapplication.h> |
30 | #include <opie/oapplicationfactory.h> | ||
32 | 31 | ||
33 | int main(int argc, char **argv) | 32 | #include "mainwindow.h" |
34 | { | ||
35 | QPEApplication app(argc, argv); | ||
36 | |||
37 | MainWindow *cb = new MainWindow(); | ||
38 | app.setMainWidget(cb); | ||
39 | cb->showMaximized(); | ||
40 | 33 | ||
41 | return app.exec(); | 34 | OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) |
42 | } | ||
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp index 6d1d7b9..8d64cad 100644 --- a/noncore/apps/checkbook/mainwindow.cpp +++ b/noncore/apps/checkbook/mainwindow.cpp | |||
@@ -1,335 +1,360 @@ | |||
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 "mainwindow.h" | 29 | #include "mainwindow.h" |
30 | #include "cbinfo.h" | 30 | #include "cbinfo.h" |
31 | #include "configuration.h" | 31 | #include "configuration.h" |
32 | #include "password.h" | 32 | #include "password.h" |
33 | #include "checkbook.h" | 33 | #include "checkbook.h" |
34 | #include "listedit.h" | ||
34 | 35 | ||
35 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
36 | #include <qpe/global.h> | 37 | #include <qpe/global.h> |
37 | #include <qpe/qpeapplication.h> | 38 | #include <qpe/qpeapplication.h> |
38 | #include <qpe/qpemenubar.h> | 39 | #include <qpe/qpemenubar.h> |
39 | #include <qpe/qpemessagebox.h> | 40 | #include <qpe/qpemessagebox.h> |
40 | #include <qpe/qpetoolbar.h> | 41 | #include <qpe/qpetoolbar.h> |
41 | #include <qpe/resource.h> | 42 | #include <qpe/resource.h> |
42 | 43 | ||
43 | #include <qaction.h> | 44 | #include <qaction.h> |
44 | #include <qcheckbox.h> | 45 | #include <qcheckbox.h> |
45 | #include <qdir.h> | 46 | #include <qdir.h> |
46 | #include <qlineedit.h> | 47 | #include <qlineedit.h> |
47 | #include <qwhatsthis.h> | 48 | #include <qwhatsthis.h> |
48 | 49 | ||
49 | MainWindow::MainWindow() | 50 | |
50 | : QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) | 51 | MainWindow::MainWindow( QWidget* parent, const char* name, WFlags fl ) |
52 | : QMainWindow( parent, name, fl || WStyle_ContextHelp ) | ||
51 | { | 53 | { |
52 | setCaption( tr( "Checkbook" ) ); | 54 | setCaption( tr( "Checkbook" ) ); |
53 | 55 | ||
54 | cbDir = Global::applicationFileName( "checkbook", "" ); | 56 | cbDir = Global::applicationFileName( "checkbook", "" ); |
55 | lockIcon = Resource::loadPixmap( "locked" ); | 57 | lockIcon = Resource::loadPixmap( "locked" ); |
56 | 58 | ||
57 | // Load configuration options | 59 | // Load configuration options |
58 | Config config( "checkbook" ); | 60 | Config config( "checkbook" ); |
59 | config.setGroup( "Config" ); | 61 | qDebug( "Reading config" ); |
60 | currencySymbol = config.readEntry( "CurrencySymbol", "$" ); | 62 | _cfg.readConfig( config ); |
61 | showLocks = config.readBoolEntry( "ShowLocks", FALSE ); | 63 | |
62 | showBalances = config.readBoolEntry( "ShowBalances", FALSE ); | ||
63 | 64 | ||
64 | // Build menu and tool bars | 65 | // Build menu and tool bars |
65 | setToolBarsMovable( FALSE ); | 66 | setToolBarsMovable( FALSE ); |
66 | 67 | ||
67 | QPEToolBar *bar = new QPEToolBar( this ); | 68 | QPEToolBar *bar = new QPEToolBar( this ); |
68 | bar->setHorizontalStretchable( TRUE ); | 69 | bar->setHorizontalStretchable( TRUE ); |
69 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 70 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
70 | mb->setMargin( 0 ); | 71 | mb->setMargin( 0 ); |
71 | QPopupMenu *popup = new QPopupMenu( this ); | 72 | QPopupMenu *popup = new QPopupMenu( this ); |
72 | 73 | ||
73 | bar = new QPEToolBar( this ); | 74 | bar = new QPEToolBar( this ); |
74 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 75 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
75 | a->setWhatsThis( tr( "Click here to create a new checkbook.\n\nYou also can select New from the Checkbook menu." ) ); | 76 | a->setWhatsThis( tr( "Click here to create a new checkbook.\n\nYou also can select New from the Checkbook menu." ) ); |
76 | connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); | 77 | connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); |
77 | a->addTo( popup ); | 78 | a->addTo( popup ); |
78 | a->addTo( bar ); | 79 | a->addTo( bar ); |
79 | 80 | ||
80 | actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, | 81 | actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, |
81 | 0, this, 0 ); | 82 | 0, this, 0 ); |
82 | actionOpen->setWhatsThis( tr( "Select a checkbook and then click here to edit it.\n\nYou also can select Edit from the Checkbook menu, or click and hold on a checkbook name." ) ); | 83 | actionOpen->setWhatsThis( tr( "Select a checkbook and then click here to edit it.\n\nYou also can select Edit from the Checkbook menu, or click and hold on a checkbook name." ) ); |
83 | connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) ); | 84 | connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) ); |
84 | actionOpen->addTo( popup ); | 85 | actionOpen->addTo( popup ); |
85 | actionOpen->addTo( bar ); | 86 | actionOpen->addTo( bar ); |
86 | 87 | ||
87 | actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, | 88 | actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, |
88 | 0, this, 0 ); | 89 | 0, this, 0 ); |
89 | actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) ); | 90 | actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) ); |
90 | connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); | 91 | connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); |
91 | actionDelete->addTo( popup ); | 92 | actionDelete->addTo( popup ); |
92 | actionDelete->addTo( bar ); | 93 | actionDelete->addTo( bar ); |
93 | 94 | ||
94 | popup->insertSeparator(); | 95 | popup->insertSeparator(); |
95 | 96 | ||
96 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); | 97 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); |
97 | a->setWhatsThis( tr( "Click here to configure this app." ) ); | 98 | a->setWhatsThis( tr( "Click here to configure this app." ) ); |
98 | connect( a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) ); | 99 | connect( a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) ); |
99 | a->addTo( popup ); | 100 | a->addTo( popup ); |
100 | a->addTo( bar ); | 101 | a->addTo( bar ); |
101 | 102 | ||
102 | mb->insertItem( tr( "Checkbook" ), popup ); | 103 | mb->insertItem( tr( "Checkbook" ), popup ); |
103 | 104 | ||
104 | // Load Checkbook selection list | 105 | // Load Checkbook selection list |
105 | checkbooks = new CBInfoList(); | 106 | checkbooks = new CBInfoList(); |
106 | 107 | ||
107 | QDir checkdir( cbDir ); | 108 | QDir checkdir( cbDir ); |
108 | if (checkdir.exists() == true) | 109 | if (checkdir.exists() == true) |
109 | { | 110 | { |
110 | QStringList cblist = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable, | 111 | QStringList cblist = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable, |
111 | QDir::Time ); | 112 | QDir::Time ); |
112 | CBInfo *cb = 0x0; | 113 | CBInfo *cb = 0x0; |
113 | QString filename; | 114 | QString filename; |
114 | 115 | ||
115 | for ( QStringList::Iterator it = cblist.begin(); it != cblist.end(); it++ ) | 116 | for ( QStringList::Iterator it = cblist.begin(); it != cblist.end(); it++ ) |
116 | { | 117 | { |
117 | filename = cbDir; | 118 | filename = cbDir; |
118 | filename.append( (*it) ); | 119 | filename.append( (*it) ); |
119 | 120 | ||
120 | cb = new CBInfo( (*it).remove( (*it).find('.'), (*it).length() ), filename ); | 121 | cb = new CBInfo( (*it).remove( (*it).find('.'), (*it).length() ), filename ); |
121 | checkbooks->inSort( cb ); | 122 | checkbooks->inSort( cb ); |
122 | } | 123 | } |
123 | } | 124 | } |
124 | 125 | ||
125 | // Build Checkbook selection list control | 126 | // Build Checkbook selection list control |
126 | cbList = 0x0; | 127 | cbList = 0x0; |
127 | buildList(); | 128 | buildList(); |
129 | |||
130 | // open last book? | ||
131 | if( _cfg.isOpenLastBook() ) { | ||
132 | this->show(); | ||
133 | this->showMaximized(); | ||
134 | QListViewItem *itm=cbList->firstChild(); | ||
135 | while( itm ) { | ||
136 | if( itm->text(posName)==_cfg.getLastBook() ) { | ||
137 | openBook( itm ); | ||
138 | break; | ||
139 | } | ||
140 | itm=itm->nextSibling(); | ||
141 | } | ||
142 | } | ||
128 | } | 143 | } |
129 | 144 | ||
145 | |||
146 | // --- ~MainWindow ------------------------------------------------------------ | ||
130 | MainWindow::~MainWindow() | 147 | MainWindow::~MainWindow() |
131 | { | 148 | { |
132 | //config.write(); | 149 | writeConfig(); |
133 | } | 150 | } |
134 | 151 | ||
152 | |||
153 | // --- buildList -------------------------------------------------------------- | ||
135 | void MainWindow::buildList() | 154 | void MainWindow::buildList() |
136 | { | 155 | { |
137 | if ( cbList ) | 156 | if ( cbList ) |
138 | { | 157 | delete cbList; |
139 | delete cbList; | ||
140 | } | ||
141 | 158 | ||
142 | cbList = new QListView( this ); | 159 | cbList = new QListView( this ); |
143 | QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) ); | 160 | QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) ); |
144 | 161 | ||
145 | if ( showLocks ) | 162 | if ( _cfg.getShowLocks() ) |
146 | { | 163 | { |
147 | cbList->addColumn( Resource::loadIconSet( "locked" ), "", 24 ); | 164 | cbList->addColumn( Resource::loadIconSet( "locked" ), "", 24 ); |
148 | posName = 1; | 165 | posName = 1; |
149 | } | 166 | } |
150 | else | 167 | else |
151 | { | 168 | { |
152 | posName = 0; | 169 | posName = 0; |
153 | } | 170 | } |
154 | cbList->addColumn( tr( "Checkbook Name" ) ); | 171 | cbList->addColumn( tr( "Checkbook Name" ) ); |
155 | if ( showBalances ) | 172 | if ( _cfg.getShowBalances() ) |
156 | { | 173 | { |
157 | int colnum = cbList->addColumn( tr( "Balance" ) ); | 174 | int colnum = cbList->addColumn( tr( "Balance" ) ); |
158 | cbList->setColumnAlignment( colnum, Qt::AlignRight ); | 175 | cbList->setColumnAlignment( colnum, Qt::AlignRight ); |
159 | } | 176 | } |
160 | cbList->setAllColumnsShowFocus( TRUE ); | 177 | cbList->setAllColumnsShowFocus( TRUE ); |
161 | cbList->setSorting( posName ); | 178 | cbList->setSorting( posName ); |
162 | QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); | 179 | QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); |
163 | connect( cbList, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 180 | connect( cbList, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), |
164 | this, SLOT( slotEdit() ) ); | 181 | this, SLOT( slotEdit() ) ); |
165 | setCentralWidget( cbList ); | 182 | setCentralWidget( cbList ); |
166 | 183 | ||
167 | for ( CBInfo *cb = checkbooks->first(); cb; cb = checkbooks->next() ) | 184 | for ( CBInfo *cb = checkbooks->first(); cb; cb = checkbooks->next() ) |
168 | { | 185 | { |
169 | addCheckbook( cb ); | 186 | addCheckbook( cb ); |
170 | } | 187 | } |
171 | } | 188 | } |
172 | 189 | ||
173 | void MainWindow::addCheckbook( CBInfo *cb ) | 190 | void MainWindow::addCheckbook( CBInfo *cb ) |
174 | { | 191 | { |
175 | QListViewItem *lvi = new QListViewItem( cbList ); | 192 | QListViewItem *lvi = new QListViewItem( cbList ); |
176 | if ( showLocks && !cb->password().isNull() ) | 193 | if ( _cfg.getShowLocks() && !cb->password().isNull() ) |
177 | { | 194 | { |
178 | lvi->setPixmap( 0, lockIcon ); | 195 | lvi->setPixmap( 0, lockIcon ); |
179 | } | 196 | } |
180 | lvi->setText( posName, cb->name() ); | 197 | lvi->setText( posName, cb->name() ); |
181 | if ( showBalances ) | 198 | if ( _cfg.getShowBalances() ) |
182 | { | 199 | { |
183 | QString balance; | 200 | QString balance; |
184 | balance.sprintf( "%s%.2f", currencySymbol.latin1(), cb->balance() ); | 201 | balance.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); |
185 | lvi->setText( posName + 1, balance ); | 202 | lvi->setText( posName + 1, balance ); |
186 | } | 203 | } |
187 | } | 204 | } |
188 | 205 | ||
189 | void MainWindow::buildFilename( const QString &name ) | 206 | void MainWindow::buildFilename( const QString &name ) |
190 | { | 207 | { |
191 | tempFilename = cbDir; | 208 | tempFilename = cbDir; |
192 | tempFilename.append( name ); | 209 | tempFilename.append( name ); |
193 | tempFilename.append( ".qcb" ); | 210 | tempFilename.append( ".qcb" ); |
194 | } | 211 | } |
195 | 212 | ||
196 | void MainWindow::slotNew() | 213 | void MainWindow::slotNew() |
197 | { | 214 | { |
198 | CBInfo *cb = new CBInfo(); | 215 | CBInfo *cb = new CBInfo(); |
199 | 216 | ||
200 | Checkbook *currcb = new Checkbook( this, cb, currencySymbol ); | 217 | Checkbook *currcb = new Checkbook( this, cb, &_cfg ); |
201 | currcb->showMaximized(); | 218 | currcb->showMaximized(); |
202 | if ( currcb->exec() == QDialog::Accepted ) | 219 | if ( currcb->exec() == QDialog::Accepted ) |
203 | { | 220 | { |
204 | // Save new checkbook | 221 | // Save new checkbook |
205 | buildFilename( cb->name() ); | 222 | buildFilename( cb->name() ); |
223 | _cfg.setLastBook( cb->name() ); | ||
206 | cb->setFilename( tempFilename ); | 224 | cb->setFilename( tempFilename ); |
207 | cb->write(); | 225 | cb->write(); |
208 | 226 | ||
209 | // Add to listbox | 227 | // Add to listbox |
210 | checkbooks->inSort( cb ); | 228 | checkbooks->inSort( cb ); |
211 | addCheckbook( cb ); | 229 | addCheckbook( cb ); |
212 | } | 230 | } |
213 | delete currcb; | 231 | delete currcb; |
214 | } | 232 | } |
215 | 233 | ||
234 | // --- slotEdit --------------------------------------------------------------- | ||
216 | void MainWindow::slotEdit() | 235 | void MainWindow::slotEdit() |
217 | { | 236 | { |
218 | 237 | // get name and open it | |
219 | QListViewItem *curritem = cbList->currentItem(); | 238 | QListViewItem *curritem = cbList->currentItem(); |
220 | if ( !curritem ) | 239 | if ( !curritem ) |
221 | { | ||
222 | return; | 240 | return; |
223 | } | 241 | openBook( curritem ); |
224 | QString currname = curritem->text( posName ); | 242 | } |
225 | 243 | ||
226 | CBInfo *cb = checkbooks->first(); | 244 | |
227 | while ( cb ) | 245 | // --- openBook --------------------------------------------------------------- |
228 | { | 246 | void MainWindow::openBook(QListViewItem *curritem) |
247 | { | ||
248 | // find book in List | ||
249 | QString currname=curritem->text(posName); | ||
250 | CBInfo *cb = checkbooks->first(); | ||
251 | while ( cb ) { | ||
229 | if ( cb->name() == currname ) | 252 | if ( cb->name() == currname ) |
230 | break; | 253 | break; |
231 | cb = checkbooks->next(); | 254 | cb = checkbooks->next(); |
232 | } | 255 | } |
233 | if ( !cb ) | 256 | if ( !cb ) return; |
234 | { | ||
235 | return; | ||
236 | } | ||
237 | 257 | ||
258 | // | ||
238 | buildFilename( currname ); | 259 | buildFilename( currname ); |
239 | float currbalance = cb->balance(); | 260 | float currbalance = cb->balance(); |
240 | bool currlock = !cb->password().isNull(); | 261 | bool currlock = !cb->password().isNull(); |
241 | 262 | ||
242 | if ( currlock ) | 263 | if ( currlock ) |
243 | { | 264 | { |
244 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); | 265 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); |
245 | if ( pw->exec() != QDialog::Accepted || pw->password != cb->password() ) | 266 | if ( pw->exec() != QDialog::Accepted || pw->password != cb->password() ) |
246 | { | 267 | { |
247 | delete pw; | 268 | delete pw; |
248 | return; | 269 | return; |
249 | } | 270 | } |
250 | delete pw; | 271 | delete pw; |
251 | } | 272 | } |
252 | 273 | ||
253 | Checkbook *currcb = new Checkbook( this, cb, currencySymbol ); | 274 | _cfg.setLastBook( currname ); |
275 | Checkbook *currcb = new Checkbook( this, cb, &_cfg ); | ||
254 | currcb->showMaximized(); | 276 | currcb->showMaximized(); |
255 | if ( currcb->exec() == QDialog::Accepted ) | 277 | if ( currcb->exec() == QDialog::Accepted ) |
256 | { | 278 | { |
257 | QString newname = cb->name(); | 279 | QString newname = cb->name(); |
258 | if ( currname != newname ) | 280 | if ( currname != newname ) |
259 | { | 281 | { |
260 | // Update name if changed | 282 | // Update name if changed |
261 | curritem->setText( posName, newname ); | 283 | if( curritem ) { |
262 | cbList->sort(); | 284 | curritem->setText( posName, newname ); |
285 | cbList->sort(); | ||
286 | } | ||
287 | _cfg.setLastBook( newname ); | ||
263 | 288 | ||
264 | // Remove old file | 289 | // Remove old file |
265 | QFile f( tempFilename ); | 290 | QFile f( tempFilename ); |
266 | if ( f.exists() ) | 291 | if ( f.exists() ) |
267 | { | ||
268 | f.remove(); | 292 | f.remove(); |
269 | } | ||
270 | 293 | ||
271 | // Get new filename | 294 | // Get new filename |
272 | buildFilename( newname ); | 295 | buildFilename( newname ); |
273 | cb->setFilename( tempFilename ); | 296 | cb->setFilename( tempFilename ); |
274 | } | 297 | } |
275 | 298 | ||
276 | cb->write(); | 299 | cb->write(); |
277 | 300 | ||
278 | // Update lock if changed | 301 | // Update lock if changed |
279 | if ( showLocks && !cb->password().isNull() != currlock ) | 302 | if ( _cfg.getShowLocks() && !cb->password().isNull() != currlock ) |
280 | { | 303 | { |
281 | if ( !cb->password().isNull() ) | 304 | if ( !cb->password().isNull() ) |
282 | curritem->setPixmap( 0, lockIcon ); | 305 | curritem->setPixmap( 0, lockIcon ); |
283 | else | 306 | else |
284 | curritem->setPixmap( 0, nullIcon ); | 307 | curritem->setPixmap( 0, nullIcon ); |
285 | } | 308 | } |
286 | 309 | ||
287 | // Update balance if changed | 310 | // Update balance if changed |
288 | if ( showBalances && cb->balance() != currbalance ) | 311 | if ( _cfg.getShowBalances() && cb->balance() != currbalance ) |
289 | { | 312 | { |
290 | QString tempstr; | 313 | QString tempstr; |
291 | tempstr.sprintf( "%s%.2f", currencySymbol.latin1(), cb->balance() ); | 314 | tempstr.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); |
292 | curritem->setText( posName + 1, tempstr ); | 315 | curritem->setText( posName + 1, tempstr ); |
293 | } | 316 | } |
294 | } | 317 | } |
295 | delete currcb; | 318 | delete currcb; |
296 | } | 319 | } |
297 | 320 | ||
321 | // --- slotDelete ------------------------------------------------------------- | ||
298 | void MainWindow::slotDelete() | 322 | void MainWindow::slotDelete() |
299 | { | 323 | { |
300 | QString currname = cbList->currentItem()->text( posName ); | 324 | QString currname = cbList->currentItem()->text( posName ); |
301 | 325 | ||
302 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), currname ) ) | 326 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), currname ) ) |
303 | { | 327 | { |
304 | buildFilename( currname ); | 328 | buildFilename( currname ); |
305 | QFile f( tempFilename ); | 329 | QFile f( tempFilename ); |
306 | if ( f.exists() ) | 330 | if ( f.exists() ) |
307 | { | 331 | { |
308 | f.remove(); | 332 | f.remove(); |
309 | } | 333 | } |
310 | 334 | ||
311 | delete cbList->currentItem(); | 335 | delete cbList->currentItem(); |
312 | } | 336 | } |
313 | } | 337 | } |
314 | 338 | ||
339 | // --- slotConfigure ---------------------------------------------------------- | ||
315 | void MainWindow::slotConfigure() | 340 | void MainWindow::slotConfigure() |
316 | { | 341 | { |
317 | Configuration *cfgdlg = new Configuration( this, currencySymbol, showLocks, showBalances ); | 342 | Configuration *cfgdlg = new Configuration( this, _cfg ); |
318 | cfgdlg->showMaximized(); | 343 | cfgdlg->showMaximized(); |
319 | if ( cfgdlg->exec() == QDialog::Accepted ) | 344 | if ( cfgdlg->exec() == QDialog::Accepted ) |
320 | { | 345 | { |
321 | currencySymbol = cfgdlg->symbolEdit->text(); | 346 | // read data from config dialog & save it |
322 | showLocks = cfgdlg->lockCB->isChecked(); | 347 | cfgdlg->saveConfig( _cfg ); |
323 | showBalances = cfgdlg->balCB->isChecked(); | 348 | writeConfig(); |
324 | |||
325 | Config config( "checkbook" ); | ||
326 | config.setGroup( "Config" ); | ||
327 | config.writeEntry( "CurrencySymbol", currencySymbol ); | ||
328 | config.writeEntry( "ShowLocks", showLocks ); | ||
329 | config.writeEntry( "ShowBalances", showBalances ); | ||
330 | config.write(); | ||
331 | |||
332 | buildList(); | 349 | buildList(); |
333 | } | 350 | } |
334 | delete cfgdlg; | 351 | delete cfgdlg; |
335 | } | 352 | } |
353 | |||
354 | |||
355 | // --- writeConfig -------------------------------------------------------------- | ||
356 | void MainWindow::writeConfig() | ||
357 | { | ||
358 | Config config("checkbook"); | ||
359 | _cfg.writeConfig( config ); | ||
360 | } | ||
diff --git a/noncore/apps/checkbook/mainwindow.h b/noncore/apps/checkbook/mainwindow.h index 2bc70b3..6275f94 100644 --- a/noncore/apps/checkbook/mainwindow.h +++ b/noncore/apps/checkbook/mainwindow.h | |||
@@ -1,76 +1,83 @@ | |||
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 | #ifndef MAINWINDOW_H | 29 | #ifndef MAINWINDOW_H |
30 | #define MAINWINDOW_H | 30 | #define MAINWINDOW_H |
31 | 31 | ||
32 | #include <qmainwindow.h> | 32 | #include <qmainwindow.h> |
33 | #include <qpixmap.h> | 33 | #include <qpixmap.h> |
34 | #include "cfg.h" | ||
34 | 35 | ||
35 | class CBInfo; | 36 | class CBInfo; |
36 | class CBInfoList; | 37 | class CBInfoList; |
37 | class QAction; | 38 | class QAction; |
38 | class QListView; | 39 | class QListView; |
39 | class QString; | 40 | class QString; |
41 | class QListViewItem; | ||
40 | 42 | ||
41 | class MainWindow : public QMainWindow | 43 | class MainWindow : public QMainWindow |
42 | { | 44 | { |
43 | Q_OBJECT | 45 | Q_OBJECT |
44 | 46 | ||
45 | public: | 47 | public: |
46 | MainWindow(); | 48 | MainWindow(QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
47 | ~MainWindow(); | 49 | ~MainWindow(); |
50 | static QString appName() { return QString::fromLatin1("checkbook"); }; | ||
51 | |||
52 | // safe config | ||
53 | void writeConfig(); | ||
54 | |||
55 | // open a check book | ||
56 | void openBook(QListViewItem *curr); | ||
48 | 57 | ||
49 | private: | 58 | private: |
50 | QListView *cbList; | 59 | QListView *cbList; |
51 | QString cbDir; | 60 | QString cbDir; |
52 | QAction *actionOpen; | 61 | QAction *actionOpen; |
53 | QAction *actionDelete; | 62 | QAction *actionDelete; |
54 | 63 | ||
55 | QString currencySymbol; | 64 | Cfg _cfg; |
56 | bool showLocks; | ||
57 | bool showBalances; | ||
58 | int posName; | 65 | int posName; |
59 | 66 | ||
60 | CBInfoList *checkbooks; | 67 | CBInfoList *checkbooks; |
61 | QString tempFilename; | 68 | QString tempFilename; |
62 | QPixmap lockIcon; | 69 | QPixmap lockIcon; |
63 | QPixmap nullIcon; | 70 | QPixmap nullIcon; |
64 | 71 | ||
65 | void buildList(); | 72 | void buildList(); |
66 | void addCheckbook( CBInfo * ); | 73 | void addCheckbook( CBInfo * ); |
67 | void buildFilename( const QString & ); | 74 | void buildFilename( const QString & ); |
68 | 75 | ||
69 | private slots: | 76 | private slots: |
70 | void slotNew(); | 77 | void slotNew(); |
71 | void slotEdit(); | 78 | void slotEdit(); |
72 | void slotDelete(); | 79 | void slotDelete(); |
73 | void slotConfigure(); | 80 | void slotConfigure(); |
74 | }; | 81 | }; |
75 | 82 | ||
76 | #endif | 83 | #endif |
diff --git a/noncore/apps/checkbook/tabledef.cpp b/noncore/apps/checkbook/tabledef.cpp new file mode 100644 index 0000000..13edded --- a/dev/null +++ b/noncore/apps/checkbook/tabledef.cpp | |||
@@ -0,0 +1,76 @@ | |||
1 | /* | ||
2 | This file is part of the OPIE Project | ||
3 | =. | ||
4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This file is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
11 | ._= =} : or (at your option) any later version. | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This file is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | ||
18 | ..}^=.= = ; Public License for more details. | ||
19 | ++= -. .` .: | ||
20 | : = ...= . :.=- You should have received a copy of the GNU | ||
21 | -. .:....=;==+<; General Public License along with this file; | ||
22 | -_. . . )=. = see the file COPYING. If not, write to the | ||
23 | -- :-=` Free Software Foundation, Inc., | ||
24 | 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #include "tabledef.h" | ||
30 | |||
31 | #include <qstring.h> | ||
32 | #include <qpe/resource.h> | ||
33 | |||
34 | // --- ColumnDef -------------------------------------------------------------- | ||
35 | ColumnDef::ColumnDef(const char *sName, ColumnType type, const char *sNewValue) | ||
36 | { | ||
37 | _sName=sName; | ||
38 | _type=type; | ||
39 | _sNewValue=sNewValue; | ||
40 | } | ||
41 | |||
42 | |||
43 | // --- addColumnValue --------------------------------------------------------- | ||
44 | void ColumnDef::addColumnValue(const QString &sValue) | ||
45 | { | ||
46 | if( (_type & 0x00ffffff) !=typeList ) | ||
47 | qDebug("Column %s is not a list", (const char *)_sName); | ||
48 | else | ||
49 | _valueList.append(sValue); | ||
50 | } | ||
51 | void ColumnDef::addColumnValue(const char *sValue) | ||
52 | { | ||
53 | if( (_type & 0x00ffffff)!=typeList ) | ||
54 | qDebug("Column %s is not a list", (const char *)_sName); | ||
55 | else | ||
56 | _valueList.append(sValue); | ||
57 | } | ||
58 | |||
59 | // --- TableDef --------------------------------------------------------------- | ||
60 | TableDef::TableDef(const char *sName) | ||
61 | { | ||
62 | _sName=sName; | ||
63 | _vColumns.setAutoDelete(TRUE); | ||
64 | } | ||
65 | |||
66 | |||
67 | // --- ~TableDef -------------------------------------------------------------- | ||
68 | TableDef::~TableDef() | ||
69 | { | ||
70 | } | ||
71 | |||
72 | // --- addColumnDef ----------------------------------------------------------- | ||
73 | void TableDef::addColumnDef(ColumnDef *pDef) | ||
74 | { | ||
75 | _vColumns.append(pDef); | ||
76 | } | ||
diff --git a/noncore/apps/checkbook/tabledef.h b/noncore/apps/checkbook/tabledef.h new file mode 100644 index 0000000..5891ad7 --- a/dev/null +++ b/noncore/apps/checkbook/tabledef.h | |||
@@ -0,0 +1,99 @@ | |||
1 | /* | ||
2 | This file is part of the OPIE Project | ||
3 | =. | ||
4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This file is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
11 | ._= =} : or (at your option) any later version. | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This file is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | ||
18 | ..}^=.= = ; Public License for more details. | ||
19 | ++= -. .` .: | ||
20 | : = ...= . :.=- You should have received a copy of the GNU | ||
21 | -. .:....=;==+<; General Public License along with this file; | ||
22 | -_. . . )=. = see the file COPYING. If not, write to the | ||
23 | -- :-=` Free Software Foundation, Inc., | ||
24 | 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #ifndef TABLEDEF_H | ||
30 | #define TABLEDEF_H | ||
31 | |||
32 | #include <qstring.h> | ||
33 | #include <qstringlist.h> | ||
34 | #include <qlist.h> | ||
35 | |||
36 | |||
37 | |||
38 | // --- ColumnDef ------------------------------------------------------------- | ||
39 | class ColumnDef | ||
40 | { | ||
41 | public: | ||
42 | enum ColumnType { | ||
43 | typeString=0x1, | ||
44 | typeList=0x2, | ||
45 | typeUnique=0x80000000 | ||
46 | }; | ||
47 | |||
48 | // Constructor | ||
49 | ColumnDef(const char *sName, ColumnType type, const char *sNewValue); | ||
50 | |||
51 | // add column value | ||
52 | void addColumnValue(const QString &Value); | ||
53 | void addColumnValue(const char *sValue); | ||
54 | |||
55 | // member functions | ||
56 | const QString getName() { return(_sName); } | ||
57 | const QString getNewValue() { return(_sNewValue); } | ||
58 | |||
59 | // test for type | ||
60 | int isType(ColumnType x) { return( (_type & 0x00ffffff)==x ); } | ||
61 | int hasFlag(ColumnType x) { return( (_type & x) ); } | ||
62 | |||
63 | // get value list | ||
64 | QStringList &getValueList() { return(_valueList); } | ||
65 | |||
66 | private: | ||
67 | QString _sName; | ||
68 | QString _sNewValue; | ||
69 | enum ColumnType _type; | ||
70 | QStringList _valueList; | ||
71 | }; | ||
72 | |||
73 | typedef QList<ColumnDef> ColumnDefList; | ||
74 | |||
75 | |||
76 | // --- TableDef --------------------------------------------------------------- | ||
77 | class TableDef | ||
78 | { | ||
79 | public: | ||
80 | // Constructor & Destructor | ||
81 | TableDef(const char *sName); | ||
82 | virtual ~TableDef(); | ||
83 | |||
84 | // adds a column definition | ||
85 | virtual void addColumnDef(ColumnDef *pDef); | ||
86 | |||
87 | // movement operators | ||
88 | ColumnDef *first() { return(_vColumns.first() ); } | ||
89 | ColumnDef *last() { return(_vColumns.last() ); } | ||
90 | ColumnDef *next() { return(_vColumns.next() ); } | ||
91 | ColumnDef *prev() { return(_vColumns.prev() ); } | ||
92 | ColumnDef *at(int i) { return(_vColumns.at(i)); } | ||
93 | |||
94 | protected: | ||
95 | QString _sName; | ||
96 | ColumnDefList _vColumns; | ||
97 | }; | ||
98 | |||
99 | #endif | ||
diff --git a/noncore/apps/checkbook/traninfo.cpp b/noncore/apps/checkbook/traninfo.cpp index 65c190c..d880bb4 100644 --- a/noncore/apps/checkbook/traninfo.cpp +++ b/noncore/apps/checkbook/traninfo.cpp | |||
@@ -1,190 +1,212 @@ | |||
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 | 32 | ||
33 | QString tempstr; | 33 | QString tempstr; |
34 | 34 | ||
35 | TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal, | 35 | TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal, |
36 | const QString &type, const QString &category, float amount, | 36 | const QString &type, const QString &category, float amount, |
37 | float fee, const QString &number, const QString ¬es ) | 37 | float fee, const QString &number, const QString ¬es, int next ) |
38 | { | 38 | { |
39 | i = id; | 39 | i = id; |
40 | d = desc; | 40 | d = desc; |
41 | td = date; | 41 | td = date; |
42 | w = withdrawal; | 42 | w = withdrawal; |
43 | t = type; | 43 | t = type; |
44 | c = category; | 44 | c = category; |
45 | a = amount; | 45 | a = amount; |
46 | f = fee; | 46 | f = fee; |
47 | cn = number; | 47 | cn = number; |
48 | n = notes; | 48 | n = notes; |
49 | _next=next; | ||
49 | } | 50 | } |
50 | 51 | ||
51 | TranInfo::TranInfo( Config config, int entry ) | 52 | TranInfo::TranInfo( Config config, int entry ) |
52 | { | 53 | { |
53 | config.setGroup( QString::number( entry ) ); | 54 | config.setGroup( QString::number( entry ) ); |
54 | QString desc = config.readEntry( "Description", "Not Found" ); | 55 | QString desc = config.readEntry( "Description", "Not Found" ); |
55 | if ( desc != "Not Found" ) | 56 | if ( desc != "Not Found" ) |
56 | { | 57 | { |
57 | // ID | 58 | // ID |
58 | i = entry; | 59 | i = entry; |
59 | 60 | ||
60 | // Description | 61 | // Description |
61 | d = desc; | 62 | d = desc; |
62 | 63 | ||
63 | // Transaction date | 64 | // Transaction date |
64 | int yr, mn, dy; | 65 | int yr, mn, dy; |
65 | QString datestr = config.readEntry( "Date", "" ); | 66 | QString datestr = config.readEntry( "Date", "" ); |
66 | int begin, end; | 67 | int begin, end; |
67 | begin = datestr.find( '/' ); | 68 | begin = datestr.find( '/' ); |
68 | mn = datestr.left( begin ).toInt(); | 69 | mn = datestr.left( begin ).toInt(); |
69 | end = datestr.find( '/', ++begin ); | 70 | end = datestr.find( '/', ++begin ); |
70 | dy = datestr.mid( begin, end - begin ).toInt(); | 71 | dy = datestr.mid( begin, end - begin ).toInt(); |
71 | yr = datestr.right( datestr.length() - end - 1).toInt(); | 72 | yr = datestr.right( datestr.length() - end - 1).toInt(); |
72 | td.setYMD( yr, mn, dy ); | 73 | td.setYMD( yr, mn, dy ); |
73 | 74 | ||
74 | // Deposit/withdrawal indicator ( withdrawal == TRUE ) | 75 | // Deposit/withdrawal indicator ( withdrawal == TRUE ) |
75 | w = ( config.readEntry( "Payment", "false" ) == "true" ); | 76 | w = ( config.readEntry( "Payment", "false" ) == "true" ); |
76 | 77 | ||
77 | // Type | 78 | // Type |
78 | QString type = config.readEntry( "Type", "0" ); | 79 | QString type = config.readEntry( "Type", "0" ); |
79 | if ( w ) | 80 | if ( w ) |
80 | { // Withdrawal types | 81 | { // Withdrawal types |
81 | if( type == "0" ) | 82 | if( type == "0" ) |
82 | t = "Debit Charge"; | 83 | t = "Debit Charge"; |
83 | else if( type == "1" ) | 84 | else if( type == "1" ) |
84 | t = "Written Check"; | 85 | t = "Written Check"; |
85 | else if( type == "2" ) | 86 | else if( type == "2" ) |
86 | t = "Transfer"; | 87 | t = "Transfer"; |
87 | else if( type == "3" ) | 88 | else if( type == "3" ) |
88 | t = "Credit Card"; | 89 | t = "Credit Card"; |
89 | } | 90 | } |
90 | else | 91 | else |
91 | { | 92 | { |
92 | if( type == "0" ) | 93 | if( type == "0" ) |
93 | t = "Written Check"; | 94 | t = "Written Check"; |
94 | else if( type == "1" ) | 95 | else if( type == "1" ) |
95 | t = "Automatic Payment"; | 96 | t = "Automatic Payment"; |
96 | else if( type == "2" ) | 97 | else if( type == "2" ) |
97 | t = "Transfer"; | 98 | t = "Transfer"; |
98 | else if( type == "3" ) | 99 | else if( type == "3" ) |
99 | t = "Cash"; | 100 | t = "Cash"; |
100 | } | 101 | } |
101 | 102 | ||
102 | // Category | 103 | // Category |
103 | c = config.readEntry( "Category", "" ); | 104 | c = config.readEntry( "Category", "" ); |
104 | 105 | ||
105 | // Transaction amount | 106 | // Transaction amount |
106 | QString stramount = config.readEntry( "Amount", "0.00" ); | 107 | QString stramount = config.readEntry( "Amount", "0.00" ); |
107 | bool ok; | 108 | bool ok; |
108 | a = stramount.toFloat( &ok ); | 109 | a = stramount.toFloat( &ok ); |
109 | 110 | ||
110 | // Transaction fee | 111 | // Transaction fee |
111 | stramount = config.readEntry( "TransactionFee", "0.00" ); | 112 | stramount = config.readEntry( "TransactionFee", "0.00" ); |
112 | f = stramount.toFloat( &ok ); | 113 | f = stramount.toFloat( &ok ); |
113 | 114 | ||
114 | // Transaction number | 115 | // Transaction number |
115 | cn = config.readEntry( "CheckNumber", "" ); | 116 | cn = config.readEntry( "CheckNumber", "" ); |
116 | 117 | ||
117 | // Notes | 118 | // Notes |
118 | n = config.readEntry( "Comments", "" ); | 119 | n = config.readEntry( "Comments", "" ); |
120 | |||
121 | // next | ||
122 | _next = config.readNumEntry("Next", -1); | ||
119 | } | 123 | } |
120 | } | 124 | } |
121 | 125 | ||
126 | // --- datestr ---------------------------------------------------------------- | ||
122 | const QString &TranInfo::datestr() | 127 | const QString &TranInfo::datestr() |
123 | { | 128 | { |
124 | tempstr = QString::number( td.year() ); | 129 | int y=td.year(); |
125 | tempstr.append( '/' ); | 130 | y= y>=2000 && y<=2099 ? y-2000 : y; |
126 | int tempfield = td.month(); | 131 | tempstr.sprintf( "%02d/%02d/%02d", y ,td.month(), td.day() ); |
127 | if ( tempfield < 10 ) tempstr.append( '0' ); | 132 | return( tempstr ); |
128 | tempstr.append( QString::number( tempfield ) ); | 133 | } |
129 | tempstr.append( '/' ); | ||
130 | tempfield = td.day(); | ||
131 | if ( tempfield < 10 ) tempstr.append( '0' ); | ||
132 | tempstr.append( QString::number( tempfield ) ); | ||
133 | 134 | ||
134 | return( tempstr ); | 135 | // --- getIdStr --------------------------------------------------------------- |
136 | const QString &TranInfo::getIdStr() | ||
137 | { | ||
138 | tempstr.sprintf("%04d", i); | ||
139 | return( tempstr ); | ||
135 | } | 140 | } |
136 | 141 | ||
137 | void TranInfo::write( Config *config, int entry ) | 142 | // --- write ------------------------------------------------------------------ |
143 | void TranInfo::write( Config *config ) | ||
138 | { | 144 | { |
139 | config->setGroup( QString::number( entry ) ); | 145 | config->setGroup( QString::number( id() ) ); |
140 | 146 | ||
141 | config->writeEntry( "Description", d ); | 147 | config->writeEntry( "Description", d ); |
142 | 148 | ||
143 | tempstr = QString::number( td.month() ); | 149 | tempstr = QString::number( td.month() ); |
144 | tempstr.append( '/' ); | 150 | tempstr.append( '/' ); |
145 | tempstr.append( QString::number( td.day() ) ); | 151 | tempstr.append( QString::number( td.day() ) ); |
146 | tempstr.append( '/' ); | 152 | tempstr.append( '/' ); |
147 | tempstr.append( QString::number( td.year() ) ); | 153 | tempstr.append( QString::number( td.year() ) ); |
148 | config->writeEntry( "Date", tempstr ); | 154 | config->writeEntry( "Date", tempstr ); |
149 | 155 | ||
150 | w ? tempstr = "true" | 156 | w ? tempstr = "true" |
151 | : tempstr = "false"; | 157 | : tempstr = "false"; |
152 | config->writeEntry( "Payment", tempstr ); | 158 | config->writeEntry( "Payment", tempstr ); |
153 | 159 | ||
154 | if ( t == "Debit Charge" || t == "Written Check" ) | 160 | if ( t == "Debit Charge" || t == "Written Check" ) |
155 | tempstr = "0"; | 161 | tempstr = "0"; |
156 | else if ( t == "Written Check" || t == "Automatic Payment" ) | 162 | else if ( t == "Written Check" || t == "Automatic Payment" ) |
157 | tempstr = "1"; | 163 | tempstr = "1"; |
158 | else if ( t == "Transfer" ) | 164 | else if ( t == "Transfer" ) |
159 | tempstr = "2"; | 165 | tempstr = "2"; |
160 | else if ( t == "Credit Card" || t == "Cash" ) | 166 | else if ( t == "Credit Card" || t == "Cash" ) |
161 | tempstr = "3"; | 167 | tempstr = "3"; |
162 | config->writeEntry( "Type", tempstr ); | 168 | config->writeEntry( "Type", tempstr ); |
163 | 169 | ||
164 | config->writeEntry( "Category", c ); | 170 | config->writeEntry( "Category", c ); |
165 | 171 | ||
166 | tempstr.setNum( a, 'f', 2 ); | 172 | tempstr.setNum( a, 'f', 2 ); |
167 | config->writeEntry( "Amount", tempstr ); | 173 | config->writeEntry( "Amount", tempstr ); |
168 | 174 | ||
169 | tempstr.setNum( f, 'f', 2 ); | 175 | tempstr.setNum( f, 'f', 2 ); |
170 | config->writeEntry( "TransactionFee", tempstr ); | 176 | config->writeEntry( "TransactionFee", tempstr ); |
171 | 177 | ||
172 | config->writeEntry( "CheckNumber", cn ); | 178 | config->writeEntry( "CheckNumber", cn ); |
173 | |||
174 | config->writeEntry( "Comments", n ); | 179 | config->writeEntry( "Comments", n ); |
180 | config->writeEntry( "Next", _next ); | ||
175 | } | 181 | } |
176 | 182 | ||
183 | |||
177 | int TranInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 ) | 184 | int TranInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 ) |
178 | { | 185 | { |
179 | QDate d1 = ((TranInfo *)item1)->date(); | 186 | QDate d1 = ((TranInfo *)item1)->date(); |
180 | QDate d2 = ((TranInfo *)item2)->date(); | 187 | QDate d2 = ((TranInfo *)item2)->date(); |
181 | int r = -1; | 188 | int r = -1; |
182 | 189 | ||
183 | if ( d1 < d2 ) | 190 | if ( d1 < d2 ) |
184 | r = -1; | 191 | r = -1; |
185 | else if ( d1 == d2 ) | 192 | else if ( d1 == d2 ) |
186 | r = 0; | 193 | r = 0; |
187 | else if ( d1 > d2 ) | 194 | else if ( d1 > d2 ) |
188 | r = 1; | 195 | r = 1; |
189 | return( r ); | 196 | return( r ); |
190 | } | 197 | } |
198 | |||
199 | // --- toString --------------------------------------------------------------- | ||
200 | QString TranInfo::toString() | ||
201 | { | ||
202 | QString ret; | ||
203 | ret.sprintf("(%4d) %10s %4s %-10s %5.2f %5.2f", | ||
204 | id(), | ||
205 | (const char *)datestr(), | ||
206 | (const char *)number(), | ||
207 | (const char *)desc(), | ||
208 | (withdrawal() ? -1 : 1) * amount(), | ||
209 | fee() | ||
210 | ); | ||
211 | return(ret); | ||
212 | } | ||
diff --git a/noncore/apps/checkbook/traninfo.h b/noncore/apps/checkbook/traninfo.h index f6c5cae..0abdc61 100644 --- a/noncore/apps/checkbook/traninfo.h +++ b/noncore/apps/checkbook/traninfo.h | |||
@@ -1,89 +1,100 @@ | |||
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 | #ifndef TRANINFO_H | 29 | #ifndef TRANINFO_H |
30 | #define TRANINFO_H | 30 | #define TRANINFO_H |
31 | 31 | ||
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qlist.h> | 33 | #include <qlist.h> |
34 | 34 | ||
35 | class Config; | 35 | class Config; |
36 | 36 | ||
37 | class TranInfo | 37 | class TranInfo |
38 | { | 38 | { |
39 | public: | 39 | public: |
40 | TranInfo( int = 0, const QString & = 0x0, const QDate & = QDate::currentDate(), | 40 | TranInfo( int = 0, const QString & = 0x0, const QDate & = QDate::currentDate(), |
41 | bool = TRUE, const QString & = 0x0, const QString & = 0x0, | 41 | bool = TRUE, const QString & = 0x0, const QString & = 0x0, |
42 | float = 0.0, float = 0.0, | 42 | float = 0.0, float = 0.0, |
43 | const QString & = 0x0, const QString & = 0x0 ); | 43 | const QString & = 0x0, const QString & = 0x0, int =-1 ); |
44 | TranInfo( Config, int ); | 44 | TranInfo( Config, int ); |
45 | 45 | ||
46 | // getters | ||
46 | int id() const { return i; } | 47 | int id() const { return i; } |
48 | const QString &getIdStr(); | ||
49 | |||
47 | const QString &desc() const { return d; } | 50 | const QString &desc() const { return d; } |
48 | const QDate &date() const { return td; } | 51 | const QDate &date() const { return td; } |
49 | const QString &datestr(); | 52 | const QString &datestr(); |
50 | bool withdrawal()const { return w; } | 53 | bool withdrawal()const { return w; } |
51 | const QString &type() const { return t; } | 54 | const QString &type() const { return t; } |
52 | const QString &category()const { return c; } | 55 | const QString &category()const { return c; } |
53 | float amount() const { return a; } | 56 | float amount() const { return a; } |
54 | float fee() const { return f; } | 57 | float fee() const { return f; } |
55 | const QString &number()const { return cn; } | 58 | const QString &number()const { return cn; } |
56 | const QString ¬es() const { return n; } | 59 | const QString ¬es() const { return n; } |
60 | int getNext() { return(_next); } | ||
57 | 61 | ||
58 | void setDesc( const QString &desc ) { d = desc; } | 62 | // setters |
63 | void setDesc( const QString &desc ) { d = desc; } | ||
59 | void setDate( const QDate &date ) { td = date; } | 64 | void setDate( const QDate &date ) { td = date; } |
60 | void setWithdrawal( bool withdrawal ) { w = withdrawal; } | 65 | void setWithdrawal( bool withdrawal ) { w = withdrawal; } |
61 | void setType( const QString &type ) { t = type; } | 66 | void setType( const QString &type ) { t = type; } |
62 | void setCategory( const QString &cat ){ c = cat; } | 67 | void setCategory( const QString &cat ){ c = cat; } |
63 | void setAmount( float amount ) { a = amount; } | 68 | void setAmount( float amount ) { a = amount; } |
64 | void setFee( float fee ) { f = fee; } | 69 | void setFee( float fee ) { f = fee; } |
65 | void setNumber( const QString &num ) { cn = num; } | 70 | void setNumber( const QString &num ) { cn = num; } |
66 | void setNotes( const QString ¬es ) { n = notes; } | 71 | void setNotes( const QString ¬es ) { n = notes; } |
72 | void setNext(int next) { _next=next; } | ||
73 | |||
74 | // write | ||
75 | void write( Config * ); | ||
67 | 76 | ||
68 | void write( Config *, int ); | 77 | // toString |
78 | QString toString(); | ||
69 | 79 | ||
70 | private: | 80 | private: |
71 | int i; | 81 | int i; |
72 | QString d; | 82 | QString d; |
73 | QDate td; | 83 | QDate td; |
74 | bool w; | 84 | bool w; |
75 | QString t; | 85 | QString t; |
76 | QString c; | 86 | QString c; |
77 | float a; | 87 | float a; |
78 | float f; | 88 | float f; |
79 | QString cn; | 89 | QString cn; |
80 | QString n; | 90 | QString n; |
91 | int _next; | ||
81 | }; | 92 | }; |
82 | 93 | ||
83 | class TranInfoList : public QList<TranInfo> | 94 | class TranInfoList : public QList<TranInfo> |
84 | { | 95 | { |
85 | protected: | 96 | protected: |
86 | int compareItems( QCollection::Item, QCollection::Item ); | 97 | int compareItems( QCollection::Item, QCollection::Item ); |
87 | }; | 98 | }; |
88 | 99 | ||
89 | #endif | 100 | #endif |
diff --git a/noncore/apps/checkbook/transaction.cpp b/noncore/apps/checkbook/transaction.cpp index c94b989..138d0e6 100644 --- a/noncore/apps/checkbook/transaction.cpp +++ b/noncore/apps/checkbook/transaction.cpp | |||
@@ -1,274 +1,270 @@ | |||
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 "transaction.h" | 29 | #include "transaction.h" |
30 | #include "traninfo.h" | 30 | #include "traninfo.h" |
31 | #include "cfg.h" | ||
31 | 32 | ||
32 | #include <qpe/datebookmonth.h> | 33 | #include <qpe/datebookmonth.h> |
33 | 34 | ||
34 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
35 | #include <qcombobox.h> | 36 | #include <qcombobox.h> |
36 | #include <qlabel.h> | 37 | #include <qlabel.h> |
37 | #include <qlayout.h> | 38 | #include <qlayout.h> |
38 | #include <qlineedit.h> | 39 | #include <qlineedit.h> |
39 | #include <qmultilineedit.h> | 40 | #include <qmultilineedit.h> |
40 | #include <qradiobutton.h> | 41 | #include <qradiobutton.h> |
41 | #include <qwhatsthis.h> | 42 | #include <qwhatsthis.h> |
42 | 43 | ||
43 | Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info, | 44 | Transaction::Transaction( QWidget *parent, const QString &acctname, TranInfo *info, |
44 | const QString &symbol ) | 45 | Cfg *pCfg ) |
45 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) | 46 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) |
46 | { | 47 | { |
47 | QString tempstr = tr( "Transaction for " ); | 48 | QString tempstr = tr( "Transaction for " ); |
48 | tempstr.append( acctname ); | 49 | tempstr.append( acctname ); |
49 | setCaption( tempstr ); | 50 | setCaption( tempstr ); |
50 | 51 | ||
51 | tran = info; | 52 | tran = info; |
52 | currencySymbol = symbol; | 53 | _pCfg=pCfg; |
53 | 54 | ||
54 | QVBoxLayout *vb = new QVBoxLayout( this ); | 55 | QVBoxLayout *vb = new QVBoxLayout( this ); |
55 | 56 | ||
56 | QScrollView *sv = new QScrollView( this ); | 57 | QScrollView *sv = new QScrollView( this ); |
57 | vb->addWidget( sv, 0, 0 ); | 58 | vb->addWidget( sv, 0, 0 ); |
58 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 59 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
59 | sv->setFrameStyle( QFrame::NoFrame ); | 60 | sv->setFrameStyle( QFrame::NoFrame ); |
60 | 61 | ||
61 | QWidget *container = new QWidget( sv->viewport() ); | 62 | QWidget *container = new QWidget( sv->viewport() ); |
62 | sv->addChild( container ); | 63 | sv->addChild( container ); |
63 | 64 | ||
64 | QGridLayout *layout = new QGridLayout( container ); | 65 | QGridLayout *layout = new QGridLayout( container ); |
65 | layout->setSpacing( 2 ); | 66 | layout->setSpacing( 2 ); |
66 | layout->setMargin( 4 ); | 67 | layout->setMargin( 4 ); |
67 | 68 | ||
68 | // Withdrawal/Deposit | 69 | // Withdrawal/Deposit |
69 | QButtonGroup *btngrp = new QButtonGroup( container ); | 70 | QButtonGroup *btngrp = new QButtonGroup( container ); |
70 | btngrp->setColumnLayout(0, Qt::Vertical ); | 71 | btngrp->setColumnLayout(0, Qt::Vertical ); |
71 | btngrp->layout()->setSpacing( 0 ); | 72 | btngrp->layout()->setSpacing( 0 ); |
72 | btngrp->layout()->setMargin( 0 ); | 73 | btngrp->layout()->setMargin( 0 ); |
73 | btngrp->setMaximumWidth( 220 ); | 74 | btngrp->setMaximumWidth( 220 ); |
74 | QGridLayout *layout2 = new QGridLayout( btngrp->layout() ); | 75 | QGridLayout *layout2 = new QGridLayout( btngrp->layout() ); |
75 | layout2->setSpacing( 2 ); | 76 | layout2->setSpacing( 2 ); |
76 | layout2->setMargin( 2 ); | 77 | layout2->setMargin( 2 ); |
77 | withBtn = new QRadioButton( tr( "Withdrawal" ), btngrp ); | 78 | withBtn = new QRadioButton( tr( "Withdrawal" ), btngrp ); |
78 | QWhatsThis::add( withBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); | 79 | QWhatsThis::add( withBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); |
79 | layout2->addWidget( withBtn, 0, 0 ); | 80 | layout2->addWidget( withBtn, 0, 0 ); |
80 | connect( withBtn, SIGNAL( clicked() ), this, SLOT( slotWithdrawalClicked() ) ); | 81 | connect( withBtn, SIGNAL( clicked() ), this, SLOT( slotWithdrawalClicked() ) ); |
81 | depBtn = new QRadioButton( tr( "Deposit" ), btngrp ); | 82 | depBtn = new QRadioButton( tr( "Deposit" ), btngrp ); |
82 | QWhatsThis::add( depBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); | 83 | QWhatsThis::add( depBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); |
83 | layout2->addWidget( depBtn, 0, 1 ); | 84 | layout2->addWidget( depBtn, 0, 1 ); |
84 | btngrp->setMaximumSize( 320, withBtn->height() ); | 85 | btngrp->setMaximumSize( 320, withBtn->height() ); |
85 | connect( depBtn, SIGNAL( clicked() ), this, SLOT( slotDepositClicked() ) ); | 86 | connect( depBtn, SIGNAL( clicked() ), this, SLOT( slotDepositClicked() ) ); |
86 | layout->addMultiCellWidget( btngrp, 0, 0, 0, 3 ); | 87 | layout->addMultiCellWidget( btngrp, 0, 0, 0, 3 ); |
87 | 88 | ||
88 | // Date | 89 | // Date |
89 | QLabel *label = new QLabel( tr( "Date:" ), container ); | 90 | QLabel *label = new QLabel( tr( "Date:" ), container ); |
90 | QWhatsThis::add( label, tr( "Select date of transaction here." ) ); | 91 | QWhatsThis::add( label, tr( "Select date of transaction here." ) ); |
91 | layout->addWidget( label, 1, 0 ); | 92 | layout->addWidget( label, 1, 0 ); |
92 | dateBtn = new QPushButton( TimeString::shortDate( QDate::currentDate() ), | 93 | dateBtn = new QPushButton( TimeString::shortDate( QDate::currentDate() ), |
93 | container ); | 94 | container ); |
94 | QWhatsThis::add( dateBtn, tr( "Select date of transaction here." ) ); | 95 | QWhatsThis::add( dateBtn, tr( "Select date of transaction here." ) ); |
95 | QPopupMenu *m1 = new QPopupMenu( container ); | 96 | QPopupMenu *m1 = new QPopupMenu( container ); |
96 | datePicker = new DateBookMonth( m1, 0, TRUE ); | 97 | datePicker = new DateBookMonth( m1, 0, TRUE ); |
97 | m1->insertItem( datePicker ); | 98 | m1->insertItem( datePicker ); |
98 | dateBtn->setPopup( m1 ); | 99 | dateBtn->setPopup( m1 ); |
99 | connect( datePicker, SIGNAL( dateClicked( int, int, int ) ), | 100 | connect( datePicker, SIGNAL( dateClicked( int, int, int ) ), |
100 | this, SLOT( slotDateChanged( int, int, int ) ) ); | 101 | this, SLOT( slotDateChanged( int, int, int ) ) ); |
101 | layout->addWidget( dateBtn, 1, 1 ); | 102 | layout->addWidget( dateBtn, 1, 1 ); |
102 | 103 | ||
103 | // Check number | 104 | // Check number |
104 | label = new QLabel( tr( "Number:" ), container ); | 105 | label = new QLabel( tr( "Number:" ), container ); |
105 | QWhatsThis::add( label, tr( "Enter check number here." ) ); | 106 | QWhatsThis::add( label, tr( "Enter check number here." ) ); |
106 | layout->addWidget( label, 1, 2 ); | 107 | layout->addWidget( label, 1, 2 ); |
107 | numEdit = new QLineEdit( container ); | 108 | numEdit = new QLineEdit( container ); |
108 | QWhatsThis::add( numEdit, tr( "Enter check number here." ) ); | 109 | QWhatsThis::add( numEdit, tr( "Enter check number here." ) ); |
109 | numEdit->setMaximumWidth( 40 ); | 110 | numEdit->setMaximumWidth( 40 ); |
110 | layout->addWidget( numEdit, 1, 3 ); | 111 | layout->addWidget( numEdit, 1, 3 ); |
111 | 112 | ||
112 | // Description | 113 | // Description |
113 | label = new QLabel( tr( "Description:" ), container ); | 114 | label = new QLabel( tr( "Description:" ), container ); |
114 | QWhatsThis::add( label, tr( "Enter description of transaction here." ) ); | 115 | QWhatsThis::add( label, tr( "Enter description of transaction here." ) ); |
115 | layout->addWidget( label, 2, 0 ); | 116 | layout->addWidget( label, 2, 0 ); |
116 | descEdit = new QLineEdit( container ); | 117 | descEdit = new QLineEdit( container ); |
117 | QWhatsThis::add( descEdit, tr( "Enter description of transaction here." ) ); | 118 | QWhatsThis::add( descEdit, tr( "Enter description of transaction here." ) ); |
118 | layout->addMultiCellWidget( descEdit, 2, 2, 1, 3 ); | 119 | layout->addMultiCellWidget( descEdit, 2, 2, 1, 3 ); |
119 | 120 | ||
120 | // Category | 121 | // Category |
121 | label = new QLabel( tr( "Category:" ), container ); | 122 | label = new QLabel( tr( "Category:" ), container ); |
122 | QWhatsThis::add( label, tr( "Select transaction category here." ) ); | 123 | QWhatsThis::add( label, tr( "Select transaction category here." ) ); |
123 | layout->addWidget( label, 3, 0 ); | 124 | layout->addWidget( label, 3, 0 ); |
124 | catList = new QComboBox( container ); | 125 | catList = new QComboBox( container ); |
125 | QWhatsThis::add( catList, tr( "Select transaction category here." ) ); | 126 | QWhatsThis::add( catList, tr( "Select transaction category here." ) ); |
126 | layout->addMultiCellWidget( catList, 3, 3, 1, 3 ); | 127 | layout->addMultiCellWidget( catList, 3, 3, 1, 3 ); |
127 | 128 | ||
128 | // Type | 129 | // Type |
129 | label = new QLabel( tr( "Type:" ), container ); | 130 | label = new QLabel( tr( "Type:" ), container ); |
130 | QWhatsThis::add( label, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); | 131 | QWhatsThis::add( label, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); |
131 | layout->addWidget( label, 4, 0 ); | 132 | layout->addWidget( label, 4, 0 ); |
132 | typeList = new QComboBox( container ); | 133 | typeList = new QComboBox( container ); |
133 | QWhatsThis::add( typeList, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); | 134 | QWhatsThis::add( typeList, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); |
134 | layout->addMultiCellWidget( typeList, 4, 4, 1, 3 ); | 135 | layout->addMultiCellWidget( typeList, 4, 4, 1, 3 ); |
135 | 136 | ||
136 | // Amount | 137 | // Amount |
137 | label = new QLabel( tr( "Amount:" ), container ); | 138 | label = new QLabel( tr( "Amount:" ), container ); |
138 | QWhatsThis::add( label, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); | 139 | QWhatsThis::add( label, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); |
139 | layout->addWidget( label, 5, 0 ); | 140 | layout->addWidget( label, 5, 0 ); |
140 | amtEdit = new QLineEdit( container ); | 141 | amtEdit = new QLineEdit( container ); |
141 | QWhatsThis::add( amtEdit, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); | 142 | QWhatsThis::add( amtEdit, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); |
142 | layout->addMultiCellWidget( amtEdit, 5, 5, 1, 3 ); | 143 | layout->addMultiCellWidget( amtEdit, 5, 5, 1, 3 ); |
143 | 144 | ||
144 | // Fee | 145 | // Fee |
145 | label = new QLabel( tr( "Fee:" ), container ); | 146 | label = new QLabel( tr( "Fee:" ), container ); |
146 | QWhatsThis::add( label, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) ); | 147 | QWhatsThis::add( label, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) ); |
147 | layout->addWidget( label, 6, 0 ); | 148 | layout->addWidget( label, 6, 0 ); |
148 | feeEdit = new QLineEdit( container ); | 149 | feeEdit = new QLineEdit( container ); |
149 | QWhatsThis::add( feeEdit, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) ); | 150 | QWhatsThis::add( feeEdit, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) ); |
150 | layout->addMultiCellWidget( feeEdit, 6, 6, 1, 3 ); | 151 | layout->addMultiCellWidget( feeEdit, 6, 6, 1, 3 ); |
151 | 152 | ||
152 | // Notes | 153 | // Notes |
153 | label = new QLabel( tr( "Notes:" ), container ); | 154 | label = new QLabel( tr( "Notes:" ), container ); |
154 | QWhatsThis::add( label, tr( "Enter any additional information for this transaction here." ) ); | 155 | QWhatsThis::add( label, tr( "Enter any additional information for this transaction here." ) ); |
155 | layout->addWidget( label, 7, 0 ); | 156 | layout->addWidget( label, 7, 0 ); |
156 | noteEdit = new QMultiLineEdit( container ); | 157 | noteEdit = new QMultiLineEdit( container ); |
157 | QWhatsThis::add( noteEdit, tr( "Enter any additional information for this transaction here." ) ); | 158 | QWhatsThis::add( noteEdit, tr( "Enter any additional information for this transaction here." ) ); |
158 | layout->addMultiCellWidget( noteEdit, 8, 8, 0, 3 ); | 159 | layout->addMultiCellWidget( noteEdit, 8, 8, 0, 3 ); |
159 | 160 | ||
160 | // Populate current values if provided | 161 | // Populate current values if provided |
161 | if ( info ) | 162 | if ( info ) |
162 | { | 163 | { |
163 | if ( info->withdrawal() ) | 164 | if ( info->withdrawal() ) |
164 | { | 165 | { |
165 | withBtn->setChecked( TRUE ); | 166 | withBtn->setChecked( TRUE ); |
166 | slotWithdrawalClicked(); | 167 | slotWithdrawalClicked(); |
167 | } | 168 | } |
168 | else | 169 | else |
169 | { | 170 | { |
170 | depBtn->setChecked( TRUE ); | 171 | depBtn->setChecked( TRUE ); |
171 | slotDepositClicked(); | 172 | slotDepositClicked(); |
172 | } | 173 | } |
173 | QDate dt = info->date(); | 174 | QDate dt = info->date(); |
174 | slotDateChanged( dt.year(), dt.month(), dt.day() ); | 175 | slotDateChanged( dt.year(), dt.month(), dt.day() ); |
175 | datePicker->setDate( dt ); | 176 | datePicker->setDate( dt ); |
176 | numEdit->setText( info->number() ); | 177 | numEdit->setText( info->number() ); |
177 | descEdit->setText( info->desc() ); | 178 | descEdit->setText( info->desc() ); |
178 | QString temptext = info->category(); | 179 | QString temptext = info->category(); |
179 | int i = catList->count(); | 180 | int i = catList->count(); |
180 | while ( i > 0 ) | 181 | while ( i > 0 ) |
181 | { | 182 | { |
182 | i--; | 183 | i--; |
183 | catList->setCurrentItem( i ); | 184 | catList->setCurrentItem( i ); |
184 | if ( catList->currentText() == temptext ) | 185 | if ( catList->currentText() == temptext ) |
185 | { | 186 | { |
186 | break; | 187 | break; |
187 | } | 188 | } |
188 | } | 189 | } |
189 | temptext = info->type(); | 190 | temptext = info->type(); |
190 | i = typeList->count(); | 191 | i = typeList->count(); |
191 | while ( i > 0 ) | 192 | while ( i > 0 ) |
192 | { | 193 | { |
193 | i--; | 194 | i--; |
194 | typeList->setCurrentItem( i ); | 195 | typeList->setCurrentItem( i ); |
195 | if ( typeList->currentText() == temptext ) | 196 | if ( typeList->currentText() == temptext ) |
196 | { | 197 | { |
197 | break; | 198 | break; |
198 | } | 199 | } |
199 | } | 200 | } |
200 | amtEdit->setText( QString( "%1" ).arg( info->amount(), 0, 'f', 2 ) ); | 201 | amtEdit->setText( QString( "%1" ).arg( info->amount(), 0, 'f', 2 ) ); |
201 | feeEdit->setText( QString( "%1" ).arg( info->fee(), 0, 'f', 2 ) ); | 202 | feeEdit->setText( QString( "%1" ).arg( info->fee(), 0, 'f', 2 ) ); |
202 | noteEdit->setText( info->notes() ); | 203 | noteEdit->setText( info->notes() ); |
203 | } | 204 | } |
204 | else | 205 | else |
205 | { | 206 | { |
206 | withBtn->setChecked( TRUE ); | 207 | withBtn->setChecked( TRUE ); |
207 | } | 208 | } |
208 | } | 209 | } |
209 | 210 | ||
210 | Transaction::~Transaction() | 211 | Transaction::~Transaction() |
211 | { | 212 | { |
212 | } | 213 | } |
213 | 214 | ||
214 | void Transaction::accept() | 215 | void Transaction::accept() |
215 | { | 216 | { |
216 | tran->setDesc( descEdit->text() ); | 217 | tran->setDesc( descEdit->text() ); |
217 | tran->setDate( datePicker->selectedDate() ); | 218 | tran->setDate( datePicker->selectedDate() ); |
218 | tran->setWithdrawal( withBtn->isChecked() ); | 219 | tran->setWithdrawal( withBtn->isChecked() ); |
219 | tran->setType( typeList->currentText() ); | 220 | tran->setType( typeList->currentText() ); |
220 | tran->setCategory( catList->currentText() ); | 221 | tran->setCategory( catList->currentText() ); |
221 | bool ok; | 222 | bool ok; |
222 | tran->setAmount( amtEdit->text().toFloat( &ok ) ); | 223 | tran->setAmount( amtEdit->text().toFloat( &ok ) ); |
223 | tran->setFee( feeEdit->text().toFloat( &ok ) ); | 224 | tran->setFee( feeEdit->text().toFloat( &ok ) ); |
224 | tran->setNumber( numEdit->text() ); | 225 | tran->setNumber( numEdit->text() ); |
225 | tran->setNotes( noteEdit->text() ); | 226 | tran->setNotes( noteEdit->text() ); |
226 | 227 | ||
227 | QDialog::accept(); | 228 | QDialog::accept(); |
228 | } | 229 | } |
229 | 230 | ||
230 | void Transaction::slotWithdrawalClicked() | 231 | void Transaction::slotWithdrawalClicked() |
231 | { | 232 | { |
232 | catList->clear(); | 233 | catList->clear(); |
233 | catList->insertItem( tr( "Automobile" ) ); | 234 | CategoryList *pCatList=_pCfg->getCategoryList(); |
234 | catList->insertItem( tr( "Bills" ) ); | 235 | for(Category *pCat=pCatList->first(); pCat; pCat=pCatList->next()) { |
235 | catList->insertItem( tr( "CDs" ) ); | 236 | if( !pCat->isIncome() ) |
236 | catList->insertItem( tr( "Clothing" ) ); | 237 | catList->insertItem( pCat->getName() ); |
237 | catList->insertItem( tr( "Computer" ) ); | 238 | } |
238 | catList->insertItem( tr( "DVDs" ) ); | 239 | catList->setCurrentItem(0); |
239 | catList->insertItem( tr( "Electronics" ) ); | 240 | |
240 | catList->insertItem( tr( "Entertainment" ) ); | ||
241 | catList->insertItem( tr( "Food" ) ); | ||
242 | catList->insertItem( tr( "Gasoline" ) ); | ||
243 | catList->insertItem( tr( "Misc" ) ); | ||
244 | catList->insertItem( tr( "Movies" ) ); | ||
245 | catList->insertItem( tr( "Rent" ) ); | ||
246 | catList->insertItem( tr( "Travel" ) ); | ||
247 | catList->setCurrentItem( 0 ); | ||
248 | typeList->clear(); | 241 | typeList->clear(); |
249 | typeList->insertItem( tr( "Debit Charge" ) ); | 242 | typeList->insertItem( tr( "Debit Charge" ) ); |
250 | typeList->insertItem( tr( "Written Check" ) ); | 243 | typeList->insertItem( tr( "Written Check" ) ); |
251 | typeList->insertItem( tr( "Transfer" ) ); | 244 | typeList->insertItem( tr( "Transfer" ) ); |
252 | typeList->insertItem( tr( "Credit Card" ) ); | 245 | typeList->insertItem( tr( "Credit Card" ) ); |
253 | } | 246 | } |
254 | 247 | ||
255 | void Transaction::slotDepositClicked() | 248 | void Transaction::slotDepositClicked() |
256 | { | 249 | { |
257 | catList->clear(); | 250 | catList->clear(); |
258 | catList->insertItem( tr( "Work" ) ); | 251 | CategoryList *pCatList=_pCfg->getCategoryList(); |
259 | catList->insertItem( tr( "Family Member" ) ); | 252 | for(Category *pCat=pCatList->first(); pCat; pCat=pCatList->next()) { |
260 | catList->insertItem( tr( "Misc. Credit" ) ); | 253 | if( pCat->isIncome() ) |
261 | catList->setCurrentItem( 0 ); | 254 | catList->insertItem( pCat->getName() ); |
255 | } | ||
256 | catList->setCurrentItem( 0 ); | ||
257 | |||
262 | typeList->clear(); | 258 | typeList->clear(); |
263 | typeList->insertItem( tr( "Written Check" ) ); | 259 | typeList->insertItem( tr( "Written Check" ) ); |
264 | typeList->insertItem( tr( "Automatic Payment" ) ); | 260 | typeList->insertItem( tr( "Automatic Payment" ) ); |
265 | typeList->insertItem( tr( "Transfer" ) ); | 261 | typeList->insertItem( tr( "Transfer" ) ); |
266 | typeList->insertItem( tr( "Cash" ) ); | 262 | typeList->insertItem( tr( "Cash" ) ); |
267 | } | 263 | } |
268 | 264 | ||
269 | void Transaction::slotDateChanged( int y, int m, int d ) | 265 | void Transaction::slotDateChanged( int y, int m, int d ) |
270 | { | 266 | { |
271 | QDate date; | 267 | QDate date; |
272 | date.setYMD( y, m, d ); | 268 | date.setYMD( y, m, d ); |
273 | dateBtn->setText( TimeString::shortDate( date ) ); | 269 | dateBtn->setText( TimeString::shortDate( date ) ); |
274 | } | 270 | } |
diff --git a/noncore/apps/checkbook/transaction.h b/noncore/apps/checkbook/transaction.h index 000aee7..fbe9cd3 100644 --- a/noncore/apps/checkbook/transaction.h +++ b/noncore/apps/checkbook/transaction.h | |||
@@ -1,79 +1,79 @@ | |||
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 | #ifndef TRANSACTION_H | 29 | #ifndef TRANSACTION_H |
30 | #define TRANSACTION_H | 30 | #define TRANSACTION_H |
31 | 31 | ||
32 | #include <qdialog.h> | 32 | #include <qdialog.h> |
33 | 33 | ||
34 | class DateBookMonth; | 34 | class DateBookMonth; |
35 | class QComboBox; | 35 | class QComboBox; |
36 | class QLineEdit; | 36 | class QLineEdit; |
37 | class QMultiLineEdit; | 37 | class QMultiLineEdit; |
38 | class QPushButton; | 38 | class QPushButton; |
39 | class QRadioButton; | 39 | class QRadioButton; |
40 | class QString; | 40 | class QString; |
41 | class QWidget; | 41 | class QWidget; |
42 | class TranInfo; | 42 | class TranInfo; |
43 | class Cfg; | ||
43 | 44 | ||
44 | class Transaction : public QDialog | 45 | class Transaction : public QDialog |
45 | { | 46 | { |
46 | Q_OBJECT | 47 | Q_OBJECT |
47 | 48 | ||
48 | public: | 49 | public: |
49 | Transaction( QWidget * = 0x0, const QString & = 0x0, TranInfo * = 0x0, | 50 | Transaction( QWidget *, const QString &, TranInfo *, Cfg *); |
50 | const QString & = "$" ); | ||
51 | ~Transaction(); | 51 | ~Transaction(); |
52 | 52 | ||
53 | private: | 53 | private: |
54 | TranInfo *tran; | 54 | TranInfo *tran; |
55 | 55 | ||
56 | QString currencySymbol; | 56 | Cfg *_pCfg; |
57 | 57 | ||
58 | QRadioButton *withBtn; | 58 | QRadioButton *withBtn; |
59 | QRadioButton *depBtn; | 59 | QRadioButton *depBtn; |
60 | QPushButton *dateBtn; | 60 | QPushButton *dateBtn; |
61 | DateBookMonth *datePicker; | 61 | DateBookMonth *datePicker; |
62 | QLineEdit *numEdit; | 62 | QLineEdit *numEdit; |
63 | QLineEdit *descEdit; | 63 | QLineEdit *descEdit; |
64 | QComboBox *catList; | 64 | QComboBox *catList; |
65 | QComboBox *typeList; | 65 | QComboBox *typeList; |
66 | QLineEdit *amtEdit; | 66 | QLineEdit *amtEdit; |
67 | QLineEdit *feeEdit; | 67 | QLineEdit *feeEdit; |
68 | QMultiLineEdit *noteEdit; | 68 | QMultiLineEdit *noteEdit; |
69 | 69 | ||
70 | protected slots: | 70 | protected slots: |
71 | void accept(); | 71 | void accept(); |
72 | 72 | ||
73 | private slots: | 73 | private slots: |
74 | void slotWithdrawalClicked(); | 74 | void slotWithdrawalClicked(); |
75 | void slotDepositClicked(); | 75 | void slotDepositClicked(); |
76 | void slotDateChanged( int, int, int ); | 76 | void slotDateChanged( int, int, int ); |
77 | }; | 77 | }; |
78 | 78 | ||
79 | #endif | 79 | #endif |
diff --git a/noncore/apps/odict/main.cpp b/noncore/apps/odict/main.cpp index c68253f..0642022 100644 --- a/noncore/apps/odict/main.cpp +++ b/noncore/apps/odict/main.cpp | |||
@@ -1,29 +1,24 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | application: : ODict | 2 | application: : ODict |
3 | 3 | ||
4 | begin : December 2002 | 4 | begin : December 2002 |
5 | copyright : ( C ) 2002, 2003 by Carsten Niehaus | 5 | copyright : ( C ) 2002, 2003 by Carsten Niehaus |
6 | email : cniehaus@handhelds.org | 6 | email : cniehaus@handhelds.org |
7 | **************************************************************************/ | 7 | **************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * ( at your option ) any later version. * | 14 | * ( at your option ) any later version. * |
15 | * * | 15 | * * |
16 | **************************************************************************/ | 16 | **************************************************************************/ |
17 | 17 | ||
18 | 18 | ||
19 | #include <qpe/qpeapplication.h> | 19 | #include <qpe/qpeapplication.h> |
20 | #include <opie/oapplicationfactory.h> | ||
20 | #include "odict.h" | 21 | #include "odict.h" |
21 | 22 | ||
22 | int main(int argc, char **argv) | 23 | |
23 | { | 24 | OPIE_EXPORT_APP( OApplicationFactory<ODict> ) |
24 | QPEApplication app(argc, argv); | ||
25 | ODict *odict= new ODict(); | ||
26 | app.setMainWidget(odict); | ||
27 | odict->showMaximized(); | ||
28 | return app.exec(); | ||
29 | } | ||
diff --git a/noncore/apps/odict/odict.cpp b/noncore/apps/odict/odict.cpp index 010545e..9718c5c 100644 --- a/noncore/apps/odict/odict.cpp +++ b/noncore/apps/odict/odict.cpp | |||
@@ -1,220 +1,220 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | application: : ODict | 2 | application: : ODict |
3 | 3 | ||
4 | begin : December 2002 | 4 | begin : December 2002 |
5 | copyright : ( C ) 2002, 2003 by Carsten Niehaus | 5 | copyright : ( C ) 2002, 2003 by Carsten Niehaus |
6 | email : cniehaus@handhelds.org | 6 | email : cniehaus@handhelds.org |
7 | **************************************************************************/ | 7 | **************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * ( at your option ) any later version. * | 14 | * ( at your option ) any later version. * |
15 | * * | 15 | * * |
16 | **************************************************************************/ | 16 | **************************************************************************/ |
17 | #include "odict.h" | 17 | #include "odict.h" |
18 | #include "configdlg.h" | 18 | #include "configdlg.h" |
19 | #include "dingwidget.h" | 19 | #include "dingwidget.h" |
20 | 20 | ||
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | #include <qpopupmenu.h> | 22 | #include <qpopupmenu.h> |
23 | #include <qmenubar.h> | 23 | #include <qmenubar.h> |
24 | #include <qmessagebox.h> | 24 | #include <qmessagebox.h> |
25 | #include <qhbox.h> | 25 | #include <qhbox.h> |
26 | #include <qvbox.h> | 26 | #include <qvbox.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qpushbutton.h> | 28 | #include <qpushbutton.h> |
29 | #include <qlineedit.h> | 29 | #include <qlineedit.h> |
30 | #include <qmainwindow.h> | 30 | #include <qmainwindow.h> |
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | #include <qaction.h> | 32 | #include <qaction.h> |
33 | #include <qtextbrowser.h> | 33 | #include <qtextbrowser.h> |
34 | #include <qcombobox.h> | 34 | #include <qcombobox.h> |
35 | 35 | ||
36 | #include <qpe/resource.h> | 36 | #include <qpe/resource.h> |
37 | #include <qpe/config.h> | 37 | #include <qpe/config.h> |
38 | 38 | ||
39 | ODict::ODict() : QMainWindow() | 39 | ODict::ODict(QWidget* parent, const char* name, WFlags fl ) : QMainWindow(parent, name, fl ) |
40 | { | 40 | { |
41 | activated_name = QString::null; | 41 | activated_name = QString::null; |
42 | 42 | ||
43 | vbox = new QVBox( this ); | 43 | vbox = new QVBox( this ); |
44 | setCaption( tr( "Opie-Dictionary" ) ); | 44 | setCaption( tr( "Opie-Dictionary" ) ); |
45 | setupMenus(); | 45 | setupMenus(); |
46 | 46 | ||
47 | QHBox *hbox = new QHBox( vbox ); | 47 | QHBox *hbox = new QHBox( vbox ); |
48 | QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); | 48 | QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); |
49 | query_label->show(); | 49 | query_label->show(); |
50 | query_le = new QLineEdit( hbox ); | 50 | query_le = new QLineEdit( hbox ); |
51 | query_co = new QComboBox( hbox ); | 51 | query_co = new QComboBox( hbox ); |
52 | connect( query_co , SIGNAL( activated(const QString&) ), this, SLOT( slotMethodChanged(const QString&) ) ); | 52 | connect( query_co , SIGNAL( activated(const QString&) ), this, SLOT( slotMethodChanged(const QString&) ) ); |
53 | ok_button = new QPushButton( tr( "&Ok" ), hbox ); | 53 | ok_button = new QPushButton( tr( "&Ok" ), hbox ); |
54 | connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) ); | 54 | connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) ); |
55 | 55 | ||
56 | top_name = new QLabel( vbox ); | 56 | top_name = new QLabel( vbox ); |
57 | top_name->setAlignment( AlignHCenter ); | 57 | top_name->setAlignment( AlignHCenter ); |
58 | browser_top = new QTextBrowser( vbox ); | 58 | browser_top = new QTextBrowser( vbox ); |
59 | bottom_name = new QLabel( vbox ); | 59 | bottom_name = new QLabel( vbox ); |
60 | bottom_name->setAlignment( AlignHCenter ); | 60 | bottom_name->setAlignment( AlignHCenter ); |
61 | browser_bottom = new QTextBrowser( vbox ); | 61 | browser_bottom = new QTextBrowser( vbox ); |
62 | 62 | ||
63 | ding = new DingWidget(); | 63 | ding = new DingWidget(); |
64 | 64 | ||
65 | loadConfig(); | 65 | loadConfig(); |
66 | setCentralWidget( vbox ); | 66 | setCentralWidget( vbox ); |
67 | } | 67 | } |
68 | 68 | ||
69 | void ODict::loadConfig() | 69 | void ODict::loadConfig() |
70 | { | 70 | { |
71 | /* | 71 | /* |
72 | * the name of the last used dictionary | 72 | * the name of the last used dictionary |
73 | */ | 73 | */ |
74 | QString lastname; | 74 | QString lastname; |
75 | 75 | ||
76 | Config cfg ( "odict" ); | 76 | Config cfg ( "odict" ); |
77 | cfg.setGroup( "generalsettings" ); | 77 | cfg.setGroup( "generalsettings" ); |
78 | casesens = cfg.readEntry( "casesens" ).toInt(); | 78 | casesens = cfg.readEntry( "casesens" ).toInt(); |
79 | 79 | ||
80 | QString lastDict = cfg.readEntry( "lastdict" ); | 80 | QString lastDict = cfg.readEntry( "lastdict" ); |
81 | int i = 0, e = 0; | 81 | int i = 0, e = 0; |
82 | 82 | ||
83 | QStringList groupListCfg = cfg.groupList().grep( "Method_" ); | 83 | QStringList groupListCfg = cfg.groupList().grep( "Method_" ); |
84 | query_co->clear(); | 84 | query_co->clear(); |
85 | for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) | 85 | for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) |
86 | { | 86 | { |
87 | QString name; | 87 | QString name; |
88 | cfg.setGroup( *it ); | 88 | cfg.setGroup( *it ); |
89 | name = cfg.readEntry( "Name" ); | 89 | name = cfg.readEntry( "Name" ); |
90 | query_co->insertItem( name ); | 90 | query_co->insertItem( name ); |
91 | 91 | ||
92 | /* | 92 | /* |
93 | * this check is to look up what dictionary has been used the | 93 | * this check is to look up what dictionary has been used the |
94 | * last time | 94 | * last time |
95 | */ | 95 | */ |
96 | if ( lastDict == name ) | 96 | if ( lastDict == name ) |
97 | { | 97 | { |
98 | e = i; | 98 | e = i; |
99 | lastname = name; | 99 | lastname = name; |
100 | } | 100 | } |
101 | i++; | 101 | i++; |
102 | } | 102 | } |
103 | /* | 103 | /* |
104 | * now set the two names of the dictionary and the correct QComboBox-Entry | 104 | * now set the two names of the dictionary and the correct QComboBox-Entry |
105 | */ | 105 | */ |
106 | 106 | ||
107 | lookupLanguageNames( lastname ); | 107 | lookupLanguageNames( lastname ); |
108 | ding->loadDict( lastname ); | 108 | ding->loadDict( lastname ); |
109 | ding->loadValues(); | 109 | ding->loadValues(); |
110 | 110 | ||
111 | query_co->setCurrentItem( e ); | 111 | query_co->setCurrentItem( e ); |
112 | top_name->setText( top_name_content ); | 112 | top_name->setText( top_name_content ); |
113 | bottom_name->setText( bottom_name_content ); | 113 | bottom_name->setText( bottom_name_content ); |
114 | } | 114 | } |
115 | 115 | ||
116 | void ODict::lookupLanguageNames( QString dictname ) | 116 | void ODict::lookupLanguageNames( QString dictname ) |
117 | { | 117 | { |
118 | Config cfg ( "odict" ); | 118 | Config cfg ( "odict" ); |
119 | cfg.setGroup( "Method_"+dictname ); | 119 | cfg.setGroup( "Method_"+dictname ); |
120 | top_name_content = cfg.readEntry( "Lang1" ); | 120 | top_name_content = cfg.readEntry( "Lang1" ); |
121 | bottom_name_content = cfg.readEntry( "Lang2" ); | 121 | bottom_name_content = cfg.readEntry( "Lang2" ); |
122 | } | 122 | } |
123 | 123 | ||
124 | void ODict::saveConfig() | 124 | void ODict::saveConfig() |
125 | { | 125 | { |
126 | Config cfg ( "odict" ); | 126 | Config cfg ( "odict" ); |
127 | cfg.setGroup( "generalsettings" ); | 127 | cfg.setGroup( "generalsettings" ); |
128 | cfg.writeEntry( "casesens" , casesens ); | 128 | cfg.writeEntry( "casesens" , casesens ); |
129 | cfg.writeEntry( "lastdict" , query_co->currentText() ); | 129 | cfg.writeEntry( "lastdict" , query_co->currentText() ); |
130 | } | 130 | } |
131 | 131 | ||
132 | void ODict::slotStartQuery() | 132 | void ODict::slotStartQuery() |
133 | { | 133 | { |
134 | QString querystring = query_le->text(); | 134 | QString querystring = query_le->text(); |
135 | if ( !querystring.isEmpty() ) | 135 | if ( !querystring.isEmpty() ) |
136 | { | 136 | { |
137 | /* | 137 | /* |
138 | * if the user has not yet defined a dictionary | 138 | * if the user has not yet defined a dictionary |
139 | */ | 139 | */ |
140 | if ( !query_co->currentText() ) | 140 | if ( !query_co->currentText() ) |
141 | { | 141 | { |
142 | switch ( QMessageBox::information( this, tr( "OPIE-Dictionary" ), | 142 | switch ( QMessageBox::information( this, tr( "OPIE-Dictionary" ), |
143 | tr( "No dictionary defined" ), | 143 | tr( "No dictionary defined" ), |
144 | tr( "&Define one" ), | 144 | tr( "&Define one" ), |
145 | tr( "&Cancel" ), | 145 | tr( "&Cancel" ), |
146 | 0, // Define a dict | 146 | 0, // Define a dict |
147 | 1 ) ) // Cancel choosen | 147 | 1 ) ) // Cancel choosen |
148 | { | 148 | { |
149 | case 0: | 149 | case 0: |
150 | slotSettings(); | 150 | slotSettings(); |
151 | break; | 151 | break; |
152 | case 1: // stop here | 152 | case 1: // stop here |
153 | return; | 153 | return; |
154 | } | 154 | } |
155 | } | 155 | } |
156 | 156 | ||
157 | /* | 157 | /* |
158 | * ok, the user has defined a dict | 158 | * ok, the user has defined a dict |
159 | */ | 159 | */ |
160 | ding->setCaseSensitive( casesens ); | 160 | ding->setCaseSensitive( casesens ); |
161 | 161 | ||
162 | BroswerContent test = ding->setText( querystring ); | 162 | BroswerContent test = ding->setText( querystring ); |
163 | 163 | ||
164 | browser_top->setText( test.top ); | 164 | browser_top->setText( test.top ); |
165 | browser_bottom->setText( test.bottom ); | 165 | browser_bottom->setText( test.bottom ); |
166 | } | 166 | } |
167 | } | 167 | } |
168 | 168 | ||
169 | void ODict::slotSettings() | 169 | void ODict::slotSettings() |
170 | { | 170 | { |
171 | ConfigDlg dlg( this, "Config" , true); | 171 | ConfigDlg dlg( this, "Config" , true); |
172 | if ( dlg.exec() == QDialog::Accepted ) | 172 | if ( dlg.exec() == QDialog::Accepted ) |
173 | saveConfig(); | 173 | saveConfig(); |
174 | } | 174 | } |
175 | 175 | ||
176 | void ODict::slotSetParameter( int count ) | 176 | void ODict::slotSetParameter( int count ) |
177 | { | 177 | { |
178 | if ( count == 0 ) | 178 | if ( count == 0 ) |
179 | { | 179 | { |
180 | if ( casesens ) | 180 | if ( casesens ) |
181 | casesens = false; | 181 | casesens = false; |
182 | else | 182 | else |
183 | casesens = true; | 183 | casesens = true; |
184 | } | 184 | } |
185 | 185 | ||
186 | saveConfig(); | 186 | saveConfig(); |
187 | } | 187 | } |
188 | 188 | ||
189 | void ODict::slotMethodChanged( const QString& methodnumber ) | 189 | void ODict::slotMethodChanged( const QString& methodnumber ) |
190 | { | 190 | { |
191 | activated_name = methodnumber; | 191 | activated_name = methodnumber; |
192 | 192 | ||
193 | if ( activated_name != ding->loadedDict() ) | 193 | if ( activated_name != ding->loadedDict() ) |
194 | { | 194 | { |
195 | ding->loadDict(activated_name); | 195 | ding->loadDict(activated_name); |
196 | 196 | ||
197 | lookupLanguageNames( activated_name ); | 197 | lookupLanguageNames( activated_name ); |
198 | top_name->setText( top_name_content ); | 198 | top_name->setText( top_name_content ); |
199 | bottom_name->setText( bottom_name_content ); | 199 | bottom_name->setText( bottom_name_content ); |
200 | } | 200 | } |
201 | } | 201 | } |
202 | 202 | ||
203 | void ODict::setupMenus() | 203 | void ODict::setupMenus() |
204 | { | 204 | { |
205 | menu = new QMenuBar( this ); | 205 | menu = new QMenuBar( this ); |
206 | 206 | ||
207 | settings = new QPopupMenu( menu ); | 207 | settings = new QPopupMenu( menu ); |
208 | setting_a = new QAction(tr( "Configuration" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 208 | setting_a = new QAction(tr( "Configuration" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
209 | connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 209 | connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); |
210 | setting_a->addTo( settings ); | 210 | setting_a->addTo( settings ); |
211 | setting_b = new QAction(tr( "Searchmethods" ), Resource::loadPixmap( "edit" ), QString::null, 0, this, 0 ); | 211 | setting_b = new QAction(tr( "Searchmethods" ), Resource::loadPixmap( "edit" ), QString::null, 0, this, 0 ); |
212 | 212 | ||
213 | parameter = new QPopupMenu( menu ); | 213 | parameter = new QPopupMenu( menu ); |
214 | connect( parameter, SIGNAL( activated( int ) ), this, SLOT( slotSetParameter( int ) ) ); | 214 | connect( parameter, SIGNAL( activated( int ) ), this, SLOT( slotSetParameter( int ) ) ); |
215 | parameter->insertItem( tr( "C&ase sensitive" ), 0 ,0 ); | 215 | parameter->insertItem( tr( "C&ase sensitive" ), 0 ,0 ); |
216 | parameter->insertSeparator(); | 216 | parameter->insertSeparator(); |
217 | 217 | ||
218 | menu->insertItem( tr( "Settings" ) , settings ); | 218 | menu->insertItem( tr( "Settings" ) , settings ); |
219 | menu->insertItem( tr( "Parameter" ) , parameter ); | 219 | menu->insertItem( tr( "Parameter" ) , parameter ); |
220 | } | 220 | } |
diff --git a/noncore/apps/odict/odict.h b/noncore/apps/odict/odict.h index be2a532..68a8f95 100644 --- a/noncore/apps/odict/odict.h +++ b/noncore/apps/odict/odict.h | |||
@@ -1,70 +1,70 @@ | |||
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 | 9 | ||
10 | #include <qmainwindow.h> | 10 | #include <qmainwindow.h> |
11 | 11 | ||
12 | class QLabel; | 12 | class QLabel; |
13 | class QVBox; | 13 | class QVBox; |
14 | class QPopupMenu; | 14 | class QPopupMenu; |
15 | class QMenuBar; | 15 | class QMenuBar; |
16 | class QHBox; | 16 | class QHBox; |
17 | class QPushButton; | 17 | class QPushButton; |
18 | class QLineEdit; | 18 | class QLineEdit; |
19 | class QAction; | 19 | class QAction; |
20 | class QVBoxLayout; | 20 | class QVBoxLayout; |
21 | class QActionGroup; | 21 | class QActionGroup; |
22 | class DingWidget; | 22 | class DingWidget; |
23 | class QTextBrowser; | 23 | class QTextBrowser; |
24 | class QComboBox; | 24 | class QComboBox; |
25 | class DingWidget; | 25 | class DingWidget; |
26 | 26 | ||
27 | class ODict : public QMainWindow | 27 | class ODict : public QMainWindow |
28 | { | 28 | { |
29 | Q_OBJECT | 29 | Q_OBJECT |
30 | 30 | ||
31 | public: | 31 | public: |
32 | ODict(); | 32 | ODict(QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
33 | QVBox *vbox; | 33 | QVBox *vbox; |
34 | QTextBrowser *browser_top, | 34 | QTextBrowser *browser_top, |
35 | *browser_bottom; | 35 | *browser_bottom; |
36 | DingWidget *ding; | 36 | DingWidget *ding; |
37 | 37 | static QString appName() { return QString::fromLatin1("odict"); } | |
38 | private: | 38 | private: |
39 | QPopupMenu *help, *settings, *parameter; | 39 | QPopupMenu *help, *settings, *parameter; |
40 | QMenuBar *menu; | 40 | QMenuBar *menu; |
41 | QHBox *hbox; | 41 | QHBox *hbox; |
42 | QLineEdit *query_le; | 42 | QLineEdit *query_le; |
43 | QComboBox *query_co; | 43 | QComboBox *query_co; |
44 | QPushButton *ok_button; | 44 | QPushButton *ok_button; |
45 | 45 | ||
46 | QVBoxLayout *vbox_layout; | 46 | QVBoxLayout *vbox_layout; |
47 | 47 | ||
48 | QAction *setting_a, *setting_b; | 48 | QAction *setting_a, *setting_b; |
49 | 49 | ||
50 | void setupMenus(); | 50 | void setupMenus(); |
51 | 51 | ||
52 | bool casesens, completewords; | 52 | bool casesens, completewords; |
53 | 53 | ||
54 | void loadConfig(); | 54 | void loadConfig(); |
55 | void saveConfig(); | 55 | void saveConfig(); |
56 | 56 | ||
57 | QString activated_name; | 57 | QString activated_name; |
58 | QLabel *bottom_name, | 58 | QLabel *bottom_name, |
59 | *top_name; | 59 | *top_name; |
60 | 60 | ||
61 | QString top_name_content, bottom_name_content; | 61 | QString top_name_content, bottom_name_content; |
62 | 62 | ||
63 | void lookupLanguageNames( QString ); | 63 | void lookupLanguageNames( QString ); |
64 | 64 | ||
65 | private slots: | 65 | private slots: |
66 | void slotStartQuery(); | 66 | void slotStartQuery(); |
67 | void slotSettings(); | 67 | void slotSettings(); |
68 | void slotSetParameter( int ); | 68 | void slotSetParameter( int ); |
69 | void slotMethodChanged( const QString& ); | 69 | void slotMethodChanged( const QString& ); |
70 | }; | 70 | }; |
diff --git a/noncore/apps/odict/odict.pro b/noncore/apps/odict/odict.pro index 82f6a41..4ad287b 100644 --- a/noncore/apps/odict/odict.pro +++ b/noncore/apps/odict/odict.pro | |||
@@ -1,41 +1,38 @@ | |||
1 | TEMPLATE= app | 1 | CONFIG = qt warn_on release quick-app |
2 | CONFIG = qt warn_on debug | ||
3 | #CONFIG = qt warn_on release | ||
4 | HEADERS = odict.h \ | 2 | HEADERS = odict.h \ |
5 | searchmethoddlg.h \ | 3 | searchmethoddlg.h \ |
6 | configdlg.h \ | 4 | configdlg.h \ |
7 | dingwidget.h | 5 | dingwidget.h |
8 | 6 | ||
9 | SOURCES = main.cpp \ | 7 | SOURCES = main.cpp \ |
10 | odict.cpp \ | 8 | odict.cpp \ |
11 | searchmethoddlg.cpp \ | 9 | searchmethoddlg.cpp \ |
12 | configdlg.cpp \ | 10 | configdlg.cpp \ |
13 | dingwidget.cpp | 11 | dingwidget.cpp |
14 | INCLUDEPATH += $(OPIEDIR)/include | 12 | INCLUDEPATH += $(OPIEDIR)/include |
15 | DEPENDPATH += $(OPIEDIR)/include | 13 | DEPENDPATH += $(OPIEDIR)/include |
16 | LIBS += -lqpe -lstdc++ -lopie | 14 | LIBS += -lqpe -lstdc++ -lopie |
17 | TARGET = odict | 15 | TARGET = odict |
18 | DESTDIR = $(OPIEDIR)/bin | ||
19 | 16 | ||
20 | TRANSLATIONS = ../../../i18n/de/odict.ts \ | 17 | TRANSLATIONS = ../../../i18n/de/odict.ts \ |
21 | ../../../i18n/nl/odict.ts \ | 18 | ../../../i18n/nl/odict.ts \ |
22 | ../../../i18n/xx/odict.ts \ | 19 | ../../../i18n/xx/odict.ts \ |
23 | ../../../i18n/en/odict.ts \ | 20 | ../../../i18n/en/odict.ts \ |
24 | ../../../i18n/es/odict.ts \ | 21 | ../../../i18n/es/odict.ts \ |
25 | ../../../i18n/fr/odict.ts \ | 22 | ../../../i18n/fr/odict.ts \ |
26 | ../../../i18n/hu/odict.ts \ | 23 | ../../../i18n/hu/odict.ts \ |
27 | ../../../i18n/ja/odict.ts \ | 24 | ../../../i18n/ja/odict.ts \ |
28 | ../../../i18n/ko/odict.ts \ | 25 | ../../../i18n/ko/odict.ts \ |
29 | ../../../i18n/no/odict.ts \ | 26 | ../../../i18n/no/odict.ts \ |
30 | ../../../i18n/pl/odict.ts \ | 27 | ../../../i18n/pl/odict.ts \ |
31 | ../../../i18n/pt/odict.ts \ | 28 | ../../../i18n/pt/odict.ts \ |
32 | ../../../i18n/pt_BR/odict.ts \ | 29 | ../../../i18n/pt_BR/odict.ts \ |
33 | ../../../i18n/sl/odict.ts \ | 30 | ../../../i18n/sl/odict.ts \ |
34 | ../../../i18n/zh_CN/odict.ts \ | 31 | ../../../i18n/zh_CN/odict.ts \ |
35 | ../../../i18n/zh_TW/odict.ts \ | 32 | ../../../i18n/zh_TW/odict.ts \ |
36 | ../../../i18n/it/odict.ts \ | 33 | ../../../i18n/it/odict.ts \ |
37 | ../../../i18n/da/odict.ts | 34 | ../../../i18n/da/odict.ts |
38 | 35 | ||
39 | 36 | ||
40 | 37 | ||
41 | include ( $(OPIEDIR)/include.pro ) | 38 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/opie-console/opie-console.control b/noncore/apps/opie-console/opie-console.control index 3934fa1..504de85 100644 --- a/noncore/apps/opie-console/opie-console.control +++ b/noncore/apps/opie-console/opie-console.control | |||
@@ -1,11 +1,11 @@ | |||
1 | Package: opie-console | 1 | Package: opie-console |
2 | Files: plugins/application/libopie-console.so* bin/opie-console apps/Applications/opie-console.desktop pics/console/* | 2 | Files: bin/opie-console apps/Applications/opie-console.desktop pics/console/* |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/applications | 4 | Section: opie/applications |
5 | Maintainer: Opie team <opie@handhelds.org> | 5 | Maintainer: Opie team <opie@handhelds.org> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Version: 0.6-$SUB_VERSION | 7 | Version: 0.6-$SUB_VERSION |
8 | Depends: qpe-base, libopie1, opie-console-help-en, lrzsz, opie-keytabs | 8 | Depends: qpe-base, libopie1, opie-console-help-en, lrzsz, opie-keytabs |
9 | License: GPL | 9 | License: GPL |
10 | Description: Opie terminal app | 10 | Description: Opie terminal app |
11 | 11 | ||
diff --git a/noncore/apps/opie-reader/opie-reader.pro b/noncore/apps/opie-reader/opie-reader.pro index 62113c3..686f083 100644 --- a/noncore/apps/opie-reader/opie-reader.pro +++ b/noncore/apps/opie-reader/opie-reader.pro | |||
@@ -1,93 +1,92 @@ | |||
1 | TEMPLATE= app | ||
2 | CONFIG = qt warn_on release | 1 | CONFIG = qt warn_on release |
3 | HEADERS = Aportis.h \ | 2 | HEADERS = Aportis.h \ |
4 | Bkmks.h \ | 3 | Bkmks.h \ |
5 | BuffDoc.h \ | 4 | BuffDoc.h \ |
6 | CAnnoEdit.h \ | 5 | CAnnoEdit.h \ |
7 | CBuffer.h \ | 6 | CBuffer.h \ |
8 | CDrawBuffer.h \ | 7 | CDrawBuffer.h \ |
9 | CEncoding.h \ | 8 | CEncoding.h \ |
10 | CEncoding_tables.h \ | 9 | CEncoding_tables.h \ |
11 | CExpander.h \ | 10 | CExpander.h \ |
12 | CFilter.h \ | 11 | CFilter.h \ |
13 | CloseDialog.h \ | 12 | CloseDialog.h \ |
14 | Filedata.h \ | 13 | Filedata.h \ |
15 | FixedFont.h \ | 14 | FixedFont.h \ |
16 | FontControl.h \ | 15 | FontControl.h \ |
17 | GraphicWin.h \ | 16 | GraphicWin.h \ |
18 | Markups.h \ | 17 | Markups.h \ |
19 | Navigation.h \ | 18 | Navigation.h \ |
20 | Palm2QImage.h \ | 19 | Palm2QImage.h \ |
21 | Prefs.h \ | 20 | Prefs.h \ |
22 | QFloatBar.h \ | 21 | QFloatBar.h \ |
23 | QTReader.h \ | 22 | QTReader.h \ |
24 | QTReaderApp.h \ | 23 | QTReaderApp.h \ |
25 | QtrListView.h \ | 24 | QtrListView.h \ |
26 | Queue.h \ | 25 | Queue.h \ |
27 | StateData.h \ | 26 | StateData.h \ |
28 | StyleConsts.h \ | 27 | StyleConsts.h \ |
29 | ToolbarPrefs.h \ | 28 | ToolbarPrefs.h \ |
30 | URLDialog.h \ | 29 | URLDialog.h \ |
31 | ZText.h \ | 30 | ZText.h \ |
32 | arith.h \ | 31 | arith.h \ |
33 | cbkmkselector.h \ | 32 | cbkmkselector.h \ |
34 | config.h \ | 33 | config.h \ |
35 | fileBrowser.h \ | 34 | fileBrowser.h \ |
36 | infowin.h \ | 35 | infowin.h \ |
37 | linktype.h \ | 36 | linktype.h \ |
38 | my_list.h \ | 37 | my_list.h \ |
39 | names.h \ | 38 | names.h \ |
40 | opie.h \ | 39 | opie.h \ |
41 | pdb.h \ | 40 | pdb.h \ |
42 | plucker_base.h \ | 41 | plucker_base.h \ |
43 | plucker.h \ | 42 | plucker.h \ |
44 | ppm.h \ | 43 | ppm.h \ |
45 | ppm_expander.h \ | 44 | ppm_expander.h \ |
46 | usenef.h \ | 45 | usenef.h \ |
47 | useqpe.h \ | 46 | useqpe.h \ |
48 | ustring.h \ | 47 | ustring.h \ |
49 | utypes.h \ | 48 | utypes.h \ |
50 | version.h \ | 49 | version.h \ |
51 | ztxt.h | 50 | ztxt.h |
52 | 51 | ||
53 | SOURCES = Aportis.cpp \ | 52 | SOURCES = Aportis.cpp \ |
54 | Bkmks.cpp \ | 53 | Bkmks.cpp \ |
55 | BuffDoc.cpp \ | 54 | BuffDoc.cpp \ |
56 | CBuffer.cpp \ | 55 | CBuffer.cpp \ |
57 | CDrawBuffer.cpp \ | 56 | CDrawBuffer.cpp \ |
58 | CEncoding.cpp \ | 57 | CEncoding.cpp \ |
59 | CEncoding_tables.cpp \ | 58 | CEncoding_tables.cpp \ |
60 | CFilter.cpp \ | 59 | CFilter.cpp \ |
61 | CloseDialog.cpp \ | 60 | CloseDialog.cpp \ |
62 | FontControl.cpp \ | 61 | FontControl.cpp \ |
63 | Navigation.cpp \ | 62 | Navigation.cpp \ |
64 | Palm2QImage.cpp \ | 63 | Palm2QImage.cpp \ |
65 | Prefs.cpp \ | 64 | Prefs.cpp \ |
66 | QTReader.cpp \ | 65 | QTReader.cpp \ |
67 | QTReaderApp.cpp \ | 66 | QTReaderApp.cpp \ |
68 | QtrListView.cpp \ | 67 | QtrListView.cpp \ |
69 | StyleConsts.cpp \ | 68 | StyleConsts.cpp \ |
70 | ToolbarPrefs.cpp \ | 69 | ToolbarPrefs.cpp \ |
71 | URLDialog.cpp \ | 70 | URLDialog.cpp \ |
72 | arith_d.cpp \ | 71 | arith_d.cpp \ |
73 | fileBrowser.cpp \ | 72 | fileBrowser.cpp \ |
74 | infowin.cpp \ | 73 | infowin.cpp \ |
75 | main.cpp \ | 74 | main.cpp \ |
76 | pdb.cpp \ | 75 | pdb.cpp \ |
77 | plucker.cpp \ | 76 | plucker.cpp \ |
78 | plucker_base.cpp \ | 77 | plucker_base.cpp \ |
79 | ppm.cpp \ | 78 | ppm.cpp \ |
80 | ppm_expander.cpp \ | 79 | ppm_expander.cpp \ |
81 | version.cpp \ | 80 | version.cpp \ |
82 | ztxt.cpp | 81 | ztxt.cpp |
83 | 82 | ||
84 | INTERFACES= | 83 | DESTDIR = $(OPIEDIR)/bin |
85 | DESTDIR = $(OPIEDIR)/bin | 84 | TARGET = reader |
85 | |||
86 | INCLUDEPATH+= $(OPIEDIR)/include | 86 | INCLUDEPATH+= $(OPIEDIR)/include |
87 | DEPENDPATH+= $(OPIEDIR)/include | 87 | DEPENDPATH+= $(OPIEDIR)/include |
88 | TARGET = reader | ||
89 | LIBS += -lqpe | 88 | LIBS += -lqpe |
90 | 89 | ||
91 | include ( $(OPIEDIR)/include.pro ) | 90 | include ( $(OPIEDIR)/include.pro ) |
92 | 91 | ||
93 | 92 | ||
diff --git a/noncore/apps/opie-sheet/main.cpp b/noncore/apps/opie-sheet/main.cpp index e42b4a5..d0a2995 100644 --- a/noncore/apps/opie-sheet/main.cpp +++ b/noncore/apps/opie-sheet/main.cpp | |||
@@ -1,28 +1,22 @@ | |||
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 | 9 | ||
10 | /* | 10 | /* |
11 | * Opie Sheet (formerly Sheet/Qt) | 11 | * Opie Sheet (formerly Sheet/Qt) |
12 | * by Serdar Ozler <sozler@sitebest.com> | 12 | * by Serdar Ozler <sozler@sitebest.com> |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include <qpe/qpeapplication.h> | 15 | #include <qpe/qpeapplication.h> |
16 | 16 | ||
17 | #include "mainwindow.h" | 17 | #include "mainwindow.h" |
18 | 18 | ||
19 | int main(int argc, char **argv) | 19 | #include <opie/oapplicationfactory.h> |
20 | { | ||
21 | QPEApplication application(argc, argv); | ||
22 | 20 | ||
23 | MainWindow windowMain; | 21 | OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) |
24 | windowMain.setHelpFile(application.qpeDir()+"/help/html/"+QString(argv[0])+".html"); | ||
25 | application.showMainDocumentWidget(&windowMain); | ||
26 | 22 | ||
27 | return application.exec(); | ||
28 | } | ||
diff --git a/noncore/apps/opie-sheet/mainwindow.cpp b/noncore/apps/opie-sheet/mainwindow.cpp index 43e5131..3915e52 100644 --- a/noncore/apps/opie-sheet/mainwindow.cpp +++ b/noncore/apps/opie-sheet/mainwindow.cpp | |||
@@ -1,835 +1,835 @@ | |||
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 | 9 | ||
10 | /* | 10 | /* |
11 | * Opie Sheet (formerly Sheet/Qt) | 11 | * Opie Sheet (formerly Sheet/Qt) |
12 | * by Serdar Ozler <sozler@sitebest.com> | 12 | * by Serdar Ozler <sozler@sitebest.com> |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include "mainwindow.h" | 15 | #include "mainwindow.h" |
16 | 16 | ||
17 | #include <qpe/filemanager.h> | 17 | #include <qpe/filemanager.h> |
18 | #include <qpe/qcopenvelope_qws.h> | 18 | #include <qpe/qcopenvelope_qws.h> |
19 | #include <qpe/resource.h> | 19 | #include <qpe/resource.h> |
20 | #include <qmessagebox.h> | 20 | #include <qmessagebox.h> |
21 | #include <qfile.h> | 21 | #include <qfile.h> |
22 | #include <qtranslator.h> | 22 | #include <qtranslator.h> |
23 | #include <qradiobutton.h> | 23 | #include <qradiobutton.h> |
24 | #include "cellformat.h" | 24 | #include "cellformat.h" |
25 | #include "numberdlg.h" | 25 | #include "numberdlg.h" |
26 | #include "textdlg.h" | 26 | #include "textdlg.h" |
27 | #include "sortdlg.h" | 27 | #include "sortdlg.h" |
28 | #include "finddlg.h" | 28 | #include "finddlg.h" |
29 | 29 | ||
30 | 30 | ||
31 | #include "func-plus.xpm" | 31 | #include "func-plus.xpm" |
32 | #include "func-minus.xpm" | 32 | #include "func-minus.xpm" |
33 | #include "func-cross.xpm" | 33 | #include "func-cross.xpm" |
34 | #include "func-divide.xpm" | 34 | #include "func-divide.xpm" |
35 | #include "func-paran-open.xpm" | 35 | #include "func-paran-open.xpm" |
36 | #include "func-paran-close.xpm" | 36 | #include "func-paran-close.xpm" |
37 | #include "func-comma.xpm" | 37 | #include "func-comma.xpm" |
38 | #include "func-func.xpm" | 38 | #include "func-func.xpm" |
39 | #include "func-equal.xpm" | 39 | #include "func-equal.xpm" |
40 | #include "cell-select.xpm" | 40 | #include "cell-select.xpm" |
41 | 41 | ||
42 | #define DEFAULT_NUM_ROWS 199 | 42 | #define DEFAULT_NUM_ROWS 199 |
43 | #define DEFAULT_NUM_COLS (26*3) | 43 | #define DEFAULT_NUM_COLS (26*3) |
44 | #define DEFAULT_NUM_SHEETS 3 | 44 | #define DEFAULT_NUM_SHEETS 3 |
45 | 45 | ||
46 | MainWindow::MainWindow() | 46 | MainWindow::MainWindow(QWidget *parent, const char* n, WFlags fl) |
47 | :QMainWindow() | 47 | :QMainWindow(parent, n, fl) |
48 | { | 48 | { |
49 | // initialize variables | 49 | // initialize variables |
50 | documentModified=FALSE; | 50 | documentModified=FALSE; |
51 | 51 | ||
52 | // construct objects | 52 | // construct objects |
53 | currentDoc=0; | 53 | currentDoc=0; |
54 | fileSelector=new FileSelector("application/sheet-qt", this, QString::null); | 54 | fileSelector=new FileSelector("application/sheet-qt", this, QString::null); |
55 | connect(fileSelector, SIGNAL(closeMe()), this, SLOT(selectorHide())); | 55 | connect(fileSelector, SIGNAL(closeMe()), this, SLOT(selectorHide())); |
56 | connect(fileSelector, SIGNAL(newSelected(const DocLnk &)), this, SLOT(selectorFileNew(const DocLnk &))); | 56 | connect(fileSelector, SIGNAL(newSelected(const DocLnk &)), this, SLOT(selectorFileNew(const DocLnk &))); |
57 | connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), this, SLOT(selectorFileOpen(const DocLnk &))); | 57 | connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), this, SLOT(selectorFileOpen(const DocLnk &))); |
58 | 58 | ||
59 | listSheets.setAutoDelete(TRUE); | 59 | listSheets.setAutoDelete(TRUE); |
60 | 60 | ||
61 | initActions(); | 61 | initActions(); |
62 | initMenu(); | 62 | initMenu(); |
63 | initEditToolbar(); | 63 | initEditToolbar(); |
64 | initFunctionsToolbar(); | 64 | initFunctionsToolbar(); |
65 | initStandardToolbar(); | 65 | initStandardToolbar(); |
66 | initSheet(); | 66 | initSheet(); |
67 | 67 | ||
68 | // set window title | 68 | // set window title |
69 | setCaption(tr("Opie Sheet")); | 69 | setCaption(tr("Opie Sheet")); |
70 | 70 | ||
71 | // create sheets | 71 | // create sheets |
72 | selectorFileNew(DocLnk()); | 72 | selectorFileNew(DocLnk()); |
73 | } | 73 | } |
74 | 74 | ||
75 | MainWindow::~MainWindow() | 75 | MainWindow::~MainWindow() |
76 | { | 76 | { |
77 | if (currentDoc) delete currentDoc; | 77 | if (currentDoc) delete currentDoc; |
78 | } | 78 | } |
79 | 79 | ||
80 | void MainWindow::documentSave(DocLnk *lnkDoc) | 80 | void MainWindow::documentSave(DocLnk *lnkDoc) |
81 | { | 81 | { |
82 | FileManager fm; | 82 | FileManager fm; |
83 | QByteArray streamBuffer; | 83 | QByteArray streamBuffer; |
84 | QDataStream stream(streamBuffer, IO_WriteOnly); | 84 | QDataStream stream(streamBuffer, IO_WriteOnly); |
85 | 85 | ||
86 | typeSheet *currentSheet=findSheet(sheet->getName()); | 86 | typeSheet *currentSheet=findSheet(sheet->getName()); |
87 | if (!currentSheet) | 87 | if (!currentSheet) |
88 | { | 88 | { |
89 | QMessageBox::critical(this, tr("Error"), tr("Inconsistency error!")); | 89 | QMessageBox::critical(this, tr("Error"), tr("Inconsistency error!")); |
90 | return; | 90 | return; |
91 | } | 91 | } |
92 | sheet->copySheetData(¤tSheet->data); | 92 | sheet->copySheetData(¤tSheet->data); |
93 | stream.writeRawBytes("SQT100", 6); | 93 | stream.writeRawBytes("SQT100", 6); |
94 | stream << (Q_UINT32)listSheets.count(); | 94 | stream << (Q_UINT32)listSheets.count(); |
95 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) | 95 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) |
96 | { | 96 | { |
97 | stream << tempSheet->name << (Q_UINT32)tempSheet->data.count(); | 97 | stream << tempSheet->name << (Q_UINT32)tempSheet->data.count(); |
98 | for (typeCellData *tempCell=tempSheet->data.first(); tempCell; tempCell=tempSheet->data.next()) | 98 | for (typeCellData *tempCell=tempSheet->data.first(); tempCell; tempCell=tempSheet->data.next()) |
99 | stream << (Q_UINT32)tempCell->col << (Q_UINT32)tempCell->row << tempCell->borders.right << tempCell->borders.bottom << tempCell->background << (Q_UINT32)tempCell->alignment << tempCell->fontColor << tempCell->font << tempCell->data; | 99 | stream << (Q_UINT32)tempCell->col << (Q_UINT32)tempCell->row << tempCell->borders.right << tempCell->borders.bottom << tempCell->background << (Q_UINT32)tempCell->alignment << tempCell->fontColor << tempCell->font << tempCell->data; |
100 | } | 100 | } |
101 | 101 | ||
102 | lnkDoc->setType("application/sheet-qt"); | 102 | lnkDoc->setType("application/sheet-qt"); |
103 | if (!fm.saveFile(*lnkDoc, streamBuffer)) | 103 | if (!fm.saveFile(*lnkDoc, streamBuffer)) |
104 | { | 104 | { |
105 | QMessageBox::critical(this, tr("Error"), tr("File cannot be saved!")); | 105 | QMessageBox::critical(this, tr("Error"), tr("File cannot be saved!")); |
106 | return; | 106 | return; |
107 | } | 107 | } |
108 | documentModified=FALSE; | 108 | documentModified=FALSE; |
109 | } | 109 | } |
110 | 110 | ||
111 | void MainWindow::documentOpen(const DocLnk &lnkDoc) | 111 | void MainWindow::documentOpen(const DocLnk &lnkDoc) |
112 | { | 112 | { |
113 | FileManager fm; | 113 | FileManager fm; |
114 | QByteArray streamBuffer; | 114 | QByteArray streamBuffer; |
115 | if (!lnkDoc.isValid() || !fm.loadFile(lnkDoc, streamBuffer)) | 115 | if (!lnkDoc.isValid() || !fm.loadFile(lnkDoc, streamBuffer)) |
116 | { | 116 | { |
117 | QMessageBox::critical(this, tr("Error"), tr("File cannot be opened!")); | 117 | QMessageBox::critical(this, tr("Error"), tr("File cannot be opened!")); |
118 | documentModified=FALSE; | 118 | documentModified=FALSE; |
119 | selectorFileNew(DocLnk()); | 119 | selectorFileNew(DocLnk()); |
120 | return; | 120 | return; |
121 | } | 121 | } |
122 | QDataStream stream(streamBuffer, IO_ReadOnly); | 122 | QDataStream stream(streamBuffer, IO_ReadOnly); |
123 | 123 | ||
124 | Q_UINT32 countSheet, countCell, i, j, row, col, alignment; | 124 | Q_UINT32 countSheet, countCell, i, j, row, col, alignment; |
125 | typeSheet *newSheet; | 125 | typeSheet *newSheet; |
126 | typeCellData *newCell; | 126 | typeCellData *newCell; |
127 | 127 | ||
128 | char fileFormat[7]; | 128 | char fileFormat[7]; |
129 | stream.readRawBytes(fileFormat, 6); | 129 | stream.readRawBytes(fileFormat, 6); |
130 | fileFormat[6]=0; | 130 | fileFormat[6]=0; |
131 | if ((QString)fileFormat!="SQT100") | 131 | if ((QString)fileFormat!="SQT100") |
132 | { | 132 | { |
133 | QMessageBox::critical(this, tr("Error"), tr("Invalid file format!")); | 133 | QMessageBox::critical(this, tr("Error"), tr("Invalid file format!")); |
134 | documentModified=FALSE; | 134 | documentModified=FALSE; |
135 | selectorFileNew(DocLnk()); | 135 | selectorFileNew(DocLnk()); |
136 | return; | 136 | return; |
137 | } | 137 | } |
138 | 138 | ||
139 | stream >> countSheet; | 139 | stream >> countSheet; |
140 | for (i=0; i<countSheet; ++i) | 140 | for (i=0; i<countSheet; ++i) |
141 | { | 141 | { |
142 | newSheet=new typeSheet; | 142 | newSheet=new typeSheet; |
143 | newSheet->data.setAutoDelete(TRUE); | 143 | newSheet->data.setAutoDelete(TRUE); |
144 | stream >> newSheet->name >> countCell; | 144 | stream >> newSheet->name >> countCell; |
145 | comboSheets->insertItem(newSheet->name); | 145 | comboSheets->insertItem(newSheet->name); |
146 | 146 | ||
147 | for (j=0; j<countCell; ++j) | 147 | for (j=0; j<countCell; ++j) |
148 | { | 148 | { |
149 | newCell=new typeCellData; | 149 | newCell=new typeCellData; |
150 | stream >> col >> row >> newCell->borders.right >> newCell->borders.bottom >> newCell->background >> alignment >> newCell->fontColor >> newCell->font >> newCell->data; | 150 | stream >> col >> row >> newCell->borders.right >> newCell->borders.bottom >> newCell->background >> alignment >> newCell->fontColor >> newCell->font >> newCell->data; |
151 | newCell->col=col; | 151 | newCell->col=col; |
152 | newCell->row=row; | 152 | newCell->row=row; |
153 | newCell->alignment=(Qt::AlignmentFlags)alignment; | 153 | newCell->alignment=(Qt::AlignmentFlags)alignment; |
154 | newSheet->data.append(newCell); | 154 | newSheet->data.append(newCell); |
155 | } | 155 | } |
156 | listSheets.append(newSheet); | 156 | listSheets.append(newSheet); |
157 | 157 | ||
158 | if (i==0) | 158 | if (i==0) |
159 | { | 159 | { |
160 | sheet->setName(newSheet->name); | 160 | sheet->setName(newSheet->name); |
161 | sheet->setSheetData(&newSheet->data); | 161 | sheet->setSheetData(&newSheet->data); |
162 | } | 162 | } |
163 | } | 163 | } |
164 | } | 164 | } |
165 | 165 | ||
166 | int MainWindow::saveCurrentFile(bool ask) | 166 | int MainWindow::saveCurrentFile(bool ask) |
167 | { | 167 | { |
168 | if (ask) | 168 | if (ask) |
169 | { | 169 | { |
170 | int result=QMessageBox::information(this, tr("Save File"), tr("Do you want to save the current file?"), QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel); | 170 | int result=QMessageBox::information(this, tr("Save File"), tr("Do you want to save the current file?"), QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel); |
171 | if (result!=QMessageBox::Yes) return result; | 171 | if (result!=QMessageBox::Yes) return result; |
172 | } | 172 | } |
173 | 173 | ||
174 | if (!currentDoc->isValid()) | 174 | if (!currentDoc->isValid()) |
175 | { | 175 | { |
176 | TextDialog dialogText(this); | 176 | TextDialog dialogText(this); |
177 | if (dialogText.exec(tr("Save File"), tr("&File Name:"), tr("UnnamedFile"))!=QDialog::Accepted || dialogText.getValue().isEmpty()) return QMessageBox::Cancel; | 177 | if (dialogText.exec(tr("Save File"), tr("&File Name:"), tr("UnnamedFile"))!=QDialog::Accepted || dialogText.getValue().isEmpty()) return QMessageBox::Cancel; |
178 | 178 | ||
179 | currentDoc->setName(dialogText.getValue()); | 179 | currentDoc->setName(dialogText.getValue()); |
180 | currentDoc->setFile(QString::null); | 180 | currentDoc->setFile(QString::null); |
181 | currentDoc->setLinkFile(QString::null); | 181 | currentDoc->setLinkFile(QString::null); |
182 | } | 182 | } |
183 | 183 | ||
184 | documentSave(currentDoc); | 184 | documentSave(currentDoc); |
185 | return QMessageBox::Yes; | 185 | return QMessageBox::Yes; |
186 | } | 186 | } |
187 | 187 | ||
188 | void MainWindow::selectorFileNew(const DocLnk &lnkDoc) | 188 | void MainWindow::selectorFileNew(const DocLnk &lnkDoc) |
189 | { | 189 | { |
190 | selectorHide(); | 190 | selectorHide(); |
191 | 191 | ||
192 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; | 192 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; |
193 | if (currentDoc) delete currentDoc; | 193 | if (currentDoc) delete currentDoc; |
194 | currentDoc = new DocLnk(lnkDoc); | 194 | currentDoc = new DocLnk(lnkDoc); |
195 | editData->clear(); | 195 | editData->clear(); |
196 | listSheets.clear(); | 196 | listSheets.clear(); |
197 | comboSheets->clear(); | 197 | comboSheets->clear(); |
198 | 198 | ||
199 | typeSheet *newSheet=createNewSheet(); | 199 | typeSheet *newSheet=createNewSheet(); |
200 | newSheet->data.setAutoDelete(TRUE); | 200 | newSheet->data.setAutoDelete(TRUE); |
201 | sheet->setName(newSheet->name); | 201 | sheet->setName(newSheet->name); |
202 | sheet->setSheetData(&newSheet->data); | 202 | sheet->setSheetData(&newSheet->data); |
203 | for (int i=1; i<DEFAULT_NUM_SHEETS; ++i) | 203 | for (int i=1; i<DEFAULT_NUM_SHEETS; ++i) |
204 | createNewSheet(); | 204 | createNewSheet(); |
205 | documentModified=FALSE; | 205 | documentModified=FALSE; |
206 | } | 206 | } |
207 | 207 | ||
208 | void MainWindow::closeEvent(QCloseEvent *e) | 208 | void MainWindow::closeEvent(QCloseEvent *e) |
209 | { | 209 | { |
210 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) e->ignore(); | 210 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) e->ignore(); |
211 | else e->accept(); | 211 | else e->accept(); |
212 | } | 212 | } |
213 | 213 | ||
214 | void MainWindow::selectorFileOpen(const DocLnk &lnkDoc) | 214 | void MainWindow::selectorFileOpen(const DocLnk &lnkDoc) |
215 | { | 215 | { |
216 | selectorHide(); | 216 | selectorHide(); |
217 | 217 | ||
218 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; | 218 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; |
219 | if (currentDoc) delete currentDoc; | 219 | if (currentDoc) delete currentDoc; |
220 | currentDoc = new DocLnk(lnkDoc); | 220 | currentDoc = new DocLnk(lnkDoc); |
221 | listSheets.clear(); | 221 | listSheets.clear(); |
222 | comboSheets->clear(); | 222 | comboSheets->clear(); |
223 | 223 | ||
224 | documentOpen(lnkDoc); | 224 | documentOpen(lnkDoc); |
225 | documentModified=FALSE; | 225 | documentModified=FALSE; |
226 | } | 226 | } |
227 | 227 | ||
228 | void MainWindow::selectorShow() | 228 | void MainWindow::selectorShow() |
229 | { | 229 | { |
230 | sheet->hide(); | 230 | sheet->hide(); |
231 | setCentralWidget(fileSelector); | 231 | setCentralWidget(fileSelector); |
232 | fileSelector->show(); | 232 | fileSelector->show(); |
233 | fileSelector->reread(); | 233 | fileSelector->reread(); |
234 | } | 234 | } |
235 | 235 | ||
236 | void MainWindow::selectorHide() | 236 | void MainWindow::selectorHide() |
237 | { | 237 | { |
238 | fileSelector->hide(); | 238 | fileSelector->hide(); |
239 | setCentralWidget(sheet); | 239 | setCentralWidget(sheet); |
240 | sheet->show(); | 240 | sheet->show(); |
241 | } | 241 | } |
242 | 242 | ||
243 | void MainWindow::slotFileNew() | 243 | void MainWindow::slotFileNew() |
244 | { | 244 | { |
245 | selectorFileNew(DocLnk()); | 245 | selectorFileNew(DocLnk()); |
246 | } | 246 | } |
247 | 247 | ||
248 | void MainWindow::slotFileOpen() | 248 | void MainWindow::slotFileOpen() |
249 | { | 249 | { |
250 | selectorShow(); | 250 | selectorShow(); |
251 | } | 251 | } |
252 | 252 | ||
253 | void MainWindow::slotFileSave() | 253 | void MainWindow::slotFileSave() |
254 | { | 254 | { |
255 | saveCurrentFile(FALSE); | 255 | saveCurrentFile(FALSE); |
256 | } | 256 | } |
257 | 257 | ||
258 | void MainWindow::setDocument(const QString &applnk_filename) | 258 | void MainWindow::setDocument(const QString &applnk_filename) |
259 | { | 259 | { |
260 | selectorFileOpen(DocLnk(applnk_filename)); | 260 | selectorFileOpen(DocLnk(applnk_filename)); |
261 | } | 261 | } |
262 | 262 | ||
263 | void MainWindow::initActions() | 263 | void MainWindow::initActions() |
264 | { | 264 | { |
265 | fileNew=new QAction(tr("New File"), Resource::loadPixmap( "new" ), tr("&New"), 0, this); | 265 | fileNew=new QAction(tr("New File"), Resource::loadPixmap( "new" ), tr("&New"), 0, this); |
266 | connect(fileNew, SIGNAL(activated()), this, SLOT(slotFileNew())); | 266 | connect(fileNew, SIGNAL(activated()), this, SLOT(slotFileNew())); |
267 | fileOpen=new QAction(tr("Open File"), Resource::loadPixmap( "fileopen" ), tr("&Open"), 0, this); | 267 | fileOpen=new QAction(tr("Open File"), Resource::loadPixmap( "fileopen" ), tr("&Open"), 0, this); |
268 | connect(fileOpen, SIGNAL(activated()), this, SLOT(slotFileOpen())); | 268 | connect(fileOpen, SIGNAL(activated()), this, SLOT(slotFileOpen())); |
269 | fileSave=new QAction(tr("Save File"),Resource::loadPixmap( "save" ), tr("&Save"), 0, this); | 269 | fileSave=new QAction(tr("Save File"),Resource::loadPixmap( "save" ), tr("&Save"), 0, this); |
270 | connect(fileSave, SIGNAL(activated()), this, SLOT(slotFileSave())); | 270 | connect(fileSave, SIGNAL(activated()), this, SLOT(slotFileSave())); |
271 | fileSaveAs=new QAction(tr("Save File As"), Resource::loadPixmap( "save" ), tr("Save &As"), 0, this); | 271 | fileSaveAs=new QAction(tr("Save File As"), Resource::loadPixmap( "save" ), tr("Save &As"), 0, this); |
272 | connect(fileSaveAs, SIGNAL(activated()), this, SLOT(slotFileSaveAs())); | 272 | connect(fileSaveAs, SIGNAL(activated()), this, SLOT(slotFileSaveAs())); |
273 | //fileQuit=new QAction(tr("Quit"), tr("&Quit"), 0, this); | 273 | //fileQuit=new QAction(tr("Quit"), tr("&Quit"), 0, this); |
274 | //connect(fileQuit, SIGNAL(activated()), this, SLOT(close())); | 274 | //connect(fileQuit, SIGNAL(activated()), this, SLOT(close())); |
275 | 275 | ||
276 | // helpGeneral=new QAction(tr("General Help"), QPixmap(help_general_xpm), tr("&General"), 0, this); | 276 | // helpGeneral=new QAction(tr("General Help"), QPixmap(help_general_xpm), tr("&General"), 0, this); |
277 | //connect(helpGeneral, SIGNAL(activated()), this, SLOT(slotHelpGeneral())); | 277 | //connect(helpGeneral, SIGNAL(activated()), this, SLOT(slotHelpGeneral())); |
278 | //helpAbout=new QAction(tr("About Opie Sheet"), tr("&About"), 0, this); | 278 | //helpAbout=new QAction(tr("About Opie Sheet"), tr("&About"), 0, this); |
279 | //connect(helpAbout, SIGNAL(activated()), this, SLOT(slotHelpAbout())); | 279 | //connect(helpAbout, SIGNAL(activated()), this, SLOT(slotHelpAbout())); |
280 | 280 | ||
281 | editAccept=new QAction(tr("Accept"),Resource::loadPixmap( "enter" ) , tr("&Accept"), 0, this); | 281 | editAccept=new QAction(tr("Accept"),Resource::loadPixmap( "enter" ) , tr("&Accept"), 0, this); |
282 | connect(editAccept, SIGNAL(activated()), this, SLOT(slotEditAccept())); | 282 | connect(editAccept, SIGNAL(activated()), this, SLOT(slotEditAccept())); |
283 | editCancel=new QAction(tr("Cancel"), Resource::loadPixmap( "close" ), tr("&Cancel"), 0, this); | 283 | editCancel=new QAction(tr("Cancel"), Resource::loadPixmap( "close" ), tr("&Cancel"), 0, this); |
284 | connect(editCancel, SIGNAL(activated()), this, SLOT(slotEditCancel())); | 284 | connect(editCancel, SIGNAL(activated()), this, SLOT(slotEditCancel())); |
285 | editCellSelect=new QAction(tr("Cell Selector"), QPixmap(cell_select_xpm), tr("Cell &Selector"), 0, this); | 285 | editCellSelect=new QAction(tr("Cell Selector"), QPixmap(cell_select_xpm), tr("Cell &Selector"), 0, this); |
286 | editCellSelect->setToggleAction(TRUE); | 286 | editCellSelect->setToggleAction(TRUE); |
287 | connect(editCellSelect, SIGNAL(toggled(bool)), this, SLOT(slotCellSelect(bool))); | 287 | connect(editCellSelect, SIGNAL(toggled(bool)), this, SLOT(slotCellSelect(bool))); |
288 | editCut=new QAction(tr("Cut Cells"), tr("Cu&t"), 0, this); | 288 | editCut=new QAction(tr("Cut Cells"), tr("Cu&t"), 0, this); |
289 | editCopy=new QAction(tr("Copy Cells"), tr("&Copy"), 0, this); | 289 | editCopy=new QAction(tr("Copy Cells"), tr("&Copy"), 0, this); |
290 | editPaste=new QAction(tr("Paste Cells"), tr("&Paste"), 0, this); | 290 | editPaste=new QAction(tr("Paste Cells"), tr("&Paste"), 0, this); |
291 | connect(editPaste, SIGNAL(activated()), this, SLOT(slotEditPaste())); | 291 | connect(editPaste, SIGNAL(activated()), this, SLOT(slotEditPaste())); |
292 | editPasteContents=new QAction(tr("Paste Contents"), tr("Paste Cont&ents"), 0, this); | 292 | editPasteContents=new QAction(tr("Paste Contents"), tr("Paste Cont&ents"), 0, this); |
293 | connect(editPasteContents, SIGNAL(activated()), this, SLOT(slotEditPasteContents())); | 293 | connect(editPasteContents, SIGNAL(activated()), this, SLOT(slotEditPasteContents())); |
294 | editClear=new QAction(tr("Clear Cells"), tr("C&lear"), 0, this); | 294 | editClear=new QAction(tr("Clear Cells"), tr("C&lear"), 0, this); |
295 | 295 | ||
296 | insertCells=new QAction(tr("Insert Cells"), tr("C&ells"), 0, this); | 296 | insertCells=new QAction(tr("Insert Cells"), tr("C&ells"), 0, this); |
297 | connect(insertCells, SIGNAL(activated()), this, SLOT(slotInsertCells())); | 297 | connect(insertCells, SIGNAL(activated()), this, SLOT(slotInsertCells())); |
298 | insertRows=new QAction(tr("Insert Rows"), tr("&Rows"), 0, this); | 298 | insertRows=new QAction(tr("Insert Rows"), tr("&Rows"), 0, this); |
299 | connect(insertRows, SIGNAL(activated()), this, SLOT(slotInsertRows())); | 299 | connect(insertRows, SIGNAL(activated()), this, SLOT(slotInsertRows())); |
300 | insertCols=new QAction(tr("Insert Columns"), tr("&Columns"), 0, this); | 300 | insertCols=new QAction(tr("Insert Columns"), tr("&Columns"), 0, this); |
301 | connect(insertCols, SIGNAL(activated()), this, SLOT(slotInsertCols())); | 301 | connect(insertCols, SIGNAL(activated()), this, SLOT(slotInsertCols())); |
302 | insertSheets=new QAction(tr("Add Sheets"), tr("&Sheets"), 0, this); | 302 | insertSheets=new QAction(tr("Add Sheets"), tr("&Sheets"), 0, this); |
303 | connect(insertSheets, SIGNAL(activated()), this, SLOT(slotInsertSheets())); | 303 | connect(insertSheets, SIGNAL(activated()), this, SLOT(slotInsertSheets())); |
304 | 304 | ||
305 | formatCells=new QAction(tr("Cells"), tr("&Cells"), 0, this); | 305 | formatCells=new QAction(tr("Cells"), tr("&Cells"), 0, this); |
306 | connect(formatCells, SIGNAL(activated()), this, SLOT(slotFormatCells())); | 306 | connect(formatCells, SIGNAL(activated()), this, SLOT(slotFormatCells())); |
307 | 307 | ||
308 | rowHeight=new QAction(tr("Row Height"), tr("H&eight"), 0, this); | 308 | rowHeight=new QAction(tr("Row Height"), tr("H&eight"), 0, this); |
309 | connect(rowHeight, SIGNAL(activated()), this, SLOT(slotRowHeight())); | 309 | connect(rowHeight, SIGNAL(activated()), this, SLOT(slotRowHeight())); |
310 | rowAdjust=new QAction(tr("Adjust Row"), tr("&Adjust"), 0, this); | 310 | rowAdjust=new QAction(tr("Adjust Row"), tr("&Adjust"), 0, this); |
311 | connect(rowAdjust, SIGNAL(activated()), this, SLOT(slotRowAdjust())); | 311 | connect(rowAdjust, SIGNAL(activated()), this, SLOT(slotRowAdjust())); |
312 | rowShow=new QAction(tr("Show Row"), tr("&Show"), 0, this); | 312 | rowShow=new QAction(tr("Show Row"), tr("&Show"), 0, this); |
313 | connect(rowShow, SIGNAL(activated()), this, SLOT(slotRowShow())); | 313 | connect(rowShow, SIGNAL(activated()), this, SLOT(slotRowShow())); |
314 | rowHide=new QAction(tr("Hide Row"), tr("&Hide"), 0, this); | 314 | rowHide=new QAction(tr("Hide Row"), tr("&Hide"), 0, this); |
315 | connect(rowHide, SIGNAL(activated()), this, SLOT(slotRowHide())); | 315 | connect(rowHide, SIGNAL(activated()), this, SLOT(slotRowHide())); |
316 | 316 | ||
317 | colWidth=new QAction(tr("Column Width"), tr("&Width"), 0, this); | 317 | colWidth=new QAction(tr("Column Width"), tr("&Width"), 0, this); |
318 | connect(colWidth, SIGNAL(activated()), this, SLOT(slotColumnWidth())); | 318 | connect(colWidth, SIGNAL(activated()), this, SLOT(slotColumnWidth())); |
319 | colAdjust=new QAction(tr("Adjust Column"), tr("&Adjust"), 0, this); | 319 | colAdjust=new QAction(tr("Adjust Column"), tr("&Adjust"), 0, this); |
320 | connect(colAdjust, SIGNAL(activated()), this, SLOT(slotColumnAdjust())); | 320 | connect(colAdjust, SIGNAL(activated()), this, SLOT(slotColumnAdjust())); |
321 | colShow=new QAction(tr("Show Column"), tr("&Show"), 0, this); | 321 | colShow=new QAction(tr("Show Column"), tr("&Show"), 0, this); |
322 | connect(colShow, SIGNAL(activated()), this, SLOT(slotColumnShow())); | 322 | connect(colShow, SIGNAL(activated()), this, SLOT(slotColumnShow())); |
323 | colHide=new QAction(tr("Hide Column"), tr("&Hide"), 0, this); | 323 | colHide=new QAction(tr("Hide Column"), tr("&Hide"), 0, this); |
324 | connect(colHide, SIGNAL(activated()), this, SLOT(slotColumnHide())); | 324 | connect(colHide, SIGNAL(activated()), this, SLOT(slotColumnHide())); |
325 | 325 | ||
326 | sheetRename=new QAction(tr("Rename Sheet"), tr("&Rename"), 0, this); | 326 | sheetRename=new QAction(tr("Rename Sheet"), tr("&Rename"), 0, this); |
327 | connect(sheetRename, SIGNAL(activated()), this, SLOT(slotSheetRename())); | 327 | connect(sheetRename, SIGNAL(activated()), this, SLOT(slotSheetRename())); |
328 | sheetRemove=new QAction(tr("Remove Sheet"), tr("R&emove"), 0, this); | 328 | sheetRemove=new QAction(tr("Remove Sheet"), tr("R&emove"), 0, this); |
329 | connect(sheetRemove, SIGNAL(activated()), this, SLOT(slotSheetRemove())); | 329 | connect(sheetRemove, SIGNAL(activated()), this, SLOT(slotSheetRemove())); |
330 | 330 | ||
331 | dataSort=new QAction(tr("Sort Data"), tr("&Sort"), 0, this); | 331 | dataSort=new QAction(tr("Sort Data"), tr("&Sort"), 0, this); |
332 | connect(dataSort, SIGNAL(activated()), this, SLOT(slotDataSort())); | 332 | connect(dataSort, SIGNAL(activated()), this, SLOT(slotDataSort())); |
333 | dataFindReplace=new QAction(tr("Find && Replace"), tr("&Find && Replace"), 0, this); | 333 | dataFindReplace=new QAction(tr("Find && Replace"), tr("&Find && Replace"), 0, this); |
334 | connect(dataFindReplace, SIGNAL(activated()), this, SLOT(slotDataFindReplace())); | 334 | connect(dataFindReplace, SIGNAL(activated()), this, SLOT(slotDataFindReplace())); |
335 | 335 | ||
336 | funcEqual=new QAction(tr("Equal To"), QPixmap(func_equal_xpm), tr("&Equal To"), 0, this); | 336 | funcEqual=new QAction(tr("Equal To"), QPixmap(func_equal_xpm), tr("&Equal To"), 0, this); |
337 | funcEqual->setToolTip("="); | 337 | funcEqual->setToolTip("="); |
338 | connect(funcEqual, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 338 | connect(funcEqual, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
339 | funcPlus=new QAction(tr("Addition"), QPixmap(func_plus_xpm), tr("&Addition"), 0, this); | 339 | funcPlus=new QAction(tr("Addition"), QPixmap(func_plus_xpm), tr("&Addition"), 0, this); |
340 | funcPlus->setToolTip("+"); | 340 | funcPlus->setToolTip("+"); |
341 | connect(funcPlus, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 341 | connect(funcPlus, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
342 | funcMinus=new QAction(tr("Subtraction"), QPixmap(func_minus_xpm), tr("&Subtraction"), 0, this); | 342 | funcMinus=new QAction(tr("Subtraction"), QPixmap(func_minus_xpm), tr("&Subtraction"), 0, this); |
343 | funcMinus->setToolTip("-"); | 343 | funcMinus->setToolTip("-"); |
344 | connect(funcMinus, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 344 | connect(funcMinus, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
345 | funcCross=new QAction(tr("Multiplication"), QPixmap(func_cross_xpm), tr("&Multiplication"), 0, this); | 345 | funcCross=new QAction(tr("Multiplication"), QPixmap(func_cross_xpm), tr("&Multiplication"), 0, this); |
346 | funcCross->setToolTip("*"); | 346 | funcCross->setToolTip("*"); |
347 | connect(funcCross, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 347 | connect(funcCross, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
348 | funcDivide=new QAction(tr("Division"), QPixmap(func_divide_xpm), tr("&Division"), 0, this); | 348 | funcDivide=new QAction(tr("Division"), QPixmap(func_divide_xpm), tr("&Division"), 0, this); |
349 | funcDivide->setToolTip("/"); | 349 | funcDivide->setToolTip("/"); |
350 | connect(funcDivide, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 350 | connect(funcDivide, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
351 | funcParanOpen=new QAction(tr("Open ParanthesistempCellData->row+row1, tempCellData->col+col1"), QPixmap(func_paran_open_xpm), tr("&Open Paranthesis"), 0, this); | 351 | funcParanOpen=new QAction(tr("Open ParanthesistempCellData->row+row1, tempCellData->col+col1"), QPixmap(func_paran_open_xpm), tr("&Open Paranthesis"), 0, this); |
352 | funcParanOpen->setToolTip("("); | 352 | funcParanOpen->setToolTip("("); |
353 | connect(funcParanOpen, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 353 | connect(funcParanOpen, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
354 | funcParanClose=new QAction(tr("Close Paranthesis"), QPixmap(func_paran_close_xpm), tr("&Close Paranthesis"), 0, this); | 354 | funcParanClose=new QAction(tr("Close Paranthesis"), QPixmap(func_paran_close_xpm), tr("&Close Paranthesis"), 0, this); |
355 | funcParanClose->setToolTip(")"); | 355 | funcParanClose->setToolTip(")"); |
356 | connect(funcParanClose, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 356 | connect(funcParanClose, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
357 | funcComma=new QAction(tr("Comma"), QPixmap(func_comma_xpm), tr("&Comma"), 0, this); | 357 | funcComma=new QAction(tr("Comma"), QPixmap(func_comma_xpm), tr("&Comma"), 0, this); |
358 | funcComma->setToolTip(","); | 358 | funcComma->setToolTip(","); |
359 | connect(funcComma, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 359 | connect(funcComma, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
360 | } | 360 | } |
361 | 361 | ||
362 | void MainWindow::initMenu() | 362 | void MainWindow::initMenu() |
363 | { | 363 | { |
364 | menu=new QPEMenuBar(this); | 364 | menu=new QPEMenuBar(this); |
365 | 365 | ||
366 | menuFile=new QPopupMenu; | 366 | menuFile=new QPopupMenu; |
367 | fileNew->addTo(menuFile); | 367 | fileNew->addTo(menuFile); |
368 | fileOpen->addTo(menuFile); | 368 | fileOpen->addTo(menuFile); |
369 | fileSave->addTo(menuFile); | 369 | fileSave->addTo(menuFile); |
370 | fileSaveAs->addTo(menuFile); | 370 | fileSaveAs->addTo(menuFile); |
371 | // menuFile->insertSeparator(); | 371 | // menuFile->insertSeparator(); |
372 | // fileQuit->addTo(menuFile); | 372 | // fileQuit->addTo(menuFile); |
373 | menu->insertItem(tr("&File"), menuFile); | 373 | menu->insertItem(tr("&File"), menuFile); |
374 | 374 | ||
375 | menuEdit=new QPopupMenu; | 375 | menuEdit=new QPopupMenu; |
376 | editAccept->addTo(menuEdit); | 376 | editAccept->addTo(menuEdit); |
377 | editCancel->addTo(menuEdit); | 377 | editCancel->addTo(menuEdit); |
378 | editCellSelect->addTo(menuEdit); | 378 | editCellSelect->addTo(menuEdit); |
379 | menuEdit->insertSeparator(); | 379 | menuEdit->insertSeparator(); |
380 | editCut->addTo(menuEdit); | 380 | editCut->addTo(menuEdit); |
381 | editCopy->addTo(menuEdit); | 381 | editCopy->addTo(menuEdit); |
382 | editPaste->addTo(menuEdit); | 382 | editPaste->addTo(menuEdit); |
383 | editPasteContents->addTo(menuEdit); | 383 | editPasteContents->addTo(menuEdit); |
384 | editClear->addTo(menuEdit); | 384 | editClear->addTo(menuEdit); |
385 | menu->insertItem(tr("&Edit"), menuEdit); | 385 | menu->insertItem(tr("&Edit"), menuEdit); |
386 | 386 | ||
387 | menuInsert=new QPopupMenu; | 387 | menuInsert=new QPopupMenu; |
388 | menu->insertItem(tr("&Insert"), menuInsert); | 388 | menu->insertItem(tr("&Insert"), menuInsert); |
389 | 389 | ||
390 | menuFormat=new QPopupMenu; | 390 | menuFormat=new QPopupMenu; |
391 | formatCells->addTo(menuFormat); | 391 | formatCells->addTo(menuFormat); |
392 | menu->insertItem(tr("&Format"), menuFormat); | 392 | menu->insertItem(tr("&Format"), menuFormat); |
393 | 393 | ||
394 | menuData=new QPopupMenu; | 394 | menuData=new QPopupMenu; |
395 | dataSort->addTo(menuData); | 395 | dataSort->addTo(menuData); |
396 | dataFindReplace->addTo(menuData); | 396 | dataFindReplace->addTo(menuData); |
397 | menu->insertItem(tr("&Data"), menuData); | 397 | menu->insertItem(tr("&Data"), menuData); |
398 | 398 | ||
399 | // menuHelp=new QPopupMenu; | 399 | // menuHelp=new QPopupMenu; |
400 | // helpGeneral->addTo(menuHelp); | 400 | // helpGeneral->addTo(menuHelp); |
401 | // helpAbout->addTo(menuHelp); | 401 | // helpAbout->addTo(menuHelp); |
402 | // menu->insertItem(tr("&Help"), menuHelp); | 402 | // menu->insertItem(tr("&Help"), menuHelp); |
403 | 403 | ||
404 | submenuRow=new QPopupMenu; | 404 | submenuRow=new QPopupMenu; |
405 | rowHeight->addTo(submenuRow); | 405 | rowHeight->addTo(submenuRow); |
406 | rowAdjust->addTo(submenuRow); | 406 | rowAdjust->addTo(submenuRow); |
407 | rowShow->addTo(submenuRow); | 407 | rowShow->addTo(submenuRow); |
408 | rowHide->addTo(submenuRow); | 408 | rowHide->addTo(submenuRow); |
409 | menuFormat->insertItem(tr("&Row"), submenuRow); | 409 | menuFormat->insertItem(tr("&Row"), submenuRow); |
410 | 410 | ||
411 | submenuCol=new QPopupMenu; | 411 | submenuCol=new QPopupMenu; |
412 | colWidth->addTo(submenuCol); | 412 | colWidth->addTo(submenuCol); |
413 | colAdjust->addTo(submenuCol); | 413 | colAdjust->addTo(submenuCol); |
414 | colShow->addTo(submenuCol); | 414 | colShow->addTo(submenuCol); |
415 | colHide->addTo(submenuCol); | 415 | colHide->addTo(submenuCol); |
416 | menuFormat->insertItem(tr("Colum&n"), submenuCol); | 416 | menuFormat->insertItem(tr("Colum&n"), submenuCol); |
417 | 417 | ||
418 | submenuSheet=new QPopupMenu; | 418 | submenuSheet=new QPopupMenu; |
419 | sheetRename->addTo(submenuSheet); | 419 | sheetRename->addTo(submenuSheet); |
420 | sheetRemove->addTo(submenuSheet); | 420 | sheetRemove->addTo(submenuSheet); |
421 | menuFormat->insertItem(tr("&Sheet"), submenuSheet); | 421 | menuFormat->insertItem(tr("&Sheet"), submenuSheet); |
422 | 422 | ||
423 | submenuFunc=new QPopupMenu; | 423 | submenuFunc=new QPopupMenu; |
424 | menuInsert->insertItem(tr("&Function"), submenuFunc); | 424 | menuInsert->insertItem(tr("&Function"), submenuFunc); |
425 | 425 | ||
426 | submenuFuncStd=new QPopupMenu; | 426 | submenuFuncStd=new QPopupMenu; |
427 | funcPlus->addTo(submenuFuncStd); | 427 | funcPlus->addTo(submenuFuncStd); |
428 | funcMinus->addTo(submenuFuncStd); | 428 | funcMinus->addTo(submenuFuncStd); |
429 | funcCross->addTo(submenuFuncStd); | 429 | funcCross->addTo(submenuFuncStd); |
430 | funcDivide->addTo(submenuFuncStd); | 430 | funcDivide->addTo(submenuFuncStd); |
431 | submenuFunc->insertItem(tr("&Standard"), submenuFuncStd); | 431 | submenuFunc->insertItem(tr("&Standard"), submenuFuncStd); |
432 | 432 | ||
433 | submenuFuncMath=new QPopupMenu; | 433 | submenuFuncMath=new QPopupMenu; |
434 | addFlyAction(tr("Summation"), tr("&Summation"), "SUM(", submenuFuncMath); | 434 | addFlyAction(tr("Summation"), tr("&Summation"), "SUM(", submenuFuncMath); |
435 | addFlyAction(tr("Absolute Value"), tr("&Absolute"), "ABS(", submenuFuncMath); | 435 | addFlyAction(tr("Absolute Value"), tr("&Absolute"), "ABS(", submenuFuncMath); |
436 | submenuFuncMath->insertSeparator(); | 436 | submenuFuncMath->insertSeparator(); |
437 | addFlyAction(tr("Sine"), tr("Si&ne"), "SIN(", submenuFuncMath); | 437 | addFlyAction(tr("Sine"), tr("Si&ne"), "SIN(", submenuFuncMath); |
438 | addFlyAction(tr("Arc Sine"), tr("A&rc Sine"), "ASIN(", submenuFuncMath); | 438 | addFlyAction(tr("Arc Sine"), tr("A&rc Sine"), "ASIN(", submenuFuncMath); |
439 | addFlyAction(tr("Cosine"), tr("&Cosine"), "COS(", submenuFuncMath); | 439 | addFlyAction(tr("Cosine"), tr("&Cosine"), "COS(", submenuFuncMath); |
440 | addFlyAction(tr("ArcCosine"), tr("Arc Cos&ine"), "COS(", submenuFuncMath); | 440 | addFlyAction(tr("ArcCosine"), tr("Arc Cos&ine"), "COS(", submenuFuncMath); |
441 | addFlyAction(tr("Tangent"), tr("&Tangent"), "TAN(", submenuFuncMath); | 441 | addFlyAction(tr("Tangent"), tr("&Tangent"), "TAN(", submenuFuncMath); |
442 | addFlyAction(tr("Arc Tangent"), tr("Arc Tan&gent"), "ATAN(", submenuFuncMath); | 442 | addFlyAction(tr("Arc Tangent"), tr("Arc Tan&gent"), "ATAN(", submenuFuncMath); |
443 | addFlyAction(tr("Arc Tangent of Coordinates"), tr("C&oor. Arc Tangent"), "ATAN2(", submenuFuncMath); | 443 | addFlyAction(tr("Arc Tangent of Coordinates"), tr("C&oor. Arc Tangent"), "ATAN2(", submenuFuncMath); |
444 | submenuFuncMath->insertSeparator(); | 444 | submenuFuncMath->insertSeparator(); |
445 | addFlyAction(tr("Exponential"), tr("&Exponential"), "EXP(", submenuFuncMath); | 445 | addFlyAction(tr("Exponential"), tr("&Exponential"), "EXP(", submenuFuncMath); |
446 | addFlyAction(tr("Logarithm"), tr("&Logarithm"), "LOG(", submenuFuncMath); | 446 | addFlyAction(tr("Logarithm"), tr("&Logarithm"), "LOG(", submenuFuncMath); |
447 | addFlyAction(tr("Power"), tr("&Power"), "POW(", submenuFuncMath); | 447 | addFlyAction(tr("Power"), tr("&Power"), "POW(", submenuFuncMath); |
448 | submenuFunc->insertItem(tr("&Mathematical"), submenuFuncMath); | 448 | submenuFunc->insertItem(tr("&Mathematical"), submenuFuncMath); |
449 | 449 | ||
450 | submenuFuncStat=new QPopupMenu; | 450 | submenuFuncStat=new QPopupMenu; |
451 | addFlyAction(tr("Average"), tr("&Average"), "AVG(", submenuFuncStat); | 451 | addFlyAction(tr("Average"), tr("&Average"), "AVG(", submenuFuncStat); |
452 | addFlyAction(tr("Maximum"), tr("Ma&ximum"), "MAX(", submenuFuncStat); | 452 | addFlyAction(tr("Maximum"), tr("Ma&ximum"), "MAX(", submenuFuncStat); |
453 | addFlyAction(tr("Minimum"), tr("&Minimum"), "MIN(", submenuFuncStat); | 453 | addFlyAction(tr("Minimum"), tr("&Minimum"), "MIN(", submenuFuncStat); |
454 | addFlyAction(tr("Count"), tr("&Count"), "COUNT(", submenuFuncStat); | 454 | addFlyAction(tr("Count"), tr("&Count"), "COUNT(", submenuFuncStat); |
455 | submenuFunc->insertItem(tr("&Statistical"), submenuFuncStat); | 455 | submenuFunc->insertItem(tr("&Statistical"), submenuFuncStat); |
456 | 456 | ||
457 | menuInsert->insertSeparator(); | 457 | menuInsert->insertSeparator(); |
458 | insertCells->addTo(menuInsert); | 458 | insertCells->addTo(menuInsert); |
459 | insertRows->addTo(menuInsert); | 459 | insertRows->addTo(menuInsert); |
460 | insertCols->addTo(menuInsert); | 460 | insertCols->addTo(menuInsert); |
461 | insertSheets->addTo(menuInsert); | 461 | insertSheets->addTo(menuInsert); |
462 | } | 462 | } |
463 | 463 | ||
464 | void MainWindow::initStandardToolbar() | 464 | void MainWindow::initStandardToolbar() |
465 | { | 465 | { |
466 | toolbarStandard=new QPEToolBar(this); | 466 | toolbarStandard=new QPEToolBar(this); |
467 | toolbarStandard->setHorizontalStretchable(TRUE); | 467 | toolbarStandard->setHorizontalStretchable(TRUE); |
468 | moveToolBar(toolbarStandard, Top); | 468 | moveToolBar(toolbarStandard, Top); |
469 | 469 | ||
470 | fileNew->addTo(toolbarStandard); | 470 | fileNew->addTo(toolbarStandard); |
471 | fileOpen->addTo(toolbarStandard); | 471 | fileOpen->addTo(toolbarStandard); |
472 | fileSave->addTo(toolbarStandard); | 472 | fileSave->addTo(toolbarStandard); |
473 | 473 | ||
474 | comboSheets=new QComboBox(toolbarStandard); | 474 | comboSheets=new QComboBox(toolbarStandard); |
475 | toolbarStandard->setStretchableWidget(comboSheets); | 475 | toolbarStandard->setStretchableWidget(comboSheets); |
476 | connect(comboSheets, SIGNAL(activated(const QString &)), this, SLOT(slotSheetChanged(const QString &))); | 476 | connect(comboSheets, SIGNAL(activated(const QString &)), this, SLOT(slotSheetChanged(const QString &))); |
477 | } | 477 | } |
478 | 478 | ||
479 | void MainWindow::initFunctionsToolbar() | 479 | void MainWindow::initFunctionsToolbar() |
480 | { | 480 | { |
481 | toolbarFunctions=new QPEToolBar(this); | 481 | toolbarFunctions=new QPEToolBar(this); |
482 | toolbarFunctions->setHorizontalStretchable(TRUE); | 482 | toolbarFunctions->setHorizontalStretchable(TRUE); |
483 | moveToolBar(toolbarFunctions, Bottom); | 483 | moveToolBar(toolbarFunctions, Bottom); |
484 | 484 | ||
485 | funcEqual->addTo(toolbarFunctions); | 485 | funcEqual->addTo(toolbarFunctions); |
486 | funcPlus->addTo(toolbarFunctions); | 486 | funcPlus->addTo(toolbarFunctions); |
487 | funcMinus->addTo(toolbarFunctions); | 487 | funcMinus->addTo(toolbarFunctions); |
488 | funcCross->addTo(toolbarFunctions); | 488 | funcCross->addTo(toolbarFunctions); |
489 | funcDivide->addTo(toolbarFunctions); | 489 | funcDivide->addTo(toolbarFunctions); |
490 | funcParanOpen->addTo(toolbarFunctions); | 490 | funcParanOpen->addTo(toolbarFunctions); |
491 | funcParanClose->addTo(toolbarFunctions); | 491 | funcParanClose->addTo(toolbarFunctions); |
492 | funcComma->addTo(toolbarFunctions); | 492 | funcComma->addTo(toolbarFunctions); |
493 | 493 | ||
494 | toolFunction=new QToolButton(toolbarFunctions); | 494 | toolFunction=new QToolButton(toolbarFunctions); |
495 | toolFunction->setPixmap(func_func_xpm); | 495 | toolFunction->setPixmap(func_func_xpm); |
496 | toolFunction->setTextLabel(tr("Functions")); | 496 | toolFunction->setTextLabel(tr("Functions")); |
497 | toolFunction->setPopup(submenuFunc); | 497 | toolFunction->setPopup(submenuFunc); |
498 | toolFunction->setPopupDelay(0); | 498 | toolFunction->setPopupDelay(0); |
499 | } | 499 | } |
500 | 500 | ||
501 | void MainWindow::initEditToolbar() | 501 | void MainWindow::initEditToolbar() |
502 | { | 502 | { |
503 | toolbarEdit=new QPEToolBar(this); | 503 | toolbarEdit=new QPEToolBar(this); |
504 | toolbarEdit->setHorizontalStretchable(TRUE); | 504 | toolbarEdit->setHorizontalStretchable(TRUE); |
505 | moveToolBar(toolbarEdit, Bottom); | 505 | moveToolBar(toolbarEdit, Bottom); |
506 | 506 | ||
507 | editAccept->addTo(toolbarEdit); | 507 | editAccept->addTo(toolbarEdit); |
508 | editCancel->addTo(toolbarEdit); | 508 | editCancel->addTo(toolbarEdit); |
509 | 509 | ||
510 | editData=new QLineEdit(toolbarEdit); | 510 | editData=new QLineEdit(toolbarEdit); |
511 | toolbarEdit->setStretchableWidget(editData); | 511 | toolbarEdit->setStretchableWidget(editData); |
512 | connect(editData, SIGNAL(returnPressed()), this, SLOT(slotEditAccept())); | 512 | connect(editData, SIGNAL(returnPressed()), this, SLOT(slotEditAccept())); |
513 | 513 | ||
514 | editCellSelect->addTo(toolbarEdit); | 514 | editCellSelect->addTo(toolbarEdit); |
515 | } | 515 | } |
516 | 516 | ||
517 | void MainWindow::slotHelpAbout() | 517 | void MainWindow::slotHelpAbout() |
518 | { | 518 | { |
519 | QDialog dialogAbout(this, 0, TRUE); | 519 | QDialog dialogAbout(this, 0, TRUE); |
520 | dialogAbout.resize(width()-40, height()-80); | 520 | dialogAbout.resize(width()-40, height()-80); |
521 | dialogAbout.setCaption(tr("About Opie Sheet")); | 521 | dialogAbout.setCaption(tr("About Opie Sheet")); |
522 | 522 | ||
523 | QLabel label(tr("Opie Sheet\nSpreadsheet Software for Opie\nQWDC Beta Winner (as Sheet/Qt)\n\nDeveloped by: Serdar Ozler\nRelease 1.0.2\nRelease Date: October 08, 2002\n\nThis product is licensed under GPL. It is freely distributable. If you want to get the latest version and also the source code, please visit the web site.\n\nhttp://qtopia.sitebest.com"), &dialogAbout); | 523 | QLabel label(tr("Opie Sheet\nSpreadsheet Software for Opie\nQWDC Beta Winner (as Sheet/Qt)\n\nDeveloped by: Serdar Ozler\nRelease 1.0.2\nRelease Date: October 08, 2002\n\nThis product is licensed under GPL. It is freely distributable. If you want to get the latest version and also the source code, please visit the web site.\n\nhttp://qtopia.sitebest.com"), &dialogAbout); |
524 | label.setGeometry(dialogAbout.rect()); | 524 | label.setGeometry(dialogAbout.rect()); |
525 | label.setAlignment(Qt::AlignCenter | Qt::WordBreak); | 525 | label.setAlignment(Qt::AlignCenter | Qt::WordBreak); |
526 | 526 | ||
527 | dialogAbout.exec(); | 527 | dialogAbout.exec(); |
528 | } | 528 | } |
529 | 529 | ||
530 | void MainWindow::initSheet() | 530 | void MainWindow::initSheet() |
531 | { | 531 | { |
532 | sheet=new Sheet(DEFAULT_NUM_ROWS, DEFAULT_NUM_COLS, this); | 532 | sheet=new Sheet(DEFAULT_NUM_ROWS, DEFAULT_NUM_COLS, this); |
533 | setCentralWidget(sheet); | 533 | setCentralWidget(sheet); |
534 | 534 | ||
535 | connect(sheet, SIGNAL(currentDataChanged(const QString &)), editData, SLOT(setText(const QString &))); | 535 | connect(sheet, SIGNAL(currentDataChanged(const QString &)), editData, SLOT(setText(const QString &))); |
536 | connect(sheet, SIGNAL(cellClicked(const QString &)), this, SLOT(slotCellClicked(const QString &))); | 536 | connect(sheet, SIGNAL(cellClicked(const QString &)), this, SLOT(slotCellClicked(const QString &))); |
537 | connect(sheet, SIGNAL(sheetModified()), this, SLOT(slotDocModified())); | 537 | connect(sheet, SIGNAL(sheetModified()), this, SLOT(slotDocModified())); |
538 | 538 | ||
539 | connect(editCut, SIGNAL(activated()), sheet, SLOT(editCut())); | 539 | connect(editCut, SIGNAL(activated()), sheet, SLOT(editCut())); |
540 | connect(editCopy, SIGNAL(activated()), sheet, SLOT(editCopy())); | 540 | connect(editCopy, SIGNAL(activated()), sheet, SLOT(editCopy())); |
541 | connect(editClear, SIGNAL(activated()), sheet, SLOT(editClear())); | 541 | connect(editClear, SIGNAL(activated()), sheet, SLOT(editClear())); |
542 | } | 542 | } |
543 | 543 | ||
544 | void MainWindow::slotEditAccept() | 544 | void MainWindow::slotEditAccept() |
545 | { | 545 | { |
546 | sheet->setData(editData->text()); | 546 | sheet->setData(editData->text()); |
547 | } | 547 | } |
548 | 548 | ||
549 | void MainWindow::slotEditCancel() | 549 | void MainWindow::slotEditCancel() |
550 | { | 550 | { |
551 | editData->setText(sheet->getData()); | 551 | editData->setText(sheet->getData()); |
552 | } | 552 | } |
553 | 553 | ||
554 | void MainWindow::slotCellSelect(bool lock) | 554 | void MainWindow::slotCellSelect(bool lock) |
555 | { | 555 | { |
556 | sheet->lockClicks(lock); | 556 | sheet->lockClicks(lock); |
557 | } | 557 | } |
558 | 558 | ||
559 | void MainWindow::addToData(const QString &data) | 559 | void MainWindow::addToData(const QString &data) |
560 | { | 560 | { |
561 | editData->setText(editData->text().insert(editData->cursorPosition(), data)); | 561 | editData->setText(editData->text().insert(editData->cursorPosition(), data)); |
562 | } | 562 | } |
563 | 563 | ||
564 | void MainWindow::slotFuncOutput() | 564 | void MainWindow::slotFuncOutput() |
565 | { | 565 | { |
566 | if (sender()->isA("QAction")) | 566 | if (sender()->isA("QAction")) |
567 | addToData(((QAction *)sender())->toolTip()); | 567 | addToData(((QAction *)sender())->toolTip()); |
568 | } | 568 | } |
569 | 569 | ||
570 | void MainWindow::slotInsertRows() | 570 | void MainWindow::slotInsertRows() |
571 | { | 571 | { |
572 | NumberDialog dialogNumber(this); | 572 | NumberDialog dialogNumber(this); |
573 | if (dialogNumber.exec(tr("Insert Rows"), tr("&Number of rows:"))==QDialog::Accepted) | 573 | if (dialogNumber.exec(tr("Insert Rows"), tr("&Number of rows:"))==QDialog::Accepted) |
574 | sheet->insertRows(dialogNumber.getValue()); | 574 | sheet->insertRows(dialogNumber.getValue()); |
575 | } | 575 | } |
576 | 576 | ||
577 | void MainWindow::slotInsertCols() | 577 | void MainWindow::slotInsertCols() |
578 | { | 578 | { |
579 | NumberDialog dialogNumber(this); | 579 | NumberDialog dialogNumber(this); |
580 | if (dialogNumber.exec(tr("Insert Columns"), tr("&Number of columns:"))==QDialog::Accepted) | 580 | if (dialogNumber.exec(tr("Insert Columns"), tr("&Number of columns:"))==QDialog::Accepted) |
581 | sheet->insertColumns(dialogNumber.getValue()); | 581 | sheet->insertColumns(dialogNumber.getValue()); |
582 | } | 582 | } |
583 | 583 | ||
584 | void MainWindow::slotInsertSheets() | 584 | void MainWindow::slotInsertSheets() |
585 | { | 585 | { |
586 | NumberDialog dialogNumber(this); | 586 | NumberDialog dialogNumber(this); |
587 | if (dialogNumber.exec(tr("Add Sheets"), tr("&Number of sheets:"))==QDialog::Accepted) | 587 | if (dialogNumber.exec(tr("Add Sheets"), tr("&Number of sheets:"))==QDialog::Accepted) |
588 | for (int i=dialogNumber.getValue(); i>0; --i) createNewSheet(); | 588 | for (int i=dialogNumber.getValue(); i>0; --i) createNewSheet(); |
589 | } | 589 | } |
590 | 590 | ||
591 | void MainWindow::slotCellClicked(const QString &cell) | 591 | void MainWindow::slotCellClicked(const QString &cell) |
592 | { | 592 | { |
593 | editCellSelect->setOn(FALSE); | 593 | editCellSelect->setOn(FALSE); |
594 | addToData(cell); | 594 | addToData(cell); |
595 | } | 595 | } |
596 | 596 | ||
597 | typeSheet *MainWindow::createNewSheet() | 597 | typeSheet *MainWindow::createNewSheet() |
598 | { | 598 | { |
599 | typeSheet *newSheet=new typeSheet; | 599 | typeSheet *newSheet=new typeSheet; |
600 | int currentNo=1, tempNo; | 600 | int currentNo=1, tempNo; |
601 | bool ok; | 601 | bool ok; |
602 | 602 | ||
603 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) | 603 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) |
604 | if (tempSheet->name.startsWith(tr("Sheet")) && (tempNo=tempSheet->name.mid(tr("Sheet").length()).toInt(&ok))>=currentNo && ok) | 604 | if (tempSheet->name.startsWith(tr("Sheet")) && (tempNo=tempSheet->name.mid(tr("Sheet").length()).toInt(&ok))>=currentNo && ok) |
605 | currentNo=tempNo+1; | 605 | currentNo=tempNo+1; |
606 | 606 | ||
607 | newSheet->name=tr("Sheet")+QString::number(currentNo); | 607 | newSheet->name=tr("Sheet")+QString::number(currentNo); |
608 | newSheet->data.setAutoDelete(TRUE); | 608 | newSheet->data.setAutoDelete(TRUE); |
609 | 609 | ||
610 | comboSheets->insertItem(newSheet->name); | 610 | comboSheets->insertItem(newSheet->name); |
611 | listSheets.append(newSheet); | 611 | listSheets.append(newSheet); |
612 | return newSheet; | 612 | return newSheet; |
613 | } | 613 | } |
614 | 614 | ||
615 | typeSheet *MainWindow::findSheet(const QString &name) | 615 | typeSheet *MainWindow::findSheet(const QString &name) |
616 | { | 616 | { |
617 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) | 617 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) |
618 | if (tempSheet->name==name) | 618 | if (tempSheet->name==name) |
619 | return tempSheet; | 619 | return tempSheet; |
620 | return NULL; | 620 | return NULL; |
621 | } | 621 | } |
622 | 622 | ||
623 | void MainWindow::slotSheetChanged(const QString &name) | 623 | void MainWindow::slotSheetChanged(const QString &name) |
624 | { | 624 | { |
625 | sheet->copySheetData(&findSheet(sheet->getName())->data); | 625 | sheet->copySheetData(&findSheet(sheet->getName())->data); |
626 | sheet->setName(name); | 626 | sheet->setName(name); |
627 | sheet->setSheetData(&findSheet(name)->data); | 627 | sheet->setSheetData(&findSheet(name)->data); |
628 | } | 628 | } |
629 | 629 | ||
630 | void MainWindow::addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w) | 630 | void MainWindow::addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w) |
631 | { | 631 | { |
632 | QAction *action=new QAction(text, menuText, 0, this); | 632 | QAction *action=new QAction(text, menuText, 0, this); |
633 | action->setToolTip(tip); | 633 | action->setToolTip(tip); |
634 | connect(action, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 634 | connect(action, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
635 | action->addTo(w); | 635 | action->addTo(w); |
636 | } | 636 | } |
637 | 637 | ||
638 | void MainWindow::slotFormatCells() | 638 | void MainWindow::slotFormatCells() |
639 | { | 639 | { |
640 | CellFormat dialogCellFormat(this); | 640 | CellFormat dialogCellFormat(this); |
641 | dialogCellFormat.showMaximized(); | 641 | dialogCellFormat.showMaximized(); |
642 | dialogCellFormat.exec(sheet); | 642 | dialogCellFormat.exec(sheet); |
643 | } | 643 | } |
644 | 644 | ||
645 | void MainWindow::slotEditPaste() | 645 | void MainWindow::slotEditPaste() |
646 | { | 646 | { |
647 | sheet->editPaste(); | 647 | sheet->editPaste(); |
648 | } | 648 | } |
649 | 649 | ||
650 | void MainWindow::slotEditPasteContents() | 650 | void MainWindow::slotEditPasteContents() |
651 | { | 651 | { |
652 | sheet->editPaste(TRUE); | 652 | sheet->editPaste(TRUE); |
653 | } | 653 | } |
654 | 654 | ||
655 | void MainWindow::slotRowHeight() | 655 | void MainWindow::slotRowHeight() |
656 | { | 656 | { |
657 | int row1, row2, col1, col2; | 657 | int row1, row2, col1, col2; |
658 | sheet->getSelection(&row1, &col1, &row2, &col2); | 658 | sheet->getSelection(&row1, &col1, &row2, &col2); |
659 | 659 | ||
660 | NumberDialog dialogNumber(this); | 660 | NumberDialog dialogNumber(this); |
661 | if (dialogNumber.exec(tr("Row Height"), tr("&Height of each row:"), sheet->rowHeight(row1))==QDialog::Accepted) | 661 | if (dialogNumber.exec(tr("Row Height"), tr("&Height of each row:"), sheet->rowHeight(row1))==QDialog::Accepted) |
662 | { | 662 | { |
663 | int newHeight=dialogNumber.getValue(), row; | 663 | int newHeight=dialogNumber.getValue(), row; |
664 | for (row=row1; row<=row2; ++row) | 664 | for (row=row1; row<=row2; ++row) |
665 | sheet->setRowHeight(row, newHeight); | 665 | sheet->setRowHeight(row, newHeight); |
666 | } | 666 | } |
667 | } | 667 | } |
668 | 668 | ||
669 | void MainWindow::slotRowAdjust() | 669 | void MainWindow::slotRowAdjust() |
670 | { | 670 | { |
671 | int row1, row2, col1, col2; | 671 | int row1, row2, col1, col2; |
672 | sheet->getSelection(&row1, &col1, &row2, &col2); | 672 | sheet->getSelection(&row1, &col1, &row2, &col2); |
673 | 673 | ||
674 | for (int row=row1; row<=row2; ++row) | 674 | for (int row=row1; row<=row2; ++row) |
675 | sheet->adjustRow(row); | 675 | sheet->adjustRow(row); |
676 | } | 676 | } |
677 | 677 | ||
678 | void MainWindow::slotRowShow() | 678 | void MainWindow::slotRowShow() |
679 | { | 679 | { |
680 | int row1, row2, col1, col2; | 680 | int row1, row2, col1, col2; |
681 | sheet->getSelection(&row1, &col1, &row2, &col2); | 681 | sheet->getSelection(&row1, &col1, &row2, &col2); |
682 | 682 | ||
683 | for (int row=row1; row<=row2; ++row) | 683 | for (int row=row1; row<=row2; ++row) |
684 | sheet->showRow(row); | 684 | sheet->showRow(row); |
685 | } | 685 | } |
686 | 686 | ||
687 | void MainWindow::slotRowHide() | 687 | void MainWindow::slotRowHide() |
688 | { | 688 | { |
689 | int row1, row2, col1, col2; | 689 | int row1, row2, col1, col2; |
690 | sheet->getSelection(&row1, &col1, &row2, &col2); | 690 | sheet->getSelection(&row1, &col1, &row2, &col2); |
691 | 691 | ||
692 | for (int row=row1; row<=row2; ++row) | 692 | for (int row=row1; row<=row2; ++row) |
693 | sheet->hideRow(row); | 693 | sheet->hideRow(row); |
694 | } | 694 | } |
695 | 695 | ||
696 | void MainWindow::slotColumnWidth() | 696 | void MainWindow::slotColumnWidth() |
697 | { | 697 | { |
698 | int row1, row2, col1, col2; | 698 | int row1, row2, col1, col2; |
699 | sheet->getSelection(&row1, &col1, &row2, &col2); | 699 | sheet->getSelection(&row1, &col1, &row2, &col2); |
700 | 700 | ||
701 | NumberDialog dialogNumber(this); | 701 | NumberDialog dialogNumber(this); |
702 | if (dialogNumber.exec(tr("Column Width"), tr("&Width of each column:"), sheet->columnWidth(col1))==QDialog::Accepted) | 702 | if (dialogNumber.exec(tr("Column Width"), tr("&Width of each column:"), sheet->columnWidth(col1))==QDialog::Accepted) |
703 | { | 703 | { |
704 | int newWidth=dialogNumber.getValue(), col; | 704 | int newWidth=dialogNumber.getValue(), col; |
705 | for (col=col1; col<=col2; ++col) | 705 | for (col=col1; col<=col2; ++col) |
706 | sheet->setColumnWidth(col, newWidth); | 706 | sheet->setColumnWidth(col, newWidth); |
707 | } | 707 | } |
708 | } | 708 | } |
709 | 709 | ||
710 | void MainWindow::slotColumnAdjust() | 710 | void MainWindow::slotColumnAdjust() |
711 | { | 711 | { |
712 | int row1, row2, col1, col2; | 712 | int row1, row2, col1, col2; |
713 | sheet->getSelection(&row1, &col1, &row2, &col2); | 713 | sheet->getSelection(&row1, &col1, &row2, &col2); |
714 | 714 | ||
715 | for (int col=col1; col<=col2; ++col) | 715 | for (int col=col1; col<=col2; ++col) |
716 | sheet->adjustColumn(col); | 716 | sheet->adjustColumn(col); |
717 | } | 717 | } |
718 | 718 | ||
719 | void MainWindow::slotColumnShow() | 719 | void MainWindow::slotColumnShow() |
720 | { | 720 | { |
721 | int row1, row2, col1, col2; | 721 | int row1, row2, col1, col2; |
722 | sheet->getSelection(&row1, &col1, &row2, &col2); | 722 | sheet->getSelection(&row1, &col1, &row2, &col2); |
723 | 723 | ||
724 | for (int col=col1; col<=col2; ++col) | 724 | for (int col=col1; col<=col2; ++col) |
725 | sheet->showColumn(col); | 725 | sheet->showColumn(col); |
726 | } | 726 | } |
727 | 727 | ||
728 | void MainWindow::slotColumnHide() | 728 | void MainWindow::slotColumnHide() |
729 | { | 729 | { |
730 | int row1, row2, col1, col2; | 730 | int row1, row2, col1, col2; |
731 | sheet->getSelection(&row1, &col1, &row2, &col2); | 731 | sheet->getSelection(&row1, &col1, &row2, &col2); |
732 | 732 | ||
733 | for (int col=col1; col<=col2; ++col) | 733 | for (int col=col1; col<=col2; ++col) |
734 | sheet->hideColumn(col); | 734 | sheet->hideColumn(col); |
735 | } | 735 | } |
736 | 736 | ||
737 | void MainWindow::slotFileSaveAs() | 737 | void MainWindow::slotFileSaveAs() |
738 | { | 738 | { |
739 | TextDialog dialogText(this); | 739 | TextDialog dialogText(this); |
740 | if (dialogText.exec(tr("Save File As"), tr("&File Name:"), currentDoc->name())!=QDialog::Accepted || dialogText.getValue().isEmpty()) return; | 740 | if (dialogText.exec(tr("Save File As"), tr("&File Name:"), currentDoc->name())!=QDialog::Accepted || dialogText.getValue().isEmpty()) return; |
741 | 741 | ||
742 | currentDoc->setName(dialogText.getValue()); | 742 | currentDoc->setName(dialogText.getValue()); |
743 | currentDoc->setFile(QString::null); | 743 | currentDoc->setFile(QString::null); |
744 | currentDoc->setLinkFile(QString::null); | 744 | currentDoc->setLinkFile(QString::null); |
745 | documentSave(currentDoc); | 745 | documentSave(currentDoc); |
746 | } | 746 | } |
747 | 747 | ||
748 | void MainWindow::slotSheetRename() | 748 | void MainWindow::slotSheetRename() |
749 | { | 749 | { |
750 | TextDialog dialogText(this); | 750 | TextDialog dialogText(this); |
751 | if (dialogText.exec(tr("Rename Sheet"), tr("&Sheet Name:"), sheet->getName())!=QDialog::Accepted || dialogText.getValue().isEmpty()) return; | 751 | if (dialogText.exec(tr("Rename Sheet"), tr("&Sheet Name:"), sheet->getName())!=QDialog::Accepted || dialogText.getValue().isEmpty()) return; |
752 | QString newName=dialogText.getValue(); | 752 | QString newName=dialogText.getValue(); |
753 | 753 | ||
754 | typeSheet *tempSheet=findSheet(newName); | 754 | typeSheet *tempSheet=findSheet(newName); |
755 | if (tempSheet) | 755 | if (tempSheet) |
756 | { | 756 | { |
757 | QMessageBox::critical(this, tr("Error"), tr("There is already a sheet named '"+newName+'\'')); | 757 | QMessageBox::critical(this, tr("Error"), tr("There is already a sheet named '"+newName+'\'')); |
758 | return; | 758 | return; |
759 | } | 759 | } |
760 | 760 | ||
761 | tempSheet=findSheet(sheet->getName()); | 761 | tempSheet=findSheet(sheet->getName()); |
762 | for (int i=0; i<comboSheets->count(); ++i) | 762 | for (int i=0; i<comboSheets->count(); ++i) |
763 | if (comboSheets->text(i)==tempSheet->name) | 763 | if (comboSheets->text(i)==tempSheet->name) |
764 | { | 764 | { |
765 | comboSheets->changeItem(newName, i); | 765 | comboSheets->changeItem(newName, i); |
766 | break; | 766 | break; |
767 | } | 767 | } |
768 | tempSheet->name=newName; | 768 | tempSheet->name=newName; |
769 | sheet->setName(newName); | 769 | sheet->setName(newName); |
770 | } | 770 | } |
771 | 771 | ||
772 | void MainWindow::slotSheetRemove() | 772 | void MainWindow::slotSheetRemove() |
773 | { | 773 | { |
774 | if (comboSheets->count()<2) | 774 | if (comboSheets->count()<2) |
775 | { | 775 | { |
776 | QMessageBox::warning(this, tr("Error"), tr("There is only one sheet!")); | 776 | QMessageBox::warning(this, tr("Error"), tr("There is only one sheet!")); |
777 | return; | 777 | return; |
778 | } | 778 | } |
779 | if (QMessageBox::information(this, tr("Remove Sheet"), tr("Are you sure?"), QMessageBox::Yes, QMessageBox::No)==QMessageBox::Yes) | 779 | if (QMessageBox::information(this, tr("Remove Sheet"), tr("Are you sure?"), QMessageBox::Yes, QMessageBox::No)==QMessageBox::Yes) |
780 | { | 780 | { |
781 | typeSheet *tempSheet=findSheet(sheet->getName()); | 781 | typeSheet *tempSheet=findSheet(sheet->getName()); |
782 | for (int i=0; i<comboSheets->count(); ++i) | 782 | for (int i=0; i<comboSheets->count(); ++i) |
783 | if (comboSheets->text(i)==tempSheet->name) | 783 | if (comboSheets->text(i)==tempSheet->name) |
784 | { | 784 | { |
785 | comboSheets->removeItem(i); | 785 | comboSheets->removeItem(i); |
786 | break; | 786 | break; |
787 | } | 787 | } |
788 | comboSheets->setCurrentItem(0); | 788 | comboSheets->setCurrentItem(0); |
789 | slotSheetChanged(comboSheets->currentText()); | 789 | slotSheetChanged(comboSheets->currentText()); |
790 | listSheets.remove(tempSheet); | 790 | listSheets.remove(tempSheet); |
791 | } | 791 | } |
792 | } | 792 | } |
793 | 793 | ||
794 | void MainWindow::slotDataSort() | 794 | void MainWindow::slotDataSort() |
795 | { | 795 | { |
796 | SortDialog dialogSort(this); | 796 | SortDialog dialogSort(this); |
797 | dialogSort.showMaximized(); | 797 | dialogSort.showMaximized(); |
798 | dialogSort.exec(sheet); | 798 | dialogSort.exec(sheet); |
799 | } | 799 | } |
800 | 800 | ||
801 | void MainWindow::slotDocModified() | 801 | void MainWindow::slotDocModified() |
802 | { | 802 | { |
803 | documentModified=TRUE; | 803 | documentModified=TRUE; |
804 | } | 804 | } |
805 | 805 | ||
806 | void MainWindow::slotInsertCells() | 806 | void MainWindow::slotInsertCells() |
807 | { | 807 | { |
808 | QDialog dialogInsert(this, 0, TRUE); | 808 | QDialog dialogInsert(this, 0, TRUE); |
809 | dialogInsert.resize(180, 130); | 809 | dialogInsert.resize(180, 130); |
810 | dialogInsert.setCaption(tr("Insert Cells")); | 810 | dialogInsert.setCaption(tr("Insert Cells")); |
811 | 811 | ||
812 | QVButtonGroup *group=new QVButtonGroup(tr("&Type"), &dialogInsert); | 812 | QVButtonGroup *group=new QVButtonGroup(tr("&Type"), &dialogInsert); |
813 | group->setGeometry(10, 10, 160, 110); | 813 | group->setGeometry(10, 10, 160, 110); |
814 | QRadioButton *radio=new QRadioButton(tr("Shift cells &down"), group); | 814 | QRadioButton *radio=new QRadioButton(tr("Shift cells &down"), group); |
815 | radio=new QRadioButton(tr("Shift cells &right"), group); | 815 | radio=new QRadioButton(tr("Shift cells &right"), group); |
816 | radio=new QRadioButton(tr("Entire ro&w"), group); | 816 | radio=new QRadioButton(tr("Entire ro&w"), group); |
817 | radio=new QRadioButton(tr("Entire &column"), group); | 817 | radio=new QRadioButton(tr("Entire &column"), group); |
818 | group->setButton(0); | 818 | group->setButton(0); |
819 | 819 | ||
820 | if (dialogInsert.exec()==QDialog::Accepted) | 820 | if (dialogInsert.exec()==QDialog::Accepted) |
821 | switch (group->id(group->selected())) | 821 | switch (group->id(group->selected())) |
822 | { | 822 | { |
823 | case 0: sheet->insertRows(1, FALSE); break; | 823 | case 0: sheet->insertRows(1, FALSE); break; |
824 | case 1: sheet->insertColumns(1, FALSE); break; | 824 | case 1: sheet->insertColumns(1, FALSE); break; |
825 | case 2: sheet->insertRows(1, TRUE); break; | 825 | case 2: sheet->insertRows(1, TRUE); break; |
826 | case 3: sheet->insertColumns(1, TRUE); break; | 826 | case 3: sheet->insertColumns(1, TRUE); break; |
827 | } | 827 | } |
828 | } | 828 | } |
829 | 829 | ||
830 | void MainWindow::slotDataFindReplace() | 830 | void MainWindow::slotDataFindReplace() |
831 | { | 831 | { |
832 | FindDialog dialogFind(this); | 832 | FindDialog dialogFind(this); |
833 | dialogFind.showMaximized(); | 833 | dialogFind.showMaximized(); |
834 | dialogFind.exec(sheet); | 834 | dialogFind.exec(sheet); |
835 | } | 835 | } |
diff --git a/noncore/apps/opie-sheet/mainwindow.h b/noncore/apps/opie-sheet/mainwindow.h index 10d6650..370d82e 100644 --- a/noncore/apps/opie-sheet/mainwindow.h +++ b/noncore/apps/opie-sheet/mainwindow.h | |||
@@ -1,132 +1,133 @@ | |||
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 | 9 | ||
10 | /* | 10 | /* |
11 | * Opie Sheet (formerly Sheet/Qt) | 11 | * Opie Sheet (formerly Sheet/Qt) |
12 | * by Serdar Ozler <sozler@sitebest.com> | 12 | * by Serdar Ozler <sozler@sitebest.com> |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #ifndef MAINWINDOW_H | 15 | #ifndef MAINWINDOW_H |
16 | #define MAINWINDOW_H | 16 | #define MAINWINDOW_H |
17 | 17 | ||
18 | #include <qpe/applnk.h> | 18 | #include <qpe/applnk.h> |
19 | #include <qpe/fileselector.h> | 19 | #include <qpe/fileselector.h> |
20 | #include <qpe/qpemenubar.h> | 20 | #include <qpe/qpemenubar.h> |
21 | #include <qpe/qpetoolbar.h> | 21 | #include <qpe/qpetoolbar.h> |
22 | #include <qmainwindow.h> | 22 | #include <qmainwindow.h> |
23 | #include <qaction.h> | 23 | #include <qaction.h> |
24 | #include <qlineedit.h> | 24 | #include <qlineedit.h> |
25 | #include <qbutton.h> | 25 | #include <qbutton.h> |
26 | #include <qcombobox.h> | 26 | #include <qcombobox.h> |
27 | #include <qtoolbutton.h> | 27 | #include <qtoolbutton.h> |
28 | 28 | ||
29 | #include "sheet.h" | 29 | #include "sheet.h" |
30 | 30 | ||
31 | typedef struct typeSheet | 31 | typedef struct typeSheet |
32 | { | 32 | { |
33 | QString name; | 33 | QString name; |
34 | QList<typeCellData> data; | 34 | QList<typeCellData> data; |
35 | }; | 35 | }; |
36 | 36 | ||
37 | class MainWindow: public QMainWindow | 37 | class MainWindow: public QMainWindow |
38 | { | 38 | { |
39 | Q_OBJECT | 39 | Q_OBJECT |
40 | 40 | ||
41 | // QPE objects | 41 | // QPE objects |
42 | DocLnk* currentDoc; | 42 | DocLnk* currentDoc; |
43 | QPEMenuBar *menu; | 43 | QPEMenuBar *menu; |
44 | QPEToolBar *toolbarFunctions, *toolbarEdit, *toolbarStandard; | 44 | QPEToolBar *toolbarFunctions, *toolbarEdit, *toolbarStandard; |
45 | FileSelector *fileSelector; | 45 | FileSelector *fileSelector; |
46 | 46 | ||
47 | // QT objects | 47 | // QT objects |
48 | QPopupMenu *menuFile, *menuEdit, *menuInsert, *menuFormat, *menuData, *menuHelp, | 48 | QPopupMenu *menuFile, *menuEdit, *menuInsert, *menuFormat, *menuData, *menuHelp, |
49 | *submenuFunc, *submenuFuncStd, *submenuFuncMath, *submenuFuncStat, | 49 | *submenuFunc, *submenuFuncStd, *submenuFuncMath, *submenuFuncStat, |
50 | *submenuRow, *submenuCol, *submenuSheet; | 50 | *submenuRow, *submenuCol, *submenuSheet; |
51 | QAction *fileNew, *fileOpen, *fileSave, *fileSaveAs, *fileQuit, *helpAbout, *editAccept, *editCancel, *formatCells, | 51 | QAction *fileNew, *fileOpen, *fileSave, *fileSaveAs, *fileQuit, *helpAbout, *editAccept, *editCancel, *formatCells, |
52 | *funcPlus, *funcMinus, *funcCross, *funcDivide, *funcParanOpen, *funcParanClose, *funcComma, *funcEqual, | 52 | *funcPlus, *funcMinus, *funcCross, *funcDivide, *funcParanOpen, *funcParanClose, *funcComma, *funcEqual, |
53 | *editCut, *editCopy, *editPaste, *editPasteContents, *editClear, *insertCols, *insertRows, *insertSheets, *insertCells, | 53 | *editCut, *editCopy, *editPaste, *editPasteContents, *editClear, *insertCols, *insertRows, *insertSheets, *insertCells, |
54 | *rowHeight, *rowShow, *rowHide, *rowAdjust, *colWidth, *colShow, *colHide, *colAdjust, *sheetRename, *sheetRemove, | 54 | *rowHeight, *rowShow, *rowHide, *rowAdjust, *colWidth, *colShow, *colHide, *colAdjust, *sheetRename, *sheetRemove, |
55 | *dataSort, *dataFindReplace, *editCellSelect, *helpGeneral; | 55 | *dataSort, *dataFindReplace, *editCellSelect, *helpGeneral; |
56 | QLineEdit *editData; | 56 | QLineEdit *editData; |
57 | QButton *buttonUp, *buttonDown, *buttonLeft, *buttonRight; | 57 | QButton *buttonUp, *buttonDown, *buttonLeft, *buttonRight; |
58 | QComboBox *comboSheets; | 58 | QComboBox *comboSheets; |
59 | QToolButton *toolFunction; | 59 | QToolButton *toolFunction; |
60 | QList<typeSheet> listSheets; | 60 | QList<typeSheet> listSheets; |
61 | QString helpFile; | 61 | QString helpFile; |
62 | 62 | ||
63 | // Other objects | 63 | // Other objects |
64 | Sheet *sheet; | 64 | Sheet *sheet; |
65 | 65 | ||
66 | // Variables | 66 | // Variables |
67 | bool documentModified; | 67 | bool documentModified; |
68 | 68 | ||
69 | // Private functions | 69 | // Private functions |
70 | void initMenu(); | 70 | void initMenu(); |
71 | void initActions(); | 71 | void initActions(); |
72 | void initFunctionsToolbar(); | 72 | void initFunctionsToolbar(); |
73 | void initEditToolbar(); | 73 | void initEditToolbar(); |
74 | void initStandardToolbar(); | 74 | void initStandardToolbar(); |
75 | void initSheet(); | 75 | void initSheet(); |
76 | void addToData(const QString &data); | 76 | void addToData(const QString &data); |
77 | int saveCurrentFile(bool ask=TRUE); | 77 | int saveCurrentFile(bool ask=TRUE); |
78 | void documentOpen(const DocLnk &lnkDoc); | 78 | void documentOpen(const DocLnk &lnkDoc); |
79 | void documentSave(DocLnk *lnkDoc); | 79 | void documentSave(DocLnk *lnkDoc); |
80 | void closeEvent(QCloseEvent *e); | 80 | void closeEvent(QCloseEvent *e); |
81 | void addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w); | 81 | void addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w); |
82 | typeSheet *createNewSheet(); | 82 | typeSheet *createNewSheet(); |
83 | typeSheet *findSheet(const QString &name); | 83 | typeSheet *findSheet(const QString &name); |
84 | 84 | ||
85 | private slots: | 85 | private slots: |
86 | void slotFileNew(); | 86 | void slotFileNew(); |
87 | void slotFileOpen(); | 87 | void slotFileOpen(); |
88 | void slotFileSave(); | 88 | void slotFileSave(); |
89 | void slotFileSaveAs(); | 89 | void slotFileSaveAs(); |
90 | void slotHelpAbout(); | 90 | void slotHelpAbout(); |
91 | void slotEditAccept(); | 91 | void slotEditAccept(); |
92 | void slotEditCancel(); | 92 | void slotEditCancel(); |
93 | void slotEditPaste(); | 93 | void slotEditPaste(); |
94 | void slotEditPasteContents(); | 94 | void slotEditPasteContents(); |
95 | void slotFormatCells(); | 95 | void slotFormatCells(); |
96 | void slotInsertCells(); | 96 | void slotInsertCells(); |
97 | void slotInsertRows(); | 97 | void slotInsertRows(); |
98 | void slotInsertCols(); | 98 | void slotInsertCols(); |
99 | void slotInsertSheets(); | 99 | void slotInsertSheets(); |
100 | void slotDataSort(); | 100 | void slotDataSort(); |
101 | void slotDataFindReplace(); | 101 | void slotDataFindReplace(); |
102 | void slotRowHeight(); | 102 | void slotRowHeight(); |
103 | void slotRowAdjust(); | 103 | void slotRowAdjust(); |
104 | void slotRowShow(); | 104 | void slotRowShow(); |
105 | void slotRowHide(); | 105 | void slotRowHide(); |
106 | void slotColumnWidth(); | 106 | void slotColumnWidth(); |
107 | void slotColumnAdjust(); | 107 | void slotColumnAdjust(); |
108 | void slotColumnShow(); | 108 | void slotColumnShow(); |
109 | void slotColumnHide(); | 109 | void slotColumnHide(); |
110 | void slotSheetRename(); | 110 | void slotSheetRename(); |
111 | void slotSheetRemove(); | 111 | void slotSheetRemove(); |
112 | void slotFuncOutput(); | 112 | void slotFuncOutput(); |
113 | void slotCellSelect(bool lock); | 113 | void slotCellSelect(bool lock); |
114 | void slotCellClicked(const QString &cell); | 114 | void slotCellClicked(const QString &cell); |
115 | void slotSheetChanged(const QString &name); | 115 | void slotSheetChanged(const QString &name); |
116 | void slotDocModified(); | 116 | void slotDocModified(); |
117 | void selectorShow(); | 117 | void selectorShow(); |
118 | void selectorHide(); | 118 | void selectorHide(); |
119 | void selectorFileNew(const DocLnk &lnkDoc); | 119 | void selectorFileNew(const DocLnk &lnkDoc); |
120 | void selectorFileOpen(const DocLnk &lnkDoc); | 120 | void selectorFileOpen(const DocLnk &lnkDoc); |
121 | 121 | ||
122 | public: | 122 | public: |
123 | MainWindow(); | 123 | static QString appName() { return QString::fromLatin1("sheetqt"); } |
124 | MainWindow(QWidget *p, const char*, WFlags); | ||
124 | ~MainWindow(); | 125 | ~MainWindow(); |
125 | 126 | ||
126 | void setHelpFile(const QString &help_filename) { helpFile=help_filename; } | 127 | void setHelpFile(const QString &help_filename) { helpFile=help_filename; } |
127 | 128 | ||
128 | public slots: | 129 | public slots: |
129 | void setDocument(const QString &applnk_filename); | 130 | void setDocument(const QString &applnk_filename); |
130 | }; | 131 | }; |
131 | 132 | ||
132 | #endif | 133 | #endif |
diff --git a/noncore/apps/opie-sheet/opie-sheet.pro b/noncore/apps/opie-sheet/opie-sheet.pro index 1435af6..acd5fa0 100644 --- a/noncore/apps/opie-sheet/opie-sheet.pro +++ b/noncore/apps/opie-sheet/opie-sheet.pro | |||
@@ -1,32 +1,30 @@ | |||
1 | TEMPLATE= app | 1 | CONFIG = qt warn_on release quick-app |
2 | CONFIG = qt warn_on release | ||
3 | DESTDIR = $(OPIEDIR)/bin | ||
4 | HEADERS = mainwindow.h sheet.h cellformat.h finddlg.h numberdlg.h sortdlg.h textdlg.h | 2 | HEADERS = mainwindow.h sheet.h cellformat.h finddlg.h numberdlg.h sortdlg.h textdlg.h |
5 | SOURCES = main.cpp mainwindow.cpp sheet.cpp cellformat.cpp finddlg.cpp numberdlg.cpp sortdlg.cpp textdlg.cpp | 3 | SOURCES = main.cpp mainwindow.cpp sheet.cpp cellformat.cpp finddlg.cpp numberdlg.cpp sortdlg.cpp textdlg.cpp |
6 | INCLUDEPATH+= $(OPIEDIR)/include | 4 | INCLUDEPATH+= $(OPIEDIR)/include |
7 | DEPENDPATH+= $(OPIEDIR)/include | 5 | DEPENDPATH+= $(OPIEDIR)/include |
8 | LIBS += -lqpe | 6 | LIBS += -lqpe |
9 | TARGET = sheetqt | 7 | TARGET = sheetqt |
10 | 8 | ||
11 | TRANSLATIONS = ../../../i18n/de/sheetqt.ts \ | 9 | TRANSLATIONS = ../../../i18n/de/sheetqt.ts \ |
12 | ../../../i18n/nl/sheetqt.ts \ | 10 | ../../../i18n/nl/sheetqt.ts \ |
13 | ../../../i18n/da/sheetqt.ts \ | 11 | ../../../i18n/da/sheetqt.ts \ |
14 | ../../../i18n/xx/sheetqt.ts \ | 12 | ../../../i18n/xx/sheetqt.ts \ |
15 | ../../../i18n/en/sheetqt.ts \ | 13 | ../../../i18n/en/sheetqt.ts \ |
16 | ../../../i18n/es/sheetqt.ts \ | 14 | ../../../i18n/es/sheetqt.ts \ |
17 | ../../../i18n/fr/sheetqt.ts \ | 15 | ../../../i18n/fr/sheetqt.ts \ |
18 | ../../../i18n/hu/sheetqt.ts \ | 16 | ../../../i18n/hu/sheetqt.ts \ |
19 | ../../../i18n/ja/sheetqt.ts \ | 17 | ../../../i18n/ja/sheetqt.ts \ |
20 | ../../../i18n/ko/sheetqt.ts \ | 18 | ../../../i18n/ko/sheetqt.ts \ |
21 | ../../../i18n/no/sheetqt.ts \ | 19 | ../../../i18n/no/sheetqt.ts \ |
22 | ../../../i18n/pl/sheetqt.ts \ | 20 | ../../../i18n/pl/sheetqt.ts \ |
23 | ../../../i18n/pt/sheetqt.ts \ | 21 | ../../../i18n/pt/sheetqt.ts \ |
24 | ../../../i18n/pt_BR/sheetqt.ts \ | 22 | ../../../i18n/pt_BR/sheetqt.ts \ |
25 | ../../../i18n/sl/sheetqt.ts \ | 23 | ../../../i18n/sl/sheetqt.ts \ |
26 | ../../../i18n/zh_CN/sheetqt.ts \ | 24 | ../../../i18n/zh_CN/sheetqt.ts \ |
27 | ../../../i18n/zh_TW/sheetqt.ts \ | 25 | ../../../i18n/zh_TW/sheetqt.ts \ |
28 | ../../../i18n/it/sheetqt.ts | 26 | ../../../i18n/it/sheetqt.ts |
29 | 27 | ||
30 | 28 | ||
31 | 29 | ||
32 | include ( $(OPIEDIR)/include.pro ) | 30 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/opie-write/main.cpp b/noncore/apps/opie-write/main.cpp index 027af38..2cdfa55 100644 --- a/noncore/apps/opie-write/main.cpp +++ b/noncore/apps/opie-write/main.cpp | |||
@@ -1,37 +1,28 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** Licensees holding valid Qtopia Developer license may use this | 6 | ** Licensees holding valid Qtopia Developer license may use this |
7 | ** file in accordance with the Qtopia Developer License Agreement | 7 | ** file in accordance with the Qtopia Developer License Agreement |
8 | ** provided with the Software. | 8 | ** provided with the Software. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING |
11 | ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 11 | ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
12 | ** PURPOSE. | 12 | ** PURPOSE. |
13 | ** | 13 | ** |
14 | ** email sales@trolltech.com for information about Qtopia License | 14 | ** email sales@trolltech.com for information about Qtopia License |
15 | ** Agreements. | 15 | ** Agreements. |
16 | ** | 16 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 18 | ** not clear to you. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | 21 | ||
22 | #include <qpe/qpeapplication.h> | 22 | #include <qpe/qpeapplication.h> |
23 | #include <qpe/fileselector.h> | 23 | #include <opie/oapplicationfactory.h> |
24 | #include "mainwindow.h" | 24 | #include "mainwindow.h" |
25 | 25 | ||
26 | int main( int argc, char ** argv ) | 26 | OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) |
27 | { | ||
28 | QPEApplication a( argc, argv ); | ||
29 | 27 | ||
30 | MainWindow e; | ||
31 | a.showMainDocumentWidget(&e); | ||
32 | 28 | ||
33 | QObject::connect( &a, SIGNAL( lastWindowClosed() ), | ||
34 | &a, SLOT( quit() ) ); | ||
35 | |||
36 | a.exec(); | ||
37 | } | ||
diff --git a/noncore/apps/opie-write/mainwindow.cpp b/noncore/apps/opie-write/mainwindow.cpp index 4a49abf..6bb524f 100644 --- a/noncore/apps/opie-write/mainwindow.cpp +++ b/noncore/apps/opie-write/mainwindow.cpp | |||
@@ -1,574 +1,574 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** Licensees holding valid Qtopia Developer license may use this | 6 | ** Licensees holding valid Qtopia Developer license may use this |
7 | ** file in accordance with the Qtopia Developer License Agreement | 7 | ** file in accordance with the Qtopia Developer License Agreement |
8 | ** provided with the Software. | 8 | ** provided with the Software. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING |
11 | ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 11 | ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
12 | ** PURPOSE. | 12 | ** PURPOSE. |
13 | ** | 13 | ** |
14 | ** email sales@trolltech.com for information about Qtopia License | 14 | ** email sales@trolltech.com for information about Qtopia License |
15 | ** Agreements. | 15 | ** Agreements. |
16 | ** | 16 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 18 | ** not clear to you. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | 21 | ||
22 | #include "mainwindow.h" | 22 | #include "mainwindow.h" |
23 | #include <qpe/fileselector.h> | 23 | #include <qpe/fileselector.h> |
24 | #include <qpe/applnk.h> | 24 | #include <qpe/applnk.h> |
25 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
26 | #include <qpe/fontdatabase.h> | 26 | #include <qpe/fontdatabase.h> |
27 | 27 | ||
28 | //#include "qspellchecker.h" | 28 | //#include "qspellchecker.h" |
29 | #include "qtextedit.h" | 29 | #include "qtextedit.h" |
30 | #include <qaction.h> | 30 | #include <qaction.h> |
31 | #include <qtoolbar.h> | 31 | #include <qtoolbar.h> |
32 | #include <qtoolbutton.h> | 32 | #include <qtoolbutton.h> |
33 | #include <qtabwidget.h> | 33 | #include <qtabwidget.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | #include <qfontdatabase.h> | 35 | #include <qfontdatabase.h> |
36 | #include <qcombobox.h> | 36 | #include <qcombobox.h> |
37 | #include <qlineedit.h> | 37 | #include <qlineedit.h> |
38 | #include <qfileinfo.h> | 38 | #include <qfileinfo.h> |
39 | #include <qfile.h> | 39 | #include <qfile.h> |
40 | #include <qfiledialog.h> | 40 | #include <qfiledialog.h> |
41 | #include <qprinter.h> | 41 | #include <qprinter.h> |
42 | #include <qpaintdevicemetrics.h> | 42 | #include <qpaintdevicemetrics.h> |
43 | #include <qmenubar.h> | 43 | #include <qmenubar.h> |
44 | #include <qpopupmenu.h> | 44 | #include <qpopupmenu.h> |
45 | #include <qcolordialog.h> | 45 | #include <qcolordialog.h> |
46 | #include <qpainter.h> | 46 | #include <qpainter.h> |
47 | #include <qstyle.h> | 47 | #include <qstyle.h> |
48 | 48 | ||
49 | class ButtonMenu : public QToolButton | 49 | class ButtonMenu : public QToolButton |
50 | { | 50 | { |
51 | Q_OBJECT | 51 | Q_OBJECT |
52 | public: | 52 | public: |
53 | ButtonMenu( QWidget *parent, const char *name=0 ) | 53 | ButtonMenu( QWidget *parent, const char *name=0 ) |
54 | : QToolButton( parent, name ), current(0) | 54 | : QToolButton( parent, name ), current(0) |
55 | { | 55 | { |
56 | setPopup( new QPopupMenu( this ) ); | 56 | setPopup( new QPopupMenu( this ) ); |
57 | setPopupDelay( 1 ); | 57 | setPopupDelay( 1 ); |
58 | connect( popup(), SIGNAL(activated(int)), this, SLOT(selected(int)) ); | 58 | connect( popup(), SIGNAL(activated(int)), this, SLOT(selected(int)) ); |
59 | } | 59 | } |
60 | 60 | ||
61 | int insertItem(const QIconSet &icon, const QString &text, int id ) { | 61 | int insertItem(const QIconSet &icon, const QString &text, int id ) { |
62 | if ( !popup()->count() ) { | 62 | if ( !popup()->count() ) { |
63 | setIconSet( icon ); | 63 | setIconSet( icon ); |
64 | current = id; | 64 | current = id; |
65 | } | 65 | } |
66 | return popup()->insertItem( icon, text, id ); | 66 | return popup()->insertItem( icon, text, id ); |
67 | } | 67 | } |
68 | 68 | ||
69 | void setCurrentItem( int id ) { | 69 | void setCurrentItem( int id ) { |
70 | if ( id != current ) { | 70 | if ( id != current ) { |
71 | current = id; | 71 | current = id; |
72 | setIconSet( *popup()->iconSet( id ) ); | 72 | setIconSet( *popup()->iconSet( id ) ); |
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
76 | virtual QSize sizeHint() const { | 76 | virtual QSize sizeHint() const { |
77 | return QToolButton::sizeHint() + QSize( 4, 0 ); | 77 | return QToolButton::sizeHint() + QSize( 4, 0 ); |
78 | } | 78 | } |
79 | 79 | ||
80 | signals: | 80 | signals: |
81 | void activated( int id ); | 81 | void activated( int id ); |
82 | 82 | ||
83 | protected slots: | 83 | protected slots: |
84 | void selected( int id ) { | 84 | void selected( int id ) { |
85 | current = id; | 85 | current = id; |
86 | setIconSet( *popup()->iconSet( id ) ); | 86 | setIconSet( *popup()->iconSet( id ) ); |
87 | emit activated( id ); | 87 | emit activated( id ); |
88 | } | 88 | } |
89 | 89 | ||
90 | protected: | 90 | protected: |
91 | virtual void drawButtonLabel( QPainter *p ) { | 91 | virtual void drawButtonLabel( QPainter *p ) { |
92 | p->translate( -4, 0 ); | 92 | p->translate( -4, 0 ); |
93 | QToolButton::drawButtonLabel( p ); | 93 | QToolButton::drawButtonLabel( p ); |
94 | p->translate( 4, 0 ); | 94 | p->translate( 4, 0 ); |
95 | } | 95 | } |
96 | 96 | ||
97 | private: | 97 | private: |
98 | int current; | 98 | int current; |
99 | }; | 99 | }; |
100 | 100 | ||
101 | //=========================================================================== | 101 | //=========================================================================== |
102 | 102 | ||
103 | MainWindow::MainWindow( QWidget *parent, const char *name ) | 103 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags fl ) |
104 | : QMainWindow( parent, name ), | 104 | : QMainWindow( parent, name, fl ), |
105 | doc( 0 ) | 105 | doc( 0 ) |
106 | { | 106 | { |
107 | setRightJustification(TRUE); | 107 | setRightJustification(TRUE); |
108 | 108 | ||
109 | editorStack = new QWidgetStack( this ); | 109 | editorStack = new QWidgetStack( this ); |
110 | 110 | ||
111 | fileSelector = new FileSelector( "text/html", | 111 | fileSelector = new FileSelector( "text/html", |
112 | editorStack, "fileselector" ); | 112 | editorStack, "fileselector" ); |
113 | 113 | ||
114 | 114 | ||
115 | fileSelector->setCloseVisible( FALSE ); | 115 | fileSelector->setCloseVisible( FALSE ); |
116 | editorStack->addWidget( fileSelector, 0 ); | 116 | editorStack->addWidget( fileSelector, 0 ); |
117 | 117 | ||
118 | editor = new Qt3::QTextEdit( editorStack ); | 118 | editor = new Qt3::QTextEdit( editorStack ); |
119 | editor->setTextFormat( Qt::RichText ); | 119 | editor->setTextFormat( Qt::RichText ); |
120 | editorStack->addWidget( editor, 1 ); | 120 | editorStack->addWidget( editor, 1 ); |
121 | 121 | ||
122 | setupActions(); | 122 | setupActions(); |
123 | 123 | ||
124 | QObject::connect( fileSelector, SIGNAL(closeMe()), | 124 | QObject::connect( fileSelector, SIGNAL(closeMe()), |
125 | this, SLOT(showEditTools()) ); | 125 | this, SLOT(showEditTools()) ); |
126 | QObject::connect( fileSelector, SIGNAL(fileSelected(const DocLnk &)), | 126 | QObject::connect( fileSelector, SIGNAL(fileSelected(const DocLnk &)), |
127 | this, SLOT(openFile(const DocLnk &)) ); | 127 | this, SLOT(openFile(const DocLnk &)) ); |
128 | QObject::connect( fileSelector, SIGNAL(newSelected(const DocLnk&)), | 128 | QObject::connect( fileSelector, SIGNAL(newSelected(const DocLnk&)), |
129 | this, SLOT(newFile(const DocLnk&)) ); | 129 | this, SLOT(newFile(const DocLnk&)) ); |
130 | 130 | ||
131 | if ( fileSelector->fileCount() < 1 ) | 131 | if ( fileSelector->fileCount() < 1 ) |
132 | fileNew(); | 132 | fileNew(); |
133 | else { | 133 | else { |
134 | fileOpen(); | 134 | fileOpen(); |
135 | } | 135 | } |
136 | doConnections( editor ); | 136 | doConnections( editor ); |
137 | 137 | ||
138 | setCentralWidget( editorStack ); | 138 | setCentralWidget( editorStack ); |
139 | } | 139 | } |
140 | 140 | ||
141 | MainWindow::~MainWindow() | 141 | MainWindow::~MainWindow() |
142 | { | 142 | { |
143 | save(); | 143 | save(); |
144 | } | 144 | } |
145 | 145 | ||
146 | void MainWindow::setupActions() | 146 | void MainWindow::setupActions() |
147 | { | 147 | { |
148 | setToolBarsMovable(false); | 148 | setToolBarsMovable(false); |
149 | 149 | ||
150 | tbMenu = new QToolBar( this ); | 150 | tbMenu = new QToolBar( this ); |
151 | tbMenu->setHorizontalStretchable( TRUE ); | 151 | tbMenu->setHorizontalStretchable( TRUE ); |
152 | 152 | ||
153 | QMenuBar *menu = new QMenuBar( tbMenu ); | 153 | QMenuBar *menu = new QMenuBar( tbMenu ); |
154 | 154 | ||
155 | tbEdit = new QToolBar( this ); | 155 | tbEdit = new QToolBar( this ); |
156 | 156 | ||
157 | QPopupMenu *file = new QPopupMenu( this ); | 157 | QPopupMenu *file = new QPopupMenu( this ); |
158 | menu->insertItem( tr("File"), file ); | 158 | menu->insertItem( tr("File"), file ); |
159 | 159 | ||
160 | QPopupMenu *edit = new QPopupMenu( this ); | 160 | QPopupMenu *edit = new QPopupMenu( this ); |
161 | menu->insertItem( tr("Edit"), edit ); | 161 | menu->insertItem( tr("Edit"), edit ); |
162 | 162 | ||
163 | // ### perhaps these shortcut keys should have some | 163 | // ### perhaps these shortcut keys should have some |
164 | // IPaq keys defined??? | 164 | // IPaq keys defined??? |
165 | QAction *a; | 165 | QAction *a; |
166 | 166 | ||
167 | a = new QAction( tr( "New" ), Resource::loadPixmap("new"), QString::null, 0, this, 0 ); | 167 | a = new QAction( tr( "New" ), Resource::loadPixmap("new"), QString::null, 0, this, 0 ); |
168 | connect( a, SIGNAL(activated()), this, SLOT(fileNew()) ); | 168 | connect( a, SIGNAL(activated()), this, SLOT(fileNew()) ); |
169 | a->addTo( file ); | 169 | a->addTo( file ); |
170 | 170 | ||
171 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); | 171 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); |
172 | connect( a, SIGNAL(activated()), this, SLOT(fileOpen()) ); | 172 | connect( a, SIGNAL(activated()), this, SLOT(fileOpen()) ); |
173 | a->addTo( file ); | 173 | a->addTo( file ); |
174 | 174 | ||
175 | a = new QAction( tr( "Undo" ), Resource::loadIconSet("undo"), | 175 | a = new QAction( tr( "Undo" ), Resource::loadIconSet("undo"), |
176 | QString::null, 0, this, "editUndo" ); | 176 | QString::null, 0, this, "editUndo" ); |
177 | connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) ); | 177 | connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) ); |
178 | connect( editor, SIGNAL(undoAvailable(bool)), a, SLOT(setEnabled(bool)) ); | 178 | connect( editor, SIGNAL(undoAvailable(bool)), a, SLOT(setEnabled(bool)) ); |
179 | a->addTo( tbEdit ); | 179 | a->addTo( tbEdit ); |
180 | a->addTo( edit ); | 180 | a->addTo( edit ); |
181 | a = new QAction( tr( "Redo" ), Resource::loadIconSet("redo"), | 181 | a = new QAction( tr( "Redo" ), Resource::loadIconSet("redo"), |
182 | QString::null, 0, this, "editRedo" ); | 182 | QString::null, 0, this, "editRedo" ); |
183 | connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) ); | 183 | connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) ); |
184 | connect( editor, SIGNAL(redoAvailable(bool)), a, SLOT(setEnabled(bool)) ); | 184 | connect( editor, SIGNAL(redoAvailable(bool)), a, SLOT(setEnabled(bool)) ); |
185 | a->addTo( tbEdit ); | 185 | a->addTo( tbEdit ); |
186 | a->addTo( edit ); | 186 | a->addTo( edit ); |
187 | 187 | ||
188 | edit->insertSeparator(); | 188 | edit->insertSeparator(); |
189 | 189 | ||
190 | a = new QAction( tr( "Copy" ), Resource::loadIconSet("copy"), | 190 | a = new QAction( tr( "Copy" ), Resource::loadIconSet("copy"), |
191 | QString::null, 0, this, "editCopy" ); | 191 | QString::null, 0, this, "editCopy" ); |
192 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 192 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
193 | connect( editor, SIGNAL(copyAvailable(bool)), a, SLOT(setEnabled(bool)) ); | 193 | connect( editor, SIGNAL(copyAvailable(bool)), a, SLOT(setEnabled(bool)) ); |
194 | a->addTo( tbEdit ); | 194 | a->addTo( tbEdit ); |
195 | a->addTo( edit ); | 195 | a->addTo( edit ); |
196 | a = new QAction( tr( "Cut" ), Resource::loadIconSet("cut"), | 196 | a = new QAction( tr( "Cut" ), Resource::loadIconSet("cut"), |
197 | QString::null, 0, this, "editCut" ); | 197 | QString::null, 0, this, "editCut" ); |
198 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 198 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
199 | connect( editor, SIGNAL(copyAvailable(bool)), a, SLOT(setEnabled(bool)) ); | 199 | connect( editor, SIGNAL(copyAvailable(bool)), a, SLOT(setEnabled(bool)) ); |
200 | a->addTo( tbEdit ); | 200 | a->addTo( tbEdit ); |
201 | a->addTo( edit ); | 201 | a->addTo( edit ); |
202 | a = new QAction( tr( "Paste" ), Resource::loadPixmap("paste"), | 202 | a = new QAction( tr( "Paste" ), Resource::loadPixmap("paste"), |
203 | QString::null, 0, this, "editPaste" ); | 203 | QString::null, 0, this, "editPaste" ); |
204 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 204 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
205 | a->addTo( tbEdit ); | 205 | a->addTo( tbEdit ); |
206 | a->addTo( edit ); | 206 | a->addTo( edit ); |
207 | 207 | ||
208 | tbFont = new QToolBar( this ); | 208 | tbFont = new QToolBar( this ); |
209 | tbFont->setLabel( "Font Actions" ); | 209 | tbFont->setLabel( "Font Actions" ); |
210 | tbFont->setHorizontalStretchable(TRUE); | 210 | tbFont->setHorizontalStretchable(TRUE); |
211 | 211 | ||
212 | comboFont = new QComboBox( FALSE, tbFont ); | 212 | comboFont = new QComboBox( FALSE, tbFont ); |
213 | FontDatabase db; | 213 | FontDatabase db; |
214 | QStringList f= db.families(); | 214 | QStringList f= db.families(); |
215 | comboFont->insertStringList( db.families() ); | 215 | comboFont->insertStringList( db.families() ); |
216 | connect( comboFont, SIGNAL( activated( const QString & ) ), | 216 | connect( comboFont, SIGNAL( activated( const QString & ) ), |
217 | this, SLOT( textFamily( const QString & ) ) ); | 217 | this, SLOT( textFamily( const QString & ) ) ); |
218 | comboFont->setCurrentItem( comboFont->listBox()->index( comboFont->listBox()->findItem( QApplication::font().family() ) ) ); | 218 | comboFont->setCurrentItem( comboFont->listBox()->index( comboFont->listBox()->findItem( QApplication::font().family() ) ) ); |
219 | comboFont->setMaximumWidth(90); | 219 | comboFont->setMaximumWidth(90); |
220 | 220 | ||
221 | comboSize = new QComboBox( TRUE, tbFont ); | 221 | comboSize = new QComboBox( TRUE, tbFont ); |
222 | QValueList<int> sizes = db.standardSizes(); | 222 | QValueList<int> sizes = db.standardSizes(); |
223 | QValueList<int>::Iterator it = sizes.begin(); | 223 | QValueList<int>::Iterator it = sizes.begin(); |
224 | for ( ; it != sizes.end(); ++it ) | 224 | for ( ; it != sizes.end(); ++it ) |
225 | comboSize->insertItem( QString::number( *it ) ); | 225 | comboSize->insertItem( QString::number( *it ) ); |
226 | connect( comboSize, SIGNAL( activated( const QString & ) ), | 226 | connect( comboSize, SIGNAL( activated( const QString & ) ), |
227 | this, SLOT( textSize( const QString & ) ) ); | 227 | this, SLOT( textSize( const QString & ) ) ); |
228 | comboSize->lineEdit()->setText( QString::number( QApplication::font().pointSize() ) ); | 228 | comboSize->lineEdit()->setText( QString::number( QApplication::font().pointSize() ) ); |
229 | comboSize->setFixedWidth( 38 ); | 229 | comboSize->setFixedWidth( 38 ); |
230 | 230 | ||
231 | tbStyle = new QToolBar( this ); | 231 | tbStyle = new QToolBar( this ); |
232 | tbStyle->setLabel( "Style Actions" ); | 232 | tbStyle->setLabel( "Style Actions" ); |
233 | 233 | ||
234 | actionTextBold = new QAction( tr( "Bold" ), | 234 | actionTextBold = new QAction( tr( "Bold" ), |
235 | Resource::loadPixmap("bold"), | 235 | Resource::loadPixmap("bold"), |
236 | QString::null, CTRL + Key_B, | 236 | QString::null, CTRL + Key_B, |
237 | this, "textBold" ); | 237 | this, "textBold" ); |
238 | connect( actionTextBold, SIGNAL( activated() ), this, SLOT( textBold() ) ); | 238 | connect( actionTextBold, SIGNAL( activated() ), this, SLOT( textBold() ) ); |
239 | actionTextBold->addTo( tbStyle ); | 239 | actionTextBold->addTo( tbStyle ); |
240 | actionTextBold->setToggleAction( TRUE ); | 240 | actionTextBold->setToggleAction( TRUE ); |
241 | actionTextItalic = new QAction( tr( "Italic" ), | 241 | actionTextItalic = new QAction( tr( "Italic" ), |
242 | Resource::loadPixmap("italic"), | 242 | Resource::loadPixmap("italic"), |
243 | tr( "&Italic" ), CTRL + Key_I, | 243 | tr( "&Italic" ), CTRL + Key_I, |
244 | this, "textItalic" ); | 244 | this, "textItalic" ); |
245 | connect( actionTextItalic, SIGNAL( activated() ), this, | 245 | connect( actionTextItalic, SIGNAL( activated() ), this, |
246 | SLOT( textItalic() ) ); | 246 | SLOT( textItalic() ) ); |
247 | actionTextItalic->addTo( tbStyle ); | 247 | actionTextItalic->addTo( tbStyle ); |
248 | actionTextItalic->setToggleAction( TRUE ); | 248 | actionTextItalic->setToggleAction( TRUE ); |
249 | actionTextUnderline = new QAction( tr( "Underline" ), | 249 | actionTextUnderline = new QAction( tr( "Underline" ), |
250 | Resource::loadPixmap("underline"), | 250 | Resource::loadPixmap("underline"), |
251 | tr( "&Underline" ), CTRL + Key_U, | 251 | tr( "&Underline" ), CTRL + Key_U, |
252 | this, "textUnderline" ); | 252 | this, "textUnderline" ); |
253 | connect( actionTextUnderline, SIGNAL( activated() ), | 253 | connect( actionTextUnderline, SIGNAL( activated() ), |
254 | this, SLOT( textUnderline() ) ); | 254 | this, SLOT( textUnderline() ) ); |
255 | actionTextUnderline->addTo( tbStyle ); | 255 | actionTextUnderline->addTo( tbStyle ); |
256 | actionTextUnderline->setToggleAction( TRUE ); | 256 | actionTextUnderline->setToggleAction( TRUE ); |
257 | 257 | ||
258 | alignMenu = new ButtonMenu( tbStyle ); | 258 | alignMenu = new ButtonMenu( tbStyle ); |
259 | alignMenu->insertItem( Resource::loadPixmap("left"), tr("Left"), AlignLeft ); | 259 | alignMenu->insertItem( Resource::loadPixmap("left"), tr("Left"), AlignLeft ); |
260 | alignMenu->insertItem( Resource::loadPixmap("center"), tr("Center"), AlignCenter ); | 260 | alignMenu->insertItem( Resource::loadPixmap("center"), tr("Center"), AlignCenter ); |
261 | alignMenu->insertItem( Resource::loadPixmap("right"), tr("Right"), AlignRight ); | 261 | alignMenu->insertItem( Resource::loadPixmap("right"), tr("Right"), AlignRight ); |
262 | alignMenu->insertItem( Resource::loadPixmap("opie-write/justify"), tr("Full"), Qt3::AlignJustify ); | 262 | alignMenu->insertItem( Resource::loadPixmap("opie-write/justify"), tr("Full"), Qt3::AlignJustify ); |
263 | connect( alignMenu, SIGNAL(activated(int)), this, SLOT(textAlign(int)) ); | 263 | connect( alignMenu, SIGNAL(activated(int)), this, SLOT(textAlign(int)) ); |
264 | } | 264 | } |
265 | 265 | ||
266 | Qt3::QTextEdit *MainWindow::currentEditor() const | 266 | Qt3::QTextEdit *MainWindow::currentEditor() const |
267 | { | 267 | { |
268 | return editor; | 268 | return editor; |
269 | } | 269 | } |
270 | 270 | ||
271 | void MainWindow::doConnections( Qt3::QTextEdit *e ) | 271 | void MainWindow::doConnections( Qt3::QTextEdit *e ) |
272 | { | 272 | { |
273 | connect( e, SIGNAL( currentFontChanged( const QFont & ) ), | 273 | connect( e, SIGNAL( currentFontChanged( const QFont & ) ), |
274 | this, SLOT( fontChanged( const QFont & ) ) ); | 274 | this, SLOT( fontChanged( const QFont & ) ) ); |
275 | connect( e, SIGNAL( currentColorChanged( const QColor & ) ), | 275 | connect( e, SIGNAL( currentColorChanged( const QColor & ) ), |
276 | this, SLOT( colorChanged( const QColor & ) ) ); | 276 | this, SLOT( colorChanged( const QColor & ) ) ); |
277 | connect( e, SIGNAL( currentAlignmentChanged( int ) ), | 277 | connect( e, SIGNAL( currentAlignmentChanged( int ) ), |
278 | this, SLOT( alignmentChanged( int ) ) ); | 278 | this, SLOT( alignmentChanged( int ) ) ); |
279 | } | 279 | } |
280 | 280 | ||
281 | void MainWindow::updateFontSizeCombo( const QFont &f ) | 281 | void MainWindow::updateFontSizeCombo( const QFont &f ) |
282 | { | 282 | { |
283 | comboSize->clear(); | 283 | comboSize->clear(); |
284 | FontDatabase fdb; | 284 | FontDatabase fdb; |
285 | QValueList<int> sizes = fdb.pointSizes( f.family() ); | 285 | QValueList<int> sizes = fdb.pointSizes( f.family() ); |
286 | QValueList<int>::Iterator it = sizes.begin(); | 286 | QValueList<int>::Iterator it = sizes.begin(); |
287 | for ( ; it != sizes.end(); ++it ) | 287 | for ( ; it != sizes.end(); ++it ) |
288 | comboSize->insertItem( QString::number( *it ) ); | 288 | comboSize->insertItem( QString::number( *it ) ); |
289 | } | 289 | } |
290 | 290 | ||
291 | void MainWindow::editUndo() | 291 | void MainWindow::editUndo() |
292 | { | 292 | { |
293 | if ( !currentEditor() ) | 293 | if ( !currentEditor() ) |
294 | return; | 294 | return; |
295 | currentEditor()->undo(); | 295 | currentEditor()->undo(); |
296 | } | 296 | } |
297 | 297 | ||
298 | void MainWindow::editRedo() | 298 | void MainWindow::editRedo() |
299 | { | 299 | { |
300 | if ( !currentEditor() ) | 300 | if ( !currentEditor() ) |
301 | return; | 301 | return; |
302 | currentEditor()->redo(); | 302 | currentEditor()->redo(); |
303 | } | 303 | } |
304 | 304 | ||
305 | void MainWindow::editCut() | 305 | void MainWindow::editCut() |
306 | { | 306 | { |
307 | if ( !currentEditor() ) | 307 | if ( !currentEditor() ) |
308 | return; | 308 | return; |
309 | currentEditor()->cut(); | 309 | currentEditor()->cut(); |
310 | } | 310 | } |
311 | 311 | ||
312 | void MainWindow::editCopy() | 312 | void MainWindow::editCopy() |
313 | { | 313 | { |
314 | if ( !currentEditor() ) | 314 | if ( !currentEditor() ) |
315 | return; | 315 | return; |
316 | currentEditor()->copy(); | 316 | currentEditor()->copy(); |
317 | } | 317 | } |
318 | 318 | ||
319 | void MainWindow::editPaste() | 319 | void MainWindow::editPaste() |
320 | { | 320 | { |
321 | if ( !currentEditor() ) | 321 | if ( !currentEditor() ) |
322 | return; | 322 | return; |
323 | currentEditor()->paste(); | 323 | currentEditor()->paste(); |
324 | } | 324 | } |
325 | 325 | ||
326 | void MainWindow::textBold() | 326 | void MainWindow::textBold() |
327 | { | 327 | { |
328 | if ( !currentEditor() ) | 328 | if ( !currentEditor() ) |
329 | return; | 329 | return; |
330 | currentEditor()->setBold( actionTextBold->isOn() ); | 330 | currentEditor()->setBold( actionTextBold->isOn() ); |
331 | } | 331 | } |
332 | 332 | ||
333 | void MainWindow::textUnderline() | 333 | void MainWindow::textUnderline() |
334 | { | 334 | { |
335 | if ( !currentEditor() ) | 335 | if ( !currentEditor() ) |
336 | return; | 336 | return; |
337 | currentEditor()->setUnderline( actionTextUnderline->isOn() ); | 337 | currentEditor()->setUnderline( actionTextUnderline->isOn() ); |
338 | } | 338 | } |
339 | 339 | ||
340 | void MainWindow::textItalic() | 340 | void MainWindow::textItalic() |
341 | { | 341 | { |
342 | if ( !currentEditor() ) | 342 | if ( !currentEditor() ) |
343 | return; | 343 | return; |
344 | currentEditor()->setItalic( actionTextItalic->isOn() ); | 344 | currentEditor()->setItalic( actionTextItalic->isOn() ); |
345 | } | 345 | } |
346 | 346 | ||
347 | void MainWindow::textFamily( const QString &f ) | 347 | void MainWindow::textFamily( const QString &f ) |
348 | { | 348 | { |
349 | if ( !currentEditor() ) | 349 | if ( !currentEditor() ) |
350 | return; | 350 | return; |
351 | currentEditor()->setFamily( f ); | 351 | currentEditor()->setFamily( f ); |
352 | currentEditor()->viewport()->setFocus(); | 352 | currentEditor()->viewport()->setFocus(); |
353 | } | 353 | } |
354 | 354 | ||
355 | void MainWindow::textSize( const QString &p ) | 355 | void MainWindow::textSize( const QString &p ) |
356 | { | 356 | { |
357 | if ( !currentEditor() ) | 357 | if ( !currentEditor() ) |
358 | return; | 358 | return; |
359 | currentEditor()->setPointSize( p.toInt() ); | 359 | currentEditor()->setPointSize( p.toInt() ); |
360 | currentEditor()->viewport()->setFocus(); | 360 | currentEditor()->viewport()->setFocus(); |
361 | } | 361 | } |
362 | 362 | ||
363 | void MainWindow::textStyle( int i ) | 363 | void MainWindow::textStyle( int i ) |
364 | { | 364 | { |
365 | if ( !currentEditor() ) | 365 | if ( !currentEditor() ) |
366 | return; | 366 | return; |
367 | if ( i == 0 ) | 367 | if ( i == 0 ) |
368 | currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayBlock, | 368 | currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayBlock, |
369 | Qt3::QStyleSheetItem::ListDisc ); | 369 | Qt3::QStyleSheetItem::ListDisc ); |
370 | else if ( i == 1 ) | 370 | else if ( i == 1 ) |
371 | currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem, | 371 | currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem, |
372 | Qt3::QStyleSheetItem::ListDisc ); | 372 | Qt3::QStyleSheetItem::ListDisc ); |
373 | else if ( i == 2 ) | 373 | else if ( i == 2 ) |
374 | currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem, | 374 | currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem, |
375 | Qt3::QStyleSheetItem::ListCircle ); | 375 | Qt3::QStyleSheetItem::ListCircle ); |
376 | else if ( i == 3 ) | 376 | else if ( i == 3 ) |
377 | currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem, | 377 | currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem, |
378 | Qt3::QStyleSheetItem::ListSquare ); | 378 | Qt3::QStyleSheetItem::ListSquare ); |
379 | else if ( i == 4 ) | 379 | else if ( i == 4 ) |
380 | currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem, | 380 | currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem, |
381 | Qt3::QStyleSheetItem::ListDecimal ); | 381 | Qt3::QStyleSheetItem::ListDecimal ); |
382 | else if ( i == 5 ) | 382 | else if ( i == 5 ) |
383 | currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem, | 383 | currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem, |
384 | Qt3::QStyleSheetItem::ListLowerAlpha ); | 384 | Qt3::QStyleSheetItem::ListLowerAlpha ); |
385 | else if ( i == 6 ) | 385 | else if ( i == 6 ) |
386 | currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem, | 386 | currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem, |
387 | Qt3::QStyleSheetItem::ListUpperAlpha ); | 387 | Qt3::QStyleSheetItem::ListUpperAlpha ); |
388 | currentEditor()->viewport()->setFocus(); | 388 | currentEditor()->viewport()->setFocus(); |
389 | } | 389 | } |
390 | 390 | ||
391 | void MainWindow::textAlign( int a ) | 391 | void MainWindow::textAlign( int a ) |
392 | { | 392 | { |
393 | if ( !currentEditor() ) | 393 | if ( !currentEditor() ) |
394 | return; | 394 | return; |
395 | editor->setAlignment( a ); | 395 | editor->setAlignment( a ); |
396 | } | 396 | } |
397 | 397 | ||
398 | void MainWindow::fontChanged( const QFont &f ) | 398 | void MainWindow::fontChanged( const QFont &f ) |
399 | { | 399 | { |
400 | comboFont->setCurrentItem( comboFont->listBox()->index( comboFont->listBox()->findItem( f.family() ) ) ); | 400 | comboFont->setCurrentItem( comboFont->listBox()->index( comboFont->listBox()->findItem( f.family() ) ) ); |
401 | updateFontSizeCombo( f ); | 401 | updateFontSizeCombo( f ); |
402 | comboSize->lineEdit()->setText( QString::number( f.pointSize() ) ); | 402 | comboSize->lineEdit()->setText( QString::number( f.pointSize() ) ); |
403 | actionTextBold->setOn( f.bold() ); | 403 | actionTextBold->setOn( f.bold() ); |
404 | actionTextItalic->setOn( f.italic() ); | 404 | actionTextItalic->setOn( f.italic() ); |
405 | actionTextUnderline->setOn( f.underline() ); | 405 | actionTextUnderline->setOn( f.underline() ); |
406 | } | 406 | } |
407 | 407 | ||
408 | void MainWindow::colorChanged( const QColor & ) | 408 | void MainWindow::colorChanged( const QColor & ) |
409 | { | 409 | { |
410 | } | 410 | } |
411 | 411 | ||
412 | void MainWindow::alignmentChanged( int a ) | 412 | void MainWindow::alignmentChanged( int a ) |
413 | { | 413 | { |
414 | if ( ( a == Qt3::AlignAuto ) || ( a & AlignLeft )) { | 414 | if ( ( a == Qt3::AlignAuto ) || ( a & AlignLeft )) { |
415 | alignMenu->setCurrentItem(AlignLeft); | 415 | alignMenu->setCurrentItem(AlignLeft); |
416 | } else if ( ( a & AlignCenter ) ) { | 416 | } else if ( ( a & AlignCenter ) ) { |
417 | alignMenu->setCurrentItem(AlignCenter); | 417 | alignMenu->setCurrentItem(AlignCenter); |
418 | } else if ( ( a & AlignRight ) ) { | 418 | } else if ( ( a & AlignRight ) ) { |
419 | alignMenu->setCurrentItem(AlignRight); | 419 | alignMenu->setCurrentItem(AlignRight); |
420 | } else if ( ( a & Qt3::AlignJustify ) ) { | 420 | } else if ( ( a & Qt3::AlignJustify ) ) { |
421 | alignMenu->setCurrentItem(Qt3::AlignJustify); | 421 | alignMenu->setCurrentItem(Qt3::AlignJustify); |
422 | } | 422 | } |
423 | } | 423 | } |
424 | 424 | ||
425 | void MainWindow::editorChanged( QWidget * ) | 425 | void MainWindow::editorChanged( QWidget * ) |
426 | { | 426 | { |
427 | if ( !currentEditor() ) | 427 | if ( !currentEditor() ) |
428 | return; | 428 | return; |
429 | fontChanged( currentEditor()->font() ); | 429 | fontChanged( currentEditor()->font() ); |
430 | colorChanged( currentEditor()->color() ); | 430 | colorChanged( currentEditor()->color() ); |
431 | alignmentChanged( currentEditor()->alignment() ); | 431 | alignmentChanged( currentEditor()->alignment() ); |
432 | } | 432 | } |
433 | 433 | ||
434 | void MainWindow::fileOpen() | 434 | void MainWindow::fileOpen() |
435 | { | 435 | { |
436 | save(); | 436 | save(); |
437 | editorStack->raiseWidget( fileSelector ); | 437 | editorStack->raiseWidget( fileSelector ); |
438 | fileSelector->reread(); | 438 | fileSelector->reread(); |
439 | hideEditTools(); | 439 | hideEditTools(); |
440 | fileSelector->setNewVisible( TRUE ); | 440 | fileSelector->setNewVisible( TRUE ); |
441 | clear(); | 441 | clear(); |
442 | updateCaption(); | 442 | updateCaption(); |
443 | } | 443 | } |
444 | 444 | ||
445 | void MainWindow::fileRevert() | 445 | void MainWindow::fileRevert() |
446 | { | 446 | { |
447 | qDebug( "QMainWindow::fileRevert needs to be done" ); | 447 | qDebug( "QMainWindow::fileRevert needs to be done" ); |
448 | } | 448 | } |
449 | 449 | ||
450 | void MainWindow::fileNew() | 450 | void MainWindow::fileNew() |
451 | { | 451 | { |
452 | editor->setTextFormat( Qt::RichText ); | 452 | editor->setTextFormat( Qt::RichText ); |
453 | save(); | 453 | save(); |
454 | newFile(DocLnk()); | 454 | newFile(DocLnk()); |
455 | } | 455 | } |
456 | 456 | ||
457 | void MainWindow::insertTable() | 457 | void MainWindow::insertTable() |
458 | { | 458 | { |
459 | qDebug( "MainWindow::insertTable() needs to be done" ); | 459 | qDebug( "MainWindow::insertTable() needs to be done" ); |
460 | } | 460 | } |
461 | 461 | ||
462 | void MainWindow::newFile( const DocLnk &dl ) | 462 | void MainWindow::newFile( const DocLnk &dl ) |
463 | { | 463 | { |
464 | DocLnk nf = dl; | 464 | DocLnk nf = dl; |
465 | nf.setType( "text/html" ); | 465 | nf.setType( "text/html" ); |
466 | clear(); | 466 | clear(); |
467 | editorStack->raiseWidget( editor ); | 467 | editorStack->raiseWidget( editor ); |
468 | editor->viewport()->setFocus(); | 468 | editor->viewport()->setFocus(); |
469 | doc = new DocLnk( nf ); | 469 | doc = new DocLnk( nf ); |
470 | updateCaption(); | 470 | updateCaption(); |
471 | } | 471 | } |
472 | 472 | ||
473 | void MainWindow::openFile( const DocLnk &dl ) | 473 | void MainWindow::openFile( const DocLnk &dl ) |
474 | { | 474 | { |
475 | FileManager fm; | 475 | FileManager fm; |
476 | QString txt; | 476 | QString txt; |
477 | if ( !fm.loadFile( dl, txt ) ) | 477 | if ( !fm.loadFile( dl, txt ) ) |
478 | qDebug( "couldn't open file" ); | 478 | qDebug( "couldn't open file" ); |
479 | clear(); | 479 | clear(); |
480 | editorStack->raiseWidget( editor ); | 480 | editorStack->raiseWidget( editor ); |
481 | editor->viewport()->setFocus(); | 481 | editor->viewport()->setFocus(); |
482 | doc = new DocLnk( dl ); | 482 | doc = new DocLnk( dl ); |
483 | editor->setText( txt ); | 483 | editor->setText( txt ); |
484 | editor->setModified( FALSE ); | 484 | editor->setModified( FALSE ); |
485 | updateCaption(); | 485 | updateCaption(); |
486 | } | 486 | } |
487 | 487 | ||
488 | void MainWindow::showEditTools( void ) | 488 | void MainWindow::showEditTools( void ) |
489 | { | 489 | { |
490 | tbMenu->show(); | 490 | tbMenu->show(); |
491 | tbEdit->show(); | 491 | tbEdit->show(); |
492 | tbFont->show(); | 492 | tbFont->show(); |
493 | tbStyle->show(); | 493 | tbStyle->show(); |
494 | } | 494 | } |
495 | 495 | ||
496 | void MainWindow::hideEditTools( void ) | 496 | void MainWindow::hideEditTools( void ) |
497 | { | 497 | { |
498 | // let's reset the buttons... | 498 | // let's reset the buttons... |
499 | actionTextBold->setOn( FALSE ); | 499 | actionTextBold->setOn( FALSE ); |
500 | actionTextItalic->setOn( FALSE ); | 500 | actionTextItalic->setOn( FALSE ); |
501 | actionTextUnderline->setOn( FALSE ); | 501 | actionTextUnderline->setOn( FALSE ); |
502 | //comboFont->setCurrentText( QApplication::font().family() ); | 502 | //comboFont->setCurrentText( QApplication::font().family() ); |
503 | comboSize->lineEdit()->setText( QString::number(QApplication::font().pointSize() ) ); | 503 | comboSize->lineEdit()->setText( QString::number(QApplication::font().pointSize() ) ); |
504 | tbMenu->hide(); | 504 | tbMenu->hide(); |
505 | tbEdit->hide(); | 505 | tbEdit->hide(); |
506 | tbFont->hide(); | 506 | tbFont->hide(); |
507 | tbStyle->hide(); | 507 | tbStyle->hide(); |
508 | } | 508 | } |
509 | 509 | ||
510 | 510 | ||
511 | void MainWindow::save() | 511 | void MainWindow::save() |
512 | { | 512 | { |
513 | if ( !doc ) | 513 | if ( !doc ) |
514 | return; | 514 | return; |
515 | if ( !editor->isModified() ) | 515 | if ( !editor->isModified() ) |
516 | return; | 516 | return; |
517 | 517 | ||
518 | QString rt = editor->text(); | 518 | QString rt = editor->text(); |
519 | 519 | ||
520 | // quick hack to get around formatting... | 520 | // quick hack to get around formatting... |
521 | editor->setTextFormat( Qt::PlainText ); | 521 | editor->setTextFormat( Qt::PlainText ); |
522 | QString pt = editor->text(); | 522 | QString pt = editor->text(); |
523 | editor->setTextFormat( Qt::RichText ); | 523 | editor->setTextFormat( Qt::RichText ); |
524 | 524 | ||
525 | if ( doc->name().isEmpty() ) { | 525 | if ( doc->name().isEmpty() ) { |
526 | unsigned ispace = pt.find( ' ' ); | 526 | unsigned ispace = pt.find( ' ' ); |
527 | unsigned ienter = pt.find( '\n' ); | 527 | unsigned ienter = pt.find( '\n' ); |
528 | int i = (ispace < ienter) ? ispace : ienter; | 528 | int i = (ispace < ienter) ? ispace : ienter; |
529 | QString docname; | 529 | QString docname; |
530 | if ( i == -1 ) { | 530 | if ( i == -1 ) { |
531 | if ( pt.isEmpty() ) | 531 | if ( pt.isEmpty() ) |
532 | docname = "Empty Text"; | 532 | docname = "Empty Text"; |
533 | else | 533 | else |
534 | docname = pt; | 534 | docname = pt; |
535 | } else { | 535 | } else { |
536 | docname = pt.left( i ); | 536 | docname = pt.left( i ); |
537 | } | 537 | } |
538 | doc->setName(docname); | 538 | doc->setName(docname); |
539 | } | 539 | } |
540 | FileManager fm; | 540 | FileManager fm; |
541 | fm.saveFile( *doc, rt ); | 541 | fm.saveFile( *doc, rt ); |
542 | } | 542 | } |
543 | 543 | ||
544 | void MainWindow::clear() | 544 | void MainWindow::clear() |
545 | { | 545 | { |
546 | delete doc; | 546 | delete doc; |
547 | doc = 0; | 547 | doc = 0; |
548 | editor->clear(); | 548 | editor->clear(); |
549 | } | 549 | } |
550 | 550 | ||
551 | void MainWindow::updateCaption() | 551 | void MainWindow::updateCaption() |
552 | { | 552 | { |
553 | if ( !doc ) | 553 | if ( !doc ) |
554 | setCaption( tr("Rich Text Editor") ); | 554 | setCaption( tr("Rich Text Editor") ); |
555 | else { | 555 | else { |
556 | QString s = doc->name(); | 556 | QString s = doc->name(); |
557 | if ( s.isEmpty() ) | 557 | if ( s.isEmpty() ) |
558 | s = tr( "Unnamed" ); | 558 | s = tr( "Unnamed" ); |
559 | setCaption( s + " - " + tr("Rich Text Editor") ); | 559 | setCaption( s + " - " + tr("Rich Text Editor") ); |
560 | } | 560 | } |
561 | } | 561 | } |
562 | 562 | ||
563 | void MainWindow::closeEvent( QCloseEvent *e ) | 563 | void MainWindow::closeEvent( QCloseEvent *e ) |
564 | { | 564 | { |
565 | if ( editorStack->visibleWidget() == editor ) { | 565 | if ( editorStack->visibleWidget() == editor ) { |
566 | // call fileOpen instead, don't close it | 566 | // call fileOpen instead, don't close it |
567 | fileOpen(); | 567 | fileOpen(); |
568 | e->ignore(); | 568 | e->ignore(); |
569 | } else { | 569 | } else { |
570 | e->accept(); | 570 | e->accept(); |
571 | } | 571 | } |
572 | } | 572 | } |
573 | 573 | ||
574 | #include "mainwindow.moc" | 574 | #include "mainwindow.moc" |
diff --git a/noncore/apps/opie-write/mainwindow.h b/noncore/apps/opie-write/mainwindow.h index 565ad05..17713d8 100644 --- a/noncore/apps/opie-write/mainwindow.h +++ b/noncore/apps/opie-write/mainwindow.h | |||
@@ -1,113 +1,115 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** Licensees holding valid Qtopia Developer license may use this | 6 | ** Licensees holding valid Qtopia Developer license may use this |
7 | ** file in accordance with the Qtopia Developer License Agreement | 7 | ** file in accordance with the Qtopia Developer License Agreement |
8 | ** provided with the Software. | 8 | ** provided with the Software. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING |
11 | ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 11 | ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
12 | ** PURPOSE. | 12 | ** PURPOSE. |
13 | ** | 13 | ** |
14 | ** email sales@trolltech.com for information about Qtopia License | 14 | ** email sales@trolltech.com for information about Qtopia License |
15 | ** Agreements. | 15 | ** Agreements. |
16 | ** | 16 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 18 | ** not clear to you. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | 21 | ||
22 | #ifndef MAINWINDOW_H | 22 | #ifndef MAINWINDOW_H |
23 | #define MAINWINDOW_H | 23 | #define MAINWINDOW_H |
24 | 24 | ||
25 | #include <qmainwindow.h> | 25 | #include <qmainwindow.h> |
26 | #include <qwidgetstack.h> | 26 | #include <qwidgetstack.h> |
27 | #include <qmap.h> | 27 | #include <qmap.h> |
28 | #include <qpe/filemanager.h> | 28 | #include <qpe/filemanager.h> |
29 | 29 | ||
30 | class QAction; | 30 | class QAction; |
31 | class QComboBox; | 31 | class QComboBox; |
32 | class FileSelectorView; | 32 | class FileSelectorView; |
33 | class FileSelector; | 33 | class FileSelector; |
34 | class QToolBar; | 34 | class QToolBar; |
35 | class ButtonMenu; | 35 | class ButtonMenu; |
36 | 36 | ||
37 | namespace Qt3 { | 37 | namespace Qt3 { |
38 | 38 | ||
39 | class QTextEdit; | 39 | class QTextEdit; |
40 | 40 | ||
41 | } | 41 | } |
42 | 42 | ||
43 | class MainWindow : public QMainWindow | 43 | class MainWindow : public QMainWindow |
44 | { | 44 | { |
45 | Q_OBJECT | 45 | Q_OBJECT |
46 | 46 | ||
47 | public: | 47 | public: |
48 | MainWindow( QWidget *parent = 0, const char *name = 0 ); | 48 | MainWindow( QWidget *parent = 0, const char *name = 0 , WFlags fl = 0); |
49 | ~MainWindow(); | 49 | ~MainWindow(); |
50 | 50 | ||
51 | static QString appName() { return QString::fromLatin1("opie-write"); } | ||
52 | |||
51 | protected: | 53 | protected: |
52 | void closeEvent( QCloseEvent *e ); | 54 | void closeEvent( QCloseEvent *e ); |
53 | 55 | ||
54 | private slots: | 56 | private slots: |
55 | // new file functions | 57 | // new file functions |
56 | void fileOpen(); | 58 | void fileOpen(); |
57 | void fileRevert(); | 59 | void fileRevert(); |
58 | void fileNew(); | 60 | void fileNew(); |
59 | 61 | ||
60 | void editUndo(); | 62 | void editUndo(); |
61 | void editRedo(); | 63 | void editRedo(); |
62 | void editCut(); | 64 | void editCut(); |
63 | void editCopy(); | 65 | void editCopy(); |
64 | void editPaste(); | 66 | void editPaste(); |
65 | 67 | ||
66 | void textBold(); | 68 | void textBold(); |
67 | void textUnderline(); | 69 | void textUnderline(); |
68 | void textItalic(); | 70 | void textItalic(); |
69 | void textFamily( const QString &f ); | 71 | void textFamily( const QString &f ); |
70 | void textSize( const QString &p ); | 72 | void textSize( const QString &p ); |
71 | void textStyle( int s ); | 73 | void textStyle( int s ); |
72 | void textAlign( int ); | 74 | void textAlign( int ); |
73 | 75 | ||
74 | void fontChanged( const QFont &f ); | 76 | void fontChanged( const QFont &f ); |
75 | void colorChanged( const QColor &c ); | 77 | void colorChanged( const QColor &c ); |
76 | void alignmentChanged( int a ); | 78 | void alignmentChanged( int a ); |
77 | void editorChanged( QWidget * ); | 79 | void editorChanged( QWidget * ); |
78 | 80 | ||
79 | // these are from textedit, we may need them | 81 | // these are from textedit, we may need them |
80 | void insertTable(); | 82 | void insertTable(); |
81 | void newFile( const DocLnk & ); | 83 | void newFile( const DocLnk & ); |
82 | void openFile( const DocLnk & ); | 84 | void openFile( const DocLnk & ); |
83 | void showEditTools(); | 85 | void showEditTools(); |
84 | void hideEditTools(); | 86 | void hideEditTools(); |
85 | 87 | ||
86 | private: | 88 | private: |
87 | void updateFontSizeCombo( const QFont &f ); | 89 | void updateFontSizeCombo( const QFont &f ); |
88 | void setupActions(); | 90 | void setupActions(); |
89 | Qt3::QTextEdit *currentEditor() const; | 91 | Qt3::QTextEdit *currentEditor() const; |
90 | void doConnections( Qt3::QTextEdit *e ); | 92 | void doConnections( Qt3::QTextEdit *e ); |
91 | void updateCaption(); | 93 | void updateCaption(); |
92 | void save(); | 94 | void save(); |
93 | void clear(); | 95 | void clear(); |
94 | 96 | ||
95 | // added these from the textedit | 97 | // added these from the textedit |
96 | QWidgetStack *editorStack; | 98 | QWidgetStack *editorStack; |
97 | FileSelector *fileSelector; | 99 | FileSelector *fileSelector; |
98 | QToolBar *tbMenu; | 100 | QToolBar *tbMenu; |
99 | QToolBar *tbEdit; | 101 | QToolBar *tbEdit; |
100 | QToolBar *tbFont; | 102 | QToolBar *tbFont; |
101 | QToolBar *tbStyle; | 103 | QToolBar *tbStyle; |
102 | QAction *actionTextBold, | 104 | QAction *actionTextBold, |
103 | *actionTextUnderline, | 105 | *actionTextUnderline, |
104 | *actionTextItalic; | 106 | *actionTextItalic; |
105 | QComboBox *comboFont, | 107 | QComboBox *comboFont, |
106 | *comboSize; | 108 | *comboSize; |
107 | ButtonMenu *alignMenu; | 109 | ButtonMenu *alignMenu; |
108 | DocLnk *doc; | 110 | DocLnk *doc; |
109 | Qt3::QTextEdit* editor; | 111 | Qt3::QTextEdit* editor; |
110 | }; | 112 | }; |
111 | 113 | ||
112 | 114 | ||
113 | #endif | 115 | #endif |
diff --git a/noncore/apps/opie-write/opie-write.pro b/noncore/apps/opie-write/opie-write.pro index 21a3c3a..bbaacd3 100644 --- a/noncore/apps/opie-write/opie-write.pro +++ b/noncore/apps/opie-write/opie-write.pro | |||
@@ -1,46 +1,27 @@ | |||
1 | TEMPLATE= app | ||
2 | CONFIG += qt warn_on release | ||
3 | 1 | ||
4 | DESTDIR = $(OPIEDIR)/bin | 2 | CONFIG += qt warn on release quick-app |
3 | |||
5 | 4 | ||
6 | HEADERS =qcleanuphandler.h \ | 5 | HEADERS =qcleanuphandler.h \ |
7 | qcomplextext_p.h \ | 6 | qcomplextext_p.h \ |
8 | qrichtext_p.h \ | 7 | qrichtext_p.h \ |
9 | qstylesheet.h \ | 8 | qstylesheet.h \ |
10 | qtextedit.h \ | 9 | qtextedit.h \ |
11 | mainwindow.h | 10 | mainwindow.h |
12 | 11 | ||
13 | SOURCES =qcomplextext.cpp \ | 12 | SOURCES =qcomplextext.cpp \ |
14 | qstylesheet.cpp \ | 13 | qstylesheet.cpp \ |
15 | qrichtext_p.cpp \ | 14 | qrichtext_p.cpp \ |
16 | qrichtext.cpp \ | 15 | qrichtext.cpp \ |
17 | qtextedit.cpp \ | 16 | qtextedit.cpp \ |
18 | main.cpp \ | 17 | main.cpp \ |
19 | mainwindow.cpp | 18 | mainwindow.cpp |
20 | 19 | ||
21 | INCLUDEPATH+= $(OPIEDIR)/include | 20 | INCLUDEPATH+= $(OPIEDIR)/include |
22 | DEPENDPATH+= $(OPIEDIR)/include | 21 | DEPENDPATH+= $(OPIEDIR)/include |
23 | LIBS += -lqpe | 22 | LIBS += -lqpe |
24 | 23 | ||
25 | TARGET = opie-write | 24 | TARGET = opie-write |
26 | 25 | ||
27 | TRANSLATIONS = ../../../i18n/de/opie-write.ts \ | ||
28 | ../../../i18n/nl/opie-write.ts \ | ||
29 | ../../../i18n/da/opie-write.ts \ | ||
30 | ../../../i18n/xx/opie-write.ts \ | ||
31 | ../../../i18n/en/opie-write.ts \ | ||
32 | ../../../i18n/es/opie-write.ts \ | ||
33 | ../../../i18n/fr/opie-write.ts \ | ||
34 | ../../../i18n/hu/opie-write.ts \ | ||
35 | ../../../i18n/ja/opie-write.ts \ | ||
36 | ../../../i18n/ko/opie-write.ts \ | ||
37 | ../../../i18n/no/opie-write.ts \ | ||
38 | ../../../i18n/pl/opie-write.ts \ | ||
39 | ../../../i18n/pt/opie-write.ts \ | ||
40 | ../../../i18n/pt_BR/opie-write.ts \ | ||
41 | ../../../i18n/sl/opie-write.ts \ | ||
42 | ../../../i18n/zh_CN/opie-write.ts \ | ||
43 | ../../../i18n/zh_TW/opie-write.ts | ||
44 | |||
45 | 26 | ||
46 | include ( $(OPIEDIR)/include.pro ) | 27 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/oxygen/main.cpp b/noncore/apps/oxygen/main.cpp index c8fcdb4..ac992aa 100644 --- a/noncore/apps/oxygen/main.cpp +++ b/noncore/apps/oxygen/main.cpp | |||
@@ -1,29 +1,24 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | application: : Oxygen | 2 | application: : Oxygen |
3 | 3 | ||
4 | begin : September 2002 | 4 | begin : September 2002 |
5 | copyright : ( C ) 2002 by Carsten Niehaus | 5 | copyright : ( C ) 2002 by Carsten Niehaus |
6 | email : cniehaus@handhelds.org | 6 | email : cniehaus@handhelds.org |
7 | **************************************************************************/ | 7 | **************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * ( at your option ) any later version. * | 14 | * ( at your option ) any later version. * |
15 | * * | 15 | * * |
16 | **************************************************************************/ | 16 | **************************************************************************/ |
17 | 17 | ||
18 | 18 | ||
19 | #include <qpe/qpeapplication.h> | 19 | #include <qpe/qpeapplication.h> |
20 | #include <opie/oapplicationfactory.h> | ||
20 | #include "oxygen.h" | 21 | #include "oxygen.h" |
21 | 22 | ||
22 | int main(int argc, char **argv) | 23 | |
23 | { | 24 | OPIE_EXPORT_APP( OApplicationFactory<Oxygen> ) |
24 | QPEApplication app(argc, argv); | ||
25 | Oxygen *oxi = new Oxygen(); | ||
26 | app.setMainWidget(oxi); | ||
27 | oxi->showMaximized(); | ||
28 | return app.exec(); | ||
29 | } | ||
diff --git a/noncore/apps/oxygen/oxygen.cpp b/noncore/apps/oxygen/oxygen.cpp index 5999cb0..5bdc2aa 100644 --- a/noncore/apps/oxygen/oxygen.cpp +++ b/noncore/apps/oxygen/oxygen.cpp | |||
@@ -1,157 +1,157 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | application: : Oxygen | 2 | application: : Oxygen |
3 | 3 | ||
4 | begin : September 2002 | 4 | begin : September 2002 |
5 | copyright : ( C ) 2002 by Carsten Niehaus | 5 | copyright : ( C ) 2002 by Carsten Niehaus |
6 | email : cniehaus@handhelds.org | 6 | email : cniehaus@handhelds.org |
7 | **************************************************************************/ | 7 | **************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * ( at your option ) any later version. * | 14 | * ( at your option ) any later version. * |
15 | * * | 15 | * * |
16 | **************************************************************************/ | 16 | **************************************************************************/ |
17 | #include "oxygen.h" | 17 | #include "oxygen.h" |
18 | 18 | ||
19 | #include <qapplication.h> | 19 | #include <qapplication.h> |
20 | #include <qtabwidget.h> | 20 | #include <qtabwidget.h> |
21 | 21 | ||
22 | #include "calcdlg.h" | 22 | #include "calcdlg.h" |
23 | #include "calcdlgui.h" | 23 | #include "calcdlgui.h" |
24 | #include "datawidgetui.h" | 24 | #include "datawidgetui.h" |
25 | #include "psewidget.h" | 25 | #include "psewidget.h" |
26 | 26 | ||
27 | 27 | ||
28 | Oxygen::Oxygen() : QMainWindow() | 28 | Oxygen::Oxygen( QWidget *parent, const char *name, WFlags f) : QMainWindow( parent, name, f ) |
29 | { | 29 | { |
30 | loadNames(); | 30 | loadNames(); |
31 | calcDlgUI *CalcDlgUI = new calcDlgUI(); | 31 | calcDlgUI *CalcDlgUI = new calcDlgUI(); |
32 | PSEWidget *pse = new PSEWidget(names); | 32 | PSEWidget *pse = new PSEWidget(names); |
33 | dataWidgetUI *DataWidgetUI = new dataWidgetUI(names); | 33 | dataWidgetUI *DataWidgetUI = new dataWidgetUI(names); |
34 | 34 | ||
35 | setCaption( tr( "Oxygen" ) ); | 35 | setCaption( tr( "Oxygen" ) ); |
36 | 36 | ||
37 | QTabWidget *tabw = new QTabWidget( this , "qtab" ); | 37 | QTabWidget *tabw = new QTabWidget( this , "qtab" ); |
38 | tabw->addTab( pse, tr( "PSE" )); | 38 | tabw->addTab( pse, tr( "PSE" )); |
39 | tabw->addTab( DataWidgetUI , tr( "Data" ) ); | 39 | tabw->addTab( DataWidgetUI , tr( "Data" ) ); |
40 | tabw->addTab( CalcDlgUI, tr( "Calculations" ) ); | 40 | tabw->addTab( CalcDlgUI, tr( "Calculations" ) ); |
41 | setCentralWidget( tabw ); | 41 | setCentralWidget( tabw ); |
42 | } | 42 | } |
43 | 43 | ||
44 | void Oxygen::loadNames() | 44 | void Oxygen::loadNames() |
45 | { | 45 | { |
46 | names.clear(); | 46 | names.clear(); |
47 | names.append( tr("Hydrogen") ); | 47 | names.append( tr("Hydrogen") ); |
48 | names.append( tr("Helium") ); | 48 | names.append( tr("Helium") ); |
49 | names.append( tr("Lithium") ); | 49 | names.append( tr("Lithium") ); |
50 | names.append( tr("Beryllium") ); | 50 | names.append( tr("Beryllium") ); |
51 | names.append( tr("Boron") ); | 51 | names.append( tr("Boron") ); |
52 | names.append( tr("Carbon") ); | 52 | names.append( tr("Carbon") ); |
53 | names.append( tr("Nitrogen") ); | 53 | names.append( tr("Nitrogen") ); |
54 | names.append( tr("Oxygen") ); | 54 | names.append( tr("Oxygen") ); |
55 | names.append( tr("Fluorine") ); | 55 | names.append( tr("Fluorine") ); |
56 | names.append( tr("Neon") ); | 56 | names.append( tr("Neon") ); |
57 | names.append( tr("Sodium") ); | 57 | names.append( tr("Sodium") ); |
58 | names.append( tr("Magnesium") ); | 58 | names.append( tr("Magnesium") ); |
59 | names.append( tr("Aluminum") ); | 59 | names.append( tr("Aluminum") ); |
60 | names.append( tr("Silicon") ); | 60 | names.append( tr("Silicon") ); |
61 | names.append( tr("Phosphorus") ); | 61 | names.append( tr("Phosphorus") ); |
62 | names.append( tr("Sulfur") ); | 62 | names.append( tr("Sulfur") ); |
63 | names.append( tr("Chlorine") ); | 63 | names.append( tr("Chlorine") ); |
64 | names.append( tr("Argon") ); | 64 | names.append( tr("Argon") ); |
65 | names.append( tr("Potassium") ); | 65 | names.append( tr("Potassium") ); |
66 | names.append( tr("Calcium") ); | 66 | names.append( tr("Calcium") ); |
67 | names.append( tr("Scandium") ); | 67 | names.append( tr("Scandium") ); |
68 | names.append( tr("Titanium") ); | 68 | names.append( tr("Titanium") ); |
69 | names.append( tr("Vanadium") ); | 69 | names.append( tr("Vanadium") ); |
70 | names.append( tr("Chromium") ); | 70 | names.append( tr("Chromium") ); |
71 | names.append( tr("Manganese") ); | 71 | names.append( tr("Manganese") ); |
72 | names.append( tr("Iron") ); | 72 | names.append( tr("Iron") ); |
73 | names.append( tr("Cobalt") ); | 73 | names.append( tr("Cobalt") ); |
74 | names.append( tr("Nickel") ); | 74 | names.append( tr("Nickel") ); |
75 | names.append( tr("Copper") ); | 75 | names.append( tr("Copper") ); |
76 | names.append( tr("Zinc") ); | 76 | names.append( tr("Zinc") ); |
77 | names.append( tr("Gallium") ); | 77 | names.append( tr("Gallium") ); |
78 | names.append( tr("Germanium") ); | 78 | names.append( tr("Germanium") ); |
79 | names.append( tr("Arsenic") ); | 79 | names.append( tr("Arsenic") ); |
80 | names.append( tr("Selenium") ); | 80 | names.append( tr("Selenium") ); |
81 | names.append( tr("Bromine") ); | 81 | names.append( tr("Bromine") ); |
82 | names.append( tr("Krypton") ); | 82 | names.append( tr("Krypton") ); |
83 | names.append( tr("Rubidium") ); | 83 | names.append( tr("Rubidium") ); |
84 | names.append( tr("Strontium") ); | 84 | names.append( tr("Strontium") ); |
85 | names.append( tr("Yttrium") ); | 85 | names.append( tr("Yttrium") ); |
86 | names.append( tr("Zirconium") ); | 86 | names.append( tr("Zirconium") ); |
87 | names.append( tr("Niobium") ); | 87 | names.append( tr("Niobium") ); |
88 | names.append( tr("Molybdenum") ); | 88 | names.append( tr("Molybdenum") ); |
89 | names.append( tr("Technetium") ); | 89 | names.append( tr("Technetium") ); |
90 | names.append( tr("Ruthenium") ); | 90 | names.append( tr("Ruthenium") ); |
91 | names.append( tr("Rhodium") ); | 91 | names.append( tr("Rhodium") ); |
92 | names.append( tr("Palladium") ); | 92 | names.append( tr("Palladium") ); |
93 | names.append( tr("Silver") ); | 93 | names.append( tr("Silver") ); |
94 | names.append( tr("Cadmium") ); | 94 | names.append( tr("Cadmium") ); |
95 | names.append( tr("Indium") ); | 95 | names.append( tr("Indium") ); |
96 | names.append( tr("Tin") ); | 96 | names.append( tr("Tin") ); |
97 | names.append( tr("Antimony") ); | 97 | names.append( tr("Antimony") ); |
98 | names.append( tr("Tellurium") ); | 98 | names.append( tr("Tellurium") ); |
99 | names.append( tr("Iodine") ); | 99 | names.append( tr("Iodine") ); |
100 | names.append( tr("Xenon") ); | 100 | names.append( tr("Xenon") ); |
101 | names.append( tr("Cesium") ); | 101 | names.append( tr("Cesium") ); |
102 | names.append( tr("Barium") ); | 102 | names.append( tr("Barium") ); |
103 | names.append( tr("Lanthanum") ); | 103 | names.append( tr("Lanthanum") ); |
104 | names.append( tr("Cerium") ); | 104 | names.append( tr("Cerium") ); |
105 | names.append( tr("Praseodymium") ); | 105 | names.append( tr("Praseodymium") ); |
106 | names.append( tr("Neodymium") ); | 106 | names.append( tr("Neodymium") ); |
107 | names.append( tr("Promethium") ); | 107 | names.append( tr("Promethium") ); |
108 | names.append( tr("Samarium") ); | 108 | names.append( tr("Samarium") ); |
109 | names.append( tr("Europium") ); | 109 | names.append( tr("Europium") ); |
110 | names.append( tr("Gadolinium") ); | 110 | names.append( tr("Gadolinium") ); |
111 | names.append( tr("Terbium") ); | 111 | names.append( tr("Terbium") ); |
112 | names.append( tr("Dysprosium") ); | 112 | names.append( tr("Dysprosium") ); |
113 | names.append( tr("Holmium") ); | 113 | names.append( tr("Holmium") ); |
114 | names.append( tr("Erbium") ); | 114 | names.append( tr("Erbium") ); |
115 | names.append( tr("Thulium") ); | 115 | names.append( tr("Thulium") ); |
116 | names.append( tr("Ytterbium") ); | 116 | names.append( tr("Ytterbium") ); |
117 | names.append( tr("Lutetium") ); | 117 | names.append( tr("Lutetium") ); |
118 | names.append( tr("Hafnium") ); | 118 | names.append( tr("Hafnium") ); |
119 | names.append( tr("Tantalum") ); | 119 | names.append( tr("Tantalum") ); |
120 | names.append( tr("Tungsten") ); | 120 | names.append( tr("Tungsten") ); |
121 | names.append( tr("Rhenium") ); | 121 | names.append( tr("Rhenium") ); |
122 | names.append( tr("Osmium") ); | 122 | names.append( tr("Osmium") ); |
123 | names.append( tr("Iridium") ); | 123 | names.append( tr("Iridium") ); |
124 | names.append( tr("Platinum") ); | 124 | names.append( tr("Platinum") ); |
125 | names.append( tr("Gold") ); | 125 | names.append( tr("Gold") ); |
126 | names.append( tr("Mercury") ); | 126 | names.append( tr("Mercury") ); |
127 | names.append( tr("Thallium") ); | 127 | names.append( tr("Thallium") ); |
128 | names.append( tr("Lead") ); | 128 | names.append( tr("Lead") ); |
129 | names.append( tr("Bismuth") ); | 129 | names.append( tr("Bismuth") ); |
130 | names.append( tr("Polonium") ); | 130 | names.append( tr("Polonium") ); |
131 | names.append( tr("Astatine") ); | 131 | names.append( tr("Astatine") ); |
132 | names.append( tr("Radon") ); | 132 | names.append( tr("Radon") ); |
133 | names.append( tr("Francium") ); | 133 | names.append( tr("Francium") ); |
134 | names.append( tr("Radium") ); | 134 | names.append( tr("Radium") ); |
135 | names.append( tr("Actinium") ); | 135 | names.append( tr("Actinium") ); |
136 | names.append( tr("Thorium") ); | 136 | names.append( tr("Thorium") ); |
137 | names.append( tr("Protactinium") ); | 137 | names.append( tr("Protactinium") ); |
138 | names.append( tr("Uranium") ); | 138 | names.append( tr("Uranium") ); |
139 | names.append( tr("Neptunium") ); | 139 | names.append( tr("Neptunium") ); |
140 | names.append( tr("Plutonium") ); | 140 | names.append( tr("Plutonium") ); |
141 | names.append( tr("Americium") ); | 141 | names.append( tr("Americium") ); |
142 | names.append( tr("Curium") ); | 142 | names.append( tr("Curium") ); |
143 | names.append( tr("Berkelium") ); | 143 | names.append( tr("Berkelium") ); |
144 | names.append( tr("Californium") ); | 144 | names.append( tr("Californium") ); |
145 | names.append( tr("Einsteinium") ); | 145 | names.append( tr("Einsteinium") ); |
146 | names.append( tr("Fermium") ); | 146 | names.append( tr("Fermium") ); |
147 | names.append( tr("Mendelevium") ); | 147 | names.append( tr("Mendelevium") ); |
148 | names.append( tr("Nobelium") ); | 148 | names.append( tr("Nobelium") ); |
149 | names.append( tr("Lawrencium") ); | 149 | names.append( tr("Lawrencium") ); |
150 | names.append( tr("Rutherfordium") ); | 150 | names.append( tr("Rutherfordium") ); |
151 | names.append( tr("Dubnium") ); | 151 | names.append( tr("Dubnium") ); |
152 | names.append( tr("Seaborgium") ); | 152 | names.append( tr("Seaborgium") ); |
153 | names.append( tr("Bohrium") ); | 153 | names.append( tr("Bohrium") ); |
154 | names.append( tr("Hassium") ); | 154 | names.append( tr("Hassium") ); |
155 | names.append( tr("Meitnerium") ); | 155 | names.append( tr("Meitnerium") ); |
156 | } | 156 | } |
157 | 157 | ||
diff --git a/noncore/apps/oxygen/oxygen.h b/noncore/apps/oxygen/oxygen.h index 57fe9fe..c59662d 100644 --- a/noncore/apps/oxygen/oxygen.h +++ b/noncore/apps/oxygen/oxygen.h | |||
@@ -1,24 +1,25 @@ | |||
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 | 9 | ||
10 | class QStringList; | 10 | class QStringList; |
11 | 11 | ||
12 | #include <qmainwindow.h> | 12 | #include <qmainwindow.h> |
13 | 13 | ||
14 | class Oxygen : public QMainWindow | 14 | class Oxygen : public QMainWindow |
15 | { | 15 | { |
16 | Q_OBJECT | 16 | Q_OBJECT |
17 | 17 | ||
18 | public: | 18 | public: |
19 | Oxygen(); | 19 | Oxygen(QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
20 | 20 | static QString appName() { return QString::fromLatin1("oxygen"); } | |
21 | private: | 21 | |
22 | void loadNames(); | 22 | private: |
23 | QStringList names; | 23 | void loadNames(); |
24 | QStringList names; | ||
24 | }; | 25 | }; |
diff --git a/noncore/apps/oxygen/oxygen.pro b/noncore/apps/oxygen/oxygen.pro index a41bf7b..71d4dac 100644 --- a/noncore/apps/oxygen/oxygen.pro +++ b/noncore/apps/oxygen/oxygen.pro | |||
@@ -1,49 +1,27 @@ | |||
1 | TEMPLATE= app | 1 | CONFIG = qt warn_on release quick-app |
2 | CONFIG = qt warn_on release | ||
3 | HEADERS = oxygen.h \ | 2 | HEADERS = oxygen.h \ |
4 | kmolcalc.h \ | 3 | kmolcalc.h \ |
5 | kmolelements.h \ | 4 | kmolelements.h \ |
6 | calcdlgui.h \ | 5 | calcdlgui.h \ |
7 | dataTable.h \ | 6 | dataTable.h \ |
8 | psewidget.h \ | 7 | psewidget.h \ |
9 | oxyframe.h \ | 8 | oxyframe.h \ |
10 | datawidgetui.h | 9 | datawidgetui.h |
11 | 10 | ||
12 | SOURCES = main.cpp \ | 11 | SOURCES = main.cpp \ |
13 | oxygen.cpp \ | 12 | oxygen.cpp \ |
14 | kmolcalc.cpp \ | 13 | kmolcalc.cpp \ |
15 | calcdlgui.cpp \ | 14 | calcdlgui.cpp \ |
16 | kmolelements.cpp \ | 15 | kmolelements.cpp \ |
17 | dataTable.cpp \ | 16 | dataTable.cpp \ |
18 | psewidget.cpp \ | 17 | psewidget.cpp \ |
19 | oxyframe.cpp \ | 18 | oxyframe.cpp \ |
20 | datawidgetui.cpp | 19 | datawidgetui.cpp |
21 | INCLUDEPATH += $(OPIEDIR)/include | 20 | INCLUDEPATH += $(OPIEDIR)/include |
22 | DEPENDPATH += $(OPIEDIR)/include | 21 | DEPENDPATH += $(OPIEDIR)/include |
23 | LIBS += -lqpe -lstdc++ | 22 | LIBS += -lqpe |
24 | INTERFACES= calcdlg.ui | 23 | INTERFACES= calcdlg.ui |
25 | TARGET = oxygen | ||
26 | DESTDIR = $(OPIEDIR)/bin | ||
27 | |||
28 | TRANSLATIONS = ../../../i18n/de/oxygen.ts \ | ||
29 | ../../../i18n/nl/oxygen.ts \ | ||
30 | ../../../i18n/xx/oxygen.ts \ | ||
31 | ../../../i18n/en/oxygen.ts \ | ||
32 | ../../../i18n/es/oxygen.ts \ | ||
33 | ../../../i18n/fr/oxygen.ts \ | ||
34 | ../../../i18n/hu/oxygen.ts \ | ||
35 | ../../../i18n/ja/oxygen.ts \ | ||
36 | ../../../i18n/ko/oxygen.ts \ | ||
37 | ../../../i18n/no/oxygen.ts \ | ||
38 | ../../../i18n/pl/oxygen.ts \ | ||
39 | ../../../i18n/pt/oxygen.ts \ | ||
40 | ../../../i18n/pt_BR/oxygen.ts \ | ||
41 | ../../../i18n/sl/oxygen.ts \ | ||
42 | ../../../i18n/zh_CN/oxygen.ts \ | ||
43 | ../../../i18n/zh_TW/oxygen.ts \ | ||
44 | ../../../i18n/it/oxygen.ts \ | ||
45 | ../../../i18n/da/oxygen.ts | ||
46 | |||
47 | 24 | ||
25 | TARGET= oxygen | ||
48 | 26 | ||
49 | include ( $(OPIEDIR)/include.pro ) | 27 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/tableviewer/main.cpp b/noncore/apps/tableviewer/main.cpp index d17ee65..ce39c84 100644 --- a/noncore/apps/tableviewer/main.cpp +++ b/noncore/apps/tableviewer/main.cpp | |||
@@ -1,32 +1,25 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "tableviewer.h" | 20 | #include "tableviewer.h" |
21 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | #include <opie/oapplicationfactory.h> | ||
22 | 23 | ||
23 | int main( int argc, char ** argv ) | 24 | OPIE_EXPORT_APP( OApplicationFactory<TableViewerWindow> ) |
24 | { | ||
25 | QPEApplication a( argc, argv ); | ||
26 | 25 | ||
27 | TableViewerWindow mw; | ||
28 | mw.setCaption( TableViewerWindow::tr("Table Viewer") ); | ||
29 | a.showMainWidget(&mw); | ||
30 | |||
31 | return a.exec(); | ||
32 | } | ||
diff --git a/noncore/apps/tableviewer/tableviewer.h b/noncore/apps/tableviewer/tableviewer.h index 817db21..f56a460 100644 --- a/noncore/apps/tableviewer/tableviewer.h +++ b/noncore/apps/tableviewer/tableviewer.h | |||
@@ -1,112 +1,113 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef Tableviewer_H | 20 | #ifndef Tableviewer_H |
21 | #define Tableviewer_H | 21 | #define Tableviewer_H |
22 | 22 | ||
23 | #include <qmainwindow.h> | 23 | #include <qmainwindow.h> |
24 | #include "db/common.h" | 24 | #include "db/common.h" |
25 | #include <qpe/fileselector.h> | 25 | #include <qpe/fileselector.h> |
26 | 26 | ||
27 | /* Forward class declarations */ | 27 | /* Forward class declarations */ |
28 | class QWidgetStack; | 28 | class QWidgetStack; |
29 | class QDialog; | 29 | class QDialog; |
30 | class QMenuBar; | 30 | class QMenuBar; |
31 | 31 | ||
32 | class TVListView; | 32 | class TVListView; |
33 | class TVBrowseView; | 33 | class TVBrowseView; |
34 | class TVFilterView; | 34 | class TVFilterView; |
35 | class TVEditView; | 35 | class TVEditView; |
36 | 36 | ||
37 | class DBStore; | 37 | class DBStore; |
38 | 38 | ||
39 | class TableViewerWindow: public QMainWindow | 39 | class TableViewerWindow: public QMainWindow |
40 | { | 40 | { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | public: | 42 | public: |
43 | static QString appName() { return QString::fromLatin1("tableviewer"); } | ||
43 | TableViewerWindow( QWidget *parent = 0, | 44 | TableViewerWindow( QWidget *parent = 0, |
44 | const char *name = 0, WFlags f = 0 ); | 45 | const char *name = 0, WFlags f = 0 ); |
45 | ~TableViewerWindow(); | 46 | ~TableViewerWindow(); |
46 | 47 | ||
47 | public slots: | 48 | public slots: |
48 | void selectDocument(); | 49 | void selectDocument(); |
49 | 50 | ||
50 | void newDocument(); | 51 | void newDocument(); |
51 | void saveDocument(); | 52 | void saveDocument(); |
52 | void setDocument(const QString &); | 53 | void setDocument(const QString &); |
53 | void openDocument(const DocLnk &); | 54 | void openDocument(const DocLnk &); |
54 | 55 | ||
55 | void firstItem(); | 56 | void firstItem(); |
56 | void lastItem(); | 57 | void lastItem(); |
57 | void nextItem(); | 58 | void nextItem(); |
58 | void previousItem(); | 59 | void previousItem(); |
59 | 60 | ||
60 | void listViewSlot(); | 61 | void listViewSlot(); |
61 | void browseViewSlot(); | 62 | void browseViewSlot(); |
62 | void filterViewSlot(); | 63 | void filterViewSlot(); |
63 | 64 | ||
64 | void editItemSlot(); | 65 | void editItemSlot(); |
65 | void newItemSlot(); | 66 | void newItemSlot(); |
66 | void deleteItemSlot(); | 67 | void deleteItemSlot(); |
67 | 68 | ||
68 | void editKeysSlot(); | 69 | void editKeysSlot(); |
69 | 70 | ||
70 | /* reveiw the sig. for this function TODO */ | 71 | /* reveiw the sig. for this function TODO */ |
71 | void searchOnKey(int, TVVariant); | 72 | void searchOnKey(int, TVVariant); |
72 | void setPrimaryKey(int); | 73 | void setPrimaryKey(int); |
73 | 74 | ||
74 | /* TODO add new event */ | 75 | /* TODO add new event */ |
75 | protected: | 76 | protected: |
76 | 77 | ||
77 | /* TODO add new slots */ | 78 | /* TODO add new slots */ |
78 | private slots: | 79 | private slots: |
79 | 80 | ||
80 | /* TODO add other widgets used here */ | 81 | /* TODO add other widgets used here */ |
81 | private: | 82 | private: |
82 | bool dirty; | 83 | bool dirty; |
83 | 84 | ||
84 | QMenuBar *menu; | 85 | QMenuBar *menu; |
85 | QToolBar *navigation; | 86 | QToolBar *navigation; |
86 | 87 | ||
87 | TVListView *listView; | 88 | TVListView *listView; |
88 | TVBrowseView *browseView; | 89 | TVBrowseView *browseView; |
89 | TVFilterView *filterView; | 90 | TVFilterView *filterView; |
90 | TVEditView *editView; | 91 | TVEditView *editView; |
91 | FileSelector *fileSelector; | 92 | FileSelector *fileSelector; |
92 | 93 | ||
93 | DocLnk doc; | 94 | DocLnk doc; |
94 | 95 | ||
95 | QWidgetStack *cw; | 96 | QWidgetStack *cw; |
96 | DBStore *ds; | 97 | DBStore *ds; |
97 | TableState ts; /* not a pointer.. this class keeps the state */ | 98 | TableState ts; /* not a pointer.. this class keeps the state */ |
98 | 99 | ||
99 | enum UserState { | 100 | enum UserState { |
100 | BrowseState = 0, | 101 | BrowseState = 0, |
101 | ListState, | 102 | ListState, |
102 | FilterState, | 103 | FilterState, |
103 | EditState, | 104 | EditState, |
104 | FileState, | 105 | FileState, |
105 | }; | 106 | }; |
106 | 107 | ||
107 | UserState current_view; | 108 | UserState current_view; |
108 | 109 | ||
109 | void applyFilter(); | 110 | void applyFilter(); |
110 | }; | 111 | }; |
111 | 112 | ||
112 | #endif | 113 | #endif |
diff --git a/noncore/apps/tableviewer/tableviewer.pro b/noncore/apps/tableviewer/tableviewer.pro index f047e0b..c6d9e68 100644 --- a/noncore/apps/tableviewer/tableviewer.pro +++ b/noncore/apps/tableviewer/tableviewer.pro | |||
@@ -1,60 +1,58 @@ | |||
1 | TEMPLATE= app | 1 | CONFIG = qt warn_on debug quick-app |
2 | CONFIG = qt warn_on debug | ||
3 | DESTDIR = $(OPIEDIR)/bin | ||
4 | SUBDIRS = db ui | 2 | SUBDIRS = db ui |
5 | HEADERS = tableviewer.h \ | 3 | HEADERS = tableviewer.h \ |
6 | xmlencodeattr.h \ | 4 | xmlencodeattr.h \ |
7 | ui/commonwidgets.h \ | 5 | ui/commonwidgets.h \ |
8 | ui/tvbrowseview.h \ | 6 | ui/tvbrowseview.h \ |
9 | ui/tvlistview.h \ | 7 | ui/tvlistview.h \ |
10 | ui/tvfilterview.h \ | 8 | ui/tvfilterview.h \ |
11 | ui/tveditview.h \ | 9 | ui/tveditview.h \ |
12 | ui/browsekeyentry.h \ | 10 | ui/browsekeyentry.h \ |
13 | ui/filterkeyentry.h \ | 11 | ui/filterkeyentry.h \ |
14 | ui/tvkeyedit.h \ | 12 | ui/tvkeyedit.h \ |
15 | db/datacache.h \ | 13 | db/datacache.h \ |
16 | db/common.h \ | 14 | db/common.h \ |
17 | db/xmlsource.h \ | 15 | db/xmlsource.h \ |
18 | db/csvsource.h | 16 | db/csvsource.h |
19 | SOURCES = main.cpp \ | 17 | SOURCES = main.cpp \ |
20 | tableviewer.cpp \ | 18 | tableviewer.cpp \ |
21 | xmlencodeattr.cpp \ | 19 | xmlencodeattr.cpp \ |
22 | ui/commonwidgets.cpp \ | 20 | ui/commonwidgets.cpp \ |
23 | ui/tvbrowseview.cpp \ | 21 | ui/tvbrowseview.cpp \ |
24 | ui/tvfilterview.cpp \ | 22 | ui/tvfilterview.cpp \ |
25 | ui/browsekeyentry.cpp \ | 23 | ui/browsekeyentry.cpp \ |
26 | ui/filterkeyentry.cpp \ | 24 | ui/filterkeyentry.cpp \ |
27 | ui/tvlistview.cpp \ | 25 | ui/tvlistview.cpp \ |
28 | ui/tveditview.cpp \ | 26 | ui/tveditview.cpp \ |
29 | ui/tvkeyedit.cpp \ | 27 | ui/tvkeyedit.cpp \ |
30 | db/datacache.cpp \ | 28 | db/datacache.cpp \ |
31 | db/xmlsource.cpp \ | 29 | db/xmlsource.cpp \ |
32 | db/csvsource.cpp \ | 30 | db/csvsource.cpp \ |
33 | db/common.cpp | 31 | db/common.cpp |
34 | INTERFACES= ui/tvkeyedit_gen.ui | 32 | INTERFACES= ui/tvkeyedit_gen.ui |
35 | TARGET = tableviewer | 33 | TARGET = tableviewer |
36 | INCLUDEPATH += $(OPIEDIR)/include | 34 | INCLUDEPATH += $(OPIEDIR)/include |
37 | DEPENDPATH += $(OPIEDIR)/include | 35 | DEPENDPATH += $(OPIEDIR)/include |
38 | LIBS += -lqpe | 36 | LIBS += -lqpe |
39 | 37 | ||
40 | TRANSLATIONS = ../../../i18n/de/tableviewer.ts \ | 38 | TRANSLATIONS = ../../../i18n/de/tableviewer.ts \ |
41 | ../../../i18n/nl/tableviewer.ts \ | 39 | ../../../i18n/nl/tableviewer.ts \ |
42 | ../../../i18n/da/tableviewer.ts \ | 40 | ../../../i18n/da/tableviewer.ts \ |
43 | ../../../i18n/xx/tableviewer.ts \ | 41 | ../../../i18n/xx/tableviewer.ts \ |
44 | ../../../i18n/en/tableviewer.ts \ | 42 | ../../../i18n/en/tableviewer.ts \ |
45 | ../../../i18n/es/tableviewer.ts \ | 43 | ../../../i18n/es/tableviewer.ts \ |
46 | ../../../i18n/fr/tableviewer.ts \ | 44 | ../../../i18n/fr/tableviewer.ts \ |
47 | ../../../i18n/hu/tableviewer.ts \ | 45 | ../../../i18n/hu/tableviewer.ts \ |
48 | ../../../i18n/ja/tableviewer.ts \ | 46 | ../../../i18n/ja/tableviewer.ts \ |
49 | ../../../i18n/ko/tableviewer.ts \ | 47 | ../../../i18n/ko/tableviewer.ts \ |
50 | ../../../i18n/no/tableviewer.ts \ | 48 | ../../../i18n/no/tableviewer.ts \ |
51 | ../../../i18n/pl/tableviewer.ts \ | 49 | ../../../i18n/pl/tableviewer.ts \ |
52 | ../../../i18n/pt/tableviewer.ts \ | 50 | ../../../i18n/pt/tableviewer.ts \ |
53 | ../../../i18n/pt_BR/tableviewer.ts \ | 51 | ../../../i18n/pt_BR/tableviewer.ts \ |
54 | ../../../i18n/sl/tableviewer.ts \ | 52 | ../../../i18n/sl/tableviewer.ts \ |
55 | ../../../i18n/zh_CN/tableviewer.ts \ | 53 | ../../../i18n/zh_CN/tableviewer.ts \ |
56 | ../../../i18n/zh_TW/tableviewer.ts | 54 | ../../../i18n/zh_TW/tableviewer.ts |
57 | 55 | ||
58 | 56 | ||
59 | 57 | ||
60 | include ( $(OPIEDIR)/include.pro ) | 58 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/tinykate/main.cpp b/noncore/apps/tinykate/main.cpp index e06668a..e21c040 100644 --- a/noncore/apps/tinykate/main.cpp +++ b/noncore/apps/tinykate/main.cpp | |||
@@ -1,28 +1,22 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | main.cpp | 2 | main.cpp |
3 | ------------------- | 3 | ------------------- |
4 | begin : November 2002 | 4 | begin : November 2002 |
5 | copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> | 5 | copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> |
6 | ***************************************************************************/ | 6 | ***************************************************************************/ |
7 | 7 | ||
8 | /*************************************************************************** | 8 | /*************************************************************************** |
9 | * * | 9 | * * |
10 | * This program is free software; you can redistribute it and/or modify * | 10 | * This program is free software; you can redistribute it and/or modify * |
11 | * it under the terms of the GNU General Public License as published by * | 11 | * it under the terms of the GNU General Public License as published by * |
12 | * the Free Software Foundation. * | 12 | * the Free Software Foundation. * |
13 | * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * | 13 | * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * |
14 | * * | 14 | * * |
15 | ***************************************************************************/ | 15 | ***************************************************************************/ |
16 | #include <qpe/qpeapplication.h> | ||
17 | #include <qmainwindow.h> | 16 | #include <qmainwindow.h> |
18 | #include "tinykate.h" | 17 | #include "tinykate.h" |
19 | 18 | ||
19 | #include <opie/oapplicationfactory.h> | ||
20 | 20 | ||
21 | int main( int argc, char ** argv ) | 21 | OPIE_EXPORT_APP( OApplicationFactory<TinyKate> ) |
22 | { | ||
23 | QPEApplication a( argc, argv ); | ||
24 | 22 | ||
25 | TinyKate m; | ||
26 | a.showMainWidget(&m ); | ||
27 | return a.exec(); | ||
28 | } | ||
diff --git a/noncore/apps/tinykate/opie-tinykate.control b/noncore/apps/tinykate/opie-tinykate.control index 1fde467..9bc0130 100644 --- a/noncore/apps/tinykate/opie-tinykate.control +++ b/noncore/apps/tinykate/opie-tinykate.control | |||
@@ -1,9 +1,9 @@ | |||
1 | Package: opie-tinykate | 1 | Package: opie-tinykate |
2 | Files: plugins/application/libtinykate.so* bin/tinykate apps/Applications/tinykate.desktop pics/tinykate $OPIEDIR/lib/libtinykate.so.1.0.0 $OPIEDIR/lib/libtinykate.so.1.0 $OPIEDIR/lib/libtinykate.so.1 | 2 | Files: plugins/application/libkate.so* bin/kate apps/Applications/tinykate.desktop pics/tinykate $OPIEDIR/lib/libtinykate.so.1.0.0 $OPIEDIR/lib/libtinykate.so.1.0 $OPIEDIR/lib/libtinykate.so.1 |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/applications | 4 | Section: opie/applications |
5 | Maintainer: Opie Team <opie@handhelds.org> | 5 | Maintainer: Opie Team <opie@handhelds.org> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Depends: task-opie-minimal | 7 | Depends: task-opie-minimal |
8 | Description: Kate for opie | 8 | Description: Kate for opie |
9 | Version: $QPE_VERSION$EXTRAVERSION | 9 | Version: $QPE_VERSION$EXTRAVERSION |
diff --git a/noncore/apps/tinykate/tinykate.h b/noncore/apps/tinykate/tinykate.h index 2bf4de6..a5ee9b9 100644 --- a/noncore/apps/tinykate/tinykate.h +++ b/noncore/apps/tinykate/tinykate.h | |||
@@ -1,64 +1,66 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | tinykate.h | 2 | tinykate.h |
3 | Tiny KATE mainwindow | 3 | Tiny KATE mainwindow |
4 | ------------------- | 4 | ------------------- |
5 | begin : November 2002 | 5 | begin : November 2002 |
6 | copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> | 6 | copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> |
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation. * | 13 | * the Free Software Foundation. * |
14 | * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * | 14 | * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #ifndef __TINYKATE_H__ | 18 | #ifndef __TINYKATE_H__ |
19 | #define __TINYKATE_H__ | 19 | #define __TINYKATE_H__ |
20 | 20 | ||
21 | 21 | ||
22 | #include <qmainwindow.h> | 22 | #include <qmainwindow.h> |
23 | #include <opie/otabwidget.h> | 23 | #include <opie/otabwidget.h> |
24 | #include <ktexteditor.h> | 24 | #include <ktexteditor.h> |
25 | 25 | ||
26 | class QToolButton; | 26 | class QToolButton; |
27 | class QAction; | 27 | class QAction; |
28 | class QPopupMenu; | 28 | class QPopupMenu; |
29 | 29 | ||
30 | class TinyKate : public QMainWindow | 30 | class TinyKate : public QMainWindow |
31 | { | 31 | { |
32 | Q_OBJECT | 32 | Q_OBJECT |
33 | public: | 33 | public: |
34 | TinyKate( QWidget *parent=0, const char *name=0, WFlags f = 0); | 34 | TinyKate( QWidget *parent=0, const char *name=0, WFlags f = 0); |
35 | ~TinyKate( ); | 35 | ~TinyKate( ); |
36 | static QString appName() { return QString::fromLatin1( "kate" ); }; | ||
37 | |||
36 | 38 | ||
37 | public slots: | 39 | public slots: |
38 | void slotNew(); | 40 | void slotNew(); |
39 | void setDocument(const QString& fileref); | 41 | void setDocument(const QString& fileref); |
40 | 42 | ||
41 | protected slots: | 43 | protected slots: |
42 | void slotOpen(); | 44 | void slotOpen(); |
43 | void slotClose(); | 45 | void slotClose(); |
44 | void slotCurrentChanged(QWidget *); | 46 | void slotCurrentChanged(QWidget *); |
45 | void slotSave(); | 47 | void slotSave(); |
46 | void slotSaveAs(); | 48 | void slotSaveAs(); |
47 | protected: | 49 | protected: |
48 | void open(const QString&); | 50 | void open(const QString&); |
49 | private: | 51 | private: |
50 | QString currentFileName; | 52 | QString currentFileName; |
51 | OTabWidget *tabwidget; | 53 | OTabWidget *tabwidget; |
52 | KTextEditor::View *currentView; | 54 | KTextEditor::View *currentView; |
53 | bool shutDown; | 55 | bool shutDown; |
54 | 56 | ||
55 | QToolButton *editCopy, *editCut, *editPaste, *editUndo, *editRedo, *editFindReplace; | 57 | QToolButton *editCopy, *editCut, *editPaste, *editUndo, *editRedo, *editFindReplace; |
56 | QAction *viewIncFontSizes, *viewDecFontSizes, *utilSettings; | 58 | QAction *viewIncFontSizes, *viewDecFontSizes, *utilSettings; |
57 | 59 | ||
58 | QPopupMenu *hlmenu; | 60 | QPopupMenu *hlmenu; |
59 | uint nextUnnamed; | 61 | uint nextUnnamed; |
60 | uint viewCount; | 62 | uint viewCount; |
61 | }; | 63 | }; |
62 | 64 | ||
63 | 65 | ||
64 | #endif // __TINYKATE_H__ | 66 | #endif // __TINYKATE_H__ |
diff --git a/noncore/apps/tinykate/tinykate.pro b/noncore/apps/tinykate/tinykate.pro index 632bd49..91d4230 100644 --- a/noncore/apps/tinykate/tinykate.pro +++ b/noncore/apps/tinykate/tinykate.pro | |||
@@ -1,22 +1,22 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release quick-app |
3 | DESTDIR = $(OPIEDIR)/bin | 3 | DESTDIR = $(OPIEDIR)/bin |
4 | HEADERS = tinykate.h | 4 | HEADERS = tinykate.h |
5 | SOURCES = tinykate.cpp main.cpp | 5 | SOURCES = tinykate.cpp main.cpp |
6 | INTERFACES= | 6 | INTERFACES= |
7 | INCLUDEPATH+= $(OPIEDIR)/include \ | 7 | INCLUDEPATH+= $(OPIEDIR)/include \ |
8 | $(OPIEDIR)/noncore/apps/tinykate/libkate \ | 8 | $(OPIEDIR)/noncore/apps/tinykate/libkate \ |
9 | $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \ | 9 | $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \ |
10 | $(OPIEDIR)/noncore/apps/tinykate/libkate/document \ | 10 | $(OPIEDIR)/noncore/apps/tinykate/libkate/document \ |
11 | $(OPIEDIR)/noncore/apps/tinykate/libkate/view \ | 11 | $(OPIEDIR)/noncore/apps/tinykate/libkate/view \ |
12 | $(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \ | 12 | $(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \ |
13 | $(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \ | 13 | $(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \ |
14 | $(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back | 14 | $(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back |
15 | 15 | ||
16 | DEPENDPATH+= $(OPIEDIR)/include | 16 | DEPENDPATH+= $(OPIEDIR)/include |
17 | LIBS += -lqpe -ltinykate -lopie | 17 | LIBS += -lqpe -ltinykate -lopie |
18 | TARGET = tinykate | 18 | TARGET = kate |
19 | 19 | ||
20 | 20 | ||
21 | 21 | ||
22 | include ( $(OPIEDIR)/include.pro ) | 22 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/zsafe/.cvsignore b/noncore/apps/zsafe/.cvsignore new file mode 100644 index 0000000..2f8556e --- a/dev/null +++ b/noncore/apps/zsafe/.cvsignore | |||
@@ -0,0 +1,3 @@ | |||
1 | Makefile | ||
2 | Makefile.in | ||
3 | moc* | ||
diff --git a/noncore/settings/aqpkg/.cvsignore b/noncore/settings/aqpkg/.cvsignore index 2888d4a..4183697 100644 --- a/noncore/settings/aqpkg/.cvsignore +++ b/noncore/settings/aqpkg/.cvsignore | |||
@@ -1,2 +1,3 @@ | |||
1 | Makefile* | 1 | Makefile* |
2 | moc* | 2 | moc* |
3 | .moc* | ||
diff --git a/noncore/settings/aqpkg/aqpkg.pro b/noncore/settings/aqpkg/aqpkg.pro index d241d1b..882cfd4 100644 --- a/noncore/settings/aqpkg/aqpkg.pro +++ b/noncore/settings/aqpkg/aqpkg.pro | |||
@@ -1,62 +1,40 @@ | |||
1 | TEMPLATE= app | 1 | CONFIG = qt warn_on release quick-app |
2 | CONFIG = qt warn_on release | ||
3 | HEADERS = global.h \ | 2 | HEADERS = global.h \ |
4 | mainwin.h \ | 3 | mainwin.h \ |
5 | datamgr.h \ | 4 | datamgr.h \ |
6 | settingsimpl.h \ | 5 | settingsimpl.h \ |
7 | ipkg.h \ | 6 | ipkg.h \ |
8 | packagewin.h \ | 7 | packagewin.h \ |
9 | package.h \ | 8 | package.h \ |
10 | installdlgimpl.h \ | 9 | installdlgimpl.h \ |
11 | instoptionsimpl.h \ | 10 | instoptionsimpl.h \ |
12 | destination.h \ | 11 | destination.h \ |
13 | utils.h \ | 12 | utils.h \ |
14 | server.h \ | 13 | server.h \ |
15 | letterpushbutton.h \ | 14 | letterpushbutton.h \ |
16 | inputdlg.h \ | 15 | inputdlg.h \ |
17 | categoryfilterimpl.h | 16 | categoryfilterimpl.h |
18 | SOURCES = mainwin.cpp \ | 17 | SOURCES = mainwin.cpp \ |
19 | datamgr.cpp \ | 18 | datamgr.cpp \ |
20 | mem.cpp \ | 19 | mem.cpp \ |
21 | settingsimpl.cpp \ | 20 | settingsimpl.cpp \ |
22 | ipkg.cpp \ | 21 | ipkg.cpp \ |
23 | main.cpp \ | 22 | main.cpp \ |
24 | packagewin.cpp \ | 23 | packagewin.cpp \ |
25 | package.cpp \ | 24 | package.cpp \ |
26 | installdlgimpl.cpp \ | 25 | installdlgimpl.cpp \ |
27 | instoptionsimpl.cpp \ | 26 | instoptionsimpl.cpp \ |
28 | destination.cpp \ | 27 | destination.cpp \ |
29 | utils.cpp \ | 28 | utils.cpp \ |
30 | server.cpp \ | 29 | server.cpp \ |
31 | letterpushbutton.cpp \ | 30 | letterpushbutton.cpp \ |
32 | inputdlg.cpp \ | 31 | inputdlg.cpp \ |
33 | version.cpp \ | 32 | version.cpp \ |
34 | categoryfilterimpl.cpp | 33 | categoryfilterimpl.cpp |
35 | INTERFACES= | ||
36 | TARGET = aqpkg | 34 | TARGET = aqpkg |
37 | INCLUDEPATH += $(OPIEDIR)/include | 35 | INCLUDEPATH += $(OPIEDIR)/include |
38 | DEPENDPATH += $(OPIEDIR)/include | 36 | DEPENDPATH += $(OPIEDIR)/include |
39 | LIBS += -lqpe -lopie -lstdc++ | 37 | LIBS += -lqpe -lopie -lstdc++ |
40 | DESTDIR = $(OPIEDIR)/bin | ||
41 | |||
42 | TRANSLATIONS = ../../../i18n/de/aqpkg.ts \ | ||
43 | ../../../i18n/nl/aqpkg.ts \ | ||
44 | ../../../i18n/xx/aqpkg.ts \ | ||
45 | ../../../i18n/en/aqpkg.ts \ | ||
46 | ../../../i18n/es/aqpkg.ts \ | ||
47 | ../../../i18n/fr/aqpkg.ts \ | ||
48 | ../../../i18n/hu/aqpkg.ts \ | ||
49 | ../../../i18n/ja/aqpkg.ts \ | ||
50 | ../../../i18n/ko/aqpkg.ts \ | ||
51 | ../../../i18n/no/aqpkg.ts \ | ||
52 | ../../../i18n/pl/aqpkg.ts \ | ||
53 | ../../../i18n/pt/aqpkg.ts \ | ||
54 | ../../../i18n/pt_BR/aqpkg.ts \ | ||
55 | ../../../i18n/sl/aqpkg.ts \ | ||
56 | ../../../i18n/zh_CN/aqpkg.ts \ | ||
57 | ../../../i18n/zh_TW/aqpkg.ts \ | ||
58 | ../../../i18n/it/aqpkg.ts \ | ||
59 | ../../../i18n/da/aqpkg.ts | ||
60 | |||
61 | 38 | ||
62 | include ( $(OPIEDIR)/include.pro ) | 39 | include ( $(OPIEDIR)/include.pro ) |
40 | |||
diff --git a/noncore/settings/aqpkg/main.cpp b/noncore/settings/aqpkg/main.cpp index b7f8b7b..179f8b7 100644 --- a/noncore/settings/aqpkg/main.cpp +++ b/noncore/settings/aqpkg/main.cpp | |||
@@ -1,78 +1,38 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifdef QWS | ||
31 | #include <qpe/qpeapplication.h> | ||
32 | #include <qpe/qcopenvelope_qws.h> | ||
33 | #else | ||
34 | #include <qapplication.h> | ||
35 | #endif | ||
36 | |||
37 | #include <qobjectdefs.h> | ||
38 | |||
39 | #include "mainwin.h" | 30 | #include "mainwin.h" |
40 | #include "server.h" | ||
41 | |||
42 | #include "global.h" | ||
43 | 31 | ||
32 | #include <opie/oapplicationfactory.h> | ||
44 | 33 | ||
45 | /* be less intrusive for translation -zecke */ | 34 | /* be less intrusive for translation -zecke */ |
46 | extern QString LOCAL_SERVER; | 35 | extern QString LOCAL_SERVER; |
47 | extern QString LOCAL_IPKGS; | 36 | extern QString LOCAL_IPKGS; |
48 | 37 | ||
49 | int main(int argc, char *argv[]) | 38 | OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) |
50 | { | ||
51 | #ifdef QWS | ||
52 | QPEApplication a( argc, argv ); | ||
53 | #else | ||
54 | QApplication a( argc, argv ); | ||
55 | #endif | ||
56 | |||
57 | #ifdef QWS | ||
58 | // Disable suspend mode | ||
59 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; | ||
60 | #endif | ||
61 | |||
62 | LOCAL_SERVER = QObject::tr( "Installed packages" ); | ||
63 | LOCAL_IPKGS = QObject::tr( "Local packages" ); | ||
64 | |||
65 | MainWindow *win = new MainWindow(); | ||
66 | a.setMainWidget(win); | ||
67 | win->showMaximized(); | ||
68 | |||
69 | a.exec(); | ||
70 | |||
71 | #ifdef QWS | ||
72 | // Reenable suspend mode | ||
73 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | ||
74 | #endif | ||
75 | #ifdef _DEBUG | ||
76 | DumpUnfreed(); | ||
77 | #endif | ||
78 | } | ||
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index 42093cf..dbe694e 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp | |||
@@ -1,1233 +1,1240 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <linux/limits.h> | 30 | #include <linux/limits.h> |
31 | #include <unistd.h> | 31 | #include <unistd.h> |
32 | 32 | ||
33 | #include <qpe/qcopenvelope_qws.h> | 33 | #include <qpe/qcopenvelope_qws.h> |
34 | #include <qmenubar.h> | 34 | #include <qmenubar.h> |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #include <qtoolbar.h> | 36 | #include <qtoolbar.h> |
37 | #include <qpe/config.h> | 37 | #include <qpe/config.h> |
38 | #include <qpe/resource.h> | 38 | #include <qpe/resource.h> |
39 | 39 | ||
40 | #include <qaction.h> | 40 | #include <qaction.h> |
41 | #include <qcombobox.h> | 41 | #include <qcombobox.h> |
42 | #include <qfile.h> | 42 | #include <qfile.h> |
43 | #include <qlabel.h> | 43 | #include <qlabel.h> |
44 | #include <qlayout.h> | 44 | #include <qlayout.h> |
45 | #include <qlineedit.h> | 45 | #include <qlineedit.h> |
46 | #include <qlistview.h> | 46 | #include <qlistview.h> |
47 | #include <qmenubar.h> | 47 | #include <qmenubar.h> |
48 | #include <qmessagebox.h> | 48 | #include <qmessagebox.h> |
49 | #include <qpopupmenu.h> | 49 | #include <qpopupmenu.h> |
50 | #include <qprogressbar.h> | 50 | #include <qprogressbar.h> |
51 | #include <qtimer.h> | 51 | #include <qtimer.h> |
52 | #include <qwhatsthis.h> | 52 | #include <qwhatsthis.h> |
53 | #include <qwidgetstack.h> | 53 | #include <qwidgetstack.h> |
54 | 54 | ||
55 | #include "categoryfilterimpl.h" | 55 | #include "categoryfilterimpl.h" |
56 | #include "datamgr.h" | 56 | #include "datamgr.h" |
57 | #include "global.h" | 57 | #include "global.h" |
58 | #include "inputdlg.h" | 58 | #include "inputdlg.h" |
59 | #include "ipkg.h" | 59 | #include "ipkg.h" |
60 | #include "installdlgimpl.h" | 60 | #include "installdlgimpl.h" |
61 | #include "letterpushbutton.h" | 61 | #include "letterpushbutton.h" |
62 | #include "mainwin.h" | 62 | #include "mainwin.h" |
63 | #include "packagewin.h" | 63 | #include "packagewin.h" |
64 | #include "settingsimpl.h" | 64 | #include "settingsimpl.h" |
65 | #include "utils.h" | 65 | #include "utils.h" |
66 | 66 | ||
67 | extern int compareVersions( const char *v1, const char *v2 ); | 67 | extern int compareVersions( const char *v1, const char *v2 ); |
68 | 68 | ||
69 | MainWindow :: MainWindow() | 69 | MainWindow :: MainWindow( QWidget* parent, const char* name, WFlags fl ) |
70 | :QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) | 70 | :QMainWindow( parent, name, fl || WStyle_ContextHelp ) |
71 | { | 71 | { |
72 | // Disable suspend mode | ||
73 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; | ||
74 | |||
75 | LOCAL_SERVER = QObject::tr( "Installed packages" ); | ||
76 | LOCAL_IPKGS = QObject::tr( "Local packages" ); | ||
77 | |||
72 | setCaption( tr( "AQPkg - Package Manager" ) ); | 78 | setCaption( tr( "AQPkg - Package Manager" ) ); |
73 | 79 | ||
74 | // Create UI widgets | 80 | // Create UI widgets |
75 | initMainWidget(); | 81 | initMainWidget(); |
76 | initProgressWidget(); | 82 | initProgressWidget(); |
77 | 83 | ||
78 | // Build menu and tool bars | 84 | // Build menu and tool bars |
79 | setToolBarsMovable( FALSE ); | 85 | setToolBarsMovable( FALSE ); |
80 | 86 | ||
81 | QToolBar *bar = new QToolBar( this ); | 87 | QToolBar *bar = new QToolBar( this ); |
82 | bar->setHorizontalStretchable( TRUE ); | 88 | bar->setHorizontalStretchable( TRUE ); |
83 | QMenuBar *mb = new QMenuBar( bar ); | 89 | QMenuBar *mb = new QMenuBar( bar ); |
84 | mb->setMargin( 0 ); | 90 | mb->setMargin( 0 ); |
85 | bar = new QToolBar( this ); | 91 | bar = new QToolBar( this ); |
86 | 92 | ||
87 | // Find toolbar | 93 | // Find toolbar |
88 | findBar = new QToolBar( this ); | 94 | findBar = new QToolBar( this ); |
89 | addToolBar( findBar, QMainWindow::Top, true ); | 95 | addToolBar( findBar, QMainWindow::Top, true ); |
90 | findBar->setHorizontalStretchable( true ); | 96 | findBar->setHorizontalStretchable( true ); |
91 | findEdit = new QLineEdit( findBar ); | 97 | findEdit = new QLineEdit( findBar ); |
92 | QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); | 98 | QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); |
93 | findBar->setStretchableWidget( findEdit ); | 99 | findBar->setStretchableWidget( findEdit ); |
94 | connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); | 100 | connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); |
95 | 101 | ||
96 | // Quick jump toolbar | 102 | // Quick jump toolbar |
97 | jumpBar = new QToolBar( this ); | 103 | jumpBar = new QToolBar( this ); |
98 | addToolBar( jumpBar, QMainWindow::Top, true ); | 104 | addToolBar( jumpBar, QMainWindow::Top, true ); |
99 | jumpBar->setHorizontalStretchable( true ); | 105 | jumpBar->setHorizontalStretchable( true ); |
100 | QWidget *w = new QWidget( jumpBar ); | 106 | QWidget *w = new QWidget( jumpBar ); |
101 | jumpBar->setStretchableWidget( w ); | 107 | jumpBar->setStretchableWidget( w ); |
102 | 108 | ||
103 | QGridLayout *layout = new QGridLayout( w ); | 109 | QGridLayout *layout = new QGridLayout( w ); |
104 | 110 | ||
105 | char text[2]; | 111 | char text[2]; |
106 | text[1] = '\0'; | 112 | text[1] = '\0'; |
107 | for ( int i = 0 ; i < 26 ; ++i ) | 113 | for ( int i = 0 ; i < 26 ; ++i ) |
108 | { | 114 | { |
109 | text[0] = 'A' + i; | 115 | text[0] = 'A' + i; |
110 | LetterPushButton *b = new LetterPushButton( text, w ); | 116 | LetterPushButton *b = new LetterPushButton( text, w ); |
111 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); | 117 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); |
112 | layout->addWidget( b, i / 13, i % 13); | 118 | layout->addWidget( b, i / 13, i % 13); |
113 | } | 119 | } |
114 | 120 | ||
115 | QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 ); | 121 | QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 ); |
116 | a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) ); | 122 | a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) ); |
117 | connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) ); | 123 | connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) ); |
118 | a->addTo( jumpBar ); | 124 | a->addTo( jumpBar ); |
119 | jumpBar->hide(); | 125 | jumpBar->hide(); |
120 | 126 | ||
121 | // Packages menu | 127 | // Packages menu |
122 | QPopupMenu *popup = new QPopupMenu( this ); | 128 | QPopupMenu *popup = new QPopupMenu( this ); |
123 | 129 | ||
124 | a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); | 130 | a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); |
125 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); | 131 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); |
126 | connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); | 132 | connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); |
127 | a->addTo( popup ); | 133 | a->addTo( popup ); |
128 | a->addTo( bar ); | 134 | a->addTo( bar ); |
129 | 135 | ||
130 | actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); | 136 | actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); |
131 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); | 137 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); |
132 | connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); | 138 | connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); |
133 | actionUpgrade->addTo( popup ); | 139 | actionUpgrade->addTo( popup ); |
134 | actionUpgrade->addTo( bar ); | 140 | actionUpgrade->addTo( bar ); |
135 | 141 | ||
136 | iconDownload = Resource::loadPixmap( "aqpkg/download" ); | 142 | iconDownload = Resource::loadPixmap( "aqpkg/download" ); |
137 | iconRemove = Resource::loadPixmap( "aqpkg/remove" ); | 143 | iconRemove = Resource::loadPixmap( "aqpkg/remove" ); |
138 | actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); | 144 | actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); |
139 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); | 145 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); |
140 | connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); | 146 | connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); |
141 | actionDownload->addTo( popup ); | 147 | actionDownload->addTo( popup ); |
142 | actionDownload->addTo( bar ); | 148 | actionDownload->addTo( bar ); |
143 | 149 | ||
144 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); | 150 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); |
145 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); | 151 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); |
146 | connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); | 152 | connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); |
147 | a->addTo( popup ); | 153 | a->addTo( popup ); |
148 | a->addTo( bar ); | 154 | a->addTo( bar ); |
149 | 155 | ||
150 | popup->insertSeparator(); | 156 | popup->insertSeparator(); |
151 | 157 | ||
152 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); | 158 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); |
153 | a->setWhatsThis( tr( "Click here to configure this application." ) ); | 159 | a->setWhatsThis( tr( "Click here to configure this application." ) ); |
154 | connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); | 160 | connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); |
155 | a->addTo( popup ); | 161 | a->addTo( popup ); |
156 | mb->insertItem( tr( "Actions" ), popup ); | 162 | mb->insertItem( tr( "Actions" ), popup ); |
157 | 163 | ||
158 | // View menu | 164 | // View menu |
159 | popup = new QPopupMenu( this ); | 165 | popup = new QPopupMenu( this ); |
160 | 166 | ||
161 | actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); | 167 | actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); |
162 | actionUninstalled->setToggleAction( TRUE ); | 168 | actionUninstalled->setToggleAction( TRUE ); |
163 | actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); | 169 | actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); |
164 | connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); | 170 | connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); |
165 | actionUninstalled->addTo( popup ); | 171 | actionUninstalled->addTo( popup ); |
166 | 172 | ||
167 | actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); | 173 | actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); |
168 | actionInstalled->setToggleAction( TRUE ); | 174 | actionInstalled->setToggleAction( TRUE ); |
169 | actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); | 175 | actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); |
170 | connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); | 176 | connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); |
171 | actionInstalled->addTo( popup ); | 177 | actionInstalled->addTo( popup ); |
172 | 178 | ||
173 | actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); | 179 | actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); |
174 | actionUpdated->setToggleAction( TRUE ); | 180 | actionUpdated->setToggleAction( TRUE ); |
175 | actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); | 181 | actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); |
176 | connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); | 182 | connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); |
177 | actionUpdated->addTo( popup ); | 183 | actionUpdated->addTo( popup ); |
178 | 184 | ||
179 | popup->insertSeparator(); | 185 | popup->insertSeparator(); |
180 | 186 | ||
181 | actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); | 187 | actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); |
182 | actionFilter->setToggleAction( TRUE ); | 188 | actionFilter->setToggleAction( TRUE ); |
183 | actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); | 189 | actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); |
184 | connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); | 190 | connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); |
185 | actionFilter->addTo( popup ); | 191 | actionFilter->addTo( popup ); |
186 | 192 | ||
187 | a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); | 193 | a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); |
188 | a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); | 194 | a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); |
189 | connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); | 195 | connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); |
190 | a->addTo( popup ); | 196 | a->addTo( popup ); |
191 | 197 | ||
192 | popup->insertSeparator(); | 198 | popup->insertSeparator(); |
193 | 199 | ||
194 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 200 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
195 | a->setWhatsThis( tr( "Click here to search for text in package names." ) ); | 201 | a->setWhatsThis( tr( "Click here to search for text in package names." ) ); |
196 | connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); | 202 | connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); |
197 | a->addTo( popup ); | 203 | a->addTo( popup ); |
198 | 204 | ||
199 | actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); | 205 | actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); |
200 | actionFindNext->setEnabled( FALSE ); | 206 | actionFindNext->setEnabled( FALSE ); |
201 | actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); | 207 | actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); |
202 | connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); | 208 | connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); |
203 | actionFindNext->addTo( popup ); | 209 | actionFindNext->addTo( popup ); |
204 | actionFindNext->addTo( findBar ); | 210 | actionFindNext->addTo( findBar ); |
205 | 211 | ||
206 | 212 | ||
207 | popup->insertSeparator(); | 213 | popup->insertSeparator(); |
208 | 214 | ||
209 | a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 ); | 215 | a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 ); |
210 | a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) ); | 216 | a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) ); |
211 | connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) ); | 217 | connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) ); |
212 | a->addTo( popup ); | 218 | a->addTo( popup ); |
213 | 219 | ||
214 | mb->insertItem( tr( "View" ), popup ); | 220 | mb->insertItem( tr( "View" ), popup ); |
215 | 221 | ||
216 | // Finish find toolbar creation | 222 | // Finish find toolbar creation |
217 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 223 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
218 | a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); | 224 | a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); |
219 | connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); | 225 | connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); |
220 | a->addTo( findBar ); | 226 | a->addTo( findBar ); |
221 | findBar->hide(); | 227 | findBar->hide(); |
222 | 228 | ||
223 | // Create widget stack and add UI widgets | 229 | // Create widget stack and add UI widgets |
224 | stack = new QWidgetStack( this ); | 230 | stack = new QWidgetStack( this ); |
225 | stack->addWidget( progressWindow, 2 ); | 231 | stack->addWidget( progressWindow, 2 ); |
226 | stack->addWidget( networkPkgWindow, 1 ); | 232 | stack->addWidget( networkPkgWindow, 1 ); |
227 | setCentralWidget( stack ); | 233 | setCentralWidget( stack ); |
228 | stack->raiseWidget( progressWindow ); | 234 | stack->raiseWidget( progressWindow ); |
229 | 235 | ||
230 | // Delayed call to finish initialization | 236 | // Delayed call to finish initialization |
231 | QTimer::singleShot( 100, this, SLOT( init() ) ); | 237 | QTimer::singleShot( 100, this, SLOT( init() ) ); |
232 | } | 238 | } |
233 | 239 | ||
234 | MainWindow :: ~MainWindow() | 240 | MainWindow :: ~MainWindow() |
235 | { | 241 | { |
236 | delete mgr; | 242 | delete mgr; |
243 | |||
244 | // Reenable suspend mode | ||
245 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | ||
237 | } | 246 | } |
238 | 247 | ||
239 | void MainWindow :: initMainWidget() | 248 | void MainWindow :: initMainWidget() |
240 | { | 249 | { |
241 | networkPkgWindow = new QWidget( this ); | 250 | networkPkgWindow = new QWidget( this ); |
242 | 251 | ||
243 | QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); | 252 | QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); |
244 | 253 | ||
245 | serversList = new QComboBox( networkPkgWindow ); | 254 | serversList = new QComboBox( networkPkgWindow ); |
246 | connect( serversList, SIGNAL(activated(int)), this, SLOT(serverSelected(int)) ); | 255 | connect( serversList, SIGNAL(activated(int)), this, SLOT(serverSelected(int)) ); |
247 | QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); | 256 | QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); |
248 | 257 | ||
249 | installedIcon = Resource::loadPixmap( "installed" ); | 258 | installedIcon = Resource::loadPixmap( "installed" ); |
250 | updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); | 259 | updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); |
251 | 260 | ||
252 | packagesList = new QListView( networkPkgWindow ); | 261 | packagesList = new QListView( networkPkgWindow ); |
253 | packagesList->addColumn( tr( "Packages" ), 225 ); | 262 | packagesList->addColumn( tr( "Packages" ), 225 ); |
254 | QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); | 263 | QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); |
255 | QPEApplication::setStylusOperation( packagesList->viewport(), QPEApplication::RightOnHold ); | 264 | QPEApplication::setStylusOperation( packagesList->viewport(), QPEApplication::RightOnHold ); |
256 | connect( packagesList, SIGNAL(rightButtonPressed(QListViewItem *,const QPoint &,int)), | 265 | connect( packagesList, SIGNAL(rightButtonPressed(QListViewItem *,const QPoint &,int)), |
257 | this, SLOT(slotDisplayPackage(QListViewItem *)) ); | 266 | this, SLOT(slotDisplayPackage(QListViewItem *)) ); |
258 | 267 | ||
259 | QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); | 268 | QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); |
260 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); | 269 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); |
261 | hbox1->addWidget( l ); | 270 | hbox1->addWidget( l ); |
262 | hbox1->addWidget( serversList ); | 271 | hbox1->addWidget( serversList ); |
263 | 272 | ||
264 | vbox->addWidget( packagesList ); | 273 | vbox->addWidget( packagesList ); |
265 | 274 | ||
266 | downloadEnabled = TRUE; | 275 | downloadEnabled = TRUE; |
267 | } | 276 | } |
268 | 277 | ||
269 | void MainWindow :: initProgressWidget() | 278 | void MainWindow :: initProgressWidget() |
270 | { | 279 | { |
271 | progressWindow = new QWidget( this ); | 280 | progressWindow = new QWidget( this ); |
272 | 281 | ||
273 | QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); | 282 | QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); |
274 | 283 | ||
275 | m_status = new QLabel( progressWindow ); | 284 | m_status = new QLabel( progressWindow ); |
276 | m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); | 285 | m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); |
277 | layout->addWidget( m_status ); | 286 | layout->addWidget( m_status ); |
278 | 287 | ||
279 | m_progress = new QProgressBar( progressWindow ); | 288 | m_progress = new QProgressBar( progressWindow ); |
280 | layout->addWidget( m_progress ); | 289 | layout->addWidget( m_progress ); |
281 | } | 290 | } |
282 | 291 | ||
283 | void MainWindow :: init() | 292 | void MainWindow :: init() |
284 | { | 293 | { |
285 | #ifdef QWS | 294 | #ifdef QWS |
286 | // read download directory from config file | 295 | // read download directory from config file |
287 | Config cfg( "aqpkg" ); | 296 | Config cfg( "aqpkg" ); |
288 | cfg.setGroup( "settings" ); | 297 | cfg.setGroup( "settings" ); |
289 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); | 298 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); |
290 | // showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); | 299 | // showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); |
291 | 300 | ||
292 | #endif | 301 | #endif |
293 | 302 | ||
294 | stack->raiseWidget( progressWindow ); | 303 | stack->raiseWidget( progressWindow ); |
295 | 304 | ||
296 | mgr = new DataManager(); | 305 | mgr = new DataManager(); |
297 | connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); | 306 | connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); |
298 | connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), | 307 | connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), |
299 | this, SLOT( setProgressMessage( const QString & ) ) ); | 308 | this, SLOT( setProgressMessage( const QString & ) ) ); |
300 | connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); | 309 | connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); |
301 | mgr->loadServers(); | 310 | mgr->loadServers(); |
302 | 311 | ||
303 | showUninstalledPkgs = false; | 312 | showUninstalledPkgs = false; |
304 | showInstalledPkgs = false; | 313 | showInstalledPkgs = false; |
305 | showUpgradedPkgs = false; | 314 | showUpgradedPkgs = false; |
306 | categoryFilterEnabled = false; | 315 | categoryFilterEnabled = false; |
307 | 316 | ||
308 | updateData(); | 317 | updateData(); |
309 | 318 | ||
310 | stack->raiseWidget( networkPkgWindow ); | 319 | stack->raiseWidget( networkPkgWindow ); |
311 | } | 320 | } |
312 | 321 | ||
313 | void MainWindow :: setDocument( const QString &doc ) | 322 | void MainWindow :: setDocument( const QString &doc ) |
314 | { | 323 | { |
315 | // Remove path from package | 324 | // Remove path from package |
316 | QString package = Utils::getPackageNameFromIpkFilename( doc ); | 325 | QString package = Utils::getPackageNameFromIpkFilename( doc ); |
317 | 326 | ||
318 | // First select local server | 327 | // First select local server |
319 | for ( int i = 0 ; i < serversList->count() ; ++i ) | 328 | for ( int i = 0 ; i < serversList->count() ; ++i ) |
320 | { | 329 | { |
321 | if ( serversList->text( i ) == LOCAL_IPKGS ) | 330 | if ( serversList->text( i ) == LOCAL_IPKGS ) |
322 | { | 331 | { |
323 | serversList->setCurrentItem( i ); | 332 | serversList->setCurrentItem( i ); |
324 | break; | 333 | break; |
325 | } | 334 | } |
326 | } | 335 | } |
327 | serverSelected( 0 ); | 336 | serverSelected( 0 ); |
328 | 337 | ||
329 | // Now set the check box of the selected package | 338 | // Now set the check box of the selected package |
330 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 339 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
331 | item != 0 ; | 340 | item != 0 ; |
332 | item = (QCheckListItem *)item->nextSibling() ) | 341 | item = (QCheckListItem *)item->nextSibling() ) |
333 | { | 342 | { |
334 | if ( item->text().startsWith( package ) ) | 343 | if ( item->text().startsWith( package ) ) |
335 | { | 344 | { |
336 | item->setOn( true ); | 345 | item->setOn( true ); |
337 | break; | 346 | break; |
338 | } | 347 | } |
339 | } | 348 | } |
340 | } | 349 | } |
341 | 350 | ||
342 | void MainWindow :: displaySettings() | 351 | void MainWindow :: displaySettings() |
343 | { | 352 | { |
344 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); | 353 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); |
345 | if ( dlg->showDlg() ) | 354 | if ( dlg->showDlg() ) |
346 | { | 355 | { |
347 | stack->raiseWidget( progressWindow ); | 356 | stack->raiseWidget( progressWindow ); |
348 | updateData(); | 357 | updateData(); |
349 | stack->raiseWidget( networkPkgWindow ); | 358 | stack->raiseWidget( networkPkgWindow ); |
350 | } | 359 | } |
351 | delete dlg; | 360 | delete dlg; |
352 | } | 361 | } |
353 | 362 | ||
354 | void MainWindow :: closeEvent( QCloseEvent *e ) | 363 | void MainWindow :: closeEvent( QCloseEvent *e ) |
355 | { | 364 | { |
356 | // If install dialog is visible, return to main view, otherwise close app | 365 | // If install dialog is visible, return to main view, otherwise close app |
357 | QWidget *widget = stack->visibleWidget(); | 366 | QWidget *widget = stack->visibleWidget(); |
358 | 367 | ||
359 | if ( widget != networkPkgWindow && widget != progressWindow ) | 368 | if ( widget != networkPkgWindow && widget != progressWindow ) |
360 | { | 369 | { |
361 | if ( widget ) delete widget; | 370 | if ( widget ) delete widget; |
362 | stack->raiseWidget( networkPkgWindow ); | 371 | stack->raiseWidget( networkPkgWindow ); |
363 | e->ignore(); | 372 | e->ignore(); |
364 | } | 373 | } |
365 | else | 374 | else |
366 | { | 375 | { |
367 | e->accept(); | 376 | e->accept(); |
368 | } | 377 | } |
369 | } | 378 | } |
370 | 379 | ||
371 | void MainWindow :: displayFindBar() | 380 | void MainWindow :: displayFindBar() |
372 | { | 381 | { |
373 | findBar->show(); | 382 | findBar->show(); |
374 | findEdit->setFocus(); | 383 | findEdit->setFocus(); |
375 | } | 384 | } |
376 | 385 | ||
377 | void MainWindow :: displayJumpBar() | 386 | void MainWindow :: displayJumpBar() |
378 | { | 387 | { |
379 | jumpBar->show(); | 388 | jumpBar->show(); |
380 | } | 389 | } |
381 | 390 | ||
382 | void MainWindow :: repeatFind() | 391 | void MainWindow :: repeatFind() |
383 | { | 392 | { |
384 | searchForPackage( findEdit->text() ); | 393 | searchForPackage( findEdit->text() ); |
385 | } | 394 | } |
386 | 395 | ||
387 | void MainWindow :: findPackage( const QString &text ) | 396 | void MainWindow :: findPackage( const QString &text ) |
388 | { | 397 | { |
389 | actionFindNext->setEnabled( !text.isEmpty() ); | 398 | actionFindNext->setEnabled( !text.isEmpty() ); |
390 | searchForPackage( text ); | 399 | searchForPackage( text ); |
391 | } | 400 | } |
392 | 401 | ||
393 | void MainWindow :: hideFindBar() | 402 | void MainWindow :: hideFindBar() |
394 | { | 403 | { |
395 | findBar->hide(); | 404 | findBar->hide(); |
396 | } | 405 | } |
397 | 406 | ||
398 | void MainWindow :: hideJumpBar() | 407 | void MainWindow :: hideJumpBar() |
399 | { | 408 | { |
400 | jumpBar->hide(); | 409 | jumpBar->hide(); |
401 | } | 410 | } |
402 | 411 | ||
403 | void MainWindow :: filterUninstalledPackages() | 412 | void MainWindow :: filterUninstalledPackages() |
404 | { | 413 | { |
405 | showUninstalledPkgs = actionUninstalled->isOn(); | 414 | showUninstalledPkgs = actionUninstalled->isOn(); |
406 | if ( showUninstalledPkgs ) | 415 | if ( showUninstalledPkgs ) |
407 | { | 416 | { |
408 | showInstalledPkgs = FALSE; | 417 | showInstalledPkgs = FALSE; |
409 | showUpgradedPkgs = FALSE; | 418 | showUpgradedPkgs = FALSE; |
410 | } | 419 | } |
411 | serverSelected( -1 ); | 420 | serverSelected( -1 ); |
412 | 421 | ||
413 | actionInstalled->setOn( FALSE ); | 422 | actionInstalled->setOn( FALSE ); |
414 | actionUpdated->setOn( FALSE ); | 423 | actionUpdated->setOn( FALSE ); |
415 | } | 424 | } |
416 | 425 | ||
417 | void MainWindow :: filterInstalledPackages() | 426 | void MainWindow :: filterInstalledPackages() |
418 | { | 427 | { |
419 | showInstalledPkgs = actionInstalled->isOn(); | 428 | showInstalledPkgs = actionInstalled->isOn(); |
420 | if ( showInstalledPkgs ) | 429 | if ( showInstalledPkgs ) |
421 | { | 430 | { |
422 | showUninstalledPkgs = FALSE; | 431 | showUninstalledPkgs = FALSE; |
423 | showUpgradedPkgs = FALSE; | 432 | showUpgradedPkgs = FALSE; |
424 | } | 433 | } |
425 | serverSelected( -1 ); | 434 | serverSelected( -1 ); |
426 | 435 | ||
427 | actionUninstalled->setOn( FALSE ); | 436 | actionUninstalled->setOn( FALSE ); |
428 | actionUpdated->setOn( FALSE ); | 437 | actionUpdated->setOn( FALSE ); |
429 | } | 438 | } |
430 | 439 | ||
431 | void MainWindow :: filterUpgradedPackages() | 440 | void MainWindow :: filterUpgradedPackages() |
432 | { | 441 | { |
433 | showUpgradedPkgs = actionUpdated->isOn(); | 442 | showUpgradedPkgs = actionUpdated->isOn(); |
434 | if ( showUpgradedPkgs ) | 443 | if ( showUpgradedPkgs ) |
435 | { | 444 | { |
436 | showUninstalledPkgs = FALSE; | 445 | showUninstalledPkgs = FALSE; |
437 | showInstalledPkgs = FALSE; | 446 | showInstalledPkgs = FALSE; |
438 | } | 447 | } |
439 | serverSelected( -1 ); | 448 | serverSelected( -1 ); |
440 | 449 | ||
441 | actionUninstalled->setOn( FALSE ); | 450 | actionUninstalled->setOn( FALSE ); |
442 | actionInstalled->setOn( FALSE ); | 451 | actionInstalled->setOn( FALSE ); |
443 | } | 452 | } |
444 | 453 | ||
445 | bool MainWindow :: setFilterCategory() | 454 | bool MainWindow :: setFilterCategory() |
446 | { | 455 | { |
447 | // Get categories; | 456 | // Get categories; |
448 | CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); | 457 | CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); |
449 | if ( dlg.exec() == QDialog::Accepted ) | 458 | if ( dlg.exec() == QDialog::Accepted ) |
450 | { | 459 | { |
451 | categoryFilter = dlg.getSelectedFilter(); | 460 | categoryFilter = dlg.getSelectedFilter(); |
452 | 461 | ||
453 | if ( categoryFilter == "" ) | 462 | if ( categoryFilter == "" ) |
454 | return false; | 463 | return false; |
455 | 464 | ||
456 | categoryFilterEnabled = true; | 465 | categoryFilterEnabled = true; |
457 | serverSelected( -1 ); | 466 | serverSelected( -1 ); |
458 | actionFilter->setOn( TRUE ); | 467 | actionFilter->setOn( TRUE ); |
459 | return true; | 468 | return true; |
460 | } | 469 | } |
461 | 470 | ||
462 | return false; | 471 | return false; |
463 | } | 472 | } |
464 | 473 | ||
465 | void MainWindow :: filterCategory() | 474 | void MainWindow :: filterCategory() |
466 | { | 475 | { |
467 | if ( !actionFilter->isOn() ) | 476 | if ( !actionFilter->isOn() ) |
468 | { | 477 | { |
469 | filterByCategory( FALSE ); | 478 | filterByCategory( FALSE ); |
470 | } | 479 | } |
471 | else | 480 | else |
472 | { | 481 | { |
473 | actionFilter->setOn( filterByCategory( TRUE ) ); | 482 | actionFilter->setOn( filterByCategory( TRUE ) ); |
474 | } | 483 | } |
475 | } | 484 | } |
476 | 485 | ||
477 | bool MainWindow :: filterByCategory( bool val ) | 486 | bool MainWindow :: filterByCategory( bool val ) |
478 | { | 487 | { |
479 | if ( val ) | 488 | if ( val ) |
480 | { | 489 | { |
481 | if ( categoryFilter == "" ) | 490 | if ( categoryFilter == "" ) |
482 | { | 491 | { |
483 | if ( !setFilterCategory() ) | 492 | if ( !setFilterCategory() ) |
484 | return false; | 493 | return false; |
485 | } | 494 | } |
486 | 495 | ||
487 | categoryFilterEnabled = true; | 496 | categoryFilterEnabled = true; |
488 | serverSelected( -1 ); | 497 | serverSelected( -1 ); |
489 | return true; | 498 | return true; |
490 | } | 499 | } |
491 | else | 500 | else |
492 | { | 501 | { |
493 | // Turn off filter | 502 | // Turn off filter |
494 | categoryFilterEnabled = false; | 503 | categoryFilterEnabled = false; |
495 | serverSelected( -1 ); | 504 | serverSelected( -1 ); |
496 | return false; | 505 | return false; |
497 | } | 506 | } |
498 | } | 507 | } |
499 | 508 | ||
500 | void MainWindow :: raiseMainWidget() | 509 | void MainWindow :: raiseMainWidget() |
501 | { | 510 | { |
502 | stack->raiseWidget( networkPkgWindow ); | 511 | stack->raiseWidget( networkPkgWindow ); |
503 | } | 512 | } |
504 | 513 | ||
505 | void MainWindow :: raiseProgressWidget() | 514 | void MainWindow :: raiseProgressWidget() |
506 | { | 515 | { |
507 | stack->raiseWidget( progressWindow ); | 516 | stack->raiseWidget( progressWindow ); |
508 | } | 517 | } |
509 | 518 | ||
510 | void MainWindow :: enableUpgrade( bool enabled ) | 519 | void MainWindow :: enableUpgrade( bool enabled ) |
511 | { | 520 | { |
512 | actionUpgrade->setEnabled( enabled ); | 521 | actionUpgrade->setEnabled( enabled ); |
513 | } | 522 | } |
514 | 523 | ||
515 | void MainWindow :: enableDownload( bool enabled ) | 524 | void MainWindow :: enableDownload( bool enabled ) |
516 | { | 525 | { |
517 | if ( enabled ) | 526 | if ( enabled ) |
518 | { | 527 | { |
519 | actionDownload->setIconSet( iconDownload ); | 528 | actionDownload->setIconSet( iconDownload ); |
520 | actionDownload->setText( tr( "Download" ) ); | 529 | actionDownload->setText( tr( "Download" ) ); |
521 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); | 530 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); |
522 | } | 531 | } |
523 | else | 532 | else |
524 | { | 533 | { |
525 | actionDownload->setIconSet( iconRemove ); | 534 | actionDownload->setIconSet( iconRemove ); |
526 | actionDownload->setText( tr( "Remove" ) ); | 535 | actionDownload->setText( tr( "Remove" ) ); |
527 | actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); | 536 | actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); |
528 | } | 537 | } |
529 | } | 538 | } |
530 | 539 | ||
531 | void MainWindow :: setProgressSteps( int numsteps ) | 540 | void MainWindow :: setProgressSteps( int numsteps ) |
532 | { | 541 | { |
533 | m_progress->setTotalSteps( numsteps ); | 542 | m_progress->setTotalSteps( numsteps ); |
534 | } | 543 | } |
535 | 544 | ||
536 | void MainWindow :: setProgressMessage( const QString &msg ) | 545 | void MainWindow :: setProgressMessage( const QString &msg ) |
537 | { | 546 | { |
538 | m_status->setText( msg ); | 547 | m_status->setText( msg ); |
539 | } | 548 | } |
540 | 549 | ||
541 | void MainWindow :: updateProgress( int progress ) | 550 | void MainWindow :: updateProgress( int progress ) |
542 | { | 551 | { |
543 | m_progress->setProgress( progress ); | 552 | m_progress->setProgress( progress ); |
544 | } | 553 | } |
545 | 554 | ||
546 | void MainWindow :: updateData() | 555 | void MainWindow :: updateData() |
547 | { | 556 | { |
548 | m_progress->setTotalSteps( mgr->getServerList().count() ); | 557 | m_progress->setTotalSteps( mgr->getServerList().count() ); |
549 | 558 | ||
550 | serversList->clear(); | 559 | serversList->clear(); |
551 | packagesList->clear(); | 560 | packagesList->clear(); |
552 | 561 | ||
553 | int activeItem = -1; | 562 | int activeItem = -1; |
554 | int i = 0; | 563 | int i = 0; |
555 | QString serverName; | 564 | QString serverName; |
556 | 565 | ||
557 | QListIterator<Server> it( mgr->getServerList() ); | 566 | QListIterator<Server> it( mgr->getServerList() ); |
558 | Server *server; | 567 | Server *server; |
559 | 568 | ||
560 | for ( ; it.current(); ++it, ++i ) | 569 | for ( ; it.current(); ++it, ++i ) |
561 | { | 570 | { |
562 | server = it.current(); | 571 | server = it.current(); |
563 | serverName = server->getServerName(); | 572 | serverName = server->getServerName(); |
564 | m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); | 573 | m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); |
565 | m_progress->setProgress( i ); | 574 | m_progress->setProgress( i ); |
566 | qApp->processEvents(); | 575 | qApp->processEvents(); |
567 | 576 | ||
568 | if ( !server->isServerActive() ) | 577 | if ( !server->isServerActive() ) |
569 | { | 578 | { |
570 | i--; | 579 | i--; |
571 | continue; | 580 | continue; |
572 | } | 581 | } |
573 | 582 | ||
574 | serversList->insertItem( serverName ); | 583 | serversList->insertItem( serverName ); |
575 | if ( serverName == currentlySelectedServer ) | 584 | if ( serverName == currentlySelectedServer ) |
576 | activeItem = i; | 585 | activeItem = i; |
577 | } | 586 | } |
578 | 587 | ||
579 | // set selected server to be active server | 588 | // set selected server to be active server |
580 | if ( activeItem != -1 ) | 589 | if ( activeItem != -1 ) |
581 | serversList->setCurrentItem( activeItem ); | 590 | serversList->setCurrentItem( activeItem ); |
582 | serverSelected( 0, FALSE ); | 591 | serverSelected( 0, FALSE ); |
583 | } | 592 | } |
584 | 593 | ||
585 | void MainWindow :: serverSelected( int index ) | 594 | void MainWindow :: serverSelected( int index ) |
586 | { | 595 | { |
587 | serverSelected( index, TRUE ); | 596 | serverSelected( index, TRUE ); |
588 | } | 597 | } |
589 | 598 | ||
590 | void MainWindow :: serverSelected( int, bool raiseProgress ) | 599 | void MainWindow :: serverSelected( int, bool raiseProgress ) |
591 | { | 600 | { |
592 | QPixmap nullIcon( installedIcon.size() ); | 601 | QPixmap nullIcon( installedIcon.size() ); |
593 | nullIcon.fill( colorGroup().base() ); | 602 | nullIcon.fill( colorGroup().base() ); |
594 | 603 | ||
595 | // display packages | 604 | // display packages |
596 | QString serverName = serversList->currentText(); | 605 | QString serverName = serversList->currentText(); |
597 | currentlySelectedServer = serverName; | 606 | currentlySelectedServer = serverName; |
598 | 607 | ||
599 | Server *s = mgr->getServer( serverName ); | 608 | Server *s = mgr->getServer( serverName ); |
600 | 609 | ||
601 | QList<Package> &list = s->getPackageList(); | 610 | QList<Package> &list = s->getPackageList(); |
602 | QListIterator<Package> it( list ); | 611 | QListIterator<Package> it( list ); |
603 | 612 | ||
604 | // Display progress widget while loading list | 613 | // Display progress widget while loading list |
605 | bool doProgress = ( list.count() > 200 ); | 614 | bool doProgress = ( list.count() > 200 ); |
606 | if ( doProgress ) | 615 | if ( doProgress ) |
607 | { | 616 | { |
608 | if ( raiseProgress ) | 617 | if ( raiseProgress ) |
609 | { | 618 | { |
610 | stack->raiseWidget( progressWindow ); | 619 | stack->raiseWidget( progressWindow ); |
611 | } | 620 | } |
612 | m_progress->setTotalSteps( list.count() ); | 621 | m_progress->setTotalSteps( list.count() ); |
613 | m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); | 622 | m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); |
614 | } | 623 | } |
615 | 624 | ||
616 | packagesList->clear(); | 625 | packagesList->clear(); |
617 | 626 | ||
618 | #ifdef QWS | 627 | #ifdef QWS |
619 | // read download directory from config file | 628 | // read download directory from config file |
620 | Config cfg( "aqpkg" ); | 629 | Config cfg( "aqpkg" ); |
621 | cfg.setGroup( "settings" ); | 630 | cfg.setGroup( "settings" ); |
622 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); | 631 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); |
623 | #endif | 632 | #endif |
624 | 633 | ||
625 | int i = 0; | 634 | int i = 0; |
626 | Package *package; | 635 | Package *package; |
627 | for ( ; it.current(); ++it ) | 636 | for ( ; it.current(); ++it ) |
628 | { | 637 | { |
629 | // Update progress after every 100th package (arbitrary value, seems to give good balance) | 638 | // Update progress after every 100th package (arbitrary value, seems to give good balance) |
630 | i++; | 639 | i++; |
631 | if ( ( i % 100 ) == 0 ) | 640 | if ( ( i % 100 ) == 0 ) |
632 | { | 641 | { |
633 | if ( doProgress ) | 642 | if ( doProgress ) |
634 | { | 643 | { |
635 | m_progress->setProgress( i ); | 644 | m_progress->setProgress( i ); |
636 | } | 645 | } |
637 | qApp->processEvents(); | 646 | qApp->processEvents(); |
638 | } | 647 | } |
639 | 648 | ||
640 | QString text = ""; | 649 | QString text = ""; |
641 | 650 | ||
642 | package = it.current(); | 651 | package = it.current(); |
643 | 652 | ||
644 | // Apply show only uninstalled packages filter | 653 | // Apply show only uninstalled packages filter |
645 | if ( showUninstalledPkgs && package->isInstalled() ) | 654 | if ( showUninstalledPkgs && package->isInstalled() ) |
646 | continue; | 655 | continue; |
647 | 656 | ||
648 | // Apply show only installed packages filter | 657 | // Apply show only installed packages filter |
649 | if ( showInstalledPkgs && !package->isInstalled() ) | 658 | if ( showInstalledPkgs && !package->isInstalled() ) |
650 | continue; | 659 | continue; |
651 | 660 | ||
652 | // Apply show only new installed packages filter | 661 | // Apply show only new installed packages filter |
653 | if ( showUpgradedPkgs ) | 662 | if ( showUpgradedPkgs ) |
654 | { | 663 | { |
655 | if ( !package->isInstalled() || !package->getNewVersionAvailable() ) | 664 | if ( !package->isInstalled() || !package->getNewVersionAvailable() ) |
656 | continue; | 665 | continue; |
657 | } | 666 | } |
658 | 667 | ||
659 | // Apply the section filter | 668 | // Apply the section filter |
660 | if ( categoryFilterEnabled && categoryFilter != "" ) | 669 | if ( categoryFilterEnabled && categoryFilter != "" ) |
661 | { | 670 | { |
662 | if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 ) | 671 | if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 ) |
663 | continue; | 672 | continue; |
664 | } | 673 | } |
665 | 674 | ||
666 | // If the local server, only display installed packages | 675 | // If the local server, only display installed packages |
667 | if ( serverName == LOCAL_SERVER && !package->isInstalled() ) | 676 | if ( serverName == LOCAL_SERVER && !package->isInstalled() ) |
668 | continue; | 677 | continue; |
669 | 678 | ||
670 | 679 | ||
671 | QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), | 680 | QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), |
672 | QCheckListItem::CheckBox ); | 681 | QCheckListItem::CheckBox ); |
673 | 682 | ||
674 | if ( package->isInstalled() ) | 683 | if ( package->isInstalled() ) |
675 | { | 684 | { |
676 | // If a different version of package is available, show update available icon | 685 | // If a different version of package is available, show update available icon |
677 | // Otherwise, show installed icon | 686 | // Otherwise, show installed icon |
678 | if ( package->getNewVersionAvailable()) | 687 | if ( package->getNewVersionAvailable()) |
679 | { | 688 | { |
680 | 689 | ||
681 | item->setPixmap( 0, updatedIcon ); | 690 | item->setPixmap( 0, updatedIcon ); |
682 | } | 691 | } |
683 | else | 692 | else |
684 | { | 693 | { |
685 | item->setPixmap( 0, installedIcon ); | 694 | item->setPixmap( 0, installedIcon ); |
686 | } | 695 | } |
687 | } | 696 | } |
688 | else | 697 | else |
689 | { | 698 | { |
690 | item->setPixmap( 0, nullIcon ); | 699 | item->setPixmap( 0, nullIcon ); |
691 | } | 700 | } |
692 | 701 | ||
693 | packagesList->insertItem( item ); | 702 | packagesList->insertItem( item ); |
694 | } | 703 | } |
695 | 704 | ||
696 | // If the local server or the local ipkgs server disable the download button | 705 | // If the local server or the local ipkgs server disable the download button |
697 | if ( serverName == LOCAL_SERVER ) | 706 | if ( serverName == LOCAL_SERVER ) |
698 | { | 707 | { |
699 | downloadEnabled = TRUE; | 708 | downloadEnabled = TRUE; |
700 | actionUpgrade->setEnabled( FALSE ); | 709 | actionUpgrade->setEnabled( FALSE ); |
701 | } | 710 | } |
702 | else if ( serverName == LOCAL_IPKGS ) | 711 | else if ( serverName == LOCAL_IPKGS ) |
703 | { | 712 | { |
704 | downloadEnabled = FALSE; | 713 | downloadEnabled = FALSE; |
705 | actionUpgrade->setEnabled( FALSE ); | 714 | actionUpgrade->setEnabled( FALSE ); |
706 | } | 715 | } |
707 | else | 716 | else |
708 | { | 717 | { |
709 | downloadEnabled = TRUE; | 718 | downloadEnabled = TRUE; |
710 | actionUpgrade->setEnabled( TRUE ); | 719 | actionUpgrade->setEnabled( TRUE ); |
711 | } | 720 | } |
712 | enableDownload( downloadEnabled ); | 721 | enableDownload( downloadEnabled ); |
713 | 722 | ||
714 | // Display this widget once everything is done | 723 | // Display this widget once everything is done |
715 | if ( doProgress && raiseProgress ) | 724 | if ( doProgress && raiseProgress ) |
716 | { | 725 | { |
717 | stack->raiseWidget( networkPkgWindow ); | 726 | stack->raiseWidget( networkPkgWindow ); |
718 | } | 727 | } |
719 | } | 728 | } |
720 | 729 | ||
721 | void MainWindow :: searchForPackage( const QString &text ) | 730 | void MainWindow :: searchForPackage( const QString &text ) |
722 | { | 731 | { |
723 | if ( !text.isEmpty() ) | 732 | if ( !text.isEmpty() ) |
724 | { | 733 | { |
725 | // look through package list for text startng at current position | 734 | // look through package list for text startng at current position |
726 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 735 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
727 | 736 | ||
728 | if ( start == 0 ) | 737 | if ( start == 0 ) |
729 | start = (QCheckListItem *)packagesList->firstChild(); | 738 | start = (QCheckListItem *)packagesList->firstChild(); |
730 | 739 | ||
731 | for ( QCheckListItem *item = start; item != 0 ; | 740 | for ( QCheckListItem *item = start; item != 0 ; |
732 | item = (QCheckListItem *)item->nextSibling() ) | 741 | item = (QCheckListItem *)item->nextSibling() ) |
733 | { | 742 | { |
734 | if ( item->text().lower().find( text ) != -1 ) | 743 | if ( item->text().lower().find( text ) != -1 ) |
735 | { | 744 | { |
736 | packagesList->ensureItemVisible( item ); | 745 | packagesList->ensureItemVisible( item ); |
737 | packagesList->setCurrentItem( item ); | 746 | packagesList->setCurrentItem( item ); |
738 | break; | 747 | break; |
739 | } | 748 | } |
740 | } | 749 | } |
741 | } | 750 | } |
742 | } | 751 | } |
743 | 752 | ||
744 | void MainWindow :: updateServer() | 753 | void MainWindow :: updateServer() |
745 | { | 754 | { |
746 | QString serverName = serversList->currentText(); | 755 | QString serverName = serversList->currentText(); |
747 | 756 | ||
748 | // Update the current server | 757 | // Update the current server |
749 | // Display dialog | 758 | // Display dialog |
750 | 759 | ||
751 | // Disable buttons to stop silly people clicking lots on them :) | 760 | // Disable buttons to stop silly people clicking lots on them :) |
752 | 761 | ||
753 | // First, write out ipkg_conf file so that ipkg can use it | 762 | // First, write out ipkg_conf file so that ipkg can use it |
754 | mgr->writeOutIpkgConf(); | 763 | mgr->writeOutIpkgConf(); |
755 | 764 | ||
756 | Ipkg *ipkg = new Ipkg; | 765 | Ipkg *ipkg = new Ipkg; |
757 | ipkg->setOption( "update" ); | 766 | ipkg->setOption( "update" ); |
758 | 767 | ||
759 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), | 768 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), |
760 | tr( "Update lists" ) ); | 769 | tr( "Update lists" ) ); |
761 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 770 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); |
762 | reloadDocuments = FALSE; | 771 | reloadDocuments = FALSE; |
763 | stack->addWidget( dlg, 3 ); | 772 | stack->addWidget( dlg, 3 ); |
764 | stack->raiseWidget( dlg ); | 773 | stack->raiseWidget( dlg ); |
765 | 774 | ||
766 | // delete progDlg; | 775 | // delete progDlg; |
767 | } | 776 | } |
768 | 777 | ||
769 | void MainWindow :: upgradePackages() | 778 | void MainWindow :: upgradePackages() |
770 | { | 779 | { |
771 | // We're gonna do an upgrade of all packages | 780 | // We're gonna do an upgrade of all packages |
772 | // First warn user that this isn't recommended | 781 | // First warn user that this isn't recommended |
773 | // TODO - ODevice???? | 782 | // TODO - ODevice???? |
774 | QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); | 783 | QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); |
775 | QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, | 784 | QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, |
776 | QMessageBox::Yes, | 785 | QMessageBox::Yes, |
777 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , | 786 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , |
778 | 0, this ); | 787 | 0, this ); |
779 | warn.adjustSize(); | 788 | warn.adjustSize(); |
780 | 789 | ||
781 | if ( warn.exec() == QMessageBox::Yes ) | 790 | if ( warn.exec() == QMessageBox::Yes ) |
782 | { | 791 | { |
783 | // First, write out ipkg_conf file so that ipkg can use it | 792 | // First, write out ipkg_conf file so that ipkg can use it |
784 | mgr->writeOutIpkgConf(); | 793 | mgr->writeOutIpkgConf(); |
785 | 794 | ||
786 | // Now run upgrade | 795 | // Now run upgrade |
787 | Ipkg *ipkg = new Ipkg; | 796 | Ipkg *ipkg = new Ipkg; |
788 | ipkg->setOption( "upgrade" ); | 797 | ipkg->setOption( "upgrade" ); |
789 | 798 | ||
790 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), | 799 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), |
791 | tr ( "Upgrade" ) ); | 800 | tr ( "Upgrade" ) ); |
792 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 801 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); |
793 | reloadDocuments = TRUE; | 802 | reloadDocuments = TRUE; |
794 | stack->addWidget( dlg, 3 ); | 803 | stack->addWidget( dlg, 3 ); |
795 | stack->raiseWidget( dlg ); | 804 | stack->raiseWidget( dlg ); |
796 | } | 805 | } |
797 | } | 806 | } |
798 | 807 | ||
799 | void MainWindow :: downloadPackage() | 808 | void MainWindow :: downloadPackage() |
800 | { | 809 | { |
801 | bool doUpdate = true; | 810 | bool doUpdate = true; |
802 | if ( downloadEnabled ) | 811 | if ( downloadEnabled ) |
803 | { | 812 | { |
804 | // See if any packages are selected | 813 | // See if any packages are selected |
805 | bool found = false; | 814 | bool found = false; |
806 | if ( serversList->currentText() != LOCAL_SERVER ) | 815 | if ( serversList->currentText() != LOCAL_SERVER ) |
807 | { | 816 | { |
808 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 817 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
809 | item != 0 && !found; | 818 | item != 0 && !found; |
810 | item = (QCheckListItem *)item->nextSibling() ) | 819 | item = (QCheckListItem *)item->nextSibling() ) |
811 | { | 820 | { |
812 | if ( item->isOn() ) | 821 | if ( item->isOn() ) |
813 | found = true; | 822 | found = true; |
814 | } | 823 | } |
815 | } | 824 | } |
816 | 825 | ||
817 | // If user selected some packages then download the and store the locally | 826 | // If user selected some packages then download the and store the locally |
818 | // otherwise, display dialog asking user what package to download from an http server | 827 | // otherwise, display dialog asking user what package to download from an http server |
819 | // and whether to install it | 828 | // and whether to install it |
820 | if ( found ) | 829 | if ( found ) |
821 | downloadSelectedPackages(); | 830 | downloadSelectedPackages(); |
822 | else | 831 | else |
823 | downloadRemotePackage(); | 832 | downloadRemotePackage(); |
824 | 833 | ||
825 | } | 834 | } |
826 | else | 835 | else |
827 | { | 836 | { |
828 | doUpdate = false; | 837 | doUpdate = false; |
829 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 838 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
830 | item != 0 ; | 839 | item != 0 ; |
831 | item = (QCheckListItem *)item->nextSibling() ) | 840 | item = (QCheckListItem *)item->nextSibling() ) |
832 | { | 841 | { |
833 | if ( item->isOn() ) | 842 | if ( item->isOn() ) |
834 | { | 843 | { |
835 | QString name = item->text(); | 844 | QString name = item->text(); |
836 | int pos = name.find( "*" ); | 845 | int pos = name.find( "*" ); |
837 | name.truncate( pos ); | 846 | name.truncate( pos ); |
838 | 847 | ||
839 | // if (there is a (installed), remove it | 848 | // if (there is a (installed), remove it |
840 | pos = name.find( "(installed)" ); | 849 | pos = name.find( "(installed)" ); |
841 | if ( pos > 0 ) | 850 | if ( pos > 0 ) |
842 | name.truncate( pos - 1 ); | 851 | name.truncate( pos - 1 ); |
843 | 852 | ||
844 | Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); | 853 | Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); |
845 | 854 | ||
846 | QString msgtext; | 855 | QString msgtext; |
847 | msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); | 856 | msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); |
848 | if ( QMessageBox::information( this, tr( "Are you sure?" ), | 857 | if ( QMessageBox::information( this, tr( "Are you sure?" ), |
849 | msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) | 858 | msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) |
850 | { | 859 | { |
851 | doUpdate = true; | 860 | doUpdate = true; |
852 | QFile f( p->getFilename() ); | 861 | QFile f( p->getFilename() ); |
853 | f.remove(); | 862 | f.remove(); |
854 | } | 863 | } |
855 | } | 864 | } |
856 | } | 865 | } |
857 | } | 866 | } |
858 | 867 | ||
859 | if ( doUpdate ) | 868 | if ( doUpdate ) |
860 | { | 869 | { |
861 | reloadData( 0x0 ); | 870 | reloadData( 0x0 ); |
862 | } | 871 | } |
863 | } | 872 | } |
864 | 873 | ||
865 | void MainWindow :: downloadSelectedPackages() | 874 | void MainWindow :: downloadSelectedPackages() |
866 | { | 875 | { |
867 | // First, write out ipkg_conf file so that ipkg can use it | 876 | // First, write out ipkg_conf file so that ipkg can use it |
868 | mgr->writeOutIpkgConf(); | 877 | mgr->writeOutIpkgConf(); |
869 | 878 | ||
870 | // Display dialog to user asking where to download the files to | 879 | // Display dialog to user asking where to download the files to |
871 | bool ok = FALSE; | 880 | bool ok = FALSE; |
872 | QString dir = ""; | 881 | QString dir = ""; |
873 | #ifdef QWS | 882 | #ifdef QWS |
874 | // read download directory from config file | 883 | // read download directory from config file |
875 | Config cfg( "aqpkg" ); | 884 | Config cfg( "aqpkg" ); |
876 | cfg.setGroup( "settings" ); | 885 | cfg.setGroup( "settings" ); |
877 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); | 886 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); |
878 | #endif | 887 | #endif |
879 | 888 | ||
880 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); | 889 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); |
881 | if ( ok && !text.isEmpty() ) | 890 | if ( ok && !text.isEmpty() ) |
882 | dir = text; // user entered something and pressed ok | 891 | dir = text; // user entered something and pressed ok |
883 | else | 892 | else |
884 | return; // user entered nothing or pressed cancel | 893 | return; // user entered nothing or pressed cancel |
885 | 894 | ||
886 | #ifdef QWS | 895 | #ifdef QWS |
887 | // Store download directory in config file | 896 | // Store download directory in config file |
888 | cfg.writeEntry( "downloadDir", dir ); | 897 | cfg.writeEntry( "downloadDir", dir ); |
889 | #endif | 898 | #endif |
890 | 899 | ||
891 | // Get starting directory | 900 | // Get starting directory |
892 | char initDir[PATH_MAX]; | 901 | char initDir[PATH_MAX]; |
893 | getcwd( initDir, PATH_MAX ); | 902 | getcwd( initDir, PATH_MAX ); |
894 | 903 | ||
895 | // Download each package | 904 | // Download each package |
896 | Ipkg ipkg; | 905 | Ipkg ipkg; |
897 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 906 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
898 | 907 | ||
899 | ipkg.setOption( "download" ); | 908 | ipkg.setOption( "download" ); |
900 | ipkg.setRuntimeDirectory( dir ); | 909 | ipkg.setRuntimeDirectory( dir ); |
901 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 910 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
902 | item != 0 ; | 911 | item != 0 ; |
903 | item = (QCheckListItem *)item->nextSibling() ) | 912 | item = (QCheckListItem *)item->nextSibling() ) |
904 | { | 913 | { |
905 | if ( item->isOn() ) | 914 | if ( item->isOn() ) |
906 | { | 915 | { |
907 | ipkg.setPackage( item->text() ); | 916 | ipkg.setPackage( item->text() ); |
908 | ipkg.runIpkg( ); | 917 | ipkg.runIpkg( ); |
909 | } | 918 | } |
910 | } | 919 | } |
911 | } | 920 | } |
912 | 921 | ||
913 | void MainWindow :: downloadRemotePackage() | 922 | void MainWindow :: downloadRemotePackage() |
914 | { | 923 | { |
915 | // Display dialog | 924 | // Display dialog |
916 | bool ok; | 925 | bool ok; |
917 | QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); | 926 | QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); |
918 | if ( !ok || package.isEmpty() ) | 927 | if ( !ok || package.isEmpty() ) |
919 | return; | 928 | return; |
920 | // DownloadRemoteDlgImpl dlg( this, "Install", true ); | 929 | // DownloadRemoteDlgImpl dlg( this, "Install", true ); |
921 | // if ( dlg.exec() == QDialog::Rejected ) | 930 | // if ( dlg.exec() == QDialog::Rejected ) |
922 | // return; | 931 | // return; |
923 | 932 | ||
924 | // grab details from dialog | 933 | // grab details from dialog |
925 | // QString package = dlg.getPackageLocation(); | 934 | // QString package = dlg.getPackageLocation(); |
926 | 935 | ||
927 | InstallData *item = new InstallData(); | 936 | InstallData *item = new InstallData(); |
928 | item->option = "I"; | 937 | item->option = "I"; |
929 | item->packageName = package; | 938 | item->packageName = package; |
930 | QList<InstallData> workingPackages; | 939 | QList<InstallData> workingPackages; |
931 | workingPackages.setAutoDelete( TRUE ); | 940 | workingPackages.setAutoDelete( TRUE ); |
932 | workingPackages.append( item ); | 941 | workingPackages.append( item ); |
933 | 942 | ||
934 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); | 943 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); |
935 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 944 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); |
936 | reloadDocuments = TRUE; | 945 | reloadDocuments = TRUE; |
937 | stack->addWidget( dlg, 3 ); | 946 | stack->addWidget( dlg, 3 ); |
938 | stack->raiseWidget( dlg ); | 947 | stack->raiseWidget( dlg ); |
939 | } | 948 | } |
940 | 949 | ||
941 | 950 | ||
942 | void MainWindow :: applyChanges() | 951 | void MainWindow :: applyChanges() |
943 | { | 952 | { |
944 | stickyOption = ""; | 953 | stickyOption = ""; |
945 | 954 | ||
946 | // First, write out ipkg_conf file so that ipkg can use it | 955 | // First, write out ipkg_conf file so that ipkg can use it |
947 | mgr->writeOutIpkgConf(); | 956 | mgr->writeOutIpkgConf(); |
948 | 957 | ||
949 | // Now for each selected item | 958 | // Now for each selected item |
950 | // deal with it | 959 | // deal with it |
951 | 960 | ||
952 | QList<InstallData> workingPackages; | 961 | QList<InstallData> workingPackages; |
953 | workingPackages.setAutoDelete( TRUE ); | 962 | workingPackages.setAutoDelete( TRUE ); |
954 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 963 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
955 | item != 0 ; | 964 | item != 0 ; |
956 | item = (QCheckListItem *)item->nextSibling() ) | 965 | item = (QCheckListItem *)item->nextSibling() ) |
957 | { | 966 | { |
958 | if ( item->isOn() ) | 967 | if ( item->isOn() ) |
959 | { | 968 | { |
960 | InstallData *instdata = dealWithItem( item ); | 969 | InstallData *instdata = dealWithItem( item ); |
961 | if ( instdata ) | 970 | if ( instdata ) |
962 | workingPackages.append( instdata ); | 971 | workingPackages.append( instdata ); |
963 | else | 972 | else |
964 | return; | 973 | return; |
965 | } | 974 | } |
966 | } | 975 | } |
967 | 976 | ||
968 | if ( workingPackages.count() == 0 ) | 977 | if ( workingPackages.count() == 0 ) |
969 | { | 978 | { |
970 | // Nothing to do | 979 | // Nothing to do |
971 | QMessageBox::information( this, tr( "Nothing to do" ), | 980 | QMessageBox::information( this, tr( "Nothing to do" ), |
972 | tr( "No packages selected" ), tr( "OK" ) ); | 981 | tr( "No packages selected" ), tr( "OK" ) ); |
973 | 982 | ||
974 | return; | 983 | return; |
975 | } | 984 | } |
976 | 985 | ||
977 | // do the stuff | 986 | // do the stuff |
978 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); | 987 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); |
979 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 988 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); |
980 | reloadDocuments = TRUE; | 989 | reloadDocuments = TRUE; |
981 | stack->addWidget( dlg, 3 ); | 990 | stack->addWidget( dlg, 3 ); |
982 | stack->raiseWidget( dlg ); | 991 | stack->raiseWidget( dlg ); |
983 | } | 992 | } |
984 | 993 | ||
985 | // decide what to do - either remove, upgrade or install | 994 | // decide what to do - either remove, upgrade or install |
986 | // Current rules: | 995 | // Current rules: |
987 | // If not installed - install | 996 | // If not installed - install |
988 | // If installed and different version available - upgrade | 997 | // If installed and different version available - upgrade |
989 | // If installed and version up to date - remove | 998 | // If installed and version up to date - remove |
990 | InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) | 999 | InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) |
991 | { | 1000 | { |
992 | QString name = item->text(); | 1001 | QString name = item->text(); |
993 | 1002 | ||
994 | // Get package | 1003 | // Get package |
995 | Server *s = mgr->getServer( serversList->currentText() ); | 1004 | Server *s = mgr->getServer( serversList->currentText() ); |
996 | Package *p = s->getPackage( name ); | 1005 | Package *p = s->getPackage( name ); |
997 | 1006 | ||
998 | // If the package has a filename then it is a local file | 1007 | // If the package has a filename then it is a local file |
999 | if ( p->isPackageStoredLocally() ) | 1008 | if ( p->isPackageStoredLocally() ) |
1000 | name = p->getFilename(); | 1009 | name = p->getFilename(); |
1001 | 1010 | ||
1002 | QString option; | 1011 | QString option; |
1003 | QString dest = "root"; | 1012 | QString dest = "root"; |
1004 | if ( !p->isInstalled() ) | 1013 | if ( !p->isInstalled() ) |
1005 | { | 1014 | { |
1006 | InstallData *newitem = new InstallData(); | 1015 | InstallData *newitem = new InstallData(); |
1007 | newitem->option = "I"; | 1016 | newitem->option = "I"; |
1008 | newitem->packageName = name; | 1017 | newitem->packageName = name; |
1009 | return newitem; | 1018 | return newitem; |
1010 | } | 1019 | } |
1011 | else | 1020 | else |
1012 | { | 1021 | { |
1013 | InstallData *newitem = new InstallData(); | 1022 | InstallData *newitem = new InstallData(); |
1014 | newitem->option = "D"; | 1023 | newitem->option = "D"; |
1015 | |||
1016 | // If local file, remove using package name, not filename | 1024 | // If local file, remove using package name, not filename |
1017 | if ( p->isPackageStoredLocally() ) | 1025 | if ( p->isPackageStoredLocally() ) |
1018 | name = item->text(); | 1026 | name = item->text(); |
1019 | 1027 | ||
1020 | if ( !p->isPackageStoredLocally() ) | 1028 | if ( !p->isPackageStoredLocally() ) |
1021 | newitem->packageName = p->getInstalledPackageName(); | 1029 | newitem->packageName = p->getInstalledPackageName(); |
1022 | else | 1030 | else |
1023 | newitem->packageName = name; | 1031 | newitem->packageName = name; |
1024 | 1032 | ||
1025 | if ( p->getInstalledTo() ) | 1033 | if ( p->getInstalledTo() ) |
1026 | { | 1034 | { |
1027 | newitem->destination = p->getInstalledTo(); | 1035 | newitem->destination = p->getInstalledTo(); |
1028 | } | 1036 | } |
1029 | else | 1037 | else |
1030 | { | 1038 | { |
1031 | newitem->destination = p->getLocalPackage()->getInstalledTo(); | 1039 | newitem->destination = p->getLocalPackage()->getInstalledTo(); |
1032 | } | 1040 | } |
1033 | 1041 | ||
1034 | // Now see if version is newer or not | 1042 | // Now see if version is newer or not |
1035 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); | 1043 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); |
1036 | 1044 | ||
1037 | // If the version requested is older and user selected a local ipk file, then reinstall the file | 1045 | // If the version requested is older and user selected a local ipk file, then reinstall the file |
1038 | if ( p->isPackageStoredLocally() && val == -1 ) | 1046 | if ( p->isPackageStoredLocally() && val == -1 ) |
1039 | val = 0; | 1047 | val = 0; |
1040 | 1048 | ||
1041 | if ( val == -2 ) | 1049 | if ( val == -2 ) |
1042 | { | 1050 | { |
1043 | // Error - should handle | 1051 | // Error - should handle |
1044 | } | 1052 | } |
1045 | else if ( val == -1 ) | 1053 | else if ( val == -1 ) |
1046 | { | 1054 | { |
1047 | // Version available is older - remove only | 1055 | // Version available is older - remove only |
1048 | newitem->option = "D"; | 1056 | newitem->option = "D"; |
1049 | |||
1050 | // If local file, remove using package name, not filename | 1057 | // If local file, remove using package name, not filename |
1051 | if ( p->isPackageStoredLocally() ) | 1058 | if ( p->isPackageStoredLocally() ) |
1052 | name = item->text(); | 1059 | name = item->text(); |
1053 | } | 1060 | } |
1054 | else | 1061 | else |
1055 | { | 1062 | { |
1056 | QString caption; | 1063 | QString caption; |
1057 | QString text; | 1064 | QString text; |
1058 | QString secondButton; | 1065 | QString secondButton; |
1059 | QString secondOption; | 1066 | QString secondOption; |
1060 | if ( val == 0 ) | 1067 | if ( val == 0 ) |
1061 | { | 1068 | { |
1062 | // Version available is the same - option to remove or reinstall | 1069 | // Version available is the same - option to remove or reinstall |
1063 | caption = tr( "Do you wish to remove or reinstall\n%1?" ); | 1070 | caption = tr( "Do you wish to remove or reinstall\n%1?" ); |
1064 | text = tr( "Remove or ReInstall" ); | 1071 | text = tr( "Remove or ReInstall" ); |
1065 | secondButton = tr( "ReInstall" ); | 1072 | secondButton = tr( "ReInstall" ); |
1066 | secondOption = "R"; // Internal action code, do not translate | 1073 | secondOption = "R"; // Internal action code, do not translate |
1067 | } | 1074 | } |
1068 | else if ( val == 1 ) | 1075 | else if ( val == 1 ) |
1069 | { | 1076 | { |
1070 | // Version available is newer - option to remove or upgrade | 1077 | // Version available is newer - option to remove or upgrade |
1071 | caption = tr( "Do you wish to remove or upgrade\n%1?" ); | 1078 | caption = tr( "Do you wish to remove or upgrade\n%1?" ); |
1072 | text = tr( "Remove or Upgrade" ); | 1079 | text = tr( "Remove or Upgrade" ); |
1073 | secondButton = tr( "Upgrade" ); | 1080 | secondButton = tr( "Upgrade" ); |
1074 | secondOption = "U"; // Internal action code, do not translate | 1081 | secondOption = "U"; // Internal action code, do not translate |
1075 | } | 1082 | } |
1076 | 1083 | ||
1077 | // Sticky option not implemented yet, but will eventually allow | 1084 | // Sticky option not implemented yet, but will eventually allow |
1078 | // the user to say something like 'remove all' | 1085 | // the user to say something like 'remove all' |
1079 | if ( stickyOption == "" ) | 1086 | if ( stickyOption == "" ) |
1080 | { | 1087 | { |
1081 | QString msgtext; | 1088 | QString msgtext; |
1082 | msgtext = caption.arg( ( const char * )name ); | 1089 | msgtext = caption.arg( ( const char * )name ); |
1083 | QuestionDlg dlg( text, msgtext, secondButton ); | 1090 | QuestionDlg dlg( text, msgtext, secondButton ); |
1084 | switch( dlg.exec() ) | 1091 | switch( dlg.exec() ) |
1085 | { | 1092 | { |
1086 | case 0: // Cancel | 1093 | case 0: // Cancel |
1087 | delete newitem; | 1094 | delete newitem; |
1088 | return 0x0; | 1095 | return 0x0; |
1089 | break; | 1096 | break; |
1090 | case 1: // Remove | 1097 | case 1: // Remove |
1091 | newitem->option = "D"; | 1098 | newitem->option = "D"; |
1092 | // If local file, remove using package name, not filename | 1099 | // If local file, remove using package name, not filename |
1093 | if ( p->isPackageStoredLocally() ) | 1100 | if ( p->isPackageStoredLocally() ) |
1094 | name = item->text(); | 1101 | name = item->text(); |
1095 | break; | 1102 | break; |
1096 | case 2: // Reinstall or Upgrade | 1103 | case 2: // Reinstall or Upgrade |
1097 | newitem->option = secondOption; | 1104 | newitem->option = secondOption; |
1098 | break; | 1105 | break; |
1099 | } | 1106 | } |
1100 | } | 1107 | } |
1101 | else | 1108 | else |
1102 | { | 1109 | { |
1103 | // newitem->option = stickyOption; | 1110 | // newitem->option = stickyOption; |
1104 | } | 1111 | } |
1105 | } | 1112 | } |
1106 | 1113 | ||
1107 | 1114 | ||
1108 | // Check if we are reinstalling the same version | 1115 | // Check if we are reinstalling the same version |
1109 | if ( newitem->option != "R" ) | 1116 | if ( newitem->option != "R" ) |
1110 | newitem->recreateLinks = true; | 1117 | newitem->recreateLinks = true; |
1111 | else | 1118 | else |
1112 | newitem->recreateLinks = false; | 1119 | newitem->recreateLinks = false; |
1113 | 1120 | ||
1114 | // User hit cancel (on dlg - assume remove) | 1121 | // User hit cancel (on dlg - assume remove) |
1115 | return newitem; | 1122 | return newitem; |
1116 | } | 1123 | } |
1117 | } | 1124 | } |
1118 | 1125 | ||
1119 | void MainWindow :: reloadData( InstallDlgImpl *dlg ) | 1126 | void MainWindow :: reloadData( InstallDlgImpl *dlg ) |
1120 | { | 1127 | { |
1121 | stack->raiseWidget( progressWindow ); | 1128 | stack->raiseWidget( progressWindow ); |
1122 | 1129 | ||
1123 | if ( dlg ) | 1130 | if ( dlg ) |
1124 | { | 1131 | { |
1125 | dlg->close(); | 1132 | dlg->close(); |
1126 | delete dlg; | 1133 | delete dlg; |
1127 | } | 1134 | } |
1128 | 1135 | ||
1129 | mgr->reloadServerData(); | 1136 | mgr->reloadServerData(); |
1130 | serverSelected( -1, FALSE ); | 1137 | serverSelected( -1, FALSE ); |
1131 | 1138 | ||
1132 | #ifdef QWS | 1139 | #ifdef QWS |
1133 | if ( reloadDocuments ) | 1140 | if ( reloadDocuments ) |
1134 | { | 1141 | { |
1135 | m_status->setText( tr( "Updating Launcher..." ) ); | 1142 | m_status->setText( tr( "Updating Launcher..." ) ); |
1136 | 1143 | ||
1137 | // Finally let the main system update itself | 1144 | // Finally let the main system update itself |
1138 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 1145 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
1139 | QString lf = QString::null; | 1146 | QString lf = QString::null; |
1140 | e << lf; | 1147 | e << lf; |
1141 | } | 1148 | } |
1142 | #endif | 1149 | #endif |
1143 | 1150 | ||
1144 | stack->raiseWidget( networkPkgWindow ); | 1151 | stack->raiseWidget( networkPkgWindow ); |
1145 | } | 1152 | } |
1146 | 1153 | ||
1147 | void MainWindow :: letterPushed( QString t ) | 1154 | void MainWindow :: letterPushed( QString t ) |
1148 | { | 1155 | { |
1149 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); | 1156 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); |
1150 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 1157 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
1151 | if ( packagesList->firstChild() == 0 ) | 1158 | if ( packagesList->firstChild() == 0 ) |
1152 | return; | 1159 | return; |
1153 | 1160 | ||
1154 | QCheckListItem *item; | 1161 | QCheckListItem *item; |
1155 | if ( start == 0 ) | 1162 | if ( start == 0 ) |
1156 | { | 1163 | { |
1157 | item = (QCheckListItem *)packagesList->firstChild(); | 1164 | item = (QCheckListItem *)packagesList->firstChild(); |
1158 | start = top; | 1165 | start = top; |
1159 | } | 1166 | } |
1160 | else | 1167 | else |
1161 | item = (QCheckListItem *)start->nextSibling(); | 1168 | item = (QCheckListItem *)start->nextSibling(); |
1162 | 1169 | ||
1163 | if ( item == 0 ) | 1170 | if ( item == 0 ) |
1164 | item = (QCheckListItem *)packagesList->firstChild(); | 1171 | item = (QCheckListItem *)packagesList->firstChild(); |
1165 | do | 1172 | do |
1166 | { | 1173 | { |
1167 | if ( item->text().lower().startsWith( t.lower() ) ) | 1174 | if ( item->text().lower().startsWith( t.lower() ) ) |
1168 | { | 1175 | { |
1169 | packagesList->setSelected( item, true ); | 1176 | packagesList->setSelected( item, true ); |
1170 | packagesList->ensureItemVisible( item ); | 1177 | packagesList->ensureItemVisible( item ); |
1171 | break; | 1178 | break; |
1172 | } | 1179 | } |
1173 | 1180 | ||
1174 | item = (QCheckListItem *)item->nextSibling(); | 1181 | item = (QCheckListItem *)item->nextSibling(); |
1175 | if ( !item ) | 1182 | if ( !item ) |
1176 | item = (QCheckListItem *)packagesList->firstChild(); | 1183 | item = (QCheckListItem *)packagesList->firstChild(); |
1177 | } while ( item != start); | 1184 | } while ( item != start); |
1178 | } | 1185 | } |
1179 | 1186 | ||
1180 | void MainWindow :: slotDisplayPackage( QListViewItem *item ) | 1187 | void MainWindow :: slotDisplayPackage( QListViewItem *item ) |
1181 | { | 1188 | { |
1182 | QString itemstr( ((QCheckListItem*)item)->text() ); | 1189 | QString itemstr( ((QCheckListItem*)item)->text() ); |
1183 | PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) ); | 1190 | PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) ); |
1184 | p->showMaximized(); | 1191 | p->showMaximized(); |
1185 | } | 1192 | } |
1186 | 1193 | ||
1187 | QuestionDlg::QuestionDlg( const QString &caption, const QString &text, const QString &secondbtn ) | 1194 | QuestionDlg::QuestionDlg( const QString &caption, const QString &text, const QString &secondbtn ) |
1188 | : QWidget( 0x0, 0x0, WType_Modal | WType_TopLevel | WStyle_Dialog ) | 1195 | : QWidget( 0x0, 0x0, WType_Modal | WType_TopLevel | WStyle_Dialog ) |
1189 | { | 1196 | { |
1190 | setCaption( caption ); | 1197 | setCaption( caption ); |
1191 | resize( 175, 100 ); | 1198 | resize( 175, 100 ); |
1192 | 1199 | ||
1193 | QGridLayout *layout = new QGridLayout( this ); | 1200 | QGridLayout *layout = new QGridLayout( this ); |
1194 | 1201 | ||
1195 | QLabel *l = new QLabel( text, this ); | 1202 | QLabel *l = new QLabel( text, this ); |
1196 | l->setAlignment( AlignCenter | WordBreak ); | 1203 | l->setAlignment( AlignCenter | WordBreak ); |
1197 | layout->addMultiCellWidget( l, 0, 0, 0, 1 ); | 1204 | layout->addMultiCellWidget( l, 0, 0, 0, 1 ); |
1198 | 1205 | ||
1199 | btn1 = new QPushButton( tr( "Remove" ), this ); | 1206 | btn1 = new QPushButton( tr( "Remove" ), this ); |
1200 | connect( btn1, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); | 1207 | connect( btn1, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); |
1201 | layout->addWidget( btn1, 1, 0 ); | 1208 | layout->addWidget( btn1, 1, 0 ); |
1202 | 1209 | ||
1203 | btn2 = new QPushButton( secondbtn, this ); | 1210 | btn2 = new QPushButton( secondbtn, this ); |
1204 | connect( btn2, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); | 1211 | connect( btn2, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); |
1205 | layout->addWidget( btn2, 1, 1 ); | 1212 | layout->addWidget( btn2, 1, 1 ); |
1206 | 1213 | ||
1207 | executing = FALSE; | 1214 | executing = FALSE; |
1208 | } | 1215 | } |
1209 | 1216 | ||
1210 | int QuestionDlg::exec() | 1217 | int QuestionDlg::exec() |
1211 | { | 1218 | { |
1212 | show(); | 1219 | show(); |
1213 | 1220 | ||
1214 | if ( !executing ) | 1221 | if ( !executing ) |
1215 | { | 1222 | { |
1216 | executing = TRUE; | 1223 | executing = TRUE; |
1217 | qApp->enter_loop(); | 1224 | qApp->enter_loop(); |
1218 | } | 1225 | } |
1219 | 1226 | ||
1220 | return buttonpressed; | 1227 | return buttonpressed; |
1221 | } | 1228 | } |
1222 | 1229 | ||
1223 | void QuestionDlg::slotButtonPressed() | 1230 | void QuestionDlg::slotButtonPressed() |
1224 | { | 1231 | { |
1225 | if ( sender() == btn1 ) | 1232 | if ( sender() == btn1 ) |
1226 | buttonpressed = 1; | 1233 | buttonpressed = 1; |
1227 | else if ( sender() == btn2 ) | 1234 | else if ( sender() == btn2 ) |
1228 | buttonpressed = 2; | 1235 | buttonpressed = 2; |
1229 | else | 1236 | else |
1230 | buttonpressed = 0; | 1237 | buttonpressed = 0; |
1231 | 1238 | ||
1232 | qApp->exit_loop(); | 1239 | qApp->exit_loop(); |
1233 | } | 1240 | } |
diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h index 615ff8b..b8e1c98 100644 --- a/noncore/settings/aqpkg/mainwin.h +++ b/noncore/settings/aqpkg/mainwin.h | |||
@@ -1,175 +1,176 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef MAINWIN_H | 30 | #ifndef MAINWIN_H |
31 | #define MAINWIN_H | 31 | #define MAINWIN_H |
32 | 32 | ||
33 | #include <qmainwindow.h> | 33 | #include <qmainwindow.h> |
34 | #include <qpixmap.h> | 34 | #include <qpixmap.h> |
35 | 35 | ||
36 | class DataManager; | 36 | class DataManager; |
37 | class InstallData; | 37 | class InstallData; |
38 | class InstallDlgImpl; | 38 | class InstallDlgImpl; |
39 | 39 | ||
40 | class QAction; | 40 | class QAction; |
41 | class QCheckListItem; | 41 | class QCheckListItem; |
42 | class QComboBox; | 42 | class QComboBox; |
43 | class QLabel; | 43 | class QLabel; |
44 | class QLineEdit; | 44 | class QLineEdit; |
45 | class QListView; | 45 | class QListView; |
46 | class QListViewItem; | 46 | class QListViewItem; |
47 | class QToolBar; | 47 | class QToolBar; |
48 | class QProgressBar; | 48 | class QProgressBar; |
49 | class QPushButton; | 49 | class QPushButton; |
50 | class QWidgetStack; | 50 | class QWidgetStack; |
51 | 51 | ||
52 | class MainWindow :public QMainWindow | 52 | class MainWindow :public QMainWindow |
53 | { | 53 | { |
54 | Q_OBJECT | 54 | Q_OBJECT |
55 | public: | 55 | public: |
56 | 56 | ||
57 | MainWindow(); | 57 | MainWindow( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
58 | ~MainWindow(); | 58 | ~MainWindow(); |
59 | static QString appName() { return QString::fromLatin1( "aqpkg" ); }; | ||
59 | 60 | ||
60 | protected: | 61 | protected: |
61 | void closeEvent( QCloseEvent* e ); | 62 | void closeEvent( QCloseEvent* e ); |
62 | 63 | ||
63 | private: | 64 | private: |
64 | DataManager *mgr; | 65 | DataManager *mgr; |
65 | 66 | ||
66 | QWidgetStack *stack; | 67 | QWidgetStack *stack; |
67 | 68 | ||
68 | QToolBar *findBar; | 69 | QToolBar *findBar; |
69 | QToolBar *jumpBar; | 70 | QToolBar *jumpBar; |
70 | QLineEdit *findEdit; | 71 | QLineEdit *findEdit; |
71 | QAction *actionFindNext; | 72 | QAction *actionFindNext; |
72 | QAction *actionFilter; | 73 | QAction *actionFilter; |
73 | QAction *actionUpgrade; | 74 | QAction *actionUpgrade; |
74 | QAction *actionDownload; | 75 | QAction *actionDownload; |
75 | QAction *actionUninstalled; | 76 | QAction *actionUninstalled; |
76 | QAction *actionInstalled; | 77 | QAction *actionInstalled; |
77 | QAction *actionUpdated; | 78 | QAction *actionUpdated; |
78 | 79 | ||
79 | QPixmap iconDownload; | 80 | QPixmap iconDownload; |
80 | QPixmap iconRemove; | 81 | QPixmap iconRemove; |
81 | 82 | ||
82 | int mnuShowUninstalledPkgsId; | 83 | int mnuShowUninstalledPkgsId; |
83 | int mnuShowInstalledPkgsId; | 84 | int mnuShowInstalledPkgsId; |
84 | int mnuShowUpgradedPkgsId; | 85 | int mnuShowUpgradedPkgsId; |
85 | int mnuFilterByCategory; | 86 | int mnuFilterByCategory; |
86 | int mnuSetFilterCategory; | 87 | int mnuSetFilterCategory; |
87 | 88 | ||
88 | // Main package list widget | 89 | // Main package list widget |
89 | QWidget *networkPkgWindow; | 90 | QWidget *networkPkgWindow; |
90 | QComboBox *serversList; | 91 | QComboBox *serversList; |
91 | QListView *packagesList; | 92 | QListView *packagesList; |
92 | QPixmap installedIcon; | 93 | QPixmap installedIcon; |
93 | QPixmap updatedIcon; | 94 | QPixmap updatedIcon; |
94 | QString currentlySelectedServer; | 95 | QString currentlySelectedServer; |
95 | QString categoryFilter; | 96 | QString categoryFilter; |
96 | QString stickyOption; | 97 | QString stickyOption; |
97 | 98 | ||
98 | bool categoryFilterEnabled; | 99 | bool categoryFilterEnabled; |
99 | bool showJumpTo; | 100 | bool showJumpTo; |
100 | bool showUninstalledPkgs; | 101 | bool showUninstalledPkgs; |
101 | bool showInstalledPkgs; | 102 | bool showInstalledPkgs; |
102 | bool showUpgradedPkgs; | 103 | bool showUpgradedPkgs; |
103 | bool downloadEnabled; | 104 | bool downloadEnabled; |
104 | bool reloadDocuments; | 105 | bool reloadDocuments; |
105 | 106 | ||
106 | void initMainWidget(); | 107 | void initMainWidget(); |
107 | void updateData(); | 108 | void updateData(); |
108 | void serverSelected( int index, bool showProgress ); | 109 | void serverSelected( int index, bool showProgress ); |
109 | void searchForPackage( const QString & ); | 110 | void searchForPackage( const QString & ); |
110 | bool filterByCategory( bool val ); | 111 | bool filterByCategory( bool val ); |
111 | void downloadSelectedPackages(); | 112 | void downloadSelectedPackages(); |
112 | void downloadRemotePackage(); | 113 | void downloadRemotePackage(); |
113 | InstallData *dealWithItem( QCheckListItem *item ); | 114 | InstallData *dealWithItem( QCheckListItem *item ); |
114 | 115 | ||
115 | // Progress widget | 116 | // Progress widget |
116 | QWidget *progressWindow; | 117 | QWidget *progressWindow; |
117 | QLabel *m_status; | 118 | QLabel *m_status; |
118 | QProgressBar *m_progress; | 119 | QProgressBar *m_progress; |
119 | 120 | ||
120 | void initProgressWidget(); | 121 | void initProgressWidget(); |
121 | 122 | ||
122 | public slots: | 123 | public slots: |
123 | void setDocument( const QString &doc ); | 124 | void setDocument( const QString &doc ); |
124 | void displayFindBar(); | 125 | void displayFindBar(); |
125 | void displayJumpBar(); | 126 | void displayJumpBar(); |
126 | void repeatFind(); | 127 | void repeatFind(); |
127 | void findPackage( const QString & ); | 128 | void findPackage( const QString & ); |
128 | void hideFindBar(); | 129 | void hideFindBar(); |
129 | void hideJumpBar(); | 130 | void hideJumpBar(); |
130 | void displaySettings(); | 131 | void displaySettings(); |
131 | void filterUninstalledPackages(); | 132 | void filterUninstalledPackages(); |
132 | void filterInstalledPackages(); | 133 | void filterInstalledPackages(); |
133 | void filterUpgradedPackages(); | 134 | void filterUpgradedPackages(); |
134 | void filterCategory(); | 135 | void filterCategory(); |
135 | bool setFilterCategory(); | 136 | bool setFilterCategory(); |
136 | void raiseMainWidget(); | 137 | void raiseMainWidget(); |
137 | void raiseProgressWidget(); | 138 | void raiseProgressWidget(); |
138 | void enableUpgrade( bool ); | 139 | void enableUpgrade( bool ); |
139 | void enableDownload( bool ); | 140 | void enableDownload( bool ); |
140 | void reloadData( InstallDlgImpl * ); | 141 | void reloadData( InstallDlgImpl * ); |
141 | 142 | ||
142 | private slots: | 143 | private slots: |
143 | void init(); | 144 | void init(); |
144 | void setProgressSteps( int ); | 145 | void setProgressSteps( int ); |
145 | void setProgressMessage( const QString & ); | 146 | void setProgressMessage( const QString & ); |
146 | void updateProgress( int ); | 147 | void updateProgress( int ); |
147 | void serverSelected( int index ); | 148 | void serverSelected( int index ); |
148 | void updateServer(); | 149 | void updateServer(); |
149 | void upgradePackages(); | 150 | void upgradePackages(); |
150 | void downloadPackage(); | 151 | void downloadPackage(); |
151 | void applyChanges(); | 152 | void applyChanges(); |
152 | void letterPushed( QString t ); | 153 | void letterPushed( QString t ); |
153 | void slotDisplayPackage( QListViewItem * ); | 154 | void slotDisplayPackage( QListViewItem * ); |
154 | }; | 155 | }; |
155 | 156 | ||
156 | class QuestionDlg : public QWidget | 157 | class QuestionDlg : public QWidget |
157 | { | 158 | { |
158 | Q_OBJECT | 159 | Q_OBJECT |
159 | public: | 160 | public: |
160 | QuestionDlg( const QString &caption, const QString &text, const QString &secondbtn ); | 161 | QuestionDlg( const QString &caption, const QString &text, const QString &secondbtn ); |
161 | 162 | ||
162 | int exec(); | 163 | int exec(); |
163 | 164 | ||
164 | private: | 165 | private: |
165 | QPushButton *btn1; | 166 | QPushButton *btn1; |
166 | QPushButton *btn2; | 167 | QPushButton *btn2; |
167 | 168 | ||
168 | bool executing; | 169 | bool executing; |
169 | int buttonpressed; | 170 | int buttonpressed; |
170 | 171 | ||
171 | private slots: | 172 | private slots: |
172 | void slotButtonPressed(); | 173 | void slotButtonPressed(); |
173 | }; | 174 | }; |
174 | 175 | ||
175 | #endif | 176 | #endif |
diff --git a/noncore/settings/sysinfo/main.cpp b/noncore/settings/sysinfo/main.cpp index 6e889db..02b1098 100644 --- a/noncore/settings/sysinfo/main.cpp +++ b/noncore/settings/sysinfo/main.cpp | |||
@@ -1,34 +1,27 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "sysinfo.h" | 21 | #include "sysinfo.h" |
22 | 22 | ||
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | #include <opie/oapplicationfactory.h> | ||
24 | 25 | ||
25 | int main( int argc, char *argv[] ) | ||
26 | { | ||
27 | QPEApplication a( argc, argv ); | ||
28 | |||
29 | SystemInfo *si = new SystemInfo(); | ||
30 | a.showMainWidget( si ); | ||
31 | |||
32 | return a.exec(); | ||
33 | } | ||
34 | 26 | ||
27 | OPIE_EXPORT_APP( OApplicationFactory<SystemInfo> ) | ||
diff --git a/noncore/settings/sysinfo/storage.cpp b/noncore/settings/sysinfo/storage.cpp index c4474d5..4ef7122 100644 --- a/noncore/settings/sysinfo/storage.cpp +++ b/noncore/settings/sysinfo/storage.cpp | |||
@@ -1,187 +1,178 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // additions copyright 2002 by L.J. Potter | 20 | // additions copyright 2002 by L.J. Potter |
21 | 21 | ||
22 | #include <qpe/storage.h> | 22 | #include <qpe/storage.h> |
23 | 23 | ||
24 | #include <qlabel.h> | 24 | #include <qlabel.h> |
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | #include <qscrollview.h> | 26 | #include <qscrollview.h> |
27 | #include <qtimer.h> | 27 | #include <qtimer.h> |
28 | #include <qwhatsthis.h> | 28 | #include <qwhatsthis.h> |
29 | 29 | ||
30 | #include "graph.h" | 30 | #include "graph.h" |
31 | #include "storage.h" | 31 | #include "storage.h" |
32 | 32 | ||
33 | #include <stdio.h> | 33 | #include <stdio.h> |
34 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 34 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
35 | #include <sys/vfs.h> | 35 | #include <sys/vfs.h> |
36 | #include <mntent.h> | 36 | #include <mntent.h> |
37 | #endif | 37 | #endif |
38 | 38 | ||
39 | FileSysInfo::FileSysInfo( QWidget *parent, const char *name ) | 39 | FileSysInfo::FileSysInfo( QWidget *parent, const char *name ) |
40 | : QWidget( parent, name ) | 40 | : QWidget( parent, name ) |
41 | { | 41 | { |
42 | QVBoxLayout *tmpvb = new QVBoxLayout( this ); | 42 | QVBoxLayout *tmpvb = new QVBoxLayout( this ); |
43 | QScrollView *sv = new QScrollView( this ); | 43 | QScrollView *sv = new QScrollView( this ); |
44 | tmpvb->addWidget( sv, 0, 0 ); | 44 | tmpvb->addWidget( sv, 0, 0 ); |
45 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 45 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
46 | sv->setFrameStyle( QFrame::NoFrame ); | 46 | sv->setFrameStyle( QFrame::NoFrame ); |
47 | container = new QWidget( sv->viewport() ); | 47 | container = new QWidget( sv->viewport() ); |
48 | sv->addChild( container ); | 48 | sv->addChild( container ); |
49 | vb = 0x0; | 49 | vb = 0x0; |
50 | 50 | ||
51 | storage = new StorageInfo( this ); | 51 | storage = new StorageInfo( this ); |
52 | connect( storage, SIGNAL( disksChanged() ), this, SLOT( disksChanged() ) ); | 52 | connect( storage, SIGNAL( disksChanged() ), this, SLOT( disksChanged() ) ); |
53 | 53 | ||
54 | lines.setAutoDelete(TRUE); | 54 | lines.setAutoDelete(TRUE); |
55 | 55 | ||
56 | rebuildDisks = TRUE; | 56 | rebuildDisks = TRUE; |
57 | updateMounts(); | 57 | updateMounts(); |
58 | startTimer( 5000 ); | 58 | startTimer( 5000 ); |
59 | } | 59 | } |
60 | 60 | ||
61 | |||
61 | void FileSysInfo::timerEvent(QTimerEvent*) | 62 | void FileSysInfo::timerEvent(QTimerEvent*) |
62 | { | 63 | { |
63 | updateMounts(); | 64 | updateMounts(); |
64 | } | 65 | } |
65 | 66 | ||
66 | void FileSysInfo::updateMounts() | 67 | void FileSysInfo::updateMounts() |
67 | { | 68 | { |
68 | storage->update(); | 69 | storage->update(); |
69 | 70 | ||
70 | if ( rebuildDisks ) | 71 | if ( rebuildDisks ) |
71 | { | 72 | { |
72 | // Cannot auto delete QDict<MountInfo> disks because it seems to delete | ||
73 | // the filesystem object as well causing a segfault | ||
74 | MountInfo *mi; | ||
75 | for ( QDictIterator<MountInfo> delit(disks); delit.current(); ++delit ) | ||
76 | { | ||
77 | mi = delit.current(); | ||
78 | mi->fs = 0x0; | ||
79 | delete mi; | ||
80 | } | ||
81 | disks.clear(); | 73 | disks.clear(); |
82 | lines.clear(); | 74 | lines.clear(); |
83 | 75 | ||
84 | delete vb; | 76 | delete vb; |
85 | vb = new QVBoxLayout( container/*, n > 3 ? 1 : 5*/ ); | 77 | vb = new QVBoxLayout( container/*, n > 3 ? 1 : 5*/ ); |
86 | 78 | ||
87 | bool frst=TRUE; | 79 | bool frst=TRUE; |
88 | 80 | ||
89 | FileSystem *fs; | 81 | FileSystem *fs; |
90 | for ( QListIterator<FileSystem> it(storage->fileSystems()); it.current(); ++it ) | 82 | for ( QListIterator<FileSystem> it(storage->fileSystems()); it.current(); ++it ) |
91 | { | 83 | { |
92 | fs = it.current(); | 84 | fs = it.current(); |
93 | 85 | ||
94 | if ( !frst ) | 86 | if ( !frst ) |
95 | { | 87 | { |
96 | QFrame *f = new QFrame( container ); | 88 | QFrame *f = new QFrame( container ); |
97 | vb->addWidget(f); | 89 | vb->addWidget(f); |
98 | f->setFrameStyle( QFrame::HLine | QFrame::Sunken ); | 90 | f->setFrameStyle( QFrame::HLine | QFrame::Sunken ); |
99 | lines.append(f); | 91 | lines.append(f); |
100 | f->show(); | 92 | f->show(); |
101 | } | 93 | } |
102 | frst = FALSE; | 94 | frst = FALSE; |
103 | 95 | ||
104 | MountInfo *mi = new MountInfo( fs, container ); | 96 | MountInfo *mi = new MountInfo( fs, container ); |
105 | vb->addWidget( mi ); | 97 | vb->addWidget( mi ); |
106 | disks.insert( fs->path(), mi ); | 98 | disks.insert( fs->path(), mi ); |
107 | mi->show(); | 99 | mi->show(); |
108 | QString tempstr = fs->name().left( 2 ); | 100 | QString tempstr = fs->name().left( 2 ); |
109 | if ( tempstr == tr( "CF" ) ) | 101 | if ( tempstr == tr( "CF" ) ) |
110 | QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used on this Compact Flash memory card." ) ); | 102 | QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used on this Compact Flash memory card." ) ); |
111 | else if ( tempstr == tr( "Ha" ) ) | 103 | else if ( tempstr == tr( "Ha" ) ) |
112 | QWhatsThis::add( mi, tr( "This graph represents how much storage is currently used on this hard drive." ) ); | 104 | QWhatsThis::add( mi, tr( "This graph represents how much storage is currently used on this hard drive." ) ); |
113 | else if ( tempstr == tr( "SD" ) ) | 105 | else if ( tempstr == tr( "SD" ) ) |
114 | QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used on this Secure Digital memory card." ) ); | 106 | QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used on this Secure Digital memory card." ) ); |
115 | else if ( tempstr == tr( "SC" ) ) | 107 | else if ( tempstr == tr( "SC" ) ) |
116 | QWhatsThis::add( mi, tr( "This graph represents how much storage is currently used on this hard drive." ) ); | 108 | QWhatsThis::add( mi, tr( "This graph represents how much storage is currently used on this hard drive." ) ); |
117 | else if ( tempstr == tr( "In" ) ) | 109 | else if ( tempstr == tr( "In" ) ) |
118 | QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used of the built-in memory (i.e. Flash memory) on this handheld device." ) ); | 110 | QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used of the built-in memory (i.e. Flash memory) on this handheld device." ) ); |
119 | else if ( tempstr == tr( "RA" ) ) | 111 | else if ( tempstr == tr( "RA" ) ) |
120 | QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used of the temporary RAM disk." ) ); | 112 | QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used of the temporary RAM disk." ) ); |
121 | } | 113 | } |
122 | vb->addStretch(); | 114 | vb->addStretch(); |
123 | } | 115 | } |
124 | else | 116 | else |
125 | { | 117 | { |
126 | for (QDictIterator<MountInfo> i(disks); i.current(); ++i) | 118 | for (QDictIterator<MountInfo> i(disks); i.current(); ++i) |
127 | i.current()->updateData(); | 119 | i.current()->updateData(); |
128 | } | 120 | } |
129 | 121 | ||
130 | rebuildDisks = FALSE; | 122 | rebuildDisks = FALSE; |
131 | } | 123 | } |
132 | 124 | ||
133 | void FileSysInfo::disksChanged() | 125 | void FileSysInfo::disksChanged() |
134 | { | 126 | { |
135 | rebuildDisks = TRUE; | 127 | rebuildDisks = TRUE; |
136 | } | 128 | } |
137 | 129 | ||
138 | MountInfo::MountInfo( FileSystem *filesys, QWidget *parent, const char *name ) | 130 | MountInfo::MountInfo( FileSystem *filesys, QWidget *parent, const char *name ) |
139 | : QWidget( parent, name ) | 131 | : QWidget( parent, name ) |
140 | { | 132 | { |
141 | QVBoxLayout *vb = new QVBoxLayout( this, 3 ); | 133 | QVBoxLayout *vb = new QVBoxLayout( this, 3 ); |
142 | 134 | ||
143 | totalSize = new QLabel( this ); | 135 | totalSize = new QLabel( this ); |
144 | vb->addWidget( totalSize ); | 136 | vb->addWidget( totalSize ); |
145 | 137 | ||
146 | fs = filesys; | 138 | fs = filesys; |
147 | title = fs->name(); | 139 | title = fs->name(); |
148 | 140 | ||
149 | data = new GraphData(); | 141 | data = new GraphData(); |
150 | graph = new BarGraph( this ); | 142 | graph = new BarGraph( this ); |
151 | graph->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 143 | graph->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
152 | vb->addWidget( graph, 1 ); | 144 | vb->addWidget( graph, 1 ); |
153 | graph->setData( data ); | 145 | graph->setData( data ); |
154 | 146 | ||
155 | legend = new GraphLegend( this ); | 147 | legend = new GraphLegend( this ); |
156 | legend->setOrientation(Horizontal); | 148 | legend->setOrientation(Horizontal); |
157 | vb->addWidget( legend ); | 149 | vb->addWidget( legend ); |
158 | legend->setData( data ); | 150 | legend->setData( data ); |
159 | 151 | ||
160 | updateData(); | 152 | updateData(); |
161 | } | 153 | } |
162 | 154 | ||
163 | MountInfo::~MountInfo() | 155 | MountInfo::~MountInfo() |
164 | { | 156 | { |
165 | delete data; | 157 | delete data; |
166 | delete fs; | ||
167 | } | 158 | } |
168 | 159 | ||
169 | void MountInfo::updateData() | 160 | void MountInfo::updateData() |
170 | { | 161 | { |
171 | long mult = fs->blockSize() / 1024; | 162 | long mult = fs->blockSize() / 1024; |
172 | long div = 1024 / fs->blockSize(); | 163 | long div = 1024 / fs->blockSize(); |
173 | if ( !mult ) mult = 1; | 164 | if ( !mult ) mult = 1; |
174 | if ( !div ) div = 1; | 165 | if ( !div ) div = 1; |
175 | long total = fs->totalBlocks() * mult / div; | 166 | long total = fs->totalBlocks() * mult / div; |
176 | long avail = fs->availBlocks() * mult / div; | 167 | long avail = fs->availBlocks() * mult / div; |
177 | long used = total - avail; | 168 | long used = total - avail; |
178 | totalSize->setText( title + tr(" : %1 kB").arg( total ) ); | 169 | totalSize->setText( title + tr(" : %1 kB").arg( total ) ); |
179 | data->clear(); | 170 | data->clear(); |
180 | data->addItem( tr("Used (%1 kB)").arg(used), used ); | 171 | data->addItem( tr("Used (%1 kB)").arg(used), used ); |
181 | data->addItem( tr("Available (%1 kB)").arg(avail), avail ); | 172 | data->addItem( tr("Available (%1 kB)").arg(avail), avail ); |
182 | graph->repaint( FALSE ); | 173 | graph->repaint( FALSE ); |
183 | legend->update(); | 174 | legend->update(); |
184 | graph->show(); | 175 | graph->show(); |
185 | legend->show(); | 176 | legend->show(); |
186 | } | 177 | } |
187 | 178 | ||
diff --git a/noncore/settings/sysinfo/sysinfo.h b/noncore/settings/sysinfo/sysinfo.h index d69346a..94c3876 100644 --- a/noncore/settings/sysinfo/sysinfo.h +++ b/noncore/settings/sysinfo/sysinfo.h | |||
@@ -1,33 +1,34 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | ********************************************************************** | 19 | ********************************************************************** |
20 | ** | 20 | ** |
21 | ** Enhancements by: Dan Williams, <williamsdr@acm.org> | 21 | ** Enhancements by: Dan Williams, <williamsdr@acm.org> |
22 | ** | 22 | ** |
23 | **********************************************************************/ | 23 | **********************************************************************/ |
24 | 24 | ||
25 | #include <qwidget.h> | 25 | #include <qwidget.h> |
26 | 26 | ||
27 | class SystemInfo : public QWidget | 27 | class SystemInfo : public QWidget |
28 | { | 28 | { |
29 | Q_OBJECT | 29 | Q_OBJECT |
30 | public: | 30 | public: |
31 | SystemInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 31 | SystemInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
32 | static QString appName() { return QString::fromLatin1("sysinfo"); } | ||
32 | }; | 33 | }; |
33 | 34 | ||
diff --git a/noncore/settings/sysinfo/sysinfo.pro b/noncore/settings/sysinfo/sysinfo.pro index 2582ea2..2322989 100644 --- a/noncore/settings/sysinfo/sysinfo.pro +++ b/noncore/settings/sysinfo/sysinfo.pro | |||
@@ -1,49 +1,48 @@ | |||
1 | TEMPLATE = app | 1 | CONFIG = qt warn_on release quick-app |
2 | CONFIG = qt warn_on release | ||
3 | DESTDIR = $(OPIEDIR)/bin | ||
4 | HEADERS = memory.h \ | 2 | HEADERS = memory.h \ |
5 | graph.h \ | 3 | graph.h \ |
6 | load.h \ | 4 | load.h \ |
7 | storage.h \ | 5 | storage.h \ |
8 | processinfo.h \ | 6 | processinfo.h \ |
9 | modulesinfo.h \ | 7 | modulesinfo.h \ |
10 | detail.h \ | 8 | detail.h \ |
11 | versioninfo.h \ | 9 | versioninfo.h \ |
12 | sysinfo.h | 10 | sysinfo.h |
13 | SOURCES = main.cpp \ | 11 | SOURCES = main.cpp \ |
14 | memory.cpp \ | 12 | memory.cpp \ |
15 | graph.cpp \ | 13 | graph.cpp \ |
16 | load.cpp \ | 14 | load.cpp \ |
17 | storage.cpp \ | 15 | storage.cpp \ |
18 | processinfo.cpp \ | 16 | processinfo.cpp \ |
19 | modulesinfo.cpp \ | 17 | modulesinfo.cpp \ |
20 | detail.cpp \ | 18 | detail.cpp \ |
21 | versioninfo.cpp \ | 19 | versioninfo.cpp \ |
22 | sysinfo.cpp | 20 | sysinfo.cpp |
23 | INTERFACES = | 21 | |
24 | INCLUDEPATH += $(OPIEDIR)/include | 22 | INCLUDEPATH += $(OPIEDIR)/include |
25 | DEPENDPATH += $(OPIEDIR)/include | 23 | DEPENDPATH += $(OPIEDIR)/include |
26 | LIBS += -lqpe -lopie | 24 | LIBS += -lqpe -lopie |
27 | TARGET = sysinfo | 25 | |
26 | TARGET= sysinfo | ||
28 | 27 | ||
29 | TRANSLATIONS = ../../../i18n/de/sysinfo.ts \ | 28 | TRANSLATIONS = ../../../i18n/de/sysinfo.ts \ |
30 | ../../../i18n/nl/sysinfo.ts \ | 29 | ../../../i18n/nl/sysinfo.ts \ |
31 | ../../../i18n/xx/sysinfo.ts \ | 30 | ../../../i18n/xx/sysinfo.ts \ |
32 | ../../../i18n/en/sysinfo.ts \ | 31 | ../../../i18n/en/sysinfo.ts \ |
33 | ../../../i18n/es/sysinfo.ts \ | 32 | ../../../i18n/es/sysinfo.ts \ |
34 | ../../../i18n/fr/sysinfo.ts \ | 33 | ../../../i18n/fr/sysinfo.ts \ |
35 | ../../../i18n/hu/sysinfo.ts \ | 34 | ../../../i18n/hu/sysinfo.ts \ |
36 | ../../../i18n/ja/sysinfo.ts \ | 35 | ../../../i18n/ja/sysinfo.ts \ |
37 | ../../../i18n/ko/sysinfo.ts \ | 36 | ../../../i18n/ko/sysinfo.ts \ |
38 | ../../../i18n/no/sysinfo.ts \ | 37 | ../../../i18n/no/sysinfo.ts \ |
39 | ../../../i18n/pl/sysinfo.ts \ | 38 | ../../../i18n/pl/sysinfo.ts \ |
40 | ../../../i18n/pt/sysinfo.ts \ | 39 | ../../../i18n/pt/sysinfo.ts \ |
41 | ../../../i18n/pt_BR/sysinfo.ts \ | 40 | ../../../i18n/pt_BR/sysinfo.ts \ |
42 | ../../../i18n/sl/sysinfo.ts \ | 41 | ../../../i18n/sl/sysinfo.ts \ |
43 | ../../../i18n/zh_CN/sysinfo.ts \ | 42 | ../../../i18n/zh_CN/sysinfo.ts \ |
44 | ../../../i18n/zh_TW/sysinfo.ts \ | 43 | ../../../i18n/zh_TW/sysinfo.ts \ |
45 | ../../../i18n/da/sysinfo.ts | 44 | ../../../i18n/da/sysinfo.ts |
46 | 45 | ||
47 | 46 | ||
48 | 47 | ||
49 | include ( $(OPIEDIR)/include.pro ) | 48 | include ( $(OPIEDIR)/include.pro ) |