⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 entrydialog.cpp

📁 Trolltech公司发布的图形界面操作系统。可在qt-embedded-2.3.10平台上编译为嵌入式图形界面操作系统。
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/************************************************************************ Copyright (C) 2000-2005 Trolltech AS.  All rights reserved.**** This file is part of the Qtopia Environment.** ** This program is free software; you can redistribute it and/or modify it** under the terms of the GNU General Public License as published by the** Free Software Foundation; either version 2 of the License, or (at your** option) any later version.** ** A copy of the GNU GPL license version 2 is included in this package as ** LICENSE.GPL.**** This program 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 General Public License for more details.**** In addition, as a special exception Trolltech gives permission to link** the code of this program with Qtopia applications copyrighted, developed** and distributed by Trolltech under the terms of the Qtopia Personal Use** License Agreement. You must comply with the GNU General Public License** in all respects for all of the code used other than the applications** licensed under the Qtopia Personal Use License Agreement. If you modify** this file, you may extend this exception to your version of the file,** but you are not obligated to do so. If you do not wish to do so, delete** this exception statement from your version.** ** 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_TZSELECT_INC_LOCAL#include "entrydialog.h"#include "repeatentry.h"#include "nulldb.h"#include "eventview.h"#include <qtopia/vscrollview.h>#include <qtopia/datetimeedit.h>#include <qtopia/qpeapplication.h>#include <qtopia/categoryselect.h>#include <qtopia/global.h>#include <qtopia/timeconversion.h>#include <qtopia/timestring.h>#include <qtopia/tzselect.h>#include <qtopia/pim/private/eventio_p.h>#if !defined(QTOPIA_PHONE) && defined(QTOPIA_DATA_LINKING)#include <qtopia/pixmapdisplay.h>#endif#include <qtopia/resource.h>#ifdef QTOPIA_PHONE#include <qtopia/iconselect.h>#endif#ifdef QTOPIA_DATA_LINKING#include <qtopia/qdl.h>#endif#ifdef QTOPIA_DESKTOP#include <worldtimedialog.h>#endif#include <qcheckbox.h>#include <qstyle.h>#include <qregexp.h>#include <qcombobox.h>#include <qlayout.h>#include <qlineedit.h>#include <qmultilineedit.h>#include <qpopupmenu.h>#include <qscrollview.h>#include <qspinbox.h>#include <qtoolbutton.h>#include <qlabel.h>#include <qlayout.h>#include <qtabwidget.h>#include <qtimer.h>#include <stdlib.h>static bool onceAWeek(const PimEvent &e){    int orig = e.start().date().dayOfWeek();    for (int i = 1; i <= 7; i++) {	if (i != orig && e.repeatOnWeekDay(i))	    return FALSE;    }    return TRUE;}static void setOnceAWeek( PimEvent &e ){    int orig = e.start().date().dayOfWeek();    for (int i = 1; i <= 7; i++) {	if (i != orig)	    e.setRepeatOnWeekDay(i, FALSE);    }}static void addOrPick( QComboBox* combo, const QString& t ){    for (int i=0; i<combo->count(); i++) {	if ( combo->text(i) == t ) {	    combo->setCurrentItem(i);	    return;	}    }    combo->setEditText(t);}//------------------------------------------------------------------------------EntryDialog::EntryDialog( bool startOnMonday, const QDateTime &start, const QDateTime &end,			  QWidget *parent, const char *name, bool modal, WFlags f )    : QDialog( parent, name, modal, f #ifdef QTOPIA_DESKTOP    | WStyle_Customize | WStyle_DialogBorder | WStyle_Title#endif    ),    startWeekOnMonday( startOnMonday ){    Q_UNUSED(name);    init();    setDates(start,end);}EntryDialog::EntryDialog( bool startOnMonday, const PimEvent &event,			  QWidget *parent, const char *name, bool modal, WFlags f )    : QDialog( parent, name, modal, f#ifdef QTOPIA_DESKTOP    | WStyle_Customize | WStyle_DialogBorder | WStyle_Title#endif    ),    mEvent(event), mOrigEvent( event ), startWeekOnMonday( startOnMonday ){    Q_UNUSED(name);    init();    if (mEvent.timeZone().isValid()) {	entry->timezone->setCurrentZone(mEvent.timeZone().id());    }    setDates(mEvent.start(),mEvent.end());    entry->comboCategory->setCategories( mEvent.categories(), "Calendar", // No tr	    tr("Calendar") );    addOrPick( entry->comboDescription, mEvent.description() );    addOrPick( entry->comboLocation, mEvent.location() );    entry->spinAlarm->setValue(mEvent.alarmDelay());    entry->spinAlarm->setEnabled(mEvent.hasAlarm());    if ( mEvent.hasAlarm() ) {	if (mEvent.alarmSound() != PimEvent::Silent)	    entry->comboSound->setCurrentItem(2);	else	    entry->comboSound->setCurrentItem(1);    } else {	entry->comboSound->setCurrentItem(0);    }    entry->checkAllDay->setChecked( mEvent.isAllDay() );    if(!mEvent.notes().isEmpty())	editNote->setText(mEvent.notes());    if ( mEvent.hasRepeat() ) {	if (mEvent.frequency() == 1 && mEvent.repeatType() == PimEvent::Daily)	    entry->repeatSelect->setCurrentItem(1);	else if (mEvent.frequency() == 1 && mEvent.repeatType() == PimEvent::Weekly		&& onceAWeek(mEvent) )	    entry->repeatSelect->setCurrentItem(2);	else if (mEvent.frequency() == 1 && mEvent.repeatType() == PimEvent::Yearly)	    entry->repeatSelect->setCurrentItem(3);	else	    entry->repeatSelect->setCurrentItem(4);	if (mEvent.repeatForever()) {	    // so that when opens, will have view at or close to start date of event,	    entry->endDateSelect->setDate(mEvent.start().date());	    entry->endDateSelect->setDate(QDate());	} else {	    entry->endDateSelect->setDate(mEvent.repeatTill());	}    } else {	entry->repeatSelect->setCurrentItem(0);	entry->endDateSelect->setEnabled(FALSE);	// so that when opens, will have view at or close to start date of event,	entry->endDateSelect->setDate(mEvent.start().date());	entry->endDateSelect->setDate(QDate());    }    setRepeatLabel();    #ifdef QTOPIA_DATA_LINKING    QDL::loadLinks( event.customField( QDL::DATA_KEY ), QDL::clients( this ) );#endif}void EntryDialog::setDates( const QDateTime& s, const QDateTime& e ){    mEvent.setStart(s);    mEvent.setEnd(e);    entry->startButton->setDateTime(s);    entry->endButton->setDateTime(e);}void EntryDialog::init(){    //setCaption?    QGridLayout *gl = new QGridLayout( this );    gl->setSpacing( 3 );    gl->setMargin( 0 );    tw = new QTabWidget( this, "tabwidget" );    gl->addMultiCellWidget( tw, 0, 0, 0, 2 );#ifdef QTOPIA_DESKTOP    gl->setSpacing( 6 );    gl->setMargin( 6 );    QPushButton *buttonCancel = new QPushButton( this, "buttoncancel" );    buttonCancel->setText( tr("Cancel") );    gl->addWidget( buttonCancel, 1, 2 );    QPushButton *buttonOk = new QPushButton( this, "buttonok" );    buttonOk->setText( tr( "OK" ) );    gl->addWidget( buttonOk, 1, 1 );    buttonOk->setDefault( TRUE );    QSpacerItem *spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );    gl->addItem( spacer, 1, 0 );#endif    QWidget *noteTab = new QWidget( this );    QGridLayout *noteLayout = new QGridLayout( noteTab );    editNote = new QMultiLineEdit( noteTab );    editNote->setWordWrap( QMultiLineEdit::WidgetWidth );    int rowCount = 0;#if defined(QTOPIA_DATA_LINKING)    QDLWidgetClient *client = new QDLWidgetClient( editNote, "editNote" );#ifdef QTOPIA_PHONE    client->setupStandardContextMenu();#else    PixmapDisplay *linkButton = new PixmapDisplay( noteTab );    linkButton->setPixmap( Resource::loadIconSet( "qdllink" )					    .pixmap( QIconSet::Small, TRUE ) );    connect( linkButton, SIGNAL(clicked()), client, SLOT(requestLink()) );    noteLayout->addWidget( linkButton, rowCount++, 0, Qt::AlignRight );    linkButton->setFocusPolicy( NoFocus );#endif#endif    noteLayout->addWidget( editNote, rowCount++, 0 );#ifndef QTOPIA_DESKTOP    VScrollView *sv = new VScrollView( this );    entry = new EntryDetails( sv->viewport() );    sv->addChild( entry );    tw->addTab( sv, tr("Event") );#else    entry = new EntryDetails( tw );    tw->addTab( entry, tr("Event") );#endif    entry->startButton->setOrientation(Vertical);    entry->endButton->setOrientation(Vertical);    tw->addTab( noteTab, tr("Notes") );#if defined(QTOPIA_DESKTOP)    eventView = new EventView( this );    connect(tw, SIGNAL(currentChanged(QWidget*)),	    this, SLOT(tabChanged(QWidget*)) );    tw->addTab( eventView, tr("Summary") );#else    eventView = 0;#endif    // XXX should load/save this    entry->comboLocation->insertItem(tr("Office"));    entry->comboLocation->insertItem(tr("Home","ie. not work"));    addOrPick( entry->comboLocation, "" );    // XXX enable these two lines to be able to specify local time events.    entry->timezone->setLocalIncluded(TRUE);    entry->timezone->setCurrentZone("None");    entry->comboDescription->setInsertionPolicy(QComboBox::AtCurrent);    entry->comboLocation->setInsertionPolicy(QComboBox::AtCurrent);#ifdef QTOPIA_PHONE    // Setup the comboSound widget    entry->comboSound->insertItem( QPixmap( Resource::loadPixmap( "noalarm" ) ), tr( "No Alarm" ) );    entry->comboSound->insertItem( QPixmap( Resource::loadPixmap( "silent" ) ), tr( "Silent" ) );    entry->comboSound->insertItem( QPixmap( Resource::loadPixmap( "audible" ) ), tr( "Audible" ) );#endif#ifdef QTOPIA_DESKTOP    connect((QObject *)entry->timezone->d, SIGNAL(configureTimeZones()), this, SLOT(configureTimeZones()));#endif    setTabOrder(entry->comboDescription, entry->comboLocation);    setTabOrder(entry->comboLocation, entry->checkAllDay);    setTabOrder(entry->checkAllDay,  // No tr	    (QWidget *)entry->startButton->child("date")); // No tr    setTabOrder((QWidget *)entry->startButton->child("date"),  // No tr	    (QWidget *)entry->startButton->child("time")); // No tr    setTabOrder((QWidget *)entry->startButton->child("time"),  // No tr	    (QWidget *)entry->endButton->child("date")); // No tr    setTabOrder((QWidget *)entry->endButton->child("date"),  // No tr	    (QWidget *)entry->endButton->child("time")); // No tr    setTabOrder((QWidget *)entry->endButton->child("time"),	    (QWidget *)entry->timezone->child("timezone combo"));    setTabOrder((QWidget *)entry->timezone->child("timezone combo"), entry->comboSound); // No tr    setTabOrder(entry->comboSound, entry->spinAlarm);    setTabOrder(entry->spinAlarm, entry->repeatSelect);    setTabOrder(entry->repeatSelect, entry->endDateSelect);    setTabOrder(entry->endDateSelect, (QWidget *)entry->comboCategory->child("category combo")); // No tr    QTimer::singleShot( 0, entry->comboDescription, SLOT( setFocus() ) );    // Now for the lines to do with eneabling for exception events.    if (mEvent.isException()) {	entry->repeatSelect->setEnabled(FALSE);	entry->repeatSelect->hide();	entry->endDateSelect->setEnabled(FALSE);	entry->endDateSelect->hide();	entry->lblEndDate->hide();	entry->lblRepeat->hide();    }    connect( entry->checkAllDay, SIGNAL(toggled(bool)),	     this, SLOT(allDayToggled(bool)) );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -