Fix various compiler warnings

This commit is contained in:
Martchus 2023-07-02 00:06:13 +02:00
parent ff76de974b
commit 464b49d086
5 changed files with 16 additions and 18 deletions

View File

@ -184,7 +184,7 @@ void QtWindow::displayUsage()
int QtWindow::decodeIntegerParam(const QString &arg, int defaultParam)
{
int n = arg.lastIndexOf('=');
const auto n = arg.lastIndexOf(QChar('='));
if (n == -1 || (n + 1) >= arg.size())
return defaultParam;
bool ok;
@ -196,7 +196,7 @@ int QtWindow::decodeIntegerParam(const QString &arg, int defaultParam)
bool QtWindow::validateIntegerParam(const QString &arg)
{
int n = arg.lastIndexOf('=');
const auto n = arg.lastIndexOf(QChar('='));
if (n == -1 || (n + 1) >= arg.size())
return false;
bool ok;
@ -541,12 +541,10 @@ void QtWindow::showUISettingsDialog()
// load the recent file list from the config file into the file menu
void QtWindow::updateRecentFileActions()
{
const auto files = m_settings->value("RecentFileList").toStringList();
const auto numRecentFiles = qMin(files.size(), maxRecentFiles());
QStringList files = m_settings->value("RecentFileList").toStringList();
int numRecentFiles = qMin(files.size(), maxRecentFiles());
for (int i = 0; i < numRecentFiles; ++i) {
for (auto i = 0; i < numRecentFiles; ++i) {
QString text = tr("&%1 %2").arg(i + 1).arg(strippedName(files[i]));
if (m_recentFileActs[i] == nullptr)
break;
@ -555,7 +553,7 @@ void QtWindow::updateRecentFileActions()
m_recentFileActs[i]->setVisible(true);
}
for (int j = numRecentFiles; j < maxRecentFiles(); ++j) {
for (auto j = numRecentFiles; j < maxRecentFiles(); ++j) {
if (m_recentFileActs[j] == nullptr)
break;
m_recentFileActs[j]->setVisible(false);

View File

@ -48,7 +48,7 @@ class QSlider;
class QPushButton;
class QTextBrowser;
static constexpr int maxRecentFiles() { return 20; }
static constexpr qsizetype maxRecentFiles() { return 20; }
namespace QtUtilities {
class SettingsDialog;

View File

@ -152,8 +152,8 @@ public:
auto locale = value(QStringLiteral("General/lang"), QString()).toString();
if (locale.isEmpty()) {
locale = QLocale::system().bcp47Name();
int n = locale.indexOf("_");
if ((n > 0)) {
const auto n = locale.indexOf(QChar('_'));
if (n > 0) {
locale = locale.left(n);
}
}

View File

@ -47,7 +47,7 @@ void CSong::loadSong(const QString & filename)
CNote::reset();
m_songTitle = filename;
int index = m_songTitle.lastIndexOf("/");
const auto index = m_songTitle.lastIndexOf(QChar('/'));
if (index >= 0)
m_songTitle = m_songTitle.right( m_songTitle.length() - index - 1);

View File

@ -49,14 +49,14 @@ void CStavePos::notePos(whichPart_t hand, int midiNote, int clef) // in fact cle
lookUpItem = &m_staveLookUpTable[index];
if (clef == -1) {
if (m_hand == PB_PART_right)
clef = PB_SYMBOL_gClef;
if (m_hand == PB_PART_left)
clef = PB_SYMBOL_fClef;
if (m_hand == PB_PART_right)
clef = PB_SYMBOL_gClef;
if (m_hand == PB_PART_left)
clef = PB_SYMBOL_fClef;
}
if (m_hand == PB_PART_right && clef == PB_SYMBOL_gClef || m_hand == PB_PART_left && clef == PB_SYMBOL_gClef)
if ((m_hand == PB_PART_right && clef == PB_SYMBOL_gClef) || (m_hand == PB_PART_left && clef == PB_SYMBOL_gClef))
m_staveIndex = lookUpItem->pianoNote - 7;
else if (m_hand == PB_PART_left && clef == PB_SYMBOL_fClef || m_hand == PB_PART_right && clef == PB_SYMBOL_fClef)
else if ((m_hand == PB_PART_left && clef == PB_SYMBOL_fClef) || (m_hand == PB_PART_right && clef == PB_SYMBOL_fClef))
m_staveIndex = lookUpItem->pianoNote + 5;
m_staveIndex += (midiNote/semitonesInAnOctive)*notesInAnOctive - notesInAnOctive*5 ;