Skip to content

Commit 62c86f0

Browse files
committedMar 29, 2016
Highlight today's date in date time calendar popup
1 parent 692a17e commit 62c86f0

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed
 

‎src/gui/editorwidgets/qgsdatetimeeditwrapper.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,16 @@
1313
* *
1414
***************************************************************************/
1515

16-
17-
#include <QDateTimeEdit>
18-
#include <QDateEdit>
19-
#include <QTimeEdit>
20-
21-
2216
#include "qgsdatetimeeditwrapper.h"
2317
#include "qgsdatetimeeditfactory.h"
2418
#include "qgsmessagelog.h"
2519
#include "qgslogger.h"
2620

21+
#include <QDateTimeEdit>
22+
#include <QDateEdit>
23+
#include <QTimeEdit>
24+
#include <QTextCharFormat>
25+
#include <QCalendarWidget>

Comment on line R25

m-kuhn commented on Mar 30, 2016

@m-kuhn
Member

Just wondering, why did you move these down?

nyalldawson replied on Mar 30, 2016

@nyalldawson
CollaboratorAuthor

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!

Code has comments. Press enter to view.
2726

2827
QgsDateTimeEditWrapper::QgsDateTimeEditWrapper( QgsVectorLayer* vl, int fieldIdx, QWidget* editor, QWidget* parent )
2928
: QgsEditorWidgetWrapper( vl, fieldIdx, editor, parent )
@@ -67,6 +66,13 @@ void QgsDateTimeEditWrapper::initWidget( QWidget *editor )
6766

6867
const bool calendar = config( "calendar_popup", false ).toBool();
6968
mQDateTimeEdit->setCalendarPopup( calendar );
69+
if ( calendar )
70+
{
71+
// highlight today's date
72+
QTextCharFormat todayFormat;
73+
todayFormat.setBackground( QColor( 160, 180, 200 ) );
74+
mQDateTimeEdit->calendarWidget()->setDateTextFormat( QDate::currentDate(), todayFormat );
75+
}
7076

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

0 commit comments

Comments
 (0)
Please sign in to comment.