Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Highlight today's date in date time calendar popup
  • Loading branch information
nyalldawson committed Mar 29, 2016
1 parent 692a17e commit 62c86f0
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/gui/editorwidgets/qgsdatetimeeditwrapper.cpp
Expand Up @@ -13,17 +13,16 @@
* *
***************************************************************************/


#include <QDateTimeEdit>
#include <QDateEdit>
#include <QTimeEdit>


#include "qgsdatetimeeditwrapper.h"
#include "qgsdatetimeeditfactory.h"
#include "qgsmessagelog.h"
#include "qgslogger.h"

#include <QDateTimeEdit>
#include <QDateEdit>
#include <QTimeEdit>
#include <QTextCharFormat>
#include <QCalendarWidget>

This comment has been minimized.

Copy link
@m-kuhn

m-kuhn Mar 30, 2016

Member

Just wondering, why did you move these down?

This comment has been minimized.

Copy link
@nyalldawson

nyalldawson Mar 30, 2016

Author Collaborator

No particular reason... I just think it's good practice to put the system includes at the end. I had to add some new ones so I took the opportunity to move stuff!


QgsDateTimeEditWrapper::QgsDateTimeEditWrapper( QgsVectorLayer* vl, int fieldIdx, QWidget* editor, QWidget* parent )
: QgsEditorWidgetWrapper( vl, fieldIdx, editor, parent )
Expand Down Expand Up @@ -67,6 +66,13 @@ void QgsDateTimeEditWrapper::initWidget( QWidget *editor )

const bool calendar = config( "calendar_popup", false ).toBool();
mQDateTimeEdit->setCalendarPopup( calendar );
if ( calendar )
{
// highlight today's date
QTextCharFormat todayFormat;
todayFormat.setBackground( QColor( 160, 180, 200 ) );
mQDateTimeEdit->calendarWidget()->setDateTextFormat( QDate::currentDate(), todayFormat );
}

const bool allowNull = config( "allow_null", true ).toBool();
if ( mQgsDateTimeEdit )
Expand Down

0 comments on commit 62c86f0

Please sign in to comment.