summaryrefslogtreecommitdiff
path: root/library
authoralwin <alwin>2004-03-02 12:21:11 (UTC)
committer alwin <alwin>2004-03-02 12:21:11 (UTC)
commitb6b1c97559c0ed9f2e33632272426bf98f289232 (patch) (side-by-side diff)
treed3a9987704770cdf5eb14e1136f6e3ecb2f36a04 /library
parent0d59c780513da78033f4d9040475dee9db0256d4 (diff)
downloadopie-b6b1c97559c0ed9f2e33632272426bf98f289232.zip
opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.gz
opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.bz2
applied the patch generated by the optimize_connect script from
TT.
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/datebookmonth.cpp28
-rw-r--r--library/fileselector.cpp16
-rw-r--r--library/finddialog.cpp12
-rw-r--r--library/findwidget_p.cpp4
-rw-r--r--library/ir.cpp4
-rw-r--r--library/network.cpp4
-rw-r--r--library/qcopenvelope_qws.cpp4
-rw-r--r--library/qpeapplication.cpp12
-rw-r--r--library/qpedialog.cpp4
-rw-r--r--library/storage.cpp4
-rw-r--r--library/timestring.cpp2
-rw-r--r--library/tzselect.cpp8
12 files changed, 49 insertions, 53 deletions
diff --git a/library/datebookmonth.cpp b/library/datebookmonth.cpp
index 76e022f..421559e 100644
--- a/library/datebookmonth.cpp
+++ b/library/datebookmonth.cpp
@@ -24,99 +24,99 @@
#include <qpe/qpeapplication.h>
#include <qtoolbutton.h>
#include <qspinbox.h>
#include <qcombobox.h>
#include <qvaluestack.h>
#include <qwhatsthis.h>
DateBookMonthHeader::DateBookMonthHeader( QWidget *parent, const char *name )
: QHBox( parent, name )
{
setBackgroundMode( PaletteButton );
begin = new QToolButton( this );
begin->setFocusPolicy(NoFocus);
begin->setPixmap( Resource::loadPixmap( "start" ) );
begin->setAutoRaise( TRUE );
begin->setFixedSize( begin->sizeHint() );
QWhatsThis::add( begin, tr("Show January in the selected year") );
back = new QToolButton( this );
back->setFocusPolicy(NoFocus);
back->setPixmap( Resource::loadPixmap( "back" ) );
back->setAutoRaise( TRUE );
back->setFixedSize( back->sizeHint() );
QWhatsThis::add( back, tr("Show the previous month") );
month = new QComboBox( FALSE, this );
for ( int i = 0; i < 12; ++i )
month->insertItem( Calendar::nameOfMonth( i + 1 ) );
year = new QSpinBox( 1752, 8000, 1, this );
next = new QToolButton( this );
next->setFocusPolicy(NoFocus);
next->setPixmap( Resource::loadPixmap( "forward" ) );
next->setAutoRaise( TRUE );
next->setFixedSize( next->sizeHint() );
QWhatsThis::add( next, tr("Show the next month") );
end = new QToolButton( this );
end->setFocusPolicy(NoFocus);
end->setPixmap( Resource::loadPixmap( "finish" ) );
end->setAutoRaise( TRUE );
end->setFixedSize( end->sizeHint() );
QWhatsThis::add( end, tr("Show December in the selected year") );
- connect( month, SIGNAL( activated( int ) ),
+ connect( month, SIGNAL( activated(int) ),
this, SLOT( updateDate() ) );
- connect( year, SIGNAL( valueChanged( int ) ),
+ connect( year, SIGNAL( valueChanged(int) ),
this, SLOT( updateDate() ) );
connect( begin, SIGNAL( clicked() ),
this, SLOT( firstMonth() ) );
connect( end, SIGNAL( clicked() ),
this, SLOT( lastMonth() ) );
connect( back, SIGNAL( clicked() ),
this, SLOT( monthBack() ) );
connect( next, SIGNAL( clicked() ),
this, SLOT( monthForward() ) );
back->setAutoRepeat( TRUE );
next->setAutoRepeat( TRUE );
}
DateBookMonthHeader::~DateBookMonthHeader()
{
}
void DateBookMonthHeader::updateDate()
{
emit dateChanged( year->value(), month->currentItem() + 1 );
}
void DateBookMonthHeader::firstMonth()
{
emit dateChanged( year->value(), 1 );
month->setCurrentItem( 0 );
}
void DateBookMonthHeader::lastMonth()
{
emit dateChanged( year->value(), 12 );
month->setCurrentItem( 11 );
}
void DateBookMonthHeader::monthBack()
{
if ( month->currentItem() > 0 ) {
emit dateChanged( year->value(), month->currentItem() );
month->setCurrentItem( month->currentItem() - 1 );
} else {
emit dateChanged( year->value() - 1, 12 );
// we have a signal set to a changed value in year so we only need to change
// year to get the result...
month->setCurrentItem( 11 );
year->setValue( year->value() - 1 );
}
@@ -142,100 +142,100 @@ void DateBookMonthHeader::setDate( int y, int m )
}
//---------------------------------------------------------------------------
class DateBookMonthTablePrivate
{
public:
DateBookMonthTablePrivate() {};
~DateBookMonthTablePrivate() { mMonthEvents.clear(); };
QValueList<EffectiveEvent> mMonthEvents;
bool onMonday;
};
DateBookMonthTable::DateBookMonthTable( QWidget *parent, const char *name,
DateBookDB *newDb )
: QTable( 6, 7, parent, name ),
db( newDb )
{
d = new DateBookMonthTablePrivate();
selYear = -1;
selMonth = -1;
selDay = -1;
/* init these as well make valgrind happy and be consistent with Qtopia1.6 -zecke */
year = -1;
month = -1;
day = -1;
Config cfg( "qpe" );
cfg.setGroup( "Time" );
d->onMonday = cfg.readBoolEntry( "MONDAY" );
horizontalHeader()->setResizeEnabled( FALSE );
// we have to do this here... or suffer the consequences later...
for ( int i = 0; i < 7; i++ ){
horizontalHeader()->resizeSection( i, 30 );
setColumnStretchable( i, TRUE );
}
setupLabels();
verticalHeader()->hide();
setLeftMargin( 0 );
for ( int i = 0; i < 6; ++i )
setRowStretchable( i, TRUE );
setSelectionMode( NoSelection );
- connect( this, SIGNAL( clicked( int, int, int, const QPoint & ) ),
- this, SLOT( dayClicked( int, int ) ) );
- connect( this, SIGNAL( currentChanged( int, int ) ),
- this, SLOT( dragDay( int, int ) ) );
+ connect( this, SIGNAL( clicked(int,int,int,const QPoint&) ),
+ this, SLOT( dayClicked(int,int) ) );
+ connect( this, SIGNAL( currentChanged(int,int) ),
+ this, SLOT( dragDay(int,int) ) );
setVScrollBarMode( AlwaysOff );
setHScrollBarMode( AlwaysOff );
}
DateBookMonthTable::~DateBookMonthTable()
{
monthsEvents.clear();
delete d;
}
void DateBookMonthTable::setDate(int y, int m, int d)
{
if (month == m && year == y) {
if ( selYear == -1 )
year = selYear;
if ( selMonth == -1 )
month = selMonth;
int r1, c1, r2, c2;
findDay(selDay, r1, c1);
selDay = day = d;
findDay(selDay, r2, c2);
setCurrentCell( r2, c2 );
//updateCell(r1,c1);
//updateCell(r2,c2);
} else {
selYear = year = y;
selMonth = month = m;
selDay = day = d;
setupTable();
}
}
void DateBookMonthTable::redraw()
{
setupLabels();
setupTable();
}
void DateBookMonthTable::setWeekStart( bool onMonday )
{
d->onMonday = onMonday;
setupLabels();
setupTable();
}
void DateBookMonthTable::setupTable()
{
QValueList<Calendar::Day> days = Calendar::daysOfMonth( year, month, d->onMonday );
@@ -349,100 +349,100 @@ void DateBookMonthTable::getEvents()
&& e.date() == (*it).date() ) {
dayEvent.append( *it );
++it;
}
int row, col;
findDay( e.date().day(), row, col );
DayItemMonth* w = static_cast<DayItemMonth*>( item( row, col ) );
w->setEvents( dayEvent );
updateCell( row, col );
dayEvent.clear();
}
}
void DateBookMonthTable::setupLabels()
{
for ( int i = 0; i < 7; ++i ) {
// horizontalHeader()->resizeSection( i, 30 );
// setColumnStretchable( i, TRUE );
if ( d->onMonday )
horizontalHeader()->setLabel( i, Calendar::nameOfDay( i + 1 ) );
else {
if ( i == 0 )
horizontalHeader()->setLabel( i, Calendar::nameOfDay( 7 ) );
else
horizontalHeader()->setLabel( i, Calendar::nameOfDay( i ) );
}
}
}
//---------------------------------------------------------------------------
DateBookMonth::DateBookMonth( QWidget *parent, const char *name, bool ac,
DateBookDB *data )
: QVBox( parent, name ),
autoClose( ac )
{
setFocusPolicy(StrongFocus);
year = QDate::currentDate().year();
month = QDate::currentDate().month();
day = QDate::currentDate().day();
header = new DateBookMonthHeader( this, "DateBookMonthHeader" );
table = new DateBookMonthTable( this, "DateBookMonthTable", data );
header->setDate( year, month );
table->setDate( year, month, QDate::currentDate().day() );
header->setFocusPolicy(NoFocus);
table->setFocusPolicy(NoFocus);
- connect( header, SIGNAL( dateChanged( int, int ) ),
- this, SLOT( setDate( int, int ) ) );
- connect( table, SIGNAL( dateClicked( int, int, int ) ),
- this, SLOT( finalDate(int, int, int) ) );
+ connect( header, SIGNAL( dateChanged(int,int) ),
+ this, SLOT( setDate(int,int) ) );
+ connect( table, SIGNAL( dateClicked(int,int,int) ),
+ this, SLOT( finalDate(int,int,int) ) );
connect( qApp, SIGNAL(weekChanged(bool)), this,
SLOT(slotWeekChange(bool)) );
table->setFocus();
}
DateBookMonth::~DateBookMonth()
{
}
void DateBookMonth::setDate( int y, int m )
{
/* only change the date if this is a different date,
* other wise we may mistakenly overide the day */
if ( (y != year) || (m != month) ) {
year = y;
month = m;
QDate nd( y, m, 1 );
if ( nd.daysInMonth() < day )
day = nd.daysInMonth();
table->setDate( year, month, day );
}
}
void DateBookMonth::setDate( int y, int m, int d )
{
header->setDate( y, m);
table->setDate( y, m, d);
year = y;
month = m;
day = d;
}
/* called when we wish to close or pass back the date */
void DateBookMonth::finalDate(int y, int m, int d)
{
setDate( y, m, d );
emit dateClicked(y, m, d);
// emit dateClicked(QDate(y, m, d).toString());
if ( autoClose && parentWidget() )
parentWidget()->close();
}
void DateBookMonth::setDate( QDate d)
{
setDate(d.year(), d.month(), d.day());
@@ -651,100 +651,100 @@ void DayItemMonth::paint( QPainter *p, const QColorGroup &cg,
p->setFont( f );
QFontMetrics fm( f );
p->drawText( 1, 1 + fm.ascent(), QString::number( day() ) );
p->restore();
}
void DayItemMonth::setType( Calendar::Day::Type t )
{
switch ( t ) {
case Calendar::Day::PrevMonth:
case Calendar::Day::NextMonth:
back = QBrush( QColor( 224, 224, 224 ) );
forg = black;
break;
case Calendar::Day::ThisMonth:
back = QBrush( white );
forg = black;
break;
}
typ = t;
}
DateButton::DateButton( bool longDate, QWidget *parent, const char * name )
:QPushButton( parent, name )
{
longFormat = longDate;
df = DateFormat('/', DateFormat::MonthDayYear, DateFormat::MonthDayYear);
setDate( QDate::currentDate() );
connect(this,SIGNAL(pressed()),this,SLOT(pickDate()));
}
void DateButton::pickDate()
{
static QPopupMenu *m1 = 0;
static DateBookMonth *picker = 0;
if ( !m1 ) {
m1 = new QPopupMenu( this );
picker = new DateBookMonth( m1, 0, TRUE );
m1->insertItem( picker );
- connect( picker, SIGNAL( dateClicked( int, int, int ) ),
- this, SLOT( setDate( int, int, int ) ) );
- connect( picker, SIGNAL( dateClicked( int, int, int ) ),
- this, SIGNAL( dateSelected( int, int, int ) ) );
+ connect( picker, SIGNAL( dateClicked(int,int,int) ),
+ this, SLOT( setDate(int,int,int) ) );
+ connect( picker, SIGNAL( dateClicked(int,int,int) ),
+ this, SIGNAL( dateSelected(int,int,int) ) );
connect( m1, SIGNAL( aboutToHide() ),
this, SLOT( gotHide() ) );
}
picker->slotWeekChange( weekStartsMonday );
picker->setDate( currDate.year(), currDate.month(), currDate.day() );
m1->popup(mapToGlobal(QPoint(0,height())));
picker->setFocus();
}
void DateButton::gotHide()
{
// we have to redo the button...
setDown( false );
}
// void dateSelected( int year, int month, int day );
void DateButton::setWeekStartsMonday( int b )
{
weekStartsMonday = b;
}
void DateButton::setDate( int y, int m, int d )
{
setDate( QDate( y,m,d) );
}
void DateButton::setDate( QDate d )
{
currDate = d;
setText( longFormat ? TimeString::longDateString( d, df ) :
TimeString::shortDate( d, df ) );
}
void DateButton::setDateFormat( DateFormat f )
{
df = f;
setDate( currDate );
}
bool DateButton::customWhatsThis() const
{
return TRUE;
}
diff --git a/library/fileselector.cpp b/library/fileselector.cpp
index 7c29aba..93fb429 100644
--- a/library/fileselector.cpp
+++ b/library/fileselector.cpp
@@ -263,125 +263,125 @@ public:
\ingroup qtopiaemb
\sa FileManager
*/
/*!
Constructs a FileSelector with mime filter \a f.
The standard Qt \a parent and \a name parameters are passed to the
parent widget.
If \a newVisible is TRUE, the widget has a button to allow the user
the create "new" documents; this is useful for applications that can
create and edit documents but not suitable for applications that
only provide viewing.
\a closeVisible is deprecated
\sa DocLnkSet::DocLnkSet()
*/
FileSelector::FileSelector( const QString &f, QWidget *parent, const char *name, bool newVisible, bool closeVisible )
: QVBox( parent, name ), filter( f )
{
setMargin( 0 );
setSpacing( 0 );
d = new FileSelectorPrivate();
d->newDocItem = 0;
d->showNew = newVisible;
d->catId = -2; // All files
d->toolbar = new QHBox( this );
d->toolbar->setBackgroundMode( PaletteButton ); // same colour as toolbars
d->toolbar->setSpacing( 0 );
d->toolbar->hide();
QWidget *spacer = new QWidget( d->toolbar );
spacer->setBackgroundMode( PaletteButton );
QToolButton *tb = new QToolButton( d->toolbar );
tb->setPixmap( Resource::loadPixmap( "close" ) );
connect( tb, SIGNAL( clicked() ), this, SIGNAL( closeMe() ) );
buttonClose = tb;
tb->setFixedSize( 18, 20 ); // tb->sizeHint() );
tb->setAutoRaise( TRUE );
QToolTip::add( tb, tr( "Close the File Selector" ) );
QPEMenuToolFocusManager::manager()->addWidget( tb );
view = new FileSelectorView( this, "fileview" );
QPEApplication::setStylusOperation( view->viewport(), QPEApplication::RightOnHold );
- connect( view, SIGNAL( mouseButtonClicked( int, QListViewItem *, const QPoint &, int ) ),
- this, SLOT( fileClicked( int, QListViewItem *, const QPoint &, int ) ) );
- connect( view, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint &, int ) ),
- this, SLOT( filePressed( int, QListViewItem *, const QPoint &, int ) ) );
- connect( view, SIGNAL( returnPressed( QListViewItem * ) ),
- this, SLOT( fileClicked( QListViewItem * ) ) );
+ connect( view, SIGNAL( mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ),
+ this, SLOT( fileClicked(int,QListViewItem*,const QPoint&,int) ) );
+ connect( view, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),
+ this, SLOT( filePressed(int,QListViewItem*,const QPoint&,int) ) );
+ connect( view, SIGNAL( returnPressed(QListViewItem*) ),
+ this, SLOT( fileClicked(QListViewItem*) ) );
QHBox *hb = new QHBox( this );
d->typeCombo = new TypeCombo( hb );
connect( d->typeCombo, SIGNAL(selected(const QString&)),
this, SLOT(typeSelected(const QString&)) );
QWhatsThis::add( d->typeCombo, tr("Show documents of this type") );
Categories c;
c.load(categoryFileName());
QArray<int> vl( 0 );
d->catSelect = new CategorySelect( hb );
d->catSelect->setRemoveCategoryEdit( TRUE );
d->catSelect->setCategories( vl, "Document View", tr("Document View") );
d->catSelect->setAllCategories( TRUE );
connect( d->catSelect, SIGNAL(signalSelected(int)), this, SLOT(catSelected(int)) );
QWhatsThis::add( d->catSelect, tr("Show documents in this category") );
setCloseVisible( closeVisible );
QCopChannel *channel = new QCopChannel( "QPE/Card", this );
- connect( channel, SIGNAL(received(const QCString &, const QByteArray &)),
- this, SLOT(cardMessage( const QCString &, const QByteArray &)) );
+ connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
+ this, SLOT(cardMessage(const QCString&,const QByteArray&)) );
reread();
updateWhatsThis();
}
/*!
Destroys the widget.
*/
FileSelector::~FileSelector()
{
delete d;
}
/*!
Returns the number of files in the view. If this is zero, an editor
application might bypass the selector and immediately start with
a "new" document.
*/
int FileSelector::fileCount()
{
return d->files.children().count();;
}
/*!
Calling this function is the programmatic equivalent of the user
pressing the "new" button.
\sa newSelected(), closeMe()
*/
void FileSelector::createNew()
{
DocLnk f;
emit newSelected( f );
emit closeMe();
}
void FileSelector::fileClicked( int button, QListViewItem *i, const QPoint &, int )
{
if ( !i )
return;
if ( button == Qt::LeftButton ) {
fileClicked( i );
}
}
void FileSelector::filePressed( int button, QListViewItem *i, const QPoint &, int )
{
if ( !i || i == d->newDocItem )
diff --git a/library/finddialog.cpp b/library/finddialog.cpp
index 64487c9..9417179 100644
--- a/library/finddialog.cpp
+++ b/library/finddialog.cpp
@@ -1,84 +1,80 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
** This file is part of the Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
// WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT
// have this class.
#define QTOPIA_INTERNAL_FD
#include "finddialog.h"
#include "findwidget_p.h"
#include <qlayout.h>
/*!
\class FindDialog finddialog.h
\brief A simple FindDialog
A find dialog. FIXME!!!!
*/
FindDialog::FindDialog( const QString &appName, QWidget *parent,
const char *name, bool modal )
: QDialog( parent, name, modal )
{
setCaption( tr("Find") );
QVBoxLayout *vb;
vb = new QVBoxLayout( this );
fw = new FindWidget( appName, this, "Find Widget" );
vb->addWidget( fw );
- QObject::connect( fw, SIGNAL(signalFindClicked(const QString&,
- bool,bool,int)),
- this, SIGNAL(signalFindClicked(const QString&,
- bool,bool,int)) );
- QObject::connect( fw, SIGNAL(signalFindClicked(const QString&,const QDate&,
- bool,bool,int)),
- this, SIGNAL(signalFindClicked(const QString&,
- const QDate&,bool,bool,int)) );
+ QObject::connect( fw, SIGNAL(signalFindClicked(const QString&,bool,bool,int)),
+ this, SIGNAL(signalFindClicked(const QString&,bool,bool,int)) );
+ QObject::connect( fw, SIGNAL(signalFindClicked(const QString&,const QDate&,bool,bool,int)),
+ this, SIGNAL(signalFindClicked(const QString&,const QDate&,bool,bool,int)) );
d = 0;
}
FindDialog::~FindDialog()
{
}
QString FindDialog::findText() const
{
return fw->findText();
}
void FindDialog::setUseDate( bool show )
{
fw->setUseDate( show );
}
void FindDialog::setDate( const QDate &dt )
{
fw->setDate( dt );
}
void FindDialog::slotNotFound()
{
fw->slotNotFound();
}
void FindDialog::slotWrapAround()
{
fw->slotWrapAround();
}
diff --git a/library/findwidget_p.cpp b/library/findwidget_p.cpp
index e91d789..0591f07 100644
--- a/library/findwidget_p.cpp
+++ b/library/findwidget_p.cpp
@@ -2,98 +2,98 @@
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
** This file is part of the Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "findwidget_p.h"
#include <qpe/categoryselect.h>
#include <qpe/datebookmonth.h>
#include <qcheckbox.h>
#include <qlabel.h>
#include <qlineedit.h>
FindWidget::FindWidget( const QString &appName, QWidget *parent,
const char *name )
: FindWidgetBase( parent, name ),
mStrApp( appName ),
mDate( QDate::currentDate() )
{
setMaximumSize( sizeHint() );
QArray<int> vl(0);
cmbCat->setCategories( vl, mStrApp );
cmbCat->setRemoveCategoryEdit( TRUE );
cmbCat->setAllCategories( TRUE );
// hide junk for the moment...
lblStartDate->hide();
cmdStartDate->hide();
QPopupMenu *m1 = new QPopupMenu( this );
dtPicker = new DateBookMonth( m1, 0, TRUE );
dtPicker->setDate( mDate.year(), mDate.month(), mDate.day() );
m1->insertItem( dtPicker );
cmdStartDate->setPopup( m1 );
cmdStartDate->setText( TimeString::shortDate(mDate) );
- QObject::connect( dtPicker, SIGNAL(dateClicked(int, int, int)),
- this, SLOT(slotDateChanged(int, int, int)) );
+ QObject::connect( dtPicker, SIGNAL(dateClicked(int,int,int)),
+ this, SLOT(slotDateChanged(int,int,int)) );
QObject::connect( cmdFind, SIGNAL(clicked()),
this, SLOT(slotFindClicked()) );
}
FindWidget::~FindWidget()
{
}
QString FindWidget::findText() const
{
return txtFind->text();
}
void FindWidget::slotFindClicked()
{
lblStatus->setText( "" );
if ( cmdStartDate->isVisible() )
emit signalFindClicked( findText(),
mDate,
chkCase->isChecked(),
chkBackwards->isChecked(),
cmbCat->currentCategory() );
else
emit signalFindClicked( findText(), chkCase->isChecked(),
chkBackwards->isChecked(),
cmbCat->currentCategory() );
}
void FindWidget::setUseDate( bool show )
{
if ( show ) {
lblStartDate->show();
cmdStartDate->show();
} else {
lblStartDate->hide();
cmdStartDate->hide();
}
chkBackwards->setDisabled( show );
}
void FindWidget::setDate( const QDate &dt )
{
slotDateChanged( dt.year(), dt.month(), dt.day() );
}
void FindWidget::slotNotFound()
{
diff --git a/library/ir.cpp b/library/ir.cpp
index 32c0925..c581eb1 100644
--- a/library/ir.cpp
+++ b/library/ir.cpp
@@ -3,98 +3,98 @@
**
** This file is part of the Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "ir.h"
#include "qcopenvelope_qws.h"
#include "applnk.h"
/*!
\class Ir ir.h
\brief The Ir class implements basic support for sending objects over an
infrared communication link.
Both \link doclnk.html DocLnk\endlink objects and files can be
sent to another device via the infrared link using the send()
function. When the send has completed the done() signal is
emitted.
The supported() function returns whether the device supports
infrared communication or not.
\ingroup qtopiaemb
*/
/*!
Constructs an Ir object. The \a parent and \a name classes are the
standard QObject parameters.
*/
Ir::Ir( QObject *parent, const char *name )
: QObject( parent, name )
{
#ifndef QT_NO_COP
ch = new QCopChannel( "QPE/Obex" );
- connect( ch, SIGNAL(received(const QCString &, const QByteArray &)),
- this, SLOT(obexMessage( const QCString &, const QByteArray &)) );
+ connect( ch, SIGNAL(received(const QCString&,const QByteArray&)),
+ this, SLOT(obexMessage(const QCString&,const QByteArray&)) );
#endif
}
/*!
Returns TRUE if the system supports infrared communication;
otherwise returns FALSE.
*/
bool Ir::supported()
{
#ifndef QT_NO_COP
return QCopChannel::isRegistered( "QPE/Obex" );
#endif
}
/*!
Sends the object in file \a fn over the infrared link. The \a
description is used in the text shown to the user while sending
is in progress. The optional \a mimetype parameter specifies the
mimetype of the object. If this parameter is not set, it is
determined by the the filename's suffix.
\sa done()
*/
void Ir::send( const QString &fn, const QString &description, const QString &mimetype)
{
if ( !filename.isEmpty() ) return;
filename = fn;
#ifndef QT_NO_COP
QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)");
e << description << filename << mimetype;
#endif
}
/*!
\overload
Uses the DocLnk::file() and DocLnk::type() of \a doc.
\sa done()
*/
void Ir::send( const DocLnk &doc, const QString &description )
{
send( doc.file(), description, doc.type() );
}
/*!
\fn Ir::done( Ir *ir );
diff --git a/library/network.cpp b/library/network.cpp
index 991e11a..df28857 100644
--- a/library/network.cpp
+++ b/library/network.cpp
@@ -116,98 +116,98 @@ void Network::connectChoiceChange(QObject* receiver, const char* slot)
}
#endif // QT_NO_COP
/*!
\internal
*/
QString Network::settingsDir()
{
return Global::applicationFileName("Network", "modules");
}
#ifndef QT_NO_COP
/*!
\internal
*/
QStringList Network::choices(QListBox* lb, const QString& dir)
{
QStringList list;
if ( lb )
lb->clear();
QString adir = dir.isEmpty() ? settingsDir() : dir;
QDir settingsdir(adir);
settingsdir.mkdir(adir);
QStringList files = settingsdir.entryList("*.conf");
for (QStringList::ConstIterator it=files.begin(); it!=files.end(); ++it ) {
QString filename = settingsdir.filePath(*it);
Config cfg(filename, Config::File);
cfg.setGroup("Info");
if ( lb )
lb->insertItem(Resource::loadPixmap("Network/" + cfg.readEntry("Type")),
cfg.readEntry("Name"));
list.append(filename);
}
return list;
}
class NetworkServer : public QCopChannel {
Q_OBJECT
public:
NetworkServer(QObject* parent) : QCopChannel("QPE/Network",parent), wait(0)
{
up = FALSE;
examineNetworks( TRUE );
QCopChannel* card = new QCopChannel("QPE/Card",parent);
- connect(card,SIGNAL(received(const QCString &, const QByteArray&)),
- this,SLOT(cardMessage(const QCString &, const QByteArray&)));
+ connect(card,SIGNAL(received(const QCString&,const QByteArray&)),
+ this,SLOT(cardMessage(const QCString&,const QByteArray&)));
}
~NetworkServer()
{
stop();
}
bool networkOnline() const
{
return up;
}
private:
void receive(const QCString &msg, const QByteArray& data)
{
if ( msg == "start(QString,QString)" ) {
QDataStream stream(data,IO_ReadOnly);
QString file,password;
stream >> file >> password;
if ( file.isEmpty() ) {
QStringList l = Network::choices();
for (QStringList::ConstIterator i=l.begin(); i!=l.end(); ++i) {
Config cfg(*i,Config::File);
cfg.setGroup("Info");
QString type = cfg.readEntry("Type");
NetworkInterface* plugin = Network::loadPlugin(type);
cfg.setGroup("Properties");
if ( plugin && plugin->isAvailable(cfg) ) {
file = *i;
break;
}
}
if ( file.isEmpty() ) {
QCopEnvelope("QPE/Network", "failed()");
return;
}
}
start(file,password);
} else if ( msg == "stop()" ) {
stop();
} else if ( msg == "choicesChanged()" ) {
examineNetworks();
}
}
private slots:
void cardMessage(const QCString &msg, const QByteArray&)
{
diff --git a/library/qcopenvelope_qws.cpp b/library/qcopenvelope_qws.cpp
index 8f58787..63efb13 100644
--- a/library/qcopenvelope_qws.cpp
+++ b/library/qcopenvelope_qws.cpp
@@ -23,98 +23,98 @@
#endif
#include <qbuffer.h>
#include <qfile.h>
#include <unistd.h>
#include <errno.h>
#include <sys/file.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#ifndef QT_NO_COP
/*!
\class QCopEnvelope qcopenvelope_qws.h
\brief The QCopEnvelope class encapsulates and sends QCop messages
over QCopChannels.
QCop messages allow applications to communicate with each other.
These messages are sent using QCopEnvelope, and received by connecting
to a QCopChannel.
To send a message, use the following protocol:
\code
QCopEnvelope e(channelname, messagename);
e << parameter1 << parameter2 << ...;
\endcode
For messages without parameters, simply use:
\code
QCopEnvelope e(channelname, messagename);
\endcode
(Do not try to simplify this further as it may confuse some
compilers.)
The \c{channelname} of channels within Qtopia all start with "QPE/".
The \c{messagename} is a function identifier followed by a list of types
in parentheses. There is no whitespace in the message name.
To receive a message, you will generally just use your application's
predefined QPE/Application/\e{appname} channel
(see QPEApplication::appMessage()), but you can make another channel
and connect it to a slot like this:
\code
myChannel = new QCopChannel( "QPE/FooBar", this );
- connect( myChannel, SIGNAL(received(const QCString &, const QByteArray &)),
- this, SLOT(fooBarMessage( const QCString &, const QByteArray &)) );
+ connect( myChannel, SIGNAL(received(const QCString&,const QByteArray&)),
+ this, SLOT(fooBarMessage(const QCString&,const QByteArray&)) );
\endcode
See also, the \link qcop.html list of Qtopia messages\endlink.
*/
/*!
Constructs a QCopEnvelope that will write \a message to \a channel.
If \a message has parameters, you must then use operator<<() to
add these parameters to the envelope.
*/
QCopEnvelope::QCopEnvelope( const QCString& channel, const QCString& message ) :
QDataStream(new QBuffer),
ch(channel), msg(message)
{
device()->open(IO_WriteOnly);
}
/*!
Writes the message and then destroys the QCopEnvelope.
*/
QCopEnvelope::~QCopEnvelope()
{
QByteArray data = ((QBuffer*)device())->buffer();
const int pref=16;
if ( qstrncmp(ch.data(),"QPE/Application/",pref)==0 ) {
QString qcopfn("/tmp/qcop-msg-");
qcopfn += ch.mid(pref);
QFile qcopfile(qcopfn);
if ( qcopfile.open(IO_WriteOnly | IO_Append) ) {
#ifndef Q_OS_WIN32
if(flock(qcopfile.handle(), LOCK_EX)) {
/* some error occurred */
qWarning(QString("Failed to obtain file lock on %1 (%2)")
.arg(qcopfn).arg( errno ));
}
#endif
{
QDataStream ds(&qcopfile);
ds << ch << msg << data;
qcopfile.flush();
#ifndef Q_OS_WIN32
flock(qcopfile.handle(), LOCK_UN);
#endif
qcopfile.close();
}
QByteArray b;
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 262221e..c339a78 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -583,120 +583,120 @@ void QPEApplication::processQCopFile()
\endcode
\sa qcop.html
Note that messages received here may be processed by qpe application
and emitted as signals, such as flush() and reload().
*/
/*!
Constructs a QPEApplication just as you would construct
a QApplication, passing \a argc, \a argv, and \a t.
For applications, \a t should be the default, GuiClient. Only
the Qtopia server passes GuiServer.
*/
QPEApplication::QPEApplication( int & argc, char **argv, Type t )
: QApplication( hack(argc), argv, t ), pidChannel( 0 )
{
QPixmapCache::setCacheLimit(256); // sensible default for smaller devices.
d = new QPEApplicationData;
d->loadTextCodecs();
d->loadImageCodecs();
int dw = desktop() ->width();
if ( dw < 200 ) {
setFont( QFont( "vera", 8 ) );
AppLnk::setSmallIconSize( 10 );
AppLnk::setBigIconSize( 28 );
}
#if defined(OPIE_HIGH_RES_SMALL_PHY)
else if ( dw > 600 ) {
setFont( QFont( "vera", 16 ) );
AppLnk::setSmallIconSize( 24 );
AppLnk::setBigIconSize( 48 );
}
#endif
else if ( dw > 200 ) {
setFont( QFont( "vera", 10 ) );
AppLnk::setSmallIconSize( 14 );
AppLnk::setBigIconSize( 32 );
}
QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory );
connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) );
sysChannel = new QCopChannel( "QPE/System", this );
- connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ),
- this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) );
+ connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
+ this, SLOT( systemMessage(const QCString&,const QByteArray&) ) );
/* COde now in initapp */
#if 0
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
QString qcopfn( "/tmp/qcop-msg-" );
qcopfn += QString( argv[ 0 ] ); // append command name
QFile f( qcopfn );
if ( f.open( IO_ReadOnly ) ) {
flock( f.handle(), LOCK_EX );
}
QCString channel = QCString( argv[ 0 ] );
channel.replace( QRegExp( ".*/" ), "" );
d->appName = channel;
channel = "QPE/Application/" + channel;
pidChannel = new QCopChannel( channel, this );
- connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ),
- this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) );
+ connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
+ this, SLOT( pidMessage(const QCString&,const QByteArray&) ) );
if ( f.isOpen() ) {
d->keep_running = FALSE;
QDataStream ds( &f );
QCString channel, message;
QByteArray data;
while ( !ds.atEnd() ) {
ds >> channel >> message >> data;
d->enqueueQCop( channel, message, data );
}
flock( f.handle(), LOCK_UN );
f.close();
f.remove();
}
for ( int a = 0; a < argc; a++ ) {
if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) {
argv[ a ] = argv[ a + 1 ];
a++;
d->preloaded = TRUE;
argc -= 1;
}
else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) {
argv[ a ] = argv[ a + 1 ];
a++;
d->preloaded = TRUE;
d->forceshow = TRUE;
argc -= 1;
}
}
/* overide stored arguments */
setArgs( argc, argv );
#endif
#else
initApp( argc, argv );
#endif
// qwsSetDecoration( new QPEDecoration() );
#ifndef QT_NO_TRANSLATION
d->langs = Global::languageList();
for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) {
QString lang = *it;
installTranslation( lang + "/libopie.qm");
@@ -706,98 +706,98 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
//###language/font hack; should look it up somewhere
#ifdef QWS
if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
QFont fn = FontManager::unicodeFont( FontManager::Proportional );
setFont( fn );
}
#endif
}
#endif
applyStyle();
if ( type() == GuiServer ) {
setVolume();
}
installEventFilter( this );
QPEMenuToolFocusManager::initialize();
#ifdef QT_NO_QWS_CURSOR
// if we have no cursor, probably don't want tooltips
QToolTip::setEnabled( FALSE );
#endif
}
#ifdef QTOPIA_INTERNAL_INITAPP
void QPEApplication::initApp( int argc, char **argv )
{
delete pidChannel;
d->keep_running = TRUE;
d->preloaded = FALSE;
d->forceshow = FALSE;
QCString channel = QCString(argv[0]);
channel.replace(QRegExp(".*/"),"");
d->appName = channel;
#if QT_VERSION > 235
qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6
#endif
channel = "QPE/Application/" + channel;
pidChannel = new QCopChannel( channel, this);
- connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)),
- this, SLOT(pidMessage(const QCString &, const QByteArray &)));
+ connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)),
+ this, SLOT(pidMessage(const QCString&,const QByteArray&)));
processQCopFile();
d->keep_running = d->qcopq.isEmpty();
for (int a=0; a<argc; a++) {
if ( qstrcmp(argv[a],"-preload")==0 ) {
argv[a] = argv[a+1];
a++;
d->preloaded = TRUE;
argc-=1;
} else if ( qstrcmp(argv[a],"-preload-show")==0 ) {
argv[a] = argv[a+1];
a++;
d->preloaded = TRUE;
d->forceshow = TRUE;
argc-=1;
}
}
/* overide stored arguments */
setArgs(argc, argv);
/* install translation here */
for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it )
installTranslation( (*it) + "/" + d->appName + ".qm" );
}
#endif
static QPtrDict<void>* inputMethodDict = 0;
static void createInputMethodDict()
{
if ( !inputMethodDict )
inputMethodDict = new QPtrDict<void>;
}
/*!
Returns the currently set hint to the system as to whether
widget \a w has any use for text input methods.
\sa setInputMethodHint() InputMethodHint
*/
QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w )
{
if ( inputMethodDict && w )
diff --git a/library/qpedialog.cpp b/library/qpedialog.cpp
index ac42972..da461b7 100644
--- a/library/qpedialog.cpp
+++ b/library/qpedialog.cpp
@@ -4,71 +4,71 @@
** This file is part of the Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#define protected public
#include <qdialog.h>
#undef protected
#include "qpedialog.h"
#include <qpe/qpeapplication.h>
/**
* \brief This is the only c'tor.
*
* The parent of this Listener is the Dialog you pass. This means once
* the dialog is deleted this listener will be deleted too.
* This Listener listens on QPEApplication::appMessage signal and implements
* accept() and reject().
*
* \code
* QDialog *dialog = new YourDialog();
(void)new QPEDialogListener(dialog);
if( QPEApplication::execDialog(dialog) == QDialog::Accept ){
// do some stuff
}
delete dialog;
* \endcode
*
* @param di The dialog to handle
*/
QPEDialogListener::QPEDialogListener(QDialog *di ) : QObject(di)
{
dialog = di;
- connect(qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)),
- this, SLOT(appMessage(const QCString&, const QByteArray&)) );
+ connect(qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)),
+ this, SLOT(appMessage(const QCString&,const QByteArray&)) );
}
/**
* d'tor
*/
QPEDialogListener::~QPEDialogListener() {}
/**
* \internal
*/
void QPEDialogListener::appMessage( const QCString &msg, const QByteArray & )
{
if (!dialog)
return;
if (msg == "accept()") {
dialog->accept();
} else if (msg == "reject()") {
dialog->reject();
}
}
diff --git a/library/storage.cpp b/library/storage.cpp
index 0ea465b..fcee689 100644
--- a/library/storage.cpp
+++ b/library/storage.cpp
@@ -50,98 +50,98 @@ static bool isCF(const QString& m)
#ifndef Q_OS_MACX
FILE* f = fopen("/var/run/stab", "r");
if (!f) f = fopen("/var/state/pcmcia/stab", "r");
if (!f) f = fopen("/var/lib/pcmcia/stab", "r");
if ( f )
{
char line[1024];
char devtype[80];
char devname[80];
while ( fgets( line, 1024, f ) )
{
// 0 ide ide-cs 0 hda 3 0
if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 )
{
if ( QString(devtype) == "ide" && m.find(devname)>0 )
{
fclose(f);
return TRUE;
}
}
}
fclose(f);
}
#endif /* Q_OS_MACX */
return FALSE;
}
/*! \class StorageInfo storage.h
\brief The StorageInfo class describes the disks mounted on the file system.
This class provides access to the mount information for the Linux
filesystem. Each mount point is represented by the FileSystem class.
To ensure this class has the most up to date size information, call
the update() method. Note that this will automatically be signaled
by the operating system when a disk has been mounted or unmounted.
\ingroup qtopiaemb
*/
/*! Constructor that determines the current mount points of the filesystem.
The standard \a parent parameters is passed on to QObject.
*/
StorageInfo::StorageInfo( QObject *parent )
: QObject( parent )
{
mFileSystems.setAutoDelete( TRUE );
channel = new QCopChannel( "QPE/Card", this );
- connect( channel, SIGNAL(received(const QCString &, const QByteArray &)),
- this, SLOT(cardMessage( const QCString &, const QByteArray &)) );
+ connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
+ this, SLOT(cardMessage(const QCString&,const QByteArray&)) );
update();
}
/*! Returns the longest matching FileSystem that starts with the
same prefix as \a filename as its mount point.
*/
const FileSystem *StorageInfo::fileSystemOf( const QString &filename )
{
for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i)
{
if ( filename.startsWith( (*i)->path() ) )
return (*i);
}
return 0;
}
void StorageInfo::cardMessage( const QCString& msg, const QByteArray& )
{
if ( msg == "mtabChanged()" )
update();
}
/*! Updates the mount and free space available information for each mount
point. This method is automatically called when a disk is mounted or
unmounted.
*/
// cause of the lack of a d pointer we need
// to store informations in a config file :(
void StorageInfo::update()
{
//qDebug("StorageInfo::updating");
#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
struct mntent *me;
FILE *mntfp = setmntent( "/etc/mtab", "r" );
QStringList curdisks;
QStringList curopts;
QStringList curfs;
bool rebuild = FALSE;
int n=0;
if ( mntfp )
{
while ( (me = getmntent( mntfp )) != 0 )
{
QString fs = me->mnt_fsname;
if ( fs.left(7)=="/dev/hd" || fs.left(7)=="/dev/sd"
diff --git a/library/timestring.cpp b/library/timestring.cpp
index 2fd0191..91c29ae 100644
--- a/library/timestring.cpp
+++ b/library/timestring.cpp
@@ -8,97 +8,97 @@
** 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 "timestring.h"
#include <qobject.h>
#include <qpe/qpeapplication.h> //for qApp
#include "config.h"
class TimeStringFormatKeeper : public QObject
{
Q_OBJECT
public:
static DateFormat currentFormat()
{
if ( !self )
self = new TimeStringFormatKeeper;
return self->format;
}
private slots:
void formatChanged( DateFormat f )
{
format = f;
}
private:
static TimeStringFormatKeeper *self;
DateFormat format;
TimeStringFormatKeeper()
: QObject( qApp )
{
Config config("qpe");
config.setGroup( "Date" );
format = DateFormat(QChar(config.readEntry("Separator", "/")[0]),
(DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear),
(DateFormat::Order)config.readNumEntry("LongOrder", DateFormat::DayMonthYear));
connect( qApp, SIGNAL( dateFormatChanged(DateFormat) ),
- this, SLOT( formatChanged( DateFormat ) ) );
+ this, SLOT( formatChanged(DateFormat) ) );
}
};
TimeStringFormatKeeper *TimeStringFormatKeeper::self = 0;
QString DateFormat::toNumberString() const
{
QString buf = "";
// for each part of the order
for (int i = 0; i < 3; i++) {
// switch on the relavent 3 bits.
switch((_shortOrder >> (i * 3)) & 0x0007) {
case 0x0001:
buf += QObject::tr( "D" , "Shortcut for Day");
break;
case 0x0002:
buf += QObject::tr( "M", "Shortcur for Month" );
break;
case 0x0004:
buf += QObject::tr( "Y" );
break;
}
if (i < 2)
buf += _shortSeparator;
}
return buf;
}
QString DateFormat::toWordString() const
{
QString buf = "";
// for each part of the order
for (int i = 0; i < 3; i++) {
// switch on the relavent 3 bits.
switch((_longOrder >> (i * 3)) & 0x0007) {
case 0x0001:
buf += QObject::tr( "day" );
if (i < 2) {
if ((_shortOrder << ((i+1) * 3)) & 0x0007)
buf += ", ";
else
buf += " ";
}
break;
case 0x0002:
buf += QObject::tr( "month" );
if (i < 2)
buf += " ";
diff --git a/library/tzselect.cpp b/library/tzselect.cpp
index f28100b..848dfb7 100644
--- a/library/tzselect.cpp
+++ b/library/tzselect.cpp
@@ -32,98 +32,98 @@
#include <qmessagebox.h>
/*!
\class TimeZoneSelector
\brief The TimeZoneSelector widget allows users to configure their time zone information.
\ingroup qtopiaemb
*/
class TimeZoneSelectorPrivate
{
public:
TimeZoneSelectorPrivate() : includeLocal(FALSE) {}
bool includeLocal;
};
TZCombo::TZCombo( QWidget *p, const char* n )
: QComboBox( p, n )
{
updateZones();
// check to see if TZ is set, if it is set the current item to that
QString tz = getenv("TZ");
if (parent()->inherits("TimeZoneSelector")) {
if ( ((TimeZoneSelector *)parent())->localIncluded() ) {
// overide to the 'local' type.
tz = "None";
}
}
if ( !tz.isNull() ) {
int n = 0,
index = 0;
for ( QStringList::Iterator it=identifiers.begin();
it!=identifiers.end(); ++it) {
if ( *it == tz )
index = n;
n++;
}
setCurrentItem(index);
} else {
setCurrentItem(0);
}
// listen on QPE/System
#if !defined(QT_NO_COP)
QCopChannel *channel = new QCopChannel( "QPE/System", this );
- connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
- this, SLOT(handleSystemChannel(const QCString&, const QByteArray&)) );
+ connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
+ this, SLOT(handleSystemChannel(const QCString&,const QByteArray&)) );
#endif
}
TZCombo::~TZCombo()
{
}
void TZCombo::updateZones()
{
QString cur = currentText();
clear();
identifiers.clear();
int curix=0;
QString tz = getenv("TZ");
bool tzFound = FALSE;
Config cfg("CityTime");
cfg.setGroup("TimeZones");
int listIndex = 0;
if (parent()->inherits("TimeZoneSelector")) {
if ( ((TimeZoneSelector *)parent())->localIncluded() ) {
// overide to the 'local' type.
identifiers.append( "None" );
insertItem( tr("None") );
if ( cur == tr("None"))
curix = 0;
listIndex++;
}
}
int cfgIndex = 0;
while (1) {
QString zn = cfg.readEntry("Zone"+QString::number(cfgIndex), QString::null);
if ( zn.isNull() )
break;
if ( zn == tz )
tzFound = TRUE;
QString nm = cfg.readEntry("ZoneName"+QString::number(cfgIndex));
identifiers.append(zn);
insertItem(nm);
if ( nm == cur )
curix = listIndex;
++cfgIndex;
++listIndex;
}
if ( !listIndex ) {
QStringList list = timezoneDefaults();
for ( QStringList::Iterator it = list.begin(); it!=list.end(); ++it ) {
@@ -173,98 +173,98 @@ void TZCombo::mousePressEvent(QMouseEvent*e)
}
QString TZCombo::currZone() const
{
return identifiers[currentItem()];
}
void TZCombo::setCurrZone( const QString& id )
{
for (int i=0; i< count(); i++) {
if ( identifiers[i] == id ) {
setCurrentItem(i);
return;
}
}
insertItem(id);
setCurrentItem( count() - 1);
identifiers.append(id);
extras.append(id);
}
void TZCombo::handleSystemChannel(const QCString&msg, const QByteArray&)
{
if ( msg == "timeZoneListChange()" ) {
updateZones();
}
}
/*!
Creates a new TimeZoneSelector with parent \a p and name \a n. The combobox will be
populated with the available timezones.
*/
TimeZoneSelector::TimeZoneSelector(QWidget* p, const char* n) :
QHBox(p,n)
{
d = new TimeZoneSelectorPrivate();
// build the combobox before we do any updates...
cmbTz = new TZCombo( this, "timezone combo" );
cmdTz = new QToolButton( this, "timezone button" );
cmdTz->setIconSet( Resource::loadIconSet( "citytime_icon" ) );
cmdTz->setMaximumSize( cmdTz->sizeHint() );
// set up a connection to catch a newly selected item and throw our
// signal
- QObject::connect( cmbTz, SIGNAL( activated( int ) ),
- this, SLOT( slotTzActive( int ) ) );
+ QObject::connect( cmbTz, SIGNAL( activated(int) ),
+ this, SLOT( slotTzActive(int) ) );
QObject::connect( cmdTz, SIGNAL( clicked() ),
this, SLOT( slotExecute() ) );
}
/*!
Destroys a TimeZoneSelector.
*/
TimeZoneSelector::~TimeZoneSelector()
{
}
void TimeZoneSelector::setLocalIncluded(bool b)
{
d->includeLocal = b;
cmbTz->updateZones();
}
bool TimeZoneSelector::localIncluded() const
{
return d->includeLocal;
}
/*!
Returns the currently selected timezone as a string in location format, e.g.
\code Australia/Brisbane \endcode
*/
QString TimeZoneSelector::currentZone() const
{
return cmbTz->currZone();
}
/*!
Sets the current timezone to \a id.
*/
void TimeZoneSelector::setCurrentZone( const QString& id )
{
cmbTz->setCurrZone( id );
}
/*! \fn void TimeZoneSelector::signalNewTz( const QString& id )
This signal is emitted when a timezone has been selected by the user. The id
is a \l QString in location format, eg \code Australia/Brisbane \endcode
*/
void TimeZoneSelector::slotTzActive( int )
{
emit signalNewTz( cmbTz->currZone() );
}