summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOwen Williams <owilliams@mixxx.org>2020-03-15 11:32:42 -0400
committerOwen Williams <owilliams@mixxx.org>2020-03-15 11:32:42 -0400
commitf7d988c5f7d76587fc65433bccf4a43abbca2383 (patch)
tree31e8f31e98e2a79adb18a84142929e31d6b004db /src
parent693ef74246965384648dff354b55d92744d7fa0a (diff)
parent03095b8ce3b61e843556111904a52837c9181514 (diff)
Merge branch 'master' of github.com:mixxxdj/mixxx into mastersync-onemaster
Diffstat (limited to 'src')
-rw-r--r--src/library/dao/cuedao.cpp32
-rw-r--r--src/widget/wcuemenupopup.cpp1
2 files changed, 30 insertions, 3 deletions
diff --git a/src/library/dao/cuedao.cpp b/src/library/dao/cuedao.cpp
index dd723dce52..5a7d50d851 100644
--- a/src/library/dao/cuedao.cpp
+++ b/src/library/dao/cuedao.cpp
@@ -14,6 +14,31 @@
#include "util/color/color.h"
#include "util/color/predefinedcolor.h"
+namespace {
+
+// The label column is not nullable!
+const QVariant kEmptyLabel = QVariant(QStringLiteral(""));
+
+inline const QVariant labelToQVariant(const QString& label) {
+ if (label.isNull()) {
+ return kEmptyLabel; // null -> empty
+ } else {
+ return label;
+ }
+}
+
+// Empty labels are read as null strings
+inline QString labelFromQVariant(const QVariant& value) {
+ const auto label = value.toString();
+ if (label.isEmpty()) {
+ return QString(); // empty -> null
+ } else {
+ return label;
+ }
+}
+
+}
+
int CueDAO::cueCount() {
qDebug() << "CueDAO::cueCount" << QThread::currentThread() << m_database.connectionName();
QSqlQuery query(m_database);
@@ -52,7 +77,7 @@ CuePointer CueDAO::cueFromRow(const QSqlQuery& query) const {
int position = record.value(record.indexOf("position")).toInt();
int length = record.value(record.indexOf("length")).toInt();
int hotcue = record.value(record.indexOf("hotcue")).toInt();
- QString label = record.value(record.indexOf("label")).toString();
+ QString label = labelFromQVariant(record.value(record.indexOf("label")));
int iColorId = record.value(record.indexOf("color")).toInt();
PredefinedColorPointer color = Color::kPredefinedColorsSet.predefinedColorFromId(iColorId);
CuePointer pCue(new Cue(id, trackId, (mixxx::CueType)type, position, length, hotcue, label, color));
@@ -146,7 +171,8 @@ bool CueDAO::saveCue(Cue* cue) {
query.bindValue(":position", cue->getPosition());
query.bindValue(":length", cue->getLength());
query.bindValue(":hotcue", cue->getHotCue());
- query.bindValue(":label", cue->getLabel());
+
+ query.bindValue(":label", labelToQVariant(cue->getLabel()));
query.bindValue(":color", cue->getColor()->m_iId);
if (query.exec()) {
@@ -174,7 +200,7 @@ bool CueDAO::saveCue(Cue* cue) {
query.bindValue(":position", cue->getPosition());
query.bindValue(":length", cue->getLength());
query.bindValue(":hotcue", cue->getHotCue());
- query.bindValue(":label", cue->getLabel());
+ query.bindValue(":label", labelToQVariant(cue->getLabel()));
query.bindValue(":color", cue->getColor()->m_iId);
if (query.exec()) {
diff --git a/src/widget/wcuemenupopup.cpp b/src/widget/wcuemenupopup.cpp
index 6cefca6aef..c3e06c7c2d 100644
--- a/src/widget/wcuemenupopup.cpp
+++ b/src/widget/wcuemenupopup.cpp
@@ -27,6 +27,7 @@ WCueMenuPopup::WCueMenuPopup(QWidget* parent)
m_pEditLabel = new QLineEdit(this);
m_pEditLabel->setToolTip(tr("Edit cue label"));
m_pEditLabel->setObjectName("CueLabelEdit");
+ m_pEditLabel->setPlaceholderText(tr("Label..."));
connect(m_pEditLabel, &QLineEdit::textEdited, this, &WCueMenuPopup::slotEditLabel);
connect(m_pEditLabel, &QLineEdit::returnPressed, this, &WCueMenuPopup::hide);