diff options
author | Ferran Pujol Camins <ferranpujolcamins@gmail.com> | 2019-11-04 10:15:40 +0100 |
---|---|---|
committer | Ferran Pujol Camins <ferranpujolcamins@gmail.com> | 2019-11-04 10:15:40 +0100 |
commit | 768c3066fab585682c48666eafc58e144e8a7695 (patch) | |
tree | fe273daddeecf56a9abc7de80b69fe65bf8dd884 | |
parent | 3233dc33213db2d0c2325a3f0103077b1fb46f75 (diff) |
Remove cues tab on TrackInfo
-rw-r--r-- | src/library/dlgtrackinfo.cpp | 230 | ||||
-rw-r--r-- | src/library/dlgtrackinfo.h | 5 | ||||
-rw-r--r-- | src/library/dlgtrackinfo.ui | 102 |
3 files changed, 12 insertions, 325 deletions
diff --git a/src/library/dlgtrackinfo.cpp b/src/library/dlgtrackinfo.cpp index 3b6cb9346c..ab665aaffd 100644 --- a/src/library/dlgtrackinfo.cpp +++ b/src/library/dlgtrackinfo.cpp @@ -39,7 +39,6 @@ DlgTrackInfo::~DlgTrackInfo() { void DlgTrackInfo::init() { setupUi(this); - cueTable->hideColumn(0); coverBox->insertWidget(1, m_pWCoverArtLabel); connect(btnNext, &QPushButton::clicked, this, &DlgTrackInfo::slotNext); @@ -92,14 +91,6 @@ void DlgTrackInfo::init() { this, &DlgTrackInfo::slotKeyTextChanged); - connect(btnCueActivate, - &QPushButton::clicked, - this, - &DlgTrackInfo::cueActivate); - connect(btnCueDelete, - &QPushButton::clicked, - this, - &DlgTrackInfo::cueDelete); connect(bpmTap, &QPushButton::pressed, m_pTapFilter.data(), @@ -165,30 +156,6 @@ void DlgTrackInfo::slotPrev() { emit(previous()); } -void DlgTrackInfo::cueActivate() { - -} - -void DlgTrackInfo::cueDelete() { - QList<QTableWidgetItem*> selected = cueTable->selectedItems(); - QListIterator<QTableWidgetItem*> item_it(selected); - - QSet<int> rowsToDelete; - while(item_it.hasNext()) { - QTableWidgetItem* item = item_it.next(); - rowsToDelete.insert(item->row()); - } - - QList<int> rowsList = QList<int>::fromSet(rowsToDelete); - std::sort(rowsList.begin(), rowsList.end()); - - QListIterator<int> it(rowsList); - it.toBack(); - while (it.hasPrevious()) { - cueTable->removeRow(it.previous()); - } -} - void DlgTrackInfo::populateFields(const Track& track) { setWindowTitle(track.getArtist() % " - " % track.getTitle()); @@ -257,7 +224,6 @@ void DlgTrackInfo::loadTrack(TrackPointer pTrack) { m_pLoadedTrack = pTrack; populateFields(*m_pLoadedTrack); - populateCues(m_pLoadedTrack); m_pWCoverArtLabel->loadTrack(m_pLoadedTrack); // We already listen to changed() so we don't need to listen to individual @@ -309,131 +275,6 @@ void DlgTrackInfo::slotOpenInFileBrowser() { mixxx::DesktopHelper::openInFileBrowser(QStringList(m_pLoadedTrack->getLocation())); } -void DlgTrackInfo::populateCues(TrackPointer pTrack) { - int sampleRate = pTrack->getSampleRate(); - - QList<CuePointer> listPoints; - const QList<CuePointer> cuePoints = pTrack->getCuePoints(); - QListIterator<CuePointer> it(cuePoints); - while (it.hasNext()) { - CuePointer pCue = it.next(); - Cue::CueType type = pCue->getType(); - if (type == Cue::CUE || type == Cue::LOAD || type == Cue::INTRO - || type == Cue::OUTRO) { - listPoints.push_back(pCue); - } - } - it = QListIterator<CuePointer>(listPoints); - cueTable->setSortingEnabled(false); - int row = 0; - - while (it.hasNext()) { - CuePointer pCue(it.next()); - - QString rowStr = QString("%1").arg(row); - - // All hotcues are stored in Cue's as 0-indexed, but the GUI presents - // them to the user as 1-indexex. Add 1 here. rryan 9/2010 - int iHotcue = pCue->getHotCue() + 1; - QString hotcue = ""; - hotcue = QString("%1").arg(iHotcue); - double position = pCue->getPosition(); - if (position == -1) { - continue; - } - - double totalSeconds = position / sampleRate / 2.0; - - bool negative = false; - if (totalSeconds < 0) { - totalSeconds *= -1; - negative = true; - } - - int iTotalSeconds = static_cast<int>(totalSeconds); - int fraction = 100 * (totalSeconds - iTotalSeconds); - int seconds = iTotalSeconds % 60; - int mins = iTotalSeconds / 60; - //int hours = mins / 60; //Not going to worry about this for now. :) - - //Construct a nicely formatted duration string now. - QString duration = QString("%1%2:%3.%4").arg( - negative ? QString("-") : QString(), - QString::number(mins), - QString("%1").arg(seconds, 2, 10, QChar('0')), - QString("%1").arg(fraction, 2, 10, QChar('0'))); - - QTableWidgetItem* durationItem = new QTableWidgetItem(duration); - // Make the duration read only - durationItem->setFlags(Qt::NoItemFlags); - - // Decode cue type to display text - QString cueType; - switch (pCue->getType()) { - case Cue::INVALID: - cueType = "?"; - break; - case Cue::CUE: - cueType = "Hotcue"; - break; - case Cue::LOAD: - cueType = "Main Cue"; - break; - case Cue::BEAT: - cueType = "Beat"; - break; - case Cue::LOOP: - cueType = "Loop"; - break; - case Cue::JUMP: - cueType = "Jump"; - break; - case Cue::INTRO: - cueType = "Intro"; - break; - case Cue::OUTRO: - cueType = "Outro"; - break; - default: - break; - } - - QTableWidgetItem* typeItem = new QTableWidgetItem(cueType); - // Make the type read only - typeItem->setFlags(Qt::NoItemFlags); - - HotcueColorPaletteSettings colorPaletteSettings(m_pConfig); - auto colorPalette = colorPaletteSettings.getHotcueColorPalette(); - QList<QColor> hotcueColorList = - colorPaletteSettings.getHotcueColorPalette().m_colorList; - QComboBox* colorComboBox = new QComboBox(); - for (int i = 0; i < hotcueColorList.count(); i++) { - QColor color = hotcueColorList.at(i); - colorComboBox->addItem("", color); - QPixmap pixmap(80, 80); - pixmap.fill(color); - QIcon icon(pixmap); - colorComboBox->setItemIcon(i, icon); - } - QColor cueColor = pCue->getColor(); - int colorIndex = hotcueColorList.indexOf(cueColor); - colorComboBox->setCurrentIndex(math_min(colorIndex, 0)); - - m_cueMap[row] = pCue; - cueTable->insertRow(row); - cueTable->setItem(row, 0, new QTableWidgetItem(rowStr)); - cueTable->setItem(row, 1, durationItem); - cueTable->setItem(row, 2, typeItem); - cueTable->setItem(row, 3, new QTableWidgetItem(hotcue)); - cueTable->setCellWidget(row, 4, colorComboBox); - cueTable->setItem(row, 5, new QTableWidgetItem(pCue->getLabel())); - row += 1; - } - cueTable->setSortingEnabled(true); - cueTable->horizontalHeader()->setStretchLastSection(true); - cueTable->horizontalHeader()->setSectionResizeMode(3, QHeaderView::ResizeToContents); -} - void DlgTrackInfo::saveTrack() { if (!m_pLoadedTrack) return; @@ -469,73 +310,6 @@ void DlgTrackInfo::saveTrack() { m_pLoadedTrack->setKeys(m_keysClone); - QSet<int> updatedRows; - for (int row = 0; row < cueTable->rowCount(); ++row) { - QTableWidgetItem* rowItem = cueTable->item(row, 0); - QTableWidgetItem* hotcueItem = cueTable->item(row, 3); - QWidget* colorWidget = cueTable->cellWidget(row, 4); - QTableWidgetItem* labelItem = cueTable->item(row, 5); - - VERIFY_OR_DEBUG_ASSERT(rowItem && hotcueItem && colorWidget && labelItem) { - qWarning() << "unable to retrieve cells from cueTable row"; - continue; - } - - int oldRow = rowItem->data(Qt::DisplayRole).toInt(); - CuePointer pCue(m_cueMap.value(oldRow, CuePointer())); - if (!pCue) { - continue; - } - updatedRows.insert(oldRow); - - QVariant vHotcue = hotcueItem->data(Qt::DisplayRole); - bool ok; - int iTableHotcue = vHotcue.toInt(&ok); - if (ok) { - // The GUI shows hotcues as 1-indexed, but they are actually - // 0-indexed, so subtract 1 - pCue->setHotCue(iTableHotcue - 1); - } else { - pCue->setHotCue(-1); - } - - if (pCue->getType() == Cue::CUE) { - auto colorComboBox = qobject_cast<QComboBox*>(colorWidget); - if (colorComboBox) { - HotcueColorPaletteSettings colorPaletteSettings(m_pConfig); - auto colorPalette = - colorPaletteSettings.getHotcueColorPalette(); - QList<QColor> hotcueColorList = - colorPaletteSettings.getHotcueColorPalette() - .m_colorList; - QColor color = - hotcueColorList.at(colorComboBox->currentIndex()); - pCue->setColor(color); - } - } - // do nothing for now. - - QString label = labelItem->data(Qt::DisplayRole).toString(); - pCue->setLabel(label); - } - - QMutableHashIterator<int,CuePointer> it(m_cueMap); - // Everything that was not processed above was removed. - while (it.hasNext()) { - it.next(); - int oldRow = it.key(); - - // If cue's old row is not in updatedRows then it must have been - // deleted. - if (updatedRows.contains(oldRow)) { - continue; - } - CuePointer pCue(it.value()); - it.remove(); - qDebug() << "Deleting cue" << pCue->getId() << pCue->getHotCue(); - m_pLoadedTrack->removeCue(pCue); - } - m_pLoadedTrack->setCoverInfo(m_loadedCoverInfo); // Reconnect changed signals now. @@ -585,10 +359,6 @@ void DlgTrackInfo::clear() { txtKey->setText(""); txtReplayGain->setText(""); - m_cueMap.clear(); - cueTable->clearContents(); - cueTable->setRowCount(0); - m_loadedCoverInfo = CoverInfo(); m_pWCoverArtLabel->setCoverArt(m_loadedCoverInfo, QPixmap()); } diff --git a/src/library/dlgtrackinfo.h b/src/library/dlgtrackinfo.h index 16bfd450e9..9856dcbeeb 100644 --- a/src/library/dlgtrackinfo.h +++ b/src/library/dlgtrackinfo.h @@ -39,9 +39,6 @@ class DlgTrackInfo : public QDialog, public Ui::DlgTrackInfo { void cancel(); void trackUpdated(); - void cueActivate(); - void cueDelete(); - void slotBpmDouble(); void slotBpmHalve(); void slotBpmTwoThirds(); @@ -69,12 +66,10 @@ class DlgTrackInfo : public QDialog, public Ui::DlgTrackInfo { private: void populateFields(const Track& track); void reloadTrackBeats(const Track& track); - void populateCues(TrackPointer pTrack); void saveTrack(); void unloadTrack(bool save); void clear(); void init(); - QHash<int, CuePointer> m_cueMap; TrackPointer m_pLoadedTrack; BeatsPointer m_pBeatsClone; Keys m_keysClone; diff --git a/src/library/dlgtrackinfo.ui b/src/library/dlgtrackinfo.ui index 4435134c7a..caf42ac2c2 100644 --- a/src/library/dlgtrackinfo.ui +++ b/src/library/dlgtrackinfo.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>700</width> - <height>588</height> + <height>595</height> </rect> </property> <property name="sizePolicy"> @@ -41,7 +41,7 @@ </size> </property> <property name="currentIndex"> - <number>0</number> + <number>2</number> </property> <widget class="QWidget" name="tabSummary"> <attribute name="title"> @@ -376,7 +376,16 @@ <property name="sizeConstraint"> <enum>QLayout::SetDefaultConstraint</enum> </property> - <property name="margin"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> <number>0</number> </property> <item> @@ -798,90 +807,6 @@ Often results in higher quality beatgrids, but will not do well on tracks that h </item> </layout> </widget> - <widget class="QWidget" name="tabCuepoints"> - <attribute name="title"> - <string>Cuepoints</string> - </attribute> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QTableWidget" name="cueTable"> - <column> - <property name="text"> - <string>Cue Id</string> - </property> - </column> - <column> - <property name="text"> - <string>Position</string> - </property> - </column> - <column> - <property name="text"> - <string>Type</string> - </property> - </column> - <column> - <property name="text"> - <string>Hotcue</string> - </property> - </column> - <column> - <property name="text"> - <string>Color</string> - </property> - </column> - <column> - <property name="text"> - <string>Label</string> - </property> - </column> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QPushButton" name="btnCueDelete"> - <property name="minimumSize"> - <size> - <width>125</width> - <height>0</height> - </size> - </property> - <property name="text"> - <string>Delete Cue</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_3"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="btnCueActivate"> - <property name="minimumSize"> - <size> - <width>125</width> - <height>0</height> - </size> - </property> - <property name="text"> - <string>Activate Cue</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> </widget> </item> <item> @@ -1030,9 +955,6 @@ Often results in higher quality beatgrids, but will not do well on tracks that h <tabstop>bpmThreeFourth</tabstop> <tabstop>bpmThreeHalves</tabstop> <tabstop>bpmFourThirds</tabstop> - <tabstop>cueTable</tabstop> - <tabstop>btnCueDelete</tabstop> - <tabstop>btnCueActivate</tabstop> </tabstops> <resources/> <connections/> |