author | sandman <sandman> | 2002-11-26 23:34:04 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-11-26 23:34:04 (UTC) |
commit | e52158d2f9e1fdc9766d991dc672729648d5a020 (patch) (side-by-side diff) | |
tree | 2e87e8d9a24cdb336b2d7ca654a5ffa2f80c5f8c | |
parent | ac4f32931212847803534a72eb5e951bd01e6ff5 (diff) | |
download | opie-e52158d2f9e1fdc9766d991dc672729648d5a020.zip opie-e52158d2f9e1fdc9766d991dc672729648d5a020.tar.gz opie-e52158d2f9e1fdc9766d991dc672729648d5a020.tar.bz2 |
Sharp ROM compatibilty upgrade:
All these functions are needed to get qtmail (from the Sharp ROM) running
on Opie - I have even tested qtmail on an iPAQ and it seems to work ..
-rw-r--r-- | library/config.cpp | 12 | ||||
-rw-r--r-- | library/config.h | 3 | ||||
-rw-r--r-- | library/datebookmonth.cpp | 12 | ||||
-rw-r--r-- | library/datebookmonth.h | 15 | ||||
-rw-r--r-- | library/qpemenubar.cpp | 9 | ||||
-rw-r--r-- | library/qpemenubar.h | 7 |
6 files changed, 58 insertions, 0 deletions
diff --git a/library/config.cpp b/library/config.cpp index 1121cd4..b47c620 100644 --- a/library/config.cpp +++ b/library/config.cpp @@ -9,192 +9,204 @@ ** 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(); QStringList l = Global::languageList(); lang = l[0]; glang = l[1]; } + +// Sharp ROM compatibility +Config::Config ( const QString &name, bool what ) + : filename( configFilename(name,what ? User : File) ) +{ + git = groups.end(); + read(); + 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 ) { ( *git ).insert( key, value ); changed = TRUE; } } /* Note that the degree of protection offered by the encryption here is only sufficient to avoid the most casual observation of the configuration files. People with access to the files can write down the contents and decrypt it using this source code. Conceivably, and at some burden to the user, this encryption could be improved. */ static QString encipher(const QString& plain) { // mainly, we make it long QString cipher; int mix=28730492; for (int i=0; i<(int)plain.length(); i++) { int u = plain[i].unicode(); int c = u ^ mix; QString x = QString::number(c,36); cipher.append(QChar('a'+x.length())); cipher.append(x); mix *= u; } return cipher; } static QString decipher(const QString& cipher) { QString plain; int mix=28730492; diff --git a/library/config.h b/library/config.h index 1dc32fa..0bab7ca 100644 --- a/library/config.h +++ b/library/config.h @@ -1,102 +1,105 @@ /********************************************************************** ** 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 CONFIG_H #define CONFIG_H // ##### could use QSettings with Qt 3.0 #include <qmap.h> #include <qstringlist.h> class ConfigPrivate; class Config { public: typedef QMap< QString, QString > ConfigGroup; enum Domain { File, User }; Config( const QString &name, Domain domain=User ); ~Config(); bool operator == ( const Config & other ) const { return (filename == other.filename); } bool operator != ( const Config & other ) const { return (filename != other.filename); } bool isValid() const; bool hasKey( const QString &key ) const; void setGroup( const QString &gname ); void writeEntry( const QString &key, const char* value ); void writeEntry( const QString &key, const QString &value ); void writeEntryCrypt( const QString &key, const QString &value ); void writeEntry( const QString &key, int num ); #ifdef Q_HAS_BOOL_TYPE void writeEntry( const QString &key, bool b ); #endif void writeEntry( const QString &key, const QStringList &lst, const QChar &sep ); void removeEntry( const QString &key ); QString readEntry( const QString &key, const QString &deflt = QString::null ) const; QString readEntryCrypt( const QString &key, const QString &deflt = QString::null ) const; QString readEntryDirect( const QString &key, const QString &deflt = QString::null ) const; int readNumEntry( const QString &key, int deflt = -1 ) const; bool readBoolEntry( const QString &key, bool deflt = FALSE ) const; QStringList readListEntry( const QString &key, const QChar &sep ) const; // For compatibility, non-const versions. QString readEntry( const QString &key, const QString &deflt ); QString readEntryCrypt( const QString &key, const QString &deflt ); QString readEntryDirect( const QString &key, const QString &deflt ); int readNumEntry( const QString &key, int deflt ); bool readBoolEntry( const QString &key, bool deflt ); QStringList readListEntry( const QString &key, const QChar &sep ); void clearGroup(); void write( const QString &fn = QString::null ); protected: void read(); bool parse( const QString &line ); QMap< QString, ConfigGroup > groups; QMap< QString, ConfigGroup >::Iterator git; QString filename; QString lang; QString glang; bool changed; ConfigPrivate *d; static QString configFilename(const QString& name, Domain); + +private: // Sharp ROM compatibility + Config( const QString &name, bool what ); }; inline QString Config::readEntry( const QString &key, const QString &deflt ) const { return ((Config*)this)->readEntry(key,deflt); } inline QString Config::readEntryCrypt( const QString &key, const QString &deflt ) const { return ((Config*)this)->readEntryCrypt(key,deflt); } inline QString Config::readEntryDirect( const QString &key, const QString &deflt ) const { return ((Config*)this)->readEntryDirect(key,deflt); } inline int Config::readNumEntry( const QString &key, int deflt ) const { return ((Config*)this)->readNumEntry(key,deflt); } inline bool Config::readBoolEntry( const QString &key, bool deflt ) const { return ((Config*)this)->readBoolEntry(key,deflt); } inline QStringList Config::readListEntry( const QString &key, const QChar &sep ) const { return ((Config*)this)->readListEntry(key,sep); } #endif diff --git a/library/datebookmonth.cpp b/library/datebookmonth.cpp index 4a9dcbd..e8be313 100644 --- a/library/datebookmonth.cpp +++ b/library/datebookmonth.cpp @@ -655,96 +655,108 @@ void DayItemMonth::paint( QPainter *p, const QColorGroup &cg, p->restore(); } void DayItemMonth::setType( Calendar::Day::Type t ) { switch ( t ) { case Calendar::Day::PrevMonth: case Calendar::Day::NextMonth: back = QBrush( QColor( 224, 224, 224 ) ); forg = black; break; case Calendar::Day::ThisMonth: back = QBrush( white ); forg = black; break; } typ = t; } DateButton::DateButton( bool longDate, QWidget *parent, const char * name ) :QPushButton( parent, name ) { longFormat = longDate; df = DateFormat('/', DateFormat::MonthDayYear, DateFormat::MonthDayYear); setDate( QDate::currentDate() ); connect(this,SIGNAL(pressed()),this,SLOT(pickDate())); } void DateButton::pickDate() { static QPopupMenu *m1 = 0; static DateBookMonth *picker = 0; if ( !m1 ) { m1 = new QPopupMenu( this ); picker = new DateBookMonth( m1, 0, TRUE ); m1->insertItem( picker ); connect( picker, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( setDate( int, int, int ) ) ); connect( picker, SIGNAL( dateClicked( int, int, int ) ), this, SIGNAL( dateSelected( int, int, int ) ) ); connect( m1, SIGNAL( aboutToHide() ), this, SLOT( gotHide() ) ); } picker->slotWeekChange( weekStartsMonday ); picker->setDate( currDate.year(), currDate.month(), currDate.day() ); m1->popup(mapToGlobal(QPoint(0,height()))); picker->setFocus(); } void DateButton::gotHide() { // we have to redo the button... setDown( false ); } // void dateSelected( int year, int month, int day ); void DateButton::setWeekStartsMonday( int b ) { weekStartsMonday = b; } void DateButton::setDate( int y, int m, int d ) { setDate( QDate( y,m,d) ); } void DateButton::setDate( QDate d ) { currDate = d; setText( longFormat ? TimeString::longDateString( d, df ) : TimeString::shortDate( d, df ) ); } void DateButton::setDateFormat( DateFormat f ) { df = f; setDate( currDate ); } bool DateButton::customWhatsThis() const { return TRUE; } + +// this class is only here for Sharp ROM compatibility +// I have reverse engineered this class and it seems to +// work (only qtmail seems to use it) - sandman +// DO NOT USE IT IN NEW CODE !! + +DateBookMonthPopup::DateBookMonthPopup ( QWidget *w ) + : QPopupMenu ( w ) +{ + m_dbm = new DateBookMonth( this, 0, TRUE ); + insertItem( m_dbm ); +} diff --git a/library/datebookmonth.h b/library/datebookmonth.h index 3c57c19..cb436a8 100644 --- a/library/datebookmonth.h +++ b/library/datebookmonth.h @@ -1,213 +1,228 @@ /********************************************************************** ** 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 DATEBOOKMONTH #define DATEBOOKMONTH #include <qtopia/private/event.h> #include <qvbox.h> #include <qhbox.h> #include <qdatetime.h> #include <qvaluelist.h> #include <qtable.h> #include <qpushbutton.h> +#include <qpopupmenu.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 ); void getEvents(); void changeDaySelection( int row, int col ); int year, month, day; int selYear, selMonth, selDay; QValueList<Event> monthsEvents; // not used anymore... DateBookDB *db; DateBookMonthTablePrivate *d; }; class DateBookMonthPrivate; class DateBookMonth : public QVBox { Q_OBJECT public: DateBookMonth( QWidget *parent = 0, const char *name = 0, bool ac = FALSE, DateBookDB *data = 0 ); ~DateBookMonth(); QDate selectedDate() const; signals: void dateClicked( int year, int month, int day ); public slots: void setDate( int y, int m ); void setDate( int y, int m, int d ); void setDate( QDate ); void redraw(); void slotWeekChange( bool ); protected slots: virtual void keyPressEvent(QKeyEvent *e); private slots: void forwardDateClicked( int y, int m, int d ) { emit dateClicked( y, m, d ); } void finalDate(int, int, int); private: DateBookMonthHeader *header; DateBookMonthTable *table; int year, month, day; bool autoClose; class DateBookMonthPrivate *d; }; class DateButton : public QPushButton { Q_OBJECT public: DateButton( bool longDate, QWidget *parent, const char * name = 0 ); QDate date() const { return currDate; } bool customWhatsThis() const; signals: void dateSelected( int year, int month, int day ); public slots: void setDate( int y, int m, int d ); void setDate( QDate ); void setWeekStartsMonday( int ); void setDateFormat( DateFormat ); private slots: void pickDate(); void gotHide(); private: bool longFormat; bool weekStartsMonday; QDate currDate; DateFormat df; }; +// this class is only here for Sharp ROM compatibility +// I have reverse engineered this class and it seems to +// work (only qtmail seems to use it) - sandman +// DO NOT USE IT IN NEW CODE !! + +class DateBookMonthPopup : public QPopupMenu +{ + Q_OBJECT +public: + DateBookMonthPopup ( QWidget *w ); + +private: + DateBookMonth *m_dbm; +}; #endif diff --git a/library/qpemenubar.cpp b/library/qpemenubar.cpp index c658d10..4aa0bf3 100644 --- a/library/qpemenubar.cpp +++ b/library/qpemenubar.cpp @@ -1,142 +1,151 @@ /********************************************************************** ** 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 INCLUDE_MENUITEM_DEF #include "qpemenubar.h" #include <qapplication.h> #include <qguardedptr.h> #include <qtimer.h> class QMenuBarHack : public QMenuBar { public: int activeItem() const { return actItem; } void goodbye() { activateItemAt(-1); for ( unsigned int i = 0; i < count(); i++ ) { QMenuItem *mi = findItem( idAt(i) ); if ( mi->popup() ) { mi->popup()->hide(); } } } }; +// Sharp ROM compatibility +void QPEMenuToolFocusManager::setMenukeyEnabled ( bool ) +{ +} +int QPEMenuBar::getOldFocus ( ) +{ + return 0; +} + QPEMenuToolFocusManager *QPEMenuToolFocusManager::me = 0; QPEMenuToolFocusManager::QPEMenuToolFocusManager() : QObject() { qApp->installEventFilter( this ); } void QPEMenuToolFocusManager::addWidget( QWidget *w ) { list.append( GuardedWidget(w) ); } void QPEMenuToolFocusManager::removeWidget( QWidget *w ) { list.remove( GuardedWidget(w) ); } void QPEMenuToolFocusManager::setActive( bool a ) { if ( a ) { oldFocus = qApp->focusWidget(); QValueList<GuardedWidget>::Iterator it; it = list.begin(); while ( it != list.end() ) { QWidget *w = (*it); if ( w && w->isEnabled() && w->isVisible() && w->topLevelWidget() == qApp->activeWindow() ) { setFocus( w ); return; } ++it; } } else { if ( inFocus ) { if ( inFocus->inherits( "QMenuBar" ) ) ((QMenuBarHack *)(QWidget *)inFocus)->goodbye(); if ( inFocus->hasFocus() ) { if ( oldFocus && oldFocus->isVisible() && oldFocus->isEnabled() ) { oldFocus->setFocus(); } else { inFocus->clearFocus(); } } } inFocus = 0; oldFocus = 0; } } bool QPEMenuToolFocusManager::isActive() const { return !inFocus.isNull(); } void QPEMenuToolFocusManager::moveFocus( bool next ) { if ( !isActive() ) return; int n = list.count(); QValueList<GuardedWidget>::Iterator it; it = list.find( inFocus ); if ( it == list.end() ) it = list.begin(); while ( --n ) { if ( next ) { ++it; if ( it == list.end() ) it = list.begin(); } else { if ( it == list.begin() ) it = list.end(); --it; } QWidget *w = (*it); if ( w && w->isEnabled() && w->isVisible() && !w->inherits("QToolBarSeparator") && w->topLevelWidget() == qApp->activeWindow() ) { setFocus( w, next ); return; } } } void QPEMenuToolFocusManager::initialize() { if ( !me ) me = new QPEMenuToolFocusManager; } QPEMenuToolFocusManager *QPEMenuToolFocusManager::manager() { if ( !me ) me = new QPEMenuToolFocusManager; return me; } diff --git a/library/qpemenubar.h b/library/qpemenubar.h index 05abc4e..66d0c85 100644 --- a/library/qpemenubar.h +++ b/library/qpemenubar.h @@ -1,78 +1,85 @@ /********************************************************************** ** 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 QPEMENUBAR_H #define QPEMENUBAR_H #include <qmenubar.h> #include <qguardedptr.h> #include <qvaluelist.h> class QPEMenuToolFocusManager : public QObject { Q_OBJECT public: QPEMenuToolFocusManager(); void addWidget( QWidget *w ); void removeWidget( QWidget *w ); void setActive( bool a ); bool isActive() const; void moveFocus( bool next ); static QPEMenuToolFocusManager *manager(); static void initialize(); protected: void setFocus( QWidget *w, bool next=TRUE ); bool eventFilter( QObject *object, QEvent *event ); private slots: void deactivate(); private: typedef QGuardedPtr<QWidget> GuardedWidget; QValueList<GuardedWidget> list; GuardedWidget inFocus; GuardedWidget oldFocus; static QPEMenuToolFocusManager *me; + +private: // Sharp ROM compatibility + void setMenukeyEnabled ( bool b ); }; class QPEMenuBar : public QMenuBar { Q_OBJECT public: QPEMenuBar( QWidget *parent=0, const char* name=0 ); ~QPEMenuBar(); protected: virtual void keyPressEvent( QKeyEvent *e ); /* Patch from Mickey * Sharp Qtopia1.5 seems to have these functions * TO BE RESOLVED - zecke */ void activateItem( int index ); void goodbye(); + + // This is a special "lineo" add-on for the Sharp ROM + // nobody knows, what it does, though ... + int getOldFocus ( ); }; #endif |