author | kergoth <kergoth> | 2002-06-07 18:53:14 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2002-06-07 18:53:14 (UTC) |
commit | 640d964cfdc7467f6cacb513087cd3acda2c04f0 (patch) (side-by-side diff) | |
tree | 9a784686c1795f8b1f81eb344598f3b549d43467 | |
parent | dfb9c76738bb68e235114c5ad43dbd26a59b98ab (diff) | |
download | opie-640d964cfdc7467f6cacb513087cd3acda2c04f0.zip opie-640d964cfdc7467f6cacb513087cd3acda2c04f0.tar.gz opie-640d964cfdc7467f6cacb513087cd3acda2c04f0.tar.bz2 |
Backing out unintentional merge from TT branch.
70 files changed, 646 insertions, 1607 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 @@ -# Compiling -INTERFACE_DECL_PATH = . -SYSCONF_CXX = arm-linux-g++ -SYSCONF_CC = arm-linux-gcc -DASHCROSS = -arm - -# Set XROOT to the root directory of the arm X11 files for cross compiling -XROOT=/scratch/src/xfree86.41/xbinaries -# Compiling with support libraries -SYSCONF_CXXFLAGS_X11 = -SYSCONF_CXXFLAGS_QT = -I$(QTDIR)/include -SYSCONF_CXXFLAGS_OPENGL = -I$(XROOT)/usr/X11R6/include - -# Compiling YACC output -SYSCONF_CXXFLAGS_YACC = -Wno-unused -Wno-parentheses - -# Linking with support libraries -SYSCONF_RPATH_X11 = -SYSCONF_RPATH_QT = -Wl,-rpath,$(QTDIR)/lib,-rpath,$(XROOT)/usr/X11R6/lib -SYSCONF_RPATH_OPENGL = -Wl,-rpath,$(XROOT)/usr/X11R6/lib - -# Linking with support libraries -# X11 -SYSCONF_LFLAGS_X11 = -SYSCONF_LIBS_X11 = -# Qt, Qt+OpenGL -SYSCONF_LFLAGS_QT = -L$(QTDIR)/lib -SYSCONF_LIBS_QT = -lqt$(QT_THREAD_SUFFIX) -SYSCONF_LIBS_QT_OPENGL = -# OpenGL -SYSCONF_LFLAGS_OPENGL = -L$(XROOT)/usr/X11R6/lib -SYSCONF_LIBS_OPENGL = -# Yacc -SYSCONF_LIBS_YACC = - -# Linking applications -SYSCONF_LINK = arm-linux-gcc -SYSCONF_LFLAGS = -SYSCONF_LIBS = - -# Link flags for shared objects -SYSCONF_LFLAGS_SHOBJ = -shared - -# Flags for threading -SYSCONF_CFLAGS_THREAD = -D_REENTRANT -SYSCONF_CXXFLAGS_THREAD = -D_REENTRANT -SYSCONF_LFLAGS_THREAD = -SYSCONF_LIBS_THREAD = -lpthread - -# Point to /usr/bin for moc and uic since we are cross compiling here -# Meta-object compiler -SYSCONF_MOC = /usr/bin/moc - -# UI compiler -SYSCONF_UIC = /usr/bin/uic - -# Linking shared libraries -# - Build the $(TARGET) library, eg. lib$(TARGET).so.2.2.2 -# - Place target in $(DESTDIR) - which has a trailing / -# - Usually needs to incorporate $(VER_MAJ), $(VER_MIN) and $(VER_PATCH) -# -SYSCONF_LINK_SHLIB = arm-linux-gcc -SYSCONF_LINK_TARGET_SHARED = lib$(TARGET).so.$(VER_MAJ).$(VER_MIN).$(VER_PATCH) -SYSCONF_LINK_LIB_SHARED = $(SYSCONF_LINK_SHLIB) -shared -Wl,-soname,lib$(TARGET).so.$(VER_MAJ) \ - $(LFLAGS) -o $(SYSCONF_LINK_TARGET_SHARED) \ - $(OBJECTS) $(OBJMOC) $(LIBS) && \ - mv $(SYSCONF_LINK_TARGET_SHARED) $(DESTDIR); \ - cd $(DESTDIR) && \ - rm -f lib$(TARGET).so lib$(TARGET).so.$(VER_MAJ) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN); \ - ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so; \ - ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ); \ - ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN) - -# Linking static libraries -# - Build the $(TARGET) library, eg. lib$(TARGET).a -# - Place target in $(DESTDIR) - which has a trailing / -# -SYSCONF_AR = arm-linux-ar cqs -SYSCONF_LINK_TARGET_STATIC = lib$(TARGET).a -SYSCONF_LINK_LIB_STATIC = rm -f $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) ; \ - $(SYSCONF_AR) $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) $(OBJECTS) $(OBJMOC) -# Compiling application source -SYSCONF_CXXFLAGS = -pipe -DQT_NO_COP -fno-exceptions -fno-rtti -O2 -Wall -W -SYSCONF_CFLAGS = -pipe -O2 -Wall -W -# Default link type (static linking is still be used where required) -SYSCONF_LINK_LIB = $(SYSCONF_LINK_LIB_SHARED) -SYSCONF_LINK_TARGET = $(SYSCONF_LINK_TARGET_SHARED) -# Compiling library source -SYSCONF_CXXFLAGS_LIB = -fPIC -SYSCONF_CFLAGS_LIB = -fPIC -# Compiling shared-object source -SYSCONF_CXXFLAGS_SHOBJ = -fPIC -SYSCONF_CFLAGS_SHOBJ = -fPIC -# Linking Qt -SYSCONF_LIBS_QTLIB = $(SYSCONF_LFLAGS_X11) $(QT_LIBS_MT) $(QT_LIBS_OPT) -# Linking Qt applications -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 @@ -# Compiling -INTERFACE_DECL_PATH = . -SYSCONF_CXX = g++ -SYSCONF_CC = gcc -DASHCROSS = - -# Compiling with support libraries -SYSCONF_CXXFLAGS_X11 = -SYSCONF_CXXFLAGS_QT = -I$(QTDIR)/include -SYSCONF_CXXFLAGS_OPENGL = -I/usr/X11R6/include - -# Compiling YACC output -SYSCONF_CXXFLAGS_YACC = -Wno-unused -Wno-parentheses - -# Linking with support libraries -SYSCONF_RPATH_X11 = -SYSCONF_RPATH_QT = -Wl,-rpath,$(QTDIR)/lib -SYSCONF_RPATH_OPENGL = -Wl,-rpath,/usr/X11R6/lib - -# Linking with support libraries -# X11 -SYSCONF_LFLAGS_X11 = -SYSCONF_LIBS_X11 = -# Qt, Qt+OpenGL -SYSCONF_LFLAGS_QT = -L$(QTDIR)/lib -SYSCONF_LIBS_QT = -lqt$(QT_THREAD_SUFFIX) -SYSCONF_LIBS_QT_OPENGL = -# OpenGL -SYSCONF_LFLAGS_OPENGL = -L/usr/X11R6/lib -SYSCONF_LIBS_OPENGL = -# Yacc -SYSCONF_LIBS_YACC = - -# Linking applications -SYSCONF_LINK = gcc -SYSCONF_LFLAGS = -SYSCONF_LIBS = - -# Link flags for shared objects -SYSCONF_LFLAGS_SHOBJ = -shared - -# Flags for threading -SYSCONF_CFLAGS_THREAD = -D_REENTRANT -SYSCONF_CXXFLAGS_THREAD = -D_REENTRANT -SYSCONF_LFLAGS_THREAD = -SYSCONF_LIBS_THREAD = -lpthread - -# Meta-object compiler -SYSCONF_MOC = $(QTDIR)/bin/moc - -# UI compiler -SYSCONF_UIC = $(QTDIR)/bin/uic - -# Linking shared libraries -# - Build the $(TARGET) library, eg. lib$(TARGET).so.2.2.2 -# - Place target in $(DESTDIR) - which has a trailing / -# - Usually needs to incorporate $(VER_MAJ), $(VER_MIN) and $(VER_PATCH) -# -SYSCONF_LINK_SHLIB = gcc -SYSCONF_LINK_TARGET_SHARED = lib$(TARGET).so.$(VER_MAJ).$(VER_MIN).$(VER_PATCH) -SYSCONF_LINK_LIB_SHARED = $(SYSCONF_LINK_SHLIB) -shared -Wl,-soname,lib$(TARGET).so.$(VER_MAJ) \ - $(LFLAGS) -o $(SYSCONF_LINK_TARGET_SHARED) \ - $(OBJECTS) $(OBJMOC) $(LIBS) && \ - mv $(SYSCONF_LINK_TARGET_SHARED) $(DESTDIR); \ - cd $(DESTDIR) && \ - rm -f lib$(TARGET).so lib$(TARGET).so.$(VER_MAJ) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN); \ - ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so; \ - ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ); \ - ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN) - -# Linking static libraries -# - Build the $(TARGET) library, eg. lib$(TARGET).a -# - Place target in $(DESTDIR) - which has a trailing / -# -SYSCONF_AR = ar cqs -SYSCONF_LINK_TARGET_STATIC = lib$(TARGET).a -SYSCONF_LINK_LIB_STATIC = rm -f $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) ; \ - $(SYSCONF_AR) $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) $(OBJECTS) $(OBJMOC) -# Compiling application source -SYSCONF_CXXFLAGS = -pipe -DQT_NO_COP -fno-exceptions -fno-rtti -O2 -Wall -W -SYSCONF_CFLAGS = -pipe -O2 -Wall -W -# Default link type (static linking is still be used where required) -SYSCONF_LINK_LIB = $(SYSCONF_LINK_LIB_SHARED) -SYSCONF_LINK_TARGET = $(SYSCONF_LINK_TARGET_SHARED) -# Compiling library source -SYSCONF_CXXFLAGS_LIB = -fPIC -SYSCONF_CFLAGS_LIB = -fPIC -# Compiling shared-object source -SYSCONF_CXXFLAGS_SHOBJ = -fPIC -SYSCONF_CFLAGS_SHOBJ = -fPIC -# Linking Qt -SYSCONF_LIBS_QTLIB = $(SYSCONF_LFLAGS_X11) $(QT_LIBS_MT) $(QT_LIBS_OPT) -# Linking Qt applications -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 @@ -/********************************************************************** -** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. -** -** This file is part of the Qtopia Environment. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include "layoutmanager.h" - -static const int min_height = 15; - -LayoutItem::LayoutItem( const EffectiveEvent e ) : eevent(e) { } - -LayoutManager::LayoutManager(int w, int h) : width(w), height(h), maxWidth(w) { } - -LayoutManager::~LayoutManager() { } - -void LayoutManager::setSize(int w, int h) -{ - height = h; - maxWidth = width = w; - // with changed, re-init, re-layout items. - for (uint i = 0; i < mItems.count(); i++) - initializeGeometry(mItems.at(i)); -} - -void LayoutManager::setOccurances(QValueList<EffectiveEvent> &events) -{ - mItems.clear(); - - QValueListIterator<EffectiveEvent> it; - for ( it = events.begin(); it != events.end(); ++it ) { - addOccurance(*it); - } - layoutItems(TRUE); -} - -void LayoutManager::addOccurance(EffectiveEvent &event) -{ - LayoutItem *i = new LayoutItem(event); - initializeGeometry(i); - addItem(i); -} - -void LayoutManager::addItem(LayoutItem *i) -{ - mItems.resize(mItems.size() + 1); - mItems.insert(mItems.size() - 1, i); -} - -void LayoutManager::layoutItems(bool resetMaxWidth) -{ - if (resetMaxWidth) - maxWidth = width; - - int iCount = mItems.count(); - int itemWidth = QMIN(width, maxWidth); - int n = 1; - - if (width < 1) - return; - if (iCount < (width/4)) { - int i = 0; - while (i < iCount) { - LayoutItem *item = mItems.at(i); - int x = 0; - int xp = 0; - QRect geom = item->geometry(); - geom.setX( x ); - geom.setWidth(itemWidth); - while ( xp < n && intersects(item, geom)) { - x += itemWidth; - xp++; - geom.moveBy(itemWidth, 0); - } - if (xp >= n) { - n++; - itemWidth = QMIN(width / n, maxWidth); - i = 0; // Start again. - } else { - item->setGeometry( geom ); - i++; - } - } - } else { - // alturnate algorithm. // same as above, but just overlap - // if fail. - itemWidth = 4; - n = width / itemWidth; - int i = 0; - int rovingXp = 0; - while (i < iCount) { - LayoutItem *item = mItems.at(i); - int x = 0; - int xp = 0; - QRect geom = item->geometry(); - geom.setX( x ); - geom.setWidth(itemWidth); - while ( xp < n && intersects(item, geom)) { - x += itemWidth; - xp++; - geom.moveBy(itemWidth, 0); - } - if (xp >= n) { - geom.setX(rovingXp * itemWidth); - geom.setWidth(itemWidth); - rovingXp++; - item->setGeometry( geom ); - } else { - item->setGeometry( geom ); - } - i++; - } - } - if (itemWidth < maxWidth) - maxWidth = itemWidth; -} - -int LayoutManager::timeToHeight( const QTime &time ) const -{ - int y = time.hour() * 60 + time.minute(); - if (y) - y = (y * (height / 24)) / 60; - return y; -} - -QTime LayoutManager::heightToTime( int h ) const -{ - // broken - return QTime(0,0,0); -} - -LayoutItem *LayoutManager::intersects(LayoutItem *item, QRect geom) const -{ - int i = 0; - // allow overlapping - geom.moveBy(1,1); - geom.setSize( geom.size() - QSize(2,2) ); - - LayoutItem *it = mItems.at(i); - int count = mItems.count(); - while (i < count && it != item) { - if (it->geometry().intersects( geom ) ) - return it; - it = mItems.at(++i); - } - return 0; -} - -void LayoutManager::initializeGeometry(LayoutItem *item) -{ - int y = timeToHeight(item->occurance().start()); - int yend = timeToHeight(item->occurance().end()); - - int h = yend - y; - if (h < min_height) - h = min_height; - if (y + min_height > height) { - y = height - min_height; - h = min_height; - } - - item->setGeometry(QRect(0, y, width, h)); -} 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 @@ -/********************************************************************** -** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. -** -** This file is part of the Qtopia Environment. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include <qvector.h> -#include <qvaluelist.h> -#include <qrect.h> -#include <qdatetime.h> -#include <qpe/event.h> - -class LayoutItem -{ -public: - LayoutItem( const EffectiveEvent e ); - - void setGeometry(const QRect &rect) { r = rect; } - void setGeometry(int x, int y, int w, int h) - { setGeometry(QRect(x,y,w,h)); } - QRect geometry() const { return r; } - - EffectiveEvent occurance() const { return eevent; } - Event event() const { return eevent.event(); } - -private: - EffectiveEvent eevent; - QRect r; -}; - -class LayoutManager -{ -public: - LayoutManager(int w, int h); - virtual ~LayoutManager(); - - void setSize(int w, int h); - void setMaximumColumnWidth(int x) { maxWidth = x; }; - int maximumColumnWidth() const { return maxWidth; }; - void setOccurances(QValueList<EffectiveEvent> &events); - virtual void addOccurance(EffectiveEvent &event); - - void clear() { mItems.clear(); } - - QVector<LayoutItem> items() const { return mItems; } - QSize size() const { return QSize(width, height); } - int count() const { return mItems.count(); } - - virtual void layoutItems(bool resetMaxWidth = FALSE); - - virtual int timeToHeight(const QTime &) const; - virtual QTime heightToTime(int) const; - -protected: - void initializeGeometry(LayoutItem *); - LayoutItem *intersects(LayoutItem *, QRect) const; - void addItem(LayoutItem *); - -private: - QVector<LayoutItem> mItems; - int width; - int height; - int maxWidth; -}; 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 @@ -/*! \class InputMethodInterface inputmethodinterface.h - \brief The InputMethodInterface class provides an interface for Qtopia - input methods. - - Input methods must supply a QWidget that will be shown above the task bar - and emit a signal when a key is pressed: - - Input methods may be added to Qtopia via plugins. In order to write an - input method plugin you must create an interface to your input method by - deriving from the InputMethodInterface class and implementing the pure - virtual functions. - - See also: <a href=inputmethods.html>Input Method Tutorial</a> -*/ - - -/*! \fn QWidget *InputMethodInterface::inputMethod( QWidget *parent, Qt::WFlags f ) - - The inputMethod() function returns the input method widget. This - widget will be display just above the task bar when the user needs to input - text. You should always return the same widget if this function is called - multiple times. -*/ - -/*! \fn void InputMethodInterface::resetState() - - The resetState() function should return the input method to its default - state. -*/ - -/*! \fn QString InputMethodInterface::name() - - The name() function returns the name of the input method. This will - be displayed in the popup list of available input methods. -*/ - -/*! \fn QPixmap *InputMethodInterface::icon() - - The icon() function returns the icon for the input method. This will - be displayed in the taskbar when the input method is selected. -*/ - - -/*! \fn void InputMethodInterface::onKeyPress( QObject *receiver, const char *slot ) - - The onKeyPress() function must connect the supplied slot to the signal - that is emitted when a key press is generated. -*/ - diff --git a/examples/application/Example.png b/examples/application/Example.png Binary files differdeleted file mode 100644 index f63d0bc..0000000 --- a/examples/application/Example.png +++ b/dev/null 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 @@ -See /opt/Qtopia/doc/index.html for help. -See 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 @@ -Files: bin/example apps/Applications/example.desktop pics/Example.png help/html/example.html -Priority: optional -Section: qpe/applications -Maintainer: Your Name <you@your.domain.com> -Architecture: arm -Version: 1.0.0 -Depends: qpe-base ($QPE_VERSION) -License: Public Domain -Description: Example program - An example program for the Qtopia environment. - 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 @@ -#include "example.h" -#include <qpushbutton.h> - -/* - * Constructs a Example which is a child of 'parent', with the - * name 'name' and widget flags set to 'f' - */ -Example::Example( QWidget* parent, const char* name, WFlags fl ) - : ExampleBase( parent, name, fl ) -{ - connect(quit, SIGNAL(clicked()), this, SLOT(goodBye())); -} - -/* - * Destroys the object and frees any allocated resources - */ -Example::~Example() -{ - // no need to delete child widgets, Qt does it all for us -} - -/* - * A simple slot... not very interesting. - */ -void Example::goodBye() -{ - close(); -} 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 @@ -[Desktop Entry] -Comment=An Example Program -Exec=example -Icon=Example -Type=Application -Name=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 @@ -#ifndef EXAMPLE_H -#define EXAMPLE_H -#include "examplebase.h" - -class Example : public ExampleBase -{ - Q_OBJECT - -public: - Example( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); - ~Example(); - -private slots: - void goodBye(); -}; - -#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 @@ -<html> -<h1>Example</h1> - -<p>This is the help for the Example program. - -<p>To user this application: - -<ol> - <li>Press the <img width=12 height=12 src=Example.png> icon in the Qtopia launcher. - <li>Read the label. - <li>Press the button. - <li>Read the source code provided. -</ol> - -Now 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 @@ -TEMPLATE = app -#CONFIG = qt warn_on debug -CONFIG = qt warn_on release -HEADERS = example.h -SOURCES = main.cpp example.cpp -INCLUDEPATH += $(QPEDIR)/include -DEPENDPATH += $(QPEDIR)/include -LIBS += -lqpe -INTERFACES = examplebase.ui -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 @@ -<!DOCTYPE UI><UI> -<class>ExampleBase</class> -<widget> - <class>QWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>ExampleBase</cstring> - </property> - <property stdset="1"> - <name>geometry</name> - <rect> - <x>0</x> - <y>0</y> - <width>196</width> - <height>245</height> - </rect> - </property> - <property stdset="1"> - <name>caption</name> - <string>Example</string> - </property> - <vbox> - <property stdset="1"> - <name>margin</name> - <number>11</number> - </property> - <property stdset="1"> - <name>spacing</name> - <number>6</number> - </property> - <widget> - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel1</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string><p>This is just an <i>example</i>. It doesn't do anything interesting at all.</string> - </property> - </widget> - <widget> - <class>QPushButton</class> - <property stdset="1"> - <name>name</name> - <cstring>quit</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Quit</string> - </property> - </widget> - </vbox> -</widget> -</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 @@ -<h1 align=center><small>Welcome to the</small><br>Qtopia SDK</h1> - -<h3>API Documentation</h3> -<p> -For API documentation, point a web browser at -/opt/Qtopia/doc/html/qtopia/index.html - -<h3>Application Documentation</h3> -Put English documentation for applications in: - -<p> - $QPEDIR/help/html/<i>appname</i>.html - -<p> -Put non-English documentation for applications in: - -<p> - $QPEDIR/help/<i>lang</i>/html/<i>appname</i>.html - -<p> -Where <i>lang</i> is the language specifier (eg. "de" for German), -and <i>appname</i> is the program name of your application. - 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 @@ -#include "example.h" -#include <qpe/qpeapplication.h> - -int main( int argc, char ** argv ) -{ - QPEApplication a( argc, argv ); - - Example mw; - a.showMainWidget( &mw ); - - return a.exec(); -} 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 @@ -[Desktop Entry] -Comment=Simple QPEPIM Example -Exec=abexample -Icon=abexample -Type=Application -Name=AB QPEPIM diff --git a/examples/qpepim-addressbook/abexample.png b/examples/qpepim-addressbook/abexample.png Binary files differdeleted file mode 100644 index f63d0bc..0000000 --- a/examples/qpepim-addressbook/abexample.png +++ b/dev/null 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 @@ -/********************************************************************** -** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. -** -** This file is part of the Qtopia Environment. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include <qpe/contact.h> -#include <qvaluelist.h> -#include "addressbookdumper.h" - -AddressBookDumper::AddressBookDumper(QWidget* parent) : QMultiLineEdit(parent) { - // connect(&m_ABAccess, SIGNAL(addressbookUpdated()), this, SLOT(abChanged())); -} - -AddressBookDumper::~AddressBookDumper() { -} - -void AddressBookDumper::abChanged() { - QString newText; - QValueList<Contact> contacts = m_ABAccess.contacts(); - QValueListConstIterator<Contact> it; - for (it = contacts.begin() ; it != contacts.end(); it++) { - newText.append((*it).firstName() + " " + (*it).lastName() + "\n"); - } - setText(newText); -} - -void AddressBookDumper::startBigEdit() { - if (m_ABAccess.startBlockEdit()) - qDebug("*** Block edit successfully started."); - else - qDebug("*** Block edit start failed."); -} - -void AddressBookDumper::endBigEdit() { - if (m_ABAccess.endBlockEdit()) - qDebug("*** Block edit successfully ended."); - else - qDebug("*** Block edit end failed."); -} - -void AddressBookDumper::addContact() { - Contact foo; - foo.setFirstName("Foo"); - foo.setLastName("Bar"); - foo.setFileAs(); - if (m_ABAccess.addContact(foo)) - qDebug("*** Add succeeded.."); - else - qDebug("*** Add failed.."); -} 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 @@ -/********************************************************************** -** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. -** -** This file is part of the Qtopia Environment. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include <qmultilineedit.h> -#include <qpe/pim/addressbookaccess.h> - -class AddressBookDumper : public QMultiLineEdit { - Q_OBJECT - - public: - AddressBookDumper(QWidget* parent); - ~AddressBookDumper(); - - public slots: - void abChanged(); - void startBigEdit(); - void endBigEdit(); - void addContact(); - - private: - AddressBookAccess m_ABAccess; -}; 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 @@ -/********************************************************************** -** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. -** -** This file is part of the Qtopia Environment. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include <qpe/qpeapplication.h> -#ifdef QWS -#include <qpe/qcopenvelope_qws.h> -#endif -#include <qapplication.h> -#include <qpe/pim/addressbookaccess.h> -#include "addressbookdumper.h" -#include <qvbox.h> -#include <qpushbutton.h> - -int main( int argc, char ** argv ) -{ - QPEApplication a( argc, argv ); - QVBox* vbox = new QVBox(0L); - QPushButton* clicker = new QPushButton("Refresh", vbox); - QPushButton* startBigEditButton = new QPushButton("Start Big Edit", vbox); - QPushButton* endBigEditButton = new QPushButton("End Big Edit", vbox); - QPushButton* addContactButton = new QPushButton("Add Contact", vbox); - AddressBookDumper* abDumper = new AddressBookDumper(vbox); - QObject::connect(clicker, SIGNAL(clicked()), abDumper, SLOT(abChanged())); - QObject::connect(startBigEditButton, SIGNAL(clicked()), abDumper, SLOT(startBigEdit())); - QObject::connect(endBigEditButton, SIGNAL(clicked()), abDumper, SLOT(endBigEdit())); - QObject::connect(addContactButton, SIGNAL(clicked()), abDumper, SLOT(addContact())); - a.setMainWidget(vbox); - vbox->show(); - return a.exec(); -} 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 @@ -Files: bin/abexample apps/Applications/abexample.desktop -Priority: optional -Section: qpe/applications -Maintainer: Warwick Allison <warwick@trolltech.com> -Architecture: arm -Version: $QPE_VERSION-1 -Depends: qpe-pim, qpe-base ($QPE_VERSION) -Description: Example Addressbook reader - 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 @@ -TEMPLATE = app -CONFIG = qt warn_on debug - -HEADERS = addressbookdumper.h -SOURCES = main.cpp addressbookdumper.cpp -TARGET = abexample -INCLUDEPATH = $(QPEDIR)/include -LIBS += -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 @@ -368,129 +368,129 @@ bool QIMPenCharSet::save( Domain d ) ds << QString( "QPT 1.1" ); ds << csTitle; ds << desc; ds << (Q_INT8)csType; QIMPenCharIterator ci( chars ); for ( ; ci.current(); ++ci ) { QIMPenChar *pc = ci.current(); if ( ( (d == System) && pc->testFlag( QIMPenChar::System ) ) || ( (d == User) && !pc->testFlag( QIMPenChar::System ) ) ) { ds << *pc; } if ( file.status() != IO_Ok ) break; } if ( file.status() == IO_Ok ) ok = TRUE; } if ( ok ) { if ( ::rename( tmpFn.latin1(), fn.latin1() ) < 0 ) { qWarning( "problem renaming file %s to %s, errno: %d", tmpFn.latin1(), fn.latin1(), errno ); // remove the tmp file, otherwise, it will just lay around... QFile::remove( tmpFn.latin1() ); ok = FALSE; } } return ok; } QIMPenChar *QIMPenCharSet::at( int i ) { return chars.at(i); } void QIMPenCharSet::markDeleted( uint ch ) { QIMPenCharIterator ci( chars ); for ( ; ci.current(); ++ci ) { QIMPenChar *pc = ci.current(); if ( pc->character() == ch && pc->testFlag( QIMPenChar::System ) ) pc->setFlag( QIMPenChar::Deleted ); } } /*! Find the best matches for \a ch in this character set. */ QIMPenCharMatchList QIMPenCharSet::match( QIMPenChar *ch ) { QIMPenCharMatchList matches; QIMPenCharIterator ci( chars ); for ( ; ci.current(); ++ci ) { QIMPenChar *tmplChar = ci.current(); if ( tmplChar->testFlag( QIMPenChar::Deleted ) ) { continue; } int err; if ( ch->penStrokes().count() <= tmplChar->penStrokes().count() ) { err = ch->match( tmplChar ); if ( err <= QIMPEN_MATCH_THRESHOLD ) { if (tmplChar->penStrokes().count() != ch->penStrokes().count()) - err = QIMPEN_MATCH_THRESHOLD; + err = QMIN(err*3, QIMPEN_MATCH_THRESHOLD); QIMPenCharMatchList::Iterator it; for ( it = matches.begin(); it != matches.end(); ++it ) { if ( (*it).penChar->character() == tmplChar->character() && (*it).penChar->penStrokes().count() == tmplChar->penStrokes().count() ) { if ( (*it).error > err ) (*it).error = err; break; } } if ( it == matches.end() ) { QIMPenCharMatch m; m.error = err; m.penChar = tmplChar; matches.append( m ); } } } } qHeapSort( matches ); /* QIMPenCharMatchList::Iterator it; for ( it = matches.begin(); it != matches.end(); ++it ) { qDebug( "Match: \'%c\', error %d, strokes %d", (*it).penChar->character(), (*it).error, (*it).penChar->penStrokes().count() ); } */ return matches; } /*! Add a character \a ch to this set. QIMPenCharSet will delete this character when it is no longer needed. */ void QIMPenCharSet::addChar( QIMPenChar *ch ) { if ( ch->penStrokes().count() > maxStrokes ) maxStrokes = ch->penStrokes().count(); chars.append( ch ); } /*! Remove a character by reference \a ch from this set. QIMPenCharSet will delete this character. */ void QIMPenCharSet::removeChar( QIMPenChar *ch ) { chars.remove( ch ); } /*! Move the character up the list of characters. */ void QIMPenCharSet::up( QIMPenChar *ch ) { int idx = chars.findRef( ch ); if ( idx > 0 ) { chars.take(); chars.insert( idx - 1, ch ); } } /*! Move the character down the list of characters. */ 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 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef ALARM_SERVER_H #define ALARM_SERVER_H #include <qstring.h> #include <qdatetime.h> class AlarmServer { public: static void addAlarm ( QDateTime when, const QCString& channel, const QCString& msg, int data=0); static void deleteAlarm (QDateTime when, const QCString& channel, const QCString& msg, int data=0); + +private: + friend int initApplication(int, char **); static void initialize(); }; #endif diff --git a/library/applnk.h b/library/applnk.h index c6f92a3..18e20b6 100644 --- a/library/applnk.h +++ b/library/applnk.h @@ -1,162 +1,165 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef __APPLNK_H__ #define __APPLNK_H__ #include <qobject.h> #include <qiconset.h> #include <qlist.h> #include <qdict.h> #include <qstringlist.h> class AppLnkSetPrivate; class AppLnkPrivate; class AppLnk { public: AppLnk(); AppLnk( const QString &file ); AppLnk( const AppLnk © ); // copy constructor virtual ~AppLnk(); bool isValid() const { return !mLinkFile.isNull(); } static void setSmallIconSize(int); static void setBigIconSize(int); static int smallIconSize(); static int bigIconSize(); QString name() const { return mName; } const QPixmap& pixmap() const; const QPixmap& bigPixmap() const; virtual QString exec() const { return mExec; } QString type() const; QString rotation() const { return mRotation; } QString comment() const { return mComment; } QString file() const; QString linkFile() const; QStringList mimeTypes() const { return mMimeTypes; } QStringList mimeTypeIcons() const { return mMimeTypeIcons; } const QArray<int> &categories() const; int id() const { return mId; } + bool linkFileKnown() const { return !mLinkFile.isNull(); } + void execute() const; void execute(const QStringList& args) const; void removeFiles(); void removeLinkFile(); void setName( const QString& docname ); void setExec( const QString& exec ); void setFile( const QString& filename ); void setLinkFile( const QString& filename ); void setComment( const QString& comment ); void setType( const QString& mimetype ); void setIcon( const QString& iconname ); void setCategories( const QArray<int> &v ); bool writeLink() const; void setProperty(const QString& key, const QString& value); QString property(const QString& key) const; protected: QString mName; QPixmap mPixmap; QPixmap mBigPixmap; QString mExec; QString mType; QString mRotation; QString mComment; QString mFile; QString mLinkFile; QString mIconFile; QStringList mMimeTypes; QStringList mMimeTypeIcons; int mId; static int lastId; AppLnkPrivate *d; friend class AppLnkSet; virtual void invoke(const QStringList& args) const; bool ensureLinkExists() const; + void storeLink() const; }; class DocLnk : public AppLnk { public: DocLnk(); DocLnk( const DocLnk &o ) : AppLnk(o) { } DocLnk( const QString &file ); DocLnk( const QString &file, bool may_be_desktopfile ); virtual ~DocLnk(); QString exec() const; protected: void invoke(const QStringList& args) const; private: void init(const QString &file); }; class AppLnkSet { public: AppLnkSet(); AppLnkSet( const QString &dir ); ~AppLnkSet(); const AppLnk *find( int id ) const; const AppLnk *findExec( const QString& execname ) const; QStringList types() const { return typs; } QString typeName( const QString& ) const; QPixmap typePixmap( const QString& ) const; QPixmap typeBigPixmap( const QString& ) const; void add(AppLnk*); bool remove(AppLnk*); const QList<AppLnk> &children() const { return mApps; } void detachChildren(); protected: friend class AppLnk; QList<AppLnk> mApps; QString mFile; QStringList typs; AppLnkSetPrivate *d; private: AppLnkSet( const AppLnkSet & ); // no copying! void findChildren(const QString &, const QString& t, const QString& lt, int depth = 0); }; class DocLnkSet : public AppLnkSet { public: DocLnkSet(); DocLnkSet( const QString &dir, const QString &mimefilter=QString::null ); const QList<DocLnk> &children() const { return (const QList<DocLnk> &)mApps; } void appendFrom( DocLnkSet& other ); private: 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 @@ -110,158 +110,128 @@ bool CategoryGroup::rename( int uid, const QString &newLabel ) mLabelIdMap[newLabel] = uid; *idIt = newLabel; return TRUE; } bool CategoryGroup::rename( const QString &oldLabel, const QString &newLabel ) { return rename( id(oldLabel), newLabel ); } bool CategoryGroup::contains(int uid) const { return ( mIdLabelMap.find( uid ) != mIdLabelMap.end() ); } bool CategoryGroup::contains(const QString &label) const { return ( mLabelIdMap.find( label ) != mLabelIdMap.end() ); } /** Returns label associated with the uid or QString::null if * not found */ const QString &CategoryGroup::label(int uid) const { QMap<int,QString>::ConstIterator idIt = mIdLabelMap.find( uid ); if ( idIt == mIdLabelMap.end() ) return QString::null; return *idIt; } /** Returns the uid associated with label or 0 if not found */ int CategoryGroup::id(const QString &label) const { QMap<QString,int>::ConstIterator labelIt = mLabelIdMap.find( label ); if ( labelIt == mLabelIdMap.end() ) return 0; return *labelIt; } QStringList CategoryGroup::labels() const { QStringList labels; for ( QMap<int, QString>::ConstIterator it = mIdLabelMap.begin(); it != mIdLabelMap.end(); ++it ) labels += *it; // ### I don't think this is the place for this... // labels.sort(); return labels; } QStringList CategoryGroup::labels(const QArray<int> &catids ) const { QStringList labels; if ( catids.count() == 0 ) return labels; for ( QMap<int, QString>::ConstIterator it = mIdLabelMap.begin(); it != mIdLabelMap.end(); ++it ) if ( catids.find( it.key() ) != -1 ) labels += *it; return labels; } -QArray<int> CategoryGroup::ids( const QStringList &cats ) const -{ - QArray<int> results; - - for ( QStringList::ConstIterator catIt = cats.begin(); - catIt != cats.end(); ++catIt ) { - if ( *catIt == QObject::tr("All") || *catIt == QObject::tr("Unfiled") ) - continue; - int value = id( *catIt ); - if ( value != 0 ) { - int tmp = results.size(); - results.resize( tmp + 1 ); - results[ tmp ] = value; - } - } - - return results; -} - -QArray<int> CategoryGroup::ids() const -{ - QArray<int> results( mIdLabelMap.count() ); - int i = 0; - for ( QMap<int, QString>::ConstIterator it = mIdLabelMap.begin(); - it != mIdLabelMap.end(); ++it ) - results[i++] = it.key(); - - return results; -} - /*********************************************************** * * Categories * **********************************************************/ /** Add the category name as long as it doesn't already exist locally * or globally. Return TRUE if added, FALSE if conflicts. */ int Categories::addCategory( const QString &appname, const QString &catname, int uid ) { if ( mGlobalCats.contains(catname) ) return 0; QMap< QString, CategoryGroup >::Iterator appIt = mAppCats.find( appname ); if ( appIt == mAppCats.end() ) { CategoryGroup newgroup; newgroup.add( uid, catname ); mAppCats.insert( appname, newgroup ); emit categoryAdded( *this, appname, uid ); return uid; } CategoryGroup &cats = *appIt; cats.add( uid, catname ); emit categoryAdded( *this, appname, uid ); return uid; } int Categories::addCategory( const QString &appname, const QString &catname ) { if ( mGlobalCats.contains(catname) ) return 0; QMap< QString, CategoryGroup >::Iterator appIt = mAppCats.find( appname ); if ( appIt == mAppCats.end() ) { CategoryGroup newgroup; int uid = newgroup.add( catname ); mAppCats.insert( appname, newgroup ); emit categoryAdded( *this, appname, uid ); return uid; } CategoryGroup &cats = *appIt; int uid = cats.add( catname ); if ( !uid ) return 0; emit categoryAdded( *this, appname, uid ); return uid; } int Categories::addGlobalCategory( const QString &catname, int uid ) { mGlobalCats.add( uid, catname ); emit categoryAdded( *this, QString::null, uid ); return uid; } @@ -282,363 +252,369 @@ int Categories::addGlobalCategory( const QString &catname ) bool Categories::removeCategory( const QString &appname, const QString &catname, bool checkGlobal ) { QMap< QString, CategoryGroup >::Iterator appIt = mAppCats.find( appname ); if ( appIt != mAppCats.end() ) { CategoryGroup &cats = *appIt; int uid = cats.id( catname ); if ( cats.remove( uid ) ) { emit categoryRemoved( *this, appname, uid ); return TRUE; } } if ( !checkGlobal ) return FALSE; return removeGlobalCategory( catname ); } bool Categories::removeCategory( const QString &appname, int uid ) { QMap< QString, CategoryGroup >::Iterator appIt = mAppCats.find( appname ); if ( appIt != mAppCats.end() ) { CategoryGroup &cats = *appIt; if ( cats.remove( uid ) ) { emit categoryRemoved( *this, appname, uid ); return TRUE; } } return FALSE; } bool Categories::removeGlobalCategory( const QString &catname ) { int uid = mGlobalCats.id( catname ); if ( mGlobalCats.remove( uid ) ) { emit categoryRemoved( *this, QString::null, uid ); return TRUE; } return FALSE; } bool Categories::removeGlobalCategory( int uid ) { if ( mGlobalCats.remove( uid ) ) { emit categoryRemoved( *this, QString::null, uid ); return TRUE; } return FALSE; } /** Returns the sorted list of all categories that are associated with * the app. If includeGlobal parameter is TRUE then the returned * categories will include the global category items. */ QStringList Categories::labels( const QString &app, bool includeGlobal, ExtraLabels extra ) const { QMap< QString, CategoryGroup >::ConstIterator appIt = mAppCats.find( app ); QStringList cats; + + if ( appIt != mAppCats.end() ) + cats += (*appIt).labels(); + else qDebug("Categories::labels didn't find app %s", app.latin1() ); + if ( includeGlobal ) + cats += mGlobalCats.labels(); + + cats.sort(); switch ( extra ) { case NoExtra: break; case AllUnfiled: cats.append( tr("All") ); cats.append( tr("Unfiled") ); break; case AllLabel: cats.append( tr("All") ); break; case UnfiledLabel: cats.append( tr("Unfiled") ); break; } - if ( appIt != mAppCats.end() ) - cats += (*appIt).labels(); - else qDebug("Categories::labels didn't find app %s", app.latin1() ); - if ( includeGlobal ) - cats += mGlobalCats.labels(); - // I don't think a sorted list is useful, the user might find prefer - // it in the original order. -// cats.sort(); + return cats; } QString Categories::label( const QString &app, int id ) const { if ( mGlobalCats.contains( id ) ) return mGlobalCats.label( id ); QMap< QString, CategoryGroup >::ConstIterator appIt = mAppCats.find( app ); if ( appIt == mAppCats.end() ) return QString::null; return (*appIt).label( id ); } -QStringList Categories::labels( const QString & app, - const QArray<int> &catids ) const -{ - QStringList strs = mGlobalCats.labels( catids ); - strs += mAppCats[app].labels( catids ); - return strs; -} - /** Returns a single string associated with the cat ids for display in * a combobox or any area that requires one string. If catids are empty * then "Unfiled" will be returned. If multiple categories are assigned * the first cat id is shown with " (multi)" appended to the string. */ QString Categories::displaySingle( const QString &app, const QArray<int> &catids, DisplaySingle display ) const { QStringList strs = labels( app, catids ); if ( !strs.count() ) return tr("Unfiled"); strs.sort(); QString r; if ( strs.count() > 1 ) { switch ( display ) { case ShowFirst: r = strs.first(); break; case ShowMulti: r = strs.first() + tr(" (multi.)"); break; case ShowAll: r = strs.join(" "); break; } } else r = strs.first(); return r; } -QArray<int> Categories::ids( const QString &app ) const +QArray<int> Categories::ids( const QString &app, const QStringList &labels) const { - QArray<int> allIds = mGlobalCats.ids(); - QArray<int> appIds = mAppCats[app].ids(); - - // we should make the guarentee that the ids are in the - // same order as the labels, (i.e. app cats then global) - // otherwise there is no point in having these two separate functions. - uint appSize = appIds.size(); - appIds.resize( appSize + allIds.size() ); - for ( uint i = appSize; i < appIds.size(); ++i ) - appIds[int(i)] = allIds[int(i - appSize)]; + QArray<int> results; + QStringList::ConstIterator it; + int i; - return appIds; + for ( i=0, it=labels.begin(); it!=labels.end(); i++, ++it ) { + int value = id( app, *it ); + if ( value != 0 ) { + int tmp = results.size(); + results.resize( tmp + 1 ); + results[ tmp ] = value; } - -QArray<int> Categories::ids( const QString &app, const QStringList &cats ) const -{ - QArray<int> allIds = mGlobalCats.ids( cats ); - QArray<int> appIds = mAppCats[app].ids( cats ); - - uint appSize = appIds.size(); - appIds.resize( appSize + allIds.size() ); - for ( uint i = appSize; i < appIds.size(); ++i ) - appIds[int(i)] = allIds[int(i - appSize)]; - - return appIds; + } + return results; } int Categories::id( const QString &app, const QString &cat ) const { if ( cat == tr("Unfiled") || cat.contains( tr(" (multi.)") ) ) return 0; int uid = mGlobalCats.id( cat ); if ( uid != 0 ) return uid; return mAppCats[app].id( cat ); } /** Return TRUE if renaming succeeded; FALSE if app name not found, * or if there was a name conflict */ bool Categories::renameCategory( const QString &appname, const QString &oldName, const QString &newName ) { QMap< QString, CategoryGroup >::Iterator appIt = mAppCats.find( appname ); if ( appIt != mAppCats.end() ) { CategoryGroup &cats = *appIt; int id = cats.id( oldName ); if ( id != 0 && cats.rename( id, newName ) ) { emit categoryRenamed( *this, appname, id ); return TRUE; } } return renameGlobalCategory( oldName, newName ); } bool Categories::renameGlobalCategory( const QString &oldName, const QString &newName ) { int uid = mGlobalCats.id( oldName ); if ( uid != 0 && mGlobalCats.rename( uid, newName ) ) { emit categoryRenamed( *this, QString::null, uid ); return TRUE; } return FALSE; } void Categories::setGlobal( const QString &appname, const QString &catname, bool global ) { // if in global and should be in app; then move it if ( mGlobalCats.contains( catname ) && !global ) { mGlobalCats.remove( catname ); addCategory( appname, catname ); return ; } // if in app and should be in global, then move it if ( !global ) return; if ( removeCategory( appname, catname, FALSE ) ) addGlobalCategory( catname ); } bool Categories::isGlobal( const QString &catname ) const { return mGlobalCats.contains( catname ); } /** Returns true if the catname is associated with any application */ bool Categories::exists( const QString &catname ) const { if ( isGlobal(catname) ) return TRUE; for ( QMap<QString, CategoryGroup>::ConstIterator appsIt = mAppCats.begin(); appsIt != mAppCats.end(); ++appsIt ) if ( exists( appsIt.key(), catname ) ) return TRUE; return FALSE; } bool Categories::exists( const QString &appname, const QString &catname) const { QMap< QString, CategoryGroup >::ConstIterator appIt = mAppCats.find( appname ); if ( appIt == mAppCats.end() ) return FALSE; return (*appIt).contains( catname ); } + bool Categories::save( const QString &fname ) const { - QFile file( fname ); - if ( !file.open( IO_WriteOnly ) ) { + QString strNewFile = fname + ".new"; + QFile f( strNewFile ); + QString out; + int total_written; + + if ( !f.open( IO_WriteOnly|IO_Raw ) ) { qWarning("Unable to write to %s", fname.latin1()); return FALSE; } - QTextStream ts( &file ); - ts << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; - ts << "<!DOCTYPE CategoryList>" << endl; + out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; + out += "<!DOCTYPE CategoryList>\n"; + + out += "<Categories>\n"; - ts << "<Categories>" << endl; for ( QMap<int, QString>::ConstIterator git = mGlobalCats.idMap().begin(); git != mGlobalCats.idMap().end(); ++git ) - ts << "<Category id=\"" << git.key() << "\"" - << " name=\"" << escapeString(*git) << "\" />" << endl; + out += "<Category id=\"" + QString::number(git.key()) + "\"" + + " name=\"" + escapeString(*git) + "\" />\n"; for ( QMap<QString, CategoryGroup>::ConstIterator appsIt=mAppCats.begin(); appsIt != mAppCats.end(); ++appsIt ) { const QString &app = appsIt.key(); const QMap<int, QString> &appcats = (*appsIt).idMap(); for ( QMap<int, QString>::ConstIterator appcatit = appcats.begin(); appcatit != appcats.end(); ++appcatit ) - ts << "<Category id=\"" << appcatit.key() << "\"" - << " app=\"" << escapeString(app) << "\"" - << " name=\"" << escapeString(*appcatit) << "\" />" << endl; + out += "<Category id=\"" + QString::number(appcatit.key()) + "\"" + + " app=\"" + escapeString(app) + "\"" + + " name=\"" + escapeString(*appcatit) + "\" />\n"; + } + out += "</Categories>\n"; + + QCString cstr = out.utf8(); + total_written = f.writeBlock( cstr.data(), cstr.length() ); + if ( total_written != int(cstr.length()) ) { + f.close(); + QFile::remove( strNewFile ); + return FALSE; + } + f.close(); + + if ( ::rename( strNewFile.latin1(), fname.latin1() ) < 0 ) { + qWarning( "problem renaming file %s to %s", + strNewFile.latin1(), fname.latin1()); + // remove the tmp file... + QFile::remove( strNewFile ); } - ts << "</Categories>" << endl; - file.close(); return TRUE; } bool Categories::load( const QString &fname ) { QFile file( fname ); if ( !file.open( IO_ReadOnly ) ) { qWarning("Unable to open %s", fname.latin1()); + + addGlobalCategory(tr("Business")); + addGlobalCategory(tr("Personal")); + save(fname); + return FALSE; } clear(); QByteArray ba = file.readAll(); QString data = QString::fromUtf8( ba.data(), ba.size() ); QChar *uc = (QChar *)data.unicode(); int len = data.length(); // QTime t; // t.start(); QString name; QString id; QString app; int i = 0; while ( (i = data.find( "<Category ", i)) != -1 ) { i += 10; name = QString::null; app = QString::null; while ( 1 ) { // skip white space while ( i < len && (uc[i] == ' ' || uc[i] == '\n' || uc[i] == '\r') ) i++; // if at the end, then done if ( i >= len-2 || (uc[i] == '/' && uc[i+1] == '>') ) break; // we have another attribute read it. int j = i; while ( j < len && uc[j] != '=' ) j++; QString attr = QConstString( uc+i, j-i ).string(); i = ++j; // skip = while ( i < len && uc[i] != '"' ) i++; j = ++i; while ( j < len && uc[j] != '"' ) j++; QString value = Qtopia::plainString( QConstString( uc+i, j-i ).string() ); i = j + 1; // qDebug("attr='%s' value='%s'", attr.latin1(), value.latin1() ); if ( attr == "id" ) id = value; else if ( attr == "app" ) app = value; else if ( attr == "name" ) name = value; } if ( name.isNull() || id.isNull() ) { qWarning("No name or id in the category"); continue; } if ( app.isNull() ) mGlobalCats.add( id.toInt(), name ); else mAppCats[ app ].add( id.toInt(), name ); } return TRUE; } 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 @@ -10,214 +10,208 @@ ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A ** PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef QTPALMTOP_CATEGORIES_H #define QTPALMTOP_CATEGORIES_H #include <qstring.h> #include <qstringlist.h> #include <qmap.h> #include <qlistview.h> #include <qarray.h> #include "qpcglobal.h" #include "palmtopuidgen.h" class CategoryGroup; #if defined(QPC_TEMPLATEDLL) // MOC_SKIP_BEGIN template class QPC_EXPORT QMap<int, QString>; template class QPC_EXPORT QMap<QString, int>; template class QPC_EXPORT QMap< QString, CategoryGroup >; // MOC_SKIP_END #endif class QPC_EXPORT CategoryGroup { friend class Categories; public: CategoryGroup(): mIdLabelMap(), mLabelIdMap() { } CategoryGroup( const CategoryGroup &c ) : mIdLabelMap( c.mIdLabelMap), mLabelIdMap( c.mLabelIdMap ) { } void clear() { mIdLabelMap.clear(); mLabelIdMap.clear(); } int add( const QString &label ); bool add( int uid, const QString &label ); bool remove( const QString &label ); bool remove( int uid ); bool rename( int uid, const QString &newLabel ); bool rename( const QString &oldLabel, const QString &newLabel ); bool contains(int id) const; bool contains(const QString &label) const; /** Returns label associated with the uid or QString::null if * not found */ const QString &label(int id) const; /** Returns the uid associated with label or 0 if not found */ int id(const QString &label) const; /** Returns a sorted list of labels */ QStringList labels() const; - QArray<int> ids( const QStringList &cats ) const; - QArray<int> ids() const; + QStringList labels( const QArray<int> &catids ) const; const QMap<int, QString> &idMap() const { return mIdLabelMap; } private: void insert( int uid, const QString &label ); QMap<int, QString> mIdLabelMap; QMap<QString, int> mLabelIdMap; static Qtopia::UidGen &uidGen() { return sUidGen; } static Qtopia::UidGen sUidGen; }; /** Map from application name to categories */ class QPC_EXPORT Categories : public QObject { Q_OBJECT public: Categories( QObject *parent=0, const char *name = 0 ) : QObject( parent, name ), mGlobalCats(), mAppCats() { } Categories( const Categories ©From ) : QObject( copyFrom.parent() ), mGlobalCats( copyFrom.mGlobalCats ), mAppCats( copyFrom.mAppCats ) { } virtual ~Categories() { } Categories &operator= ( const Categories &c ) { mAppCats = c.mAppCats; mGlobalCats = c.mGlobalCats; return *this; } void clear(); /** Add the category name as long as it doesn't already exist * locally or globally. Return UID if added, 0 if conflicts * (error). */ int addCategory( const QString &appname, const QString &catname); /** Add the category name as long as it doesn't already exist * locally or globally. Return UID if added, 0 if conflicts * (error). */ int addCategory( const QString &appname, const QString &catname, int uid); /** Add the global category just checking that it doesn't * already exist globally. Return UID if added, 0 if conflicts. */ int addGlobalCategory( const QString &catname ); /** Add the global category just checking that it doesn't * already exist globally. Return UID if added, 0 if conflicts. */ int addGlobalCategory( const QString &catname, int uid ); /** Removes the category from the application; if it is not found * in the application, then it removes it from the global list */ bool removeCategory( const QString &appName, const QString &catName, bool checkGlobal = TRUE); bool removeCategory( const QString &appName, int uid ); bool removeGlobalCategory( const QString &catName ); bool removeGlobalCategory( int uid ); - QArray<int> ids( const QString &app ) const; - QArray<int> ids( const QString &app, - const QStringList &cats ) const; + QArray<int> ids( const QString &app, const QStringList &labels) const; + /** Returns the id associated with the app */ int id( const QString &app, const QString &cat ) const; /** Returns the label associated with the id */ QString label( const QString &app, int id ) const; enum ExtraLabels { NoExtra, AllUnfiled, AllLabel, UnfiledLabel }; /** Returns the sorted list of all categories that are * associated with the app. * If includeGlobal parameter is TRUE then the returned * categories will include the global category items. * If extra = NoExtra, then * If extra = AllUnfiled, then All and Unfiled will be prepended to * the list * If extra = AllLabel, then All is prepended * If extra = UnfiledLabel, then Unfiled is prepended */ QStringList labels( const QString &app, bool includeGlobal = TRUE, ExtraLabels extra = NoExtra ) const; - /** Returns the labels of the categories associated with the uids */ - QStringList labels( const QString & app, - const QArray<int> &catids ) const; - enum DisplaySingle { ShowMulti, ShowAll, ShowFirst }; /** Returns a single string associated with the cat ids for display in * a combobox or any area that requires one string. If catids are empty * then "Unfiled" will be returned. If multiple categories are assigned * then the behavior depends on the DisplaySingle type. * If /a display is set to ShowMulti then " (multi)" appended to the * first string. If /a display is set to ShowAll, then a space seperated * string is returned with all categories. If ShowFirst is returned, * the just the first string is returned. */ QString displaySingle( const QString &app, const QArray<int> &catids, DisplaySingle display ) const; QStringList globalCategories() const { return mGlobalCats.labels();} bool renameCategory( const QString &appname, const QString &oldName, const QString &newName ); bool renameGlobalCategory( const QString &oldName, const QString &newName ); void setGlobal( const QString &appname, const QString &catname, bool value ); bool isGlobal( const QString &catname ) const; /** Returns true if the catname is associated with any application */ bool exists( const QString &catname ) const; bool exists( const QString &appname, const QString &catname) const; bool save( const QString &fname ) const; bool load( const QString &fname ); // for debugging void dump() const; const QMap<QString, CategoryGroup> &appGroupMap() const{ return mAppCats; } const CategoryGroup &globalGroup() const { return mGlobalCats; } signals: /** emitted if added a category; * the second param is the application the category was added to * or null if global * the third param is the uid of the newly added category */ void categoryAdded( const Categories &, const QString &, int ); /** emitted if removed a category * the second param is the application the category was removed from * or null if global * the third param is the uid of the removed category */ void categoryRemoved( const Categories &, const QString &, int ); /** emitted if a category is renamed; the second param is the uid of * the removed category */ void categoryRenamed( const Categories &, const QString &, int ); private: CategoryGroup mGlobalCats; QMap< QString, CategoryGroup > mAppCats; }; 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,84 +1,86 @@ /********************************************************************** ** Copyright (C) 2001 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ +#define QTOPIA_INTERNAL_CONTACT_MRE + #include "contact.h" #include "vobject_p.h"
#include "qfiledirect_p.h"
#include <qpe/stringutil.h> #include <qpe/timeconversion.h> #include <qobject.h> #include <qregexp.h> #include <qstylesheet.h> #include <qfileinfo.h> #include <stdio.h> Qtopia::UidGen Contact::sUidGen( Qtopia::UidGen::Qtopia ); Contact::Contact() : Record(), mMap(), d( 0 ) { } Contact::Contact( const QMap<int, QString> &fromMap ) : Record(), mMap( fromMap ), d( 0 ) { QString cats = mMap[ Qtopia::AddressCategory ]; if ( !cats.isEmpty() ) setCategories( idsFromString( cats ) ); QString uidStr = find( Qtopia::AddressUid ); if ( uidStr.isEmpty() ) setUid( uidGen().generate() ); else setUid( uidStr.toInt() ); } Contact::~Contact() { } QMap<int, QString> Contact::toMap() const { QMap<int, QString> map = mMap; map.insert( Qtopia::AddressCategory, idsToString( categories() )); return map; } /*! Returns a rich text formatted QString of the Contact. */ QString Contact::toRichText() const { QString text; QString value, comp, state; // name, jobtitle and company if ( !(value = fullName()).isEmpty() ) text += "<b>" + Qtopia::escapeString(value) + "</b><br>"; if ( !(value = jobTitle()).isEmpty() ) text += Qtopia::escapeString(value) + "<br>"; comp = company(); if ( !(value = department()).isEmpty() ) { text += Qtopia::escapeString(value); if ( comp ) text += ", "; @@ -325,221 +327,229 @@ QStringList Contact::childrenList() const return QStringList::split( " ", find( Qtopia::Children ) ); } QStringList Contact::emailList() const { return QStringList::split( ";", find( Qtopia::Emails ) ); } void Contact::setFileAs() { QString lastName, firstName, middleName, fileas; lastName = find( Qtopia::LastName ); firstName = find( Qtopia::FirstName ); middleName = find( Qtopia::MiddleName ); if ( !lastName.isEmpty() && !firstName.isEmpty() && !middleName.isEmpty() ) fileas = lastName + ", " + firstName + " " + middleName; else if ( !lastName.isEmpty() && !firstName.isEmpty() ) fileas = lastName + ", " + firstName; else if ( !lastName.isEmpty() || !firstName.isEmpty() || !middleName.isEmpty() ) fileas = firstName + ( firstName.isEmpty() ? "" : " " ) + middleName + ( middleName.isEmpty() ? "" : " " ) + lastName; replace( Qtopia::FileAs, fileas ); } void Contact::save( QString &buf ) const { static const QStringList SLFIELDS = fields(); // I'm expecting "<Contact " in front of this... for ( QMap<int, QString>::ConstIterator it = mMap.begin(); it != mMap.end(); ++it ) { const QString &value = it.data(); int key = it.key(); if ( !value.isEmpty() ) { if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) continue; key -= Qtopia::AddressCategory+1; buf += SLFIELDS[key]; buf += "=\"" + Qtopia::escapeString(value) + "\" "; } } buf += customToXml(); if ( categories().count() > 0 ) buf += "Categories=\"" + idsToString( categories() ) + "\" "; buf += "Uid=\"" + QString::number( uid() ) + "\" "; // You need to close this yourself } QStringList Contact::fields() { QStringList list; list.append( "Title" ); // Not Used! list.append( "FirstName" ); list.append( "MiddleName" ); list.append( "LastName" ); list.append( "Suffix" ); list.append( "FileAs" ); + list.append( "JobTitle" ); + list.append( "Department" ); + list.append( "Company" ); + list.append( "BusinessPhone" ); + list.append( "BusinessFax" ); + list.append( "BusinessMobile" ); + list.append( "DefaultEmail" ); list.append( "Emails" ); - list.append( "HomeStreet" ); - list.append( "HomeCity" ); - list.append( "HomeState" ); - list.append( "HomeZip" ); - list.append( "HomeCountry" ); list.append( "HomePhone" ); list.append( "HomeFax" ); list.append( "HomeMobile" ); - list.append( "HomeWebPage" ); - list.append( "Company" ); list.append( "BusinessStreet" ); list.append( "BusinessCity" ); list.append( "BusinessState" ); list.append( "BusinessZip" ); list.append( "BusinessCountry" ); + list.append( "BusinessPager" ); list.append( "BusinessWebPage" ); - list.append( "JobTitle" ); - list.append( "Department" ); + list.append( "Office" ); - list.append( "BusinessPhone" ); - list.append( "BusinessFax" ); - list.append( "BusinessMobile" ); - list.append( "BusinessPager" ); list.append( "Profession" ); list.append( "Assistant" ); list.append( "Manager" ); + list.append( "HomeStreet" ); + list.append( "HomeCity" ); + list.append( "HomeState" ); + list.append( "HomeZip" ); + list.append( "HomeCountry" ); + list.append( "HomeWebPage" ); + list.append( "Spouse" ); list.append( "Gender" ); list.append( "Birthday" ); list.append( "Anniversary" ); list.append( "Nickname" ); - list.append( "Children" ); + list.append( "Notes" ); + list.append( "Groups" ); return list; } QStringList Contact::trfields() { QStringList list; list.append( QObject::tr( "Name Title") ); list.append( QObject::tr( "First Name" ) ); list.append( QObject::tr( "Middle Name" ) ); list.append( QObject::tr( "Last Name" ) ); list.append( QObject::tr( "Suffix" ) ); list.append( QObject::tr( "File As" ) ); + list.append( QObject::tr( "Job Title" ) ); + list.append( QObject::tr( "Department" ) ); + list.append( QObject::tr( "Company" ) ); + list.append( QObject::tr( "Business Phone" ) ); + list.append( QObject::tr( "Business Fax" ) ); + list.append( QObject::tr( "Business Mobile" ) ); + list.append( QObject::tr( "Default Email" ) ); list.append( QObject::tr( "Emails" ) ); - list.append( QObject::tr( "Home Street" ) ); - list.append( QObject::tr( "Home City" ) ); - list.append( QObject::tr( "Home State" ) ); - list.append( QObject::tr( "Home Zip" ) ); - list.append( QObject::tr( "Home Country" ) ); list.append( QObject::tr( "Home Phone" ) ); list.append( QObject::tr( "Home Fax" ) ); list.append( QObject::tr( "Home Mobile" ) ); - list.append( QObject::tr( "Home Web Page" ) ); - list.append( QObject::tr( "Company" ) ); list.append( QObject::tr( "Business Street" ) ); list.append( QObject::tr( "Business City" ) ); list.append( QObject::tr( "Business State" ) ); list.append( QObject::tr( "Business Zip" ) ); list.append( QObject::tr( "Business Country" ) ); + list.append( QObject::tr( "Business Pager" ) ); list.append( QObject::tr( "Business WebPage" ) ); - list.append( QObject::tr( "Job Title" ) ); - list.append( QObject::tr( "Department" ) ); + list.append( QObject::tr( "Office" ) ); - list.append( QObject::tr( "Business Phone" ) ); - list.append( QObject::tr( "Business Fax" ) ); - list.append( QObject::tr( "Business Mobile" ) ); - list.append( QObject::tr( "Business Pager" ) ); list.append( QObject::tr( "Profession" ) ); list.append( QObject::tr( "Assistant" ) ); list.append( QObject::tr( "Manager" ) ); + list.append( QObject::tr( "Home Street" ) ); + list.append( QObject::tr( "Home City" ) ); + list.append( QObject::tr( "Home State" ) ); + list.append( QObject::tr( "Home Zip" ) ); + list.append( QObject::tr( "Home Country" ) ); + list.append( QObject::tr( "Home Web Page" ) ); + list.append( QObject::tr( "Spouse" ) ); list.append( QObject::tr( "Gender" ) ); list.append( QObject::tr( "Birthday" ) ); list.append( QObject::tr( "Anniversary" ) ); list.append( QObject::tr( "Nickname" ) ); - list.append( QObject::tr( "Children" ) ); + list.append( QObject::tr( "Notes" ) ); + list.append( QObject::tr( "Groups" ) ); return list; } void Contact::setEmails( const QString &v ) { replace( Qtopia::Emails, v ); if ( v.isEmpty() ) setDefaultEmail( QString::null ); } void Contact::setChildren( const QString &v ) { replace( Qtopia::Children, v ); } // vcard conversion code static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) { VObject *ret = 0; if ( o && !value.isEmpty() ) ret = addPropValue( o, prop, value.latin1() ); return ret; } static inline VObject *safeAddProp( VObject *o, const char *prop) { VObject *ret = 0; if ( o ) ret = addProp( o, prop ); return ret; } static VObject *createVObject( const Contact &c ) { VObject *vcard = newVObject( VCCardProp ); safeAddPropValue( vcard, VCVersionProp, "2.1" ); safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); // full name safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); // name properties VObject *name = safeAddProp( vcard, VCNameProp ); safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); safeAddPropValue( name, VCGivenNameProp, c.firstName() ); safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); safeAddPropValue( name, VCNamePrefixesProp, c.title() ); safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); // home properties VObject *home_adr= safeAddProp( vcard, VCAdrProp ); safeAddProp( home_adr, VCHomeProp ); safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); safeAddProp( home_phone, VCHomeProp ); home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); safeAddProp( home_phone, VCHomeProp ); @@ -568,342 +578,347 @@ static VObject *createVObject( const Contact &c ) work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); safeAddProp( work_phone, VCWorkProp ); safeAddProp( work_phone, VCFaxProp ); work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); safeAddProp( work_phone, VCWorkProp ); safeAddProp( work_phone, VCPagerProp ); url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); safeAddProp( url, VCWorkProp ); VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); safeAddProp( title, VCWorkProp ); QStringList emails = c.emailList(); emails.prepend( c.defaultEmail() ); for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); safeAddProp( email, VCInternetProp ); } safeAddPropValue( vcard, VCNoteProp, c.notes() ); safeAddPropValue( vcard, VCBirthDateProp, c.birthday() ); if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { VObject *org = safeAddProp( vcard, VCOrgProp ); safeAddPropValue( org, VCOrgNameProp, c.company() ); safeAddPropValue( org, VCOrgUnitProp, c.department() ); safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); } // some values we have to export as custom fields safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); safeAddPropValue( vcard, "X-Qtopia-Anniversary", c.anniversary() ); safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); return vcard; } static Contact parseVObject( VObject *obj ) { Contact c; bool haveDefaultEmail = FALSE; VObjectIterator it; initPropIterator( &it, obj ); while( moreIteration( &it ) ) { VObject *o = nextVObject( &it ); QCString name = vObjectName( o ); QCString value = vObjectStringZValue( o ); if ( name == VCNameProp ) { VObjectIterator nit; initPropIterator( &nit, o ); while( moreIteration( &nit ) ) { VObject *o = nextVObject( &nit ); - QCString name = vObjectName( o ); + QCString name = vObjectTypeInfo( o ); QString value = vObjectStringZValue( o ); if ( name == VCNamePrefixesProp ) c.setTitle( value ); else if ( name == VCNameSuffixesProp ) c.setSuffix( value ); else if ( name == VCFamilyNameProp ) c.setLastName( value ); else if ( name == VCGivenNameProp ) c.setFirstName( value ); else if ( name == VCAdditionalNamesProp ) c.setMiddleName( value ); } } else if ( name == VCAdrProp ) { bool work = TRUE; // default address is work address QString street; QString city; QString region; QString postal; QString country; VObjectIterator nit; initPropIterator( &nit, o ); while( moreIteration( &nit ) ) { VObject *o = nextVObject( &nit ); QCString name = vObjectName( o ); QString value = vObjectStringZValue( o ); if ( name == VCHomeProp ) work = FALSE; else if ( name == VCWorkProp ) work = TRUE; else if ( name == VCStreetAddressProp ) street = value; else if ( name == VCCityProp ) city = value; else if ( name == VCRegionProp ) region = value; else if ( name == VCPostalCodeProp ) postal = value; else if ( name == VCCountryNameProp ) country = value; } if ( work ) { c.setBusinessStreet( street ); c.setBusinessCity( city ); c.setBusinessCountry( country ); c.setBusinessZip( postal ); c.setBusinessState( region ); } else { c.setHomeStreet( street ); c.setHomeCity( city ); c.setHomeCountry( country ); c.setHomeZip( postal ); c.setHomeState( region ); } } else if ( name == VCTelephoneProp ) { enum { HOME = 0x01, WORK = 0x02, VOICE = 0x04, CELL = 0x08, FAX = 0x10, PAGER = 0x20, UNKNOWN = 0x80 }; int type = 0; VObjectIterator nit; initPropIterator( &nit, o ); while( moreIteration( &nit ) ) { VObject *o = nextVObject( &nit ); - QCString name = vObjectName( o ); + QCString name = vObjectTypeInfo( o ); if ( name == VCHomeProp ) type |= HOME; else if ( name == VCWorkProp ) type |= WORK; else if ( name == VCVoiceProp ) type |= VOICE; else if ( name == VCCellularProp ) type |= CELL; else if ( name == VCFaxProp ) type |= FAX; else if ( name == VCPagerProp ) type |= PAGER; else if ( name == VCPreferredProp ) ; else type |= UNKNOWN; } if ( (type & UNKNOWN) != UNKNOWN ) { if ( ( type & (HOME|WORK) ) == 0 ) // default type |= HOME; if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default type |= VOICE; if ( (type & (VOICE|HOME) ) == (VOICE|HOME) ) c.setHomePhone( value ); if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) c.setHomeFax( value ); if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) c.setHomeMobile( value ); if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) ) c.setBusinessPhone( value ); if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) c.setBusinessFax( value ); if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) c.setBusinessMobile( value ); if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) c.setBusinessPager( value ); } } else if ( name == VCEmailAddressProp ) { QString email = vObjectStringZValue( o ); bool valid = TRUE; VObjectIterator nit; initPropIterator( &nit, o ); while( moreIteration( &nit ) ) { VObject *o = nextVObject( &nit ); - QCString name = vObjectName( o ); + QCString name = vObjectTypeInfo( o ); if ( name != VCInternetProp && name != VCHomeProp && name != VCWorkProp && name != VCPreferredProp ) // ### preffered should map to default email valid = FALSE; } if ( valid ) { if ( haveDefaultEmail ) { QString str = c.emails(); if ( !str.isEmpty() ) str += ","+email; c.setEmails( str ); } else { c.setDefaultEmail( email ); } } } else if ( name == VCURLProp ) { VObjectIterator nit; initPropIterator( &nit, o ); while( moreIteration( &nit ) ) { VObject *o = nextVObject( &nit ); - QCString name = vObjectName( o ); + QCString name = vObjectTypeInfo( o ); if ( name == VCHomeProp ) c.setHomeWebpage( value ); else if ( name == VCWorkProp ) c.setBusinessWebpage( value ); } } else if ( name == VCOrgProp ) { VObjectIterator nit; initPropIterator( &nit, o ); while( moreIteration( &nit ) ) { VObject *o = nextVObject( &nit ); QCString name = vObjectName( o ); QString value = vObjectStringZValue( o ); if ( name == VCOrgNameProp ) c.setCompany( value ); else if ( name == VCOrgUnitProp ) c.setDepartment( value ); else if ( name == VCOrgUnit2Prop ) c.setOffice( value ); } } else if ( name == VCTitleProp ) { c.setJobTitle( value ); } else if ( name == "X-Qtopia-Profession" ) { c.setProfession( value ); } else if ( name == "X-Qtopia-Manager" ) { c.setManager( value ); } else if ( name == "X-Qtopia-Assistant" ) { c.setAssistant( value ); } else if ( name == "X-Qtopia-Spouse" ) { c.setSpouse( value ); } else if ( name == "X-Qtopia-Gender" ) { c.setGender( value ); } else if ( name == "X-Qtopia-Anniversary" ) { c.setAnniversary( value ); } else if ( name == "X-Qtopia-Nickname" ) { c.setNickname( value ); } else if ( name == "X-Qtopia-Children" ) { c.setChildren( value ); } #if 0 else { printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); VObjectIterator nit; initPropIterator( &nit, o ); while( moreIteration( &nit ) ) { VObject *o = nextVObject( &nit ); QCString name = vObjectName( o ); QString value = vObjectStringZValue( o ); printf(" subprop: %s = %s\n", name.data(), value.latin1() ); } } #endif } c.setFileAs(); return c; } void Contact::writeVCard( const QString &filename, const QValueList<Contact> &contacts) {
QFileDirect f( filename.utf8().data() );
if ( !f.open( IO_WriteOnly ) ) {
qWarning("Unable to open vcard write");
return;
}
QValueList<Contact>::ConstIterator it; for( it = contacts.begin(); it != contacts.end(); ++it ) { VObject *obj = createVObject( *it ); writeVObject(f.directHandle() , obj ); cleanVObject( obj ); } cleanStrTbl(); } void Contact::writeVCard( const QString &filename, const Contact &contact) {
QFileDirect f( filename.utf8().data() );
if ( !f.open( IO_WriteOnly ) ) {
qWarning("Unable to open vcard write");
return;
}
VObject *obj = createVObject( contact ); writeVObject( f.directHandle() , obj ); cleanVObject( obj ); cleanStrTbl(); } QValueList<Contact> Contact::readVCard( const QString &filename ) { qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); qDebug("vobject = %p", obj ); QValueList<Contact> contacts; while ( obj ) { contacts.append( parseVObject( obj ) ); VObject *t = obj; obj = nextVObjectInList(obj); cleanVObject( t ); } return contacts; } +bool Contact::match( const QString ®exp ) const +{ + return match(QRegExp(regexp)); +} + bool Contact::match( const QRegExp &r ) const { bool match; match = false; QMap<int, QString>::ConstIterator it; for ( it = mMap.begin(); it != mMap.end(); ++it ) { if ( (*it).find( r ) > -1 ) { match = true; break; } } return match; } 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 @@ -40,129 +40,134 @@ public: Contact(); Contact( const QMap<int, QString> &fromMap ); virtual ~Contact(); static void writeVCard( const QString &filename, const QValueList<Contact> &contacts); static void writeVCard( const QString &filename, const Contact &c ); static QValueList<Contact> readVCard( const QString &filename ); enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } void setFileAs(); // default email address void setDefaultEmail( const QString &v ) { replace( Qtopia::DefaultEmail, v ); } // the emails should be seperated by a semicolon void setEmails( const QString &v ); // home void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } // business void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } // personal void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } void setBirthday( const QString &v ) { replace( Qtopia::Birthday, v ); } void setAnniversary( const QString &v ) { replace( Qtopia::Anniversary, v ); } void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } void setChildren( const QString &v ); // other void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } - bool match( const QRegExp &r ) const; + bool match( const QString ®exp ) const; + +// DON'T ATTEMPT TO USE THIS +#ifdef QTOPIA_INTERNAL_CONTACT_MRE + bool match( const QRegExp ®exp ) const; +#endif // // custom // void setCustomField( const QString &key, const QString &v ) // { replace(Custom- + key, v ); } // name QString fullName() const; QString title() const { return find( Qtopia::Title ); } QString firstName() const { return find( Qtopia::FirstName ); } QString middleName() const { return find( Qtopia::MiddleName ); } QString lastName() const { return find( Qtopia::LastName ); } QString suffix() const { return find( Qtopia::Suffix ); } QString fileAs() const { return find( Qtopia::FileAs ); } // email QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } QString emails() const { return find( Qtopia::Emails ); } QStringList emailList() const; // home QString homeStreet() const { return find( Qtopia::HomeStreet ); } QString homeCity() const { return find( Qtopia::HomeCity ); } QString homeState() const { return find( Qtopia::HomeState ); } QString homeZip() const { return find( Qtopia::HomeZip ); } QString homeCountry() const { return find( Qtopia::HomeCountry ); } QString homePhone() const { return find( Qtopia::HomePhone ); } QString homeFax() const { return find( Qtopia::HomeFax ); } QString homeMobile() const { return find( Qtopia::HomeMobile ); } QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } /** Multi line string containing all non-empty address info in the form * Street * City, State Zip * Country */ QString displayHomeAddress() const; // business QString company() const { return find( Qtopia::Company ); } QString businessStreet() const { return find( Qtopia::BusinessStreet ); } QString businessCity() const { return find( Qtopia::BusinessCity ); } QString businessState() const { return find( Qtopia::BusinessState ); } QString businessZip() const { return find( Qtopia::BusinessZip ); } QString businessCountry() const { return find( Qtopia::BusinessCountry ); } QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } QString jobTitle() const { return find( Qtopia::JobTitle ); } QString department() const { return find( Qtopia::Department ); } QString office() const { return find( Qtopia::Office ); } QString businessPhone() const { return find( Qtopia::BusinessPhone ); } QString businessFax() const { return find( Qtopia::BusinessFax ); } QString businessMobile() const { return find( Qtopia::BusinessMobile ); } QString businessPager() const { return find( Qtopia::BusinessPager ); } QString profession() const { return find( Qtopia::Profession ); } QString assistant() const { return find( Qtopia::Assistant ); } QString manager() const { return find( Qtopia::Manager ); } /** Multi line string containing all non-empty address info in the form * Street * City, State Zip * Country */ QString displayBusinessAddress() const; //personal QString spouse() const { return find( Qtopia::Spouse ); } QString gender() const { return find( Qtopia::Gender ); } 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 @@ -79,129 +79,134 @@ public: void setDescription( const QString &s ); const QString &description() const; void setLocation( const QString &s ); const QString &location() const; void setType( Type t ); Type type() const; void setStart( const QDateTime &d ); void setStart( time_t time ); QDateTime start( bool actual = FALSE ) const; time_t startTime() const { return startUTC; } void setEnd( const QDateTime &e ); void setEnd( time_t time ); QDateTime end( bool actual = FALSE ) const; time_t endTime() const { return endUTC; } void setTimeZone( const QString & ); const QString &timeZone() const; void setAlarm( bool b, int minutes, SoundTypeChoice ); bool hasAlarm() const; int alarmTime() const; SoundTypeChoice alarmSound() const; void setRepeat( bool b, const RepeatPattern &p ); void setRepeat( const RepeatPattern &p ); bool hasRepeat() const; const RepeatPattern &repeatPattern() const; RepeatPattern &repeatPattern(); void setNotes( const QString &n ); const QString ¬es() const; bool doRepeat() const { return pattern.type != NoRepeat; } void save( QString& buf ); //void load( Node *n ); // helper function to calculate the week of the given date static int week( const QDate& date ); // calculates the number of occurrences of the week day of // the given date from the start of the month static int occurrence( const QDate& date ); // returns a proper days-char for a given dayOfWeek() static char day( int dayOfWeek ) { return 1 << ( dayOfWeek - 1 ); } // returns the dayOfWeek for the *first* day it finds (ignores // any further days!). Returns 1 (Monday) if there isn't any day found static int dayOfWeek( char day ); // returns the difference of months from first to second. static int monthDiff( const QDate& first, const QDate& second ); bool match( const QRegExp &r ) const; private: Qtopia::UidGen &uidGen() { return sUidGen; } static Qtopia::UidGen sUidGen; QString descript, locat, categ; Type typ : 4; bool startTimeDirty : 1; bool endTimeDirty : 1; time_t startUTC, endUTC; QString tz; bool hAlarm, hRepeat; int aMinutes; SoundTypeChoice aSound; RepeatPattern pattern; QString note; + // ADDITION + int mRid; // Recode ID + int mRinfo; // Recode Info + // EventPrivate *d; + }; // Since an event spans multiple day, it is better to have this // class to represent a day instead of creating many // dummy events... class EffectiveEventPrivate; class QPC_EXPORT EffectiveEvent { public: // If we calculate the effective event of a multi-day event // we have to figure out whether we are at the first day, // at the end, or anywhere else ("middle"). This is important // for the start/end times (00:00/23:59) // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi- // day event // Start: start time -> 23:59 // End: 00:00 -> end time // Start | End == StartEnd: for single-day events (default) // here we draw start time -> end time enum Position { MidWay = 0, Start = 1, End = 2, StartEnd = 3 }; EffectiveEvent(); EffectiveEvent( const Event &event, const QDate &startDate, Position pos = StartEnd ); EffectiveEvent( const EffectiveEvent & ); EffectiveEvent& operator=( const EffectiveEvent & ); ~EffectiveEvent(); bool operator<( const EffectiveEvent &e ) const; bool operator<=( const EffectiveEvent &e ) const; bool operator==( const EffectiveEvent &e ) const; bool operator!=( const EffectiveEvent &e ) const; bool operator>( const EffectiveEvent &e ) const; bool operator>= ( const EffectiveEvent &e ) const; void setStart( const QTime &start ); void setEnd( const QTime &end ); void setEvent( Event e ); void setDate( const QDate &date ); void setEffectiveDates( const QDate &from, const QDate &to ); // QString category() const; const QString &description() const; const QString &location() const; const QString ¬es() const; const Event &event() const; const QTime &start() const; const QTime &end() const; const QDate &date() const; int length() const; int size() const; QDate startDate() const; QDate endDate() const; private: class EffectiveEventPrivate *d; Event mEvent; QDate mDate; QTime mStart, mEnd; }; 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 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** Licensees holding valid Qtopia Developer license may use this ** file in accordance with the Qtopia Developer License Agreement ** provided with the Software. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR ** PURPOSE. ** ** email sales@trolltech.com for information about Qtopia License ** Agreements. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef QPC_RECORD_FIELDS_H #define QPC_RECORD_FIELDS_H #include "qpcglobal.h" // dataset = "addressbook" namespace Qtopia { static const int UID_ID = 0; static const int CATEGORY_ID = 1; enum AddressBookFields { AddressUid = UID_ID, AddressCategory = CATEGORY_ID, + // NOTE: Order of fields dependency in backend/contact.cpp + Title, FirstName, MiddleName, LastName, Suffix, FileAs, + JobTitle, + Department, + Company, + BusinessPhone, + BusinessFax, + BusinessMobile, + // email DefaultEmail, Emails, - // home - HomeStreet, - HomeCity, - HomeState, - HomeZip, - HomeCountry, HomePhone, HomeFax, HomeMobile, - HomeWebPage, // business - Company, BusinessStreet, BusinessCity, BusinessState, BusinessZip, BusinessCountry, + BusinessPager, BusinessWebPage, - JobTitle, - Department, + Office, - BusinessPhone, - BusinessFax, - BusinessMobile, - BusinessPager, Profession, Assistant, Manager, + // home + HomeStreet, + HomeCity, + HomeState, + HomeZip, + HomeCountry, + HomeWebPage, + //personal Spouse, Gender, Birthday, Anniversary, Nickname, Children, // other Notes, Groups + + ,rid, + rinfo }; // dataset = "todolist" enum TaskFields { TaskUid = UID_ID, TaskCategory = CATEGORY_ID, HasDate, Completed, TaskDescription, Priority, - Date + Date, + + TaskRid, + TaskRinfo }; // dataset = "categories" for todos enum CategoryFields { CatUid = UID_ID, CatName, CatAppGroup }; // dataset = "datebook" enum DatebookFields { DatebookUid = UID_ID, DatebookCategory = CATEGORY_ID, DatebookDescription, Location, TimeZone, Note, StartDateTime, EndDateTime, DatebookType, HasAlarm, SoundType, AlarmTime, RepeatPatternType, RepeatPatternFrequency, RepeatPatternPosition, RepeatPatternDays, RepeatPatternHasEndDate, RepeatPatternEndDate, + + DateBookRid, + DateBookRinfo }; }; #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 @@ -11,67 +11,71 @@ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef __TASK_H__ #define __TASK_H__ #include <qpe/palmtoprecord.h> #include <qpe/stringutil.h> #include <qvaluelist.h> #include <qdatetime.h> class TaskPrivate; class QPC_EXPORT Task : public Qtopia::Record { public: Task(); Task( const QMap<int, QString> &fromMap ); ~Task(); QMap<int, QString> toMap() const; static void writeVCalendar( const QString &filename, const QValueList<Task> &tasks); static void writeVCalendar( const QString &filename, const Task &task); static QValueList<Task> readVCalendar( const QString &filename ); void setPriority( int priority ) { mPriority = priority; } int priority() const { return mPriority; } // void setCategory( const QString& category ) // { mCategory = category.stripWhiteSpace(); } // const QString &category() const { return mCategory; } void setDescription( const QString& description ) { mDesc = Qtopia::simplifyMultiLineSpace(description); } const QString &description() const { return mDesc; } void setDueDate( const QDate& date, bool hasDue ) { mDueDate = date; mDue = hasDue; } const QDate &dueDate() const { return mDueDate; } bool hasDueDate() const { return mDue; } void setHasDueDate( bool b ) { mDue = b; } void setCompleted( bool b ) { mCompleted = b; } bool isCompleted() const { return mCompleted; } void save( QString& buf ) const; bool match( const QRegExp &r ) const; private: Qtopia::UidGen &uidGen() { return sUidGen; } static Qtopia::UidGen sUidGen; bool mDue; QDate mDueDate; bool mCompleted; int mPriority; QString mDesc; TaskPrivate *d; + // ADDITION + int recordId; + int recordInfo; + // }; #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 @@ -1146,65 +1146,74 @@ static void writeProp(OFile *fp, VObject *o) writeValue(fp,o,size);
}
appendcOFile(fp,'\n');
}
static void writeVObject_(OFile *fp, VObject *o)
{
if (NAME_OF(o)) {
struct PreDefProp *pi;
pi = lookupPropInfo(NAME_OF(o));
if (pi && ((pi->flags & PD_BEGIN) != 0)) {
VObjectIterator t;
const char *begin = NAME_OF(o);
appendsOFile(fp,"BEGIN:");
appendsOFile(fp,begin);
appendcOFile(fp,'\n');
initPropIterator(&t,o);
while (moreIteration(&t)) {
VObject *eachProp = nextVObject(&t);
writeProp(fp, eachProp);
}
appendsOFile(fp,"END:");
appendsOFile(fp,begin);
appendsOFile(fp,"\n\n");
}
}
}
void writeVObject(FILE *fp, VObject *o)
{
OFile ofp;
// #####
//_setmode(_fileno(fp), _O_BINARY);
initOFile(&ofp,fp);
writeVObject_(&ofp,o);
}
DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o)
{
QFileDirect f( fname);
if ( !f.open( IO_WriteOnly ) ) {
qWarning("Unable to open vobject write %s", fname);
return;
}
writeVObject( f.directHandle(),o );
}
DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list)
{
QFileDirect f( fname);
if ( !f.open( IO_WriteOnly ) ) {
qWarning("Unable to open vobject write %s", fname);
return;
}
while (list) {
writeVObject(f.directHandle(),list);
list = nextVObjectInList(list);
}
}
+DLLEXPORT(const char *) vObjectTypeInfo(VObject *o)
+{
+ const char *type = vObjectName( o );
+ if ( strcmp( type, "TYPE" ) == 0 )
+ type = vObjectStringZValue( o );
+ return type;
+}
+
+
// 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 @@ -335,67 +335,70 @@ extern DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list); extern DLLEXPORT(int) vObjectValueType(VObject *o);
/* return type of vObjectValueType: */
#define VCVT_NOVALUE 0
/* if the VObject has no value associated with it. */
#define VCVT_STRINGZ 1
/* if the VObject has value set by setVObjectStringZValue. */
#define VCVT_UINT 2
/* if the VObject has value set by setVObjectIntegerValue. */
#define VCVT_ULONG 3
/* if the VObject has value set by setVObjectLongValue. */
#define VCVT_RAW 4
/* if the VObject has value set by setVObjectAnyValue. */
#define VCVT_VOBJECT 5
/* if the VObject has value set by setVObjectVObjectValue. */
extern const char** fieldedProp;
/***************************************************
* The methods below are implemented in vcc.c (generated from vcc.y )
***************************************************/
/* NOTE regarding printVObject and writeVObject
The functions below are not exported from the DLL because they
take a FILE* as a parameter, which cannot be passed across a DLL
interface (at least that is my experience). Instead you can use
their companion functions which take file names or pointers
to memory. However, if you are linking this code into
your build directly then you may find them a more convenient API
and you can go ahead and use them. If you try to use them with
the DLL LIB you will get a link error.
*/
extern void writeVObject(FILE *fp, VObject *o);
typedef void (*MimeErrorHandler)(char *);
extern DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler);
extern DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len);
extern DLLEXPORT(VObject*) Parse_MIME_FromFileName(char* fname);
/* NOTE regarding Parse_MIME_FromFile
The function above, Parse_MIME_FromFile, comes in two flavors,
neither of which is exported from the DLL. Each version takes
a CFile or FILE* as a parameter, neither of which can be
passed across a DLL interface (at least that is my experience).
If you are linking this code into your build directly then
you may find them a more convenient API that the other flavors
that take a file name. If you use them with the DLL LIB you
will get a link error.
*/
#if INCLUDEMFC
extern VObject* Parse_MIME_FromFile(CFile *file);
#else
extern VObject* Parse_MIME_FromFile(FILE *file);
#endif
+extern DLLEXPORT(const char *) vObjectTypeInfo(VObject *o);
+
+
#endif /* __VOBJECT_H__ */
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 @@ -14,131 +14,133 @@ ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "categoryedit_p.h" #include <qpe/categories.h> #include <qdir.h> #include <qcheckbox.h> #include <qlineedit.h> #include <qlistview.h> #include <qstringlist.h> #include <qtoolbutton.h> #include <sys/types.h> #include <sys/stat.h> #include <stdlib.h> using namespace Qtopia; class CategoryEditPrivate { public: CategoryEditPrivate( QWidget *parent, const QString &appName ) : mCategories( parent, "" ), mStrApp( appName ) { editItem = 0; mCategories.load( categoryFileName() ); } Categories mCategories; QListViewItem *editItem; QString mStrApp; QString mVisible; }; CategoryEdit::CategoryEdit( QWidget *parent, const char *name ) : CategoryEditBase( parent, name ) { d = 0; } CategoryEdit::CategoryEdit( const QArray<int> &recCats, const QString &appName, const QString &visibleName, QWidget *parent, const char *name ) : CategoryEditBase( parent, name ) { d = 0; setCategories( recCats, appName, visibleName ); } void CategoryEdit::setCategories( const QArray<int> &recCats, const QString &appName, const QString &visibleName ) { if ( !d ) d = new CategoryEditPrivate( (QWidget*)parent(), name() ); d->mStrApp = appName; d->mVisible = visibleName; - QArray<int> cats = d->mCategories.ids( d->mStrApp ); - lvView->clear(); + QStringList appCats = d->mCategories.labels( d->mStrApp ); + QArray<int> cats = d->mCategories.ids(d->mStrApp, appCats); + lvView->clear(); + QStringList::ConstIterator it; int i, j; for ( i = 0, it = appCats.begin(); it != appCats.end(); i++, ++it ) { QCheckListItem *chk; chk = new QCheckListItem( lvView, (*it), QCheckListItem::CheckBox ); if ( !d->mCategories.isGlobal((*it)) ) chk->setText( 1, tr(d->mVisible) ); else chk->setText( 1, tr("All") ); // Is this record using this category, then we should check it for ( j = 0; j < int(recCats.count()); j++ ) { if ( cats[i] == recCats[j] ) { chk->setOn( true ); break; } } } lvView->setSorting( 0, TRUE ); lvView->sort(); if ( lvView->childCount() < 1 ) txtCat->setEnabled( FALSE ); else { lvView->setSelected( lvView->firstChild(), true ); } } CategoryEdit::~CategoryEdit() { if ( d ) delete d; } void CategoryEdit::slotSetText( QListViewItem *selected ) { d->editItem = selected; if ( !d->editItem ) return; txtCat->setText( d->editItem->text(0) ); txtCat->setEnabled( true ); if ( d->editItem->text(1) == tr("All") ) chkGlobal->setChecked( true ); else chkGlobal->setChecked( false ); } void CategoryEdit::slotAdd() { QString name = tr( "New Category" ); bool insertOk = FALSE; int num = 0; while ( !insertOk ) { if ( num++ > 0 ) name = tr("New Category ") + QString::number(num); insertOk = d->mCategories.addCategory( d->mStrApp, name ); } QCheckListItem *chk; chk = new QCheckListItem( lvView, name, QCheckListItem::CheckBox ); if ( !chkGlobal->isChecked() ) chk->setText( 1, tr(d->mVisible) ); else chk->setText( 1, tr("All") ); lvView->setSelected( chk, TRUE ); txtCat->selectAll(); 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 @@ /********************************************************************** ** Copyright (C) 2001 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include <qpe/categories.h> +#include <qpe/palmtoprecord.h> -#include <qdialog.h> +#include <qmessagebox.h> #include <qlayout.h> #include <qtoolbutton.h> +#include <qfile.h> #include "categorywidget.h" #include "categoryselect.h" +#include <stdlib.h> + +static QString categoryEdittingFileName() +{ + QString str = getenv("HOME"); + str +="/.cateditting"; + return str; +} class CategoryComboPrivate { public: CategoryComboPrivate(QObject *o) : mCat( o ) { } QArray<int> mAppCats; QString mStrAppName; QString mStrVisibleName; Categories mCat; }; class CategorySelectPrivate { public: CategorySelectPrivate( const QArray<int> &cats) : mRec( cats ), usingAll( false ) { } CategorySelectPrivate() { } QArray<int> mRec; bool usingAll; QString mVisibleName; }; -CategoryCombo::CategoryCombo( QWidget *parent, const char *name ) +CategoryCombo::CategoryCombo( QWidget *parent, const char *name , int width) : QComboBox( parent, name ) { d = new CategoryComboPrivate(this); + if (width) + setFixedWidth(width); } void CategoryCombo::initCombo( const QArray<int> &recCats, const QString &appName ) { initCombo( recCats, appName, appName ); } void CategoryCombo::initCombo( const QArray<int> &recCats, const QString &appName, const QString &visibleName ) { d->mStrAppName = appName; d->mStrVisibleName = visibleName; clear(); QStringList slApp; + QObject::disconnect( this, SIGNAL(activated(int)), + this, SLOT(slotValueChanged(int)) ); + QObject::connect( this, SIGNAL(activated(int)), this, SLOT(slotValueChanged(int)) ); bool loadOk = d->mCat.load( categoryFileName() ); slApp = d->mCat.labels( d->mStrAppName, TRUE, Categories::UnfiledLabel ); - d->mAppCats = d->mCat.ids( d->mStrAppName ); + + d->mAppCats = d->mCat.ids( d->mStrAppName, slApp); int i, j, saveMe, recCount; QStringList::Iterator it; // now add in all the items... recCount = recCats.count(); saveMe = -1; if ( recCount > 1 && loadOk ) { it = slApp.begin(); - insertItem( *it ); - ++it; - for ( j = 0; it != slApp.end(); ++it, j++ ) { + for ( j = 0; j< (int)(slApp.count()-1); ++it, j++ ) { // grr... we have to go through and compare... if ( j < int(d->mAppCats.size()) ) { for ( i = 0; i < recCount; i++ ) { if ( recCats[i] == d->mAppCats[j] ) { (*it).append( tr(" (Multi.)") ); if ( saveMe < 0 ) saveMe = j; // no need to continue through the list. break; } } } insertItem( *it ); } + insertItem( *it ); } else insertStringList( slApp ); if ( recCount > 0 && loadOk ) { for ( i = 0; i < int(d->mAppCats.size()); i++ ) { if ( d->mAppCats[i] == recCats[0] ) { - setCurrentItem( i + 1 ); + setCurrentItem( i ); break; } } } else - setCurrentItem( 0 ); // unfiled + { + setCurrentItem( slApp.count()-1 ); // unfiled + } +} + +// this is a new function by SHARP instead of initCombo() +QArray<int> CategoryCombo::initComboWithRefind( const QArray<int> &recCats, + const QString &appName) +{ + QString visibleName = appName; + d->mStrAppName = appName; + d->mStrVisibleName = visibleName; + clear(); + QStringList slApp; + QArray<int> results; + + QObject::disconnect( this, SIGNAL(activated(int)), + this, SLOT(slotValueChanged(int)) ); + QObject::connect( this, SIGNAL(activated(int)), this, SLOT(slotValueChanged(int)) ); + bool loadOk = d->mCat.load( categoryFileName() ); + slApp = d->mCat.labels( d->mStrAppName, TRUE, Categories::UnfiledLabel ); + + d->mAppCats = d->mCat.ids( d->mStrAppName, slApp); + + // addition part + // make new recCats + if (loadOk){ + int i,j; + int value; + int rCount = recCats.count(); + int mCount = d->mAppCats.count(); + + for (i=0; i<rCount; i++){ + value = 0; + for (j=0; j<mCount; j++){ + if (recCats[i] == d->mAppCats[j]){ + value = recCats[i]; + break; + } + } + if (value != 0){ + int tmp = results.size(); + results.resize( tmp + 1 ); + results[ tmp ] = value; + } + } } + else{ + results = recCats; + } + // addition end + + int i, + j, + saveMe, + recCount; + QStringList::Iterator it; + // now add in all the items... + recCount = results.count(); + saveMe = -1; + if ( recCount > 1 && loadOk ) { + it = slApp.begin(); + for ( j = 0; j< (int)(slApp.count()-1); ++it, j++ ) { + + // grr... we have to go through and compare... + if ( j < int(d->mAppCats.size()) ) { + for ( i = 0; i < recCount; i++ ) { + if ( results[i] == d->mAppCats[j] ) { + (*it).append( tr(" (Multi.)") ); + if ( saveMe < 0 ) + saveMe = j; + // no need to continue through the list. + break; + } + } + } + insertItem( *it ); + } + insertItem( *it ); + } else + insertStringList( slApp ); + + if ( recCount > 0 && loadOk ) { + for ( i = 0; i < int(d->mAppCats.size()); i++ ) { + if ( d->mAppCats[i] == results[0] ) { + setCurrentItem( i ); + break; + } + } + } else + { + setCurrentItem( slApp.count()-1 ); // unfiled + } +/* + QObject::connect( this, SIGNAL(activated(int)), + this, SLOT(slotValueChanged(int)) ); +*/ + return results; +} + CategoryCombo::~CategoryCombo() { delete d; } int CategoryCombo::currentCategory() const { int returnMe; returnMe = currentItem(); - // unfiled is now 0... - if ( returnMe == 0 ) + + if ( returnMe == (int)d->mAppCats.count() ) returnMe = -1; else if ( returnMe > (int)d->mAppCats.count() ) // only happen on "All" returnMe = -2; else - returnMe = d->mAppCats[returnMe - 1]; + returnMe = d->mAppCats[returnMe]; return returnMe; } void CategoryCombo::setCurrentCategory( int newCatUid ) { int i; for ( i = 0; i < int(d->mAppCats.size()); i++ ) { if ( d->mAppCats[i] == newCatUid ) setCurrentItem( i ); } } void CategoryCombo::setCurrentText( const QString &str ) { int i; int stop; stop = count(); for ( i = 0; i < stop; i++ ) { if ( text( i ) == str ) { setCurrentItem( i ); break; } } } void CategoryCombo::slotValueChanged( int ) { emit sigCatChanged( currentCategory() ); } -CategorySelect::CategorySelect( QWidget *parent, const char *name ) +CategorySelect::CategorySelect( QWidget *parent, const char *name,int width) : QHBox( parent, name ), cmbCat( 0 ), cmdCat( 0 ), d( 0 ) { d = new CategorySelectPrivate(); - init(); + init(width); } CategorySelect::CategorySelect( const QArray<int> &vl, const QString &appName, QWidget *parent, - const char *name ) + const char *name ,int width) : QHBox( parent, name ) { d = new CategorySelectPrivate( vl ); - init(); + + init(width); + setCategories( vl, appName, appName ); } CategorySelect::CategorySelect( const QArray<int> &vl, const QString &appName, const QString &visibleName, - QWidget *parent, const char *name ) + QWidget *parent, const char *name , int width) : QHBox( parent, name ) { d = new CategorySelectPrivate( vl ); - init(); + init(width); setCategories( vl, appName, visibleName ); } CategorySelect::~CategorySelect() { delete d; } void CategorySelect::slotDialog() { + if (QFile::exists( categoryEdittingFileName() )){ + QMessageBox::warning(this,tr("Error"), + tr("Sorry, another application is\nediting categories.") ); + return; + } + + QFile f( categoryEdittingFileName() ); + if ( !f.open( IO_WriteOnly) ){ + return; + } + QDialog editDlg( this, 0, TRUE ); editDlg.setCaption( tr("Edit Categories") ); QVBoxLayout *vb = new QVBoxLayout( &editDlg ); QScrollView *sv = new QScrollView( &editDlg ); sv->setResizePolicy( QScrollView::AutoOneFit ); sv->setHScrollBarMode( QScrollView::AlwaysOff ); vb->addWidget( sv ); CategoryWidget ce( d->mRec, mStrAppName, d->mVisibleName, &editDlg ); sv->addChild( &ce ); editDlg.showMaximized(); if ( editDlg.exec() ) { d->mRec = ce.newCategories(); cmbCat->initCombo( d->mRec, mStrAppName ); } + + f.close(); + QFile::remove( categoryEdittingFileName() ); } void CategorySelect::slotNewCat( int newUid ) { if ( newUid != -1 ) { bool alreadyIn = false; for ( uint it = 0; it < d->mRec.count(); ++it ) { if ( d->mRec[it] == newUid ) { alreadyIn = true; break; } } if ( !alreadyIn ) { d->mRec.resize( 1 ); d->mRec[ 0 ] = newUid; } } else d->mRec.resize(0); // now Unfiled. emit signalSelected( currentCategory() ); } -void CategorySelect::setCategories( const QArray<int> &rec, +QString CategorySelect::setCategories( const QArray<int> &rec, const QString &appName ) { - setCategories( rec, appName, appName ); + return setCategories( rec, appName, appName ); } -void CategorySelect::setCategories( const QArray<int> &rec, +QString CategorySelect::setCategories( const QArray<int> &rec, const QString &appName, const QString &visibleName ) { - d->mRec = rec; d->mVisibleName = visibleName; mStrAppName = appName; - cmbCat->initCombo( rec, appName ); + d->mRec = cmbCat->initComboWithRefind( rec, appName ); + return Qtopia::Record::idsToString(d->mRec); } -void CategorySelect::init() +void CategorySelect::init(int width) { - cmbCat = new CategoryCombo( this ); + cmbCat = new CategoryCombo( this, 0, width); + QObject::connect( cmbCat, SIGNAL(sigCatChanged(int)), this, SLOT(slotNewCat(int)) ); cmdCat = new QToolButton( this ); QObject::connect( cmdCat, SIGNAL(clicked()), this, SLOT(slotDialog()) ); cmdCat->setTextLabel( "...", FALSE ); cmdCat->setUsesTextLabel( true ); cmdCat->setMaximumSize( cmdCat->sizeHint() ); cmdCat->setFocusPolicy( TabFocus ); } int CategorySelect::currentCategory() const { return cmbCat->currentCategory(); } void CategorySelect::setCurrentCategory( int newCatUid ) { cmbCat->setCurrentCategory( newCatUid ); } const QArray<int> &CategorySelect::currentCategories() const { return d->mRec; } void CategorySelect::setRemoveCategoryEdit( bool remove ) { if ( remove ) { cmdCat->setEnabled( FALSE ); cmdCat->hide(); } else { cmdCat->setEnabled( TRUE ); cmdCat->show(); } } void CategorySelect::setAllCategories( bool add ) { d->usingAll = add; if ( add ) { cmbCat->insertItem( tr( "All" ), cmbCat->count() ); cmbCat->setCurrentItem( cmbCat->count() - 1 ); } else cmbCat->removeItem( cmbCat->count() - 1 ); } + +// 01.12.21 added +void CategorySelect::setFixedWidth(int width) +{ + width -= cmdCat->width(); + cmbCat->setFixedWidth(width); +} 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 @@ /********************************************************************** ** Copyright (C) 2001 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef __CATEGORYCOMBO_H__ #define __CATEGORYCOMBO_H__ #include <qcombobox.h> #include <qhbox.h> #include <qstring.h> #include <qarray.h> extern QString categoryFileName(); class QToolButton; class CategoryComboPrivate; class CategoryCombo : public QComboBox { Q_OBJECT public: - CategoryCombo( QWidget *parent, const char* name = 0 ); + CategoryCombo( QWidget *parent, const char* name = 0, int width=0); + ~CategoryCombo(); int currentCategory() const; void setCurrentCategory( int id ); // depreciated. void initCombo( const QArray<int> &recCats, const QString &appName ); void initCombo( const QArray<int> &recCats, const QString &appName, const QString &visibleName /* = appName */ ); + QArray<int> initComboWithRefind( const QArray<int> &recCats, const QString &appName ); + signals: void sigCatChanged( int newUid ); private slots: void slotValueChanged( int ); private: void setCurrentText( const QString &str ); CategoryComboPrivate *d; }; #endif class CategorySelectPrivate; class CategorySelect : public QHBox { Q_OBJECT public: // we need two constructors, the first gets around designer limitations - CategorySelect( QWidget *parent = 0, const char *name = 0 ); + + CategorySelect( QWidget *parent = 0, const char *name = 0, int width = 0 ); CategorySelect( const QArray<int> &vlCats, const QString &appName, - QWidget *parent = 0, const char *name = 0 ); + QWidget *parent = 0, const char *name = 0, + int width = 0); CategorySelect( const QArray<int> &vlCats, const QString &appName, const QString &visibleName, QWidget *parent = 0, - const char *name = 0 ); + const char *name = 0 , int width = 0); + ~CategorySelect(); const QArray<int> ¤tCategories() const; int currentCategory() const; void setCurrentCategory( int newCatUid ); // pretty much if you don't set it the constructor, you need to // call it here ASAP! // however this call is depreciated... - void setCategories( const QArray<int> &vlCats, const QString &appName ); - // use this one instead (for translating ) - void setCategories( const QArray<int> &vlCats, const QString &appName, - const QString &visibleName ); + QString setCategories( const QArray<int> &vlCats, const QString &appName ); + QString setCategories( const QArray<int> &vlCats, const QString &appName, + const QString &visibleName ); // these were added for find dialog. void setRemoveCategoryEdit( bool remove ); void setAllCategories( bool add ); + void setFixedWidth(int width); signals: void signalSelected( int ); private slots: void slotDialog(); + +public slots: void slotNewCat( int id ); private: - void init(); + void init(int width=0); QString mStrAppName; CategoryCombo *cmbCat; QToolButton *cmdCat; CategorySelectPrivate *d; }; diff --git a/library/config.cpp b/library/config.cpp index 9634571..e07eecb 100644 --- a/library/config.cpp +++ b/library/config.cpp @@ -1,169 +1,166 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include <qdir.h> #include <qfile.h> #include <qfileinfo.h> #include <qmessagebox.h> #if QT_VERSION <= 230 && defined(QT_NO_CODECS) #include <qtextcodec.h> #endif #include <qtextstream.h> #include <sys/stat.h> #include <sys/types.h> #include <fcntl.h> #include <stdlib.h> #include <unistd.h> +#define QTOPIA_INTERNAL_LANGLIST #include "config.h" +#include "global.h" /*! \internal */ QString Config::configFilename(const QString& name, Domain d) { switch (d) { case File: return name; case User: { QDir dir = (QString(getenv("HOME")) + "/Settings"); if ( !dir.exists() ) mkdir(dir.path().local8Bit(),0700); return dir.path() + "/" + name + ".conf"; } } return name; } /*! \class Config config.h \brief The Config class provides for saving application cofniguration state. You should keep a Config in existence only while you do not want others to be able to change the state. There is no locking currently, but there may be in the future. */ /*! \enum Config::ConfigGroup \internal */ /*! \enum Config::Domain \value File \value User See Config for details. */ /*! Constructs a config that will load or create a configuration with the given \a name in the given \a domain. You must call setGroup() before doing much else with the Config. In the default Domain, \e User, the configuration is user-specific. \a name should not contain "/" in this case, and in general should be the name of the C++ class that is primarily responsible for maintaining the configuration. In the File Domain, \a name is an absolute filename. */ Config::Config( const QString &name, Domain domain ) : filename( configFilename(name,domain) ) { git = groups.end(); read(); - - lang = getenv("LANG"); - int i = lang.find("."); - if ( i > 0 ) - lang = lang.left( i ); - i = lang.find( "_" ); - if ( i > 0 ) - glang = lang.left(i); + QStringList l = Global::languageList(); + lang = l[0]; + glang = l[1]; } /*! Writes any changes to disk and destroys the in-memory object. */ Config::~Config() { if ( changed ) write(); } /*! Returns whether the current group has an entry called \a key. */ bool Config::hasKey( const QString &key ) const { if ( groups.end() == git ) return FALSE; ConfigGroup::ConstIterator it = ( *git ).find( key ); return it != ( *git ).end(); } /*! Sets the current group for subsequent reading and writing of entries to \a gname. Grouping allows the application to partition the namespace. This function must be called prior to any reading or writing of entries. The \a gname must not be empty. */ void Config::setGroup( const QString &gname ) { QMap< QString, ConfigGroup>::Iterator it = groups.find( gname ); if ( it == groups.end() ) { git = groups.insert( gname, ConfigGroup() ); changed = TRUE; return; } git = it; } /*! Writes a (\a key, \a value) entry to the current group. \sa readEntry() */ void Config::writeEntry( const QString &key, const char* value ) { writeEntry(key,QString(value)); } /*! Writes a (\a key, \a value) entry to the current group. \sa readEntry() */ void Config::writeEntry( const QString &key, const QString &value ) { if ( git == groups.end() ) { qWarning( "no group set" ); return; } if ( (*git)[key] != value ) { 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 @@ -/********************************************************************** -** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. -** -** This file is part of the Qtopia Environment. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#define QPE_OWNAPM -#define QPE_HAVE_TOGGLELIGHT -#define QPE_NOCIBAUD -#define QPE_STARTMENU -#include <asm/sharp_apm.h> -#ifndef APM_IOC_BATTERY_BACK_CHK -#define APM_IOC_BATTERY_BACK_CHK _IO(APM_IOC_MAGIC, 32) -#endif -#ifndef APM_IOC_BATTERY_MAIN_CHK -#define APM_IOC_BATTERY_MAIN_CHK _IO(APM_IOC_MAGIC, 33) -#endif - -#include <unistd.h> -#include <stdio.h> -#include <signal.h> -#include <fcntl.h> -#include <sys/ioctl.h> - -#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 - -/* --- for SHARP_BUZZER device --- */ -#define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) -#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) -#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) -#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) -#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) -#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) -#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) - -#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ -#define SHARP_BUZ_KEYSOUND 2 /* key sound */ -#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ -#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ -#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ -#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ -#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ -#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ -#define SHARP_PDA_APPSTART 9 /* application start */ -#define SHARP_PDA_APPQUIT 10 /* application ends */ -#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ -#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ -#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ -#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ - - -#define CUSTOM_BUZZER( sound ) \ -{ \ - static int fd = open( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); \ - ioctl( fd, SHARP_BUZZER_MAKESOUND, sound ); \ -} - -#define CUSTOM_SOUND_ALARM CUSTOM_BUZZER( SHARP_BUZ_SCHEDULE_ALARM ) - -#include <sys/ioctl.h> -#include <asm/sharp_char.h> - -// a bit awkward, as this value is defined in emailclient.cpp aswell... -#define LED_MAIL 0 -#define SHARP_LED_MAIL 9 - -#define CUSTOM_LEDS( led, status ) \ -{ \ - if ( led == LED_MAIL ) \ - led = SHARP_LED_MAIL; \ - static int fd = open( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); \ - sharp_led_status leds; \ - memset(&leds, 0, sizeof(leds)); \ - leds.which = led; \ - leds.status = status; \ - ioctl( fd, SHARP_LED_SETSTATUS, (char*)&leds ); \ -} - -#define QPE_HAVE_MEMALERTER - -#define QPE_MEMALERTER_IMPL \ -static void sig_handler(int sig) \ -{ \ - switch (sig) { \ - case SIGHUP: \ - memstate = VeryLow; \ - break; \ - case SIGUSR1: \ - memstate = Normal; \ - break; \ - case SIGUSR2: \ - memstate = Low; \ - break; \ - } \ -} \ -static void initMemalerter() \ -{ \ - struct sigaction sa; \ - memset(&sa, '\0', sizeof sa); \ - sa.sa_handler = sig_handler; \ - sa.sa_flags = SA_RESTART; \ - if (sigaction(SIGHUP, &sa, NULL) < 0) { \ - return; \ - } \ - if (sigaction(SIGUSR1, &sa, NULL) < 0) { \ - return; \ - } \ - if (sigaction(SIGUSR2, &sa, NULL) < 0) { \ - return; \ - } \ - FILE *fo = fopen("/proc/sys/vm/freepg_signal_proc", "w"); \ - \ - if (!fo) \ - return; \ - fprintf(fo, "qpe\n"); \ - fclose(fo); \ -} - -#define QPE_INITIAL_NUMLOCK_STATE \ -{ \ - bool numLock = FALSE; \ - sharp_kbdctl_modifstat st; \ - int dev = ::open("/dev/sharp_kbdctl", O_RDWR); \ - if( dev >= 0 ) { \ - memset(&st, 0, sizeof(st)); \ - st.which = 3; \ - int ret = ioctl(dev, SHARP_KBDCTL_GETMODIFSTAT, (char*)&st); \ - if( !ret ) \ - numLock = (bool)st.stat; \ - ::close(dev); \ - } \ - return numLock; \ -} diff --git a/library/datebookmonth.h b/library/datebookmonth.h index 6cd1ac5..a7647ae 100644 --- a/library/datebookmonth.h +++ b/library/datebookmonth.h @@ -7,128 +7,129 @@ ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef DATEBOOKMONTH #define DATEBOOKMONTH #include <qpe/event.h> #include <qvbox.h> #include <qhbox.h> #include <qdatetime.h> #include <qvaluelist.h> #include <qtable.h> #include <qpushbutton.h> #include "calendar.h" #include "timestring.h" class QToolButton; class QComboBox; class QSpinBox; class Event; class DateBookDB; class DateBookMonthHeaderPrivate; class DateBookMonthHeader : public QHBox { Q_OBJECT public: DateBookMonthHeader( QWidget *parent = 0, const char *name = 0 ); ~DateBookMonthHeader(); void setDate( int year, int month ); signals: void dateChanged( int year, int month ); protected slots: void keyPressEvent(QKeyEvent *e ) { e->ignore(); } private slots: void updateDate(); void firstMonth(); void lastMonth(); void monthBack(); void monthForward(); private: QToolButton *begin, *back, *next, *end; QComboBox *month; QSpinBox *year; DateBookMonthHeaderPrivate *d; + int focus; }; class DayItemMonthPrivate; class DayItemMonth : public QTableItem { public: DayItemMonth( QTable *table, EditType et, const QString &t ); ~DayItemMonth(); void paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ); void setDay( int d ) { dy = d; } void setEvents( const QValueList<Event> &events ) { daysEvents = events; }; void setEvents( const QValueList<EffectiveEvent> &effEvents ); void clearEvents() { daysEvents.clear(); }; void clearEffEvents(); int day() const { return dy; } void setType( Calendar::Day::Type t ); Calendar::Day::Type type() const { return typ; } private: QBrush back; QColor forg; int dy; Calendar::Day::Type typ; QValueList<Event> daysEvents; // not used anymore... DayItemMonthPrivate *d; }; class DateBookMonthTablePrivate; class DateBookMonthTable : public QTable { Q_OBJECT public: DateBookMonthTable( QWidget *parent = 0, const char *name = 0, DateBookDB *newDb = 0 ); ~DateBookMonthTable(); void setDate( int y, int m, int d ); void redraw(); QSize minimumSizeHint() const { return sizeHint(); } QSize minimumSize() const { return sizeHint(); } void getDate( int& y, int &m, int &d ) const {y=selYear;m=selMonth;d=selDay;} void setWeekStart( bool onMonday ); signals: void dateClicked( int year, int month, int day ); protected: void viewportMouseReleaseEvent( QMouseEvent * ); protected slots: void keyPressEvent(QKeyEvent *e ) { e->ignore(); } private slots: void dayClicked( int row, int col ); void dragDay( int row, int col ); private: void setupTable(); void setupLabels(); void findDay( int day, int &row, int &col ); 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 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef FILESELECTOR_H #define FILESELECTOR_H #include <qhbox.h> #include <qvbox.h> -#include <qlistview.h> #include <qtoolbutton.h> +#include <qlistview.h> #include "filemanager.h" #include "applnk.h" class QPopupMenu; class QPushButton; +class FileSelectorView; class FileSelectorItem : public QListViewItem { public: FileSelectorItem( QListView *parent, const DocLnk& f ); ~FileSelectorItem(); DocLnk file() const { return fl; } private: DocLnk fl; }; -class CategoryMenu; -class FileSelectorViewPrivate; -class FileSelectorView : public QListView -{ - Q_OBJECT - -public: - FileSelectorView( const QString &mimefilter, QWidget *parent, const char *name ); - ~FileSelectorView(); - void reread(); - int fileCount() { return count; } - - void setCategoryFilter(CategoryMenu *); -protected: - void keyPressEvent( QKeyEvent *e ); - -protected slots: - void cardMessage( const QCString &, const QByteArray &); - - void categoryChanged(); - -private: - QString filter; - FileManager *fileManager; - int count; - FileSelectorViewPrivate *d; -}; - class FileSelectorPrivate; class FileSelector : public QVBox { Q_OBJECT public: FileSelector( const QString &mimefilter, QWidget *parent, const char *name, bool newVisible = TRUE, bool closeVisible = TRUE ); ~FileSelector(); void setNewVisible( bool b ); void setCloseVisible( bool b ); - void setCategoriesVisible( bool b ); void reread(); int fileCount(); const DocLnk *selected(); signals: void fileSelected( const DocLnk & ); void newSelected( const DocLnk & ); void closeMe(); private slots: void createNew(); void fileClicked( int, QListViewItem *, const QPoint &, int ); // pressed to get 'right down' void filePressed( int, QListViewItem *, const QPoint &, int ); void fileClicked( QListViewItem *); private: FileSelectorView *view; QString filter; QToolButton *buttonNew, *buttonClose; FileSelectorPrivate *d; }; #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 @@ /********************************************************************** ** Copyright (C) 2001 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ +// WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT +// have this class. +#define QTOPIA_INTERNAL_FD + #include "finddialog.h" #include "findwidget_p.h" #include <qlayout.h> #include <qpushbutton.h> FindDialog::FindDialog( const QString &appName, QWidget *parent, const char *name, bool modal ) : QDialog( parent, name, modal ) { QVBoxLayout *vb; vb = new QVBoxLayout( this ); fw = new FindWidget( appName, this, "Find Widget" ); vb->addWidget( fw ); QObject::connect( fw, SIGNAL(signalFindClicked(const QString&, bool,bool,int)), this, SIGNAL(signalFindClicked(const QString&, bool,bool,int)) ); QObject::connect( fw, SIGNAL(signalFindClicked(const QString&,const QDate&, bool,bool,int)), this, SIGNAL(signalFindClicked(const QString&, const QDate&,bool,bool,int)) ); d = 0; } FindDialog::~FindDialog() { } QString FindDialog::findText() const { return fw->findText(); } void FindDialog::setUseDate( bool show ) { fw->setUseDate( show ); } void FindDialog::setDate( const QDate &dt ) { fw->setDate( dt ); } void FindDialog::slotNotFound() { fw->slotNotFound(); } void FindDialog::slotWrapAround() { fw->slotWrapAround(); } 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 @@ /********************************************************************** ** Copyright (C) 2001 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ + +// +// DO NOT ATTEMPT TO USE THIS CLASS +// + #ifndef __FINDDIALOG_H__ #define __FINDDIALOG_H__ #include <qdatetime.h> #include <qdialog.h> class FindWidget; class FindDialogPrivate; class FindDialog : public QDialog { Q_OBJECT public: + +// WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT +// have this class. +#ifdef QTOPIA_INTERNAL_FD + FindDialog( const QString &appName, QWidget *parent = 0, const char *name = 0, bool modal = TRUE ); ~FindDialog(); +#endif QString findText() const; void setUseDate( bool show ); void setDate( const QDate &dt ); public slots: void slotNotFound(); void slotWrapAround(); signals: void signalFindClicked( const QString &txt, bool caseSensitive, bool backwards, int category ); void signalFindClicked( const QString &txt, const QDate &dt, bool caseSensitive, bool backwards, int category ); private: FindWidget *fw; FindDialogPrivate *d; }; #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 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ +#define QTOPIA_INTERNAL_MIMEEXT #include "mimetype.h" #include "applnk.h" #include "resource.h" #include "qpeapplication.h" #include <qfile.h> #include <qdict.h> #include <qregexp.h> #include <qstringlist.h> #include <qtextstream.h> #include <qmap.h> class MimeTypeData { public: MimeTypeData(const QString& i, const AppLnk& lnk, const QString& icon ) : id(i), desc(lnk.name()+" document"), app(lnk) { if ( icon.isEmpty() ) { regIcon = lnk.pixmap(); bigIcon = lnk.bigPixmap(); } else { QImage unscaledIcon = Resource::loadImage( icon ); regIcon.convertFromImage( unscaledIcon.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); bigIcon.convertFromImage( unscaledIcon.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ) ); } } QString id; + QString extension; QString desc; QPixmap regIcon; QPixmap bigIcon; AppLnk app; }; class MimeType::Dict : public QDict<MimeTypeData> { public: Dict() {} }; MimeType::Dict* MimeType::d=0; static QMap<QString,QString> *typeFor = 0; +static QMap<QString,QString> *extFor = 0; MimeType::Dict& MimeType::dict() { if ( !d ) { d = new Dict; d->setAutoDelete(TRUE); } return *d; } MimeType::MimeType( const QString& ext_or_id ) { init(ext_or_id); } MimeType::MimeType( const DocLnk& lnk ) { init(lnk.type()); } QString MimeType::id() const { return i; } QString MimeType::description() const { MimeTypeData* d = data(i); return d ? d->desc : QString::null; } QPixmap MimeType::pixmap() const { MimeTypeData* d = data(i); return d ? d->regIcon : QPixmap(); } +QString MimeType::extension() const +{ + loadExtensions(); + return *(*extFor).find(i); +} + QPixmap MimeType::bigPixmap() const { MimeTypeData* d = data(i); return d ? d->bigIcon : QPixmap(); } const AppLnk* MimeType::application() const { MimeTypeData* d = data(i); return d ? &d->app : 0; } void MimeType::registerApp( const AppLnk& lnk ) { QStringList list = lnk.mimeTypes(); QStringList icons = lnk.mimeTypeIcons(); QStringList::ConstIterator icon = icons.begin(); for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it, ++icon) { MimeTypeData *item = new MimeTypeData( *it, lnk, *icon ); dict().replace( *it, item ); } } void MimeType::clear() { delete d; d = 0; } void MimeType::loadExtensions() { if ( !typeFor ) { + extFor = new QMap<QString,QString>; typeFor = new QMap<QString,QString>; loadExtensions("/etc/mime.types"); loadExtensions(QPEApplication::qpeDir()+"etc/mime.types"); } } void MimeType::loadExtensions(const QString& filename) { QFile file(filename); if ( file.open(IO_ReadOnly) ) { QTextStream in(&file); QRegExp space("[ \t]+"); while (!in.atEnd()) { QStringList tokens = QStringList::split(space, in.readLine()); QStringList::ConstIterator it = tokens.begin(); if ( it != tokens.end() ) { QString id = *it; ++it; + if ( it != tokens.end() ) { + (*extFor)[id] = *it; while (it != tokens.end()) { (*typeFor)[*it] = id; ++it; } } } } } +} void MimeType::init( const QString& ext_or_id ) { if ( ext_or_id[0] != '/' && ext_or_id.contains('/') ) { i = ext_or_id.lower(); } else { loadExtensions(); int dot = ext_or_id.findRev('.'); QString ext = dot >= 0 ? ext_or_id.mid(dot+1) : ext_or_id; i = (*typeFor)[ext.lower()]; if ( i.isNull() ) i = "application/octet-stream"; } static bool appsUpdated = FALSE; if ( !appsUpdated ) { appsUpdated = TRUE; updateApplications(); } } MimeTypeData* MimeType::data(const QString& id) { MimeTypeData* d = dict()[id]; if ( !d ) { int s = id.find('/'); QString idw = id.left(s)+"/*"; d = dict()[idw]; } return d; } QString MimeType::appsFolderName() { return QPEApplication::qpeDir() + "apps"; } void MimeType::updateApplications() { clear(); AppLnkSet apps( appsFolderName() ); updateApplications(&apps); } void MimeType::updateApplications(AppLnkSet* folder) { for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { registerApp(*it.current()); } } 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 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef MIMETYPE_H #define MIMETYPE_H #include <qstring.h> #include <qpixmap.h> class AppLnk; class DocLnk; class QStringList; class MimeTypeData; class AppLnkSet; class MimeType { public: MimeType( const QString& ext_or_id ); MimeType( const DocLnk& ); QString id() const; QString description() const; QPixmap pixmap() const; QPixmap bigPixmap() const; +// DON'T define this yourself! +#ifdef QTOPIA_INTERNAL_MIMEEXT + QString extension() const; +#endif + const AppLnk* application() const; static QString appsFolderName(); static void updateApplications(); // These shouldn't be needed static void clear(); static void registerApp( const AppLnk& ); private: static void updateApplications(AppLnkSet* folder); static void loadExtensions(); static void loadExtensions(const QString&); void init( const QString& ext_or_id ); class Dict; static Dict* d; static Dict& dict(); static MimeTypeData* data(const QString& id); QString i; }; #endif diff --git a/library/network.cpp b/library/network.cpp index 7d51016..e6d2781 100644 --- a/library/network.cpp +++ b/library/network.cpp @@ -1,84 +1,85 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ +#define QTOPIA_INTERNAL_LANGLIST #include "qpe/network.h" #include "qpe/networkinterface.h" #include "qpe/global.h" #include "qpe/config.h" #include "qpe/resource.h" #include "qpe/qpeapplication.h" #include <qpe/qcopenvelope_qws.h> #include <qpe/qlibrary.h> #include <qlistbox.h> #include <qdir.h> #include <qlayout.h> #include <qdict.h> #include <qtranslator.h> #include <stdlib.h> class NetworkEmitter : public QCopChannel { Q_OBJECT public: NetworkEmitter() : QCopChannel("QPE/Network",qApp) { } void receive(const QCString &msg, const QByteArray&) { if ( msg == "choicesChanged()" ) emit changed(); } signals: void changed(); }; /*! \internal Requests that the service \a choice be started. The \a password is the password to use if required. */ void Network::start(const QString& choice, const QString& password) { QCopEnvelope e("QPE/Network", "start(QString,QString)"); e << choice << password; } /*! \class Network network.h \brief The Network class provides network access functionality. */ // copy the proxy settings of the active config over to the Proxies.conf file /*! \internal */ void Network::writeProxySettings( Config &cfg ) { Config proxy( Network::settingsDir() + "/Proxies.conf", Config::File ); proxy.setGroup("Properties"); cfg.setGroup("Proxy"); proxy.writeEntry("type", cfg.readEntry("type") ); proxy.writeEntry("autoconfig", cfg.readEntry("autoconfig") ); proxy.writeEntry("httphost", cfg.readEntry("httphost") ); proxy.writeEntry("httpport", cfg.readEntry("httpport") ); @@ -357,80 +358,82 @@ bool Network::serviceNeedsPassword(const QString& service) cfg.setGroup("Info"); QString type = cfg.readEntry("Type"); NetworkInterface* plugin = Network::loadPlugin(type); cfg.setGroup("Properties"); return plugin ? plugin->needPassword(cfg) : FALSE; } /*! \internal */ bool Network::networkOnline() { return ns && ns->networkOnline(); } /*! \internal */ void Network::createServer(QObject* parent) { ns = new NetworkServer(parent); } /*! \internal */ int Network::addStateWidgets(QWidget* parent) { int n=0; QStringList l = Network::choices(); QVBoxLayout* vb = new QVBoxLayout(parent); for (QStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) { Config cfg(*it,Config::File); cfg.setGroup("Info"); QString type = cfg.readEntry("Type"); NetworkInterface* plugin = Network::loadPlugin(type); cfg.setGroup("Properties"); if ( plugin ) { QWidget* w; if ( (w=plugin->addStateWidget(parent,cfg)) ) { n++; vb->addWidget(w); } } } return n; } static QDict<NetworkInterface> *ifaces; /*! \internal */ NetworkInterface* Network::loadPlugin(const QString& type) { #ifndef QT_NO_COMPONENT if ( !ifaces ) ifaces = new QDict<NetworkInterface>; NetworkInterface *iface = ifaces->find(type); if ( !iface ) { QString libfile = QPEApplication::qpeDir() + "/plugins/network/lib" + type + ".so"; QLibrary lib(libfile); if ( !lib.queryInterface( IID_Network, (QUnknownInterface**)&iface ) == QS_OK ) return 0; ifaces->insert(type,iface); - QString lang = getenv( "LANG" ); + QStringList langs = Global::languageList(); + for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { + QString lang = *it; QTranslator * trans = new QTranslator(qApp); QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/lib"+type+".qm"; if ( trans->load( tfn )) qApp->installTranslator( trans ); else delete trans; - + } } return iface; #else return 0; #endif } #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 @@ -41,128 +41,130 @@ static bool haveProcApm = false; PowerStatusManager::PowerStatusManager() { powerManager = this; ps = new PowerStatus; FILE *f = fopen("/proc/apm", "r"); if ( f ) { fclose(f); haveProcApm = TRUE; } } const PowerStatus &PowerStatusManager::readStatus() { if ( !powerManager ) (void)new PowerStatusManager; powerManager->getStatus(); return *ps; } // Standard /proc/apm reader bool PowerStatusManager::getProcApmStatus( int &ac, int &bs, int &bf, int &pc, int &sec ) { bool ok = false; ac = 0xff; bs = 0xff; bf = 0xff; pc = -1; sec = -1; FILE *f = fopen("/proc/apm", "r"); if ( f ) { //I 1.13 1.2 0x02 0x00 0xff 0xff 49% 147 sec char u; fscanf(f, "%*[^ ] %*d.%*d 0x%*x 0x%x 0x%x 0x%x %d%% %i %c", &ac, &bs, &bf, &pc, &sec, &u); fclose(f); switch ( u ) { case 'm': sec *= 60; case 's': break; // ok default: sec = -1; // unknown } // extract data switch ( bs ) { case 0x00: ps->bs = PowerStatus::High; break; case 0x01: ps->bs = PowerStatus::Low; break; case 0x7f: ps->bs = PowerStatus::VeryLow; break; case 0x02: ps->bs = PowerStatus::Critical; break; case 0x03: ps->bs = PowerStatus::Charging; break; case 0x04: + case 0xff: // 0xff is Unknown but we map to NotPresent + default: ps->bs = PowerStatus::NotPresent; break; } switch ( ac ) { case 0x00: ps->ac = PowerStatus::Offline; break; case 0x01: ps->ac = PowerStatus::Online; break; case 0x02: ps->ac = PowerStatus::Backup; break; } if ( pc > 100 ) pc = -1; ps->percentRemain = pc; ps->secsRemain = sec; ok = true; } return ok; } #ifdef QT_QWS_CUSTOM void PowerStatusManager::getStatus() { int ac, bs, bf, pc, sec; ps->percentAccurate = TRUE; // not for long... if ( haveProcApm && getProcApmStatus( ac, bs, bf, pc, sec ) ) { // special case if ( bs == 0x7f ) ps->bs = PowerStatus::VeryLow; pc = -1; // fake percentage if ( pc < 0 ) { switch ( bs ) { case 0x00: ps->percentRemain = 100; break; // High case 0x01: ps->percentRemain = 30; break; // Low case 0x7f: ps->percentRemain = 10; break; // Very Low case 0x02: ps->percentRemain = 5; break; // Critical case 0x03: ps->percentRemain = -1; break; // Charging } ps->percentAccurate = FALSE; } } char *device = "/dev/apm_bios"; int fd = ::open (device, O_WRONLY); if ( fd >= 0 ) { int bbat_status = ioctl( fd, APM_IOC_BATTERY_BACK_CHK, 0 ); switch ( bbat_status ) { case 0x00: ps->bbs = PowerStatus::High; break; case 0x01: ps->bbs = PowerStatus::Low; break; case 0x7f: 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 @@ -/********************************************************************** -** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. -** -** This file is part of the Qtopia Environment. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef QCOP_MESSAGE_H -#define QCOP_MESSAGE_H - -#include <qdatastream.h> -#include <qbuffer.h> - -class QCopMessage : public QDataStream { - public: - QCopMessage(); - QCopMessage(const QCString& channel, const QCString& message); - QCopMessage(const QCopMessage& orig); - ~QCopMessage(); - - void setChannel(QCString& channel) { m_Channel = channel; } - QCString channel() const { return m_Channel; } - void setMessage(QCString& message) { m_Message = message; } - QCString message() const { return m_Message; } - const QByteArray data() const; - - QCopMessage& operator=(const QCopMessage& orig); - - private: - QCString m_Channel; - QCString m_Message; -}; - -// ### No need to inline, just maintaining binary compatability -inline QCopMessage::QCopMessage() : QDataStream(new QBuffer()) { - device()->open(IO_WriteOnly); -} - -inline QCopMessage::QCopMessage(const QCString& channel, const QCString& message) - : QDataStream(new QBuffer()), m_Channel(channel), m_Message(message) { - device()->open(IO_WriteOnly); -} - -inline QCopMessage::QCopMessage(const QCopMessage& orig) : QDataStream() { - // The QBuffer is going to share the byte array, so it will keep the - // data pointer even when this one goes out of scope. - QByteArray array(((QBuffer*)orig.device())->buffer()); - array.detach(); - setDevice(new QBuffer(array)); - device()->open(IO_Append); - - m_Channel = orig.channel(); - m_Message = orig.message(); -} - -inline QCopMessage& QCopMessage::operator=(const QCopMessage& orig) { - if (device()) { - delete device(); - unsetDevice(); - } - - // The QBuffer is going to share the byte array, so it will keep the - // data pointer even when this one goes out of scope. - QByteArray array(((QBuffer*)orig.device())->buffer()); - array.detach(); - setDevice(new QBuffer(array)); - device()->open(IO_Append); - - m_Channel = orig.channel(); - m_Message = orig.message(); - - return *this; -} - -inline const QByteArray QCopMessage::data() const { - return ((QBuffer*)device())->buffer(); -} - -inline QCopMessage::~QCopMessage() { - // If we still have our QBuffer, clean it up... - if (device()) - delete device(); - unsetDevice(); -} - -#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,83 +1,84 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ +#define QTOPIA_INTERNAL_LANGLIST #include <qapplication.h> #include <qstyle.h> #include <qwidget.h> #include <qpainter.h> #include <qtimer.h> #include <qwhatsthis.h> #include "qcopenvelope_qws.h" #include "qpedecoration_qws.h" #include <qdialog.h> #include <qdrawutil.h> #include <qgfx_qws.h> #include "qpeapplication.h" #include "resource.h" #include "global.h" #include <qfile.h> #include <qsignal.h> #include <stdlib.h> extern QRect qt_maxWindowRect; //#define MINIMIZE_HELP_HACK // use minimize button when not a dialog //#define WHATSTHIS_MODE #ifndef QT_NO_QWS_QPE_WM_STYLE #ifndef QT_NO_IMAGEIO_XPM /* XPM */ static const char * const qpe_close_xpm[] = { "16 16 3 1", " c None", ". c #FFFFFF", "+ c #000000", " ", " ", " ..... ", " ..+++++.. ", " .+++++++++. ", " .+..+++..+. ", " .++...+...++. ", " .+++.....+++. ", " .++++...++++. ", " .+++.....+++. ", " .++...+...++. ", " .+..+++..+. ", " .+++++++++. ", " ..+++++.. ", " ..... ", " "}; /* XPM */ static const char * const qpe_accept_xpm[] = { "16 16 3 1", " c None", ". c #FFFFFF", "+ c #000000", " ", " ", " ..... ", " ..+++++.. ", " .+++++++++. ", " .+++++++++. ", @@ -183,132 +184,132 @@ bool QPEManager::eventFilter( QObject *o, QEvent *e ) } return true; } break; case QEvent::MouseMove: if ( helpState & QWSButton::Clicked ) { int oldState = helpState; QPoint p = ((QMouseEvent*)e)->globalPos(); if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) helpState = QWSButton::Clicked|QWSButton::MouseOver; else helpState = 0; if ( helpState != oldState ) drawButton( w, QPEDecoration::Help, helpState ); } break; default: break; } return QObject::eventFilter( o, e ); } void QPEManager::drawButton( QWidget *w, QPEDecoration::QPERegion r, int state ) { QPainter painter(w); QRegion rgn = ((TLWidget *)w)->topExtra()->decor_allocated_region; painter.internalGfx()->setWidgetDeviceRegion( rgn ); painter.setClipRegion(decoration->region(w, w->rect(),QWSDecoration::All)); decoration->paintButton( &painter, w, (QWSDecoration::Region)r, state ); } void QPEManager::whatsThisTimeout() { if ( !QWhatsThis::inWhatsThisMode() ) { wtTimer->stop(); if ( active ) drawButton( active, QPEDecoration::Help, 0 ); } else if ( active ) { static int state = 0; if ( !state ) state = QWSButton::Clicked|QWSButton::MouseOver; else state = 0; drawButton( active, QPEDecoration::Help, state ); } } //========= class HackWidget : public QWidget { public: bool needsOk() { return (getWState() & WState_Reserved1 ); } }; //=========================================================================== QPEDecoration::QPEDecoration() : QWSDefaultDecoration() { imageOk = Resource::loadImage( "OKButton" ); imageClose = Resource::loadImage( "CloseButton" ); imageHelp = Resource::loadImage( "HelpButton" ); helpFile = QString(qApp->argv()[0]) + ".html"; - QString lang = getenv( "LANG" ); - helpExists = QFile::exists( QPEApplication::qpeDir() + "/help/" + lang + "/html/" + helpFile ); - if ( !helpExists ) - helpExists = QFile::exists( QPEApplication::qpeDir() + "/help/en/html/" + helpFile ); + QStringList path = Global::helpPath(); + helpExists = FALSE; + for (QStringList::ConstIterator it=path.begin(); it!=path.end() && !helpExists; ++it) + helpExists = QFile::exists( *it + "/" + helpFile ); #ifndef MINIMIZE_HELP_HACK qpeManager = new QPEManager( this ); #else qpeManager = 0; #endif } QPEDecoration::~QPEDecoration() { delete qpeManager; } const char **QPEDecoration::menuPixmap() { return (const char **)0; } const char **QPEDecoration::closePixmap() { return (const char **)qpe_close_xpm; } const char **QPEDecoration::minimizePixmap() { return (const char **)qpe_accept_xpm; } const char **QPEDecoration::maximizePixmap() { return (const char **)0; } const char **QPEDecoration::normalizePixmap() { return (const char **)0; } int QPEDecoration::getTitleHeight(const QWidget *) { return 15; } /* If rect is empty, no frame is added. (a hack, really) */ QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecoration::Region type) { int titleHeight = getTitleHeight(widget); // int titleWidth = getTitleWidth(widget); // int bw = rect.isEmpty() ? 0 : BORDER_WIDTH; QRegion region; #ifndef MINIMIZE_HELP_HACK qpeManager->updateActive(); #endif switch ((int)type) { case Menu: case Maximize: break; case Minimize: { if ( ((HackWidget *)widget)->needsOk() || (widget->inherits( "QDialog" ) && !widget->inherits( "QMessageBox" ) ) ) { QRect r(rect.right() - imageOk.width(), 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,115 +1,117 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "gowidget.h" #include <qpe/config.h> #include <qpe/resource.h> #include <qpainter.h> #include <qpixmap.h> #include <qpe/qpetoolbar.h> #include <qpe/qpemenubar.h> #include <qpopupmenu.h> #include <qaction.h> #include <qapplication.h> //processEvents() #include <qlabel.h> //#include <stdio.h> #include "amigo.h" #include "goplayutils.h" static const enum bVal computer_color = BLACK; static int current_handicap = 1; static QBrush *goBrush; //static QImage *newBlackStone; //static QImage *blackStone; //static QImage *whiteStone; static QPixmap *newBlackStone; static QPixmap *blackStone; static QPixmap *whiteStone; +static bool smallStones = FALSE; + GoMainWidget::GoMainWidget( QWidget *parent, const char* name) : QMainWindow( parent, name ) { setToolBarsMovable( FALSE ); GoWidget *go = new GoWidget(this); setCentralWidget(go); toolbar = new QPEToolBar(this); toolbar->setHorizontalStretchable( TRUE ); addToolBar(toolbar); QPEMenuBar *mb = new QPEMenuBar( toolbar ); mb->setMargin(0); QPopupMenu *file = new QPopupMenu( this ); QAction *a = new QAction( tr( "New Game" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), go, SLOT( newGame() ) ); a->addTo( file ); a = new QAction( tr( "Pass" ), Resource::loadPixmap( "pass" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), go, SLOT( pass() ) ); a->addTo( file ); a->addTo( toolbar ); a = new QAction( tr( "Resign" ), Resource::loadPixmap( "reset" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), go, SLOT( resign() ) ); a->addTo( file ); a = new QAction( tr( "Two player option" ), QString::null, 0, this, 0 ); a->setToggleAction( TRUE ); connect( a, SIGNAL( toggled(bool) ), go, SLOT( setTwoplayer(bool) ) ); a->addTo( file ); mb->insertItem( tr( "Game" ), file ); QLabel *turnLabel = new QLabel( toolbar ); turnLabel->setBackgroundMode( PaletteButton ); connect( go, SIGNAL(showTurn(const QPixmap&)), turnLabel, SLOT(setPixmap(const QPixmap&)) ); QLabel * scoreLabel = new QLabel( toolbar ); scoreLabel->setBackgroundMode( PaletteButton ); connect( go, SIGNAL(showScore(const QString&)), scoreLabel, SLOT(setText(const QString&)) ); toolbar->setStretchableWidget( scoreLabel ); go->readConfig(); } void GoMainWidget::resizeEvent( QResizeEvent * ) { //### this won't work because of the text label... /* if ( width() > height() ) moveToolBar( toolbar, Left ); else moveToolBar( toolbar, Top ); */ } GoWidget *GoWidget::self = 0; @@ -136,128 +138,141 @@ GoWidget::GoWidget( QWidget *parent, const char* name) : whiteStone = new QImage( fn ); */ blackStone = new QPixmap(Resource::loadPixmap( "Go-black" )); whiteStone = new QPixmap(Resource::loadPixmap( "Go-white" )); newBlackStone = new QPixmap(Resource::loadPixmap( "Go-black-highlight" )); init(); } GoWidget::~GoWidget() { writeConfig(); } void GoWidget::writeConfig() { Config cfg("Go"); cfg.setGroup("Game"); cfg.writeEntry("TwoPlayer", twoplayer); cfg.writeEntry("CurrentPlayer", currentPlayer); cfg.writeEntry("NPassed", nPassed); QString b; for (int i=0; i<19; i++) for (int j=0; j<19; j++) b += board[i][j] == BLACK ? 'B' : board[i][j] == WHITE ? 'W' : '.'; cfg.writeEntry("Board", b); cfg.writeEntry("LastX", lastX); cfg.writeEntry("LastY", lastY); extern int blackPrisoners, whitePrisoners; cfg.writeEntry("BlackPrisoners", blackPrisoners); cfg.writeEntry("WhitePrisoners", whitePrisoners); } void GoWidget::readConfig() { init(); Config cfg("Go"); cfg.setGroup("Game"); twoplayer = cfg.readBoolEntry("TwoPlayer"); currentPlayer = (bVal)cfg.readNumEntry("CurrentPlayer",1); nPassed = cfg.readNumEntry("NPassed",0); QString b = cfg.readEntry("Board"); if ( b.length() == 19*19 ) for (int i=0; i<19; i++) for (int j=0; j<19; j++) { QChar ch = b[j+19*i]; if ( ch != '.' ) GoPlaceStone( ch == 'B' ? BLACK : WHITE, i, j ); } lastX = cfg.readNumEntry("LastX"); lastY = cfg.readNumEntry("LastY"); extern int blackPrisoners, whitePrisoners; blackPrisoners = cfg.readNumEntry("BlackPrisoners",0); whitePrisoners = cfg.readNumEntry("WhitePrisoners",0); reportPrisoners(blackPrisoners,whitePrisoners); emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone ); } void GoWidget::resizeEvent( QResizeEvent * ) { d = QMIN(width(),height())/19; // int r = (d/2-1); bx = (width() - 18*d)/2 ; by = (height() - 18*d)/2 ; + + if ( d < 10 && !smallStones ) { + blackStone->convertFromImage( blackStone->convertToImage().smoothScale(8,8) ); + whiteStone->convertFromImage( whiteStone->convertToImage().smoothScale(8,8) ); + newBlackStone->convertFromImage( newBlackStone->convertToImage().smoothScale(8,8) ); + + smallStones = TRUE; + } else if ( d >= 10 && smallStones ) { + blackStone = new QPixmap(Resource::loadPixmap( "Go-black" )); + whiteStone = new QPixmap(Resource::loadPixmap( "Go-white" )); + newBlackStone = new QPixmap(Resource::loadPixmap( "Go-black-highlight" )); + smallStones = FALSE; + } } void GoWidget::init() { lastX = lastY = newX = newY = -1; nPassed = 0; for ( int i = 0; i < 19; i++ ) for ( int j = 0; j < 19; j++ ) board[i][j]=-1; gameActive = TRUE; goRestart(current_handicap); if ( twoplayer ) { currentPlayer = BLACK; } else { doComputerMove(); currentPlayer = WHITE; } emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone ); } void GoWidget::paintEvent( QPaintEvent *e ) { int i,j; int r = whiteStone->width()/2; QPainter p(this); p.fillRect( bx - d/2, by - d/2, 19*d, 19*d, *goBrush ); int xMin = QMAX( x2board(e->rect().left()), 0 ); int xMax = QMIN( x2board(e->rect().right()), 18 ); int yMin = QMAX( y2board(e->rect().top()), 0 ); int yMax = QMIN( y2board(e->rect().bottom()), 18 ); QColor pine( 255, 186, 89 ); p.setPen( pine.dark() ); for ( i = xMin; i < xMax+1 ; i ++ ) { p.drawLine( bx+i*d, by, bx+i*d, by+18*d ); } for ( j = yMin; j < yMax+1 ; j ++ ) { p.drawLine( bx, by+j*d, bx+18*d, by+j*d); } // dots are at (3,3), (3,9), (3,15) and so on p.setBrush( black ); for ( i = 3; i < xMax+1; i+=6 ) for ( j = 3; j < yMax+1; j+=6 ) p.drawEllipse( bx+i*d-2, by+j*d-2, 5, 5 ); for ( i = xMin; i < xMax+1; i++ ) for ( j = yMin; j < yMax+1; j++ ) { if ( board[i][j] == WHITE || currentPlayer==WHITE && newX == i && newY == j ) p.drawPixmap( bx+i*d - r, by+j*d - r, *whiteStone ); else if ( i == lastX && j == lastY ) p.drawPixmap( bx+i*d - r, by+j*d - r, *newBlackStone ); else if ( board[i][j] == BLACK || currentPlayer==BLACK && newX == i && newY == j) p.drawPixmap( bx+i*d - r, by+j*d - r, *blackStone ); } } 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 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef MINEFIELD_H #define MINEFIELD_H -#include <qtable.h> +#include <qscrollview.h> class Mine; class Config; -class MineField : public QTable +class MineField : public QScrollView { Q_OBJECT public: MineField( QWidget* parent = 0, const char* name = 0 ); ~MineField(); enum State { Waiting, Playing, GameOver }; State state() const { return stat; } void readConfig(Config&); void writeConfig(Config&) const; int level() const { return lev; } + void setAvailableRect( const QRect & ); public slots: void setup( int level ); void showMines(); signals: void gameOver( bool won ); void gameStarted(); void mineCount( int ); protected: - void paintFocus( QPainter*, const QRect& ); - void viewportMousePressEvent( QMouseEvent* ); - void viewportMouseReleaseEvent( QMouseEvent* ); + + void contentsMousePressEvent( QMouseEvent* ); + void contentsMouseReleaseEvent( QMouseEvent* ); void keyPressEvent( QKeyEvent* ); void keyReleaseEvent( QKeyEvent* ); + void drawContents( QPainter * p, int clipx, int clipy, int clipw, int cliph ); int getHint( int row, int col ); - void setHint( Mine* ); + void setHint( int r, int c ); void updateMine( int row, int col ); void paletteChange( const QPalette & ); + void updateCell( int r, int c ); + bool onBoard( int r, int c ) const { return r >= 0 && r < numRows && c >= 0 && c < numCols; } + Mine *mine( int row, int col ) { return onBoard(row, col ) ? mines[row+numCols*col] : 0; } + const Mine *mine( int row, int col ) const { return onBoard(row, col ) ? mines[row+numCols*col] : 0; } protected slots: void cellPressed( int row, int col ); void cellClicked( int row, int col ); void held(); private: + int findCellSize(); + void setCellSize( int ); + State stat; void MineField::setState( State st ); void MineField::placeMines(); enum FlagAction { NoAction, FlagOn, FlagNext }; FlagAction flagAction; bool ignoreClick; int currRow; int currCol; + int numRows, numCols; + int minecount; int mineguess; int nonminecount; int lev; + QRect availableRect; + int cellSize; QTimer *holdTimer; + Mine **mines; }; #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 @@ -158,185 +158,200 @@ class ResultIndicator : private QLabel public: static void showResult( QWidget *ref, bool won ); private: ResultIndicator( QWidget *parent, const char *name, WFlags f) :QLabel( parent, name, f ) {} void timerEvent( QTimerEvent *); void center(); bool twoStage; int timerId; }; void ResultIndicator::showResult( QWidget *ref, bool won ) { ResultIndicator *r = new ResultIndicator( ref, 0, WStyle_Customize | WStyle_Tool | WType_TopLevel ); r->setAlignment( AlignCenter ); r->setFrameStyle( Sunken|StyledPanel ); if ( won ) { r->setText( MineSweep::tr("You won!") ); r->center(); r->show(); r->twoStage = FALSE; r->timerId = r->startTimer(1500); } else { QPalette p( red ); r->setPalette( p ); r->setText( MineSweep::tr("You exploded!") ); r->resize( ref->size() ); r->move( ref->mapToGlobal(QPoint(0,0)) ); r->show(); r->twoStage = TRUE; r->timerId =r->startTimer(200); } } void ResultIndicator::center() { QWidget *w = parentWidget(); QPoint pp = w->mapToGlobal( QPoint(0,0) ); QSize s = sizeHint()*3; pp = QPoint( pp.x() + w->width()/2 - s.width()/2, pp.y() + w->height()/ 2 - s.height()/2 ); setGeometry( QRect(pp, s) ); } void ResultIndicator::timerEvent( QTimerEvent *te ) { if ( te->timerId() != timerId ) return; killTimer( timerId ); if ( twoStage ) { center(); twoStage = FALSE; timerId = startTimer( 1000 ); } else { delete this; } } +class MineFrame : public QFrame +{ +public: + MineFrame( QWidget *parent, const char *name = 0 ) + :QFrame( parent, name ) {} + void setField( MineField *f ) { field = f; } +protected: + void resizeEvent( QResizeEvent *e ) { + field->setAvailableRect( contentsRect()); + QFrame::resizeEvent(e); + } +private: + MineField *field; +}; + + + MineSweep::MineSweep( QWidget* parent, const char* name, WFlags f ) : QMainWindow( parent, name, f ) { srand(::time(0)); setCaption( tr("Mine Hunt") ); setIcon( Resource::loadPixmap( "minesweep_icon" ) ); - QPEToolBar *menuToolBar = new QPEToolBar( this ); - QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar ); + QPEToolBar *toolBar = new QPEToolBar( this ); + toolBar->setHorizontalStretchable( TRUE ); + + QPEMenuBar *menuBar = new QPEMenuBar( toolBar ); QPopupMenu *gameMenu = new QPopupMenu( this ); gameMenu->insertItem( tr("Beginner"), this, SLOT( beginner() ) ); gameMenu->insertItem( tr("Advanced"), this, SLOT( advanced() ) ); gameMenu->insertItem( tr("Expert"), this, SLOT( expert() ) ); menuBar->insertItem( tr("Game"), gameMenu ); - QPEToolBar *toolBar = new QPEToolBar( this ); - toolBar->setHorizontalStretchable( TRUE ); - guessLCD = new QLCDNumber( toolBar ); toolBar->setStretchableWidget( guessLCD ); QPalette lcdPal( red ); lcdPal.setColor( QColorGroup::Background, QApplication::palette().active().background() ); lcdPal.setColor( QColorGroup::Button, QApplication::palette().active().button() ); // guessLCD->setPalette( lcdPal ); guessLCD->setSegmentStyle( QLCDNumber::Flat ); guessLCD->setFrameStyle( QFrame::NoFrame ); guessLCD->setNumDigits( 2 ); guessLCD->setBackgroundMode( PaletteButton ); newGameButton = new QPushButton( toolBar ); newGameButton->setPixmap( QPixmap( pix_new ) ); newGameButton->setFocusPolicy(QWidget::NoFocus); connect( newGameButton, SIGNAL(clicked()), this, SLOT(newGame()) ); timeLCD = new QLCDNumber( toolBar ); // timeLCD->setPalette( lcdPal ); timeLCD->setSegmentStyle( QLCDNumber::Flat ); timeLCD->setFrameStyle( QFrame::NoFrame ); timeLCD->setNumDigits( 5 ); // "mm:ss" timeLCD->setBackgroundMode( PaletteButton ); setToolBarsMovable ( FALSE ); - addToolBar( menuToolBar ); addToolBar( toolBar ); - QFrame *mainframe = new QFrame( this ); + MineFrame *mainframe = new MineFrame( this ); mainframe->setFrameShape( QFrame::Box ); mainframe->setFrameShadow( QFrame::Raised ); - mainframe->setMargin(5); + mainframe->setLineWidth(2); - QBoxLayout *box = new QVBoxLayout( mainframe ); + field = new MineField( mainframe ); - box->addWidget( field, 0, AlignCenter ); + mainframe->setField( field ); QFont fnt = field->font(); fnt.setBold( TRUE ); field->setFont( QFont( fnt ) ); field->setFocus(); setCentralWidget( mainframe ); connect( field, SIGNAL( gameOver( bool ) ), this, SLOT( gameOver( bool ) ) ); connect( field, SIGNAL( mineCount( int ) ), this, SLOT( setCounter( int ) ) ); connect( field, SIGNAL( gameStarted()), this, SLOT( startPlaying() ) ); timer = new QTimer( this ); connect( timer, SIGNAL( timeout() ), this, SLOT( updateTime() ) ); readConfig(); } MineSweep::~MineSweep() { writeConfig(); } void MineSweep::gameOver( bool won ) { field->showMines(); if ( won ) { newGameButton->setPixmap( QPixmap( happy_xpm ) ); } else { newGameButton->setPixmap( QPixmap( dead_xpm ) ); } ResultIndicator::showResult( this, won ); timer->stop(); } void MineSweep::newGame() { newGame(field->level()); } void MineSweep::newGame(int level) { timeLCD->display( "0:00" ); field->setup( level ); newGameButton->setPixmap( QPixmap( pix_new ) ); timer->stop(); } void MineSweep::startPlaying() { newGameButton->setPixmap( QPixmap( worried_xpm ) ); starttime = QDateTime::currentDateTime(); timer->start( 1000 ); } void MineSweep::beginner() { newGame(1); } void MineSweep::advanced() { newGame(2); } 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 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include <qmainwindow.h> #include <qcanvas.h> #include <qlabel.h> #include "snake.h" #include "target.h" #include "obstacle.h" // class QCanvas; class SnakeGame : public QMainWindow { Q_OBJECT public: SnakeGame(QWidget* parent=0, const char* name=0, WFlags f=0); ~SnakeGame(); void clear(); void createTargets(); - void welcomescreen(); protected: virtual void keyPressEvent(QKeyEvent*); virtual void resizeEvent(QResizeEvent *e); signals: void moveFaster(); private slots: void newGame(); void gameOver(); void wait(); void levelUp(); void scoreInc(); + void welcomescreen(); private: void showScore(int); QCanvasView* cv; QLabel* scorelabel; QCanvas canvas; QTimer* pauseTimer; Snake* snake; int last; int level; int stage; int targetamount; int notargets; bool waitover; bool gamestopped; }; 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 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "obstacle.h" #include "codes.h" #include <qpe/resource.h> -Obstacle::Obstacle(QCanvas* canvas, int x, int y) + + +Obstacle::Obstacle(QCanvas* canvas, int y) : QCanvasSprite(0, canvas) { - newObstacle(x, y); + newObstacle(y); } -void Obstacle::newObstacle(int x, int y) +void Obstacle::newObstacle(int y) { - QCanvasPixmapArray* obstaclearray = new QCanvasPixmapArray(Resource::findPixmap("snake/wall.png")); + QPixmap obstaclePix( Resource::findPixmap("snake/wall.png") ); + + if ( obstaclePix.width() > canvas()->width()*3/5 ) { + int w = canvas()->width()*3/5; + w = w - w % 16; + obstaclePix.resize( w, obstaclePix.height() ); + } + QList<QPixmap> pixl; + pixl.append( &obstaclePix ); + + QPoint nullp; + QList<QPoint> pl; + pl.append( &nullp ); + + QCanvasPixmapArray* obstaclearray = new QCanvasPixmapArray(pixl, pl); setSequence(obstaclearray); + int x = ( canvas()->width() - obstaclePix.width() )/2; + x = x - x % 16; + y = y - y % 16; move(x, y); - + setZ( -100 ); show(); canvas()->update(); } int Obstacle::rtti() const { return obstacle_rtti; } Obstacle::~Obstacle() { } 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 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include <qcanvas.h> class Obstacle : public QCanvasSprite { public: - Obstacle(QCanvas*, int x, int y); + Obstacle(QCanvas*, int y); ~Obstacle(); - void newObstacle(int x, int y); + void newObstacle(int y); int rtti() const; }; 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,252 +1,283 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "cardgame.h" #include "canvascard.h" #include <qpe/resource.h> #include <qpainter.h> #include <qimage.h> #include <qpaintdevice.h> #include <qbitmap.h> +#include <qgfx_qws.h> // Needed to get the device's width #include <math.h> #if defined( QT_QWS_CASSIOPEIA ) #define SLOW_HARDWARE #endif // Seems to be fast enough to me even without Transformations in the library //#if defined( QT_NO_TRANSFORMATIONS ) && defined( QT_QWS_IPAQ ) //#define SLOW_HARDWARE //#endif QBitmap *Create180RotatedBitmap(QBitmap *srcBitmap) { #ifdef QT_NO_TRANSFORMATIONS int w = srcBitmap->width(); int h = srcBitmap->height(); QBitmap *dstBitmap = new QBitmap( w, h ); // ### this is very poorly implemented and probably could be much faster for (int i = 0; i < w; i++) for (int j = 0; j < h; j++) bitBlt( dstBitmap, i, j, srcBitmap, w - i - 1, h - j - 1, 1, 1 ); return dstBitmap; #else QWMatrix m; m.rotate( 180.0 ); return new QBitmap( srcBitmap->xForm( m ) ); #endif } QPixmap *CreateScaledPixmap(QPixmap *srcPixmap, double scaleX, double scaleY) { #ifdef QT_NO_TRANSFORMATIONS int w = srcPixmap->width(); int h = srcPixmap->height(); int newW = (int)(w * scaleX); int newH = (int)(h * scaleY); QPixmap *dstPixmap = new QPixmap( newW, newH ); // ### this is very poorly implemented and probably could be much faster for (int i = 0; i < newW; i++) { int srcX = w * i / newW; if (newH == h) { // Optimise for scaleing in the X-axis only bitBlt( dstPixmap, i, 0, srcPixmap, srcX, 0, 1, h ); } else { for (int j = 0; j < newH; j++) { int srcY = h * j / newH; bitBlt( dstPixmap, i, j, srcPixmap, srcX, srcY, 1, 1 ); } } } return dstPixmap; #else QWMatrix s; s.scale( scaleX, scaleY ); return new QPixmap( srcPixmap->xForm( s ) ); #endif } // Initialise static member variables to NULL QPixmap *CanvasCard::cardsFaces = NULL; QPixmap *CanvasCard::cardsBacks = NULL; QBitmap *CanvasCard::cardsChars = NULL; QBitmap *CanvasCard::cardsSuits = NULL; QBitmap *CanvasCard::cardsCharsUpsideDown = NULL; QBitmap *CanvasCard::cardsSuitsUpsideDown = NULL; CanvasCard::CanvasCard( eValue v, eSuit s, bool f, QCanvas *canvas ) : Card(v, s, f), QCanvasRectangle( 0, 0, 1, 1, canvas ), cardBack(1), scaleX(1.0), scaleY(1.0) { if ( !cardsFaces ) { + if ( qt_screen->deviceWidth() < 200 ) { + cardsFaces = new QPixmap( Resource::loadPixmap( "cards/card_face_small" ) ); + cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001_small" ) ); + cardsChars = new QBitmap( Resource::loadBitmap( "cards/card_chars_small" ) ); + cardsSuits = new QBitmap( Resource::loadBitmap( "cards/card_suits_small" ) ); + } else { cardsFaces = new QPixmap( Resource::loadPixmap( "cards/card_face" ) ); cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001" ) ); cardsChars = new QBitmap( Resource::loadBitmap( "cards/card_chars" ) ); cardsSuits = new QBitmap( Resource::loadBitmap( "cards/card_suits" ) ); + } cardsCharsUpsideDown = Create180RotatedBitmap( cardsChars ); cardsSuitsUpsideDown = Create180RotatedBitmap( cardsSuits ); } xOff = cardsFaces->width() / 2; yOff = cardsFaces->height() / 2; setSize( cardsFaces->width(), cardsFaces->height() ); setPen( NoPen ); flipping = FALSE; } void CanvasCard::setCardBack(int b) { if ( cardBack != b ) { cardBack = b; if ( cardsBacks ) delete cardsBacks; + if ( qt_screen->deviceWidth() < 200 ) { + switch (cardBack) { + case 0: + cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001_small" ) ); break; + case 1: + cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0002_small" ) ); break; + case 2: + cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0003_small" ) ); break; + case 3: + cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0004_small" ) ); break; + case 4: + cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0005_small" ) ); break; + } + } else { switch (cardBack) { case 0: cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001" ) ); break; case 1: cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0002" ) ); break; case 2: cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0003" ) ); break; case 3: cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0004" ) ); break; case 4: cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0005" ) ); break; } + } if ( !isFacing() ) redraw(); } } void CanvasCard::draw(QPainter &painter) { int ix = (int)x(), iy = (int)y(); QPainter *p = &painter; QPixmap *unscaledCard = NULL; if ((scaleX <= 0.98) || (scaleY <= 0.98)) { p = new QPainter(); unscaledCard = new QPixmap( cardsFaces->width(), cardsFaces->height() ); p->begin(unscaledCard); ix = 0; iy = 0; } if ( isFacing() ) { /* // Now add the joker and card backs to the list of pixmaps QPixmap *CardsBack = new QPixmap( Resource::loadPixmap( "cards/card_joker.png" ) ); QPoint *newBackHotspot = new QPoint( 0, 0 ); pixmaps->append((const QPixmap *)CardsBack); hotspots->append((const QPoint *)newBackHotspot); */ int w = cardsFaces->width(), h = cardsFaces->height(); // p->setBrush( NoBrush ); p->setBrush( QColor( 0xFF, 0xFF, 0xFF ) ); if ( isRed() == TRUE ) p->setPen( QColor( 0xFF, 0, 0 ) ); else p->setPen( QColor( 0, 0, 0 ) ); + if ( qt_screen->deviceWidth() < 200 ) { + p->drawPixmap( ix + 0, iy + 0, *cardsFaces ); + p->drawPixmap( ix + 3, iy + 3, *cardsChars, 5*(getValue()-1), 0, 5, 6 ); + p->drawPixmap( ix + 11, iy + 3, *cardsSuits, 5*(getSuit()-1), 0, 5, 6 ); + p->drawPixmap( ix + w-3-5, iy + h-3-6, *cardsCharsUpsideDown, 5*(12-getValue()+1), 0, 5, 6 ); + p->drawPixmap( ix + w-11-5, iy + h-3-6, *cardsSuitsUpsideDown, 5*(3-getSuit()+1), 0, 5, 6 ); + } else { p->drawPixmap( ix + 0, iy + 0, *cardsFaces ); p->drawPixmap( ix + 4, iy + 4, *cardsChars, 7*(getValue()-1), 0, 7, 7 ); p->drawPixmap( ix + 12, iy + 4, *cardsSuits, 7*(getSuit()-1), 0, 7, 8 ); p->drawPixmap( ix + w-4-7, iy + h-4-7, *cardsCharsUpsideDown, 7*(12-getValue()+1), 0, 7, 7 ); p->drawPixmap( ix + w-12-7, iy + h-5-7, *cardsSuitsUpsideDown, 7*(3-getSuit()+1), 0, 7, 8 ); + } } else { p->drawPixmap( ix, iy, *cardsBacks ); } if (p != &painter) { p->end(); QPixmap *scaledCard = CreateScaledPixmap( unscaledCard, scaleX, scaleY ); int xoff = scaledCard->width() / 2; int yoff = scaledCard->height() / 2; painter.drawPixmap( (int)x() + xOff - xoff, (int)y() + yOff - yoff, *scaledCard ); delete p; delete unscaledCard; delete scaledCard; } } static const double flipLift = 1.5; void CanvasCard::flipTo(int x2, int y2, int steps) { flipSteps = steps; #ifdef SLOW_HARDWARE move(x2,y2); Card::flipTo(x2,y2,steps); #else int x1 = (int)x(); int y1 = (int)y(); double dx = x2 - x1; double dy = y2 - y1; flipping = TRUE; destX = x2; destY = y2; animSteps = flipSteps; setVelocity(dx/animSteps, dy/animSteps-flipLift); setAnimated(TRUE); #endif } void CanvasCard::advance(int stage) { if ( stage==1 ) { if ( animSteps-- <= 0 ) { scaleX = 1.0; scaleY = 1.0; flipping = FALSE; setVelocity(0,0); setAnimated(FALSE); move(destX,destY); // exact } else { if ( flipping ) { if ( animSteps > flipSteps / 2 ) { // animSteps = flipSteps .. flipSteps/2 (flip up) -> 1..0 scaleX = ((double)animSteps/flipSteps-0.5)*2; } else { // animSteps = flipSteps/2 .. 0 (flip down) -> 0..1 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 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include <qpainter.h> #include <qcanvas.h> +#include <qgfx_qws.h> #include "canvasshapes.h" CanvasRoundRect::CanvasRoundRect(int x, int y, QCanvas *canvas) : - QCanvasRectangle( x, y, 23, 36, canvas) + QCanvasRectangle( x, y, ( qt_screen->deviceWidth() < 200 ) ? 20 : 23, ( qt_screen->deviceWidth() < 200 ) ? 27 : 36, canvas) { setZ(0); show(); } void CanvasRoundRect::redraw() { hide(); show(); } void CanvasRoundRect::drawShape(QPainter &p) { + if ( qt_screen->deviceWidth() < 200 ) + p.drawRoundRect( (int)x() + 1, (int)y() + 1, 18, 25); + else p.drawRoundRect( (int)x(), (int)y(), 23, 36); } CanvasCircleOrCross::CanvasCircleOrCross(int x, int y, QCanvas *canvas) : QCanvasRectangle( x, y, 21, 21, canvas), circleShape(TRUE) { show(); } void CanvasCircleOrCross::redraw() { hide(); show(); } void CanvasCircleOrCross::setCircle() { circleShape = TRUE; redraw(); } void CanvasCircleOrCross::setCross() { circleShape = FALSE; redraw(); } void CanvasCircleOrCross::drawShape(QPainter &p) { + if ( qt_screen->deviceWidth() < 200 ) { + int x1 = (int)x(), y1 = (int)y(); + // Green circle + if (circleShape == TRUE) { + p.setPen( QPen( QColor(0x10, 0xE0, 0x10), 1 ) ); + p.drawEllipse( x1 - 1, y1 - 1, 17, 17); + p.drawEllipse( x1 - 1, y1 - 0, 17, 15); + p.drawEllipse( x1 + 0, y1 + 0, 15, 15); + p.drawEllipse( x1 + 1, y1 + 0, 13, 15); + p.drawEllipse( x1 + 1, y1 + 1, 13, 13); + // Red cross + } else { + p.setPen( QPen( QColor(0xE0, 0x10, 0x10), 4 ) ); + p.drawLine( x1, y1, x1 + 14, y1 + 14); + p.drawLine( x1 + 14, y1, x1, y1 + 14); + } + } else { int x1 = (int)x(), y1 = (int)y(); // Green circle if (circleShape == TRUE) { p.setPen( QPen( QColor(0x10, 0xE0, 0x10), 1 ) ); p.drawEllipse( x1 - 1, y1 - 1, 21, 21); p.drawEllipse( x1 - 1, y1 - 0, 21, 19); p.drawEllipse( x1 + 0, y1 + 0, 19, 19); p.drawEllipse( x1 + 1, y1 + 0, 17, 19); p.drawEllipse( x1 + 1, y1 + 1, 17, 17); // Red cross } else { p.setPen( QPen( QColor(0xE0, 0x10, 0x10), 5 ) ); p.drawLine( x1, y1, x1 + 20, y1 + 20); p.drawLine( x1 + 20, y1, x1, y1 + 20); } } +} 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,105 +1,110 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ +#include <qgfx_qws.h> #include "freecellcardgame.h" extern int highestZ; int numberOfFreeCells = 4; FreecellCardGame::FreecellCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent) { numberOfFreeCells = 4; highestZ = 0; + int spaceBetweenPiles = ( qt_screen->deviceWidth() < 200 ) ? 21 : 28; + int xOrigin = ( qt_screen->deviceWidth() < 200 ) ? 0 : 5; + int spacing = ( qt_screen->deviceWidth() < 200 ) ? 0 : 0; + for (int i = 0; i < 4; i++) { - freecellPiles[i] = new FreecellFreecellPile( 5 + i * 28, 10, canvas() ); + freecellPiles[i] = new FreecellFreecellPile( xOrigin + i * spaceBetweenPiles, 10, canvas() ); addCardPile(freecellPiles[i]); } for (int i = 0; i < 4; i++) { - discardPiles[i] = new FreecellDiscardPile( 125 + i * 28, 10, canvas() ); + discardPiles[i] = new FreecellDiscardPile( xOrigin + spacing + 6 + (i + 4) * spaceBetweenPiles, 10, canvas() ); addCardPile(discardPiles[i]); } for (int i = 0; i < 8; i++) { - workingPiles[i] = new FreecellWorkingPile( 10 + i * 28, 50, canvas() ); + workingPiles[i] = new FreecellWorkingPile( xOrigin + spacing + 2 + i * spaceBetweenPiles, 50, canvas() ); addCardPile(workingPiles[i]); } } void FreecellCardGame::deal(void) { highestZ = 1; beginDealing(); for (int i = 0; i < 52; i++) { Card *card = cards[i]; card->setFace( TRUE ); card->setPos( 0, 0, highestZ ); card->setCardPile( workingPiles[i%8] ); workingPiles[i%8]->addCardToTop( card ); card->move( workingPiles[i%8]->getCardPos( card ) ); card->showCard(); highestZ++; } endDealing(); } bool FreecellCardGame::mousePressCard( Card *c, QPoint p ) { Q_UNUSED(p); if ( !c->getCardPile()->isAllowedToBeMoved(c) ) { moving = NULL; return TRUE; } return FALSE; } void FreecellCardGame::readConfig( Config& cfg ) { cfg.setGroup("GameState"); // Create Cards, but don't shuffle or deal them yet createDeck(); // Move the cards to their piles (deal them to their previous places) beginDealing(); highestZ = 1; for (int k = 0; k < 4; k++) { QString pile; pile.sprintf( "FreeCellPile%i", k ); readPile( cfg, freecellPiles[k], pile, highestZ ); } for (int k = 0; k < 4; k++) { QString pile; pile.sprintf( "DiscardPile%i", k ); readPile( cfg, discardPiles[k], pile, highestZ ); } for (int k = 0; k < 8; k++) { 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,108 +1,125 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ +#include <qgfx_qws.h> #include "patiencecardgame.h" int highestZ = 0; PatienceCardGame::PatienceCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent) { numberOfTimesThroughDeck = 0; highestZ = 0; + if ( qt_screen->deviceWidth() < 200 ) { + circleCross = new CanvasCircleOrCross( 7, 16, canvas() ); + rectangle = new CanvasRoundRect( 30, 10, canvas() ); + + for (int i = 0; i < 4; i++) { + discardPiles[i] = new PatienceDiscardPile( 78 + i * 23, 10, canvas() ); + addCardPile(discardPiles[i]); + } + for (int i = 0; i < 7; i++) { + workingPiles[i] = new PatienceWorkingPile( 5 + i * 23, 50, canvas() ); + addCardPile(workingPiles[i]); + } + faceDownDealingPile = new PatienceFaceDownDeck( 5, 10, canvas() ); + faceUpDealingPile = new PatienceFaceUpDeck( 30, 10, canvas() ); + } else { circleCross = new CanvasCircleOrCross( 7, 18, canvas() ); rectangle = new CanvasRoundRect( 35, 10, canvas() ); for (int i = 0; i < 4; i++) { discardPiles[i] = new PatienceDiscardPile( 110 + i * 30, 10, canvas() ); addCardPile(discardPiles[i]); } for (int i = 0; i < 7; i++) { workingPiles[i] = new PatienceWorkingPile( 10 + i * 30, 50, canvas() ); addCardPile(workingPiles[i]); } faceDownDealingPile = new PatienceFaceDownDeck( 5, 10, canvas() ); faceUpDealingPile = new PatienceFaceUpDeck( 35, 10, canvas() ); } +} PatienceCardGame::~PatienceCardGame() { delete circleCross; delete rectangle; delete faceDownDealingPile; delete faceUpDealingPile; } void PatienceCardGame::deal(void) { highestZ = 1; int t = 0; beginDealing(); for (int i = 0; i < 7; i++) { cards[t]->setFace(TRUE); for (int k = i; k < 7; k++, t++) { Card *card = cards[t]; workingPiles[k]->addCardToTop(card); card->setCardPile( workingPiles[k] ); QPoint p = workingPiles[k]->getCardPos( card ); card->setPos( p.x(), p.y(), highestZ ); card->showCard(); highestZ++; } } for ( ; t < 52; t++) { Card *card = cards[t]; faceDownDealingPile->addCardToTop(card); card->setCardPile( faceDownDealingPile ); QPoint p = faceDownDealingPile->getCardPos( card ); card->setPos( p.x(), p.y(), highestZ ); card->showCard(); highestZ++; } endDealing(); } void PatienceCardGame::readConfig( Config& cfg ) { cfg.setGroup("GameState"); // Do we have a config file to read in? if ( !cfg.hasKey("numberOfTimesThroughDeck") ) { // if not, create a new game newGame(); return; } // We have a config file, lets read it in and use it // Create Cards, but don't shuffle or deal them yet createDeck(); // How many times through the deck have we been numberOfTimesThroughDeck = cfg.readNumEntry("NumberOfTimesThroughDeck"); // restore state to the circle/cross under the dealing pile @@ -112,123 +129,129 @@ void PatienceCardGame::readConfig( Config& cfg ) circleCross->setCross(); // Move the cards to their piles (deal them to their previous places) beginDealing(); highestZ = 1; for (int k = 0; k < 7; k++) { QString pile; pile.sprintf( "WorkingPile%i", k ); readPile( cfg, workingPiles[k], pile, highestZ ); } for (int k = 0; k < 4; k++) { QString pile; pile.sprintf( "DiscardPile%i", k ); readPile( cfg, discardPiles[k], pile, highestZ ); } readPile( cfg, faceDownDealingPile, "FaceDownDealingPile", highestZ ); readPile( cfg, faceUpDealingPile, "FaceUpDealingPile", highestZ ); highestZ++; endDealing(); } void PatienceCardGame::writeConfig( Config& cfg ) { cfg.setGroup("GameState"); cfg.writeEntry("numberOfTimesThroughDeck", numberOfTimesThroughDeck); for ( int i = 0; i < 7; i++ ) { QString pile; pile.sprintf( "WorkingPile%i", i ); workingPiles[i]->writeConfig( cfg, pile ); } for ( int i = 0; i < 4; i++ ) { QString pile; pile.sprintf( "DiscardPile%i", i ); discardPiles[i]->writeConfig( cfg, pile ); } faceDownDealingPile->writeConfig( cfg, "FaceDownDealingPile" ); faceUpDealingPile->writeConfig( cfg, "FaceUpDealingPile" ); } bool PatienceCardGame::mousePressCard( Card *card, QPoint p ) { Q_UNUSED(p); CanvasCard *item = (CanvasCard *)card; if (item->isFacing() != TRUE) { // From facedown stack if ((item->x() == 5) && ((int)item->y() == 10)) { item->setZ(highestZ); highestZ++; // Added Code faceDownDealingPile->removeCard(item); faceUpDealingPile->addCardToTop(item); item->setCardPile( faceUpDealingPile ); + if ( qt_screen->deviceWidth() < 200 ) + item->flipTo( 30, (int)item->y() ); + else item->flipTo( 35, (int)item->y() ); } moving = NULL; moved = FALSE; // move two other cards if we flip three at a time int flipped = 1; QCanvasItemList l = canvas()->collisions( p ); for (QCanvasItemList::Iterator it = l.begin(); (it != l.end()) && (flipped != cardsDrawn()); ++it) { if ( (*it)->rtti() == canvasCardId ) { CanvasCard *item = (CanvasCard *)*it; if (item->animated()) continue; item->setZ(highestZ); highestZ++; flipped++; // Added Code faceDownDealingPile->removeCard(item); faceUpDealingPile->addCardToTop(item); item->setCardPile( faceUpDealingPile ); + if ( qt_screen->deviceWidth() < 200 ) + item->flipTo( 30, (int)item->y(), 8 * flipped ); + else item->flipTo( 35, (int)item->y(), 8 * flipped ); } } return TRUE; } return FALSE; } void PatienceCardGame::mousePress(QPoint p) { if ( canTurnOverDeck() && (p.x() > 5) && (p.x() < 28) && (p.y() > 10) && (p.y() < 46) ) { beginDealing(); Card *card = faceUpDealingPile->cardOnTop(); while ( card ) { card->setPos( 5, 10, highestZ ); card->setFace( FALSE ); faceUpDealingPile->removeCard( card ); faceDownDealingPile->addCardToTop( card ); card->setCardPile( faceDownDealingPile ); card = faceUpDealingPile->cardOnTop(); highestZ++; } endDealing(); throughDeck(); moved = TRUE; } } 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 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef PATIENCE_CARD_GAME_H #define PATIENCE_CARD_GAME_H #include <qpopupmenu.h> #include <qmainwindow.h> #include <qintdict.h> #include <qcanvas.h> +#include <qgfx_qws.h> // #include "canvascardshapes.h" // #include "canvascard.h" #include "canvascardgame.h" class PatienceFaceDownDeck : public CardPile, public CanvasRoundRect { public: PatienceFaceDownDeck(int x, int y, QCanvas *canvas) : CardPile(x, y), CanvasRoundRect(x, y, canvas) { } virtual bool isAllowedOnTop(Card *card) { Q_UNUSED(card); // Need to check it is from the faceUpDealingPile return TRUE; } virtual bool isAllowedToBeMoved(Card *card) { Q_UNUSED(card); //if ( ( !card->isFacing() ) && ( card == cardOnTop() ) ) if ( card == cardOnTop() ) return TRUE; return FALSE; } }; class PatienceFaceUpDeck : public CardPile, public CanvasRoundRect { public: PatienceFaceUpDeck(int x, int y, QCanvas *canvas) : CardPile(x, y), CanvasRoundRect(x, y, canvas) { } virtual bool isAllowedOnTop(Card *card) { Q_UNUSED(card); // Need to check it is from the faceDownDealingPile return TRUE; } virtual bool isAllowedToBeMoved(Card *card) { Q_UNUSED(card); //if ( ( card->isFacing() ) && ( card == cardOnTop() ) ) if ( card == cardOnTop() ) return TRUE; return FALSE; } }; class PatienceDiscardPile : public CardPile, public CanvasRoundRect { public: PatienceDiscardPile(int x, int y, QCanvas *canvas) : CardPile(x, y), CanvasRoundRect(x, y, canvas) { } virtual bool isAllowedOnTop(Card *card) { if ( card->isFacing() && ( card->getCardPile()->cardInfront(card) == NULL ) && ( ( ( cardOnTop() == NULL ) && ( card->getValue() == ace ) ) || ( ( cardOnTop() != NULL ) && ( (int)card->getValue() == (int)cardOnTop()->getValue() + 1 ) && ( card->getSuit() == cardOnTop()->getSuit() ) ) ) ) return TRUE; return FALSE; } virtual bool isAllowedToBeMoved(Card *card) { if ( card->isFacing() && ( card == cardOnTop() ) ) return TRUE; return FALSE; } }; class PatienceWorkingPile : public CardPile, public CanvasRoundRect { public: PatienceWorkingPile(int x, int y, QCanvas *canvas) : CardPile(x, y), CanvasRoundRect(x, y, canvas), top(x, y) { } virtual bool isAllowedOnTop(Card *card) { if ( card->isFacing() && ( ( ( cardOnTop() == NULL ) && (card->getValue() == king) ) || ( ( cardOnTop() != NULL ) && ( (int)card->getValue() + 1 == (int)cardOnTop()->getValue() ) && ( card->isRed() != cardOnTop()->isRed() ) ) ) ) return TRUE; return FALSE; } virtual bool isAllowedToBeMoved(Card *card) { if ( card->isFacing() ) return TRUE; return FALSE; } virtual void cardAddedToTop(Card *card) { Q_UNUSED(card); top = getCardPos(NULL); setNextX( top.x() ); setNextY( top.y() ); } virtual void cardRemoved(Card *card) { Q_UNUSED(card); Card *newTopCard = cardOnTop(); if ( !newTopCard ) { top = QPoint( pileX, pileY ); setNextX( pileX ); setNextY( pileY ); return; } else { top = getCardPos(NULL); if ( newTopCard->isFacing() == FALSE ) { + int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13; // correct the position taking in to account the card is not // yet flipped, but will become flipped top = QPoint( top.x() - 1, top.y() - 3 ); newTopCard->flipTo( top.x(), top.y() ); - top = QPoint( top.x(), top.y() + 13 ); + top = QPoint( top.x(), top.y() + offsetDown ); } setNextX( top.x() ); setNextY( top.y() ); } } virtual QPoint getCardPos(Card *c) { int x = pileX, y = pileY; Card *card = cardOnBottom(); while ((card != c) && (card != NULL)) { if (card->isFacing()) { - y += 13; + int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13; + y += offsetDown; } else { x += 1; y += 3; } card = cardInfront(card); } return QPoint( x, y ); } virtual QPoint getHypertheticalNextCardPos(void) { return top; // return QPoint( getNextX(), getNextY() ); } private: QPoint top; }; class PatienceCardGame : public CanvasCardGame { public: PatienceCardGame(QCanvas *c, bool snap, QWidget *parent = 0); virtual ~PatienceCardGame(); virtual void deal(void); virtual bool haveWeWon() { return ( discardPiles[0]->kingOnTop() && discardPiles[1]->kingOnTop() && discardPiles[2]->kingOnTop() && discardPiles[3]->kingOnTop() );; } virtual void mousePress(QPoint p); virtual void mouseRelease(QPoint p) { Q_UNUSED(p); } // virtual void mouseMove(QPoint p); virtual bool mousePressCard(Card *card, QPoint p); virtual void mouseReleaseCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); } // virtual void mouseMoveCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); } bool canTurnOverDeck(void) { return (numberOfTimesThroughDeck != 3); } void throughDeck(void) { numberOfTimesThroughDeck++; if (numberOfTimesThroughDeck == 3) circleCross->setCross(); } bool snapOn; virtual void writeConfig( Config& cfg ); virtual void readConfig( Config& cfg ); private: CanvasCircleOrCross *circleCross; CanvasRoundRect *rectangle; PatienceWorkingPile *workingPiles[7]; PatienceDiscardPile *discardPiles[4]; PatienceFaceDownDeck *faceDownDealingPile; PatienceFaceUpDeck *faceUpDealingPile; int numberOfTimesThroughDeck; }; #endif 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,177 +1,193 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "wordgame.h" #include <qpe/applnk.h> #include <qpe/global.h> #include <qpe/filemanager.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qapplication.h> #include <qmessagebox.h> #include <qcombobox.h> #include <qdatetime.h> #include <qfileinfo.h> #include <qfile.h> #include <qdir.h> #include <qiconset.h> #include <qlabel.h> #include <qlineedit.h> #include <qpushbutton.h> #include <qtextstream.h> #include <qtimer.h> #include <qpe/qpetoolbar.h> #include <qtoolbutton.h> #include <qvbox.h> #include <qwidgetstack.h> #include <qpainter.h> #include <qlayout.h> #include <qregexp.h> #include <stdlib.h> #include <unistd.h> #include <pwd.h> #include <sys/types.h> enum RuleEffects { Multiplier=15, MultiplyAll=64, Start=128 }; +static int tile_smallw = 16; +static int tile_smallh = 16; +static int tile_bigw = 22; +static int tile_bigh = 22; +static int tile_stweak = -2; +static int tile_btweak = -1; + static const int rack_tiles=7; const char* sampleWGR= "wordgame_shapes\n" "15 15\n" "400001040100004\n" "030000000000030\n" "002002000200200\n" "000300020003000\n" "000020000020000\n" "102001000100201\n" "000000202000000\n" "400200050002004\n" "000000202000000\n" "102001000100201\n" "000020000020000\n" "000300020003000\n" "002002000200200\n" "030000000000030\n" "400001040100004\n" "1 2 3 66 67 194 100 0\n" "1 j 8\n" "1 q 7\n" "1 x 6\n" "1 z 6\n" "1 w 4\n" "1 k 4\n" "1 v 3\n" "1 f 3\n" "2 y 3\n" "2 h 2\n" "2 b 2\n" "2 m 2\n" "3 p 2\n" "3 g 2\n" "3 u 2\n" "4 d 2\n" "4 c 2\n" "5 l 1\n" "5 o 1\n" "7 t 1\n" "7 n 1\n" "7 a 1\n" "7 r 1\n" "8 s 1\n" "8 i 1\n" "11 e 1\n" "0\n"; WordGame::WordGame( QWidget* parent, const char* name, WFlags fl ) : QMainWindow(parent, name, fl) { + if ( qApp->desktop()->width() < 240 ) { + tile_smallw = 10; + tile_smallh = 10; + tile_bigw = 16; + tile_bigh = 16; + tile_stweak = 0; + tile_btweak = 0; + } + setIcon( Resource::loadPixmap( "wordgame" ) ); setCaption( tr("Word Game") ); setToolBarsMovable( FALSE ); vbox = new QVBox(this); setCentralWidget(vbox); toolbar = new QPEToolBar(this); addToolBar(toolbar, Bottom); reset = new QToolButton(Resource::loadPixmap("back"), tr("Back"), "", this, SLOT(resetTurn()), toolbar); done = new QToolButton(Resource::loadPixmap("done"), tr("Done"), "", this, SLOT(endTurn()), toolbar); scoreinfo = new ScoreInfo(toolbar); scoreinfo->setFont(QFont("Helvetica",10)); new QToolButton(Resource::loadPixmap("finish"), tr("Close"), "", this, SLOT(endGame()), toolbar); toolbar->setStretchableWidget(scoreinfo); cpu = 0; board = 0; bag = 0; racks = 0; aiheart = new QTimer(this); connect(aiheart, SIGNAL(timeout()), this, SLOT(think())); readConfig(); } WordGame::~WordGame() { writeConfig(); } void WordGame::writeConfig() { Config cfg("WordGame"); cfg.setGroup("Game"); cfg.writeEntry("NameList",namelist,';'); cfg.writeEntry("CurrentPlayer",gameover ? 0 : player+1); if ( !gameover ) { cfg.writeEntry("Rules",rules); bag->writeConfig(cfg); board->writeConfig(cfg); scoreinfo->writeConfig(cfg); } for (int p=0; p<nplayers; p++) { cfg.setGroup("Player"+QString::number(p+1)); if ( gameover ) cfg.clearGroup(); else rack(p)->writeConfig(cfg); } } void WordGame::readConfig() { Config cfg("WordGame"); cfg.setGroup("Game"); int currentplayer = cfg.readNumEntry("CurrentPlayer",0); QStringList pnames = cfg.readListEntry("NameList",';'); if ( currentplayer ) { gameover = FALSE; rules = cfg.readEntry("Rules"); if ( rules.find("x-wordgamerules") >= 0 ) { // rules files moved rules = "Sample.rules"; } if ( loadRules(rules) ) { @@ -186,178 +202,184 @@ void WordGame::readConfig() player=currentplayer-1; readyRack(player); return; } } // fall-back openGameSelector(pnames); } void WordGame::openGameSelector(const QStringList& initnames) { toolbar->hide(); gameover = FALSE; delete board; board = 0; delete racks; racks = 0; delete cpu; cpu = 0; newgame = new NewGame(vbox); //Rules rules(this); //connect(game.editrules, SIGNAL(clicked()), &rules, SLOT(editRules())); //connect(&rules, SIGNAL(rulesChanged()), &game, SLOT(updateRuleSets())); struct passwd* n = getpwuid(getuid()); QString playername = n ? n->pw_name : ""; if ( playername.isEmpty() ) { playername = "Player"; } newgame->player0->changeItem(playername,0); newgame->player1->setCurrentItem(1); newgame->updateRuleSets(); newgame->show(); connect(newgame->buttonOk, SIGNAL(clicked()), this, SLOT(startGame())); } void WordGame::startGame() { rules = newgame->ruleslist[newgame->rules->currentItem()]; if ( loadRules(rules) ) { QStringList names; names.append(newgame->player0->currentText()); names.append(newgame->player1->currentText()); names.append(newgame->player2->currentText()); names.append(newgame->player3->currentText()); names.append(newgame->player4->currentText()); names.append(newgame->player5->currentText()); delete newgame; startGame(names); } else { // error... delete newgame; close(); } } void WordGame::startGame(const QStringList& playerlist) { toolbar->show(); racks = new QWidgetStack(vbox); + racks->setFixedHeight(TileItem::bigHeight()+2); namelist.clear(); nplayers=0; for (QStringList::ConstIterator it=playerlist.begin(); it!=playerlist.end(); ++it) addPlayer(*it); scoreinfo->init(namelist); if ( nplayers ) { player=0; readyRack(player); } board->show(); racks->show(); } bool WordGame::loadRules(const QString &name) { QString filename = Global::applicationFileName( "wordgame", name ); QFile file( filename ); if ( !file.open( IO_ReadOnly ) ) return FALSE; QTextStream ts( &file ); QString title = name; title.truncate( title.length() - 6 ); setCaption( title ); QString shapepixmap; ts >> shapepixmap; int htiles,vtiles; ts >> htiles >> vtiles; if ( htiles < 3 || vtiles < 3 ) return FALSE; - QPixmap bgshapes = Resource::loadPixmap(shapepixmap); QString rule_shapes; for (int i=0; i<vtiles; i++) { QString line; ts >> line; rule_shapes += line; } static int rule_effects[12]; int re=0,e; ts >> e; while ( e && re < 10 ) { rule_effects[re] = e; if ( re++ < 10 ) ts >> e; } + + QImage shim = Resource::loadImage(shapepixmap); + shim = shim.smoothScale((re-1)*TileItem::smallWidth(),TileItem::smallHeight()); + QPixmap bgshapes; + bgshapes.convertFromImage(shim); + rule_effects[re++] = 100; // default bonus board = new Board(bgshapes, htiles, vtiles, vbox); board->setRules(rule_shapes, rule_effects); connect(board, SIGNAL(temporaryScore(int)), scoreinfo, SLOT(showTemporaryScore(int))); bag = new Bag; int count; ts >> count; while ( count ) { QString text; int value; ts >> text >> value; if ( text == "_" ) text = ""; Tile t(text, value); for (int n=count; n--; ) bag->add(t); ts >> count; } return TRUE; } NewGame::NewGame(QWidget* parent) : NewGameBase(parent) { } void NewGame::updateRuleSets() { rules->clear(); QString rulesDir = Global::applicationFileName( "wordgame", "" ); QDir dir( rulesDir, "*.rules" ); ruleslist = dir.entryList(); if ( ruleslist.isEmpty() ) { // Provide a sample QFile file( rulesDir + "Sample.rules" ); if ( file.open( IO_WriteOnly ) ) { file.writeBlock( sampleWGR, strlen(sampleWGR) ); file.close(); updateRuleSets(); } return; } int newest=0; int newest_age=INT_MAX; QDateTime now = QDateTime::currentDateTime(); QStringList::Iterator it; for ( it = ruleslist.begin(); it != ruleslist.end(); ++it ) { QFileInfo fi((*it)); int age = fi.lastModified().secsTo(now); QString name = *it; name.truncate( name.length()-6 ); // remove extension rules->insertItem( name ); if ( age < newest_age ) { newest_age = age; newest = rules->count()-1; } } @@ -620,211 +642,227 @@ void ComputerPlayer::findBest(QPoint at, const QPoint& d, const QDawg::Node* nod } else { if ( nletter[l.unicode()] || nletter[0] ) { int rc = rack->count(); ulong msk = 1; for ( int x=0; x<rc; x++ ) { if ( !(used&msk) ) { const Tile* t = rack->tileRef(x); if ( t->isBlank() || t->text() == l ) { // #### multi-char value()s bool nextok = board->contains(at+d); tiles[n++] = t; if ( t->isBlank() ) blankvalues[blused++] = Tile(l,0); if ( node->isWord() && (!nextok || !board->tile(at+d)) ) noteChoice(tiles,n,d,blankvalues,blused); used |= msk; // mark nletter[t->text()[0].unicode()]--; if ( nextok ) findBest(at+d, d, node->jump(), used, nletter, tiles, n, blankvalues, blused); n--; nletter[t->text()[0].unicode()]++; if ( t->isBlank() ) { // keep looking blused--; used &= ~msk; // unmark } else { break; } } } msk <<= 1; } } // #### text()[1]... } findBest(at, d, node->next(), used, nletter, tiles, n, blankvalues, blused); } void ComputerPlayer::noteChoice(const Tile** tiles, int n, const QPoint& d, const Tile* blankvalues, int blused) { int s = board->score(current, tiles, n, blankvalues, d, TRUE, 0); /* if (s>0 || current==QPoint(5,1)){ QString st; for ( int i=0; i<n; i++ ) st += tiles[i]->text(); qDebug("%d,%d: %s (%d) for %d",current.x(),current.y(),st.latin1(),n,s); } */ if ( s > best_score ) { int i; for ( i=0; i<n; i++ ) best[i] = tiles[i]; for ( i=0; i<blused; i++ ) best_blankvalues[i] = blankvalues[i]; best_n = n; best_blused = blused; best_score = s; best_dir = d; best_start = current; } } int TileItem::smallWidth() { - return 16; + return tile_smallw; } int TileItem::smallHeight() { - return 16; + return tile_smallh; } int TileItem::bigWidth() { - return 22; + return tile_bigw; } int TileItem::bigHeight() { - return 22; + return tile_bigh; } void TileItem::setState( State state ) { hide(); s = state; show(); // ### use update() in Qt 3.0 } void TileItem::setTile(const Tile& tile) { hide(); t = tile; show(); // ### use update() in Qt 3.0 } void TileItem::setBig(bool b) { big = b; } void TileItem::drawShape(QPainter& p) { - static QFont value_font("heletica",8); - static QFont big_font("smoothtimes",17); - static QFont small_font("smoothtimes",10); + static QFont *value_font=0; + static QFont *big_font=0; + static QFont *small_font=0; + if ( !value_font ) { + value_font = new QFont("helvetica",8); + if ( TileItem::bigWidth() < 20 ) { + big_font = new QFont("helvetica",12); + small_font = new QFont("helvetica",8); + } else { + big_font = new QFont("smoothtimes",17); + small_font = new QFont("smoothtimes",10); + } + } QRect area(x(),y(),width(),height()); p.setBrush(s == Floating ? yellow/*lightGray*/ : white); p.drawRect(area); if ( big ) { - p.setFont(value_font); + p.setFont(*value_font); QString n = QString::number(t.value()); int w = p.fontMetrics().width('1'); int h = p.fontMetrics().height(); w *= n.length(); - QRect valuearea(x()+width()-w-2,y()+height()-h+1,w,h); + QRect valuearea(x()+width()-w-1,y()+height()-h,w,h); p.drawText(valuearea,AlignCenter,n); - p.setFont(big_font); - area = QRect(x(),y(),width()-2,height()-1); + p.setFont(*big_font); + area = QRect(x(),y()+tile_btweak,width()-4,height()-1); } else { - p.setFont(small_font); - area = QRect(x(),y()+2,width(),height()-2); + p.setFont(*small_font); + area = QRect(x()+1+tile_stweak,y()+1,width(),height()-3); } if ( t.value() == 0 ) p.setPen(darkGray); p.drawText(area,AlignCenter,t.text().upper()); } Board::Board(QPixmap bgshapes, int w, int h, QWidget* parent) : QCanvasView(new QCanvas(bgshapes,w,h, TileItem::smallWidth(), TileItem::smallHeight()), parent) { + setFixedSize(w*TileItem::smallWidth(),h*TileItem::smallHeight()); grid = new TileItem*[w*h]; memset(grid,0,w*h*sizeof(TileItem*)); setFrameStyle(0); setHScrollBarMode(AlwaysOff); setVScrollBarMode(AlwaysOff); current_rack = 0; shown_n = 0; } Board::~Board() { delete canvas(); } +QSize Board::sizeHint() const +{ + return QSize(canvas()->width(),canvas()->height()); +} + void Board::writeConfig(Config& cfg) { QStringList t; int n=canvas()->tilesHorizontally()*canvas()->tilesVertically(); for (int i=0; i<n; i++) t.append( grid[i] ? grid[i]->tile().key() : QString(".") ); cfg.writeEntry("Board",t,';'); } void Board::readConfig(Config& cfg) { clear(); QStringList t = cfg.readListEntry("Board",';'); int i=0; int h=canvas()->tilesHorizontally(); for (QStringList::ConstIterator it=t.begin(); it!=t.end(); ++it) { if ( *it != "." ) { QPoint p(i%h,i/h); setTile(p,Tile(*it)); } i++; } canvas()->update(); } void Board::clear() { int n=canvas()->tilesHorizontally()*canvas()->tilesVertically(); for (int i=0; i<n; i++) { delete grid[i]; grid[i]=0; } } void Board::setCurrentRack(Rack* r) { turn_score = -1; current_rack = r; } void Board::resetRack() { unshowTurn(); canvas()->update(); } void Board::contentsMousePressEvent(QMouseEvent* e) { dragstart = e->pos(); } void Board::contentsMouseMoveEvent(QMouseEvent* e) { if ( current_rack && !current_rack->computerized() ) { QPoint d = e->pos() - dragstart; if ( d.x() <= 0 && d.y() <= 0 ) { // None resetRack(); } else { int n; QPoint start=boardPos(dragstart); QPoint end=boardPos(e->pos()); QPoint diff=end-start; @@ -1120,128 +1158,133 @@ QPoint Board::boardPos(const QPoint& p) const } void Board::contentsMouseReleaseEvent(QMouseEvent*) { if ( current_rack ) { } } void Board::setRules(const QString& shapes, const int* effects) { rule_shape=shapes; rule_effect=effects; int i=0; int maxre=0; for (int y=0; y<yTiles(); y++) { for (int x=0; x<xTiles(); x++) { int re = shapes[i++]-'0'; if ( re > maxre ) maxre = re; canvas()->setTile(x,y,re); } } rack_tiles_bonus=effects[maxre+1]; } void Board::unsetTile(const QPoint& p) { delete item(p); grid[idx(p)] = 0; } void Board::setTile(const QPoint& p, const Tile& t) { TileItem* it=item(p); if ( !it ) { it = grid[idx(p)] = new TileItem(t,FALSE,canvas()); it->move(p.x()*canvas()->tileWidth(), p.y()*canvas()->tileHeight()); it->show(); } else { it->setTile(t); } } Rack::Rack(int ntiles, QWidget* parent) : QCanvasView( new QCanvas(ntiles*TileItem::bigWidth(),TileItem::bigHeight()), parent), item(ntiles) { setLineWidth(1); setFixedHeight(sizeHint().height()); n = 0; for (int i=0; i<ntiles; i++) item[i]=0; setHScrollBarMode(AlwaysOff); setVScrollBarMode(AlwaysOff); canvas()->setBackgroundColor(gray); dragging = 0; } Rack::~Rack() { clear(); delete canvas(); } +QSize Rack::sizeHint() const +{ + return QSize(-1,TileItem::bigHeight()+2); +} + void Rack::clear() { for (int i=0; i<n; i++) delete item[i]; n=0; } void Rack::writeConfig(Config& cfg) { QStringList l; for (int i=0; i<n; i++) l.append(tile(i).key()); cfg.writeEntry("Tiles",l,';'); } void Rack::readConfig(Config& cfg) { clear(); int x=0; QStringList l = cfg.readListEntry("Tiles",';'); for (QStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) { TileItem *i = new TileItem(Tile(*it),TRUE,canvas()); i->move(x++,0); i->show(); item[n++] = i; } layoutTiles(); } static int cmp_tileitem(const void *a, const void *b) { const TileItem* ia = *(TileItem**)a; const TileItem* ib = *(TileItem**)b; return int(ia->x() - ib->x()); } void Rack::layoutTiles() { int w = TileItem::bigWidth()+2; if ( dragging ) dragging->moveBy(dragging_adj,0); qsort(item.data(), n, sizeof(TileItem*), cmp_tileitem); if ( dragging ) dragging->moveBy(-dragging_adj,0); for (int i=0; i<n ;i++) if ( item[i] == dragging ) { item[i]->setZ(1); } else { item[i]->move(i*w, 0); item[i]->setZ(0); } canvas()->update(); } void Rack::setBlanks(const Tile* bv) { for (int j=0; j<n; j++) { Tile tt = item[j]->tile(); if ( tt.isBlank() ) { tt.setText(bv->text()); item[j]->setTile(tt); bv++; } } 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 @@ -87,290 +87,294 @@ public: void writeConfig(Config&); void add(const Tile&); bool isEmpty() const { return tiles.isEmpty(); } Tile takeRandom(); private: QList<Tile> tiles; }; class TileItem : public QCanvasRectangle { public: TileItem(const Tile& tile, bool b, QCanvas* c) : QCanvasRectangle(0,0, b?bigWidth():smallWidth(), b?bigHeight():smallHeight(),c), t(tile), big(b), s(Firm) { } static int smallWidth(); static int smallHeight(); static int bigWidth(); static int bigHeight(); enum State { Firm, Floating }; void setState( State state ); State state() const { return s; } const Tile& tile() const { return t; } void setTile(const Tile&); void setBig(bool); protected: void drawShape(QPainter&); private: Tile t; bool big; State s; }; class Rack : public QCanvasView { public: Rack(int ntiles, QWidget* parent); ~Rack(); void readConfig(Config&); void writeConfig(Config&); bool isFull() const { return count()==max(); } int max() const { return item.count(); } int count() const { return n; } void addTile(const Tile& t); Tile tile(int i) const { return item[i]->tile(); } const Tile* tileRef(int i) const { return &item[i]->tile(); } void remove(int i); void remove(Tile); bool arrangeTiles(const Tile** s, int sn); void setBlanks(const Tile*); void setPlayerName(const QString& name) { nm = name; } QString playerName() const { return nm; } void setComputerization(int level) { cpu=level; } bool computerized() const { return cpu>0; } + QSize sizeHint() const; + protected: void resizeEvent(QResizeEvent*e); void contentsMousePressEvent(QMouseEvent*); void contentsMouseMoveEvent(QMouseEvent*); void contentsMouseReleaseEvent(QMouseEvent*); private: void clear(); void layoutTiles(); int n; QArray<TileItem*> item; int dragging_adj; QPoint dragstart; QCanvasItem* dragging; QString nm; int cpu; }; class Board : public QCanvasView { Q_OBJECT public: Board(QPixmap bgshapes, int w, int h, QWidget* parent); ~Board(); void readConfig(Config&); void writeConfig(Config&); int xTiles() const { return canvas()->tilesHorizontally(); } int yTiles() const { return canvas()->tilesVertically(); } bool contains(const QPoint& p) const { return p.x() >= 0 && p.y() >= 0 && p.x() < canvas()->tilesHorizontally() && p.y() < canvas()->tilesVertically(); } const Tile* tile(const QPoint& p) const { TileItem* it=item(p); return it ? &it->tile() : 0; } void setRules(const QString& shapes, const int* effects); void clear(); void unsetTile(const QPoint& p); void setTile(const QPoint& p, const Tile& t); void setTileState(const QPoint& p, TileItem::State s) { TileItem* it=item(p); if (it) it->setState(s); } void setCurrentRack(Rack*); void resetRack(); void finalizeTurn(); void showTurn(); void scoreTurn(const QPoint& at, int n, const QPoint& d); bool checkTurn(); int score(QPoint at, const Tile** tiles, int n, const Tile* blankvalue, const QPoint& d, bool ignoredict, QStringList* words) const; int bonussedValue(const QPoint& at, int base, int& all_mult) const; bool isStart(const QPoint& at) const; int turnScore() const { return turn_score; } + QSize sizeHint() const; + signals: void temporaryScore(int); protected: void contentsMousePressEvent(QMouseEvent*); void contentsMouseMoveEvent(QMouseEvent*); void contentsMouseReleaseEvent(QMouseEvent*); private: int idx(const QPoint& p) const { return p.x()+p.y()*canvas()->tilesHorizontally(); } TileItem*& item(const QPoint& p) const { return grid[idx(p)]; } TileItem **grid; QString rule_shape; const int* rule_effect; int rack_tiles_bonus; Rack* current_rack; QPoint boardPos(const QPoint&) const; QPoint dragstart; QPoint shown_at; int shown_n; QPoint shown_step; void unshowTurn(); int turn_score; }; class ComputerPlayer { Board* board; Rack* rack; bool across; int dict; QPoint current; const Tile** best; int best_n; Tile* best_blankvalues; int best_blused; int best_score; QPoint best_dir; QPoint best_start; public: ComputerPlayer(Board* b, Rack* r); ~ComputerPlayer(); bool step(); private: void findBest(QPoint at, const QPoint& d, const QDawg::Node* node, ulong used, uchar *nletter, const Tile** tiles, int n, Tile* blankvalues, int blused); void noteChoice(const Tile** tiles, int n, const QPoint& d, const Tile* blankvalues, int blused); }; class ScoreInfo : public QLabel { Q_OBJECT public: ScoreInfo( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~ScoreInfo(); void init(const QStringList&); void addScore(int player, int change); int playerScore(int player) const { return score[player]; } void setShowWinner(bool); void setBoldOne(int); void readConfig(Config&); void writeConfig(Config&); protected: QSize sizeHint() const; public slots: void showTemporaryScore(int amount); private slots: void showScores(); private: QStringList names; int *score; QTimer* msgtimer; bool showwinner; int boldone; }; class NewGame; class WordGame : public QMainWindow { Q_OBJECT public: WordGame( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~WordGame(); private slots: void endTurn(); void resetTurn(); void passTurn(); void think(); void endGame(); void startGame(); private: void writeConfig(); void readConfig(); void startGame(const QStringList& pnames); bool mayEndGame(); void openGameSelector(const QStringList& initnames); bool loadRules(const QString& filename); void addPlayer(const QString& name); void addPlayer(const QString& name, int cpu); void nextPlayer(); bool refillRack(int i); void readyRack(int i); Rack* rack(int i) const; QWidgetStack *racks; QToolBar* toolbar; - QVBox *vbox; + QWidget *vbox; Board *board; Bag *bag; ScoreInfo *scoreinfo; QToolButton *done; QToolButton *reset; QTimer* aiheart; ComputerPlayer *cpu; int player; int nplayers; QStringList namelist; bool gameover; QString rules; NewGame* newgame; }; class NewGame : public NewGameBase { Q_OBJECT public: NewGame(QWidget* parent); QStringList ruleslist; public slots: void updateRuleSets(); }; class Rules : public RulesBase { Q_OBJECT public: Rules(QWidget* parent); signals: void rulesChanged(); public slots: void editRules(); private: void deleteRuleSet(); }; #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 @@ -/********************************************************************** -** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. -** -** This file is part of the Qtopia Environment. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include "settingsdialog.h" -#include <qslider.h> -#include <qlabel.h> -#include <qcheckbox.h> - -SettingsDialog::SettingsDialog( QWidget *parent, const char *name, bool modal, WFlags f ) - : SettingsDialogBase( parent, name, modal, f ) -{ - connect( delaySlider, SIGNAL(valueChanged(int)), this, SLOT(delayChanged(int)) ); -} - -void SettingsDialog::setDelay( int d ) -{ - delaySlider->setValue( d ); - delayChanged( d ); -} - -int SettingsDialog::delay() const -{ - return delaySlider->value(); -} - -void SettingsDialog::setRepeat( bool r ) -{ - repeatCheck->setChecked( r ); -} - -bool SettingsDialog::repeat() const -{ - return repeatCheck->isChecked(); -} - -void SettingsDialog::delayChanged( int d ) -{ - delayText->setText( QString::number( d ) + " s" ); -} - 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 @@ -/********************************************************************** -** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. -** -** This file is part of the Qtopia Environment. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef SETTINGSDIALOG_H -#define SETTINGSDIALOG_H - -#include "settingsdialogbase.h" - -class SettingsDialog : public SettingsDialogBase -{ - Q_OBJECT -public: - SettingsDialog( QWidget * parent=0, const char * name=0, bool modal=FALSE, WFlags f=0 ); - - void setDelay( int d ); - int delay() const; - void setRepeat( bool r ); - bool repeat() const; - -private slots: - void delayChanged( int ); -}; - - -#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 @@ -<!DOCTYPE UI><UI> -<class>SettingsDialogBase</class> -<widget> - <class>QDialog</class> - <property stdset="1"> - <name>name</name> - <cstring>SettingsDialogBase</cstring> - </property> - <property stdset="1"> - <name>geometry</name> - <rect> - <x>0</x> - <y>0</y> - <width>227</width> - <height>258</height> - </rect> - </property> - <property stdset="1"> - <name>caption</name> - <string>Preferences</string> - </property> - <vbox> - <property stdset="1"> - <name>margin</name> - <number>11</number> - </property> - <property stdset="1"> - <name>spacing</name> - <number>6</number> - </property> - <widget> - <class>QGroupBox</class> - <property stdset="1"> - <name>name</name> - <cstring>GroupBox1</cstring> - </property> - <property stdset="1"> - <name>title</name> - <string>Slide Show</string> - </property> - <vbox> - <property stdset="1"> - <name>margin</name> - <number>11</number> - </property> - <property stdset="1"> - <name>spacing</name> - <number>6</number> - </property> - <widget> - <class>QCheckBox</class> - <property stdset="1"> - <name>name</name> - <cstring>repeatCheck</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Repeat</string> - </property> - </widget> - <widget> - <class>QLayoutWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>Layout1</cstring> - </property> - <hbox> - <property stdset="1"> - <name>margin</name> - <number>0</number> - </property> - <property stdset="1"> - <name>spacing</name> - <number>6</number> - </property> - <widget> - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel1</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Delay</string> - </property> - </widget> - <widget> - <class>QSlider</class> - <property stdset="1"> - <name>name</name> - <cstring>delaySlider</cstring> - </property> - <property stdset="1"> - <name>minValue</name> - <number>5</number> - </property> - <property stdset="1"> - <name>maxValue</name> - <number>60</number> - </property> - <property stdset="1"> - <name>lineStep</name> - <number>5</number> - </property> - <property stdset="1"> - <name>orientation</name> - <enum>Horizontal</enum> - </property> - <property stdset="1"> - <name>tickmarks</name> - <enum>Right</enum> - </property> - <property stdset="1"> - <name>tickInterval</name> - <number>10</number> - </property> - </widget> - <widget> - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>delayText</cstring> - </property> - <property stdset="1"> - <name>minimumSize</name> - <size> - <width>25</width> - <height>0</height> - </size> - </property> - <property stdset="1"> - <name>text</name> - <string>s</string> - </property> - <property stdset="1"> - <name>alignment</name> - <set>AlignVCenter|AlignRight</set> - </property> - <property> - <name>hAlign</name> - </property> - </widget> - </hbox> - </widget> - </vbox> - </widget> - </vbox> -</widget> -</UI> diff --git a/pics/cards/circle.png b/pics/cards/circle.png Binary files differdeleted file mode 100644 index 3b006de..0000000 --- a/pics/cards/circle.png +++ b/dev/null diff --git a/pics/cards/cross.png b/pics/cards/cross.png Binary files differdeleted file mode 100644 index cac7576..0000000 --- a/pics/cards/cross.png +++ b/dev/null diff --git a/pics/inline/today.png b/pics/inline/today.png Binary files differdeleted file mode 100644 index ac244c6..0000000 --- a/pics/inline/today.png +++ b/dev/null diff --git a/pics/slideshow.png b/pics/slideshow.png Binary files differdeleted file mode 100644 index 9a7f8d5..0000000 --- a/pics/slideshow.png +++ b/dev/null |