mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
cleanup: simplify string-comparison in CylindersModel::setData()
Convert to QString instead of a QByteArray. Use qPrintable() instead of data(). This might do one more UTF16->UTF8 conversion. However, this is completely irrelevant, since we don't change the type of a cylinder in a tight loop. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
ee1c438d41
commit
f1e1a9634a
1 changed files with 5 additions and 6 deletions
|
@ -8,6 +8,7 @@
|
|||
#include "qt-models/diveplannermodel.h"
|
||||
#include "core/gettextfromc.h"
|
||||
#include "core/subsurface-qt/divelistnotifier.h"
|
||||
#include "core/subsurface-string.h"
|
||||
|
||||
CylindersModel::CylindersModel(QObject *parent) :
|
||||
CleanerTableModel(parent),
|
||||
|
@ -317,13 +318,11 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
|
|||
}
|
||||
|
||||
switch (index.column()) {
|
||||
case TYPE:
|
||||
if (!value.isNull()) {
|
||||
QByteArray ba = value.toByteArray();
|
||||
const char *text = ba.constData();
|
||||
if (!cyl->type.description || strcmp(cyl->type.description, text)) {
|
||||
case TYPE: {
|
||||
QString type = value.toString();
|
||||
if (!same_string(qPrintable(type), cyl->type.description)) {
|
||||
free((void *)cyl->type.description);
|
||||
cyl->type.description = strdup(text);
|
||||
cyl->type.description = strdup(qPrintable(type));
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue