Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/examples/widgets/calendarwidget/window.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information ([email protected])
     4** All rights reserved.
     5** Contact: Nokia Corporation ([email protected])
    56**
    67** This file is part of the examples of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you
     37** @nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    168168void Window::reformatCalendarPage()
    169169{
    170     QTextCharFormat mayFirstFormat;
    171     if (mayFirstCheckBox->isChecked())
     170    if (firstFridayCheckBox->isChecked()) {
     171        QDate firstFriday(calendar->yearShown(), calendar->monthShown(), 1);
     172        while (firstFriday.dayOfWeek() != Qt::Friday)
     173            firstFriday = firstFriday.addDays(1);
     174        QTextCharFormat firstFridayFormat;
     175        firstFridayFormat.setForeground(Qt::blue);
     176        calendar->setDateTextFormat(firstFriday, firstFridayFormat);
     177    }
     178
     179    //May First in Red takes precedence
     180    if (mayFirstCheckBox->isChecked()) {
     181        const QDate mayFirst(calendar->yearShown(), 5, 1);
     182        QTextCharFormat mayFirstFormat;
    172183        mayFirstFormat.setForeground(Qt::red);
    173 
    174     QTextCharFormat firstFridayFormat;
    175     if (firstFridayCheckBox->isChecked())
    176         firstFridayFormat.setForeground(Qt::blue);
    177 
    178     QDate date(calendar->yearShown(), calendar->monthShown(), 1);
    179 
    180     calendar->setDateTextFormat(QDate(date.year(), 5, 1), mayFirstFormat);
    181 
    182     date.setDate(date.year(), date.month(), 1);
    183     while (date.dayOfWeek() != Qt::Friday)
    184         date = date.addDays(1);
    185     calendar->setDateTextFormat(date, firstFridayFormat);
     184        calendar->setDateTextFormat(mayFirst, mayFirstFormat);
     185    }
    186186}
    187187//! [8]
     
    197197    calendar->setGridVisible(true);
    198198
    199     connect(calendar, SIGNAL(currentPageChanged(int, int)),
     199    connect(calendar, SIGNAL(currentPageChanged(int,int)),
    200200            this, SLOT(reformatCalendarPage()));
    201201
     
    358358
    359359//! [13] //! [14]
    360     connect(currentDateEdit, SIGNAL(dateChanged(const QDate &)),
    361             calendar, SLOT(setSelectedDate(const QDate &)));
     360    connect(currentDateEdit, SIGNAL(dateChanged()),
     361            calendar, SLOT(setSelectedDate()));
    362362    connect(calendar, SIGNAL(selectionChanged()),
    363363            this, SLOT(selectedDateChanged()));
    364     connect(minimumDateEdit, SIGNAL(dateChanged(const QDate &)),
    365             this, SLOT(minimumDateChanged(const QDate &)));
    366     connect(maximumDateEdit, SIGNAL(dateChanged(const QDate &)),
    367             this, SLOT(maximumDateChanged(const QDate &)));
     364    connect(minimumDateEdit, SIGNAL(dateChanged()),
     365            this, SLOT(minimumDateChanged()));
     366    connect(maximumDateEdit, SIGNAL(dateChanged()),
     367            this, SLOT(maximumDateChanged()));
    368368
    369369//! [14]
     
    419419    connect(weekendColorCombo, SIGNAL(currentIndexChanged(int)),
    420420            this, SLOT(weekendFormatChanged()));
    421     connect(headerTextFormatCombo, SIGNAL(currentIndexChanged(const QString &)),
     421    connect(headerTextFormatCombo, SIGNAL(currentIndexChanged()),
    422422            this, SLOT(reformatHeaders()));
    423423    connect(firstFridayCheckBox, SIGNAL(toggled(bool)),
Note: See TracChangeset for help on using the changeset viewer.