Commit 2dcb568e authored by Julius Künzel's avatar Julius Künzel 💬
Browse files

[Code Gardening] Remove more unused code

parent 49242eec
Pipeline #243517 failed with stage
in 4 minutes and 43 seconds
/*
SPDX-FileCopyrightText: 2010 Till Theato <root@ttill.de>
SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "tracksconfigdialog.h"
#include "timeline/timeline.h"
#include <KComboBox>
#include <QIcon>
#include <QTableWidget>
#include "klocalizedstring.h"
TracksDelegate::TracksDelegate(QObject *parent)
: QItemDelegate(parent)
{
}
QWidget *TracksDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem & /* option */, const QModelIndex & /*index*/) const
{
KComboBox *comboBox = new KComboBox(parent);
comboBox->addItem(i18n("Video"));
comboBox->addItem(i18n("Audio"));
connect(comboBox, SIGNAL(activated(int)), this, SLOT(emitCommitData()));
return comboBox;
}
void TracksDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
KComboBox *comboBox = qobject_cast<KComboBox *>(editor);
if (!comboBox) {
return;
}
const int pos = comboBox->findText(index.model()->data(index).toString(), Qt::MatchExactly);
comboBox->setCurrentIndex(pos);
}
void TracksDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
KComboBox *comboBox = qobject_cast<KComboBox *>(editor);
if (!comboBox) {
return;
}
model->setData(index, comboBox->currentText());
}
void TracksDelegate::emitCommitData()
{
emit commitData(qobject_cast<QWidget *>(sender()));
}
TracksConfigDialog::TracksConfigDialog(Timeline *timeline, int selected, QWidget *parent)
: QDialog(parent)
, m_timeline(timeline)
{
setupUi(this);
table->setColumnCount(5);
table->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
table->setHorizontalHeaderLabels(QStringList() << i18n("Name") << i18n("Type") << i18n("Hidden") << i18n("Muted") << i18n("Locked") << i18n("Composite"));
table->setSelectionMode(QAbstractItemView::SingleSelection);
table->setItemDelegateForColumn(1, new TracksDelegate(this));
table->verticalHeader()->setHidden(true);
buttonReset->setIcon(QIcon::fromTheme(QStringLiteral("document-revert")));
buttonReset->setToolTip(i18n("Reset"));
connect(buttonReset, &QAbstractButton::clicked, this, &TracksConfigDialog::setupOriginal);
buttonAdd->setIcon(QIcon::fromTheme(QStringLiteral("list-add")));
buttonAdd->setToolTip(i18n("Add Track"));
buttonAdd->setEnabled(false);
buttonDelete->setIcon(QIcon::fromTheme(QStringLiteral("list-remove")));
buttonDelete->setToolTip(i18n("Delete Track"));
connect(buttonDelete, &QAbstractButton::clicked, this, &TracksConfigDialog::slotDelete);
buttonUp->setIcon(QIcon::fromTheme(QStringLiteral("arrow-up")));
buttonUp->setToolTip(i18n("Move Track upwards"));
buttonUp->setEnabled(false);
buttonDown->setIcon(QIcon::fromTheme(QStringLiteral("arrow-down")));
buttonDown->setToolTip(i18n("Move Track downwards"));
buttonDown->setEnabled(false);
setupOriginal(selected);
// table->resizeColumnToContents(0);
table->resizeColumnsToContents();
/*QRect rect = table->geometry();
rect.setWidth(table->horizontalHeader()->length());
table->setGeometry(rect);*/
table->horizontalHeader()->setStretchLastSection(true);
table->setMinimumSize(table->horizontalHeader()->length(), table->verticalHeader()->length() + table->horizontalHeader()->height() * 2);
connect(table, &QTableWidget::itemChanged, this, &TracksConfigDialog::slotUpdateRow);
}
const QList<TrackInfo> TracksConfigDialog::tracksList()
{
QList<TrackInfo> tracks;
TrackInfo info;
tracks.reserve(table->rowCount());
for (int i = 0; i < table->rowCount(); i++) {
info.trackName = table->item(i, 0)->text();
QTableWidgetItem *item = table->item(i, 1);
if (item->text() == i18n("Audio")) {
info.type = AudioTrack;
info.isBlind = true;
} else {
info.type = VideoTrack;
info.isBlind = (table->item(i, 2)->checkState() == Qt::Checked);
}
info.isMute = (table->item(i, 3)->checkState() == Qt::Checked);
info.isLocked = (table->item(i, 4)->checkState() == Qt::Checked);
tracks << info;
}
return tracks;
}
QList<int> TracksConfigDialog::deletedTracks() const
{
return m_deletedRows;
}
void TracksConfigDialog::setupOriginal(int selected)
{
int max = m_timeline->visibleTracksCount();
table->setRowCount(max);
QStringList numbers;
TrackInfo info;
for (int i = 0; i < max; i++) {
numbers << QString::number(i);
info = m_timeline->getTrackInfo(max - i);
table->setItem(i, 0, new QTableWidgetItem(info.trackName));
QTableWidgetItem *item1 = new QTableWidgetItem(i18n("Video"));
if (info.type == AudioTrack) {
item1->setText(i18n("Audio"));
}
table->setItem(i, 1, item1);
table->openPersistentEditor(item1);
QTableWidgetItem *item2 = new QTableWidgetItem(QString());
item2->setFlags(item2->flags() & ~Qt::ItemIsEditable);
item2->setCheckState(info.isBlind ? Qt::Checked : Qt::Unchecked);
if (info.type == AudioTrack) {
item2->setFlags(item2->flags() & ~Qt::ItemIsEnabled);
}
table->setItem(i, 2, item2);
QTableWidgetItem *item3 = new QTableWidgetItem(QString());
item3->setFlags(item3->flags() & ~Qt::ItemIsEditable);
item3->setCheckState(info.isMute ? Qt::Checked : Qt::Unchecked);
table->setItem(i, 3, item3);
QTableWidgetItem *item4 = new QTableWidgetItem(QString());
item4->setFlags(item4->flags() & ~Qt::ItemIsEditable);
item4->setCheckState(info.isLocked ? Qt::Checked : Qt::Unchecked);
table->setItem(i, 4, item4);
}
table->setVerticalHeaderLabels(numbers);
table->resizeColumnsToContents();
if (selected != -1) {
table->selectRow(max - selected);
}
m_deletedRows.clear();
}
void TracksConfigDialog::slotUpdateRow(QTableWidgetItem *item)
{
if (table->column(item) == 1) {
QTableWidgetItem *item2 = table->item(table->row(item), 2);
if (item->text() == i18n("Audio")) {
item2->setFlags(item2->flags() & ~Qt::ItemIsEnabled);
item2->setCheckState(Qt::Checked);
} else {
item2->setFlags(item2->flags() | Qt::ItemIsEnabled);
item2->setCheckState(Qt::Unchecked);
}
}
}
void TracksConfigDialog::slotDelete()
{
int row = table->currentRow();
int trackToDelete = table->rowCount() - row;
if (row < 0 || m_deletedRows.contains(trackToDelete)) {
return;
}
m_deletedRows.append(trackToDelete);
std::sort(m_deletedRows.begin(), m_deletedRows.end());
for (int i = 0; i < table->columnCount(); ++i) {
QTableWidgetItem *item = table->item(row, i);
item->setFlags(Qt::NoItemFlags);
item->setBackground(palette().dark());
}
}
/*
SPDX-FileCopyrightText: 2010 Till Theato <root@ttill.de>
SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#pragma once
#include "ui_tracksconfigdialog_ui.h"
#include <QItemDelegate>
class TracksDelegate : public QItemDelegate
{
Q_OBJECT
public:
explicit TracksDelegate(QObject *parent = nullptr);
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
void setEditorData(QWidget *editor, const QModelIndex &index) const override;
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
private slots:
void emitCommitData();
};
class TrackInfo;
class Timeline;
class QTableWidgetItem;
/** @class TracksConfigDialog
@brief A dialog to change the name, type, ... of tracks.
@author Till Theato
*/
class TracksConfigDialog : public QDialog, public Ui::TracksConfigDialog_UI
{
Q_OBJECT
public:
/** @brief Sets up the table.
* @param doc the kdenlive document whose tracks to use
* @param selected the track which should be selected by default
* @param parent the parent widget */
explicit TracksConfigDialog(Timeline *timeline, int selected = -1, QWidget *parent = nullptr);
/** @brief Returns the new list of tracks created from the table. */
const QList<TrackInfo> tracksList();
/** @brief A list of tracks, which should be deleted. */
QList<int> deletedTracks() const;
private slots:
/** @brief Updates the "hidden" checkbox if type was changed. */
void slotUpdateRow(QTableWidgetItem *item);
private slots:
/** @brief Recreates the table from the list of tracks in m_doc. */
void setupOriginal(int selected = -1);
/** @brief Marks a track to be deleted. */
void slotDelete();
private:
Timeline *m_timeline;
QList<int> m_deletedRows;
};
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>EffectStack2_UI</class>
<widget class="QWidget" name="EffectStack2_UI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>113</width>
<height>121</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QCheckBox" name="checkAll">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="tristate">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonShowComments">
<property name="text">
<string/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelComment">
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QScrollArea" name="container">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>113</width>
<height>72</height>
</rect>
</property>
<zorder>labelComment</zorder>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>EffectStack_UI</class>
<widget class="QWidget" name="EffectStack_UI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>200</width>
<height>121</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="verticalSpacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="checkAll">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="tristate">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonShowComments">
<property name="text">
<string/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListWidget" name="effectlist">
<property name="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="movement">
<enum>QListView::Free</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="buttonNew">
<property name="text">
<string notr="true">N</string>
</property>
<property name="popupMode">
<enum>QToolButton::InstantPopup</enum>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonUp">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string notr="true">Up</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonDown">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string notr="true">Dw</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonReset">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string notr="true">R</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="buttonSave">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string notr="true">E</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonDel">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string notr="true">D</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget1">
<layout class="QVBoxLayout" name="layoutEdit">
<item>
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelComment">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="text">
<string/>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>