6 files changed, 62 insertions, 29 deletions
diff --git a/core/multimedia/opieplayer/modplug/sndfile.cpp b/core/multimedia/opieplayer/modplug/sndfile.cpp index 1d0d610..799555c 100644 --- a/core/multimedia/opieplayer/modplug/sndfile.cpp +++ b/core/multimedia/opieplayer/modplug/sndfile.cpp | |||
@@ -1694,97 +1694,100 @@ void CSoundFile::FrequencyToTranspose(MODINSTRUMENT *psmp) | |||
1694 | int ftune = f2t & 0x7F; | 1694 | int ftune = f2t & 0x7F; |
1695 | if (ftune > 80) | 1695 | if (ftune > 80) |
1696 | { | 1696 | { |
1697 | transp++; | 1697 | transp++; |
1698 | ftune -= 128; | 1698 | ftune -= 128; |
1699 | } | 1699 | } |
1700 | if (transp > 127) transp = 127; | 1700 | if (transp > 127) transp = 127; |
1701 | if (transp < -127) transp = -127; | 1701 | if (transp < -127) transp = -127; |
1702 | psmp->RelativeTone = transp; | 1702 | psmp->RelativeTone = transp; |
1703 | psmp->nFineTune = ftune; | 1703 | psmp->nFineTune = ftune; |
1704 | } | 1704 | } |
1705 | 1705 | ||
1706 | 1706 | ||
1707 | void CSoundFile::CheckCPUUsage(UINT nCPU) | 1707 | void CSoundFile::CheckCPUUsage(UINT nCPU) |
1708 | //--------------------------------------- | 1708 | //--------------------------------------- |
1709 | { | 1709 | { |
1710 | if (nCPU > 100) nCPU = 100; | 1710 | if (nCPU > 100) nCPU = 100; |
1711 | gnCPUUsage = nCPU; | 1711 | gnCPUUsage = nCPU; |
1712 | if (nCPU < 90) | 1712 | if (nCPU < 90) |
1713 | { | 1713 | { |
1714 | m_dwSongFlags &= ~SONG_CPUVERYHIGH; | 1714 | m_dwSongFlags &= ~SONG_CPUVERYHIGH; |
1715 | } else | 1715 | } else |
1716 | if ((m_dwSongFlags & SONG_CPUVERYHIGH) && (nCPU >= 94)) | 1716 | if ((m_dwSongFlags & SONG_CPUVERYHIGH) && (nCPU >= 94)) |
1717 | { | 1717 | { |
1718 | UINT i=MAX_CHANNELS; | 1718 | UINT i=MAX_CHANNELS; |
1719 | while (i >= 8) | 1719 | while (i >= 8) |
1720 | { | 1720 | { |
1721 | i--; | 1721 | i--; |
1722 | if (Chn[i].nLength) | 1722 | if (Chn[i].nLength) |
1723 | { | 1723 | { |
1724 | Chn[i].nLength = Chn[i].nPos = 0; | 1724 | Chn[i].nLength = Chn[i].nPos = 0; |
1725 | nCPU -= 2; | 1725 | nCPU -= 2; |
1726 | if (nCPU < 94) break; | 1726 | if (nCPU < 94) break; |
1727 | } | 1727 | } |
1728 | } | 1728 | } |
1729 | } else | 1729 | } else |
1730 | if (nCPU > 90) | 1730 | if (nCPU > 90) |
1731 | { | 1731 | { |
1732 | m_dwSongFlags |= SONG_CPUVERYHIGH; | 1732 | m_dwSongFlags |= SONG_CPUVERYHIGH; |
1733 | } | 1733 | } |
1734 | } | 1734 | } |
1735 | 1735 | ||
1736 | 1736 | ||
1737 | BOOL CSoundFile::SetPatternName(UINT nPat, LPCSTR lpszName) | 1737 | BOOL CSoundFile::SetPatternName(UINT nPat, LPCSTR lpszName) |
1738 | //--------------------------------------------------------- | 1738 | //--------------------------------------------------------- |
1739 | { | 1739 | { |
1740 | char szName[MAX_PATTERNNAME] = ""; // changed from CHAR | 1740 | char szName[MAX_PATTERNNAME] = ""; // changed from CHAR |
1741 | if (nPat >= MAX_PATTERNS) return FALSE; | 1741 | if (nPat >= MAX_PATTERNS) return FALSE; |
1742 | if (lpszName) lstrcpyn(szName, lpszName, MAX_PATTERNNAME); | 1742 | if (lpszName) |
1743 | lstrcpyn(szName, lpszName, MAX_PATTERNNAME); | ||
1744 | else | ||
1745 | return FALSE; | ||
1743 | szName[MAX_PATTERNNAME-1] = 0; | 1746 | szName[MAX_PATTERNNAME-1] = 0; |
1744 | if (!m_lpszPatternNames) m_nPatternNames = 0; | 1747 | if (!m_lpszPatternNames) m_nPatternNames = 0; |
1745 | if (nPat >= m_nPatternNames) | 1748 | if (nPat >= m_nPatternNames) |
1746 | { | 1749 | { |
1747 | if (!lpszName[0]) return TRUE; | 1750 | if (!lpszName[0]) return TRUE; |
1748 | UINT len = (nPat+1)*MAX_PATTERNNAME; | 1751 | UINT len = (nPat+1)*MAX_PATTERNNAME; |
1749 | char *p = new char[len]; // changed from CHAR | 1752 | char *p = new char[len]; // changed from CHAR |
1750 | if (!p) return FALSE; | 1753 | if (!p) return FALSE; |
1751 | memset(p, 0, len); | 1754 | memset(p, 0, len); |
1752 | if (m_lpszPatternNames) | 1755 | if (m_lpszPatternNames) |
1753 | { | 1756 | { |
1754 | memcpy(p, m_lpszPatternNames, m_nPatternNames * MAX_PATTERNNAME); | 1757 | memcpy(p, m_lpszPatternNames, m_nPatternNames * MAX_PATTERNNAME); |
1755 | delete m_lpszPatternNames; | 1758 | delete m_lpszPatternNames; |
1756 | m_lpszPatternNames = NULL; | 1759 | m_lpszPatternNames = NULL; |
1757 | } | 1760 | } |
1758 | m_lpszPatternNames = p; | 1761 | m_lpszPatternNames = p; |
1759 | m_nPatternNames = nPat + 1; | 1762 | m_nPatternNames = nPat + 1; |
1760 | } | 1763 | } |
1761 | memcpy(m_lpszPatternNames + nPat * MAX_PATTERNNAME, szName, MAX_PATTERNNAME); | 1764 | memcpy(m_lpszPatternNames + nPat * MAX_PATTERNNAME, szName, MAX_PATTERNNAME); |
1762 | return TRUE; | 1765 | return TRUE; |
1763 | } | 1766 | } |
1764 | 1767 | ||
1765 | 1768 | ||
1766 | BOOL CSoundFile::GetPatternName(UINT nPat, LPSTR lpszName, UINT cbSize) const | 1769 | BOOL CSoundFile::GetPatternName(UINT nPat, LPSTR lpszName, UINT cbSize) const |
1767 | //--------------------------------------------------------------------------- | 1770 | //--------------------------------------------------------------------------- |
1768 | { | 1771 | { |
1769 | if ((!lpszName) || (!cbSize)) return FALSE; | 1772 | if ((!lpszName) || (!cbSize)) return FALSE; |
1770 | lpszName[0] = 0; | 1773 | lpszName[0] = 0; |
1771 | if (cbSize > MAX_PATTERNNAME) cbSize = MAX_PATTERNNAME; | 1774 | if (cbSize > MAX_PATTERNNAME) cbSize = MAX_PATTERNNAME; |
1772 | if ((m_lpszPatternNames) && (nPat < m_nPatternNames)) | 1775 | if ((m_lpszPatternNames) && (nPat < m_nPatternNames)) |
1773 | { | 1776 | { |
1774 | memcpy(lpszName, m_lpszPatternNames + nPat * MAX_PATTERNNAME, cbSize); | 1777 | memcpy(lpszName, m_lpszPatternNames + nPat * MAX_PATTERNNAME, cbSize); |
1775 | lpszName[cbSize-1] = 0; | 1778 | lpszName[cbSize-1] = 0; |
1776 | return TRUE; | 1779 | return TRUE; |
1777 | } | 1780 | } |
1778 | return FALSE; | 1781 | return FALSE; |
1779 | } | 1782 | } |
1780 | 1783 | ||
1781 | 1784 | ||
1782 | #ifndef FASTSOUNDLIB | 1785 | #ifndef FASTSOUNDLIB |
1783 | 1786 | ||
1784 | UINT CSoundFile::DetectUnusedSamples(BOOL *pbIns) | 1787 | UINT CSoundFile::DetectUnusedSamples(BOOL *pbIns) |
1785 | //----------------------------------------------- | 1788 | //----------------------------------------------- |
1786 | { | 1789 | { |
1787 | UINT nExt = 0; | 1790 | UINT nExt = 0; |
1788 | 1791 | ||
1789 | if (!pbIns) return 0; | 1792 | if (!pbIns) return 0; |
1790 | if (m_nInstruments) | 1793 | if (m_nInstruments) |
diff --git a/core/multimedia/opieplayer/vorbis/tremor/block.c b/core/multimedia/opieplayer/vorbis/tremor/block.c index 8949253..7b5531b 100644 --- a/core/multimedia/opieplayer/vorbis/tremor/block.c +++ b/core/multimedia/opieplayer/vorbis/tremor/block.c | |||
@@ -181,98 +181,100 @@ static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){ | |||
181 | v->W=0; /* current window size */ | 181 | v->W=0; /* current window size */ |
182 | 182 | ||
183 | /* initialize all the mapping/backend lookups */ | 183 | /* initialize all the mapping/backend lookups */ |
184 | b->mode=(vorbis_look_mapping **)_ogg_calloc(ci->modes,sizeof(*b->mode)); | 184 | b->mode=(vorbis_look_mapping **)_ogg_calloc(ci->modes,sizeof(*b->mode)); |
185 | for(i=0;i<ci->modes;i++){ | 185 | for(i=0;i<ci->modes;i++){ |
186 | int mapnum=ci->mode_param[i]->mapping; | 186 | int mapnum=ci->mode_param[i]->mapping; |
187 | int maptype=ci->map_type[mapnum]; | 187 | int maptype=ci->map_type[mapnum]; |
188 | b->mode[i]=_mapping_P[maptype]->look(v,ci->mode_param[i], | 188 | b->mode[i]=_mapping_P[maptype]->look(v,ci->mode_param[i], |
189 | ci->map_param[mapnum]); | 189 | ci->map_param[mapnum]); |
190 | } | 190 | } |
191 | return(0); | 191 | return(0); |
192 | } | 192 | } |
193 | 193 | ||
194 | int vorbis_synthesis_restart(vorbis_dsp_state *v){ | 194 | int vorbis_synthesis_restart(vorbis_dsp_state *v){ |
195 | vorbis_info *vi=v->vi; | 195 | vorbis_info *vi=v->vi; |
196 | codec_setup_info *ci; | 196 | codec_setup_info *ci; |
197 | 197 | ||
198 | if(!v->backend_state)return -1; | 198 | if(!v->backend_state)return -1; |
199 | if(!vi)return -1; | 199 | if(!vi)return -1; |
200 | ci=vi->codec_setup; | 200 | ci=vi->codec_setup; |
201 | if(!ci)return -1; | 201 | if(!ci)return -1; |
202 | 202 | ||
203 | v->centerW=ci->blocksizes[1]/2; | 203 | v->centerW=ci->blocksizes[1]/2; |
204 | v->pcm_current=v->centerW; | 204 | v->pcm_current=v->centerW; |
205 | 205 | ||
206 | v->pcm_returned=-1; | 206 | v->pcm_returned=-1; |
207 | v->granulepos=-1; | 207 | v->granulepos=-1; |
208 | v->sequence=-1; | 208 | v->sequence=-1; |
209 | ((private_state *)(v->backend_state))->sample_count=-1; | 209 | ((private_state *)(v->backend_state))->sample_count=-1; |
210 | 210 | ||
211 | return(0); | 211 | return(0); |
212 | } | 212 | } |
213 | 213 | ||
214 | int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi){ | 214 | int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi){ |
215 | _vds_init(v,vi); | 215 | _vds_init(v,vi); |
216 | vorbis_synthesis_restart(v); | 216 | vorbis_synthesis_restart(v); |
217 | 217 | ||
218 | return(0); | 218 | return(0); |
219 | } | 219 | } |
220 | 220 | ||
221 | void vorbis_dsp_clear(vorbis_dsp_state *v){ | 221 | void vorbis_dsp_clear(vorbis_dsp_state *v){ |
222 | int i; | 222 | int i; |
223 | if(v){ | 223 | if(v){ |
224 | vorbis_info *vi=v->vi; | 224 | vorbis_info *vi=v->vi; |
225 | codec_setup_info *ci=(codec_setup_info *)(vi?vi->codec_setup:NULL); | 225 | codec_setup_info *ci=(codec_setup_info *)(vi?vi->codec_setup:NULL); |
226 | private_state *b=(private_state *)v->backend_state; | 226 | private_state *b=(private_state *)v->backend_state; |
227 | 227 | ||
228 | if(v->pcm){ | 228 | if(v->pcm){ |
229 | for(i=0;i<vi->channels;i++) | 229 | if (vi) { |
230 | if(v->pcm[i])_ogg_free(v->pcm[i]); | 230 | for(i=0;i<vi->channels;i++) |
231 | if(v->pcm[i])_ogg_free(v->pcm[i]); | ||
232 | } | ||
231 | _ogg_free(v->pcm); | 233 | _ogg_free(v->pcm); |
232 | if(v->pcmret)_ogg_free(v->pcmret); | 234 | if(v->pcmret)_ogg_free(v->pcmret); |
233 | } | 235 | } |
234 | 236 | ||
235 | /* free mode lookups; these are actually vorbis_look_mapping structs */ | 237 | /* free mode lookups; these are actually vorbis_look_mapping structs */ |
236 | if(ci){ | 238 | if(ci){ |
237 | for(i=0;i<ci->modes;i++){ | 239 | for(i=0;i<ci->modes;i++){ |
238 | int mapnum=ci->mode_param[i]->mapping; | 240 | int mapnum=ci->mode_param[i]->mapping; |
239 | int maptype=ci->map_type[mapnum]; | 241 | int maptype=ci->map_type[mapnum]; |
240 | if(b && b->mode)_mapping_P[maptype]->free_look(b->mode[i]); | 242 | if(b && b->mode)_mapping_P[maptype]->free_look(b->mode[i]); |
241 | } | 243 | } |
242 | } | 244 | } |
243 | 245 | ||
244 | if(b){ | 246 | if(b){ |
245 | if(b->mode)_ogg_free(b->mode); | 247 | if(b->mode)_ogg_free(b->mode); |
246 | _ogg_free(b); | 248 | _ogg_free(b); |
247 | } | 249 | } |
248 | 250 | ||
249 | memset(v,0,sizeof(*v)); | 251 | memset(v,0,sizeof(*v)); |
250 | } | 252 | } |
251 | } | 253 | } |
252 | 254 | ||
253 | /* Unlike in analysis, the window is only partially applied for each | 255 | /* Unlike in analysis, the window is only partially applied for each |
254 | block. The time domain envelope is not yet handled at the point of | 256 | block. The time domain envelope is not yet handled at the point of |
255 | calling (as it relies on the previous block). */ | 257 | calling (as it relies on the previous block). */ |
256 | 258 | ||
257 | int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){ | 259 | int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){ |
258 | vorbis_info *vi=v->vi; | 260 | vorbis_info *vi=v->vi; |
259 | codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; | 261 | codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; |
260 | private_state *b=v->backend_state; | 262 | private_state *b=v->backend_state; |
261 | int i,j; | 263 | int i,j; |
262 | 264 | ||
263 | if(v->pcm_current>v->pcm_returned && v->pcm_returned!=-1)return(OV_EINVAL); | 265 | if(v->pcm_current>v->pcm_returned && v->pcm_returned!=-1)return(OV_EINVAL); |
264 | 266 | ||
265 | v->lW=v->W; | 267 | v->lW=v->W; |
266 | v->W=vb->W; | 268 | v->W=vb->W; |
267 | v->nW=-1; | 269 | v->nW=-1; |
268 | 270 | ||
269 | if((v->sequence==-1)|| | 271 | if((v->sequence==-1)|| |
270 | (v->sequence+1 != vb->sequence)){ | 272 | (v->sequence+1 != vb->sequence)){ |
271 | v->granulepos=-1; /* out of sequence; lose count */ | 273 | v->granulepos=-1; /* out of sequence; lose count */ |
272 | b->sample_count=-1; | 274 | b->sample_count=-1; |
273 | } | 275 | } |
274 | 276 | ||
275 | v->sequence=vb->sequence; | 277 | v->sequence=vb->sequence; |
276 | 278 | ||
277 | if(vb->pcm){ /* no pcm to process if vorbis_synthesis_trackonly | 279 | if(vb->pcm){ /* no pcm to process if vorbis_synthesis_trackonly |
278 | was called on block */ | 280 | was called on block */ |
diff --git a/core/multimedia/opieplayer/vorbis/tremor/info.c b/core/multimedia/opieplayer/vorbis/tremor/info.c index 941695e..3499ae4 100644 --- a/core/multimedia/opieplayer/vorbis/tremor/info.c +++ b/core/multimedia/opieplayer/vorbis/tremor/info.c | |||
@@ -52,98 +52,98 @@ static int tagcompare(const char *s1, const char *s2, int n){ | |||
52 | } | 52 | } |
53 | return 0; | 53 | return 0; |
54 | } | 54 | } |
55 | 55 | ||
56 | char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count){ | 56 | char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count){ |
57 | long i; | 57 | long i; |
58 | int found = 0; | 58 | int found = 0; |
59 | int taglen = strlen(tag)+1; /* +1 for the = we append */ | 59 | int taglen = strlen(tag)+1; /* +1 for the = we append */ |
60 | char *fulltag = (char *)alloca(taglen+ 1); | 60 | char *fulltag = (char *)alloca(taglen+ 1); |
61 | 61 | ||
62 | strcpy(fulltag, tag); | 62 | strcpy(fulltag, tag); |
63 | strcat(fulltag, "="); | 63 | strcat(fulltag, "="); |
64 | 64 | ||
65 | for(i=0;i<vc->comments;i++){ | 65 | for(i=0;i<vc->comments;i++){ |
66 | if(!tagcompare(vc->user_comments[i], fulltag, taglen)){ | 66 | if(!tagcompare(vc->user_comments[i], fulltag, taglen)){ |
67 | if(count == found) | 67 | if(count == found) |
68 | /* We return a pointer to the data, not a copy */ | 68 | /* We return a pointer to the data, not a copy */ |
69 | return vc->user_comments[i] + taglen; | 69 | return vc->user_comments[i] + taglen; |
70 | else | 70 | else |
71 | found++; | 71 | found++; |
72 | } | 72 | } |
73 | } | 73 | } |
74 | return NULL; /* didn't find anything */ | 74 | return NULL; /* didn't find anything */ |
75 | } | 75 | } |
76 | 76 | ||
77 | int vorbis_comment_query_count(vorbis_comment *vc, char *tag){ | 77 | int vorbis_comment_query_count(vorbis_comment *vc, char *tag){ |
78 | int i,count=0; | 78 | int i,count=0; |
79 | int taglen = strlen(tag)+1; /* +1 for the = we append */ | 79 | int taglen = strlen(tag)+1; /* +1 for the = we append */ |
80 | char *fulltag = (char *)alloca(taglen+1); | 80 | char *fulltag = (char *)alloca(taglen+1); |
81 | strcpy(fulltag,tag); | 81 | strcpy(fulltag,tag); |
82 | strcat(fulltag, "="); | 82 | strcat(fulltag, "="); |
83 | 83 | ||
84 | for(i=0;i<vc->comments;i++){ | 84 | for(i=0;i<vc->comments;i++){ |
85 | if(!tagcompare(vc->user_comments[i], fulltag, taglen)) | 85 | if(!tagcompare(vc->user_comments[i], fulltag, taglen)) |
86 | count++; | 86 | count++; |
87 | } | 87 | } |
88 | 88 | ||
89 | return count; | 89 | return count; |
90 | } | 90 | } |
91 | 91 | ||
92 | void vorbis_comment_clear(vorbis_comment *vc){ | 92 | void vorbis_comment_clear(vorbis_comment *vc){ |
93 | if(vc){ | 93 | if(vc){ |
94 | long i; | 94 | long i; |
95 | for(i=0;i<vc->comments;i++) | 95 | for(i=0;i<vc->comments;i++) |
96 | if(vc->user_comments[i])_ogg_free(vc->user_comments[i]); | 96 | if(vc->user_comments[i])_ogg_free(vc->user_comments[i]); |
97 | if(vc->user_comments)_ogg_free(vc->user_comments); | 97 | if(vc->user_comments)_ogg_free(vc->user_comments); |
98 | if(vc->comment_lengths)_ogg_free(vc->comment_lengths); | 98 | if(vc->comment_lengths)_ogg_free(vc->comment_lengths); |
99 | if(vc->vendor)_ogg_free(vc->vendor); | 99 | if(vc->vendor)_ogg_free(vc->vendor); |
100 | memset(vc,0,sizeof(*vc)); | ||
100 | } | 101 | } |
101 | memset(vc,0,sizeof(*vc)); | ||
102 | } | 102 | } |
103 | 103 | ||
104 | /* blocksize 0 is guaranteed to be short, 1 is guarantted to be long. | 104 | /* blocksize 0 is guaranteed to be short, 1 is guarantted to be long. |
105 | They may be equal, but short will never ge greater than long */ | 105 | They may be equal, but short will never ge greater than long */ |
106 | int vorbis_info_blocksize(vorbis_info *vi,int zo){ | 106 | int vorbis_info_blocksize(vorbis_info *vi,int zo){ |
107 | codec_setup_info *ci = (codec_setup_info *)vi->codec_setup; | 107 | codec_setup_info *ci = (codec_setup_info *)vi->codec_setup; |
108 | return ci ? ci->blocksizes[zo] : -1; | 108 | return ci ? ci->blocksizes[zo] : -1; |
109 | } | 109 | } |
110 | 110 | ||
111 | /* used by synthesis, which has a full, alloced vi */ | 111 | /* used by synthesis, which has a full, alloced vi */ |
112 | void vorbis_info_init(vorbis_info *vi){ | 112 | void vorbis_info_init(vorbis_info *vi){ |
113 | memset(vi,0,sizeof(*vi)); | 113 | memset(vi,0,sizeof(*vi)); |
114 | vi->codec_setup=(codec_setup_info *)_ogg_calloc(1,sizeof(codec_setup_info)); | 114 | vi->codec_setup=(codec_setup_info *)_ogg_calloc(1,sizeof(codec_setup_info)); |
115 | } | 115 | } |
116 | 116 | ||
117 | void vorbis_info_clear(vorbis_info *vi){ | 117 | void vorbis_info_clear(vorbis_info *vi){ |
118 | codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; | 118 | codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; |
119 | int i; | 119 | int i; |
120 | 120 | ||
121 | if(ci){ | 121 | if(ci){ |
122 | 122 | ||
123 | for(i=0;i<ci->modes;i++) | 123 | for(i=0;i<ci->modes;i++) |
124 | if(ci->mode_param[i])_ogg_free(ci->mode_param[i]); | 124 | if(ci->mode_param[i])_ogg_free(ci->mode_param[i]); |
125 | 125 | ||
126 | for(i=0;i<ci->maps;i++) /* unpack does the range checking */ | 126 | for(i=0;i<ci->maps;i++) /* unpack does the range checking */ |
127 | _mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]); | 127 | _mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]); |
128 | 128 | ||
129 | for(i=0;i<ci->floors;i++) /* unpack does the range checking */ | 129 | for(i=0;i<ci->floors;i++) /* unpack does the range checking */ |
130 | _floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]); | 130 | _floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]); |
131 | 131 | ||
132 | for(i=0;i<ci->residues;i++) /* unpack does the range checking */ | 132 | for(i=0;i<ci->residues;i++) /* unpack does the range checking */ |
133 | _residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]); | 133 | _residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]); |
134 | 134 | ||
135 | for(i=0;i<ci->books;i++){ | 135 | for(i=0;i<ci->books;i++){ |
136 | if(ci->book_param[i]){ | 136 | if(ci->book_param[i]){ |
137 | /* knows if the book was not alloced */ | 137 | /* knows if the book was not alloced */ |
138 | vorbis_staticbook_destroy(ci->book_param[i]); | 138 | vorbis_staticbook_destroy(ci->book_param[i]); |
139 | } | 139 | } |
140 | if(ci->fullbooks) | 140 | if(ci->fullbooks) |
141 | vorbis_book_clear(ci->fullbooks+i); | 141 | vorbis_book_clear(ci->fullbooks+i); |
142 | } | 142 | } |
143 | if(ci->fullbooks) | 143 | if(ci->fullbooks) |
144 | _ogg_free(ci->fullbooks); | 144 | _ogg_free(ci->fullbooks); |
145 | 145 | ||
146 | _ogg_free(ci); | 146 | _ogg_free(ci); |
147 | } | 147 | } |
148 | 148 | ||
149 | memset(vi,0,sizeof(*vi)); | 149 | memset(vi,0,sizeof(*vi)); |
diff --git a/noncore/apps/opie-write/qrichtext.cpp b/noncore/apps/opie-write/qrichtext.cpp index f040f1e..768da44 100644 --- a/noncore/apps/opie-write/qrichtext.cpp +++ b/noncore/apps/opie-write/qrichtext.cpp | |||
@@ -144,140 +144,149 @@ QTextCursor *QTextCommandHistory::redo( QTextCursor *c ) | |||
144 | } | 144 | } |
145 | } | 145 | } |
146 | return 0; | 146 | return 0; |
147 | } | 147 | } |
148 | 148 | ||
149 | bool QTextCommandHistory::isUndoAvailable() | 149 | bool QTextCommandHistory::isUndoAvailable() |
150 | { | 150 | { |
151 | return current > -1; | 151 | return current > -1; |
152 | } | 152 | } |
153 | 153 | ||
154 | bool QTextCommandHistory::isRedoAvailable() | 154 | bool QTextCommandHistory::isRedoAvailable() |
155 | { | 155 | { |
156 | return current > -1 && current < (int)history.count() - 1 || current == -1 && history.count() > 0; | 156 | return current > -1 && current < (int)history.count() - 1 || current == -1 && history.count() > 0; |
157 | } | 157 | } |
158 | 158 | ||
159 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 159 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
160 | 160 | ||
161 | QTextDeleteCommand::QTextDeleteCommand( QTextDocument *d, int i, int idx, const QMemArray<QTextStringChar> &str, | 161 | QTextDeleteCommand::QTextDeleteCommand( QTextDocument *d, int i, int idx, const QMemArray<QTextStringChar> &str, |
162 | const QByteArray& oldStyleInfo ) | 162 | const QByteArray& oldStyleInfo ) |
163 | : QTextCommand( d ), id( i ), index( idx ), parag( 0 ), text( str ), styleInformation( oldStyleInfo ) | 163 | : QTextCommand( d ), id( i ), index( idx ), parag( 0 ), text( str ), styleInformation( oldStyleInfo ) |
164 | { | 164 | { |
165 | for ( int j = 0; j < (int)text.size(); ++j ) { | 165 | for ( int j = 0; j < (int)text.size(); ++j ) { |
166 | if ( text[ j ].format() ) | 166 | if ( text[ j ].format() ) |
167 | text[ j ].format()->addRef(); | 167 | text[ j ].format()->addRef(); |
168 | } | 168 | } |
169 | } | 169 | } |
170 | 170 | ||
171 | QTextDeleteCommand::QTextDeleteCommand( QTextParagraph *p, int idx, const QMemArray<QTextStringChar> &str ) | 171 | QTextDeleteCommand::QTextDeleteCommand( QTextParagraph *p, int idx, const QMemArray<QTextStringChar> &str ) |
172 | : QTextCommand( 0 ), id( -1 ), index( idx ), parag( p ), text( str ) | 172 | : QTextCommand( 0 ), id( -1 ), index( idx ), parag( p ), text( str ) |
173 | { | 173 | { |
174 | for ( int i = 0; i < (int)text.size(); ++i ) { | 174 | for ( int i = 0; i < (int)text.size(); ++i ) { |
175 | if ( text[ i ].format() ) | 175 | if ( text[ i ].format() ) |
176 | text[ i ].format()->addRef(); | 176 | text[ i ].format()->addRef(); |
177 | } | 177 | } |
178 | } | 178 | } |
179 | 179 | ||
180 | QTextDeleteCommand::~QTextDeleteCommand() | 180 | QTextDeleteCommand::~QTextDeleteCommand() |
181 | { | 181 | { |
182 | for ( int i = 0; i < (int)text.size(); ++i ) { | 182 | for ( int i = 0; i < (int)text.size(); ++i ) { |
183 | if ( text[ i ].format() ) | 183 | if ( text[ i ].format() ) |
184 | text[ i ].format()->removeRef(); | 184 | text[ i ].format()->removeRef(); |
185 | } | 185 | } |
186 | text.resize( 0 ); | 186 | text.resize( 0 ); |
187 | } | 187 | } |
188 | 188 | ||
189 | QTextCursor *QTextDeleteCommand::execute( QTextCursor *c ) | 189 | QTextCursor *QTextDeleteCommand::execute( QTextCursor *c ) |
190 | { | 190 | { |
191 | QTextParagraph *s = doc ? doc->paragAt( id ) : parag; | 191 | QTextParagraph *s = doc ? doc->paragAt( id ) : parag; |
192 | if ( !s ) { | 192 | if ( !s && doc ) { |
193 | owarn << "can't locate parag at " << id << ", last parag: " << doc->lastParagraph()->paragId() << "" << oendl; | 193 | owarn << "can't locate parag at " << id << ", last parag: " << doc->lastParagraph()->paragId() << "" << oendl; |
194 | return 0; | 194 | return 0; |
195 | } else if ( !doc ) { | ||
196 | owarn << "No valid doc" << oendl; | ||
197 | return 0; | ||
195 | } | 198 | } |
196 | 199 | ||
197 | cursor.setParagraph( s ); | 200 | cursor.setParagraph( s ); |
198 | cursor.setIndex( index ); | 201 | cursor.setIndex( index ); |
199 | int len = text.size(); | 202 | int len = text.size(); |
200 | if ( c ) | 203 | if ( c ) |
201 | *c = cursor; | 204 | *c = cursor; |
202 | if ( doc ) { | 205 | if ( doc ) { |
203 | doc->setSelectionStart( QTextDocument::Temp, cursor ); | 206 | doc->setSelectionStart( QTextDocument::Temp, cursor ); |
204 | for ( int i = 0; i < len; ++i ) | 207 | for ( int i = 0; i < len; ++i ) |
205 | cursor.gotoNextLetter(); | 208 | cursor.gotoNextLetter(); |
206 | doc->setSelectionEnd( QTextDocument::Temp, cursor ); | 209 | doc->setSelectionEnd( QTextDocument::Temp, cursor ); |
207 | doc->removeSelectedText( QTextDocument::Temp, &cursor ); | 210 | doc->removeSelectedText( QTextDocument::Temp, &cursor ); |
208 | if ( c ) | 211 | if ( c ) |
209 | *c = cursor; | 212 | *c = cursor; |
210 | } else { | 213 | } else { |
211 | s->remove( index, len ); | 214 | s->remove( index, len ); |
212 | } | 215 | } |
213 | 216 | ||
214 | return c; | 217 | return c; |
215 | } | 218 | } |
216 | 219 | ||
217 | QTextCursor *QTextDeleteCommand::unexecute( QTextCursor *c ) | 220 | QTextCursor *QTextDeleteCommand::unexecute( QTextCursor *c ) |
218 | { | 221 | { |
219 | QTextParagraph *s = doc ? doc->paragAt( id ) : parag; | 222 | QTextParagraph *s = doc ? doc->paragAt( id ) : parag; |
220 | if ( !s ) { | 223 | if ( !s && doc ) { |
221 | owarn << "can't locate parag at " << id << ", last parag: " << doc->lastParagraph()->paragId() << "" << oendl; | 224 | owarn << "can't locate parag at " << id << ", last parag: " << doc->lastParagraph()->paragId() << "" << oendl; |
222 | return 0; | 225 | return 0; |
226 | } else if ( !doc ) { | ||
227 | owarn << "No valid doc" << oendl; | ||
228 | return 0; | ||
223 | } | 229 | } |
224 | 230 | ||
225 | cursor.setParagraph( s ); | 231 | cursor.setParagraph( s ); |
226 | cursor.setIndex( index ); | 232 | cursor.setIndex( index ); |
227 | QString str = QTextString::toString( text ); | 233 | QString str = QTextString::toString( text ); |
228 | cursor.insert( str, TRUE, &text ); | 234 | cursor.insert( str, TRUE, &text ); |
229 | cursor.setParagraph( s ); | 235 | cursor.setParagraph( s ); |
230 | cursor.setIndex( index ); | 236 | cursor.setIndex( index ); |
231 | if ( c ) { | 237 | if ( c ) { |
232 | c->setParagraph( s ); | 238 | c->setParagraph( s ); |
233 | c->setIndex( index ); | 239 | c->setIndex( index ); |
234 | for ( int i = 0; i < (int)text.size(); ++i ) | 240 | for ( int i = 0; i < (int)text.size(); ++i ) |
235 | c->gotoNextLetter(); | 241 | c->gotoNextLetter(); |
242 | } else { | ||
243 | owarn << "No valid cursor" << oendl; | ||
244 | return 0; | ||
236 | } | 245 | } |
237 | 246 | ||
238 | if ( !styleInformation.isEmpty() ) { | 247 | if ( !styleInformation.isEmpty() ) { |
239 | QDataStream styleStream( styleInformation, IO_ReadOnly ); | 248 | QDataStream styleStream( styleInformation, IO_ReadOnly ); |
240 | int num; | 249 | int num; |
241 | styleStream >> num; | 250 | styleStream >> num; |
242 | QTextParagraph *p = s; | 251 | QTextParagraph *p = s; |
243 | while ( num-- && p ) { | 252 | while ( num-- && p ) { |
244 | p->readStyleInformation( styleStream ); | 253 | p->readStyleInformation( styleStream ); |
245 | p = p->next(); | 254 | p = p->next(); |
246 | } | 255 | } |
247 | } | 256 | } |
248 | s = cursor.paragraph(); | 257 | s = cursor.paragraph(); |
249 | while ( s ) { | 258 | while ( s ) { |
250 | s->format(); | 259 | s->format(); |
251 | s->setChanged( TRUE ); | 260 | s->setChanged( TRUE ); |
252 | if ( s == c->paragraph() ) | 261 | if ( s == c->paragraph() ) |
253 | break; | 262 | break; |
254 | s = s->next(); | 263 | s = s->next(); |
255 | } | 264 | } |
256 | 265 | ||
257 | return &cursor; | 266 | return &cursor; |
258 | } | 267 | } |
259 | 268 | ||
260 | QTextFormatCommand::QTextFormatCommand( QTextDocument *d, int sid, int sidx, int eid, int eidx, | 269 | QTextFormatCommand::QTextFormatCommand( QTextDocument *d, int sid, int sidx, int eid, int eidx, |
261 | const QMemArray<QTextStringChar> &old, QTextFormat *f, int fl ) | 270 | const QMemArray<QTextStringChar> &old, QTextFormat *f, int fl ) |
262 | : QTextCommand( d ), startId( sid ), startIndex( sidx ), endId( eid ), endIndex( eidx ), format( f ), oldFormats( old ), flags( fl ) | 271 | : QTextCommand( d ), startId( sid ), startIndex( sidx ), endId( eid ), endIndex( eidx ), format( f ), oldFormats( old ), flags( fl ) |
263 | { | 272 | { |
264 | format = d->formatCollection()->format( f ); | 273 | format = d->formatCollection()->format( f ); |
265 | for ( int j = 0; j < (int)oldFormats.size(); ++j ) { | 274 | for ( int j = 0; j < (int)oldFormats.size(); ++j ) { |
266 | if ( oldFormats[ j ].format() ) | 275 | if ( oldFormats[ j ].format() ) |
267 | oldFormats[ j ].format()->addRef(); | 276 | oldFormats[ j ].format()->addRef(); |
268 | } | 277 | } |
269 | } | 278 | } |
270 | 279 | ||
271 | QTextFormatCommand::~QTextFormatCommand() | 280 | QTextFormatCommand::~QTextFormatCommand() |
272 | { | 281 | { |
273 | format->removeRef(); | 282 | format->removeRef(); |
274 | for ( int j = 0; j < (int)oldFormats.size(); ++j ) { | 283 | for ( int j = 0; j < (int)oldFormats.size(); ++j ) { |
275 | if ( oldFormats[ j ].format() ) | 284 | if ( oldFormats[ j ].format() ) |
276 | oldFormats[ j ].format()->removeRef(); | 285 | oldFormats[ j ].format()->removeRef(); |
277 | } | 286 | } |
278 | } | 287 | } |
279 | 288 | ||
280 | QTextCursor *QTextFormatCommand::execute( QTextCursor *c ) | 289 | QTextCursor *QTextFormatCommand::execute( QTextCursor *c ) |
281 | { | 290 | { |
282 | QTextParagraph *sp = doc->paragAt( startId ); | 291 | QTextParagraph *sp = doc->paragAt( startId ); |
283 | QTextParagraph *ep = doc->paragAt( endId ); | 292 | QTextParagraph *ep = doc->paragAt( endId ); |
@@ -1347,114 +1356,125 @@ void QTextDocument::setPlainText( const QString &text ) | |||
1347 | } | 1356 | } |
1348 | if ( !lParag ) | 1357 | if ( !lParag ) |
1349 | lParag = fParag = createParagraph( this, 0, 0 ); | 1358 | lParag = fParag = createParagraph( this, 0, 0 ); |
1350 | } | 1359 | } |
1351 | 1360 | ||
1352 | struct Q_EXPORT QTextDocumentTag { | 1361 | struct Q_EXPORT QTextDocumentTag { |
1353 | QTextDocumentTag(){} | 1362 | QTextDocumentTag(){} |
1354 | QTextDocumentTag( const QString&n, const QStyleSheetItem* s, const QTextFormat& f ) | 1363 | QTextDocumentTag( const QString&n, const QStyleSheetItem* s, const QTextFormat& f ) |
1355 | :name(n),style(s), format(f), alignment(Qt3::AlignAuto), direction(QChar::DirON),liststyle(QStyleSheetItem::ListDisc) { | 1364 | :name(n),style(s), format(f), alignment(Qt3::AlignAuto), direction(QChar::DirON),liststyle(QStyleSheetItem::ListDisc) { |
1356 | wsm = QStyleSheetItem::WhiteSpaceNormal; | 1365 | wsm = QStyleSheetItem::WhiteSpaceNormal; |
1357 | } | 1366 | } |
1358 | QString name; | 1367 | QString name; |
1359 | const QStyleSheetItem* style; | 1368 | const QStyleSheetItem* style; |
1360 | QString anchorHref; | 1369 | QString anchorHref; |
1361 | QStyleSheetItem::WhiteSpaceMode wsm; | 1370 | QStyleSheetItem::WhiteSpaceMode wsm; |
1362 | QTextFormat format; | 1371 | QTextFormat format; |
1363 | int alignment : 16; | 1372 | int alignment : 16; |
1364 | int direction : 5; | 1373 | int direction : 5; |
1365 | QStyleSheetItem::ListStyle liststyle; | 1374 | QStyleSheetItem::ListStyle liststyle; |
1366 | 1375 | ||
1367 | QTextDocumentTag( const QTextDocumentTag& t ) { | 1376 | QTextDocumentTag( const QTextDocumentTag& t ) { |
1368 | name = t.name; | 1377 | name = t.name; |
1369 | style = t.style; | 1378 | style = t.style; |
1370 | anchorHref = t.anchorHref; | 1379 | anchorHref = t.anchorHref; |
1371 | wsm = t.wsm; | 1380 | wsm = t.wsm; |
1372 | format = t.format; | 1381 | format = t.format; |
1373 | alignment = t.alignment; | 1382 | alignment = t.alignment; |
1374 | direction = t.direction; | 1383 | direction = t.direction; |
1375 | liststyle = t.liststyle; | 1384 | liststyle = t.liststyle; |
1376 | } | 1385 | } |
1377 | QTextDocumentTag& operator=(const QTextDocumentTag& t) { | 1386 | QTextDocumentTag& operator=(const QTextDocumentTag& t) { |
1378 | name = t.name; | 1387 | name = t.name; |
1379 | style = t.style; | 1388 | style = t.style; |
1380 | anchorHref = t.anchorHref; | 1389 | anchorHref = t.anchorHref; |
1381 | wsm = t.wsm; | 1390 | wsm = t.wsm; |
1382 | format = t.format; | 1391 | format = t.format; |
1383 | alignment = t.alignment; | 1392 | alignment = t.alignment; |
1384 | direction = t.direction; | 1393 | direction = t.direction; |
1385 | liststyle = t.liststyle; | 1394 | liststyle = t.liststyle; |
1386 | return *this; | 1395 | return *this; |
1387 | } | 1396 | } |
1388 | 1397 | ||
1389 | #if defined(Q_FULL_TEMPLATE_INSTANTIATION) | 1398 | #if defined(Q_FULL_TEMPLATE_INSTANTIATION) |
1390 | bool operator==( const QTextDocumentTag& ) const { return FALSE; } | 1399 | bool operator==( const QTextDocumentTag& ) const { return FALSE; } |
1391 | #endif | 1400 | #endif |
1392 | }; | 1401 | }; |
1393 | 1402 | ||
1394 | 1403 | ||
1395 | #define NEWPAR do{ if ( !hasNewPar) { \ | 1404 | #define NEWPAR do { \ |
1396 | if ( !textEditMode && curpar && curpar->length()>1 && curpar->at( curpar->length()-2)->c == QChar_linesep ) \ | 1405 | if ( !hasNewPar) { \ |
1397 | curpar->remove( curpar->length()-2, 1 ); \ | 1406 | if ( !curpar ) { \ |
1398 | curpar = createParagraph( this, curpar, curpar->next() ); styles.append( vec ); vec = 0;} \ | 1407 | owarn << "no current paragraph" << oendl; \ |
1399 | hasNewPar = TRUE; \ | 1408 | return; \ |
1400 | curpar->rtext = TRUE; \ | 1409 | } \ |
1401 | curpar->align = curtag.alignment; \ | 1410 | if ( !textEditMode && curpar && curpar->length()>1 && curpar->at( curpar->length()-2)->c == QChar_linesep ) \ |
1402 | curpar->lstyle = curtag.liststyle; \ | 1411 | curpar->remove( curpar->length()-2, 1 ); \ |
1403 | curpar->litem = ( curtag.style->displayMode() == QStyleSheetItem::DisplayListItem ); \ | 1412 | curpar = createParagraph( this, curpar, curpar->next() ); styles.append( vec ); \ |
1404 | curpar->str->setDirection( (QChar::Direction)curtag.direction ); \ | 1413 | if ( !curpar ) { \ |
1405 | space = TRUE; \ | 1414 | owarn << "failed in creating a new paragraph" << oendl; \ |
1406 | delete vec; vec = new QPtrVector<QStyleSheetItem>( (uint)tags.count() + 1); \ | 1415 | return; \ |
1407 | int i = 0; \ | 1416 | } \ |
1408 | for ( QValueStack<QTextDocumentTag>::Iterator it = tags.begin(); it != tags.end(); ++it ) \ | 1417 | vec = 0; \ |
1409 | vec->insert( i++, (*it).style ); \ | 1418 | } \ |
1410 | vec->insert( i, curtag.style ); \ | 1419 | hasNewPar = TRUE; \ |
1411 | }while(FALSE) | 1420 | curpar->rtext = TRUE; \ |
1412 | 1421 | curpar->align = curtag.alignment; \ | |
1422 | curpar->lstyle = curtag.liststyle; \ | ||
1423 | curpar->litem = ( curtag.style->displayMode() == QStyleSheetItem::DisplayListItem ); \ | ||
1424 | curpar->str->setDirection( (QChar::Direction)curtag.direction ); \ | ||
1425 | space = TRUE; \ | ||
1426 | delete vec; \ | ||
1427 | vec = new QPtrVector<QStyleSheetItem>( (uint)tags.count() + 1); \ | ||
1428 | int i = 0; \ | ||
1429 | for ( QValueStack<QTextDocumentTag>::Iterator it = tags.begin(); it != tags.end(); ++it ) \ | ||
1430 | vec->insert( i++, (*it).style ); \ | ||
1431 | vec->insert( i, curtag.style ); \ | ||
1432 | } while ( FALSE ) | ||
1413 | 1433 | ||
1414 | void QTextDocument::setRichText( const QString &text, const QString &context ) | 1434 | void QTextDocument::setRichText( const QString &text, const QString &context ) |
1415 | { | 1435 | { |
1416 | if ( !context.isEmpty() ) | 1436 | if ( !context.isEmpty() ) |
1417 | setContext( context ); | 1437 | setContext( context ); |
1418 | clear(); | 1438 | clear(); |
1419 | fParag = lParag = createParagraph( this ); | 1439 | fParag = lParag = createParagraph( this ); |
1420 | oTextValid = TRUE; | 1440 | oTextValid = TRUE; |
1421 | oText = text; | 1441 | oText = text; |
1422 | setRichTextInternal( text ); | 1442 | setRichTextInternal( text ); |
1423 | fParag->rtext = TRUE; | 1443 | fParag->rtext = TRUE; |
1424 | } | 1444 | } |
1425 | 1445 | ||
1426 | void QTextDocument::setRichTextInternal( const QString &text, QTextCursor* cursor ) | 1446 | void QTextDocument::setRichTextInternal( const QString &text, QTextCursor* cursor ) |
1427 | { | 1447 | { |
1428 | QTextParagraph* curpar = lParag; | 1448 | QTextParagraph* curpar = lParag; |
1429 | int pos = 0; | 1449 | int pos = 0; |
1430 | QValueStack<QTextDocumentTag> tags; | 1450 | QValueStack<QTextDocumentTag> tags; |
1431 | QTextDocumentTag initag( "", sheet_->item(""), *formatCollection()->defaultFormat() ); | 1451 | QTextDocumentTag initag( "", sheet_->item(""), *formatCollection()->defaultFormat() ); |
1432 | QTextDocumentTag curtag = initag; | 1452 | QTextDocumentTag curtag = initag; |
1433 | bool space = TRUE; | 1453 | bool space = TRUE; |
1434 | bool canMergeLi = FALSE; | 1454 | bool canMergeLi = FALSE; |
1435 | 1455 | ||
1436 | bool textEditMode = FALSE; | 1456 | bool textEditMode = FALSE; |
1437 | 1457 | ||
1438 | const QChar* doc = text.unicode(); | 1458 | const QChar* doc = text.unicode(); |
1439 | int length = text.length(); | 1459 | int length = text.length(); |
1440 | bool hasNewPar = curpar->length() <= 1; | 1460 | bool hasNewPar = curpar->length() <= 1; |
1441 | QString anchorName; | 1461 | QString anchorName; |
1442 | 1462 | ||
1443 | // style sheet handling for margin and line spacing calculation below | 1463 | // style sheet handling for margin and line spacing calculation below |
1444 | QTextParagraph* stylesPar = curpar; | 1464 | QTextParagraph* stylesPar = curpar; |
1445 | QPtrVector<QStyleSheetItem>* vec = 0; | 1465 | QPtrVector<QStyleSheetItem>* vec = 0; |
1446 | QPtrList< QPtrVector<QStyleSheetItem> > styles; | 1466 | QPtrList< QPtrVector<QStyleSheetItem> > styles; |
1447 | styles.setAutoDelete( TRUE ); | 1467 | styles.setAutoDelete( TRUE ); |
1448 | 1468 | ||
1449 | if ( cursor ) { | 1469 | if ( cursor ) { |
1450 | cursor->splitAndInsertEmptyParagraph(); | 1470 | cursor->splitAndInsertEmptyParagraph(); |
1451 | QTextCursor tmp = *cursor; | 1471 | QTextCursor tmp = *cursor; |
1452 | tmp.gotoPreviousLetter(); | 1472 | tmp.gotoPreviousLetter(); |
1453 | stylesPar = curpar = tmp.paragraph(); | 1473 | stylesPar = curpar = tmp.paragraph(); |
1454 | hasNewPar = TRUE; | 1474 | hasNewPar = TRUE; |
1455 | textEditMode = TRUE; | 1475 | textEditMode = TRUE; |
1456 | } else { | 1476 | } else { |
1457 | NEWPAR; | 1477 | NEWPAR; |
1458 | } | 1478 | } |
1459 | 1479 | ||
1460 | // set rtext spacing to FALSE for the initial paragraph. | 1480 | // set rtext spacing to FALSE for the initial paragraph. |
@@ -1850,98 +1870,101 @@ void QTextDocument::setRichTextInternal( const QString &text, QTextCursor* curso | |||
1850 | f->ref += s.length() -1; // that what friends are for... | 1870 | f->ref += s.length() -1; // that what friends are for... |
1851 | if ( !curtag.anchorHref.isEmpty() ) { | 1871 | if ( !curtag.anchorHref.isEmpty() ) { |
1852 | for ( int i = 0; i < int(s.length()); i++ ) | 1872 | for ( int i = 0; i < int(s.length()); i++ ) |
1853 | curpar->at(index + i)->setAnchor( QString::null, curtag.anchorHref ); | 1873 | curpar->at(index + i)->setAnchor( QString::null, curtag.anchorHref ); |
1854 | } | 1874 | } |
1855 | if ( !anchorName.isEmpty() ) { | 1875 | if ( !anchorName.isEmpty() ) { |
1856 | curpar->at(index)->setAnchor( anchorName, curpar->at(index)->anchorHref() ); | 1876 | curpar->at(index)->setAnchor( anchorName, curpar->at(index)->anchorHref() ); |
1857 | anchorName = QString::null; | 1877 | anchorName = QString::null; |
1858 | } | 1878 | } |
1859 | } | 1879 | } |
1860 | } | 1880 | } |
1861 | } | 1881 | } |
1862 | if ( hasNewPar && curpar != fParag && !cursor ) { | 1882 | if ( hasNewPar && curpar != fParag && !cursor ) { |
1863 | // cleanup unused last paragraphs | 1883 | // cleanup unused last paragraphs |
1864 | curpar = curpar->p; | 1884 | curpar = curpar->p; |
1865 | delete curpar->n; | 1885 | delete curpar->n; |
1866 | } | 1886 | } |
1867 | if ( !anchorName.isEmpty() ) { | 1887 | if ( !anchorName.isEmpty() ) { |
1868 | curpar->at(curpar->length() - 1)->setAnchor( anchorName, curpar->at( curpar->length() - 1 )->anchorHref() ); | 1888 | curpar->at(curpar->length() - 1)->setAnchor( anchorName, curpar->at( curpar->length() - 1 )->anchorHref() ); |
1869 | anchorName = QString::null; | 1889 | anchorName = QString::null; |
1870 | } | 1890 | } |
1871 | 1891 | ||
1872 | 1892 | ||
1873 | setRichTextMarginsInternal( styles, stylesPar ); | 1893 | setRichTextMarginsInternal( styles, stylesPar ); |
1874 | 1894 | ||
1875 | if ( cursor ) { | 1895 | if ( cursor ) { |
1876 | cursor->gotoPreviousLetter(); | 1896 | cursor->gotoPreviousLetter(); |
1877 | cursor->remove(); | 1897 | cursor->remove(); |
1878 | } | 1898 | } |
1879 | 1899 | ||
1880 | } | 1900 | } |
1881 | 1901 | ||
1882 | void QTextDocument::setRichTextMarginsInternal( QPtrList< QPtrVector<QStyleSheetItem> >& styles, QTextParagraph* stylesPar ) | 1902 | void QTextDocument::setRichTextMarginsInternal( QPtrList< QPtrVector<QStyleSheetItem> >& styles, QTextParagraph* stylesPar ) |
1883 | { | 1903 | { |
1884 | // margin and line spacing calculation | 1904 | // margin and line spacing calculation |
1885 | QPtrVector<QStyleSheetItem>* prevStyle = 0; | 1905 | QPtrVector<QStyleSheetItem>* prevStyle = 0; |
1886 | QPtrVector<QStyleSheetItem>* curStyle = styles.first(); | 1906 | QPtrVector<QStyleSheetItem>* curStyle = styles.first(); |
1887 | QPtrVector<QStyleSheetItem>* nextStyle = styles.next(); | 1907 | QPtrVector<QStyleSheetItem>* nextStyle = styles.next(); |
1888 | while ( stylesPar ) { | 1908 | while ( stylesPar ) { |
1889 | if ( !curStyle ) { | 1909 | if ( !curStyle ) { |
1890 | stylesPar = stylesPar->next(); | 1910 | stylesPar = stylesPar->next(); |
1891 | prevStyle = curStyle; | 1911 | prevStyle = curStyle; |
1892 | curStyle = nextStyle; | 1912 | curStyle = nextStyle; |
1893 | nextStyle = styles.next(); | 1913 | nextStyle = styles.next(); |
1894 | continue; | 1914 | continue; |
1895 | } | 1915 | } |
1896 | 1916 | ||
1897 | int i, mar; | 1917 | int i, mar; |
1898 | QStyleSheetItem* mainStyle = curStyle->size() ? (*curStyle)[curStyle->size()-1] : 0; | 1918 | QStyleSheetItem* mainStyle = (*curStyle)[curStyle->size()-1]; |
1899 | if ( mainStyle && mainStyle->displayMode() == QStyleSheetItem::DisplayListItem ) | 1919 | if ( !mainStyle ) |
1920 | return; | ||
1921 | |||
1922 | if ( mainStyle->displayMode() == QStyleSheetItem::DisplayListItem ) | ||
1900 | stylesPar->setListItem( TRUE ); | 1923 | stylesPar->setListItem( TRUE ); |
1901 | int numLists = 0; | 1924 | int numLists = 0; |
1902 | for ( i = 0; i < (int)curStyle->size(); ++i ) { | 1925 | for ( i = 0; i < (int)curStyle->size(); ++i ) { |
1903 | if ( (*curStyle)[ i ]->displayMode() == QStyleSheetItem::DisplayBlock | 1926 | if ( (*curStyle)[ i ]->displayMode() == QStyleSheetItem::DisplayBlock |
1904 | && int((*curStyle)[ i ]->listStyle()) != QStyleSheetItem::Undefined ) | 1927 | && int((*curStyle)[ i ]->listStyle()) != QStyleSheetItem::Undefined ) |
1905 | numLists++; | 1928 | numLists++; |
1906 | } | 1929 | } |
1907 | stylesPar->ldepth = numLists; | 1930 | stylesPar->ldepth = numLists; |
1908 | if ( stylesPar->next() && nextStyle ) { | 1931 | if ( stylesPar->next() && nextStyle ) { |
1909 | // also set the depth of the next paragraph, required for the margin calculation | 1932 | // also set the depth of the next paragraph, required for the margin calculation |
1910 | numLists = 0; | 1933 | numLists = 0; |
1911 | for ( i = 0; i < (int)nextStyle->size(); ++i ) { | 1934 | for ( i = 0; i < (int)nextStyle->size(); ++i ) { |
1912 | if ( (*nextStyle)[ i ]->displayMode() == QStyleSheetItem::DisplayBlock | 1935 | if ( (*nextStyle)[ i ]->displayMode() == QStyleSheetItem::DisplayBlock |
1913 | && int((*nextStyle)[ i ]->listStyle()) != QStyleSheetItem::Undefined ) | 1936 | && int((*nextStyle)[ i ]->listStyle()) != QStyleSheetItem::Undefined ) |
1914 | numLists++; | 1937 | numLists++; |
1915 | } | 1938 | } |
1916 | stylesPar->next()->ldepth = numLists; | 1939 | stylesPar->next()->ldepth = numLists; |
1917 | } | 1940 | } |
1918 | 1941 | ||
1919 | // do the top margin | 1942 | // do the top margin |
1920 | QStyleSheetItem* item = mainStyle; | 1943 | QStyleSheetItem* item = mainStyle; |
1921 | int m; | 1944 | int m; |
1922 | if (stylesPar->utm > 0 ) { | 1945 | if (stylesPar->utm > 0 ) { |
1923 | m = stylesPar->utm-1; | 1946 | m = stylesPar->utm-1; |
1924 | stylesPar->utm = 0; | 1947 | stylesPar->utm = 0; |
1925 | } else { | 1948 | } else { |
1926 | m = QMAX(0, item->margin( QStyleSheetItem::MarginTop ) ); | 1949 | m = QMAX(0, item->margin( QStyleSheetItem::MarginTop ) ); |
1927 | if ( item->displayMode() == QStyleSheetItem::DisplayListItem | 1950 | if ( item->displayMode() == QStyleSheetItem::DisplayListItem |
1928 | && stylesPar->ldepth ) | 1951 | && stylesPar->ldepth ) |
1929 | m /= stylesPar->ldepth; | 1952 | m /= stylesPar->ldepth; |
1930 | } | 1953 | } |
1931 | for ( i = (int)curStyle->size() - 2 ; i >= 0; --i ) { | 1954 | for ( i = (int)curStyle->size() - 2 ; i >= 0; --i ) { |
1932 | item = (*curStyle)[ i ]; | 1955 | item = (*curStyle)[ i ]; |
1933 | if ( prevStyle && i < (int) prevStyle->size() && | 1956 | if ( prevStyle && i < (int) prevStyle->size() && |
1934 | ( item->displayMode() == QStyleSheetItem::DisplayBlock && | 1957 | ( item->displayMode() == QStyleSheetItem::DisplayBlock && |
1935 | (*prevStyle)[ i ] == item ) ) | 1958 | (*prevStyle)[ i ] == item ) ) |
1936 | break; | 1959 | break; |
1937 | // emulate CSS2' standard 0 vertical margin for multiple ul or ol tags | 1960 | // emulate CSS2' standard 0 vertical margin for multiple ul or ol tags |
1938 | if ( int(item->listStyle()) != QStyleSheetItem::Undefined && | 1961 | if ( int(item->listStyle()) != QStyleSheetItem::Undefined && |
1939 | ( ( i> 0 && (*curStyle)[ i-1 ] == item ) || (*curStyle)[i+1] == item ) ) | 1962 | ( ( i> 0 && (*curStyle)[ i-1 ] == item ) || (*curStyle)[i+1] == item ) ) |
1940 | continue; | 1963 | continue; |
1941 | mar = QMAX( 0, item->margin( QStyleSheetItem::MarginTop ) ); | 1964 | mar = QMAX( 0, item->margin( QStyleSheetItem::MarginTop ) ); |
1942 | m = QMAX( m, mar ); | 1965 | m = QMAX( m, mar ); |
1943 | } | 1966 | } |
1944 | stylesPar->utm = m - stylesPar->topMargin(); | 1967 | stylesPar->utm = m - stylesPar->topMargin(); |
1945 | 1968 | ||
1946 | // do the bottom margin | 1969 | // do the bottom margin |
1947 | item = mainStyle; | 1970 | item = mainStyle; |
@@ -5296,97 +5319,97 @@ int QTextFormatterBreakWords::format( QTextDocument *doc, QTextParagraph *parag, | |||
5296 | QTextStringChar *firstChar = 0; | 5319 | QTextStringChar *firstChar = 0; |
5297 | QTextString *string = parag->string(); | 5320 | QTextString *string = parag->string(); |
5298 | int left = doc ? parag->leftMargin() + doc->leftMargin() : 0; | 5321 | int left = doc ? parag->leftMargin() + doc->leftMargin() : 0; |
5299 | int x = left + ( doc ? parag->firstLineMargin() : 0 ); | 5322 | int x = left + ( doc ? parag->firstLineMargin() : 0 ); |
5300 | int y = parag->prev() ? QMAX(parag->prev()->bottomMargin(),parag->topMargin()) / 2: 0; | 5323 | int y = parag->prev() ? QMAX(parag->prev()->bottomMargin(),parag->topMargin()) / 2: 0; |
5301 | int h = y; | 5324 | int h = y; |
5302 | int len = parag->length(); | 5325 | int len = parag->length(); |
5303 | if ( doc ) | 5326 | if ( doc ) |
5304 | x = doc->flow()->adjustLMargin( y + parag->rect().y(), parag->rect().height(), x, 0 ); | 5327 | x = doc->flow()->adjustLMargin( y + parag->rect().y(), parag->rect().height(), x, 0 ); |
5305 | int dw = parag->documentVisibleWidth() - ( doc ? ( left != x ? 0 : doc->rightMargin() ) : 0 ); | 5328 | int dw = parag->documentVisibleWidth() - ( doc ? ( left != x ? 0 : doc->rightMargin() ) : 0 ); |
5306 | 5329 | ||
5307 | int curLeft = x; | 5330 | int curLeft = x; |
5308 | int rm = parag->rightMargin(); | 5331 | int rm = parag->rightMargin(); |
5309 | int rdiff = doc ? doc->flow()->adjustRMargin( y + parag->rect().y(), parag->rect().height(), rm, 0 ) : 0; | 5332 | int rdiff = doc ? doc->flow()->adjustRMargin( y + parag->rect().y(), parag->rect().height(), rm, 0 ) : 0; |
5310 | int w = dw - rdiff; | 5333 | int w = dw - rdiff; |
5311 | bool fullWidth = TRUE; | 5334 | bool fullWidth = TRUE; |
5312 | int marg = left + rdiff; | 5335 | int marg = left + rdiff; |
5313 | int minw = 0; | 5336 | int minw = 0; |
5314 | int wused = 0; | 5337 | int wused = 0; |
5315 | int tminw = marg; | 5338 | int tminw = marg; |
5316 | int linespacing = doc ? parag->lineSpacing() : 0; | 5339 | int linespacing = doc ? parag->lineSpacing() : 0; |
5317 | bool wrapEnabled = isWrapEnabled( parag ); | 5340 | bool wrapEnabled = isWrapEnabled( parag ); |
5318 | 5341 | ||
5319 | start = 0; | 5342 | start = 0; |
5320 | if ( start == 0 ) | 5343 | if ( start == 0 ) |
5321 | c = ¶g->string()->at( 0 ); | 5344 | c = ¶g->string()->at( 0 ); |
5322 | 5345 | ||
5323 | int i = start; | 5346 | int i = start; |
5324 | QTextLineStart *lineStart = new QTextLineStart( y, y, 0 ); | 5347 | QTextLineStart *lineStart = new QTextLineStart( y, y, 0 ); |
5325 | insertLineStart( parag, 0, lineStart ); | 5348 | insertLineStart( parag, 0, lineStart ); |
5326 | int lastBreak = -1; | 5349 | int lastBreak = -1; |
5327 | int tmpBaseLine = 0, tmph = 0; | 5350 | int tmpBaseLine = 0, tmph = 0; |
5328 | bool lastWasNonInlineCustom = FALSE; | 5351 | bool lastWasNonInlineCustom = FALSE; |
5329 | 5352 | ||
5330 | int align = parag->alignment(); | 5353 | int align = parag->alignment(); |
5331 | if ( align == Qt3::AlignAuto && doc && doc->alignment() != Qt3::AlignAuto ) | 5354 | if ( align == Qt3::AlignAuto && doc && doc->alignment() != Qt3::AlignAuto ) |
5332 | align = doc->alignment(); | 5355 | align = doc->alignment(); |
5333 | 5356 | ||
5334 | align &= Qt3::AlignHorizontal_Mask; | 5357 | align &= Qt3::AlignHorizontal_Mask; |
5335 | 5358 | ||
5336 | QPainter *painter = QTextFormat::painter(); | 5359 | QPainter *painter = QTextFormat::painter(); |
5337 | int col = 0; | 5360 | int col = 0; |
5338 | int ww = 0; | 5361 | int ww = 0; |
5339 | QChar lastChr; | 5362 | QChar lastChr; |
5340 | for ( ; i < len; ++i, ++col ) { | 5363 | for ( ; i < len; ++i, ++col ) { |
5341 | if ( c ) | 5364 | if ( c ) |
5342 | lastChr = c->c; | 5365 | lastChr = c->c; |
5343 | // ### next line should not be needed | 5366 | // ### next line should not be needed |
5344 | if ( painter ) | 5367 | if ( c && painter ) |
5345 | c->format()->setPainter( painter ); | 5368 | c->format()->setPainter( painter ); |
5346 | c = &string->at( i ); | 5369 | c = &string->at( i ); |
5347 | c->rightToLeft = FALSE; | 5370 | c->rightToLeft = FALSE; |
5348 | if ( i > 0 && (x > curLeft || ww == 0) || lastWasNonInlineCustom ) { | 5371 | if ( i > 0 && (x > curLeft || ww == 0) || lastWasNonInlineCustom ) { |
5349 | c->lineStart = 0; | 5372 | c->lineStart = 0; |
5350 | } else { | 5373 | } else { |
5351 | c->lineStart = 1; | 5374 | c->lineStart = 1; |
5352 | firstChar = c; | 5375 | firstChar = c; |
5353 | } | 5376 | } |
5354 | 5377 | ||
5355 | if ( c->isCustom() && c->customItem()->placement() != QTextCustomItem::PlaceInline ) | 5378 | if ( c->isCustom() && c->customItem()->placement() != QTextCustomItem::PlaceInline ) |
5356 | lastWasNonInlineCustom = TRUE; | 5379 | lastWasNonInlineCustom = TRUE; |
5357 | else | 5380 | else |
5358 | lastWasNonInlineCustom = FALSE; | 5381 | lastWasNonInlineCustom = FALSE; |
5359 | 5382 | ||
5360 | if ( c->c.unicode() >= 32 || c->isCustom() ) { | 5383 | if ( c->c.unicode() >= 32 || c->isCustom() ) { |
5361 | ww = string->width( i ); | 5384 | ww = string->width( i ); |
5362 | } else if ( c->c == '\t' ) { | 5385 | } else if ( c->c == '\t' ) { |
5363 | int nx = parag->nextTab( i, x - left ) + left; | 5386 | int nx = parag->nextTab( i, x - left ) + left; |
5364 | if ( nx < x ) | 5387 | if ( nx < x ) |
5365 | ww = w - x; | 5388 | ww = w - x; |
5366 | else | 5389 | else |
5367 | ww = nx - x; | 5390 | ww = nx - x; |
5368 | } else { | 5391 | } else { |
5369 | ww = c->format()->width( ' ' ); | 5392 | ww = c->format()->width( ' ' ); |
5370 | } | 5393 | } |
5371 | 5394 | ||
5372 | // last character ("invisible" space) has no width | 5395 | // last character ("invisible" space) has no width |
5373 | if ( i == len - 1 ) | 5396 | if ( i == len - 1 ) |
5374 | ww = 0; | 5397 | ww = 0; |
5375 | 5398 | ||
5376 | QTextCustomItem* ci = c->customItem(); | 5399 | QTextCustomItem* ci = c->customItem(); |
5377 | if ( c->isCustom() && ci->ownLine() ) { | 5400 | if ( c->isCustom() && ci->ownLine() ) { |
5378 | x = doc ? doc->flow()->adjustLMargin( y + parag->rect().y(), parag->rect().height(), left, 4 ) : left; | 5401 | x = doc ? doc->flow()->adjustLMargin( y + parag->rect().y(), parag->rect().height(), left, 4 ) : left; |
5379 | w = dw - ( doc ? doc->flow()->adjustRMargin( y + parag->rect().y(), parag->rect().height(), rm, 4 ) : 0 ); | 5402 | w = dw - ( doc ? doc->flow()->adjustRMargin( y + parag->rect().y(), parag->rect().height(), rm, 4 ) : 0 ); |
5380 | QTextLineStart *lineStart2 = formatLine( parag, string, lineStart, firstChar, c-1, align, SPACE(w - x) ); | 5403 | QTextLineStart *lineStart2 = formatLine( parag, string, lineStart, firstChar, c-1, align, SPACE(w - x) ); |
5381 | ci->resize( w - x); | 5404 | ci->resize( w - x); |
5382 | if ( ci->width < w - x ) { | 5405 | if ( ci->width < w - x ) { |
5383 | if ( align & Qt::AlignHCenter ) | 5406 | if ( align & Qt::AlignHCenter ) |
5384 | x = ( w - ci->width ) / 2; | 5407 | x = ( w - ci->width ) / 2; |
5385 | else if ( align & Qt::AlignRight ) { | 5408 | else if ( align & Qt::AlignRight ) { |
5386 | x = w - ci->width; | 5409 | x = w - ci->width; |
5387 | } | 5410 | } |
5388 | } | 5411 | } |
5389 | c->x = x; | 5412 | c->x = x; |
5390 | curLeft = x; | 5413 | curLeft = x; |
5391 | if ( i == 0 || !isBreakable( string, i - 1 ) || string->at( i - 1 ).lineStart == 0 ) { | 5414 | if ( i == 0 || !isBreakable( string, i - 1 ) || string->at( i - 1 ).lineStart == 0 ) { |
5392 | y += QMAX( h, QMAX( tmph, linespacing ) ); | 5415 | y += QMAX( h, QMAX( tmph, linespacing ) ); |
diff --git a/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.cpp b/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.cpp index 9069c09..3fd877f 100644 --- a/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.cpp +++ b/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.cpp | |||
@@ -250,80 +250,83 @@ QString OTSDPAttribute::getURL() { | |||
250 | 250 | ||
251 | const OTSDPAttribute::int128_t & OTSDPAttribute::getInt() { | 251 | const OTSDPAttribute::int128_t & OTSDPAttribute::getInt() { |
252 | assert(type == INT); | 252 | assert(type == INT); |
253 | return *Value.intVal; | 253 | return *Value.intVal; |
254 | } | 254 | } |
255 | 255 | ||
256 | 256 | ||
257 | const OTSDPAttribute::uint128_t & OTSDPAttribute::getUInt() { | 257 | const OTSDPAttribute::uint128_t & OTSDPAttribute::getUInt() { |
258 | assert(type == UINT); | 258 | assert(type == UINT); |
259 | return *Value.uintVal; | 259 | return *Value.uintVal; |
260 | } | 260 | } |
261 | 261 | ||
262 | const OTUUID & OTSDPAttribute::getUUID() { | 262 | const OTUUID & OTSDPAttribute::getUUID() { |
263 | assert(type == UUID); | 263 | assert(type == UUID); |
264 | return *Value.uuidVal; | 264 | return *Value.uuidVal; |
265 | } | 265 | } |
266 | 266 | ||
267 | bool OTSDPAttribute::getBool() { | 267 | bool OTSDPAttribute::getBool() { |
268 | assert(type == BOOLEAN); | 268 | assert(type == BOOLEAN); |
269 | return Value.boolVal; | 269 | return Value.boolVal; |
270 | } | 270 | } |
271 | 271 | ||
272 | AttributeVector * OTSDPAttribute::getSequence() { | 272 | AttributeVector * OTSDPAttribute::getSequence() { |
273 | assert(type == SEQUENCE); | 273 | assert(type == SEQUENCE); |
274 | return Value.sequenceVal; | 274 | return Value.sequenceVal; |
275 | } | 275 | } |
276 | 276 | ||
277 | AttributeVector * OTSDPAttribute::getAlternative() { | 277 | AttributeVector * OTSDPAttribute::getAlternative() { |
278 | assert(type == ALTERNATIVE); | 278 | assert(type == ALTERNATIVE); |
279 | return Value.sequenceVal; | 279 | return Value.sequenceVal; |
280 | } | 280 | } |
281 | 281 | ||
282 | UUIDVector OTSDPAttribute::getAllUUIDs() { | 282 | UUIDVector OTSDPAttribute::getAllUUIDs() { |
283 | 283 | ||
284 | UUIDVector uuids; | 284 | UUIDVector uuids; |
285 | 285 | ||
286 | if (getType() == UUID) { | 286 | if (getType() == UUID) { |
287 | uuids.resize( uuids.size()+1 ); | 287 | uuids.resize( uuids.size()+1 ); |
288 | uuids[uuids.size()-1] = getUUID(); | 288 | uuids[uuids.size()-1] = getUUID(); |
289 | } else { | 289 | } else { |
290 | AttributeVector * subAttributes = 0 ; | 290 | AttributeVector * subAttributes = 0 ; |
291 | 291 | ||
292 | if (getType() == SEQUENCE) { | 292 | if (getType() == SEQUENCE) { |
293 | subAttributes = getSequence(); | 293 | subAttributes = getSequence(); |
294 | } else if (getType() == ALTERNATIVE) { | 294 | } else if (getType() == ALTERNATIVE) { |
295 | subAttributes = getAlternative(); | 295 | subAttributes = getAlternative(); |
296 | } | 296 | } |
297 | 297 | ||
298 | if (!subAttributes) | ||
299 | return 0; | ||
300 | |||
298 | int os; | 301 | int os; |
299 | for( unsigned int i = 0; i < subAttributes->count(); i++ ) { | 302 | for( unsigned int i = 0; i < subAttributes->count(); i++ ) { |
300 | UUIDVector subUUIDs = (*subAttributes)[i]->getAllUUIDs(); | 303 | UUIDVector subUUIDs = (*subAttributes)[i]->getAllUUIDs(); |
301 | 304 | ||
302 | os = uuids.size(); | 305 | os = uuids.size(); |
303 | uuids.resize( uuids.size()+subUUIDs.count() ); | 306 | uuids.resize( uuids.size()+subUUIDs.count() ); |
304 | 307 | ||
305 | for( unsigned int k = 0; k < subUUIDs.count(); k++ ) { | 308 | for( unsigned int k = 0; k < subUUIDs.count(); k++ ) { |
306 | uuids[os + k] = subUUIDs[k]; | 309 | uuids[os + k] = subUUIDs[k]; |
307 | } | 310 | } |
308 | } | 311 | } |
309 | } | 312 | } |
310 | return uuids; | 313 | return uuids; |
311 | } | 314 | } |
312 | 315 | ||
313 | static char * Attr2String[] = { | 316 | static char * Attr2String[] = { |
314 | "Invalid", | 317 | "Invalid", |
315 | "Nil", | 318 | "Nil", |
316 | "UInt", | 319 | "UInt", |
317 | "int", | 320 | "int", |
318 | "UUID", | 321 | "UUID", |
319 | "Boolean", | 322 | "Boolean", |
320 | "String", | 323 | "String", |
321 | "Sequence", | 324 | "Sequence", |
322 | "Alternative", | 325 | "Alternative", |
323 | "URL", | 326 | "URL", |
324 | "Unknown" | 327 | "Unknown" |
325 | }; | 328 | }; |
326 | 329 | ||
327 | const char * OTSDPAttribute::getTypeString() { | 330 | const char * OTSDPAttribute::getTypeString() { |
328 | return Attr2String[type]; | 331 | return Attr2String[type]; |
329 | } | 332 | } |
diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.cpp b/noncore/settings/packagemanager/oipkgconfigdlg.cpp index d014378..78a18f7 100644 --- a/noncore/settings/packagemanager/oipkgconfigdlg.cpp +++ b/noncore/settings/packagemanager/oipkgconfigdlg.cpp | |||
@@ -391,111 +391,113 @@ void OIpkgConfigDlg::initData() | |||
391 | { | 391 | { |
392 | OConfItem *config = configIt.current(); | 392 | OConfItem *config = configIt.current(); |
393 | 393 | ||
394 | // Add configuration item to the appropriate dialog controls | 394 | // Add configuration item to the appropriate dialog controls |
395 | if ( config ) | 395 | if ( config ) |
396 | { | 396 | { |
397 | switch ( config->type() ) | 397 | switch ( config->type() ) |
398 | { | 398 | { |
399 | case OConfItem::Source : m_serverList->insertItem( config->name() ); break; | 399 | case OConfItem::Source : m_serverList->insertItem( config->name() ); break; |
400 | case OConfItem::Destination : m_destList->insertItem( config->name() ); break; | 400 | case OConfItem::Destination : m_destList->insertItem( config->name() ); break; |
401 | case OConfItem::Option : | 401 | case OConfItem::Option : |
402 | { | 402 | { |
403 | if ( config->name() == "http_proxy" ) | 403 | if ( config->name() == "http_proxy" ) |
404 | { | 404 | { |
405 | m_proxyHttpServer->setText( config->value() ); | 405 | m_proxyHttpServer->setText( config->value() ); |
406 | m_proxyHttpActive->setChecked( config->active() ); | 406 | m_proxyHttpActive->setChecked( config->active() ); |
407 | } | 407 | } |
408 | else if ( config->name() == "ftp_proxy" ) | 408 | else if ( config->name() == "ftp_proxy" ) |
409 | { | 409 | { |
410 | m_proxyFtpServer->setText( config->value() ); | 410 | m_proxyFtpServer->setText( config->value() ); |
411 | m_proxyFtpActive->setChecked( config->active() ); | 411 | m_proxyFtpActive->setChecked( config->active() ); |
412 | } | 412 | } |
413 | else if ( config->name() == "proxy_username" ) | 413 | else if ( config->name() == "proxy_username" ) |
414 | { | 414 | { |
415 | m_proxyUsername->setText( config->value() ); | 415 | m_proxyUsername->setText( config->value() ); |
416 | } | 416 | } |
417 | else if ( config->name() == "proxy_password" ) | 417 | else if ( config->name() == "proxy_password" ) |
418 | { | 418 | { |
419 | m_proxyPassword->setText( config->value() ); | 419 | m_proxyPassword->setText( config->value() ); |
420 | } | 420 | } |
421 | } | 421 | } |
422 | break; | 422 | break; |
423 | case OConfItem::Other : | 423 | case OConfItem::Other : |
424 | { | 424 | { |
425 | if ( config->name() == "lists_dir" ) | 425 | if ( config->name() == "lists_dir" ) |
426 | m_optSourceLists->setText( config->value() ); | 426 | m_optSourceLists->setText( config->value() ); |
427 | else // TODO - use proper libipkg define | 427 | else // TODO - use proper libipkg define |
428 | m_optSourceLists->setText( "/usr/lib/ipkg/lists" ); | 428 | m_optSourceLists->setText( "/usr/lib/ipkg/lists" ); |
429 | } | 429 | } |
430 | break; | 430 | break; |
431 | default : break; | 431 | default : break; |
432 | }; | 432 | }; |
433 | } | 433 | } |
434 | } | 434 | } |
435 | } | 435 | } |
436 | } | 436 | } |
437 | 437 | ||
438 | // Get Ipkg execution options | 438 | // Get Ipkg execution options |
439 | int options = m_ipkg->ipkgExecOptions(); | 439 | int options = 0; |
440 | if ( m_ipkg ) | ||
441 | options = m_ipkg->ipkgExecOptions(); | ||
440 | if ( options & FORCE_DEPENDS ) | 442 | if ( options & FORCE_DEPENDS ) |
441 | m_optForceDepends->setChecked( true ); | 443 | m_optForceDepends->setChecked( true ); |
442 | if ( options & FORCE_REINSTALL ) | 444 | if ( options & FORCE_REINSTALL ) |
443 | m_optForceReinstall->setChecked( true ); | 445 | m_optForceReinstall->setChecked( true ); |
444 | if ( options & FORCE_REMOVE ) | 446 | if ( options & FORCE_REMOVE ) |
445 | m_optForceRemove->setChecked( true ); | 447 | m_optForceRemove->setChecked( true ); |
446 | if ( options & FORCE_OVERWRITE ) | 448 | if ( options & FORCE_OVERWRITE ) |
447 | m_optForceOverwrite->setChecked( true ); | 449 | m_optForceOverwrite->setChecked( true ); |
448 | if ( options & FORCE_RECURSIVE ) | 450 | if ( options & FORCE_RECURSIVE ) |
449 | m_optForceRecursive->setChecked( true ); | 451 | m_optForceRecursive->setChecked( true ); |
450 | if ( options & FORCE_VERBOSE_WGET ) | 452 | if ( options & FORCE_VERBOSE_WGET ) |
451 | m_optVerboseWget->setChecked( true ); | 453 | m_optVerboseWget->setChecked( true ); |
452 | 454 | ||
453 | m_optVerboseIpkg->setCurrentItem( m_ipkg->ipkgExecVerbosity() ); | 455 | m_optVerboseIpkg->setCurrentItem( ( m_ipkg ? m_ipkg->ipkgExecVerbosity() : 0 ) ); |
454 | } | 456 | } |
455 | 457 | ||
456 | void OIpkgConfigDlg::slotServerSelected( int index ) | 458 | void OIpkgConfigDlg::slotServerSelected( int index ) |
457 | { | 459 | { |
458 | m_serverCurrent = index; | 460 | m_serverCurrent = index; |
459 | 461 | ||
460 | // Enable Edit and Delete buttons | 462 | // Enable Edit and Delete buttons |
461 | m_serverEditBtn->setEnabled( true ); | 463 | m_serverEditBtn->setEnabled( true ); |
462 | m_serverDeleteBtn->setEnabled( true ); | 464 | m_serverDeleteBtn->setEnabled( true ); |
463 | } | 465 | } |
464 | 466 | ||
465 | void OIpkgConfigDlg::slotServerNew() | 467 | void OIpkgConfigDlg::slotServerNew() |
466 | { | 468 | { |
467 | OConfItem *server = new OConfItem( OConfItem::Source ); | 469 | OConfItem *server = new OConfItem( OConfItem::Source ); |
468 | 470 | ||
469 | OIpkgServerDlg dlg( server, this ); | 471 | OIpkgServerDlg dlg( server, this ); |
470 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) | 472 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) |
471 | { | 473 | { |
472 | // Add to configuration option list | 474 | // Add to configuration option list |
473 | m_configs->append( server ); | 475 | m_configs->append( server ); |
474 | m_configs->sort(); | 476 | m_configs->sort(); |
475 | 477 | ||
476 | // Add to server list | 478 | // Add to server list |
477 | m_serverList->insertItem( server->name() ); | 479 | m_serverList->insertItem( server->name() ); |
478 | m_serverList->setCurrentItem( m_serverList->count() ); | 480 | m_serverList->setCurrentItem( m_serverList->count() ); |
479 | } | 481 | } |
480 | else | 482 | else |
481 | delete server; | 483 | delete server; |
482 | } | 484 | } |
483 | 485 | ||
484 | void OIpkgConfigDlg::slotServerEdit() | 486 | void OIpkgConfigDlg::slotServerEdit() |
485 | { | 487 | { |
486 | // Find selected server in list | 488 | // Find selected server in list |
487 | OConfItem *server = m_ipkg->findConfItem( OConfItem::Source, m_serverList->currentText() ); | 489 | OConfItem *server = m_ipkg->findConfItem( OConfItem::Source, m_serverList->currentText() ); |
488 | 490 | ||
489 | // Edit server | 491 | // Edit server |
490 | if ( server ) | 492 | if ( server ) |
491 | { | 493 | { |
492 | QString origName = server->name(); | 494 | QString origName = server->name(); |
493 | OIpkgServerDlg dlg( server, this ); | 495 | OIpkgServerDlg dlg( server, this ); |
494 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) | 496 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) |
495 | { | 497 | { |
496 | // Check to see if name has changed, if so update the server list | 498 | // Check to see if name has changed, if so update the server list |
497 | if ( server->name() != origName ) | 499 | if ( server->name() != origName ) |
498 | m_serverList->changeItem( server->name(), m_serverCurrent ); | 500 | m_serverList->changeItem( server->name(), m_serverCurrent ); |
499 | } | 501 | } |
500 | } | 502 | } |
501 | } | 503 | } |