summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-write/qrichtext_p.h157
-rw-r--r--noncore/apps/tableviewer/browsekeyentry.cpp53
-rw-r--r--noncore/apps/tableviewer/db/common.cpp165
-rw-r--r--noncore/apps/tableviewer/db/datacache.cpp68
-rw-r--r--noncore/apps/tableviewer/db/datacache.h24
-rw-r--r--noncore/apps/tableviewer/ui/browsekeyentry.cpp49
-rw-r--r--noncore/apps/tableviewer/ui/filterkeyentry.cpp42
-rw-r--r--noncore/apps/tableviewer/ui/tvfilterview.cpp55
-rw-r--r--noncore/apps/tinykate/libkate/kateconfig.cpp4
-rw-r--r--noncore/apps/zsafe/main.cpp25
-rw-r--r--noncore/apps/zsafe/zlistview.cpp11
-rw-r--r--noncore/apps/zsafe/zsafe.cpp51
-rw-r--r--noncore/comm/keypebble/krfbdecoder.cpp108
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp6
-rw-r--r--noncore/graphics/opie-eye/gui/viewmodebutton.cpp5
-rw-r--r--noncore/net/opietooth/lib/device.cc95
-rw-r--r--noncore/net/opietooth/lib/manager.cc65
-rw-r--r--noncore/net/opietooth/lib/parser.cc60
-rw-r--r--noncore/settings/mediummount/mediumglobal.cc11
-rw-r--r--noncore/styles/theme/othemebase.h981
20 files changed, 1037 insertions, 998 deletions
diff --git a/noncore/apps/opie-write/qrichtext_p.h b/noncore/apps/opie-write/qrichtext_p.h
index e368edb..3778feb 100644
--- a/noncore/apps/opie-write/qrichtext_p.h
+++ b/noncore/apps/opie-write/qrichtext_p.h
@@ -1,1509 +1,1512 @@
/****************************************************************************
** $Id$
**
** Definition of internal rich text classes
**
** Created : 990124
**
** Copyright (C) 1999-2000 Trolltech AS. All rights reserved.
**
** This file is part of the kernel module of the Qt GUI Toolkit.
**
** This file may be distributed under the terms of the Q Public License
** as defined by Trolltech AS of Norway and appearing in the file
** LICENSE.QPL included in the packaging of this file.
**
** 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.
**
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
** licenses may use this file in accordance with the Qt Commercial 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.
**
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
** information about Qt Commercial License Agreements.
** See http://www.trolltech.com/qpl/ for QPL licensing information.
** 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 QRICHTEXT_P_H
#define QRICHTEXT_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of a number of Qt sources files. This header file may change from
// version to version without notice, or even be removed.
//
// We mean it.
//
//
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+
#ifndef QT_H
#include "qstring.h"
#include "qlist.h"
#include "qrect.h"
#include "qfontmetrics.h"
#include "qintdict.h"
#include "qmap.h"
#include "qstringlist.h"
#include "qfont.h"
#include "qcolor.h"
#include "qsize.h"
#include "qvaluelist.h"
#include "qvaluestack.h"
#include "qobject.h"
#include "qdict.h"
#include "qtextstream.h"
#include "qpixmap.h"
#include "qstylesheet.h"
#include "qvector.h"
#include "qpainter.h"
#include "qlayout.h"
#include "qobject.h"
#include "qcomplextext_p.h"
#include "qapplication.h"
#include <limits.h>
#endif // QT_H
namespace Qt3 {
class QTextDocument;
class QTextString;
class QTextPreProcessor;
class QTextFormat;
class QTextCursor;
class QTextParagraph;
class QTextFormatter;
class QTextIndent;
class QTextFormatCollection;
class QStyleSheetItem;
class QTextCustomItem;
class QTextFlow;
struct QBidiContext;
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class Q_EXPORT QTextStringChar
{
friend class QTextString;
public:
// this is never called, initialize variables in QTextString::insert()!!!
QTextStringChar() : lineStart( 0 ), type( Regular ), startOfRun( 0 ) {d.format=0;}
~QTextStringChar();
QChar c;
enum Type { Regular=0, Custom=1, Anchor=2, CustomAnchor=3 };
uint lineStart : 1;
uint rightToLeft : 1;
uint hasCursor : 1;
uint canBreak : 1;
Type type : 2;
uint startOfRun : 1;
int x;
int height() const;
int ascent() const;
int descent() const;
bool isCustom() const { return (type & Custom) != 0; }
QTextFormat *format() const;
QTextCustomItem *customItem() const;
void setFormat( QTextFormat *f );
void setCustomItem( QTextCustomItem *i );
struct CustomData
{
- QTextFormat *format;
- QTextCustomItem *custom;
- QString anchorName;
- QString anchorHref;
+ QTextFormat *format;
+ QTextCustomItem *custom;
+ QString anchorName;
+ QString anchorHref;
};
void loseCustomItem();
union {
- QTextFormat* format;
- CustomData* custom;
+ QTextFormat* format;
+ CustomData* custom;
} d;
bool isAnchor() const { return ( type & Anchor) != 0; }
QString anchorName() const;
QString anchorHref() const;
void setAnchor( const QString& name, const QString& href );
private:
QTextStringChar &operator=( const QTextStringChar & ) {
- //abort();
- return *this;
+ //abort();
+ return *this;
}
friend class QComplexText;
friend class QTextParagraph;
};
#if defined(Q_TEMPLATEDLL)
// MOC_SKIP_BEGIN
Q_TEMPLATE_EXTERN template class Q_EXPORT QMemArray<QTextStringChar>;
// MOC_SKIP_END
#endif
class Q_EXPORT QTextString
{
public:
QTextString();
QTextString( const QTextString &s );
virtual ~QTextString();
static QString toString( const QMemArray<QTextStringChar> &data );
QString toString() const;
QTextStringChar &at( int i ) const;
int length() const;
int width( int idx ) const;
void insert( int index, const QString &s, QTextFormat *f );
void insert( int index, const QChar *unicode, int len, QTextFormat *f );
void insert( int index, QTextStringChar *c, bool doAddRefFormat = FALSE );
void truncate( int index );
void remove( int index, int len );
void clear();
void setFormat( int index, QTextFormat *f, bool useCollection );
void setBidi( bool b ) { bidi = b; }
bool isBidi() const;
bool isRightToLeft() const;
QChar::Direction direction() const;
void setDirection( QChar::Direction d ) { dir = d; bidiDirty = TRUE; }
QMemArray<QTextStringChar> subString( int start = 0, int len = 0xFFFFFF ) const;
QMemArray<QTextStringChar> rawData() const { return data; }
void operator=( const QString &s ) { clear(); insert( 0, s, 0 ); }
void operator+=( const QString &s ) {insert( length(), s, 0 ); }
void prepend( const QString &s ) { insert( 0, s, 0 ); }
private:
void checkBidi() const;
QMemArray<QTextStringChar> data;
uint bidiDirty : 1;
uint bidi : 1; // true when the paragraph has right to left characters
uint rightToLeft : 1;
uint dir : 5;
};
inline bool QTextString::isBidi() const
{
if ( bidiDirty )
- checkBidi();
+ checkBidi();
return bidi;
}
inline bool QTextString::isRightToLeft() const
{
if ( bidiDirty )
- checkBidi();
+ checkBidi();
return rightToLeft;
}
inline QChar::Direction QTextString::direction() const
{
return (QChar::Direction) dir;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#if defined(Q_TEMPLATEDLL)
// MOC_SKIP_BEGIN
Q_TEMPLATE_EXTERN template class Q_EXPORT QValueStack<int>;
Q_TEMPLATE_EXTERN template class Q_EXPORT QValueStack<QTextParagraph*>;
Q_TEMPLATE_EXTERN template class Q_EXPORT QValueStack<bool>;
// MOC_SKIP_END
#endif
class Q_EXPORT QTextCursor
{
public:
QTextCursor( QTextDocument *d = 0 );
QTextCursor( const QTextCursor &c );
QTextCursor &operator=( const QTextCursor &c );
virtual ~QTextCursor() {}
bool operator==( const QTextCursor &c ) const;
bool operator!=( const QTextCursor &c ) const { return !(*this == c); }
QTextParagraph *paragraph() const;
void setParagraph( QTextParagraph*p ) { gotoPosition(p, 0 ); }
QTextDocument *document() const;
int index() const;
void setIndex( int index ) { gotoPosition(paragraph(), index ); }
void gotoPosition( QTextParagraph* p, int index = 0);
void gotoLeft();
void gotoRight();
void gotoNextLetter();
void gotoPreviousLetter();
void gotoUp();
void gotoDown();
void gotoLineEnd();
void gotoLineStart();
void gotoHome();
void gotoEnd();
void gotoPageUp( int visibleHeight );
void gotoPageDown( int visibleHeight );
void gotoNextWord();
void gotoPreviousWord();
void gotoWordLeft();
void gotoWordRight();
void insert( const QString &s, bool checkNewLine, QMemArray<QTextStringChar> *formatting = 0 );
void splitAndInsertEmptyParagraph( bool ind = TRUE, bool updateIds = TRUE );
bool remove();
void indent();
bool atParagStart();
bool atParagEnd();
int x() const; // x in current paragraph
int y() const; // y in current paragraph
int globalX() const;
int globalY() const;
QTextParagraph *topParagraph() const { return paras.isEmpty() ? para : paras.first(); }
int offsetX() const { return ox; } // inner document offset
int offsetY() const { return oy; } // inner document offset
int totalOffsetX() const; // total document offset
int totalOffsetY() const; // total document offset
bool place( const QPoint &pos, QTextParagraph *s ) { return place( pos, s, FALSE ); }
bool place( const QPoint &pos, QTextParagraph *s, bool link );
void restoreState();
int nestedDepth() const { return (int)indices.count(); } //### size_t/int cast
void oneUp() { if ( !indices.isEmpty() ) pop(); }
void setValid( bool b ) { valid = b; }
bool isValid() const { return valid; }
private:
enum Operation { EnterBegin, EnterEnd, Next, Prev, Up, Down };
void push();
void pop();
void processNesting( Operation op );
void invalidateNested();
void gotoIntoNested( const QPoint &globalPos );
QTextParagraph *para;
int idx, tmpIndex;
int ox, oy;
QValueStack<int> indices;
QValueStack<QTextParagraph*> paras;
QValueStack<int> xOffsets;
QValueStack<int> yOffsets;
uint valid : 1;
};
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class Q_EXPORT QTextCommand
{
public:
enum Commands { Invalid, Insert, Delete, Format, Style };
QTextCommand( QTextDocument *d ) : doc( d ), cursor( d ) {}
virtual ~QTextCommand();
virtual Commands type() const;
virtual QTextCursor *execute( QTextCursor *c ) = 0;
virtual QTextCursor *unexecute( QTextCursor *c ) = 0;
protected:
QTextDocument *doc;
QTextCursor cursor;
};
#if defined(Q_TEMPLATEDLL)
// MOC_SKIP_BEGIN
Q_TEMPLATE_EXTERN template class Q_EXPORT QPtrList<QTextCommand>;
// MOC_SKIP_END
#endif
class Q_EXPORT QTextCommandHistory
{
public:
QTextCommandHistory( int s ) : current( -1 ), steps( s ) { history.setAutoDelete( TRUE ); }
virtual ~QTextCommandHistory();
void clear() { history.clear(); current = -1; }
void addCommand( QTextCommand *cmd );
QTextCursor *undo( QTextCursor *c );
QTextCursor *redo( QTextCursor *c );
bool isUndoAvailable();
bool isRedoAvailable();
void setUndoDepth( int d ) { steps = d; }
int undoDepth() const { return steps; }
int historySize() const { return history.count(); }
int currentPosition() const { return current; }
private:
QPtrList<QTextCommand> history;
int current, steps;
};
inline QTextCommandHistory::~QTextCommandHistory()
{
clear();
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class Q_EXPORT QTextCustomItem
{
public:
QTextCustomItem( QTextDocument *p )
- : xpos(0), ypos(-1), width(-1), height(0), parent( p )
+ : xpos(0), ypos(-1), width(-1), height(0), parent( p )
{}
virtual ~QTextCustomItem();
virtual void draw(QPainter* p, int x, int y, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected ) = 0;
virtual void adjustToPainter( QPainter* );
enum Placement { PlaceInline = 0, PlaceLeft, PlaceRight };
virtual Placement placement() const;
bool placeInline() { return placement() == PlaceInline; }
virtual bool ownLine() const;
virtual void resize( int nwidth );
virtual void invalidate();
virtual int ascent() const { return height; }
virtual bool isNested() const;
virtual int minimumWidth() const;
virtual QString richText() const;
int xpos; // used for floating items
int ypos; // used for floating items
int width;
int height;
QRect geometry() const { return QRect( xpos, ypos, width, height ); }
virtual bool enter( QTextCursor *, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy, bool atEnd = FALSE );
virtual bool enterAt( QTextCursor *, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy, const QPoint & );
virtual bool next( QTextCursor *, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy );
virtual bool prev( QTextCursor *, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy );
virtual bool down( QTextCursor *, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy );
virtual bool up( QTextCursor *, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy );
void setParagraph( QTextParagraph *p ) { parag = p; }
QTextParagraph *paragraph() const { return parag; }
QTextDocument *parent;
QTextParagraph *parag;
virtual void pageBreak( int y, QTextFlow* flow );
};
#if defined(Q_TEMPLATEDLL)
// MOC_SKIP_BEGIN
Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<QString, QString>;
// MOC_SKIP_END
#endif
class Q_EXPORT QTextImage : public QTextCustomItem
{
public:
QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context,
- QMimeSourceFactory &factory );
+ QMimeSourceFactory &factory );
virtual ~QTextImage();
Placement placement() const { return place; }
void adjustToPainter( QPainter* );
int minimumWidth() const { return width; }
QString richText() const;
void draw( QPainter* p, int x, int y, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected );
private:
QRegion* reg;
QPixmap pm;
Placement place;
int tmpwidth, tmpheight;
QMap<QString, QString> attributes;
QString imgId;
};
class Q_EXPORT QTextHorizontalLine : public QTextCustomItem
{
public:
QTextHorizontalLine( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context,
- QMimeSourceFactory &factory );
+ QMimeSourceFactory &factory );
virtual ~QTextHorizontalLine();
void adjustToPainter( QPainter* );
void draw(QPainter* p, int x, int y, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected );
QString richText() const;
bool ownLine() const { return TRUE; }
private:
int tmpheight;
QColor color;
};
#if defined(Q_TEMPLATEDLL)
// MOC_SKIP_BEGIN
Q_TEMPLATE_EXTERN template class Q_EXPORT QPtrList<QTextCustomItem>;
// MOC_SKIP_END
#endif
class Q_EXPORT QTextFlow
{
friend class QTextDocument;
friend class QTextTableCell;
public:
QTextFlow();
virtual ~QTextFlow();
virtual void setWidth( int width );
int width() const;
virtual void setPageSize( int ps );
int pageSize() const { return pagesize; }
virtual int adjustLMargin( int yp, int h, int margin, int space );
virtual int adjustRMargin( int yp, int h, int margin, int space );
virtual void registerFloatingItem( QTextCustomItem* item );
virtual void unregisterFloatingItem( QTextCustomItem* item );
virtual QRect boundingRect() const;
virtual void drawFloatingItems(QPainter* p, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected );
virtual int adjustFlow( int y, int w, int h ); // adjusts y according to the defined pagesize. Returns the shift.
virtual bool isEmpty();
void clear();
private:
int w;
int pagesize;
QPtrList<QTextCustomItem> leftItems;
QPtrList<QTextCustomItem> rightItems;
};
inline int QTextFlow::width() const { return w; }
class QTextTable;
class Q_EXPORT QTextTableCell : public QLayoutItem
{
friend class QTextTable;
public:
QTextTableCell( QTextTable* table,
- int row, int column,
- const QMap<QString, QString> &attr,
- const QStyleSheetItem* style,
- const QTextFormat& fmt, const QString& context,
- QMimeSourceFactory &factory, QStyleSheet *sheet, const QString& doc );
+ int row, int column,
+ const QMap<QString, QString> &attr,
+ const QStyleSheetItem* style,
+ const QTextFormat& fmt, const QString& context,
+ QMimeSourceFactory &factory, QStyleSheet *sheet, const QString& doc );
virtual ~QTextTableCell();
QSize sizeHint() const ;
QSize minimumSize() const ;
QSize maximumSize() const ;
QSizePolicy::ExpandData expanding() const;
bool isEmpty() const;
void setGeometry( const QRect& ) ;
QRect geometry() const;
bool hasHeightForWidth() const;
int heightForWidth( int ) const;
void adjustToPainter( QPainter* );
int row() const { return row_; }
int column() const { return col_; }
int rowspan() const { return rowspan_; }
int colspan() const { return colspan_; }
int stretch() const { return stretch_; }
QTextDocument* richText() const { return richtext; }
QTextTable* table() const { return parent; }
void draw( QPainter* p, int x, int y, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected );
QBrush *backGround() const { return background; }
virtual void invalidate();
int verticalAlignmentOffset() const;
int horizontalAlignmentOffset() const;
private:
QRect geom;
QTextTable* parent;
QTextDocument* richtext;
int row_;
int col_;
int rowspan_;
int colspan_;
int stretch_;
int maxw;
int minw;
bool hasFixedWidth;
QBrush *background;
int cached_width;
int cached_sizehint;
QMap<QString, QString> attributes;
int align;
};
#if defined(Q_TEMPLATEDLL)
// MOC_SKIP_BEGIN
Q_TEMPLATE_EXTERN template class Q_EXPORT QPtrList<QTextTableCell>;
Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<QTextCursor*, int>;
// MOC_SKIP_END
#endif
class Q_EXPORT QTextTable: public QTextCustomItem
{
friend class QTextTableCell;
public:
QTextTable( QTextDocument *p, const QMap<QString, QString> &attr );
virtual ~QTextTable();
void adjustToPainter( QPainter *p );
void pageBreak( int y, QTextFlow* flow );
void draw( QPainter* p, int x, int y, int cx, int cy, int cw, int ch,
- const QColorGroup& cg, bool selected );
+ const QColorGroup& cg, bool selected );
bool noErase() const { return TRUE; }
bool ownLine() const { return TRUE; }
Placement placement() const { return place; }
bool isNested() const { return TRUE; }
void resize( int nwidth );
virtual void invalidate();
virtual bool enter( QTextCursor *c, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy, bool atEnd = FALSE );
virtual bool enterAt( QTextCursor *c, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy, const QPoint &pos );
virtual bool next( QTextCursor *c, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy );
virtual bool prev( QTextCursor *c, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy );
virtual bool down( QTextCursor *c, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy );
virtual bool up( QTextCursor *c, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy );
QString richText() const;
int minimumWidth() const;
QPtrList<QTextTableCell> tableCells() const { return cells; }
bool isStretching() const { return stretch; }
private:
void format( int w );
void addCell( QTextTableCell* cell );
private:
QGridLayout* layout;
QPtrList<QTextTableCell> cells;
int cachewidth;
int fixwidth;
int cellpadding;
int cellspacing;
int border;
int outerborder;
int stretch;
int innerborder;
int us_cp, us_ib, us_b, us_ob, us_cs;
QMap<QString, QString> attributes;
QMap<QTextCursor*, int> currCell;
Placement place;
void adjustCells( int y , int shift );
int pageBreakFor;
};
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class QTextTableCell;
class QTextParagraph;
struct Q_EXPORT QTextDocumentSelection
{
QTextCursor startCursor, endCursor;
bool swapped;
};
#if defined(Q_TEMPLATEDLL)
// MOC_SKIP_BEGIN
Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, QColor>;
Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, bool>;
Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, QTextDocumentSelection>;
Q_TEMPLATE_EXTERN template class Q_EXPORT QPtrList<QTextDocument>;
// MOC_SKIP_END
#endif
class Q_EXPORT QTextDocument : public QObject
{
Q_OBJECT
friend class QTextTableCell;
friend class QTextCursor;
friend class QTextEdit;
friend class QTextParagraph;
public:
enum SelectionIds {
- Standard = 0,
- Temp = 32000 // This selection must not be drawn, it's used e.g. by undo/redo to
- // remove multiple lines with removeSelectedText()
+ Standard = 0,
+ Temp = 32000 // This selection must not be drawn, it's used e.g. by undo/redo to
+ // remove multiple lines with removeSelectedText()
};
QTextDocument( QTextDocument *p );
QTextDocument( QTextDocument *d, QTextFormatCollection *f );
virtual ~QTextDocument();
QTextDocument *parent() const { return par; }
QTextParagraph *parentParagraph() const { return parentPar; }
void setText( const QString &text, const QString &context );
QMap<QString, QString> attributes() const { return attribs; }
void setAttributes( const QMap<QString, QString> &attr ) { attribs = attr; }
QString text() const;
QString text( int parag ) const;
QString originalText() const;
int x() const;
int y() const;
int width() const;
int widthUsed() const;
int visibleWidth() const;
int height() const;
void setWidth( int w );
int minimumWidth() const;
bool setMinimumWidth( int needed, int used = -1, QTextParagraph *parag = 0 );
void setY( int y );
int leftMargin() const;
void setLeftMargin( int lm );
int rightMargin() const;
void setRightMargin( int rm );
QTextParagraph *firstParagraph() const;
QTextParagraph *lastParagraph() const;
void setFirstParagraph( QTextParagraph *p );
void setLastParagraph( QTextParagraph *p );
void invalidate();
void setPreProcessor( QTextPreProcessor *sh );
QTextPreProcessor *preProcessor() const;
void setFormatter( QTextFormatter *f );
QTextFormatter *formatter() const;
void setIndent( QTextIndent *i );
QTextIndent *indent() const;
QColor selectionColor( int id ) const;
bool invertSelectionText( int id ) const;
void setSelectionColor( int id, const QColor &c );
void setInvertSelectionText( int id, bool b );
bool hasSelection( int id, bool visible = FALSE ) const;
void setSelectionStart( int id, const QTextCursor &cursor );
bool setSelectionEnd( int id, const QTextCursor &cursor );
void selectAll( int id );
bool removeSelection( int id );
void selectionStart( int id, int &paragId, int &index );
QTextCursor selectionStartCursor( int id );
QTextCursor selectionEndCursor( int id );
void selectionEnd( int id, int &paragId, int &index );
void setFormat( int id, QTextFormat *f, int flags );
int numSelections() const { return nSelections; }
void addSelection( int id );
QString selectedText( int id, bool asRichText = FALSE ) const;
void removeSelectedText( int id, QTextCursor *cursor );
void indentSelection( int id );
QTextParagraph *paragAt( int i ) const;
void addCommand( QTextCommand *cmd );
QTextCursor *undo( QTextCursor *c = 0 );
QTextCursor *redo( QTextCursor *c = 0 );
QTextCommandHistory *commands() const { return commandHistory; }
QTextFormatCollection *formatCollection() const;
bool find( QTextCursor &cursor, const QString &expr, bool cs, bool wo, bool forward);
void setTextFormat( Qt::TextFormat f );
Qt::TextFormat textFormat() const;
bool inSelection( int selId, const QPoint &pos ) const;
QStyleSheet *styleSheet() const { return sheet_; }
QMimeSourceFactory *mimeSourceFactory() const { return factory_; }
QString context() const { return contxt; }
void setStyleSheet( QStyleSheet *s );
void setDefaultFormat( const QFont &font, const QColor &color );
void setMimeSourceFactory( QMimeSourceFactory *f ) { if ( f ) factory_ = f; }
void setContext( const QString &c ) { if ( !c.isEmpty() ) contxt = c; }
void setUnderlineLinks( bool b );
bool underlineLinks() const { return underlLinks; }
void setPaper( QBrush *brush ) { if ( backBrush ) delete backBrush; backBrush = brush; }
QBrush *paper() const { return backBrush; }
void doLayout( QPainter *p, int w );
void draw( QPainter *p, const QRect& rect, const QColorGroup &cg, const QBrush *paper = 0 );
void drawParagraph( QPainter *p, QTextParagraph *parag, int cx, int cy, int cw, int ch,
- QPixmap *&doubleBuffer, const QColorGroup &cg,
- bool drawCursor, QTextCursor *cursor, bool resetChanged = TRUE );
+ QPixmap *&doubleBuffer, const QColorGroup &cg,
+ bool drawCursor, QTextCursor *cursor, bool resetChanged = TRUE );
QTextParagraph *draw( QPainter *p, int cx, int cy, int cw, int ch, const QColorGroup &cg,
- bool onlyChanged = FALSE, bool drawCursor = FALSE, QTextCursor *cursor = 0,
- bool resetChanged = TRUE );
+ bool onlyChanged = FALSE, bool drawCursor = FALSE, QTextCursor *cursor = 0,
+ bool resetChanged = TRUE );
void registerCustomItem( QTextCustomItem *i, QTextParagraph *p );
void unregisterCustomItem( QTextCustomItem *i, QTextParagraph *p );
void setFlow( QTextFlow *f );
void takeFlow();
QTextFlow *flow() const { return flow_; }
bool isPageBreakEnabled() const { return pages; }
void setPageBreakEnabled( bool b ) { pages = b; }
void setUseFormatCollection( bool b ) { useFC = b; }
bool useFormatCollection() const { return useFC; }
QTextTableCell *tableCell() const { return tc; }
void setTableCell( QTextTableCell *c ) { tc = c; }
void setPlainText( const QString &text );
void setRichText( const QString &text, const QString &context );
QString richText() const;
QString plainText() const;
bool focusNextPrevChild( bool next );
int alignment() const;
void setAlignment( int a );
int *tabArray() const;
int tabStopWidth() const;
void setTabArray( int *a );
void setTabStops( int tw );
void setUndoDepth( int d ) { commandHistory->setUndoDepth( d ); }
int undoDepth() const { return commandHistory->undoDepth(); }
int length() const;
void clear( bool createEmptyParag = FALSE );
virtual QTextParagraph *createParagraph( QTextDocument *d, QTextParagraph *pr = 0, QTextParagraph *nx = 0, bool updateIds = TRUE );
void insertChild( QObject *o ) { QObject::insertChild( o ); }
void removeChild( QObject *o ) { QObject::removeChild( o ); }
void insertChild( QTextDocument *d ) { childList.append( d ); }
void removeChild( QTextDocument *d ) { childList.removeRef( d ); }
QPtrList<QTextDocument> children() const { return childList; }
bool hasFocusParagraph() const;
QString focusHref() const;
void invalidateOriginalText() { oTextValid = FALSE; oText = ""; }
static QString section( QString str, const QString &sep, int start, int end = 0xffffffff );
static bool endsWith( QString str, const QString &s);
signals:
void minimumWidthChanged( int );
private:
void init();
QPixmap *bufferPixmap( const QSize &s );
// HTML parser
bool hasPrefix(const QChar* doc, int length, int pos, QChar c);
bool hasPrefix(const QChar* doc, int length, int pos, const QString& s);
QTextCustomItem* parseTable( const QMap<QString, QString> &attr, const QTextFormat &fmt,
- const QChar* doc, int length, int& pos, QTextParagraph *curpar );
+ const QChar* doc, int length, int& pos, QTextParagraph *curpar );
bool eatSpace(const QChar* doc, int length, int& pos, bool includeNbsp = FALSE );
bool eat(const QChar* doc, int length, int& pos, QChar c);
QString parseOpenTag(const QChar* doc, int length, int& pos, QMap<QString, QString> &attr, bool& emptyTag);
QString parseCloseTag( const QChar* doc, int length, int& pos );
QChar parseHTMLSpecialChar(const QChar* doc, int length, int& pos);
QString parseWord(const QChar* doc, int length, int& pos, bool lower = TRUE);
QChar parseChar(const QChar* doc, int length, int& pos, QStyleSheetItem::WhiteSpaceMode wsm );
void setRichTextInternal( const QString &text, QTextCursor* cursor = 0 );
void setRichTextMarginsInternal( QPtrList< QPtrVector<QStyleSheetItem> >& styles, QTextParagraph* stylesPar );
private:
struct Q_EXPORT Focus {
- QTextParagraph *parag;
- int start, len;
- QString href;
+ QTextParagraph *parag;
+ int start, len;
+ QString href;
};
int cx, cy, cw, vw;
QTextParagraph *fParag, *lParag;
QTextPreProcessor *pProcessor;
QMap<int, QColor> selectionColors;
QMap<int, QTextDocumentSelection> selections;
QMap<int, bool> selectionText;
QTextCommandHistory *commandHistory;
QTextFormatter *pFormatter;
QTextIndent *indenter;
QTextFormatCollection *fCollection;
Qt::TextFormat txtFormat;
uint preferRichText : 1;
uint pages : 1;
uint useFC : 1;
uint withoutDoubleBuffer : 1;
uint underlLinks : 1;
uint nextDoubleBuffered : 1;
uint oTextValid : 1;
uint mightHaveCustomItems : 1;
int align;
int nSelections;
QTextFlow *flow_;
QTextDocument *par;
QTextParagraph *parentPar;
QTextTableCell *tc;
QBrush *backBrush;
QPixmap *buf_pixmap;
Focus focusIndicator;
int minw;
int wused;
int leftmargin;
int rightmargin;
QTextParagraph *minwParag, *curParag;
QStyleSheet* sheet_;
QMimeSourceFactory* factory_;
QString contxt;
QMap<QString, QString> attribs;
int *tArray;
int tStopWidth;
int uDepth;
QString oText;
QPtrList<QTextDocument> childList;
QColor linkColor;
double scaleFontsFactor;
short list_tm,list_bm, list_lm, li_tm, li_bm, par_tm, par_bm;
};
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class Q_EXPORT QTextDeleteCommand : public QTextCommand
{
public:
QTextDeleteCommand( QTextDocument *d, int i, int idx, const QMemArray<QTextStringChar> &str,
- const QByteArray& oldStyle );
+ const QByteArray& oldStyle );
QTextDeleteCommand( QTextParagraph *p, int idx, const QMemArray<QTextStringChar> &str );
virtual ~QTextDeleteCommand();
Commands type() const { return Delete; }
QTextCursor *execute( QTextCursor *c );
QTextCursor *unexecute( QTextCursor *c );
protected:
int id, index;
QTextParagraph *parag;
QMemArray<QTextStringChar> text;
QByteArray styleInformation;
};
class Q_EXPORT QTextInsertCommand : public QTextDeleteCommand
{
public:
QTextInsertCommand( QTextDocument *d, int i, int idx, const QMemArray<QTextStringChar> &str,
- const QByteArray& oldStyleInfo )
- : QTextDeleteCommand( d, i, idx, str, oldStyleInfo ) {}
+ const QByteArray& oldStyleInfo )
+ : QTextDeleteCommand( d, i, idx, str, oldStyleInfo ) {}
QTextInsertCommand( QTextParagraph *p, int idx, const QMemArray<QTextStringChar> &str )
- : QTextDeleteCommand( p, idx, str ) {}
+ : QTextDeleteCommand( p, idx, str ) {}
virtual ~QTextInsertCommand() {}
Commands type() const { return Insert; }
QTextCursor *execute( QTextCursor *c ) { return QTextDeleteCommand::unexecute( c ); }
QTextCursor *unexecute( QTextCursor *c ) { return QTextDeleteCommand::execute( c ); }
};
class Q_EXPORT QTextFormatCommand : public QTextCommand
{
public:
QTextFormatCommand( QTextDocument *d, int sid, int sidx, int eid, int eidx, const QMemArray<QTextStringChar> &old, QTextFormat *f, int fl );
virtual ~QTextFormatCommand();
Commands type() const { return Format; }
QTextCursor *execute( QTextCursor *c );
QTextCursor *unexecute( QTextCursor *c );
protected:
int startId, startIndex, endId, endIndex;
QTextFormat *format;
QMemArray<QTextStringChar> oldFormats;
int flags;
};
class Q_EXPORT QTextStyleCommand : public QTextCommand
{
public:
QTextStyleCommand( QTextDocument *d, int fParag, int lParag, const QByteArray& beforeChange );
virtual ~QTextStyleCommand() {}
Commands type() const { return Style; }
QTextCursor *execute( QTextCursor *c );
QTextCursor *unexecute( QTextCursor *c );
static QByteArray readStyleInformation( QTextDocument* d, int fParag, int lParag );
static void writeStyleInformation( QTextDocument* d, int fParag, const QByteArray& style );
private:
int firstParag, lastParag;
QByteArray before;
QByteArray after;
};
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
struct Q_EXPORT QTextParagraphSelection
{
int start, end;
};
struct Q_EXPORT QTextLineStart
{
QTextLineStart() : y( 0 ), baseLine( 0 ), h( 0 )
#ifndef QT_NO_COMPLEXTEXT
- , bidicontext( 0 )
+ , bidicontext( 0 )
#endif
{ }
QTextLineStart( ushort y_, ushort bl, ushort h_ ) : y( y_ ), baseLine( bl ), h( h_ ),
- w( 0 )
+ w( 0 )
#ifndef QT_NO_COMPLEXTEXT
- , bidicontext( 0 )
+ , bidicontext( 0 )
#endif
{ }
#ifndef QT_NO_COMPLEXTEXT
QTextLineStart( QBidiContext *c, QBidiStatus s ) : y(0), baseLine(0), h(0),
- status( s ), bidicontext( c ) { if ( bidicontext ) bidicontext->ref(); }
+ status( s ), bidicontext( c ) { if ( bidicontext ) bidicontext->ref(); }
#endif
virtual ~QTextLineStart()
{
#ifndef QT_NO_COMPLEXTEXT
- if ( bidicontext && bidicontext->deref() )
- delete bidicontext;
+ if ( bidicontext && bidicontext->deref() )
+ delete bidicontext;
#endif
}
#ifndef QT_NO_COMPLEXTEXT
void setContext( QBidiContext *c ) {
- if ( c == bidicontext )
- return;
- if ( bidicontext && bidicontext->deref() )
- delete bidicontext;
- bidicontext = c;
- if ( bidicontext )
- bidicontext->ref();
+ if ( c == bidicontext )
+ return;
+ if ( bidicontext && bidicontext->deref() )
+ delete bidicontext;
+ bidicontext = c;
+ if ( bidicontext )
+ bidicontext->ref();
}
QBidiContext *context() const { return bidicontext; }
#endif
public:
ushort y, baseLine, h;
#ifndef QT_NO_COMPLEXTEXT
QBidiStatus status;
#endif
int w;
private:
#ifndef QT_NO_COMPLEXTEXT
QBidiContext *bidicontext;
#endif
};
#if defined(Q_TEMPLATEDLL)
// MOC_SKIP_BEGIN
Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, QTextParagraphSelection>;
Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, QTextLineStart*>;
// MOC_SKIP_END
#endif
class Q_EXPORT QTextParagraphData
{
public:
QTextParagraphData() {}
virtual ~QTextParagraphData();
virtual void join( QTextParagraphData * );
};
class Q_EXPORT QTextParagraphPseudoDocument
{
public:
QTextParagraphPseudoDocument();
~QTextParagraphPseudoDocument();
QRect docRect;
QTextFormatter *pFormatter;
QTextCommandHistory *commandHistory;
int minw;
int wused;
};
//nase
class Q_EXPORT QTextParagraph
{
friend class QTextDocument;
friend class QTextCursor;
public:
QTextParagraph( QTextDocument *d, QTextParagraph *pr = 0, QTextParagraph *nx = 0, bool updateIds = TRUE );
virtual ~QTextParagraph();
QTextString *string() const;
QTextStringChar *at( int i ) const; // maybe remove later
int leftGap() const;
int length() const; // maybe remove later
void setListStyle( QStyleSheetItem::ListStyle ls ) { lstyle = ls; changed = TRUE; }
QStyleSheetItem::ListStyle listStyle() const { return lstyle; }
void setListItem( bool li ) { litem = li; changed = TRUE; }
bool isListItem() const { return litem; }
void setListValue( int v ) { list_val = v; }
int listValue() const { return list_val > 0 ? list_val : -1; }
void setListDepth( int depth );
int listDepth() const { return ldepth; }
// void setFormat( QTextFormat *fm );
// QTextFormat *paragFormat() const;
QTextDocument *document() const;
QTextParagraphPseudoDocument *pseudoDocument() const;
QRect rect() const;
void setHeight( int h ) { r.setHeight( h ); }
void show();
void hide();
bool isVisible() const { return visible; }
QTextParagraph *prev() const;
QTextParagraph *next() const;
void setPrev( QTextParagraph *s );
void setNext( QTextParagraph *s );
void insert( int index, const QString &s );
void insert( int index, const QChar *unicode, int len );
void append( const QString &s, bool reallyAtEnd = FALSE );
void truncate( int index );
void remove( int index, int len );
void join( QTextParagraph *s );
void invalidate( int chr );
void move( int &dy );
void format( int start = -1, bool doMove = TRUE );
bool isValid() const;
bool hasChanged() const;
void setChanged( bool b, bool recursive = FALSE );
int lineHeightOfChar( int i, int *bl = 0, int *y = 0 ) const;
QTextStringChar *lineStartOfChar( int i, int *index = 0, int *line = 0 ) const;
int lines() const;
QTextStringChar *lineStartOfLine( int line, int *index = 0 ) const;
int lineY( int l ) const;
int lineBaseLine( int l ) const;
int lineHeight( int l ) const;
void lineInfo( int l, int &y, int &h, int &bl ) const;
void setSelection( int id, int start, int end );
void removeSelection( int id );
int selectionStart( int id ) const;
int selectionEnd( int id ) const;
bool hasSelection( int id ) const;
bool hasAnySelection() const;
bool fullSelected( int id ) const;
void setEndState( int s );
int endState() const;
void setParagId( int i );
int paragId() const;
bool firstPreProcess() const;
void setFirstPreProcess( bool b );
void indent( int *oldIndent = 0, int *newIndent = 0 );
void setExtraData( QTextParagraphData *data );
QTextParagraphData *extraData() const;
QMap<int, QTextLineStart*> &lineStartList();
void setFormat( int index, int len, QTextFormat *f, bool useCollection = TRUE, int flags = -1 );
void setAlignment( int a );
int alignment() const;
virtual void paint( QPainter &painter, const QColorGroup &cg, QTextCursor *cursor = 0, bool drawSelections = FALSE,
- int clipx = -1, int clipy = -1, int clipw = -1, int cliph = -1 );
+ int clipx = -1, int clipy = -1, int clipw = -1, int cliph = -1 );
virtual int topMargin() const;
virtual int bottomMargin() const;
virtual int leftMargin() const;
virtual int firstLineMargin() const;
virtual int rightMargin() const;
virtual int lineSpacing() const;
void registerFloatingItem( QTextCustomItem *i );
void unregisterFloatingItem( QTextCustomItem *i );
void setFullWidth( bool b ) { fullWidth = b; }
bool isFullWidth() const { return fullWidth; }
QTextTableCell *tableCell() const;
QBrush *background() const;
int documentWidth() const;
int documentVisibleWidth() const;
int documentX() const;
int documentY() const;
QTextFormatCollection *formatCollection() const;
QTextFormatter *formatter() const;
virtual int nextTab( int i, int x );
int *tabArray() const;
void setTabArray( int *a );
void setTabStops( int tw );
void adjustToPainter( QPainter *p );
void setNewLinesAllowed( bool b );
bool isNewLinesAllowed() const;
QString richText() const;
void addCommand( QTextCommand *cmd );
QTextCursor *undo( QTextCursor *c = 0 );
QTextCursor *redo( QTextCursor *c = 0 );
QTextCommandHistory *commands() const;
virtual void copyParagData( QTextParagraph *parag );
void setBreakable( bool b ) { breakable = b; }
bool isBreakable() const { return breakable; }
void setBackgroundColor( const QColor &c );
QColor *backgroundColor() const { return bgcol; }
void clearBackgroundColor();
void setMovedDown( bool b ) { movedDown = b; }
bool wasMovedDown() const { return movedDown; }
void setDirection( QChar::Direction d );
QChar::Direction direction() const;
void readStyleInformation( QDataStream& stream );
void writeStyleInformation( QDataStream& stream ) const;
protected:
virtual void drawLabel( QPainter* p, int x, int y, int w, int h, int base, const QColorGroup& cg );
virtual void drawString( QPainter &painter, const QString &str, int start, int len, int xstart,
- int y, int baseLine, int w, int h, int selection,
- QTextStringChar *formatChar, const QColorGroup& cg,
- bool rightToLeft );
+ int y, int baseLine, int w, int h, int selection,
+ QTextStringChar *formatChar, const QColorGroup& cg,
+ bool rightToLeft );
private:
QMap<int, QTextParagraphSelection> &selections() const;
QPtrList<QTextCustomItem> &floatingItems() const;
QBrush backgroundBrush( const QColorGroup&cg ) { if ( bgcol ) return *bgcol; return cg.brush( QColorGroup::Base ); }
void invalidateStyleCache();
QMap<int, QTextLineStart*> lineStarts;
int invalid;
QRect r;
QTextParagraph *p, *n;
void *docOrPseudo;
uint changed : 1;
uint firstFormat : 1;
uint firstPProcess : 1;
uint needPreProcess : 1;
uint fullWidth : 1;
uint lastInFrame : 1;
uint visible : 1;
uint breakable : 1;
uint movedDown : 1;
uint mightHaveCustomItems : 1;
uint hasdoc : 1;
uint litem : 1; // whether the paragraph is a list item
uint rtext : 1; // whether the paragraph needs rich text margin
int align : 4;
int state, id;
QTextString *str;
QMap<int, QTextParagraphSelection> *mSelections;
QPtrList<QTextCustomItem> *mFloatingItems;
QStyleSheetItem::ListStyle lstyle;
short utm, ubm, ulm, urm, uflm, ulinespacing;
int *tArray;
short tabStopWidth;
QTextParagraphData *eData;
short list_val;
QColor *bgcol;
ushort ldepth;
};
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class Q_EXPORT QTextFormatter
{
public:
QTextFormatter();
virtual ~QTextFormatter();
virtual int format( QTextDocument *doc, QTextParagraph *parag, int start, const QMap<int, QTextLineStart*> &oldLineStarts ) = 0;
virtual int formatVertically( QTextDocument* doc, QTextParagraph* parag );
bool isWrapEnabled( QTextParagraph *p ) const { if ( !wrapEnabled ) return FALSE; if ( p && !p->isBreakable() ) return FALSE; return TRUE;}
int wrapAtColumn() const { return wrapColumn;}
virtual void setWrapEnabled( bool b );
virtual void setWrapAtColumn( int c );
virtual void setAllowBreakInWords( bool b ) { biw = b; }
bool allowBreakInWords() const { return biw; }
int minimumWidth() const { return thisminw; }
int widthUsed() const { return thiswused; }
static bool isBreakable( QTextString *string, int pos );
protected:
virtual QTextLineStart *formatLine( QTextParagraph *parag, QTextString *string, QTextLineStart *line, QTextStringChar *start,
- QTextStringChar *last, int align = Qt3::AlignAuto, int space = 0 );
+ QTextStringChar *last, int align = Qt3::AlignAuto, int space = 0 );
#ifndef QT_NO_COMPLEXTEXT
virtual QTextLineStart *bidiReorderLine( QTextParagraph *parag, QTextString *string, QTextLineStart *line, QTextStringChar *start,
- QTextStringChar *last, int align, int space );
+ QTextStringChar *last, int align, int space );
#endif
void insertLineStart( QTextParagraph *parag, int index, QTextLineStart *ls );
int thisminw;
int thiswused;
private:
bool wrapEnabled;
int wrapColumn;
bool biw;
#ifdef HAVE_THAI_BREAKS
static QCString *thaiCache;
static QTextString *cachedString;
static ThBreakIterator *thaiIt;
#endif
};
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class Q_EXPORT QTextFormatterBreakInWords : public QTextFormatter
{
public:
QTextFormatterBreakInWords();
virtual ~QTextFormatterBreakInWords() {}
int format( QTextDocument *doc, QTextParagraph *parag, int start, const QMap<int, QTextLineStart*> &oldLineStarts );
};
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class Q_EXPORT QTextFormatterBreakWords : public QTextFormatter
{
public:
QTextFormatterBreakWords();
virtual ~QTextFormatterBreakWords() {}
int format( QTextDocument *doc, QTextParagraph *parag, int start, const QMap<int, QTextLineStart*> &oldLineStarts );
};
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class Q_EXPORT QTextIndent
{
public:
QTextIndent();
virtual ~QTextIndent() {}
virtual void indent( QTextDocument *doc, QTextParagraph *parag, int *oldIndent = 0, int *newIndent = 0 ) = 0;
};
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class Q_EXPORT QTextPreProcessor
{
public:
enum Ids {
- Standard = 0
+ Standard = 0
};
QTextPreProcessor();
virtual ~QTextPreProcessor() {}
virtual void process( QTextDocument *doc, QTextParagraph *, int, bool = TRUE ) = 0;
virtual QTextFormat *format( int id ) = 0;
};
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class Q_EXPORT QTextFormat
{
friend class QTextFormatCollection;
friend class QTextDocument;
public:
enum Flags {
- NoFlags,
- Bold = 1,
- Italic = 2,
- Underline = 4,
- Family = 8,
- Size = 16,
- Color = 32,
- Misspelled = 64,
- VAlign = 128,
- StrikeOut= 256,
- Font = Bold | Italic | Underline | Family | Size | StrikeOut,
- Format = Font | Color | Misspelled | VAlign
+ NoFlags,
+ Bold = 1,
+ Italic = 2,
+ Underline = 4,
+ Family = 8,
+ Size = 16,
+ Color = 32,
+ Misspelled = 64,
+ VAlign = 128,
+ StrikeOut= 256,
+ Font = Bold | Italic | Underline | Family | Size | StrikeOut,
+ Format = Font | Color | Misspelled | VAlign
};
enum VerticalAlignment { AlignNormal, AlignSuperScript, AlignSubScript };
QTextFormat();
virtual ~QTextFormat();
QTextFormat( const QStyleSheetItem *s );
QTextFormat( const QFont &f, const QColor &c, QTextFormatCollection *parent = 0 );
QTextFormat( const QTextFormat &fm );
QTextFormat makeTextFormat( const QStyleSheetItem *style, const QMap<QString,QString>& attr, double scaleFontsFactor ) const;
QTextFormat& operator=( const QTextFormat &fm );
QColor color() const;
QFont font() const;
bool isMisspelled() const;
VerticalAlignment vAlign() const;
int minLeftBearing() const;
int minRightBearing() const;
int width( const QChar &c ) const;
int width( const QString &str, int pos ) const;
int height() const;
int ascent() const;
int descent() const;
int leading() const;
bool useLinkColor() const;
void setBold( bool b );
void setItalic( bool b );
void setUnderline( bool b );
void setStrikeOut( bool b );
void setFamily( const QString &f );
void setPointSize( int s );
void setFont( const QFont &f );
void setColor( const QColor &c );
void setMisspelled( bool b );
void setVAlign( VerticalAlignment a );
bool operator==( const QTextFormat &f ) const;
QTextFormatCollection *parent() const;
QString key() const;
static QString getKey( const QFont &f, const QColor &c, bool misspelled, VerticalAlignment vAlign );
void addRef();
void removeRef();
QString makeFormatChangeTags( QTextFormat* defaultFormat, QTextFormat *f, const QString& oldAnchorHref, const QString& anchorHref ) const;
QString makeFormatEndTags( QTextFormat* defaultFormat, const QString& anchorHref ) const;
static void setPainter( QPainter *p );
static QPainter* painter();
bool fontSizesInPixels() { return usePixelSizes; }
protected:
virtual void generateKey();
private:
void update();
private:
QFont fn;
QColor col;
QFontMetrics fm;
uint missp : 1;
uint linkColor : 1;
uint usePixelSizes : 1;
int leftBearing, rightBearing;
VerticalAlignment ha;
uchar widths[ 256 ];
int hei, asc, dsc;
QTextFormatCollection *collection;
int ref;
QString k;
int logicalFontSize;
int stdSize;
static QPainter *pntr;
};
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#if defined(Q_TEMPLATEDLL)
// MOC_SKIP_BEGIN
Q_TEMPLATE_EXTERN template class Q_EXPORT QDict<QTextFormat>;
// MOC_SKIP_END
#endif
class Q_EXPORT QTextFormatCollection
{
friend class QTextDocument;
friend class QTextFormat;
public:
QTextFormatCollection();
virtual ~QTextFormatCollection();
@@ -1636,381 +1639,381 @@ inline int QTextDocument::rightMargin() const
}
inline void QTextDocument::setRightMargin( int rm )
{
rightmargin = rm;
}
inline QTextPreProcessor *QTextDocument::preProcessor() const
{
return pProcessor;
}
inline void QTextDocument::setPreProcessor( QTextPreProcessor * sh )
{
pProcessor = sh;
}
inline void QTextDocument::setFormatter( QTextFormatter *f )
{
delete pFormatter;
pFormatter = f;
}
inline QTextFormatter *QTextDocument::formatter() const
{
return pFormatter;
}
inline void QTextDocument::setIndent( QTextIndent *i )
{
indenter = i;
}
inline QTextIndent *QTextDocument::indent() const
{
return indenter;
}
inline QColor QTextDocument::selectionColor( int id ) const
{
return selectionColors[ id ];
}
inline bool QTextDocument::invertSelectionText( int id ) const
{
return selectionText[ id ];
}
inline void QTextDocument::setSelectionColor( int id, const QColor &c )
{
selectionColors[ id ] = c;
}
inline void QTextDocument::setInvertSelectionText( int id, bool b )
{
selectionText[ id ] = b;
}
inline QTextFormatCollection *QTextDocument::formatCollection() const
{
return fCollection;
}
inline int QTextDocument::alignment() const
{
return align;
}
inline void QTextDocument::setAlignment( int a )
{
align = a;
}
inline int *QTextDocument::tabArray() const
{
return tArray;
}
inline int QTextDocument::tabStopWidth() const
{
return tStopWidth;
}
inline void QTextDocument::setTabArray( int *a )
{
tArray = a;
}
inline void QTextDocument::setTabStops( int tw )
{
tStopWidth = tw;
}
inline QString QTextDocument::originalText() const
{
if ( oTextValid )
- return oText;
+ return oText;
return text();
}
inline void QTextDocument::setFlow( QTextFlow *f )
{
if ( flow_ )
- delete flow_;
+ delete flow_;
flow_ = f;
}
inline void QTextDocument::takeFlow()
{
flow_ = 0;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
inline QColor QTextFormat::color() const
{
return col;
}
inline QFont QTextFormat::font() const
{
return fn;
}
inline bool QTextFormat::isMisspelled() const
{
return missp;
}
inline QTextFormat::VerticalAlignment QTextFormat::vAlign() const
{
return ha;
}
inline bool QTextFormat::operator==( const QTextFormat &f ) const
{
return k == f.k;
}
inline QTextFormatCollection *QTextFormat::parent() const
{
return collection;
}
inline void QTextFormat::addRef()
{
ref++;
}
inline void QTextFormat::removeRef()
{
ref--;
if ( !collection )
- return;
+ return;
if ( this == collection->defFormat )
- return;
+ return;
if ( ref == 0 )
- collection->remove( this );
+ collection->remove( this );
}
inline QString QTextFormat::key() const
{
return k;
}
inline bool QTextFormat::useLinkColor() const
{
return linkColor;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
inline QTextStringChar &QTextString::at( int i ) const
{
return data[ i ];
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
inline QTextStringChar *QTextParagraph::at( int i ) const
{
return &str->at( i );
}
inline bool QTextParagraph::isValid() const
{
return invalid == -1;
}
inline bool QTextParagraph::hasChanged() const
{
return changed;
}
inline void QTextParagraph::setBackgroundColor( const QColor & c )
{
delete bgcol;
bgcol = new QColor( c );
setChanged( TRUE );
}
inline void QTextParagraph::clearBackgroundColor()
{
delete bgcol; bgcol = 0; setChanged( TRUE );
}
inline void QTextParagraph::append( const QString &s, bool reallyAtEnd )
{
if ( reallyAtEnd )
- insert( str->length(), s );
+ insert( str->length(), s );
else
- insert( QMAX( str->length() - 1, 0 ), s );
+ insert( QMAX( str->length() - 1, 0 ), s );
}
inline QTextParagraph *QTextParagraph::prev() const
{
return p;
}
inline QTextParagraph *QTextParagraph::next() const
{
return n;
}
inline bool QTextParagraph::hasAnySelection() const
{
return mSelections ? !selections().isEmpty() : FALSE;
}
inline void QTextParagraph::setEndState( int s )
{
if ( s == state )
- return;
+ return;
state = s;
}
inline int QTextParagraph::endState() const
{
return state;
}
inline void QTextParagraph::setParagId( int i )
{
id = i;
}
inline int QTextParagraph::paragId() const
{
if ( id == -1 )
- qWarning( "invalid parag id!!!!!!!! (%p)", (void*)this );
+ owarn << "invalid parag id!!!!!!!! (" << (void*)this << ")" << oendl;
return id;
}
inline bool QTextParagraph::firstPreProcess() const
{
return firstPProcess;
}
inline void QTextParagraph::setFirstPreProcess( bool b )
{
firstPProcess = b;
}
inline QMap<int, QTextLineStart*> &QTextParagraph::lineStartList()
{
return lineStarts;
}
inline QTextString *QTextParagraph::string() const
{
return str;
}
inline QTextDocument *QTextParagraph::document() const
{
if ( hasdoc )
- return (QTextDocument*) docOrPseudo;
+ return (QTextDocument*) docOrPseudo;
return 0;
}
inline QTextParagraphPseudoDocument *QTextParagraph::pseudoDocument() const
{
if ( hasdoc )
- return 0;
+ return 0;
return (QTextParagraphPseudoDocument*) docOrPseudo;
}
inline QTextTableCell *QTextParagraph::tableCell() const
{
return hasdoc ? document()->tableCell () : 0;
}
inline QTextCommandHistory *QTextParagraph::commands() const
{
return hasdoc ? document()->commands() : pseudoDocument()->commandHistory;
}
inline int QTextParagraph::alignment() const
{
return align;
}
inline void QTextParagraph::registerFloatingItem( QTextCustomItem *i )
{
floatingItems().append( i );
}
inline void QTextParagraph::unregisterFloatingItem( QTextCustomItem *i )
{
floatingItems().removeRef( i );
}
inline QBrush *QTextParagraph::background() const
{
return tableCell() ? tableCell()->backGround() : 0;
}
inline int QTextParagraph::documentWidth() const
{
return hasdoc ? document()->width() : pseudoDocument()->docRect.width();
}
inline int QTextParagraph::documentVisibleWidth() const
{
return hasdoc ? document()->visibleWidth() : pseudoDocument()->docRect.width();
}
inline int QTextParagraph::documentX() const
{
return hasdoc ? document()->x() : pseudoDocument()->docRect.x();
}
inline int QTextParagraph::documentY() const
{
return hasdoc ? document()->y() : pseudoDocument()->docRect.y();
}
inline void QTextParagraph::setExtraData( QTextParagraphData *data )
{
eData = data;
}
inline QTextParagraphData *QTextParagraph::extraData() const
{
return eData;
}
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
inline void QTextFormatCollection::setDefaultFormat( QTextFormat *f )
{
defFormat = f;
}
inline QTextFormat *QTextFormatCollection::defaultFormat() const
{
return defFormat;
}
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
inline QTextFormat *QTextStringChar::format() const
{
return (type == Regular) ? d.format : d.custom->format;
}
inline QTextCustomItem *QTextStringChar::customItem() const
{
return isCustom() ? d.custom->custom : 0;
}
inline int QTextStringChar::height() const
{
return !isCustom() ? format()->height() : ( customItem()->placement() == QTextCustomItem::PlaceInline ? customItem()->height : 0 );
}
inline int QTextStringChar::ascent() const
diff --git a/noncore/apps/tableviewer/browsekeyentry.cpp b/noncore/apps/tableviewer/browsekeyentry.cpp
index 04e7902..bab9af6 100644
--- a/noncore/apps/tableviewer/browsekeyentry.cpp
+++ b/noncore/apps/tableviewer/browsekeyentry.cpp
@@ -1,242 +1,243 @@
/**********************************************************************
** 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 "browsekeyentry.h"
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+
+/* QT */
#include <qtoolbutton.h>
#include <qwidgetstack.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qpopupmenu.h>
#include <qhbox.h>
#include <qdatetime.h>
-//#include <iostream.h>
-#include <qheader.h>
-// For qWarning(const char *)
/*!
\class TVBrowseKeyEntry
\brief a Widget used enter keys into the TVBrowseViewWidget
The TVBrowseKeyEntry Widget provides the facility to enter
various key types to be search on in the table. The key can be changed
and the entry field will update to the correct sort of widget appropriately
*/
/*!
- Constructs the widget
+ Constructs the widget
*/
TVBrowseKeyEntry::TVBrowseKeyEntry(QWidget *parent, const char *name, WFlags f)
: QWidget(parent, name, f)
{
int stack_elem = 0;
QHBoxLayout *h_layout = new QHBoxLayout(this);
textKey = new QLineEdit(this, 0);
dateKey = new QHBox(this, 0);
dayKey = new QLineEdit(dateKey, 0);
monthKey = new QLineEdit(dateKey, 0);
yearKey = new QLineEdit(dateKey, 0);
timeKey = new QHBox(this, 0);
hourKey = new QLineEdit(timeKey, 0);
minuteKey = new QLineEdit(timeKey, 0);
secondKey = new QLineEdit(timeKey, 0);
resetButton = new QPushButton(this, "reset");
resetButton->setMinimumSize(QSize(50, 0));
resetButton->setText(tr("Reset"));
changeKeyButton = new QToolButton(this, "changekey");
// TODO The icon stuff.
changeKeyButton->setText(tr("key"));
totalKeys = 0;
ts = 0;
keyMenu = new QPopupMenu(this, "keymenu");
ws = new QWidgetStack(this, 0);
ws->addWidget(textKey, stack_elem++);
ws->addWidget(timeKey, stack_elem++);
ws->addWidget(dateKey, stack_elem++);
ws->raiseWidget(0);
-
+
// TODO connect slots and signals....
- connect(changeKeyButton, SIGNAL(clicked()),
+ connect(changeKeyButton, SIGNAL(clicked()),
this, SLOT(changeKeyMenuSlot()));
- connect(resetButton, SIGNAL(clicked()),
+ connect(resetButton, SIGNAL(clicked()),
this, SLOT(resetKeySlot()));
- connect(textKey, SIGNAL(textChanged(const QString&)),
+ connect(textKey, SIGNAL(textChanged(const QString&)),
this, SLOT(searchOnText()));
- connect(dayKey, SIGNAL(textChanged(const QString&)),
+ connect(dayKey, SIGNAL(textChanged(const QString&)),
this, SLOT(searchOnText()));
- connect(monthKey, SIGNAL(textChanged(const QString&)),
+ connect(monthKey, SIGNAL(textChanged(const QString&)),
this, SLOT(searchOnText()));
- connect(yearKey, SIGNAL(textChanged(const QString&)),
+ connect(yearKey, SIGNAL(textChanged(const QString&)),
this, SLOT(searchOnText()));
- connect(secondKey, SIGNAL(textChanged(const QString&)),
+ connect(secondKey, SIGNAL(textChanged(const QString&)),
this, SLOT(searchOnText()));
- connect(minuteKey, SIGNAL(textChanged(const QString&)),
+ connect(minuteKey, SIGNAL(textChanged(const QString&)),
this, SLOT(searchOnText()));
- connect(hourKey, SIGNAL(textChanged(const QString&)),
+ connect(hourKey, SIGNAL(textChanged(const QString&)),
this, SLOT(searchOnText()));
-
+
h_layout->addWidget(ws);
h_layout->addWidget(resetButton);
h_layout->addWidget(changeKeyButton);
}
/*!
- Destructs the widget
+ Destructs the widget
*/
TVBrowseKeyEntry::~TVBrowseKeyEntry()
{
}
/*!
Changes which key the user intends to search on
\param id_param the index of the key future searches should be base on
*/
void TVBrowseKeyEntry::changeKeySlot(int id_param)
{
emit sortChanged(id_param);
switch(ts->kRep->getKeyType(ts->current_column)) {
/* work out what to raise */
case kt_string:
case kt_int:
ws->raiseWidget(0);
break;
case kt_time:
ws->raiseWidget(1);
break;
case kt_date:
ws->raiseWidget(2);
break;
- default:
- return;
+ default:
+ return;
}
}
/*!
Opens the change key menu
*/
void TVBrowseKeyEntry::changeKeyMenuSlot()
{
- if(ts)
+ if(ts)
keyMenu->exec(changeKeyButton->mapToGlobal(QPoint(0,0)));
}
/*!
Blanks the key entry widget
\TODO the actual implmentation
*/
void TVBrowseKeyEntry::resetKeySlot() {
;
}
void TVBrowseKeyEntry::setTableState(TableState *t) {
int i;
ts = t;
/* clear the old */
keyMenu->clear();
for (i = 0; i < t->kRep->getNumFields(); i++) {
- keyMenu->insertItem(ts->kRep->getKeyName(i), this,
+ keyMenu->insertItem(ts->kRep->getKeyName(i), this,
SLOT(changeKeySlot(int)), 0, i);
keyMenu->setItemParameter(i, i);
}
}
/*!
- Searches on the current value of the key entry provided that the
- current key is of type text WARNING, TODO fix memory leaks
+ Searches on the current value of the key entry provided that the
+ current key is of type text WARNING, TODO fix memory leaks
*/
void TVBrowseKeyEntry::searchOnText()
{
void *sendkey;
int tmp;
switch(ts->kRep->getKeyType(ts->current_column)) {
/* work out what to raise */
case kt_string:
sendkey = (void *)new QString(textKey->text());
break;
case kt_int: {
bool ok;
tmp = textKey->text().toInt(&ok);
sendkey = &tmp;
if (!ok)
return;
break;
}
case kt_time: {
bool ok;
int s,m,h;
s = secondKey->text().toInt(&ok);
if (!ok)
return;
m = minuteKey->text().toInt(&ok);
if (!ok)
return;
h = hourKey->text().toInt(&ok);
if (!ok)
return;
if(!QTime::isValid(h, m, s))
return;
sendkey = (void *) new QTime(h, m, s);
break;
}
case kt_date: {
bool ok;
int d,m,y;
d = dayKey->text().toInt(&ok);
if (!ok)
return;
m = monthKey->text().toInt(&ok);
if (!ok)
return;
y = yearKey->text().toInt(&ok);
if (!ok)
return;
if(!QDate::isValid(y, m, d))
return;
sendkey = (void *) new QDate(y, m, d);
break;
}
default:
- qWarning("TVBrowseKeyEntry::searchOnText() "
- "cannot work out data type");
+ owarn << "TVBrowseKeyEntry::searchOnText() cannot work out data type" << oendl;
return;
}
emit searchOnKey(ts->current_column, sendkey);
}
/*! \fn void TVBrowseKeyEntry::searchOnKey(int currentKeyId, void *v)
This signal indicates that a search on key index currentKeyId should be
done searching for the value v.
-*/
+*/
diff --git a/noncore/apps/tableviewer/db/common.cpp b/noncore/apps/tableviewer/db/common.cpp
index b58af85..c35dbea 100644
--- a/noncore/apps/tableviewer/db/common.cpp
+++ b/noncore/apps/tableviewer/db/common.cpp
@@ -1,193 +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 "common.h"
+**********************************************************************/
+#include "common.h"
#include "datacache.h"
/* OPIE */
#include <opie2/odebug.h>
#include <qpe/timestring.h>
using namespace Opie::Core;
/* QT */
#include <qstring.h>
#include <qheader.h>
#include <qvector.h>
#include <qdatetime.h>
/* STD */
#include <assert.h>
#include <stdlib.h>
static const int del_flag = 0x1;
static const int new_flag = 0x2;
/* Helper function */
int parseNextNumber(QString *q) {
QChar c;
uint i;
int result = 0;
bool found_digits = FALSE;
for(i = 0; i < q->length(); i++) {
c = q->at(i);
if (c.isDigit()) {
if (found_digits)
result *= 10;
found_digits = TRUE;
result += c.digitValue();
} else {
if (found_digits)
break;
/* just skip this char */
}
}
/* now truncate q */
if (found_digits)
q->remove(0, i);
return result;
}
/*!
\class QStringVector
\brief A Vector of QStrings that can be sorted and searched
Implmented in order to allow reverse lookup on the string name
*/
/*!
This function implements the compare function in order to allow the
searching and sorting of the QStringVector to occur
\returns an int which is either
<UL>
<LI> < 0 if the first string is smaller than the second,</LI>
<LI> > 0 if the first string is bigger then the second,</LI>
<LI> == 0 if the first string is equal to the second.</LI>
</UL>
*/
int QStringVector::compareItems(Item a, Item b)
{
QString *qa = (QString *)a;
QString *qb = (QString *)b;
-
+
return QString::compare(*qa, *qb);
}
/*!
\class TVVariant
- A way of abstracting void * and keeping information on
+ A way of abstracting void * and keeping information on
the keytypes and behaviours in one place
*/
TVVariantPrivate::TVVariantPrivate()
{
typ = TVVariant::Invalid;
}
TVVariantPrivate::TVVariantPrivate( TVVariantPrivate *d)
{
switch(d->typ)
{
case TVVariant::Invalid:
break;
case TVVariant::String:
value.ptr = new QString(*((QString *)d->value.ptr));
break;
case TVVariant::Date:
value.ptr = new QDate(*((QDate *)d->value.ptr));
break;
case TVVariant::Time:
value.ptr = new QTime(*((QTime *)d->value.ptr));
break;
case TVVariant::Int:
value.i = d->value.i;
break;
default:
ASSERT( 0 );
}
typ = d->typ;
}
TVVariantPrivate::~TVVariantPrivate()
{
clear();
}
void TVVariantPrivate::clear()
{
switch( typ )
{
case TVVariant::String:
delete (QString *)value.ptr;
break;
case TVVariant::Date:
delete (QDate *)value.ptr;
break;
case TVVariant::Time:
delete (QTime *)value.ptr;
break;
case TVVariant::Invalid:
case TVVariant::Int:
break;
}
typ = TVVariant::Invalid;
}
/*!
\class TVVariant
blah
*/
TVVariant::TVVariant()
{
d = new TVVariantPrivate;
}
TVVariant::~TVVariant()
{
if (d->deref())
delete d;
}
TVVariant::TVVariant(const TVVariant& p)
{
d = new TVVariantPrivate;
*this = p;
}
TVVariant::TVVariant(QDataStream& s)
{
d = new TVVariantPrivate;
s >> *this;
}
TVVariant::TVVariant(const QString &val)
{
d = new TVVariantPrivate;
d->typ = String;
d->value.ptr = new QString(val);
}
TVVariant::TVVariant(const QDate &val)
{
@@ -227,1252 +227,1249 @@ void TVVariant::detach()
{
if (d->count == 1)
return;
d->deref();
d = new TVVariantPrivate(d);
}
const QString TVVariant::typeName() const
{
return typeToName(d->typ);
}
void TVVariant::clear()
{
if (d->count > 1)
{
d->deref();
d = new TVVariantPrivate;
return;
}
d->clear();
}
const QString TVVariant::typeToName(KeyType typ)
{
switch(typ) {
case String:
return QString("String");
case Date:
return QString("Date");
case Time:
return QString("Time");
case Int:
return QString("Int");
case Invalid:
default:
return QString("Invalid");
}
return QString("Invalid");
}
TVVariant::KeyType TVVariant::nameToType(const QString &name)
{
if(!qstrcmp("String", name))
return String;
if(!qstrcmp("Date", name))
return Date;
if(!qstrcmp("Time", name))
return Time;
if(!qstrcmp("Int", name))
return Int;
return Invalid;
}
void TVVariant::load(QDataStream &s )
{
KeyType t;
s >> t;
d->typ = t;
switch(t) {
case Invalid:
d->typ = t;
break;
case String:
{
QString *x = new QString;
s >> *x;
d->value.ptr = x;
}
break;
case Time:
{
QTime *x = new QTime;
s >> *x;
d->value.ptr = x;
}
break;
case Date:
{
QDate *x = new QDate;
s >> *x;
d->value.ptr = x;
}
break;
case Int:
{
int x;
s >> x;
d->value.i = x;
}
break;
default:
- ofatal << "Unrecognized data type" << oendl;
+ ofatal << "Unrecognized data type" << oendl;
}
}
void TVVariant::save( QDataStream &s ) const
{
s << type();
switch( d->typ ) {
case String:
s << *((QString *)d->value.ptr);
break;
case Date:
s << *((QDate *)d->value.ptr);
break;
case Time:
s << *((QTime *)d->value.ptr);
break;
case Int:
s << d->value.i;
break;
case Invalid:
break;
}
}
QDataStream& operator>>(QDataStream& s, TVVariant& p)
{
p.load( s );
return s;
}
QDataStream& operator<<(QDataStream &s, const TVVariant& p)
{
p.save( s );
return s;
}
QDataStream& operator>> (QDataStream &s, TVVariant::KeyType& p)
{
Q_UINT8 u = 0;
s >> u;
p = (TVVariant::KeyType) u;
return s;
}
QDataStream& operator<< (QDataStream& s, const TVVariant::KeyType& p)
{
s << (Q_UINT8)p;
return s;
}
const QString TVVariant::toString() const
{
switch(d->typ) {
case String:
return *((QString*)d->value.ptr);
case Date:
return ((QDate*)d->value.ptr)->toString();
case Time:
return ((QTime*)d->value.ptr)->toString();
- case Int:
+ case Int:
return QString::number(d->value.i);
case Invalid:
default:
return QString::null;
}
return QString::null;
}
// TODO DO, this properly, */
int TVVariant::toInt() const
{
if(d->typ == Int)
return d->value.i;
if(d->typ == String) {
QString tmpq(*(QString *)d->value.ptr);
return parseNextNumber(&tmpq);
}
return 0;
}
const QDate TVVariant::toDate() const
{
if(d->typ == Date)
return *((QDate *)d->value.ptr);
if(d->typ == String) {
QString q = toString();
/* date format is day mon d yyyy */
/* ignore the first three letters, read the next
three for month.. etc */
int day = parseNextNumber(&q);
int month = parseNextNumber(&q);
int year = parseNextNumber(&q);
if (!QDate::isValid(year, month, day))
return QDate();
return QDate(year, month, day);
}
-
+
return QDate();
}
const QTime TVVariant::toTime() const
{
if(d->typ == Time)
return *((QTime *)d->value.ptr);
-
+
if(d->typ == String) {
QString q = toString();
int hour = parseNextNumber(&q);
int minute = parseNextNumber(&q);
int second = parseNextNumber(&q);
int msecond = parseNextNumber(&q);
if (!QTime::isValid(hour, minute, second, msecond))
return QTime();
return QTime(hour, minute, second, msecond);
}
return QTime();
}
#define TV_VARIANT_AS( f ) Q##f& TVVariant::as##f() { \
if ( d->typ != f ) \
*this = TVVariant( to##f() ); \
else \
detach(); \
return *((Q##f*)d->value.ptr); }
-
+
TV_VARIANT_AS(String)
TV_VARIANT_AS(Date)
TV_VARIANT_AS(Time)
#undef TV_VARIANT_AS
int& TVVariant::asInt()
{
detach();
if (d->typ != Int) {
d->value.i = toInt();
d->typ = Int;
}
return d->value.i;
}
/*!
valid cast is
anything to String
same to same
*/
bool TVVariant::canCast(KeyType t) const
{
if(d->typ == t)
return TRUE;
if(t == String)
return TRUE;
if(t == Int) {
if (d->typ == Date)
return TRUE;
if (d->typ == Time)
return TRUE;
if (d->typ == String)
return TRUE;
}
return FALSE;
}
bool TVVariant::operator==( const TVVariant &v ) const
{
switch(d->typ) {
case String:
return v.toString() == toString();
case Date:
return v.toDate() == toDate();
case Time:
return v.toTime() == toTime();
case Int:
return v.toInt() == toInt();
case Invalid:
break;
}
return FALSE;
}
bool TVVariant::operator!=( const TVVariant &v ) const
{
return !( v == *this);
}
bool TVVariant::operator<( const TVVariant &v ) const
{
switch(d->typ) {
case String:
return toString().lower() < v.toString().lower();
case Date:
return toDate() < v.toDate();
case Time:
return toTime() < v.toTime();
case Int:
return toInt() < v.toInt();
case Invalid:
default:
break;
}
return FALSE;
}
bool TVVariant::operator>( const TVVariant &v ) const
{
switch(d->typ) {
case String:
return toString().lower() > v.toString().lower();
case Date:
return toDate() > v.toDate();
case Time:
return toTime() > v.toTime();
case Int:
return toInt() > v.toInt();
case Invalid:
default:
break;
}
return FALSE;
}
/*! True if n is closer to this than o */
bool TVVariant::closer(TVVariant n, TVVariant o)
{
/* Nothing is close to an invalid, so nothing can be closer */
if(d->typ == Invalid)
- return FALSE;
+ return FALSE;
/* can't be closer if of different type */
if(n.type() != type())
return FALSE;
/* if new shares type, and old doesn't, then new is closer */
if(o.type() != type())
return TRUE;
switch(type()){
case String: {
- /* case for strings is close is a substring.. closer is
+ /* case for strings is close is a substring.. closer is
* earlier alphabetically */
QString qs1 = n.toString().lower();
QString qs2 = o.toString().lower();
QString qsv = toString().lower();
if (!qs1.startsWith(qsv))
return FALSE;
/* contains sub-str, if later than is not closer */
- if(QString::compare(qs1, qs2) > 0)
+ if(QString::compare(qs1, qs2) > 0)
return FALSE;
return TRUE;
}
case Int: {
/* case for int is smallest absolute difference */
int i1 = n.toInt();
int i2 = o.toInt();
int iv = toInt();
int diff1 = (i1 - iv);
- if (diff1 < 0)
+ if (diff1 < 0)
diff1 = -diff1;
int diff2 = (i2 - iv);
- if (diff2 < 0)
+ if (diff2 < 0)
diff2 = -diff2;
- if (diff1 < diff2)
+ if (diff1 < diff2)
return TRUE;
return FALSE;
}
case Date: {
QDate i1 = n.toDate();
QDate i2 = o.toDate();
QDate iv = toDate();
/* definition of closer is the least difference in days */
int diff1 = i1.daysTo(iv);
- if (diff1 < 0)
+ if (diff1 < 0)
diff1 = -diff1;
int diff2 = i2.daysTo(iv);
- if (diff2 < 0)
+ if (diff2 < 0)
diff2 = -diff2;
if (diff1 < diff2)
return TRUE;
return FALSE;
}
case Time: {
QTime i1 = n.toTime();
QTime i2 = o.toTime();
QTime iv = toTime();
/* definition of closer is the least difference in days */
int diff1 = i1.msecsTo(iv);
- if (diff1 < 0)
+ if (diff1 < 0)
diff1 = -diff1;
int diff2 = i2.msecsTo(iv);
- if (diff2 < 0)
+ if (diff2 < 0)
diff2 = -diff2;
if (diff1 < diff2)
return TRUE;
return FALSE;
}
default:
/* don't know how to do 'closer' on this type, hence never closer
* or even close */
break;
}
return FALSE;
}
/*! True if n is close to this */
bool TVVariant::close(TVVariant n)
{
/* Nothing is close to an invalid, so nothing can be closer */
if(type() == Invalid)
- return FALSE;
+ return FALSE;
/* can't be close if of different type */
if(n.type() != type())
return FALSE;
switch(type()){
case String: {
- /* case for strings is close is a substring.. closer is
+ /* case for strings is close is a substring.. closer is
* earlier alphabetically */
QString qs1 = n.toString().lower();
QString qsv = toString().lower();
if (!qs1.startsWith(qsv))
return FALSE;
return TRUE;
}
- case Int:
+ case Int:
case Date:
case Time:
return TRUE;
default:
/* don't know how to do 'closer' on this type, hence never closer
* or even close */
break;
}
return FALSE;
}
/*!
\class Key
\brief document me!
-
+
document me!
*/
Key::Key() : kname(), kexample(), kflags(0) { }
Key::Key(QString name, TVVariant example, int flags) :
- kname(name), kexample(example), kflags(flags) { }
+ kname(name), kexample(example), kflags(flags) { }
Key::Key(const Key &other)
{
kname = other.kname;
kexample = other.kexample;
kflags = other.kflags;
}
-Key& Key::operator=(const Key& key)
+Key& Key::operator=(const Key& key)
{
kname = key.kname;
kexample = key.kexample;
kflags = key.kflags;
return *this;
}
QString Key::name() const
{
return QString(kname);
}
TVVariant Key::example() const
{
return TVVariant(kexample);
}
TVVariant::KeyType Key::type() const
{
return kexample.type();
}
void Key::setName(const QString &name)
{
kname = QString(name);
}
void Key::setExample(const TVVariant &e)
{
kexample = TVVariant(e);
}
int Key::flags() const
{
return kflags;
}
void Key::setFlags(int fl)
{
kflags = fl;
}
bool Key::delFlag() const
{
if(kflags & del_flag)
return TRUE;
return FALSE;
}
bool Key::newFlag() const
{
if(kflags & new_flag)
return TRUE;
return FALSE;
}
void Key::setDelFlag(bool v)
{
if(delFlag() != v)
kflags = kflags ^ del_flag;
}
void Key::setNewFlag(bool v)
{
if(newFlag() != v)
kflags = kflags ^ new_flag;
}
/*!
\class KeyList
\brief A represntation of keys used for a table.
The KeyList class is used to store the representation of keys used in table
headings by DBStore. It stores the names and types of the keys
*/
/*!
Constructs a KeyList
*/
-KeyList::KeyList() : QIntDict<Key>(20)
+KeyList::KeyList() : QIntDict<Key>(20)
{
setAutoDelete(TRUE);
}
/* Should be deep copy, but isn't */
-KeyList::KeyList(const KeyList &k) : QIntDict<Key>(k)
+KeyList::KeyList(const KeyList &k) : QIntDict<Key>(k)
{
KeyListIterator it(k);
while(it.current()) {
replace(it.currentKey(), new Key(*it.current()));
++it;
}
setAutoDelete(TRUE);
}
/*!
Destroys a KeyList
*/
KeyList::~KeyList() {
}
/* Do a comparision base on Keys */
bool KeyList::operator!=(const KeyList &other)
{
KeyListIterator it(*this);
if (other.getNumFields() != getNumFields())
return TRUE;
while(it.current()) {
//it.currentKey(), it.current();
if (other.getKeyName(it.currentKey()) != getKeyName(it.currentKey()))
return TRUE;
if (other.getKeyType(it.currentKey()) != getKeyType(it.currentKey()))
return TRUE;
++it;
}
return FALSE;
}
/*!
Returns the number of keys stored in the KeyList
*/
-int KeyList::getNumFields() const
+int KeyList::getNumFields() const
{
return count();
}
/*!
Adds a new key to the KeyList
\param name the name of the new key
\param type the type of the new key
*/
int KeyList::addKey(QString name, TVVariant example)
{
int i = count();
while(find(i) && (i > -1))
i--;
replace(i, new Key(name, example, 0));
return i;
}
int KeyList::addKey(QString name, TVVariant::KeyType type)
{
/* generate a valid type for the example? */
TVVariant e = TVVariant("0");
switch(type) {
- case TVVariant::String:
+ case TVVariant::String:
return addKey(name, TVVariant("<undefined>").asString());
break;
- case TVVariant::Date:
+ case TVVariant::Date:
return addKey(name, TVVariant(QDate::currentDate()).asDate());
break;
- case TVVariant::Time:
+ case TVVariant::Time:
return addKey(name, TVVariant(QTime(0,0,0)).toTime());
break;
- case TVVariant::Int:
+ case TVVariant::Int:
return addKey(name, TVVariant(0).toInt());
break;
default:
- qWarning(QObject::tr("KeyList::addKey() Cannot make default "
- "value for type %1, Key not added.").arg(type));
+ owarn << "KeyList::addKey() Cannot make default value for type " << type << ", Key not added." << oendl;
break;
}
return -1;
}
-void KeyList::setKeyFlags(int i, int flag)
+void KeyList::setKeyFlags(int i, int flag)
{
if(find(i))
find(i)->setFlags(flag);
}
int KeyList::getKeyFlags(int i) const
{
if(find(i))
return find(i)->flags();
return 0;
}
-bool KeyList::checkNewFlag(int i) const
+bool KeyList::checkNewFlag(int i) const
{
if (find(i))
return find(i)->newFlag();
return false;
}
-void KeyList::setNewFlag(int i, bool f)
+void KeyList::setNewFlag(int i, bool f)
{
if(!find(i))
return;
find(i)->setNewFlag(f);
}
-bool KeyList::checkDeleteFlag(int i) const
+bool KeyList::checkDeleteFlag(int i) const
{
if (find(i))
return find(i)->delFlag();
return false;
}
-void KeyList::setDeleteFlag(int i, bool f)
+void KeyList::setDeleteFlag(int i, bool f)
{
if(!find(i))
return;
find(i)->setDelFlag(f);
}
/*!
Returns the name of the key at index i
*/
QString KeyList::getKeyName(int i) const
{
if (find (i))
return find(i)->name();
return QString();
}
-void KeyList::setKeyName(int i, const QString &n)
+void KeyList::setKeyName(int i, const QString &n)
{
if(find(i))
find(i)->setName(n);
}
/*!
Returns the type of the key at index i
*/
TVVariant::KeyType KeyList::getKeyType(int i) const
{
if(find(i))
return find(i)->type();
return TVVariant::Invalid;
}
-void KeyList::setKeyType(int i, TVVariant::KeyType t)
+void KeyList::setKeyType(int i, TVVariant::KeyType t)
{
if(!find(i))
return;
switch(t) {
case TVVariant::String:
find(i)->setExample(TVVariant(QString("default")));
return;
case TVVariant::Int:
find(i)->setExample(TVVariant(int(0)));
return;
case TVVariant::Date:
find(i)->setExample(TVVariant(QDate::currentDate()));
return;
case TVVariant::Time:
find(i)->setExample(TVVariant(QTime(0,0,0,0)));
return;
default:
break;
}
return;
}
TVVariant KeyList::getKeyExample(int i) const
{
if(find(i))
return find(i)->example();
return TVVariant();
}
void KeyList::setKeyExample(int i, TVVariant example)
{
if(find(i))
find(i)->setExample(example);
}
/*!
Returns the index of the key with name q
*/
int KeyList::getKeyIndex(QString q) const
{
KeyListIterator it(*this);
while(it.current()) {
if(it.current()->name() == q)
return it.currentKey();
++it;
}
return -1;
}
bool KeyList::validIndex(int i) const
{
if(!find(i))
return FALSE;
if(find(i)->delFlag())
return FALSE;
return TRUE;
}
QDataStream &operator<<( QDataStream &s, const KeyList &k)
{
s << k.getNumFields();
KeyListIterator it(k);
while(it.current()) {
s << (Q_UINT16)it.currentKey();
s << it.current()->name();
s << it.current()->example();
s << (Q_UINT16)it.current()->flags();
++it;
}
return s;
}
QDataStream &operator>>( QDataStream &s, KeyList &k)
{
int i;
int size;
int index = 0;
int flags = 0;
TVVariant type = TVVariant();
QString name;
s >> size;
for (i=0; i < size; i++) {
s >> (Q_UINT16 &)index;
s >> name;
s >> type;
s >> (Q_UINT16 &)flags;
k.replace(index, new Key(name, type, flags));
}
return s;
}
/*!
\class DataElem
\brief A class representing a single row or element of a table in a DBStore
This class holds the data of a row in a table.
*/
/*!
- Constructs a DataElem. This function needs a container because the
- size, types of keys and primary key are all defined by the containing
- database
+ Constructs a DataElem. This function needs a container because the
+ size, types of keys and primary key are all defined by the containing
+ database
*/
DataElem::DataElem(DBStore *c) : values(20)
{
int size;
contained = c;
size = c->getNumFields();
values.setAutoDelete(TRUE);
}
/*!
Destroys a DataElem and frees memory used by the DataElem
*/
DataElem::~DataElem() {
}
QDataStream &operator<<( QDataStream &s, const DataElem &d)
{
int size = d.getNumFields();
s << size; /* redundent data but makes streaming easier */
KeyList k = d.getKeys();
KeyListIterator it(k);
while(it.current()) {
s << (Q_UINT16)it.currentKey();
s << d.getField(it.currentKey());
++it;
}
return s;
}
QDataStream &operator>>( QDataStream &s, DataElem &d)
{
int i;
int size;
TVVariant t;
Q_UINT16 index = 0;
s >> size; /* redundent data but makes streaming easier */
if (size != d.getNumFields()) {
- owarn << "DataSize mis-match" << oendl;
+ owarn << "DataSize mis-match" << oendl;
return s; /* sanity check failed.. don't load */
}
for(i = 0; i < size; i++) {
s >> index;
s >> t;
d.setField(index, t);
}
return s;
}
/*! Returns the number of possible (not valid) fields in the data element */
int DataElem::getNumFields() const
{
return contained->getNumFields();
}
KeyList DataElem::getKeys() const
{
return *(contained->getKeys());
}
-/*!
+/*!
This function determines whether field index i of the element has been
set yet.
- \return A boolean value that is TRUE if the specfied field of this
- element has been set and FALSE if the field has not yet been set
+ \return A boolean value that is TRUE if the specfied field of this
+ element has been set and FALSE if the field has not yet been set
*/
bool DataElem::hasValidValue(int i) const
{
if(!values.find(i))
return FALSE;
- if(!contained->getKeys()->validIndex(i))
+ if(!contained->getKeys()->validIndex(i))
return FALSE;
return values.find(i)->isValid();
}
-/*!
+/*!
This function determines whether field name qs of the element has been
set yet.
- \return A boolean value that is TRUE if the specfied field of this
- element has been set and FALSE if the field has not yet been set
+ \return A boolean value that is TRUE if the specfied field of this
+ element has been set and FALSE if the field has not yet been set
*/
-bool DataElem::hasValidValue(QString qs) const
+bool DataElem::hasValidValue(QString qs) const
{
int i = contained->getKeyIndex(qs);
return hasValidValue(i);
}
/*! returns the type of the field specified by index i */
-TVVariant::KeyType DataElem::getFieldType(int i) const
+TVVariant::KeyType DataElem::getFieldType(int i) const
{
return contained->getKeyType(i);
}
/*! returns the type of the field specified by name qs */
TVVariant::KeyType DataElem::getFieldType(QString qs) const
{
int i = contained->getKeyIndex(qs);
return contained->getKeyType(i);
}
-/*!
- returns a pointer to the data stored in field index i for this
- data element, (value may not be valid)
+/*!
+ returns a pointer to the data stored in field index i for this
+ data element, (value may not be valid)
*/
TVVariant DataElem::getField(int i) const
{
if(hasValidValue(i))
return TVVariant(*values.find(i));
return TVVariant();
}
-/*!
- returns a pointer to the data stored in field name qs for this
- data element, (value may not be valid)
+/*!
+ returns a pointer to the data stored in field name qs for this
+ data element, (value may not be valid)
*/
TVVariant DataElem::getField(QString qs) const
{
int i = contained->getKeyIndex(qs);
return getField(i);
}
/*!
Sets the value of the elements field index i to the value represented in
the QString q.
\param i index of the field to set
\param q a string that can be parsed to get the value to be set
*/
-void DataElem::setField(int i, QString q)
+void DataElem::setField(int i, QString q)
{
/* from the type of the field, parse q and store */
TVVariant::KeyType kt = contained->getKeyType(i);
TVVariant t = TVVariant(q);
switch(kt) {
case TVVariant::Int: {
t.asInt();
setField(i, t);
return;
}
case TVVariant::String: {
t.asString();
setField(i, t);
return;
}
case TVVariant::Date: {
t.asDate();
setField(i, t);
return;
}
case TVVariant::Time: {
t.asTime();
setField(i, t);
return;
}
default:
- qWarning(
- QObject::tr("DataElem::setField(%1, %2) No valid type found").arg(i).arg(q)
- );
+ owarn << "DataElem::setField(" << i << ", " << q << ") No valid type found" << oendl;
}
}
/*!
Sets the value of the elements field index i to the value at the pointer
value.
\param i index of the field to set
- \param value a pointer to the (already allocated) value to set
+ \param value a pointer to the (already allocated) value to set
*/
-void DataElem::setField(int i, TVVariant value)
+void DataElem::setField(int i, TVVariant value)
{
if (value.isValid()) {
values.remove(i);
values.replace(i, new TVVariant(value));
}
}
/*!
Sets the value of the elements field name qs to the value represented in
the QString q.
\param qs name of the field to set
\param q a string that can be parsed to get the value to be set
*/
-void DataElem::setField(QString qs, QString q)
+void DataElem::setField(QString qs, QString q)
{
/* from the type of the field, parse q and store */
int i = contained->getKeyIndex(qs);
setField(i, qs);
}
/*!
Sets the value of the elements field name qs to the value at the pointer
value.
\param qs name of the field to set
- \param value a pointer to the (already allocated) value to set
+ \param value a pointer to the (already allocated) value to set
*/
void DataElem::setField(QString qs, TVVariant value)
{
int i = contained->getKeyIndex(qs);
setField(i, value);
}
void DataElem::unsetField(int i) {
values.remove(i);
}
void DataElem::unsetField(QString qs)
{
int i = contained->getKeyIndex(qs);
unsetField(i);
}
/*!
- Converts the data element to a Rich Text QString
+ Converts the data element to a Rich Text QString
*/
QString DataElem::toQString() const
{
/* lets make an attempt at this function */
int i;
QString scratch = "";
QIntDictIterator<TVVariant> it(values);
while (it.current()) {
i = it.currentKey();
if(hasValidValue(i)) {
scratch += "<B>" + contained->getKeyName(i) + ":</B> ";
scratch += getField(i).toString();
scratch += "<br>";
}
++it;
}
return scratch;
}
/*! formats individual fields to strings so can be displayed */
-QString DataElem::toQString(int i) const
+QString DataElem::toQString(int i) const
{
if(hasValidValue(i)) {
return getField(i).toString();
}
return "";
}
/*! formats individual fields to strings so can be sorted by QListView */
-QString DataElem::toSortableQString(int i) const
+QString DataElem::toSortableQString(int i) const
{
QString scratch = "";
if(hasValidValue(i)) {
switch (contained->getKeyType(i)) {
case TVVariant::String: {
scratch += getField(i).toString();
break;
}
case TVVariant::Int: {
scratch.sprintf("%08d", getField(i).toInt());
break;
}
case TVVariant::Date: {
static QDate epochD(1800, 1, 1);
- scratch.sprintf("%08d",
+ scratch.sprintf("%08d",
epochD.daysTo(getField(i).toDate()));
break;
}
case TVVariant::Time: {
static QTime epochT(0, 0, 0);
- scratch.sprintf("%08d",
+ scratch.sprintf("%08d",
epochT.msecsTo(getField(i).toTime()));
break;
}
default:
scratch += "Unknown type";
break;
}
}
return scratch;
}
/* compare functions */
bool DataElem::lessThan(int i, TVVariant v) const
{
if (!hasValidValue(i)) return FALSE;
if (getField(i).type() != v.type())
return FALSE;
return (getField(i) < v);
}
bool DataElem::moreThan(int i, TVVariant v) const
{
if (!hasValidValue(i)) return FALSE;
if (getField(i).type() != v.type())
return FALSE;
return (getField(i) > v);
}
bool DataElem::equalTo(int i, TVVariant v) const
{
if (!hasValidValue(i)) return FALSE;
if (getField(i).type() != v.type())
return FALSE;
return (getField(i) == v);
}
bool DataElem::contains(int i, TVVariant v) const
{
if (!hasValidValue(i)) return FALSE;
if (getField(i).type() != v.type())
return FALSE;
switch(getField(i).type()) {
case TVVariant::String: {
QString qs1 = getField(i).toString().lower();
QString qs2 = v.toString().lower();
if (qs1.contains(qs2) > 0) return TRUE;
break;
}
/* meaningless for ints */
/* meaningless for time */
/* meaningless for dates */
- case TVVariant::Int:
+ case TVVariant::Int:
case TVVariant::Time:
case TVVariant::Date:
break;
default:
- owarn << "Tried to compare unknown data type" << oendl;
+ owarn << "Tried to compare unknown data type" << oendl;
}
return FALSE;
}
bool DataElem::startsWith(int i, TVVariant v) const
{
if (!hasValidValue(i)) return FALSE;
if (getField(i).type() != v.type())
return FALSE;
switch(getField(i).type()) {
case TVVariant::String: {
QString qs1 = getField(i).toString().lower();
QString qs2 = v.toString().lower();
return qs1.startsWith(qs2);
}
/* meaningless for ints */
/* meaningless for time */
/* meaningless for dates */
- case TVVariant::Int:
+ case TVVariant::Int:
case TVVariant::Time:
case TVVariant::Date:
return FALSE;
default:
- owarn << "Tried to compare unknown data type" << oendl;
+ owarn << "Tried to compare unknown data type" << oendl;
}
return FALSE;
}
bool DataElem::endsWith(int i, TVVariant v) const
{
if (!hasValidValue(i)) return FALSE;
if (getField(i).type() != v.type())
return FALSE;
switch(getField(i).type()) {
case TVVariant::String: {
QString qs1 = getField(i).toString().lower();
QString qs2 = v.toString().lower();
return qs1.startsWith(qs2);
}
/* meaningless for ints */
/* meaningless for time */
/* meaningless for dates */
- case TVVariant::Int:
+ case TVVariant::Int:
case TVVariant::Time:
case TVVariant::Date:
return FALSE;
default:
- owarn << "Tried to compare unknown data type" << oendl;
+ owarn << "Tried to compare unknown data type" << oendl;
}
return FALSE;
}
/*!
Determins which of the first to parameters are closer to the third, target
parameter.
- \return
+ \return
<UL>
- <LI>TRUE if the first element is a closer match to the target than the
+ <LI>TRUE if the first element is a closer match to the target than the
second element</LI>
<LI>FALSE if the first element is not a closer match to the target than
the second element</LI>
</UL>
*/
bool DataElem::closer(DataElem*d1, DataElem *d2, TVVariant target, int column)
{
- int type;
+ int type;
if(!d1) return FALSE;
if (!d1->hasValidValue(column)) return FALSE;
if(!target.isValid()) return FALSE;
type = d1->getField(column).type();
if(d2) {
if (type != d2->getField(column).type()) {
/* can't do compare */
- owarn << "Tried to compare two incompatable types" << oendl;
+ owarn << "Tried to compare two incompatable types" << oendl;
return FALSE;
}
return target.closer(d1->getField(column), d2->getField(column));
- }
+ }
return target.close(d1->getField(column));
}
diff --git a/noncore/apps/tableviewer/db/datacache.cpp b/noncore/apps/tableviewer/db/datacache.cpp
index 6380e1b..de57961 100644
--- a/noncore/apps/tableviewer/db/datacache.cpp
+++ b/noncore/apps/tableviewer/db/datacache.cpp
@@ -1,301 +1,301 @@
/**********************************************************************
** 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.
**
-**********************************************************************/
+**********************************************************************/
/*
* This file is used to load the xml files that represent the database.
* The main requirment for said file is each data entry must contain a key,
* otherwise any other data headings are allowed.
*/
#include "datacache.h"
#include "xmlsource.h"
#include "csvsource.h"
/* OPIE */
#include <opie2/odebug.h>
using namespace Opie::Core;
/* QT */
#include <qheader.h>
/* STD */
#include <stdlib.h>
#define INIT_TABLE_SIZE 128
/*!
\class DBStore datastore.h
\brief The DBStore class is the class responsible for storing, sorting and
searching the data loaded by the application
*/
/*!
Constructs a DBStore item
*/
DBStore::DBStore()
{
name = "";
number_elems = 0;
full = false;
kRep = new KeyList();
master_table.resize(INIT_TABLE_SIZE);
table_size = INIT_TABLE_SIZE;
current_elem = 0;
archive = 0;
}
-//TODO
+//TODO
/*!
- Reinitializes the table to empty (include a resize of the master table,
- which should free some memory)
+ Reinitializes the table to empty (include a resize of the master table,
+ which should free some memory)
*/
void DBStore::freeTable()
{
name = "";
if(archive) {
delete archive;
archive = 0;
}
kRep->clear(); /* clear the current key list */
number_elems = 0;
table_size = INIT_TABLE_SIZE;
master_table.resize(table_size);
full = false;
current_elem = 0;
}
/*!
Removes all items from the DBStore and destroys the DBStore
*/
DBStore::~DBStore()
{
freeTable();
}
/*!
- This function opens the given xml file, loads it and sets up the
+ This function opens the given xml file, loads it and sets up the
appropriate data structures.
\param file_name A string representing the name of the file to be opened
\return true if successful, false otherwise.
*/
bool DBStore::openSource(QIODevice *inDev, const QString &source) {
- /* first check if db is already open, if contains data.. then clear */
+ /* first check if db is already open, if contains data.. then clear */
if(number_elems > 0) {
freeTable();
}
if (source == "text/x-xml-tableviewer") {
archive = new DBXml(this);
} else if (source == "text/csv") {
- archive = new DBCsv(this);
+ archive = new DBCsv(this);
} else
- return false;
+ return false;
return (archive->openSource(inDev));
}
-bool DBStore::saveSource(QIODevice *outDev, const QString &source)
+bool DBStore::saveSource(QIODevice *outDev, const QString &source)
{
/* saving a new file */
if(!archive) {
if (source == "text/x-xml-tableviewer") {
archive = new DBXml(this);
- } else if (source == "text/x-xml-tableviewer") {
+ } else if (source == "text/x-xml-tableviewer") {
archive = new DBCsv(this);
} else
- return false;
+ return false;
}
/* changing file type */
if(archive->type() != source) {
delete archive;
if (source == "text/x-xml-tableviewer") {
archive = new DBXml(this);
- } else if (source == "text/x-xml-tableviewer") {
+ } else if (source == "text/x-xml-tableviewer") {
archive = new DBCsv(this);
- } else
- return false;
+ } else
+ return false;
}
return (archive->saveSource(outDev));
}
-/*!
+/*!
This function is used to add new elements to the database. If the database
has already reached the maximum allowable size this function does not alter
the database.
\param delm An already allocated and initialized data element to be added
*/
void DBStore::addItem(DataElem *delem)
{
addItemInternal(delem);
}
void DBStore::addItemInternal(DataElem *delem)
{
- /* if already full, don't over fill, do a qWarning though */
+ /* if already full, don't over fill, do a owarn though */
if (full) {
- owarn << "Attempted to add items to already full table" << oendl;
+ owarn << "Attempted to add items to already full table" << oendl;
return;
}
master_table.insert(number_elems, delem);
current_elem = number_elems;
number_elems++;
if(number_elems >= table_size) {
/* filled current table, double if we can */
table_size = table_size << 1;
/* check that the new table size is still valid, i.e. that we didn't
just shift the 1 bit of the end of the int. */
if (!table_size) {
full = true;
/* no point in doing antying else. */
return;
}
master_table.resize(table_size);
}
}
void DBStore::removeItem(DataElem *r)
{
int position = master_table.findRef(r);
- if(position != -1) {
- /* there is at least one item, this is it */
- /* replace this with the last element, decrease the element count */
- master_table.insert(position, master_table.at(--number_elems));
- master_table.remove(number_elems);
- delete r;
- }
+ if(position != -1) {
+ /* there is at least one item, this is it */
+ /* replace this with the last element, decrease the element count */
+ master_table.insert(position, master_table.at(--number_elems));
+ master_table.remove(number_elems);
+ delete r;
+ }
}
/*!
Sets the name of the database
\param n A string representing the new name of the database.
*/
void DBStore::setName(const QString &n)
{
- name = n;
+ name = n;
}
/*!
Gets the name of the database
\return A string representing the name of the database.
*/
QString DBStore::getName()
{
- return name;
+ return name;
}
/*!
- Retrieves a pointer to the key representation of the database for
+ Retrieves a pointer to the key representation of the database for
other classes to use as reference.
\return a pointer to the databases key representaion
*/
KeyList *DBStore::getKeys()
{
return kRep;
}
/*!
sets the database's key representation the passed pointer
\param a pointer to a key representaton
*/
void DBStore::setKeys(KeyList *k)
{
kRep = k;
}
/*!
- Sets the current element to the first element of the database
+ Sets the current element to the first element of the database
*/
void DBStore::first()
{
current_elem = 0;
}
/*!
- Sets the current element to the last element of the database
+ Sets the current element to the last element of the database
*/
void DBStore::last()
{
current_elem = number_elems - 1;
}
/*!
Sets the current element to the next element of the database if
there exists an element after the current one.
*/
bool DBStore::next()
{
unsigned int new_current_elem = current_elem + 1;
- if (current_elem < number_elems)
+ if (current_elem < number_elems)
/* was valid before inc (it is possible but unlikely that inc current
elem will change it from invalid to valid) */
if (new_current_elem < number_elems) {
/* is valid after inc */
current_elem = new_current_elem;
return true;
}
return false;
}
/*!
Sets the current element to the previous element of the database if
there exists an element before the current one.
*/
bool DBStore::previous()
{
unsigned int new_current_elem = current_elem -1;
if (current_elem < number_elems)
/* was valid */
if (new_current_elem < number_elems) {
- /* still is (if was 0, then now -1, but as is unsigned will wrap
+ /* still is (if was 0, then now -1, but as is unsigned will wrap
and hence be invalid */
current_elem = new_current_elem;
return true;
}
return false;
}
/*!
Returns the current data element in the database. Which element is current
- is affected by newly added items, findItem, next, previous, first and
+ is affected by newly added items, findItem, next, previous, first and
last functions
\return a pointer to the current data element
*/
-DataElem *DBStore::getCurrentData()
+DataElem *DBStore::getCurrentData()
{
- if (current_elem >= number_elems)
+ if (current_elem >= number_elems)
return NULL;
return master_table[current_elem];
}
diff --git a/noncore/apps/tableviewer/db/datacache.h b/noncore/apps/tableviewer/db/datacache.h
index c5dc637..e38050c 100644
--- a/noncore/apps/tableviewer/db/datacache.h
+++ b/noncore/apps/tableviewer/db/datacache.h
@@ -1,130 +1,136 @@
/**********************************************************************
** 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.
**
**********************************************************************/
/*
* This file is used to load the xml files that represent the database.
* The main requirment for said file is each data entry must contain a key,
* otherwise any other data headings are allowed.
*/
#ifndef __DATACACHE_H__
#define __DATACACHE_H__
+#include "common.h"
+
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+
+/* QT */
#include <qstring.h>
#include <qvector.h>
-#include "common.h"
class DBStore;
/*! Abstract class that defines how database stuff can be accessed */
class DBAccess {
public:
// DBAccess(DBStore *d) { dstore = d; }
virtual ~DBAccess() {}
virtual QString type() {
return QString();
}
virtual bool openSource(QIODevice *) {
- qWarning("DBAccess::openSource not yet implemented");
+ owarn << "DBAccess::openSource not yet implemented" << oendl;
return false;
}
virtual bool saveSource(QIODevice *) {
- qWarning("DBAccess::saveSource(QString) not yet implemented");
+ owarn << "DBAccess::saveSource(QString) not yet implemented" << oendl;
return false;
}
protected:
DBStore *dstore;
QString source_name;
};
class DBStore {
public:
DBStore();
~DBStore();
bool openSource(QIODevice *, const QString &source);
bool saveSource(QIODevice *, const QString &source);
// Add an item
void addItem(DataElem *);
void addItemInternal(DataElem *);
- void removeItem(DataElem *);
+ void removeItem(DataElem *);
// Set the name of the database
void setName(const QString &name);
// Get the name of the database
QString getName();
KeyList *getKeys();
void setKeys(KeyList *);
/*! gets the number of fields defined in the database */
inline int getNumFields() {
return kRep->getNumFields();
}
/*! gets the index of a key given its name */
inline int getKeyIndex(QString qs) {
return kRep->getKeyIndex(qs);
}
/*! gets the type of a key given its index */
inline TVVariant::KeyType getKeyType(int i) {
return kRep->getKeyType(i);
}
/*! gets the name of a key given its index */
inline QString getKeyName(int i) {
return kRep->getKeyName(i);
}
// Access functions.. iterator type stuff
void first();
void last();
- bool next();
- bool previous();
+ bool next();
+ bool previous();
- DataElem* getCurrentData();
+ DataElem* getCurrentData();
private:
/* does the work of freeing used memory */
void freeTable();
- QString name;
+ QString name;
QVector<DataElem> master_table;
DBAccess *archive;
KeyList *kRep;
unsigned int number_elems;
unsigned int table_size; /* should always be a power of 2 */
- bool full; /* since because we are using an int for indexing there is
+ bool full; /* since because we are using an int for indexing there is
an upper limit on the number of items we can store. */
unsigned int current_elem;
};
#endif
diff --git a/noncore/apps/tableviewer/ui/browsekeyentry.cpp b/noncore/apps/tableviewer/ui/browsekeyentry.cpp
index 42e24dd..6b78437 100644
--- a/noncore/apps/tableviewer/ui/browsekeyentry.cpp
+++ b/noncore/apps/tableviewer/ui/browsekeyentry.cpp
@@ -1,206 +1,205 @@
/**********************************************************************
** 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 "browsekeyentry.h"
#include "commonwidgets.h"
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+
#include <qtoolbutton.h>
#include <qwidgetstack.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qpopupmenu.h>
#include <qhbox.h>
#include <qdatetime.h>
-#include <qheader.h>
-// For qWarning(const char *)
-
/*!
\class TVBrowseKeyEntry
\brief a Widget used enter keys into the TVBrowseViewWidget
The TVBrowseKeyEntry Widget provides the facility to enter
various key types to be search on in the table. The key can be changed
and the entry field will update to the correct sort of widget appropriately
*/
/*!
- Constructs the widget
+ Constructs the widget
*/
TVBrowseKeyEntry::TVBrowseKeyEntry(QWidget *parent, const char *name, WFlags f)
: QWidget(parent, name, f)
{
QHBoxLayout *h_layout = new QHBoxLayout(this);
textKey = new QLineEdit(this, 0);
intKey = new IntEdit(this, 0);
dateKey = new DateEdit(this, 0);
timeKey = new TimeEdit(this, 0);
resetButton = new QPushButton(this, "reset");
resetButton->setMinimumSize(QSize(50, 0));
resetButton->setText(tr("Reset"));
changeKeyButton = new QToolButton(this, "changekey");
// TODO The icon stuff.
changeKeyButton->setText(tr("key"));
totalKeys = 0;
ts = 0;
keyMenu = new QPopupMenu(this, "keymenu");
ws = new QWidgetStack(this, 0);
ws->addWidget(textKey, TVVariant::String);
ws->addWidget(intKey, TVVariant::Int);
ws->addWidget(timeKey, TVVariant::Time);
ws->addWidget(dateKey, TVVariant::Date);
ws->raiseWidget(TVVariant::String);
-
+
// TODO connect slots and signals....
- connect(changeKeyButton, SIGNAL(clicked()),
+ connect(changeKeyButton, SIGNAL(clicked()),
this, SLOT(changeKeyMenuSlot()));
- connect(resetButton, SIGNAL(clicked()),
+ connect(resetButton, SIGNAL(clicked()),
textKey, SLOT(clear()));
- connect(resetButton, SIGNAL(clicked()),
+ connect(resetButton, SIGNAL(clicked()),
intKey, SLOT(clear()));
- connect(resetButton, SIGNAL(clicked()),
+ connect(resetButton, SIGNAL(clicked()),
dateKey, SLOT(clear()));
- connect(resetButton, SIGNAL(clicked()),
+ connect(resetButton, SIGNAL(clicked()),
timeKey, SLOT(clear()));
h_layout->addWidget(ws);
h_layout->addWidget(resetButton);
h_layout->addWidget(changeKeyButton);
- connect(textKey, SIGNAL(textChanged(const QString&)),
+ connect(textKey, SIGNAL(textChanged(const QString&)),
this, SLOT(searchOnText()));
- connect(intKey, SIGNAL(valueChanged(int)),
+ connect(intKey, SIGNAL(valueChanged(int)),
this, SLOT(searchOnText()));
- connect(dateKey, SIGNAL(valueChanged(const QDate&)),
+ connect(dateKey, SIGNAL(valueChanged(const QDate&)),
this, SLOT(searchOnText()));
- connect(timeKey, SIGNAL(valueChanged(const QTime&)),
+ connect(timeKey, SIGNAL(valueChanged(const QTime&)),
this, SLOT(searchOnText()));
}
/*!
- Destructs the widget
+ Destructs the widget
*/
TVBrowseKeyEntry::~TVBrowseKeyEntry()
{
}
/*!
Changes which key the user intends to search on
\param id_param the index of the key future searches should be base on
*/
void TVBrowseKeyEntry::changeKeySlot(int id_param)
{
if(ts) {
emit sortChanged(id_param);
ws->raiseWidget(ts->kRep->getKeyType(ts->current_column));
}
}
/*!
Opens the change key menu
*/
void TVBrowseKeyEntry::changeKeyMenuSlot()
{
- if(ts)
+ if(ts)
keyMenu->exec(changeKeyButton->mapToGlobal(QPoint(0,0)));
}
void TVBrowseKeyEntry::setTableState(TableState *t) {
ts = t;
}
void TVBrowseKeyEntry::rebuildKeys() {
int i;
if (!ts) return;
if (!ts->kRep) return;
/* clear the old */
keyMenu->clear();
KeyListIterator it(*ts->kRep);
for (i = 0; i < ts->kRep->getNumFields(); i++) {
- keyMenu->insertItem(it.current()->name(), this,
+ keyMenu->insertItem(it.current()->name(), this,
SLOT(changeKeySlot(int)), 0, i);
keyMenu->setItemParameter(i, it.currentKey());
++it;
}
}
void TVBrowseKeyEntry::reset()
{
textKey->clear();
intKey->clear();
dateKey->clear();
timeKey->clear();
keyMenu->clear();
}
/*!
- Searches on the current value of the key entry provided that the
- current key is of type text WARNING, TODO fix memory leaks
+ Searches on the current value of the key entry provided that the
+ current key is of type text WARNING, TODO fix memory leaks
*/
void TVBrowseKeyEntry::searchOnText()
{
TVVariant sendkey;
if (!ts)
return;
switch(ts->kRep->getKeyType(ts->current_column)) {
case TVVariant::String:
sendkey = TVVariant(QString(textKey->text()));
break;
case TVVariant::Int: {
sendkey = TVVariant(intKey->value());
break;
}
case TVVariant::Time: {
sendkey = TVVariant(QTime(timeKey->time()));
break;
}
case TVVariant::Date: {
sendkey = TVVariant(QDate(dateKey->date()));
break;
}
- case TVVariant::Invalid:
- break;
+ case TVVariant::Invalid:
+ break;
default:
- qWarning("TVBrowseKeyEntry::searchOnText() "
- "cannot work out data type");
+ owarn << "TVBrowseKeyEntry::searchOnText() cannot work out data type" << oendl;
return;
}
emit searchOnKey(ts->current_column, sendkey);
}
/*! \fn void TVBrowseKeyEntry::searchOnKey(int currentKeyId, TVVariant)
This signal indicates that a search on key index currentKeyId should be
done searching for the value v.
-*/
+*/
diff --git a/noncore/apps/tableviewer/ui/filterkeyentry.cpp b/noncore/apps/tableviewer/ui/filterkeyentry.cpp
index d108fbd..4d74d6b 100644
--- a/noncore/apps/tableviewer/ui/filterkeyentry.cpp
+++ b/noncore/apps/tableviewer/ui/filterkeyentry.cpp
@@ -1,208 +1,212 @@
/**********************************************************************
** 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 "filterkeyentry.h"
#include "commonwidgets.h"
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+
+/* QT */
#include <qwidgetstack.h>
#include <qcombobox.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qsizepolicy.h>
#include <qdatetime.h>
#include <qhbox.h>
TVFilterKeyEntry::TVFilterKeyEntry(QWidget *parent, const char *name, WFlags f)
: QWidget(parent, name, f)
{
int stack_elem = 0;
layout = new QHBoxLayout(this, 0);
layout->setSpacing(0);
layout->setMargin(0);
textEntry = new QHBox(this, 0);
textEntry->setSpacing(0);
textEntry->setMargin(0);
intEntry = new QHBox(this, 0);
intEntry->setSpacing(0);
intEntry->setMargin(0);
timeEntry = new QHBox(this, 0);
timeEntry->setSpacing(0);
timeEntry->setMargin(0);
dateEntry = new QHBox(this, 0);
dateEntry->setSpacing(0);
dateEntry->setMargin(0);
textCombo = new QComboBox(textEntry, 0);
textKey = new QLineEdit(textEntry, 0);
/* Build the text combo list */
textCombo->insertItem("less than");
textCombo->insertItem("more than");
textCombo->insertItem("equal to");
textCombo->insertItem("containing");
textCombo->insertItem("starting with");
textCombo->insertItem("ending with");
intCombo = new QComboBox(intEntry, 0);
intKey = new IntEdit(intEntry, 0);
/* Build the int combo list */
intCombo->insertItem("less than");
intCombo->insertItem("more than");
intCombo->insertItem("equal to");
timeCombo = new QComboBox(timeEntry, 0);
timeKey = new TimeEdit(timeEntry, 0);
/* Build the time combo list */
timeCombo->insertItem("less than");
timeCombo->insertItem("more than");
timeCombo->insertItem("equal to");
dateCombo = new QComboBox(dateEntry, 0);
dateKey = new DateEdit(dateEntry, 0);
/* Build the date combo list */
dateCombo->insertItem("less than");
dateCombo->insertItem("more than");
dateCombo->insertItem("equal to");
ts = 0;
ws = new QWidgetStack(this, 0);
ws->setMargin(0);
ws->addWidget(textEntry, TVVariant::String);
ws->addWidget(intEntry, TVVariant::Int);
ws->addWidget(timeEntry, TVVariant::Time);
ws->addWidget(dateEntry, TVVariant::Date);
/* connect the signals down */
- connect(textKey, SIGNAL(textChanged(const QString&)),
+ connect(textKey, SIGNAL(textChanged(const QString&)),
this, SIGNAL(valueChanged()));
- connect(intKey, SIGNAL(valueChanged(int)),
+ connect(intKey, SIGNAL(valueChanged(int)),
this, SIGNAL(valueChanged()));
- connect(dateKey, SIGNAL(valueChanged(const QDate&)),
+ connect(dateKey, SIGNAL(valueChanged(const QDate&)),
this, SIGNAL(valueChanged()));
- connect(timeKey, SIGNAL(valueChanged(const QTime&)),
+ connect(timeKey, SIGNAL(valueChanged(const QTime&)),
this, SIGNAL(valueChanged()));
connect(intCombo, SIGNAL(activated(int)), this, SIGNAL(valueChanged()));
connect(textCombo, SIGNAL(activated(int)), this, SIGNAL(valueChanged()));
connect(timeCombo, SIGNAL(activated(int)), this, SIGNAL(valueChanged()));
connect(dateCombo, SIGNAL(activated(int)), this, SIGNAL(valueChanged()));
ws->raiseWidget(TVVariant::String);
layout->addWidget(ws);
current_type = TVVariant::String;
}
/*!
- Destructs the widget
+ Destructs the widget
*/
TVFilterKeyEntry::~TVFilterKeyEntry()
{
}
-void TVFilterKeyEntry::setKey(int i)
+void TVFilterKeyEntry::setKey(int i)
{
if (!ts) return;
if (!ts->kRep) return;
/* set up to raise appropriate widget set */
if (current_type != ts->kRep->getKeyType(i)) {
current_type = ts->kRep->getKeyType(i);
ws->raiseWidget(current_type);
}
}
void TVFilterKeyEntry::setTableState(TableState *t) {
int i;
ts = t;
if(!t) return;
if (!t->kRep)
return;
if (t->kRep->getNumFields() < 1)
return;
setKey(0);
/* set up the the menu stuff.. */
}
CmpType TVFilterKeyEntry::getCompareType()
{
switch(current_type) {
case TVVariant::String: {
CmpType k = (CmpType) textCombo->currentItem();
return k;
}
case TVVariant::Int: {
CmpType k = (CmpType) intCombo->currentItem();
return k;
}
case TVVariant::Time: {
CmpType k = (CmpType) timeCombo->currentItem();
return k;
}
case TVVariant::Date: {
CmpType k = (CmpType) dateCombo->currentItem();
return k;
}
default:
break;
}
return ct_equal;
}
/* MUST return a valid pointer */
TVVariant TVFilterKeyEntry::getCompareValue()
{
TVVariant sendkey;
int tmp;
switch(current_type) {
- case TVVariant::String:
- sendkey = TVVariant(QString(textKey->text()));
- break;
- case TVVariant::Int: {
+ case TVVariant::String:
+ sendkey = TVVariant(QString(textKey->text()));
+ break;
+ case TVVariant::Int: {
sendkey = TVVariant(intKey->value());
- break;
- }
+ break;
+ }
case TVVariant::Time: {
- sendkey = TVVariant(QTime(timeKey->time()));
- break;
+ sendkey = TVVariant(QTime(timeKey->time()));
+ break;
}
case TVVariant::Date: {
- sendkey = TVVariant(QDate(dateKey->date()));
- break;
+ sendkey = TVVariant(QDate(dateKey->date()));
+ break;
}
default: {
sendkey = TVVariant(0);
- qWarning("TVFilterKeyEntry::getCompareValue() "
- "cannot work out data type");
+ owarn << "TVFilterKeyEntry::getCompareValue() cannot work out data type" << oendl;
}
}
return sendkey;
}
diff --git a/noncore/apps/tableviewer/ui/tvfilterview.cpp b/noncore/apps/tableviewer/ui/tvfilterview.cpp
index 22f1fb7..198c8b5 100644
--- a/noncore/apps/tableviewer/ui/tvfilterview.cpp
+++ b/noncore/apps/tableviewer/ui/tvfilterview.cpp
@@ -1,306 +1,311 @@
/**********************************************************************
** 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 "tvfilterview.h"
+
+/* OPIE */
+#include <opie2/odebug.h>
+#include <qpe/qpeapplication.h>
+using namespace Opie::Core;
+
+/* QT */
#include <qtoolbutton.h>
#include <qcombobox.h>
#include <qlistview.h>
#include <qlayout.h>
#include <qheader.h>
#include <qpushbutton.h>
#include <qlabel.h>
-#include <qpe/qpeapplication.h>
TVFilterView::TVFilterView(TableState *t, QWidget* parent,
const char *name, WFlags fl ) : QDialog(parent, name, TRUE, fl)
{
- if ( !name )
- setName( "Filter View" );
+ if ( !name )
+ setName( "Filter View" );
QVBoxLayout *vlayout = new QVBoxLayout(this);
display = new QListView(this, "display");
display->addColumn("Key");
display->addColumn("Constraint");
display->addColumn("Value");
display->header()->setClickEnabled(FALSE);
display->header()->setResizeEnabled(FALSE);
vlayout->addWidget(display);
QHBoxLayout *hlayout = new QHBoxLayout;
hlayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum));
newFilterButton = new QPushButton(this, "new Filter");
newFilterButton->setMaximumSize(QSize(50, 32767));
newFilterButton->setText("New");
hlayout->addWidget(newFilterButton);
deleteFilterButton = new QPushButton(this, "delete Filter");
deleteFilterButton->setMaximumSize(QSize(50, 32767));
deleteFilterButton->setText("Delete");
hlayout->addWidget(deleteFilterButton);
clearFilterButton = new QPushButton(this, "delete Filter");
clearFilterButton->setMaximumSize(QSize(60, 32767));
clearFilterButton->setText("Clear All");
hlayout->addWidget(clearFilterButton);
vlayout->addLayout(hlayout);
QHBoxLayout *hlayout2 = new QHBoxLayout;
keyNameCombo = new QComboBox(FALSE, this, "key name");
keyNameCombo->setEnabled(FALSE);
hlayout2->addWidget(keyNameCombo);
QLabel *label = new QLabel(this);
label->setText("has value");
hlayout2->addWidget(label);
keyEntry = new TVFilterKeyEntry(this, "key entry");
keyEntry->setEnabled(FALSE);
vlayout->addLayout(hlayout2);
vlayout->addWidget(keyEntry);
connect(newFilterButton, SIGNAL( clicked() ), this, SLOT( newTerm() ));
connect(deleteFilterButton, SIGNAL( clicked() ), this, SLOT( deleteTerm()));
connect(clearFilterButton, SIGNAL( clicked() ), this, SLOT( clearTerms()));
connect(keyEntry, SIGNAL(valueChanged()), this, SLOT( updateTerm() ));
connect(keyNameCombo, SIGNAL(activated(int)), this, SLOT( updateTerm() ));
- connect(display, SIGNAL(selectionChanged(QListViewItem*)), this,
- SLOT(setTerm(QListViewItem*)));
+ connect(display, SIGNAL(selectionChanged(QListViewItem*)), this,
+ SLOT(setTerm(QListViewItem*)));
ts = t;
current = 0;
terms.setAutoDelete(true);
do_filter = false;
#ifdef Q_WS_QWS
QPEApplication::showDialog( this );
#endif
}
/*!
- Destroys the TVFilterView widget
+ Destroys the TVFilterView widget
*/
TVFilterView::~TVFilterView()
{
}
void TVFilterView::rebuildData()
{
}
void TVFilterView::reset()
{
keyNameCombo->clear();
keyIds.clear();
}
-void TVFilterView::rebuildKeys()
+void TVFilterView::rebuildKeys()
{
int i;
if (!ts) return;
if(!ts->kRep) return;
keyEntry->setTableState(ts);
-
+
/* set up the list of keys that can be compared on */
keyNameCombo->clear();
KeyListIterator it(*ts->kRep);
i = 0;
while(it.current()) {
- if(ts->kRep->validIndex(it.currentKey())) {
- keyNameCombo->insertItem(it.current()->name());
- keyIds.insert(i, it.currentKey());
- ++i;
- }
- ++it;
+ if(ts->kRep->validIndex(it.currentKey())) {
+ keyNameCombo->insertItem(it.current()->name());
+ keyIds.insert(i, it.currentKey());
+ ++i;
+ }
+ ++it;
}
}
bool TVFilterView::passesFilter(DataElem *d) {
if (!filterActive()) return true;
FilterTerm *t;
-
+
for (t = terms.first(); t != 0; t = terms.next() ) {
/* check against filter */
switch(t->ct) {
case ct_less:
if (!d->lessThan(t->keyIndex, t->value))
return false;
break;
case ct_more:
if (!d->moreThan(t->keyIndex, t->value))
return false;
break;
case ct_equal:
if (!d->equalTo(t->keyIndex, t->value))
return false;
break;
case ct_contains:
if (!d->contains(t->keyIndex, t->value))
return false;
break;
case ct_startswith:
if (!d->startsWith(t->keyIndex, t->value))
return false;
break;
case ct_endswith:
if (!d->endsWith(t->keyIndex, t->value))
return false;
break;
default:
- qWarning("TVFilterView::passesFilter() "
- "unrecognized filter type");
+ owarn << "TVFilterView::passesFilter() unrecognized filter type" << oendl;
return false;
}
}
return true;
}
bool TVFilterView::filterActive() const
{
/* when button operated, also check the do_filter value
return do_filter;
*/
if (terms.isEmpty())
return false;
return true;
}
/* SLOTS */
-void TVFilterView::newTerm()
+void TVFilterView::newTerm()
{
if (!ts) return;
FilterTerm *term = new FilterTerm;
current = term;
term->view = 0;
updateTerm();
display->setSelected(term->view, true);
terms.append(term);
keyEntry->setEnabled(true);
keyNameCombo->setEnabled(true);
}
-void TVFilterView::updateTerm()
+void TVFilterView::updateTerm()
{
FilterTerm *term;
/* Read the widget values (keyname, compare type, value)
* and build the lists */
if (!ts) return;
if (!current) return;
QString keyString;
QString cmpString;
QString vString;
term = current;
/* create new list item, set initial values, enable widgets */
term->keyIndex = keyIds[keyNameCombo->currentItem()];
keyEntry->setKey(term->keyIndex); /* so the next two items make sense */
term->ct = keyEntry->getCompareType(),
term->value = keyEntry->getCompareValue();
-
+
keyString = keyNameCombo->currentText();
switch(term->ct) {
case ct_less:
cmpString = " less than ";
break;
case ct_more:
cmpString = " more than ";
break;
case ct_equal:
cmpString = " equal to ";
break;
case ct_contains:
cmpString = " containing ";
break;
case ct_startswith:
cmpString = " starting with ";
break;
case ct_endswith:
cmpString = " ending with ";
break;
default:
cmpString = " ERROR ";
}
vString = term->value.toString();
/* remove old view */
- if (term->view)
+ if (term->view)
delete(term->view);
term->view = new QListViewItem(display, 0, keyString, cmpString, vString);
display->setSelected(term->view, true);
}
/* deletes current term */
-void TVFilterView::deleteTerm()
+void TVFilterView::deleteTerm()
{
if(!current) return;
if (current->view)
delete(current->view);
terms.removeRef(current);
current = terms.first();
if(terms.isEmpty()) {
keyEntry->setEnabled(false);
keyNameCombo->setEnabled(false);
}
}
/* clears all terminations */
-void TVFilterView::clearTerms()
+void TVFilterView::clearTerms()
{
while(current)
deleteTerm();
}
void TVFilterView::setTerm(QListViewItem *target)
{
- /* Iterate through the list to find item with view=target..
+ /* Iterate through the list to find item with view=target..
* set as current, delete */
FilterTerm *term = current;
for (current = terms.first(); current != 0; current = terms.next() )
if (current->view == target)
break;
if (!current) {
- current = term;
+ current = term;
}
}
diff --git a/noncore/apps/tinykate/libkate/kateconfig.cpp b/noncore/apps/tinykate/libkate/kateconfig.cpp
index 782b629..4b8ce78 100644
--- a/noncore/apps/tinykate/libkate/kateconfig.cpp
+++ b/noncore/apps/tinykate/libkate/kateconfig.cpp
@@ -1,122 +1,123 @@
/**********************************************************************
** 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 "kateconfig.h"
/* OPIE */
#include <opie2/odebug.h>
#include <qpe/global.h>
+using namespace Opie::Core;
/* QT */
#include <qdir.h>
#include <qmessagebox.h>
#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
#include <qtextcodec.h>
#endif
#include <qtextstream.h>
/* STD */
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
/*!
\internal
*/
QString KateConfig::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 KateConfig config.h
\brief The KateConfig class provides for saving application cofniguration state.
You should keep a KateConfig 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 KateConfig::KateConfigGroup
\internal
*/
/*!
\enum KateConfig::Domain
\value File
\value User
See KateConfig 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 KateConfig.
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.
*/
KateConfig::KateConfig( const QString &name, Domain domain )
: filename( configFilename(name,domain) )
{
owarn << "KateConfig constructor\n" << oendl;
git = groups.end();
read();
QStringList l = Global::languageList();
lang = l[0];
glang = l[1];
}
// Sharp ROM compatibility
KateConfig::KateConfig ( 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.
@@ -463,175 +464,174 @@ QStringList KateConfig::readListEntry( const QString &key, const QChar &sep )
if ( s.isEmpty() )
return QStringList();
else
return QStringList::split( sep, s );
}
QColor KateConfig::readColorEntry( const QString &key, const QColor &def ) const
{
QStringList list = readListEntry(key, QChar(','));
if( list.count() != 3 )
return def;
return QColor(list[0].toInt(), list[1].toInt(), list[2].toInt());
}
QFont KateConfig::readFontEntry( const QString &key, const QFont &def ) const
{
QStringList list = readListEntry(key, QChar(','));
if( list.count() != 5 )
return def;
return QFont(list[0], list[1].toInt(), list[2].toInt(), (bool)list[3].toInt(), (QFont::CharSet)list[4].toInt());
}
QValueList<int> KateConfig::readIntListEntry( const QString &key ) const
{
QString s = readEntry( key );
QValueList<int> il;
if ( s.isEmpty() )
return il;
QStringList l = QStringList::split( QChar(','), s );
QStringList::Iterator l_it;
for( l_it = l.begin(); l_it != l.end(); ++l_it )
il.append( (*l_it).toInt() );
return il;
}
/*!
Removes all entries from the current group.
*/
void KateConfig::clearGroup()
{
if ( git == groups.end() ) {
owarn << "no group set" << oendl;
return;
}
if ( !(*git).isEmpty() ) {
( *git ).clear();
changed = TRUE;
}
}
/*!
\internal
*/
void KateConfig::write( const QString &fn )
{
QString strNewFile;
if ( !fn.isEmpty() )
filename = fn;
strNewFile = filename + ".new";
QFile f( strNewFile );
if ( !f.open( IO_WriteOnly|IO_Raw ) ) {
owarn << "could not open for writing `" << strNewFile << "'" << oendl;
git = groups.end();
return;
}
QString str;
QCString cstr;
QMap< QString, KateConfigGroup >::Iterator g_it = groups.begin();
for ( ; g_it != groups.end(); ++g_it ) {
str += "[" + g_it.key() + "]\n";
KateConfigGroup::Iterator e_it = ( *g_it ).begin();
for ( ; e_it != ( *g_it ).end(); ++e_it )
str += e_it.key() + " = " + *e_it + "\n";
}
cstr = str.utf8();
int total_length;
total_length = f.writeBlock( cstr.data(), cstr.length() );
if ( total_length != int(cstr.length()) ) {
QMessageBox::critical( 0, QObject::tr("Out of Space"),
QObject::tr("There was a problem creating\nKateConfiguration Information \nfor this program.\n\nPlease free up some space and\ntry again.") );
f.close();
QFile::remove( strNewFile );
return;
}
f.close();
// now rename the file...
if ( rename( strNewFile, filename ) < 0 ) {
- qWarning( "problem renaming the file %s to %s", strNewFile.latin1(),
- filename.latin1() );
+ owarn << "problem renaming the file " << strNewFile.latin1() << " to " << filename.latin1() << oendl;
QFile::remove( strNewFile );
}
}
/*!
Returns whether the KateConfig is in a valid state.
*/
bool KateConfig::isValid() const
{
return groups.end() != git;
}
/*!
\internal
*/
void KateConfig::read()
{
changed = FALSE;
if ( !QFileInfo( filename ).exists() ) {
git = groups.end();
return;
}
QFile f( filename );
if ( !f.open( IO_ReadOnly ) ) {
git = groups.end();
return;
}
QTextStream s( &f );
#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
// The below should work, but doesn't in Qt 2.3.0
s.setCodec( QTextCodec::codecForMib( 106 ) );
#else
s.setEncoding( QTextStream::UnicodeUTF8 );
#endif
QStringList list = QStringList::split('\n', s.read() );
f.close();
for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
if ( !parse( *it ) ) {
git = groups.end();
return;
}
}
}
/*!
\internal
*/
bool KateConfig::parse( const QString &l )
{
QString line = l.stripWhiteSpace();
if ( line [0] == QChar ( '#' ))
return true; // ignore comments
if ( line[ 0 ] == QChar( '[' ) ) {
QString gname = line;
gname = gname.remove( 0, 1 );
if ( gname[ (int)gname.length() - 1 ] == QChar( ']' ) )
gname = gname.remove( gname.length() - 1, 1 );
git = groups.insert( gname, KateConfigGroup() );
} else if ( !line.isEmpty() ) {
if ( git == groups.end() )
return FALSE;
int eq = line.find( '=' );
if ( eq == -1 )
return FALSE;
QString key = line.left(eq).stripWhiteSpace();
QString value = line.mid(eq+1).stripWhiteSpace();
( *git ).insert( key, value );
}
return TRUE;
}
diff --git a/noncore/apps/zsafe/main.cpp b/noncore/apps/zsafe/main.cpp
index 4fe319b..5f48f77 100644
--- a/noncore/apps/zsafe/main.cpp
+++ b/noncore/apps/zsafe/main.cpp
@@ -1,111 +1,116 @@
/*
** Author: Carsten Schneider <CarstenSchneider@t-online.de>
**
** $Id$
**
** Homepage: http://home.t-online.de/home/CarstenSchneider/zsafe/index.html
*/
#include "zsafe.h"
+
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+
+/* QT */
#ifdef DESKTOP
#include <qapplication.h>
#else
#include <qpe/qpeapplication.h>
#endif
+
+/* STD */
#include <stdio.h>
#include <signal.h>
ZSafe *zs;
#ifdef DESKTOP
QApplication *appl;
#else
QPEApplication *appl;
#endif
int DeskW;
int DeskH;
void suspend (int signum)
{
printf ("Suspend signal %d received\n", signum);
}
void resume (int signum)
{
printf ("Resume signal %d received\n", signum);
zs->resume(signum);
}
int main( int argc, char ** argv )
{
#ifndef WIN32
// install signal handler
signal (SIGSTOP, suspend);
#endif
#ifdef DESKTOP
QApplication a( argc, argv );
#else
QPEApplication a( argc, argv );
#endif
appl = &a;
#ifdef DESKTOP
if (argc >= 3)
{
#ifndef WIN32
DeskW = atoi(argv[1]);
DeskH = atoi(argv[2]);
#else
- int w, h;
- sscanf (argv[1], "%d", &w);
- sscanf (argv[2], "%d", &h);
- DeskW = w;
+ int w, h;
+ sscanf (argv[1], "%d", &w);
+ sscanf (argv[2], "%d", &h);
+ DeskW = w;
DeskH = h;
#endif
}
else
{
DeskW = 600;
DeskH = 400;
}
#else
DeskW = a.desktop()->width();
DeskH = a.desktop()->height();
- char buf[128];
- sprintf (buf, "Width: %d Height: %d\n", DeskW, DeskH);
- qWarning (buf);
+ owarn << "Width: " << DeskW << " Height: " << DeskH << oendl;
#ifdef JPATCH_HDE
// nothings
#else
- if (DeskW > 240)
+ if (DeskW > 240)
{
DeskW -= 20;
DeskH += 25;
- sprintf (buf, "Changed width: %d Height: %d\n", DeskW, DeskH);
- qWarning (buf);
+ owarn << "Changed width: " << DeskW << " Height: " << DeskH << oendl;
}
#endif
#endif
ZSafe mw;
zs = &mw;
#ifndef WIN32
signal (SIGCONT, resume);
#endif
#ifdef DESKTOP
a.setMainWidget(&mw);
mw.show();
#else
// a.showMainWidget( &mw );
a.showMainDocumentWidget( &mw );
#endif
int ret = a.exec();
return ret;
}
diff --git a/noncore/apps/zsafe/zlistview.cpp b/noncore/apps/zsafe/zlistview.cpp
index ba02a15..7d0b8c2 100644
--- a/noncore/apps/zsafe/zlistview.cpp
+++ b/noncore/apps/zsafe/zlistview.cpp
@@ -1,36 +1,39 @@
/*
** $Id$
*/
#include "zlistview.h"
-#include <stdio.h>
#include "zsafe.h"
+/* OPIE */
+//#include <opie2/odebug.h>
+
+/* STD */
+#include <stdio.h>
+
ZListView::ZListView (ZSafe *zsafe, const char *id) : QListView(zsafe, id)
{
zs = zsafe;
}
ZListView::~ZListView()
{
}
void ZListView::keyPressEvent ( QKeyEvent *e )
{
/*
- char buf[64];
- sprintf (buf, "key: %d\n", e->key());
- qWarning (buf);
+ owarn << "key: " << e->key() << oendl;
*/
switch (e->key())
{
case 32: // middle cursor key pressed
zs->showInfo (zs->selectedItem);
break;
default:
QListView::keyPressEvent( e );
}
}
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp
index 6ff05ac..ca3ff52 100644
--- a/noncore/apps/zsafe/zsafe.cpp
+++ b/noncore/apps/zsafe/zsafe.cpp
@@ -788,270 +788,270 @@ void ZSafe::newPwd()
selectedItem = selectedItem->parent();
if (isCategory(selectedItem))
{
QString cat = selectedItem->text(0);
// open the 'New Entry' dialog
NewDialog *dialog = new NewDialog(this, tr("New Entry"), TRUE);
#ifdef WIN32
dialog->setCaption ("Qt " + tr("New Entry"));
dialog->setGeometry(200, 250, 220, 310 );
#endif
// set the labels
dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name")));
dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username")));
dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password")));
dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment")));
dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4")));
dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5")));
retype:
DialogCode result = (DialogCode) QPEApplication::execDialog( dialog );
#ifdef DESKTOP
result = Accepted;
#endif
if (result == Accepted)
{
QString name = dialog->NameField->text();
if (cat == name)
{
QMessageBox::critical( 0, tr("ZSafe"),
tr("Entry name must be different\nfrom the category name.") );
goto retype; // it's not a good programming style :-)
}
modified = true;
// add the new item
QListViewItem *i = new ShadedListItem (0, selectedItem);
i->setOpen (TRUE);
i->setText (0, tr (name));
QString user = dialog->UsernameField->text();
i->setText (1, tr (user));
QString pwd = dialog->PasswordField->text();
i->setText (2, tr (pwd));
QString comment = dialog->CommentField->text();
comment.replace (QRegExp("\n"), "<br>");
i->setText (3, tr (comment));
QString f5 = dialog->Field5->text();
i->setText (4, tr (f5));
QString f6 = dialog->Field6->text();
i->setText (5, tr (f6));
}
delete dialog;
}
}
void ZSafe::findPwd()
{
// open the 'Search' dialog
SearchDialog *dialog = new SearchDialog(this, tr("Search"), TRUE);
#ifdef WIN32
dialog->setCaption ("Qt " + tr("Search"));
#endif
#ifdef DESKTOP
#endif
if (lastSearchedName)
dialog->NameField->setText(lastSearchedName);
else
dialog->NameField->setText("");
if (lastSearchedUsername)
dialog->UsernameField->setText(lastSearchedUsername);
else
dialog->UsernameField->setText("");
if (lastSearchedComment)
dialog->CommentField->setText(lastSearchedComment);
else
dialog->CommentField->setText("");
DialogCode result = (DialogCode) dialog->exec();
#ifdef DESKTOP
result = Accepted;
#endif
QString name;
QString username;
QString comment;
if (result == Accepted)
{
name = dialog->NameField->text();
username = dialog->UsernameField->text();
comment = dialog->CommentField->text();
- qWarning (name);
+ owarn << name << oendl;
}
else
{
delete dialog;
return;
}
if (!name.isEmpty() && name != lastSearchedName ||
lastSearchedName.isEmpty() && !name.isEmpty())
{
// set search at the beginning if a new name is given
lastSearchedCategory = NULL;
lastSearchedItem = NULL;
}
lastSearchedName = name;
if (!username.isEmpty() && username != lastSearchedUsername ||
lastSearchedUsername.isEmpty() && !username.isEmpty())
{
// set search at the beginning if a new name is given
lastSearchedCategory = NULL;
lastSearchedItem = NULL;
}
lastSearchedUsername = username;
if (!comment.isEmpty() && comment != lastSearchedComment ||
lastSearchedComment.isEmpty() && !comment.isEmpty())
{
// set search at the beginning if a new name is given
lastSearchedCategory = NULL;
lastSearchedItem = NULL;
}
lastSearchedComment = comment;
ListView->clearSelection();
bool found=FALSE;
// step through all categories
QListViewItem *i;
if (lastSearchedCategory)
i = lastSearchedCategory;
else
i = ListView->firstChild();
for (;
i != NULL;
i = i->nextSibling())
{
- qWarning (i->text(0));
+ owarn << i->text(0) << oendl;
i->setSelected(FALSE);
// step through all subitems
QListViewItem *si;
if (lastSearchedItem)
si = lastSearchedItem;
else
si = i->firstChild();
// for (si = i->firstChild();
for (;
si != NULL;
si = si->nextSibling())
{
- qWarning (si->text(0));
+ owarn << si->text(0) << oendl;
if (si->isSelected())
si->setSelected(FALSE);
// ListView->repaintItem(si);
bool n=TRUE;
bool u=TRUE;
bool c=TRUE;
if (!name.isEmpty())
n = (si->text(0)).contains (name, FALSE);
if (!username.isEmpty())
u = (si->text(1)).contains (username, FALSE);
if (!comment.isEmpty())
c = (si->text(3)).contains (comment, FALSE);
if ((n && u && c ) && !found)
{
- qWarning ("Found");
+ owarn << "Found" << oendl;
selectedItem = si;
si->setSelected(TRUE);
ListView->setCurrentItem(si);
ListView->ensureItemVisible(si);
ListView->triggerUpdate();
lastSearchedCategory = i;
// set to the next item
lastSearchedItem = si->nextSibling();
if (!lastSearchedItem)
{
// no next item within category -> set next category
lastSearchedCategory = i->nextSibling();
if (!lastSearchedCategory)
lastSearchedItem = NULL; // END
}
found = TRUE;
delete dialog;
update();
return;
}
}
lastSearchedCategory = i->nextSibling();
lastSearchedItem = NULL;
}
lastSearchedCategory = NULL;
lastSearchedItem = NULL;
delete dialog;
update();
QMessageBox::information( this, tr("ZSafe"),
tr("Entry not found"), tr("&OK"), 0);
}
QString ZSafe::getFieldLabel (QListViewItem *_item, QString field, QString def)
{
QString category;
if (_item)
{
if (isCategory(_item))
{
category = _item->text(0);
}
else
{
QListViewItem *cat = _item->parent();
category = cat->text(0);
}
}
else
{
return def;
}
QString app_key = APP_KEY;
#ifndef DESKTOP
#ifndef WIN32
conf->setGroup ("fieldDefs");
#endif
#else
#ifndef WIN32
app_key += "/fieldDefs/";
#endif
#endif
// #ifndef WIN32
QString label = conf->readEntry(app_key+category+"-field"+field,def);
// #else
// QString label(def);
// #endif
#ifndef DESKTOP
conf->setGroup ("zsafe");
#endif
return label;
}
QString ZSafe::getFieldLabel (QString category, QString field, QString def)
{
QString app_key = APP_KEY;
#ifndef DESKTOP
conf->setGroup ("fieldDefs");
#else
#ifndef WIN32
app_key += "/fieldDefs/";
#endif
#endif
// #ifndef WIN32
QString label = conf->readEntry(app_key+category+"-field"+field,
def);
// #else
// QString label(def);
// #endif
#ifndef DESKTOP
conf->setGroup ("zsafe");
#endif
@@ -1135,792 +1135,787 @@ void ZSafe::showInfo( QListViewItem *_item)
if (!entry.isEmpty() && entry.compare(" "))
{
text += "<u><b>";
text += getFieldLabel (selectedItem, "4", tr("Comment"));
text += ":<br> </b></u>";
QString comment = selectedItem->text(3);
comment.replace (QRegExp("\n"), "<br>");
text += comment;
// text += "<br>";
}
text += "</body></html>";
infoForm->InfoText->setText(text);
infoForm->hide();
QPEApplication::showDialog( infoForm );
}
}
void ZSafe::listViewSelected( QListViewItem *_item)
{
if (!_item)
return;
if (selectedItem != NULL)
selectedItem->setSelected(FALSE);
selectedItem = _item;
#ifndef DESKTOP
// set the column text dependent on the selected item
ListView->setColumnText(0, getFieldLabel (selectedItem, "1", tr("Name")));
ListView->setColumnText(1, getFieldLabel (selectedItem, "2", tr("Field 2")));
ListView->setColumnText(2, getFieldLabel (selectedItem, "3", tr("Field 3")));
ListView->setColumnText(3, getFieldLabel (selectedItem, "4", tr("Comment")));
ListView->setColumnText(4, getFieldLabel (selectedItem, "5", tr("Field 4")));
ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5")));
#endif
#ifdef WIN32
// set the column text dependent on the selected item
ListView->setColumnText(0, getFieldLabel (selectedItem, "1", tr("Name")));
ListView->setColumnText(1, getFieldLabel (selectedItem, "2", tr("Field 2")));
ListView->setColumnText(2, getFieldLabel (selectedItem, "3", tr("Field 3")));
ListView->setColumnText(3, getFieldLabel (selectedItem, "4", tr("Comment")));
ListView->setColumnText(4, getFieldLabel (selectedItem, "5", tr("Field 4")));
ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5")));
#endif
}
bool ZSafe::isCategory(QListViewItem *_item)
{
if (_item == NULL)
return FALSE;
QString categoryName = _item->text (0);
if (categories.find (categoryName))
return TRUE;
else
return FALSE;
}
void ZSafe::removeAsciiFile()
{
// QString fn = filename + ".txt";
// open the file dialog
#ifndef DESKTOP
#ifndef NO_OPIE
QMap<QString, QStringList> mimeTypes;
mimeTypes.insert(tr("All"), QStringList() );
mimeTypes.insert(tr("Text"), "text/*" );
QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL,
QDir::homeDirPath() + "/Documents/application/zsafe",
QString::null,
mimeTypes,
this,
tr ("Remove text file"));
#else
QString fn = ScQtFileEdit::getOpenFileName(this,
tr ("Remove text file"),
QDir::homeDirPath() + "/Documents/application/zsafe",
"*.txt");
#endif
#else
QString fn = QFileDialog::getOpenFileName(
QDir::homeDirPath() + "/Documents/application/zsafe",
"ZSafe (*.txt)",
this,
"ZSafe File Dialog"
"Choose a text file" );
#endif
if (fn && fn.length() > 0 )
{
QFile f( fn );
if ( !f.remove() )
{
- qWarning( QString("Could not remove file %1").arg(fn),
- 2000 );
+ owarn << "Could not remove file " << fn << oendl;
QMessageBox::critical( 0, tr("ZSafe"),
tr("Could not remove text file.") );
return;
}
}
}
void ZSafe::writeAllEntries()
{
if (filename.isEmpty())
{
QMessageBox::critical( 0, tr("ZSafe"),
tr("No document defined.\nYou have to create a new document"));
return;
}
// open the file dialog
#ifndef DESKTOP
#ifndef NO_OPIE
QMap<QString, QStringList> mimeTypes;
mimeTypes.insert(tr("All"), QStringList() );
mimeTypes.insert(tr("Text"), "text/*" );
QString fn = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL,
QDir::homeDirPath() + "/Documents/application/zsafe",
QString::null,
mimeTypes,
this,
tr ("Export text file"));
#else
QString fn = ScQtFileEdit::getSaveAsFileName(this,
tr ("Export text file"),
QDir::homeDirPath() + "/Documents/application/zsafe",
"*.txt");
#endif
#else
QString fn = QFileDialog::getSaveFileName(
QDir::homeDirPath() + "/Documents/application/zsafe",
"ZSafe (*.txt)",
this,
"ZSafe File Dialog"
"Choose a text file" );
#endif
// open the new document
if (fn && fn.length() > 0 )
{
QFile f( fn );
if ( !f.open( IO_WriteOnly ) ) {
- qWarning( QString("Could not write to file %1").arg(fn),
- 2000 );
+ owarn << "Could not write to file " << fn << oendl;
QMessageBox::critical( 0, "ZSafe",
QString("Could not export to text file.") );
return;
}
QTextStream t( &f );
QListViewItem *i;
// step through all categories
for (i = ListView->firstChild();
i != NULL;
i = i->nextSibling())
{
// step through all subitems
QListViewItem *si;
for (si = i->firstChild();
si != NULL;
si = si->nextSibling())
{
QString oneEntry;
oneEntry += "\"";
oneEntry += i->text(0);
oneEntry += "\";";
oneEntry += "\"";
oneEntry += si->text(0);
oneEntry += "\";";
oneEntry += "\"";
oneEntry += si->text(1);
oneEntry += "\";";
oneEntry += "\"";
oneEntry += si->text(2);
oneEntry += "\";";
oneEntry += "\"";
QString comment = si->text(3);
comment.replace (QRegExp("\n"), "<br>");
oneEntry += comment;
oneEntry += "\";";
oneEntry += "\"";
oneEntry += si->text(4);
oneEntry += "\";";
oneEntry += "\"";
oneEntry += si->text(5);
oneEntry += "\"";
- // qWarning (oneEntry);
+ // owarn << oneEntry << oendl;
t << oneEntry << endl;
- // qWarning (si->text(0));
+ // owarn << si->text(0) << oendl;
}
}
f.close();
}
}
void ZSafe::readAllEntries()
{
if (filename.isEmpty())
{
QMessageBox::critical( 0, tr("ZSafe"),
tr("No document defined.\nYou have to create a new document"));
return;
}
// open the file dialog
#ifndef DESKTOP
#ifndef NO_OPIE
QMap<QString, QStringList> mimeTypes;
mimeTypes.insert(tr("All"), QStringList() );
mimeTypes.insert(tr("Text"), "text/*" );
QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL,
QDir::homeDirPath() + "/Documents/application/zsafe",
QString::null,
mimeTypes,
this,
tr ("Import text file"));
#else
QString fn = ScQtFileEdit::getOpenFileName(this,
tr ("Import text file"),
QDir::homeDirPath() + "/Documents/application/zsafe",
"*.txt");
#endif
#else
QString fn = QFileDialog::getOpenFileName(
QDir::homeDirPath() + "/Documents/application/zsafe",
"ZSafe (*.txt)",
this,
"ZSafe File Dialog"
"Choose a text file" );
#endif
if (fn && fn.length() > 0 )
{
QFile f( fn );
if ( !f.open( IO_ReadOnly ) )
{
- qWarning( QString("Could not read file %1").arg(fn),
- 2000 );
+ owarn << "Could not read file " << fn << oendl;
QMessageBox::critical( 0, "ZSafe",
QString("Could not import text file.") );
return;
}
modified = true;
// clear the password list
selectedItem = NULL;
QListViewItem *i;
// step through all categories
for (i = ListView->firstChild();
i != NULL;
i = i->nextSibling())
{
// step through all subitems
QListViewItem *si;
for (si = i->firstChild();
si != NULL; )
// si = si->nextSibling())
{
QListViewItem *_si = si;
si = si->nextSibling();
i->takeItem(_si); // remove from view list
if (_si) delete _si;
}
}
- qWarning ("ReadAllEntries(): ");
+ owarn << "ReadAllEntries(): " << oendl;
QTextStream t(&f);
while ( !t.eof() )
{
QString s = t.readLine();
s.replace (QRegExp("\";\""), "\"|\"");
// char buffer[1024];
#ifndef WIN32
char buffer[s.length()+1];
#else
char buffer[4048];
#endif
/* modify QString -> QCString::utf8 */
strcpy (buffer, s.utf8());
QString name;
QString user;
QString password;
QString comment;
QString field5="";
QString field6="";
// separete the entries
char *i = strtok (buffer, "|");
QString category(QString::fromUtf8(&i[1]));
category.truncate(category.length() -1);
int idx=0;
while ((i = strtok (NULL, "|")) != NULL)
{
switch (idx)
{
case 0:
name = QString::fromUtf8(&i[1]);
name.truncate(name.length() -1);
// name
break;
case 1:
// user
user = QString::fromUtf8(&i[1]);
user.truncate(user.length() -1);
break;
case 2:
// password
password = QString::fromUtf8(&i[1]);
password.truncate(password.length() -1);
break;
case 3:
// comment
comment = QString::fromUtf8(&i[1]);
comment.truncate(comment.length() -1);
break;
case 4:
// field5
field5 = QString::fromUtf8(&i[1]);
field5.truncate(field5.length() -1);
break;
case 5:
// field6
field6 = QString::fromUtf8(&i[1]);
field6.truncate(field6.length() -1);
break;
}
idx++;
}
Category *cat= categories.find (category);
if (cat)
{
// use the existend item
QListViewItem *catItem = cat->getListItem();
if (catItem)
{
QListViewItem * item = new ShadedListItem( 0, catItem );
item->setText( 0, tr( name ) );
item->setText( 1, tr( user ) );
item->setText( 2, tr( password ) );
item->setText( 3, tr( comment ) );
item->setText( 4, tr( field5 ) );
item->setText( 5, tr( field6 ) );
catItem->setOpen( TRUE );
}
}
else
{
QListViewItem *catI = new ShadedListItem( 1, ListView );
// create and insert a new item
QListViewItem * item = new ShadedListItem( 0, catI );
item->setText( 0, tr( name ) );
item->setText( 1, tr( user ) );
item->setText( 2, tr( password ) );
item->setText( 3, tr( comment ) );
item->setText( 4, tr( field5 ) );
item->setText( 5, tr( field6 ) );
catI->setOpen( TRUE );
Category *c1 = new Category();
c1->setCategoryName(category);
QString icon;
QString fullIconPath;
QPixmap *pix;
// #ifndef WIN32
icon = conf->readEntry(APP_KEY+category);
// #endif
bool isIconAv = false;
if (!icon.isEmpty() && !icon.isNull())
{
// build the full path
fullIconPath = iconPath + icon;
pix = new QPixmap (fullIconPath);
if (pix)
{
QImage img = pix->convertToImage();
pix->convertFromImage(img.smoothScale(14,14));
c1->setIconName (icon);
c1->setIcon (*pix);
isIconAv = true;
}
}
if (!isIconAv)
{
c1->setIcon (*getPredefinedIcon(category));
}
c1->setListItem (catI);
c1->initListItem();
categories.insert (c1->getCategoryName(), c1);
}
}
f.close();
}
else
{
}
}
#ifdef UNUSED
void ZSafe::writeAllEntries()
{
// open the file for writing
QString fn = filename + ".txt";
QFile f( fn );
if ( !f.open( IO_WriteOnly ) ) {
- qWarning( QString("Could not write to file %1").arg(fn),
- 2000 );
+ owarn << "Could not write to file " << fn << oendl;
QMessageBox::critical( 0, tr("ZSafe"),
tr("Could not export to text file.") );
return;
}
QTextStream t( &f );
QListViewItem *i;
// step through all categories
for (i = ListView->firstChild();
i != NULL;
i = i->nextSibling())
{
// step through all subitems
QListViewItem *si;
for (si = i->firstChild();
si != NULL;
si = si->nextSibling())
{
QString oneEntry;
oneEntry += "\"";
oneEntry += i->text(0);
oneEntry += "\";";
oneEntry += "\"";
oneEntry += si->text(0);
oneEntry += "\";";
oneEntry += "\"";
oneEntry += si->text(1);
oneEntry += "\";";
oneEntry += "\"";
oneEntry += si->text(2);
oneEntry += "\";";
oneEntry += "\"";
// oneEntry += si->text(3);
QString comment = si->text(3);
comment.replace (QRegExp("\n"), "<br>");
oneEntry += comment;
oneEntry += "\"";
- // qWarning (oneEntry);
+ // owarn << oneEntry << oendl;
t << oneEntry << endl;
- // qWarning (si->text(0));
+ // owarn << si->text(0) << oendl;
}
}
f.close();
}
void ZSafe::readAllEntries()
{
QString fn = filename + ".txt";
QFile f( fn );
if ( !f.open( IO_ReadOnly ) )
{
- qWarning( QString("Could not read file %1").arg(fn),
- 2000 );
+ owarn << "Could not read file " << fn << oendl;
QMessageBox::critical( 0, tr("ZSafe"),
tr("Could not import text file.") );
return;
}
modified = true;
// clear the password list
selectedItem = NULL;
QListViewItem *i;
// step through all categories
for (i = ListView->firstChild();
i != NULL;
i = i->nextSibling())
{
// step through all subitems
QListViewItem *si;
for (si = i->firstChild();
si != NULL; )
// si = si->nextSibling())
{
QListViewItem *_si = si;
si = si->nextSibling();
i->takeItem(_si); // remove from view list
if (_si) delete _si;
}
}
- qWarning ("ReadAllEntries(): ");
+ owarn << "ReadAllEntries(): " << oendl;
QTextStream t(&f);
while ( !t.eof() )
{
QString s = t.readLine();
s.replace (QRegExp("\";\""), "\"|\"");
// char buffer[1024];
int len=s.length()+1;
#ifdef WIN32
char buffer[512];
#else
char buffer[len];
#endif
strcpy (buffer, s);
QString name;
QString user;
QString password;
QString comment;
// separete the entries
char *i = strtok (buffer, "|");
QString category(&i[1]);
category.truncate(category.length() -1);
int idx=0;
while (i = strtok (NULL, "|"))
{
switch (idx)
{
case 0:
name = &i[1];
name.truncate(name.length() -1);
// name
break;
case 1:
// user
user = &i[1];
user.truncate(user.length() -1);
break;
case 2:
// password
password = &i[1];
password.truncate(password.length() -1);
break;
case 3:
// comment
comment = &i[1];
comment.truncate(comment.length() -1);
break;
}
idx++;
}
Category *cat= categories.find (category);
if (cat)
{
// use the existend item
QListViewItem *catItem = cat->getListItem();
if (catItem)
{
QListViewItem * item = new ShadedListItem( 0, catItem );
item->setText( 0, tr( name ) );
item->setText( 1, tr( user ) );
item->setText( 2, tr( password ) );
item->setText( 3, tr( comment ) );
catItem->setOpen( TRUE );
}
}
else
{
QListViewItem *catI = new ShadedListItem( 1, ListView );
// create and insert a new item
QListViewItem * item = new ShadedListItem( 0, catI );
item->setText( 0, tr( name ) );
item->setText( 1, tr( user ) );
item->setText( 2, tr( password ) );
item->setText( 3, tr( comment ) );
catI->setOpen( TRUE );
Category *c1 = new Category();
c1->setCategoryName(category);
QString icon;
QString fullIconPath;
QPixmap *pix;
// #ifndef WIN32
icon = conf->readEntry(APP_KEY+category);
// #endif
bool isIconAv = false;
if (!icon.isEmpty() && !icon.isNull())
{
// build the full path
fullIconPath = iconPath + icon;
pix = new QPixmap (fullIconPath);
if (pix)
{
QImage img = pix->convertToImage();
pix->convertFromImage(img.smoothScale(14,14));
c1->setIconName (icon);
c1->setIcon (*pix);
isIconAv = true;
}
}
if (!isIconAv)
{
c1->setIcon (*getPredefinedIcon(category));
}
c1->setListItem (catI);
c1->initListItem();
categories.insert (c1->getCategoryName(), c1);
}
}
f.close();
}
#endif // UNUSED
void ZSafe::resume(int)
{
- qWarning ("Resume");
+ owarn << "Resume" << oendl;
// hide the main window
infoForm->hide();
// open zsafe again
m_password = "";
selectedItem = NULL;
// clear the password list
QListViewItem *i;
// step through all categories
for (i = ListView->firstChild();
i != NULL;
i = i->nextSibling())
{
// step through all subitems
QListViewItem *si;
for (si = i->firstChild();
si != NULL; )
{
QListViewItem *_si = si;
si = si->nextSibling();
i->takeItem(_si); // remove from view list
if (_si) delete _si;
}
}
// ask for password and read again
openDocument(filename);
}
//---------------------------------------------
bool ZSafe::openDocument(const char* _filename, const char* )
{
int retval;
char* entry[FIELD_SIZE];
// #ifndef WIN32
int validationFlag = conf->readNumEntry(APP_KEY+"valzsafe", 1);
// #else
// int validationFlag = 1;
// #endif
int pwdOk = 0;
int numberOfTries = 3;
for (int i=0; i < numberOfTries; i++)
{
QFile f(_filename);
if (f.exists())
{
// ask with a dialog for the password
if (m_password.isEmpty())
getDocPassword(tr("Enter Password"));
if (m_password.isEmpty() && validationFlag == 0)
{
- qWarning ("Wrong password");
+ owarn << "Wrong password" << oendl;
QMessageBox::critical( 0, tr("ZSafe"),
tr("Wrong password.\n\nZSafe will now exit.") );
exitZs (1);
}
retval = loadInit(_filename, m_password);
if (retval != PWERR_GOOD)
{
- qWarning ("Error loading Document");
+ owarn << "Error loading Document" << oendl;
return false;
}
}
else
{
#ifdef WIN32
this->setCaption("Qt ZSafe");
#else
this->setCaption("ZSafe");
#endif
filename = "";
return false;
}
// load the validation entry
if (validationFlag == 0)
{
pwdOk = 1;
break;
}
retval = loadEntry(entry);
if (retval == 1 &&
!strcmp (entry[0], "ZSAFECATEGORY") &&
!strcmp (entry[1], "name") &&
!strcmp (entry[2], "username") &&
!strcmp (entry[3], "password") &&
!strcmp (entry[4], "comment") )
{
for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]);
pwdOk = 1;
break;
}
else
// for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]);
fclose (fd);
m_password = "";
if (i < numberOfTries - 1)
{
switch( QMessageBox::warning( this, tr("ZSafe"),
tr("Wrong password.\nEnter again?"),
tr("&Yes"), tr("&No."),
0
) )
{
case 1: // No
exitZs (1);
break;
case 0: // Yes
continue;
}
}
}
if (pwdOk == 0)
{
// unset the document entry
conf->writeEntry(APP_KEY+"document", "INVALIDPWD");
if (conf)
delete conf;
exitZs (1);
}
retval = loadEntry(entry);
int numberOfEntries=0;
while (retval == 1) {
QString category( QString::fromUtf8(entry[0]) );
QString name( QString::fromUtf8(entry[1]) );
QString user( QString::fromUtf8(entry[2]) );
QString password( QString::fromUtf8(entry[3]) );
QString comment( QString::fromUtf8(entry[4]) );
QString field5( QString::fromUtf8(entry[5]) );
QString field6( QString::fromUtf8(entry[6]) );
// add the subitems to the categories
Category *cat= categories.find (category);
if (cat)
{
// use the existend item
QListViewItem *catItem = cat->getListItem();
if (catItem)
{
QListViewItem * item = new ShadedListItem( 0, catItem );
item->setText( 0, tr( name ) );
item->setText( 1, tr( user ) );
item->setText( 2, tr( password ) );
item->setText( 3, tr( comment ) );
item->setText( 4, tr( field5 ) );
item->setText( 5, tr( field6 ) );
if (expandTree)
@@ -2208,372 +2203,372 @@ bool ZSafe::saveDocument(const char* _filename,
// save the validation entry
{
int i=0;
entry[i] = (char*)malloc(strlen("ZSAFECATEGORY")+1);
strcpy(entry[i++], "ZSAFECATEGORY");
entry[i] = (char*)malloc(strlen("name")+1);
strcpy(entry[i++], "name");
entry[i] = (char*)malloc(strlen("username")+1);
strcpy(entry[i++], "username");
entry[i] = (char*)malloc(strlen("password")+1);
strcpy(entry[i++], "password");
entry[i] = (char*)malloc(strlen("comment")+1);
strcpy(entry[i++], "comment");
entry[i] = (char*)malloc(strlen("field5")+1);
strcpy(entry[i++], "field5");
entry[i] = (char*)malloc(strlen("field6")+1);
strcpy(entry[i++], "field6");
retval = saveEntry(entry);
for (int z=0; z<i; z++) free(entry[z]);
if (retval == PWERR_DATA) {
owarn << "1: Error writing file, contents not saved" << oendl;
saveFinalize();
return false;
}
// #ifndef WIN32
conf->writeEntry(APP_KEY+"valzsafe", 1);
// #endif
saveConf();
}
QListViewItem *i;
// step through all categories
for (i = ListView->firstChild();
i != NULL;
i = i->nextSibling())
{
// step through all subitems
QListViewItem *si;
for (si = i->firstChild();
si != NULL;
si = si->nextSibling())
{
int j=0;
entry[j] = (char*)malloc(strlen(i->text(0).utf8())+1);
strcpy(entry[j++], i->text(0).utf8());
entry[j] = (char*)malloc(strlen(si->text(0).utf8())+1);
strcpy(entry[j++], si->text(0).utf8());
entry[j] = (char*)malloc(strlen(si->text(1).utf8())+1);
strcpy(entry[j++], si->text(1).utf8());
entry[j] = (char*)malloc(strlen(si->text(2).utf8())+1);
strcpy(entry[j++], si->text(2).utf8());
entry[j] = (char*)malloc(strlen(si->text(3).utf8())+1);
strcpy(entry[j++], si->text(3).utf8());
entry[j] = (char*)malloc(strlen(si->text(4).utf8())+1);
strcpy(entry[j++], si->text(4).utf8());
entry[j] = (char*)malloc(strlen(si->text(5).utf8())+1);
strcpy(entry[j++], si->text(5).utf8());
retval = saveEntry(entry);
for (int z=0; z<j; z++)
{
free(entry[z]);
}
if (retval == PWERR_DATA) {
owarn << "1: Error writing file, contents not saved" << oendl;
saveFinalize();
return false;
}
}
}
if (saveFinalize() == PWERR_DATA) {
owarn << "2: Error writing file, contents not saved" << oendl;
return false;
} else {
#ifndef DESKTOP
Global::statusMessage (tr("Password file saved."));
#endif
modified = false;
return true;
}
}
PasswordForm *newPwdDialog;
bool newPwdDialogResult = false;
void ZSafe::setPasswordDialogDone()
{
newPwdDialogResult = true;
newPwdDialog->close();
}
void ZSafe::getDocPassword(QString title)
{
-qWarning ("getDocPassword");
+ owarn << "getDocPassword" << oendl;
// open the 'Password' dialog
PasswordForm *dialog = new PasswordForm(this, title, TRUE);
newPwdDialog = dialog;
newPwdDialogResult = false;
connect( dialog->PasswordField, SIGNAL( returnPressed() ),
this, SLOT( setPasswordDialogDone() ) );
// CS: !!!
// int pos = filename.findRev ('/');
QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
#ifdef WIN32
dialog->setCaption("Qt " + ti);
#else
dialog->setCaption(ti);
#endif
// dialog->setCaption(title);
dialog->PasswordField->setFocus();
DialogCode result = (DialogCode) dialog->exec();
#ifdef DESKTOP
result = Accepted;
#endif
QString password;
if (result == Accepted || newPwdDialogResult)
{
m_password = dialog->PasswordField->text();
}
else
{
exitZs (1);
}
}
int ZSafe::saveInit(const char *_filename, const char *password)
{
char key[128];
unsigned int j = 0;
unsigned int keylength;
// int val;
int count2;
Krc2* krc2 = new Krc2();
/* first we should check the permissions of the filename */
/*
if (QFile::exists(_filename)) {
val = checkFile(_filename);
if (val != PWERR_GOOD)
return val;
} else
{
val = creat (_filename, (S_IRUSR | S_IWUSR));
if (val == -1)
return PWERR_OPEN;
else
close(val);
}
*/
QFileInfo f (_filename);
save_buffer_length = f.size();
save_buffer_length = ((save_buffer_length / 1024)+1) * 1024;
fd = fopen (_filename, "wb");
if (fd == NULL)
return PWERR_OPEN;
buffer = (char*)malloc(save_buffer_length);
/* make the key ready */
for (j = 0; password[j] != '\0'; j++) {
key[j] = password[j];
}
keylength = j;
krc2->rc2_expandkey (key, keylength, 128);
/* First, we make the IV */
for (count2 = 0; count2 < 4; count2++) {
iv[count2] = rand ();
putc ((unsigned char) (iv[count2] >> 8), fd);
putc ((unsigned char) (iv[count2] & 0xff), fd);
}
bufferIndex = 0;
return PWERR_GOOD;
}
int ZSafe::saveEntry(char *entry[FIELD_SIZE])
{
char *text1;
int count2, count3;
unsigned short ciphertext[4];
Krc2* krc2 = new Krc2();
buffer = (char*)memset(buffer, '\0', save_buffer_length);
for (count2 = 0; count2 < FIELD_SIZE; count2++) {
text1 = entry[count2];
if (strlen (text1) == 0) {
strncat(buffer, " ", strlen(" "));
} else {
strncat(buffer, text1, strlen(text1));
}
/* Use 255 as the marker. \n is too tough to test for */
buffer[strlen (buffer)] = 255;
} /*for (count2 = 0; count2 < 5; count2++)*/
count2 = 0;
/* I'm using CBC mode and encrypting the data straight from top down.
* At the bottom, encrypted, I will append an MD5 hash of the file, eventually.
* PKCS 5 padding (explained at the code section
*/
while (count2 < (int)strlen (buffer)) {
#ifndef WORDS_BIGENDIAN
plaintext[bufferIndex] = buffer[count2 + 1] << 8;
plaintext[bufferIndex] += buffer[count2] & 0xff;
#endif
#ifdef WORDS_BIGENDIAN
plaintext[bufferIndex] = buffer[count2] << 8;
plaintext[bufferIndex] += buffer[count2 + 1] & 0xff;
#endif
bufferIndex++;
if (bufferIndex == 4) {
krc2->rc2_encrypt (plaintext);
for (count3 = 0; count3 < 4; count3++) {
ciphertext[count3] = iv[count3] ^ plaintext[count3];
/* Now store the ciphertext as the iv */
iv[count3] = plaintext[count3];
/* reset the buffer index */
bufferIndex = 0;
if (putc ((unsigned char) (ciphertext[count3] >> 8), fd) == EOF) return PWERR_DATA;
if (putc ((unsigned char) (ciphertext[count3] & 0xff), fd) == EOF) return PWERR_DATA;
} /*for (count3 = 0; count3 < 5; count3++)*/
} /*if (bufferIndex == 5)*/
/* increment a short, not a byte */
count2 += 2;
} /*while (count2 < strlen (buffer))*/
int ret = PWERR_GOOD;
return ret;
}
int ZSafe::saveFinalize(void)
{
int count1, retval = PWERR_GOOD;
unsigned short ciphertext[4];
Krc2* krc2 = new Krc2();
/* Tack on the PKCS 5 padding
* How it works is we fill up the last n bytes with the value n
*
* So, if we have, say, 13 bytes, 8 of which are used, we have 5 left
* over, leaving us 3 short, so we fill it in with 3's.
*
* If we come out even, we fill it with 8 8s
*
* um, except that in this instance we are using 4 shorts instead of 8 bytes.
* so, half everything
*/
for (count1 = bufferIndex; count1 < 4; count1++) {
plaintext[count1] = (4 - bufferIndex);
}
krc2->rc2_encrypt (plaintext);
for (count1 = 0; count1 < 4; count1++) {
ciphertext[count1] = iv[count1] ^ plaintext[count1];
if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA;
if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA;
}
fclose (fd);
free(buffer);
return retval;
}
void ZSafe::quitMe ()
{
- qWarning ("QUIT...");
+ owarn << "QUIT..." << oendl;
if (modified)
{
switch( QMessageBox::information( this, tr("ZSafe"),
tr("Do you want to save\nbefore exiting?"),
tr("&Save"),
tr("S&ave with\nnew\npassword"),
tr("&Don't Save"),
0 // Enter == button 0
) )
{ // Escape == button 2
case 0: // Save clicked, Alt-S or Enter pressed.
// save
modified = false;
saveDocument(filename, FALSE);
exitZs (1);
break;
case 1: //
// Save with new password
modified = false;
saveDocument(filename, TRUE);
exitZs (1);
break;
case 2: // Don't Save clicked or Alt-D pressed
// don't save but exitZs
exitZs (1);
break;
}
}
exitZs (1);
}
void ZSafe::categoryFieldActivated( const QString& category)
{
if (categoryDialog)
setCategoryDialogFields(categoryDialog, category);
}
void ZSafe::addCategory()
{
if (filename.isEmpty())
{
QMessageBox::critical( 0, tr("ZSafe"),
tr("No document defined.\nYou have to create a new document"));
return;
}
else
{
// open the 'Category' dialog
bool initIcons = false;
// open the 'Category' dialog
CategoryDialog *dialog;
if (categoryDialog)
{
dialog = categoryDialog;
}
else
{
categoryDialog = new CategoryDialog(this, tr("Category"), TRUE);
#ifdef WIN32
categoryDialog->setCaption ("Qt " + tr("Category"));
#endif
dialog = categoryDialog;
connect( dialog->CategoryField,
SIGNAL( activated(const QString&)),
this, SLOT( categoryFieldActivated(const QString&) ) );
initIcons = true;
}
#ifdef DESKTOP
#ifndef WIN32
QStringList list = conf->entryList( APP_KEY+"/fieldDefs" );
#else
// read all categories from the config file and store
// into a list
QFile f (cfgFile);
QStringList list;
if ( f.open(IO_ReadOnly) ) { // file opened successfully
QTextStream t( &f ); // use a text stream
QString s;
int n = 1;
while ( !t.eof() ) { // until end of file...
s = t.readLine(); // line of text excluding '\n'
list.append(s);
}
f.close();
}
#endif
#else
// read all categories from the config file and store
// into a list
QFile f (cfgFile);
QStringList list;
if ( f.open(IO_ReadOnly) ) { // file opened successfully
QTextStream t( &f ); // use a text stream
@@ -2591,193 +2586,193 @@ void ZSafe::addCategory()
dialog->CategoryField->clear(); // remove all items
while( it != list.end() )
{
QString *cat = new QString (*it);
if (cat->contains("-field1", FALSE))
{
#ifdef DESKTOP
#ifndef WIN32
categ = cat->section ("-field1", 0, 0);
#else
int pos = cat->find ("-field1");
categ = cat->left (pos);
#endif
#else
int pos = cat->find ("-field1");
cat->truncate(pos);
categ = *cat;
#endif
if (!categ.isEmpty())
{
dialog->CategoryField->insertItem (categ, -1);
if (firstCategory.isEmpty())
firstCategory = categ;
}
}
++it;
}
if (firstCategory.isEmpty())
setCategoryDialogFields(dialog);
else
setCategoryDialogFields(dialog, firstCategory);
// CategoryDialog *dialog = new CategoryDialog(this, "Category", TRUE);
if (initIcons)
{
Wait waitDialog(this, tr("Wait dialog"));
waitDialog.waitLabel->setText(tr("Gathering icons..."));
waitDialog.show();
qApp->processEvents();
#ifdef DESKTOP
QDir d(iconPath);
#else
QDir d(QPEApplication::qpeDir() + "/pics/");
#endif
d.setFilter( QDir::Files);
const QFileInfoList *list = d.entryInfoList();
QFileInfoListIterator it( *list ); // create list iterator
QFileInfo *fi; // pointer for traversing
dialog->IconField->insertItem("predefined");
while ( (fi=it.current()) ) { // for each file...
QString fileName = fi->fileName();
if(fileName.right(4) == ".png"){
fileName = fileName.mid(0,fileName.length()-4);
#ifdef DESKTOP
QPixmap imageOfFile;
imageOfFile.load(iconPath + fi->fileName());
#else
QPixmap imageOfFile(Resource::loadPixmap(fileName));
#endif
QImage foo = imageOfFile.convertToImage();
foo = foo.smoothScale(16,16);
imageOfFile.convertFromImage(foo);
dialog->IconField->insertItem(imageOfFile,fileName);
}
++it;
}
waitDialog.hide();
}
#ifndef WIN32
dialog->show();
#endif
#ifndef DESKTOP
// dialog->move (20, 100);
#endif
DialogCode result = (DialogCode) dialog->exec();
#ifdef DESKTOP
result = Accepted;
#endif
QString category;
QString icon;
QString fullIconPath;
QPixmap *pix;
if (result == Accepted)
{
modified = true;
category = dialog->CategoryField->currentText();
icon = dialog->IconField->currentText()+".png";
- qWarning (category);
+ owarn << category << oendl;
QListViewItem *li = new ShadedListItem( 1, ListView );
Category *c1 = new Category();
c1->setCategoryName(category);
// if (!icon.isEmpty() && !icon.isNull())
if (icon != "predefined.png")
{
// build the full path
fullIconPath = iconPath + icon;
pix = new QPixmap (fullIconPath);
// pix->resize(14, 14);
if (pix)
{
// save the full pixmap name into the config file
// #ifndef WIN32
conf->writeEntry(APP_KEY+category, icon);
// #endif
saveConf();
QImage img = pix->convertToImage();
pix->convertFromImage(img.smoothScale(14,14));
c1->setIcon (*pix);
c1->setIconName(icon);
}
else
{
QPixmap folder( ( const char** ) general_data );
c1->setIcon (folder);
}
}
else
{
c1->setIcon (*getPredefinedIcon(category));
}
c1->setListItem (li);
c1->initListItem();
categories.insert (c1->getCategoryName(), c1);
saveCategoryDialogFields(dialog);
}
else
{
// delete dialog;
dialog->hide();
return;
}
}
}
void ZSafe::delCategory()
{
if (!selectedItem)
return;
if (isCategory(selectedItem))
{
switch( QMessageBox::information( this, tr("ZSafe"),
tr("Do you want to delete?"),
tr("&Delete"), tr("D&on't Delete"),
0 // Enter == button 0
) ) { // Escape == button 2
case 0: // Delete clicked, Alt-S or Enter pressed.
// Delete from the category list
modified = true;
categories.remove (selectedItem->text(0));
// #ifndef WIN32
conf->removeEntry (selectedItem->text(0));
// #endif
saveConf();
// Delete the selected item and all subitems
// step through all subitems
QListViewItem *si;
for (si = selectedItem->firstChild();
si != NULL; )
{
QListViewItem *_si = si;
si = si->nextSibling();
selectedItem->takeItem(_si); // remove from view list
if (_si) delete _si;
}
ListView->takeItem(selectedItem);
delete selectedItem;
selectedItem = NULL;
break;
case 1: // Don't delete
break;
}
}
}
void ZSafe::setCategoryDialogFields(CategoryDialog *dialog)
@@ -3099,193 +3094,193 @@ void ZSafe::editCategory()
#endif
d.setFilter( QDir::Files);
const QFileInfoList *list = d.entryInfoList();
int i=0;
QFileInfoListIterator it( *list ); // create list iterator
QFileInfo *fi; // pointer for traversing
if (icon.isEmpty() || icon.isNull())
{
dialog->IconField->setCurrentItem(0);
}
else
{
while ( (fi=it.current()) )
{ // for each file...
QString fileName = fi->fileName();
if(fileName.right(4) == ".png")
{
fileName = fileName.mid(0,fileName.length()-4);
if(fileName+".png"==icon)
{
dialog->IconField->setCurrentItem(i+1);
break;
}
++i;
}
++it;
}
}
}
// dialog->show();
#ifndef DESKTOP
// dialog->move (20, 100);
#endif
DialogCode result = (DialogCode) dialog->exec();
#ifdef DESKTOP
result = Accepted;
#endif
QString fullIconPath;
QPixmap *pix;
if (result == Accepted)
{
modified = true;
if (category != dialog->CategoryField->currentText())
{
categories.remove (category);
// #ifndef WIN32
conf->removeEntry(category);
// #endif
saveConf();
}
category = dialog->CategoryField->currentText();
icon = dialog->IconField->currentText()+".png";
if (cat)
{
owarn << "Category found" << oendl;
// if (!icon.isEmpty() && !icon.isNull())
if (icon != "predefined.png")
{
// build the full path
fullIconPath = iconPath + icon;
pix = new QPixmap (fullIconPath);
if (pix)
{
// save the full pixmap name into the config file
// #ifndef WIN32
conf->writeEntry(APP_KEY+category, icon);
// #endif
saveConf();
QImage img = pix->convertToImage();
pix->convertFromImage(img.smoothScale(14,14));
cat->setIconName (icon);
cat->setIcon (*pix);
}
}
else
{
// #ifndef WIN32
conf->removeEntry (category);
// #endif
saveConf();
cat->setIcon (*getPredefinedIcon(category));
}
// change the category name of the selected category
QListViewItem *catItem = cat->getListItem();
if (catItem)
{
- qWarning (category);
+ owarn << category << oendl;
catItem->setText( 0, tr( category ) );
cat->setCategoryName (tr(category));
cat->initListItem();
categories.insert (category, cat);
}
}
saveCategoryDialogFields(dialog);
}
else
{
// delete dialog;
dialog->hide();
return;
}
}
}
void ZSafe::cutItem()
{
if (!selectedItem)
return;
if (!isCategory(selectedItem))
{
IsCut = true;
copiedItem = selectedItem;
}
}
void ZSafe::copyItem()
{
if (!selectedItem)
return;
if (!isCategory(selectedItem))
{
IsCopy = true;
copiedItem = selectedItem;
}
}
// paste item into category
void ZSafe::pasteItem()
{
if (!selectedItem)
return;
if (isCategory(selectedItem))
{
modified = true;
if (IsCut)
{
if (copiedItem)
{
// add the new item
QListViewItem *i = new ShadedListItem (0, selectedItem);
// i->setOpen (TRUE);
i->setText (0, copiedItem->text(0));
i->setText (1, copiedItem->text(1));
i->setText (2, copiedItem->text(2));
i->setText (3, copiedItem->text(3));
i->setText (4, copiedItem->text(4));
i->setText (5, copiedItem->text(5));
selectedItem->setOpen( TRUE );
// remove the cutted item
copiedItem->parent()->takeItem(copiedItem);
selectedItem = NULL;
}
}
else if (IsCopy)
{
if (copiedItem)
{
// add the new item
QListViewItem *i = new ShadedListItem (0, selectedItem);
// i->setOpen (TRUE);
i->setText (0, copiedItem->text(0));
i->setText (1, copiedItem->text(1));
i->setText (2, copiedItem->text(2));
i->setText (3, copiedItem->text(3));
i->setText (4, copiedItem->text(4));
i->setText (5, copiedItem->text(5));
selectedItem->setOpen( TRUE );
}
}
}
IsCut = false;
IsCopy = false;
}
void ZSafe::newDocument()
{
// open the file dialog
#ifndef DESKTOP
#ifndef NO_OPIE
@@ -3500,193 +3495,193 @@ void ZSafe::saveDocumentAs()
this->setCaption("ZSafe: " + ti);
#endif
QMessageBox::information( this, tr("ZSafe"),
tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0);
saveDocumentWithPwd();
}
}
void ZSafe::saveDocumentWithoutPwd()
{
saveDocument(filename, FALSE);
}
void ZSafe::saveDocumentWithPwd()
{
saveDocument(filename, TRUE);
}
void ZSafe::about()
{
QString info;
#ifdef JPATCH_HDE
info = "<html><body><div align=""center"">";
info += "<b>";
info += tr("Zaurus Password Manager<br>");
info += tr("ZSafe version 2.1.2-jv01b<br>");
info += "</b>";
info += tr("by Carsten Schneider<br>");
info += "zcarsten@gmx.net<br>";
info += "http://z-soft.z-portal.info/zsafe";
info += "<br>";
info += tr("Translations by Robert Ernst<br>");
info += "robert.ernst@linux-solutions.at<br>";
info += "<br><br>";
info += QString::fromUtf8("æ~W¥æ~\\¬èª~^/VGA Zaurus対å¿~\\ã~C~Qã~C~Cã~C~Aä½~\\æ ~H~P<br>");
info += "HADECO R&D<br>";
info += "r&d@hadeco.co.jp<br>";
info += "http://www.hadeco.co.jp/r&d/<br>";
info += "<br></div>";
info += "</body></html>";
#else
info = "<html><body><div align=""center"">";
info += "<b>";
info += tr("Zaurus Password Manager<br>");
info += tr("ZSafe version 2.1.2<br>");
info += "</b>";
info += tr("by Carsten Schneider<br>");
info += "zcarsten@gmx.net<br>";
info += "http://z-soft.z-portal.info/zsafe";
info += "<br>";
info += tr("Translations by Robert Ernst<br>");
info += "robert.ernst@linux-solutions.at<br>";
info += "<br></div>";
info += "</body></html>";
#endif
// QMessageBox::information( this, tr("ZSafe"), info, tr("&OK"), 0);
QMessageBox mb( this, tr("ZSafe"));
mb.setText (info);
mb.setButtonText (QMessageBox::Ok, tr ("&OK"));
QPixmap zsafe_img((const char**) zsafe_xpm);
mb.setIconPixmap (zsafe_img);
mb.exec();
}
void ZSafe::setExpandFlag()
{
expandTree = !expandTree;
file->setItemChecked('o', expandTree);
#ifndef DESKTOP
conf->setGroup ("zsafePrefs");
#endif
// #ifndef WIN32
conf->writeEntry (APP_KEY+"expandTree", expandTree);
// #endif
saveConf();
}
void ZSafe::paintEvent( QPaintEvent * )
{
if (raiseFlag)
{
raiseFlag = false;
raiseTimer.start (1, true);
if (infoForm->isVisible())
infoForm->raise();
}
}
void ZSafe::resizeEvent ( QResizeEvent * )
{
- // qWarning ("resizeEvent");
+ // owarn << "resizeEvent" << oendl;
#ifndef DESKTOP
DeskW = appl->desktop()->width();
DeskH = appl->desktop()->height();
#else
DeskW = this->width();
DeskH = this->height();
#endif
if (New)
New->setGeometry ( QRect( DeskW-84, 2, 20, 20 ) );
if (Edit)
Edit->setGeometry ( QRect( DeskW-64, 2, 20, 20 ) );
if (Delete)
Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) );
if (Find)
Find->setGeometry ( QRect( DeskW-24, 2, 20, 20 ) );
}
void ZSafe::slotRaiseTimer()
{
if (infoForm->isVisible())
infoForm->raise();
raiseFlag = true;
}
QPixmap * ZSafe::getPredefinedIcon(QString category)
{
QPixmap *pm;
if (category == "Bank cards")
pm = new QPixmap((const char**)bank_cards_data);
else if (category == "Passwords")
pm = new QPixmap((const char**)passwords_data);
else if (category == "Software")
pm = new QPixmap((const char**)software_data);
else if (category == "General")
pm = new QPixmap((const char**)general_data);
else
pm = new QPixmap((const char**)general_data);
return pm;
}
void ZSafe::setDocument(const QString& fileref)
{
#ifndef DESKTOP
// stop the timer to prevent loading of the default document
docuTimer.stop();
DocLnk link(fileref);
if ( link.isValid() )
{
// if (filename != link.file())
// saveDocument(filename, FALSE);
filename = link.file();
}
else
{
// if (filename != fileref)
// saveDocument(filename, FALSE);
filename = fileref;
}
// save the current filename to the config file
conf->writeEntry(APP_KEY+"document", filename);
saveConf();
QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
#ifdef WIN32
this->setCaption("Qt ZSafe: " + ti);
#else
this->setCaption("ZSafe: " + ti);
#endif
// clear the password list
QListViewItem *i;
QListViewItem *c = NULL;
// step through all categories
for (i = ListView->firstChild();
i != NULL;
i = i->nextSibling())
{
if (c) delete c; // delete the previous category
c = i;
// step through all subitems
QListViewItem *si;
for (si = i->firstChild();
si != NULL; )
{
QListViewItem *_si = si;
si = si->nextSibling();
i->takeItem(_si); // remove from view list
if (_si) delete _si;
}
}
if (c) delete c; // delete the previous category
categories.clear();
m_password = "";
diff --git a/noncore/comm/keypebble/krfbdecoder.cpp b/noncore/comm/keypebble/krfbdecoder.cpp
index d61433f..837fcc5 100644
--- a/noncore/comm/keypebble/krfbdecoder.cpp
+++ b/noncore/comm/keypebble/krfbdecoder.cpp
@@ -1,835 +1,831 @@
#include "krfbconnection.h"
#include "krfbserverinfo.h"
#include "krfbdecoder.h"
#include "krfbbuffer.h"
/* OPIE */
#include <opie2/odebug.h>
using namespace Opie::Core;
/* QT */
#include <qpixmap.h>
/* STD */
#include <assert.h>
//
// Endian stuff
//
//#ifndef OPIE_NO_DEBUG
const int endianTest = 1;
//#endif
#define Swap16IfLE(s) \
(*(char *)&endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s))
#define Swap32IfLE(l) \
(*(char *)&endianTest ? ((((l) & 0xff000000) >> 24) | \
- (((l) & 0x00ff0000) >> 8) | \
- (((l) & 0x0000ff00) << 8) | \
- (((l) & 0x000000ff) << 24)) : (l))
+ (((l) & 0x00ff0000) >> 8) | \
+ (((l) & 0x0000ff00) << 8) | \
+ (((l) & 0x000000ff) << 24)) : (l))
//
// The lengths of the messages we need to wait for
//
const int ServerInitLength = 24;
const int UpdateHeaderLength = 4;
const int RectHeaderLength = 12;
const int RectChunkSize = 4;
const int CopyRectPosLength = 4;
const int ServerCutLenLength = 7;
//
// Client -> Server Message Identifiers
//
static CARD8 SetPixelFormatId = 0;
//static CARD8 FixColourMapEntriesId = 1; // Not used
static CARD8 SetEncodingsId = 2;
static CARD8 UpdateRequestId = 3;
static CARD8 KeyEventId = 4;
static CARD8 PointerEventId = 5;
static CARD8 ClientCutTextId = 6;
//
// Server -> Client Message Identifiers
//
static CARD8 UpdateId = 0;
static CARD8 BellId = 2;
static CARD8 ServerCutId = 3;
//
// Encoding identifiers
//
static CARD32 RawEncoding = Swap32IfLE( 0 );
static CARD32 CopyRectEncoding = Swap32IfLE(1 );
static CARD32 RreEncoding = Swap32IfLE( 2 );
static CARD32 CorreEncoding = Swap32IfLE( 4 );
static CARD32 HexTileEncoding = Swap32IfLE( 5 );
static struct {
int keysym;
int keycode;
} keyMap[] = {
{ 0xff08, Qt::Key_Backspace },
{ 0xff09, Qt::Key_Tab },
{ 0xff0d, Qt::Key_Return },
{ 0xff1b, Qt::Key_Escape },
{ 0xff63, Qt::Key_Insert },
{ 0xffff, Qt::Key_Delete },
{ 0xff50, Qt::Key_Home },
{ 0xff57, Qt::Key_End },
{ 0xff55, Qt::Key_Prior },
{ 0xff56, Qt::Key_Next },
{ 0xff51, Qt::Key_Left },
{ 0xff52, Qt::Key_Up },
{ 0xff53, Qt::Key_Right },
{ 0xff54, Qt::Key_Down },
{ 0xffbe, Qt::Key_F1 },
{ 0xffbf, Qt::Key_F2 },
{ 0xffc0, Qt::Key_F3 },
{ 0xffc1, Qt::Key_F4 },
{ 0xffc2, Qt::Key_F5 },
{ 0xffc3, Qt::Key_F6 },
{ 0xffc4, Qt::Key_F7 },
{ 0xffc5, Qt::Key_F8 },
{ 0xffc6, Qt::Key_F9 },
{ 0xffc7, Qt::Key_F10 },
{ 0xffc8, Qt::Key_F11 },
{ 0xffc9, Qt::Key_F12 },
{ 0xffe1, Qt::Key_Shift },
{ 0xffe2, Qt::Key_Shift },
{ 0xffe3, Qt::Key_Control },
{ 0xffe4, Qt::Key_Control },
{ 0xffe7, Qt::Key_Meta },
{ 0xffe8, Qt::Key_Meta },
{ 0xffe9, Qt::Key_Alt },
{ 0xffea, Qt::Key_Alt },
{ 0, 0 }
};
KRFBDecoder::KRFBDecoder( KRFBConnection *con )
: QObject( con, "RFB Decoder" )
{
assert( con );
assert( con->state() == KRFBConnection::Connected );
this->con = con;
this->buf = 0;
this->info = 0;
this->format = 0;
this->buttonMask = 0;
currentState = Idle;
}
KRFBDecoder::~KRFBDecoder()
{
if ( info )
delete info;
if ( format )
delete format;
}
void KRFBDecoder::start()
{
sendClientInit();
}
void KRFBDecoder::sendClientInit()
{
con->write( &( con->options()->shared ), 1 );
// Wait for server init
- owarn << "Waiting for server init" << oendl;
+ owarn << "Waiting for server init" << oendl;
static QString statusMsg = tr( "Waiting for server initialization..." );
emit status( statusMsg );
currentState = AwaitingServerInit;
connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerInit() ) );
con->waitForData( ServerInitLength );
}
void KRFBDecoder::gotServerInit()
{
- owarn << "Got server init" << oendl;
+ owarn << "Got server init" << oendl;
disconnect( con, SIGNAL( gotEnoughData() ), this, SLOT( gotServerInit() ) );
if ( info )
delete info;
info = new KRFBServerInfo;
CHECK_PTR( info );
con->read( &(info->width), 2 );
info->width = Swap16IfLE( info->width );
con->read( &info->height, 2 );
info->height = Swap16IfLE( info->height );
con->read( &(info->bpp), 1 );
con->read( &(info->depth), 1 );
con->read( &(info->bigEndian), 1 );
con->read( &(info->trueColor), 1 );
con->read( &(info->redMax), 2 );
info->redMax = Swap16IfLE( info->redMax );
con->read( &(info->greenMax), 2 );
info->greenMax = Swap16IfLE( info->greenMax );
con->read( &(info->blueMax), 2 );
info->blueMax = Swap16IfLE( info->blueMax );
con->read( &(info->redShift), 1 );
con->read( &(info->greenShift), 1 );
con->read( &(info->blueShift), 1 );
con->read( info->padding, 3 );
con->read( &(info->nameLength), 4 );
info->nameLength = Swap32IfLE( info->nameLength );
- owarn << "Width = " << info->width << ", Height = " << info->height << "" << oendl;
- qWarning( "Bpp = %d, Depth = %d, Big = %d, True = %d",
- info->bpp, info->depth, info->bigEndian, info->trueColor );
- qWarning( "RedMax = %d, GreenMax = %d, BlueMax = %d",
- info->redMax, info->greenMax, info->blueMax );
- qWarning( "RedShift = %d, GreenShift = %d, BlueShift = %d",
- info->redShift, info->greenShift,info-> blueShift );
+ owarn << "Width = " << info->width << ", Height = " << info->height << "" << oendl;
+ owarn << "Bpp = " << info->bpp << ", Depth = " << info->depth << ", Big = " << info->bigEndian
+ << ", True = " << info->trueColor << oendl;
+ owarn << "RedMax = " << info->redMax << ", GreenMax = " << info->greenMax << ", BlueMax = " << info->blueMax << oendl;
+ owarn << "RedShift = " << info->redShift << ", GreenShift = " << info->greenShift
+ << ", BlueShift = " << info-> blueShift << oendl;
buf->resize( info->width/con->options()->scaleFactor, info->height /con->options()->scaleFactor);
// Wait for desktop name
- owarn << "Waiting for desktop name" << oendl;
+ owarn << "Waiting for desktop name" << oendl;
static QString statusMsg = tr( "Waiting for desktop name..." );
emit status( statusMsg );
currentState = AwaitingDesktopName;
connect( con, SIGNAL( gotEnoughData() ), SLOT( gotDesktopName() ) );
con->waitForData( info->nameLength );
}
void KRFBDecoder::gotDesktopName()
{
assert( info );
assert( currentState == AwaitingDesktopName );
- owarn << "Got desktop name" << oendl;
+ owarn << "Got desktop name" << oendl;
disconnect( con, SIGNAL( gotEnoughData() ),
- this, SLOT( gotDesktopName() ) );
+ this, SLOT( gotDesktopName() ) );
char *buf = new char[ info->nameLength + 1 ];
CHECK_PTR( buf );
con->read( buf, info->nameLength );
buf[ info->nameLength ] = '\0';
info->name = buf;
- owarn << "Desktop: " << info->name.latin1() << "" << oendl;
+ owarn << "Desktop: " << info->name.latin1() << "" << oendl;
delete buf;
// Get the format we'll really use and tell the server
decidePixelFormat();
sendPixelFormat();
sendAllowedEncodings();
currentState = Idle;
QString msg;
msg = tr( "Connected to %1" );
msg = msg.arg( info->name );
emit status( msg );
sendUpdateRequest( false );
}
void KRFBDecoder::decidePixelFormat()
{
assert( info );
if ( format )
delete format;
format = new KRFBPixelFormat;
CHECK_PTR( format );
// What depth do we want?
//
// We'll use the minimum of the remote and local depths, UNLESS an
// eight bit session has been specifically requested by the user.
int screenDepth = QPixmap::defaultDepth();
int bestDepth = ( screenDepth > info->depth ) ? info->depth : screenDepth;
int chosenDepth;
if ( con->options()->colors256 )
chosenDepth = 8;
else
chosenDepth = bestDepth;
- qWarning( "Screen depth=%d, server depth=%d, best depth=%d, " \
- "eight bit %d, chosenDepth=%d",
- screenDepth,
- info->depth,
- bestDepth,
- con->options()->colors256, chosenDepth );
+ owarn << "Screen depth=" << screenDepth << ", server depth=" << info->depth
+ << ", best depth=" << bestDepth << "eight bit " << con->options()->colors256
+ << ", chosenDepth=" << chosenDepth << oendl;
format->depth = chosenDepth;
// If we're using the servers native depth
if ( chosenDepth == info->depth ) {
// Use the servers native format
format->bpp = info->bpp;
// format->bigEndian = info->bigEndian;
format->bigEndian = true;
format->trueColor = info->trueColor;
format->redMax = info->redMax;
format->greenMax = info->greenMax;
format->blueMax = info->blueMax;
format->redShift = info->redShift;
format->greenShift = info->greenShift;
format->blueShift = info->blueShift;
}
else {
if ( chosenDepth == 8 ) {
format->bpp = 8;
format->bigEndian = true;
format->trueColor = true;
format->redMax = 7;
format->greenMax = 7;
format->blueMax = 3;
format->redShift = 0;
format->greenShift = 3;
format->blueShift = 6;
}
}
format->redMax = Swap16IfLE( format->redMax );
format->greenMax = Swap16IfLE( format->greenMax );
format->blueMax = Swap16IfLE( format->blueMax );
}
void KRFBDecoder::sendPixelFormat()
{
static char padding[3];
con->write( &SetPixelFormatId, 1 );
con->write( padding, 3 );
con->write( &(format->bpp), 1 );
con->write( &(format->depth), 1 );
con->write( &(format->bigEndian), 1 );
con->write( &(format->trueColor), 1 );
con->write( &(format->redMax), 2 );
con->write( &(format->greenMax), 2 );
con->write( &(format->blueMax), 2 );
con->write( &(format->redShift), 1 );
con->write( &(format->greenShift), 1 );
con->write( &(format->blueShift), 1 );
con->write( format->padding, 3 ); // Padding
}
void KRFBDecoder::sendAllowedEncodings()
{
static CARD8 padding[1];
con->write( &SetEncodingsId, 1 );
con->write( padding, 1 );
CARD16 noEncodings = con->options()->encodings();
noEncodings = Swap16IfLE( noEncodings );
con->write( &noEncodings, 2 );
if ( con->options()->corre )
con->write( &CorreEncoding, 4 );
if ( con->options()->hexTile )
con->write( &HexTileEncoding, 4 );
if ( con->options()->rre )
con->write( &RreEncoding, 4 );
if ( con->options()->copyrect )
con->write( &CopyRectEncoding, 4 );
// We always support this
con->write( &RawEncoding, 4 );
}
void KRFBDecoder::sendUpdateRequest( bool incremental )
{
if ( currentState != Idle )
return;
con->write( &UpdateRequestId, 1 );
con->write( &incremental, 1 );
static CARD16 x = 0, y = 0;
static CARD16 w = Swap16IfLE( info->width );
static CARD16 h = Swap16IfLE( info->height );
con->write( &x, 2 );
con->write( &y, 2 );
con->write( &w, 2 );
con->write( &h, 2 );
// Now wait for the update
currentState = AwaitingUpdate;
connect( con, SIGNAL( gotEnoughData() ), SLOT( gotUpdateHeader() ) );
con->waitForData( UpdateHeaderLength );
}
void KRFBDecoder::gotUpdateHeader()
{
assert( currentState == AwaitingUpdate );
- // owarn << "Got update header" << oendl;
+ // owarn << "Got update header" << oendl;
disconnect( con, SIGNAL( gotEnoughData() ),
- this, SLOT( gotUpdateHeader() ) );
+ this, SLOT( gotUpdateHeader() ) );
CARD8 msgType;
con->read( &msgType, 1 );
if ( msgType != UpdateId ) {
// We might have a bell or server cut
if ( msgType == ServerCutId ) {
oldState = currentState;
gotServerCut();
}
else if ( msgType == BellId ) {
oldState = currentState;
gotBell();
}
else {
int msg = msgType;
QString protocolError = tr( "Protocol Error: Message Id %1 was "
"found when expecting an update "
"message." ).arg( msg );
currentState = Error;
emit error( protocolError );
}
return;
}
CARD8 padding;
con->read( &padding, 1 );
con->read( &noRects, 2 );
noRects = Swap16IfLE( noRects );
- // owarn << "Expecting " << noRects << " rects" << oendl;
+ // owarn << "Expecting " << noRects << " rects" << oendl;
// Now wait for the data
currentState = AwaitingRectHeader;
connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) );
con->waitForData( RectHeaderLength );
}
void KRFBDecoder::gotRectHeader()
{
assert( currentState == AwaitingRectHeader );
- // owarn << "Got rect header" << oendl;
+ // owarn << "Got rect header" << oendl;
disconnect( con, SIGNAL( gotEnoughData() ),
- this, SLOT( gotRectHeader() ) );
+ this, SLOT( gotRectHeader() ) );
con->read( &x, 2 );
x = Swap16IfLE( x );
con->read( &y, 2 );
y = Swap16IfLE( y );
con->read( &w, 2 );
w = Swap16IfLE( w );
con->read( &h, 2 );
h = Swap16IfLE( h );
con->read( &encoding, 4 );
// CARD32 encodingLocal = Swap32IfLE( encoding );
- // qWarning( "Rect: x=%d, y= %d, w=%d, h=%d, encoding=%ld",
- // x, y, w, h, encodingLocal );
+ // owarn << "Rect: x=" << x << ", y= " << y << ", w=" << w << ", h=" << h
+ // << ", encoding= " << encodingLocal << oendl;
//
// Each encoding needs to be handled differently. Some require
// waiting for more data, but others like a copyrect do not.
// Our constants have already been byte swapped, so we use
// the remote value as is.
//
if ( encoding == RawEncoding ) {
- // owarn << "Raw encoding" << oendl;
+ // owarn << "Raw encoding" << oendl;
handleRawRect();
}
else if ( encoding == CopyRectEncoding ) {
-// owarn << "CopyRect encoding" << oendl;
+// owarn << "CopyRect encoding" << oendl;
handleCopyRect();
}
else if ( encoding == RreEncoding ) {
- owarn << "RRE encoding" << oendl;
+ owarn << "RRE encoding" << oendl;
handleRRERect();
}
else if ( encoding == CorreEncoding ) {
- owarn << "CoRRE encoding" << oendl;
+ owarn << "CoRRE encoding" << oendl;
handleCoRRERect();
}
else if ( encoding == HexTileEncoding ) {
- owarn << "HexTile encoding" << oendl;
+ owarn << "HexTile encoding" << oendl;
handleHexTileRect();
}
else {
int msg = Swap32IfLE( encoding );
QString protocolError = tr( "Protocol Error: An unknown encoding was "
- "used by the server %1" ).arg( msg );
+ "used by the server %1" ).arg( msg );
currentState = Error;
- owarn << "Unknown encoding, " << msg << "" << oendl;
+ owarn << "Unknown encoding, " << msg << "" << oendl;
emit error( protocolError );
return;
}
}
//
// Raw Encoding
//
void KRFBDecoder::handleRawRect()
{
// We need something a bit cleverer here to handle large
// rectanges nicely. The chunking should be based on the
// overall size (but has to be in complete lines).
- // owarn << "Handling a raw rect chunk" << oendl;
+ // owarn << "Handling a raw rect chunk" << oendl;
// CARD32 lineCount = w * format->bpp / 8;
if ( h > RectChunkSize ) {
// if ( con->sock->size() / lineCount ) {
// getRawRectChunk( con->sock->size() / lineCount );
// }
// else {
getRawRectChunk( RectChunkSize );
// }
}
else {
getRawRectChunk( h );
}
}
void KRFBDecoder::getRawRectChunk( int lines )
{
this->lines = lines;
CARD32 count = lines * w * format->bpp / 8;
// Wait for server init
- // owarn << "Waiting for raw rect chunk, " << count << "" << oendl;
+ // owarn << "Waiting for raw rect chunk, " << count << "" << oendl;
currentState = AwaitingRawRectChunk;
connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRawRectChunk() ) );
con->waitForData( count );
}
void KRFBDecoder::gotRawRectChunk()
{
assert( currentState == AwaitingRawRectChunk );
disconnect( con, SIGNAL( gotEnoughData() ),
this, SLOT( gotRawRectChunk() ) );
- // owarn << "Got raw rect chunk" << oendl;
+ // owarn << "Got raw rect chunk" << oendl;
//
// Read the rect data and copy it to the buffer.
//
// TODO: Replace this!
int count = lines * w * format->bpp / 8;
char *hack = new char[ count ];
con->read( hack, count );
buf->drawRawRectChunk( hack, x, y, w, lines );
delete hack;
// /TODO:
h = h - lines;
y = y + lines;
if ( h > 0 ) {
handleRawRect();
}
else {
noRects--;
- // owarn << "There are " << noRects << " rects left" << oendl;
+ // owarn << "There are " << noRects << " rects left" << oendl;
if ( noRects ) {
currentState = AwaitingRectHeader;
connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) );
con->waitForData( RectHeaderLength );
}
else {
// we are now ready for the next update - no need to wait for the timer
currentState = Idle;
sendUpdateRequest (1);
}
}
}
//
// Copy Rectangle Encoding
//
void KRFBDecoder::handleCopyRect()
{
currentState = AwaitingCopyRectPos;
connect( con, SIGNAL( gotEnoughData() ), SLOT( gotCopyRectPos() ) );
con->waitForData( CopyRectPosLength );
}
void KRFBDecoder::gotCopyRectPos()
{
disconnect( con, SIGNAL( gotEnoughData() ),
this, SLOT( gotCopyRectPos() ) );
CARD16 srcX;
CARD16 srcY;
con->read( &srcX, 2 );
con->read( &srcY, 2 );
srcX = Swap16IfLE( srcX );
srcY = Swap16IfLE( srcY );
buf->copyRect( srcX, srcY, x, y, w, h );
noRects--;
- // owarn << "There are " << noRects << " rects left" << oendl;
+ // owarn << "There are " << noRects << " rects left" << oendl;
if ( noRects ) {
currentState = AwaitingRectHeader;
connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) );
con->waitForData( RectHeaderLength );
}
else
currentState = Idle;
}
void KRFBDecoder::handleRRERect()
{
- owarn << "RRE not implemented" << oendl;
+ owarn << "RRE not implemented" << oendl;
}
void KRFBDecoder::handleCoRRERect()
{
- owarn << "CoRRE not implemented" << oendl;
+ owarn << "CoRRE not implemented" << oendl;
}
void KRFBDecoder::handleHexTileRect()
{
- owarn << "HexTile not implemented" << oendl;
+ owarn << "HexTile not implemented" << oendl;
}
void KRFBDecoder::sendMouseEvent( QMouseEvent *e )
{
// Deal with the buttons
if ( e->type() != QEvent::MouseMove ) {
buttonMask = 0;
if ( e->type() == QEvent::MouseButtonPress ) {
if ( e->button() & LeftButton )
buttonMask |= 0x01;
if ( e->button() & MidButton )
buttonMask |= 0x04;
if ( e->button() & RightButton )
buttonMask |= 0x02;
}
else if ( e->type() == QEvent::MouseButtonRelease ) {
if ( e->button() & LeftButton )
buttonMask &= 0x06;
if ( e->button() & MidButton )
buttonMask |= 0x03;
if ( e->button() & RightButton )
buttonMask |= 0x05;
}
}
- // HACK: Scaling
+ // HACK: Scaling
CARD16 x = Swap16IfLE( e->x() * con->options()->scaleFactor );
- CARD16 y = Swap16IfLE( e->y() * con->options()->scaleFactor );
+ CARD16 y = Swap16IfLE( e->y() * con->options()->scaleFactor );
con->write( &PointerEventId, 1 );
con->write( &buttonMask, 1 );
con->write( &x, 2 );
con->write( &y, 2 );
}
void KRFBDecoder::sendCutEvent( const QString &unicode )
{
//
// Warning: There is a bug in the RFB protocol because there is no way to find
// out the codepage in use on the remote machine. This could be fixed by requiring
// the remote server to use utf8 etc. but for now we have to assume they're the
// same. I've reported this problem to the ORL guys, but they apparantly have no
// immediate plans to fix the issue. :-( (rich)
//
CARD8 padding[3];
QCString text = unicode.local8Bit();
CARD32 length = text.length();
length = Swap32IfLE( length );
con->write( &ClientCutTextId, 1 );
con->write( &padding, 3 );
con->write( &length, 4 );
con->write( text.data(), length );
}
void KRFBDecoder::gotServerCut()
{
- owarn << "Got server cut" << oendl;
+ owarn << "Got server cut" << oendl;
currentState = AwaitingServerCutLength;
connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerCutLength() ) );
con->waitForData( ServerCutLenLength );
}
void KRFBDecoder::gotServerCutLength()
{
assert( currentState = AwaitingServerCutLength );
disconnect( con, SIGNAL( gotEnoughData() ),
this, SLOT( gotServerCutLength() ) );
CARD8 padding[3];
con->read( padding, 3 );
con->read( &serverCutTextLen, 4 );
serverCutTextLen = Swap32IfLE( serverCutTextLen );
currentState = AwaitingServerCutText;
connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerCutText() ) );
con->waitForData( serverCutTextLen );
}
void KRFBDecoder::gotServerCutText()
{
assert( currentState = AwaitingServerCutText );
disconnect( con, SIGNAL( gotEnoughData() ),
this, SLOT( gotServerCutText() ) );
//
// Warning: There is a bug in the RFB protocol because there is no way to find
// out the codepage in use on the remote machine. This could be fixed by requiring
// the remote server to use utf8 etc. but for now we have to assume they're the
// same. I've reported this problem to the ORL guys, but they apparantly have no
// immediate plans to fix the issue. :-( (rich)
//
char *cutbuf = new char[ serverCutTextLen + 1 ];
CHECK_PTR( cutbuf );
con->read( cutbuf, serverCutTextLen );
cutbuf[ serverCutTextLen ] = '\0';
/* For some reason QApplication::clipboard()->setText() segfaults when called
* from within keypebble's mass of signals and slots
- owarn << "Server cut: " << cutbuf << "" << oendl;
+ owarn << "Server cut: " << cutbuf << "" << oendl;
QString cutText( cutbuf ); // DANGER!!
qApp->clipboard()->setText( cutText );
*/
delete cutbuf;
// Now wait for the update (again)
if ( oldState == AwaitingUpdate ) {
currentState = AwaitingUpdate;
connect( con, SIGNAL( gotEnoughData() ), SLOT( gotUpdateHeader() ) );
con->waitForData( UpdateHeaderLength );
}
else if ( oldState == Idle ) {
currentState = Idle;
}
else {
- owarn << "Async handled in weird state" << oendl;
+ owarn << "Async handled in weird state" << oendl;
currentState = oldState;
};
}
void KRFBDecoder::gotBell()
{
- owarn << "Got server bell" << oendl;
+ owarn << "Got server bell" << oendl;
buf->soundBell();
// Now wait for the update (again)
if ( oldState == AwaitingUpdate ) {
currentState = AwaitingUpdate;
connect( con, SIGNAL( gotEnoughData() ), SLOT( gotUpdateHeader() ) );
con->waitForData( UpdateHeaderLength );
}
else if ( oldState == Idle ) {
currentState = Idle;
}
else {
- owarn << "Async handled in weird state" << oendl;
+ owarn << "Async handled in weird state" << oendl;
currentState = oldState;
};
}
void KRFBDecoder::sendKeyPressEvent( QKeyEvent *event )
{
int key;
key = toKeySym( event );
if ( key ) {
key = Swap32IfLE( key );
CARD8 mask = true;
CARD16 padding = 0;
con->write( &KeyEventId, 1 );
con->write( &mask, 1 );
con->write( &padding, 2 );
con->write( &key, 4 );
}
}
void KRFBDecoder::sendKeyReleaseEvent( QKeyEvent *event )
{
int key;
key = toKeySym( event );
if ( key ) {
key = Swap32IfLE( key );
CARD8 mask = false;
CARD16 padding = 0;
con->write( &KeyEventId, 1 );
con->write( &mask, 1 );
con->write( &padding, 2 );
con->write( &key, 4 );
}
}
//
// The RFB protocol spec says 'For most ordinary keys, the 'keysym'
// is the same as the corresponding ASCII value.', but doesn't
// elaborate what the most ordinary keys are. The spec also lists
// a set (possibly subset, it's unspecified) of mappings for
// "other common keys" (backspace, tab, return, escape, etc).
//
int KRFBDecoder::toKeySym( QKeyEvent *k )
{
//
// Try and map these "other common keys" first.
//
if ((k->key() >= Qt::Key_Escape) && (k->key() <= Qt::Key_F12)) {
- for(int i = 0; keyMap[i].keycode != 0; i++) {
- if (k->key() == keyMap[i].keycode) {
- return keyMap[i].keysym;
- }
- }
+ for(int i = 0; keyMap[i].keycode != 0; i++) {
+ if (k->key() == keyMap[i].keycode) {
+ return keyMap[i].keysym;
+ }
+ }
}
//
// If these keys aren't matched, return the ascii code and let the
// server figure it out. We don't return k->key(), as the data in
// key differs between input methods, and we don't want special cases.
//
return k->ascii();
}
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
index 6c5f5ea..211314b 100644
--- a/noncore/graphics/opie-eye/gui/iconview.cpp
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -17,195 +17,195 @@
#include <opie2/oimagescrollview.h>
#include <qpe/resource.h>
#include <qpe/qpemessagebox.h>
#include <qpe/ir.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/qpeapplication.h>
#include <qiconview.h>
#include <qlabel.h>
#include <qhbox.h>
#include <qcombobox.h>
#include <qdir.h>
#include <qapplication.h>
#include <qmainwindow.h>
#include <qtimer.h>
#include <qstyle.h>
using Opie::Core::OKeyConfigItem;
/*
* The Icons, Request Cache and IconViewItem for the IconView
*/
namespace {
static QPixmap* _dirPix = 0;
static QPixmap* _unkPix = 0;
static QPixmap* _picPix = 0;
static QPixmap* _emptyPix = 0;
class IconViewItem : public QIconViewItem {
public:
IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false);
QPixmap* pixmap()const;
QString path()const { return m_path; }
bool isDir()const { return m_isDir; }
void setText( const QString& );
bool textOnly()const{return m_textOnly;}
void setTextOnly(bool how){m_textOnly=how;}
/* just for starting recalc of item rect! */
virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE );
/* just for starting recalc of item rect! */
virtual void setPixmap( const QPixmap & icon);
protected:
mutable QPixmap* m_pix;
private:
QString m_path;
bool m_isDir : 1;
bool m_noInfo :1;
bool m_textOnly:1;
bool m_NameOnly:1;
bool m_Pixset:1;
};
class TextViewItem : public IconViewItem {
TextViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false );
QPixmap *pixmap()const;
void setText( const QString& );
};
class ThumbViewItem : public IconViewItem {
ThumbViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false );
QPixmap *pixmap()const;
void setText( const QString& );
};
/*
* If we request an Image or String
* we add it to the map
*/
static QMap<QString, IconViewItem*> g_stringInf;
static QMap<QString, IconViewItem*> g_stringPix;
IconViewItem::IconViewItem( QIconView* view,const QString& path,
const QString& name, bool isDir )
: QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ),
m_noInfo( false ),m_textOnly(false),m_Pixset(false)
{
if ( isDir && !_dirPix )
_dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser"));
else if ( !isDir && !_unkPix )
_unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) );
}
inline void IconViewItem::setPixmap( const QPixmap & icon, bool recalc, bool redraw)
{
m_Pixset = true;
calcRect(text());
}
inline void IconViewItem::setPixmap( const QPixmap & icon)
{
m_Pixset = true;
calcRect(text());
}
inline QPixmap* IconViewItem::pixmap()const {
-// qWarning( "Name is " + m_path.right( 15 ) + " rect is %d %d %d %d | %d %d",
-// rect().x(),rect().y(),rect().width(),rect().height(),
-// iconView()->contentsX(), iconView()->contentsY());
+// owarn << "Name is " << m_path.right( 15 ) << " rect is " << rect().x() << " " << rect().y()
+// << " " << rect().width() << " " << rect().height() << " | " << iconView()->contentsX()
+// << " " << iconView()->contentsY() << oendl;
if (textOnly()&&!m_isDir) {
if (!_emptyPix) _emptyPix = new QPixmap(0,0,1);
return _emptyPix;
}
if ( m_isDir )
return _dirPix;
else{
if (!m_noInfo && !g_stringInf.contains( m_path ) ) {
currentView()->dirLister()->imageInfo( m_path );
g_stringInf.insert( m_path, const_cast<IconViewItem*>(this));
}
m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 );
if (!m_pix && !g_stringPix.contains( m_path )) {
currentView()->dirLister()->thumbNail( m_path, 64, 64 );
g_stringPix.insert( m_path, const_cast<IconViewItem*>(this));
}
return m_pix ? m_pix : _unkPix;
}
}
inline void IconViewItem::setText( const QString& str ) {
QString text = QIconViewItem::text()+"\n"+str;
m_noInfo = true;
QIconViewItem::setText( text );
}
}
/*
* Set up the GUI.. initialize the slave set up gui
* and also load a dir
*/
PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg )
: QVBox( wid ), m_cfg( cfg ), m_updatet( false )
{
{
QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" );
}
m_path = QDir::homeDirPath();
m_mode = 0;
QHBox *hbox = new QHBox( this );
QLabel* lbl = new QLabel( hbox );
lbl->setText( tr("View as" ) );
m_views = new QComboBox( hbox, "View As" );
m_view= new QIconView( this );
connect(m_view, SIGNAL(clicked(QIconViewItem*) ),
this, SLOT(slotClicked(QIconViewItem*)) );
connect(m_view, SIGNAL(returnPressed(QIconViewItem*)),
this, SLOT(slotClicked(QIconViewItem*)) );
m_view->setArrangement( QIconView::LeftToRight );
m_mode = m_cfg->readNumEntry("ListViewMode", 1);
QString lastView = m_cfg->readEntry("LastView","");
if (m_mode < 1 || m_mode>3) m_mode = 1;
m_view->setItemTextPos( QIconView::Right );
calculateGrid();
initKeys();
loadViews();
int cc=0;
for (; cc<m_views->count();++cc) {
if (m_views->text(cc)==lastView) {
break;
}
}
if (cc<m_views->count()) {
m_views->setCurrentItem(cc);
slotViewChanged(cc);
} else {
slotViewChanged(m_views->currentItem());
}
connect( m_views, SIGNAL(activated(int)),
this, SLOT(slotViewChanged(int)) );
}
/*
* Unref the slave and save the keyboard manager
*/
PIconView::~PIconView() {
{
QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
}
m_viewManager->save();
delete m_viewManager;
}
Opie::Core::OKeyConfigManager* PIconView::manager() {
diff --git a/noncore/graphics/opie-eye/gui/viewmodebutton.cpp b/noncore/graphics/opie-eye/gui/viewmodebutton.cpp
index 36e5dcf..aa15d31 100644
--- a/noncore/graphics/opie-eye/gui/viewmodebutton.cpp
+++ b/noncore/graphics/opie-eye/gui/viewmodebutton.cpp
@@ -1,45 +1,48 @@
#include "viewmodebutton.h"
+/* OPIE */
#include <opie2/odebug.h>
+using namespace Opie::Core;
+/* QT */
#include <qtoolbar.h>
#include <qpopupmenu.h>
ViewModeButton::ViewModeButton( QToolBar* bar,int def )
: QToolButton( bar )
{
slotChange( def );
QPopupMenu *pop= new QPopupMenu( this );
pop->setCheckable( true );
pop->insertItem( tr("Thumbnail and Imageinfo"), 1 );
pop->insertItem( tr("Thumbnail and Name" ), 2 );
pop->insertItem( tr("Name Only" ), 3 );
connect(pop, SIGNAL(activated(int)),
this, SIGNAL(changeMode(int)) );
connect(pop, SIGNAL(activated(int)),
this, SLOT(slotChange(int)) );
setPopup( pop );
}
ViewModeButton::~ViewModeButton() {
}
void ViewModeButton::slotChange( int i ) {
QString name;
switch( i ) {
case 1:
name = "opie-eye/opie-eye-thumb";
break;
case 2:
name = "opie-eye/opie-eye-thumbonly";
break;
case 3:
name = "opie-eye/opie-eye-textview";
break;
}
- qWarning("foo %d" +name, i );
+ owarn << "foo " << name << oendl;
setIconSet( Resource::loadIconSet( name ) );
}
diff --git a/noncore/net/opietooth/lib/device.cc b/noncore/net/opietooth/lib/device.cc
index 04c50d9..f81066e 100644
--- a/noncore/net/opietooth/lib/device.cc
+++ b/noncore/net/opietooth/lib/device.cc
@@ -1,152 +1,157 @@
-#include <signal.h>
+#include "device.h"
+/* OPIE */
#include <opie2/oprocess.h>
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+
+/* STD */
+#include <signal.h>
-#include "device.h"
using namespace OpieTooth;
using Opie::Core::OProcess;
namespace {
int parsePid( const QCString& par ){
int id=0;
QString string( par );
QStringList list = QStringList::split( '\n', string );
for( QStringList::Iterator it = list.begin(); it != list.end(); ++it ){
- qWarning("parsePID: %s", (*it).latin1() );
+ owarn << "parsePID: " << (*it).latin1() << oendl;
if( !(*it).startsWith("CSR") ){
- id = (*it).toInt();
- break;
+ id = (*it).toInt();
+ break;
}
}
return id;
}
}
Device::Device(const QString &device, const QString &mode, const QString &speed )
: QObject(0, "device") {
- qWarning("OpieTooth::Device create" );
+ owarn << "OpieTooth::Device create" << oendl;
m_hci = 0;
m_process = 0;
m_attached = false;
m_device = device;
m_mode = mode;
m_speed = speed;
attach();
}
Device::~Device(){
detach();
}
void Device::attach(){
- qWarning("attaching %s %s %s", m_device.latin1(), m_mode.latin1(), m_speed.latin1() );
+ owarn << "attaching " << m_device.latin1() << " " << m_mode.latin1() << " " << m_speed.latin1() << oendl;
if(m_process == 0 ){
m_output.resize(0);
- qWarning("new process to create" );
+ owarn << "new process to create" << oendl;
m_process = new OProcess();
*m_process << "hciattach";
*m_process << "-p";
*m_process << m_device << m_mode << m_speed;
connect(m_process, SIGNAL( processExited(Opie::Core::OProcess*) ),
this, SLOT( slotExited(Opie::Core::OProcess* ) ) );
connect(m_process, SIGNAL( receivedStdout(Opie::Core::OProcess*, char*, int) ),
this, SLOT(slotStdOut(Opie::Core::OProcess*,char*,int ) ) );
connect(m_process, SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int ) ),
this, SLOT(slotStdErr(Opie::Core::OProcess*,char*,int) ) );
if(!m_process->start(OProcess::NotifyOnExit, OProcess::AllOutput ) ){
- qWarning("Could not start" );
+ owarn << "Could not start" << oendl;
delete m_process;
m_process = 0;
}
};
}
void Device::detach(){
delete m_hci;
delete m_process;
// kill the pid we got
if(m_attached ){
//kill the pid
- qWarning( "killing" );
+ warn << "killing" << oendl;
kill(pid, 9);
}
- qWarning("detached" );
+ owarn << "detached" << oendl;
}
bool Device::isLoaded()const{
return m_attached;
}
QString Device::devName()const {
return QString::fromLatin1("hci0");
};
void Device::slotExited( OProcess* proc)
{
- qWarning("prcess exited" );
+ owarn << "prcess exited" << oendl;
if(proc== m_process ){
- qWarning("proc == m_process" );
+ owarn << "proc == m_process" << oendl;
if( m_process->normalExit() ){ // normal exit
- qWarning("normalExit" );
+ owarn << "normalExit" << oendl;
int ret = m_process->exitStatus();
if( ret == 0 ){ // attached
- qWarning("attached" );
- qWarning("Output: %s", m_output.data() );
- pid = parsePid( m_output );
- qWarning("Pid = %d", pid );
- // now hciconfig hci0 up ( determine hciX FIXME)
- // and call hciconfig hci0 up
- // FIXME hardcoded to hci0 now :(
- m_hci = new OProcess( );
- *m_hci << "hciconfig";
- *m_hci << "hci0 up";
- connect(m_hci, SIGNAL( processExited(Opie::Core::OProcess*) ),
+ owarn << "attached" << oendl;
+ owarn << "Output: " << m_output.data() << oendl;
+ pid = parsePid( m_output );
+ owarn << "Pid = " << pid << oendl;
+ // now hciconfig hci0 up ( determine hciX FIXME)
+ // and call hciconfig hci0 up
+ // FIXME hardcoded to hci0 now :(
+ m_hci = new OProcess( );
+ *m_hci << "hciconfig";
+ *m_hci << "hci0 up";
+ connect(m_hci, SIGNAL( processExited(Opie::Core::OProcess*) ),
this, SLOT( slotExited(Opie::Core::OProcess* ) ) );
- if(!m_hci->start() ){
- qWarning("could not start" );
- m_attached = false;
- emit device("hci0", false );
- }
+ if(!m_hci->start() ){
+ owarn << "could not start" << oendl;
+ m_attached = false;
+ emit device("hci0", false );
+ }
}else{
- qWarning("crass" );
- m_attached = false;
- emit device("hci0", false );
+ owarn << "crass" << oendl;
+ m_attached = false;
+ emit device("hci0", false );
}
}
delete m_process;
m_process = 0;
}else if(proc== m_hci ){
- qWarning("M HCI exited" );
+ owarn << "M HCI exited" << oendl;
if( m_hci->normalExit() ){
- qWarning("normal exit" );
+ owarn << "normal exit" << oendl;
int ret = m_hci->exitStatus();
if( ret == 0 ){
- qWarning("attached really really attached" );
- m_attached = true;
- emit device("hci0", true );
+ owarn << "attached really really attached" << oendl;
+ m_attached = true;
+ emit device("hci0", true );
}else{
- qWarning( "failed" );
- emit device("hci0", false );
- m_attached = false;
+ owarn << "failed" << oendl;
+ emit device("hci0", false );
+ m_attached = false;
}
}// normal exit
delete m_hci;
m_hci = 0;
}
}
void Device::slotStdOut(OProcess* proc, char* chars, int len)
{
- qWarning("std out" );
+ owarn << "std out" << oendl;
if( len <1 ){
- qWarning( "len < 1 " );
+ owarn << "len < 1 " << oendl;
return;
}
if(proc == m_process ){
QCString string( chars, len+1 ); // \0 == +1
- qWarning("output: %s", string.data() );
+ owarn << "output: " << string.data() << oendl;
m_output.append( string.data() );
}
}
void Device::slotStdErr(OProcess* proc, char* chars, int len)
{
- qWarning("std err" );
+ owarn << "std err" << oendl;
slotStdOut( proc, chars, len );
}
diff --git a/noncore/net/opietooth/lib/manager.cc b/noncore/net/opietooth/lib/manager.cc
index 18e1df9..76d9127 100644
--- a/noncore/net/opietooth/lib/manager.cc
+++ b/noncore/net/opietooth/lib/manager.cc
@@ -1,335 +1,336 @@
-
-#include <opie2/oprocess.h>
-
#include "parser.h"
#include "manager.h"
+#include <opie2/oprocess.h>
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+
using namespace OpieTooth;
using Opie::Core::OProcess;
Manager::Manager( const QString& dev )
: QObject()
{
- qWarning("created");
+ owarn << "created" << oendl;
m_device = dev;
m_hcitool = 0;
m_sdp = 0;
}
Manager::Manager( Device* /*dev*/ )
: QObject()
{
m_hcitool = 0;
m_sdp = 0;
}
Manager::Manager()
: QObject()
{
m_hcitool = 0;
m_sdp = 0;
}
Manager::~Manager(){
delete m_hcitool;
delete m_sdp;
}
void Manager::setDevice( const QString& dev ){
m_device = dev;
}
void Manager::setDevice( Device* /*dev*/ ){
}
void Manager::isAvailable( const QString& device ){
OProcess* l2ping = new OProcess();
l2ping->setName( device.latin1() );
*l2ping << "l2ping" << "-c1" << device;
connect(l2ping, SIGNAL(processExited(Opie::Core::OProcess* ) ),
this, SLOT(slotProcessExited(Opie::Core::OProcess*) ) );
if (!l2ping->start() ) {
emit available( device, false );
delete l2ping;
}
}
void Manager::isAvailable( Device* /*dev*/ ){
}
void Manager::searchDevices( const QString& device ){
- qWarning("search devices");
+ owarn << "search devices" << oendl;
OProcess* hcitool = new OProcess();
hcitool->setName( device.isEmpty() ? "hci0" : device.latin1() );
*hcitool << "hcitool" << "scan";
connect( hcitool, SIGNAL(processExited(Opie::Core::OProcess*) ) ,
this, SLOT(slotHCIExited(Opie::Core::OProcess* ) ) );
connect( hcitool, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ),
this, SLOT(slotHCIOut(Opie::Core::OProcess*, char*, int ) ) );
if (!hcitool->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
- qWarning("could not start");
+ owarn << "could not start" << oendl;
RemoteDevice::ValueList list;
emit foundDevices( device, list );
delete hcitool;
}
}
void Manager::searchDevices(Device* /*d*/ ){
}
void Manager::addService(const QString& name ){
OProcess proc;
proc << "sdptool" << "add" << name;
bool bo = true;
if (!proc.start(OProcess::DontCare ) )
bo = false;
emit addedService( name, bo );
}
void Manager::addServices(const QStringList& list){
QStringList::ConstIterator it;
for (it = list.begin(); it != list.end(); ++it )
addService( (*it) );
}
void Manager::removeService( const QString& name ){
OProcess prc;
prc << "sdptool" << "del" << name;
bool bo = true;
if (!prc.start(OProcess::DontCare ) )
bo = false;
emit removedService( name, bo );
}
void Manager::removeServices( const QStringList& list){
QStringList::ConstIterator it;
for (it = list.begin(); it != list.end(); ++it )
removeService( (*it) );
}
void Manager::searchServices( const QString& remDevice ){
OProcess *m_sdp =new OProcess();
*m_sdp << "sdptool" << "browse" << remDevice;
m_sdp->setName( remDevice.latin1() );
- qWarning("search Services for %s", remDevice.latin1() );
+ owarn << "search Services for " << remDevice.latin1() << oendl;
connect(m_sdp, SIGNAL(processExited(Opie::Core::OProcess*) ),
this, SLOT(slotSDPExited(Opie::Core::OProcess* ) ) );
connect(m_sdp, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ),
this, SLOT(slotSDPOut(Opie::Core::OProcess*, char*, int) ) );
if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
- qWarning("could not start sdptool" );
+ owarn << "could not start sdptool" << oendl;
delete m_sdp;
Services::ValueList list;
emit foundServices( remDevice, list );
}
}
void Manager::searchServices( const RemoteDevice& dev){
searchServices( dev.mac() );
}
QString Manager::toDevice( const QString& /*mac*/ ){
return QString::null;
}
QString Manager::toMac( const QString &/*device*/ ){
return QString::null;
}
void Manager::slotProcessExited(OProcess* proc ) {
bool conn= false;
if (proc->normalExit() && proc->exitStatus() == 0 )
conn = true;
QString name = QString::fromLatin1(proc->name() );
emit available( name, conn );
delete proc;
}
void Manager::slotSDPOut(OProcess* proc, char* ch, int len)
{
QCString str(ch, len+1 );
- qWarning("SDP:%s", str.data() );
+ owarn << "SDP:" << str.data() << oendl;
QMap<QString, QString>::Iterator it;
it = m_out.find(proc->name() );
QString string;
if ( it != m_out.end() ) {
string = it.data();
}
string.append( str );
m_out.replace( proc->name(), string );
}
void Manager::slotSDPExited( OProcess* proc)
{
- qWarning("proc name %s", proc->name() );
+ owarn << "proc name " << proc->name() << oendl;
Services::ValueList list;
if (proc->normalExit() ) {
QMap<QString, QString>::Iterator it = m_out.find( proc->name() );
if ( it != m_out.end() ) {
- qWarning("found process" );
+ owarn << "found process" << oendl;
list = parseSDPOutput( it.data() );
m_out.remove( it );
}
}
emit foundServices( proc->name(), list );
delete proc;
}
Services::ValueList Manager::parseSDPOutput( const QString& out ) {
Services::ValueList list;
- qWarning("parsing output" );
+ owarn << "parsing output" << oendl;
Parser parser( out );
list = parser.services();
return list;
}
void Manager::slotHCIExited(OProcess* proc ) {
- qWarning("process exited");
+ owarn << "process exited" << oendl;
RemoteDevice::ValueList list;
if (proc->normalExit() ) {
- qWarning("normalExit %s", proc->name() );
+ owarn << "normalExit " << proc->name() << oendl;
QMap<QString, QString>::Iterator it = m_devices.find(proc->name() );
if (it != m_devices.end() ) {
- qWarning("!= end ;)");
+ owarn << "!= end ;)" << oendl;
list = parseHCIOutput( it.data() );
m_devices.remove( it );
}
}
emit foundDevices( proc->name(), list );
delete proc;
}
void Manager::slotHCIOut(OProcess* proc, char* ch, int len) {
QCString str( ch, len+1 );
- qWarning("hci: %s", str.data() );
+ owarn << "hci: " << str.data() oendl;
QMap<QString, QString>::Iterator it;
it = m_devices.find( proc->name() );
- qWarning("proc->name %s", proc->name() );
+ owarn << "proc->name " << proc->name() << oendl;
QString string;
if (it != m_devices.end() ) {
- qWarning("slotHCIOut ");
+ owarn << "slotHCIOut " << oendl;
string = it.data();
}
string.append( str );
m_devices.replace( proc->name(), string );
}
RemoteDevice::ValueList Manager::parseHCIOutput(const QString& output ) {
- qWarning("parseHCI %s", output.latin1() );
+ owarn << "parseHCI " << output.latin1() << oendl;
RemoteDevice::ValueList list;
QStringList strList = QStringList::split('\n', output );
QStringList::Iterator it;
QString str;
for ( it = strList.begin(); it != strList.end(); ++it ) {
str = (*it).stripWhiteSpace();
- qWarning("OpieTooth %s", str.latin1() );
+ owarn << "OpieTooth " << str.latin1() << oendl;
int pos = str.findRev(':' );
if ( pos > 0 ) {
QString mac = str.left(17 );
str.remove( 0, 17 );
- qWarning("mac %s", mac.latin1() );
- qWarning("rest:%s", str.latin1() );
+ owarn << "mac " << mac.latin1() << oendl;
+ owarn << "rest: " << str.latin1() << oendl;
RemoteDevice rem( mac , str.stripWhiteSpace() );
list.append( rem );
}
}
return list;
}
////// hcitool cc and hcitool con
/**
* Create it on the stack as don't care
* so we don't need to care for it
* cause hcitool gets reparented
*/
void Manager::connectTo( const QString& mac) {
OProcess proc;
proc << "hcitool";
proc << "cc";
proc << mac;
proc.start(OProcess::DontCare); // the lib does not care at this point
}
void Manager::searchConnections() {
- qWarning("searching connections?");
+ owarn << "searching connections?" << oendl;
OProcess* proc = new OProcess();
m_hcitoolCon = QString::null;
connect(proc, SIGNAL(processExited(Opie::Core::OProcess*) ),
this, SLOT(slotConnectionExited( Opie::Core::OProcess*) ) );
connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int) ),
this, SLOT(slotConnectionOutput(Opie::Core::OProcess*, char*, int) ) );
*proc << "hcitool";
*proc << "con";
if (!proc->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
ConnectionState::ValueList list;
emit connections( list );
delete proc;
}
}
void Manager::slotConnectionExited( OProcess* proc ) {
ConnectionState::ValueList list;
list = parseConnections( m_hcitoolCon );
emit connections(list );
delete proc;
}
void Manager::slotConnectionOutput(OProcess* /*proc*/, char* cha, int len) {
QCString str(cha, len );
m_hcitoolCon.append( str );
//delete proc;
}
ConnectionState::ValueList Manager::parseConnections( const QString& out ) {
ConnectionState::ValueList list2;
QStringList list = QStringList::split('\n', out );
QStringList::Iterator it;
// remove the first line ( "Connections:")
it = list.begin();
it = list.remove( it );
for (; it != list.end(); ++it ) {
QString row = (*it).stripWhiteSpace();
QStringList value = QStringList::split(' ', row );
- qWarning("0: %s", value[0].latin1() );
- qWarning("1: %s", value[1].latin1() );
- qWarning("2: %s", value[2].latin1() );
- qWarning("3: %s", value[3].latin1() );
- qWarning("4: %s", value[4].latin1() );
- qWarning("5: %s", value[5].latin1() );
- qWarning("6: %s", value[6].latin1() );
- qWarning("7: %s", value[7].latin1() );
- qWarning("8: %s", value[8].latin1() );
+ owan << "0: %s" << value[0].latin1() << oendl;
+ owan << "1: %s" << value[1].latin1() << oendl;
+ owan << "2: %s" << value[2].latin1() << oendl;
+ owan << "3: %s" << value[3].latin1() << oendl;
+ owan << "4: %s" << value[4].latin1() << oendl;
+ owan << "5: %s" << value[5].latin1() << oendl;
+ owan << "6: %s" << value[6].latin1() << oendl;
+ owan << "7: %s" << value[7].latin1() << oendl;
+ owan << "8: %s" << value[8].latin1() << oendl;
ConnectionState con;
con.setDirection( value[0] == QString::fromLatin1("<") ? Outgoing : Incoming );
con.setConnectionMode( value[1] );
con.setMac( value[2] );
con.setHandle( value[4].toInt() );
con.setState( value[6].toInt() );
con.setLinkMode( value[8] == QString::fromLatin1("MASTER") ? Master : Client );
list2.append( con );
}
return list2;
}
void Manager::signalStrength( const QString &mac ) {
OProcess* sig_proc = new OProcess();
connect(sig_proc, SIGNAL(processExited(Opie::Core::OProcess*) ),
this, SLOT(slotSignalStrengthExited( Opie::Core::OProcess*) ) );
connect(sig_proc, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int) ),
this, SLOT(slotSignalStrengthOutput(Opie::Core::OProcess*, char*, int) ) );
*sig_proc << "hcitool";
*sig_proc << "lq";
*sig_proc << mac;
sig_proc->setName( mac.latin1() );
if (!sig_proc->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
emit signalStrength( mac, "-1" );
delete sig_proc;
}
}
void Manager::slotSignalStrengthOutput(OProcess* proc, char* cha, int len) {
QCString str(cha, len );
QString temp = QString(str).stripWhiteSpace();
QStringList value = QStringList::split(' ', temp );
emit signalStrength( proc->name(), value[2].latin1() );
}
void Manager::slotSignalStrengthExited( OProcess* proc ) {
delete proc;
}
diff --git a/noncore/net/opietooth/lib/parser.cc b/noncore/net/opietooth/lib/parser.cc
index 8baf284..7e95907 100644
--- a/noncore/net/opietooth/lib/parser.cc
+++ b/noncore/net/opietooth/lib/parser.cc
@@ -1,199 +1,205 @@
+#include "parser.h"
+
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+
+/* QT */
#include <qstringlist.h>
-#include "parser.h"
using namespace OpieTooth;
namespace {
// "Test Foo Bar" (0x3456)
// @param ret Test Foo Bar
// @eturn 13398
// tactic find " (
int convert( const QString& line, QString& ret ) {
-// qWarning("called");
+// owarn << "called" << oendl;
ret = QString::null;
int i = 0;
int pos = line.findRev("\" (");
if ( pos > 0 ) { // it shouldn't be at pos 0
ret = line.left(pos ).stripWhiteSpace();
- // qWarning("ret: %s", ret.latin1() );
+ // owarn << "ret: " << ret.latin1() << oendl;
ret = ret.replace(QRegExp("[\"]"), "");
- //qWarning("ret: %s", ret.latin1() );
+ //owarn << "ret: " << ret.latin1() << oendl;
QString dummy = line.mid(pos + 5 );
- //qWarning("dummy: %s", dummy.latin1() );
+ //owarn << "dummy: " << dummy.latin1() << oendl;
dummy = dummy.replace(QRegExp("[)]"), "");
- //qWarning("dummy: %s", dummy.latin1() );
+ //owarn << "dummy: " << dummy.latin1() << oendl;
// dummy = dummy.remove( dummy.length() -2, 1 ); // remove the )
bool ok;
i = dummy.toInt(&ok, 16 );
//if (ok ) {
- // qWarning("converted %d", i);
- //}else qWarning("failed" );
- //qWarning("exiting");
+ // owarn << "converted " << i << oendl;
+ //}else owarn << "failed" << oendl;
+ //owarn << "exiting" << oendl;
return i;
}
- //qWarning("output %d", i );
+ //owarn << "output " << i << oendl;
return i;
}
};
Parser::Parser(const QString& output ) {
parse( output );
}
void Parser::setText(const QString& output) {
parse( output );
}
Services::ValueList Parser::services() const {
return m_list;
}
void Parser::parse( const QString& string) {
m_list.clear();
m_complete = true;
QStringList list = QStringList::split('\n', string,TRUE );
QStringList::Iterator it;
for (it = list.begin(); it != list.end(); ++it ) {
- //qWarning("line:%s:line", (*it).latin1() );
+ //owarn << "line:" << (*it).latin1() << oendl;
if ( (*it).startsWith("Browsing") ) continue;
if ( (*it).stripWhiteSpace().isEmpty() ) { // line is empty because a new Service begins
- qWarning("could add");
+ owarn << "could add" << oendl;
// now see if complete and add
if (m_complete ) {
if (!m_item.serviceName().isEmpty() )
m_list.append( m_item );
Services serv;
m_item = serv;
m_complete = true;
continue;
}
}
if (parseName( (*it) ) ) ;//continue;
if (parseRecHandle( (*it) ) ) ;//continue;
if (parseClassId( (*it) ) ) ;//continue;
if (parseProtocol( (*it) ) ) ;//continue;
if (parseProfile( (*it) ) ) ;//continue;
}
// missed the last one
if (m_complete) {
-// qWarning("adding");
+// owarn << "adding" << oendl;
if (!m_item.serviceName().isEmpty() )
m_list.append(m_item );
}
QValueList<Services>::Iterator it2;
if (m_list.isEmpty() )
- qWarning("m_list is empty");
+ owarn << "m_list is empty" << oendl;
for (it2 = m_list.begin(); it2 != m_list.end(); ++it2 ) {
- qWarning("name %s", (*it2).serviceName().latin1() );
+ owarn << "name " << (*it2).serviceName().latin1() << oendl;
}
}
bool Parser::parseName( const QString& str) {
if (str.startsWith("Service Name:") ) {
m_item.setServiceName( str.mid(13).stripWhiteSpace() );
- qWarning(m_item.serviceName() );
+ owarn << m_item.serviceName() << oendl;
return true;
}
return false;
}
bool Parser::parseRecHandle( const QString& str) {
if (str.startsWith("Service RecHandle:" ) ) {
QString out = str.mid(18 ).stripWhiteSpace();
- qWarning("out %s", out.latin1() );
+ owarn << "out " << out.latin1() << oendl;
int value = out.mid(2).toInt(&m_ok, 16 );
if (m_ok && (value != -1) )
m_complete = true;
else
m_complete = false;
- qWarning("rec handle %d", value);
+ owarn << "rec handle " << value << oendl;
m_item.setRecHandle( value );
return true;
}
return false;
}
bool Parser::parseClassId( const QString& str) {
if (str.startsWith("Service Class ID List:") ) {
- qWarning("found class id" );
- qWarning("line:%s", str.latin1() );
+ owarn << "found class id" << oendl;
+ owarn << "line: " << str.latin1() << oendl;
m_classOver = true;
return true;
}else if ( m_classOver && str.startsWith(" " ) ){ // ok now are the informations in place
- qWarning("line with class id" );
- qWarning("%s",str.latin1() );
+ owarn << "line with class id" << oendl;
+ owarn << str.latin1() << oendl;
// "Obex Object Push" (0x1105)
// find backwards the " and the from 0 to pos and the mid pos+1
// then stripWhiteSpace add name replace '"' with ""
// and then convert 0x1105 toInt()
QString classes;
int ids;
ids = convert( str, classes );
- qWarning("ids %d", ids );
+ owarn << "ids " << ids << oendl;
m_item.insertClassId( ids, classes );
return true;
}else{
- qWarning("Else %d", m_classOver );
+ owarn << "Else " << m_classOver << oendl;
m_classOver = false;
}
return false;
}
bool Parser::parseProtocol( const QString& str) {
if (str.startsWith("Protocol Descriptor List:") ) {
m_protocolOver = true;
m_protocolAdded = false;
return true;
}else if (m_protocolOver && str.startsWith(" ") ) { // "L2CAP" (0x0100)
- qWarning("double protocol filter");
+ owarn << "double protocol filter" << oendl;
if (!m_protocolAdded ) { // the protocol does neither supply a channel nor port so add it now
Services::ProtocolDescriptor desc( m_protName, m_protId );
m_item.insertProtocolDescriptor( desc );
}
m_protocolAdded = false;
{ // the find function
m_protId = convert(str, m_protName );
}
return true;
}else if (m_protocolOver && str.startsWith(" ") ) {
- qWarning("tripple protocol filter");
+ owarn << "tripple protocol filter" << oendl;
m_protocolAdded = true;
QString dummy = str.stripWhiteSpace();
int pos = dummy.findRev(':');
if ( pos > -1 ) {
int port = dummy.mid(pos+1 ).stripWhiteSpace().toInt();
Services::ProtocolDescriptor desc( m_protName, m_protId, port );
m_item.insertProtocolDescriptor( desc );
}
return true;
}else if (m_protocolOver ) {
m_protocolOver = false;
}
return false;
}
bool Parser::parseProfile( const QString& str) {
if (str.startsWith("Profile Descriptor List:") ) {
m_profOver = true;
}else if ( m_profOver && str.startsWith(" ") ) {
m_profId = convert( str, m_profName );
}else if ( m_profOver && str.startsWith(" ") ) {
// now find
int pos = str.findRev(':');
if ( pos > 0 ) {
int dummy = str.mid(pos+1 ).stripWhiteSpace().toInt();
- qWarning("dummyInt:%d", dummy );
+ owarn << "dummyInt: " << dummy << oendl;
Services::ProfileDescriptor desc( m_profName, m_profId, dummy );
m_item.insertProfileDescriptor(desc);
}
}else
m_profOver = false;
return false;
}
diff --git a/noncore/settings/mediummount/mediumglobal.cc b/noncore/settings/mediummount/mediumglobal.cc
index ab0b3af..0c6cf12 100644
--- a/noncore/settings/mediummount/mediumglobal.cc
+++ b/noncore/settings/mediummount/mediumglobal.cc
@@ -1,185 +1,190 @@
+#include "mediumglobal.h"
+
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+#include <qpe/config.h>
+/* QT */
#include <qlineedit.h>
#include <qcheckbox.h>
#include <qlabel.h>
#include <qabstractlayout.h> // spacer item
#include <qlayout.h>
#include <qframe.h>
#include <qgroupbox.h>
#include <qwhatsthis.h>
-#include <qpe/config.h>
-#include "mediumglobal.h"
using namespace MediumMountSetting;
/* TRANSLATOR MediumMountSetting::MediumGlobalWidget */
MediumGlobalWidget::MediumGlobalWidget(QWidget *wid, const char *name )
: QWidget( wid, name, WStyle_ContextHelp )
{
m_config = 0;
initGUI();
readConfig();
}
void MediumGlobalWidget::initGUI()
{
m_layout = new QVBoxLayout(this );
m_layout->setMargin( 4 );
// m_layout->setSpacing( 10 );
m_label = new QLabel( this );
m_label->setTextFormat( Qt::RichText );
m_label->setText( tr("") );
QWhatsThis::add( this, tr("If a medium gets inserted into this device Opie "
"tries to search the medium for Documents. On "
"large mediums this can take some time. You can choose "
"if Opie should scan for Documents globally or on a "
"per medium level. You're also able to reconfigure "
"each medium.") );
m_layout->addWidget( m_label );
m_check = new QCheckBox( tr("Enable medium checking" ), this );
connect( m_check, SIGNAL(stateChanged(int) ),
this, SLOT(slotEnableChecking() ) );
m_layout->addWidget(m_check );
m_frame = new QFrame(this, "Frame" );
m_frame->setFrameShape( QFrame::Box );
m_frame->setFrameShadow( QFrame::Sunken );
m_box = new QVBoxLayout( m_frame );
m_box->setMargin( 5 );
m_useglobal = new QCheckBox( tr("Use global settings"), m_frame );
connect( m_useglobal, SIGNAL( stateChanged(int) ),
this, SLOT( slotGlobalChanged() ) );
m_box->addWidget( m_useglobal );
m_global = new QGroupBox( tr("Which media files"), m_frame );
m_frameLay = new QGridLayout(m_global, 4, 3 );
m_frameLay->setMargin( 10 );
QSpacerItem *item2 = new QSpacerItem( 5, 8,
QSizePolicy::Fixed,
QSizePolicy::Fixed );
m_audio = new QCheckBox( tr("Audio"), m_global );
m_all = new QCheckBox( tr("All") , m_global );
m_image = new QCheckBox( tr("Image"), m_global );
m_text = new QCheckBox( tr("Text") , m_global );
m_video = new QCheckBox( tr("Video"), m_global );
connect(m_all, SIGNAL(stateChanged(int) ),
this, SLOT(slotAllChanged() ) );
m_frameLay->addItem( item2, 0, 0 );
m_frameLay->addWidget( m_audio, 1, 0 );
m_frameLay->addWidget( m_image, 2, 0 );
m_frameLay->addWidget( m_all, 3, 0 );
m_frameLay->addWidget( m_text, 1, 2 );
m_frameLay->addWidget( m_video, 2, 2 );
m_frameLay->addRowSpacing( 0, 8 );
m_frameLay->addColSpacing( 1, 2 );
m_box->addWidget( m_global );
m_layout->addWidget( m_frame );
QSpacerItem *item1 = new QSpacerItem( 1, 24,
QSizePolicy::Fixed,
QSizePolicy::Expanding );
m_layout->addItem( item1 );
}
void MediumGlobalWidget::readConfig()
{
if( m_config == 0 )
m_config = new Config("medium" );
m_config->setGroup("main");
m_useglobal->setChecked( m_config->readBoolEntry("global", false ) );
m_check->setChecked( m_config->readBoolEntry("use", true ) );
m_config->setGroup("mimetypes" );
m_all->setChecked ( m_config->readBoolEntry("all", false ) );
m_audio->setChecked( m_config->readBoolEntry("audio", true ) );
m_video->setChecked( m_config->readBoolEntry("video", true ) );
m_text->setChecked ( m_config->readBoolEntry("text", true ) );
m_image->setChecked( m_config->readBoolEntry("image", true ) );
slotAllChanged();
slotEnableChecking();
slotGlobalChanged();
if( m_all->isChecked() ){
m_video->setEnabled( false );
m_text->setEnabled( false );
m_audio->setEnabled( false );
m_image->setEnabled( false );
}
}
void MediumGlobalWidget::writeConfig()
{
m_config->setGroup( "main" );
m_config->writeEntry("global", m_useglobal->isChecked() );
m_config->writeEntry("use", m_check->isChecked() );
m_config->setGroup("mimetypes" );
m_config->writeEntry("all", m_all->isChecked() );
m_config->writeEntry("audio", m_audio->isChecked() );
m_config->writeEntry("video", m_video->isChecked() );
m_config->writeEntry("text", m_text->isChecked() );
m_config->writeEntry("image", m_image->isChecked() );
}
MediumGlobalWidget::~MediumGlobalWidget()
{
delete m_config;
}
void MediumGlobalWidget::slotGlobalChanged()
{
int mode = GLOBAL_DISABLED;
bool enabled = false;
if( ( enabled =m_useglobal->isChecked() ) ){
mode = GLOBAL_ENABLED;
}else
mode = GLOBAL_DISABLED;
- qWarning("enabled = %d", enabled );
+ owarn << "enabled = " << enabled << oendl;
m_all->setEnabled ( enabled );
m_audio->setEnabled( enabled );
m_image->setEnabled( enabled );
m_text->setEnabled ( enabled );
m_video->setEnabled ( enabled );
slotAllChanged();
emit globalStateChanged( mode );
}
void MediumGlobalWidget::slotEnableChecking()
{
int mode = ENABLE_CHECKS;
bool enabled = false;
if( ( enabled = m_check->isChecked() ) ){
mode = ENABLE_CHECKS;
}else{
mode = DISABLE_CHECKS;
}
m_frame->setEnabled( enabled );
slotGlobalChanged();
emit enableStateChanged( mode );
}
void MediumGlobalWidget::slotAllChanged()
{
bool enable = !m_all->isChecked();
m_audio->setEnabled( enable );
m_text->setEnabled( enable );
m_video->setEnabled( enable );
m_image->setEnabled( enable );
}
diff --git a/noncore/styles/theme/othemebase.h b/noncore/styles/theme/othemebase.h
index e691692..5519798 100644
--- a/noncore/styles/theme/othemebase.h
+++ b/noncore/styles/theme/othemebase.h
@@ -1,739 +1,744 @@
/* This file is part of the KDE libraries
Copyright (C) 1999 Daniel M. Duley <mosfet@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef __OTHEMEBASE_H
#define __OTHEMEBASE_H
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+
+/* QT */
#include <qdatetime.h>
#include <qtimer.h>
#include <qwindowsstyle.h>
#include <qpixmap.h>
#include <qpe/config.h>
#include <qimage.h>
#include <qintcache.h>
#include <qstring.h>
#include <qpalette.h>
#define WIDGETS 54
/**
* This class adds simple time management to QPixmap for use in flushing
* OThemeCache.
*
* @author Daniel M. Duley <mosfet@kde.org>
*/
class OThemePixmap : public QPixmap
{
public:
- enum BorderType{Top = 0, Bottom, Left, Right, TopLeft, TopRight, BottomLeft,
- BottomRight};
-
- OThemePixmap( bool timer = true );
- OThemePixmap( const OThemePixmap &p );
- ~OThemePixmap();
- QPixmap* border( BorderType type );
- void setBorder( BorderType type, const QPixmap &p );
- void updateAccessed();
- bool isOld();
+ enum BorderType{Top = 0, Bottom, Left, Right, TopLeft, TopRight, BottomLeft,
+ BottomRight};
+
+ OThemePixmap( bool timer = true );
+ OThemePixmap( const OThemePixmap &p );
+ ~OThemePixmap();
+ QPixmap* border( BorderType type );
+ void setBorder( BorderType type, const QPixmap &p );
+ void updateAccessed();
+ bool isOld();
protected:
- QTime *t;
- QPixmap *b[ 8 ];
+ QTime *t;
+ QPixmap *b[ 8 ];
private:
- class OThemePixmapPrivate;
- OThemePixmapPrivate *d;
+ class OThemePixmapPrivate;
+ OThemePixmapPrivate *d;
};
inline QPixmap* OThemePixmap::border( BorderType type )
{
- return ( b[ type ] );
+ return ( b[ type ] );
}
inline void OThemePixmap::setBorder( BorderType type, const QPixmap &p )
{
- if ( b[ type ] ) {
- qWarning( "OThemePixmap: Overwriting existing border!" );
- delete( b[ type ] );
- }
- b[ type ] = new QPixmap( p );
+ if ( b[ type ] ) {
+ owarn << "OThemePixmap: Overwriting existing border!" << oendl;
+ delete( b[ type ] );
+ }
+ b[ type ] = new QPixmap( p );
}
inline void OThemePixmap::updateAccessed()
{
- if (t)
- t->start();
+ if (t)
+ t->start();
}
inline bool OThemePixmap::isOld()
{
- return ( t ? t->elapsed() >= 300000 : false );
+ return ( t ? t->elapsed() >= 300000 : false );
}
/**
* A very simple pixmap cache for theme plugins. QPixmapCache is not used
* since it uses QString keys which are not needed. All the information we
* need can be encoded in a numeric key. Using QIntCache instead allows us to
* skip the string operations.
*
* This class is mostly just inline methods that do bit operations on a key
* composed of the widget ID, width and/or height, and then calls
* QIntCache::find().
*
* One other thing to note is that full, horizontal, and vertically scaled
* pixmaps are not used interchangeably. For example, if you insert a fully
* scaled pixmap that is 32x32 then request a horizontally scaled pixmap with
* a width of 32, they will not match. This is because a pixmap that has been
* inserted into the cache has already been scaled at some point and it is
* very likely the vertical height was not originally 32. Thus the pixmap
* will be wrong when drawn, even though the horizontal width matches.
*
* @author Daniel M. Duley <mosfet@kde.org>
*
*/
class OThemeCache : public QObject
{
- Q_OBJECT
+ Q_OBJECT
public:
- /**
- * The scale hints supported by the cache. Note that Tiled is not here
- * since tiled pixmaps are kept only once in OThemeBase.
- */
- enum ScaleHint{FullScale, HorizontalScale, VerticalScale};
- /**
- * The constructor.
- *
- * @param maxSize The maximum size of the cache in kilobytes.
- */
- OThemeCache( int maxSize, QObject *parent = 0, const char *name = 0 );
- /**
- * Inserts a new pixmap into the cache.
- *
- * @param pixmap The pixmap to insert.
- * @param scale The scaling type of the pixmap.
- * @param widgetID The widget ID of the pixmap, usually from OThemeBase's
- * WidgetType enum.
- *
- * @return True if the insert was successful, false otherwise.
- */
- bool insert( OThemePixmap *pixmap, ScaleHint scale, int widgetID,
- bool border = false, bool mask = false );
- /**
- * Returns a fully scaled pixmap.
- *
- * @param w The pixmap width to search for.
- * @param h The pixmap height to search for.
- * @param widgetID The widget ID to search for.
- *
- * @return True if a pixmap matching the width, height, and widget ID of
- * the pixmap exists, NULL otherwise.
- */
- OThemePixmap* pixmap( int w, int h, int widgetID, bool border = false,
- bool mask = false );
- /**
- * Returns a horizontally scaled pixmap.
- *
- * @param w The pixmap width to search for.
- * @param widgetID The widget ID to search for.
- *
- * @return True if a pixmap matching the width and widget ID of
- * the pixmap exists, NULL otherwise.
- */
- OThemePixmap* horizontalPixmap( int w, int widgetID );
- /**
- * Returns a vertically scaled pixmap.
- *
- * @param h The pixmap height to search for.
- * @param widgetID The widget ID to search for.
- *
- * @return True if a pixmap matching the height and widget ID of
- * the pixmap exists, NULL otherwise.
- */
- OThemePixmap* verticalPixmap( int h, int widgetID );
+ /**
+ * The scale hints supported by the cache. Note that Tiled is not here
+ * since tiled pixmaps are kept only once in OThemeBase.
+ */
+ enum ScaleHint{FullScale, HorizontalScale, VerticalScale};
+ /**
+ * The constructor.
+ *
+ * @param maxSize The maximum size of the cache in kilobytes.
+ */
+ OThemeCache( int maxSize, QObject *parent = 0, const char *name = 0 );
+ /**
+ * Inserts a new pixmap into the cache.
+ *
+ * @param pixmap The pixmap to insert.
+ * @param scale The scaling type of the pixmap.
+ * @param widgetID The widget ID of the pixmap, usually from OThemeBase's
+ * WidgetType enum.
+ *
+ * @return True if the insert was successful, false otherwise.
+ */
+ bool insert( OThemePixmap *pixmap, ScaleHint scale, int widgetID,
+ bool border = false, bool mask = false );
+ /**
+ * Returns a fully scaled pixmap.
+ *
+ * @param w The pixmap width to search for.
+ * @param h The pixmap height to search for.
+ * @param widgetID The widget ID to search for.
+ *
+ * @return True if a pixmap matching the width, height, and widget ID of
+ * the pixmap exists, NULL otherwise.
+ */
+ OThemePixmap* pixmap( int w, int h, int widgetID, bool border = false,
+ bool mask = false );
+ /**
+ * Returns a horizontally scaled pixmap.
+ *
+ * @param w The pixmap width to search for.
+ * @param widgetID The widget ID to search for.
+ *
+ * @return True if a pixmap matching the width and widget ID of
+ * the pixmap exists, NULL otherwise.
+ */
+ OThemePixmap* horizontalPixmap( int w, int widgetID );
+ /**
+ * Returns a vertically scaled pixmap.
+ *
+ * @param h The pixmap height to search for.
+ * @param widgetID The widget ID to search for.
+ *
+ * @return True if a pixmap matching the height and widget ID of
+ * the pixmap exists, NULL otherwise.
+ */
+ OThemePixmap* verticalPixmap( int h, int widgetID );
protected slots:
- void flushTimeout();
+ void flushTimeout();
protected:
- QIntCache<OThemePixmap> cache;
- QTimer flushTimer;
+ QIntCache<OThemePixmap> cache;
+ QTimer flushTimer;
private:
- class OThemeCachePrivate;
- OThemeCachePrivate *d;
+ class OThemeCachePrivate;
+ OThemeCachePrivate *d;
};
/**
* This is a base class for KDE themed styles. It implements a cache,
* configuration file parsing, pixmap scaling, gradients, and a lot
* of inline methods for accessing user specified parameters.
*
* Note that this class *does not* actually implement any themes. It just
* provides the groundwork for doing so. The only reason to use this class
* directly is if you plan to reimplement all of the widgets. Otherwise,
* refer to OThemeStyle for a fully themed style you can derive from.
*
* @author Daniel M. Duley <mosfet@kde.org>
*/
class OThemeBase: public QWindowsStyle
{
- Q_OBJECT
+ Q_OBJECT
public:
- /**
- * Constructs a new OThemeBase object.
- */
- OThemeBase( const QString &configFile );
- ~OThemeBase();
- /**
- * Describes if a pixmap should be scaled fully, horizontally, vertically,
- * or not at all and tiled.
- */
- enum ScaleHint{FullScale, HorizontalScale, VerticalScale, TileScale};
- /**
- * The default arrow types.
- */
- enum ArrowStyle{MotifArrow, LargeArrow, SmallArrow};
- /**
- * The default frame shading styles.
- */
- enum ShadeStyle{Motif, Windows, Next, KDE};
- /**
- * The default scrollbar button layout. BottomLeft is like what Next
- * uses, BottomRight is like Platinum, and Opposite it like Windows and
- * Motif.
- */
- enum SButton{SBBottomLeft, SBBottomRight, SBOpposite};
- /**
- * The gradient types. Horizontal is left to right, Vertical is top to
- * bottom, and diagonal is upper-left to bottom-right.
- */
- enum Gradient{GrNone, GrHorizontal, GrVertical, GrDiagonal, GrPyramid,
- GrRectangle, GrElliptic, GrReverseBevel};
- /**
- * This provides a list of widget types that OThemeBase recognizes.
- */
- /* Internal note: The order here is important. Some widgets inherit
- * properties. This is usually for when you have two settings for the
- * same widget, ie: on(sunken), and off. The on settings will inherit
- * the properties of the off one when nothing is specified in the config.
- *
- * In order to be able to handle this while still having everything in
- * one group that is easy to loop from we have the following order:
- * unsunked(off) items, sunken(on)items, and then the ones that don't
- * matter. INHERIT_ITEMS define the number of widgets that have inheritence
- * so if 0 == PushButtonOff then INHERIT_ITEMS should == PushButtonOn
- * and so on. WIDGETS define the total number of widgets.
- */
- enum WidgetType{
- // Off (unsunken widgets)
- PushButton = 0, ComboBox, HScrollBarSlider, VScrollBarSlider, Bevel,
- ToolButton, ScrollButton, HScrollDeco, VScrollDeco,
- ComboDeco, MenuItem, InactiveTab, ArrowUp, ArrowDown, ArrowLeft,
- ArrowRight,
- // On (sunken widgets)
- PushButtonDown, ComboBoxDown, HScrollBarSliderDown,
- VScrollBarSliderDown, BevelDown, ToolButtonDown, ScrollButtonDown,
- HScrollDecoDown, VScrollDecoDown, ComboDecoDown, MenuItemDown,
- ActiveTab, SunkenArrowUp, SunkenArrowDown, SunkenArrowLeft,
- SunkenArrowRight,
- // Everything else (indicators must have separate settings)
- HScrollGroove, VScrollGroove, Slider, SliderGroove, IndicatorOn,
- IndicatorOff, ExIndicatorOn, ExIndicatorOff, HBarHandle, VBarHandle,
- ToolBar, Splitter, CheckMark, MenuBar, DisArrowUp, DisArrowDown,
- DisArrowLeft, DisArrowRight, ProgressBar, ProgressBg, MenuBarItem,
- Background};
-
- /**
- * The scaling type specified by the Config file.
- *
- * @param widget A Widgets enum value.
- *
- * @return A ScaleHint enum value.
- */
- ScaleHint scaleHint( WidgetType widget ) const;
- /**
- * The gradient type specified by the KConfig file.
- *
- * @param widget A Widgets enum value.
- *
- * @return A Gradient enum value.
- */
- Gradient gradientHint( WidgetType widget ) const;
- /**
- * The color group specified for a given widget.
- * If a color group is set in the theme configuration
- * that is used, otherwise defaultColor is returned.
- *
- * @param defaultColor The colorGroup to set if one is available.
- *
- * @param widget The widget whose color group to retrieve.
- *
- */
- const QColorGroup* colorGroup( const QColorGroup &defaultGroup,
- WidgetType widget ) const;
-
- QBrush pixmapBrush( const QColorGroup &group, QColorGroup::ColorRole role,
- int w, int h, WidgetType widget );
- /**
- * True if the widget has a pixmap or gradient specified.
- */
- bool isPixmap( WidgetType widget ) const;
- /**
- * True if the widget has a color group specified.
- */
- bool isColor( WidgetType widget ) const;
- /**
- * True if the user specified a 3D focus rectangle
- */
- bool is3DFocus() const;
- /**
- * If the user specified a 3D focus rectangle, they may also specify an
- * offset from the default rectangle to use when drawing it. This returns
- * the specified offset.
- */
- int focusOffset() const;
- /**
- * The border width of the specified widget.
- */
- int borderWidth( WidgetType widget ) const;
- /**
- * Pixmap border width of the specified widget.
- */
- int pixBorderWidth( WidgetType widget ) const;
- /**
- * Returns the border pixmap if enabled for the specified widget. This
- * will contain the originial pixmap, plus the edges separated in
- * OThemePixmap::border() if valid. If invalid it will return NULL.
- */
- OThemePixmap* borderPixmap( WidgetType widget );
- /**
- * The highlight width of the specified widget.
- */
- int highlightWidth( WidgetType widget ) const;
- /**
- * The border plus highlight width of the widget.
- */
- int decoWidth( WidgetType widget ) const;
- /**
- * The extent (width for vertical, height for horizontal) requested
- * for the scrollbars.
- */
- int getSBExtent() const;
- /**
- * The scrollbar button layout.
- */
- SButton scrollBarLayout() const;
- /**
- * The arrow type.
- */
- ArrowStyle arrowType() const;
- /**
- * The shading type.
- */
- ShadeStyle shade() const;
- /**
- * The frame width.
- */
- int frameWidth() const;
- /**
- * The splitter width.
- */
- int splitWidth() const;
- /**
- * The contrast for some bevel effects such as reverse gradient.
- */
- int bevelContrast( WidgetType widget ) const;
- /**
- * The button text X shift.
- */
- int buttonXShift() const;
- /**
- * The button text Y shift.
- */
- int buttonYShift() const;
- /**
- * Returns either the slider length of the slider pixmap if available,
- * otherwise the length specified in the config file.
- */
- int sliderButtonLength() const;
- /**
- * True if rounded buttons are requested.
- */
- bool roundButton() const;
- /**
- * True if rounded comboboxes are requested.
- */
- bool roundComboBox() const;
- /**
- * True if rounded slider grooves are requested.
- */
- bool roundSlider() const;
- /**
- * True if a line should be drawn on the bottom of active tabs.
- */
- bool activeTabLine() const;
- /**
- * True if a line should be drawn on the bottom of inactive tabs.
- */
- bool inactiveTabLine() const;
- /**
- * Returns the current uncached pixmap for the given widget. This will
- * usually be either the last scaled or gradient pixmap if those have
- * been specified in the config file, the original pixmap if not, or NULL
- * if no pixmap has been specified.
- */
- OThemePixmap* uncached( WidgetType widget ) const;
- /**
- * Returns the pixmap for the given widget at the specified width and
- * height. This will return NULL if no pixmap or gradient is specified.
- * It may also return a different sized pixmap if the scaling
- * is set to Tiled. When using this method, you should call it using
- * the needed width and height then use QPainter::drawTiledPixmap to
- * paint it. Doing this, if the pixmap is scaled it will be the proper
- * size, otherwise it will be tiled.
- *
- * @param w Requested width.
- * @param h Requested height.
- * @param widget Widget type.
- * @return The pixmap or NULL if one is not specified.
- */
- virtual OThemePixmap *scalePixmap( int w, int h, WidgetType widget );
- /**
- * This method reads a configuration file and applies it to the user's
- * kstylerc file. It does not signal applications to reload via the
- * KDEChangeGeneral atom, if you want to do this you must do so yourself.
- * See kcmdisplay's general.cpp for an example.
- *
- * @param file The configuration file to apply.
- */
- static void applyConfigFile( const QString &file );
+ /**
+ * Constructs a new OThemeBase object.
+ */
+ OThemeBase( const QString &configFile );
+ ~OThemeBase();
+ /**
+ * Describes if a pixmap should be scaled fully, horizontally, vertically,
+ * or not at all and tiled.
+ */
+ enum ScaleHint{FullScale, HorizontalScale, VerticalScale, TileScale};
+ /**
+ * The default arrow types.
+ */
+ enum ArrowStyle{MotifArrow, LargeArrow, SmallArrow};
+ /**
+ * The default frame shading styles.
+ */
+ enum ShadeStyle{Motif, Windows, Next, KDE};
+ /**
+ * The default scrollbar button layout. BottomLeft is like what Next
+ * uses, BottomRight is like Platinum, and Opposite it like Windows and
+ * Motif.
+ */
+ enum SButton{SBBottomLeft, SBBottomRight, SBOpposite};
+ /**
+ * The gradient types. Horizontal is left to right, Vertical is top to
+ * bottom, and diagonal is upper-left to bottom-right.
+ */
+ enum Gradient{GrNone, GrHorizontal, GrVertical, GrDiagonal, GrPyramid,
+ GrRectangle, GrElliptic, GrReverseBevel};
+ /**
+ * This provides a list of widget types that OThemeBase recognizes.
+ */
+ /* Internal note: The order here is important. Some widgets inherit
+ * properties. This is usually for when you have two settings for the
+ * same widget, ie: on(sunken), and off. The on settings will inherit
+ * the properties of the off one when nothing is specified in the config.
+ *
+ * In order to be able to handle this while still having everything in
+ * one group that is easy to loop from we have the following order:
+ * unsunked(off) items, sunken(on)items, and then the ones that don't
+ * matter. INHERIT_ITEMS define the number of widgets that have inheritence
+ * so if 0 == PushButtonOff then INHERIT_ITEMS should == PushButtonOn
+ * and so on. WIDGETS define the total number of widgets.
+ */
+ enum WidgetType{
+ // Off (unsunken widgets)
+ PushButton = 0, ComboBox, HScrollBarSlider, VScrollBarSlider, Bevel,
+ ToolButton, ScrollButton, HScrollDeco, VScrollDeco,
+ ComboDeco, MenuItem, InactiveTab, ArrowUp, ArrowDown, ArrowLeft,
+ ArrowRight,
+ // On (sunken widgets)
+ PushButtonDown, ComboBoxDown, HScrollBarSliderDown,
+ VScrollBarSliderDown, BevelDown, ToolButtonDown, ScrollButtonDown,
+ HScrollDecoDown, VScrollDecoDown, ComboDecoDown, MenuItemDown,
+ ActiveTab, SunkenArrowUp, SunkenArrowDown, SunkenArrowLeft,
+ SunkenArrowRight,
+ // Everything else (indicators must have separate settings)
+ HScrollGroove, VScrollGroove, Slider, SliderGroove, IndicatorOn,
+ IndicatorOff, ExIndicatorOn, ExIndicatorOff, HBarHandle, VBarHandle,
+ ToolBar, Splitter, CheckMark, MenuBar, DisArrowUp, DisArrowDown,
+ DisArrowLeft, DisArrowRight, ProgressBar, ProgressBg, MenuBarItem,
+ Background};
+
+ /**
+ * The scaling type specified by the Config file.
+ *
+ * @param widget A Widgets enum value.
+ *
+ * @return A ScaleHint enum value.
+ */
+ ScaleHint scaleHint( WidgetType widget ) const;
+ /**
+ * The gradient type specified by the KConfig file.
+ *
+ * @param widget A Widgets enum value.
+ *
+ * @return A Gradient enum value.
+ */
+ Gradient gradientHint( WidgetType widget ) const;
+ /**
+ * The color group specified for a given widget.
+ * If a color group is set in the theme configuration
+ * that is used, otherwise defaultColor is returned.
+ *
+ * @param defaultColor The colorGroup to set if one is available.
+ *
+ * @param widget The widget whose color group to retrieve.
+ *
+ */
+ const QColorGroup* colorGroup( const QColorGroup &defaultGroup,
+ WidgetType widget ) const;
+
+ QBrush pixmapBrush( const QColorGroup &group, QColorGroup::ColorRole role,
+ int w, int h, WidgetType widget );
+ /**
+ * True if the widget has a pixmap or gradient specified.
+ */
+ bool isPixmap( WidgetType widget ) const;
+ /**
+ * True if the widget has a color group specified.
+ */
+ bool isColor( WidgetType widget ) const;
+ /**
+ * True if the user specified a 3D focus rectangle
+ */
+ bool is3DFocus() const;
+ /**
+ * If the user specified a 3D focus rectangle, they may also specify an
+ * offset from the default rectangle to use when drawing it. This returns
+ * the specified offset.
+ */
+ int focusOffset() const;
+ /**
+ * The border width of the specified widget.
+ */
+ int borderWidth( WidgetType widget ) const;
+ /**
+ * Pixmap border width of the specified widget.
+ */
+ int pixBorderWidth( WidgetType widget ) const;
+ /**
+ * Returns the border pixmap if enabled for the specified widget. This
+ * will contain the originial pixmap, plus the edges separated in
+ * OThemePixmap::border() if valid. If invalid it will return NULL.
+ */
+ OThemePixmap* borderPixmap( WidgetType widget );
+ /**
+ * The highlight width of the specified widget.
+ */
+ int highlightWidth( WidgetType widget ) const;
+ /**
+ * The border plus highlight width of the widget.
+ */
+ int decoWidth( WidgetType widget ) const;
+ /**
+ * The extent (width for vertical, height for horizontal) requested
+ * for the scrollbars.
+ */
+ int getSBExtent() const;
+ /**
+ * The scrollbar button layout.
+ */
+ SButton scrollBarLayout() const;
+ /**
+ * The arrow type.
+ */
+ ArrowStyle arrowType() const;
+ /**
+ * The shading type.
+ */
+ ShadeStyle shade() const;
+ /**
+ * The frame width.
+ */
+ int frameWidth() const;
+ /**
+ * The splitter width.
+ */
+ int splitWidth() const;
+ /**
+ * The contrast for some bevel effects such as reverse gradient.
+ */
+ int bevelContrast( WidgetType widget ) const;
+ /**
+ * The button text X shift.
+ */
+ int buttonXShift() const;
+ /**
+ * The button text Y shift.
+ */
+ int buttonYShift() const;
+ /**
+ * Returns either the slider length of the slider pixmap if available,
+ * otherwise the length specified in the config file.
+ */
+ int sliderButtonLength() const;
+ /**
+ * True if rounded buttons are requested.
+ */
+ bool roundButton() const;
+ /**
+ * True if rounded comboboxes are requested.
+ */
+ bool roundComboBox() const;
+ /**
+ * True if rounded slider grooves are requested.
+ */
+ bool roundSlider() const;
+ /**
+ * True if a line should be drawn on the bottom of active tabs.
+ */
+ bool activeTabLine() const;
+ /**
+ * True if a line should be drawn on the bottom of inactive tabs.
+ */
+ bool inactiveTabLine() const;
+ /**
+ * Returns the current uncached pixmap for the given widget. This will
+ * usually be either the last scaled or gradient pixmap if those have
+ * been specified in the config file, the original pixmap if not, or NULL
+ * if no pixmap has been specified.
+ */
+ OThemePixmap* uncached( WidgetType widget ) const;
+ /**
+ * Returns the pixmap for the given widget at the specified width and
+ * height. This will return NULL if no pixmap or gradient is specified.
+ * It may also return a different sized pixmap if the scaling
+ * is set to Tiled. When using this method, you should call it using
+ * the needed width and height then use QPainter::drawTiledPixmap to
+ * paint it. Doing this, if the pixmap is scaled it will be the proper
+ * size, otherwise it will be tiled.
+ *
+ * @param w Requested width.
+ * @param h Requested height.
+ * @param widget Widget type.
+ * @return The pixmap or NULL if one is not specified.
+ */
+ virtual OThemePixmap *scalePixmap( int w, int h, WidgetType widget );
+ /**
+ * This method reads a configuration file and applies it to the user's
+ * kstylerc file. It does not signal applications to reload via the
+ * KDEChangeGeneral atom, if you want to do this you must do so yourself.
+ * See kcmdisplay's general.cpp for an example.
+ *
+ * @param file The configuration file to apply.
+ */
+ static void applyConfigFile( const QString &file );
protected:
- /**
- * Returns a QImage for the given widget if the widget is scaled, NULL
- * otherwise. QImages of the original pixmap are stored for scaled
- * widgets in order to facilitate fast and accurate smooth-scaling. This
- * also saves us a conversion from a pixmap to an image then back again.
- */
- QImage* image( WidgetType widget ) const;
- /**
- * Returns the gradient high color if one is specified, NULL otherwise.
- */
- QColor* gradientHigh( WidgetType widget ) const;
- /**
- * Returns the gradient low color if one is specified, NULL otherwise.
- */
- QColor* gradientLow( WidgetType widget ) const;
- /**
- * Reads in all the configuration file entries supported.
- *
- * @param colorStyle The style for the color groups. In KDE, colors were
- * calculated a little differently for Motif vs Windows styles. This
- * is obsolete.
- */
- void readConfig( Qt::GUIStyle colorStyle = Qt::WindowsStyle );
- void readWidgetConfig( int i, Config *config, QString *pixnames,
- QString *brdnames, bool *loadArray );
- void copyWidgetConfig( int sourceID, int destID, QString *pixnames,
- QString *brdnames );
- /**
- * Makes a full color group based on the given foreground and background
- * colors. This is the same code used by KDE (kapp.cpp) in previous
- * versions.
- */
- QColorGroup* makeColorGroup( QColor &fg, QColor &bg,
- Qt::GUIStyle style = Qt::WindowsStyle );
- OThemePixmap* scale( int w, int h, WidgetType widget );
- OThemePixmap* scaleBorder( int w, int h, WidgetType type );
- OThemePixmap* gradient( int w, int h, WidgetType widget );
- OThemePixmap* blend( WidgetType widget );
- void generateBorderPix( int i );
- void applyResourceGroup( Config *config, int i, QString *copyfrom, QString *pixnames, QString *brdnames );
- void applyMiscResourceGroup( Config *config );
- void readResourceGroup( int i, QString *copyfrom, QString *pixnames, QString *brdnames,
- bool *loadArray );
- void readMiscResourceGroup();
- /**
- * Attempts to load a pixmap from the default OThemeBase locations.
- */
- OThemePixmap* loadPixmap( QString &name );
- /**
- * Attempts to load a image from the default OThemeBase locations.
- */
- QImage* loadImage( QString &name );
+ /**
+ * Returns a QImage for the given widget if the widget is scaled, NULL
+ * otherwise. QImages of the original pixmap are stored for scaled
+ * widgets in order to facilitate fast and accurate smooth-scaling. This
+ * also saves us a conversion from a pixmap to an image then back again.
+ */
+ QImage* image( WidgetType widget ) const;
+ /**
+ * Returns the gradient high color if one is specified, NULL otherwise.
+ */
+ QColor* gradientHigh( WidgetType widget ) const;
+ /**
+ * Returns the gradient low color if one is specified, NULL otherwise.
+ */
+ QColor* gradientLow( WidgetType widget ) const;
+ /**
+ * Reads in all the configuration file entries supported.
+ *
+ * @param colorStyle The style for the color groups. In KDE, colors were
+ * calculated a little differently for Motif vs Windows styles. This
+ * is obsolete.
+ */
+ void readConfig( Qt::GUIStyle colorStyle = Qt::WindowsStyle );
+ void readWidgetConfig( int i, Config *config, QString *pixnames,
+ QString *brdnames, bool *loadArray );
+ void copyWidgetConfig( int sourceID, int destID, QString *pixnames,
+ QString *brdnames );
+ /**
+ * Makes a full color group based on the given foreground and background
+ * colors. This is the same code used by KDE (kapp.cpp) in previous
+ * versions.
+ */
+ QColorGroup* makeColorGroup( QColor &fg, QColor &bg,
+ Qt::GUIStyle style = Qt::WindowsStyle );
+ OThemePixmap* scale( int w, int h, WidgetType widget );
+ OThemePixmap* scaleBorder( int w, int h, WidgetType type );
+ OThemePixmap* gradient( int w, int h, WidgetType widget );
+ OThemePixmap* blend( WidgetType widget );
+ void generateBorderPix( int i );
+ void applyResourceGroup( Config *config, int i, QString *copyfrom, QString *pixnames, QString *brdnames );
+ void applyMiscResourceGroup( Config *config );
+ void readResourceGroup( int i, QString *copyfrom, QString *pixnames, QString *brdnames,
+ bool *loadArray );
+ void readMiscResourceGroup();
+ /**
+ * Attempts to load a pixmap from the default OThemeBase locations.
+ */
+ OThemePixmap* loadPixmap( QString &name );
+ /**
+ * Attempts to load a image from the default OThemeBase locations.
+ */
+ QImage* loadImage( QString &name );
private:
- SButton sbPlacement;
- ArrowStyle arrowStyle;
- ShadeStyle shading;
- int defaultFrame;
- int btnXShift, btnYShift;
- int sliderLen;
- int splitterWidth;
- int focus3DOffset;
- int sbExtent;
- bool smallGroove;
- bool roundedButton, roundedCombo, roundedSlider;
- bool aTabLine, iTabLine;
- bool focus3D;
- OThemeCache *cache;
- int cacheSize;
- QString configFileName;
- QString configFilePath;
+ SButton sbPlacement;
+ ArrowStyle arrowStyle;
+ ShadeStyle shading;
+ int defaultFrame;
+ int btnXShift, btnYShift;
+ int sliderLen;
+ int splitterWidth;
+ int focus3DOffset;
+ int sbExtent;
+ bool smallGroove;
+ bool roundedButton, roundedCombo, roundedSlider;
+ bool aTabLine, iTabLine;
+ bool focus3D;
+ OThemeCache *cache;
+ int cacheSize;
+ QString configFileName;
+ QString configFilePath;
protected:
- QColor fgcolor, bgcolor, selfgcolor, selbgcolor, winfgcolor, winbgcolor;
+ QColor fgcolor, bgcolor, selfgcolor, selbgcolor, winfgcolor, winbgcolor;
private:
- /**
- * The theme pixmaps. Many of these may be NULL if no pixmap is specified.
- * There may also be duplicate pixmap pointers if more than one widget
- * uses the same tiled pixmap. If a pixmap is tiled, it is kept here and
- * this acts as a cache. Otherwise this will hold whatever the last scaled
- * pixmap was.
- */
- OThemePixmap *pixmaps[ WIDGETS ];
- /**
- * The theme images. These are for scaled images and are kept in order
- * to maintain fast smoothscaling.
- */
- QImage *images[ WIDGETS ];
- /**
- * The border widths
- */
- unsigned char borders[ WIDGETS ];
- /**
- * The highlight widths
- */
- unsigned char highlights[ WIDGETS ];
- /**
- * The scale hints for pixmaps and gradients.
- */
- ScaleHint scaleHints[ WIDGETS ];
- /**
- * All the color groups.
- */
- QColorGroup *colors[ WIDGETS ];
- /**
- * Gradient low colors (or blend background).
- */
- QColor *grLowColors[ WIDGETS ];
- /**
- * Gradient high colors.
- */
- QColor *grHighColors[ WIDGETS ];
- /**
- * Gradient types.
- */
- Gradient gradients[ WIDGETS ];
- /**
- * Blend intensity factors
- */
- float blends[ WIDGETS ];
- /**
- * Bevel contrasts
- */
- unsigned char bContrasts[ WIDGETS ];
- /**
- * Duplicate pixmap entries (used during destruction).
- */
- bool duplicate[ WIDGETS ];
- /**
- * Pixmapped border widths
- */
- int pbWidth[ WIDGETS ];
- /**
- * Pixmapped borders
- */
- OThemePixmap *pbPixmaps[ WIDGETS ];
- /**
- * Duplicate border pixmapped border entries
- */
- bool pbDuplicate[ WIDGETS ];
+ /**
+ * The theme pixmaps. Many of these may be NULL if no pixmap is specified.
+ * There may also be duplicate pixmap pointers if more than one widget
+ * uses the same tiled pixmap. If a pixmap is tiled, it is kept here and
+ * this acts as a cache. Otherwise this will hold whatever the last scaled
+ * pixmap was.
+ */
+ OThemePixmap *pixmaps[ WIDGETS ];
+ /**
+ * The theme images. These are for scaled images and are kept in order
+ * to maintain fast smoothscaling.
+ */
+ QImage *images[ WIDGETS ];
+ /**
+ * The border widths
+ */
+ unsigned char borders[ WIDGETS ];
+ /**
+ * The highlight widths
+ */
+ unsigned char highlights[ WIDGETS ];
+ /**
+ * The scale hints for pixmaps and gradients.
+ */
+ ScaleHint scaleHints[ WIDGETS ];
+ /**
+ * All the color groups.
+ */
+ QColorGroup *colors[ WIDGETS ];
+ /**
+ * Gradient low colors (or blend background).
+ */
+ QColor *grLowColors[ WIDGETS ];
+ /**
+ * Gradient high colors.
+ */
+ QColor *grHighColors[ WIDGETS ];
+ /**
+ * Gradient types.
+ */
+ Gradient gradients[ WIDGETS ];
+ /**
+ * Blend intensity factors
+ */
+ float blends[ WIDGETS ];
+ /**
+ * Bevel contrasts
+ */
+ unsigned char bContrasts[ WIDGETS ];
+ /**
+ * Duplicate pixmap entries (used during destruction).
+ */
+ bool duplicate[ WIDGETS ];
+ /**
+ * Pixmapped border widths
+ */
+ int pbWidth[ WIDGETS ];
+ /**
+ * Pixmapped borders
+ */
+ OThemePixmap *pbPixmaps[ WIDGETS ];
+ /**
+ * Duplicate border pixmapped border entries
+ */
+ bool pbDuplicate[ WIDGETS ];
private:
- class OThemeBasePrivate;
- OThemeBasePrivate *d;
+ class OThemeBasePrivate;
+ OThemeBasePrivate *d;
};
inline bool OThemeBase::isPixmap( WidgetType widget ) const
{
- return ( pixmaps[ widget ] != NULL || gradients[ widget ] != GrNone );
+ return ( pixmaps[ widget ] != NULL || gradients[ widget ] != GrNone );
}
inline bool OThemeBase::isColor( WidgetType widget ) const
{
- return ( colors[ widget ] != NULL );
+ return ( colors[ widget ] != NULL );
}
inline bool OThemeBase::is3DFocus() const
{
- return ( focus3D );
+ return ( focus3D );
}
inline int OThemeBase::focusOffset() const
{
- return ( focus3DOffset );
+ return ( focus3DOffset );
}
inline int OThemeBase::bevelContrast( WidgetType widget ) const
{
- return ( bContrasts[ widget ] );
+ return ( bContrasts[ widget ] );
}
inline OThemeBase::ScaleHint OThemeBase::scaleHint( WidgetType widget ) const
{
- return ( ( widget < WIDGETS ) ? scaleHints[ widget ] : TileScale );
+ return ( ( widget < WIDGETS ) ? scaleHints[ widget ] : TileScale );
}
inline OThemeBase::Gradient OThemeBase::gradientHint( WidgetType widget ) const
{
- return ( ( widget < WIDGETS ) ? gradients[ widget ] : GrNone );
+ return ( ( widget < WIDGETS ) ? gradients[ widget ] : GrNone );
}
inline OThemePixmap* OThemeBase::uncached( WidgetType widget ) const
{
- return ( pixmaps[ widget ] );
+ return ( pixmaps[ widget ] );
}
inline QBrush OThemeBase::pixmapBrush( const QColorGroup &group,
QColorGroup::ColorRole role,
int w, int h, WidgetType widget )
{
- if ( pixmaps[ widget ] || images[ widget ] )
- return ( QBrush( group.color( role ), *scalePixmap( w, h, widget ) ) );
- else
- return ( group.color( role ) );
+ if ( pixmaps[ widget ] || images[ widget ] )
+ return ( QBrush( group.color( role ), *scalePixmap( w, h, widget ) ) );
+ else
+ return ( group.color( role ) );
}
inline const QColorGroup* OThemeBase::colorGroup( const QColorGroup &defaultGroup,
WidgetType widget ) const
{
- return ( ( colors[ widget ] ) ? colors[ widget ] : &defaultGroup );
+ return ( ( colors[ widget ] ) ? colors[ widget ] : &defaultGroup );
}
inline int OThemeBase::borderWidth( WidgetType widget ) const
{
- return ( pbWidth[ widget ] ? pbWidth[ widget ] : borders[ widget ] );
+ return ( pbWidth[ widget ] ? pbWidth[ widget ] : borders[ widget ] );
}
inline int OThemeBase::pixBorderWidth( WidgetType widget ) const
{
- return ( pbWidth[ widget ] );
+ return ( pbWidth[ widget ] );
}
inline int OThemeBase::highlightWidth( WidgetType widget ) const
{
- return ( pbWidth[ widget ] ? 0 : highlights[ widget ] );
+ return ( pbWidth[ widget ] ? 0 : highlights[ widget ] );
}
inline int OThemeBase::decoWidth( WidgetType widget ) const
{
- return ( pbWidth[ widget ] ? pbWidth[ widget ] : borders[ widget ] + highlights[ widget ] );
+ return ( pbWidth[ widget ] ? pbWidth[ widget ] : borders[ widget ] + highlights[ widget ] );
}
inline QColor* OThemeBase::gradientHigh( WidgetType widget ) const
{
- return ( grHighColors[ widget ] );
+ return ( grHighColors[ widget ] );
}
inline QColor* OThemeBase::gradientLow( WidgetType widget ) const
{
- return ( grLowColors[ widget ] );
+ return ( grLowColors[ widget ] );
}
inline QImage* OThemeBase::image( WidgetType widget ) const
{
- return ( images[ widget ] );
+ return ( images[ widget ] );
}
inline OThemeBase::SButton OThemeBase::scrollBarLayout() const
{
- return ( sbPlacement );
+ return ( sbPlacement );
}
inline OThemeBase::ArrowStyle OThemeBase::arrowType() const
{
- return ( arrowStyle );
+ return ( arrowStyle );
}
inline OThemeBase::ShadeStyle OThemeBase::shade() const
{
- return ( shading );
+ return ( shading );
}
inline int OThemeBase::frameWidth() const
{
- return ( defaultFrame );
+ return ( defaultFrame );
}
inline int OThemeBase::buttonXShift() const
{
- return ( btnXShift );
+ return ( btnXShift );
}
inline int OThemeBase::splitWidth() const
{
- return ( splitterWidth );
+ return ( splitterWidth );
}
inline int OThemeBase::buttonYShift() const
{
- return ( btnYShift );
+ return ( btnYShift );
}
inline int OThemeBase::sliderButtonLength() const
{
- if ( isPixmap( Slider ) )
- return ( uncached( Slider ) ->width() );
- else
- return ( sliderLen );
+ if ( isPixmap( Slider ) )
+ return ( uncached( Slider ) ->width() );
+ else
+ return ( sliderLen );
}
inline bool OThemeBase::roundButton() const
{
- return ( roundedButton );
+ return ( roundedButton );
}
inline bool OThemeBase::roundComboBox() const
{
- return ( roundedCombo );
+ return ( roundedCombo );
}
inline bool OThemeBase::roundSlider() const
{
- return ( roundedSlider );
+ return ( roundedSlider );
}
inline bool OThemeBase::activeTabLine() const
{
- return ( aTabLine );
+ return ( aTabLine );
}
inline bool OThemeBase::inactiveTabLine() const
{
- return ( iTabLine );
+ return ( iTabLine );
}
inline int OThemeBase::getSBExtent() const
{
- return ( sbExtent );
+ return ( sbExtent );
}
inline OThemePixmap* OThemeBase::borderPixmap( WidgetType widget )
{
- return ( pbPixmaps[ widget ] );
+ return ( pbPixmaps[ widget ] );
}
#endif