summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--configs/linux-arm-g++-sharedx1197
-rw-r--r--configs/linux-generic-g++-sharedx1194
-rw-r--r--core/pim/datebook/layoutmanager.cpp177
-rw-r--r--core/pim/datebook/layoutmanager.h78
-rw-r--r--docs/inputmethodinterface.doc49
-rw-r--r--examples/application/Example.pngbin1262 -> 0 bytes
-rw-r--r--examples/application/README2
-rw-r--r--examples/application/example.control11
-rw-r--r--examples/application/example.cpp28
-rw-r--r--examples/application/example.desktop6
-rw-r--r--examples/application/example.h17
-rw-r--r--examples/application/example.html15
-rw-r--r--examples/application/example.pro10
-rw-r--r--examples/application/examplebase.ui55
-rw-r--r--examples/application/index.html23
-rw-r--r--examples/application/main.cpp12
-rw-r--r--examples/qpepim-addressbook/abexample.desktop6
-rw-r--r--examples/qpepim-addressbook/abexample.pngbin1262 -> 0 bytes
-rw-r--r--examples/qpepim-addressbook/addressbookdumper.cpp65
-rw-r--r--examples/qpepim-addressbook/addressbookdumper.h39
-rw-r--r--examples/qpepim-addressbook/main.cpp47
-rw-r--r--examples/qpepim-addressbook/qpepim-abexample.control9
-rw-r--r--examples/qpepim-addressbook/qpepim-addressbook.pro8
-rw-r--r--inputmethods/handwriting/qimpenchar.cpp2
-rw-r--r--library/alarmserver.h3
-rw-r--r--library/applnk.h3
-rw-r--r--library/backend/categories.cpp146
-rw-r--r--library/backend/categories.h12
-rw-r--r--library/backend/contact.cpp107
-rw-r--r--library/backend/contact.h7
-rw-r--r--library/backend/event.h5
-rw-r--r--library/backend/recordfields.h46
-rw-r--r--library/backend/task.h4
-rw-r--r--library/backend/vobject.cpp9
-rw-r--r--library/backend/vobject_p.h3
-rw-r--r--library/categoryedit_p.cpp6
-rw-r--r--library/categoryselect.cpp185
-rw-r--r--library/categoryselect.h26
-rw-r--r--library/config.cpp13
-rw-r--r--library/custom-linux-sharp-g++.h147
-rw-r--r--library/datebookmonth.h1
-rw-r--r--library/fileselector.h32
-rw-r--r--library/finddialog.cpp4
-rw-r--r--library/finddialog.h11
-rw-r--r--library/mimetype.cpp19
-rw-r--r--library/mimetype.h5
-rw-r--r--library/network.cpp19
-rw-r--r--library/power.cpp2
-rw-r--r--library/qcopmessage_qws.h99
-rw-r--r--library/qpedecoration_qws.cpp9
-rw-r--r--noncore/games/go/gowidget.cpp15
-rw-r--r--noncore/games/minesweep/minefield.h30
-rw-r--r--noncore/games/minesweep/minesweep.cpp35
-rw-r--r--noncore/games/snake/interface.h2
-rw-r--r--noncore/games/snake/obstacle.cpp35
-rw-r--r--noncore/games/snake/obstacle.h4
-rw-r--r--noncore/games/solitaire/canvascard.cpp71
-rw-r--r--noncore/games/solitaire/canvasshapes.cpp52
-rw-r--r--noncore/games/solitaire/freecellcardgame.cpp11
-rw-r--r--noncore/games/solitaire/patiencecardgame.cpp49
-rw-r--r--noncore/games/solitaire/patiencecardgame.h7
-rw-r--r--noncore/games/wordgame/wordgame.cpp71
-rw-r--r--noncore/games/wordgame/wordgame.h6
-rw-r--r--noncore/multimedia/showimg/settingsdialog.cpp57
-rw-r--r--noncore/multimedia/showimg/settingsdialog.h42
-rw-r--r--noncore/multimedia/showimg/settingsdialogbase.ui149
-rw-r--r--pics/cards/circle.pngbin436 -> 0 bytes
-rw-r--r--pics/cards/cross.pngbin480 -> 0 bytes
-rw-r--r--pics/inline/today.pngbin486 -> 0 bytes
-rw-r--r--pics/slideshow.pngbin207 -> 0 bytes
70 files changed, 724 insertions, 1685 deletions
diff --git a/configs/linux-arm-g++-sharedx11 b/configs/linux-arm-g++-sharedx11
deleted file mode 100644
index b810b05..0000000
--- a/configs/linux-arm-g++-sharedx11
+++ b/dev/null
@@ -1,97 +0,0 @@
1# Compiling
2 INTERFACE_DECL_PATH = .
3 SYSCONF_CXX = arm-linux-g++
4 SYSCONF_CC = arm-linux-gcc
5 DASHCROSS = -arm
6
7# Set XROOT to the root directory of the arm X11 files for cross compiling
8XROOT=/scratch/src/xfree86.41/xbinaries
9# Compiling with support libraries
10 SYSCONF_CXXFLAGS_X11=
11 SYSCONF_CXXFLAGS_QT= -I$(QTDIR)/include
12 SYSCONF_CXXFLAGS_OPENGL= -I$(XROOT)/usr/X11R6/include
13
14# Compiling YACC output
15SYSCONF_CXXFLAGS_YACC = -Wno-unused -Wno-parentheses
16
17# Linking with support libraries
18 SYSCONF_RPATH_X11=
19 SYSCONF_RPATH_QT= -Wl,-rpath,$(QTDIR)/lib,-rpath,$(XROOT)/usr/X11R6/lib
20 SYSCONF_RPATH_OPENGL= -Wl,-rpath,$(XROOT)/usr/X11R6/lib
21
22# Linking with support libraries
23# X11
24 SYSCONF_LFLAGS_X11=
25 SYSCONF_LIBS_X11=
26# Qt, Qt+OpenGL
27 SYSCONF_LFLAGS_QT= -L$(QTDIR)/lib
28 SYSCONF_LIBS_QT = -lqt$(QT_THREAD_SUFFIX)
29 SYSCONF_LIBS_QT_OPENGL=
30# OpenGL
31 SYSCONF_LFLAGS_OPENGL= -L$(XROOT)/usr/X11R6/lib
32 SYSCONF_LIBS_OPENGL=
33# Yacc
34 SYSCONF_LIBS_YACC=
35
36# Linking applications
37 SYSCONF_LINK = arm-linux-gcc
38 SYSCONF_LFLAGS =
39 SYSCONF_LIBS =
40
41# Link flags for shared objects
42 SYSCONF_LFLAGS_SHOBJ= -shared
43
44# Flags for threading
45 SYSCONF_CFLAGS_THREAD= -D_REENTRANT
46 SYSCONF_CXXFLAGS_THREAD= -D_REENTRANT
47 SYSCONF_LFLAGS_THREAD=
48 SYSCONF_LIBS_THREAD= -lpthread
49
50# Point to /usr/bin for moc and uic since we are cross compiling here
51# Meta-object compiler
52 SYSCONF_MOC = /usr/bin/moc
53
54# UI compiler
55 SYSCONF_UIC = /usr/bin/uic
56
57# Linking shared libraries
58# - Build the $(TARGET) library, eg. lib$(TARGET).so.2.2.2
59# - Place target in $(DESTDIR) - which has a trailing /
60# - Usually needs to incorporate $(VER_MAJ), $(VER_MIN) and $(VER_PATCH)
61#
62 SYSCONF_LINK_SHLIB= arm-linux-gcc
63 SYSCONF_LINK_TARGET_SHARED= lib$(TARGET).so.$(VER_MAJ).$(VER_MIN).$(VER_PATCH)
64 SYSCONF_LINK_LIB_SHARED= $(SYSCONF_LINK_SHLIB) -shared -Wl,-soname,lib$(TARGET).so.$(VER_MAJ) \
65 $(LFLAGS) -o $(SYSCONF_LINK_TARGET_SHARED) \
66 $(OBJECTS) $(OBJMOC) $(LIBS) && \
67 mv $(SYSCONF_LINK_TARGET_SHARED) $(DESTDIR); \
68 cd $(DESTDIR) && \
69 rm -f lib$(TARGET).so lib$(TARGET).so.$(VER_MAJ) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN); \
70 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so; \
71 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ); \
72 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN)
73
74# Linking static libraries
75# - Build the $(TARGET) library, eg. lib$(TARGET).a
76# - Place target in $(DESTDIR) - which has a trailing /
77#
78 SYSCONF_AR = arm-linux-ar cqs
79SYSCONF_LINK_TARGET_STATIC = lib$(TARGET).a
80 SYSCONF_LINK_LIB_STATIC= rm -f $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) ; \
81 $(SYSCONF_AR) $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) $(OBJECTS) $(OBJMOC)
82# Compiling application source
83 SYSCONF_CXXFLAGS= -pipe -DQT_NO_COP -fno-exceptions -fno-rtti -O2 -Wall -W
84 SYSCONF_CFLAGS = -pipe -O2 -Wall -W
85# Default link type (static linking is still be used where required)
86 SYSCONF_LINK_LIB= $(SYSCONF_LINK_LIB_SHARED)
87 SYSCONF_LINK_TARGET= $(SYSCONF_LINK_TARGET_SHARED)
88# Compiling library source
89 SYSCONF_CXXFLAGS_LIB= -fPIC
90 SYSCONF_CFLAGS_LIB= -fPIC
91# Compiling shared-object source
92 SYSCONF_CXXFLAGS_SHOBJ= -fPIC
93 SYSCONF_CFLAGS_SHOBJ= -fPIC
94# Linking Qt
95 SYSCONF_LIBS_QTLIB= $(SYSCONF_LFLAGS_X11) $(QT_LIBS_MT) $(QT_LIBS_OPT)
96# Linking Qt applications
97 SYSCONF_LIBS_QTAPP=
diff --git a/configs/linux-generic-g++-sharedx11 b/configs/linux-generic-g++-sharedx11
deleted file mode 100644
index 1cd7a46..0000000
--- a/configs/linux-generic-g++-sharedx11
+++ b/dev/null
@@ -1,94 +0,0 @@
1# Compiling
2 INTERFACE_DECL_PATH = .
3 SYSCONF_CXX = g++
4 SYSCONF_CC = gcc
5 DASHCROSS =
6
7# Compiling with support libraries
8 SYSCONF_CXXFLAGS_X11=
9 SYSCONF_CXXFLAGS_QT= -I$(QTDIR)/include
10 SYSCONF_CXXFLAGS_OPENGL= -I/usr/X11R6/include
11
12# Compiling YACC output
13SYSCONF_CXXFLAGS_YACC = -Wno-unused -Wno-parentheses
14
15# Linking with support libraries
16 SYSCONF_RPATH_X11=
17 SYSCONF_RPATH_QT= -Wl,-rpath,$(QTDIR)/lib
18 SYSCONF_RPATH_OPENGL= -Wl,-rpath,/usr/X11R6/lib
19
20# Linking with support libraries
21# X11
22 SYSCONF_LFLAGS_X11=
23 SYSCONF_LIBS_X11=
24# Qt, Qt+OpenGL
25 SYSCONF_LFLAGS_QT= -L$(QTDIR)/lib
26 SYSCONF_LIBS_QT = -lqt$(QT_THREAD_SUFFIX)
27 SYSCONF_LIBS_QT_OPENGL=
28# OpenGL
29 SYSCONF_LFLAGS_OPENGL= -L/usr/X11R6/lib
30 SYSCONF_LIBS_OPENGL=
31# Yacc
32 SYSCONF_LIBS_YACC=
33
34# Linking applications
35 SYSCONF_LINK = gcc
36 SYSCONF_LFLAGS =
37 SYSCONF_LIBS =
38
39# Link flags for shared objects
40 SYSCONF_LFLAGS_SHOBJ= -shared
41
42# Flags for threading
43 SYSCONF_CFLAGS_THREAD= -D_REENTRANT
44 SYSCONF_CXXFLAGS_THREAD= -D_REENTRANT
45 SYSCONF_LFLAGS_THREAD=
46 SYSCONF_LIBS_THREAD= -lpthread
47
48# Meta-object compiler
49 SYSCONF_MOC = $(QTDIR)/bin/moc
50
51# UI compiler
52 SYSCONF_UIC = $(QTDIR)/bin/uic
53
54# Linking shared libraries
55# - Build the $(TARGET) library, eg. lib$(TARGET).so.2.2.2
56# - Place target in $(DESTDIR) - which has a trailing /
57# - Usually needs to incorporate $(VER_MAJ), $(VER_MIN) and $(VER_PATCH)
58#
59 SYSCONF_LINK_SHLIB= gcc
60 SYSCONF_LINK_TARGET_SHARED= lib$(TARGET).so.$(VER_MAJ).$(VER_MIN).$(VER_PATCH)
61 SYSCONF_LINK_LIB_SHARED= $(SYSCONF_LINK_SHLIB) -shared -Wl,-soname,lib$(TARGET).so.$(VER_MAJ) \
62 $(LFLAGS) -o $(SYSCONF_LINK_TARGET_SHARED) \
63 $(OBJECTS) $(OBJMOC) $(LIBS) && \
64 mv $(SYSCONF_LINK_TARGET_SHARED) $(DESTDIR); \
65 cd $(DESTDIR) && \
66 rm -f lib$(TARGET).so lib$(TARGET).so.$(VER_MAJ) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN); \
67 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so; \
68 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ); \
69 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN)
70
71# Linking static libraries
72# - Build the $(TARGET) library, eg. lib$(TARGET).a
73# - Place target in $(DESTDIR) - which has a trailing /
74#
75 SYSCONF_AR = ar cqs
76SYSCONF_LINK_TARGET_STATIC = lib$(TARGET).a
77 SYSCONF_LINK_LIB_STATIC= rm -f $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) ; \
78 $(SYSCONF_AR) $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) $(OBJECTS) $(OBJMOC)
79# Compiling application source
80 SYSCONF_CXXFLAGS= -pipe -DQT_NO_COP -fno-exceptions -fno-rtti -O2 -Wall -W
81 SYSCONF_CFLAGS = -pipe -O2 -Wall -W
82# Default link type (static linking is still be used where required)
83 SYSCONF_LINK_LIB= $(SYSCONF_LINK_LIB_SHARED)
84 SYSCONF_LINK_TARGET= $(SYSCONF_LINK_TARGET_SHARED)
85# Compiling library source
86 SYSCONF_CXXFLAGS_LIB= -fPIC
87 SYSCONF_CFLAGS_LIB= -fPIC
88# Compiling shared-object source
89 SYSCONF_CXXFLAGS_SHOBJ= -fPIC
90 SYSCONF_CFLAGS_SHOBJ= -fPIC
91# Linking Qt
92 SYSCONF_LIBS_QTLIB= $(SYSCONF_LFLAGS_X11) $(QT_LIBS_MT) $(QT_LIBS_OPT)
93# Linking Qt applications
94 SYSCONF_LIBS_QTAPP=
diff --git a/core/pim/datebook/layoutmanager.cpp b/core/pim/datebook/layoutmanager.cpp
deleted file mode 100644
index 23058ed..0000000
--- a/core/pim/datebook/layoutmanager.cpp
+++ b/dev/null
@@ -1,177 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3**
4** This file is part of the Qtopia Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#include "layoutmanager.h"
22
23static const int min_height = 15;
24
25LayoutItem::LayoutItem( const EffectiveEvent e ) : eevent(e) { }
26
27LayoutManager::LayoutManager(int w, int h) : width(w), height(h), maxWidth(w) { }
28
29LayoutManager::~LayoutManager() { }
30
31void LayoutManager::setSize(int w, int h)
32{
33 height = h;
34 maxWidth = width = w;
35 // with changed, re-init, re-layout items.
36 for (uint i = 0; i < mItems.count(); i++)
37 initializeGeometry(mItems.at(i));
38}
39
40void LayoutManager::setOccurances(QValueList<EffectiveEvent> &events)
41{
42 mItems.clear();
43
44 QValueListIterator<EffectiveEvent> it;
45 for ( it = events.begin(); it != events.end(); ++it ) {
46 addOccurance(*it);
47 }
48 layoutItems(TRUE);
49}
50
51void LayoutManager::addOccurance(EffectiveEvent &event)
52{
53 LayoutItem *i = new LayoutItem(event);
54 initializeGeometry(i);
55 addItem(i);
56}
57
58void LayoutManager::addItem(LayoutItem *i)
59{
60 mItems.resize(mItems.size() + 1);
61 mItems.insert(mItems.size() - 1, i);
62}
63
64void LayoutManager::layoutItems(bool resetMaxWidth)
65{
66 if (resetMaxWidth)
67 maxWidth = width;
68
69 int iCount = mItems.count();
70 int itemWidth = QMIN(width, maxWidth);
71 int n = 1;
72
73 if (width < 1)
74 return;
75 if (iCount < (width/4)) {
76 int i = 0;
77 while (i < iCount) {
78 LayoutItem *item = mItems.at(i);
79 int x = 0;
80 int xp = 0;
81 QRect geom = item->geometry();
82 geom.setX( x );
83 geom.setWidth(itemWidth);
84 while ( xp < n && intersects(item, geom)) {
85 x += itemWidth;
86 xp++;
87 geom.moveBy(itemWidth, 0);
88 }
89 if (xp >= n) {
90 n++;
91 itemWidth = QMIN(width / n, maxWidth);
92 i = 0; // Start again.
93 } else {
94 item->setGeometry( geom );
95 i++;
96 }
97 }
98 } else {
99 // alturnate algorithm. // same as above, but just overlap
100 // if fail.
101 itemWidth = 4;
102 n = width / itemWidth;
103 int i = 0;
104 int rovingXp = 0;
105 while (i < iCount) {
106 LayoutItem *item = mItems.at(i);
107 int x = 0;
108 int xp = 0;
109 QRect geom = item->geometry();
110 geom.setX( x );
111 geom.setWidth(itemWidth);
112 while ( xp < n && intersects(item, geom)) {
113 x += itemWidth;
114 xp++;
115 geom.moveBy(itemWidth, 0);
116 }
117 if (xp >= n) {
118 geom.setX(rovingXp * itemWidth);
119 geom.setWidth(itemWidth);
120 rovingXp++;
121 item->setGeometry( geom );
122 } else {
123 item->setGeometry( geom );
124 }
125 i++;
126 }
127 }
128 if (itemWidth < maxWidth)
129 maxWidth = itemWidth;
130}
131
132int LayoutManager::timeToHeight( const QTime &time ) const
133{
134 int y = time.hour() * 60 + time.minute();
135 if (y)
136 y = (y * (height / 24)) / 60;
137 return y;
138}
139
140QTime LayoutManager::heightToTime( int h ) const
141{
142 // broken
143 return QTime(0,0,0);
144}
145
146LayoutItem *LayoutManager::intersects(LayoutItem *item, QRect geom) const
147{
148 int i = 0;
149 // allow overlapping
150 geom.moveBy(1,1);
151 geom.setSize( geom.size() - QSize(2,2) );
152
153 LayoutItem *it = mItems.at(i);
154 int count = mItems.count();
155 while (i < count && it != item) {
156 if (it->geometry().intersects( geom ) )
157 return it;
158 it = mItems.at(++i);
159 }
160 return 0;
161}
162
163void LayoutManager::initializeGeometry(LayoutItem *item)
164{
165 int y = timeToHeight(item->occurance().start());
166 int yend = timeToHeight(item->occurance().end());
167
168 int h = yend - y;
169 if (h < min_height)
170 h = min_height;
171 if (y + min_height > height) {
172 y = height - min_height;
173 h = min_height;
174 }
175
176 item->setGeometry(QRect(0, y, width, h));
177}
diff --git a/core/pim/datebook/layoutmanager.h b/core/pim/datebook/layoutmanager.h
deleted file mode 100644
index 128f927..0000000
--- a/core/pim/datebook/layoutmanager.h
+++ b/dev/null
@@ -1,78 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3**
4** This file is part of the Qtopia Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#include <qvector.h>
22#include <qvaluelist.h>
23#include <qrect.h>
24#include <qdatetime.h>
25#include <qpe/event.h>
26
27class LayoutItem
28{
29public:
30 LayoutItem( const EffectiveEvent e );
31
32 void setGeometry(const QRect &rect) { r = rect; }
33 void setGeometry(int x, int y, int w, int h)
34 { setGeometry(QRect(x,y,w,h)); }
35 QRect geometry() const { return r; }
36
37 EffectiveEvent occurance() const { return eevent; }
38 Event event() const { return eevent.event(); }
39
40private:
41 EffectiveEvent eevent;
42 QRect r;
43};
44
45class LayoutManager
46{
47public:
48 LayoutManager(int w, int h);
49 virtual ~LayoutManager();
50
51 void setSize(int w, int h);
52 void setMaximumColumnWidth(int x) { maxWidth = x; };
53 int maximumColumnWidth() const { return maxWidth; };
54 void setOccurances(QValueList<EffectiveEvent> &events);
55 virtual void addOccurance(EffectiveEvent &event);
56
57 void clear() { mItems.clear(); }
58
59 QVector<LayoutItem> items() const { return mItems; }
60 QSize size() const { return QSize(width, height); }
61 int count() const { return mItems.count(); }
62
63 virtual void layoutItems(bool resetMaxWidth = FALSE);
64
65 virtual int timeToHeight(const QTime &) const;
66 virtual QTime heightToTime(int) const;
67
68protected:
69 void initializeGeometry(LayoutItem *);
70 LayoutItem *intersects(LayoutItem *, QRect) const;
71 void addItem(LayoutItem *);
72
73private:
74 QVector<LayoutItem> mItems;
75 int width;
76 int height;
77 int maxWidth;
78};
diff --git a/docs/inputmethodinterface.doc b/docs/inputmethodinterface.doc
deleted file mode 100644
index 465182b..0000000
--- a/docs/inputmethodinterface.doc
+++ b/dev/null
@@ -1,49 +0,0 @@
1/*! \class InputMethodInterface inputmethodinterface.h
2 \brief The InputMethodInterface class provides an interface for Qtopia
3 input methods.
4
5 Input methods must supply a QWidget that will be shown above the task bar
6 and emit a signal when a key is pressed:
7
8 Input methods may be added to Qtopia via plugins. In order to write an
9 input method plugin you must create an interface to your input method by
10 deriving from the InputMethodInterface class and implementing the pure
11 virtual functions.
12
13 See also: <a href=inputmethods.html>Input Method Tutorial</a>
14*/
15
16
17/*! \fn QWidget *InputMethodInterface::inputMethod( QWidget *parent, Qt::WFlags f )
18
19 The inputMethod() function returns the input method widget. This
20 widget will be display just above the task bar when the user needs to input
21 text. You should always return the same widget if this function is called
22 multiple times.
23*/
24
25/*! \fn void InputMethodInterface::resetState()
26
27 The resetState() function should return the input method to its default
28 state.
29*/
30
31/*! \fn QString InputMethodInterface::name()
32
33 The name() function returns the name of the input method. This will
34 be displayed in the popup list of available input methods.
35*/
36
37/*! \fn QPixmap *InputMethodInterface::icon()
38
39 The icon() function returns the icon for the input method. This will
40 be displayed in the taskbar when the input method is selected.
41*/
42
43
44/*! \fn void InputMethodInterface::onKeyPress( QObject *receiver, const char *slot )
45
46 The onKeyPress() function must connect the supplied slot to the signal
47 that is emitted when a key press is generated.
48*/
49
diff --git a/examples/application/Example.png b/examples/application/Example.png
deleted file mode 100644
index f63d0bc..0000000
--- a/examples/application/Example.png
+++ b/dev/null
Binary files differ
diff --git a/examples/application/README b/examples/application/README
deleted file mode 100644
index 63986f4..0000000
--- a/examples/application/README
+++ b/dev/null
@@ -1,2 +0,0 @@
1See /opt/Qtopia/doc/index.html for help.
2See doc.trolltech.com for more recent documentation updates.
diff --git a/examples/application/example.control b/examples/application/example.control
deleted file mode 100644
index e79c6f6..0000000
--- a/examples/application/example.control
+++ b/dev/null
@@ -1,11 +0,0 @@
1Files: bin/example apps/Applications/example.desktop pics/Example.png help/html/example.html
2Priority: optional
3Section: qpe/applications
4Maintainer: Your Name <you@your.domain.com>
5Architecture: arm
6Version: 1.0.0
7Depends: qpe-base ($QPE_VERSION)
8License: Public Domain
9Description: Example program
10 An example program for the Qtopia environment.
11 Does nothing interesting.
diff --git a/examples/application/example.cpp b/examples/application/example.cpp
deleted file mode 100644
index 1e0bbe9..0000000
--- a/examples/application/example.cpp
+++ b/dev/null
@@ -1,28 +0,0 @@
1#include "example.h"
2#include <qpushbutton.h>
3
4/*
5 * Constructs a Example which is a child of 'parent', with the
6 * name 'name' and widget flags set to 'f'
7 */
8Example::Example( QWidget* parent, const char* name, WFlags fl )
9 : ExampleBase( parent, name, fl )
10{
11 connect(quit, SIGNAL(clicked()), this, SLOT(goodBye()));
12}
13
14/*
15 * Destroys the object and frees any allocated resources
16 */
17Example::~Example()
18{
19 // no need to delete child widgets, Qt does it all for us
20}
21
22/*
23 * A simple slot... not very interesting.
24 */
25void Example::goodBye()
26{
27 close();
28}
diff --git a/examples/application/example.desktop b/examples/application/example.desktop
deleted file mode 100644
index f1e6f06..0000000
--- a/examples/application/example.desktop
+++ b/dev/null
@@ -1,6 +0,0 @@
1[Desktop Entry]
2Comment=An Example Program
3Exec=example
4Icon=Example
5Type=Application
6Name=Example
diff --git a/examples/application/example.h b/examples/application/example.h
deleted file mode 100644
index 24c58c0..0000000
--- a/examples/application/example.h
+++ b/dev/null
@@ -1,17 +0,0 @@
1#ifndef EXAMPLE_H
2#define EXAMPLE_H
3#include "examplebase.h"
4
5class Example : public ExampleBase
6{
7 Q_OBJECT
8
9public:
10 Example( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
11 ~Example();
12
13private slots:
14 void goodBye();
15};
16
17#endif // EXAMPLE_H
diff --git a/examples/application/example.html b/examples/application/example.html
deleted file mode 100644
index 9163573..0000000
--- a/examples/application/example.html
+++ b/dev/null
@@ -1,15 +0,0 @@
1<html>
2<h1>Example</h1>
3
4<p>This is the help for the Example program.
5
6<p>To user this application:
7
8<ol>
9 <li>Press the <img width=12 height=12 src=Example.png> icon in the Qtopia launcher.
10 <li>Read the label.
11 <li>Press the button.
12 <li>Read the source code provided.
13</ol>
14
15Now you know how to make a Qtopia application!
diff --git a/examples/application/example.pro b/examples/application/example.pro
deleted file mode 100644
index 2d89311..0000000
--- a/examples/application/example.pro
+++ b/dev/null
@@ -1,10 +0,0 @@
1 TEMPLATE= app
2 #CONFIG = qt warn_on debug
3 CONFIG = qt warn_on release
4 HEADERS = example.h
5 SOURCES = main.cpp example.cpp
6 INCLUDEPATH+= $(QPEDIR)/include
7 DEPENDPATH+= $(QPEDIR)/include
8LIBS += -lqpe
9 INTERFACES= examplebase.ui
10 TARGET = example
diff --git a/examples/application/examplebase.ui b/examples/application/examplebase.ui
deleted file mode 100644
index b47d20c..0000000
--- a/examples/application/examplebase.ui
+++ b/dev/null
@@ -1,55 +0,0 @@
1<!DOCTYPE UI><UI>
2<class>ExampleBase</class>
3<widget>
4 <class>QWidget</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>ExampleBase</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>196</width>
15 <height>245</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Example</string>
21 </property>
22 <vbox>
23 <property stdset="1">
24 <name>margin</name>
25 <number>11</number>
26 </property>
27 <property stdset="1">
28 <name>spacing</name>
29 <number>6</number>
30 </property>
31 <widget>
32 <class>QLabel</class>
33 <property stdset="1">
34 <name>name</name>
35 <cstring>TextLabel1</cstring>
36 </property>
37 <property stdset="1">
38 <name>text</name>
39 <string>&lt;p&gt;This is just an &lt;i&gt;example&lt;/i&gt;. It doesn't do anything interesting at all.</string>
40 </property>
41 </widget>
42 <widget>
43 <class>QPushButton</class>
44 <property stdset="1">
45 <name>name</name>
46 <cstring>quit</cstring>
47 </property>
48 <property stdset="1">
49 <name>text</name>
50 <string>Quit</string>
51 </property>
52 </widget>
53 </vbox>
54</widget>
55</UI>
diff --git a/examples/application/index.html b/examples/application/index.html
deleted file mode 100644
index ad97378..0000000
--- a/examples/application/index.html
+++ b/dev/null
@@ -1,23 +0,0 @@
1<h1 align=center><small>Welcome to the</small><br>Qtopia SDK</h1>
2
3<h3>API Documentation</h3>
4<p>
5For API documentation, point a web browser at
6/opt/Qtopia/doc/html/qtopia/index.html
7
8<h3>Application Documentation</h3>
9Put English documentation for applications in:
10
11<p>
12&nbsp;&nbsp;&nbsp;$QPEDIR/help/html/<i>appname</i>.html
13
14<p>
15Put non-English documentation for applications in:
16
17<p>
18&nbsp;&nbsp;&nbsp;$QPEDIR/help/<i>lang</i>/html/<i>appname</i>.html
19
20<p>
21Where <i>lang</i> is the language specifier (eg. "de" for German),
22and <i>appname</i> is the program name of your application.
23
diff --git a/examples/application/main.cpp b/examples/application/main.cpp
deleted file mode 100644
index b705c44..0000000
--- a/examples/application/main.cpp
+++ b/dev/null
@@ -1,12 +0,0 @@
1#include "example.h"
2#include <qpe/qpeapplication.h>
3
4int main( int argc, char ** argv )
5{
6 QPEApplication a( argc, argv );
7
8 Example mw;
9 a.showMainWidget( &mw );
10
11 return a.exec();
12}
diff --git a/examples/qpepim-addressbook/abexample.desktop b/examples/qpepim-addressbook/abexample.desktop
deleted file mode 100644
index 24b44d1..0000000
--- a/examples/qpepim-addressbook/abexample.desktop
+++ b/dev/null
@@ -1,6 +0,0 @@
1[Desktop Entry]
2Comment=Simple QPEPIM Example
3Exec=abexample
4Icon=abexample
5Type=Application
6Name=AB QPEPIM
diff --git a/examples/qpepim-addressbook/abexample.png b/examples/qpepim-addressbook/abexample.png
deleted file mode 100644
index f63d0bc..0000000
--- a/examples/qpepim-addressbook/abexample.png
+++ b/dev/null
Binary files differ
diff --git a/examples/qpepim-addressbook/addressbookdumper.cpp b/examples/qpepim-addressbook/addressbookdumper.cpp
deleted file mode 100644
index c47e05c..0000000
--- a/examples/qpepim-addressbook/addressbookdumper.cpp
+++ b/dev/null
@@ -1,65 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3**
4** This file is part of the Qtopia Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#include <qpe/contact.h>
22#include <qvaluelist.h>
23#include "addressbookdumper.h"
24
25AddressBookDumper::AddressBookDumper(QWidget* parent) : QMultiLineEdit(parent) {
26 // connect(&m_ABAccess, SIGNAL(addressbookUpdated()), this, SLOT(abChanged()));
27}
28
29AddressBookDumper::~AddressBookDumper() {
30}
31
32void AddressBookDumper::abChanged() {
33 QString newText;
34 QValueList<Contact> contacts = m_ABAccess.contacts();
35 QValueListConstIterator<Contact> it;
36 for (it = contacts.begin() ; it != contacts.end(); it++) {
37 newText.append((*it).firstName() + " " + (*it).lastName() + "\n");
38 }
39 setText(newText);
40}
41
42void AddressBookDumper::startBigEdit() {
43 if (m_ABAccess.startBlockEdit())
44 qDebug("*** Block edit successfully started.");
45 else
46 qDebug("*** Block edit start failed.");
47}
48
49void AddressBookDumper::endBigEdit() {
50 if (m_ABAccess.endBlockEdit())
51 qDebug("*** Block edit successfully ended.");
52 else
53 qDebug("*** Block edit end failed.");
54}
55
56void AddressBookDumper::addContact() {
57 Contact foo;
58 foo.setFirstName("Foo");
59 foo.setLastName("Bar");
60 foo.setFileAs();
61 if (m_ABAccess.addContact(foo))
62 qDebug("*** Add succeeded..");
63 else
64 qDebug("*** Add failed..");
65}
diff --git a/examples/qpepim-addressbook/addressbookdumper.h b/examples/qpepim-addressbook/addressbookdumper.h
deleted file mode 100644
index cc83d32..0000000
--- a/examples/qpepim-addressbook/addressbookdumper.h
+++ b/dev/null
@@ -1,39 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3**
4** This file is part of the Qtopia Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#include <qmultilineedit.h>
22#include <qpe/pim/addressbookaccess.h>
23
24class AddressBookDumper : public QMultiLineEdit {
25 Q_OBJECT
26
27 public:
28 AddressBookDumper(QWidget* parent);
29 ~AddressBookDumper();
30
31 public slots:
32 void abChanged();
33 void startBigEdit();
34 void endBigEdit();
35 void addContact();
36
37 private:
38 AddressBookAccess m_ABAccess;
39};
diff --git a/examples/qpepim-addressbook/main.cpp b/examples/qpepim-addressbook/main.cpp
deleted file mode 100644
index 590fffe..0000000
--- a/examples/qpepim-addressbook/main.cpp
+++ b/dev/null
@@ -1,47 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3**
4** This file is part of the Qtopia Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#include <qpe/qpeapplication.h>
22#ifdef QWS
23#include <qpe/qcopenvelope_qws.h>
24#endif
25#include <qapplication.h>
26#include <qpe/pim/addressbookaccess.h>
27#include "addressbookdumper.h"
28#include <qvbox.h>
29#include <qpushbutton.h>
30
31int main( int argc, char ** argv )
32{
33 QPEApplication a( argc, argv );
34 QVBox* vbox = new QVBox(0L);
35 QPushButton* clicker = new QPushButton("Refresh", vbox);
36 QPushButton* startBigEditButton = new QPushButton("Start Big Edit", vbox);
37 QPushButton* endBigEditButton = new QPushButton("End Big Edit", vbox);
38 QPushButton* addContactButton = new QPushButton("Add Contact", vbox);
39 AddressBookDumper* abDumper = new AddressBookDumper(vbox);
40 QObject::connect(clicker, SIGNAL(clicked()), abDumper, SLOT(abChanged()));
41 QObject::connect(startBigEditButton, SIGNAL(clicked()), abDumper, SLOT(startBigEdit()));
42 QObject::connect(endBigEditButton, SIGNAL(clicked()), abDumper, SLOT(endBigEdit()));
43 QObject::connect(addContactButton, SIGNAL(clicked()), abDumper, SLOT(addContact()));
44 a.setMainWidget(vbox);
45 vbox->show();
46 return a.exec();
47}
diff --git a/examples/qpepim-addressbook/qpepim-abexample.control b/examples/qpepim-addressbook/qpepim-abexample.control
deleted file mode 100644
index 5a31c97..0000000
--- a/examples/qpepim-addressbook/qpepim-abexample.control
+++ b/dev/null
@@ -1,9 +0,0 @@
1Files: bin/abexample apps/Applications/abexample.desktop
2Priority: optional
3Section: qpe/applications
4Maintainer: Warwick Allison <warwick@trolltech.com>
5Architecture: arm
6Version: $QPE_VERSION-1
7Depends: qpe-pim, qpe-base ($QPE_VERSION)
8Description: Example Addressbook reader
9 Simple example for using the QPEPIM access library.
diff --git a/examples/qpepim-addressbook/qpepim-addressbook.pro b/examples/qpepim-addressbook/qpepim-addressbook.pro
deleted file mode 100644
index 7e918e0..0000000
--- a/examples/qpepim-addressbook/qpepim-addressbook.pro
+++ b/dev/null
@@ -1,8 +0,0 @@
1TEMPLATE = app
2CONFIG = qt warn_on debug
3
4HEADERS = addressbookdumper.h
5SOURCES = main.cpp addressbookdumper.cpp
6TARGET = abexample
7INCLUDEPATH = $(QPEDIR)/include
8LIBS += -lqpepim -lqpe -lqte
diff --git a/inputmethods/handwriting/qimpenchar.cpp b/inputmethods/handwriting/qimpenchar.cpp
index 9c38ec9..152bfec 100644
--- a/inputmethods/handwriting/qimpenchar.cpp
+++ b/inputmethods/handwriting/qimpenchar.cpp
@@ -336,170 +336,170 @@ bool QIMPenCharSet::load( const QString &fn, Domain d )
336 else if ( fn == "Combining" ) 336 else if ( fn == "Combining" )
337 csType = Combining; 337 csType = Combining;
338 } 338 }
339 while ( !ds.atEnd() ) { 339 while ( !ds.atEnd() ) {
340 QIMPenChar *pc = new QIMPenChar; 340 QIMPenChar *pc = new QIMPenChar;
341 ds >> *pc; 341 ds >> *pc;
342 if ( d == User ) 342 if ( d == User )
343 markDeleted( pc->character() ); // override system 343 markDeleted( pc->character() ); // override system
344 addChar( pc ); 344 addChar( pc );
345 } 345 }
346 if ( file.status() == IO_Ok ) 346 if ( file.status() == IO_Ok )
347 ok = TRUE; 347 ok = TRUE;
348 } 348 }
349 349
350 return ok; 350 return ok;
351} 351}
352 352
353/*! 353/*!
354 Save this character set. 354 Save this character set.
355*/ 355*/
356bool QIMPenCharSet::save( Domain d ) 356bool QIMPenCharSet::save( Domain d )
357{ 357{
358 if ( filename( d ).isEmpty() ) 358 if ( filename( d ).isEmpty() )
359 return FALSE; 359 return FALSE;
360 360
361 bool ok = FALSE; 361 bool ok = FALSE;
362 362
363 QString fn = filename( d ); 363 QString fn = filename( d );
364 QString tmpFn = fn + ".new"; 364 QString tmpFn = fn + ".new";
365 QFile file( tmpFn ); 365 QFile file( tmpFn );
366 if ( file.open( IO_WriteOnly|IO_Raw ) ) { 366 if ( file.open( IO_WriteOnly|IO_Raw ) ) {
367 QDataStream ds( &file ); 367 QDataStream ds( &file );
368 ds << QString( "QPT 1.1" ); 368 ds << QString( "QPT 1.1" );
369 ds << csTitle; 369 ds << csTitle;
370 ds << desc; 370 ds << desc;
371 ds << (Q_INT8)csType; 371 ds << (Q_INT8)csType;
372 QIMPenCharIterator ci( chars ); 372 QIMPenCharIterator ci( chars );
373 for ( ; ci.current(); ++ci ) { 373 for ( ; ci.current(); ++ci ) {
374 QIMPenChar *pc = ci.current(); 374 QIMPenChar *pc = ci.current();
375 if ( ( (d == System) && pc->testFlag( QIMPenChar::System ) ) || 375 if ( ( (d == System) && pc->testFlag( QIMPenChar::System ) ) ||
376 ( (d == User) && !pc->testFlag( QIMPenChar::System ) ) ) { 376 ( (d == User) && !pc->testFlag( QIMPenChar::System ) ) ) {
377 ds << *pc; 377 ds << *pc;
378 } 378 }
379 if ( file.status() != IO_Ok ) 379 if ( file.status() != IO_Ok )
380 break; 380 break;
381 } 381 }
382 if ( file.status() == IO_Ok ) 382 if ( file.status() == IO_Ok )
383 ok = TRUE; 383 ok = TRUE;
384 } 384 }
385 385
386 if ( ok ) { 386 if ( ok ) {
387 if ( ::rename( tmpFn.latin1(), fn.latin1() ) < 0 ) { 387 if ( ::rename( tmpFn.latin1(), fn.latin1() ) < 0 ) {
388 qWarning( "problem renaming file %s to %s, errno: %d", 388 qWarning( "problem renaming file %s to %s, errno: %d",
389 tmpFn.latin1(), fn.latin1(), errno ); 389 tmpFn.latin1(), fn.latin1(), errno );
390 // remove the tmp file, otherwise, it will just lay around... 390 // remove the tmp file, otherwise, it will just lay around...
391 QFile::remove( tmpFn.latin1() ); 391 QFile::remove( tmpFn.latin1() );
392 ok = FALSE; 392 ok = FALSE;
393 } 393 }
394 } 394 }
395 395
396 return ok; 396 return ok;
397} 397}
398 398
399QIMPenChar *QIMPenCharSet::at( int i ) 399QIMPenChar *QIMPenCharSet::at( int i )
400{ 400{
401 return chars.at(i); 401 return chars.at(i);
402} 402}
403 403
404void QIMPenCharSet::markDeleted( uint ch ) 404void QIMPenCharSet::markDeleted( uint ch )
405{ 405{
406 QIMPenCharIterator ci( chars ); 406 QIMPenCharIterator ci( chars );
407 for ( ; ci.current(); ++ci ) { 407 for ( ; ci.current(); ++ci ) {
408 QIMPenChar *pc = ci.current(); 408 QIMPenChar *pc = ci.current();
409 if ( pc->character() == ch && pc->testFlag( QIMPenChar::System ) ) 409 if ( pc->character() == ch && pc->testFlag( QIMPenChar::System ) )
410 pc->setFlag( QIMPenChar::Deleted ); 410 pc->setFlag( QIMPenChar::Deleted );
411 } 411 }
412} 412}
413 413
414/*! 414/*!
415 Find the best matches for \a ch in this character set. 415 Find the best matches for \a ch in this character set.
416*/ 416*/
417QIMPenCharMatchList QIMPenCharSet::match( QIMPenChar *ch ) 417QIMPenCharMatchList QIMPenCharSet::match( QIMPenChar *ch )
418{ 418{
419 QIMPenCharMatchList matches; 419 QIMPenCharMatchList matches;
420 420
421 QIMPenCharIterator ci( chars ); 421 QIMPenCharIterator ci( chars );
422 for ( ; ci.current(); ++ci ) { 422 for ( ; ci.current(); ++ci ) {
423 QIMPenChar *tmplChar = ci.current(); 423 QIMPenChar *tmplChar = ci.current();
424 if ( tmplChar->testFlag( QIMPenChar::Deleted ) ) { 424 if ( tmplChar->testFlag( QIMPenChar::Deleted ) ) {
425 continue; 425 continue;
426 } 426 }
427 int err; 427 int err;
428 if ( ch->penStrokes().count() <= tmplChar->penStrokes().count() ) { 428 if ( ch->penStrokes().count() <= tmplChar->penStrokes().count() ) {
429 err = ch->match( tmplChar ); 429 err = ch->match( tmplChar );
430 if ( err <= QIMPEN_MATCH_THRESHOLD ) { 430 if ( err <= QIMPEN_MATCH_THRESHOLD ) {
431 if (tmplChar->penStrokes().count() != ch->penStrokes().count()) 431 if (tmplChar->penStrokes().count() != ch->penStrokes().count())
432 err = QIMPEN_MATCH_THRESHOLD; 432 err = QMIN(err*3, QIMPEN_MATCH_THRESHOLD);
433 QIMPenCharMatchList::Iterator it; 433 QIMPenCharMatchList::Iterator it;
434 for ( it = matches.begin(); it != matches.end(); ++it ) { 434 for ( it = matches.begin(); it != matches.end(); ++it ) {
435 if ( (*it).penChar->character() == tmplChar->character() && 435 if ( (*it).penChar->character() == tmplChar->character() &&
436 (*it).penChar->penStrokes().count() == tmplChar->penStrokes().count() ) { 436 (*it).penChar->penStrokes().count() == tmplChar->penStrokes().count() ) {
437 if ( (*it).error > err ) 437 if ( (*it).error > err )
438 (*it).error = err; 438 (*it).error = err;
439 break; 439 break;
440 } 440 }
441 } 441 }
442 if ( it == matches.end() ) { 442 if ( it == matches.end() ) {
443 QIMPenCharMatch m; 443 QIMPenCharMatch m;
444 m.error = err; 444 m.error = err;
445 m.penChar = tmplChar; 445 m.penChar = tmplChar;
446 matches.append( m ); 446 matches.append( m );
447 } 447 }
448 } 448 }
449 } 449 }
450 } 450 }
451 qHeapSort( matches ); 451 qHeapSort( matches );
452/* 452/*
453 QIMPenCharMatchList::Iterator it; 453 QIMPenCharMatchList::Iterator it;
454 for ( it = matches.begin(); it != matches.end(); ++it ) { 454 for ( it = matches.begin(); it != matches.end(); ++it ) {
455 qDebug( "Match: \'%c\', error %d, strokes %d", (*it).penChar->character(), 455 qDebug( "Match: \'%c\', error %d, strokes %d", (*it).penChar->character(),
456 (*it).error, (*it).penChar->penStrokes().count() ); 456 (*it).error, (*it).penChar->penStrokes().count() );
457 } 457 }
458*/ 458*/
459 return matches; 459 return matches;
460} 460}
461 461
462/*! 462/*!
463 Add a character \a ch to this set. 463 Add a character \a ch to this set.
464 QIMPenCharSet will delete this character when it is no longer needed. 464 QIMPenCharSet will delete this character when it is no longer needed.
465*/ 465*/
466void QIMPenCharSet::addChar( QIMPenChar *ch ) 466void QIMPenCharSet::addChar( QIMPenChar *ch )
467{ 467{
468 if ( ch->penStrokes().count() > maxStrokes ) 468 if ( ch->penStrokes().count() > maxStrokes )
469 maxStrokes = ch->penStrokes().count(); 469 maxStrokes = ch->penStrokes().count();
470 chars.append( ch ); 470 chars.append( ch );
471} 471}
472 472
473/*! 473/*!
474 Remove a character by reference \a ch from this set. 474 Remove a character by reference \a ch from this set.
475 QIMPenCharSet will delete this character. 475 QIMPenCharSet will delete this character.
476*/ 476*/
477void QIMPenCharSet::removeChar( QIMPenChar *ch ) 477void QIMPenCharSet::removeChar( QIMPenChar *ch )
478{ 478{
479 chars.remove( ch ); 479 chars.remove( ch );
480} 480}
481 481
482/*! 482/*!
483 Move the character up the list of characters. 483 Move the character up the list of characters.
484*/ 484*/
485void QIMPenCharSet::up( QIMPenChar *ch ) 485void QIMPenCharSet::up( QIMPenChar *ch )
486{ 486{
487 int idx = chars.findRef( ch ); 487 int idx = chars.findRef( ch );
488 if ( idx > 0 ) { 488 if ( idx > 0 ) {
489 chars.take(); 489 chars.take();
490 chars.insert( idx - 1, ch ); 490 chars.insert( idx - 1, ch );
491 } 491 }
492} 492}
493 493
494/*! 494/*!
495 Move the character down the list of characters. 495 Move the character down the list of characters.
496*/ 496*/
497void QIMPenCharSet::down( QIMPenChar *ch ) 497void QIMPenCharSet::down( QIMPenChar *ch )
498{ 498{
499 int idx = chars.findRef( ch ); 499 int idx = chars.findRef( ch );
500 if ( idx >= 0 && idx < (int)chars.count() - 1 ) { 500 if ( idx >= 0 && idx < (int)chars.count() - 1 ) {
501 chars.take(); 501 chars.take();
502 chars.insert( idx + 1, ch ); 502 chars.insert( idx + 1, ch );
503 } 503 }
504} 504}
505 505
diff --git a/library/alarmserver.h b/library/alarmserver.h
index 665c3ae..f12a63d 100644
--- a/library/alarmserver.h
+++ b/library/alarmserver.h
@@ -1,35 +1,38 @@
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 ALARM_SERVER_H 20#ifndef ALARM_SERVER_H
21#define ALARM_SERVER_H 21#define ALARM_SERVER_H
22 22
23#include <qstring.h> 23#include <qstring.h>
24#include <qdatetime.h> 24#include <qdatetime.h>
25 25
26class AlarmServer 26class AlarmServer
27{ 27{
28public: 28public:
29 static void addAlarm ( QDateTime when, const QCString& channel, const QCString& msg, int data=0); 29 static void addAlarm ( QDateTime when, const QCString& channel, const QCString& msg, int data=0);
30 static void deleteAlarm (QDateTime when, const QCString& channel, const QCString& msg, int data=0); 30 static void deleteAlarm (QDateTime when, const QCString& channel, const QCString& msg, int data=0);
31
32private:
33 friend int initApplication(int, char **);
31 static void initialize(); 34 static void initialize();
32}; 35};
33 36
34#endif 37#endif
35 38
diff --git a/library/applnk.h b/library/applnk.h
index c6f92a3..18e20b6 100644
--- a/library/applnk.h
+++ b/library/applnk.h
@@ -1,169 +1,172 @@
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 __APPLNK_H__ 20#ifndef __APPLNK_H__
21#define __APPLNK_H__ 21#define __APPLNK_H__
22 22
23#include <qobject.h> 23#include <qobject.h>
24#include <qiconset.h> 24#include <qiconset.h>
25#include <qlist.h> 25#include <qlist.h>
26#include <qdict.h> 26#include <qdict.h>
27#include <qstringlist.h> 27#include <qstringlist.h>
28 28
29class AppLnkSetPrivate; 29class AppLnkSetPrivate;
30class AppLnkPrivate; 30class AppLnkPrivate;
31 31
32class AppLnk 32class AppLnk
33{ 33{
34public: 34public:
35 AppLnk(); 35 AppLnk();
36 AppLnk( const QString &file ); 36 AppLnk( const QString &file );
37 AppLnk( const AppLnk &copy ); // copy constructor 37 AppLnk( const AppLnk &copy ); // copy constructor
38 virtual ~AppLnk(); 38 virtual ~AppLnk();
39 39
40 bool isValid() const { return !mLinkFile.isNull(); } 40 bool isValid() const { return !mLinkFile.isNull(); }
41 41
42 static void setSmallIconSize(int); 42 static void setSmallIconSize(int);
43 static void setBigIconSize(int); 43 static void setBigIconSize(int);
44 static int smallIconSize(); 44 static int smallIconSize();
45 static int bigIconSize(); 45 static int bigIconSize();
46 46
47 QString name() const { return mName; } 47 QString name() const { return mName; }
48 const QPixmap& pixmap() const; 48 const QPixmap& pixmap() const;
49 const QPixmap& bigPixmap() const; 49 const QPixmap& bigPixmap() const;
50 virtual QString exec() const { return mExec; } 50 virtual QString exec() const { return mExec; }
51 QString type() const; 51 QString type() const;
52 QString rotation() const { return mRotation; } 52 QString rotation() const { return mRotation; }
53 QString comment() const { return mComment; } 53 QString comment() const { return mComment; }
54 QString file() const; 54 QString file() const;
55 QString linkFile() const; 55 QString linkFile() const;
56 QStringList mimeTypes() const { return mMimeTypes; } 56 QStringList mimeTypes() const { return mMimeTypes; }
57 QStringList mimeTypeIcons() const { return mMimeTypeIcons; } 57 QStringList mimeTypeIcons() const { return mMimeTypeIcons; }
58 const QArray<int> &categories() const; 58 const QArray<int> &categories() const;
59 int id() const { return mId; } 59 int id() const { return mId; }
60 60
61 bool linkFileKnown() const { return !mLinkFile.isNull(); }
62
61 void execute() const; 63 void execute() const;
62 void execute(const QStringList& args) const; 64 void execute(const QStringList& args) const;
63 void removeFiles(); 65 void removeFiles();
64 void removeLinkFile(); 66 void removeLinkFile();
65 67
66 void setName( const QString& docname ); 68 void setName( const QString& docname );
67 void setExec( const QString& exec ); 69 void setExec( const QString& exec );
68 void setFile( const QString& filename ); 70 void setFile( const QString& filename );
69 void setLinkFile( const QString& filename ); 71 void setLinkFile( const QString& filename );
70 void setComment( const QString& comment ); 72 void setComment( const QString& comment );
71 void setType( const QString& mimetype ); 73 void setType( const QString& mimetype );
72 void setIcon( const QString& iconname ); 74 void setIcon( const QString& iconname );
73 void setCategories( const QArray<int> &v ); 75 void setCategories( const QArray<int> &v );
74 bool writeLink() const; 76 bool writeLink() const;
75 77
76 void setProperty(const QString& key, const QString& value); 78 void setProperty(const QString& key, const QString& value);
77 QString property(const QString& key) const; 79 QString property(const QString& key) const;
78 80
79protected: 81protected:
80 QString mName; 82 QString mName;
81 QPixmap mPixmap; 83 QPixmap mPixmap;
82 QPixmap mBigPixmap; 84 QPixmap mBigPixmap;
83 QString mExec; 85 QString mExec;
84 QString mType; 86 QString mType;
85 QString mRotation; 87 QString mRotation;
86 QString mComment; 88 QString mComment;
87 QString mFile; 89 QString mFile;
88 QString mLinkFile; 90 QString mLinkFile;
89 QString mIconFile; 91 QString mIconFile;
90 QStringList mMimeTypes; 92 QStringList mMimeTypes;
91 QStringList mMimeTypeIcons; 93 QStringList mMimeTypeIcons;
92 int mId; 94 int mId;
93 static int lastId; 95 static int lastId;
94 AppLnkPrivate *d; 96 AppLnkPrivate *d;
95 friend class AppLnkSet; 97 friend class AppLnkSet;
96 98
97 virtual void invoke(const QStringList& args) const; 99 virtual void invoke(const QStringList& args) const;
98 bool ensureLinkExists() const; 100 bool ensureLinkExists() const;
101 void storeLink() const;
99}; 102};
100 103
101class DocLnk : public AppLnk 104class DocLnk : public AppLnk
102{ 105{
103public: 106public:
104 DocLnk(); 107 DocLnk();
105 DocLnk( const DocLnk &o ) : AppLnk(o) { } 108 DocLnk( const DocLnk &o ) : AppLnk(o) { }
106 DocLnk( const QString &file ); 109 DocLnk( const QString &file );
107 DocLnk( const QString &file, bool may_be_desktopfile ); 110 DocLnk( const QString &file, bool may_be_desktopfile );
108 virtual ~DocLnk(); 111 virtual ~DocLnk();
109 112
110 QString exec() const; 113 QString exec() const;
111 114
112protected: 115protected:
113 void invoke(const QStringList& args) const; 116 void invoke(const QStringList& args) const;
114 117
115private: 118private:
116 void init(const QString &file); 119 void init(const QString &file);
117}; 120};
118 121
119class AppLnkSet 122class AppLnkSet
120{ 123{
121public: 124public:
122 AppLnkSet(); 125 AppLnkSet();
123 AppLnkSet( const QString &dir ); 126 AppLnkSet( const QString &dir );
124 ~AppLnkSet(); 127 ~AppLnkSet();
125 128
126 const AppLnk *find( int id ) const; 129 const AppLnk *find( int id ) const;
127 const AppLnk *findExec( const QString& execname ) const; 130 const AppLnk *findExec( const QString& execname ) const;
128 131
129 QStringList types() const { return typs; } 132 QStringList types() const { return typs; }
130 QString typeName( const QString& ) const; 133 QString typeName( const QString& ) const;
131 QPixmap typePixmap( const QString& ) const; 134 QPixmap typePixmap( const QString& ) const;
132 QPixmap typeBigPixmap( const QString& ) const; 135 QPixmap typeBigPixmap( const QString& ) const;
133 136
134 void add(AppLnk*); 137 void add(AppLnk*);
135 bool remove(AppLnk*); 138 bool remove(AppLnk*);
136 139
137 const QList<AppLnk> &children() const { return mApps; } 140 const QList<AppLnk> &children() const { return mApps; }
138 void detachChildren(); 141 void detachChildren();
139 142
140protected: 143protected:
141 friend class AppLnk; 144 friend class AppLnk;
142 QList<AppLnk> mApps; 145 QList<AppLnk> mApps;
143 QString mFile; 146 QString mFile;
144 QStringList typs; 147 QStringList typs;
145 AppLnkSetPrivate *d; 148 AppLnkSetPrivate *d;
146 149
147private: 150private:
148 AppLnkSet( const AppLnkSet & ); // no copying! 151 AppLnkSet( const AppLnkSet & ); // no copying!
149 void findChildren(const QString &, const QString& t, const QString& lt, int depth = 0); 152 void findChildren(const QString &, const QString& t, const QString& lt, int depth = 0);
150}; 153};
151 154
152class DocLnkSet : public AppLnkSet 155class DocLnkSet : public AppLnkSet
153{ 156{
154public: 157public:
155 DocLnkSet(); 158 DocLnkSet();
156 DocLnkSet( const QString &dir, const QString &mimefilter=QString::null ); 159 DocLnkSet( const QString &dir, const QString &mimefilter=QString::null );
157 160
158 const QList<DocLnk> &children() const { return (const QList<DocLnk> &)mApps; } 161 const QList<DocLnk> &children() const { return (const QList<DocLnk> &)mApps; }
159 162
160 void appendFrom( DocLnkSet& other ); 163 void appendFrom( DocLnkSet& other );
161 164
162private: 165private:
163 DocLnkSet( const DocLnkSet & ); // no copying! 166 DocLnkSet( const DocLnkSet & ); // no copying!
164 void findChildren(const QString &dr, const QValueList<QRegExp> &mimeFilters, QDict<void> &reference, int depth=0); 167 void findChildren(const QString &dr, const QValueList<QRegExp> &mimeFilters, QDict<void> &reference, int depth=0);
165}; 168};
166 169
167 170
168#endif // __APPLNK_H__ 171#endif // __APPLNK_H__
169 172
diff --git a/library/backend/categories.cpp b/library/backend/categories.cpp
index 91331db..6e011c4 100644
--- a/library/backend/categories.cpp
+++ b/library/backend/categories.cpp
@@ -78,599 +78,575 @@ bool CategoryGroup::remove( const QString &label )
78 QMap<QString,int>::Iterator findIt = mLabelIdMap.find( label ); 78 QMap<QString,int>::Iterator findIt = mLabelIdMap.find( label );
79 if ( findIt == mLabelIdMap.end() ) 79 if ( findIt == mLabelIdMap.end() )
80 return FALSE; 80 return FALSE;
81 81
82 mIdLabelMap.remove( *findIt ); 82 mIdLabelMap.remove( *findIt );
83 mLabelIdMap.remove( findIt ); 83 mLabelIdMap.remove( findIt );
84 84
85 return TRUE; 85 return TRUE;
86} 86}
87 87
88bool CategoryGroup::remove( int uid ) 88bool CategoryGroup::remove( int uid )
89{ 89{
90 QMap<int,QString>::Iterator idIt = mIdLabelMap.find( uid ); 90 QMap<int,QString>::Iterator idIt = mIdLabelMap.find( uid );
91 if ( idIt == mIdLabelMap.end() ) 91 if ( idIt == mIdLabelMap.end() )
92 return FALSE; 92 return FALSE;
93 93
94 mLabelIdMap.remove( *idIt ); 94 mLabelIdMap.remove( *idIt );
95 mIdLabelMap.remove( idIt ); 95 mIdLabelMap.remove( idIt );
96 96
97 return TRUE; 97 return TRUE;
98} 98}
99 99
100bool CategoryGroup::rename( int uid, const QString &newLabel ) 100bool CategoryGroup::rename( int uid, const QString &newLabel )
101{ 101{
102 if ( newLabel == QObject::tr("All") || newLabel == QObject::tr("Unfiled") ) 102 if ( newLabel == QObject::tr("All") || newLabel == QObject::tr("Unfiled") )
103 return FALSE; 103 return FALSE;
104 104
105 QMap<int, QString>::Iterator idIt = mIdLabelMap.find( uid ); 105 QMap<int, QString>::Iterator idIt = mIdLabelMap.find( uid );
106 if ( idIt == mIdLabelMap.end() ) 106 if ( idIt == mIdLabelMap.end() )
107 return FALSE; 107 return FALSE;
108 108
109 mLabelIdMap.remove( *idIt ); 109 mLabelIdMap.remove( *idIt );
110 mLabelIdMap[newLabel] = uid; 110 mLabelIdMap[newLabel] = uid;
111 *idIt = newLabel; 111 *idIt = newLabel;
112 112
113 return TRUE; 113 return TRUE;
114} 114}
115 115
116bool CategoryGroup::rename( const QString &oldLabel, const QString &newLabel ) 116bool CategoryGroup::rename( const QString &oldLabel, const QString &newLabel )
117{ 117{
118 return rename( id(oldLabel), newLabel ); 118 return rename( id(oldLabel), newLabel );
119} 119}
120 120
121bool CategoryGroup::contains(int uid) const 121bool CategoryGroup::contains(int uid) const
122{ 122{
123 return ( mIdLabelMap.find( uid ) != mIdLabelMap.end() ); 123 return ( mIdLabelMap.find( uid ) != mIdLabelMap.end() );
124} 124}
125 125
126bool CategoryGroup::contains(const QString &label) const 126bool CategoryGroup::contains(const QString &label) const
127{ 127{
128 return ( mLabelIdMap.find( label ) != mLabelIdMap.end() ); 128 return ( mLabelIdMap.find( label ) != mLabelIdMap.end() );
129} 129}
130 130
131/** Returns label associated with the uid or QString::null if 131/** Returns label associated with the uid or QString::null if
132 * not found 132 * not found
133 */ 133 */
134const QString &CategoryGroup::label(int uid) const 134const QString &CategoryGroup::label(int uid) const
135{ 135{
136 QMap<int,QString>::ConstIterator idIt = mIdLabelMap.find( uid ); 136 QMap<int,QString>::ConstIterator idIt = mIdLabelMap.find( uid );
137 if ( idIt == mIdLabelMap.end() ) 137 if ( idIt == mIdLabelMap.end() )
138 return QString::null; 138 return QString::null;
139 return *idIt; 139 return *idIt;
140} 140}
141 141
142/** Returns the uid associated with label or 0 if not found */ 142/** Returns the uid associated with label or 0 if not found */
143int CategoryGroup::id(const QString &label) const 143int CategoryGroup::id(const QString &label) const
144{ 144{
145 QMap<QString,int>::ConstIterator labelIt = mLabelIdMap.find( label ); 145 QMap<QString,int>::ConstIterator labelIt = mLabelIdMap.find( label );
146 if ( labelIt == mLabelIdMap.end() ) 146 if ( labelIt == mLabelIdMap.end() )
147 return 0; 147 return 0;
148 return *labelIt; 148 return *labelIt;
149} 149}
150 150
151QStringList CategoryGroup::labels() const 151QStringList CategoryGroup::labels() const
152{ 152{
153 QStringList labels; 153 QStringList labels;
154 for ( QMap<int, QString>::ConstIterator it = mIdLabelMap.begin(); 154 for ( QMap<int, QString>::ConstIterator it = mIdLabelMap.begin();
155 it != mIdLabelMap.end(); ++it ) 155 it != mIdLabelMap.end(); ++it )
156 labels += *it; 156 labels += *it;
157 // ### I don't think this is the place for this... 157 // ### I don't think this is the place for this...
158// labels.sort(); 158// labels.sort();
159 return labels; 159 return labels;
160} 160}
161 161
162QStringList CategoryGroup::labels(const QArray<int> &catids ) const 162QStringList CategoryGroup::labels(const QArray<int> &catids ) const
163{ 163{
164 QStringList labels; 164 QStringList labels;
165 if ( catids.count() == 0 ) 165 if ( catids.count() == 0 )
166 return labels; 166 return labels;
167 for ( QMap<int, QString>::ConstIterator it = mIdLabelMap.begin(); 167 for ( QMap<int, QString>::ConstIterator it = mIdLabelMap.begin();
168 it != mIdLabelMap.end(); ++it ) 168 it != mIdLabelMap.end(); ++it )
169 if ( catids.find( it.key() ) != -1 ) 169 if ( catids.find( it.key() ) != -1 )
170 labels += *it; 170 labels += *it;
171 return labels; 171 return labels;
172} 172}
173 173
174QArray<int> CategoryGroup::ids( const QStringList &cats ) const
175{
176 QArray<int> results;
177
178 for ( QStringList::ConstIterator catIt = cats.begin();
179 catIt != cats.end(); ++catIt ) {
180 if ( *catIt == QObject::tr("All") || *catIt == QObject::tr("Unfiled") )
181 continue;
182 int value = id( *catIt );
183 if ( value != 0 ) {
184 int tmp = results.size();
185 results.resize( tmp + 1 );
186 results[ tmp ] = value;
187 }
188 }
189
190 return results;
191}
192
193QArray<int> CategoryGroup::ids() const
194{
195 QArray<int> results( mIdLabelMap.count() );
196 int i = 0;
197 for ( QMap<int, QString>::ConstIterator it = mIdLabelMap.begin();
198 it != mIdLabelMap.end(); ++it )
199 results[i++] = it.key();
200
201 return results;
202}
203
204/*********************************************************** 174/***********************************************************
205 * 175 *
206 * Categories 176 * Categories
207 * 177 *
208 **********************************************************/ 178 **********************************************************/
209 179
210/** Add the category name as long as it doesn't already exist locally 180/** Add the category name as long as it doesn't already exist locally
211 * or globally. Return TRUE if added, FALSE if conflicts. 181 * or globally. Return TRUE if added, FALSE if conflicts.
212 */ 182 */
213int Categories::addCategory( const QString &appname, 183int Categories::addCategory( const QString &appname,
214 const QString &catname, 184 const QString &catname,
215 int uid ) 185 int uid )
216{ 186{
217 if ( mGlobalCats.contains(catname) ) 187 if ( mGlobalCats.contains(catname) )
218 return 0; 188 return 0;
219 189
220 QMap< QString, CategoryGroup >::Iterator 190 QMap< QString, CategoryGroup >::Iterator
221 appIt = mAppCats.find( appname ); 191 appIt = mAppCats.find( appname );
222 192
223 if ( appIt == mAppCats.end() ) { 193 if ( appIt == mAppCats.end() ) {
224 CategoryGroup newgroup; 194 CategoryGroup newgroup;
225 newgroup.add( uid, catname ); 195 newgroup.add( uid, catname );
226 mAppCats.insert( appname, newgroup ); 196 mAppCats.insert( appname, newgroup );
227 emit categoryAdded( *this, appname, uid ); 197 emit categoryAdded( *this, appname, uid );
228 return uid; 198 return uid;
229 } 199 }
230 200
231 CategoryGroup &cats = *appIt; 201 CategoryGroup &cats = *appIt;
232 cats.add( uid, catname ); 202 cats.add( uid, catname );
233 emit categoryAdded( *this, appname, uid ); 203 emit categoryAdded( *this, appname, uid );
234 return uid; 204 return uid;
235} 205}
236 206
237int Categories::addCategory( const QString &appname, 207int Categories::addCategory( const QString &appname,
238 const QString &catname ) 208 const QString &catname )
239{ 209{
240 if ( mGlobalCats.contains(catname) ) 210 if ( mGlobalCats.contains(catname) )
241 return 0; 211 return 0;
242 212
243 QMap< QString, CategoryGroup >::Iterator 213 QMap< QString, CategoryGroup >::Iterator
244 appIt = mAppCats.find( appname ); 214 appIt = mAppCats.find( appname );
245 215
246 if ( appIt == mAppCats.end() ) { 216 if ( appIt == mAppCats.end() ) {
247 CategoryGroup newgroup; 217 CategoryGroup newgroup;
248 int uid = newgroup.add( catname ); 218 int uid = newgroup.add( catname );
249 mAppCats.insert( appname, newgroup ); 219 mAppCats.insert( appname, newgroup );
250 emit categoryAdded( *this, appname, uid ); 220 emit categoryAdded( *this, appname, uid );
251 return uid; 221 return uid;
252 } 222 }
253 223
254 CategoryGroup &cats = *appIt; 224 CategoryGroup &cats = *appIt;
255 int uid = cats.add( catname ); 225 int uid = cats.add( catname );
256 if ( !uid ) 226 if ( !uid )
257 return 0; 227 return 0;
258 emit categoryAdded( *this, appname, uid ); 228 emit categoryAdded( *this, appname, uid );
259 return uid; 229 return uid;
260} 230}
261 231
262int Categories::addGlobalCategory( const QString &catname, int uid ) 232int Categories::addGlobalCategory( const QString &catname, int uid )
263{ 233{
264 mGlobalCats.add( uid, catname ); 234 mGlobalCats.add( uid, catname );
265 emit categoryAdded( *this, QString::null, uid ); 235 emit categoryAdded( *this, QString::null, uid );
266 return uid; 236 return uid;
267} 237}
268 238
269int Categories::addGlobalCategory( const QString &catname ) 239int Categories::addGlobalCategory( const QString &catname )
270{ 240{
271 int uid = mGlobalCats.add( catname ); 241 int uid = mGlobalCats.add( catname );
272 if ( !uid ) 242 if ( !uid )
273 return 0; 243 return 0;
274 emit categoryAdded( *this, QString::null, uid ); 244 emit categoryAdded( *this, QString::null, uid );
275 return uid; 245 return uid;
276} 246}
277 247
278/** Removes the category from the application; if it is not found 248/** Removes the category from the application; if it is not found
279 * in the application, then it attempts to remove it from 249 * in the application, then it attempts to remove it from
280 * the global list 250 * the global list
281 */ 251 */
282bool Categories::removeCategory( const QString &appname, 252bool Categories::removeCategory( const QString &appname,
283 const QString &catname, 253 const QString &catname,
284 bool checkGlobal ) 254 bool checkGlobal )
285{ 255{
286 QMap< QString, CategoryGroup >::Iterator 256 QMap< QString, CategoryGroup >::Iterator
287 appIt = mAppCats.find( appname ); 257 appIt = mAppCats.find( appname );
288 if ( appIt != mAppCats.end() ) { 258 if ( appIt != mAppCats.end() ) {
289 CategoryGroup &cats = *appIt; 259 CategoryGroup &cats = *appIt;
290 int uid = cats.id( catname ); 260 int uid = cats.id( catname );
291 if ( cats.remove( uid ) ) { 261 if ( cats.remove( uid ) ) {
292 emit categoryRemoved( *this, appname, uid ); 262 emit categoryRemoved( *this, appname, uid );
293 return TRUE; 263 return TRUE;
294 } 264 }
295 } 265 }
296 if ( !checkGlobal ) 266 if ( !checkGlobal )
297 return FALSE; 267 return FALSE;
298 return removeGlobalCategory( catname ); 268 return removeGlobalCategory( catname );
299} 269}
300 270
301bool Categories::removeCategory( const QString &appname, int uid ) 271bool Categories::removeCategory( const QString &appname, int uid )
302{ 272{
303 QMap< QString, CategoryGroup >::Iterator 273 QMap< QString, CategoryGroup >::Iterator
304 appIt = mAppCats.find( appname ); 274 appIt = mAppCats.find( appname );
305 if ( appIt != mAppCats.end() ) { 275 if ( appIt != mAppCats.end() ) {
306 CategoryGroup &cats = *appIt; 276 CategoryGroup &cats = *appIt;
307 if ( cats.remove( uid ) ) { 277 if ( cats.remove( uid ) ) {
308 emit categoryRemoved( *this, appname, uid ); 278 emit categoryRemoved( *this, appname, uid );
309 return TRUE; 279 return TRUE;
310 } 280 }
311 } 281 }
312 return FALSE; 282 return FALSE;
313} 283}
314 284
315bool Categories::removeGlobalCategory( const QString &catname ) 285bool Categories::removeGlobalCategory( const QString &catname )
316{ 286{
317 int uid = mGlobalCats.id( catname ); 287 int uid = mGlobalCats.id( catname );
318 if ( mGlobalCats.remove( uid ) ) { 288 if ( mGlobalCats.remove( uid ) ) {
319 emit categoryRemoved( *this, QString::null, uid ); 289 emit categoryRemoved( *this, QString::null, uid );
320 return TRUE; 290 return TRUE;
321 } 291 }
322 return FALSE; 292 return FALSE;
323} 293}
324 294
325 295
326bool Categories::removeGlobalCategory( int uid ) 296bool Categories::removeGlobalCategory( int uid )
327{ 297{
328 if ( mGlobalCats.remove( uid ) ) { 298 if ( mGlobalCats.remove( uid ) ) {
329 emit categoryRemoved( *this, QString::null, uid ); 299 emit categoryRemoved( *this, QString::null, uid );
330 return TRUE; 300 return TRUE;
331 } 301 }
332 return FALSE; 302 return FALSE;
333} 303}
334 304
335/** Returns the sorted list of all categories that are associated with 305/** Returns the sorted list of all categories that are associated with
336 * the app. If includeGlobal parameter is TRUE then the returned 306 * the app. If includeGlobal parameter is TRUE then the returned
337 * categories will include the global category items. 307 * categories will include the global category items.
338 */ 308 */
339QStringList Categories::labels( const QString &app, 309QStringList Categories::labels( const QString &app,
340 bool includeGlobal, 310 bool includeGlobal,
341 ExtraLabels extra ) const 311 ExtraLabels extra ) const
342{ 312{
343 QMap< QString, CategoryGroup >::ConstIterator 313 QMap< QString, CategoryGroup >::ConstIterator
344 appIt = mAppCats.find( app ); 314 appIt = mAppCats.find( app );
345 QStringList cats; 315 QStringList cats;
316
317 if ( appIt != mAppCats.end() )
318 cats += (*appIt).labels();
319 else qDebug("Categories::labels didn't find app %s", app.latin1() );
320 if ( includeGlobal )
321 cats += mGlobalCats.labels();
322
323 cats.sort();
346 switch ( extra ) { 324 switch ( extra ) {
347 case NoExtra: break; 325 case NoExtra: break;
348 case AllUnfiled: 326 case AllUnfiled:
349 cats.append( tr("All") ); 327 cats.append( tr("All") );
350 cats.append( tr("Unfiled") ); 328 cats.append( tr("Unfiled") );
351 break; 329 break;
352 case AllLabel: 330 case AllLabel:
353 cats.append( tr("All") ); 331 cats.append( tr("All") );
354 break; 332 break;
355 case UnfiledLabel: 333 case UnfiledLabel:
356 cats.append( tr("Unfiled") ); 334 cats.append( tr("Unfiled") );
357 break; 335 break;
358 } 336 }
359 if ( appIt != mAppCats.end() ) 337
360 cats += (*appIt).labels();
361 else qDebug("Categories::labels didn't find app %s", app.latin1() );
362 if ( includeGlobal )
363 cats += mGlobalCats.labels();
364 // I don't think a sorted list is useful, the user might find prefer
365 // it in the original order.
366// cats.sort();
367 return cats; 338 return cats;
368} 339}
369 340
370QString Categories::label( const QString &app, int id ) const 341QString Categories::label( const QString &app, int id ) const
371{ 342{
372 if ( mGlobalCats.contains( id ) ) 343 if ( mGlobalCats.contains( id ) )
373 return mGlobalCats.label( id ); 344 return mGlobalCats.label( id );
374 QMap< QString, CategoryGroup >::ConstIterator 345 QMap< QString, CategoryGroup >::ConstIterator
375 appIt = mAppCats.find( app ); 346 appIt = mAppCats.find( app );
376 if ( appIt == mAppCats.end() ) 347 if ( appIt == mAppCats.end() )
377 return QString::null; 348 return QString::null;
378 return (*appIt).label( id ); 349 return (*appIt).label( id );
379} 350}
380 351
381QStringList Categories::labels( const QString & app,
382 const QArray<int> &catids ) const
383{
384 QStringList strs = mGlobalCats.labels( catids );
385 strs += mAppCats[app].labels( catids );
386 return strs;
387}
388
389/** Returns a single string associated with the cat ids for display in 352/** Returns a single string associated with the cat ids for display in
390 * a combobox or any area that requires one string. If catids are empty 353 * a combobox or any area that requires one string. If catids are empty
391 * then "Unfiled" will be returned. If multiple categories are assigned 354 * then "Unfiled" will be returned. If multiple categories are assigned
392 * the first cat id is shown with " (multi)" appended to the string. 355 * the first cat id is shown with " (multi)" appended to the string.
393 */ 356 */
394QString Categories::displaySingle( const QString &app, 357QString Categories::displaySingle( const QString &app,
395 const QArray<int> &catids, 358 const QArray<int> &catids,
396 DisplaySingle display ) const 359 DisplaySingle display ) const
397{ 360{
398 QStringList strs = labels( app, catids ); 361 QStringList strs = labels( app, catids );
399 if ( !strs.count() ) 362 if ( !strs.count() )
400 return tr("Unfiled"); 363 return tr("Unfiled");
401 strs.sort(); 364 strs.sort();
402 QString r; 365 QString r;
403 if ( strs.count() > 1 ) { 366 if ( strs.count() > 1 ) {
404 switch ( display ) { 367 switch ( display ) {
405 case ShowFirst: 368 case ShowFirst:
406 r = strs.first(); 369 r = strs.first();
407 break; 370 break;
408 case ShowMulti: 371 case ShowMulti:
409 r = strs.first() + tr(" (multi.)"); 372 r = strs.first() + tr(" (multi.)");
410 break; 373 break;
411 case ShowAll: 374 case ShowAll:
412 r = strs.join(" "); 375 r = strs.join(" ");
413 break; 376 break;
414 } 377 }
415 } 378 }
416 else r = strs.first(); 379 else r = strs.first();
417 return r; 380 return r;
418} 381}
419 382
420QArray<int> Categories::ids( const QString &app ) const 383QArray<int> Categories::ids( const QString &app, const QStringList &labels) const
421{
422 QArray<int> allIds = mGlobalCats.ids();
423 QArray<int> appIds = mAppCats[app].ids();
424
425 // we should make the guarentee that the ids are in the
426 // same order as the labels, (i.e. app cats then global)
427 // otherwise there is no point in having these two separate functions.
428 uint appSize = appIds.size();
429 appIds.resize( appSize + allIds.size() );
430 for ( uint i = appSize; i < appIds.size(); ++i )
431 appIds[int(i)] = allIds[int(i - appSize)];
432
433 return appIds;
434}
435
436QArray<int> Categories::ids( const QString &app, const QStringList &cats ) const
437{ 384{
438 QArray<int> allIds = mGlobalCats.ids( cats ); 385 QArray<int> results;
439 QArray<int> appIds = mAppCats[app].ids( cats ); 386 QStringList::ConstIterator it;
440 387 int i;
441 uint appSize = appIds.size(); 388
442 appIds.resize( appSize + allIds.size() ); 389 for ( i=0, it=labels.begin(); it!=labels.end(); i++, ++it ) {
443 for ( uint i = appSize; i < appIds.size(); ++i ) 390 int value = id( app, *it );
444 appIds[int(i)] = allIds[int(i - appSize)]; 391 if ( value != 0 ) {
445 392 int tmp = results.size();
446 return appIds; 393 results.resize( tmp + 1 );
394 results[ tmp ] = value;
395 }
396 }
397 return results;
447} 398}
448 399
449int Categories::id( const QString &app, const QString &cat ) const 400int Categories::id( const QString &app, const QString &cat ) const
450{ 401{
451 if ( cat == tr("Unfiled") || cat.contains( tr(" (multi.)") ) ) 402 if ( cat == tr("Unfiled") || cat.contains( tr(" (multi.)") ) )
452 return 0; 403 return 0;
453 int uid = mGlobalCats.id( cat ); 404 int uid = mGlobalCats.id( cat );
454 if ( uid != 0 ) 405 if ( uid != 0 )
455 return uid; 406 return uid;
456 return mAppCats[app].id( cat ); 407 return mAppCats[app].id( cat );
457} 408}
458 409
459 410
460/** Return TRUE if renaming succeeded; FALSE if app name not found, 411/** Return TRUE if renaming succeeded; FALSE if app name not found,
461 * or if there was a name conflict 412 * or if there was a name conflict
462 */ 413 */
463bool Categories::renameCategory( const QString &appname, 414bool Categories::renameCategory( const QString &appname,
464 const QString &oldName, 415 const QString &oldName,
465 const QString &newName ) 416 const QString &newName )
466{ 417{
467 QMap< QString, CategoryGroup >::Iterator 418 QMap< QString, CategoryGroup >::Iterator
468 appIt = mAppCats.find( appname ); 419 appIt = mAppCats.find( appname );
469 420
470 if ( appIt != mAppCats.end() ) { 421 if ( appIt != mAppCats.end() ) {
471 CategoryGroup &cats = *appIt; 422 CategoryGroup &cats = *appIt;
472 int id = cats.id( oldName ); 423 int id = cats.id( oldName );
473 if ( id != 0 && cats.rename( id, newName ) ) { 424 if ( id != 0 && cats.rename( id, newName ) ) {
474 emit categoryRenamed( *this, appname, id ); 425 emit categoryRenamed( *this, appname, id );
475 return TRUE; 426 return TRUE;
476 } 427 }
477 } 428 }
478 return renameGlobalCategory( oldName, newName ); 429 return renameGlobalCategory( oldName, newName );
479} 430}
480 431
481bool Categories::renameGlobalCategory( const QString &oldName, 432bool Categories::renameGlobalCategory( const QString &oldName,
482 const QString &newName ) 433 const QString &newName )
483{ 434{
484 int uid = mGlobalCats.id( oldName ); 435 int uid = mGlobalCats.id( oldName );
485 if ( uid != 0 && mGlobalCats.rename( uid, newName ) ) { 436 if ( uid != 0 && mGlobalCats.rename( uid, newName ) ) {
486 emit categoryRenamed( *this, QString::null, uid ); 437 emit categoryRenamed( *this, QString::null, uid );
487 return TRUE; 438 return TRUE;
488 } 439 }
489 return FALSE; 440 return FALSE;
490} 441}
491 442
492void Categories::setGlobal( const QString &appname, 443void Categories::setGlobal( const QString &appname,
493 const QString &catname, 444 const QString &catname,
494 bool global ) 445 bool global )
495{ 446{
496 // if in global and should be in app; then move it 447 // if in global and should be in app; then move it
497 if ( mGlobalCats.contains( catname ) && !global ) { 448 if ( mGlobalCats.contains( catname ) && !global ) {
498 mGlobalCats.remove( catname ); 449 mGlobalCats.remove( catname );
499 addCategory( appname, catname ); 450 addCategory( appname, catname );
500 return ; 451 return ;
501 } 452 }
502 453
503 // if in app and should be in global, then move it 454 // if in app and should be in global, then move it
504 if ( !global ) 455 if ( !global )
505 return; 456 return;
506 if ( removeCategory( appname, catname, FALSE ) ) 457 if ( removeCategory( appname, catname, FALSE ) )
507 addGlobalCategory( catname ); 458 addGlobalCategory( catname );
508} 459}
509 460
510bool Categories::isGlobal( const QString &catname ) const 461bool Categories::isGlobal( const QString &catname ) const
511{ 462{
512 return mGlobalCats.contains( catname ); 463 return mGlobalCats.contains( catname );
513} 464}
514 465
515 466
516/** Returns true if the catname is associated with any application 467/** Returns true if the catname is associated with any application
517 */ 468 */
518bool Categories::exists( const QString &catname ) const 469bool Categories::exists( const QString &catname ) const
519{ 470{
520 if ( isGlobal(catname) ) 471 if ( isGlobal(catname) )
521 return TRUE; 472 return TRUE;
522 473
523 for ( QMap<QString, CategoryGroup>::ConstIterator appsIt = mAppCats.begin(); appsIt != mAppCats.end(); ++appsIt ) 474 for ( QMap<QString, CategoryGroup>::ConstIterator appsIt = mAppCats.begin(); appsIt != mAppCats.end(); ++appsIt )
524 if ( exists( appsIt.key(), catname ) ) 475 if ( exists( appsIt.key(), catname ) )
525 return TRUE; 476 return TRUE;
526 477
527 return FALSE; 478 return FALSE;
528} 479}
529 480
530bool Categories::exists( const QString &appname, 481bool Categories::exists( const QString &appname,
531 const QString &catname) const 482 const QString &catname) const
532{ 483{
533 QMap< QString, CategoryGroup >::ConstIterator 484 QMap< QString, CategoryGroup >::ConstIterator
534 appIt = mAppCats.find( appname ); 485 appIt = mAppCats.find( appname );
535 486
536 if ( appIt == mAppCats.end() ) 487 if ( appIt == mAppCats.end() )
537 return FALSE; 488 return FALSE;
538 489
539 return (*appIt).contains( catname ); 490 return (*appIt).contains( catname );
540} 491}
541 492
493
542bool Categories::save( const QString &fname ) const 494bool Categories::save( const QString &fname ) const
543{ 495{
544 QFile file( fname ); 496 QString strNewFile = fname + ".new";
545 if ( !file.open( IO_WriteOnly ) ) { 497 QFile f( strNewFile );
498 QString out;
499 int total_written;
500
501 if ( !f.open( IO_WriteOnly|IO_Raw ) ) {
546 qWarning("Unable to write to %s", fname.latin1()); 502 qWarning("Unable to write to %s", fname.latin1());
547 return FALSE; 503 return FALSE;
548 } 504 }
549 505
550 QTextStream ts( &file ); 506 out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
551 ts << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; 507 out += "<!DOCTYPE CategoryList>\n";
552 ts << "<!DOCTYPE CategoryList>" << endl; 508
509 out += "<Categories>\n";
553 510
554 ts << "<Categories>" << endl;
555 for ( QMap<int, QString>::ConstIterator git = mGlobalCats.idMap().begin(); 511 for ( QMap<int, QString>::ConstIterator git = mGlobalCats.idMap().begin();
556 git != mGlobalCats.idMap().end(); ++git ) 512 git != mGlobalCats.idMap().end(); ++git )
557 ts << "<Category id=\"" << git.key() << "\"" 513 out += "<Category id=\"" + QString::number(git.key()) + "\"" +
558 << " name=\"" << escapeString(*git) << "\" />" << endl; 514 " name=\"" + escapeString(*git) + "\" />\n";
559 515
560 for ( QMap<QString, CategoryGroup>::ConstIterator appsIt=mAppCats.begin(); 516 for ( QMap<QString, CategoryGroup>::ConstIterator appsIt=mAppCats.begin();
561 appsIt != mAppCats.end(); ++appsIt ) { 517 appsIt != mAppCats.end(); ++appsIt ) {
562 const QString &app = appsIt.key(); 518 const QString &app = appsIt.key();
563 const QMap<int, QString> &appcats = (*appsIt).idMap(); 519 const QMap<int, QString> &appcats = (*appsIt).idMap();
564 for ( QMap<int, QString>::ConstIterator appcatit = appcats.begin(); 520 for ( QMap<int, QString>::ConstIterator appcatit = appcats.begin();
565 appcatit != appcats.end(); ++appcatit ) 521 appcatit != appcats.end(); ++appcatit )
566 ts << "<Category id=\"" << appcatit.key() << "\"" 522 out += "<Category id=\"" + QString::number(appcatit.key()) + "\"" +
567 << " app=\"" << escapeString(app) << "\"" 523 " app=\"" + escapeString(app) + "\"" +
568 << " name=\"" << escapeString(*appcatit) << "\" />" << endl; 524 " name=\"" + escapeString(*appcatit) + "\" />\n";
525 }
526 out += "</Categories>\n";
527
528 QCString cstr = out.utf8();
529 total_written = f.writeBlock( cstr.data(), cstr.length() );
530 if ( total_written != int(cstr.length()) ) {
531 f.close();
532 QFile::remove( strNewFile );
533 return FALSE;
534 }
535 f.close();
536
537 if ( ::rename( strNewFile.latin1(), fname.latin1() ) < 0 ) {
538 qWarning( "problem renaming file %s to %s",
539 strNewFile.latin1(), fname.latin1());
540 // remove the tmp file...
541 QFile::remove( strNewFile );
569 } 542 }
570 ts << "</Categories>" << endl;
571 543
572 file.close();
573 return TRUE; 544 return TRUE;
574} 545}
575 546
576bool Categories::load( const QString &fname ) 547bool Categories::load( const QString &fname )
577{ 548{
578 QFile file( fname ); 549 QFile file( fname );
579 if ( !file.open( IO_ReadOnly ) ) { 550 if ( !file.open( IO_ReadOnly ) ) {
580 qWarning("Unable to open %s", fname.latin1()); 551 qWarning("Unable to open %s", fname.latin1());
552
553 addGlobalCategory(tr("Business"));
554 addGlobalCategory(tr("Personal"));
555 save(fname);
556
581 return FALSE; 557 return FALSE;
582 } 558 }
583 559
584 clear(); 560 clear();
585 QByteArray ba = file.readAll(); 561 QByteArray ba = file.readAll();
586 QString data = QString::fromUtf8( ba.data(), ba.size() ); 562 QString data = QString::fromUtf8( ba.data(), ba.size() );
587 QChar *uc = (QChar *)data.unicode(); 563 QChar *uc = (QChar *)data.unicode();
588 int len = data.length(); 564 int len = data.length();
589 565
590 // QTime t; 566 // QTime t;
591 // t.start(); 567 // t.start();
592 QString name; 568 QString name;
593 QString id; 569 QString id;
594 QString app; 570 QString app;
595 int i = 0; 571 int i = 0;
596 while ( (i = data.find( "<Category ", i)) != -1 ) { 572 while ( (i = data.find( "<Category ", i)) != -1 ) {
597 573
598 i += 10; 574 i += 10;
599 name = QString::null; 575 name = QString::null;
600 app = QString::null; 576 app = QString::null;
601 while ( 1 ) { 577 while ( 1 ) {
602 // skip white space 578 // skip white space
603 while ( i < len && 579 while ( i < len &&
604 (uc[i] == ' ' || uc[i] == '\n' || uc[i] == '\r') ) 580 (uc[i] == ' ' || uc[i] == '\n' || uc[i] == '\r') )
605 i++; 581 i++;
606 // if at the end, then done 582 // if at the end, then done
607 if ( i >= len-2 || (uc[i] == '/' && uc[i+1] == '>') ) 583 if ( i >= len-2 || (uc[i] == '/' && uc[i+1] == '>') )
608 break; 584 break;
609 // we have another attribute read it. 585 // we have another attribute read it.
610 int j = i; 586 int j = i;
611 while ( j < len && uc[j] != '=' ) 587 while ( j < len && uc[j] != '=' )
612 j++; 588 j++;
613 QString attr = QConstString( uc+i, j-i ).string(); 589 QString attr = QConstString( uc+i, j-i ).string();
614 i = ++j; // skip = 590 i = ++j; // skip =
615 while ( i < len && uc[i] != '"' ) 591 while ( i < len && uc[i] != '"' )
616 i++; 592 i++;
617 j = ++i; 593 j = ++i;
618 while ( j < len && uc[j] != '"' ) 594 while ( j < len && uc[j] != '"' )
619 j++; 595 j++;
620 QString value = Qtopia::plainString( QConstString( uc+i, j-i ).string() ); 596 QString value = Qtopia::plainString( QConstString( uc+i, j-i ).string() );
621 i = j + 1; 597 i = j + 1;
622 598
623 // qDebug("attr='%s' value='%s'", attr.latin1(), value.latin1() ); 599 // qDebug("attr='%s' value='%s'", attr.latin1(), value.latin1() );
624 if ( attr == "id" ) 600 if ( attr == "id" )
625 id = value; 601 id = value;
626 else if ( attr == "app" ) 602 else if ( attr == "app" )
627 app = value; 603 app = value;
628 604
629 else if ( attr == "name" ) 605 else if ( attr == "name" )
630 name = value; 606 name = value;
631 } 607 }
632 608
633 if ( name.isNull() || id.isNull() ) { 609 if ( name.isNull() || id.isNull() ) {
634 qWarning("No name or id in the category"); 610 qWarning("No name or id in the category");
635 continue; 611 continue;
636 } 612 }
637 if ( app.isNull() ) 613 if ( app.isNull() )
638 mGlobalCats.add( id.toInt(), name ); 614 mGlobalCats.add( id.toInt(), name );
639 else 615 else
640 mAppCats[ app ].add( id.toInt(), name ); 616 mAppCats[ app ].add( id.toInt(), name );
641 } 617 }
642 618
643 return TRUE; 619 return TRUE;
644} 620}
645 621
646void Categories::clear() 622void Categories::clear()
647{ 623{
648 mGlobalCats.clear(); 624 mGlobalCats.clear();
649 mAppCats.clear(); 625 mAppCats.clear();
650} 626}
651 627
652void Categories::dump() const 628void Categories::dump() const
653{ 629{
654 qDebug("\tglobal categories = %s", mGlobalCats.labels().join(", ").latin1() ); 630 qDebug("\tglobal categories = %s", mGlobalCats.labels().join(", ").latin1() );
655 for ( QMap<QString, CategoryGroup>::ConstIterator appsIt = mAppCats.begin(); appsIt != mAppCats.end(); ++appsIt ) { 631 for ( QMap<QString, CategoryGroup>::ConstIterator appsIt = mAppCats.begin(); appsIt != mAppCats.end(); ++appsIt ) {
656 const QString &app = appsIt.key(); 632 const QString &app = appsIt.key();
657 QStringList appcats = (*appsIt).labels(); 633 QStringList appcats = (*appsIt).labels();
658 qDebug("\tapp = %s\tcategories = %s", app.latin1(), 634 qDebug("\tapp = %s\tcategories = %s", app.latin1(),
659 appcats.join(", ").latin1() ); 635 appcats.join(", ").latin1() );
660 636
661 } 637 }
662} 638}
663 639
664QStringList CheckedListView::checked() const 640QStringList CheckedListView::checked() const
665{ 641{
666 QStringList strs; 642 QStringList strs;
667 for ( QCheckListItem *i = (QCheckListItem *) firstChild(); 643 for ( QCheckListItem *i = (QCheckListItem *) firstChild();
668 i; i = (QCheckListItem *)i->nextSibling() ) 644 i; i = (QCheckListItem *)i->nextSibling() )
669 if ( i->isOn() ) 645 if ( i->isOn() )
670 strs += i->text( 0 ); 646 strs += i->text( 0 );
671 return strs; 647 return strs;
672} 648}
673 649
674void CheckedListView::addCheckableList( const QStringList &options ) 650void CheckedListView::addCheckableList( const QStringList &options )
675{ 651{
676 for ( QStringList::ConstIterator it = options.begin(); 652 for ( QStringList::ConstIterator it = options.begin();
diff --git a/library/backend/categories.h b/library/backend/categories.h
index 82d765b..ba65ee3 100644
--- a/library/backend/categories.h
+++ b/library/backend/categories.h
@@ -1,232 +1,226 @@
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 7** GNU General Public License version 2 as published by the Free
8** Software Foundation and appearing in the file LICENSE.GPL included 8** Software Foundation and appearing in the file LICENSE.GPL included
9** in the packaging of this file. 9** in the packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
12** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A 12** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
13** PARTICULAR PURPOSE. 13** PARTICULAR PURPOSE.
14** 14**
15** See http://www.trolltech.com/gpl/ for GPL licensing information. 15** See http://www.trolltech.com/gpl/ for GPL licensing information.
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 QTPALMTOP_CATEGORIES_H 22#ifndef QTPALMTOP_CATEGORIES_H
23#define QTPALMTOP_CATEGORIES_H 23#define QTPALMTOP_CATEGORIES_H
24 24
25#include <qstring.h> 25#include <qstring.h>
26#include <qstringlist.h> 26#include <qstringlist.h>
27#include <qmap.h> 27#include <qmap.h>
28#include <qlistview.h> 28#include <qlistview.h>
29#include <qarray.h> 29#include <qarray.h>
30#include "qpcglobal.h" 30#include "qpcglobal.h"
31#include "palmtopuidgen.h" 31#include "palmtopuidgen.h"
32 32
33class CategoryGroup; 33class CategoryGroup;
34 34
35#if defined(QPC_TEMPLATEDLL) 35#if defined(QPC_TEMPLATEDLL)
36// MOC_SKIP_BEGIN 36// MOC_SKIP_BEGIN
37template class QPC_EXPORT QMap<int, QString>; 37template class QPC_EXPORT QMap<int, QString>;
38template class QPC_EXPORT QMap<QString, int>; 38template class QPC_EXPORT QMap<QString, int>;
39template class QPC_EXPORT QMap< QString, CategoryGroup >; 39template class QPC_EXPORT QMap< QString, CategoryGroup >;
40// MOC_SKIP_END 40// MOC_SKIP_END
41#endif 41#endif
42 42
43class QPC_EXPORT CategoryGroup 43class QPC_EXPORT CategoryGroup
44{ 44{
45 friend class Categories; 45 friend class Categories;
46public: 46public:
47 CategoryGroup(): mIdLabelMap(), mLabelIdMap() { } 47 CategoryGroup(): mIdLabelMap(), mLabelIdMap() { }
48 CategoryGroup( const CategoryGroup &c ) : 48 CategoryGroup( const CategoryGroup &c ) :
49 mIdLabelMap( c.mIdLabelMap), mLabelIdMap( c.mLabelIdMap ) { } 49 mIdLabelMap( c.mIdLabelMap), mLabelIdMap( c.mLabelIdMap ) { }
50 50
51 void clear() { mIdLabelMap.clear(); mLabelIdMap.clear(); } 51 void clear() { mIdLabelMap.clear(); mLabelIdMap.clear(); }
52 52
53 int add( const QString &label ); 53 int add( const QString &label );
54 bool add( int uid, const QString &label ); 54 bool add( int uid, const QString &label );
55 55
56 bool remove( const QString &label ); 56 bool remove( const QString &label );
57 bool remove( int uid ); 57 bool remove( int uid );
58 58
59 bool rename( int uid, const QString &newLabel ); 59 bool rename( int uid, const QString &newLabel );
60 bool rename( const QString &oldLabel, const QString &newLabel ); 60 bool rename( const QString &oldLabel, const QString &newLabel );
61 61
62 bool contains(int id) const; 62 bool contains(int id) const;
63 bool contains(const QString &label) const; 63 bool contains(const QString &label) const;
64 64
65 /** Returns label associated with the uid or QString::null if 65 /** Returns label associated with the uid or QString::null if
66 * not found 66 * not found
67 */ 67 */
68 const QString &label(int id) const; 68 const QString &label(int id) const;
69 /** Returns the uid associated with label or 0 if not found */ 69 /** Returns the uid associated with label or 0 if not found */
70 int id(const QString &label) const; 70 int id(const QString &label) const;
71 71
72 /** Returns a sorted list of labels */ 72 /** Returns a sorted list of labels */
73 QStringList labels() const; 73 QStringList labels() const;
74 QArray<int> ids( const QStringList &cats ) const; 74
75 QArray<int> ids() const;
76 QStringList labels( const QArray<int> &catids ) const; 75 QStringList labels( const QArray<int> &catids ) const;
77 76
78 const QMap<int, QString> &idMap() const { return mIdLabelMap; } 77 const QMap<int, QString> &idMap() const { return mIdLabelMap; }
79 78
80private: 79private:
81 void insert( int uid, const QString &label ); 80 void insert( int uid, const QString &label );
82 QMap<int, QString> mIdLabelMap; 81 QMap<int, QString> mIdLabelMap;
83 QMap<QString, int> mLabelIdMap; 82 QMap<QString, int> mLabelIdMap;
84 83
85 static Qtopia::UidGen &uidGen() { return sUidGen; } 84 static Qtopia::UidGen &uidGen() { return sUidGen; }
86 static Qtopia::UidGen sUidGen; 85 static Qtopia::UidGen sUidGen;
87}; 86};
88 87
89/** Map from application name to categories */ 88/** Map from application name to categories */
90class QPC_EXPORT Categories : public QObject 89class QPC_EXPORT Categories : public QObject
91{ 90{
92 Q_OBJECT 91 Q_OBJECT
93public: 92public:
94 Categories( QObject *parent=0, const char *name = 0 ) 93 Categories( QObject *parent=0, const char *name = 0 )
95 : QObject( parent, name ), mGlobalCats(), mAppCats() { } 94 : QObject( parent, name ), mGlobalCats(), mAppCats() { }
96 Categories( const Categories &copyFrom ) : QObject( copyFrom.parent() ), 95 Categories( const Categories &copyFrom ) : QObject( copyFrom.parent() ),
97 mGlobalCats( copyFrom.mGlobalCats ), 96 mGlobalCats( copyFrom.mGlobalCats ),
98 mAppCats( copyFrom.mAppCats ) { } 97 mAppCats( copyFrom.mAppCats ) { }
99 virtual ~Categories() { } 98 virtual ~Categories() { }
100 99
101 Categories &operator= ( const Categories &c ) 100 Categories &operator= ( const Categories &c )
102{ mAppCats = c.mAppCats; mGlobalCats = c.mGlobalCats; return *this; } 101{ mAppCats = c.mAppCats; mGlobalCats = c.mGlobalCats; return *this; }
103 102
104 void clear(); 103 void clear();
105 104
106 /** Add the category name as long as it doesn't already exist 105 /** Add the category name as long as it doesn't already exist
107 * locally or globally. Return UID if added, 0 if conflicts 106 * locally or globally. Return UID if added, 0 if conflicts
108 * (error). 107 * (error).
109 */ 108 */
110 int addCategory( const QString &appname, const QString &catname); 109 int addCategory( const QString &appname, const QString &catname);
111 /** Add the category name as long as it doesn't already exist 110 /** Add the category name as long as it doesn't already exist
112 * locally or globally. Return UID if added, 0 if conflicts 111 * locally or globally. Return UID if added, 0 if conflicts
113 * (error). 112 * (error).
114 */ 113 */
115 int addCategory( const QString &appname, const QString &catname, int uid); 114 int addCategory( const QString &appname, const QString &catname, int uid);
116 /** Add the global category just checking that it doesn't 115 /** Add the global category just checking that it doesn't
117 * already exist globally. Return UID if added, 0 if conflicts. 116 * already exist globally. Return UID if added, 0 if conflicts.
118 */ 117 */
119 int addGlobalCategory( const QString &catname ); 118 int addGlobalCategory( const QString &catname );
120 /** Add the global category just checking that it doesn't 119 /** Add the global category just checking that it doesn't
121 * already exist globally. Return UID if added, 0 if conflicts. 120 * already exist globally. Return UID if added, 0 if conflicts.
122 */ 121 */
123 int addGlobalCategory( const QString &catname, int uid ); 122 int addGlobalCategory( const QString &catname, int uid );
124 /** Removes the category from the application; if it is not found 123 /** Removes the category from the application; if it is not found
125 * in the application, then it removes it from the global list 124 * in the application, then it removes it from the global list
126 */ 125 */
127 bool removeCategory( const QString &appName, const QString &catName, 126 bool removeCategory( const QString &appName, const QString &catName,
128 bool checkGlobal = TRUE); 127 bool checkGlobal = TRUE);
129 bool removeCategory( const QString &appName, int uid ); 128 bool removeCategory( const QString &appName, int uid );
130 bool removeGlobalCategory( const QString &catName ); 129 bool removeGlobalCategory( const QString &catName );
131 bool removeGlobalCategory( int uid ); 130 bool removeGlobalCategory( int uid );
132 131
133 QArray<int> ids( const QString &app ) const; 132 QArray<int> ids( const QString &app, const QStringList &labels) const;
134 QArray<int> ids( const QString &app, 133
135 const QStringList &cats ) const;
136 /** Returns the id associated with the app */ 134 /** Returns the id associated with the app */
137 int id( const QString &app, const QString &cat ) const; 135 int id( const QString &app, const QString &cat ) const;
138 /** Returns the label associated with the id */ 136 /** Returns the label associated with the id */
139 QString label( const QString &app, int id ) const; 137 QString label( const QString &app, int id ) const;
140 138
141 enum ExtraLabels { NoExtra, AllUnfiled, AllLabel, UnfiledLabel }; 139 enum ExtraLabels { NoExtra, AllUnfiled, AllLabel, UnfiledLabel };
142 /** Returns the sorted list of all categories that are 140 /** Returns the sorted list of all categories that are
143 * associated with the app. 141 * associated with the app.
144 * If includeGlobal parameter is TRUE then the returned 142 * If includeGlobal parameter is TRUE then the returned
145 * categories will include the global category items. 143 * categories will include the global category items.
146 * If extra = NoExtra, then 144 * If extra = NoExtra, then
147 * If extra = AllUnfiled, then All and Unfiled will be prepended to 145 * If extra = AllUnfiled, then All and Unfiled will be prepended to
148 * the list 146 * the list
149 * If extra = AllLabel, then All is prepended 147 * If extra = AllLabel, then All is prepended
150 * If extra = UnfiledLabel, then Unfiled is prepended 148 * If extra = UnfiledLabel, then Unfiled is prepended
151 */ 149 */
152 QStringList labels( const QString &app, 150 QStringList labels( const QString &app,
153 bool includeGlobal = TRUE, 151 bool includeGlobal = TRUE,
154 ExtraLabels extra = NoExtra ) const; 152 ExtraLabels extra = NoExtra ) const;
155 153
156 /** Returns the labels of the categories associated with the uids */
157 QStringList labels( const QString & app,
158 const QArray<int> &catids ) const;
159
160 enum DisplaySingle { ShowMulti, ShowAll, ShowFirst }; 154 enum DisplaySingle { ShowMulti, ShowAll, ShowFirst };
161 155
162 /** Returns a single string associated with the cat ids for display in 156 /** Returns a single string associated with the cat ids for display in
163 * a combobox or any area that requires one string. If catids are empty 157 * a combobox or any area that requires one string. If catids are empty
164 * then "Unfiled" will be returned. If multiple categories are assigned 158 * then "Unfiled" will be returned. If multiple categories are assigned
165 * then the behavior depends on the DisplaySingle type. 159 * then the behavior depends on the DisplaySingle type.
166 * If /a display is set to ShowMulti then " (multi)" appended to the 160 * If /a display is set to ShowMulti then " (multi)" appended to the
167 * first string. If /a display is set to ShowAll, then a space seperated 161 * first string. If /a display is set to ShowAll, then a space seperated
168 * string is returned with all categories. If ShowFirst is returned, 162 * string is returned with all categories. If ShowFirst is returned,
169 * the just the first string is returned. 163 * the just the first string is returned.
170 */ 164 */
171 QString displaySingle( const QString &app, 165 QString displaySingle( const QString &app,
172 const QArray<int> &catids, 166 const QArray<int> &catids,
173 DisplaySingle display ) const; 167 DisplaySingle display ) const;
174 168
175 QStringList globalCategories() const { return mGlobalCats.labels();} 169 QStringList globalCategories() const { return mGlobalCats.labels();}
176 170
177 bool renameCategory( const QString &appname, 171 bool renameCategory( const QString &appname,
178 const QString &oldName, 172 const QString &oldName,
179 const QString &newName ); 173 const QString &newName );
180 bool renameGlobalCategory( const QString &oldName, 174 bool renameGlobalCategory( const QString &oldName,
181 const QString &newName ); 175 const QString &newName );
182 176
183 void setGlobal( const QString &appname, const QString &catname, 177 void setGlobal( const QString &appname, const QString &catname,
184 bool value ); 178 bool value );
185 bool isGlobal( const QString &catname ) const; 179 bool isGlobal( const QString &catname ) const;
186 180
187 181
188 /** Returns true if the catname is associated with any application 182 /** Returns true if the catname is associated with any application
189 */ 183 */
190 bool exists( const QString &catname ) const; 184 bool exists( const QString &catname ) const;
191 bool exists( const QString &appname, const QString &catname) const; 185 bool exists( const QString &appname, const QString &catname) const;
192 186
193 bool save( const QString &fname ) const; 187 bool save( const QString &fname ) const;
194 bool load( const QString &fname ); 188 bool load( const QString &fname );
195 189
196 // for debugging 190 // for debugging
197 void dump() const; 191 void dump() const;
198 192
199 const QMap<QString, CategoryGroup> &appGroupMap() const{ return mAppCats; } 193 const QMap<QString, CategoryGroup> &appGroupMap() const{ return mAppCats; }
200 const CategoryGroup &globalGroup() const { return mGlobalCats; } 194 const CategoryGroup &globalGroup() const { return mGlobalCats; }
201 195
202signals: 196signals:
203 /** emitted if added a category; 197 /** emitted if added a category;
204 * the second param is the application the category was added to 198 * the second param is the application the category was added to
205 * or null if global 199 * or null if global
206 * the third param is the uid of the newly added category 200 * the third param is the uid of the newly added category
207 */ 201 */
208 void categoryAdded( const Categories &, const QString &, int ); 202 void categoryAdded( const Categories &, const QString &, int );
209 /** emitted if removed a category 203 /** emitted if removed a category
210 * the second param is the application the category was removed from 204 * the second param is the application the category was removed from
211 * or null if global 205 * or null if global
212 * the third param is the uid of the removed category 206 * the third param is the uid of the removed category
213 */ 207 */
214 void categoryRemoved( const Categories &, const QString &, int ); 208 void categoryRemoved( const Categories &, const QString &, int );
215 /** emitted if a category is renamed; the second param is the uid of 209 /** emitted if a category is renamed; the second param is the uid of
216 * the removed category */ 210 * the removed category */
217 void categoryRenamed( const Categories &, const QString &, int ); 211 void categoryRenamed( const Categories &, const QString &, int );
218 212
219private: 213private:
220 CategoryGroup mGlobalCats; 214 CategoryGroup mGlobalCats;
221 QMap< QString, CategoryGroup > mAppCats; 215 QMap< QString, CategoryGroup > mAppCats;
222}; 216};
223 217
224class QPC_EXPORT CheckedListView : public QListView 218class QPC_EXPORT CheckedListView : public QListView
225{ 219{
226public: 220public:
227 void addCheckableList( const QStringList &options ); 221 void addCheckableList( const QStringList &options );
228 void setChecked( const QStringList &checked ); 222 void setChecked( const QStringList &checked );
229 QStringList checked() const; 223 QStringList checked() const;
230}; 224};
231 225
232#endif 226#endif
diff --git a/library/backend/contact.cpp b/library/backend/contact.cpp
index a5f10ab..b10b19a 100644
--- a/library/backend/contact.cpp
+++ b/library/backend/contact.cpp
@@ -1,119 +1,121 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 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#define QTOPIA_INTERNAL_CONTACT_MRE
22
21#include "contact.h" 23#include "contact.h"
22#include "vobject_p.h" 24#include "vobject_p.h"
23#include "qfiledirect_p.h" 25#include "qfiledirect_p.h"
24 26
25#include <qpe/stringutil.h> 27#include <qpe/stringutil.h>
26#include <qpe/timeconversion.h> 28#include <qpe/timeconversion.h>
27 29
28#include <qobject.h> 30#include <qobject.h>
29#include <qregexp.h> 31#include <qregexp.h>
30#include <qstylesheet.h> 32#include <qstylesheet.h>
31#include <qfileinfo.h> 33#include <qfileinfo.h>
32 34
33#include <stdio.h> 35#include <stdio.h>
34 36
35Qtopia::UidGen Contact::sUidGen( Qtopia::UidGen::Qtopia ); 37Qtopia::UidGen Contact::sUidGen( Qtopia::UidGen::Qtopia );
36 38
37Contact::Contact() 39Contact::Contact()
38 : Record(), mMap(), d( 0 ) 40 : Record(), mMap(), d( 0 )
39{ 41{
40} 42}
41 43
42Contact::Contact( const QMap<int, QString> &fromMap ) : 44Contact::Contact( const QMap<int, QString> &fromMap ) :
43 Record(), mMap( fromMap ), d( 0 ) 45 Record(), mMap( fromMap ), d( 0 )
44{ 46{
45 QString cats = mMap[ Qtopia::AddressCategory ]; 47 QString cats = mMap[ Qtopia::AddressCategory ];
46 if ( !cats.isEmpty() ) 48 if ( !cats.isEmpty() )
47 setCategories( idsFromString( cats ) ); 49 setCategories( idsFromString( cats ) );
48 QString uidStr = find( Qtopia::AddressUid ); 50 QString uidStr = find( Qtopia::AddressUid );
49 if ( uidStr.isEmpty() ) 51 if ( uidStr.isEmpty() )
50 setUid( uidGen().generate() ); 52 setUid( uidGen().generate() );
51 else 53 else
52 setUid( uidStr.toInt() ); 54 setUid( uidStr.toInt() );
53} 55}
54 56
55Contact::~Contact() 57Contact::~Contact()
56{ 58{
57} 59}
58 60
59QMap<int, QString> Contact::toMap() const 61QMap<int, QString> Contact::toMap() const
60{ 62{
61 QMap<int, QString> map = mMap; 63 QMap<int, QString> map = mMap;
62 map.insert( Qtopia::AddressCategory, idsToString( categories() )); 64 map.insert( Qtopia::AddressCategory, idsToString( categories() ));
63 return map; 65 return map;
64} 66}
65 67
66/*! 68/*!
67 Returns a rich text formatted QString of the Contact. 69 Returns a rich text formatted QString of the Contact.
68*/ 70*/
69QString Contact::toRichText() const 71QString Contact::toRichText() const
70{ 72{
71 QString text; 73 QString text;
72 QString value, comp, state; 74 QString value, comp, state;
73 75
74 // name, jobtitle and company 76 // name, jobtitle and company
75 if ( !(value = fullName()).isEmpty() ) 77 if ( !(value = fullName()).isEmpty() )
76 text += "<b>" + Qtopia::escapeString(value) + "</b><br>"; 78 text += "<b>" + Qtopia::escapeString(value) + "</b><br>";
77 if ( !(value = jobTitle()).isEmpty() ) 79 if ( !(value = jobTitle()).isEmpty() )
78 text += Qtopia::escapeString(value) + "<br>"; 80 text += Qtopia::escapeString(value) + "<br>";
79 81
80 comp = company(); 82 comp = company();
81 if ( !(value = department()).isEmpty() ) { 83 if ( !(value = department()).isEmpty() ) {
82 text += Qtopia::escapeString(value); 84 text += Qtopia::escapeString(value);
83 if ( comp ) 85 if ( comp )
84 text += ", "; 86 text += ", ";
85 else 87 else
86 text += "<br>"; 88 text += "<br>";
87 } 89 }
88 if ( !comp.isEmpty() ) 90 if ( !comp.isEmpty() )
89 text += Qtopia::escapeString(comp) + "<br>"; 91 text += Qtopia::escapeString(comp) + "<br>";
90 92
91 // business address 93 // business address
92 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || 94 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() ||
93 !businessZip().isEmpty() || !businessCountry().isEmpty() ) { 95 !businessZip().isEmpty() || !businessCountry().isEmpty() ) {
94 text += "<br>"; 96 text += "<br>";
95 text += QObject::tr( "<b>Work Address:</b>" ); 97 text += QObject::tr( "<b>Work Address:</b>" );
96 text += "<br>"; 98 text += "<br>";
97 } 99 }
98 100
99 if ( !(value = businessStreet()).isEmpty() ) 101 if ( !(value = businessStreet()).isEmpty() )
100 text += Qtopia::escapeString(value) + "<br>"; 102 text += Qtopia::escapeString(value) + "<br>";
101 state = businessState(); 103 state = businessState();
102 if ( !(value = businessCity()).isEmpty() ) { 104 if ( !(value = businessCity()).isEmpty() ) {
103 text += Qtopia::escapeString(value); 105 text += Qtopia::escapeString(value);
104 if ( state ) 106 if ( state )
105 text += ", " + Qtopia::escapeString(state); 107 text += ", " + Qtopia::escapeString(state);
106 text += "<br>"; 108 text += "<br>";
107 } else if ( !state.isEmpty() ) 109 } else if ( !state.isEmpty() )
108 text += Qtopia::escapeString(state) + "<br>"; 110 text += Qtopia::escapeString(state) + "<br>";
109 if ( !(value = businessZip()).isEmpty() ) 111 if ( !(value = businessZip()).isEmpty() )
110 text += Qtopia::escapeString(value) + "<br>"; 112 text += Qtopia::escapeString(value) + "<br>";
111 if ( !(value = businessCountry()).isEmpty() ) 113 if ( !(value = businessCountry()).isEmpty() )
112 text += Qtopia::escapeString(value) + "<br>"; 114 text += Qtopia::escapeString(value) + "<br>";
113 115
114 // home address 116 // home address
115 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || 117 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() ||
116 !homeZip().isEmpty() || !homeCountry().isEmpty() ) { 118 !homeZip().isEmpty() || !homeCountry().isEmpty() ) {
117 text += "<br>"; 119 text += "<br>";
118 text += QObject::tr( "<b>Home Address:</b>" ); 120 text += QObject::tr( "<b>Home Address:</b>" );
119 text += "<br>"; 121 text += "<br>";
@@ -293,617 +295,630 @@ QString Contact::fullName() const
293 QString title = find( Qtopia::Title ); 295 QString title = find( Qtopia::Title );
294 QString firstName = find( Qtopia::FirstName ); 296 QString firstName = find( Qtopia::FirstName );
295 QString middleName = find( Qtopia::MiddleName ); 297 QString middleName = find( Qtopia::MiddleName );
296 QString lastName = find( Qtopia::LastName ); 298 QString lastName = find( Qtopia::LastName );
297 QString suffix = find( Qtopia::Suffix ); 299 QString suffix = find( Qtopia::Suffix );
298 300
299 QString name = title; 301 QString name = title;
300 if ( !firstName.isEmpty() ) { 302 if ( !firstName.isEmpty() ) {
301 if ( !name.isEmpty() ) 303 if ( !name.isEmpty() )
302 name += " "; 304 name += " ";
303 name += firstName; 305 name += firstName;
304 } 306 }
305 if ( !middleName.isEmpty() ) { 307 if ( !middleName.isEmpty() ) {
306 if ( !name.isEmpty() ) 308 if ( !name.isEmpty() )
307 name += " "; 309 name += " ";
308 name += middleName; 310 name += middleName;
309 } 311 }
310 if ( !lastName.isEmpty() ) { 312 if ( !lastName.isEmpty() ) {
311 if ( !name.isEmpty() ) 313 if ( !name.isEmpty() )
312 name += " "; 314 name += " ";
313 name += lastName; 315 name += lastName;
314 } 316 }
315 if ( !suffix.isEmpty() ) { 317 if ( !suffix.isEmpty() ) {
316 if ( !name.isEmpty() ) 318 if ( !name.isEmpty() )
317 name += " "; 319 name += " ";
318 name += suffix; 320 name += suffix;
319 } 321 }
320 return name.simplifyWhiteSpace(); 322 return name.simplifyWhiteSpace();
321} 323}
322 324
323QStringList Contact::childrenList() const 325QStringList Contact::childrenList() const
324{ 326{
325 return QStringList::split( " ", find( Qtopia::Children ) ); 327 return QStringList::split( " ", find( Qtopia::Children ) );
326} 328}
327 329
328QStringList Contact::emailList() const 330QStringList Contact::emailList() const
329{ 331{
330 return QStringList::split( ";", find( Qtopia::Emails ) ); 332 return QStringList::split( ";", find( Qtopia::Emails ) );
331} 333}
332 334
333void Contact::setFileAs() 335void Contact::setFileAs()
334{ 336{
335 QString lastName, firstName, middleName, fileas; 337 QString lastName, firstName, middleName, fileas;
336 338
337 lastName = find( Qtopia::LastName ); 339 lastName = find( Qtopia::LastName );
338 firstName = find( Qtopia::FirstName ); 340 firstName = find( Qtopia::FirstName );
339 middleName = find( Qtopia::MiddleName ); 341 middleName = find( Qtopia::MiddleName );
340 if ( !lastName.isEmpty() && !firstName.isEmpty() 342 if ( !lastName.isEmpty() && !firstName.isEmpty()
341 && !middleName.isEmpty() ) 343 && !middleName.isEmpty() )
342 fileas = lastName + ", " + firstName + " " + middleName; 344 fileas = lastName + ", " + firstName + " " + middleName;
343 else if ( !lastName.isEmpty() && !firstName.isEmpty() ) 345 else if ( !lastName.isEmpty() && !firstName.isEmpty() )
344 fileas = lastName + ", " + firstName; 346 fileas = lastName + ", " + firstName;
345 else if ( !lastName.isEmpty() || !firstName.isEmpty() || 347 else if ( !lastName.isEmpty() || !firstName.isEmpty() ||
346 !middleName.isEmpty() ) 348 !middleName.isEmpty() )
347 fileas = firstName + ( firstName.isEmpty() ? "" : " " ) 349 fileas = firstName + ( firstName.isEmpty() ? "" : " " )
348 + middleName + ( middleName.isEmpty() ? "" : " " ) 350 + middleName + ( middleName.isEmpty() ? "" : " " )
349 + lastName; 351 + lastName;
350 352
351 replace( Qtopia::FileAs, fileas ); 353 replace( Qtopia::FileAs, fileas );
352} 354}
353 355
354void Contact::save( QString &buf ) const 356void Contact::save( QString &buf ) const
355{ 357{
356 static const QStringList SLFIELDS = fields(); 358 static const QStringList SLFIELDS = fields();
357 // I'm expecting "<Contact " in front of this... 359 // I'm expecting "<Contact " in front of this...
358 for ( QMap<int, QString>::ConstIterator it = mMap.begin(); 360 for ( QMap<int, QString>::ConstIterator it = mMap.begin();
359 it != mMap.end(); ++it ) { 361 it != mMap.end(); ++it ) {
360 const QString &value = it.data(); 362 const QString &value = it.data();
361 int key = it.key(); 363 int key = it.key();
362 if ( !value.isEmpty() ) { 364 if ( !value.isEmpty() ) {
363 if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) 365 if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid)
364 continue; 366 continue;
365 367
366 key -= Qtopia::AddressCategory+1; 368 key -= Qtopia::AddressCategory+1;
367 buf += SLFIELDS[key]; 369 buf += SLFIELDS[key];
368 buf += "=\"" + Qtopia::escapeString(value) + "\" "; 370 buf += "=\"" + Qtopia::escapeString(value) + "\" ";
369 } 371 }
370 } 372 }
371 buf += customToXml(); 373 buf += customToXml();
372 if ( categories().count() > 0 ) 374 if ( categories().count() > 0 )
373 buf += "Categories=\"" + idsToString( categories() ) + "\" "; 375 buf += "Categories=\"" + idsToString( categories() ) + "\" ";
374 buf += "Uid=\"" + QString::number( uid() ) + "\" "; 376 buf += "Uid=\"" + QString::number( uid() ) + "\" ";
375 // You need to close this yourself 377 // You need to close this yourself
376} 378}
377 379
378QStringList Contact::fields() 380QStringList Contact::fields()
379{ 381{
380 QStringList list; 382 QStringList list;
381 383
382 list.append( "Title" ); // Not Used! 384 list.append( "Title" ); // Not Used!
383 list.append( "FirstName" ); 385 list.append( "FirstName" );
384 list.append( "MiddleName" ); 386 list.append( "MiddleName" );
385 list.append( "LastName" ); 387 list.append( "LastName" );
386 list.append( "Suffix" ); 388 list.append( "Suffix" );
387 list.append( "FileAs" ); 389 list.append( "FileAs" );
388 390
391 list.append( "JobTitle" );
392 list.append( "Department" );
393 list.append( "Company" );
394 list.append( "BusinessPhone" );
395 list.append( "BusinessFax" );
396 list.append( "BusinessMobile" );
397
389 list.append( "DefaultEmail" ); 398 list.append( "DefaultEmail" );
390 list.append( "Emails" ); 399 list.append( "Emails" );
391 400
392 list.append( "HomeStreet" );
393 list.append( "HomeCity" );
394 list.append( "HomeState" );
395 list.append( "HomeZip" );
396 list.append( "HomeCountry" );
397 list.append( "HomePhone" ); 401 list.append( "HomePhone" );
398 list.append( "HomeFax" ); 402 list.append( "HomeFax" );
399 list.append( "HomeMobile" ); 403 list.append( "HomeMobile" );
400 list.append( "HomeWebPage" );
401 404
402 list.append( "Company" );
403 list.append( "BusinessStreet" ); 405 list.append( "BusinessStreet" );
404 list.append( "BusinessCity" ); 406 list.append( "BusinessCity" );
405 list.append( "BusinessState" ); 407 list.append( "BusinessState" );
406 list.append( "BusinessZip" ); 408 list.append( "BusinessZip" );
407 list.append( "BusinessCountry" ); 409 list.append( "BusinessCountry" );
410 list.append( "BusinessPager" );
408 list.append( "BusinessWebPage" ); 411 list.append( "BusinessWebPage" );
409 list.append( "JobTitle" ); 412
410 list.append( "Department" );
411 list.append( "Office" ); 413 list.append( "Office" );
412 list.append( "BusinessPhone" );
413 list.append( "BusinessFax" );
414 list.append( "BusinessMobile" );
415 list.append( "BusinessPager" );
416 list.append( "Profession" ); 414 list.append( "Profession" );
417 list.append( "Assistant" ); 415 list.append( "Assistant" );
418 list.append( "Manager" ); 416 list.append( "Manager" );
419 417
418 list.append( "HomeStreet" );
419 list.append( "HomeCity" );
420 list.append( "HomeState" );
421 list.append( "HomeZip" );
422 list.append( "HomeCountry" );
423 list.append( "HomeWebPage" );
424
420 list.append( "Spouse" ); 425 list.append( "Spouse" );
421 list.append( "Gender" ); 426 list.append( "Gender" );
422 list.append( "Birthday" ); 427 list.append( "Birthday" );
423 list.append( "Anniversary" ); 428 list.append( "Anniversary" );
424 list.append( "Nickname" ); 429 list.append( "Nickname" );
425
426 list.append( "Children" ); 430 list.append( "Children" );
431
427 list.append( "Notes" ); 432 list.append( "Notes" );
433 list.append( "Groups" );
428 434
429 return list; 435 return list;
430} 436}
431 437
432QStringList Contact::trfields() 438QStringList Contact::trfields()
433{ 439{
434 QStringList list; 440 QStringList list;
435 441
436 list.append( QObject::tr( "Name Title") ); 442 list.append( QObject::tr( "Name Title") );
437 list.append( QObject::tr( "First Name" ) ); 443 list.append( QObject::tr( "First Name" ) );
438 list.append( QObject::tr( "Middle Name" ) ); 444 list.append( QObject::tr( "Middle Name" ) );
439 list.append( QObject::tr( "Last Name" ) ); 445 list.append( QObject::tr( "Last Name" ) );
440 list.append( QObject::tr( "Suffix" ) ); 446 list.append( QObject::tr( "Suffix" ) );
441 list.append( QObject::tr( "File As" ) ); 447 list.append( QObject::tr( "File As" ) );
442 448
449 list.append( QObject::tr( "Job Title" ) );
450 list.append( QObject::tr( "Department" ) );
451 list.append( QObject::tr( "Company" ) );
452 list.append( QObject::tr( "Business Phone" ) );
453 list.append( QObject::tr( "Business Fax" ) );
454 list.append( QObject::tr( "Business Mobile" ) );
455
443 list.append( QObject::tr( "Default Email" ) ); 456 list.append( QObject::tr( "Default Email" ) );
444 list.append( QObject::tr( "Emails" ) ); 457 list.append( QObject::tr( "Emails" ) );
445 458
446 list.append( QObject::tr( "Home Street" ) );
447 list.append( QObject::tr( "Home City" ) );
448 list.append( QObject::tr( "Home State" ) );
449 list.append( QObject::tr( "Home Zip" ) );
450 list.append( QObject::tr( "Home Country" ) );
451 list.append( QObject::tr( "Home Phone" ) ); 459 list.append( QObject::tr( "Home Phone" ) );
452 list.append( QObject::tr( "Home Fax" ) ); 460 list.append( QObject::tr( "Home Fax" ) );
453 list.append( QObject::tr( "Home Mobile" ) ); 461 list.append( QObject::tr( "Home Mobile" ) );
454 list.append( QObject::tr( "Home Web Page" ) );
455 462
456 list.append( QObject::tr( "Company" ) );
457 list.append( QObject::tr( "Business Street" ) ); 463 list.append( QObject::tr( "Business Street" ) );
458 list.append( QObject::tr( "Business City" ) ); 464 list.append( QObject::tr( "Business City" ) );
459 list.append( QObject::tr( "Business State" ) ); 465 list.append( QObject::tr( "Business State" ) );
460 list.append( QObject::tr( "Business Zip" ) ); 466 list.append( QObject::tr( "Business Zip" ) );
461 list.append( QObject::tr( "Business Country" ) ); 467 list.append( QObject::tr( "Business Country" ) );
468 list.append( QObject::tr( "Business Pager" ) );
462 list.append( QObject::tr( "Business WebPage" ) ); 469 list.append( QObject::tr( "Business WebPage" ) );
463 list.append( QObject::tr( "Job Title" ) ); 470
464 list.append( QObject::tr( "Department" ) );
465 list.append( QObject::tr( "Office" ) ); 471 list.append( QObject::tr( "Office" ) );
466 list.append( QObject::tr( "Business Phone" ) );
467 list.append( QObject::tr( "Business Fax" ) );
468 list.append( QObject::tr( "Business Mobile" ) );
469 list.append( QObject::tr( "Business Pager" ) );
470 list.append( QObject::tr( "Profession" ) ); 472 list.append( QObject::tr( "Profession" ) );
471 list.append( QObject::tr( "Assistant" ) ); 473 list.append( QObject::tr( "Assistant" ) );
472 list.append( QObject::tr( "Manager" ) ); 474 list.append( QObject::tr( "Manager" ) );
473 475
476 list.append( QObject::tr( "Home Street" ) );
477 list.append( QObject::tr( "Home City" ) );
478 list.append( QObject::tr( "Home State" ) );
479 list.append( QObject::tr( "Home Zip" ) );
480 list.append( QObject::tr( "Home Country" ) );
481 list.append( QObject::tr( "Home Web Page" ) );
482
474 list.append( QObject::tr( "Spouse" ) ); 483 list.append( QObject::tr( "Spouse" ) );
475 list.append( QObject::tr( "Gender" ) ); 484 list.append( QObject::tr( "Gender" ) );
476 list.append( QObject::tr( "Birthday" ) ); 485 list.append( QObject::tr( "Birthday" ) );
477 list.append( QObject::tr( "Anniversary" ) ); 486 list.append( QObject::tr( "Anniversary" ) );
478 list.append( QObject::tr( "Nickname" ) ); 487 list.append( QObject::tr( "Nickname" ) );
479
480 list.append( QObject::tr( "Children" ) ); 488 list.append( QObject::tr( "Children" ) );
489
481 list.append( QObject::tr( "Notes" ) ); 490 list.append( QObject::tr( "Notes" ) );
491 list.append( QObject::tr( "Groups" ) );
482 492
483 return list; 493 return list;
484} 494}
485 495
486void Contact::setEmails( const QString &v ) 496void Contact::setEmails( const QString &v )
487{ 497{
488 replace( Qtopia::Emails, v ); 498 replace( Qtopia::Emails, v );
489 if ( v.isEmpty() ) 499 if ( v.isEmpty() )
490 setDefaultEmail( QString::null ); 500 setDefaultEmail( QString::null );
491} 501}
492 502
493void Contact::setChildren( const QString &v ) 503void Contact::setChildren( const QString &v )
494{ 504{
495 replace( Qtopia::Children, v ); 505 replace( Qtopia::Children, v );
496} 506}
497 507
498// vcard conversion code 508// vcard conversion code
499static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) 509static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value )
500{ 510{
501 VObject *ret = 0; 511 VObject *ret = 0;
502 if ( o && !value.isEmpty() ) 512 if ( o && !value.isEmpty() )
503 ret = addPropValue( o, prop, value.latin1() ); 513 ret = addPropValue( o, prop, value.latin1() );
504 return ret; 514 return ret;
505} 515}
506 516
507static inline VObject *safeAddProp( VObject *o, const char *prop) 517static inline VObject *safeAddProp( VObject *o, const char *prop)
508{ 518{
509 VObject *ret = 0; 519 VObject *ret = 0;
510 if ( o ) 520 if ( o )
511 ret = addProp( o, prop ); 521 ret = addProp( o, prop );
512 return ret; 522 return ret;
513} 523}
514 524
515static VObject *createVObject( const Contact &c ) 525static VObject *createVObject( const Contact &c )
516{ 526{
517 VObject *vcard = newVObject( VCCardProp ); 527 VObject *vcard = newVObject( VCCardProp );
518 safeAddPropValue( vcard, VCVersionProp, "2.1" ); 528 safeAddPropValue( vcard, VCVersionProp, "2.1" );
519 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); 529 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) );
520 safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); 530 safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) );
521 531
522 // full name 532 // full name
523 safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); 533 safeAddPropValue( vcard, VCFullNameProp, c.fullName() );
524 534
525 // name properties 535 // name properties
526 VObject *name = safeAddProp( vcard, VCNameProp ); 536 VObject *name = safeAddProp( vcard, VCNameProp );
527 safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); 537 safeAddPropValue( name, VCFamilyNameProp, c.lastName() );
528 safeAddPropValue( name, VCGivenNameProp, c.firstName() ); 538 safeAddPropValue( name, VCGivenNameProp, c.firstName() );
529 safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); 539 safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() );
530 safeAddPropValue( name, VCNamePrefixesProp, c.title() ); 540 safeAddPropValue( name, VCNamePrefixesProp, c.title() );
531 safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); 541 safeAddPropValue( name, VCNameSuffixesProp, c.suffix() );
532 542
533 // home properties 543 // home properties
534 VObject *home_adr= safeAddProp( vcard, VCAdrProp ); 544 VObject *home_adr= safeAddProp( vcard, VCAdrProp );
535 safeAddProp( home_adr, VCHomeProp ); 545 safeAddProp( home_adr, VCHomeProp );
536 safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); 546 safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() );
537 safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); 547 safeAddPropValue( home_adr, VCCityProp, c.homeCity() );
538 safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); 548 safeAddPropValue( home_adr, VCRegionProp, c.homeState() );
539 safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); 549 safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() );
540 safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); 550 safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() );
541 551
542 VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); 552 VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() );
543 safeAddProp( home_phone, VCHomeProp ); 553 safeAddProp( home_phone, VCHomeProp );
544 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); 554 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() );
545 safeAddProp( home_phone, VCHomeProp ); 555 safeAddProp( home_phone, VCHomeProp );
546 safeAddProp( home_phone, VCCellularProp ); 556 safeAddProp( home_phone, VCCellularProp );
547 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); 557 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() );
548 safeAddProp( home_phone, VCHomeProp ); 558 safeAddProp( home_phone, VCHomeProp );
549 safeAddProp( home_phone, VCFaxProp ); 559 safeAddProp( home_phone, VCFaxProp );
550 560
551 VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); 561 VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() );
552 safeAddProp( url, VCHomeProp ); 562 safeAddProp( url, VCHomeProp );
553 563
554 // work properties 564 // work properties
555 VObject *work_adr= safeAddProp( vcard, VCAdrProp ); 565 VObject *work_adr= safeAddProp( vcard, VCAdrProp );
556 safeAddProp( work_adr, VCWorkProp ); 566 safeAddProp( work_adr, VCWorkProp );
557 safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); 567 safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() );
558 safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); 568 safeAddPropValue( work_adr, VCCityProp, c.businessCity() );
559 safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); 569 safeAddPropValue( work_adr, VCRegionProp, c.businessState() );
560 safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); 570 safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() );
561 safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); 571 safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() );
562 572
563 VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); 573 VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() );
564 safeAddProp( work_phone, VCWorkProp ); 574 safeAddProp( work_phone, VCWorkProp );
565 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); 575 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() );
566 safeAddProp( work_phone, VCWorkProp ); 576 safeAddProp( work_phone, VCWorkProp );
567 safeAddProp( work_phone, VCCellularProp ); 577 safeAddProp( work_phone, VCCellularProp );
568 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); 578 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() );
569 safeAddProp( work_phone, VCWorkProp ); 579 safeAddProp( work_phone, VCWorkProp );
570 safeAddProp( work_phone, VCFaxProp ); 580 safeAddProp( work_phone, VCFaxProp );
571 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); 581 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() );
572 safeAddProp( work_phone, VCWorkProp ); 582 safeAddProp( work_phone, VCWorkProp );
573 safeAddProp( work_phone, VCPagerProp ); 583 safeAddProp( work_phone, VCPagerProp );
574 584
575 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); 585 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() );
576 safeAddProp( url, VCWorkProp ); 586 safeAddProp( url, VCWorkProp );
577 587
578 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); 588 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() );
579 safeAddProp( title, VCWorkProp ); 589 safeAddProp( title, VCWorkProp );
580 590
581 591
582 QStringList emails = c.emailList(); 592 QStringList emails = c.emailList();
583 emails.prepend( c.defaultEmail() ); 593 emails.prepend( c.defaultEmail() );
584 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 594 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
585 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); 595 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it );
586 safeAddProp( email, VCInternetProp ); 596 safeAddProp( email, VCInternetProp );
587 } 597 }
588 598
589 safeAddPropValue( vcard, VCNoteProp, c.notes() ); 599 safeAddPropValue( vcard, VCNoteProp, c.notes() );
590 600
591 safeAddPropValue( vcard, VCBirthDateProp, c.birthday() ); 601 safeAddPropValue( vcard, VCBirthDateProp, c.birthday() );
592 602
593 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { 603 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
594 VObject *org = safeAddProp( vcard, VCOrgProp ); 604 VObject *org = safeAddProp( vcard, VCOrgProp );
595 safeAddPropValue( org, VCOrgNameProp, c.company() ); 605 safeAddPropValue( org, VCOrgNameProp, c.company() );
596 safeAddPropValue( org, VCOrgUnitProp, c.department() ); 606 safeAddPropValue( org, VCOrgUnitProp, c.department() );
597 safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); 607 safeAddPropValue( org, VCOrgUnit2Prop, c.office() );
598 } 608 }
599 609
600 // some values we have to export as custom fields 610 // some values we have to export as custom fields
601 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); 611 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() );
602 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); 612 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() );
603 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); 613 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() );
604 614
605 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); 615 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() );
606 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); 616 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() );
607 safeAddPropValue( vcard, "X-Qtopia-Anniversary", c.anniversary() ); 617 safeAddPropValue( vcard, "X-Qtopia-Anniversary", c.anniversary() );
608 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); 618 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() );
609 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); 619 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() );
610 620
611 return vcard; 621 return vcard;
612} 622}
613 623
614 624
615static Contact parseVObject( VObject *obj ) 625static Contact parseVObject( VObject *obj )
616{ 626{
617 Contact c; 627 Contact c;
618 628
619 bool haveDefaultEmail = FALSE; 629 bool haveDefaultEmail = FALSE;
620 630
621 VObjectIterator it; 631 VObjectIterator it;
622 initPropIterator( &it, obj ); 632 initPropIterator( &it, obj );
623 while( moreIteration( &it ) ) { 633 while( moreIteration( &it ) ) {
624 VObject *o = nextVObject( &it ); 634 VObject *o = nextVObject( &it );
625 QCString name = vObjectName( o ); 635 QCString name = vObjectName( o );
626 QCString value = vObjectStringZValue( o ); 636 QCString value = vObjectStringZValue( o );
627 if ( name == VCNameProp ) { 637 if ( name == VCNameProp ) {
628 VObjectIterator nit; 638 VObjectIterator nit;
629 initPropIterator( &nit, o ); 639 initPropIterator( &nit, o );
630 while( moreIteration( &nit ) ) { 640 while( moreIteration( &nit ) ) {
631 VObject *o = nextVObject( &nit ); 641 VObject *o = nextVObject( &nit );
632 QCString name = vObjectName( o ); 642 QCString name = vObjectTypeInfo( o );
633 QString value = vObjectStringZValue( o ); 643 QString value = vObjectStringZValue( o );
634 if ( name == VCNamePrefixesProp ) 644 if ( name == VCNamePrefixesProp )
635 c.setTitle( value ); 645 c.setTitle( value );
636 else if ( name == VCNameSuffixesProp ) 646 else if ( name == VCNameSuffixesProp )
637 c.setSuffix( value ); 647 c.setSuffix( value );
638 else if ( name == VCFamilyNameProp ) 648 else if ( name == VCFamilyNameProp )
639 c.setLastName( value ); 649 c.setLastName( value );
640 else if ( name == VCGivenNameProp ) 650 else if ( name == VCGivenNameProp )
641 c.setFirstName( value ); 651 c.setFirstName( value );
642 else if ( name == VCAdditionalNamesProp ) 652 else if ( name == VCAdditionalNamesProp )
643 c.setMiddleName( value ); 653 c.setMiddleName( value );
644 } 654 }
645 } 655 }
646 else if ( name == VCAdrProp ) { 656 else if ( name == VCAdrProp ) {
647 bool work = TRUE; // default address is work address 657 bool work = TRUE; // default address is work address
648 QString street; 658 QString street;
649 QString city; 659 QString city;
650 QString region; 660 QString region;
651 QString postal; 661 QString postal;
652 QString country; 662 QString country;
653 663
654 VObjectIterator nit; 664 VObjectIterator nit;
655 initPropIterator( &nit, o ); 665 initPropIterator( &nit, o );
656 while( moreIteration( &nit ) ) { 666 while( moreIteration( &nit ) ) {
657 VObject *o = nextVObject( &nit ); 667 VObject *o = nextVObject( &nit );
658 QCString name = vObjectName( o ); 668 QCString name = vObjectName( o );
659 QString value = vObjectStringZValue( o ); 669 QString value = vObjectStringZValue( o );
660 if ( name == VCHomeProp ) 670 if ( name == VCHomeProp )
661 work = FALSE; 671 work = FALSE;
662 else if ( name == VCWorkProp ) 672 else if ( name == VCWorkProp )
663 work = TRUE; 673 work = TRUE;
664 else if ( name == VCStreetAddressProp ) 674 else if ( name == VCStreetAddressProp )
665 street = value; 675 street = value;
666 else if ( name == VCCityProp ) 676 else if ( name == VCCityProp )
667 city = value; 677 city = value;
668 else if ( name == VCRegionProp ) 678 else if ( name == VCRegionProp )
669 region = value; 679 region = value;
670 else if ( name == VCPostalCodeProp ) 680 else if ( name == VCPostalCodeProp )
671 postal = value; 681 postal = value;
672 else if ( name == VCCountryNameProp ) 682 else if ( name == VCCountryNameProp )
673 country = value; 683 country = value;
674 } 684 }
675 if ( work ) { 685 if ( work ) {
676 c.setBusinessStreet( street ); 686 c.setBusinessStreet( street );
677 c.setBusinessCity( city ); 687 c.setBusinessCity( city );
678 c.setBusinessCountry( country ); 688 c.setBusinessCountry( country );
679 c.setBusinessZip( postal ); 689 c.setBusinessZip( postal );
680 c.setBusinessState( region ); 690 c.setBusinessState( region );
681 } else { 691 } else {
682 c.setHomeStreet( street ); 692 c.setHomeStreet( street );
683 c.setHomeCity( city ); 693 c.setHomeCity( city );
684 c.setHomeCountry( country ); 694 c.setHomeCountry( country );
685 c.setHomeZip( postal ); 695 c.setHomeZip( postal );
686 c.setHomeState( region ); 696 c.setHomeState( region );
687 } 697 }
688 } 698 }
689 else if ( name == VCTelephoneProp ) { 699 else if ( name == VCTelephoneProp ) {
690 enum { 700 enum {
691 HOME = 0x01, 701 HOME = 0x01,
692 WORK = 0x02, 702 WORK = 0x02,
693 VOICE = 0x04, 703 VOICE = 0x04,
694 CELL = 0x08, 704 CELL = 0x08,
695 FAX = 0x10, 705 FAX = 0x10,
696 PAGER = 0x20, 706 PAGER = 0x20,
697 UNKNOWN = 0x80 707 UNKNOWN = 0x80
698 }; 708 };
699 int type = 0; 709 int type = 0;
700 710
701 VObjectIterator nit; 711 VObjectIterator nit;
702 initPropIterator( &nit, o ); 712 initPropIterator( &nit, o );
703 while( moreIteration( &nit ) ) { 713 while( moreIteration( &nit ) ) {
704 VObject *o = nextVObject( &nit ); 714 VObject *o = nextVObject( &nit );
705 QCString name = vObjectName( o ); 715 QCString name = vObjectTypeInfo( o );
706 if ( name == VCHomeProp ) 716 if ( name == VCHomeProp )
707 type |= HOME; 717 type |= HOME;
708 else if ( name == VCWorkProp ) 718 else if ( name == VCWorkProp )
709 type |= WORK; 719 type |= WORK;
710 else if ( name == VCVoiceProp ) 720 else if ( name == VCVoiceProp )
711 type |= VOICE; 721 type |= VOICE;
712 else if ( name == VCCellularProp ) 722 else if ( name == VCCellularProp )
713 type |= CELL; 723 type |= CELL;
714 else if ( name == VCFaxProp ) 724 else if ( name == VCFaxProp )
715 type |= FAX; 725 type |= FAX;
716 else if ( name == VCPagerProp ) 726 else if ( name == VCPagerProp )
717 type |= PAGER; 727 type |= PAGER;
718 else if ( name == VCPreferredProp ) 728 else if ( name == VCPreferredProp )
719 ; 729 ;
720 else 730 else
721 type |= UNKNOWN; 731 type |= UNKNOWN;
722 } 732 }
723 if ( (type & UNKNOWN) != UNKNOWN ) { 733 if ( (type & UNKNOWN) != UNKNOWN ) {
724 if ( ( type & (HOME|WORK) ) == 0 ) // default 734 if ( ( type & (HOME|WORK) ) == 0 ) // default
725 type |= HOME; 735 type |= HOME;
726 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default 736 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default
727 type |= VOICE; 737 type |= VOICE;
728 738
729 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) ) 739 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) )
730 c.setHomePhone( value ); 740 c.setHomePhone( value );
731 if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) 741 if ( ( type & (FAX|HOME) ) == (FAX|HOME) )
732 c.setHomeFax( value ); 742 c.setHomeFax( value );
733 if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) 743 if ( ( type & (CELL|HOME) ) == (CELL|HOME) )
734 c.setHomeMobile( value ); 744 c.setHomeMobile( value );
735 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) ) 745 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) )
736 c.setBusinessPhone( value ); 746 c.setBusinessPhone( value );
737 if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) 747 if ( ( type & (FAX|WORK) ) == (FAX|WORK) )
738 c.setBusinessFax( value ); 748 c.setBusinessFax( value );
739 if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) 749 if ( ( type & (CELL|WORK) ) == (CELL|WORK) )
740 c.setBusinessMobile( value ); 750 c.setBusinessMobile( value );
741 if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) 751 if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) )
742 c.setBusinessPager( value ); 752 c.setBusinessPager( value );
743 } 753 }
744 } 754 }
745 else if ( name == VCEmailAddressProp ) { 755 else if ( name == VCEmailAddressProp ) {
746 QString email = vObjectStringZValue( o ); 756 QString email = vObjectStringZValue( o );
747 bool valid = TRUE; 757 bool valid = TRUE;
748 VObjectIterator nit; 758 VObjectIterator nit;
749 initPropIterator( &nit, o ); 759 initPropIterator( &nit, o );
750 while( moreIteration( &nit ) ) { 760 while( moreIteration( &nit ) ) {
751 VObject *o = nextVObject( &nit ); 761 VObject *o = nextVObject( &nit );
752 QCString name = vObjectName( o ); 762 QCString name = vObjectTypeInfo( o );
753 if ( name != VCInternetProp && name != VCHomeProp && 763 if ( name != VCInternetProp && name != VCHomeProp &&
754 name != VCWorkProp && 764 name != VCWorkProp &&
755 name != VCPreferredProp ) 765 name != VCPreferredProp )
756 // ### preffered should map to default email 766 // ### preffered should map to default email
757 valid = FALSE; 767 valid = FALSE;
758 } 768 }
759 if ( valid ) { 769 if ( valid ) {
760 if ( haveDefaultEmail ) { 770 if ( haveDefaultEmail ) {
761 QString str = c.emails(); 771 QString str = c.emails();
762 if ( !str.isEmpty() ) 772 if ( !str.isEmpty() )
763 str += ","+email; 773 str += ","+email;
764 c.setEmails( str ); 774 c.setEmails( str );
765 } else { 775 } else {
766 c.setDefaultEmail( email ); 776 c.setDefaultEmail( email );
767 } 777 }
768 } 778 }
769 } 779 }
770 else if ( name == VCURLProp ) { 780 else if ( name == VCURLProp ) {
771 VObjectIterator nit; 781 VObjectIterator nit;
772 initPropIterator( &nit, o ); 782 initPropIterator( &nit, o );
773 while( moreIteration( &nit ) ) { 783 while( moreIteration( &nit ) ) {
774 VObject *o = nextVObject( &nit ); 784 VObject *o = nextVObject( &nit );
775 QCString name = vObjectName( o ); 785 QCString name = vObjectTypeInfo( o );
776 if ( name == VCHomeProp ) 786 if ( name == VCHomeProp )
777 c.setHomeWebpage( value ); 787 c.setHomeWebpage( value );
778 else if ( name == VCWorkProp ) 788 else if ( name == VCWorkProp )
779 c.setBusinessWebpage( value ); 789 c.setBusinessWebpage( value );
780 } 790 }
781 } 791 }
782 else if ( name == VCOrgProp ) { 792 else if ( name == VCOrgProp ) {
783 VObjectIterator nit; 793 VObjectIterator nit;
784 initPropIterator( &nit, o ); 794 initPropIterator( &nit, o );
785 while( moreIteration( &nit ) ) { 795 while( moreIteration( &nit ) ) {
786 VObject *o = nextVObject( &nit ); 796 VObject *o = nextVObject( &nit );
787 QCString name = vObjectName( o ); 797 QCString name = vObjectName( o );
788 QString value = vObjectStringZValue( o ); 798 QString value = vObjectStringZValue( o );
789 if ( name == VCOrgNameProp ) 799 if ( name == VCOrgNameProp )
790 c.setCompany( value ); 800 c.setCompany( value );
791 else if ( name == VCOrgUnitProp ) 801 else if ( name == VCOrgUnitProp )
792 c.setDepartment( value ); 802 c.setDepartment( value );
793 else if ( name == VCOrgUnit2Prop ) 803 else if ( name == VCOrgUnit2Prop )
794 c.setOffice( value ); 804 c.setOffice( value );
795 } 805 }
796 } 806 }
797 else if ( name == VCTitleProp ) { 807 else if ( name == VCTitleProp ) {
798 c.setJobTitle( value ); 808 c.setJobTitle( value );
799 } 809 }
800 else if ( name == "X-Qtopia-Profession" ) { 810 else if ( name == "X-Qtopia-Profession" ) {
801 c.setProfession( value ); 811 c.setProfession( value );
802 } 812 }
803 else if ( name == "X-Qtopia-Manager" ) { 813 else if ( name == "X-Qtopia-Manager" ) {
804 c.setManager( value ); 814 c.setManager( value );
805 } 815 }
806 else if ( name == "X-Qtopia-Assistant" ) { 816 else if ( name == "X-Qtopia-Assistant" ) {
807 c.setAssistant( value ); 817 c.setAssistant( value );
808 } 818 }
809 else if ( name == "X-Qtopia-Spouse" ) { 819 else if ( name == "X-Qtopia-Spouse" ) {
810 c.setSpouse( value ); 820 c.setSpouse( value );
811 } 821 }
812 else if ( name == "X-Qtopia-Gender" ) { 822 else if ( name == "X-Qtopia-Gender" ) {
813 c.setGender( value ); 823 c.setGender( value );
814 } 824 }
815 else if ( name == "X-Qtopia-Anniversary" ) { 825 else if ( name == "X-Qtopia-Anniversary" ) {
816 c.setAnniversary( value ); 826 c.setAnniversary( value );
817 } 827 }
818 else if ( name == "X-Qtopia-Nickname" ) { 828 else if ( name == "X-Qtopia-Nickname" ) {
819 c.setNickname( value ); 829 c.setNickname( value );
820 } 830 }
821 else if ( name == "X-Qtopia-Children" ) { 831 else if ( name == "X-Qtopia-Children" ) {
822 c.setChildren( value ); 832 c.setChildren( value );
823 } 833 }
824 834
825 835
826#if 0 836#if 0
827 else { 837 else {
828 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); 838 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
829 VObjectIterator nit; 839 VObjectIterator nit;
830 initPropIterator( &nit, o ); 840 initPropIterator( &nit, o );
831 while( moreIteration( &nit ) ) { 841 while( moreIteration( &nit ) ) {
832 VObject *o = nextVObject( &nit ); 842 VObject *o = nextVObject( &nit );
833 QCString name = vObjectName( o ); 843 QCString name = vObjectName( o );
834 QString value = vObjectStringZValue( o ); 844 QString value = vObjectStringZValue( o );
835 printf(" subprop: %s = %s\n", name.data(), value.latin1() ); 845 printf(" subprop: %s = %s\n", name.data(), value.latin1() );
836 } 846 }
837 } 847 }
838#endif 848#endif
839 } 849 }
840 c.setFileAs(); 850 c.setFileAs();
841 return c; 851 return c;
842} 852}
843 853
844void Contact::writeVCard( const QString &filename, const QValueList<Contact> &contacts) 854void Contact::writeVCard( const QString &filename, const QValueList<Contact> &contacts)
845{ 855{
846 QFileDirect f( filename.utf8().data() ); 856 QFileDirect f( filename.utf8().data() );
847 if ( !f.open( IO_WriteOnly ) ) { 857 if ( !f.open( IO_WriteOnly ) ) {
848 qWarning("Unable to open vcard write"); 858 qWarning("Unable to open vcard write");
849 return; 859 return;
850 } 860 }
851 861
852 QValueList<Contact>::ConstIterator it; 862 QValueList<Contact>::ConstIterator it;
853 for( it = contacts.begin(); it != contacts.end(); ++it ) { 863 for( it = contacts.begin(); it != contacts.end(); ++it ) {
854 VObject *obj = createVObject( *it ); 864 VObject *obj = createVObject( *it );
855 writeVObject(f.directHandle() , obj ); 865 writeVObject(f.directHandle() , obj );
856 cleanVObject( obj ); 866 cleanVObject( obj );
857 } 867 }
858 cleanStrTbl(); 868 cleanStrTbl();
859} 869}
860 870
861void Contact::writeVCard( const QString &filename, const Contact &contact) 871void Contact::writeVCard( const QString &filename, const Contact &contact)
862{ 872{
863 QFileDirect f( filename.utf8().data() ); 873 QFileDirect f( filename.utf8().data() );
864 if ( !f.open( IO_WriteOnly ) ) { 874 if ( !f.open( IO_WriteOnly ) ) {
865 qWarning("Unable to open vcard write"); 875 qWarning("Unable to open vcard write");
866 return; 876 return;
867 } 877 }
868 878
869 VObject *obj = createVObject( contact ); 879 VObject *obj = createVObject( contact );
870 writeVObject( f.directHandle() , obj ); 880 writeVObject( f.directHandle() , obj );
871 cleanVObject( obj ); 881 cleanVObject( obj );
872 882
873 cleanStrTbl(); 883 cleanStrTbl();
874} 884}
875 885
876 886
877QValueList<Contact> Contact::readVCard( const QString &filename ) 887QValueList<Contact> Contact::readVCard( const QString &filename )
878{ 888{
879 qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); 889 qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() );
880 VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); 890 VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() );
881 891
882 qDebug("vobject = %p", obj ); 892 qDebug("vobject = %p", obj );
883 893
884 QValueList<Contact> contacts; 894 QValueList<Contact> contacts;
885 895
886 while ( obj ) { 896 while ( obj ) {
887 contacts.append( parseVObject( obj ) ); 897 contacts.append( parseVObject( obj ) );
888 898
889 VObject *t = obj; 899 VObject *t = obj;
890 obj = nextVObjectInList(obj); 900 obj = nextVObjectInList(obj);
891 cleanVObject( t ); 901 cleanVObject( t );
892 } 902 }
893 903
894 return contacts; 904 return contacts;
895} 905}
896 906
907bool Contact::match( const QString &regexp ) const
908{
909 return match(QRegExp(regexp));
910}
911
897bool Contact::match( const QRegExp &r ) const 912bool Contact::match( const QRegExp &r ) const
898{ 913{
899 bool match; 914 bool match;
900 match = false; 915 match = false;
901 QMap<int, QString>::ConstIterator it; 916 QMap<int, QString>::ConstIterator it;
902 for ( it = mMap.begin(); it != mMap.end(); ++it ) { 917 for ( it = mMap.begin(); it != mMap.end(); ++it ) {
903 if ( (*it).find( r ) > -1 ) { 918 if ( (*it).find( r ) > -1 ) {
904 match = true; 919 match = true;
905 break; 920 break;
906 } 921 }
907 } 922 }
908 return match; 923 return match;
909} 924}
diff --git a/library/backend/contact.h b/library/backend/contact.h
index 6abdab6..a74cbbe 100644
--- a/library/backend/contact.h
+++ b/library/backend/contact.h
@@ -8,193 +8,198 @@
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#ifndef __CONTACT_H__ 21#ifndef __CONTACT_H__
22#define __CONTACT_H__ 22#define __CONTACT_H__
23 23
24#include <qpe/palmtoprecord.h> 24#include <qpe/palmtoprecord.h>
25#include <qpe/recordfields.h> 25#include <qpe/recordfields.h>
26 26
27#include <qstringlist.h> 27#include <qstringlist.h>
28 28
29#if defined(QPC_TEMPLATEDLL) 29#if defined(QPC_TEMPLATEDLL)
30// MOC_SKIP_BEGIN 30// MOC_SKIP_BEGIN
31template class QPC_EXPORT QMap<int, QString>; 31template class QPC_EXPORT QMap<int, QString>;
32// MOC_SKIP_END 32// MOC_SKIP_END
33#endif 33#endif
34 34
35class ContactPrivate; 35class ContactPrivate;
36class QPC_EXPORT Contact : public Qtopia::Record 36class QPC_EXPORT Contact : public Qtopia::Record
37{ 37{
38 friend class DataSet; 38 friend class DataSet;
39public: 39public:
40 Contact(); 40 Contact();
41 Contact( const QMap<int, QString> &fromMap ); 41 Contact( const QMap<int, QString> &fromMap );
42 virtual ~Contact(); 42 virtual ~Contact();
43 43
44 static void writeVCard( const QString &filename, const QValueList<Contact> &contacts); 44 static void writeVCard( const QString &filename, const QValueList<Contact> &contacts);
45 static void writeVCard( const QString &filename, const Contact &c ); 45 static void writeVCard( const QString &filename, const Contact &c );
46 static QValueList<Contact> readVCard( const QString &filename ); 46 static QValueList<Contact> readVCard( const QString &filename );
47 47
48 enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; 48 enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE };
49 49
50 void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } 50 void setTitle( const QString &v ) { replace( Qtopia::Title, v ); }
51 void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } 51 void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); }
52 void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } 52 void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); }
53 void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } 53 void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); }
54 void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } 54 void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); }
55 void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } 55 void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); }
56 void setFileAs(); 56 void setFileAs();
57 57
58 // default email address 58 // default email address
59 void setDefaultEmail( const QString &v ) { replace( Qtopia::DefaultEmail, v ); } 59 void setDefaultEmail( const QString &v ) { replace( Qtopia::DefaultEmail, v ); }
60 // the emails should be seperated by a semicolon 60 // the emails should be seperated by a semicolon
61 void setEmails( const QString &v ); 61 void setEmails( const QString &v );
62 62
63 // home 63 // home
64 void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } 64 void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); }
65 void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } 65 void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); }
66 void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } 66 void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); }
67 void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } 67 void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); }
68 void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } 68 void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); }
69 void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } 69 void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); }
70 void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } 70 void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); }
71 void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } 71 void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); }
72 void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } 72 void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); }
73 73
74 // business 74 // business
75 void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } 75 void setCompany( const QString &v ) { replace( Qtopia::Company, v ); }
76 void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } 76 void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); }
77 void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } 77 void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); }
78 void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } 78 void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); }
79 void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } 79 void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); }
80 void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } 80 void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); }
81 void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } 81 void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); }
82 void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } 82 void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); }
83 void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } 83 void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); }
84 void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } 84 void setOffice( const QString &v ) { replace( Qtopia::Office, v ); }
85 void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } 85 void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); }
86 void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } 86 void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); }
87 void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } 87 void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); }
88 void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } 88 void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); }
89 void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } 89 void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); }
90 void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } 90 void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); }
91 void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } 91 void setManager( const QString &v ) { replace( Qtopia::Manager, v ); }
92 92
93 // personal 93 // personal
94 void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } 94 void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); }
95 void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } 95 void setGender( const QString &v ) { replace( Qtopia::Gender, v ); }
96 void setBirthday( const QString &v ) { replace( Qtopia::Birthday, v ); } 96 void setBirthday( const QString &v ) { replace( Qtopia::Birthday, v ); }
97 void setAnniversary( const QString &v ) { replace( Qtopia::Anniversary, v ); } 97 void setAnniversary( const QString &v ) { replace( Qtopia::Anniversary, v ); }
98 void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } 98 void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); }
99 void setChildren( const QString &v ); 99 void setChildren( const QString &v );
100 100
101 // other 101 // other
102 void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } 102 void setNotes( const QString &v ) { replace( Qtopia::Notes, v); }
103 103
104 bool match( const QRegExp &r ) const; 104 bool match( const QString &regexp ) const;
105
106// DON'T ATTEMPT TO USE THIS
107#ifdef QTOPIA_INTERNAL_CONTACT_MRE
108 bool match( const QRegExp &regexp ) const;
109#endif
105 110
106// // custom 111// // custom
107// void setCustomField( const QString &key, const QString &v ) 112// void setCustomField( const QString &key, const QString &v )
108// { replace(Custom- + key, v ); } 113// { replace(Custom- + key, v ); }
109 114
110 // name 115 // name
111 QString fullName() const; 116 QString fullName() const;
112 QString title() const { return find( Qtopia::Title ); } 117 QString title() const { return find( Qtopia::Title ); }
113 QString firstName() const { return find( Qtopia::FirstName ); } 118 QString firstName() const { return find( Qtopia::FirstName ); }
114 QString middleName() const { return find( Qtopia::MiddleName ); } 119 QString middleName() const { return find( Qtopia::MiddleName ); }
115 QString lastName() const { return find( Qtopia::LastName ); } 120 QString lastName() const { return find( Qtopia::LastName ); }
116 QString suffix() const { return find( Qtopia::Suffix ); } 121 QString suffix() const { return find( Qtopia::Suffix ); }
117 QString fileAs() const { return find( Qtopia::FileAs ); } 122 QString fileAs() const { return find( Qtopia::FileAs ); }
118 123
119 // email 124 // email
120 QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } 125 QString defaultEmail() const { return find( Qtopia::DefaultEmail ); }
121 QString emails() const { return find( Qtopia::Emails ); } 126 QString emails() const { return find( Qtopia::Emails ); }
122 QStringList emailList() const; 127 QStringList emailList() const;
123 128
124 // home 129 // home
125 QString homeStreet() const { return find( Qtopia::HomeStreet ); } 130 QString homeStreet() const { return find( Qtopia::HomeStreet ); }
126 QString homeCity() const { return find( Qtopia::HomeCity ); } 131 QString homeCity() const { return find( Qtopia::HomeCity ); }
127 QString homeState() const { return find( Qtopia::HomeState ); } 132 QString homeState() const { return find( Qtopia::HomeState ); }
128 QString homeZip() const { return find( Qtopia::HomeZip ); } 133 QString homeZip() const { return find( Qtopia::HomeZip ); }
129 QString homeCountry() const { return find( Qtopia::HomeCountry ); } 134 QString homeCountry() const { return find( Qtopia::HomeCountry ); }
130 QString homePhone() const { return find( Qtopia::HomePhone ); } 135 QString homePhone() const { return find( Qtopia::HomePhone ); }
131 QString homeFax() const { return find( Qtopia::HomeFax ); } 136 QString homeFax() const { return find( Qtopia::HomeFax ); }
132 QString homeMobile() const { return find( Qtopia::HomeMobile ); } 137 QString homeMobile() const { return find( Qtopia::HomeMobile ); }
133 QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } 138 QString homeWebpage() const { return find( Qtopia::HomeWebPage ); }
134 /** Multi line string containing all non-empty address info in the form 139 /** Multi line string containing all non-empty address info in the form
135 * Street 140 * Street
136 * City, State Zip 141 * City, State Zip
137 * Country 142 * Country
138 */ 143 */
139 QString displayHomeAddress() const; 144 QString displayHomeAddress() const;
140 145
141 // business 146 // business
142 QString company() const { return find( Qtopia::Company ); } 147 QString company() const { return find( Qtopia::Company ); }
143 QString businessStreet() const { return find( Qtopia::BusinessStreet ); } 148 QString businessStreet() const { return find( Qtopia::BusinessStreet ); }
144 QString businessCity() const { return find( Qtopia::BusinessCity ); } 149 QString businessCity() const { return find( Qtopia::BusinessCity ); }
145 QString businessState() const { return find( Qtopia::BusinessState ); } 150 QString businessState() const { return find( Qtopia::BusinessState ); }
146 QString businessZip() const { return find( Qtopia::BusinessZip ); } 151 QString businessZip() const { return find( Qtopia::BusinessZip ); }
147 QString businessCountry() const { return find( Qtopia::BusinessCountry ); } 152 QString businessCountry() const { return find( Qtopia::BusinessCountry ); }
148 QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } 153 QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); }
149 QString jobTitle() const { return find( Qtopia::JobTitle ); } 154 QString jobTitle() const { return find( Qtopia::JobTitle ); }
150 QString department() const { return find( Qtopia::Department ); } 155 QString department() const { return find( Qtopia::Department ); }
151 QString office() const { return find( Qtopia::Office ); } 156 QString office() const { return find( Qtopia::Office ); }
152 QString businessPhone() const { return find( Qtopia::BusinessPhone ); } 157 QString businessPhone() const { return find( Qtopia::BusinessPhone ); }
153 QString businessFax() const { return find( Qtopia::BusinessFax ); } 158 QString businessFax() const { return find( Qtopia::BusinessFax ); }
154 QString businessMobile() const { return find( Qtopia::BusinessMobile ); } 159 QString businessMobile() const { return find( Qtopia::BusinessMobile ); }
155 QString businessPager() const { return find( Qtopia::BusinessPager ); } 160 QString businessPager() const { return find( Qtopia::BusinessPager ); }
156 QString profession() const { return find( Qtopia::Profession ); } 161 QString profession() const { return find( Qtopia::Profession ); }
157 QString assistant() const { return find( Qtopia::Assistant ); } 162 QString assistant() const { return find( Qtopia::Assistant ); }
158 QString manager() const { return find( Qtopia::Manager ); } 163 QString manager() const { return find( Qtopia::Manager ); }
159 /** Multi line string containing all non-empty address info in the form 164 /** Multi line string containing all non-empty address info in the form
160 * Street 165 * Street
161 * City, State Zip 166 * City, State Zip
162 * Country 167 * Country
163 */ 168 */
164 QString displayBusinessAddress() const; 169 QString displayBusinessAddress() const;
165 170
166 //personal 171 //personal
167 QString spouse() const { return find( Qtopia::Spouse ); } 172 QString spouse() const { return find( Qtopia::Spouse ); }
168 QString gender() const { return find( Qtopia::Gender ); } 173 QString gender() const { return find( Qtopia::Gender ); }
169 QString birthday() const { return find( Qtopia::Birthday ); } 174 QString birthday() const { return find( Qtopia::Birthday ); }
170 QString anniversary() const { return find( Qtopia::Anniversary ); } 175 QString anniversary() const { return find( Qtopia::Anniversary ); }
171 QString nickname() const { return find( Qtopia::Nickname ); } 176 QString nickname() const { return find( Qtopia::Nickname ); }
172 QString children() const { return find( Qtopia::Children ); } 177 QString children() const { return find( Qtopia::Children ); }
173 QStringList childrenList() const; 178 QStringList childrenList() const;
174 179
175 // other 180 // other
176 QString notes() const { return find( Qtopia::Notes ); } 181 QString notes() const { return find( Qtopia::Notes ); }
177 QString groups() const { return find( Qtopia::Groups ); } 182 QString groups() const { return find( Qtopia::Groups ); }
178 QStringList groupList() const; 183 QStringList groupList() const;
179 184
180// // custom 185// // custom
181// const QString &customField( const QString &key ) 186// const QString &customField( const QString &key )
182// { return find( Custom- + key ); } 187// { return find( Custom- + key ); }
183 188
184 static QStringList fields(); 189 static QStringList fields();
185 static QStringList trfields(); 190 static QStringList trfields();
186 191
187 QString toRichText() const; 192 QString toRichText() const;
188 QMap<int, QString> toMap() const; 193 QMap<int, QString> toMap() const;
189 QString field( int key ) const { return find( key ); } 194 QString field( int key ) const { return find( key ); }
190 195
191 196
192 // journaling... 197 // journaling...
193 void saveJournal( journal_action action, const QString &key = QString::null ); 198 void saveJournal( journal_action action, const QString &key = QString::null );
194 void save( QString &buf ) const; 199 void save( QString &buf ) const;
195 200
196 void setUid( int i ) 201 void setUid( int i )
197{ Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); } 202{ Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); }
198 203
199private: 204private:
200 friend class AbTable; 205 friend class AbTable;
diff --git a/library/backend/event.h b/library/backend/event.h
index 0ebe9ea..277aadd 100644
--- a/library/backend/event.h
+++ b/library/backend/event.h
@@ -47,183 +47,188 @@ public:
47 bool operator ==( const RepeatPattern &right ) const; 47 bool operator ==( const RepeatPattern &right ) const;
48 48
49 RepeatType type; 49 RepeatType type;
50 int frequency; 50 int frequency;
51 int position;// the posistion in the month (e.g. the first sunday, etc) positive, count from the front negative count from the end... 51 int position;// the posistion in the month (e.g. the first sunday, etc) positive, count from the front negative count from the end...
52 char days; // a mask for days OR in your days! 52 char days; // a mask for days OR in your days!
53 bool hasEndDate; 53 bool hasEndDate;
54 QDate endDate() const { return TimeConversion::fromUTC( endDateUTC ).date(); } 54 QDate endDate() const { return TimeConversion::fromUTC( endDateUTC ).date(); }
55 void setEndDate( const QDate &dt ) { endDateUTC = TimeConversion::toUTC( dt ); } 55 void setEndDate( const QDate &dt ) { endDateUTC = TimeConversion::toUTC( dt ); }
56 time_t endDateUTC; 56 time_t endDateUTC;
57 time_t createTime; 57 time_t createTime;
58 }; 58 };
59 59
60 Event(); 60 Event();
61 Event( const QMap<int, QString > & map ); 61 Event( const QMap<int, QString > & map );
62 virtual ~Event(); 62 virtual ~Event();
63 63
64 QMap<int, QString> toMap() const; 64 QMap<int, QString> toMap() const;
65 65
66 static void writeVCalendar( const QString &filename, const QValueList<Event> &events); 66 static void writeVCalendar( const QString &filename, const QValueList<Event> &events);
67 static void writeVCalendar( const QString &filename, const Event &event); 67 static void writeVCalendar( const QString &filename, const Event &event);
68 static QValueList<Event> readVCalendar( const QString &filename ); 68 static QValueList<Event> readVCalendar( const QString &filename );
69 69
70 enum Type { Normal, AllDay }; 70 enum Type { Normal, AllDay };
71 enum SoundTypeChoice { Silent, Loud }; 71 enum SoundTypeChoice { Silent, Loud };
72 72
73 bool operator<( const Event &e1) const { return start() < e1.start(); }; 73 bool operator<( const Event &e1) const { return start() < e1.start(); };
74 bool operator<=( const Event &e1 ) const { return start() <= e1.start(); }; 74 bool operator<=( const Event &e1 ) const { return start() <= e1.start(); };
75 bool operator!=( const Event &e1 ) const { return !( *this == e1 ); }; 75 bool operator!=( const Event &e1 ) const { return !( *this == e1 ); };
76 bool operator>( const Event &e1 ) const { return start() > e1.start(); }; 76 bool operator>( const Event &e1 ) const { return start() > e1.start(); };
77 bool operator>=(const Event &e1 ) const { return start() >= e1.start(); }; 77 bool operator>=(const Event &e1 ) const { return start() >= e1.start(); };
78 bool operator==( const Event &e ) const; 78 bool operator==( const Event &e ) const;
79 79
80 void setDescription( const QString &s ); 80 void setDescription( const QString &s );
81 const QString &description() const; 81 const QString &description() const;
82 82
83 void setLocation( const QString &s ); 83 void setLocation( const QString &s );
84 const QString &location() const; 84 const QString &location() const;
85 85
86 void setType( Type t ); 86 void setType( Type t );
87 Type type() const; 87 Type type() const;
88 void setStart( const QDateTime &d ); 88 void setStart( const QDateTime &d );
89 void setStart( time_t time ); 89 void setStart( time_t time );
90 QDateTime start( bool actual = FALSE ) const; 90 QDateTime start( bool actual = FALSE ) const;
91 time_t startTime() const { return startUTC; } 91 time_t startTime() const { return startUTC; }
92 void setEnd( const QDateTime &e ); 92 void setEnd( const QDateTime &e );
93 void setEnd( time_t time ); 93 void setEnd( time_t time );
94 QDateTime end( bool actual = FALSE ) const; 94 QDateTime end( bool actual = FALSE ) const;
95 time_t endTime() const { return endUTC; } 95 time_t endTime() const { return endUTC; }
96 void setTimeZone( const QString & ); 96 void setTimeZone( const QString & );
97 const QString &timeZone() const; 97 const QString &timeZone() const;
98 void setAlarm( bool b, int minutes, SoundTypeChoice ); 98 void setAlarm( bool b, int minutes, SoundTypeChoice );
99 bool hasAlarm() const; 99 bool hasAlarm() const;
100 int alarmTime() const; 100 int alarmTime() const;
101 SoundTypeChoice alarmSound() const; 101 SoundTypeChoice alarmSound() const;
102 void setRepeat( bool b, const RepeatPattern &p ); 102 void setRepeat( bool b, const RepeatPattern &p );
103 void setRepeat( const RepeatPattern &p ); 103 void setRepeat( const RepeatPattern &p );
104 bool hasRepeat() const; 104 bool hasRepeat() const;
105 const RepeatPattern &repeatPattern() const; 105 const RepeatPattern &repeatPattern() const;
106 RepeatPattern &repeatPattern(); 106 RepeatPattern &repeatPattern();
107 void setNotes( const QString &n ); 107 void setNotes( const QString &n );
108 const QString &notes() const; 108 const QString &notes() const;
109 bool doRepeat() const { return pattern.type != NoRepeat; } 109 bool doRepeat() const { return pattern.type != NoRepeat; }
110 110
111 void save( QString& buf ); 111 void save( QString& buf );
112 //void load( Node *n ); 112 //void load( Node *n );
113 113
114 // helper function to calculate the week of the given date 114 // helper function to calculate the week of the given date
115 static int week( const QDate& date ); 115 static int week( const QDate& date );
116 // calculates the number of occurrences of the week day of 116 // calculates the number of occurrences of the week day of
117 // the given date from the start of the month 117 // the given date from the start of the month
118 static int occurrence( const QDate& date ); 118 static int occurrence( const QDate& date );
119 // returns a proper days-char for a given dayOfWeek() 119 // returns a proper days-char for a given dayOfWeek()
120 static char day( int dayOfWeek ) { return 1 << ( dayOfWeek - 1 ); } 120 static char day( int dayOfWeek ) { return 1 << ( dayOfWeek - 1 ); }
121 // returns the dayOfWeek for the *first* day it finds (ignores 121 // returns the dayOfWeek for the *first* day it finds (ignores
122 // any further days!). Returns 1 (Monday) if there isn't any day found 122 // any further days!). Returns 1 (Monday) if there isn't any day found
123 static int dayOfWeek( char day ); 123 static int dayOfWeek( char day );
124 // returns the difference of months from first to second. 124 // returns the difference of months from first to second.
125 static int monthDiff( const QDate& first, const QDate& second ); 125 static int monthDiff( const QDate& first, const QDate& second );
126 bool match( const QRegExp &r ) const; 126 bool match( const QRegExp &r ) const;
127 127
128private: 128private:
129 Qtopia::UidGen &uidGen() { return sUidGen; } 129 Qtopia::UidGen &uidGen() { return sUidGen; }
130 static Qtopia::UidGen sUidGen; 130 static Qtopia::UidGen sUidGen;
131 131
132 QString descript, locat, categ; 132 QString descript, locat, categ;
133 Type typ : 4; 133 Type typ : 4;
134 bool startTimeDirty : 1; 134 bool startTimeDirty : 1;
135 bool endTimeDirty : 1; 135 bool endTimeDirty : 1;
136 time_t startUTC, endUTC; 136 time_t startUTC, endUTC;
137 QString tz; 137 QString tz;
138 bool hAlarm, hRepeat; 138 bool hAlarm, hRepeat;
139 int aMinutes; 139 int aMinutes;
140 SoundTypeChoice aSound; 140 SoundTypeChoice aSound;
141 RepeatPattern pattern; 141 RepeatPattern pattern;
142 QString note; 142 QString note;
143 // ADDITION
144 int mRid;// Recode ID
145 int mRinfo;// Recode Info
146 //
143 EventPrivate *d; 147 EventPrivate *d;
148
144}; 149};
145 150
146// Since an event spans multiple day, it is better to have this 151// Since an event spans multiple day, it is better to have this
147// class to represent a day instead of creating many 152// class to represent a day instead of creating many
148// dummy events... 153// dummy events...
149 154
150class EffectiveEventPrivate; 155class EffectiveEventPrivate;
151class QPC_EXPORT EffectiveEvent 156class QPC_EXPORT EffectiveEvent
152{ 157{
153public: 158public:
154 // If we calculate the effective event of a multi-day event 159 // If we calculate the effective event of a multi-day event
155 // we have to figure out whether we are at the first day, 160 // we have to figure out whether we are at the first day,
156 // at the end, or anywhere else ("middle"). This is important 161 // at the end, or anywhere else ("middle"). This is important
157 // for the start/end times (00:00/23:59) 162 // for the start/end times (00:00/23:59)
158 // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi- 163 // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi-
159 // day event 164 // day event
160 // Start: start time -> 23:59 165 // Start: start time -> 23:59
161 // End: 00:00 -> end time 166 // End: 00:00 -> end time
162 // Start | End == StartEnd: for single-day events (default) 167 // Start | End == StartEnd: for single-day events (default)
163 // here we draw start time -> end time 168 // here we draw start time -> end time
164 enum Position { MidWay = 0, Start = 1, End = 2, StartEnd = 3 }; 169 enum Position { MidWay = 0, Start = 1, End = 2, StartEnd = 3 };
165 170
166 EffectiveEvent(); 171 EffectiveEvent();
167 EffectiveEvent( const Event &event, const QDate &startDate, Position pos = StartEnd ); 172 EffectiveEvent( const Event &event, const QDate &startDate, Position pos = StartEnd );
168 EffectiveEvent( const EffectiveEvent & ); 173 EffectiveEvent( const EffectiveEvent & );
169 EffectiveEvent& operator=( const EffectiveEvent & ); 174 EffectiveEvent& operator=( const EffectiveEvent & );
170 ~EffectiveEvent(); 175 ~EffectiveEvent();
171 176
172 177
173 bool operator<( const EffectiveEvent &e ) const; 178 bool operator<( const EffectiveEvent &e ) const;
174 bool operator<=( const EffectiveEvent &e ) const; 179 bool operator<=( const EffectiveEvent &e ) const;
175 bool operator==( const EffectiveEvent &e ) const; 180 bool operator==( const EffectiveEvent &e ) const;
176 bool operator!=( const EffectiveEvent &e ) const; 181 bool operator!=( const EffectiveEvent &e ) const;
177 bool operator>( const EffectiveEvent &e ) const; 182 bool operator>( const EffectiveEvent &e ) const;
178 bool operator>= ( const EffectiveEvent &e ) const; 183 bool operator>= ( const EffectiveEvent &e ) const;
179 184
180 void setStart( const QTime &start ); 185 void setStart( const QTime &start );
181 void setEnd( const QTime &end ); 186 void setEnd( const QTime &end );
182 void setEvent( Event e ); 187 void setEvent( Event e );
183 void setDate( const QDate &date ); 188 void setDate( const QDate &date );
184 void setEffectiveDates( const QDate &from, const QDate &to ); 189 void setEffectiveDates( const QDate &from, const QDate &to );
185 190
186 // QString category() const; 191 // QString category() const;
187 const QString &description() const; 192 const QString &description() const;
188 const QString &location() const; 193 const QString &location() const;
189 const QString &notes() const; 194 const QString &notes() const;
190 const Event &event() const; 195 const Event &event() const;
191 const QTime &start() const; 196 const QTime &start() const;
192 const QTime &end() const; 197 const QTime &end() const;
193 const QDate &date() const; 198 const QDate &date() const;
194 int length() const; 199 int length() const;
195 int size() const; 200 int size() const;
196 201
197 QDate startDate() const; 202 QDate startDate() const;
198 QDate endDate() const; 203 QDate endDate() const;
199 204
200private: 205private:
201 class EffectiveEventPrivate *d; 206 class EffectiveEventPrivate *d;
202 Event mEvent; 207 Event mEvent;
203 QDate mDate; 208 QDate mDate;
204 QTime mStart, 209 QTime mStart,
205 mEnd; 210 mEnd;
206 211
207}; 212};
208 213
209#ifdef PALMTOPCENTER 214#ifdef PALMTOPCENTER
210class QPC_EXPORT EffectiveEventSizeSorter : public QSorter<EffectiveEvent> 215class QPC_EXPORT EffectiveEventSizeSorter : public QSorter<EffectiveEvent>
211{ 216{
212public: 217public:
213 int compare( const EffectiveEvent& a, const EffectiveEvent& b ) const 218 int compare( const EffectiveEvent& a, const EffectiveEvent& b ) const
214 { 219 {
215 return a.size() - b.size(); 220 return a.size() - b.size();
216 } 221 }
217}; 222};
218 223
219class QPC_EXPORT EffectiveEventTimeSorter : public QSorter<EffectiveEvent> 224class QPC_EXPORT EffectiveEventTimeSorter : public QSorter<EffectiveEvent>
220{ 225{
221public: 226public:
222 int compare( const EffectiveEvent& a, const EffectiveEvent& b ) const 227 int compare( const EffectiveEvent& a, const EffectiveEvent& b ) const
223 { 228 {
224 return a.start().secsTo( b.start() ); 229 return a.start().secsTo( b.start() );
225 } 230 }
226}; 231};
227#endif 232#endif
228 233
229#endif 234#endif
diff --git a/library/backend/recordfields.h b/library/backend/recordfields.h
index 3cddde2..4196c8b 100644
--- a/library/backend/recordfields.h
+++ b/library/backend/recordfields.h
@@ -1,135 +1,149 @@
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** 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#ifndef QPC_RECORD_FIELDS_H 21#ifndef QPC_RECORD_FIELDS_H
22#define QPC_RECORD_FIELDS_H 22#define QPC_RECORD_FIELDS_H
23#include "qpcglobal.h" 23#include "qpcglobal.h"
24 24
25// dataset = "addressbook" 25// dataset = "addressbook"
26namespace Qtopia 26namespace Qtopia
27{ 27{
28 static const int UID_ID = 0; 28 static const int UID_ID = 0;
29 static const int CATEGORY_ID = 1; 29 static const int CATEGORY_ID = 1;
30 30
31 enum AddressBookFields { 31 enum AddressBookFields {
32 AddressUid = UID_ID, 32 AddressUid = UID_ID,
33 AddressCategory = CATEGORY_ID, 33 AddressCategory = CATEGORY_ID,
34 34
35 // NOTE: Order of fields dependency in backend/contact.cpp
36
35 Title, 37 Title,
36 FirstName, 38 FirstName,
37 MiddleName, 39 MiddleName,
38 LastName, 40 LastName,
39 Suffix, 41 Suffix,
40 FileAs, 42 FileAs,
41 43
44 JobTitle,
45 Department,
46 Company,
47 BusinessPhone,
48 BusinessFax,
49 BusinessMobile,
50
42 // email 51 // email
43 DefaultEmail, 52 DefaultEmail,
44 Emails, 53 Emails,
45 54
46 // home
47 HomeStreet,
48 HomeCity,
49 HomeState,
50 HomeZip,
51 HomeCountry,
52 HomePhone, 55 HomePhone,
53 HomeFax, 56 HomeFax,
54 HomeMobile, 57 HomeMobile,
55 HomeWebPage,
56 58
57 // business 59 // business
58 Company,
59 BusinessStreet, 60 BusinessStreet,
60 BusinessCity, 61 BusinessCity,
61 BusinessState, 62 BusinessState,
62 BusinessZip, 63 BusinessZip,
63 BusinessCountry, 64 BusinessCountry,
65 BusinessPager,
64 BusinessWebPage, 66 BusinessWebPage,
65 JobTitle, 67
66 Department,
67 Office, 68 Office,
68 BusinessPhone,
69 BusinessFax,
70 BusinessMobile,
71 BusinessPager,
72 Profession, 69 Profession,
73 Assistant, 70 Assistant,
74 Manager, 71 Manager,
75 72
73 // home
74 HomeStreet,
75 HomeCity,
76 HomeState,
77 HomeZip,
78 HomeCountry,
79 HomeWebPage,
80
76 //personal 81 //personal
77 Spouse, 82 Spouse,
78 Gender, 83 Gender,
79 Birthday, 84 Birthday,
80 Anniversary, 85 Anniversary,
81 Nickname, 86 Nickname,
82 Children, 87 Children,
83 88
84 // other 89 // other
85 Notes, 90 Notes,
86 Groups 91 Groups
92
93 ,rid,
94 rinfo
87 }; 95 };
88 96
89 // dataset = "todolist" 97 // dataset = "todolist"
90 enum TaskFields { 98 enum TaskFields {
91 TaskUid = UID_ID, 99 TaskUid = UID_ID,
92 TaskCategory = CATEGORY_ID, 100 TaskCategory = CATEGORY_ID,
93 101
94 HasDate, 102 HasDate,
95 Completed, 103 Completed,
96 TaskDescription, 104 TaskDescription,
97 Priority, 105 Priority,
98 Date 106 Date,
107
108 TaskRid,
109 TaskRinfo
99 }; 110 };
100 111
101 // dataset = "categories" for todos 112 // dataset = "categories" for todos
102 enum CategoryFields { 113 enum CategoryFields {
103 CatUid = UID_ID, 114 CatUid = UID_ID,
104 CatName, 115 CatName,
105 CatAppGroup 116 CatAppGroup
106 }; 117 };
107 118
108 119
109// dataset = "datebook" 120// dataset = "datebook"
110 enum DatebookFields { 121 enum DatebookFields {
111 DatebookUid = UID_ID, 122 DatebookUid = UID_ID,
112 DatebookCategory = CATEGORY_ID, 123 DatebookCategory = CATEGORY_ID,
113 124
114 DatebookDescription, 125 DatebookDescription,
115 Location, 126 Location,
116 TimeZone, 127 TimeZone,
117 Note, 128 Note,
118 StartDateTime, 129 StartDateTime,
119 EndDateTime, 130 EndDateTime,
120 DatebookType, 131 DatebookType,
121 HasAlarm, 132 HasAlarm,
122 SoundType, 133 SoundType,
123 AlarmTime, 134 AlarmTime,
124 135
125 RepeatPatternType, 136 RepeatPatternType,
126 RepeatPatternFrequency, 137 RepeatPatternFrequency,
127 RepeatPatternPosition, 138 RepeatPatternPosition,
128 RepeatPatternDays, 139 RepeatPatternDays,
129 RepeatPatternHasEndDate, 140 RepeatPatternHasEndDate,
130 RepeatPatternEndDate, 141 RepeatPatternEndDate,
142
143 DateBookRid,
144 DateBookRinfo
131 }; 145 };
132}; 146};
133 147
134 148
135#endif 149#endif
diff --git a/library/backend/task.h b/library/backend/task.h
index ffe26b0..6f383b8 100644
--- a/library/backend/task.h
+++ b/library/backend/task.h
@@ -1,77 +1,81 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 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 __TASK_H__ 20#ifndef __TASK_H__
21#define __TASK_H__ 21#define __TASK_H__
22 22
23#include <qpe/palmtoprecord.h> 23#include <qpe/palmtoprecord.h>
24#include <qpe/stringutil.h> 24#include <qpe/stringutil.h>
25 25
26#include <qvaluelist.h> 26#include <qvaluelist.h>
27#include <qdatetime.h> 27#include <qdatetime.h>
28 28
29class TaskPrivate; 29class TaskPrivate;
30class QPC_EXPORT Task : public Qtopia::Record 30class QPC_EXPORT Task : public Qtopia::Record
31{ 31{
32public: 32public:
33 Task(); 33 Task();
34 Task( const QMap<int, QString> &fromMap ); 34 Task( const QMap<int, QString> &fromMap );
35 ~Task(); 35 ~Task();
36 36
37 QMap<int, QString> toMap() const; 37 QMap<int, QString> toMap() const;
38 38
39 static void writeVCalendar( const QString &filename, const QValueList<Task> &tasks); 39 static void writeVCalendar( const QString &filename, const QValueList<Task> &tasks);
40 static void writeVCalendar( const QString &filename, const Task &task); 40 static void writeVCalendar( const QString &filename, const Task &task);
41 static QValueList<Task> readVCalendar( const QString &filename ); 41 static QValueList<Task> readVCalendar( const QString &filename );
42 42
43 void setPriority( int priority ) { mPriority = priority; } 43 void setPriority( int priority ) { mPriority = priority; }
44 int priority() const { return mPriority; } 44 int priority() const { return mPriority; }
45 45
46// void setCategory( const QString& category ) 46// void setCategory( const QString& category )
47// { mCategory = category.stripWhiteSpace(); } 47// { mCategory = category.stripWhiteSpace(); }
48// const QString &category() const { return mCategory; } 48// const QString &category() const { return mCategory; }
49 49
50 void setDescription( const QString& description ) 50 void setDescription( const QString& description )
51 { mDesc = Qtopia::simplifyMultiLineSpace(description); } 51 { mDesc = Qtopia::simplifyMultiLineSpace(description); }
52 const QString &description() const { return mDesc; } 52 const QString &description() const { return mDesc; }
53 53
54 void setDueDate( const QDate& date, bool hasDue ) { mDueDate = date; mDue = hasDue; } 54 void setDueDate( const QDate& date, bool hasDue ) { mDueDate = date; mDue = hasDue; }
55 const QDate &dueDate() const { return mDueDate; } 55 const QDate &dueDate() const { return mDueDate; }
56 bool hasDueDate() const { return mDue; } 56 bool hasDueDate() const { return mDue; }
57 void setHasDueDate( bool b ) { mDue = b; } 57 void setHasDueDate( bool b ) { mDue = b; }
58 58
59 void setCompleted( bool b ) { mCompleted = b; } 59 void setCompleted( bool b ) { mCompleted = b; }
60 bool isCompleted() const { return mCompleted; } 60 bool isCompleted() const { return mCompleted; }
61 61
62 void save( QString& buf ) const; 62 void save( QString& buf ) const;
63 bool match( const QRegExp &r ) const; 63 bool match( const QRegExp &r ) const;
64 64
65private: 65private:
66 Qtopia::UidGen &uidGen() { return sUidGen; } 66 Qtopia::UidGen &uidGen() { return sUidGen; }
67 static Qtopia::UidGen sUidGen; 67 static Qtopia::UidGen sUidGen;
68 68
69 bool mDue; 69 bool mDue;
70 QDate mDueDate; 70 QDate mDueDate;
71 bool mCompleted; 71 bool mCompleted;
72 int mPriority; 72 int mPriority;
73 QString mDesc; 73 QString mDesc;
74 TaskPrivate *d; 74 TaskPrivate *d;
75 // ADDITION
76 int recordId;
77 int recordInfo;
78 //
75}; 79};
76 80
77#endif 81#endif
diff --git a/library/backend/vobject.cpp b/library/backend/vobject.cpp
index af112a7..9c2ba3b 100644
--- a/library/backend/vobject.cpp
+++ b/library/backend/vobject.cpp
@@ -1114,97 +1114,106 @@ static void writeProp(OFile *fp, VObject *o)
1114 while (moreIteration(&t)) { 1114 while (moreIteration(&t)) {
1115 const char *s; 1115 const char *s;
1116 VObject *eachProp = nextVObject(&t); 1116 VObject *eachProp = nextVObject(&t);
1117 s = NAME_OF(eachProp); 1117 s = NAME_OF(eachProp);
1118 if (qstricmp(VCGroupingProp,s) && !inList(fields_,s)) 1118 if (qstricmp(VCGroupingProp,s) && !inList(fields_,s))
1119 writeAttrValue(fp,eachProp); 1119 writeAttrValue(fp,eachProp);
1120 } 1120 }
1121 if (fields_) { 1121 if (fields_) {
1122 int i = 0, n = 0; 1122 int i = 0, n = 0;
1123 const char** fields = fields_; 1123 const char** fields = fields_;
1124 /* output prop as fields */ 1124 /* output prop as fields */
1125 appendcOFile(fp,':'); 1125 appendcOFile(fp,':');
1126 while (*fields) { 1126 while (*fields) {
1127 VObject *t = isAPropertyOf(o,*fields); 1127 VObject *t = isAPropertyOf(o,*fields);
1128 i++; 1128 i++;
1129 if (t) n = i; 1129 if (t) n = i;
1130 fields++; 1130 fields++;
1131 } 1131 }
1132 fields = fields_; 1132 fields = fields_;
1133 for (i=0;i<n;i++) { 1133 for (i=0;i<n;i++) {
1134 writeValue(fp,isAPropertyOf(o,*fields),0); 1134 writeValue(fp,isAPropertyOf(o,*fields),0);
1135 fields++; 1135 fields++;
1136 if (i<(n-1)) appendcOFile(fp,';'); 1136 if (i<(n-1)) appendcOFile(fp,';');
1137 } 1137 }
1138 } 1138 }
1139 } 1139 }
1140 1140
1141 if (VALUE_TYPE(o)) { 1141 if (VALUE_TYPE(o)) {
1142 unsigned long size = 0; 1142 unsigned long size = 0;
1143 VObject *p = isAPropertyOf(o,VCDataSizeProp); 1143 VObject *p = isAPropertyOf(o,VCDataSizeProp);
1144 if (p) size = LONG_VALUE_OF(p); 1144 if (p) size = LONG_VALUE_OF(p);
1145 appendcOFile(fp,':'); 1145 appendcOFile(fp,':');
1146 writeValue(fp,o,size); 1146 writeValue(fp,o,size);
1147 } 1147 }
1148 1148
1149 appendcOFile(fp,'\n'); 1149 appendcOFile(fp,'\n');
1150} 1150}
1151 1151
1152static void writeVObject_(OFile *fp, VObject *o) 1152static void writeVObject_(OFile *fp, VObject *o)
1153{ 1153{
1154 if (NAME_OF(o)) { 1154 if (NAME_OF(o)) {
1155 struct PreDefProp *pi; 1155 struct PreDefProp *pi;
1156 pi = lookupPropInfo(NAME_OF(o)); 1156 pi = lookupPropInfo(NAME_OF(o));
1157 1157
1158 if (pi && ((pi->flags & PD_BEGIN) != 0)) { 1158 if (pi && ((pi->flags & PD_BEGIN) != 0)) {
1159 VObjectIterator t; 1159 VObjectIterator t;
1160 const char *begin = NAME_OF(o); 1160 const char *begin = NAME_OF(o);
1161 appendsOFile(fp,"BEGIN:"); 1161 appendsOFile(fp,"BEGIN:");
1162 appendsOFile(fp,begin); 1162 appendsOFile(fp,begin);
1163 appendcOFile(fp,'\n'); 1163 appendcOFile(fp,'\n');
1164 initPropIterator(&t,o); 1164 initPropIterator(&t,o);
1165 while (moreIteration(&t)) { 1165 while (moreIteration(&t)) {
1166 VObject *eachProp = nextVObject(&t); 1166 VObject *eachProp = nextVObject(&t);
1167 writeProp(fp, eachProp); 1167 writeProp(fp, eachProp);
1168 } 1168 }
1169 appendsOFile(fp,"END:"); 1169 appendsOFile(fp,"END:");
1170 appendsOFile(fp,begin); 1170 appendsOFile(fp,begin);
1171 appendsOFile(fp,"\n\n"); 1171 appendsOFile(fp,"\n\n");
1172 } 1172 }
1173 } 1173 }
1174} 1174}
1175 1175
1176void writeVObject(FILE *fp, VObject *o) 1176void writeVObject(FILE *fp, VObject *o)
1177{ 1177{
1178 OFile ofp; 1178 OFile ofp;
1179 // ##### 1179 // #####
1180 //_setmode(_fileno(fp), _O_BINARY); 1180 //_setmode(_fileno(fp), _O_BINARY);
1181 initOFile(&ofp,fp); 1181 initOFile(&ofp,fp);
1182 writeVObject_(&ofp,o); 1182 writeVObject_(&ofp,o);
1183} 1183}
1184 1184
1185DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o) 1185DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o)
1186{ 1186{
1187 QFileDirect f( fname); 1187 QFileDirect f( fname);
1188 if ( !f.open( IO_WriteOnly ) ) { 1188 if ( !f.open( IO_WriteOnly ) ) {
1189 qWarning("Unable to open vobject write %s", fname); 1189 qWarning("Unable to open vobject write %s", fname);
1190 return; 1190 return;
1191 } 1191 }
1192 1192
1193 writeVObject( f.directHandle(),o ); 1193 writeVObject( f.directHandle(),o );
1194} 1194}
1195 1195
1196DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list) 1196DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list)
1197{ 1197{
1198 QFileDirect f( fname); 1198 QFileDirect f( fname);
1199 if ( !f.open( IO_WriteOnly ) ) { 1199 if ( !f.open( IO_WriteOnly ) ) {
1200 qWarning("Unable to open vobject write %s", fname); 1200 qWarning("Unable to open vobject write %s", fname);
1201 return; 1201 return;
1202 } 1202 }
1203 1203
1204 while (list) { 1204 while (list) {
1205 writeVObject(f.directHandle(),list); 1205 writeVObject(f.directHandle(),list);
1206 list = nextVObjectInList(list); 1206 list = nextVObjectInList(list);
1207 } 1207 }
1208} 1208}
1209 1209
1210DLLEXPORT(const char *) vObjectTypeInfo(VObject *o)
1211{
1212 const char *type = vObjectName( o );
1213 if ( strcmp( type, "TYPE" ) == 0 )
1214 type = vObjectStringZValue( o );
1215 return type;
1216}
1217
1218
1210// end of source file vobject.c 1219// end of source file vobject.c
diff --git a/library/backend/vobject_p.h b/library/backend/vobject_p.h
index b6a2c0a..a0d921e 100644
--- a/library/backend/vobject_p.h
+++ b/library/backend/vobject_p.h
@@ -303,99 +303,102 @@ extern DLLEXPORT(unsigned int) vObjectIntegerValue(VObject *o);
303extern DLLEXPORT(unsigned long) vObjectLongValue(VObject *o); 303extern DLLEXPORT(unsigned long) vObjectLongValue(VObject *o);
304extern DLLEXPORT(void*) vObjectAnyValue(VObject *o); 304extern DLLEXPORT(void*) vObjectAnyValue(VObject *o);
305extern DLLEXPORT(VObject*) vObjectVObjectValue(VObject *o); 305extern DLLEXPORT(VObject*) vObjectVObjectValue(VObject *o);
306extern DLLEXPORT(void) setVObjectVObjectValue(VObject *o, VObject *p); 306extern DLLEXPORT(void) setVObjectVObjectValue(VObject *o, VObject *p);
307 307
308extern DLLEXPORT(VObject*) addVObjectProp(VObject *o, VObject *p); 308extern DLLEXPORT(VObject*) addVObjectProp(VObject *o, VObject *p);
309extern DLLEXPORT(VObject*) addProp(VObject *o, const char *id); 309extern DLLEXPORT(VObject*) addProp(VObject *o, const char *id);
310extern DLLEXPORT(VObject*) addProp_(VObject *o, const char *id); 310extern DLLEXPORT(VObject*) addProp_(VObject *o, const char *id);
311extern DLLEXPORT(VObject*) addPropValue(VObject *o, const char *p, const char *v); 311extern DLLEXPORT(VObject*) addPropValue(VObject *o, const char *p, const char *v);
312extern DLLEXPORT(VObject*) addPropSizedValue_(VObject *o, const char *p, const char *v, unsigned int size); 312extern DLLEXPORT(VObject*) addPropSizedValue_(VObject *o, const char *p, const char *v, unsigned int size);
313extern DLLEXPORT(VObject*) addPropSizedValue(VObject *o, const char *p, const char *v, unsigned int size); 313extern DLLEXPORT(VObject*) addPropSizedValue(VObject *o, const char *p, const char *v, unsigned int size);
314extern DLLEXPORT(VObject*) addGroup(VObject *o, const char *g); 314extern DLLEXPORT(VObject*) addGroup(VObject *o, const char *g);
315extern DLLEXPORT(void) addList(VObject **o, VObject *p); 315extern DLLEXPORT(void) addList(VObject **o, VObject *p);
316 316
317extern DLLEXPORT(VObject*) isAPropertyOf(VObject *o, const char *id); 317extern DLLEXPORT(VObject*) isAPropertyOf(VObject *o, const char *id);
318 318
319extern DLLEXPORT(VObject*) nextVObjectInList(VObject *o); 319extern DLLEXPORT(VObject*) nextVObjectInList(VObject *o);
320extern DLLEXPORT(void) initPropIterator(VObjectIterator *i, VObject *o); 320extern DLLEXPORT(void) initPropIterator(VObjectIterator *i, VObject *o);
321extern DLLEXPORT(int) moreIteration(VObjectIterator *i); 321extern DLLEXPORT(int) moreIteration(VObjectIterator *i);
322extern DLLEXPORT(VObject*) nextVObject(VObjectIterator *i); 322extern DLLEXPORT(VObject*) nextVObject(VObjectIterator *i);
323 323
324extern DLLEXPORT(const char*) lookupStr(const char *s); 324extern DLLEXPORT(const char*) lookupStr(const char *s);
325extern DLLEXPORT(void) cleanStrTbl(); 325extern DLLEXPORT(void) cleanStrTbl();
326 326
327extern DLLEXPORT(void) cleanVObject(VObject *o); 327extern DLLEXPORT(void) cleanVObject(VObject *o);
328extern DLLEXPORT(void) cleanVObjects(VObject *list); 328extern DLLEXPORT(void) cleanVObjects(VObject *list);
329 329
330extern DLLEXPORT(const char*) lookupProp(const char* str); 330extern DLLEXPORT(const char*) lookupProp(const char* str);
331extern DLLEXPORT(const char*) lookupProp_(const char* str); 331extern DLLEXPORT(const char*) lookupProp_(const char* str);
332 332
333extern DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o); 333extern DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o);
334extern DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list); 334extern DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list);
335 335
336extern DLLEXPORT(int) vObjectValueType(VObject *o); 336extern DLLEXPORT(int) vObjectValueType(VObject *o);
337 337
338/* return type of vObjectValueType: */ 338/* return type of vObjectValueType: */
339 #define VCVT_NOVALUE0 339 #define VCVT_NOVALUE0
340 /* if the VObject has no value associated with it. */ 340 /* if the VObject has no value associated with it. */
341 #define VCVT_STRINGZ1 341 #define VCVT_STRINGZ1
342 /* if the VObject has value set by setVObjectStringZValue. */ 342 /* if the VObject has value set by setVObjectStringZValue. */
343 #define VCVT_UINT 2 343 #define VCVT_UINT 2
344 /* if the VObject has value set by setVObjectIntegerValue. */ 344 /* if the VObject has value set by setVObjectIntegerValue. */
345 #define VCVT_ULONG 3 345 #define VCVT_ULONG 3
346 /* if the VObject has value set by setVObjectLongValue. */ 346 /* if the VObject has value set by setVObjectLongValue. */
347 #define VCVT_RAW 4 347 #define VCVT_RAW 4
348 /* if the VObject has value set by setVObjectAnyValue. */ 348 /* if the VObject has value set by setVObjectAnyValue. */
349 #define VCVT_VOBJECT5 349 #define VCVT_VOBJECT5
350 /* if the VObject has value set by setVObjectVObjectValue. */ 350 /* if the VObject has value set by setVObjectVObjectValue. */
351 351
352extern const char** fieldedProp; 352extern const char** fieldedProp;
353 353
354/*************************************************** 354/***************************************************
355 * The methods below are implemented in vcc.c (generated from vcc.y ) 355 * The methods below are implemented in vcc.c (generated from vcc.y )
356 ***************************************************/ 356 ***************************************************/
357 357
358/* NOTE regarding printVObject and writeVObject 358/* NOTE regarding printVObject and writeVObject
359 359
360The functions below are not exported from the DLL because they 360The functions below are not exported from the DLL because they
361take a FILE* as a parameter, which cannot be passed across a DLL 361take a FILE* as a parameter, which cannot be passed across a DLL
362interface (at least that is my experience). Instead you can use 362interface (at least that is my experience). Instead you can use
363their companion functions which take file names or pointers 363their companion functions which take file names or pointers
364to memory. However, if you are linking this code into 364to memory. However, if you are linking this code into
365your build directly then you may find them a more convenient API 365your build directly then you may find them a more convenient API
366and you can go ahead and use them. If you try to use them with 366and you can go ahead and use them. If you try to use them with
367the DLL LIB you will get a link error. 367the DLL LIB you will get a link error.
368*/ 368*/
369extern void writeVObject(FILE *fp, VObject *o); 369extern void writeVObject(FILE *fp, VObject *o);
370 370
371 371
372 372
373typedef void (*MimeErrorHandler)(char *); 373typedef void (*MimeErrorHandler)(char *);
374 374
375extern DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler); 375extern DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler);
376 376
377extern DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len); 377extern DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len);
378extern DLLEXPORT(VObject*) Parse_MIME_FromFileName(char* fname); 378extern DLLEXPORT(VObject*) Parse_MIME_FromFileName(char* fname);
379 379
380 380
381/* NOTE regarding Parse_MIME_FromFile 381/* NOTE regarding Parse_MIME_FromFile
382The function above, Parse_MIME_FromFile, comes in two flavors, 382The function above, Parse_MIME_FromFile, comes in two flavors,
383neither of which is exported from the DLL. Each version takes 383neither of which is exported from the DLL. Each version takes
384a CFile or FILE* as a parameter, neither of which can be 384a CFile or FILE* as a parameter, neither of which can be
385passed across a DLL interface (at least that is my experience). 385passed across a DLL interface (at least that is my experience).
386If you are linking this code into your build directly then 386If you are linking this code into your build directly then
387you may find them a more convenient API that the other flavors 387you may find them a more convenient API that the other flavors
388that take a file name. If you use them with the DLL LIB you 388that take a file name. If you use them with the DLL LIB you
389will get a link error. 389will get a link error.
390*/ 390*/
391 391
392 392
393#if INCLUDEMFC 393#if INCLUDEMFC
394extern VObject* Parse_MIME_FromFile(CFile *file); 394extern VObject* Parse_MIME_FromFile(CFile *file);
395#else 395#else
396extern VObject* Parse_MIME_FromFile(FILE *file); 396extern VObject* Parse_MIME_FromFile(FILE *file);
397#endif 397#endif
398 398
399extern DLLEXPORT(const char *) vObjectTypeInfo(VObject *o);
400
401
399#endif /* __VOBJECT_H__ */ 402#endif /* __VOBJECT_H__ */
400 403
401 404
diff --git a/library/categoryedit_p.cpp b/library/categoryedit_p.cpp
index 06e5fec..07e707e 100644
--- a/library/categoryedit_p.cpp
+++ b/library/categoryedit_p.cpp
@@ -1,176 +1,178 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 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 "categoryedit_p.h" 21#include "categoryedit_p.h"
22 22
23#include <qpe/categories.h> 23#include <qpe/categories.h>
24 24
25#include <qdir.h> 25#include <qdir.h>
26#include <qcheckbox.h> 26#include <qcheckbox.h>
27#include <qlineedit.h> 27#include <qlineedit.h>
28#include <qlistview.h> 28#include <qlistview.h>
29#include <qstringlist.h> 29#include <qstringlist.h>
30#include <qtoolbutton.h> 30#include <qtoolbutton.h>
31 31
32#include <sys/types.h> 32#include <sys/types.h>
33#include <sys/stat.h> 33#include <sys/stat.h>
34 34
35#include <stdlib.h> 35#include <stdlib.h>
36 36
37 37
38using namespace Qtopia; 38using namespace Qtopia;
39 39
40class CategoryEditPrivate 40class CategoryEditPrivate
41{ 41{
42public: 42public:
43 CategoryEditPrivate( QWidget *parent, const QString &appName ) 43 CategoryEditPrivate( QWidget *parent, const QString &appName )
44 : mCategories( parent, "" ), 44 : mCategories( parent, "" ),
45 mStrApp( appName ) 45 mStrApp( appName )
46 { 46 {
47 editItem = 0; 47 editItem = 0;
48 mCategories.load( categoryFileName() ); 48 mCategories.load( categoryFileName() );
49 } 49 }
50 Categories mCategories; 50 Categories mCategories;
51 QListViewItem *editItem; 51 QListViewItem *editItem;
52 QString mStrApp; 52 QString mStrApp;
53 QString mVisible; 53 QString mVisible;
54}; 54};
55 55
56CategoryEdit::CategoryEdit( QWidget *parent, const char *name ) 56CategoryEdit::CategoryEdit( QWidget *parent, const char *name )
57 : CategoryEditBase( parent, name ) 57 : CategoryEditBase( parent, name )
58{ 58{
59 d = 0; 59 d = 0;
60} 60}
61 61
62CategoryEdit::CategoryEdit( const QArray<int> &recCats, 62CategoryEdit::CategoryEdit( const QArray<int> &recCats,
63 const QString &appName, const QString &visibleName, 63 const QString &appName, const QString &visibleName,
64 QWidget *parent, const char *name ) 64 QWidget *parent, const char *name )
65 : CategoryEditBase( parent, name ) 65 : CategoryEditBase( parent, name )
66{ 66{
67 d = 0; 67 d = 0;
68 setCategories( recCats, appName, visibleName ); 68 setCategories( recCats, appName, visibleName );
69} 69}
70 70
71void CategoryEdit::setCategories( const QArray<int> &recCats, 71void CategoryEdit::setCategories( const QArray<int> &recCats,
72 const QString &appName, const QString &visibleName ) 72 const QString &appName, const QString &visibleName )
73{ 73{
74 if ( !d ) 74 if ( !d )
75 d = new CategoryEditPrivate( (QWidget*)parent(), name() ); 75 d = new CategoryEditPrivate( (QWidget*)parent(), name() );
76 d->mStrApp = appName; 76 d->mStrApp = appName;
77 d->mVisible = visibleName; 77 d->mVisible = visibleName;
78 QArray<int> cats = d->mCategories.ids( d->mStrApp ); 78
79 lvView->clear();
80 QStringList appCats = d->mCategories.labels( d->mStrApp ); 79 QStringList appCats = d->mCategories.labels( d->mStrApp );
80 QArray<int> cats = d->mCategories.ids(d->mStrApp, appCats);
81 lvView->clear();
82
81 QStringList::ConstIterator it; 83 QStringList::ConstIterator it;
82 int i, j; 84 int i, j;
83 for ( i = 0, it = appCats.begin(); it != appCats.end(); i++, ++it ) { 85 for ( i = 0, it = appCats.begin(); it != appCats.end(); i++, ++it ) {
84 QCheckListItem *chk; 86 QCheckListItem *chk;
85 chk = new QCheckListItem( lvView, (*it), QCheckListItem::CheckBox ); 87 chk = new QCheckListItem( lvView, (*it), QCheckListItem::CheckBox );
86 if ( !d->mCategories.isGlobal((*it)) ) 88 if ( !d->mCategories.isGlobal((*it)) )
87 chk->setText( 1, tr(d->mVisible) ); 89 chk->setText( 1, tr(d->mVisible) );
88 else 90 else
89 chk->setText( 1, tr("All") ); 91 chk->setText( 1, tr("All") );
90 // Is this record using this category, then we should check it 92 // Is this record using this category, then we should check it
91 for ( j = 0; j < int(recCats.count()); j++ ) { 93 for ( j = 0; j < int(recCats.count()); j++ ) {
92 if ( cats[i] == recCats[j] ) { 94 if ( cats[i] == recCats[j] ) {
93 chk->setOn( true ); 95 chk->setOn( true );
94 break; 96 break;
95 } 97 }
96 } 98 }
97 } 99 }
98 lvView->setSorting( 0, TRUE ); 100 lvView->setSorting( 0, TRUE );
99 lvView->sort(); 101 lvView->sort();
100 if ( lvView->childCount() < 1 ) 102 if ( lvView->childCount() < 1 )
101 txtCat->setEnabled( FALSE ); 103 txtCat->setEnabled( FALSE );
102 else { 104 else {
103 lvView->setSelected( lvView->firstChild(), true ); 105 lvView->setSelected( lvView->firstChild(), true );
104 } 106 }
105} 107}
106 108
107CategoryEdit::~CategoryEdit() 109CategoryEdit::~CategoryEdit()
108{ 110{
109 if ( d ) 111 if ( d )
110 delete d; 112 delete d;
111} 113}
112 114
113void CategoryEdit::slotSetText( QListViewItem *selected ) 115void CategoryEdit::slotSetText( QListViewItem *selected )
114{ 116{
115 d->editItem = selected; 117 d->editItem = selected;
116 if ( !d->editItem ) 118 if ( !d->editItem )
117 return; 119 return;
118 txtCat->setText( d->editItem->text(0) ); 120 txtCat->setText( d->editItem->text(0) );
119 txtCat->setEnabled( true ); 121 txtCat->setEnabled( true );
120 if ( d->editItem->text(1) == tr("All") ) 122 if ( d->editItem->text(1) == tr("All") )
121 chkGlobal->setChecked( true ); 123 chkGlobal->setChecked( true );
122 else 124 else
123 chkGlobal->setChecked( false ); 125 chkGlobal->setChecked( false );
124} 126}
125 127
126void CategoryEdit::slotAdd() 128void CategoryEdit::slotAdd()
127{ 129{
128 QString name = tr( "New Category" ); 130 QString name = tr( "New Category" );
129 bool insertOk = FALSE; 131 bool insertOk = FALSE;
130 int num = 0; 132 int num = 0;
131 while ( !insertOk ) { 133 while ( !insertOk ) {
132 if ( num++ > 0 ) 134 if ( num++ > 0 )
133 name = tr("New Category ") + QString::number(num); 135 name = tr("New Category ") + QString::number(num);
134 insertOk = d->mCategories.addCategory( d->mStrApp, name ); 136 insertOk = d->mCategories.addCategory( d->mStrApp, name );
135 } 137 }
136 QCheckListItem *chk; 138 QCheckListItem *chk;
137 chk = new QCheckListItem( lvView, name, QCheckListItem::CheckBox ); 139 chk = new QCheckListItem( lvView, name, QCheckListItem::CheckBox );
138 if ( !chkGlobal->isChecked() ) 140 if ( !chkGlobal->isChecked() )
139 chk->setText( 1, tr(d->mVisible) ); 141 chk->setText( 1, tr(d->mVisible) );
140 else 142 else
141 chk->setText( 1, tr("All") ); 143 chk->setText( 1, tr("All") );
142 144
143 lvView->setSelected( chk, TRUE ); 145 lvView->setSelected( chk, TRUE );
144 txtCat->selectAll(); 146 txtCat->selectAll();
145} 147}
146 148
147void CategoryEdit::slotRemove() 149void CategoryEdit::slotRemove()
148{ 150{
149 d->editItem = lvView->selectedItem(); 151 d->editItem = lvView->selectedItem();
150 if ( d->editItem ) { 152 if ( d->editItem ) {
151 QListViewItem *sibling = d->editItem->nextSibling(); 153 QListViewItem *sibling = d->editItem->nextSibling();
152 154
153 d->mCategories.removeCategory( d->mStrApp, d->editItem->text(0) ); 155 d->mCategories.removeCategory( d->mStrApp, d->editItem->text(0) );
154 156
155 delete d->editItem; 157 delete d->editItem;
156 d->editItem = 0; 158 d->editItem = 0;
157 159
158 if ( sibling ) 160 if ( sibling )
159 lvView->setSelected( sibling, TRUE ); 161 lvView->setSelected( sibling, TRUE );
160 } 162 }
161 if ( lvView->childCount() < 1 ) { 163 if ( lvView->childCount() < 1 ) {
162 txtCat->clear(); 164 txtCat->clear();
163 txtCat->setEnabled( FALSE ); 165 txtCat->setEnabled( FALSE );
164 } 166 }
165} 167}
166 168
167void CategoryEdit::slotSetGlobal( bool isChecked ) 169void CategoryEdit::slotSetGlobal( bool isChecked )
168{ 170{
169 if ( d->editItem ) { 171 if ( d->editItem ) {
170 if ( isChecked ) 172 if ( isChecked )
171 d->editItem->setText( 1, tr("All") ); 173 d->editItem->setText( 1, tr("All") );
172 else 174 else
173 d->editItem->setText( 1, tr(d->mVisible) ); 175 d->editItem->setText( 1, tr(d->mVisible) );
174 176
175 d->mCategories.setGlobal( d->mStrApp, d->editItem->text( 0 ), isChecked ); 177 d->mCategories.setGlobal( d->mStrApp, d->editItem->text( 0 ), isChecked );
176 } 178 }
diff --git a/library/categoryselect.cpp b/library/categoryselect.cpp
index dc5d1fa..21b3f91 100644
--- a/library/categoryselect.cpp
+++ b/library/categoryselect.cpp
@@ -1,315 +1,452 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 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 <qpe/categories.h> 21#include <qpe/categories.h>
22#include <qpe/palmtoprecord.h>
22 23
23#include <qdialog.h> 24#include <qmessagebox.h>
24#include <qlayout.h> 25#include <qlayout.h>
25#include <qtoolbutton.h> 26#include <qtoolbutton.h>
27#include <qfile.h>
26 28
27#include "categorywidget.h" 29#include "categorywidget.h"
28#include "categoryselect.h" 30#include "categoryselect.h"
29 31
32#include <stdlib.h>
33
34static QString categoryEdittingFileName()
35{
36 QString str = getenv("HOME");
37 str +="/.cateditting";
38 return str;
39}
30 40
31class CategoryComboPrivate 41class CategoryComboPrivate
32{ 42{
33public: 43public:
34 CategoryComboPrivate(QObject *o) 44 CategoryComboPrivate(QObject *o)
35 : mCat( o ) 45 : mCat( o )
36 { 46 {
37 } 47 }
38 QArray<int> mAppCats; 48 QArray<int> mAppCats;
39 QString mStrAppName; 49 QString mStrAppName;
40 QString mStrVisibleName; 50 QString mStrVisibleName;
41 Categories mCat; 51 Categories mCat;
42}; 52};
43 53
44class CategorySelectPrivate 54class CategorySelectPrivate
45{ 55{
46public: 56public:
47 CategorySelectPrivate( const QArray<int> &cats) 57 CategorySelectPrivate( const QArray<int> &cats)
48 : mRec( cats ), 58 : mRec( cats ),
49 usingAll( false ) 59 usingAll( false )
50 { 60 {
51 } 61 }
52 CategorySelectPrivate() 62 CategorySelectPrivate()
53 { 63 {
54 } 64 }
55 QArray<int> mRec; 65 QArray<int> mRec;
56 bool usingAll; 66 bool usingAll;
57 QString mVisibleName; 67 QString mVisibleName;
58}; 68};
59 69
60CategoryCombo::CategoryCombo( QWidget *parent, const char *name ) 70CategoryCombo::CategoryCombo( QWidget *parent, const char *name , int width)
61 : QComboBox( parent, name ) 71 : QComboBox( parent, name )
62{ 72{
63 d = new CategoryComboPrivate(this); 73 d = new CategoryComboPrivate(this);
74 if (width)
75 setFixedWidth(width);
64} 76}
65 77
66void CategoryCombo::initCombo( const QArray<int> &recCats, 78void CategoryCombo::initCombo( const QArray<int> &recCats,
67 const QString &appName ) 79 const QString &appName )
68{ 80{
69 initCombo( recCats, appName, appName ); 81 initCombo( recCats, appName, appName );
70} 82}
71 83
72void CategoryCombo::initCombo( const QArray<int> &recCats, 84void CategoryCombo::initCombo( const QArray<int> &recCats,
73 const QString &appName, 85 const QString &appName,
74 const QString &visibleName ) 86 const QString &visibleName )
75{ 87{
76 d->mStrAppName = appName; 88 d->mStrAppName = appName;
77 d->mStrVisibleName = visibleName; 89 d->mStrVisibleName = visibleName;
78 clear(); 90 clear();
79 QStringList slApp; 91 QStringList slApp;
80 92
93 QObject::disconnect( this, SIGNAL(activated(int)),
94 this, SLOT(slotValueChanged(int)) );
95
81 QObject::connect( this, SIGNAL(activated(int)), 96 QObject::connect( this, SIGNAL(activated(int)),
82 this, SLOT(slotValueChanged(int)) ); 97 this, SLOT(slotValueChanged(int)) );
83 bool loadOk = d->mCat.load( categoryFileName() ); 98 bool loadOk = d->mCat.load( categoryFileName() );
84 slApp = d->mCat.labels( d->mStrAppName, TRUE, Categories::UnfiledLabel ); 99 slApp = d->mCat.labels( d->mStrAppName, TRUE, Categories::UnfiledLabel );
85 d->mAppCats = d->mCat.ids( d->mStrAppName ); 100
101 d->mAppCats = d->mCat.ids( d->mStrAppName, slApp);
86 102
87 int i, 103 int i,
88 j, 104 j,
89 saveMe, 105 saveMe,
90 recCount; 106 recCount;
91 QStringList::Iterator it; 107 QStringList::Iterator it;
92 // now add in all the items... 108 // now add in all the items...
93 recCount = recCats.count(); 109 recCount = recCats.count();
94 saveMe = -1; 110 saveMe = -1;
95 if ( recCount > 1 && loadOk ) { 111 if ( recCount > 1 && loadOk ) {
96 it = slApp.begin(); 112 it = slApp.begin();
97 insertItem( *it ); 113 for ( j = 0; j< (int)(slApp.count()-1); ++it, j++ ) {
98 ++it;
99 for ( j = 0; it != slApp.end(); ++it, j++ ) {
100 // grr... we have to go through and compare... 114 // grr... we have to go through and compare...
101 if ( j < int(d->mAppCats.size()) ) { 115 if ( j < int(d->mAppCats.size()) ) {
102 for ( i = 0; i < recCount; i++ ) { 116 for ( i = 0; i < recCount; i++ ) {
103 if ( recCats[i] == d->mAppCats[j] ) { 117 if ( recCats[i] == d->mAppCats[j] ) {
104 (*it).append( tr(" (Multi.)") ); 118 (*it).append( tr(" (Multi.)") );
105 if ( saveMe < 0 ) 119 if ( saveMe < 0 )
106 saveMe = j; 120 saveMe = j;
107 // no need to continue through the list. 121 // no need to continue through the list.
108 break; 122 break;
109 } 123 }
110 } 124 }
111 } 125 }
112 insertItem( *it ); 126 insertItem( *it );
113 } 127 }
128 insertItem( *it );
114 } else 129 } else
115 insertStringList( slApp ); 130 insertStringList( slApp );
116 131
117 if ( recCount > 0 && loadOk ) { 132 if ( recCount > 0 && loadOk ) {
118 for ( i = 0; i < int(d->mAppCats.size()); i++ ) { 133 for ( i = 0; i < int(d->mAppCats.size()); i++ ) {
119 if ( d->mAppCats[i] == recCats[0] ) { 134 if ( d->mAppCats[i] == recCats[0] ) {
120 setCurrentItem( i + 1 ); 135 setCurrentItem( i );
136 break;
137 }
138 }
139 } else
140 {
141 setCurrentItem( slApp.count()-1 ); // unfiled
142 }
143}
144
145// this is a new function by SHARP instead of initCombo()
146QArray<int> CategoryCombo::initComboWithRefind( const QArray<int> &recCats,
147 const QString &appName)
148{
149 QString visibleName = appName;
150 d->mStrAppName = appName;
151 d->mStrVisibleName = visibleName;
152 clear();
153 QStringList slApp;
154 QArray<int> results;
155
156 QObject::disconnect( this, SIGNAL(activated(int)),
157 this, SLOT(slotValueChanged(int)) );
158
159 QObject::connect( this, SIGNAL(activated(int)),
160 this, SLOT(slotValueChanged(int)) );
161 bool loadOk = d->mCat.load( categoryFileName() );
162 slApp = d->mCat.labels( d->mStrAppName, TRUE, Categories::UnfiledLabel );
163
164 d->mAppCats = d->mCat.ids( d->mStrAppName, slApp);
165
166 // addition part
167 // make new recCats
168 if (loadOk){
169 int i,j;
170 int value;
171 int rCount = recCats.count();
172 int mCount = d->mAppCats.count();
173
174 for (i=0; i<rCount; i++){
175 value = 0;
176 for (j=0; j<mCount; j++){
177 if (recCats[i] == d->mAppCats[j]){
178 value = recCats[i];
179 break;
180 }
181 }
182 if (value != 0){
183 int tmp = results.size();
184 results.resize( tmp + 1 );
185 results[ tmp ] = value;
186 }
187 }
188 }
189 else{
190 results = recCats;
191 }
192 // addition end
193
194 int i,
195 j,
196 saveMe,
197 recCount;
198 QStringList::Iterator it;
199 // now add in all the items...
200 recCount = results.count();
201 saveMe = -1;
202 if ( recCount > 1 && loadOk ) {
203 it = slApp.begin();
204 for ( j = 0; j< (int)(slApp.count()-1); ++it, j++ ) {
205
206 // grr... we have to go through and compare...
207 if ( j < int(d->mAppCats.size()) ) {
208 for ( i = 0; i < recCount; i++ ) {
209 if ( results[i] == d->mAppCats[j] ) {
210 (*it).append( tr(" (Multi.)") );
211 if ( saveMe < 0 )
212 saveMe = j;
213 // no need to continue through the list.
214 break;
215 }
216 }
217 }
218 insertItem( *it );
219 }
220 insertItem( *it );
221 } else
222 insertStringList( slApp );
223
224 if ( recCount > 0 && loadOk ) {
225 for ( i = 0; i < int(d->mAppCats.size()); i++ ) {
226 if ( d->mAppCats[i] == results[0] ) {
227 setCurrentItem( i );
121 break; 228 break;
122 } 229 }
123 } 230 }
124 } else 231 } else
125 setCurrentItem( 0 ); // unfiled 232 {
233 setCurrentItem( slApp.count()-1 ); // unfiled
234 }
235/*
126 QObject::connect( this, SIGNAL(activated(int)), 236 QObject::connect( this, SIGNAL(activated(int)),
127 this, SLOT(slotValueChanged(int)) ); 237 this, SLOT(slotValueChanged(int)) );
238*/
239 return results;
128} 240}
129 241
242
130CategoryCombo::~CategoryCombo() 243CategoryCombo::~CategoryCombo()
131{ 244{
132 delete d; 245 delete d;
133} 246}
134 247
135int CategoryCombo::currentCategory() const 248int CategoryCombo::currentCategory() const
136{ 249{
137 int returnMe; 250 int returnMe;
138 returnMe = currentItem(); 251 returnMe = currentItem();
139 // unfiled is now 0... 252
140 if ( returnMe == 0 ) 253 if ( returnMe == (int)d->mAppCats.count() )
141 returnMe = -1; 254 returnMe = -1;
142 else if ( returnMe > (int)d->mAppCats.count() ) // only happen on "All" 255 else if ( returnMe > (int)d->mAppCats.count() ) // only happen on "All"
143 returnMe = -2; 256 returnMe = -2;
144 else 257 else
145 returnMe = d->mAppCats[returnMe - 1]; 258 returnMe = d->mAppCats[returnMe];
146 return returnMe; 259 return returnMe;
147} 260}
148 261
149void CategoryCombo::setCurrentCategory( int newCatUid ) 262void CategoryCombo::setCurrentCategory( int newCatUid )
150{ 263{
151 int i; 264 int i;
152 for ( i = 0; i < int(d->mAppCats.size()); i++ ) { 265 for ( i = 0; i < int(d->mAppCats.size()); i++ ) {
153 if ( d->mAppCats[i] == newCatUid ) 266 if ( d->mAppCats[i] == newCatUid )
154 setCurrentItem( i ); 267 setCurrentItem( i );
155 } 268 }
156} 269}
157 270
158void CategoryCombo::setCurrentText( const QString &str ) 271void CategoryCombo::setCurrentText( const QString &str )
159{ 272{
160 int i; 273 int i;
161 int stop; 274 int stop;
162 stop = count(); 275 stop = count();
163 for ( i = 0; i < stop; i++ ) { 276 for ( i = 0; i < stop; i++ ) {
164 if ( text( i ) == str ) { 277 if ( text( i ) == str ) {
165 setCurrentItem( i ); 278 setCurrentItem( i );
166 break; 279 break;
167 } 280 }
168 } 281 }
169} 282}
170 283
171void CategoryCombo::slotValueChanged( int ) 284void CategoryCombo::slotValueChanged( int )
172{ 285{
173 emit sigCatChanged( currentCategory() ); 286 emit sigCatChanged( currentCategory() );
174} 287}
175 288
176CategorySelect::CategorySelect( QWidget *parent, const char *name ) 289CategorySelect::CategorySelect( QWidget *parent, const char *name,int width)
177 : QHBox( parent, name ), 290 : QHBox( parent, name ),
178 cmbCat( 0 ), 291 cmbCat( 0 ),
179 cmdCat( 0 ), 292 cmdCat( 0 ),
180 d( 0 ) 293 d( 0 )
181{ 294{
182 d = new CategorySelectPrivate(); 295 d = new CategorySelectPrivate();
183 init(); 296 init(width);
184} 297}
185 298
186CategorySelect::CategorySelect( const QArray<int> &vl, 299CategorySelect::CategorySelect( const QArray<int> &vl,
187 const QString &appName, QWidget *parent, 300 const QString &appName, QWidget *parent,
188 const char *name ) 301 const char *name ,int width)
189 : QHBox( parent, name ) 302 : QHBox( parent, name )
190{ 303{
191 d = new CategorySelectPrivate( vl ); 304 d = new CategorySelectPrivate( vl );
192 init(); 305
306 init(width);
307
193 setCategories( vl, appName, appName ); 308 setCategories( vl, appName, appName );
194} 309}
195 310
196CategorySelect::CategorySelect( const QArray<int> &vl, 311CategorySelect::CategorySelect( const QArray<int> &vl,
197 const QString &appName, 312 const QString &appName,
198 const QString &visibleName, 313 const QString &visibleName,
199 QWidget *parent, const char *name ) 314 QWidget *parent, const char *name , int width)
200 : QHBox( parent, name ) 315 : QHBox( parent, name )
201{ 316{
202 d = new CategorySelectPrivate( vl ); 317 d = new CategorySelectPrivate( vl );
203 init(); 318 init(width);
204 setCategories( vl, appName, visibleName ); 319 setCategories( vl, appName, visibleName );
205} 320}
206 321
207CategorySelect::~CategorySelect() 322CategorySelect::~CategorySelect()
208{ 323{
209 delete d; 324 delete d;
210} 325}
211 326
212void CategorySelect::slotDialog() 327void CategorySelect::slotDialog()
213{ 328{
329 if (QFile::exists( categoryEdittingFileName() )){
330 QMessageBox::warning(this,tr("Error"),
331 tr("Sorry, another application is\nediting categories.") );
332 return;
333 }
334
335 QFile f( categoryEdittingFileName() );
336 if ( !f.open( IO_WriteOnly) ){
337 return;
338 }
339
214 QDialog editDlg( this, 0, TRUE ); 340 QDialog editDlg( this, 0, TRUE );
215 editDlg.setCaption( tr("Edit Categories") ); 341 editDlg.setCaption( tr("Edit Categories") );
216 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 342 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
217 QScrollView *sv = new QScrollView( &editDlg ); 343 QScrollView *sv = new QScrollView( &editDlg );
218 sv->setResizePolicy( QScrollView::AutoOneFit ); 344 sv->setResizePolicy( QScrollView::AutoOneFit );
219 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 345 sv->setHScrollBarMode( QScrollView::AlwaysOff );
220 vb->addWidget( sv ); 346 vb->addWidget( sv );
221 CategoryWidget ce( d->mRec, mStrAppName, d->mVisibleName, &editDlg ); 347 CategoryWidget ce( d->mRec, mStrAppName, d->mVisibleName, &editDlg );
222 sv->addChild( &ce ); 348 sv->addChild( &ce );
223 editDlg.showMaximized(); 349 editDlg.showMaximized();
224 350
225 if ( editDlg.exec() ) { 351 if ( editDlg.exec() ) {
226 d->mRec = ce.newCategories(); 352 d->mRec = ce.newCategories();
227 cmbCat->initCombo( d->mRec, mStrAppName ); 353 cmbCat->initCombo( d->mRec, mStrAppName );
228 } 354 }
355
356 f.close();
357 QFile::remove( categoryEdittingFileName() );
229} 358}
230 359
231void CategorySelect::slotNewCat( int newUid ) 360void CategorySelect::slotNewCat( int newUid )
232{ 361{
233 if ( newUid != -1 ) { 362 if ( newUid != -1 ) {
234 bool alreadyIn = false; 363 bool alreadyIn = false;
235 for ( uint it = 0; it < d->mRec.count(); ++it ) { 364 for ( uint it = 0; it < d->mRec.count(); ++it ) {
236 if ( d->mRec[it] == newUid ) { 365 if ( d->mRec[it] == newUid ) {
237 alreadyIn = true; 366 alreadyIn = true;
238 break; 367 break;
239 } 368 }
240 } 369 }
241 if ( !alreadyIn ) { 370 if ( !alreadyIn ) {
242 d->mRec.resize( 1 ); 371 d->mRec.resize( 1 );
243 d->mRec[ 0 ] = newUid; 372 d->mRec[ 0 ] = newUid;
244 } 373 }
245 } else 374 } else
246 d->mRec.resize(0); // now Unfiled. 375 d->mRec.resize(0); // now Unfiled.
247 emit signalSelected( currentCategory() ); 376 emit signalSelected( currentCategory() );
248} 377}
249 378
250void CategorySelect::setCategories( const QArray<int> &rec, 379QString CategorySelect::setCategories( const QArray<int> &rec,
251 const QString &appName ) 380 const QString &appName )
252{ 381{
253 setCategories( rec, appName, appName ); 382 return setCategories( rec, appName, appName );
254} 383}
255 384
256void CategorySelect::setCategories( const QArray<int> &rec, 385QString CategorySelect::setCategories( const QArray<int> &rec,
257 const QString &appName, 386 const QString &appName,
258 const QString &visibleName ) 387 const QString &visibleName )
259{ 388{
260 d->mRec = rec;
261 d->mVisibleName = visibleName; 389 d->mVisibleName = visibleName;
262 mStrAppName = appName; 390 mStrAppName = appName;
263 cmbCat->initCombo( rec, appName ); 391 d->mRec = cmbCat->initComboWithRefind( rec, appName );
392 return Qtopia::Record::idsToString(d->mRec);
264} 393}
265 394
266void CategorySelect::init() 395void CategorySelect::init(int width)
267{ 396{
268 cmbCat = new CategoryCombo( this ); 397 cmbCat = new CategoryCombo( this, 0, width);
398
269 QObject::connect( cmbCat, SIGNAL(sigCatChanged(int)), 399 QObject::connect( cmbCat, SIGNAL(sigCatChanged(int)),
270 this, SLOT(slotNewCat(int)) ); 400 this, SLOT(slotNewCat(int)) );
271 cmdCat = new QToolButton( this ); 401 cmdCat = new QToolButton( this );
272 QObject::connect( cmdCat, SIGNAL(clicked()), this, SLOT(slotDialog()) ); 402 QObject::connect( cmdCat, SIGNAL(clicked()), this, SLOT(slotDialog()) );
273 cmdCat->setTextLabel( "...", FALSE ); 403 cmdCat->setTextLabel( "...", FALSE );
274 cmdCat->setUsesTextLabel( true ); 404 cmdCat->setUsesTextLabel( true );
275 cmdCat->setMaximumSize( cmdCat->sizeHint() ); 405 cmdCat->setMaximumSize( cmdCat->sizeHint() );
276 cmdCat->setFocusPolicy( TabFocus ); 406 cmdCat->setFocusPolicy( TabFocus );
277} 407}
278 408
279 409
280int CategorySelect::currentCategory() const 410int CategorySelect::currentCategory() const
281{ 411{
282 return cmbCat->currentCategory(); 412 return cmbCat->currentCategory();
283} 413}
284 414
285void CategorySelect::setCurrentCategory( int newCatUid ) 415void CategorySelect::setCurrentCategory( int newCatUid )
286{ 416{
287 cmbCat->setCurrentCategory( newCatUid ); 417 cmbCat->setCurrentCategory( newCatUid );
288} 418}
289 419
290 420
291const QArray<int> &CategorySelect::currentCategories() const 421const QArray<int> &CategorySelect::currentCategories() const
292{ 422{
293 return d->mRec; 423 return d->mRec;
294} 424}
295 425
296void CategorySelect::setRemoveCategoryEdit( bool remove ) 426void CategorySelect::setRemoveCategoryEdit( bool remove )
297{ 427{
298 if ( remove ) { 428 if ( remove ) {
299 cmdCat->setEnabled( FALSE ); 429 cmdCat->setEnabled( FALSE );
300 cmdCat->hide(); 430 cmdCat->hide();
301 } else { 431 } else {
302 cmdCat->setEnabled( TRUE ); 432 cmdCat->setEnabled( TRUE );
303 cmdCat->show(); 433 cmdCat->show();
304 } 434 }
305} 435}
306 436
307void CategorySelect::setAllCategories( bool add ) 437void CategorySelect::setAllCategories( bool add )
308{ 438{
309 d->usingAll = add; 439 d->usingAll = add;
310 if ( add ) { 440 if ( add ) {
311 cmbCat->insertItem( tr( "All" ), cmbCat->count() ); 441 cmbCat->insertItem( tr( "All" ), cmbCat->count() );
312 cmbCat->setCurrentItem( cmbCat->count() - 1 ); 442 cmbCat->setCurrentItem( cmbCat->count() - 1 );
313 } else 443 } else
314 cmbCat->removeItem( cmbCat->count() - 1 ); 444 cmbCat->removeItem( cmbCat->count() - 1 );
315} 445}
446
447// 01.12.21 added
448void CategorySelect::setFixedWidth(int width)
449{
450 width -= cmdCat->width();
451 cmbCat->setFixedWidth(width);
452}
diff --git a/library/categoryselect.h b/library/categoryselect.h
index 5c6b565..7a8e491 100644
--- a/library/categoryselect.h
+++ b/library/categoryselect.h
@@ -1,105 +1,113 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 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#ifndef __CATEGORYCOMBO_H__ 21#ifndef __CATEGORYCOMBO_H__
22#define __CATEGORYCOMBO_H__ 22#define __CATEGORYCOMBO_H__
23 23
24#include <qcombobox.h> 24#include <qcombobox.h>
25#include <qhbox.h> 25#include <qhbox.h>
26#include <qstring.h> 26#include <qstring.h>
27#include <qarray.h> 27#include <qarray.h>
28 28
29extern QString categoryFileName(); 29extern QString categoryFileName();
30 30
31class QToolButton; 31class QToolButton;
32 32
33class CategoryComboPrivate; 33class CategoryComboPrivate;
34class CategoryCombo : public QComboBox 34class CategoryCombo : public QComboBox
35{ 35{
36 Q_OBJECT 36 Q_OBJECT
37 37
38public: 38public:
39 CategoryCombo( QWidget *parent, const char* name = 0 ); 39 CategoryCombo( QWidget *parent, const char* name = 0, int width=0);
40
40 ~CategoryCombo(); 41 ~CategoryCombo();
41 42
42 int currentCategory() const; 43 int currentCategory() const;
43 void setCurrentCategory( int id ); 44 void setCurrentCategory( int id );
44 // depreciated. 45 // depreciated.
45 void initCombo( const QArray<int> &recCats, const QString &appName ); 46 void initCombo( const QArray<int> &recCats, const QString &appName );
46 void initCombo( const QArray<int> &recCats, const QString &appName, 47 void initCombo( const QArray<int> &recCats, const QString &appName,
47 const QString &visibleName /* = appName */ ); 48 const QString &visibleName /* = appName */ );
48 49
50 QArray<int> initComboWithRefind( const QArray<int> &recCats, const QString &appName );
51
49signals: 52signals:
50 void sigCatChanged( int newUid ); 53 void sigCatChanged( int newUid );
51 54
52private slots: 55private slots:
53 void slotValueChanged( int ); 56 void slotValueChanged( int );
54 57
55private: 58private:
56 void setCurrentText( const QString &str ); 59 void setCurrentText( const QString &str );
57 CategoryComboPrivate *d; 60 CategoryComboPrivate *d;
58}; 61};
59 62
60#endif 63#endif
61 64
62class CategorySelectPrivate; 65class CategorySelectPrivate;
63class CategorySelect : public QHBox 66class CategorySelect : public QHBox
64{ 67{
65 Q_OBJECT 68 Q_OBJECT
66public: 69public:
67 // we need two constructors, the first gets around designer limitations 70 // we need two constructors, the first gets around designer limitations
68 CategorySelect( QWidget *parent = 0, const char *name = 0 ); 71
72 CategorySelect( QWidget *parent = 0, const char *name = 0, int width = 0 );
69 73
70 CategorySelect( const QArray<int> &vlCats, const QString &appName, 74 CategorySelect( const QArray<int> &vlCats, const QString &appName,
71 QWidget *parent = 0, const char *name = 0 ); 75 QWidget *parent = 0, const char *name = 0,
76 int width = 0);
72 CategorySelect( const QArray<int> &vlCats, const QString &appName, 77 CategorySelect( const QArray<int> &vlCats, const QString &appName,
73 const QString &visibleName, QWidget *parent = 0, 78 const QString &visibleName, QWidget *parent = 0,
74 const char *name = 0 ); 79 const char *name = 0 , int width = 0);
80
75 ~CategorySelect(); 81 ~CategorySelect();
76 82
77 const QArray<int> &currentCategories() const; 83 const QArray<int> &currentCategories() const;
78 int currentCategory() const; 84 int currentCategory() const;
79 void setCurrentCategory( int newCatUid ); 85 void setCurrentCategory( int newCatUid );
80 // pretty much if you don't set it the constructor, you need to 86 // pretty much if you don't set it the constructor, you need to
81 // call it here ASAP! 87 // call it here ASAP!
82 // however this call is depreciated... 88 // however this call is depreciated...
83 void setCategories( const QArray<int> &vlCats, const QString &appName );
84 // use this one instead (for translating )
85 void setCategories( const QArray<int> &vlCats, const QString &appName,
86 const QString &visibleName );
87 89
90 QString setCategories( const QArray<int> &vlCats, const QString &appName );
91 QString setCategories( const QArray<int> &vlCats, const QString &appName,
92 const QString &visibleName );
88 // these were added for find dialog. 93 // these were added for find dialog.
89 void setRemoveCategoryEdit( bool remove ); 94 void setRemoveCategoryEdit( bool remove );
90 void setAllCategories( bool add ); 95 void setAllCategories( bool add );
91 96
97 void setFixedWidth(int width);
92signals: 98signals:
93 void signalSelected( int ); 99 void signalSelected( int );
94 100
95private slots: 101private slots:
96 void slotDialog(); 102 void slotDialog();
103
104public slots:
97 void slotNewCat( int id ); 105 void slotNewCat( int id );
98 106
99private: 107private:
100 void init(); 108 void init(int width=0);
101 QString mStrAppName; 109 QString mStrAppName;
102 CategoryCombo *cmbCat; 110 CategoryCombo *cmbCat;
103 QToolButton *cmdCat; 111 QToolButton *cmdCat;
104 CategorySelectPrivate *d; 112 CategorySelectPrivate *d;
105}; 113};
diff --git a/library/config.cpp b/library/config.cpp
index 9634571..e07eecb 100644
--- a/library/config.cpp
+++ b/library/config.cpp
@@ -1,201 +1,198 @@
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 <qdir.h> 21#include <qdir.h>
22#include <qfile.h> 22#include <qfile.h>
23#include <qfileinfo.h> 23#include <qfileinfo.h>
24#include <qmessagebox.h> 24#include <qmessagebox.h>
25#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 25#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
26#include <qtextcodec.h> 26#include <qtextcodec.h>
27#endif 27#endif
28#include <qtextstream.h> 28#include <qtextstream.h>
29 29
30#include <sys/stat.h> 30#include <sys/stat.h>
31#include <sys/types.h> 31#include <sys/types.h>
32#include <fcntl.h> 32#include <fcntl.h>
33#include <stdlib.h> 33#include <stdlib.h>
34#include <unistd.h> 34#include <unistd.h>
35 35
36#define QTOPIA_INTERNAL_LANGLIST
36#include "config.h" 37#include "config.h"
38#include "global.h"
37 39
38 40
39/*! 41/*!
40 \internal 42 \internal
41*/ 43*/
42QString Config::configFilename(const QString& name, Domain d) 44QString Config::configFilename(const QString& name, Domain d)
43{ 45{
44 switch (d) { 46 switch (d) {
45 case File: 47 case File:
46 return name; 48 return name;
47 case User: { 49 case User: {
48 QDir dir = (QString(getenv("HOME")) + "/Settings"); 50 QDir dir = (QString(getenv("HOME")) + "/Settings");
49 if ( !dir.exists() ) 51 if ( !dir.exists() )
50 mkdir(dir.path().local8Bit(),0700); 52 mkdir(dir.path().local8Bit(),0700);
51 return dir.path() + "/" + name + ".conf"; 53 return dir.path() + "/" + name + ".conf";
52 } 54 }
53 } 55 }
54 return name; 56 return name;
55} 57}
56 58
57/*! 59/*!
58 \class Config config.h 60 \class Config config.h
59 \brief The Config class provides for saving application cofniguration state. 61 \brief The Config class provides for saving application cofniguration state.
60 62
61 You should keep a Config in existence only while you do not want others 63 You should keep a Config in existence only while you do not want others
62 to be able to change the state. There is no locking currently, but there 64 to be able to change the state. There is no locking currently, but there
63 may be in the future. 65 may be in the future.
64*/ 66*/
65 67
66/*! 68/*!
67 \enum Config::ConfigGroup 69 \enum Config::ConfigGroup
68 \internal 70 \internal
69*/ 71*/
70 72
71/*! 73/*!
72 \enum Config::Domain 74 \enum Config::Domain
73 75
74 \value File 76 \value File
75 \value User 77 \value User
76 78
77 See Config for details. 79 See Config for details.
78*/ 80*/
79 81
80/*! 82/*!
81 Constructs a config that will load or create a configuration with the 83 Constructs a config that will load or create a configuration with the
82 given \a name in the given \a domain. 84 given \a name in the given \a domain.
83 85
84 You must call setGroup() before doing much else with the Config. 86 You must call setGroup() before doing much else with the Config.
85 87
86 In the default Domain, \e User, 88 In the default Domain, \e User,
87 the configuration is user-specific. \a name should not contain "/" in 89 the configuration is user-specific. \a name should not contain "/" in
88 this case, and in general should be the name of the C++ class that is 90 this case, and in general should be the name of the C++ class that is
89 primarily responsible for maintaining the configuration. 91 primarily responsible for maintaining the configuration.
90 92
91 In the File Domain, \a name is an absolute filename. 93 In the File Domain, \a name is an absolute filename.
92*/ 94*/
93Config::Config( const QString &name, Domain domain ) 95Config::Config( const QString &name, Domain domain )
94 : filename( configFilename(name,domain) ) 96 : filename( configFilename(name,domain) )
95{ 97{
96 git = groups.end(); 98 git = groups.end();
97 read(); 99 read();
98 100 QStringList l = Global::languageList();
99 lang = getenv("LANG"); 101 lang = l[0];
100 int i = lang.find("."); 102 glang = l[1];
101 if ( i > 0 )
102 lang = lang.left( i );
103 i = lang.find( "_" );
104 if ( i > 0 )
105 glang = lang.left(i);
106} 103}
107 104
108/*! 105/*!
109 Writes any changes to disk and destroys the in-memory object. 106 Writes any changes to disk and destroys the in-memory object.
110*/ 107*/
111Config::~Config() 108Config::~Config()
112{ 109{
113 if ( changed ) 110 if ( changed )
114 write(); 111 write();
115} 112}
116 113
117/*! 114/*!
118 Returns whether the current group has an entry called \a key. 115 Returns whether the current group has an entry called \a key.
119*/ 116*/
120bool Config::hasKey( const QString &key ) const 117bool Config::hasKey( const QString &key ) const
121{ 118{
122 if ( groups.end() == git ) 119 if ( groups.end() == git )
123 return FALSE; 120 return FALSE;
124 ConfigGroup::ConstIterator it = ( *git ).find( key ); 121 ConfigGroup::ConstIterator it = ( *git ).find( key );
125 return it != ( *git ).end(); 122 return it != ( *git ).end();
126} 123}
127 124
128/*! 125/*!
129 Sets the current group for subsequent reading and writing of 126 Sets the current group for subsequent reading and writing of
130 entries to \a gname. Grouping allows the application to partition the namespace. 127 entries to \a gname. Grouping allows the application to partition the namespace.
131 128
132 This function must be called prior to any reading or writing 129 This function must be called prior to any reading or writing
133 of entries. 130 of entries.
134 131
135 The \a gname must not be empty. 132 The \a gname must not be empty.
136*/ 133*/
137void Config::setGroup( const QString &gname ) 134void Config::setGroup( const QString &gname )
138{ 135{
139 QMap< QString, ConfigGroup>::Iterator it = groups.find( gname ); 136 QMap< QString, ConfigGroup>::Iterator it = groups.find( gname );
140 if ( it == groups.end() ) { 137 if ( it == groups.end() ) {
141 git = groups.insert( gname, ConfigGroup() ); 138 git = groups.insert( gname, ConfigGroup() );
142 changed = TRUE; 139 changed = TRUE;
143 return; 140 return;
144 } 141 }
145 git = it; 142 git = it;
146} 143}
147 144
148/*! 145/*!
149 Writes a (\a key, \a value) entry to the current group. 146 Writes a (\a key, \a value) entry to the current group.
150 147
151 \sa readEntry() 148 \sa readEntry()
152*/ 149*/
153void Config::writeEntry( const QString &key, const char* value ) 150void Config::writeEntry( const QString &key, const char* value )
154{ 151{
155 writeEntry(key,QString(value)); 152 writeEntry(key,QString(value));
156} 153}
157 154
158/*! 155/*!
159 Writes a (\a key, \a value) entry to the current group. 156 Writes a (\a key, \a value) entry to the current group.
160 157
161 \sa readEntry() 158 \sa readEntry()
162*/ 159*/
163void Config::writeEntry( const QString &key, const QString &value ) 160void Config::writeEntry( const QString &key, const QString &value )
164{ 161{
165 if ( git == groups.end() ) { 162 if ( git == groups.end() ) {
166 qWarning( "no group set" ); 163 qWarning( "no group set" );
167 return; 164 return;
168 } 165 }
169 if ( (*git)[key] != value ) { 166 if ( (*git)[key] != value ) {
170 ( *git ).insert( key, value ); 167 ( *git ).insert( key, value );
171 changed = TRUE; 168 changed = TRUE;
172 } 169 }
173} 170}
174 171
175/* 172/*
176 Note that the degree of protection offered by the encryption here is 173 Note that the degree of protection offered by the encryption here is
177 only sufficient to avoid the most casual observation of the configuration 174 only sufficient to avoid the most casual observation of the configuration
178 files. People with access to the files can write down the contents and 175 files. People with access to the files can write down the contents and
179 decrypt it using this source code. 176 decrypt it using this source code.
180 177
181 Conceivably, and at some burden to the user, this encryption could 178 Conceivably, and at some burden to the user, this encryption could
182 be improved. 179 be improved.
183*/ 180*/
184static QString encipher(const QString& plain) 181static QString encipher(const QString& plain)
185{ 182{
186 // mainly, we make it long 183 // mainly, we make it long
187 QString cipher; 184 QString cipher;
188 int mix=28730492; 185 int mix=28730492;
189 for (int i=0; i<(int)plain.length(); i++) { 186 for (int i=0; i<(int)plain.length(); i++) {
190 int u = plain[i].unicode(); 187 int u = plain[i].unicode();
191 int c = u ^ mix; 188 int c = u ^ mix;
192 QString x = QString::number(c,36); 189 QString x = QString::number(c,36);
193 cipher.append(QChar('a'+x.length())); 190 cipher.append(QChar('a'+x.length()));
194 cipher.append(x); 191 cipher.append(x);
195 mix *= u; 192 mix *= u;
196 } 193 }
197 return cipher; 194 return cipher;
198} 195}
199 196
200static QString decipher(const QString& cipher) 197static QString decipher(const QString& cipher)
201{ 198{
diff --git a/library/custom-linux-sharp-g++.h b/library/custom-linux-sharp-g++.h
deleted file mode 100644
index f65d474..0000000
--- a/library/custom-linux-sharp-g++.h
+++ b/dev/null
@@ -1,147 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3**
4** This file is part of the Qtopia Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#define QPE_OWNAPM
22#define QPE_HAVE_TOGGLELIGHT
23#define QPE_NOCIBAUD
24#define QPE_STARTMENU
25#include <asm/sharp_apm.h>
26#ifndef APM_IOC_BATTERY_BACK_CHK
27#define APM_IOC_BATTERY_BACK_CHK _IO(APM_IOC_MAGIC, 32)
28#endif
29#ifndef APM_IOC_BATTERY_MAIN_CHK
30#define APM_IOC_BATTERY_MAIN_CHK _IO(APM_IOC_MAGIC, 33)
31#endif
32
33#include <unistd.h>
34#include <stdio.h>
35#include <signal.h>
36#include <fcntl.h>
37#include <sys/ioctl.h>
38
39#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
40
41/* --- for SHARP_BUZZER device --- */
42 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
43#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
44#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
45#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
46#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
47#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
48#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
49
50#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
51#define SHARP_BUZ_KEYSOUND 2 /* key sound */
52#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
53#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
54#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
55#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
56#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
57#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
58#define SHARP_PDA_APPSTART 9 /* application start */
59#define SHARP_PDA_APPQUIT 10 /* application ends */
60#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
61#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
62#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
63#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
64
65
66#define CUSTOM_BUZZER( sound ) \
67{ \
68 static int fd = open( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); \
69 ioctl( fd, SHARP_BUZZER_MAKESOUND, sound ); \
70}
71
72#define CUSTOM_SOUND_ALARM CUSTOM_BUZZER( SHARP_BUZ_SCHEDULE_ALARM )
73
74#include <sys/ioctl.h>
75#include <asm/sharp_char.h>
76
77// a bit awkward, as this value is defined in emailclient.cpp aswell...
78#define LED_MAIL 0
79#define SHARP_LED_MAIL 9
80
81#define CUSTOM_LEDS( led, status ) \
82{ \
83 if ( led == LED_MAIL ) \
84 led = SHARP_LED_MAIL; \
85 static int fd = open( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); \
86 sharp_led_status leds; \
87 memset(&leds, 0, sizeof(leds)); \
88 leds.which = led; \
89 leds.status = status; \
90 ioctl( fd, SHARP_LED_SETSTATUS, (char*)&leds ); \
91}
92
93#define QPE_HAVE_MEMALERTER
94
95#define QPE_MEMALERTER_IMPL \
96static void sig_handler(int sig) \
97{ \
98 switch (sig) { \
99 case SIGHUP: \
100 memstate = VeryLow; \
101 break; \
102 case SIGUSR1: \
103 memstate = Normal; \
104 break; \
105 case SIGUSR2: \
106 memstate = Low; \
107 break; \
108 } \
109} \
110static void initMemalerter() \
111{ \
112 struct sigaction sa; \
113 memset(&sa, '\0', sizeof sa); \
114 sa.sa_handler = sig_handler; \
115 sa.sa_flags = SA_RESTART; \
116 if (sigaction(SIGHUP, &sa, NULL) < 0) { \
117 return; \
118 } \
119 if (sigaction(SIGUSR1, &sa, NULL) < 0) { \
120 return; \
121 } \
122 if (sigaction(SIGUSR2, &sa, NULL) < 0) { \
123 return; \
124 } \
125 FILE *fo = fopen("/proc/sys/vm/freepg_signal_proc", "w"); \
126 \
127 if (!fo) \
128 return; \
129 fprintf(fo, "qpe\n"); \
130 fclose(fo); \
131}
132
133#define QPE_INITIAL_NUMLOCK_STATE \
134{ \
135 bool numLock = FALSE; \
136 sharp_kbdctl_modifstat st; \
137 int dev = ::open("/dev/sharp_kbdctl", O_RDWR); \
138 if( dev >= 0 ) { \
139 memset(&st, 0, sizeof(st)); \
140 st.which = 3; \
141 int ret = ioctl(dev, SHARP_KBDCTL_GETMODIFSTAT, (char*)&st); \
142 if( !ret ) \
143 numLock = (bool)st.stat; \
144 ::close(dev); \
145 } \
146 return numLock; \
147}
diff --git a/library/datebookmonth.h b/library/datebookmonth.h
index 6cd1ac5..a7647ae 100644
--- a/library/datebookmonth.h
+++ b/library/datebookmonth.h
@@ -1,166 +1,167 @@
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 DATEBOOKMONTH 20#ifndef DATEBOOKMONTH
21#define DATEBOOKMONTH 21#define DATEBOOKMONTH
22 22
23#include <qpe/event.h> 23#include <qpe/event.h>
24 24
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qhbox.h> 26#include <qhbox.h>
27#include <qdatetime.h> 27#include <qdatetime.h>
28#include <qvaluelist.h> 28#include <qvaluelist.h>
29#include <qtable.h> 29#include <qtable.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31 31
32#include "calendar.h" 32#include "calendar.h"
33#include "timestring.h" 33#include "timestring.h"
34 34
35class QToolButton; 35class QToolButton;
36class QComboBox; 36class QComboBox;
37class QSpinBox; 37class QSpinBox;
38class Event; 38class Event;
39class DateBookDB; 39class DateBookDB;
40 40
41class DateBookMonthHeaderPrivate; 41class DateBookMonthHeaderPrivate;
42class DateBookMonthHeader : public QHBox 42class DateBookMonthHeader : public QHBox
43{ 43{
44 Q_OBJECT 44 Q_OBJECT
45 45
46public: 46public:
47 DateBookMonthHeader( QWidget *parent = 0, const char *name = 0 ); 47 DateBookMonthHeader( QWidget *parent = 0, const char *name = 0 );
48 ~DateBookMonthHeader(); 48 ~DateBookMonthHeader();
49 void setDate( int year, int month ); 49 void setDate( int year, int month );
50 50
51signals: 51signals:
52 void dateChanged( int year, int month ); 52 void dateChanged( int year, int month );
53 53
54protected slots: 54protected slots:
55 void keyPressEvent(QKeyEvent *e ) { 55 void keyPressEvent(QKeyEvent *e ) {
56 e->ignore(); 56 e->ignore();
57 } 57 }
58 58
59private slots: 59private slots:
60 void updateDate(); 60 void updateDate();
61 void firstMonth(); 61 void firstMonth();
62 void lastMonth(); 62 void lastMonth();
63 void monthBack(); 63 void monthBack();
64 void monthForward(); 64 void monthForward();
65 65
66private: 66private:
67 QToolButton *begin, *back, *next, *end; 67 QToolButton *begin, *back, *next, *end;
68 QComboBox *month; 68 QComboBox *month;
69 QSpinBox *year; 69 QSpinBox *year;
70 DateBookMonthHeaderPrivate *d; 70 DateBookMonthHeaderPrivate *d;
71 int focus;
71}; 72};
72 73
73class DayItemMonthPrivate; 74class DayItemMonthPrivate;
74class DayItemMonth : public QTableItem 75class DayItemMonth : public QTableItem
75{ 76{
76public: 77public:
77 DayItemMonth( QTable *table, EditType et, const QString &t ); 78 DayItemMonth( QTable *table, EditType et, const QString &t );
78 ~DayItemMonth(); 79 ~DayItemMonth();
79 void paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ); 80 void paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected );
80 void setDay( int d ) { dy = d; } 81 void setDay( int d ) { dy = d; }
81 void setEvents( const QValueList<Event> &events ) { daysEvents = events; }; 82 void setEvents( const QValueList<Event> &events ) { daysEvents = events; };
82 void setEvents( const QValueList<EffectiveEvent> &effEvents ); 83 void setEvents( const QValueList<EffectiveEvent> &effEvents );
83 void clearEvents() { daysEvents.clear(); }; 84 void clearEvents() { daysEvents.clear(); };
84 void clearEffEvents(); 85 void clearEffEvents();
85 int day() const { return dy; } 86 int day() const { return dy; }
86 void setType( Calendar::Day::Type t ); 87 void setType( Calendar::Day::Type t );
87 Calendar::Day::Type type() const { return typ; } 88 Calendar::Day::Type type() const { return typ; }
88 89
89private: 90private:
90 QBrush back; 91 QBrush back;
91 QColor forg; 92 QColor forg;
92 int dy; 93 int dy;
93 Calendar::Day::Type typ; 94 Calendar::Day::Type typ;
94 QValueList<Event> daysEvents; // not used anymore... 95 QValueList<Event> daysEvents; // not used anymore...
95 DayItemMonthPrivate *d; 96 DayItemMonthPrivate *d;
96}; 97};
97 98
98class DateBookMonthTablePrivate; 99class DateBookMonthTablePrivate;
99class DateBookMonthTable : public QTable 100class DateBookMonthTable : public QTable
100{ 101{
101 Q_OBJECT 102 Q_OBJECT
102 103
103public: 104public:
104 DateBookMonthTable( QWidget *parent = 0, const char *name = 0, 105 DateBookMonthTable( QWidget *parent = 0, const char *name = 0,
105 DateBookDB *newDb = 0 ); 106 DateBookDB *newDb = 0 );
106 ~DateBookMonthTable(); 107 ~DateBookMonthTable();
107 void setDate( int y, int m, int d ); 108 void setDate( int y, int m, int d );
108 void redraw(); 109 void redraw();
109 110
110 QSize minimumSizeHint() const { return sizeHint(); } 111 QSize minimumSizeHint() const { return sizeHint(); }
111 QSize minimumSize() const { return sizeHint(); } 112 QSize minimumSize() const { return sizeHint(); }
112 void getDate( int& y, int &m, int &d ) const {y=selYear;m=selMonth;d=selDay;} 113 void getDate( int& y, int &m, int &d ) const {y=selYear;m=selMonth;d=selDay;}
113 void setWeekStart( bool onMonday ); 114 void setWeekStart( bool onMonday );
114signals: 115signals:
115 void dateClicked( int year, int month, int day ); 116 void dateClicked( int year, int month, int day );
116 117
117protected: 118protected:
118 void viewportMouseReleaseEvent( QMouseEvent * ); 119 void viewportMouseReleaseEvent( QMouseEvent * );
119 120
120protected slots: 121protected slots:
121 122
122 void keyPressEvent(QKeyEvent *e ) { 123 void keyPressEvent(QKeyEvent *e ) {
123 e->ignore(); 124 e->ignore();
124 } 125 }
125 126
126private slots: 127private slots:
127 void dayClicked( int row, int col ); 128 void dayClicked( int row, int col );
128 void dragDay( int row, int col ); 129 void dragDay( int row, int col );
129 130
130private: 131private:
131 void setupTable(); 132 void setupTable();
132 void setupLabels(); 133 void setupLabels();
133 134
134 void findDay( int day, int &row, int &col ); 135 void findDay( int day, int &row, int &col );
135 void getEvents(); 136 void getEvents();
136 void changeDaySelection( int row, int col ); 137 void changeDaySelection( int row, int col );
137 138
138 int year, month, day; 139 int year, month, day;
139 int selYear, selMonth, selDay; 140 int selYear, selMonth, selDay;
140 QValueList<Event> monthsEvents; // not used anymore... 141 QValueList<Event> monthsEvents; // not used anymore...
141 DateBookDB *db; 142 DateBookDB *db;
142 DateBookMonthTablePrivate *d; 143 DateBookMonthTablePrivate *d;
143}; 144};
144 145
145class DateBookMonthPrivate; 146class DateBookMonthPrivate;
146class DateBookMonth : public QVBox 147class DateBookMonth : public QVBox
147{ 148{
148 Q_OBJECT 149 Q_OBJECT
149 150
150public: 151public:
151 DateBookMonth( QWidget *parent = 0, const char *name = 0, bool ac = FALSE, 152 DateBookMonth( QWidget *parent = 0, const char *name = 0, bool ac = FALSE,
152 DateBookDB *data = 0 ); 153 DateBookDB *data = 0 );
153 ~DateBookMonth(); 154 ~DateBookMonth();
154 QDate selectedDate() const; 155 QDate selectedDate() const;
155 156
156signals: 157signals:
157 void dateClicked( int year, int month, int day ); 158 void dateClicked( int year, int month, int day );
158 159
159public slots: 160public slots:
160 void setDate( int y, int m ); 161 void setDate( int y, int m );
161 void setDate( int y, int m, int d ); 162 void setDate( int y, int m, int d );
162 void setDate( QDate ); 163 void setDate( QDate );
163 void redraw(); 164 void redraw();
164 void slotWeekChange( bool ); 165 void slotWeekChange( bool );
165 166
166protected slots: 167protected slots:
diff --git a/library/fileselector.h b/library/fileselector.h
index ef8efea..8cfdf13 100644
--- a/library/fileselector.h
+++ b/library/fileselector.h
@@ -1,108 +1,80 @@
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 FILESELECTOR_H 20#ifndef FILESELECTOR_H
21#define FILESELECTOR_H 21#define FILESELECTOR_H
22 22
23#include <qhbox.h> 23#include <qhbox.h>
24#include <qvbox.h> 24#include <qvbox.h>
25#include <qlistview.h>
26#include <qtoolbutton.h> 25#include <qtoolbutton.h>
26#include <qlistview.h>
27 27
28#include "filemanager.h" 28#include "filemanager.h"
29#include "applnk.h" 29#include "applnk.h"
30 30
31class QPopupMenu; 31class QPopupMenu;
32class QPushButton; 32class QPushButton;
33class FileSelectorView;
33 34
34class FileSelectorItem : public QListViewItem 35class FileSelectorItem : public QListViewItem
35{ 36{
36public: 37public:
37 FileSelectorItem( QListView *parent, const DocLnk& f ); 38 FileSelectorItem( QListView *parent, const DocLnk& f );
38 ~FileSelectorItem(); 39 ~FileSelectorItem();
39 40
40 DocLnk file() const { return fl; } 41 DocLnk file() const { return fl; }
41 42
42private: 43private:
43 DocLnk fl; 44 DocLnk fl;
44}; 45};
45 46
46class CategoryMenu;
47class FileSelectorViewPrivate;
48class FileSelectorView : public QListView
49{
50 Q_OBJECT
51
52public:
53 FileSelectorView( const QString &mimefilter, QWidget *parent, const char *name );
54 ~FileSelectorView();
55 void reread();
56 int fileCount() { return count; }
57
58 void setCategoryFilter(CategoryMenu *);
59protected:
60 void keyPressEvent( QKeyEvent *e );
61
62protected slots:
63 void cardMessage( const QCString &, const QByteArray &);
64
65 void categoryChanged();
66
67private:
68 QString filter;
69 FileManager *fileManager;
70 int count;
71 FileSelectorViewPrivate *d;
72};
73
74class FileSelectorPrivate; 47class FileSelectorPrivate;
75class FileSelector : public QVBox 48class FileSelector : public QVBox
76{ 49{
77 Q_OBJECT 50 Q_OBJECT
78 51
79public: 52public:
80 FileSelector( const QString &mimefilter, QWidget *parent, const char *name, bool newVisible = TRUE, bool closeVisible = TRUE ); 53 FileSelector( const QString &mimefilter, QWidget *parent, const char *name, bool newVisible = TRUE, bool closeVisible = TRUE );
81 ~FileSelector(); 54 ~FileSelector();
82 void setNewVisible( bool b ); 55 void setNewVisible( bool b );
83 void setCloseVisible( bool b ); 56 void setCloseVisible( bool b );
84 void setCategoriesVisible( bool b );
85 void reread(); 57 void reread();
86 int fileCount(); 58 int fileCount();
87 const DocLnk *selected(); 59 const DocLnk *selected();
88 60
89signals: 61signals:
90 void fileSelected( const DocLnk & ); 62 void fileSelected( const DocLnk & );
91 void newSelected( const DocLnk & ); 63 void newSelected( const DocLnk & );
92 void closeMe(); 64 void closeMe();
93 65
94private slots: 66private slots:
95 void createNew(); 67 void createNew();
96 void fileClicked( int, QListViewItem *, const QPoint &, int ); 68 void fileClicked( int, QListViewItem *, const QPoint &, int );
97 // pressed to get 'right down' 69 // pressed to get 'right down'
98 void filePressed( int, QListViewItem *, const QPoint &, int ); 70 void filePressed( int, QListViewItem *, const QPoint &, int );
99 void fileClicked( QListViewItem *); 71 void fileClicked( QListViewItem *);
100 72
101private: 73private:
102 FileSelectorView *view; 74 FileSelectorView *view;
103 QString filter; 75 QString filter;
104 QToolButton *buttonNew, *buttonClose; 76 QToolButton *buttonNew, *buttonClose;
105 FileSelectorPrivate *d; 77 FileSelectorPrivate *d;
106}; 78};
107 79
108#endif 80#endif
diff --git a/library/finddialog.cpp b/library/finddialog.cpp
index 7a9367b..904e952 100644
--- a/library/finddialog.cpp
+++ b/library/finddialog.cpp
@@ -1,73 +1,77 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 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// WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT
22// have this class.
23#define QTOPIA_INTERNAL_FD
24
21#include "finddialog.h" 25#include "finddialog.h"
22#include "findwidget_p.h" 26#include "findwidget_p.h"
23 27
24#include <qlayout.h> 28#include <qlayout.h>
25#include <qpushbutton.h> 29#include <qpushbutton.h>
26 30
27FindDialog::FindDialog( const QString &appName, QWidget *parent, 31FindDialog::FindDialog( const QString &appName, QWidget *parent,
28 const char *name, bool modal ) 32 const char *name, bool modal )
29 : QDialog( parent, name, modal ) 33 : QDialog( parent, name, modal )
30{ 34{
31 QVBoxLayout *vb; 35 QVBoxLayout *vb;
32 vb = new QVBoxLayout( this ); 36 vb = new QVBoxLayout( this );
33 fw = new FindWidget( appName, this, "Find Widget" ); 37 fw = new FindWidget( appName, this, "Find Widget" );
34 vb->addWidget( fw ); 38 vb->addWidget( fw );
35 QObject::connect( fw, SIGNAL(signalFindClicked(const QString&, 39 QObject::connect( fw, SIGNAL(signalFindClicked(const QString&,
36 bool,bool,int)), 40 bool,bool,int)),
37 this, SIGNAL(signalFindClicked(const QString&, 41 this, SIGNAL(signalFindClicked(const QString&,
38 bool,bool,int)) ); 42 bool,bool,int)) );
39 QObject::connect( fw, SIGNAL(signalFindClicked(const QString&,const QDate&, 43 QObject::connect( fw, SIGNAL(signalFindClicked(const QString&,const QDate&,
40 bool,bool,int)), 44 bool,bool,int)),
41 this, SIGNAL(signalFindClicked(const QString&, 45 this, SIGNAL(signalFindClicked(const QString&,
42 const QDate&,bool,bool,int)) ); 46 const QDate&,bool,bool,int)) );
43 d = 0; 47 d = 0;
44} 48}
45 49
46FindDialog::~FindDialog() 50FindDialog::~FindDialog()
47{ 51{
48} 52}
49 53
50QString FindDialog::findText() const 54QString FindDialog::findText() const
51{ 55{
52 return fw->findText(); 56 return fw->findText();
53} 57}
54 58
55void FindDialog::setUseDate( bool show ) 59void FindDialog::setUseDate( bool show )
56{ 60{
57 fw->setUseDate( show ); 61 fw->setUseDate( show );
58} 62}
59 63
60void FindDialog::setDate( const QDate &dt ) 64void FindDialog::setDate( const QDate &dt )
61{ 65{
62 fw->setDate( dt ); 66 fw->setDate( dt );
63} 67}
64 68
65void FindDialog::slotNotFound() 69void FindDialog::slotNotFound()
66{ 70{
67 fw->slotNotFound(); 71 fw->slotNotFound();
68} 72}
69 73
70void FindDialog::slotWrapAround() 74void FindDialog::slotWrapAround()
71{ 75{
72 fw->slotWrapAround(); 76 fw->slotWrapAround();
73} 77}
diff --git a/library/finddialog.h b/library/finddialog.h
index 265b5ae..00c7b45 100644
--- a/library/finddialog.h
+++ b/library/finddialog.h
@@ -1,57 +1,68 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 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
22//
23// DO NOT ATTEMPT TO USE THIS CLASS
24//
25
21#ifndef __FINDDIALOG_H__ 26#ifndef __FINDDIALOG_H__
22#define __FINDDIALOG_H__ 27#define __FINDDIALOG_H__
23 28
24#include <qdatetime.h> 29#include <qdatetime.h>
25#include <qdialog.h> 30#include <qdialog.h>
26 31
27class FindWidget; 32class FindWidget;
28 33
29class FindDialogPrivate; 34class FindDialogPrivate;
30class FindDialog : public QDialog 35class FindDialog : public QDialog
31{ 36{
32 Q_OBJECT 37 Q_OBJECT
33public: 38public:
39
40// WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT
41// have this class.
42#ifdef QTOPIA_INTERNAL_FD
43
34 FindDialog( const QString &appName, 44 FindDialog( const QString &appName,
35 QWidget *parent = 0, const char *name = 0, bool modal = TRUE ); 45 QWidget *parent = 0, const char *name = 0, bool modal = TRUE );
36 ~FindDialog(); 46 ~FindDialog();
47#endif
37 48
38 QString findText() const; 49 QString findText() const;
39 void setUseDate( bool show ); 50 void setUseDate( bool show );
40 void setDate( const QDate &dt ); 51 void setDate( const QDate &dt );
41 52
42public slots: 53public slots:
43 void slotNotFound(); 54 void slotNotFound();
44 void slotWrapAround(); 55 void slotWrapAround();
45 56
46signals: 57signals:
47 void signalFindClicked( const QString &txt, bool caseSensitive, 58 void signalFindClicked( const QString &txt, bool caseSensitive,
48 bool backwards, int category ); 59 bool backwards, int category );
49 void signalFindClicked( const QString &txt, const QDate &dt, 60 void signalFindClicked( const QString &txt, const QDate &dt,
50 bool caseSensitive, bool backwards, int category ); 61 bool caseSensitive, bool backwards, int category );
51 62
52private: 63private:
53 FindWidget *fw; 64 FindWidget *fw;
54 FindDialogPrivate *d; 65 FindDialogPrivate *d;
55}; 66};
56 67
57#endif 68#endif
diff --git a/library/mimetype.cpp b/library/mimetype.cpp
index c6a4453..9fab160 100644
--- a/library/mimetype.cpp
+++ b/library/mimetype.cpp
@@ -1,204 +1,217 @@
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#define QTOPIA_INTERNAL_MIMEEXT
21#include "mimetype.h" 22#include "mimetype.h"
22#include "applnk.h" 23#include "applnk.h"
23#include "resource.h" 24#include "resource.h"
24#include "qpeapplication.h" 25#include "qpeapplication.h"
25#include <qfile.h> 26#include <qfile.h>
26#include <qdict.h> 27#include <qdict.h>
27#include <qregexp.h> 28#include <qregexp.h>
28#include <qstringlist.h> 29#include <qstringlist.h>
29#include <qtextstream.h> 30#include <qtextstream.h>
30#include <qmap.h> 31#include <qmap.h>
31 32
32class MimeTypeData { 33class MimeTypeData {
33public: 34public:
34 MimeTypeData(const QString& i, const AppLnk& lnk, const QString& icon ) : 35 MimeTypeData(const QString& i, const AppLnk& lnk, const QString& icon ) :
35 id(i), 36 id(i),
36 desc(lnk.name()+" document"), 37 desc(lnk.name()+" document"),
37 app(lnk) 38 app(lnk)
38 { 39 {
39 if ( icon.isEmpty() ) { 40 if ( icon.isEmpty() ) {
40 regIcon = lnk.pixmap(); 41 regIcon = lnk.pixmap();
41 bigIcon = lnk.bigPixmap(); 42 bigIcon = lnk.bigPixmap();
42 } else { 43 } else {
43 QImage unscaledIcon = Resource::loadImage( icon ); 44 QImage unscaledIcon = Resource::loadImage( icon );
44 regIcon.convertFromImage( unscaledIcon.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); 45 regIcon.convertFromImage( unscaledIcon.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
45 bigIcon.convertFromImage( unscaledIcon.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ) ); 46 bigIcon.convertFromImage( unscaledIcon.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ) );
46 } 47 }
47 } 48 }
48 QString id; 49 QString id;
50 QString extension;
49 QString desc; 51 QString desc;
50 QPixmap regIcon; 52 QPixmap regIcon;
51 QPixmap bigIcon; 53 QPixmap bigIcon;
52 AppLnk app; 54 AppLnk app;
53}; 55};
54 56
55class MimeType::Dict : public QDict<MimeTypeData> { 57class MimeType::Dict : public QDict<MimeTypeData> {
56public: 58public:
57 Dict() {} 59 Dict() {}
58}; 60};
59 61
60MimeType::Dict* MimeType::d=0; 62MimeType::Dict* MimeType::d=0;
61static QMap<QString,QString> *typeFor = 0; 63static QMap<QString,QString> *typeFor = 0;
64static QMap<QString,QString> *extFor = 0;
62 65
63MimeType::Dict& MimeType::dict() 66MimeType::Dict& MimeType::dict()
64{ 67{
65 if ( !d ) { 68 if ( !d ) {
66 d = new Dict; 69 d = new Dict;
67 d->setAutoDelete(TRUE); 70 d->setAutoDelete(TRUE);
68 } 71 }
69 return *d; 72 return *d;
70} 73}
71 74
72MimeType::MimeType( const QString& ext_or_id ) 75MimeType::MimeType( const QString& ext_or_id )
73{ 76{
74 init(ext_or_id); 77 init(ext_or_id);
75} 78}
76 79
77MimeType::MimeType( const DocLnk& lnk ) 80MimeType::MimeType( const DocLnk& lnk )
78{ 81{
79 init(lnk.type()); 82 init(lnk.type());
80} 83}
81 84
82QString MimeType::id() const 85QString MimeType::id() const
83{ 86{
84 return i; 87 return i;
85} 88}
86 89
87QString MimeType::description() const 90QString MimeType::description() const
88{ 91{
89 MimeTypeData* d = data(i); 92 MimeTypeData* d = data(i);
90 return d ? d->desc : QString::null; 93 return d ? d->desc : QString::null;
91} 94}
92 95
93QPixmap MimeType::pixmap() const 96QPixmap MimeType::pixmap() const
94{ 97{
95 MimeTypeData* d = data(i); 98 MimeTypeData* d = data(i);
96 return d ? d->regIcon : QPixmap(); 99 return d ? d->regIcon : QPixmap();
97} 100}
98 101
102QString MimeType::extension() const
103{
104 loadExtensions();
105 return *(*extFor).find(i);
106}
107
99QPixmap MimeType::bigPixmap() const 108QPixmap MimeType::bigPixmap() const
100{ 109{
101 MimeTypeData* d = data(i); 110 MimeTypeData* d = data(i);
102 return d ? d->bigIcon : QPixmap(); 111 return d ? d->bigIcon : QPixmap();
103} 112}
104 113
105const AppLnk* MimeType::application() const 114const AppLnk* MimeType::application() const
106{ 115{
107 MimeTypeData* d = data(i); 116 MimeTypeData* d = data(i);
108 return d ? &d->app : 0; 117 return d ? &d->app : 0;
109} 118}
110 119
111void MimeType::registerApp( const AppLnk& lnk ) 120void MimeType::registerApp( const AppLnk& lnk )
112{ 121{
113 QStringList list = lnk.mimeTypes(); 122 QStringList list = lnk.mimeTypes();
114 QStringList icons = lnk.mimeTypeIcons(); 123 QStringList icons = lnk.mimeTypeIcons();
115 QStringList::ConstIterator icon = icons.begin(); 124 QStringList::ConstIterator icon = icons.begin();
116 for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it, ++icon) { 125 for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it, ++icon) {
117 MimeTypeData *item = new MimeTypeData( *it, lnk, *icon ); 126 MimeTypeData *item = new MimeTypeData( *it, lnk, *icon );
118 dict().replace( *it, item ); 127 dict().replace( *it, item );
119 } 128 }
120} 129}
121 130
122void MimeType::clear() 131void MimeType::clear()
123{ 132{
124 delete d; 133 delete d;
125 d = 0; 134 d = 0;
126} 135}
127 136
128void MimeType::loadExtensions() 137void MimeType::loadExtensions()
129{ 138{
130 if ( !typeFor ) { 139 if ( !typeFor ) {
140 extFor = new QMap<QString,QString>;
131 typeFor = new QMap<QString,QString>; 141 typeFor = new QMap<QString,QString>;
132 loadExtensions("/etc/mime.types"); 142 loadExtensions("/etc/mime.types");
133 loadExtensions(QPEApplication::qpeDir()+"etc/mime.types"); 143 loadExtensions(QPEApplication::qpeDir()+"etc/mime.types");
134 } 144 }
135} 145}
136 146
137void MimeType::loadExtensions(const QString& filename) 147void MimeType::loadExtensions(const QString& filename)
138{ 148{
139 QFile file(filename); 149 QFile file(filename);
140 if ( file.open(IO_ReadOnly) ) { 150 if ( file.open(IO_ReadOnly) ) {
141 QTextStream in(&file); 151 QTextStream in(&file);
142 QRegExp space("[ \t]+"); 152 QRegExp space("[ \t]+");
143 while (!in.atEnd()) { 153 while (!in.atEnd()) {
144 QStringList tokens = QStringList::split(space, in.readLine()); 154 QStringList tokens = QStringList::split(space, in.readLine());
145 QStringList::ConstIterator it = tokens.begin(); 155 QStringList::ConstIterator it = tokens.begin();
146 if ( it != tokens.end() ) { 156 if ( it != tokens.end() ) {
147 QString id = *it; ++it; 157 QString id = *it; ++it;
148 while (it != tokens.end()) { 158 if ( it != tokens.end() ) {
149 (*typeFor)[*it] = id; 159 (*extFor)[id] = *it;
150 ++it; 160 while (it != tokens.end()) {
161 (*typeFor)[*it] = id;
162 ++it;
163 }
151 } 164 }
152 } 165 }
153 } 166 }
154 } 167 }
155} 168}
156 169
157void MimeType::init( const QString& ext_or_id ) 170void MimeType::init( const QString& ext_or_id )
158{ 171{
159 if ( ext_or_id[0] != '/' && ext_or_id.contains('/') ) { 172 if ( ext_or_id[0] != '/' && ext_or_id.contains('/') ) {
160 i = ext_or_id.lower(); 173 i = ext_or_id.lower();
161 } else { 174 } else {
162 loadExtensions(); 175 loadExtensions();
163 int dot = ext_or_id.findRev('.'); 176 int dot = ext_or_id.findRev('.');
164 QString ext = dot >= 0 ? ext_or_id.mid(dot+1) : ext_or_id; 177 QString ext = dot >= 0 ? ext_or_id.mid(dot+1) : ext_or_id;
165 i = (*typeFor)[ext.lower()]; 178 i = (*typeFor)[ext.lower()];
166 if ( i.isNull() ) 179 if ( i.isNull() )
167 i = "application/octet-stream"; 180 i = "application/octet-stream";
168 } 181 }
169 static bool appsUpdated = FALSE; 182 static bool appsUpdated = FALSE;
170 if ( !appsUpdated ) { 183 if ( !appsUpdated ) {
171 appsUpdated = TRUE; 184 appsUpdated = TRUE;
172 updateApplications(); 185 updateApplications();
173 } 186 }
174} 187}
175 188
176MimeTypeData* MimeType::data(const QString& id) 189MimeTypeData* MimeType::data(const QString& id)
177{ 190{
178 MimeTypeData* d = dict()[id]; 191 MimeTypeData* d = dict()[id];
179 if ( !d ) { 192 if ( !d ) {
180 int s = id.find('/'); 193 int s = id.find('/');
181 QString idw = id.left(s)+"/*"; 194 QString idw = id.left(s)+"/*";
182 d = dict()[idw]; 195 d = dict()[idw];
183 } 196 }
184 return d; 197 return d;
185} 198}
186 199
187QString MimeType::appsFolderName() 200QString MimeType::appsFolderName()
188{ 201{
189 return QPEApplication::qpeDir() + "apps"; 202 return QPEApplication::qpeDir() + "apps";
190} 203}
191 204
192void MimeType::updateApplications() 205void MimeType::updateApplications()
193{ 206{
194 clear(); 207 clear();
195 AppLnkSet apps( appsFolderName() ); 208 AppLnkSet apps( appsFolderName() );
196 updateApplications(&apps); 209 updateApplications(&apps);
197} 210}
198 211
199void MimeType::updateApplications(AppLnkSet* folder) 212void MimeType::updateApplications(AppLnkSet* folder)
200{ 213{
201 for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { 214 for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) {
202 registerApp(*it.current()); 215 registerApp(*it.current());
203 } 216 }
204} 217}
diff --git a/library/mimetype.h b/library/mimetype.h
index 58725d7..b6cca95 100644
--- a/library/mimetype.h
+++ b/library/mimetype.h
@@ -1,64 +1,69 @@
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 MIMETYPE_H 20#ifndef MIMETYPE_H
21#define MIMETYPE_H 21#define MIMETYPE_H
22 22
23#include <qstring.h> 23#include <qstring.h>
24#include <qpixmap.h> 24#include <qpixmap.h>
25 25
26class AppLnk; 26class AppLnk;
27class DocLnk; 27class DocLnk;
28class QStringList; 28class QStringList;
29class MimeTypeData; 29class MimeTypeData;
30class AppLnkSet; 30class AppLnkSet;
31 31
32class MimeType 32class MimeType
33{ 33{
34public: 34public:
35 MimeType( const QString& ext_or_id ); 35 MimeType( const QString& ext_or_id );
36 MimeType( const DocLnk& ); 36 MimeType( const DocLnk& );
37 37
38 QString id() const; 38 QString id() const;
39 QString description() const; 39 QString description() const;
40 QPixmap pixmap() const; 40 QPixmap pixmap() const;
41 QPixmap bigPixmap() const; 41 QPixmap bigPixmap() const;
42 42
43// DON'T define this yourself!
44#ifdef QTOPIA_INTERNAL_MIMEEXT
45 QString extension() const;
46#endif
47
43 const AppLnk* application() const; 48 const AppLnk* application() const;
44 49
45 static QString appsFolderName(); 50 static QString appsFolderName();
46 static void updateApplications(); 51 static void updateApplications();
47 52
48 // These shouldn't be needed 53 // These shouldn't be needed
49 static void clear(); 54 static void clear();
50 static void registerApp( const AppLnk& ); 55 static void registerApp( const AppLnk& );
51 56
52private: 57private:
53 static void updateApplications(AppLnkSet* folder); 58 static void updateApplications(AppLnkSet* folder);
54 static void loadExtensions(); 59 static void loadExtensions();
55 static void loadExtensions(const QString&); 60 static void loadExtensions(const QString&);
56 void init( const QString& ext_or_id ); 61 void init( const QString& ext_or_id );
57 class Dict; 62 class Dict;
58 static Dict* d; 63 static Dict* d;
59 static Dict& dict(); 64 static Dict& dict();
60 static MimeTypeData* data(const QString& id); 65 static MimeTypeData* data(const QString& id);
61 QString i; 66 QString i;
62}; 67};
63 68
64#endif 69#endif
diff --git a/library/network.cpp b/library/network.cpp
index 7d51016..e6d2781 100644
--- a/library/network.cpp
+++ b/library/network.cpp
@@ -1,116 +1,117 @@
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#define QTOPIA_INTERNAL_LANGLIST
21#include "qpe/network.h" 22#include "qpe/network.h"
22#include "qpe/networkinterface.h" 23#include "qpe/networkinterface.h"
23#include "qpe/global.h" 24#include "qpe/global.h"
24#include "qpe/config.h" 25#include "qpe/config.h"
25#include "qpe/resource.h" 26#include "qpe/resource.h"
26#include "qpe/qpeapplication.h" 27#include "qpe/qpeapplication.h"
27#include <qpe/qcopenvelope_qws.h> 28#include <qpe/qcopenvelope_qws.h>
28#include <qpe/qlibrary.h> 29#include <qpe/qlibrary.h>
29 30
30#include <qlistbox.h> 31#include <qlistbox.h>
31#include <qdir.h> 32#include <qdir.h>
32#include <qlayout.h> 33#include <qlayout.h>
33#include <qdict.h> 34#include <qdict.h>
34#include <qtranslator.h> 35#include <qtranslator.h>
35 36
36#include <stdlib.h> 37#include <stdlib.h>
37 38
38class NetworkEmitter : public QCopChannel { 39class NetworkEmitter : public QCopChannel {
39 Q_OBJECT 40 Q_OBJECT
40public: 41public:
41 NetworkEmitter() : QCopChannel("QPE/Network",qApp) 42 NetworkEmitter() : QCopChannel("QPE/Network",qApp)
42 { 43 {
43 } 44 }
44 45
45 void receive(const QCString &msg, const QByteArray&) 46 void receive(const QCString &msg, const QByteArray&)
46 { 47 {
47 if ( msg == "choicesChanged()" ) 48 if ( msg == "choicesChanged()" )
48 emit changed(); 49 emit changed();
49 } 50 }
50 51
51signals: 52signals:
52 void changed(); 53 void changed();
53}; 54};
54 55
55/*! 56/*!
56 \internal 57 \internal
57 58
58 Requests that the service \a choice be started. The \a password is 59 Requests that the service \a choice be started. The \a password is
59 the password to use if required. 60 the password to use if required.
60*/ 61*/
61void Network::start(const QString& choice, const QString& password) 62void Network::start(const QString& choice, const QString& password)
62{ 63{
63 QCopEnvelope e("QPE/Network", "start(QString,QString)"); 64 QCopEnvelope e("QPE/Network", "start(QString,QString)");
64 e << choice << password; 65 e << choice << password;
65} 66}
66 67
67/*! 68/*!
68 \class Network network.h 69 \class Network network.h
69 \brief The Network class provides network access functionality. 70 \brief The Network class provides network access functionality.
70*/ 71*/
71 72
72// copy the proxy settings of the active config over to the Proxies.conf file 73// copy the proxy settings of the active config over to the Proxies.conf file
73/*! 74/*!
74 \internal 75 \internal
75*/ 76*/
76void Network::writeProxySettings( Config &cfg ) 77void Network::writeProxySettings( Config &cfg )
77{ 78{
78 Config proxy( Network::settingsDir() + "/Proxies.conf", Config::File ); 79 Config proxy( Network::settingsDir() + "/Proxies.conf", Config::File );
79 proxy.setGroup("Properties"); 80 proxy.setGroup("Properties");
80 cfg.setGroup("Proxy"); 81 cfg.setGroup("Proxy");
81 proxy.writeEntry("type", cfg.readEntry("type") ); 82 proxy.writeEntry("type", cfg.readEntry("type") );
82 proxy.writeEntry("autoconfig", cfg.readEntry("autoconfig") ); 83 proxy.writeEntry("autoconfig", cfg.readEntry("autoconfig") );
83 proxy.writeEntry("httphost", cfg.readEntry("httphost") ); 84 proxy.writeEntry("httphost", cfg.readEntry("httphost") );
84 proxy.writeEntry("httpport", cfg.readEntry("httpport") ); 85 proxy.writeEntry("httpport", cfg.readEntry("httpport") );
85 proxy.writeEntry("ftphost", cfg.readEntry("ftphost") ); 86 proxy.writeEntry("ftphost", cfg.readEntry("ftphost") );
86 proxy.writeEntry("ftpport", cfg.readEntry("ftpport") ); 87 proxy.writeEntry("ftpport", cfg.readEntry("ftpport") );
87 proxy.writeEntry("noproxies", cfg.readEntry("noproxies") ); 88 proxy.writeEntry("noproxies", cfg.readEntry("noproxies") );
88 cfg.setGroup("Properties"); 89 cfg.setGroup("Properties");
89} 90}
90 91
91 92
92 93
93/*! 94/*!
94 \internal 95 \internal
95 96
96 Stops the current network service. 97 Stops the current network service.
97*/ 98*/
98void Network::stop() 99void Network::stop()
99{ 100{
100 QCopEnvelope e("QPE/Network", "stop()"); 101 QCopEnvelope e("QPE/Network", "stop()");
101} 102}
102 103
103static NetworkEmitter *emitter = 0; 104static NetworkEmitter *emitter = 0;
104 105
105/*! 106/*!
106 \internal 107 \internal
107*/ 108*/
108void Network::connectChoiceChange(QObject* receiver, const char* slot) 109void Network::connectChoiceChange(QObject* receiver, const char* slot)
109{ 110{
110 if ( !emitter ) 111 if ( !emitter )
111 emitter = new NetworkEmitter; 112 emitter = new NetworkEmitter;
112 QObject::connect(emitter,SIGNAL(changed()),receiver,slot); 113 QObject::connect(emitter,SIGNAL(changed()),receiver,slot);
113} 114}
114 115
115/*! 116/*!
116 \internal 117 \internal
@@ -325,112 +326,114 @@ private:
325 bool up; 326 bool up;
326 int wait; 327 int wait;
327}; 328};
328 329
329static NetworkServer* ns=0; 330static NetworkServer* ns=0;
330 331
331/*! 332/*!
332 \internal 333 \internal
333*/ 334*/
334QString Network::serviceName(const QString& service) 335QString Network::serviceName(const QString& service)
335{ 336{
336 Config cfg(service, Config::File); 337 Config cfg(service, Config::File);
337 cfg.setGroup("Info"); 338 cfg.setGroup("Info");
338 return cfg.readEntry("Name"); 339 return cfg.readEntry("Name");
339} 340}
340 341
341/*! 342/*!
342 \internal 343 \internal
343*/ 344*/
344QString Network::serviceType(const QString& service) 345QString Network::serviceType(const QString& service)
345{ 346{
346 Config cfg(service, Config::File); 347 Config cfg(service, Config::File);
347 cfg.setGroup("Info"); 348 cfg.setGroup("Info");
348 return cfg.readEntry("Type"); 349 return cfg.readEntry("Type");
349} 350}
350 351
351/*! 352/*!
352 \internal 353 \internal
353*/ 354*/
354bool Network::serviceNeedsPassword(const QString& service) 355bool Network::serviceNeedsPassword(const QString& service)
355{ 356{
356 Config cfg(service,Config::File); 357 Config cfg(service,Config::File);
357 cfg.setGroup("Info"); 358 cfg.setGroup("Info");
358 QString type = cfg.readEntry("Type"); 359 QString type = cfg.readEntry("Type");
359 NetworkInterface* plugin = Network::loadPlugin(type); 360 NetworkInterface* plugin = Network::loadPlugin(type);
360 cfg.setGroup("Properties"); 361 cfg.setGroup("Properties");
361 return plugin ? plugin->needPassword(cfg) : FALSE; 362 return plugin ? plugin->needPassword(cfg) : FALSE;
362} 363}
363 364
364/*! 365/*!
365 \internal 366 \internal
366*/ 367*/
367bool Network::networkOnline() 368bool Network::networkOnline()
368{ 369{
369 return ns && ns->networkOnline(); 370 return ns && ns->networkOnline();
370} 371}
371 372
372/*! 373/*!
373 \internal 374 \internal
374*/ 375*/
375void Network::createServer(QObject* parent) 376void Network::createServer(QObject* parent)
376{ 377{
377 ns = new NetworkServer(parent); 378 ns = new NetworkServer(parent);
378} 379}
379 380
380/*! 381/*!
381 \internal 382 \internal
382*/ 383*/
383int Network::addStateWidgets(QWidget* parent) 384int Network::addStateWidgets(QWidget* parent)
384{ 385{
385 int n=0; 386 int n=0;
386 QStringList l = Network::choices(); 387 QStringList l = Network::choices();
387 QVBoxLayout* vb = new QVBoxLayout(parent); 388 QVBoxLayout* vb = new QVBoxLayout(parent);
388 for (QStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) { 389 for (QStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) {
389 Config cfg(*it,Config::File); 390 Config cfg(*it,Config::File);
390 cfg.setGroup("Info"); 391 cfg.setGroup("Info");
391 QString type = cfg.readEntry("Type"); 392 QString type = cfg.readEntry("Type");
392 NetworkInterface* plugin = Network::loadPlugin(type); 393 NetworkInterface* plugin = Network::loadPlugin(type);
393 cfg.setGroup("Properties"); 394 cfg.setGroup("Properties");
394 if ( plugin ) { 395 if ( plugin ) {
395 QWidget* w; 396 QWidget* w;
396 if ( (w=plugin->addStateWidget(parent,cfg)) ) { 397 if ( (w=plugin->addStateWidget(parent,cfg)) ) {
397 n++; 398 n++;
398 vb->addWidget(w); 399 vb->addWidget(w);
399 } 400 }
400 } 401 }
401 } 402 }
402 return n; 403 return n;
403} 404}
404 405
405static QDict<NetworkInterface> *ifaces; 406static QDict<NetworkInterface> *ifaces;
406 407
407/*! 408/*!
408 \internal 409 \internal
409*/ 410*/
410NetworkInterface* Network::loadPlugin(const QString& type) 411NetworkInterface* Network::loadPlugin(const QString& type)
411{ 412{
412#ifndef QT_NO_COMPONENT 413#ifndef QT_NO_COMPONENT
413 if ( !ifaces ) ifaces = new QDict<NetworkInterface>; 414 if ( !ifaces ) ifaces = new QDict<NetworkInterface>;
414 NetworkInterface *iface = ifaces->find(type); 415 NetworkInterface *iface = ifaces->find(type);
415 if ( !iface ) { 416 if ( !iface ) {
416 QString libfile = QPEApplication::qpeDir() + "/plugins/network/lib" + type + ".so"; 417 QString libfile = QPEApplication::qpeDir() + "/plugins/network/lib" + type + ".so";
417 QLibrary lib(libfile); 418 QLibrary lib(libfile);
418 if ( !lib.queryInterface( IID_Network, (QUnknownInterface**)&iface ) == QS_OK ) 419 if ( !lib.queryInterface( IID_Network, (QUnknownInterface**)&iface ) == QS_OK )
419 return 0; 420 return 0;
420 ifaces->insert(type,iface); 421 ifaces->insert(type,iface);
421 QString lang = getenv( "LANG" ); 422 QStringList langs = Global::languageList();
422 QTranslator * trans = new QTranslator(qApp); 423 for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) {
423 QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/lib"+type+".qm"; 424 QString lang = *it;
424 if ( trans->load( tfn )) 425 QTranslator * trans = new QTranslator(qApp);
425 qApp->installTranslator( trans ); 426 QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/lib"+type+".qm";
426 else 427 if ( trans->load( tfn ))
427 delete trans; 428 qApp->installTranslator( trans );
428 429 else
430 delete trans;
431 }
429 } 432 }
430 return iface; 433 return iface;
431#else 434#else
432 return 0; 435 return 0;
433#endif 436#endif
434} 437}
435 438
436#include "network.moc" 439#include "network.moc"
diff --git a/library/power.cpp b/library/power.cpp
index 990ff62..12b52ed 100644
--- a/library/power.cpp
+++ b/library/power.cpp
@@ -9,192 +9,194 @@
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 "power.h" 21#include "power.h"
22 22
23#ifdef QT_QWS_CUSTOM 23#ifdef QT_QWS_CUSTOM
24#include "custom.h" 24#include "custom.h"
25#endif 25#endif
26 26
27#include <unistd.h> 27#include <unistd.h>
28#include <stdlib.h> 28#include <stdlib.h>
29#include <stdio.h> 29#include <stdio.h>
30#include <fcntl.h> 30#include <fcntl.h>
31#include <sys/ioctl.h> 31#include <sys/ioctl.h>
32 32
33#ifdef QT_QWS_IPAQ_NO_APM 33#ifdef QT_QWS_IPAQ_NO_APM
34#include <linux/h3600_ts.h> 34#include <linux/h3600_ts.h>
35#endif 35#endif
36 36
37PowerStatusManager *PowerStatusManager::powerManager = 0; 37PowerStatusManager *PowerStatusManager::powerManager = 0;
38PowerStatus *PowerStatusManager::ps = 0; 38PowerStatus *PowerStatusManager::ps = 0;
39 39
40static bool haveProcApm = false; 40static bool haveProcApm = false;
41 41
42PowerStatusManager::PowerStatusManager() 42PowerStatusManager::PowerStatusManager()
43{ 43{
44 powerManager = this; 44 powerManager = this;
45 ps = new PowerStatus; 45 ps = new PowerStatus;
46 FILE *f = fopen("/proc/apm", "r"); 46 FILE *f = fopen("/proc/apm", "r");
47 if ( f ) { 47 if ( f ) {
48 fclose(f); 48 fclose(f);
49 haveProcApm = TRUE; 49 haveProcApm = TRUE;
50 } 50 }
51} 51}
52 52
53const PowerStatus &PowerStatusManager::readStatus() 53const PowerStatus &PowerStatusManager::readStatus()
54{ 54{
55 if ( !powerManager ) 55 if ( !powerManager )
56 (void)new PowerStatusManager; 56 (void)new PowerStatusManager;
57 57
58 powerManager->getStatus(); 58 powerManager->getStatus();
59 59
60 return *ps; 60 return *ps;
61} 61}
62 62
63// Standard /proc/apm reader 63// Standard /proc/apm reader
64bool PowerStatusManager::getProcApmStatus( int &ac, int &bs, int &bf, int &pc, int &sec ) 64bool PowerStatusManager::getProcApmStatus( int &ac, int &bs, int &bf, int &pc, int &sec )
65{ 65{
66 bool ok = false; 66 bool ok = false;
67 67
68 ac = 0xff; 68 ac = 0xff;
69 bs = 0xff; 69 bs = 0xff;
70 bf = 0xff; 70 bf = 0xff;
71 pc = -1; 71 pc = -1;
72 sec = -1; 72 sec = -1;
73 73
74 FILE *f = fopen("/proc/apm", "r"); 74 FILE *f = fopen("/proc/apm", "r");
75 if ( f ) { 75 if ( f ) {
76 //I 1.13 1.2 0x02 0x00 0xff 0xff 49% 147 sec 76 //I 1.13 1.2 0x02 0x00 0xff 0xff 49% 147 sec
77 char u; 77 char u;
78 fscanf(f, "%*[^ ] %*d.%*d 0x%*x 0x%x 0x%x 0x%x %d%% %i %c", 78 fscanf(f, "%*[^ ] %*d.%*d 0x%*x 0x%x 0x%x 0x%x %d%% %i %c",
79 &ac, &bs, &bf, &pc, &sec, &u); 79 &ac, &bs, &bf, &pc, &sec, &u);
80 fclose(f); 80 fclose(f);
81 switch ( u ) { 81 switch ( u ) {
82 case 'm': sec *= 60; 82 case 'm': sec *= 60;
83 case 's': break; // ok 83 case 's': break; // ok
84 default: sec = -1; // unknown 84 default: sec = -1; // unknown
85 } 85 }
86 86
87 // extract data 87 // extract data
88 switch ( bs ) { 88 switch ( bs ) {
89 case 0x00: 89 case 0x00:
90 ps->bs = PowerStatus::High; 90 ps->bs = PowerStatus::High;
91 break; 91 break;
92 case 0x01: 92 case 0x01:
93 ps->bs = PowerStatus::Low; 93 ps->bs = PowerStatus::Low;
94 break; 94 break;
95 case 0x7f: 95 case 0x7f:
96 ps->bs = PowerStatus::VeryLow; 96 ps->bs = PowerStatus::VeryLow;
97 break; 97 break;
98 case 0x02: 98 case 0x02:
99 ps->bs = PowerStatus::Critical; 99 ps->bs = PowerStatus::Critical;
100 break; 100 break;
101 case 0x03: 101 case 0x03:
102 ps->bs = PowerStatus::Charging; 102 ps->bs = PowerStatus::Charging;
103 break; 103 break;
104 case 0x04: 104 case 0x04:
105 case 0xff: // 0xff is Unknown but we map to NotPresent
106 default:
105 ps->bs = PowerStatus::NotPresent; 107 ps->bs = PowerStatus::NotPresent;
106 break; 108 break;
107 } 109 }
108 110
109 switch ( ac ) { 111 switch ( ac ) {
110 case 0x00: 112 case 0x00:
111 ps->ac = PowerStatus::Offline; 113 ps->ac = PowerStatus::Offline;
112 break; 114 break;
113 case 0x01: 115 case 0x01:
114 ps->ac = PowerStatus::Online; 116 ps->ac = PowerStatus::Online;
115 break; 117 break;
116 case 0x02: 118 case 0x02:
117 ps->ac = PowerStatus::Backup; 119 ps->ac = PowerStatus::Backup;
118 break; 120 break;
119 } 121 }
120 122
121 if ( pc > 100 ) 123 if ( pc > 100 )
122 pc = -1; 124 pc = -1;
123 125
124 ps->percentRemain = pc; 126 ps->percentRemain = pc;
125 ps->secsRemain = sec; 127 ps->secsRemain = sec;
126 128
127 ok = true; 129 ok = true;
128 } 130 }
129 131
130 return ok; 132 return ok;
131} 133}
132 134
133#ifdef QT_QWS_CUSTOM 135#ifdef QT_QWS_CUSTOM
134 136
135void PowerStatusManager::getStatus() 137void PowerStatusManager::getStatus()
136{ 138{
137 int ac, bs, bf, pc, sec; 139 int ac, bs, bf, pc, sec;
138 ps->percentAccurate = TRUE; // not for long... 140 ps->percentAccurate = TRUE; // not for long...
139 141
140 if ( haveProcApm && getProcApmStatus( ac, bs, bf, pc, sec ) ) { 142 if ( haveProcApm && getProcApmStatus( ac, bs, bf, pc, sec ) ) {
141 // special case 143 // special case
142 if ( bs == 0x7f ) 144 if ( bs == 0x7f )
143 ps->bs = PowerStatus::VeryLow; 145 ps->bs = PowerStatus::VeryLow;
144 pc = -1; // fake percentage 146 pc = -1; // fake percentage
145 if ( pc < 0 ) { 147 if ( pc < 0 ) {
146 switch ( bs ) { 148 switch ( bs ) {
147 case 0x00: ps->percentRemain = 100; break; // High 149 case 0x00: ps->percentRemain = 100; break; // High
148 case 0x01: ps->percentRemain = 30; break; // Low 150 case 0x01: ps->percentRemain = 30; break; // Low
149 case 0x7f: ps->percentRemain = 10; break; // Very Low 151 case 0x7f: ps->percentRemain = 10; break; // Very Low
150 case 0x02: ps->percentRemain = 5; break; // Critical 152 case 0x02: ps->percentRemain = 5; break; // Critical
151 case 0x03: ps->percentRemain = -1; break; // Charging 153 case 0x03: ps->percentRemain = -1; break; // Charging
152 } 154 }
153 ps->percentAccurate = FALSE; 155 ps->percentAccurate = FALSE;
154 } 156 }
155 } 157 }
156 158
157 char *device = "/dev/apm_bios"; 159 char *device = "/dev/apm_bios";
158 int fd = ::open (device, O_WRONLY); 160 int fd = ::open (device, O_WRONLY);
159 if ( fd >= 0 ) { 161 if ( fd >= 0 ) {
160 int bbat_status = ioctl( fd, APM_IOC_BATTERY_BACK_CHK, 0 ); 162 int bbat_status = ioctl( fd, APM_IOC_BATTERY_BACK_CHK, 0 );
161 switch ( bbat_status ) { 163 switch ( bbat_status ) {
162 case 0x00: 164 case 0x00:
163 ps->bbs = PowerStatus::High; 165 ps->bbs = PowerStatus::High;
164 break; 166 break;
165 case 0x01: 167 case 0x01:
166 ps->bbs = PowerStatus::Low; 168 ps->bbs = PowerStatus::Low;
167 break; 169 break;
168 case 0x7f: 170 case 0x7f:
169 ps->bbs = PowerStatus::VeryLow; 171 ps->bbs = PowerStatus::VeryLow;
170 break; 172 break;
171 case 0x02: 173 case 0x02:
172 ps->bbs = PowerStatus::Critical; 174 ps->bbs = PowerStatus::Critical;
173 break; 175 break;
174 case 0x03: 176 case 0x03:
175 ps->bbs = PowerStatus::Charging; 177 ps->bbs = PowerStatus::Charging;
176 break; 178 break;
177 case 0x04: 179 case 0x04:
178 ps->bbs = PowerStatus::NotPresent; 180 ps->bbs = PowerStatus::NotPresent;
179 break; 181 break;
180 } 182 }
181 ::close(fd); 183 ::close(fd);
182 } 184 }
183} 185}
184 186
185#else 187#else
186 188
187void PowerStatusManager::getStatus() 189void PowerStatusManager::getStatus()
188{ 190{
189 bool usedApm = FALSE; 191 bool usedApm = FALSE;
190 192
191 ps->percentAccurate = TRUE; 193 ps->percentAccurate = TRUE;
192 194
193 // Some iPAQ kernel builds don't have APM. If this is not the case we 195 // Some iPAQ kernel builds don't have APM. If this is not the case we
194 // save ourselves an ioctl by testing if /proc/apm exists in the 196 // save ourselves an ioctl by testing if /proc/apm exists in the
195 // constructor and we use /proc/apm instead 197 // constructor and we use /proc/apm instead
196 int ac, bs, bf, pc, sec; 198 int ac, bs, bf, pc, sec;
197 if ( haveProcApm ) 199 if ( haveProcApm )
198 usedApm = getProcApmStatus( ac, bs, bf, pc, sec ); 200 usedApm = getProcApmStatus( ac, bs, bf, pc, sec );
199 201
200 if ( !usedApm ) { 202 if ( !usedApm ) {
diff --git a/library/qcopmessage_qws.h b/library/qcopmessage_qws.h
deleted file mode 100644
index c19f57d..0000000
--- a/library/qcopmessage_qws.h
+++ b/dev/null
@@ -1,99 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3**
4** This file is part of the Qtopia Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#ifndef QCOP_MESSAGE_H
22#define QCOP_MESSAGE_H
23
24#include <qdatastream.h>
25#include <qbuffer.h>
26
27class QCopMessage : public QDataStream {
28 public:
29 QCopMessage();
30 QCopMessage(const QCString& channel, const QCString& message);
31 QCopMessage(const QCopMessage& orig);
32 ~QCopMessage();
33
34 void setChannel(QCString& channel) { m_Channel = channel; }
35 QCString channel() const { return m_Channel; }
36 void setMessage(QCString& message) { m_Message = message; }
37 QCString message() const { return m_Message; }
38 const QByteArray data() const;
39
40 QCopMessage& operator=(const QCopMessage& orig);
41
42 private:
43 QCString m_Channel;
44 QCString m_Message;
45};
46
47// ### No need to inline, just maintaining binary compatability
48inline QCopMessage::QCopMessage() : QDataStream(new QBuffer()) {
49 device()->open(IO_WriteOnly);
50}
51
52inline QCopMessage::QCopMessage(const QCString& channel, const QCString& message)
53 : QDataStream(new QBuffer()), m_Channel(channel), m_Message(message) {
54 device()->open(IO_WriteOnly);
55}
56
57inline QCopMessage::QCopMessage(const QCopMessage& orig) : QDataStream() {
58 // The QBuffer is going to share the byte array, so it will keep the
59 // data pointer even when this one goes out of scope.
60 QByteArray array(((QBuffer*)orig.device())->buffer());
61 array.detach();
62 setDevice(new QBuffer(array));
63 device()->open(IO_Append);
64
65 m_Channel = orig.channel();
66 m_Message = orig.message();
67}
68
69inline QCopMessage& QCopMessage::operator=(const QCopMessage& orig) {
70 if (device()) {
71 delete device();
72 unsetDevice();
73 }
74
75 // The QBuffer is going to share the byte array, so it will keep the
76 // data pointer even when this one goes out of scope.
77 QByteArray array(((QBuffer*)orig.device())->buffer());
78 array.detach();
79 setDevice(new QBuffer(array));
80 device()->open(IO_Append);
81
82 m_Channel = orig.channel();
83 m_Message = orig.message();
84
85 return *this;
86}
87
88inline const QByteArray QCopMessage::data() const {
89 return ((QBuffer*)device())->buffer();
90}
91
92inline QCopMessage::~QCopMessage() {
93 // If we still have our QBuffer, clean it up...
94 if (device())
95 delete device();
96 unsetDevice();
97}
98
99#endif
diff --git a/library/qpedecoration_qws.cpp b/library/qpedecoration_qws.cpp
index b6085ef..e041945 100644
--- a/library/qpedecoration_qws.cpp
+++ b/library/qpedecoration_qws.cpp
@@ -1,115 +1,116 @@
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#define QTOPIA_INTERNAL_LANGLIST
20#include <qapplication.h> 21#include <qapplication.h>
21#include <qstyle.h> 22#include <qstyle.h>
22#include <qwidget.h> 23#include <qwidget.h>
23#include <qpainter.h> 24#include <qpainter.h>
24#include <qtimer.h> 25#include <qtimer.h>
25#include <qwhatsthis.h> 26#include <qwhatsthis.h>
26#include "qcopenvelope_qws.h" 27#include "qcopenvelope_qws.h"
27#include "qpedecoration_qws.h" 28#include "qpedecoration_qws.h"
28#include <qdialog.h> 29#include <qdialog.h>
29#include <qdrawutil.h> 30#include <qdrawutil.h>
30#include <qgfx_qws.h> 31#include <qgfx_qws.h>
31#include "qpeapplication.h" 32#include "qpeapplication.h"
32#include "resource.h" 33#include "resource.h"
33#include "global.h" 34#include "global.h"
34#include <qfile.h> 35#include <qfile.h>
35#include <qsignal.h> 36#include <qsignal.h>
36 37
37#include <stdlib.h> 38#include <stdlib.h>
38 39
39extern QRect qt_maxWindowRect; 40extern QRect qt_maxWindowRect;
40 41
41//#define MINIMIZE_HELP_HACK // use minimize button when not a dialog 42//#define MINIMIZE_HELP_HACK // use minimize button when not a dialog
42 43
43//#define WHATSTHIS_MODE 44//#define WHATSTHIS_MODE
44 45
45#ifndef QT_NO_QWS_QPE_WM_STYLE 46#ifndef QT_NO_QWS_QPE_WM_STYLE
46 47
47#ifndef QT_NO_IMAGEIO_XPM 48#ifndef QT_NO_IMAGEIO_XPM
48 49
49/* XPM */ 50/* XPM */
50static const char * const qpe_close_xpm[] = { 51static const char * const qpe_close_xpm[] = {
51"16 16 3 1", 52"16 16 3 1",
52" c None", 53" c None",
53". c #FFFFFF", 54". c #FFFFFF",
54"+ c #000000", 55"+ c #000000",
55" ", 56" ",
56" ", 57" ",
57" ..... ", 58" ..... ",
58" ..+++++.. ", 59" ..+++++.. ",
59" .+++++++++. ", 60" .+++++++++. ",
60" .+..+++..+. ", 61" .+..+++..+. ",
61" .++...+...++. ", 62" .++...+...++. ",
62" .+++.....+++. ", 63" .+++.....+++. ",
63" .++++...++++. ", 64" .++++...++++. ",
64" .+++.....+++. ", 65" .+++.....+++. ",
65" .++...+...++. ", 66" .++...+...++. ",
66" .+..+++..+. ", 67" .+..+++..+. ",
67" .+++++++++. ", 68" .+++++++++. ",
68" ..+++++.. ", 69" ..+++++.. ",
69" ..... ", 70" ..... ",
70" "}; 71" "};
71 72
72/* XPM */ 73/* XPM */
73static const char * const qpe_accept_xpm[] = { 74static const char * const qpe_accept_xpm[] = {
74"16 16 3 1", 75"16 16 3 1",
75" c None", 76" c None",
76". c #FFFFFF", 77". c #FFFFFF",
77"+ c #000000", 78"+ c #000000",
78" ", 79" ",
79" ", 80" ",
80" ..... ", 81" ..... ",
81" ..+++++.. ", 82" ..+++++.. ",
82" .+++++++++. ", 83" .+++++++++. ",
83" .+++++++++. ", 84" .+++++++++. ",
84" .+++++++..++. ", 85" .+++++++..++. ",
85" .++.+++...++. ", 86" .++.+++...++. ",
86" .+...+...+++. ", 87" .+...+...+++. ",
87" .+......++++. ", 88" .+......++++. ",
88" .++....+++++. ", 89" .++....+++++. ",
89" .++..+++++. ", 90" .++..+++++. ",
90" .+++++++++. ", 91" .+++++++++. ",
91" ..+++++.. ", 92" ..+++++.. ",
92" ..... ", 93" ..... ",
93" "}; 94" "};
94 95
95#endif // QT_NO_IMAGEIO_XPM 96#endif // QT_NO_IMAGEIO_XPM
96 97
97class TLWidget : public QWidget 98class TLWidget : public QWidget
98{ 99{
99public: 100public:
100 QWSManager *manager() 101 QWSManager *manager()
101 { 102 {
102 return topData()->qwsManager; 103 return topData()->qwsManager;
103 } 104 }
104 105
105 QTLWExtra *topExtra() 106 QTLWExtra *topExtra()
106 { 107 {
107 return topData(); 108 return topData();
108 } 109 }
109}; 110};
110 111
111QPEManager::QPEManager( QPEDecoration *d, QObject *parent ) 112QPEManager::QPEManager( QPEDecoration *d, QObject *parent )
112 : QObject( parent ), decoration( d ), helpState(0) 113 : QObject( parent ), decoration( d ), helpState(0)
113{ 114{
114 wtTimer = new QTimer( this ); 115 wtTimer = new QTimer( this );
115 connect( wtTimer, SIGNAL(timeout()), this, SLOT(whatsThisTimeout()) ); 116 connect( wtTimer, SIGNAL(timeout()), this, SLOT(whatsThisTimeout()) );
@@ -151,196 +152,196 @@ bool QPEManager::eventFilter( QObject *o, QEvent *e )
151 switch ( e->type() ) { 152 switch ( e->type() ) {
152 case QEvent::MouseButtonPress: 153 case QEvent::MouseButtonPress:
153 { 154 {
154 if ( QWhatsThis::inWhatsThisMode() ) { 155 if ( QWhatsThis::inWhatsThisMode() ) {
155 QWhatsThis::leaveWhatsThisMode(); 156 QWhatsThis::leaveWhatsThisMode();
156 return true; 157 return true;
157 } 158 }
158 pressTime = QTime::currentTime(); 159 pressTime = QTime::currentTime();
159 QPoint p = ((QMouseEvent*)e)->globalPos(); 160 QPoint p = ((QMouseEvent*)e)->globalPos();
160 if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) { 161 if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) {
161 helpState = QWSButton::Clicked|QWSButton::MouseOver; 162 helpState = QWSButton::Clicked|QWSButton::MouseOver;
162 drawButton( w, QPEDecoration::Help, helpState ); 163 drawButton( w, QPEDecoration::Help, helpState );
163 return true; 164 return true;
164 } 165 }
165 } 166 }
166 break; 167 break;
167 case QEvent::MouseButtonRelease: 168 case QEvent::MouseButtonRelease:
168 if ( helpState & QWSButton::Clicked ) { 169 if ( helpState & QWSButton::Clicked ) {
169 helpState = 0; 170 helpState = 0;
170 drawButton( w, QPEDecoration::Help, helpState ); 171 drawButton( w, QPEDecoration::Help, helpState );
171 QPoint p = ((QMouseEvent*)e)->globalPos(); 172 QPoint p = ((QMouseEvent*)e)->globalPos();
172 if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) { 173 if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) {
173#ifdef WHATSTHIS_MODE 174#ifdef WHATSTHIS_MODE
174 if ( pressTime.msecsTo( QTime::currentTime() ) > 250 ) { 175 if ( pressTime.msecsTo( QTime::currentTime() ) > 250 ) {
175 decoration->help( w ); 176 decoration->help( w );
176 } else { 177 } else {
177 QWhatsThis::enterWhatsThisMode(); 178 QWhatsThis::enterWhatsThisMode();
178 wtTimer->start( 200 ); 179 wtTimer->start( 200 );
179 } 180 }
180#else 181#else
181 decoration->help( w ); 182 decoration->help( w );
182#endif 183#endif
183 } 184 }
184 return true; 185 return true;
185 } 186 }
186 break; 187 break;
187 case QEvent::MouseMove: 188 case QEvent::MouseMove:
188 if ( helpState & QWSButton::Clicked ) { 189 if ( helpState & QWSButton::Clicked ) {
189 int oldState = helpState; 190 int oldState = helpState;
190 QPoint p = ((QMouseEvent*)e)->globalPos(); 191 QPoint p = ((QMouseEvent*)e)->globalPos();
191 if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) 192 if ( pointInQpeRegion( w, p ) == QPEDecoration::Help )
192 helpState = QWSButton::Clicked|QWSButton::MouseOver; 193 helpState = QWSButton::Clicked|QWSButton::MouseOver;
193 else 194 else
194 helpState = 0; 195 helpState = 0;
195 if ( helpState != oldState ) 196 if ( helpState != oldState )
196 drawButton( w, QPEDecoration::Help, helpState ); 197 drawButton( w, QPEDecoration::Help, helpState );
197 } 198 }
198 break; 199 break;
199 default: 200 default:
200 break; 201 break;
201 } 202 }
202 return QObject::eventFilter( o, e ); 203 return QObject::eventFilter( o, e );
203} 204}
204 205
205void QPEManager::drawButton( QWidget *w, QPEDecoration::QPERegion r, int state ) 206void QPEManager::drawButton( QWidget *w, QPEDecoration::QPERegion r, int state )
206{ 207{
207 QPainter painter(w); 208 QPainter painter(w);
208 QRegion rgn = ((TLWidget *)w)->topExtra()->decor_allocated_region; 209 QRegion rgn = ((TLWidget *)w)->topExtra()->decor_allocated_region;
209 painter.internalGfx()->setWidgetDeviceRegion( rgn ); 210 painter.internalGfx()->setWidgetDeviceRegion( rgn );
210 painter.setClipRegion(decoration->region(w, w->rect(),QWSDecoration::All)); 211 painter.setClipRegion(decoration->region(w, w->rect(),QWSDecoration::All));
211 decoration->paintButton( &painter, w, (QWSDecoration::Region)r, state ); 212 decoration->paintButton( &painter, w, (QWSDecoration::Region)r, state );
212} 213}
213 214
214void QPEManager::whatsThisTimeout() 215void QPEManager::whatsThisTimeout()
215{ 216{
216 if ( !QWhatsThis::inWhatsThisMode() ) { 217 if ( !QWhatsThis::inWhatsThisMode() ) {
217 wtTimer->stop(); 218 wtTimer->stop();
218 if ( active ) 219 if ( active )
219 drawButton( active, QPEDecoration::Help, 0 ); 220 drawButton( active, QPEDecoration::Help, 0 );
220 } else if ( active ) { 221 } else if ( active ) {
221 static int state = 0; 222 static int state = 0;
222 if ( !state ) 223 if ( !state )
223 state = QWSButton::Clicked|QWSButton::MouseOver; 224 state = QWSButton::Clicked|QWSButton::MouseOver;
224 else 225 else
225 state = 0; 226 state = 0;
226 drawButton( active, QPEDecoration::Help, state ); 227 drawButton( active, QPEDecoration::Help, state );
227 } 228 }
228} 229}
229 230
230//========= 231//=========
231 232
232class HackWidget : public QWidget 233class HackWidget : public QWidget
233{ 234{
234public: 235public:
235 bool needsOk() { return (getWState() & WState_Reserved1 ); } 236 bool needsOk() { return (getWState() & WState_Reserved1 ); }
236}; 237};
237 238
238//=========================================================================== 239//===========================================================================
239 240
240QPEDecoration::QPEDecoration() 241QPEDecoration::QPEDecoration()
241 : QWSDefaultDecoration() 242 : QWSDefaultDecoration()
242{ 243{
243 imageOk = Resource::loadImage( "OKButton" ); 244 imageOk = Resource::loadImage( "OKButton" );
244 imageClose = Resource::loadImage( "CloseButton" ); 245 imageClose = Resource::loadImage( "CloseButton" );
245 imageHelp = Resource::loadImage( "HelpButton" ); 246 imageHelp = Resource::loadImage( "HelpButton" );
246 helpFile = QString(qApp->argv()[0]) + ".html"; 247 helpFile = QString(qApp->argv()[0]) + ".html";
247 QString lang = getenv( "LANG" ); 248 QStringList path = Global::helpPath();
248 helpExists = QFile::exists( QPEApplication::qpeDir() + "/help/" + lang + "/html/" + helpFile ); 249 helpExists = FALSE;
249 if ( !helpExists ) 250 for (QStringList::ConstIterator it=path.begin(); it!=path.end() && !helpExists; ++it)
250 helpExists = QFile::exists( QPEApplication::qpeDir() + "/help/en/html/" + helpFile ); 251 helpExists = QFile::exists( *it + "/" + helpFile );
251#ifndef MINIMIZE_HELP_HACK 252#ifndef MINIMIZE_HELP_HACK
252 qpeManager = new QPEManager( this ); 253 qpeManager = new QPEManager( this );
253#else 254#else
254 qpeManager = 0; 255 qpeManager = 0;
255#endif 256#endif
256} 257}
257 258
258QPEDecoration::~QPEDecoration() 259QPEDecoration::~QPEDecoration()
259{ 260{
260 delete qpeManager; 261 delete qpeManager;
261} 262}
262 263
263const char **QPEDecoration::menuPixmap() 264const char **QPEDecoration::menuPixmap()
264{ 265{
265 return (const char **)0; 266 return (const char **)0;
266} 267}
267 268
268const char **QPEDecoration::closePixmap() 269const char **QPEDecoration::closePixmap()
269{ 270{
270 return (const char **)qpe_close_xpm; 271 return (const char **)qpe_close_xpm;
271} 272}
272 273
273const char **QPEDecoration::minimizePixmap() 274const char **QPEDecoration::minimizePixmap()
274{ 275{
275 return (const char **)qpe_accept_xpm; 276 return (const char **)qpe_accept_xpm;
276} 277}
277 278
278const char **QPEDecoration::maximizePixmap() 279const char **QPEDecoration::maximizePixmap()
279{ 280{
280 return (const char **)0; 281 return (const char **)0;
281} 282}
282 283
283const char **QPEDecoration::normalizePixmap() 284const char **QPEDecoration::normalizePixmap()
284{ 285{
285 return (const char **)0; 286 return (const char **)0;
286} 287}
287 288
288int QPEDecoration::getTitleHeight(const QWidget *) 289int QPEDecoration::getTitleHeight(const QWidget *)
289{ 290{
290 return 15; 291 return 15;
291} 292}
292 293
293/* 294/*
294 If rect is empty, no frame is added. (a hack, really) 295 If rect is empty, no frame is added. (a hack, really)
295*/ 296*/
296QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecoration::Region type) 297QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecoration::Region type)
297{ 298{
298 int titleHeight = getTitleHeight(widget); 299 int titleHeight = getTitleHeight(widget);
299// int titleWidth = getTitleWidth(widget); 300// int titleWidth = getTitleWidth(widget);
300// int bw = rect.isEmpty() ? 0 : BORDER_WIDTH; 301// int bw = rect.isEmpty() ? 0 : BORDER_WIDTH;
301 QRegion region; 302 QRegion region;
302 303
303#ifndef MINIMIZE_HELP_HACK 304#ifndef MINIMIZE_HELP_HACK
304 qpeManager->updateActive(); 305 qpeManager->updateActive();
305#endif 306#endif
306 307
307 switch ((int)type) { 308 switch ((int)type) {
308 case Menu: 309 case Menu:
309 case Maximize: 310 case Maximize:
310 break; 311 break;
311 case Minimize: { 312 case Minimize: {
312 if ( ((HackWidget *)widget)->needsOk() || 313 if ( ((HackWidget *)widget)->needsOk() ||
313 (widget->inherits( "QDialog" ) && !widget->inherits( "QMessageBox" ) ) ) { 314 (widget->inherits( "QDialog" ) && !widget->inherits( "QMessageBox" ) ) ) {
314 QRect r(rect.right() - imageOk.width(), 315 QRect r(rect.right() - imageOk.width(),
315 rect.top() - titleHeight - 2, 316 rect.top() - titleHeight - 2,
316 imageOk.width(), titleHeight); 317 imageOk.width(), titleHeight);
317 if (r.left() > rect.left() + titleHeight) 318 if (r.left() > rect.left() + titleHeight)
318 region = r; 319 region = r;
319 } 320 }
320#ifdef MINIMIZE_HELP_HACK 321#ifdef MINIMIZE_HELP_HACK
321 else if ( helpExists ) { 322 else if ( helpExists ) {
322 QRect r; 323 QRect r;
323 r = QRect(rect.right() - imageClose.width() - imageHelp.width(), 324 r = QRect(rect.right() - imageClose.width() - imageHelp.width(),
324 rect.top() - titleHeight - 2, 325 rect.top() - titleHeight - 2,
325 imageHelp.width(), titleHeight); 326 imageHelp.width(), titleHeight);
326 if (r.left() > rect.left() + titleHeight) 327 if (r.left() > rect.left() + titleHeight)
327 region = r; 328 region = r;
328 } 329 }
329#endif 330#endif
330 } 331 }
331 break; 332 break;
332 case Close: { 333 case Close: {
333 if ( ((HackWidget *)widget)->needsOk() || 334 if ( ((HackWidget *)widget)->needsOk() ||
334 (widget->inherits( "QDialog" ) && !widget->inherits( "QMessageBox" ) ) ) { 335 (widget->inherits( "QDialog" ) && !widget->inherits( "QMessageBox" ) ) ) {
335 QRect r; 336 QRect r;
336 r = QRect(rect.right() - imageOk.width() - imageClose.width(), 337 r = QRect(rect.right() - imageOk.width() - imageClose.width(),
337 rect.top() - titleHeight - 2, 338 rect.top() - titleHeight - 2,
338 imageClose.width(), titleHeight); 339 imageClose.width(), titleHeight);
339 if (r.left() > rect.left() + titleHeight) 340 if (r.left() > rect.left() + titleHeight)
340 region = r; 341 region = r;
341 } else { 342 } else {
342 QRect r(rect.right() - imageClose.width(), 343 QRect r(rect.right() - imageClose.width(),
343 rect.top() - titleHeight - 2, 344 rect.top() - titleHeight - 2,
344 imageClose.width(), titleHeight); 345 imageClose.width(), titleHeight);
345 if (r.left() > rect.left() + titleHeight) 346 if (r.left() > rect.left() + titleHeight)
346 region = r; 347 region = r;
diff --git a/noncore/games/go/gowidget.cpp b/noncore/games/go/gowidget.cpp
index fca9797..8567b30 100644
--- a/noncore/games/go/gowidget.cpp
+++ b/noncore/games/go/gowidget.cpp
@@ -1,295 +1,310 @@
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 "gowidget.h" 21#include "gowidget.h"
22 22
23#include <qpe/config.h> 23#include <qpe/config.h>
24#include <qpe/resource.h> 24#include <qpe/resource.h>
25 25
26#include <qpainter.h> 26#include <qpainter.h>
27#include <qpixmap.h> 27#include <qpixmap.h>
28#include <qpe/qpetoolbar.h> 28#include <qpe/qpetoolbar.h>
29#include <qpe/qpemenubar.h> 29#include <qpe/qpemenubar.h>
30#include <qpopupmenu.h> 30#include <qpopupmenu.h>
31#include <qaction.h> 31#include <qaction.h>
32#include <qapplication.h> //processEvents() 32#include <qapplication.h> //processEvents()
33#include <qlabel.h> 33#include <qlabel.h>
34 34
35//#include <stdio.h> 35//#include <stdio.h>
36 36
37#include "amigo.h" 37#include "amigo.h"
38#include "goplayutils.h" 38#include "goplayutils.h"
39 39
40static const enum bVal computer_color = BLACK; 40static const enum bVal computer_color = BLACK;
41 41
42static int current_handicap = 1; 42static int current_handicap = 1;
43 43
44static QBrush *goBrush; 44static QBrush *goBrush;
45//static QImage *newBlackStone; 45//static QImage *newBlackStone;
46//static QImage *blackStone; 46//static QImage *blackStone;
47//static QImage *whiteStone; 47//static QImage *whiteStone;
48static QPixmap *newBlackStone; 48static QPixmap *newBlackStone;
49static QPixmap *blackStone; 49static QPixmap *blackStone;
50static QPixmap *whiteStone; 50static QPixmap *whiteStone;
51 51
52static bool smallStones = FALSE;
53
52GoMainWidget::GoMainWidget( QWidget *parent, const char* name) : 54GoMainWidget::GoMainWidget( QWidget *parent, const char* name) :
53 QMainWindow( parent, name ) 55 QMainWindow( parent, name )
54{ 56{
55 setToolBarsMovable( FALSE ); 57 setToolBarsMovable( FALSE );
56 GoWidget *go = new GoWidget(this); 58 GoWidget *go = new GoWidget(this);
57 59
58 setCentralWidget(go); 60 setCentralWidget(go);
59 toolbar = new QPEToolBar(this); 61 toolbar = new QPEToolBar(this);
60 toolbar->setHorizontalStretchable( TRUE ); 62 toolbar->setHorizontalStretchable( TRUE );
61 addToolBar(toolbar); 63 addToolBar(toolbar);
62 64
63 QPEMenuBar *mb = new QPEMenuBar( toolbar ); 65 QPEMenuBar *mb = new QPEMenuBar( toolbar );
64 mb->setMargin(0); 66 mb->setMargin(0);
65 QPopupMenu *file = new QPopupMenu( this ); 67 QPopupMenu *file = new QPopupMenu( this );
66 68
67 QAction *a = new QAction( tr( "New Game" ), QString::null, 0, this, 0 ); 69 QAction *a = new QAction( tr( "New Game" ), QString::null, 0, this, 0 );
68 connect( a, SIGNAL( activated() ), go, SLOT( newGame() ) ); 70 connect( a, SIGNAL( activated() ), go, SLOT( newGame() ) );
69 a->addTo( file ); 71 a->addTo( file );
70 72
71 a = new QAction( tr( "Pass" ), Resource::loadPixmap( "pass" ), QString::null, 0, this, 0 ); 73 a = new QAction( tr( "Pass" ), Resource::loadPixmap( "pass" ), QString::null, 0, this, 0 );
72 connect( a, SIGNAL( activated() ), go, SLOT( pass() ) ); 74 connect( a, SIGNAL( activated() ), go, SLOT( pass() ) );
73 a->addTo( file ); 75 a->addTo( file );
74 a->addTo( toolbar ); 76 a->addTo( toolbar );
75 77
76 78
77 a = new QAction( tr( "Resign" ), Resource::loadPixmap( "reset" ), QString::null, 0, this, 0 ); 79 a = new QAction( tr( "Resign" ), Resource::loadPixmap( "reset" ), QString::null, 0, this, 0 );
78 connect( a, SIGNAL( activated() ), go, SLOT( resign() ) ); 80 connect( a, SIGNAL( activated() ), go, SLOT( resign() ) );
79 a->addTo( file ); 81 a->addTo( file );
80 82
81 a = new QAction( tr( "Two player option" ), QString::null, 0, this, 0 ); 83 a = new QAction( tr( "Two player option" ), QString::null, 0, this, 0 );
82 a->setToggleAction( TRUE ); 84 a->setToggleAction( TRUE );
83 connect( a, SIGNAL( toggled(bool) ), go, SLOT( setTwoplayer(bool) ) ); 85 connect( a, SIGNAL( toggled(bool) ), go, SLOT( setTwoplayer(bool) ) );
84 a->addTo( file ); 86 a->addTo( file );
85 87
86 mb->insertItem( tr( "Game" ), file ); 88 mb->insertItem( tr( "Game" ), file );
87 89
88 QLabel *turnLabel = new QLabel( toolbar ); 90 QLabel *turnLabel = new QLabel( toolbar );
89 turnLabel->setBackgroundMode( PaletteButton ); 91 turnLabel->setBackgroundMode( PaletteButton );
90 connect( go, SIGNAL(showTurn(const QPixmap&)), 92 connect( go, SIGNAL(showTurn(const QPixmap&)),
91 turnLabel, SLOT(setPixmap(const QPixmap&)) ); 93 turnLabel, SLOT(setPixmap(const QPixmap&)) );
92 94
93 95
94 QLabel * scoreLabel = new QLabel( toolbar ); 96 QLabel * scoreLabel = new QLabel( toolbar );
95 scoreLabel->setBackgroundMode( PaletteButton ); 97 scoreLabel->setBackgroundMode( PaletteButton );
96 connect( go, SIGNAL(showScore(const QString&)), 98 connect( go, SIGNAL(showScore(const QString&)),
97 scoreLabel, SLOT(setText(const QString&)) ); 99 scoreLabel, SLOT(setText(const QString&)) );
98 100
99 toolbar->setStretchableWidget( scoreLabel ); 101 toolbar->setStretchableWidget( scoreLabel );
100 102
101 go->readConfig(); 103 go->readConfig();
102} 104}
103 105
104void GoMainWidget::resizeEvent( QResizeEvent * ) 106void GoMainWidget::resizeEvent( QResizeEvent * )
105{ 107{
106 //### this won't work because of the text label... 108 //### this won't work because of the text label...
107 /* 109 /*
108 if ( width() > height() ) 110 if ( width() > height() )
109 moveToolBar( toolbar, Left ); 111 moveToolBar( toolbar, Left );
110 else 112 else
111 moveToolBar( toolbar, Top ); 113 moveToolBar( toolbar, Top );
112 */ 114 */
113} 115}
114 116
115GoWidget *GoWidget::self = 0; 117GoWidget *GoWidget::self = 0;
116 118
117GoWidget::GoWidget( QWidget *parent, const char* name) : 119GoWidget::GoWidget( QWidget *parent, const char* name) :
118 QWidget( parent, name ) 120 QWidget( parent, name )
119{ 121{
120 if ( self ) 122 if ( self )
121 fatal( "Only one Go widget allowed" ); 123 fatal( "Only one Go widget allowed" );
122 self = this; 124 self = this;
123 twoplayer = FALSE; 125 twoplayer = FALSE;
124 126
125 127
126 d = bx = by = 1; 128 d = bx = by = 1;
127 129
128 QPixmap pix = Resource::loadPixmap( "pine" ); 130 QPixmap pix = Resource::loadPixmap( "pine" );
129 goBrush = new QBrush( black, pix ); 131 goBrush = new QBrush( black, pix );
130 /* 132 /*
131 QString fn = Resource::findPixmap("Go-black"); 133 QString fn = Resource::findPixmap("Go-black");
132 blackStone = new QImage( fn ); 134 blackStone = new QImage( fn );
133 fn = Resource::findPixmap("Go-black-highlight"); 135 fn = Resource::findPixmap("Go-black-highlight");
134 newBlackStone = new QImage( fn ); 136 newBlackStone = new QImage( fn );
135 fn = Resource::findPixmap("Go-white"); 137 fn = Resource::findPixmap("Go-white");
136 whiteStone = new QImage( fn ); 138 whiteStone = new QImage( fn );
137 */ 139 */
138 blackStone = new QPixmap(Resource::loadPixmap( "Go-black" )); 140 blackStone = new QPixmap(Resource::loadPixmap( "Go-black" ));
139 whiteStone = new QPixmap(Resource::loadPixmap( "Go-white" )); 141 whiteStone = new QPixmap(Resource::loadPixmap( "Go-white" ));
140 newBlackStone = new QPixmap(Resource::loadPixmap( "Go-black-highlight" )); 142 newBlackStone = new QPixmap(Resource::loadPixmap( "Go-black-highlight" ));
141 143
142 init(); 144 init();
143} 145}
144 146
145GoWidget::~GoWidget() 147GoWidget::~GoWidget()
146{ 148{
147 writeConfig(); 149 writeConfig();
148} 150}
149 151
150void GoWidget::writeConfig() 152void GoWidget::writeConfig()
151{ 153{
152 Config cfg("Go"); 154 Config cfg("Go");
153 cfg.setGroup("Game"); 155 cfg.setGroup("Game");
154 cfg.writeEntry("TwoPlayer", twoplayer); 156 cfg.writeEntry("TwoPlayer", twoplayer);
155 cfg.writeEntry("CurrentPlayer", currentPlayer); 157 cfg.writeEntry("CurrentPlayer", currentPlayer);
156 cfg.writeEntry("NPassed", nPassed); 158 cfg.writeEntry("NPassed", nPassed);
157 QString b; 159 QString b;
158 for (int i=0; i<19; i++) 160 for (int i=0; i<19; i++)
159 for (int j=0; j<19; j++) 161 for (int j=0; j<19; j++)
160 b += board[i][j] == BLACK ? 'B' : board[i][j] == WHITE ? 'W' : '.'; 162 b += board[i][j] == BLACK ? 'B' : board[i][j] == WHITE ? 'W' : '.';
161 cfg.writeEntry("Board", b); 163 cfg.writeEntry("Board", b);
162 cfg.writeEntry("LastX", lastX); 164 cfg.writeEntry("LastX", lastX);
163 cfg.writeEntry("LastY", lastY); 165 cfg.writeEntry("LastY", lastY);
164 extern int blackPrisoners, whitePrisoners; 166 extern int blackPrisoners, whitePrisoners;
165 cfg.writeEntry("BlackPrisoners", blackPrisoners); 167 cfg.writeEntry("BlackPrisoners", blackPrisoners);
166 cfg.writeEntry("WhitePrisoners", whitePrisoners); 168 cfg.writeEntry("WhitePrisoners", whitePrisoners);
167} 169}
168 170
169void GoWidget::readConfig() 171void GoWidget::readConfig()
170{ 172{
171 init(); 173 init();
172 Config cfg("Go"); 174 Config cfg("Go");
173 cfg.setGroup("Game"); 175 cfg.setGroup("Game");
174 twoplayer = cfg.readBoolEntry("TwoPlayer"); 176 twoplayer = cfg.readBoolEntry("TwoPlayer");
175 currentPlayer = (bVal)cfg.readNumEntry("CurrentPlayer",1); 177 currentPlayer = (bVal)cfg.readNumEntry("CurrentPlayer",1);
176 nPassed = cfg.readNumEntry("NPassed",0); 178 nPassed = cfg.readNumEntry("NPassed",0);
177 QString b = cfg.readEntry("Board"); 179 QString b = cfg.readEntry("Board");
178 if ( b.length() == 19*19 ) 180 if ( b.length() == 19*19 )
179 for (int i=0; i<19; i++) 181 for (int i=0; i<19; i++)
180 for (int j=0; j<19; j++) { 182 for (int j=0; j<19; j++) {
181 QChar ch = b[j+19*i]; 183 QChar ch = b[j+19*i];
182 if ( ch != '.' ) 184 if ( ch != '.' )
183 GoPlaceStone( ch == 'B' ? BLACK : WHITE, i, j ); 185 GoPlaceStone( ch == 'B' ? BLACK : WHITE, i, j );
184 } 186 }
185 lastX = cfg.readNumEntry("LastX"); 187 lastX = cfg.readNumEntry("LastX");
186 lastY = cfg.readNumEntry("LastY"); 188 lastY = cfg.readNumEntry("LastY");
187 extern int blackPrisoners, whitePrisoners; 189 extern int blackPrisoners, whitePrisoners;
188 blackPrisoners = cfg.readNumEntry("BlackPrisoners",0); 190 blackPrisoners = cfg.readNumEntry("BlackPrisoners",0);
189 whitePrisoners = cfg.readNumEntry("WhitePrisoners",0); 191 whitePrisoners = cfg.readNumEntry("WhitePrisoners",0);
190 reportPrisoners(blackPrisoners,whitePrisoners); 192 reportPrisoners(blackPrisoners,whitePrisoners);
191 emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone ); 193 emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone );
192} 194}
193 195
194void GoWidget::resizeEvent( QResizeEvent * ) 196void GoWidget::resizeEvent( QResizeEvent * )
195{ 197{
196 d = QMIN(width(),height())/19; 198 d = QMIN(width(),height())/19;
197 // int r = (d/2-1); 199 // int r = (d/2-1);
198 bx = (width() - 18*d)/2 ; 200 bx = (width() - 18*d)/2 ;
199 by = (height() - 18*d)/2 ; 201 by = (height() - 18*d)/2 ;
202
203 if ( d < 10 && !smallStones ) {
204 blackStone->convertFromImage( blackStone->convertToImage().smoothScale(8,8) );
205 whiteStone->convertFromImage( whiteStone->convertToImage().smoothScale(8,8) );
206 newBlackStone->convertFromImage( newBlackStone->convertToImage().smoothScale(8,8) );
207
208 smallStones = TRUE;
209 } else if ( d >= 10 && smallStones ) {
210 blackStone = new QPixmap(Resource::loadPixmap( "Go-black" ));
211 whiteStone = new QPixmap(Resource::loadPixmap( "Go-white" ));
212 newBlackStone = new QPixmap(Resource::loadPixmap( "Go-black-highlight" ));
213 smallStones = FALSE;
214 }
200} 215}
201 216
202void GoWidget::init() 217void GoWidget::init()
203{ 218{
204 lastX = lastY = newX = newY = -1; 219 lastX = lastY = newX = newY = -1;
205 nPassed = 0; 220 nPassed = 0;
206 for ( int i = 0; i < 19; i++ ) 221 for ( int i = 0; i < 19; i++ )
207 for ( int j = 0; j < 19; j++ ) 222 for ( int j = 0; j < 19; j++ )
208 board[i][j]=-1; 223 board[i][j]=-1;
209 gameActive = TRUE; 224 gameActive = TRUE;
210 goRestart(current_handicap); 225 goRestart(current_handicap);
211 226
212 if ( twoplayer ) { 227 if ( twoplayer ) {
213 currentPlayer = BLACK; 228 currentPlayer = BLACK;
214 } else { 229 } else {
215 doComputerMove(); 230 doComputerMove();
216 currentPlayer = WHITE; 231 currentPlayer = WHITE;
217 } 232 }
218 emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone ); 233 emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone );
219} 234}
220 235
221void GoWidget::paintEvent( QPaintEvent *e ) 236void GoWidget::paintEvent( QPaintEvent *e )
222{ 237{
223 int i,j; 238 int i,j;
224 239
225 int r = whiteStone->width()/2; 240 int r = whiteStone->width()/2;
226 241
227 QPainter p(this); 242 QPainter p(this);
228 p.fillRect( bx - d/2, by - d/2, 19*d, 19*d, *goBrush ); 243 p.fillRect( bx - d/2, by - d/2, 19*d, 19*d, *goBrush );
229 244
230 int xMin = QMAX( x2board(e->rect().left()), 0 ); 245 int xMin = QMAX( x2board(e->rect().left()), 0 );
231 int xMax = QMIN( x2board(e->rect().right()), 18 ); 246 int xMax = QMIN( x2board(e->rect().right()), 18 );
232 int yMin = QMAX( y2board(e->rect().top()), 0 ); 247 int yMin = QMAX( y2board(e->rect().top()), 0 );
233 int yMax = QMIN( y2board(e->rect().bottom()), 18 ); 248 int yMax = QMIN( y2board(e->rect().bottom()), 18 );
234 249
235 QColor pine( 255, 186, 89 ); 250 QColor pine( 255, 186, 89 );
236 p.setPen( pine.dark() ); 251 p.setPen( pine.dark() );
237 252
238 for ( i = xMin; i < xMax+1 ; i ++ ) { 253 for ( i = xMin; i < xMax+1 ; i ++ ) {
239 p.drawLine( bx+i*d, by, bx+i*d, by+18*d ); 254 p.drawLine( bx+i*d, by, bx+i*d, by+18*d );
240 } 255 }
241 for ( j = yMin; j < yMax+1 ; j ++ ) { 256 for ( j = yMin; j < yMax+1 ; j ++ ) {
242 p.drawLine( bx, by+j*d, bx+18*d, by+j*d); 257 p.drawLine( bx, by+j*d, bx+18*d, by+j*d);
243 } 258 }
244 259
245 // dots are at (3,3), (3,9), (3,15) and so on 260 // dots are at (3,3), (3,9), (3,15) and so on
246 p.setBrush( black ); 261 p.setBrush( black );
247 for ( i = 3; i < xMax+1; i+=6 ) 262 for ( i = 3; i < xMax+1; i+=6 )
248 for ( j = 3; j < yMax+1; j+=6 ) 263 for ( j = 3; j < yMax+1; j+=6 )
249 p.drawEllipse( bx+i*d-2, by+j*d-2, 5, 5 ); 264 p.drawEllipse( bx+i*d-2, by+j*d-2, 5, 5 );
250 265
251 266
252 for ( i = xMin; i < xMax+1; i++ ) 267 for ( i = xMin; i < xMax+1; i++ )
253 for ( j = yMin; j < yMax+1; j++ ) { 268 for ( j = yMin; j < yMax+1; j++ ) {
254 if ( board[i][j] == WHITE || 269 if ( board[i][j] == WHITE ||
255 currentPlayer==WHITE && newX == i && newY == j ) 270 currentPlayer==WHITE && newX == i && newY == j )
256 p.drawPixmap( bx+i*d - r, by+j*d - r, *whiteStone ); 271 p.drawPixmap( bx+i*d - r, by+j*d - r, *whiteStone );
257 else if ( i == lastX && j == lastY ) 272 else if ( i == lastX && j == lastY )
258 p.drawPixmap( bx+i*d - r, by+j*d - r, *newBlackStone ); 273 p.drawPixmap( bx+i*d - r, by+j*d - r, *newBlackStone );
259 else if ( board[i][j] == BLACK || 274 else if ( board[i][j] == BLACK ||
260 currentPlayer==BLACK && newX == i && newY == j) 275 currentPlayer==BLACK && newX == i && newY == j)
261 p.drawPixmap( bx+i*d - r, by+j*d - r, *blackStone ); 276 p.drawPixmap( bx+i*d - r, by+j*d - r, *blackStone );
262 } 277 }
263} 278}
264 279
265void GoWidget::doMove( int x, int y ) 280void GoWidget::doMove( int x, int y )
266{ 281{
267 282
268 if ( !GoPlaceStone( currentPlayer, x, y ) ) { 283 if ( !GoPlaceStone( currentPlayer, x, y ) ) {
269 //printf( "Illegal move (%d,%d)\n", x, y ); 284 //printf( "Illegal move (%d,%d)\n", x, y );
270 return; 285 return;
271 } 286 }
272 //printf( "you do (%d,%d)\n", x, y ); 287 //printf( "you do (%d,%d)\n", x, y );
273 nPassed = 0; 288 nPassed = 0;
274 if ( twoplayer ) 289 if ( twoplayer )
275 currentPlayer = (currentPlayer==WHITE) ? BLACK : WHITE; 290 currentPlayer = (currentPlayer==WHITE) ? BLACK : WHITE;
276 else 291 else
277 doComputerMove(); 292 doComputerMove();
278 293
279 emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone ); 294 emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone );
280 295
281} 296}
282 297
283void GoWidget::pass() 298void GoWidget::pass()
284{ 299{
285 if ( !gameActive ) 300 if ( !gameActive )
286 return; 301 return;
287 nPassed++; 302 nPassed++;
288 if ( nPassed >= 2 ) 303 if ( nPassed >= 2 )
289 endGame(); 304 endGame();
290 else if ( !twoplayer ) 305 else if ( !twoplayer )
291 doComputerMove(); 306 doComputerMove();
292} 307}
293 308
294void GoWidget::resign() 309void GoWidget::resign()
295{ 310{
diff --git a/noncore/games/minesweep/minefield.h b/noncore/games/minesweep/minefield.h
index 4ede435..1349c35 100644
--- a/noncore/games/minesweep/minefield.h
+++ b/noncore/games/minesweep/minefield.h
@@ -1,87 +1,101 @@
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 MINEFIELD_H 20#ifndef MINEFIELD_H
21#define MINEFIELD_H 21#define MINEFIELD_H
22 22
23#include <qtable.h> 23#include <qscrollview.h>
24 24
25class Mine; 25class Mine;
26class Config; 26class Config;
27 27
28class MineField : public QTable 28class MineField : public QScrollView
29{ 29{
30 Q_OBJECT 30 Q_OBJECT
31public: 31public:
32 MineField( QWidget* parent = 0, const char* name = 0 ); 32 MineField( QWidget* parent = 0, const char* name = 0 );
33 ~MineField(); 33 ~MineField();
34 34
35 enum State { Waiting, Playing, GameOver }; 35 enum State { Waiting, Playing, GameOver };
36 36
37 State state() const { return stat; } 37 State state() const { return stat; }
38 38
39 void readConfig(Config&); 39 void readConfig(Config&);
40 void writeConfig(Config&) const; 40 void writeConfig(Config&) const;
41 41
42 int level() const { return lev; } 42 int level() const { return lev; }
43 43
44 void setAvailableRect( const QRect & );
44public slots: 45public slots:
45 void setup( int level ); 46 void setup( int level );
46 47
47 void showMines(); 48 void showMines();
48 49
49signals: 50signals:
50 void gameOver( bool won ); 51 void gameOver( bool won );
51 void gameStarted(); 52 void gameStarted();
52 void mineCount( int ); 53 void mineCount( int );
53 54
54protected: 55protected:
55 void paintFocus( QPainter*, const QRect& ); 56
56 void viewportMousePressEvent( QMouseEvent* ); 57 void contentsMousePressEvent( QMouseEvent* );
57 void viewportMouseReleaseEvent( QMouseEvent* ); 58 void contentsMouseReleaseEvent( QMouseEvent* );
58 void keyPressEvent( QKeyEvent* ); 59 void keyPressEvent( QKeyEvent* );
59 void keyReleaseEvent( QKeyEvent* ); 60 void keyReleaseEvent( QKeyEvent* );
60 61 void drawContents( QPainter * p, int clipx, int clipy, int clipw, int cliph );
62
61 int getHint( int row, int col ); 63 int getHint( int row, int col );
62 void setHint( Mine* ); 64 void setHint( int r, int c );
63 void updateMine( int row, int col ); 65 void updateMine( int row, int col );
64 void paletteChange( const QPalette & ); 66 void paletteChange( const QPalette & );
65 67 void updateCell( int r, int c );
68 bool onBoard( int r, int c ) const { return r >= 0 && r < numRows && c >= 0 && c < numCols; }
69 Mine *mine( int row, int col ) { return onBoard(row, col ) ? mines[row+numCols*col] : 0; }
70 const Mine *mine( int row, int col ) const { return onBoard(row, col ) ? mines[row+numCols*col] : 0; }
71
66protected slots: 72protected slots:
67 void cellPressed( int row, int col ); 73 void cellPressed( int row, int col );
68 void cellClicked( int row, int col ); 74 void cellClicked( int row, int col );
69 void held(); 75 void held();
70 76
71private: 77private:
78 int findCellSize();
79 void setCellSize( int );
80
72 State stat; 81 State stat;
73 void MineField::setState( State st ); 82 void MineField::setState( State st );
74 void MineField::placeMines(); 83 void MineField::placeMines();
75 enum FlagAction { NoAction, FlagOn, FlagNext }; 84 enum FlagAction { NoAction, FlagOn, FlagNext };
76 FlagAction flagAction; 85 FlagAction flagAction;
77 bool ignoreClick; 86 bool ignoreClick;
78 int currRow; 87 int currRow;
79 int currCol; 88 int currCol;
89 int numRows, numCols;
90
80 int minecount; 91 int minecount;
81 int mineguess; 92 int mineguess;
82 int nonminecount; 93 int nonminecount;
83 int lev; 94 int lev;
95 QRect availableRect;
96 int cellSize;
84 QTimer *holdTimer; 97 QTimer *holdTimer;
98 Mine **mines;
85}; 99};
86 100
87#endif // MINEFIELD_H 101#endif // MINEFIELD_H
diff --git a/noncore/games/minesweep/minesweep.cpp b/noncore/games/minesweep/minesweep.cpp
index 6492462..c84fe53 100644
--- a/noncore/games/minesweep/minesweep.cpp
+++ b/noncore/games/minesweep/minesweep.cpp
@@ -126,249 +126,264 @@ static const char * worried_xpm[] = {
126 126
127 127
128/* XPM */ 128/* XPM */
129static const char * dead_xpm[] = { 129static const char * dead_xpm[] = {
130"20 20 3 1", 130"20 20 3 1",
131 " c None", 131 " c None",
132 ".c #ffff3f", 132 ".c #ffff3f",
133 "#c #000000", 133 "#c #000000",
134" ", 134" ",
135" ###### ", 135" ###### ",
136" ##......## ", 136" ##......## ",
137" #..........# ", 137" #..........# ",
138" #............# ", 138" #............# ",
139" #..............# ", 139" #..............# ",
140" #..#.#...#.#...# ", 140" #..#.#...#.#...# ",
141" #....#.....#.....# ", 141" #....#.....#.....# ",
142" #...#.#...#.#....# ", 142" #...#.#...#.#....# ",
143" #................# ", 143" #................# ",
144" #................# ", 144" #................# ",
145" #................# ", 145" #................# ",
146" #......####......# ", 146" #......####......# ",
147" #....# #....# ", 147" #....# #....# ",
148" #...#......#...# ", 148" #...#......#...# ",
149" #............# ", 149" #............# ",
150" #..........# ", 150" #..........# ",
151" ##......## ", 151" ##......## ",
152" ###### ", 152" ###### ",
153" "}; 153" "};
154 154
155 155
156class ResultIndicator : private QLabel 156class ResultIndicator : private QLabel
157{ 157{
158public: 158public:
159 static void showResult( QWidget *ref, bool won ); 159 static void showResult( QWidget *ref, bool won );
160private: 160private:
161 ResultIndicator( QWidget *parent, const char *name, WFlags f) 161 ResultIndicator( QWidget *parent, const char *name, WFlags f)
162 :QLabel( parent, name, f ) {} 162 :QLabel( parent, name, f ) {}
163 163
164 void timerEvent( QTimerEvent *); 164 void timerEvent( QTimerEvent *);
165 void center(); 165 void center();
166 bool twoStage; 166 bool twoStage;
167 int timerId; 167 int timerId;
168}; 168};
169 169
170void ResultIndicator::showResult( QWidget *ref, bool won ) 170void ResultIndicator::showResult( QWidget *ref, bool won )
171{ 171{
172 ResultIndicator *r = new ResultIndicator( ref, 0, WStyle_Customize | WStyle_Tool | WType_TopLevel ); 172 ResultIndicator *r = new ResultIndicator( ref, 0, WStyle_Customize | WStyle_Tool | WType_TopLevel );
173 173
174 r->setAlignment( AlignCenter ); 174 r->setAlignment( AlignCenter );
175 r->setFrameStyle( Sunken|StyledPanel ); 175 r->setFrameStyle( Sunken|StyledPanel );
176 if ( won ) { 176 if ( won ) {
177 r->setText( MineSweep::tr("You won!") ); 177 r->setText( MineSweep::tr("You won!") );
178 r->center(); 178 r->center();
179 r->show(); 179 r->show();
180 r->twoStage = FALSE; 180 r->twoStage = FALSE;
181 r->timerId = r->startTimer(1500); 181 r->timerId = r->startTimer(1500);
182 } else { 182 } else {
183 QPalette p( red ); 183 QPalette p( red );
184 r->setPalette( p ); 184 r->setPalette( p );
185 r->setText( MineSweep::tr("You exploded!") ); 185 r->setText( MineSweep::tr("You exploded!") );
186 r->resize( ref->size() ); 186 r->resize( ref->size() );
187 r->move( ref->mapToGlobal(QPoint(0,0)) ); 187 r->move( ref->mapToGlobal(QPoint(0,0)) );
188 r->show(); 188 r->show();
189 r->twoStage = TRUE; 189 r->twoStage = TRUE;
190 r->timerId =r->startTimer(200); 190 r->timerId =r->startTimer(200);
191 } 191 }
192} 192}
193 193
194void ResultIndicator::center() 194void ResultIndicator::center()
195{ 195{
196 QWidget *w = parentWidget(); 196 QWidget *w = parentWidget();
197 197
198 QPoint pp = w->mapToGlobal( QPoint(0,0) ); 198 QPoint pp = w->mapToGlobal( QPoint(0,0) );
199 QSize s = sizeHint()*3; 199 QSize s = sizeHint()*3;
200 pp = QPoint( pp.x() + w->width()/2 - s.width()/2, 200 pp = QPoint( pp.x() + w->width()/2 - s.width()/2,
201 pp.y() + w->height()/ 2 - s.height()/2 ); 201 pp.y() + w->height()/ 2 - s.height()/2 );
202 202
203 setGeometry( QRect(pp, s) ); 203 setGeometry( QRect(pp, s) );
204 204
205} 205}
206 206
207void ResultIndicator::timerEvent( QTimerEvent *te ) 207void ResultIndicator::timerEvent( QTimerEvent *te )
208{ 208{
209 if ( te->timerId() != timerId ) 209 if ( te->timerId() != timerId )
210 return; 210 return;
211 killTimer( timerId ); 211 killTimer( timerId );
212 if ( twoStage ) { 212 if ( twoStage ) {
213 center(); 213 center();
214 twoStage = FALSE; 214 twoStage = FALSE;
215 timerId = startTimer( 1000 ); 215 timerId = startTimer( 1000 );
216 } else { 216 } else {
217 delete this; 217 delete this;
218 } 218 }
219} 219}
220 220
221 221
222class MineFrame : public QFrame
223{
224public:
225 MineFrame( QWidget *parent, const char *name = 0 )
226 :QFrame( parent, name ) {}
227 void setField( MineField *f ) { field = f; }
228protected:
229 void resizeEvent( QResizeEvent *e ) {
230 field->setAvailableRect( contentsRect());
231 QFrame::resizeEvent(e);
232 }
233private:
234 MineField *field;
235};
236
237
238
222MineSweep::MineSweep( QWidget* parent, const char* name, WFlags f ) 239MineSweep::MineSweep( QWidget* parent, const char* name, WFlags f )
223: QMainWindow( parent, name, f ) 240: QMainWindow( parent, name, f )
224{ 241{
225 srand(::time(0)); 242 srand(::time(0));
226 setCaption( tr("Mine Hunt") ); 243 setCaption( tr("Mine Hunt") );
227 setIcon( Resource::loadPixmap( "minesweep_icon" ) ); 244 setIcon( Resource::loadPixmap( "minesweep_icon" ) );
228 245
229 QPEToolBar *menuToolBar = new QPEToolBar( this ); 246 QPEToolBar *toolBar = new QPEToolBar( this );
230 QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar ); 247 toolBar->setHorizontalStretchable( TRUE );
248
249 QPEMenuBar *menuBar = new QPEMenuBar( toolBar );
231 250
232 QPopupMenu *gameMenu = new QPopupMenu( this ); 251 QPopupMenu *gameMenu = new QPopupMenu( this );
233 gameMenu->insertItem( tr("Beginner"), this, SLOT( beginner() ) ); 252 gameMenu->insertItem( tr("Beginner"), this, SLOT( beginner() ) );
234 gameMenu->insertItem( tr("Advanced"), this, SLOT( advanced() ) ); 253 gameMenu->insertItem( tr("Advanced"), this, SLOT( advanced() ) );
235 gameMenu->insertItem( tr("Expert"), this, SLOT( expert() ) ); 254 gameMenu->insertItem( tr("Expert"), this, SLOT( expert() ) );
236 255
237 menuBar->insertItem( tr("Game"), gameMenu ); 256 menuBar->insertItem( tr("Game"), gameMenu );
238
239 QPEToolBar *toolBar = new QPEToolBar( this );
240 toolBar->setHorizontalStretchable( TRUE );
241 257
242 guessLCD = new QLCDNumber( toolBar ); 258 guessLCD = new QLCDNumber( toolBar );
243 toolBar->setStretchableWidget( guessLCD ); 259 toolBar->setStretchableWidget( guessLCD );
244 260
245 QPalette lcdPal( red ); 261 QPalette lcdPal( red );
246 lcdPal.setColor( QColorGroup::Background, QApplication::palette().active().background() ); 262 lcdPal.setColor( QColorGroup::Background, QApplication::palette().active().background() );
247 lcdPal.setColor( QColorGroup::Button, QApplication::palette().active().button() ); 263 lcdPal.setColor( QColorGroup::Button, QApplication::palette().active().button() );
248 264
249// guessLCD->setPalette( lcdPal ); 265// guessLCD->setPalette( lcdPal );
250 guessLCD->setSegmentStyle( QLCDNumber::Flat ); 266 guessLCD->setSegmentStyle( QLCDNumber::Flat );
251 guessLCD->setFrameStyle( QFrame::NoFrame ); 267 guessLCD->setFrameStyle( QFrame::NoFrame );
252 guessLCD->setNumDigits( 2 ); 268 guessLCD->setNumDigits( 2 );
253 guessLCD->setBackgroundMode( PaletteButton ); 269 guessLCD->setBackgroundMode( PaletteButton );
254 newGameButton = new QPushButton( toolBar ); 270 newGameButton = new QPushButton( toolBar );
255 newGameButton->setPixmap( QPixmap( pix_new ) ); 271 newGameButton->setPixmap( QPixmap( pix_new ) );
256 newGameButton->setFocusPolicy(QWidget::NoFocus); 272 newGameButton->setFocusPolicy(QWidget::NoFocus);
257 connect( newGameButton, SIGNAL(clicked()), this, SLOT(newGame()) ); 273 connect( newGameButton, SIGNAL(clicked()), this, SLOT(newGame()) );
258 274
259 timeLCD = new QLCDNumber( toolBar ); 275 timeLCD = new QLCDNumber( toolBar );
260// timeLCD->setPalette( lcdPal ); 276// timeLCD->setPalette( lcdPal );
261 timeLCD->setSegmentStyle( QLCDNumber::Flat ); 277 timeLCD->setSegmentStyle( QLCDNumber::Flat );
262 timeLCD->setFrameStyle( QFrame::NoFrame ); 278 timeLCD->setFrameStyle( QFrame::NoFrame );
263 timeLCD->setNumDigits( 5 ); // "mm:ss" 279 timeLCD->setNumDigits( 5 ); // "mm:ss"
264 timeLCD->setBackgroundMode( PaletteButton ); 280 timeLCD->setBackgroundMode( PaletteButton );
265 281
266 setToolBarsMovable ( FALSE ); 282 setToolBarsMovable ( FALSE );
267 283
268 addToolBar( menuToolBar );
269 addToolBar( toolBar ); 284 addToolBar( toolBar );
270 285
271 QFrame *mainframe = new QFrame( this ); 286 MineFrame *mainframe = new MineFrame( this );
272 mainframe->setFrameShape( QFrame::Box ); 287 mainframe->setFrameShape( QFrame::Box );
273 mainframe->setFrameShadow( QFrame::Raised ); 288 mainframe->setFrameShadow( QFrame::Raised );
274 mainframe->setMargin(5); 289
275 mainframe->setLineWidth(2); 290 mainframe->setLineWidth(2);
276 QBoxLayout *box = new QVBoxLayout( mainframe ); 291
277 field = new MineField( mainframe ); 292 field = new MineField( mainframe );
278 box->addWidget( field, 0, AlignCenter ); 293 mainframe->setField( field );
279 QFont fnt = field->font(); 294 QFont fnt = field->font();
280 fnt.setBold( TRUE ); 295 fnt.setBold( TRUE );
281 field->setFont( QFont( fnt ) ); 296 field->setFont( QFont( fnt ) );
282 field->setFocus(); 297 field->setFocus();
283 setCentralWidget( mainframe ); 298 setCentralWidget( mainframe );
284 299
285 connect( field, SIGNAL( gameOver( bool ) ), this, SLOT( gameOver( bool ) ) ); 300 connect( field, SIGNAL( gameOver( bool ) ), this, SLOT( gameOver( bool ) ) );
286 connect( field, SIGNAL( mineCount( int ) ), this, SLOT( setCounter( int ) ) ); 301 connect( field, SIGNAL( mineCount( int ) ), this, SLOT( setCounter( int ) ) );
287 connect( field, SIGNAL( gameStarted()), this, SLOT( startPlaying() ) ); 302 connect( field, SIGNAL( gameStarted()), this, SLOT( startPlaying() ) );
288 303
289 timer = new QTimer( this ); 304 timer = new QTimer( this );
290 305
291 connect( timer, SIGNAL( timeout() ), this, SLOT( updateTime() ) ); 306 connect( timer, SIGNAL( timeout() ), this, SLOT( updateTime() ) );
292 307
293 readConfig(); 308 readConfig();
294} 309}
295 310
296MineSweep::~MineSweep() 311MineSweep::~MineSweep()
297{ 312{
298 writeConfig(); 313 writeConfig();
299} 314}
300 315
301void MineSweep::gameOver( bool won ) 316void MineSweep::gameOver( bool won )
302{ 317{
303 field->showMines(); 318 field->showMines();
304 if ( won ) { 319 if ( won ) {
305 newGameButton->setPixmap( QPixmap( happy_xpm ) ); 320 newGameButton->setPixmap( QPixmap( happy_xpm ) );
306 } else { 321 } else {
307 newGameButton->setPixmap( QPixmap( dead_xpm ) ); 322 newGameButton->setPixmap( QPixmap( dead_xpm ) );
308 } 323 }
309 ResultIndicator::showResult( this, won ); 324 ResultIndicator::showResult( this, won );
310 timer->stop(); 325 timer->stop();
311} 326}
312 327
313void MineSweep::newGame() 328void MineSweep::newGame()
314{ 329{
315 newGame(field->level()); 330 newGame(field->level());
316} 331}
317 332
318void MineSweep::newGame(int level) 333void MineSweep::newGame(int level)
319{ 334{
320 timeLCD->display( "0:00" ); 335 timeLCD->display( "0:00" );
321 field->setup( level ); 336 field->setup( level );
322 newGameButton->setPixmap( QPixmap( pix_new ) ); 337 newGameButton->setPixmap( QPixmap( pix_new ) );
323 timer->stop(); 338 timer->stop();
324} 339}
325 340
326void MineSweep::startPlaying() 341void MineSweep::startPlaying()
327{ 342{
328 newGameButton->setPixmap( QPixmap( worried_xpm ) ); 343 newGameButton->setPixmap( QPixmap( worried_xpm ) );
329 starttime = QDateTime::currentDateTime(); 344 starttime = QDateTime::currentDateTime();
330 timer->start( 1000 ); 345 timer->start( 1000 );
331} 346}
332 347
333void MineSweep::beginner() 348void MineSweep::beginner()
334{ 349{
335 newGame(1); 350 newGame(1);
336} 351}
337 352
338void MineSweep::advanced() 353void MineSweep::advanced()
339{ 354{
340 newGame(2); 355 newGame(2);
341} 356}
342 357
343void MineSweep::expert() 358void MineSweep::expert()
344{ 359{
345 newGame(3); 360 newGame(3);
346} 361}
347 362
348void MineSweep::setCounter( int c ) 363void MineSweep::setCounter( int c )
349{ 364{
350 if ( !guessLCD ) 365 if ( !guessLCD )
351 return; 366 return;
352 367
353 guessLCD->display( c ); 368 guessLCD->display( c );
354} 369}
355 370
356void MineSweep::updateTime() 371void MineSweep::updateTime()
357{ 372{
358 if ( !timeLCD ) 373 if ( !timeLCD )
359 return; 374 return;
360 375
361 int s = starttime.secsTo(QDateTime::currentDateTime()); 376 int s = starttime.secsTo(QDateTime::currentDateTime());
362 if ( s/60 > 99 ) 377 if ( s/60 > 99 )
363 timeLCD->display( "-----" ); 378 timeLCD->display( "-----" );
364 else 379 else
365 timeLCD->display( QString().sprintf("%2d:%02d",s/60,s%60) ); 380 timeLCD->display( QString().sprintf("%2d:%02d",s/60,s%60) );
366} 381}
367 382
368void MineSweep::writeConfig() const 383void MineSweep::writeConfig() const
369{ 384{
370 Config cfg("MineSweep"); 385 Config cfg("MineSweep");
371 cfg.setGroup("Panel"); 386 cfg.setGroup("Panel");
372 cfg.writeEntry("Time", 387 cfg.writeEntry("Time",
373 timer->isActive() ? starttime.secsTo(QDateTime::currentDateTime()) : -1); 388 timer->isActive() ? starttime.secsTo(QDateTime::currentDateTime()) : -1);
374 field->writeConfig(cfg); 389 field->writeConfig(cfg);
diff --git a/noncore/games/snake/interface.h b/noncore/games/snake/interface.h
index 30c7f84..454d4ee 100644
--- a/noncore/games/snake/interface.h
+++ b/noncore/games/snake/interface.h
@@ -1,69 +1,69 @@
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 <qmainwindow.h> 20#include <qmainwindow.h>
21#include <qcanvas.h> 21#include <qcanvas.h>
22#include <qlabel.h> 22#include <qlabel.h>
23 23
24#include "snake.h" 24#include "snake.h"
25#include "target.h" 25#include "target.h"
26#include "obstacle.h" 26#include "obstacle.h"
27 27
28// class QCanvas; 28// class QCanvas;
29 29
30class SnakeGame : public QMainWindow { 30class SnakeGame : public QMainWindow {
31 Q_OBJECT 31 Q_OBJECT
32 32
33public: 33public:
34 SnakeGame(QWidget* parent=0, const char* name=0, WFlags f=0); 34 SnakeGame(QWidget* parent=0, const char* name=0, WFlags f=0);
35 ~SnakeGame(); 35 ~SnakeGame();
36 36
37 void clear(); 37 void clear();
38 void createTargets(); 38 void createTargets();
39 void welcomescreen();
40 39
41protected: 40protected:
42 virtual void keyPressEvent(QKeyEvent*); 41 virtual void keyPressEvent(QKeyEvent*);
43 virtual void resizeEvent(QResizeEvent *e); 42 virtual void resizeEvent(QResizeEvent *e);
44 43
45signals: 44signals:
46 void moveFaster(); 45 void moveFaster();
47 46
48private slots: 47private slots:
49 void newGame(); 48 void newGame();
50 void gameOver(); 49 void gameOver();
51 void wait(); 50 void wait();
52 void levelUp(); 51 void levelUp();
53 void scoreInc(); 52 void scoreInc();
53 void welcomescreen();
54 54
55private: 55private:
56 void showScore(int); 56 void showScore(int);
57 QCanvasView* cv; 57 QCanvasView* cv;
58 QLabel* scorelabel; 58 QLabel* scorelabel;
59 QCanvas canvas; 59 QCanvas canvas;
60 QTimer* pauseTimer; 60 QTimer* pauseTimer;
61 Snake* snake; 61 Snake* snake;
62 int last; 62 int last;
63 int level; 63 int level;
64 int stage; 64 int stage;
65 int targetamount; 65 int targetamount;
66 int notargets; 66 int notargets;
67 bool waitover; 67 bool waitover;
68 bool gamestopped; 68 bool gamestopped;
69}; 69};
diff --git a/noncore/games/snake/obstacle.cpp b/noncore/games/snake/obstacle.cpp
index 2d07fe7..4bdefa5 100644
--- a/noncore/games/snake/obstacle.cpp
+++ b/noncore/games/snake/obstacle.cpp
@@ -1,51 +1,70 @@
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 "obstacle.h" 21#include "obstacle.h"
22#include "codes.h" 22#include "codes.h"
23 23
24#include <qpe/resource.h> 24#include <qpe/resource.h>
25 25
26Obstacle::Obstacle(QCanvas* canvas, int x, int y) 26
27 : QCanvasSprite(0, canvas) 27
28Obstacle::Obstacle(QCanvas* canvas, int y)
29 : QCanvasSprite(0,canvas)
28{ 30{
29 newObstacle(x, y); 31 newObstacle(y);
30} 32}
31 33
32void Obstacle::newObstacle(int x, int y) 34void Obstacle::newObstacle(int y)
33{ 35{
34 QCanvasPixmapArray* obstaclearray = new QCanvasPixmapArray(Resource::findPixmap("snake/wall.png")); 36 QPixmap obstaclePix( Resource::findPixmap("snake/wall.png") );
35 37
38 if ( obstaclePix.width() > canvas()->width()*3/5 ) {
39 int w = canvas()->width()*3/5;
40 w = w - w % 16;
41 obstaclePix.resize( w, obstaclePix.height() );
42 }
43
44 QList<QPixmap> pixl;
45 pixl.append( &obstaclePix );
46
47 QPoint nullp;
48 QList<QPoint> pl;
49 pl.append( &nullp );
50
51 QCanvasPixmapArray* obstaclearray = new QCanvasPixmapArray(pixl, pl);
36 setSequence(obstaclearray); 52 setSequence(obstaclearray);
37 53
54 int x = ( canvas()->width() - obstaclePix.width() )/2;
55 x = x - x % 16;
56 y = y - y % 16;
38 move(x, y); 57 move(x, y);
39 58 setZ( -100 );
40 show(); 59 show();
41 canvas()->update(); 60 canvas()->update();
42} 61}
43 62
44int Obstacle::rtti() const 63int Obstacle::rtti() const
45{ 64{
46 return obstacle_rtti; 65 return obstacle_rtti;
47} 66}
48 67
49Obstacle::~Obstacle() 68Obstacle::~Obstacle()
50{ 69{
51} 70}
diff --git a/noncore/games/snake/obstacle.h b/noncore/games/snake/obstacle.h
index 838917f..b3c7846 100644
--- a/noncore/games/snake/obstacle.h
+++ b/noncore/games/snake/obstacle.h
@@ -1,30 +1,30 @@
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 <qcanvas.h> 20#include <qcanvas.h>
21 21
22class Obstacle : public QCanvasSprite 22class Obstacle : public QCanvasSprite
23{ 23{
24 24
25public: 25public:
26 Obstacle(QCanvas*, int x, int y); 26 Obstacle(QCanvas*, int y);
27 ~Obstacle(); 27 ~Obstacle();
28 void newObstacle(int x, int y); 28 void newObstacle(int y);
29 int rtti() const; 29 int rtti() const;
30}; 30};
diff --git a/noncore/games/solitaire/canvascard.cpp b/noncore/games/solitaire/canvascard.cpp
index ae3c859..7c4a5ba 100644
--- a/noncore/games/solitaire/canvascard.cpp
+++ b/noncore/games/solitaire/canvascard.cpp
@@ -1,282 +1,313 @@
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 "cardgame.h" 21#include "cardgame.h"
22#include "canvascard.h" 22#include "canvascard.h"
23 23
24#include <qpe/resource.h> 24#include <qpe/resource.h>
25 25
26#include <qpainter.h> 26#include <qpainter.h>
27#include <qimage.h> 27#include <qimage.h>
28#include <qpaintdevice.h> 28#include <qpaintdevice.h>
29#include <qbitmap.h> 29#include <qbitmap.h>
30#include <qgfx_qws.h> // Needed to get the device's width
30 31
31#include <math.h> 32#include <math.h>
32 33
33#if defined( QT_QWS_CASSIOPEIA ) 34#if defined( QT_QWS_CASSIOPEIA )
34#define SLOW_HARDWARE 35#define SLOW_HARDWARE
35#endif 36#endif
36 37
37// Seems to be fast enough to me even without Transformations in the library 38// Seems to be fast enough to me even without Transformations in the library
38//#if defined( QT_NO_TRANSFORMATIONS ) && defined( QT_QWS_IPAQ ) 39//#if defined( QT_NO_TRANSFORMATIONS ) && defined( QT_QWS_IPAQ )
39//#define SLOW_HARDWARE 40//#define SLOW_HARDWARE
40//#endif 41//#endif
41 42
42 43
43QBitmap *Create180RotatedBitmap(QBitmap *srcBitmap) 44QBitmap *Create180RotatedBitmap(QBitmap *srcBitmap)
44{ 45{
45#ifdef QT_NO_TRANSFORMATIONS 46#ifdef QT_NO_TRANSFORMATIONS
46 int w = srcBitmap->width(); 47 int w = srcBitmap->width();
47 int h = srcBitmap->height(); 48 int h = srcBitmap->height();
48 QBitmap *dstBitmap = new QBitmap( w, h ); 49 QBitmap *dstBitmap = new QBitmap( w, h );
49 // ### this is very poorly implemented and probably could be much faster 50 // ### this is very poorly implemented and probably could be much faster
50 for (int i = 0; i < w; i++) 51 for (int i = 0; i < w; i++)
51 for (int j = 0; j < h; j++) 52 for (int j = 0; j < h; j++)
52 bitBlt( dstBitmap, i, j, srcBitmap, w - i - 1, h - j - 1, 1, 1 ); 53 bitBlt( dstBitmap, i, j, srcBitmap, w - i - 1, h - j - 1, 1, 1 );
53 return dstBitmap; 54 return dstBitmap;
54#else 55#else
55 QWMatrix m; 56 QWMatrix m;
56 m.rotate( 180.0 ); 57 m.rotate( 180.0 );
57 return new QBitmap( srcBitmap->xForm( m ) ); 58 return new QBitmap( srcBitmap->xForm( m ) );
58#endif 59#endif
59} 60}
60 61
61 62
62QPixmap *CreateScaledPixmap(QPixmap *srcPixmap, double scaleX, double scaleY) 63QPixmap *CreateScaledPixmap(QPixmap *srcPixmap, double scaleX, double scaleY)
63{ 64{
64#ifdef QT_NO_TRANSFORMATIONS 65#ifdef QT_NO_TRANSFORMATIONS
65 int w = srcPixmap->width(); 66 int w = srcPixmap->width();
66 int h = srcPixmap->height(); 67 int h = srcPixmap->height();
67 int newW = (int)(w * scaleX); 68 int newW = (int)(w * scaleX);
68 int newH = (int)(h * scaleY); 69 int newH = (int)(h * scaleY);
69 QPixmap *dstPixmap = new QPixmap( newW, newH ); 70 QPixmap *dstPixmap = new QPixmap( newW, newH );
70 // ### this is very poorly implemented and probably could be much faster 71 // ### this is very poorly implemented and probably could be much faster
71 for (int i = 0; i < newW; i++) { 72 for (int i = 0; i < newW; i++) {
72 int srcX = w * i / newW; 73 int srcX = w * i / newW;
73 if (newH == h) { 74 if (newH == h) {
74 // Optimise for scaleing in the X-axis only 75 // Optimise for scaleing in the X-axis only
75 bitBlt( dstPixmap, i, 0, srcPixmap, srcX, 0, 1, h ); 76 bitBlt( dstPixmap, i, 0, srcPixmap, srcX, 0, 1, h );
76 } else { 77 } else {
77 for (int j = 0; j < newH; j++) { 78 for (int j = 0; j < newH; j++) {
78 int srcY = h * j / newH; 79 int srcY = h * j / newH;
79 bitBlt( dstPixmap, i, j, srcPixmap, srcX, srcY, 1, 1 ); 80 bitBlt( dstPixmap, i, j, srcPixmap, srcX, srcY, 1, 1 );
80 } 81 }
81 } 82 }
82 } 83 }
83 return dstPixmap; 84 return dstPixmap;
84#else 85#else
85 QWMatrix s; 86 QWMatrix s;
86 s.scale( scaleX, scaleY ); 87 s.scale( scaleX, scaleY );
87 return new QPixmap( srcPixmap->xForm( s ) ); 88 return new QPixmap( srcPixmap->xForm( s ) );
88#endif 89#endif
89} 90}
90 91
91 92
92// Initialise static member variables to NULL 93// Initialise static member variables to NULL
93QPixmap *CanvasCard::cardsFaces = NULL; 94QPixmap *CanvasCard::cardsFaces = NULL;
94QPixmap *CanvasCard::cardsBacks = NULL; 95QPixmap *CanvasCard::cardsBacks = NULL;
95QBitmap *CanvasCard::cardsChars = NULL; 96QBitmap *CanvasCard::cardsChars = NULL;
96QBitmap *CanvasCard::cardsSuits = NULL; 97QBitmap *CanvasCard::cardsSuits = NULL;
97QBitmap *CanvasCard::cardsCharsUpsideDown = NULL; 98QBitmap *CanvasCard::cardsCharsUpsideDown = NULL;
98QBitmap *CanvasCard::cardsSuitsUpsideDown = NULL; 99QBitmap *CanvasCard::cardsSuitsUpsideDown = NULL;
99 100
100 101
101CanvasCard::CanvasCard( eValue v, eSuit s, bool f, QCanvas *canvas ) : 102CanvasCard::CanvasCard( eValue v, eSuit s, bool f, QCanvas *canvas ) :
102 Card(v, s, f), QCanvasRectangle( 0, 0, 1, 1, canvas ), cardBack(1), scaleX(1.0), scaleY(1.0) 103 Card(v, s, f), QCanvasRectangle( 0, 0, 1, 1, canvas ), cardBack(1), scaleX(1.0), scaleY(1.0)
103{ 104{
104 if ( !cardsFaces ) { 105 if ( !cardsFaces ) {
105 cardsFaces = new QPixmap( Resource::loadPixmap( "cards/card_face" ) ); 106 if ( qt_screen->deviceWidth() < 200 ) {
106 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001" ) ); 107 cardsFaces = new QPixmap( Resource::loadPixmap( "cards/card_face_small" ) );
107 cardsChars = new QBitmap( Resource::loadBitmap( "cards/card_chars" ) ); 108 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001_small" ) );
108 cardsSuits = new QBitmap( Resource::loadBitmap( "cards/card_suits" ) ); 109 cardsChars = new QBitmap( Resource::loadBitmap( "cards/card_chars_small" ) );
110 cardsSuits = new QBitmap( Resource::loadBitmap( "cards/card_suits_small" ) );
111 } else {
112 cardsFaces = new QPixmap( Resource::loadPixmap( "cards/card_face" ) );
113 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001" ) );
114 cardsChars = new QBitmap( Resource::loadBitmap( "cards/card_chars" ) );
115 cardsSuits = new QBitmap( Resource::loadBitmap( "cards/card_suits" ) );
116 }
109 cardsCharsUpsideDown = Create180RotatedBitmap( cardsChars ); 117 cardsCharsUpsideDown = Create180RotatedBitmap( cardsChars );
110 cardsSuitsUpsideDown = Create180RotatedBitmap( cardsSuits ); 118 cardsSuitsUpsideDown = Create180RotatedBitmap( cardsSuits );
111 } 119 }
112 xOff = cardsFaces->width() / 2; 120 xOff = cardsFaces->width() / 2;
113 yOff = cardsFaces->height() / 2; 121 yOff = cardsFaces->height() / 2;
114 setSize( cardsFaces->width(), cardsFaces->height() ); 122 setSize( cardsFaces->width(), cardsFaces->height() );
115 setPen( NoPen ); 123 setPen( NoPen );
116 flipping = FALSE; 124 flipping = FALSE;
117} 125}
118 126
119 127
120void CanvasCard::setCardBack(int b) 128void CanvasCard::setCardBack(int b)
121{ 129{
122 if ( cardBack != b ) { 130 if ( cardBack != b ) {
123 131
124 cardBack = b; 132 cardBack = b;
125 133
126 if ( cardsBacks ) 134 if ( cardsBacks )
127 delete cardsBacks; 135 delete cardsBacks;
128 136
129 switch (cardBack) { 137 if ( qt_screen->deviceWidth() < 200 ) {
130 case 0: 138 switch (cardBack) {
131 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001" ) ); break; 139 case 0:
132 case 1: 140 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001_small" ) ); break;
133 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0002" ) ); break; 141 case 1:
134 case 2: 142 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0002_small" ) ); break;
135 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0003" ) ); break; 143 case 2:
136 case 3: 144 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0003_small" ) ); break;
137 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0004" ) ); break; 145 case 3:
138 case 4: 146 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0004_small" ) ); break;
139 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0005" ) ); break; 147 case 4:
148 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0005_small" ) ); break;
149 }
150 } else {
151 switch (cardBack) {
152 case 0:
153 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001" ) ); break;
154 case 1:
155 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0002" ) ); break;
156 case 2:
157 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0003" ) ); break;
158 case 3:
159 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0004" ) ); break;
160 case 4:
161 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0005" ) ); break;
162 }
140 } 163 }
141 164
142 if ( !isFacing() ) 165 if ( !isFacing() )
143 redraw(); 166 redraw();
144 } 167 }
145} 168}
146 169
147 170
148void CanvasCard::draw(QPainter &painter) 171void CanvasCard::draw(QPainter &painter)
149{ 172{
150 int ix = (int)x(), iy = (int)y(); 173 int ix = (int)x(), iy = (int)y();
151 174
152 QPainter *p = &painter; 175 QPainter *p = &painter;
153 QPixmap *unscaledCard = NULL; 176 QPixmap *unscaledCard = NULL;
154 177
155 if ((scaleX <= 0.98) || (scaleY <= 0.98)) 178 if ((scaleX <= 0.98) || (scaleY <= 0.98))
156 { 179 {
157 p = new QPainter(); 180 p = new QPainter();
158 unscaledCard = new QPixmap( cardsFaces->width(), cardsFaces->height() ); 181 unscaledCard = new QPixmap( cardsFaces->width(), cardsFaces->height() );
159 p->begin(unscaledCard); 182 p->begin(unscaledCard);
160 ix = 0; 183 ix = 0;
161 iy = 0; 184 iy = 0;
162 } 185 }
163 186
164 if ( isFacing() ) { 187 if ( isFacing() ) {
165 188
166/* 189/*
167 // Now add the joker and card backs to the list of pixmaps 190 // Now add the joker and card backs to the list of pixmaps
168 QPixmap *CardsBack = new QPixmap( Resource::loadPixmap( "cards/card_joker.png" ) ); 191 QPixmap *CardsBack = new QPixmap( Resource::loadPixmap( "cards/card_joker.png" ) );
169 QPoint *newBackHotspot = new QPoint( 0, 0 ); 192 QPoint *newBackHotspot = new QPoint( 0, 0 );
170 pixmaps->append((const QPixmap *)CardsBack); 193 pixmaps->append((const QPixmap *)CardsBack);
171 hotspots->append((const QPoint *)newBackHotspot); 194 hotspots->append((const QPoint *)newBackHotspot);
172*/ 195*/
173 196
174 int w = cardsFaces->width(), h = cardsFaces->height(); 197 int w = cardsFaces->width(), h = cardsFaces->height();
175 198
176 //p->setBrush( NoBrush ); 199 //p->setBrush( NoBrush );
177 p->setBrush( QColor( 0xFF, 0xFF, 0xFF ) ); 200 p->setBrush( QColor( 0xFF, 0xFF, 0xFF ) );
178 201
179 if ( isRed() == TRUE ) 202 if ( isRed() == TRUE )
180 p->setPen( QColor( 0xFF, 0, 0 ) ); 203 p->setPen( QColor( 0xFF, 0, 0 ) );
181 else 204 else
182 p->setPen( QColor( 0, 0, 0 ) ); 205 p->setPen( QColor( 0, 0, 0 ) );
183 206
184 p->drawPixmap( ix + 0, iy + 0, *cardsFaces ); 207 if ( qt_screen->deviceWidth() < 200 ) {
185 p->drawPixmap( ix + 4, iy + 4, *cardsChars, 7*(getValue()-1), 0, 7, 7 ); 208 p->drawPixmap( ix + 0, iy + 0, *cardsFaces );
186 p->drawPixmap( ix + 12, iy + 4, *cardsSuits, 7*(getSuit()-1), 0, 7, 8 ); 209 p->drawPixmap( ix + 3, iy + 3, *cardsChars, 5*(getValue()-1), 0, 5, 6 );
187 p->drawPixmap( ix + w-4-7, iy + h-4-7, *cardsCharsUpsideDown, 7*(12-getValue()+1), 0, 7, 7 ); 210 p->drawPixmap( ix + 11, iy + 3, *cardsSuits, 5*(getSuit()-1), 0, 5, 6 );
188 p->drawPixmap( ix + w-12-7, iy + h-5-7, *cardsSuitsUpsideDown, 7*(3-getSuit()+1), 0, 7, 8 ); 211 p->drawPixmap( ix + w-3-5, iy + h-3-6, *cardsCharsUpsideDown, 5*(12-getValue()+1), 0, 5, 6 );
212 p->drawPixmap( ix + w-11-5, iy + h-3-6, *cardsSuitsUpsideDown, 5*(3-getSuit()+1), 0, 5, 6 );
213 } else {
214 p->drawPixmap( ix + 0, iy + 0, *cardsFaces );
215 p->drawPixmap( ix + 4, iy + 4, *cardsChars, 7*(getValue()-1), 0, 7, 7 );
216 p->drawPixmap( ix + 12, iy + 4, *cardsSuits, 7*(getSuit()-1), 0, 7, 8 );
217 p->drawPixmap( ix + w-4-7, iy + h-4-7, *cardsCharsUpsideDown, 7*(12-getValue()+1), 0, 7, 7 );
218 p->drawPixmap( ix + w-12-7, iy + h-5-7, *cardsSuitsUpsideDown, 7*(3-getSuit()+1), 0, 7, 8 );
219 }
189 220
190 } else { 221 } else {
191 222
192 p->drawPixmap( ix, iy, *cardsBacks ); 223 p->drawPixmap( ix, iy, *cardsBacks );
193 224
194 } 225 }
195 226
196 if (p != &painter) 227 if (p != &painter)
197 { 228 {
198 p->end(); 229 p->end();
199 QPixmap *scaledCard = CreateScaledPixmap( unscaledCard, scaleX, scaleY ); 230 QPixmap *scaledCard = CreateScaledPixmap( unscaledCard, scaleX, scaleY );
200 int xoff = scaledCard->width() / 2; 231 int xoff = scaledCard->width() / 2;
201 int yoff = scaledCard->height() / 2; 232 int yoff = scaledCard->height() / 2;
202 painter.drawPixmap( (int)x() + xOff - xoff, (int)y() + yOff - yoff, *scaledCard ); 233 painter.drawPixmap( (int)x() + xOff - xoff, (int)y() + yOff - yoff, *scaledCard );
203 delete p; 234 delete p;
204 delete unscaledCard; 235 delete unscaledCard;
205 delete scaledCard; 236 delete scaledCard;
206 } 237 }
207} 238}
208 239
209 240
210static const double flipLift = 1.5; 241static const double flipLift = 1.5;
211 242
212 243
213void CanvasCard::flipTo(int x2, int y2, int steps) 244void CanvasCard::flipTo(int x2, int y2, int steps)
214{ 245{
215 flipSteps = steps; 246 flipSteps = steps;
216 247
217#ifdef SLOW_HARDWARE 248#ifdef SLOW_HARDWARE
218 move(x2,y2); 249 move(x2,y2);
219 Card::flipTo(x2,y2,steps); 250 Card::flipTo(x2,y2,steps);
220#else 251#else
221 int x1 = (int)x(); 252 int x1 = (int)x();
222 int y1 = (int)y(); 253 int y1 = (int)y();
223 double dx = x2 - x1; 254 double dx = x2 - x1;
224 double dy = y2 - y1; 255 double dy = y2 - y1;
225 256
226 flipping = TRUE; 257 flipping = TRUE;
227 destX = x2; 258 destX = x2;
228 destY = y2; 259 destY = y2;
229 animSteps = flipSteps; 260 animSteps = flipSteps;
230 setVelocity(dx/animSteps, dy/animSteps-flipLift); 261 setVelocity(dx/animSteps, dy/animSteps-flipLift);
231 setAnimated(TRUE); 262 setAnimated(TRUE);
232#endif 263#endif
233} 264}
234 265
235 266
236void CanvasCard::advance(int stage) 267void CanvasCard::advance(int stage)
237{ 268{
238 if ( stage==1 ) { 269 if ( stage==1 ) {
239 if ( animSteps-- <= 0 ) { 270 if ( animSteps-- <= 0 ) {
240 scaleX = 1.0; 271 scaleX = 1.0;
241 scaleY = 1.0; 272 scaleY = 1.0;
242 flipping = FALSE; 273 flipping = FALSE;
243 setVelocity(0,0); 274 setVelocity(0,0);
244 setAnimated(FALSE); 275 setAnimated(FALSE);
245 move(destX,destY); // exact 276 move(destX,destY); // exact
246 } else { 277 } else {
247 if ( flipping ) { 278 if ( flipping ) {
248 if ( animSteps > flipSteps / 2 ) { 279 if ( animSteps > flipSteps / 2 ) {
249 // animSteps = flipSteps .. flipSteps/2 (flip up) -> 1..0 280 // animSteps = flipSteps .. flipSteps/2 (flip up) -> 1..0
250 scaleX = ((double)animSteps/flipSteps-0.5)*2; 281 scaleX = ((double)animSteps/flipSteps-0.5)*2;
251 } else { 282 } else {
252 // animSteps = flipSteps/2 .. 0 (flip down) -> 0..1 283 // animSteps = flipSteps/2 .. 0 (flip down) -> 0..1
253 scaleX = 1-((double)animSteps/flipSteps)*2; 284 scaleX = 1-((double)animSteps/flipSteps)*2;
254 } 285 }
255 if ( animSteps == flipSteps / 2-1 ) { 286 if ( animSteps == flipSteps / 2-1 ) {
256 setYVelocity(yVelocity()+flipLift*2); 287 setYVelocity(yVelocity()+flipLift*2);
257 setFace( !isFacing() ); 288 setFace( !isFacing() );
258 } 289 }
259 } 290 }
260 } 291 }
261 } 292 }
262 QCanvasRectangle::advance(stage); 293 QCanvasRectangle::advance(stage);
263} 294}
264 295
265 296
266void CanvasCard::animatedMove(int x2, int y2, int steps) 297void CanvasCard::animatedMove(int x2, int y2, int steps)
267{ 298{
268 destX = x2; 299 destX = x2;
269 destY = y2; 300 destY = y2;
270 301
271 double x1 = x(), y1 = y(), dx = x2 - x1, dy = y2 - y1; 302 double x1 = x(), y1 = y(), dx = x2 - x1, dy = y2 - y1;
272 303
273 // Ensure a good speed 304 // Ensure a good speed
274 while ( fabs(dx/steps)+fabs(dy/steps) < 5.0 && steps > 4 ) 305 while ( fabs(dx/steps)+fabs(dy/steps) < 5.0 && steps > 4 )
275 steps--; 306 steps--;
276 307
277 setAnimated(TRUE); 308 setAnimated(TRUE);
278 setVelocity(dx/steps, dy/steps); 309 setVelocity(dx/steps, dy/steps);
279 310
280 animSteps = steps; 311 animSteps = steps;
281} 312}
282 313
diff --git a/noncore/games/solitaire/canvasshapes.cpp b/noncore/games/solitaire/canvasshapes.cpp
index 28d0b4e..6ccd4a4 100644
--- a/noncore/games/solitaire/canvasshapes.cpp
+++ b/noncore/games/solitaire/canvasshapes.cpp
@@ -1,92 +1,114 @@
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 <qpainter.h> 20#include <qpainter.h>
21#include <qcanvas.h> 21#include <qcanvas.h>
22#include <qgfx_qws.h>
22#include "canvasshapes.h" 23#include "canvasshapes.h"
23 24
24 25
25CanvasRoundRect::CanvasRoundRect(int x, int y, QCanvas *canvas) : 26CanvasRoundRect::CanvasRoundRect(int x, int y, QCanvas *canvas) :
26 QCanvasRectangle( x, y, 23, 36, canvas) 27 QCanvasRectangle( x, y, ( qt_screen->deviceWidth() < 200 ) ? 20 : 23, ( qt_screen->deviceWidth() < 200 ) ? 27 : 36, canvas)
27{ 28{
28 setZ(0); 29 setZ(0);
29 show(); 30 show();
30} 31}
31 32
32 33
33void CanvasRoundRect::redraw() 34void CanvasRoundRect::redraw()
34{ 35{
35 hide(); 36 hide();
36 show(); 37 show();
37} 38}
38 39
39 40
40void CanvasRoundRect::drawShape(QPainter &p) 41void CanvasRoundRect::drawShape(QPainter &p)
41{ 42{
42 p.drawRoundRect( (int)x(), (int)y(), 23, 36); 43 if ( qt_screen->deviceWidth() < 200 )
44 p.drawRoundRect( (int)x() + 1, (int)y() + 1, 18, 25);
45 else
46 p.drawRoundRect( (int)x(), (int)y(), 23, 36);
43} 47}
44 48
45 49
46CanvasCircleOrCross::CanvasCircleOrCross(int x, int y, QCanvas *canvas) : 50CanvasCircleOrCross::CanvasCircleOrCross(int x, int y, QCanvas *canvas) :
47 QCanvasRectangle( x, y, 21, 21, canvas), circleShape(TRUE) 51 QCanvasRectangle( x, y, 21, 21, canvas), circleShape(TRUE)
48{ 52{
49 show(); 53 show();
50} 54}
51 55
52 56
53void CanvasCircleOrCross::redraw() 57void CanvasCircleOrCross::redraw()
54{ 58{
55 hide(); 59 hide();
56 show(); 60 show();
57} 61}
58 62
59 63
60void CanvasCircleOrCross::setCircle() 64void CanvasCircleOrCross::setCircle()
61{ 65{
62 circleShape = TRUE; 66 circleShape = TRUE;
63 redraw(); 67 redraw();
64} 68}
65 69
66 70
67void CanvasCircleOrCross::setCross() 71void CanvasCircleOrCross::setCross()
68{ 72{
69 circleShape = FALSE; 73 circleShape = FALSE;
70 redraw(); 74 redraw();
71} 75}
72 76
73 77
74void CanvasCircleOrCross::drawShape(QPainter &p) 78void CanvasCircleOrCross::drawShape(QPainter &p)
75{ 79{
76 int x1 = (int)x(), y1 = (int)y(); 80 if ( qt_screen->deviceWidth() < 200 ) {
77 // Green circle 81 int x1 = (int)x(), y1 = (int)y();
78 if (circleShape == TRUE) { 82 // Green circle
79 p.setPen( QPen( QColor(0x10, 0xE0, 0x10), 1 ) ); 83 if (circleShape == TRUE) {
80 p.drawEllipse( x1 - 1, y1 - 1, 21, 21); 84 p.setPen( QPen( QColor(0x10, 0xE0, 0x10), 1 ) );
81 p.drawEllipse( x1 - 1, y1 - 0, 21, 19); 85 p.drawEllipse( x1 - 1, y1 - 1, 17, 17);
82 p.drawEllipse( x1 + 0, y1 + 0, 19, 19); 86 p.drawEllipse( x1 - 1, y1 - 0, 17, 15);
83 p.drawEllipse( x1 + 1, y1 + 0, 17, 19); 87 p.drawEllipse( x1 + 0, y1 + 0, 15, 15);
84 p.drawEllipse( x1 + 1, y1 + 1, 17, 17); 88 p.drawEllipse( x1 + 1, y1 + 0, 13, 15);
85 // Red cross 89 p.drawEllipse( x1 + 1, y1 + 1, 13, 13);
90 // Red cross
91 } else {
92 p.setPen( QPen( QColor(0xE0, 0x10, 0x10), 4 ) );
93 p.drawLine( x1, y1, x1 + 14, y1 + 14);
94 p.drawLine( x1 + 14, y1, x1, y1 + 14);
95 }
86 } else { 96 } else {
87 p.setPen( QPen( QColor(0xE0, 0x10, 0x10), 5 ) ); 97 int x1 = (int)x(), y1 = (int)y();
88 p.drawLine( x1, y1, x1 + 20, y1 + 20); 98 // Green circle
89 p.drawLine( x1 + 20, y1, x1, y1 + 20); 99 if (circleShape == TRUE) {
100 p.setPen( QPen( QColor(0x10, 0xE0, 0x10), 1 ) );
101 p.drawEllipse( x1 - 1, y1 - 1, 21, 21);
102 p.drawEllipse( x1 - 1, y1 - 0, 21, 19);
103 p.drawEllipse( x1 + 0, y1 + 0, 19, 19);
104 p.drawEllipse( x1 + 1, y1 + 0, 17, 19);
105 p.drawEllipse( x1 + 1, y1 + 1, 17, 17);
106 // Red cross
107 } else {
108 p.setPen( QPen( QColor(0xE0, 0x10, 0x10), 5 ) );
109 p.drawLine( x1, y1, x1 + 20, y1 + 20);
110 p.drawLine( x1 + 20, y1, x1, y1 + 20);
111 }
90 } 112 }
91} 113}
92 114
diff --git a/noncore/games/solitaire/freecellcardgame.cpp b/noncore/games/solitaire/freecellcardgame.cpp
index e82afd4..98415aa 100644
--- a/noncore/games/solitaire/freecellcardgame.cpp
+++ b/noncore/games/solitaire/freecellcardgame.cpp
@@ -1,137 +1,142 @@
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 <qgfx_qws.h>
20#include "freecellcardgame.h" 21#include "freecellcardgame.h"
21 22
22 23
23extern int highestZ; 24extern int highestZ;
24int numberOfFreeCells = 4; 25int numberOfFreeCells = 4;
25 26
26 27
27FreecellCardGame::FreecellCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent) 28FreecellCardGame::FreecellCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent)
28{ 29{
29 numberOfFreeCells = 4; 30 numberOfFreeCells = 4;
30 highestZ = 0; 31 highestZ = 0;
31 32
33 int spaceBetweenPiles = ( qt_screen->deviceWidth() < 200 ) ? 21 : 28;
34 int xOrigin = ( qt_screen->deviceWidth() < 200 ) ? 0 : 5;
35 int spacing = ( qt_screen->deviceWidth() < 200 ) ? 0 : 0;
36
32 for (int i = 0; i < 4; i++) { 37 for (int i = 0; i < 4; i++) {
33 freecellPiles[i] = new FreecellFreecellPile( 5 + i * 28, 10, canvas() ); 38 freecellPiles[i] = new FreecellFreecellPile( xOrigin + i * spaceBetweenPiles, 10, canvas() );
34 addCardPile(freecellPiles[i]); 39 addCardPile(freecellPiles[i]);
35 } 40 }
36 for (int i = 0; i < 4; i++) { 41 for (int i = 0; i < 4; i++) {
37 discardPiles[i] = new FreecellDiscardPile( 125 + i * 28, 10, canvas() ); 42 discardPiles[i] = new FreecellDiscardPile( xOrigin + spacing + 6 + (i + 4) * spaceBetweenPiles, 10, canvas() );
38 addCardPile(discardPiles[i]); 43 addCardPile(discardPiles[i]);
39 } 44 }
40 for (int i = 0; i < 8; i++) { 45 for (int i = 0; i < 8; i++) {
41 workingPiles[i] = new FreecellWorkingPile( 10 + i * 28, 50, canvas() ); 46 workingPiles[i] = new FreecellWorkingPile( xOrigin + spacing + 2 + i * spaceBetweenPiles, 50, canvas() );
42 addCardPile(workingPiles[i]); 47 addCardPile(workingPiles[i]);
43 } 48 }
44} 49}
45 50
46 51
47void FreecellCardGame::deal(void) 52void FreecellCardGame::deal(void)
48{ 53{
49 highestZ = 1; 54 highestZ = 1;
50 55
51 beginDealing(); 56 beginDealing();
52 57
53 for (int i = 0; i < 52; i++) { 58 for (int i = 0; i < 52; i++) {
54 Card *card = cards[i]; 59 Card *card = cards[i];
55 card->setFace( TRUE ); 60 card->setFace( TRUE );
56 card->setPos( 0, 0, highestZ ); 61 card->setPos( 0, 0, highestZ );
57 card->setCardPile( workingPiles[i%8] ); 62 card->setCardPile( workingPiles[i%8] );
58 workingPiles[i%8]->addCardToTop( card ); 63 workingPiles[i%8]->addCardToTop( card );
59 card->move( workingPiles[i%8]->getCardPos( card ) ); 64 card->move( workingPiles[i%8]->getCardPos( card ) );
60 card->showCard(); 65 card->showCard();
61 highestZ++; 66 highestZ++;
62 } 67 }
63 68
64 endDealing(); 69 endDealing();
65} 70}
66 71
67 72
68bool FreecellCardGame::mousePressCard( Card *c, QPoint p ) 73bool FreecellCardGame::mousePressCard( Card *c, QPoint p )
69{ 74{
70 Q_UNUSED(p); 75 Q_UNUSED(p);
71 76
72 if ( !c->getCardPile()->isAllowedToBeMoved(c) ) { 77 if ( !c->getCardPile()->isAllowedToBeMoved(c) ) {
73 moving = NULL; 78 moving = NULL;
74 return TRUE; 79 return TRUE;
75 } 80 }
76 81
77 return FALSE; 82 return FALSE;
78} 83}
79 84
80 85
81void FreecellCardGame::readConfig( Config& cfg ) 86void FreecellCardGame::readConfig( Config& cfg )
82{ 87{
83 cfg.setGroup("GameState"); 88 cfg.setGroup("GameState");
84 89
85 // Create Cards, but don't shuffle or deal them yet 90 // Create Cards, but don't shuffle or deal them yet
86 createDeck(); 91 createDeck();
87 92
88 // Move the cards to their piles (deal them to their previous places) 93 // Move the cards to their piles (deal them to their previous places)
89 beginDealing(); 94 beginDealing();
90 95
91 highestZ = 1; 96 highestZ = 1;
92 97
93 for (int k = 0; k < 4; k++) { 98 for (int k = 0; k < 4; k++) {
94 QString pile; 99 QString pile;
95 pile.sprintf( "FreeCellPile%i", k ); 100 pile.sprintf( "FreeCellPile%i", k );
96 readPile( cfg, freecellPiles[k], pile, highestZ ); 101 readPile( cfg, freecellPiles[k], pile, highestZ );
97 } 102 }
98 103
99 for (int k = 0; k < 4; k++) { 104 for (int k = 0; k < 4; k++) {
100 QString pile; 105 QString pile;
101 pile.sprintf( "DiscardPile%i", k ); 106 pile.sprintf( "DiscardPile%i", k );
102 readPile( cfg, discardPiles[k], pile, highestZ ); 107 readPile( cfg, discardPiles[k], pile, highestZ );
103 } 108 }
104 109
105 for (int k = 0; k < 8; k++) { 110 for (int k = 0; k < 8; k++) {
106 QString pile; 111 QString pile;
107 pile.sprintf( "WorkingPile%i", k ); 112 pile.sprintf( "WorkingPile%i", k );
108 readPile( cfg, workingPiles[k], pile, highestZ ); 113 readPile( cfg, workingPiles[k], pile, highestZ );
109 } 114 }
110 115
111 highestZ++; 116 highestZ++;
112 117
113 endDealing(); 118 endDealing();
114} 119}
115 120
116 121
117void FreecellCardGame::writeConfig( Config& cfg ) 122void FreecellCardGame::writeConfig( Config& cfg )
118{ 123{
119 cfg.setGroup("GameState"); 124 cfg.setGroup("GameState");
120 for ( int i = 0; i < 4; i++ ) { 125 for ( int i = 0; i < 4; i++ ) {
121 QString pile; 126 QString pile;
122 pile.sprintf( "FreeCellPile%i", i ); 127 pile.sprintf( "FreeCellPile%i", i );
123 freecellPiles[i]->writeConfig( cfg, pile ); 128 freecellPiles[i]->writeConfig( cfg, pile );
124 } 129 }
125 for ( int i = 0; i < 4; i++ ) { 130 for ( int i = 0; i < 4; i++ ) {
126 QString pile; 131 QString pile;
127 pile.sprintf( "DiscardPile%i", i ); 132 pile.sprintf( "DiscardPile%i", i );
128 discardPiles[i]->writeConfig( cfg, pile ); 133 discardPiles[i]->writeConfig( cfg, pile );
129 } 134 }
130 for ( int i = 0; i < 8; i++ ) { 135 for ( int i = 0; i < 8; i++ ) {
131 QString pile; 136 QString pile;
132 pile.sprintf( "WorkingPile%i", i ); 137 pile.sprintf( "WorkingPile%i", i );
133 workingPiles[i]->writeConfig( cfg, pile ); 138 workingPiles[i]->writeConfig( cfg, pile );
134 } 139 }
135} 140}
136 141
137 142
diff --git a/noncore/games/solitaire/patiencecardgame.cpp b/noncore/games/solitaire/patiencecardgame.cpp
index 5a9326a..1501d2f 100644
--- a/noncore/games/solitaire/patiencecardgame.cpp
+++ b/noncore/games/solitaire/patiencecardgame.cpp
@@ -1,234 +1,257 @@
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 <qgfx_qws.h>
20#include "patiencecardgame.h" 21#include "patiencecardgame.h"
21 22
22 23
23int highestZ = 0; 24int highestZ = 0;
24 25
25 26
26PatienceCardGame::PatienceCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent) 27PatienceCardGame::PatienceCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent)
27{ 28{
28 numberOfTimesThroughDeck = 0; 29 numberOfTimesThroughDeck = 0;
29 highestZ = 0; 30 highestZ = 0;
30 31
31 circleCross = new CanvasCircleOrCross( 7, 18, canvas() ); 32 if ( qt_screen->deviceWidth() < 200 ) {
32 rectangle = new CanvasRoundRect( 35, 10, canvas() ); 33 circleCross = new CanvasCircleOrCross( 7, 16, canvas() );
34 rectangle = new CanvasRoundRect( 30, 10, canvas() );
33 35
34 for (int i = 0; i < 4; i++) { 36 for (int i = 0; i < 4; i++) {
35 discardPiles[i] = new PatienceDiscardPile( 110 + i * 30, 10, canvas() ); 37 discardPiles[i] = new PatienceDiscardPile( 78 + i * 23, 10, canvas() );
36 addCardPile(discardPiles[i]); 38 addCardPile(discardPiles[i]);
37 } 39 }
38 for (int i = 0; i < 7; i++) { 40 for (int i = 0; i < 7; i++) {
39 workingPiles[i] = new PatienceWorkingPile( 10 + i * 30, 50, canvas() ); 41 workingPiles[i] = new PatienceWorkingPile( 5 + i * 23, 50, canvas() );
40 addCardPile(workingPiles[i]); 42 addCardPile(workingPiles[i]);
43 }
44 faceDownDealingPile = new PatienceFaceDownDeck( 5, 10, canvas() );
45 faceUpDealingPile = new PatienceFaceUpDeck( 30, 10, canvas() );
46 } else {
47 circleCross = new CanvasCircleOrCross( 7, 18, canvas() );
48 rectangle = new CanvasRoundRect( 35, 10, canvas() );
49
50 for (int i = 0; i < 4; i++) {
51 discardPiles[i] = new PatienceDiscardPile( 110 + i * 30, 10, canvas() );
52 addCardPile(discardPiles[i]);
53 }
54 for (int i = 0; i < 7; i++) {
55 workingPiles[i] = new PatienceWorkingPile( 10 + i * 30, 50, canvas() );
56 addCardPile(workingPiles[i]);
57 }
58 faceDownDealingPile = new PatienceFaceDownDeck( 5, 10, canvas() );
59 faceUpDealingPile = new PatienceFaceUpDeck( 35, 10, canvas() );
41 } 60 }
42 faceDownDealingPile = new PatienceFaceDownDeck( 5, 10, canvas() );
43 faceUpDealingPile = new PatienceFaceUpDeck( 35, 10, canvas() );
44} 61}
45 62
46 63
47PatienceCardGame::~PatienceCardGame() 64PatienceCardGame::~PatienceCardGame()
48{ 65{
49 delete circleCross; 66 delete circleCross;
50 delete rectangle; 67 delete rectangle;
51 delete faceDownDealingPile; 68 delete faceDownDealingPile;
52 delete faceUpDealingPile; 69 delete faceUpDealingPile;
53} 70}
54 71
55 72
56void PatienceCardGame::deal(void) 73void PatienceCardGame::deal(void)
57{ 74{
58 highestZ = 1; 75 highestZ = 1;
59 int t = 0; 76 int t = 0;
60 77
61 beginDealing(); 78 beginDealing();
62 79
63 for (int i = 0; i < 7; i++) { 80 for (int i = 0; i < 7; i++) {
64 cards[t]->setFace(TRUE); 81 cards[t]->setFace(TRUE);
65 for (int k = i; k < 7; k++, t++) { 82 for (int k = i; k < 7; k++, t++) {
66 Card *card = cards[t]; 83 Card *card = cards[t];
67 workingPiles[k]->addCardToTop(card); 84 workingPiles[k]->addCardToTop(card);
68 card->setCardPile( workingPiles[k] ); 85 card->setCardPile( workingPiles[k] );
69 QPoint p = workingPiles[k]->getCardPos( card ); 86 QPoint p = workingPiles[k]->getCardPos( card );
70 card->setPos( p.x(), p.y(), highestZ ); 87 card->setPos( p.x(), p.y(), highestZ );
71 card->showCard(); 88 card->showCard();
72 highestZ++; 89 highestZ++;
73 } 90 }
74 } 91 }
75 92
76 for ( ; t < 52; t++) { 93 for ( ; t < 52; t++) {
77 Card *card = cards[t]; 94 Card *card = cards[t];
78 faceDownDealingPile->addCardToTop(card); 95 faceDownDealingPile->addCardToTop(card);
79 card->setCardPile( faceDownDealingPile ); 96 card->setCardPile( faceDownDealingPile );
80 QPoint p = faceDownDealingPile->getCardPos( card ); 97 QPoint p = faceDownDealingPile->getCardPos( card );
81 card->setPos( p.x(), p.y(), highestZ ); 98 card->setPos( p.x(), p.y(), highestZ );
82 card->showCard(); 99 card->showCard();
83 highestZ++; 100 highestZ++;
84 } 101 }
85 102
86 endDealing(); 103 endDealing();
87} 104}
88 105
89 106
90void PatienceCardGame::readConfig( Config& cfg ) 107void PatienceCardGame::readConfig( Config& cfg )
91{ 108{
92 cfg.setGroup("GameState"); 109 cfg.setGroup("GameState");
93 110
94 // Do we have a config file to read in? 111 // Do we have a config file to read in?
95 if ( !cfg.hasKey("numberOfTimesThroughDeck") ) { 112 if ( !cfg.hasKey("numberOfTimesThroughDeck") ) {
96 // if not, create a new game 113 // if not, create a new game
97 newGame(); 114 newGame();
98 return; 115 return;
99 } 116 }
100 // We have a config file, lets read it in and use it 117 // We have a config file, lets read it in and use it
101 118
102 // Create Cards, but don't shuffle or deal them yet 119 // Create Cards, but don't shuffle or deal them yet
103 createDeck(); 120 createDeck();
104 121
105 // How many times through the deck have we been 122 // How many times through the deck have we been
106 numberOfTimesThroughDeck = cfg.readNumEntry("NumberOfTimesThroughDeck"); 123 numberOfTimesThroughDeck = cfg.readNumEntry("NumberOfTimesThroughDeck");
107 124
108 // restore state to the circle/cross under the dealing pile 125 // restore state to the circle/cross under the dealing pile
109 if ( canTurnOverDeck() ) 126 if ( canTurnOverDeck() )
110 circleCross->setCircle(); 127 circleCross->setCircle();
111 else 128 else
112 circleCross->setCross(); 129 circleCross->setCross();
113 130
114 // Move the cards to their piles (deal them to their previous places) 131 // Move the cards to their piles (deal them to their previous places)
115 beginDealing(); 132 beginDealing();
116 133
117 highestZ = 1; 134 highestZ = 1;
118 135
119 for (int k = 0; k < 7; k++) { 136 for (int k = 0; k < 7; k++) {
120 QString pile; 137 QString pile;
121 pile.sprintf( "WorkingPile%i", k ); 138 pile.sprintf( "WorkingPile%i", k );
122 readPile( cfg, workingPiles[k], pile, highestZ ); 139 readPile( cfg, workingPiles[k], pile, highestZ );
123 } 140 }
124 141
125 for (int k = 0; k < 4; k++) { 142 for (int k = 0; k < 4; k++) {
126 QString pile; 143 QString pile;
127 pile.sprintf( "DiscardPile%i", k ); 144 pile.sprintf( "DiscardPile%i", k );
128 readPile( cfg, discardPiles[k], pile, highestZ ); 145 readPile( cfg, discardPiles[k], pile, highestZ );
129 } 146 }
130 147
131 readPile( cfg, faceDownDealingPile, "FaceDownDealingPile", highestZ ); 148 readPile( cfg, faceDownDealingPile, "FaceDownDealingPile", highestZ );
132 readPile( cfg, faceUpDealingPile, "FaceUpDealingPile", highestZ ); 149 readPile( cfg, faceUpDealingPile, "FaceUpDealingPile", highestZ );
133 150
134 highestZ++; 151 highestZ++;
135 152
136 endDealing(); 153 endDealing();
137} 154}
138 155
139 156
140void PatienceCardGame::writeConfig( Config& cfg ) 157void PatienceCardGame::writeConfig( Config& cfg )
141{ 158{
142 cfg.setGroup("GameState"); 159 cfg.setGroup("GameState");
143 cfg.writeEntry("numberOfTimesThroughDeck", numberOfTimesThroughDeck); 160 cfg.writeEntry("numberOfTimesThroughDeck", numberOfTimesThroughDeck);
144 161
145 for ( int i = 0; i < 7; i++ ) { 162 for ( int i = 0; i < 7; i++ ) {
146 QString pile; 163 QString pile;
147 pile.sprintf( "WorkingPile%i", i ); 164 pile.sprintf( "WorkingPile%i", i );
148 workingPiles[i]->writeConfig( cfg, pile ); 165 workingPiles[i]->writeConfig( cfg, pile );
149 } 166 }
150 for ( int i = 0; i < 4; i++ ) { 167 for ( int i = 0; i < 4; i++ ) {
151 QString pile; 168 QString pile;
152 pile.sprintf( "DiscardPile%i", i ); 169 pile.sprintf( "DiscardPile%i", i );
153 discardPiles[i]->writeConfig( cfg, pile ); 170 discardPiles[i]->writeConfig( cfg, pile );
154 } 171 }
155 faceDownDealingPile->writeConfig( cfg, "FaceDownDealingPile" ); 172 faceDownDealingPile->writeConfig( cfg, "FaceDownDealingPile" );
156 faceUpDealingPile->writeConfig( cfg, "FaceUpDealingPile" ); 173 faceUpDealingPile->writeConfig( cfg, "FaceUpDealingPile" );
157} 174}
158 175
159 176
160bool PatienceCardGame::mousePressCard( Card *card, QPoint p ) 177bool PatienceCardGame::mousePressCard( Card *card, QPoint p )
161{ 178{
162 Q_UNUSED(p); 179 Q_UNUSED(p);
163 180
164 CanvasCard *item = (CanvasCard *)card; 181 CanvasCard *item = (CanvasCard *)card;
165 if (item->isFacing() != TRUE) { 182 if (item->isFacing() != TRUE) {
166 // From facedown stack 183 // From facedown stack
167 if ((item->x() == 5) && ((int)item->y() == 10)) { 184 if ((item->x() == 5) && ((int)item->y() == 10)) {
168 item->setZ(highestZ); 185 item->setZ(highestZ);
169 highestZ++; 186 highestZ++;
170 187
171 // Added Code 188 // Added Code
172 faceDownDealingPile->removeCard(item); 189 faceDownDealingPile->removeCard(item);
173 faceUpDealingPile->addCardToTop(item); 190 faceUpDealingPile->addCardToTop(item);
174 item->setCardPile( faceUpDealingPile ); 191 item->setCardPile( faceUpDealingPile );
175 192
176 item->flipTo( 35, (int)item->y() ); 193 if ( qt_screen->deviceWidth() < 200 )
194 item->flipTo( 30, (int)item->y() );
195 else
196 item->flipTo( 35, (int)item->y() );
177 } 197 }
178 moving = NULL; 198 moving = NULL;
179 moved = FALSE; 199 moved = FALSE;
180 200
181 // move two other cards if we flip three at a time 201 // move two other cards if we flip three at a time
182 int flipped = 1; 202 int flipped = 1;
183 QCanvasItemList l = canvas()->collisions( p ); 203 QCanvasItemList l = canvas()->collisions( p );
184 for (QCanvasItemList::Iterator it = l.begin(); (it != l.end()) && (flipped != cardsDrawn()); ++it) { 204 for (QCanvasItemList::Iterator it = l.begin(); (it != l.end()) && (flipped != cardsDrawn()); ++it) {
185 if ( (*it)->rtti() == canvasCardId ) { 205 if ( (*it)->rtti() == canvasCardId ) {
186 CanvasCard *item = (CanvasCard *)*it; 206 CanvasCard *item = (CanvasCard *)*it;
187 if (item->animated()) 207 if (item->animated())
188 continue; 208 continue;
189 item->setZ(highestZ); 209 item->setZ(highestZ);
190 highestZ++; 210 highestZ++;
191 flipped++; 211 flipped++;
192 212
193 // Added Code 213 // Added Code
194 faceDownDealingPile->removeCard(item); 214 faceDownDealingPile->removeCard(item);
195 faceUpDealingPile->addCardToTop(item); 215 faceUpDealingPile->addCardToTop(item);
196 item->setCardPile( faceUpDealingPile ); 216 item->setCardPile( faceUpDealingPile );
197 217
198 item->flipTo( 35, (int)item->y(), 8 * flipped ); 218 if ( qt_screen->deviceWidth() < 200 )
219 item->flipTo( 30, (int)item->y(), 8 * flipped );
220 else
221 item->flipTo( 35, (int)item->y(), 8 * flipped );
199 } 222 }
200 } 223 }
201 224
202 return TRUE; 225 return TRUE;
203 } 226 }
204 227
205 return FALSE; 228 return FALSE;
206} 229}
207 230
208 231
209void PatienceCardGame::mousePress(QPoint p) 232void PatienceCardGame::mousePress(QPoint p)
210{ 233{
211 if ( canTurnOverDeck() && 234 if ( canTurnOverDeck() &&
212 (p.x() > 5) && (p.x() < 28) && 235 (p.x() > 5) && (p.x() < 28) &&
213 (p.y() > 10) && (p.y() < 46) ) { 236 (p.y() > 10) && (p.y() < 46) ) {
214 237
215 beginDealing(); 238 beginDealing();
216 Card *card = faceUpDealingPile->cardOnTop(); 239 Card *card = faceUpDealingPile->cardOnTop();
217 while ( card ) { 240 while ( card ) {
218 card->setPos( 5, 10, highestZ ); 241 card->setPos( 5, 10, highestZ );
219 card->setFace( FALSE ); 242 card->setFace( FALSE );
220 faceUpDealingPile->removeCard( card ); 243 faceUpDealingPile->removeCard( card );
221 faceDownDealingPile->addCardToTop( card ); 244 faceDownDealingPile->addCardToTop( card );
222 card->setCardPile( faceDownDealingPile ); 245 card->setCardPile( faceDownDealingPile );
223 card = faceUpDealingPile->cardOnTop(); 246 card = faceUpDealingPile->cardOnTop();
224 highestZ++; 247 highestZ++;
225 } 248 }
226 endDealing(); 249 endDealing();
227 250
228 throughDeck(); 251 throughDeck();
229 252
230 moved = TRUE; 253 moved = TRUE;
231 } 254 }
232} 255}
233 256
234 257
diff --git a/noncore/games/solitaire/patiencecardgame.h b/noncore/games/solitaire/patiencecardgame.h
index c4f6c48..0d0e3d5 100644
--- a/noncore/games/solitaire/patiencecardgame.h
+++ b/noncore/games/solitaire/patiencecardgame.h
@@ -1,206 +1,209 @@
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 PATIENCE_CARD_GAME_H 20#ifndef PATIENCE_CARD_GAME_H
21#define PATIENCE_CARD_GAME_H 21#define PATIENCE_CARD_GAME_H
22 22
23 23
24#include <qpopupmenu.h> 24#include <qpopupmenu.h>
25#include <qmainwindow.h> 25#include <qmainwindow.h>
26#include <qintdict.h> 26#include <qintdict.h>
27#include <qcanvas.h> 27#include <qcanvas.h>
28#include <qgfx_qws.h>
28// #include "canvascardshapes.h" 29// #include "canvascardshapes.h"
29// #include "canvascard.h" 30// #include "canvascard.h"
30#include "canvascardgame.h" 31#include "canvascardgame.h"
31 32
32 33
33class PatienceFaceDownDeck : public CardPile, public CanvasRoundRect 34class PatienceFaceDownDeck : public CardPile, public CanvasRoundRect
34{ 35{
35public: 36public:
36 PatienceFaceDownDeck(int x, int y, QCanvas *canvas) 37 PatienceFaceDownDeck(int x, int y, QCanvas *canvas)
37 : CardPile(x, y), CanvasRoundRect(x, y, canvas) { } 38 : CardPile(x, y), CanvasRoundRect(x, y, canvas) { }
38 virtual bool isAllowedOnTop(Card *card) { 39 virtual bool isAllowedOnTop(Card *card) {
39 Q_UNUSED(card); 40 Q_UNUSED(card);
40 // Need to check it is from the faceUpDealingPile 41 // Need to check it is from the faceUpDealingPile
41 return TRUE; 42 return TRUE;
42 } 43 }
43 virtual bool isAllowedToBeMoved(Card *card) { 44 virtual bool isAllowedToBeMoved(Card *card) {
44 Q_UNUSED(card); 45 Q_UNUSED(card);
45 //if ( ( !card->isFacing() ) && ( card == cardOnTop() ) ) 46 //if ( ( !card->isFacing() ) && ( card == cardOnTop() ) )
46 if ( card == cardOnTop() ) 47 if ( card == cardOnTop() )
47 return TRUE; 48 return TRUE;
48 return FALSE; 49 return FALSE;
49 } 50 }
50}; 51};
51 52
52 53
53class PatienceFaceUpDeck : public CardPile, public CanvasRoundRect 54class PatienceFaceUpDeck : public CardPile, public CanvasRoundRect
54{ 55{
55public: 56public:
56 PatienceFaceUpDeck(int x, int y, QCanvas *canvas) 57 PatienceFaceUpDeck(int x, int y, QCanvas *canvas)
57 : CardPile(x, y), CanvasRoundRect(x, y, canvas) { } 58 : CardPile(x, y), CanvasRoundRect(x, y, canvas) { }
58 virtual bool isAllowedOnTop(Card *card) { 59 virtual bool isAllowedOnTop(Card *card) {
59 Q_UNUSED(card); 60 Q_UNUSED(card);
60 // Need to check it is from the faceDownDealingPile 61 // Need to check it is from the faceDownDealingPile
61 return TRUE; 62 return TRUE;
62 } 63 }
63 virtual bool isAllowedToBeMoved(Card *card) { 64 virtual bool isAllowedToBeMoved(Card *card) {
64 Q_UNUSED(card); 65 Q_UNUSED(card);
65 //if ( ( card->isFacing() ) && ( card == cardOnTop() ) ) 66 //if ( ( card->isFacing() ) && ( card == cardOnTop() ) )
66 if ( card == cardOnTop() ) 67 if ( card == cardOnTop() )
67 return TRUE; 68 return TRUE;
68 return FALSE; 69 return FALSE;
69 } 70 }
70}; 71};
71 72
72 73
73class PatienceDiscardPile : public CardPile, public CanvasRoundRect 74class PatienceDiscardPile : public CardPile, public CanvasRoundRect
74{ 75{
75public: 76public:
76 PatienceDiscardPile(int x, int y, QCanvas *canvas) 77 PatienceDiscardPile(int x, int y, QCanvas *canvas)
77 : CardPile(x, y), CanvasRoundRect(x, y, canvas) { } 78 : CardPile(x, y), CanvasRoundRect(x, y, canvas) { }
78 virtual bool isAllowedOnTop(Card *card) { 79 virtual bool isAllowedOnTop(Card *card) {
79 if ( card->isFacing() && ( card->getCardPile()->cardInfront(card) == NULL ) && 80 if ( card->isFacing() && ( card->getCardPile()->cardInfront(card) == NULL ) &&
80 ( ( ( cardOnTop() == NULL ) && ( card->getValue() == ace ) ) || 81 ( ( ( cardOnTop() == NULL ) && ( card->getValue() == ace ) ) ||
81 ( ( cardOnTop() != NULL ) && 82 ( ( cardOnTop() != NULL ) &&
82 ( (int)card->getValue() == (int)cardOnTop()->getValue() + 1 ) && 83 ( (int)card->getValue() == (int)cardOnTop()->getValue() + 1 ) &&
83 ( card->getSuit() == cardOnTop()->getSuit() ) ) ) ) 84 ( card->getSuit() == cardOnTop()->getSuit() ) ) ) )
84 return TRUE; 85 return TRUE;
85 return FALSE; 86 return FALSE;
86 } 87 }
87 virtual bool isAllowedToBeMoved(Card *card) { 88 virtual bool isAllowedToBeMoved(Card *card) {
88 if ( card->isFacing() && ( card == cardOnTop() ) ) 89 if ( card->isFacing() && ( card == cardOnTop() ) )
89 return TRUE; 90 return TRUE;
90 return FALSE; 91 return FALSE;
91 } 92 }
92}; 93};
93 94
94 95
95class PatienceWorkingPile : public CardPile, public CanvasRoundRect 96class PatienceWorkingPile : public CardPile, public CanvasRoundRect
96{ 97{
97public: 98public:
98 PatienceWorkingPile(int x, int y, QCanvas *canvas) 99 PatienceWorkingPile(int x, int y, QCanvas *canvas)
99 : CardPile(x, y), CanvasRoundRect(x, y, canvas), top(x, y) { } 100 : CardPile(x, y), CanvasRoundRect(x, y, canvas), top(x, y) { }
100 virtual bool isAllowedOnTop(Card *card) { 101 virtual bool isAllowedOnTop(Card *card) {
101 if ( card->isFacing() && 102 if ( card->isFacing() &&
102 ( ( ( cardOnTop() == NULL ) && (card->getValue() == king) ) || 103 ( ( ( cardOnTop() == NULL ) && (card->getValue() == king) ) ||
103 ( ( cardOnTop() != NULL ) && 104 ( ( cardOnTop() != NULL ) &&
104 ( (int)card->getValue() + 1 == (int)cardOnTop()->getValue() ) && 105 ( (int)card->getValue() + 1 == (int)cardOnTop()->getValue() ) &&
105 ( card->isRed() != cardOnTop()->isRed() ) ) ) ) 106 ( card->isRed() != cardOnTop()->isRed() ) ) ) )
106 return TRUE; 107 return TRUE;
107 return FALSE; 108 return FALSE;
108 } 109 }
109 virtual bool isAllowedToBeMoved(Card *card) { 110 virtual bool isAllowedToBeMoved(Card *card) {
110 if ( card->isFacing() ) 111 if ( card->isFacing() )
111 return TRUE; 112 return TRUE;
112 return FALSE; 113 return FALSE;
113 } 114 }
114 virtual void cardAddedToTop(Card *card) { 115 virtual void cardAddedToTop(Card *card) {
115 Q_UNUSED(card); 116 Q_UNUSED(card);
116 top = getCardPos(NULL); 117 top = getCardPos(NULL);
117 setNextX( top.x() ); 118 setNextX( top.x() );
118 setNextY( top.y() ); 119 setNextY( top.y() );
119 } 120 }
120 virtual void cardRemoved(Card *card) { 121 virtual void cardRemoved(Card *card) {
121 Q_UNUSED(card); 122 Q_UNUSED(card);
122 123
123 Card *newTopCard = cardOnTop(); 124 Card *newTopCard = cardOnTop();
124 125
125 if ( !newTopCard ) { 126 if ( !newTopCard ) {
126 top = QPoint( pileX, pileY ); 127 top = QPoint( pileX, pileY );
127 setNextX( pileX ); 128 setNextX( pileX );
128 setNextY( pileY ); 129 setNextY( pileY );
129 return; 130 return;
130 } else { 131 } else {
131 top = getCardPos(NULL); 132 top = getCardPos(NULL);
132 if ( newTopCard->isFacing() == FALSE ) { 133 if ( newTopCard->isFacing() == FALSE ) {
134 int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13;
133 // correct the position taking in to account the card is not 135 // correct the position taking in to account the card is not
134 // yet flipped, but will become flipped 136 // yet flipped, but will become flipped
135 top = QPoint( top.x() - 1, top.y() - 3 ); 137 top = QPoint( top.x() - 1, top.y() - 3 );
136 newTopCard->flipTo( top.x(), top.y() ); 138 newTopCard->flipTo( top.x(), top.y() );
137 top = QPoint( top.x(), top.y() + 13 ); 139 top = QPoint( top.x(), top.y() + offsetDown );
138 } 140 }
139 setNextX( top.x() ); 141 setNextX( top.x() );
140 setNextY( top.y() ); 142 setNextY( top.y() );
141 } 143 }
142 } 144 }
143 virtual QPoint getCardPos(Card *c) { 145 virtual QPoint getCardPos(Card *c) {
144 int x = pileX, y = pileY; 146 int x = pileX, y = pileY;
145 Card *card = cardOnBottom(); 147 Card *card = cardOnBottom();
146 while ((card != c) && (card != NULL)) { 148 while ((card != c) && (card != NULL)) {
147 if (card->isFacing()) { 149 if (card->isFacing()) {
148 y += 13; 150 int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13;
151 y += offsetDown;
149 } else { 152 } else {
150 x += 1; 153 x += 1;
151 y += 3; 154 y += 3;
152 } 155 }
153 card = cardInfront(card); 156 card = cardInfront(card);
154 } 157 }
155 return QPoint( x, y ); 158 return QPoint( x, y );
156 } 159 }
157 virtual QPoint getHypertheticalNextCardPos(void) { 160 virtual QPoint getHypertheticalNextCardPos(void) {
158 return top; 161 return top;
159 // return QPoint( getNextX(), getNextY() ); 162 // return QPoint( getNextX(), getNextY() );
160 } 163 }
161private: 164private:
162 QPoint top; 165 QPoint top;
163 166
164}; 167};
165 168
166 169
167class PatienceCardGame : public CanvasCardGame 170class PatienceCardGame : public CanvasCardGame
168{ 171{
169public: 172public:
170 PatienceCardGame(QCanvas *c, bool snap, QWidget *parent = 0); 173 PatienceCardGame(QCanvas *c, bool snap, QWidget *parent = 0);
171 virtual ~PatienceCardGame(); 174 virtual ~PatienceCardGame();
172 virtual void deal(void); 175 virtual void deal(void);
173 virtual bool haveWeWon() { 176 virtual bool haveWeWon() {
174 return ( discardPiles[0]->kingOnTop() && 177 return ( discardPiles[0]->kingOnTop() &&
175 discardPiles[1]->kingOnTop() && 178 discardPiles[1]->kingOnTop() &&
176 discardPiles[2]->kingOnTop() && 179 discardPiles[2]->kingOnTop() &&
177 discardPiles[3]->kingOnTop() );; 180 discardPiles[3]->kingOnTop() );;
178 } 181 }
179 virtual void mousePress(QPoint p); 182 virtual void mousePress(QPoint p);
180 virtual void mouseRelease(QPoint p) { Q_UNUSED(p); } 183 virtual void mouseRelease(QPoint p) { Q_UNUSED(p); }
181// virtual void mouseMove(QPoint p); 184// virtual void mouseMove(QPoint p);
182 virtual bool mousePressCard(Card *card, QPoint p); 185 virtual bool mousePressCard(Card *card, QPoint p);
183 virtual void mouseReleaseCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); } 186 virtual void mouseReleaseCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); }
184// virtual void mouseMoveCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); } 187// virtual void mouseMoveCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); }
185 bool canTurnOverDeck(void) { return (numberOfTimesThroughDeck != 3); } 188 bool canTurnOverDeck(void) { return (numberOfTimesThroughDeck != 3); }
186 void throughDeck(void) { 189 void throughDeck(void) {
187 numberOfTimesThroughDeck++; 190 numberOfTimesThroughDeck++;
188 if (numberOfTimesThroughDeck == 3) 191 if (numberOfTimesThroughDeck == 3)
189 circleCross->setCross(); 192 circleCross->setCross();
190 } 193 }
191 bool snapOn; 194 bool snapOn;
192 virtual void writeConfig( Config& cfg ); 195 virtual void writeConfig( Config& cfg );
193 virtual void readConfig( Config& cfg ); 196 virtual void readConfig( Config& cfg );
194private: 197private:
195 CanvasCircleOrCross *circleCross; 198 CanvasCircleOrCross *circleCross;
196 CanvasRoundRect *rectangle; 199 CanvasRoundRect *rectangle;
197 PatienceWorkingPile *workingPiles[7]; 200 PatienceWorkingPile *workingPiles[7];
198 PatienceDiscardPile *discardPiles[4]; 201 PatienceDiscardPile *discardPiles[4];
199 PatienceFaceDownDeck *faceDownDealingPile; 202 PatienceFaceDownDeck *faceDownDealingPile;
200 PatienceFaceUpDeck *faceUpDealingPile; 203 PatienceFaceUpDeck *faceUpDealingPile;
201 int numberOfTimesThroughDeck; 204 int numberOfTimesThroughDeck;
202}; 205};
203 206
204 207
205#endif 208#endif
206 209
diff --git a/noncore/games/wordgame/wordgame.cpp b/noncore/games/wordgame/wordgame.cpp
index ca4352d..16d37b3 100644
--- a/noncore/games/wordgame/wordgame.cpp
+++ b/noncore/games/wordgame/wordgame.cpp
@@ -1,395 +1,417 @@
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 21
22#include "wordgame.h" 22#include "wordgame.h"
23 23
24#include <qpe/applnk.h> 24#include <qpe/applnk.h>
25#include <qpe/global.h> 25#include <qpe/global.h>
26#include <qpe/filemanager.h> 26#include <qpe/filemanager.h>
27#include <qpe/resource.h> 27#include <qpe/resource.h>
28#include <qpe/config.h> 28#include <qpe/config.h>
29 29
30#include <qapplication.h> 30#include <qapplication.h>
31#include <qmessagebox.h> 31#include <qmessagebox.h>
32#include <qcombobox.h> 32#include <qcombobox.h>
33#include <qdatetime.h> 33#include <qdatetime.h>
34#include <qfileinfo.h> 34#include <qfileinfo.h>
35#include <qfile.h> 35#include <qfile.h>
36#include <qdir.h> 36#include <qdir.h>
37#include <qiconset.h> 37#include <qiconset.h>
38#include <qlabel.h> 38#include <qlabel.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qtextstream.h> 41#include <qtextstream.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qpe/qpetoolbar.h> 43#include <qpe/qpetoolbar.h>
44#include <qtoolbutton.h> 44#include <qtoolbutton.h>
45#include <qvbox.h> 45#include <qvbox.h>
46#include <qwidgetstack.h> 46#include <qwidgetstack.h>
47#include <qpainter.h> 47#include <qpainter.h>
48#include <qlayout.h> 48#include <qlayout.h>
49#include <qregexp.h> 49#include <qregexp.h>
50 50
51#include <stdlib.h> 51#include <stdlib.h>
52#include <unistd.h> 52#include <unistd.h>
53#include <pwd.h> 53#include <pwd.h>
54#include <sys/types.h> 54#include <sys/types.h>
55 55
56enum RuleEffects { 56enum RuleEffects {
57 Multiplier=15, 57 Multiplier=15,
58 MultiplyAll=64, 58 MultiplyAll=64,
59 Start=128 59 Start=128
60}; 60};
61 61
62static int tile_smallw = 16;
63static int tile_smallh = 16;
64static int tile_bigw = 22;
65static int tile_bigh = 22;
66static int tile_stweak = -2;
67static int tile_btweak = -1;
68
62static const int rack_tiles=7; 69static const int rack_tiles=7;
63 70
64const char* sampleWGR= 71const char* sampleWGR=
65 "wordgame_shapes\n" 72 "wordgame_shapes\n"
66 "15 15\n" 73 "15 15\n"
67 "400001040100004\n" 74 "400001040100004\n"
68 "030000000000030\n" 75 "030000000000030\n"
69 "002002000200200\n" 76 "002002000200200\n"
70 "000300020003000\n" 77 "000300020003000\n"
71 "000020000020000\n" 78 "000020000020000\n"
72 "102001000100201\n" 79 "102001000100201\n"
73 "000000202000000\n" 80 "000000202000000\n"
74 "400200050002004\n" 81 "400200050002004\n"
75 "000000202000000\n" 82 "000000202000000\n"
76 "102001000100201\n" 83 "102001000100201\n"
77 "000020000020000\n" 84 "000020000020000\n"
78 "000300020003000\n" 85 "000300020003000\n"
79 "002002000200200\n" 86 "002002000200200\n"
80 "030000000000030\n" 87 "030000000000030\n"
81 "400001040100004\n" 88 "400001040100004\n"
82 "1 2 3 66 67 194 100 0\n" 89 "1 2 3 66 67 194 100 0\n"
83 "1 j 8\n" 90 "1 j 8\n"
84 "1 q 7\n" 91 "1 q 7\n"
85 "1 x 6\n" 92 "1 x 6\n"
86 "1 z 6\n" 93 "1 z 6\n"
87 "1 w 4\n" 94 "1 w 4\n"
88 "1 k 4\n" 95 "1 k 4\n"
89 "1 v 3\n" 96 "1 v 3\n"
90 "1 f 3\n" 97 "1 f 3\n"
91 "2 y 3\n" 98 "2 y 3\n"
92 "2 h 2\n" 99 "2 h 2\n"
93 "2 b 2\n" 100 "2 b 2\n"
94 "2 m 2\n" 101 "2 m 2\n"
95 "3 p 2\n" 102 "3 p 2\n"
96 "3 g 2\n" 103 "3 g 2\n"
97 "3 u 2\n" 104 "3 u 2\n"
98 "4 d 2\n" 105 "4 d 2\n"
99 "4 c 2\n" 106 "4 c 2\n"
100 "5 l 1\n" 107 "5 l 1\n"
101 "5 o 1\n" 108 "5 o 1\n"
102 "7 t 1\n" 109 "7 t 1\n"
103 "7 n 1\n" 110 "7 n 1\n"
104 "7 a 1\n" 111 "7 a 1\n"
105 "7 r 1\n" 112 "7 r 1\n"
106 "8 s 1\n" 113 "8 s 1\n"
107 "8 i 1\n" 114 "8 i 1\n"
108 "11 e 1\n" 115 "11 e 1\n"
109 "0\n"; 116 "0\n";
110 117
111WordGame::WordGame( QWidget* parent, const char* name, WFlags fl ) : 118WordGame::WordGame( QWidget* parent, const char* name, WFlags fl ) :
112 QMainWindow(parent, name, fl) 119 QMainWindow(parent, name, fl)
113{ 120{
121 if ( qApp->desktop()->width() < 240 ) {
122 tile_smallw = 10;
123 tile_smallh = 10;
124 tile_bigw = 16;
125 tile_bigh = 16;
126 tile_stweak = 0;
127 tile_btweak = 0;
128 }
129
114 setIcon( Resource::loadPixmap( "wordgame" ) ); 130 setIcon( Resource::loadPixmap( "wordgame" ) );
115 setCaption( tr("Word Game") ); 131 setCaption( tr("Word Game") );
116 132
117 setToolBarsMovable( FALSE ); 133 setToolBarsMovable( FALSE );
118 vbox = new QVBox(this); 134 vbox = new QVBox(this);
119 135
120 setCentralWidget(vbox); 136 setCentralWidget(vbox);
121 toolbar = new QPEToolBar(this); 137 toolbar = new QPEToolBar(this);
122 addToolBar(toolbar, Bottom); 138 addToolBar(toolbar, Bottom);
123 reset = new QToolButton(Resource::loadPixmap("back"), tr("Back"), "", this, SLOT(resetTurn()), toolbar); 139 reset = new QToolButton(Resource::loadPixmap("back"), tr("Back"), "", this, SLOT(resetTurn()), toolbar);
124 done = new QToolButton(Resource::loadPixmap("done"), tr("Done"), "", this, SLOT(endTurn()), toolbar); 140 done = new QToolButton(Resource::loadPixmap("done"), tr("Done"), "", this, SLOT(endTurn()), toolbar);
125 scoreinfo = new ScoreInfo(toolbar); 141 scoreinfo = new ScoreInfo(toolbar);
126 scoreinfo->setFont(QFont("Helvetica",10)); 142 scoreinfo->setFont(QFont("Helvetica",10));
127 new QToolButton(Resource::loadPixmap("finish"), tr("Close"), "", this, SLOT(endGame()), toolbar); 143 new QToolButton(Resource::loadPixmap("finish"), tr("Close"), "", this, SLOT(endGame()), toolbar);
128 toolbar->setStretchableWidget(scoreinfo); 144 toolbar->setStretchableWidget(scoreinfo);
129 145
130 cpu = 0; 146 cpu = 0;
131 board = 0; 147 board = 0;
132 bag = 0; 148 bag = 0;
133 racks = 0; 149 racks = 0;
134 150
135 aiheart = new QTimer(this); 151 aiheart = new QTimer(this);
136 connect(aiheart, SIGNAL(timeout()), this, SLOT(think())); 152 connect(aiheart, SIGNAL(timeout()), this, SLOT(think()));
137 153
138 readConfig(); 154 readConfig();
139} 155}
140 156
141WordGame::~WordGame() 157WordGame::~WordGame()
142{ 158{
143 writeConfig(); 159 writeConfig();
144} 160}
145 161
146void WordGame::writeConfig() 162void WordGame::writeConfig()
147{ 163{
148 Config cfg("WordGame"); 164 Config cfg("WordGame");
149 cfg.setGroup("Game"); 165 cfg.setGroup("Game");
150 cfg.writeEntry("NameList",namelist,';'); 166 cfg.writeEntry("NameList",namelist,';');
151 cfg.writeEntry("CurrentPlayer",gameover ? 0 : player+1); 167 cfg.writeEntry("CurrentPlayer",gameover ? 0 : player+1);
152 if ( !gameover ) { 168 if ( !gameover ) {
153 cfg.writeEntry("Rules",rules); 169 cfg.writeEntry("Rules",rules);
154 bag->writeConfig(cfg); 170 bag->writeConfig(cfg);
155 board->writeConfig(cfg); 171 board->writeConfig(cfg);
156 scoreinfo->writeConfig(cfg); 172 scoreinfo->writeConfig(cfg);
157 } 173 }
158 for (int p=0; p<nplayers; p++) { 174 for (int p=0; p<nplayers; p++) {
159 cfg.setGroup("Player"+QString::number(p+1)); 175 cfg.setGroup("Player"+QString::number(p+1));
160 if ( gameover ) cfg.clearGroup(); else rack(p)->writeConfig(cfg); 176 if ( gameover ) cfg.clearGroup(); else rack(p)->writeConfig(cfg);
161 } 177 }
162} 178}
163 179
164void WordGame::readConfig() 180void WordGame::readConfig()
165{ 181{
166 Config cfg("WordGame"); 182 Config cfg("WordGame");
167 cfg.setGroup("Game"); 183 cfg.setGroup("Game");
168 int currentplayer = cfg.readNumEntry("CurrentPlayer",0); 184 int currentplayer = cfg.readNumEntry("CurrentPlayer",0);
169 QStringList pnames = cfg.readListEntry("NameList",';'); 185 QStringList pnames = cfg.readListEntry("NameList",';');
170 if ( currentplayer ) { 186 if ( currentplayer ) {
171 gameover = FALSE; 187 gameover = FALSE;
172 rules = cfg.readEntry("Rules"); 188 rules = cfg.readEntry("Rules");
173 if ( rules.find("x-wordgamerules") >= 0 ) { 189 if ( rules.find("x-wordgamerules") >= 0 ) {
174 // rules files moved 190 // rules files moved
175 rules = "Sample.rules"; 191 rules = "Sample.rules";
176 } 192 }
177 if ( loadRules(rules) ) { 193 if ( loadRules(rules) ) {
178 startGame(pnames); 194 startGame(pnames);
179 bag->readConfig(cfg); 195 bag->readConfig(cfg);
180 board->readConfig(cfg); 196 board->readConfig(cfg);
181 scoreinfo->readConfig(cfg); 197 scoreinfo->readConfig(cfg);
182 for (int p=0; p<nplayers; p++) { 198 for (int p=0; p<nplayers; p++) {
183 cfg.setGroup("Player"+QString::number(p+1)); 199 cfg.setGroup("Player"+QString::number(p+1));
184 rack(p)->readConfig(cfg); 200 rack(p)->readConfig(cfg);
185 } 201 }
186 player=currentplayer-1; 202 player=currentplayer-1;
187 readyRack(player); 203 readyRack(player);
188 return; 204 return;
189 } 205 }
190 } 206 }
191 // fall-back 207 // fall-back
192 openGameSelector(pnames); 208 openGameSelector(pnames);
193} 209}
194 210
195void WordGame::openGameSelector(const QStringList& initnames) 211void WordGame::openGameSelector(const QStringList& initnames)
196{ 212{
197 toolbar->hide(); 213 toolbar->hide();
198 gameover = FALSE; 214 gameover = FALSE;
199 215
200 delete board; 216 delete board;
201 board = 0; 217 board = 0;
202 delete racks; 218 delete racks;
203 racks = 0; 219 racks = 0;
204 220
205 delete cpu; 221 delete cpu;
206 cpu = 0; 222 cpu = 0;
207 223
208 newgame = new NewGame(vbox); 224 newgame = new NewGame(vbox);
209 225
210 //Rules rules(this); 226 //Rules rules(this);
211 //connect(game.editrules, SIGNAL(clicked()), &rules, SLOT(editRules())); 227 //connect(game.editrules, SIGNAL(clicked()), &rules, SLOT(editRules()));
212 //connect(&rules, SIGNAL(rulesChanged()), &game, SLOT(updateRuleSets())); 228 //connect(&rules, SIGNAL(rulesChanged()), &game, SLOT(updateRuleSets()));
213 struct passwd* n = getpwuid(getuid()); 229 struct passwd* n = getpwuid(getuid());
214 QString playername = n ? n->pw_name : ""; 230 QString playername = n ? n->pw_name : "";
215 if ( playername.isEmpty() ) { 231 if ( playername.isEmpty() ) {
216 playername = "Player"; 232 playername = "Player";
217 } 233 }
218 newgame->player0->changeItem(playername,0); 234 newgame->player0->changeItem(playername,0);
219 newgame->player1->setCurrentItem(1); 235 newgame->player1->setCurrentItem(1);
220 newgame->updateRuleSets(); 236 newgame->updateRuleSets();
221 newgame->show(); 237 newgame->show();
222 238
223 connect(newgame->buttonOk, SIGNAL(clicked()), this, SLOT(startGame())); 239 connect(newgame->buttonOk, SIGNAL(clicked()), this, SLOT(startGame()));
224} 240}
225 241
226void WordGame::startGame() 242void WordGame::startGame()
227{ 243{
228 rules = newgame->ruleslist[newgame->rules->currentItem()]; 244 rules = newgame->ruleslist[newgame->rules->currentItem()];
229 if ( loadRules(rules) ) { 245 if ( loadRules(rules) ) {
230 QStringList names; 246 QStringList names;
231 names.append(newgame->player0->currentText()); 247 names.append(newgame->player0->currentText());
232 names.append(newgame->player1->currentText()); 248 names.append(newgame->player1->currentText());
233 names.append(newgame->player2->currentText()); 249 names.append(newgame->player2->currentText());
234 names.append(newgame->player3->currentText()); 250 names.append(newgame->player3->currentText());
235 names.append(newgame->player4->currentText()); 251 names.append(newgame->player4->currentText());
236 names.append(newgame->player5->currentText()); 252 names.append(newgame->player5->currentText());
237 delete newgame; 253 delete newgame;
238 startGame(names); 254 startGame(names);
239 } else { 255 } else {
240 // error... 256 // error...
241 delete newgame; 257 delete newgame;
242 close(); 258 close();
243 } 259 }
244} 260}
245 261
246void WordGame::startGame(const QStringList& playerlist) 262void WordGame::startGame(const QStringList& playerlist)
247{ 263{
248 toolbar->show(); 264 toolbar->show();
249 racks = new QWidgetStack(vbox); 265 racks = new QWidgetStack(vbox);
266 racks->setFixedHeight(TileItem::bigHeight()+2);
250 namelist.clear(); 267 namelist.clear();
251 nplayers=0; 268 nplayers=0;
252 for (QStringList::ConstIterator it=playerlist.begin(); it!=playerlist.end(); ++it) 269 for (QStringList::ConstIterator it=playerlist.begin(); it!=playerlist.end(); ++it)
253 addPlayer(*it); 270 addPlayer(*it);
254 scoreinfo->init(namelist); 271 scoreinfo->init(namelist);
255 272
256 if ( nplayers ) { 273 if ( nplayers ) {
257 player=0; 274 player=0;
258 readyRack(player); 275 readyRack(player);
259 } 276 }
260 277
261 board->show(); 278 board->show();
262 racks->show(); 279 racks->show();
263} 280}
264 281
265bool WordGame::loadRules(const QString &name) 282bool WordGame::loadRules(const QString &name)
266{ 283{
267 QString filename = Global::applicationFileName( "wordgame", name ); 284 QString filename = Global::applicationFileName( "wordgame", name );
268 QFile file( filename ); 285 QFile file( filename );
269 if ( !file.open( IO_ReadOnly ) ) 286 if ( !file.open( IO_ReadOnly ) )
270 return FALSE; 287 return FALSE;
271 288
272 QTextStream ts( &file ); 289 QTextStream ts( &file );
273 290
274 QString title = name; 291 QString title = name;
275 title.truncate( title.length() - 6 ); 292 title.truncate( title.length() - 6 );
276 setCaption( title ); 293 setCaption( title );
277 294
278 QString shapepixmap; 295 QString shapepixmap;
279 ts >> shapepixmap; 296 ts >> shapepixmap;
280 int htiles,vtiles; 297 int htiles,vtiles;
281 ts >> htiles >> vtiles; 298 ts >> htiles >> vtiles;
282 299
283 if ( htiles < 3 || vtiles < 3 ) 300 if ( htiles < 3 || vtiles < 3 )
284 return FALSE; 301 return FALSE;
285 302
286 QPixmap bgshapes = Resource::loadPixmap(shapepixmap);
287 QString rule_shapes; 303 QString rule_shapes;
288 for (int i=0; i<vtiles; i++) { 304 for (int i=0; i<vtiles; i++) {
289 QString line; 305 QString line;
290 ts >> line; 306 ts >> line;
291 rule_shapes += line; 307 rule_shapes += line;
292 } 308 }
293 static int rule_effects[12]; 309 static int rule_effects[12];
294 int re=0,e; 310 int re=0,e;
295 ts >> e; 311 ts >> e;
296 while ( e && re < 10 ) { 312 while ( e && re < 10 ) {
297 rule_effects[re] = e; 313 rule_effects[re] = e;
298 if ( re++ < 10 ) ts >> e; 314 if ( re++ < 10 ) ts >> e;
299 } 315 }
316
317 QImage shim = Resource::loadImage(shapepixmap);
318 shim = shim.smoothScale((re-1)*TileItem::smallWidth(),TileItem::smallHeight());
319 QPixmap bgshapes;
320 bgshapes.convertFromImage(shim);
321
300 rule_effects[re++] = 100; // default bonus 322 rule_effects[re++] = 100; // default bonus
301 board = new Board(bgshapes, htiles, vtiles, vbox); 323 board = new Board(bgshapes, htiles, vtiles, vbox);
302 board->setRules(rule_shapes, rule_effects); 324 board->setRules(rule_shapes, rule_effects);
303 connect(board, SIGNAL(temporaryScore(int)), scoreinfo, SLOT(showTemporaryScore(int))); 325 connect(board, SIGNAL(temporaryScore(int)), scoreinfo, SLOT(showTemporaryScore(int)));
304 326
305 bag = new Bag; 327 bag = new Bag;
306 328
307 int count; 329 int count;
308 ts >> count; 330 ts >> count;
309 while ( count ) { 331 while ( count ) {
310 QString text; 332 QString text;
311 int value; 333 int value;
312 ts >> text >> value; 334 ts >> text >> value;
313 if ( text == "_" ) 335 if ( text == "_" )
314 text = ""; 336 text = "";
315 337
316 Tile t(text, value); 338 Tile t(text, value);
317 for (int n=count; n--; ) 339 for (int n=count; n--; )
318 bag->add(t); 340 bag->add(t);
319 341
320 ts >> count; 342 ts >> count;
321 } 343 }
322 344
323 return TRUE; 345 return TRUE;
324} 346}
325 347
326 348
327NewGame::NewGame(QWidget* parent) : 349NewGame::NewGame(QWidget* parent) :
328 NewGameBase(parent) 350 NewGameBase(parent)
329{ 351{
330} 352}
331 353
332void NewGame::updateRuleSets() 354void NewGame::updateRuleSets()
333{ 355{
334 rules->clear(); 356 rules->clear();
335 357
336 QString rulesDir = Global::applicationFileName( "wordgame", "" ); 358 QString rulesDir = Global::applicationFileName( "wordgame", "" );
337 QDir dir( rulesDir, "*.rules" ); 359 QDir dir( rulesDir, "*.rules" );
338 ruleslist = dir.entryList(); 360 ruleslist = dir.entryList();
339 if ( ruleslist.isEmpty() ) { 361 if ( ruleslist.isEmpty() ) {
340 // Provide a sample 362 // Provide a sample
341 QFile file( rulesDir + "Sample.rules" ); 363 QFile file( rulesDir + "Sample.rules" );
342 if ( file.open( IO_WriteOnly ) ) { 364 if ( file.open( IO_WriteOnly ) ) {
343 file.writeBlock( sampleWGR, strlen(sampleWGR) ); 365 file.writeBlock( sampleWGR, strlen(sampleWGR) );
344 file.close(); 366 file.close();
345 updateRuleSets(); 367 updateRuleSets();
346 } 368 }
347 return; 369 return;
348 } 370 }
349 int newest=0; 371 int newest=0;
350 int newest_age=INT_MAX; 372 int newest_age=INT_MAX;
351 QDateTime now = QDateTime::currentDateTime(); 373 QDateTime now = QDateTime::currentDateTime();
352 QStringList::Iterator it; 374 QStringList::Iterator it;
353 for ( it = ruleslist.begin(); it != ruleslist.end(); ++it ) { 375 for ( it = ruleslist.begin(); it != ruleslist.end(); ++it ) {
354 QFileInfo fi((*it)); 376 QFileInfo fi((*it));
355 int age = fi.lastModified().secsTo(now); 377 int age = fi.lastModified().secsTo(now);
356 QString name = *it; 378 QString name = *it;
357 name.truncate( name.length()-6 ); // remove extension 379 name.truncate( name.length()-6 ); // remove extension
358 rules->insertItem( name ); 380 rules->insertItem( name );
359 if ( age < newest_age ) { 381 if ( age < newest_age ) {
360 newest_age = age; 382 newest_age = age;
361 newest = rules->count()-1; 383 newest = rules->count()-1;
362 } 384 }
363 } 385 }
364 rules->setCurrentItem(newest); 386 rules->setCurrentItem(newest);
365} 387}
366 388
367Rules::Rules(QWidget* parent) : 389Rules::Rules(QWidget* parent) :
368 RulesBase(parent,0,TRUE) 390 RulesBase(parent,0,TRUE)
369{ 391{
370} 392}
371 393
372void Rules::editRules() 394void Rules::editRules()
373{ 395{
374 if ( exec() ) { 396 if ( exec() ) {
375 // ### create a new set of rules 397 // ### create a new set of rules
376 emit rulesChanged(); 398 emit rulesChanged();
377 } 399 }
378} 400}
379 401
380void Rules::deleteRuleSet() 402void Rules::deleteRuleSet()
381{ 403{
382 // ### delete existing rule set 404 // ### delete existing rule set
383 emit rulesChanged(); 405 emit rulesChanged();
384} 406}
385 407
386void WordGame::addPlayer(const QString& name) 408void WordGame::addPlayer(const QString& name)
387{ 409{
388 if ( !name.isEmpty() ) { 410 if ( !name.isEmpty() ) {
389 int colon = name.find(':'); 411 int colon = name.find(':');
390 int cpu = (colon >=0 && name.left(2) == "AI") ? name.mid(2,1).toInt() : 0; 412 int cpu = (colon >=0 && name.left(2) == "AI") ? name.mid(2,1).toInt() : 0;
391 addPlayer(name,cpu); 413 addPlayer(name,cpu);
392 } 414 }
393} 415}
394 416
395void WordGame::addPlayer(const QString& name, int cpu) 417void WordGame::addPlayer(const QString& name, int cpu)
@@ -588,275 +610,291 @@ bool ComputerPlayer::step()
588 board->scoreTurn(best_start, best_n, best_dir); 610 board->scoreTurn(best_start, best_n, best_dir);
589 board->showTurn(); 611 board->showTurn();
590 } 612 }
591 return FALSE; 613 return FALSE;
592 } 614 }
593 dict++; 615 dict++;
594 across = FALSE; 616 across = FALSE;
595 current = QPoint(0,0); 617 current = QPoint(0,0);
596 } else { 618 } else {
597 across = TRUE; 619 across = TRUE;
598 current = QPoint(0,0); 620 current = QPoint(0,0);
599 } 621 }
600 } 622 }
601 } 623 }
602 return TRUE; 624 return TRUE;
603} 625}
604 626
605void ComputerPlayer::findBest(QPoint at, const QPoint& d, const QDawg::Node* node, ulong used, uchar* nletter, const Tile** tiles, int n, Tile* blankvalues, int blused) 627void ComputerPlayer::findBest(QPoint at, const QPoint& d, const QDawg::Node* node, ulong used, uchar* nletter, const Tile** tiles, int n, Tile* blankvalues, int blused)
606{ 628{
607 if ( !node ) 629 if ( !node )
608 return; 630 return;
609 QChar l = node->letter(); 631 QChar l = node->letter();
610 const Tile* cur = board->tile(at); 632 const Tile* cur = board->tile(at);
611 if ( cur ) { 633 if ( cur ) {
612 if ( cur->text()[0] == l ) { 634 if ( cur->text()[0] == l ) {
613 bool nextok = board->contains(at+d); 635 bool nextok = board->contains(at+d);
614 if ( node->isWord() && n && (!nextok || !board->tile(at+d)) ) 636 if ( node->isWord() && n && (!nextok || !board->tile(at+d)) )
615 noteChoice(tiles,n,d,blankvalues,blused); 637 noteChoice(tiles,n,d,blankvalues,blused);
616 if ( nextok ) 638 if ( nextok )
617 findBest(at+d, d, node->jump(), used, nletter, tiles, n, blankvalues, blused); 639 findBest(at+d, d, node->jump(), used, nletter, tiles, n, blankvalues, blused);
618 // #### text()[1]... 640 // #### text()[1]...
619 } 641 }
620 } else { 642 } else {
621 if ( nletter[l.unicode()] || nletter[0] ) { 643 if ( nletter[l.unicode()] || nletter[0] ) {
622 int rc = rack->count(); 644 int rc = rack->count();
623 ulong msk = 1; 645 ulong msk = 1;
624 for ( int x=0; x<rc; x++ ) { 646 for ( int x=0; x<rc; x++ ) {
625 if ( !(used&msk) ) { 647 if ( !(used&msk) ) {
626 const Tile* t = rack->tileRef(x); 648 const Tile* t = rack->tileRef(x);
627 if ( t->isBlank() || t->text() == l ) { // #### multi-char value()s 649 if ( t->isBlank() || t->text() == l ) { // #### multi-char value()s
628 bool nextok = board->contains(at+d); 650 bool nextok = board->contains(at+d);
629 tiles[n++] = t; 651 tiles[n++] = t;
630 if ( t->isBlank() ) 652 if ( t->isBlank() )
631 blankvalues[blused++] = Tile(l,0); 653 blankvalues[blused++] = Tile(l,0);
632 if ( node->isWord() && (!nextok || !board->tile(at+d)) ) 654 if ( node->isWord() && (!nextok || !board->tile(at+d)) )
633 noteChoice(tiles,n,d,blankvalues,blused); 655 noteChoice(tiles,n,d,blankvalues,blused);
634 used |= msk; // mark 656 used |= msk; // mark
635 nletter[t->text()[0].unicode()]--; 657 nletter[t->text()[0].unicode()]--;
636 if ( nextok ) 658 if ( nextok )
637 findBest(at+d, d, node->jump(), used, nletter, tiles, n, blankvalues, blused); 659 findBest(at+d, d, node->jump(), used, nletter, tiles, n, blankvalues, blused);
638 n--; 660 n--;
639 nletter[t->text()[0].unicode()]++; 661 nletter[t->text()[0].unicode()]++;
640 if ( t->isBlank() ) { 662 if ( t->isBlank() ) {
641 // keep looking 663 // keep looking
642 blused--; 664 blused--;
643 used &= ~msk; // unmark 665 used &= ~msk; // unmark
644 } else { 666 } else {
645 break; 667 break;
646 } 668 }
647 } 669 }
648 } 670 }
649 msk <<= 1; 671 msk <<= 1;
650 } 672 }
651 } 673 }
652 // #### text()[1]... 674 // #### text()[1]...
653 } 675 }
654 findBest(at, d, node->next(), used, nletter, tiles, n, blankvalues, blused); 676 findBest(at, d, node->next(), used, nletter, tiles, n, blankvalues, blused);
655} 677}
656 678
657void ComputerPlayer::noteChoice(const Tile** tiles, int n, const QPoint& d, const Tile* blankvalues, int blused) 679void ComputerPlayer::noteChoice(const Tile** tiles, int n, const QPoint& d, const Tile* blankvalues, int blused)
658{ 680{
659 int s = board->score(current, tiles, n, blankvalues, d, TRUE, 0); 681 int s = board->score(current, tiles, n, blankvalues, d, TRUE, 0);
660/* 682/*
661if (s>0 || current==QPoint(5,1)){ 683if (s>0 || current==QPoint(5,1)){
662QString st; 684QString st;
663for ( int i=0; i<n; i++ ) 685for ( int i=0; i<n; i++ )
664 st += tiles[i]->text(); 686 st += tiles[i]->text();
665qDebug("%d,%d: %s (%d) for %d",current.x(),current.y(),st.latin1(),n,s); 687qDebug("%d,%d: %s (%d) for %d",current.x(),current.y(),st.latin1(),n,s);
666} 688}
667*/ 689*/
668 if ( s > best_score ) { 690 if ( s > best_score ) {
669 int i; 691 int i;
670 for ( i=0; i<n; i++ ) 692 for ( i=0; i<n; i++ )
671 best[i] = tiles[i]; 693 best[i] = tiles[i];
672 for ( i=0; i<blused; i++ ) 694 for ( i=0; i<blused; i++ )
673 best_blankvalues[i] = blankvalues[i]; 695 best_blankvalues[i] = blankvalues[i];
674 best_n = n; 696 best_n = n;
675 best_blused = blused; 697 best_blused = blused;
676 best_score = s; 698 best_score = s;
677 best_dir = d; 699 best_dir = d;
678 best_start = current; 700 best_start = current;
679 } 701 }
680} 702}
681 703
682int TileItem::smallWidth() 704int TileItem::smallWidth()
683{ 705{
684 return 16; 706 return tile_smallw;
685} 707}
686 708
687int TileItem::smallHeight() 709int TileItem::smallHeight()
688{ 710{
689 return 16; 711 return tile_smallh;
690} 712}
691 713
692int TileItem::bigWidth() 714int TileItem::bigWidth()
693{ 715{
694 return 22; 716 return tile_bigw;
695} 717}
696 718
697int TileItem::bigHeight() 719int TileItem::bigHeight()
698{ 720{
699 return 22; 721 return tile_bigh;
700} 722}
701 723
702void TileItem::setState( State state ) 724void TileItem::setState( State state )
703{ 725{
704 hide(); 726 hide();
705 s = state; 727 s = state;
706 show(); // ### use update() in Qt 3.0 728 show(); // ### use update() in Qt 3.0
707} 729}
708 730
709void TileItem::setTile(const Tile& tile) 731void TileItem::setTile(const Tile& tile)
710{ 732{
711 hide(); 733 hide();
712 t = tile; 734 t = tile;
713 show(); // ### use update() in Qt 3.0 735 show(); // ### use update() in Qt 3.0
714} 736}
715 737
716void TileItem::setBig(bool b) 738void TileItem::setBig(bool b)
717{ 739{
718 big = b; 740 big = b;
719} 741}
720 742
721void TileItem::drawShape(QPainter& p) 743void TileItem::drawShape(QPainter& p)
722{ 744{
723 static QFont value_font("heletica",8); 745 static QFont *value_font=0;
724 static QFont big_font("smoothtimes",17); 746 static QFont *big_font=0;
725 static QFont small_font("smoothtimes",10); 747 static QFont *small_font=0;
748 if ( !value_font ) {
749 value_font = new QFont("helvetica",8);
750 if ( TileItem::bigWidth() < 20 ) {
751 big_font = new QFont("helvetica",12);
752 small_font = new QFont("helvetica",8);
753 } else {
754 big_font = new QFont("smoothtimes",17);
755 small_font = new QFont("smoothtimes",10);
756 }
757 }
726 758
727 QRect area(x(),y(),width(),height()); 759 QRect area(x(),y(),width(),height());
728 p.setBrush(s == Floating ? yellow/*lightGray*/ : white); 760 p.setBrush(s == Floating ? yellow/*lightGray*/ : white);
729 p.drawRect(area); 761 p.drawRect(area);
730 if ( big ) { 762 if ( big ) {
731 p.setFont(value_font); 763 p.setFont(*value_font);
732 QString n = QString::number(t.value()); 764 QString n = QString::number(t.value());
733 int w = p.fontMetrics().width('1'); 765 int w = p.fontMetrics().width('1');
734 int h = p.fontMetrics().height(); 766 int h = p.fontMetrics().height();
735 w *= n.length(); 767 w *= n.length();
736 QRect valuearea(x()+width()-w-2,y()+height()-h+1,w,h); 768 QRect valuearea(x()+width()-w-1,y()+height()-h,w,h);
737 p.drawText(valuearea,AlignCenter,n); 769 p.drawText(valuearea,AlignCenter,n);
738 p.setFont(big_font); 770 p.setFont(*big_font);
739 area = QRect(x(),y(),width()-2,height()-1); 771 area = QRect(x(),y()+tile_btweak,width()-4,height()-1);
740 } else { 772 } else {
741 p.setFont(small_font); 773 p.setFont(*small_font);
742 area = QRect(x(),y()+2,width(),height()-2); 774 area = QRect(x()+1+tile_stweak,y()+1,width(),height()-3);
743 } 775 }
744 if ( t.value() == 0 ) 776 if ( t.value() == 0 )
745 p.setPen(darkGray); 777 p.setPen(darkGray);
746 p.drawText(area,AlignCenter,t.text().upper()); 778 p.drawText(area,AlignCenter,t.text().upper());
747} 779}
748 780
749Board::Board(QPixmap bgshapes, int w, int h, QWidget* parent) : 781Board::Board(QPixmap bgshapes, int w, int h, QWidget* parent) :
750 QCanvasView(new QCanvas(bgshapes,w,h, TileItem::smallWidth(), TileItem::smallHeight()), 782 QCanvasView(new QCanvas(bgshapes,w,h, TileItem::smallWidth(), TileItem::smallHeight()),
751 parent) 783 parent)
752{ 784{
785 setFixedSize(w*TileItem::smallWidth(),h*TileItem::smallHeight());
753 grid = new TileItem*[w*h]; 786 grid = new TileItem*[w*h];
754 memset(grid,0,w*h*sizeof(TileItem*)); 787 memset(grid,0,w*h*sizeof(TileItem*));
755 setFrameStyle(0); 788 setFrameStyle(0);
756 setHScrollBarMode(AlwaysOff); 789 setHScrollBarMode(AlwaysOff);
757 setVScrollBarMode(AlwaysOff); 790 setVScrollBarMode(AlwaysOff);
758 current_rack = 0; 791 current_rack = 0;
759 shown_n = 0; 792 shown_n = 0;
760} 793}
761 794
762Board::~Board() 795Board::~Board()
763{ 796{
764 delete canvas(); 797 delete canvas();
765} 798}
766 799
800QSize Board::sizeHint() const
801{
802 return QSize(canvas()->width(),canvas()->height());
803}
804
767void Board::writeConfig(Config& cfg) 805void Board::writeConfig(Config& cfg)
768{ 806{
769 QStringList t; 807 QStringList t;
770 int n=canvas()->tilesHorizontally()*canvas()->tilesVertically(); 808 int n=canvas()->tilesHorizontally()*canvas()->tilesVertically();
771 for (int i=0; i<n; i++) 809 for (int i=0; i<n; i++)
772 t.append( grid[i] ? grid[i]->tile().key() : QString(".") ); 810 t.append( grid[i] ? grid[i]->tile().key() : QString(".") );
773 cfg.writeEntry("Board",t,';'); 811 cfg.writeEntry("Board",t,';');
774} 812}
775 813
776void Board::readConfig(Config& cfg) 814void Board::readConfig(Config& cfg)
777{ 815{
778 clear(); 816 clear();
779 QStringList t = cfg.readListEntry("Board",';'); 817 QStringList t = cfg.readListEntry("Board",';');
780 int i=0; 818 int i=0;
781 int h=canvas()->tilesHorizontally(); 819 int h=canvas()->tilesHorizontally();
782 for (QStringList::ConstIterator it=t.begin(); it!=t.end(); ++it) { 820 for (QStringList::ConstIterator it=t.begin(); it!=t.end(); ++it) {
783 if ( *it != "." ) { 821 if ( *it != "." ) {
784 QPoint p(i%h,i/h); 822 QPoint p(i%h,i/h);
785 setTile(p,Tile(*it)); 823 setTile(p,Tile(*it));
786 } 824 }
787 i++; 825 i++;
788 } 826 }
789 canvas()->update(); 827 canvas()->update();
790} 828}
791 829
792void Board::clear() 830void Board::clear()
793{ 831{
794 int n=canvas()->tilesHorizontally()*canvas()->tilesVertically(); 832 int n=canvas()->tilesHorizontally()*canvas()->tilesVertically();
795 for (int i=0; i<n; i++) { 833 for (int i=0; i<n; i++) {
796 delete grid[i]; 834 delete grid[i];
797 grid[i]=0; 835 grid[i]=0;
798 } 836 }
799} 837}
800 838
801 839
802void Board::setCurrentRack(Rack* r) 840void Board::setCurrentRack(Rack* r)
803{ 841{
804 turn_score = -1; 842 turn_score = -1;
805 current_rack = r; 843 current_rack = r;
806} 844}
807 845
808void Board::resetRack() 846void Board::resetRack()
809{ 847{
810 unshowTurn(); 848 unshowTurn();
811 canvas()->update(); 849 canvas()->update();
812} 850}
813 851
814void Board::contentsMousePressEvent(QMouseEvent* e) 852void Board::contentsMousePressEvent(QMouseEvent* e)
815{ 853{
816 dragstart = e->pos(); 854 dragstart = e->pos();
817} 855}
818 856
819void Board::contentsMouseMoveEvent(QMouseEvent* e) 857void Board::contentsMouseMoveEvent(QMouseEvent* e)
820{ 858{
821 if ( current_rack && !current_rack->computerized() ) { 859 if ( current_rack && !current_rack->computerized() ) {
822 QPoint d = e->pos() - dragstart; 860 QPoint d = e->pos() - dragstart;
823 if ( d.x() <= 0 && d.y() <= 0 ) { 861 if ( d.x() <= 0 && d.y() <= 0 ) {
824 // None 862 // None
825 resetRack(); 863 resetRack();
826 } else { 864 } else {
827 int n; 865 int n;
828 QPoint start=boardPos(dragstart); 866 QPoint start=boardPos(dragstart);
829 QPoint end=boardPos(e->pos()); 867 QPoint end=boardPos(e->pos());
830 QPoint diff=end-start; 868 QPoint diff=end-start;
831 QPoint dir; 869 QPoint dir;
832 if ( d.x() > d.y() ) { 870 if ( d.x() > d.y() ) {
833 n = diff.x()+1; 871 n = diff.x()+1;
834 dir = QPoint(1,0); 872 dir = QPoint(1,0);
835 } else { 873 } else {
836 n = diff.y()+1; 874 n = diff.y()+1;
837 dir = QPoint(0,1); 875 dir = QPoint(0,1);
838 } 876 }
839 877
840 unshowTurn(); 878 unshowTurn();
841 879
842 // Subtract existing tiles from n 880 // Subtract existing tiles from n
843 QPoint t = start; 881 QPoint t = start;
844 for ( int i=n; i--; ) { 882 for ( int i=n; i--; ) {
845 if ( contains(t) && tile(t) ) 883 if ( contains(t) && tile(t) )
846 n--; 884 n--;
847 t += dir; 885 t += dir;
848 } 886 }
849 887
850 // Move start back to real start 888 // Move start back to real start
851 while (contains(start-dir) && tile(start-dir)) 889 while (contains(start-dir) && tile(start-dir))
852 start -= dir; 890 start -= dir;
853 891
854 scoreTurn(start, n, dir); 892 scoreTurn(start, n, dir);
855 showTurn(); 893 showTurn();
856 } 894 }
857 } 895 }
858} 896}
859 897
860void Board::finalizeTurn() 898void Board::finalizeTurn()
861{ 899{
862 int i=0; 900 int i=0;
@@ -1088,192 +1126,197 @@ int Board::score(QPoint at, const Tile** tiles, int n, const Tile* blankvalue, c
1088 side += otherd; 1126 side += otherd;
1089 } 1127 }
1090 } 1128 }
1091 if ( sideword.length() > 1 ) { 1129 if ( sideword.length() > 1 ) {
1092 if ( words ) 1130 if ( words )
1093 words->append(sideword); 1131 words->append(sideword);
1094 if ( checkdict && !Global::fixedDawg().contains(sideword) 1132 if ( checkdict && !Global::fixedDawg().contains(sideword)
1095 && !Global::dawg("WordGame").contains(sideword) ) 1133 && !Global::dawg("WordGame").contains(sideword) )
1096 return -1; 1134 return -1;
1097 totalsidetotal += sidetotal * side_mult; 1135 totalsidetotal += sidetotal * side_mult;
1098 connected = TRUE; 1136 connected = TRUE;
1099 } 1137 }
1100 i++; 1138 i++;
1101 } 1139 }
1102 at += d; 1140 at += d;
1103 } 1141 }
1104 1142
1105 if ( words ) 1143 if ( words )
1106 words->append(mainword); 1144 words->append(mainword);
1107 if ( checkdict && !Global::fixedDawg().contains(mainword) 1145 if ( checkdict && !Global::fixedDawg().contains(mainword)
1108 && !Global::dawg("WordGame").contains(mainword) ) 1146 && !Global::dawg("WordGame").contains(mainword) )
1109 return -1; 1147 return -1;
1110 1148
1111 if ( n == rack_tiles ) 1149 if ( n == rack_tiles )
1112 totalsidetotal += rack_tiles_bonus; 1150 totalsidetotal += rack_tiles_bonus;
1113 1151
1114 return connected ? totalsidetotal + total * all_mult : -1; 1152 return connected ? totalsidetotal + total * all_mult : -1;
1115} 1153}
1116 1154
1117QPoint Board::boardPos(const QPoint& p) const 1155QPoint Board::boardPos(const QPoint& p) const
1118{ 1156{
1119 return QPoint(p.x()/canvas()->tileWidth(), p.y()/canvas()->tileHeight()); 1157 return QPoint(p.x()/canvas()->tileWidth(), p.y()/canvas()->tileHeight());
1120} 1158}
1121 1159
1122void Board::contentsMouseReleaseEvent(QMouseEvent*) 1160void Board::contentsMouseReleaseEvent(QMouseEvent*)
1123{ 1161{
1124 if ( current_rack ) { 1162 if ( current_rack ) {
1125 } 1163 }
1126} 1164}
1127 1165
1128 1166
1129void Board::setRules(const QString& shapes, const int* effects) 1167void Board::setRules(const QString& shapes, const int* effects)
1130{ 1168{
1131 rule_shape=shapes; rule_effect=effects; 1169 rule_shape=shapes; rule_effect=effects;
1132 int i=0; 1170 int i=0;
1133 int maxre=0; 1171 int maxre=0;
1134 for (int y=0; y<yTiles(); y++) { 1172 for (int y=0; y<yTiles(); y++) {
1135 for (int x=0; x<xTiles(); x++) { 1173 for (int x=0; x<xTiles(); x++) {
1136 int re = shapes[i++]-'0'; 1174 int re = shapes[i++]-'0';
1137 if ( re > maxre ) maxre = re; 1175 if ( re > maxre ) maxre = re;
1138 canvas()->setTile(x,y,re); 1176 canvas()->setTile(x,y,re);
1139 } 1177 }
1140 } 1178 }
1141 rack_tiles_bonus=effects[maxre+1]; 1179 rack_tiles_bonus=effects[maxre+1];
1142} 1180}
1143 1181
1144void Board::unsetTile(const QPoint& p) 1182void Board::unsetTile(const QPoint& p)
1145{ 1183{
1146 delete item(p); 1184 delete item(p);
1147 grid[idx(p)] = 0; 1185 grid[idx(p)] = 0;
1148} 1186}
1149 1187
1150void Board::setTile(const QPoint& p, const Tile& t) 1188void Board::setTile(const QPoint& p, const Tile& t)
1151{ 1189{
1152 TileItem* it=item(p); 1190 TileItem* it=item(p);
1153 if ( !it ) { 1191 if ( !it ) {
1154 it = grid[idx(p)] = new TileItem(t,FALSE,canvas()); 1192 it = grid[idx(p)] = new TileItem(t,FALSE,canvas());
1155 it->move(p.x()*canvas()->tileWidth(), p.y()*canvas()->tileHeight()); 1193 it->move(p.x()*canvas()->tileWidth(), p.y()*canvas()->tileHeight());
1156 it->show(); 1194 it->show();
1157 } else { 1195 } else {
1158 it->setTile(t); 1196 it->setTile(t);
1159 } 1197 }
1160} 1198}
1161 1199
1162Rack::Rack(int ntiles, QWidget* parent) : QCanvasView( 1200Rack::Rack(int ntiles, QWidget* parent) : QCanvasView(
1163 new QCanvas(ntiles*TileItem::bigWidth(),TileItem::bigHeight()), 1201 new QCanvas(ntiles*TileItem::bigWidth(),TileItem::bigHeight()),
1164 parent), 1202 parent),
1165 item(ntiles) 1203 item(ntiles)
1166{ 1204{
1167 setLineWidth(1); 1205 setLineWidth(1);
1168 setFixedHeight(sizeHint().height()); 1206 setFixedHeight(sizeHint().height());
1169 n = 0; 1207 n = 0;
1170 for (int i=0; i<ntiles; i++) 1208 for (int i=0; i<ntiles; i++)
1171 item[i]=0; 1209 item[i]=0;
1172 setHScrollBarMode(AlwaysOff); 1210 setHScrollBarMode(AlwaysOff);
1173 setVScrollBarMode(AlwaysOff); 1211 setVScrollBarMode(AlwaysOff);
1174 canvas()->setBackgroundColor(gray); 1212 canvas()->setBackgroundColor(gray);
1175 dragging = 0; 1213 dragging = 0;
1176} 1214}
1177 1215
1178Rack::~Rack() 1216Rack::~Rack()
1179{ 1217{
1180 clear(); 1218 clear();
1181 delete canvas(); 1219 delete canvas();
1182} 1220}
1183 1221
1222QSize Rack::sizeHint() const
1223{
1224 return QSize(-1,TileItem::bigHeight()+2);
1225}
1226
1184void Rack::clear() 1227void Rack::clear()
1185{ 1228{
1186 for (int i=0; i<n; i++) 1229 for (int i=0; i<n; i++)
1187 delete item[i]; 1230 delete item[i];
1188 n=0; 1231 n=0;
1189} 1232}
1190 1233
1191void Rack::writeConfig(Config& cfg) 1234void Rack::writeConfig(Config& cfg)
1192{ 1235{
1193 QStringList l; 1236 QStringList l;
1194 for (int i=0; i<n; i++) 1237 for (int i=0; i<n; i++)
1195 l.append(tile(i).key()); 1238 l.append(tile(i).key());
1196 cfg.writeEntry("Tiles",l,';'); 1239 cfg.writeEntry("Tiles",l,';');
1197} 1240}
1198 1241
1199void Rack::readConfig(Config& cfg) 1242void Rack::readConfig(Config& cfg)
1200{ 1243{
1201 clear(); 1244 clear();
1202 int x=0; 1245 int x=0;
1203 QStringList l = cfg.readListEntry("Tiles",';'); 1246 QStringList l = cfg.readListEntry("Tiles",';');
1204 for (QStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) { 1247 for (QStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) {
1205 TileItem *i = new TileItem(Tile(*it),TRUE,canvas()); 1248 TileItem *i = new TileItem(Tile(*it),TRUE,canvas());
1206 i->move(x++,0); 1249 i->move(x++,0);
1207 i->show(); 1250 i->show();
1208 item[n++] = i; 1251 item[n++] = i;
1209 } 1252 }
1210 layoutTiles(); 1253 layoutTiles();
1211} 1254}
1212 1255
1213static int cmp_tileitem(const void *a, const void *b) 1256static int cmp_tileitem(const void *a, const void *b)
1214{ 1257{
1215 const TileItem* ia = *(TileItem**)a; 1258 const TileItem* ia = *(TileItem**)a;
1216 const TileItem* ib = *(TileItem**)b; 1259 const TileItem* ib = *(TileItem**)b;
1217 return int(ia->x() - ib->x()); 1260 return int(ia->x() - ib->x());
1218} 1261}
1219 1262
1220void Rack::layoutTiles() 1263void Rack::layoutTiles()
1221{ 1264{
1222 int w = TileItem::bigWidth()+2; 1265 int w = TileItem::bigWidth()+2;
1223 1266
1224 if ( dragging ) dragging->moveBy(dragging_adj,0); 1267 if ( dragging ) dragging->moveBy(dragging_adj,0);
1225 qsort(item.data(), n, sizeof(TileItem*), cmp_tileitem); 1268 qsort(item.data(), n, sizeof(TileItem*), cmp_tileitem);
1226 if ( dragging ) dragging->moveBy(-dragging_adj,0); 1269 if ( dragging ) dragging->moveBy(-dragging_adj,0);
1227 1270
1228 for (int i=0; i<n ;i++) 1271 for (int i=0; i<n ;i++)
1229 if ( item[i] == dragging ) { 1272 if ( item[i] == dragging ) {
1230 item[i]->setZ(1); 1273 item[i]->setZ(1);
1231 } else { 1274 } else {
1232 item[i]->move(i*w, 0); 1275 item[i]->move(i*w, 0);
1233 item[i]->setZ(0); 1276 item[i]->setZ(0);
1234 } 1277 }
1235 canvas()->update(); 1278 canvas()->update();
1236} 1279}
1237 1280
1238void Rack::setBlanks(const Tile* bv) 1281void Rack::setBlanks(const Tile* bv)
1239{ 1282{
1240 for (int j=0; j<n; j++) { 1283 for (int j=0; j<n; j++) {
1241 Tile tt = item[j]->tile(); 1284 Tile tt = item[j]->tile();
1242 if ( tt.isBlank() ) { 1285 if ( tt.isBlank() ) {
1243 tt.setText(bv->text()); 1286 tt.setText(bv->text());
1244 item[j]->setTile(tt); 1287 item[j]->setTile(tt);
1245 bv++; 1288 bv++;
1246 } 1289 }
1247 } 1290 }
1248} 1291}
1249 1292
1250bool Rack::arrangeTiles(const Tile** s, int sn) 1293bool Rack::arrangeTiles(const Tile** s, int sn)
1251{ 1294{
1252 bool could = TRUE; 1295 bool could = TRUE;
1253 for (int j=0; j<n; j++) { 1296 for (int j=0; j<n; j++) {
1254 Tile tt = item[j]->tile(); 1297 Tile tt = item[j]->tile();
1255 int f=-1; 1298 int f=-1;
1256 for (int i=0; i<sn && f<0; i++) { 1299 for (int i=0; i<sn && f<0; i++) {
1257 if (s[i] && *s[i] == tt ) { 1300 if (s[i] && *s[i] == tt ) {
1258 s[i]=0; 1301 s[i]=0;
1259 f=i; 1302 f=i;
1260 } 1303 }
1261 } 1304 }
1262 if ( f >= 0 ) { 1305 if ( f >= 0 ) {
1263 item[j]->move(f-999,0); 1306 item[j]->move(f-999,0);
1264 } else { 1307 } else {
1265 could = FALSE; 1308 could = FALSE;
1266 } 1309 }
1267 } 1310 }
1268 layoutTiles(); 1311 layoutTiles();
1269 return could; 1312 return could;
1270} 1313}
1271 1314
1272void Rack::addTile(const Tile& t) 1315void Rack::addTile(const Tile& t)
1273{ 1316{
1274 TileItem *i = new TileItem(t,TRUE,canvas()); 1317 TileItem *i = new TileItem(t,TRUE,canvas());
1275 i->show(); 1318 i->show();
1276 item[n++] = i; 1319 item[n++] = i;
1277 layoutTiles(); 1320 layoutTiles();
1278} 1321}
1279 1322
diff --git a/noncore/games/wordgame/wordgame.h b/noncore/games/wordgame/wordgame.h
index 0ffa56a..f73c85a 100644
--- a/noncore/games/wordgame/wordgame.h
+++ b/noncore/games/wordgame/wordgame.h
@@ -55,322 +55,326 @@ public:
55 } 55 }
56 56
57 Tile(const QString& key); 57 Tile(const QString& key);
58 58
59 int value() const { return val; } 59 int value() const { return val; }
60 bool isBlank() const { return blank; } 60 bool isBlank() const { return blank; }
61 QString text() const { return txt; } 61 QString text() const { return txt; }
62 void setText(const QString& t) 62 void setText(const QString& t)
63 { 63 {
64 txt = t; 64 txt = t;
65 } 65 }
66 66
67 int operator==(const Tile& o) const 67 int operator==(const Tile& o) const
68 { return o.txt == txt && o.val == val && o.blank == blank; } 68 { return o.txt == txt && o.val == val && o.blank == blank; }
69 int operator!=(const Tile& o) const 69 int operator!=(const Tile& o) const
70 { return !operator==(o); } 70 { return !operator==(o); }
71 Tile& operator=(const Tile& o) 71 Tile& operator=(const Tile& o)
72 { txt=o.txt; val=o.val; blank=o.blank; return *this; } 72 { txt=o.txt; val=o.val; blank=o.blank; return *this; }
73 73
74 QString key() const; 74 QString key() const;
75 75
76private: 76private:
77 QString txt; 77 QString txt;
78 int val; 78 int val;
79 bool blank; 79 bool blank;
80}; 80};
81 81
82class Bag { 82class Bag {
83public: 83public:
84 Bag(); 84 Bag();
85 85
86 void readConfig(Config&); 86 void readConfig(Config&);
87 void writeConfig(Config&); 87 void writeConfig(Config&);
88 88
89 void add(const Tile&); 89 void add(const Tile&);
90 bool isEmpty() const { return tiles.isEmpty(); } 90 bool isEmpty() const { return tiles.isEmpty(); }
91 Tile takeRandom(); 91 Tile takeRandom();
92private: 92private:
93 QList<Tile> tiles; 93 QList<Tile> tiles;
94}; 94};
95 95
96class TileItem : public QCanvasRectangle { 96class TileItem : public QCanvasRectangle {
97public: 97public:
98 TileItem(const Tile& tile, bool b, QCanvas* c) : 98 TileItem(const Tile& tile, bool b, QCanvas* c) :
99 QCanvasRectangle(0,0, 99 QCanvasRectangle(0,0,
100 b?bigWidth():smallWidth(), 100 b?bigWidth():smallWidth(),
101 b?bigHeight():smallHeight(),c), 101 b?bigHeight():smallHeight(),c),
102 t(tile), big(b), s(Firm) 102 t(tile), big(b), s(Firm)
103 { 103 {
104 } 104 }
105 105
106 static int smallWidth(); 106 static int smallWidth();
107 static int smallHeight(); 107 static int smallHeight();
108 static int bigWidth(); 108 static int bigWidth();
109 static int bigHeight(); 109 static int bigHeight();
110 110
111 enum State { Firm, Floating }; 111 enum State { Firm, Floating };
112 void setState( State state ); 112 void setState( State state );
113 State state() const { return s; } 113 State state() const { return s; }
114 const Tile& tile() const { return t; } 114 const Tile& tile() const { return t; }
115 void setTile(const Tile&); 115 void setTile(const Tile&);
116 void setBig(bool); 116 void setBig(bool);
117 117
118protected: 118protected:
119 void drawShape(QPainter&); 119 void drawShape(QPainter&);
120 120
121private: 121private:
122 Tile t; 122 Tile t;
123 bool big; 123 bool big;
124 State s; 124 State s;
125}; 125};
126 126
127class Rack : public QCanvasView { 127class Rack : public QCanvasView {
128public: 128public:
129 Rack(int ntiles, QWidget* parent); 129 Rack(int ntiles, QWidget* parent);
130 ~Rack(); 130 ~Rack();
131 131
132 void readConfig(Config&); 132 void readConfig(Config&);
133 void writeConfig(Config&); 133 void writeConfig(Config&);
134 134
135 bool isFull() const { return count()==max(); } 135 bool isFull() const { return count()==max(); }
136 int max() const { return item.count(); } 136 int max() const { return item.count(); }
137 int count() const { return n; } 137 int count() const { return n; }
138 void addTile(const Tile& t); 138 void addTile(const Tile& t);
139 Tile tile(int i) const { return item[i]->tile(); } 139 Tile tile(int i) const { return item[i]->tile(); }
140 const Tile* tileRef(int i) const { return &item[i]->tile(); } 140 const Tile* tileRef(int i) const { return &item[i]->tile(); }
141 void remove(int i); 141 void remove(int i);
142 void remove(Tile); 142 void remove(Tile);
143 bool arrangeTiles(const Tile** s, int sn); 143 bool arrangeTiles(const Tile** s, int sn);
144 void setBlanks(const Tile*); 144 void setBlanks(const Tile*);
145 145
146 void setPlayerName(const QString& name) { nm = name; } 146 void setPlayerName(const QString& name) { nm = name; }
147 QString playerName() const { return nm; } 147 QString playerName() const { return nm; }
148 void setComputerization(int level) { cpu=level; } 148 void setComputerization(int level) { cpu=level; }
149 bool computerized() const { return cpu>0; } 149 bool computerized() const { return cpu>0; }
150 150
151 QSize sizeHint() const;
152
151protected: 153protected:
152 void resizeEvent(QResizeEvent*e); 154 void resizeEvent(QResizeEvent*e);
153 void contentsMousePressEvent(QMouseEvent*); 155 void contentsMousePressEvent(QMouseEvent*);
154 void contentsMouseMoveEvent(QMouseEvent*); 156 void contentsMouseMoveEvent(QMouseEvent*);
155 void contentsMouseReleaseEvent(QMouseEvent*); 157 void contentsMouseReleaseEvent(QMouseEvent*);
156 158
157private: 159private:
158 void clear(); 160 void clear();
159 void layoutTiles(); 161 void layoutTiles();
160 int n; 162 int n;
161 QArray<TileItem*> item; 163 QArray<TileItem*> item;
162 int dragging_adj; 164 int dragging_adj;
163 QPoint dragstart; 165 QPoint dragstart;
164 QCanvasItem* dragging; 166 QCanvasItem* dragging;
165 QString nm; 167 QString nm;
166 int cpu; 168 int cpu;
167}; 169};
168 170
169class Board : public QCanvasView { 171class Board : public QCanvasView {
170 Q_OBJECT 172 Q_OBJECT
171public: 173public:
172 Board(QPixmap bgshapes, int w, int h, QWidget* parent); 174 Board(QPixmap bgshapes, int w, int h, QWidget* parent);
173 ~Board(); 175 ~Board();
174 176
175 void readConfig(Config&); 177 void readConfig(Config&);
176 void writeConfig(Config&); 178 void writeConfig(Config&);
177 179
178 int xTiles() const { return canvas()->tilesHorizontally(); } 180 int xTiles() const { return canvas()->tilesHorizontally(); }
179 int yTiles() const { return canvas()->tilesVertically(); } 181 int yTiles() const { return canvas()->tilesVertically(); }
180 182
181 bool contains(const QPoint& p) const 183 bool contains(const QPoint& p) const
182 { return p.x() >= 0 && p.y() >= 0 184 { return p.x() >= 0 && p.y() >= 0
183 && p.x() < canvas()->tilesHorizontally() 185 && p.x() < canvas()->tilesHorizontally()
184 && p.y() < canvas()->tilesVertically(); } 186 && p.y() < canvas()->tilesVertically(); }
185 const Tile* tile(const QPoint& p) const 187 const Tile* tile(const QPoint& p) const
186 { TileItem* it=item(p); return it ? &it->tile() : 0; } 188 { TileItem* it=item(p); return it ? &it->tile() : 0; }
187 189
188 void setRules(const QString& shapes, const int* effects); 190 void setRules(const QString& shapes, const int* effects);
189 191
190 void clear(); 192 void clear();
191 void unsetTile(const QPoint& p); 193 void unsetTile(const QPoint& p);
192 void setTile(const QPoint& p, const Tile& t); 194 void setTile(const QPoint& p, const Tile& t);
193 195
194 void setTileState(const QPoint& p, TileItem::State s) 196 void setTileState(const QPoint& p, TileItem::State s)
195 { 197 {
196 TileItem* it=item(p); 198 TileItem* it=item(p);
197 if (it) it->setState(s); 199 if (it) it->setState(s);
198 } 200 }
199 201
200 void setCurrentRack(Rack*); 202 void setCurrentRack(Rack*);
201 void resetRack(); 203 void resetRack();
202 void finalizeTurn(); 204 void finalizeTurn();
203 void showTurn(); 205 void showTurn();
204 void scoreTurn(const QPoint& at, int n, const QPoint& d); 206 void scoreTurn(const QPoint& at, int n, const QPoint& d);
205 bool checkTurn(); 207 bool checkTurn();
206 int score(QPoint at, const Tile** tiles, int n, 208 int score(QPoint at, const Tile** tiles, int n,
207 const Tile* blankvalue, 209 const Tile* blankvalue,
208 const QPoint& d, bool ignoredict, QStringList* words) const; 210 const QPoint& d, bool ignoredict, QStringList* words) const;
209 int bonussedValue(const QPoint& at, int base, int& all_mult) const; 211 int bonussedValue(const QPoint& at, int base, int& all_mult) const;
210 bool isStart(const QPoint& at) const; 212 bool isStart(const QPoint& at) const;
211 213
212 int turnScore() const { return turn_score; } 214 int turnScore() const { return turn_score; }
213 215
216 QSize sizeHint() const;
217
214signals: 218signals:
215 void temporaryScore(int); 219 void temporaryScore(int);
216 220
217protected: 221protected:
218 void contentsMousePressEvent(QMouseEvent*); 222 void contentsMousePressEvent(QMouseEvent*);
219 void contentsMouseMoveEvent(QMouseEvent*); 223 void contentsMouseMoveEvent(QMouseEvent*);
220 void contentsMouseReleaseEvent(QMouseEvent*); 224 void contentsMouseReleaseEvent(QMouseEvent*);
221 225
222private: 226private:
223 int idx(const QPoint& p) const 227 int idx(const QPoint& p) const
224 { return p.x()+p.y()*canvas()->tilesHorizontally(); } 228 { return p.x()+p.y()*canvas()->tilesHorizontally(); }
225 TileItem*& item(const QPoint& p) const 229 TileItem*& item(const QPoint& p) const
226 { return grid[idx(p)]; } 230 { return grid[idx(p)]; }
227 TileItem **grid; 231 TileItem **grid;
228 QString rule_shape; 232 QString rule_shape;
229 const int* rule_effect; 233 const int* rule_effect;
230 int rack_tiles_bonus; 234 int rack_tiles_bonus;
231 Rack* current_rack; 235 Rack* current_rack;
232 QPoint boardPos(const QPoint&) const; 236 QPoint boardPos(const QPoint&) const;
233 QPoint dragstart; 237 QPoint dragstart;
234 QPoint shown_at; 238 QPoint shown_at;
235 int shown_n; 239 int shown_n;
236 QPoint shown_step; 240 QPoint shown_step;
237 void unshowTurn(); 241 void unshowTurn();
238 int turn_score; 242 int turn_score;
239}; 243};
240 244
241class ComputerPlayer 245class ComputerPlayer
242{ 246{
243 Board* board; 247 Board* board;
244 Rack* rack; 248 Rack* rack;
245 249
246 bool across; 250 bool across;
247 int dict; 251 int dict;
248 QPoint current; 252 QPoint current;
249 253
250 const Tile** best; 254 const Tile** best;
251 int best_n; 255 int best_n;
252 Tile* best_blankvalues; 256 Tile* best_blankvalues;
253 int best_blused; 257 int best_blused;
254 int best_score; 258 int best_score;
255 QPoint best_dir; 259 QPoint best_dir;
256 QPoint best_start; 260 QPoint best_start;
257 261
258public: 262public:
259 ComputerPlayer(Board* b, Rack* r); 263 ComputerPlayer(Board* b, Rack* r);
260 ~ComputerPlayer(); 264 ~ComputerPlayer();
261 265
262 bool step(); 266 bool step();
263 267
264private: 268private:
265 void findBest(QPoint at, const QPoint& d, const QDawg::Node* node, ulong used, uchar *nletter, const Tile** tiles, int n, Tile* blankvalues, int blused); 269 void findBest(QPoint at, const QPoint& d, const QDawg::Node* node, ulong used, uchar *nletter, const Tile** tiles, int n, Tile* blankvalues, int blused);
266 void noteChoice(const Tile** tiles, int n, const QPoint& d, const Tile* blankvalues, int blused); 270 void noteChoice(const Tile** tiles, int n, const QPoint& d, const Tile* blankvalues, int blused);
267}; 271};
268 272
269class ScoreInfo : public QLabel { 273class ScoreInfo : public QLabel {
270 Q_OBJECT 274 Q_OBJECT
271public: 275public:
272 ScoreInfo( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 276 ScoreInfo( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
273 ~ScoreInfo(); 277 ~ScoreInfo();
274 278
275 void init(const QStringList&); 279 void init(const QStringList&);
276 void addScore(int player, int change); 280 void addScore(int player, int change);
277 int playerScore(int player) const { return score[player]; } 281 int playerScore(int player) const { return score[player]; }
278 void setShowWinner(bool); 282 void setShowWinner(bool);
279 void setBoldOne(int); 283 void setBoldOne(int);
280 284
281 void readConfig(Config&); 285 void readConfig(Config&);
282 void writeConfig(Config&); 286 void writeConfig(Config&);
283 287
284protected: 288protected:
285 QSize sizeHint() const; 289 QSize sizeHint() const;
286 290
287public slots: 291public slots:
288 void showTemporaryScore(int amount); 292 void showTemporaryScore(int amount);
289 293
290private slots: 294private slots:
291 void showScores(); 295 void showScores();
292 296
293private: 297private:
294 QStringList names; 298 QStringList names;
295 int *score; 299 int *score;
296 QTimer* msgtimer; 300 QTimer* msgtimer;
297 bool showwinner; 301 bool showwinner;
298 int boldone; 302 int boldone;
299}; 303};
300 304
301class NewGame; 305class NewGame;
302 306
303class WordGame : public QMainWindow { 307class WordGame : public QMainWindow {
304 Q_OBJECT 308 Q_OBJECT
305public: 309public:
306 WordGame( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 310 WordGame( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
307 ~WordGame(); 311 ~WordGame();
308 312
309private slots: 313private slots:
310 void endTurn(); 314 void endTurn();
311 void resetTurn(); 315 void resetTurn();
312 void passTurn(); 316 void passTurn();
313 void think(); 317 void think();
314 void endGame(); 318 void endGame();
315 void startGame(); 319 void startGame();
316 320
317private: 321private:
318 void writeConfig(); 322 void writeConfig();
319 void readConfig(); 323 void readConfig();
320 324
321 void startGame(const QStringList& pnames); 325 void startGame(const QStringList& pnames);
322 bool mayEndGame(); 326 bool mayEndGame();
323 void openGameSelector(const QStringList& initnames); 327 void openGameSelector(const QStringList& initnames);
324 bool loadRules(const QString& filename); 328 bool loadRules(const QString& filename);
325 void addPlayer(const QString& name); 329 void addPlayer(const QString& name);
326 void addPlayer(const QString& name, int cpu); 330 void addPlayer(const QString& name, int cpu);
327 void nextPlayer(); 331 void nextPlayer();
328 bool refillRack(int i); 332 bool refillRack(int i);
329 void readyRack(int i); 333 void readyRack(int i);
330 Rack* rack(int i) const; 334 Rack* rack(int i) const;
331 335
332 QWidgetStack *racks; 336 QWidgetStack *racks;
333 QToolBar* toolbar; 337 QToolBar* toolbar;
334 QVBox *vbox; 338 QWidget *vbox;
335 Board *board; 339 Board *board;
336 Bag *bag; 340 Bag *bag;
337 ScoreInfo *scoreinfo; 341 ScoreInfo *scoreinfo;
338 QToolButton *done; 342 QToolButton *done;
339 QToolButton *reset; 343 QToolButton *reset;
340 QTimer* aiheart; 344 QTimer* aiheart;
341 ComputerPlayer *cpu; 345 ComputerPlayer *cpu;
342 int player; 346 int player;
343 int nplayers; 347 int nplayers;
344 QStringList namelist; 348 QStringList namelist;
345 bool gameover; 349 bool gameover;
346 QString rules; 350 QString rules;
347 NewGame* newgame; 351 NewGame* newgame;
348}; 352};
349 353
350class NewGame : public NewGameBase { 354class NewGame : public NewGameBase {
351 Q_OBJECT 355 Q_OBJECT
352public: 356public:
353 NewGame(QWidget* parent); 357 NewGame(QWidget* parent);
354 QStringList ruleslist; 358 QStringList ruleslist;
355 359
356public slots: 360public slots:
357 void updateRuleSets(); 361 void updateRuleSets();
358}; 362};
359 363
360class Rules : public RulesBase { 364class Rules : public RulesBase {
361 Q_OBJECT 365 Q_OBJECT
362 366
363public: 367public:
364 Rules(QWidget* parent); 368 Rules(QWidget* parent);
365 369
366signals: 370signals:
367 void rulesChanged(); 371 void rulesChanged();
368 372
369public slots: 373public slots:
370 void editRules(); 374 void editRules();
371 375
372private: 376private:
373 void deleteRuleSet(); 377 void deleteRuleSet();
374}; 378};
375 379
376#endif // WORDGAME_H 380#endif // WORDGAME_H
diff --git a/noncore/multimedia/showimg/settingsdialog.cpp b/noncore/multimedia/showimg/settingsdialog.cpp
deleted file mode 100644
index d21f4cb..0000000
--- a/noncore/multimedia/showimg/settingsdialog.cpp
+++ b/dev/null
@@ -1,57 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3**
4** This file is part of the Qtopia Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#include "settingsdialog.h"
22#include <qslider.h>
23#include <qlabel.h>
24#include <qcheckbox.h>
25
26SettingsDialog::SettingsDialog( QWidget *parent, const char *name, bool modal, WFlags f )
27 : SettingsDialogBase( parent, name, modal, f )
28{
29 connect( delaySlider, SIGNAL(valueChanged(int)), this, SLOT(delayChanged(int)) );
30}
31
32void SettingsDialog::setDelay( int d )
33{
34 delaySlider->setValue( d );
35 delayChanged( d );
36}
37
38int SettingsDialog::delay() const
39{
40 return delaySlider->value();
41}
42
43void SettingsDialog::setRepeat( bool r )
44{
45 repeatCheck->setChecked( r );
46}
47
48bool SettingsDialog::repeat() const
49{
50 return repeatCheck->isChecked();
51}
52
53void SettingsDialog::delayChanged( int d )
54{
55 delayText->setText( QString::number( d ) + " s" );
56}
57
diff --git a/noncore/multimedia/showimg/settingsdialog.h b/noncore/multimedia/showimg/settingsdialog.h
deleted file mode 100644
index 6dfd2c4..0000000
--- a/noncore/multimedia/showimg/settingsdialog.h
+++ b/dev/null
@@ -1,42 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3**
4** This file is part of the Qtopia Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#ifndef SETTINGSDIALOG_H
22#define SETTINGSDIALOG_H
23
24#include "settingsdialogbase.h"
25
26class SettingsDialog : public SettingsDialogBase
27{
28 Q_OBJECT
29public:
30 SettingsDialog( QWidget * parent=0, const char * name=0, bool modal=FALSE, WFlags f=0 );
31
32 void setDelay( int d );
33 int delay() const;
34 void setRepeat( bool r );
35 bool repeat() const;
36
37private slots:
38 void delayChanged( int );
39};
40
41
42#endif
diff --git a/noncore/multimedia/showimg/settingsdialogbase.ui b/noncore/multimedia/showimg/settingsdialogbase.ui
deleted file mode 100644
index ed404d8..0000000
--- a/noncore/multimedia/showimg/settingsdialogbase.ui
+++ b/dev/null
@@ -1,149 +0,0 @@
1<!DOCTYPE UI><UI>
2<class>SettingsDialogBase</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>SettingsDialogBase</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>227</width>
15 <height>258</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Preferences</string>
21 </property>
22 <vbox>
23 <property stdset="1">
24 <name>margin</name>
25 <number>11</number>
26 </property>
27 <property stdset="1">
28 <name>spacing</name>
29 <number>6</number>
30 </property>
31 <widget>
32 <class>QGroupBox</class>
33 <property stdset="1">
34 <name>name</name>
35 <cstring>GroupBox1</cstring>
36 </property>
37 <property stdset="1">
38 <name>title</name>
39 <string>Slide Show</string>
40 </property>
41 <vbox>
42 <property stdset="1">
43 <name>margin</name>
44 <number>11</number>
45 </property>
46 <property stdset="1">
47 <name>spacing</name>
48 <number>6</number>
49 </property>
50 <widget>
51 <class>QCheckBox</class>
52 <property stdset="1">
53 <name>name</name>
54 <cstring>repeatCheck</cstring>
55 </property>
56 <property stdset="1">
57 <name>text</name>
58 <string>Repeat</string>
59 </property>
60 </widget>
61 <widget>
62 <class>QLayoutWidget</class>
63 <property stdset="1">
64 <name>name</name>
65 <cstring>Layout1</cstring>
66 </property>
67 <hbox>
68 <property stdset="1">
69 <name>margin</name>
70 <number>0</number>
71 </property>
72 <property stdset="1">
73 <name>spacing</name>
74 <number>6</number>
75 </property>
76 <widget>
77 <class>QLabel</class>
78 <property stdset="1">
79 <name>name</name>
80 <cstring>TextLabel1</cstring>
81 </property>
82 <property stdset="1">
83 <name>text</name>
84 <string>Delay</string>
85 </property>
86 </widget>
87 <widget>
88 <class>QSlider</class>
89 <property stdset="1">
90 <name>name</name>
91 <cstring>delaySlider</cstring>
92 </property>
93 <property stdset="1">
94 <name>minValue</name>
95 <number>5</number>
96 </property>
97 <property stdset="1">
98 <name>maxValue</name>
99 <number>60</number>
100 </property>
101 <property stdset="1">
102 <name>lineStep</name>
103 <number>5</number>
104 </property>
105 <property stdset="1">
106 <name>orientation</name>
107 <enum>Horizontal</enum>
108 </property>
109 <property stdset="1">
110 <name>tickmarks</name>
111 <enum>Right</enum>
112 </property>
113 <property stdset="1">
114 <name>tickInterval</name>
115 <number>10</number>
116 </property>
117 </widget>
118 <widget>
119 <class>QLabel</class>
120 <property stdset="1">
121 <name>name</name>
122 <cstring>delayText</cstring>
123 </property>
124 <property stdset="1">
125 <name>minimumSize</name>
126 <size>
127 <width>25</width>
128 <height>0</height>
129 </size>
130 </property>
131 <property stdset="1">
132 <name>text</name>
133 <string>s</string>
134 </property>
135 <property stdset="1">
136 <name>alignment</name>
137 <set>AlignVCenter|AlignRight</set>
138 </property>
139 <property>
140 <name>hAlign</name>
141 </property>
142 </widget>
143 </hbox>
144 </widget>
145 </vbox>
146 </widget>
147 </vbox>
148</widget>
149</UI>
diff --git a/pics/cards/circle.png b/pics/cards/circle.png
deleted file mode 100644
index 3b006de..0000000
--- a/pics/cards/circle.png
+++ b/dev/null
Binary files differ
diff --git a/pics/cards/cross.png b/pics/cards/cross.png
deleted file mode 100644
index cac7576..0000000
--- a/pics/cards/cross.png
+++ b/dev/null
Binary files differ
diff --git a/pics/inline/today.png b/pics/inline/today.png
deleted file mode 100644
index ac244c6..0000000
--- a/pics/inline/today.png
+++ b/dev/null
Binary files differ
diff --git a/pics/slideshow.png b/pics/slideshow.png
deleted file mode 100644
index 9a7f8d5..0000000
--- a/pics/slideshow.png
+++ b/dev/null
Binary files differ