@@ -113,10 +113,7 @@ void BandmapWidget::update()
113113 bandmapScene->clear ();
114114
115115 // do not show bandmap for submm bands
116- if ( rx_freq > 250000.0 || currentBand.start >= 300000.0 )
117- {
118- return ;
119- }
116+ if ( rx_freq > 250000.0 || currentBand.start >= 300000.0 ) return ;
120117
121118 /* ******************
122119 * Determine Scale *
@@ -126,34 +123,37 @@ void BandmapWidget::update()
126123
127124 determineStepDigits (step, digits);
128125
129- int steps = static_cast <int >(round ((currentBand.end - currentBand.start ) / step));
126+ const int steps = static_cast <int >(round ((currentBand.end - currentBand.start ) / step));
130127
131128 minHeight = steps * PIXELSPERSTEP + 30 ;
132129 ui->graphicsView ->setFixedSize (270 , minHeight);
133130
134131 /* ***************/
135132 /* Draw bandmap */
136133 /* ***************/
134+ const QPen gridPen (QColor (192 , 192 , 192 ));
135+ const QBrush highlightBrush (QColor (102 , 153 , 255 , 100 ));
136+
137137 for ( int i = 0 ; i <= steps; i++ )
138138 {
139139 double plottedFreq = currentBand.start + step * i;
140+ const double y = i * PIXELSPERSTEP;
141+
140142 // Add colored square
141143 if ( !currBandMode.isEmpty ()
142144 && i < steps
143145 && currBandMode == BandPlan::freq2BandModeGroupString (plottedFreq) )
144- bandmapScene->addRect (0 , i * PIXELSPERSTEP , 10 , 10 , QPen (Qt::NoPen), QBrush ( QColor ( 102 , 153 , 255 , 100 )) );
146+ bandmapScene->addRect (0 , y , 10 , 10 , QPen (Qt::NoPen), highlightBrush );
145147
146- bandmapScene->addLine (0 ,
147- i * PIXELSPERSTEP,
148- (i % 5 == 0 ) ? 15 : 10 ,
149- i * PIXELSPERSTEP,
150- QPen (QColor (192 ,192 ,192 )));
148+ const int lineLength = (i % 5 == 0 ) ? 15 : 10 ;
151149
152- if (i % 5 == 0 )
150+ bandmapScene->addLine (0 , y, lineLength, y, gridPen);
151+
152+ if ( i % 5 == 0 )
153153 {
154154 QGraphicsTextItem* text = bandmapScene->addText (QString::number (plottedFreq, ' f' , digits));
155- text-> setPos (- ( text->boundingRect (). width ()) - 5 ,
156- i * PIXELSPERSTEP - (text-> boundingRect () .height () / 2 ));
155+ const QRectF rect = text->boundingRect ();
156+ text-> setPos (-rect. width () - 5 , y - (rect .height () / 2 ));
157157 }
158158 }
159159
@@ -208,10 +208,6 @@ void BandmapWidget::updateStations()
208208{
209209 FCT_IDENTIFICATION;
210210
211- double step;
212- int digits;
213- double min_y = 0 ;
214-
215211 /* ***************
216212 * Restart Time *
217213 ****************/
@@ -222,10 +218,14 @@ void BandmapWidget::updateStations()
222218 spotAging ();
223219
224220 // do not show bandmap for submm bands
225- if ( rx_freq > 250000.0 || currentBand.start >= 300000.0 )
226- {
227- return ;
228- }
221+ if ( rx_freq > 250000.0 || currentBand.start >= 300000.0 )return ;
222+
223+ double step;
224+ int digits;
225+ double min_y = 0 ;
226+ const QColor lineColor (192 ,192 ,192 );
227+ const QColor defaultTextColor = qApp->palette ().color (QPalette::Text);
228+ const QString timeFormat = locale.formatTimeShort ();
229229
230230 determineStepDigits (step, digits);
231231
@@ -234,51 +234,52 @@ void BandmapWidget::updateStations()
234234
235235 while ( lower != upper )
236236 {
237+ DxSpot &spot = lower.value ();
238+
237239 double freq_y = ((lower.key () - currentBand.start ) / step) * PIXELSPERSTEP;
238- double text_y = std::max (min_y + 5 , freq_y);
240+ double text_y = std::max (min_y + 5.0 , freq_y);
239241
240242 /* ************************
241243 * Draw Line to Callsign *
242244 *************************/
243- lineItemList.append (bandmapScene->addLine (17 ,
244- freq_y,
245- 40 ,
246- text_y,
247- QPen (QColor (192 ,192 ,192 ))));
245+ lineItemList.append (bandmapScene->addLine (17 , freq_y, 40 , text_y, QPen (lineColor)));
248246
249- const QString &callsignTmp = lower. value () .callsign ;
250- const QString &timeTmp = locale.toString (lower. value (). dateTime , locale. formatTimeShort () );
247+ const QString &callsignTmp = spot .callsign ;
248+ const QString &timeTmp = locale.toString (spot. dateTime , timeFormat );
251249
252250 QGraphicsTextItem* text = bandmapScene->addText (callsignTmp + " @ " + timeTmp);
253251 text->document ()->setDocumentMargin (0 );
254- text->setPos (40 , text_y - (text->boundingRect ().height () / 2 ));
252+
253+ qreal halfHeight = text->boundingRect ().height () / 2 ;
254+ text->setPos (40 , text_y - halfHeight);
255255 text->setFlags (QGraphicsItem::ItemIsFocusable |
256256 QGraphicsItem::ItemIsSelectable |
257257 text->flags ());
258258 text->setProperty (" freq" , lower.key ());
259- text->setProperty (" bandmode" , static_cast <int >(lower.value ().bandPlanMode ));
259+ text->setProperty (" bandmode" , static_cast <int >(spot.bandPlanMode ));
260+
260261 QString unit;
261262 unsigned char decP;
262263 double spotFreq = Data::MHz2UserFriendlyFreq (lower.key (), unit, decP);
263264 text->setToolTip (QString (" <b>%1</b> de %2<br/>%3 %4; %5<br/>%6" ).arg (callsignTmp,
264- lower. value () .spotter ,
265+ spot .spotter ,
265266 QString::number (spotFreq, ' f' , decP),
266267 unit,
267- lower. value () .modeGroupString ,
268- lower. value () .comment ));
268+ spot .modeGroupString ,
269+ spot .comment ));
269270
270- min_y = text_y + text-> boundingRect (). height () / 2 ;
271+ min_y = text_y + halfHeight ;
271272
272- text->setDefaultTextColor (Data::statusToColor (lower. value () .status ,
273- lower. value () .dupeCount ,
274- qApp-> palette (). color (QPalette::Text) ));
273+ text->setDefaultTextColor (Data::statusToColor (spot .status ,
274+ spot .dupeCount ,
275+ defaultTextColor ));
275276
276277 textItemList.append (text);
277278 ++lower;
278279 }
279280
280281 // Resize scene and view dynamically
281- QRectF itemsRect = bandmapScene->itemsBoundingRect ();
282+ const QRectF & itemsRect = bandmapScene->itemsBoundingRect ();
282283 QRectF sceneRect = bandmapScene->sceneRect ();
283284
284285 double resultHeight = qMax (itemsRect.bottom (), minHeight);
0 commit comments