Code-formatting, add copyright notice

This commit is contained in:
Adriaan de Groot 2017-10-12 07:08:21 -07:00
parent c10d7470bb
commit 00fa7bff1c

View File

@ -1,6 +1,7 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2017, Adriaan de Groot <groot@kde.org>
*
* Originally from the Manjaro Installation Framework
* by Roland Singer <roland@manjaro.org>
@ -51,15 +52,18 @@ TimeZoneWidget::TimeZoneWidget(QWidget* parent) :
}
void TimeZoneWidget::setCurrentLocation(QString region, QString zone) {
void TimeZoneWidget::setCurrentLocation( QString region, QString zone )
{
QHash<QString, QList<LocaleGlobal::Location> > hash = LocaleGlobal::getLocations();
if ( !hash.contains( region ) )
return;
QList<LocaleGlobal::Location> locations = hash.value( region );
for (int i = 0; i < locations.size(); ++i) {
if (locations.at(i).zone == zone) {
for ( int i = 0; i < locations.size(); ++i )
{
if ( locations.at( i ).zone == zone )
{
setCurrentLocation( locations.at( i ) );
break;
}
@ -67,18 +71,20 @@ void TimeZoneWidget::setCurrentLocation(QString region, QString zone) {
}
void TimeZoneWidget::setCurrentLocation(LocaleGlobal::Location location) {
void TimeZoneWidget::setCurrentLocation( LocaleGlobal::Location location )
{
currentLocation = location;
// Set zone
QPoint pos = getLocationPosition( currentLocation.longitude, currentLocation.latitude );
for (int i = 0; i < timeZoneImages.size(); ++i) {
for ( int i = 0; i < timeZoneImages.size(); ++i )
{
QImage zone = timeZoneImages[i];
// If not transparent set as current
if (zone.pixel(pos) != RGB_TRANSPARENT) {
if ( zone.pixel( pos ) != RGB_TRANSPARENT )
{
currentZoneImage = zone;
break;
}
@ -95,7 +101,8 @@ void TimeZoneWidget::setCurrentLocation(LocaleGlobal::Location location) {
//###
QPoint TimeZoneWidget::getLocationPosition(double longitude, double latitude) {
QPoint TimeZoneWidget::getLocationPosition( double longitude, double latitude )
{
const int width = this->width();
const int height = this->height();
@ -126,8 +133,8 @@ QPoint TimeZoneWidget::getLocationPosition(double longitude, double latitude) {
}
void TimeZoneWidget::paintEvent(QPaintEvent*) {
void TimeZoneWidget::paintEvent( QPaintEvent* )
{
const int width = this->width();
const int height = this->height();
QFontMetrics fontMetrics( font );
@ -172,7 +179,8 @@ void TimeZoneWidget::paintEvent(QPaintEvent*) {
void TimeZoneWidget::mousePressEvent(QMouseEvent* event) {
void TimeZoneWidget::mousePressEvent( QMouseEvent* event )
{
if ( event->button() != Qt::LeftButton )
return;
@ -182,14 +190,17 @@ void TimeZoneWidget::mousePressEvent(QMouseEvent* event) {
QHash<QString, QList<LocaleGlobal::Location> > hash = LocaleGlobal::getLocations();
QHash<QString, QList<LocaleGlobal::Location> >::iterator iter = hash.begin();
while (iter != hash.end()) {
while ( iter != hash.end() )
{
QList<LocaleGlobal::Location> locations = iter.value();
for (int i = 0; i < locations.size(); ++i) {
for ( int i = 0; i < locations.size(); ++i )
{
LocaleGlobal::Location loc = locations[i];
QPoint locPos = getLocationPosition( loc.longitude, loc.latitude );
if ((abs(mX - locPos.x()) + abs(mY - locPos.y()) < abs(mX - nX) + abs(mY - nY))) {
if ( ( abs( mX - locPos.x() ) + abs( mY - locPos.y() ) < abs( mX - nX ) + abs( mY - nY ) ) )
{
currentLocation = loc;
nX = locPos.x();
nY = locPos.y();