Skip to content

Commit

Permalink
Merge branch 'clean-warnings'
Browse files Browse the repository at this point in the history
This branch cleans up around 300 warnings.
The warnings are deprecated Qt usage warnings
and some gcc warnings.

ALL warnings are gone - perfectly clean build now.
  • Loading branch information
keithvetter committed Aug 15, 2024
2 parents c722ea5 + 5469bff commit daef7a1
Show file tree
Hide file tree
Showing 40 changed files with 184 additions and 137 deletions.
18 changes: 9 additions & 9 deletions koviz/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,12 +454,12 @@ int main(int argc, char *argv[])
exit(-1);
}

QStringList items = opts.videoList.split(',',QString::SkipEmptyParts);
QStringList items = opts.videoList.split(',',Qt::SkipEmptyParts);
foreach ( QString item, items ) {
if ( item.contains(':') ) {
QString f = item.split(':',
QString::SkipEmptyParts).at(0).trimmed();
QString s = item.split(':',QString::SkipEmptyParts).at(1);
Qt::SkipEmptyParts).at(0).trimmed();
QString s = item.split(':',Qt::SkipEmptyParts).at(1);
bool ok;
double o = s.toDouble(&ok);
if ( !ok ) {
Expand Down Expand Up @@ -1039,7 +1039,7 @@ int main(int argc, char *argv[])
// Unit overrides list
QStringList unitOverridesList;
foreach ( QString unitOverride, opts.unitOverrides.
split(',',QString::SkipEmptyParts) ) {
split(',',Qt::SkipEmptyParts) ) {
unitOverridesList << unitOverride.trimmed();
}

Expand Down Expand Up @@ -1342,7 +1342,7 @@ int main(int argc, char *argv[])
//
// Handle -vars commandline option
//
QStringList vars = opts.vars.split(",", QString::SkipEmptyParts);
QStringList vars = opts.vars.split(",", Qt::SkipEmptyParts);
foreach (QString var, vars ) {
QString v = var;
if ( v.at(0) == '@' ) {
Expand Down Expand Up @@ -1975,7 +1975,7 @@ bool convert2trk(const QString& csvFileName, const QString& trkFileName)
}
foreach ( QString s, list ) {
TrickParameter p;
QStringList plist = s.split(" ", QString::SkipEmptyParts);
QStringList plist = s.split(" ", Qt::SkipEmptyParts);
p.setName(plist.at(0));
if ( plist.size() > 1 ) {
QString unitString = plist.at(1);
Expand Down Expand Up @@ -2074,7 +2074,7 @@ QHash<QString,QVariant> getShiftHash(const QString& shiftString,

if (shiftString.isEmpty() || runPaths.isEmpty() ) return shifts; //empty map

QStringList shiftStrings = shiftString.split(',',QString::SkipEmptyParts);
QStringList shiftStrings = shiftString.split(',',Qt::SkipEmptyParts);
foreach ( QString s, shiftStrings ) {

s = s.trimmed();
Expand Down Expand Up @@ -2168,7 +2168,7 @@ QHash<QString,QStringList> getVarMap(const QString& mapString)

if (mapString.isEmpty() ) return varMap; // empty map

QStringList maps = mapString.split(',',QString::SkipEmptyParts);
QStringList maps = mapString.split(',',Qt::SkipEmptyParts);
foreach ( QString s, maps ) {
s = s.trimmed();
if ( s.contains('=') ) {
Expand Down Expand Up @@ -2240,7 +2240,7 @@ QHash<QString,QStringList> getVarMapFromFile(const QString& mapFileName)
QStringList getTimeNames(const QString& timeName)
{
QStringList timeNames;
QStringList names = timeName.split('=',QString::SkipEmptyParts);
QStringList names = timeName.split('=',Qt::SkipEmptyParts);
foreach ( QString s, names ) {
timeNames << s.trimmed();
}
Expand Down
4 changes: 2 additions & 2 deletions libkoviz/bookmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2262,7 +2262,7 @@ bool PlotBookModel::isMatch(const QString &str, const QString &exp) const
#if QT_VERSION >= 0x050000
bool isRange = false;
if ( str.contains("RUN_") && exp.contains(',') ) {
QStringList els = exp.split(',',QString::SkipEmptyParts);
QStringList els = exp.split(',',Qt::SkipEmptyParts);
if ( els.size() == 2 ) {
QString el0 = els.at(0).trimmed();
QString el1 = els.at(1).trimmed();
Expand Down Expand Up @@ -3237,7 +3237,7 @@ QList<double> PlotBookModel::_calcTicSet(double aIn, double bIn,
while ( X.size() > 7 ) {
double x = X.at(0);
QString s;
s = s.sprintf("%g",x);
s = s.asprintf("%g",x);
if ( s.contains('e') ) {
int n = s.indexOf('e');
s = s.left(n);
Expand Down
6 changes: 3 additions & 3 deletions libkoviz/bookview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@ void BookView::savePdf(const QString &fname)
printer.setCreator("Koviz");
printer.setDocName(fname);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setPageSize(QPrinter::Letter);
printer.setPageSize(QPageSize(QPageSize::Letter));
printer.setOutputFileName(fname);
QString orient = _bookModel()->getDataString(QModelIndex(),"Orientation");
if ( orient == "landscape" ) {
printer.setOrientation(QPrinter::Landscape);
printer.setPageOrientation(QPageLayout::Landscape);
} else if ( orient == "portrait" ) {
printer.setOrientation(QPrinter::Portrait);
printer.setPageOrientation(QPageLayout::Portrait);
} else {
fprintf(stderr, "koviz [bad scoobs]: savePdf! Aborting!\n");
exit(-1);
Expand Down
4 changes: 2 additions & 2 deletions libkoviz/bookview_curves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1128,12 +1128,12 @@ QPixmap* CurvesView::_createLivePixmap()
QString CurvesView::_format(double d)
{
QString s;
s = s.sprintf("%.9g",d);
s = s.asprintf("%.9g",d);
QVariant v(s);
double x = v.toDouble();
double e = qAbs(x-d);
if ( e > 1.0e-9 ) {
s = s.sprintf("%.9lf",d);
s = s.asprintf("%.9lf",d);
}
return s;
}
Expand Down
26 changes: 13 additions & 13 deletions libkoviz/bookview_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ void BookTableView::paintEvent(QPaintEvent *event)
QStringList labels = _columnLabels();

// Calculate column width
int w = fm.width("0123456789");
int w = fm.horizontalAdvance("0123456789");
foreach ( QString label, labels ) {
if ( fm.width(label) > w ) {
w = fm.width(label);
if ( fm.horizontalAdvance(label) > w ) {
w = fm.horizontalAdvance(label);
}
}
w = _mLft + w + _mRgt;
Expand Down Expand Up @@ -146,7 +146,7 @@ void BookTableView::paintEvent(QPaintEvent *event)
QString s;
if ( i == 0 ) {
s = labels.at(q+j);
int l = fm.width(labels.at(q+j));
int l = fm.horizontalAdvance(labels.at(q+j));
painter.drawText(w*j+(w-l),baseline,s);
} else {
if ( j == 0 ) {
Expand All @@ -160,7 +160,7 @@ void BookTableView::paintEvent(QPaintEvent *event)
// s is an empty string since no corresponding time
}
}
int l = fm.width(s);
int l = fm.horizontalAdvance(s);
painter.drawText(w*j+(w-l),baseline,s);
}
}
Expand Down Expand Up @@ -242,7 +242,7 @@ QStringList BookTableView::_format(const QList<double> &vals)
if ( v >= 1.0e-9 && v < 1.0 ) {
QString s = list.at(i);
QString fmt = QString("%.%1lf").arg(qAbs(minExponent));
s = s.sprintf(fmt.toLatin1().constData(),v);
s = s.asprintf(fmt.toLatin1().constData(),v);
list.replace(i,s);
}
}
Expand All @@ -258,7 +258,7 @@ QStringList BookTableView::__format(const QList<double> &vals,

foreach ( double v, vals ) {
QString s;
s = s.sprintf(format.toLatin1().constData(),v);
s = s.asprintf(format.toLatin1().constData(),v);
list << s;
}

Expand Down Expand Up @@ -440,10 +440,10 @@ QModelIndex BookTableView::indexAt(const QPoint &point) const
// Calculate column width (TODO: this is cut-n-paste code from paintEvent)
QFontMetrics fm = fontMetrics();
QStringList labels = _columnLabels();
int w = fm.width("0123456789");
int w = fm.horizontalAdvance("0123456789");
foreach ( QString label, labels ) {
if ( fm.width(label) > w ) {
w = fm.width(label);
if ( fm.horizontalAdvance(label) > w ) {
w = fm.horizontalAdvance(label);
}
}
w = _mLft + w + _mRgt;
Expand Down Expand Up @@ -564,7 +564,7 @@ void BookTableView::keyPressEvent(QKeyEvent *event)

void BookTableView::wheelEvent(QWheelEvent *e)
{
QModelIndex tableVarIdx = indexAt(e->pos());
QModelIndex tableVarIdx = indexAt(e->position().toPoint());

if ( !tableVarIdx.isValid() ) return;

Expand All @@ -580,9 +580,9 @@ void BookTableView::wheelEvent(QWheelEvent *e)
unit = curveModel->y()->unit();
}

if ( e->delta() > 0 ) {
if ( e->angleDelta().y() > 0 ) {
unit = Unit::next(unit);
} else if ( e->delta() < 0 ) {
} else if ( e->angleDelta().y() < 0 ) {
unit = Unit::prev(unit);
}

Expand Down
4 changes: 2 additions & 2 deletions libkoviz/bookview_yaxislabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ void YAxisLabelView::wheelEvent(QWheelEvent *e)

QString fromUnit = _bookModel()->getCurvesYUnit(curvesIdx);
QString toUnit;
if ( e->delta() > 0 ) {
if ( e->angleDelta().y() > 0 ) {
toUnit = Unit::next(fromUnit);
} else if ( e->delta() < 0 ) {
} else if ( e->angleDelta().y() < 0 ) {
toUnit = Unit::prev(fromUnit);
}

Expand Down
6 changes: 3 additions & 3 deletions libkoviz/datamodel_csv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void CsvModel::_init()
in.setCodec("UTF-8");

QString line0 = in.readLine();
QStringList items = line0.split(',',QString::SkipEmptyParts);
QStringList items = line0.split(',',Qt::SkipEmptyParts);
int col = 0;
foreach ( QString item, items ) {
QString name;
Expand Down Expand Up @@ -339,7 +339,7 @@ bool CsvModel::isValid(const QString &csvFile, const QStringList &timeNames)
// Get list of variable names
QStringList names;
QString line0 = in.readLine();
QStringList items = line0.split(',',QString::KeepEmptyParts);
QStringList items = line0.split(',',Qt::KeepEmptyParts);
foreach ( QString item, items ) {
QString name;
if ( item.contains('{') ) {
Expand Down Expand Up @@ -373,7 +373,7 @@ bool CsvModel::isValid(const QString &csvFile, const QStringList &timeNames)

// Sanity check second line to ensure num cols is same as num header cols
QString line1 = in.readLine();
items = line1.split(',',QString::KeepEmptyParts);
items = line1.split(',',Qt::KeepEmptyParts);
if ( items.size() != names.size() ) {
file.close();
return false;
Expand Down
4 changes: 2 additions & 2 deletions libkoviz/datamodel_mot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void MotModel::_init()
_motfile.toLatin1().constData());
exit(-1);
}
QStringList items = line.split('\t',QString::SkipEmptyParts);
QStringList items = line.split('\t',Qt::SkipEmptyParts);
int col = 0;
foreach ( QString item, items ) {
QString name = item.trimmed();
Expand Down Expand Up @@ -321,7 +321,7 @@ bool MotModel::isValid(const QString &motFile)
file.close();
return false;
}
QStringList items = line.split('\t',QString::SkipEmptyParts);
QStringList items = line.split('\t',Qt::SkipEmptyParts);
if ( items.isEmpty() ) {
file.close();
return false;
Expand Down
1 change: 1 addition & 0 deletions libkoviz/datamodel_optitrack_csv.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class OptiTrackCsvModelIterator : public ModelIterator
_model(model),
_xcol(xcol), _ycol(ycol)
{
Q_UNUSED(tcol);
}

virtual ~OptiTrackCsvModelIterator() {}
Expand Down
4 changes: 2 additions & 2 deletions libkoviz/dpfilterproxymodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ DPFilterProxyModel::DPFilterProxyModel(const QString& timeName,
Runs* runs,
SieListModel* sieModel,
QObject *parent) :
QSortFilterProxyModel(parent),
_timeName(timeName),
_runs(runs),
_sieModel(sieModel),
QSortFilterProxyModel(parent)
_sieModel(sieModel)
{
_runsRefreshed();

Expand Down
2 changes: 2 additions & 0 deletions libkoviz/dptreewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ void DPTreeWidget::_setMsgLabel(const QString &msg)
void DPTreeWidget::_tvModelRowAppended(const QModelIndex &parent,
int start, int end)
{
Q_UNUSED(parent);
Q_UNUSED(end);
QModelIndex idx = _tvModel->index(start,0);
QVariant v = _tvModel->data(idx);
QString msg = QString("Time = %1").arg(v.toDouble());
Expand Down
6 changes: 3 additions & 3 deletions libkoviz/filter_sgolay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ float_mat::float_mat(const size_t rows,const size_t cols,const double defval)
(*this)[i].resize(cols, defval);
}
if ((rows < 1) || (cols < 1)) {
char buffer[1024];

sprintf(buffer, "cannot build matrix with %lu rows and %lu columns\n",
char* buffer;
asprintf(&buffer, "cannot build matrix with %lu rows and %lu columns\n",
rows, cols);
sgs_error(buffer);
free(buffer);
}
}

Expand Down
6 changes: 3 additions & 3 deletions libkoviz/frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void Frame::_calc_topjobs()
_topjobs.append(qMakePair(rt,job));
} else {
if ( len == count ) {
qSort(_topjobs.begin(), _topjobs.end(), frameTopJobsGreaterThan);
std::sort(_topjobs.begin(), _topjobs.end(), frameTopJobsGreaterThan);
}
QPair<double,Job*> ljob = _topjobs.last();
int ltidx = threadIdToTimeIdx.value(ljob.second->thread_id());
Expand All @@ -89,10 +89,10 @@ void Frame::_calc_topjobs()
delete it;
if ( rt > lrt ) {
_topjobs.replace(len-1,qMakePair(rt,job));
qSort(_topjobs.begin(), _topjobs.end(), frameTopJobsGreaterThan);
std::sort(_topjobs.begin(), _topjobs.end(), frameTopJobsGreaterThan);
}
}
}
_jobloadindex = 100.0*jcnt/(double)_jobs->size();
qSort(_topjobs.begin(),_topjobs.end(),frameTopJobsGreaterThan);
std::sort(_topjobs.begin(),_topjobs.end(),frameTopJobsGreaterThan);
}
2 changes: 1 addition & 1 deletion libkoviz/layoutitem_curves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ void CurvesLayoutItem::_printErrorplot(const QTransform& T,
yval = QString("Flatpoint=(%1,%2)").
arg(x,0,'g').arg(error,0,'g');
} else {
yval = yval.sprintf("Flatline=%.15g",error);
yval = yval.asprintf("Flatline=%.15g",error);
}
int h = painter->fontMetrics().descent();
painter->drawText(curveBBox.topLeft()-QPointF(0,h),yval);
Expand Down
2 changes: 1 addition & 1 deletion libkoviz/layoutitem_pagetitle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void PageTitleLayoutItem::paint(QPainter *painter,
painter->setFont(font);
QFontMetrics fm2(painter->fontMetrics());
if ( !title2.isEmpty() && !title2.trimmed().isEmpty() ) {
QStringList lines = title2.split('\n', QString::SkipEmptyParts);
QStringList lines = title2.split('\n', Qt::SkipEmptyParts);
y += fm1.descent() + fm1.leading() + fm2.ascent();
if ( lines.size() == 1 ) {
// single RUN
Expand Down
2 changes: 1 addition & 1 deletion libkoviz/layoutitem_plotcorner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ PlotCornerLayoutItem::~PlotCornerLayoutItem()

Qt::Orientations PlotCornerLayoutItem::expandingDirections() const
{
return 0;
return Qt::Orientations();
}

QRect PlotCornerLayoutItem::geometry() const
Expand Down
2 changes: 1 addition & 1 deletion libkoviz/layoutitem_ticlabels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ QRect TicLabelsLayoutItem::_boundingRect(const QString &strVal) const
QString TicLabelsLayoutItem::_format(double tic) const
{
QString s;
s = s.sprintf("%g", tic);
s = s.asprintf("%g", tic);
return s;
}

Expand Down
Loading

0 comments on commit daef7a1

Please sign in to comment.