summaryrefslogtreecommitdiffstats
path: root/src/widget
diff options
context:
space:
mode:
authorRJ Ryan <rryan@mixxx.org>2014-11-18 00:11:37 -0500
committerRJ Ryan <rryan@mixxx.org>2014-11-18 01:29:09 -0500
commita74c65d6469a2f1ce0d1927ffbd73be90bf754c5 (patch)
tree4381e657348dd5bba44d2e2b40c0635ed39b7f3c /src/widget
parentc21f0c6559e5c19ed7a9acd301e2100823a43e00 (diff)
Code fascism.
* Fix compiler warnings in non-3rd-party code. * Add some missing const-references. * Eliminate cases of "if(" "( ... )" and "for(".
Diffstat (limited to 'src/widget')
-rw-r--r--src/widget/controlwidgetconnection.cpp2
-rw-r--r--src/widget/wdisplay.cpp6
-rw-r--r--src/widget/wimagestore.cpp22
-rw-r--r--src/widget/wimagestore.h6
-rw-r--r--src/widget/wlabel.cpp2
-rw-r--r--src/widget/woverview.cpp8
-rw-r--r--src/widget/woverviewhsv.cpp9
-rw-r--r--src/widget/woverviewlmh.cpp2
-rw-r--r--src/widget/woverviewrgb.cpp2
-rw-r--r--src/widget/wpixmapstore.cpp10
-rw-r--r--src/widget/wpixmapstore.h2
-rw-r--r--src/widget/wsizeawarestack.cpp2
-rw-r--r--src/widget/wstarrating.cpp20
-rw-r--r--src/widget/wstatuslight.cpp2
-rw-r--r--src/widget/wtracktableview.cpp12
-rw-r--r--src/widget/wwaveformviewer.h4
16 files changed, 55 insertions, 56 deletions
diff --git a/src/widget/controlwidgetconnection.cpp b/src/widget/controlwidgetconnection.cpp
index 26e4057607..b6a07d3359 100644
--- a/src/widget/controlwidgetconnection.cpp
+++ b/src/widget/controlwidgetconnection.cpp
@@ -125,7 +125,7 @@ void ControlWidgetPropertyConnection::slotControlValueChanged(double v) {
QVariant parameter;
QWidget* pWidget = m_pWidget->toQWidget();
QVariant property = pWidget->property(m_propertyName.constData());
- if (property.type() == QMetaType::Bool) {
+ if (property.type() == QVariant::Bool) {
parameter = getControlParameterForValue(v) > 0;
} else {
parameter = getControlParameterForValue(v);
diff --git a/src/widget/wdisplay.cpp b/src/widget/wdisplay.cpp
index 21e6f97239..81eaddc969 100644
--- a/src/widget/wdisplay.cpp
+++ b/src/widget/wdisplay.cpp
@@ -100,9 +100,9 @@ void WDisplay::setPixmap(QVector<PaintablePointer>* pPixmaps, int iPos,
if (iPos < 0 || iPos >= pPixmaps->size()) {
return;
}
-
+
PixmapSource source(filename);
- PaintablePointer pPixmap = WPixmapStore::getPaintable( source,
+ PaintablePointer pPixmap = WPixmapStore::getPaintable(source,
Paintable::TILE);
if (pPixmap.isNull() || pPixmap->isNull()) {
@@ -163,7 +163,7 @@ void WDisplay::onConnectedControlChanged(double dParameter, double dValue) {
}
}
-void WDisplay::paintEvent(QPaintEvent* ) {
+void WDisplay::paintEvent(QPaintEvent*) {
QStyleOption option;
option.initFrom(this);
QStylePainter p(this);
diff --git a/src/widget/wimagestore.cpp b/src/widget/wimagestore.cpp
index 2273aa4378..aea67137a9 100644
--- a/src/widget/wimagestore.cpp
+++ b/src/widget/wimagestore.cpp
@@ -9,17 +9,17 @@ QHash<QString, WImageStore::ImageInfoType*> WImageStore::m_dictionary;
QSharedPointer<ImgSource> WImageStore::m_loader = QSharedPointer<ImgSource>();
// static
-QImage * WImageStore::getImageNoCache(const QString& fileName) {
+QImage* WImageStore::getImageNoCache(const QString& fileName) {
return getImageNoCache(PixmapSource(fileName));
}
// static
-QImage * WImageStore::getImage(const QString &fileName) {
+QImage* WImageStore::getImage(const QString& fileName) {
return getImage(PixmapSource(fileName));
}
// static
-QImage * WImageStore::getImage(const PixmapSource source) {
+QImage* WImageStore::getImage(const PixmapSource& source) {
// Search for Image in list
ImageInfoType* info = NULL;
@@ -56,20 +56,20 @@ QImage * WImageStore::getImage(const PixmapSource source) {
/**/
// static
-QImage * WImageStore::getImageNoCache(const PixmapSource source) {
+QImage* WImageStore::getImageNoCache(const PixmapSource& source) {
QImage* pImage;
if (source.isSVG()) {
- QScopedPointer<QSvgRenderer> pSvgRenderer(new QSvgRenderer());
- if( source.getData().isEmpty() ){
- pSvgRenderer->load(source.getPath());
+ QSvgRenderer renderer;
+ if (source.getData().isEmpty()) {
+ renderer.load(source.getPath());
} else {
- pSvgRenderer->load(source.getData());
+ renderer.load(source.getData());
}
-
- pImage = new QImage(pSvgRenderer->defaultSize(), QImage::Format_ARGB32);
+
+ pImage = new QImage(renderer.defaultSize(), QImage::Format_ARGB32);
pImage->fill(0x00000000); // Transparent black.
QPainter painter(pImage);
- pSvgRenderer->render(&painter);
+ renderer.render(&painter);
} else {
if (m_loader) {
pImage = m_loader->getImage(source.getPath());
diff --git a/src/widget/wimagestore.h b/src/widget/wimagestore.h
index 376579a2b9..4e79c5487b 100644
--- a/src/widget/wimagestore.h
+++ b/src/widget/wimagestore.h
@@ -8,14 +8,14 @@
#include "skin/imgsource.h"
#include "skin/pixmapsource.h"
-class QImage;
+class QImage;
class WImageStore {
public:
static QImage* getImage(const QString &fileName);
static QImage* getImageNoCache(const QString &fileName);
- static QImage* getImage(const PixmapSource source);
- static QImage* getImageNoCache(const PixmapSource source);
+ static QImage* getImage(const PixmapSource& source);
+ static QImage* getImageNoCache(const PixmapSource& source);
static void deleteImage(QImage* p);
static void setLoader(QSharedPointer<ImgSource> ld);
// For external owned images like software generated ones.
diff --git a/src/widget/wlabel.cpp b/src/widget/wlabel.cpp
index 838a749cd8..9dc755457c 100644
--- a/src/widget/wlabel.cpp
+++ b/src/widget/wlabel.cpp
@@ -50,7 +50,7 @@ void WLabel::setup(QDomNode node, const SkinContext& context) {
// Font size
if (context.hasNode(node, "FontSize")) {
int fontsize = context.selectString(node, "FontSize").toInt();
- setFont( QFont("Helvetica",fontsize,QFont::Normal) );
+ setFont(QFont("Helvetica", fontsize, QFont::Normal));
}
// Alignment
diff --git a/src/widget/woverview.cpp b/src/widget/woverview.cpp
index 19b3e74828..64b651c901 100644
--- a/src/widget/woverview.cpp
+++ b/src/widget/woverview.cpp
@@ -312,7 +312,7 @@ void WOverview::paintEvent(QPaintEvent *) {
diffGain = 255.0 - 255.0 / visualGain;
}
- if (m_diffGain != diffGain || m_waveformImageScaled.isNull() ) {
+ if (m_diffGain != diffGain || m_waveformImageScaled.isNull()) {
QRect sourceRect(0, diffGain, m_pWaveformSourceImage->width(),
m_pWaveformSourceImage->height() - 2 * diffGain);
m_waveformImageScaled = m_pWaveformSourceImage->copy(
@@ -350,7 +350,7 @@ void WOverview::paintEvent(QPaintEvent *) {
const float gain = (float)(width()-2) / trackSamples;
// Draw range (loop)
- for( unsigned int i = 0; i < m_markRanges.size(); i++) {
+ for (unsigned int i = 0; i < m_markRanges.size(); ++i) {
WaveformMarkRange& currentMarkRange = m_markRanges[i];
// If the mark range is not active we should not draw it.
@@ -397,7 +397,7 @@ void WOverview::paintEvent(QPaintEvent *) {
painter.setOpacity(0.9);
- for( int i = 0; i < m_marks.size(); i++) {
+ for (int i = 0; i < m_marks.size(); ++i) {
WaveformMark& currentMark = m_marks[i];
if (currentMark.m_pointControl && currentMark.m_pointControl->get() >= 0.0) {
//const float markPosition = 1.0 +
@@ -415,7 +415,7 @@ void WOverview::paintEvent(QPaintEvent *) {
QPointF textPoint;
textPoint.setX(markPosition+0.5f);
- if( currentMark.m_align == Qt::AlignTop) {
+ if (currentMark.m_align == Qt::AlignTop) {
QFontMetricsF metric(markerFont);
textPoint.setY(metric.tightBoundingRect(currentMark.m_text).height()+0.5f);
} else {
diff --git a/src/widget/woverviewhsv.cpp b/src/widget/woverviewhsv.cpp
index 218bbcb9ff..68df3512a8 100644
--- a/src/widget/woverviewhsv.cpp
+++ b/src/widget/woverviewhsv.cpp
@@ -24,7 +24,7 @@ bool WOverviewHSV::drawNextPixmapPart() {
}
const int dataSize = m_pWaveform->getDataSize();
- if (dataSize == 0 ) {
+ if (dataSize == 0) {
return false;
}
@@ -93,15 +93,14 @@ bool WOverviewHSV::drawNextPixmapPart() {
maxHigh[0] + maxHigh[1]) * 1.2;
// Prevent division by zero
- if( total > 0 )
- {
+ if (total > 0) {
// Normalize low and high
// (mid not need, because it not change the color)
lo = (maxLow[0] + maxLow[1]) / total;
hi = (maxHigh[0] + maxHigh[1]) / total;
- }
- else
+ } else {
lo = hi = 0.0;
+ }
// Set color
color.setHsvF(h, 1.0-hi, 1.0-lo);
diff --git a/src/widget/woverviewlmh.cpp b/src/widget/woverviewlmh.cpp
index 61632fa90b..113944bf0c 100644
--- a/src/widget/woverviewlmh.cpp
+++ b/src/widget/woverviewlmh.cpp
@@ -26,7 +26,7 @@ bool WOverviewLMH::drawNextPixmapPart() {
}
const int dataSize = m_pWaveform->getDataSize();
- if (dataSize == 0 ) {
+ if (dataSize == 0) {
return false;
}
diff --git a/src/widget/woverviewrgb.cpp b/src/widget/woverviewrgb.cpp
index b70a8249a9..4c95f5d1d2 100644
--- a/src/widget/woverviewrgb.cpp
+++ b/src/widget/woverviewrgb.cpp
@@ -23,7 +23,7 @@ bool WOverviewRGB::drawNextPixmapPart() {
}
const int dataSize = m_pWaveform->getDataSize();
- if (dataSize == 0 ) {
+ if (dataSize == 0) {
return false;
}
diff --git a/src/widget/wpixmapstore.cpp b/src/widget/wpixmapstore.cpp
index 006390e780..ecd1f89fae 100644
--- a/src/widget/wpixmapstore.cpp
+++ b/src/widget/wpixmapstore.cpp
@@ -68,16 +68,16 @@ Paintable::Paintable(const QString& fileName, DrawMode mode)
}
}
-Paintable::Paintable(PixmapSource source, DrawMode mode)
+Paintable::Paintable(const PixmapSource& source, DrawMode mode)
: m_draw_mode(mode) {
if (source.isSVG()) {
QScopedPointer<QSvgRenderer> pSvgRenderer(new QSvgRenderer());
- if( source.getData().isEmpty() ){
+ if (source.getData().isEmpty()) {
pSvgRenderer->load(source.getPath());
} else {
pSvgRenderer->load(source.getData());
}
-
+
if (mode == STRETCH) {
m_pSvg.reset(pSvgRenderer.take());
} else if (mode == TILE) {
@@ -94,7 +94,7 @@ Paintable::Paintable(PixmapSource source, DrawMode mode)
}
} else {
QPixmap * pPixmap = new QPixmap();
- if (!source.getData().isEmpty()){
+ if (!source.getData().isEmpty()) {
pPixmap->loadFromData(source.getData());
} else {
pPixmap->load(source.getPath());
@@ -241,7 +241,7 @@ PaintablePointer WPixmapStore::getPaintable(PixmapSource source,
}
return PaintablePointer();
}
-
+
m_paintableCache[source.getId()] = pPaintable;
return pPaintable;
}
diff --git a/src/widget/wpixmapstore.h b/src/widget/wpixmapstore.h
index d445284273..cc3fedbde0 100644
--- a/src/widget/wpixmapstore.h
+++ b/src/widget/wpixmapstore.h
@@ -44,7 +44,7 @@ class Paintable {
// Takes ownership of QImage.
Paintable(QImage* pImage, DrawMode mode);
Paintable(const QString& fileName, DrawMode mode);
- Paintable(PixmapSource source, DrawMode mode);
+ Paintable(const PixmapSource& source, DrawMode mode);
QSize size() const;
int width() const;
diff --git a/src/widget/wsizeawarestack.cpp b/src/widget/wsizeawarestack.cpp
index 59d1647831..9177d6cb5c 100644
--- a/src/widget/wsizeawarestack.cpp
+++ b/src/widget/wsizeawarestack.cpp
@@ -28,7 +28,7 @@ class SizeAwareLayout : public QStackedLayout
QWidget *wc = widget(i);
bool notFit = false;
- if (i > 0 ) {
+ if (i > 0) {
// Check minimum, but not for the smallest, it is the fallback
notFit = wc->minimumHeight() > s.height() || wc->minimumWidth() > s.width();
}
diff --git a/src/widget/wstarrating.cpp b/src/widget/wstarrating.cpp
index 58d1c6beb7..f40bdb75cf 100644
--- a/src/widget/wstarrating.cpp
+++ b/src/widget/wstarrating.cpp
@@ -26,14 +26,14 @@ QSize WStarRating::sizeHint() const {
QSize widgetSize = style()->sizeFromContents(QStyle::CT_PushButton, &option,
m_starRating.sizeHint(), this);
widgetSize.expandedTo(QApplication::globalStrut());
-
+
m_contentRect.setRect(
- (widgetSize.width() - m_starRating.sizeHint().width() ) / 2,
- (widgetSize.height() - m_starRating.sizeHint().height() ) / 2,
+ (widgetSize.width() - m_starRating.sizeHint().width()) / 2,
+ (widgetSize.height() - m_starRating.sizeHint().height()) / 2,
m_starRating.sizeHint().width(),
m_starRating.sizeHint().height()
);
-
+
return widgetSize;
}
@@ -72,10 +72,10 @@ void WStarRating::paintEvent(QPaintEvent *) {
QStyleOption option;
option.initFrom(this);
QStylePainter painter(this);
-
+
painter.setBrush(option.palette.text());
painter.drawPrimitive(QStyle::PE_Widget, option);
-
+
m_starRating.paint(&painter, m_contentRect, option.palette,
StarRating::ReadOnly,
option.state & QStyle::State_Selected);
@@ -106,17 +106,17 @@ int WStarRating::starAtPosition(int x) {
return 0;
}
int star = (x / (m_starRating.sizeHint().width() / m_starRating.maxStarCount())) + 1;
-
- if (star <= 0 || star > m_starRating.maxStarCount()){
+
+ if (star <= 0 || star > m_starRating.maxStarCount()) {
return 0;
}
-
+
return star;
}
void WStarRating::mouseReleaseEvent(QMouseEvent*) {
if (!m_pCurrentTrack)
return;
-
+
m_pCurrentTrack->setRating(m_starRating.starCount());
}
diff --git a/src/widget/wstatuslight.cpp b/src/widget/wstatuslight.cpp
index f33553c908..773ea43d65 100644
--- a/src/widget/wstatuslight.cpp
+++ b/src/widget/wstatuslight.cpp
@@ -48,7 +48,7 @@ void WStatusLight::setNoPos(int iNoPos) {
}
WStatusLight::SizeMode WStatusLight::SizeModeFromString(QString str) {
- if (str.toUpper() == "FIXED" ) {
+ if (str.toUpper() == "FIXED") {
return FIXED;
} else if (str.toUpper() == "RESIZE") {
return RESIZE;
diff --git a/src/widget/wtracktableview.cpp b/src/widget/wtracktableview.cpp
index c925a4d7e7..28263f232c 100644
--- a/src/widget/wtracktableview.cpp
+++ b/src/widget/wtracktableview.cpp
@@ -740,7 +740,7 @@ void WTrackTableView::contextMenuEvent(QContextMenuEvent* event) {
}
}
m_pPlaylistMenu->addSeparator();
- QAction *newPlaylistAction = new QAction( tr("Create New Playlist"), m_pPlaylistMenu);
+ QAction* newPlaylistAction = new QAction(tr("Create New Playlist"), m_pPlaylistMenu);
m_pPlaylistMenu->addAction(newPlaylistAction);
m_playlistMapper.setMapping(newPlaylistAction, -1);// -1 to signify new playlist
connect(newPlaylistAction, SIGNAL(triggered()), &m_playlistMapper, SLOT(map()));
@@ -770,7 +770,7 @@ void WTrackTableView::contextMenuEvent(QContextMenuEvent* event) {
connect(pAction, SIGNAL(triggered()), &m_crateMapper, SLOT(map()));
}
m_pCrateMenu->addSeparator();
- QAction *newCrateAction = new QAction( tr("Create New Crate"), m_pCrateMenu);
+ QAction* newCrateAction = new QAction(tr("Create New Crate"), m_pCrateMenu);
m_pCrateMenu->addAction(newCrateAction);
m_crateMapper.setMapping(newCrateAction, -1);// -1 to signify new playlist
connect(newCrateAction, SIGNAL(triggered()), &m_crateMapper, SLOT(map()));
@@ -795,7 +795,7 @@ void WTrackTableView::contextMenuEvent(QContextMenuEvent* event) {
}
int column = trackModel->fieldIndex("bpm_lock");
QModelIndex index = indices.at(0).sibling(indices.at(0).row(),column);
- if (index.data().toBool()){ //BPM is locked
+ if (index.data().toBool()) { //BPM is locked
m_pBpmUnlockAction->setEnabled(true);
m_pBpmLockAction->setEnabled(false);
m_pBpmDoubleAction->setEnabled(false);
@@ -1350,7 +1350,7 @@ void WTrackTableView::addSelectionToPlaylist(int iPlaylistId) {
trackIds.append(iTrackId);
}
}
- if (iPlaylistId==-1){//i.e. a new playlist is suppose to be created
+ if (iPlaylistId == -1) { // i.e. a new playlist is suppose to be created
QString name;
bool validNameGiven = false;
@@ -1412,7 +1412,7 @@ void WTrackTableView::addSelectionToCrate(int iCrateId) {
trackIds.append(iTrackId);
}
}
- if (iCrateId == -1){//i.e. a new crate is suppose to be created
+ if (iCrateId == -1) { // i.e. a new crate is suppose to be created
QString name;
bool validNameGiven = false;
do {
@@ -1526,7 +1526,7 @@ void WTrackTableView::slotUnlockBpm() {
lockBpm(false);
}
-void WTrackTableView::slotScaleBpm(int scale){
+void WTrackTableView::slotScaleBpm(int scale) {
TrackModel* trackModel = getTrackModel();
if (trackModel == NULL) {
return;
diff --git a/src/widget/wwaveformviewer.h b/src/widget/wwaveformviewer.h
index d3f7de0e36..19f4ad042d 100644
--- a/src/widget/wwaveformviewer.h
+++ b/src/widget/wwaveformviewer.h
@@ -36,8 +36,8 @@ signals:
void trackDropped(QString filename, QString group);
public slots:
- void onTrackLoaded( TrackPointer track);
- void onTrackUnloaded( TrackPointer track);
+ void onTrackLoaded(TrackPointer track);
+ void onTrackUnloaded(TrackPointer track);
protected:
virtual void resizeEvent(QResizeEvent *event);