Commit 7e7237ae authored by Laurent Montel's avatar Laurent Montel 😁

const'ify + fix indent + minor optimization

parent 4990696d
......@@ -49,7 +49,7 @@ public:
*
* @param parent parent QWidget
*/
KoSliderCombo(QWidget *parent = 0);
explicit KoSliderCombo(QWidget *parent = 0);
/**
* Destructor
......
......@@ -106,7 +106,7 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap<QString, QString>& map
// Video 4 Linux device detection
for (int i = 0; i < 10; ++i) {
QString path = "/dev/video" + QString::number(i);
QString path = QLatin1String("/dev/video") + QString::number(i);
if (QFile::exists(path)) {
QStringList deviceInfo = V4lCaptureHandler::getDeviceName(path);
if (!deviceInfo.isEmpty()) {
......@@ -166,22 +166,22 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap<QString, QString>& map
QStringList actions_map = JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons());
QMap<QString, int> action_pos;
foreach (const QString& action_id, actions_map) {
// This loop find out at what index is the string that would map to the action_id.
for (int i = 0; i < action_names.size(); ++i) {
if (mappable_actions[action_names[i]] == action_id) {
action_pos[action_id] = i;
break;
}
}
// This loop find out at what index is the string that would map to the action_id.
for (int i = 0; i < action_names.size(); ++i) {
if (mappable_actions[action_names.at(i)] == action_id) {
action_pos[action_id] = i;
break;
}
}
}
int i = 0;
foreach (KComboBox* button, m_shuttle_buttons) {
button->addItems(action_names);
connect(button, SIGNAL(activated(int)), this, SLOT(slotShuttleModified()));
++i;
if (i < actions_map.size())
button->setCurrentIndex(action_pos[actions_map[i]]);
button->addItems(action_names);
connect(button, SIGNAL(activated(int)), this, SLOT(slotShuttleModified()));
++i;
if (i < actions_map.size())
button->setCurrentIndex(action_pos[actions_map[i]]);
}
#else /* ! USE_JOGSHUTTLE */
m_configShuttle.kcfg_enableshuttle->hide();
......@@ -293,7 +293,7 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap<QString, QString>& map
Render::getBlackMagicDeviceList(m_configCapture.kcfg_decklink_capturedevice);
if (!Render::getBlackMagicOutputDeviceList(m_configSdl.kcfg_blackmagic_output_device)) {
// No blackmagic card found
m_configSdl.kcfg_external_display->setEnabled(false);
m_configSdl.kcfg_external_display->setEnabled(false);
}
double dvgrabVersion = 0;
......@@ -400,7 +400,7 @@ void KdenliveSettingsDialog::initDevices()
QTextStream stream(&file);
QString line = stream.readLine();
QString deviceId;
while (!line.isNull()) {
while (!line.isNull()) {
if (line.contains("playback")) {
deviceId = line.section(':', 0, 0);
m_configSdl.kcfg_audio_device->addItem(line.section(':', 1, 1), "plughw:" + QString::number(deviceId.section('-', 0, 0).toInt()) + ',' + QString::number(deviceId.section('-', 1, 1).toInt()));
......@@ -530,7 +530,7 @@ void KdenliveSettingsDialog::slotEditImageApplication()
void KdenliveSettingsDialog::slotCheckShuttle(int state)
{
#ifdef USE_JOGSHUTTLE
m_configShuttle.config_group->setEnabled(state);
m_configShuttle.config_group->setEnabled(state);
if (m_configShuttle.shuttledevicelist->count() == 0) {
// parse devices
QString baseName = "/dev/input/event";
......@@ -567,12 +567,12 @@ void KdenliveSettingsDialog::updateWidgets()
#ifdef USE_JOGSHUTTLE
// revert jog shuttle device
if (m_configShuttle.shuttledevicelist->count() > 0) {
for (int i = 0; i < m_configShuttle.shuttledevicelist->count(); ++i) {
if (m_configShuttle.shuttledevicelist->itemData(i) == KdenliveSettings::shuttledevice()) {
m_configShuttle.shuttledevicelist->setCurrentIndex(i);
break;
}
}
for (int i = 0; i < m_configShuttle.shuttledevicelist->count(); ++i) {
if (m_configShuttle.shuttledevicelist->itemData(i) == KdenliveSettings::shuttledevice()) {
m_configShuttle.shuttledevicelist->setCurrentIndex(i);
break;
}
}
}
// Revert jog shuttle buttons
......@@ -581,19 +581,19 @@ void KdenliveSettingsDialog::updateWidgets()
QStringList actions_map = JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons());
QMap<QString, int> action_pos;
foreach (const QString& action_id, actions_map) {
// This loop find out at what index is the string that would map to the action_id.
for (int i = 0; i < action_names.size(); ++i) {
if (m_mappable_actions[action_names[i]] == action_id) {
action_pos[action_id] = i;
break;
}
}
// This loop find out at what index is the string that would map to the action_id.
for (int i = 0; i < action_names.size(); ++i) {
if (m_mappable_actions[action_names[i]] == action_id) {
action_pos[action_id] = i;
break;
}
}
}
int i = 0;
foreach (KComboBox* button, m_shuttle_buttons) {
++i;
if (i < actions_map.size())
button->setCurrentIndex(action_pos[actions_map[i]]);
++i;
if (i < actions_map.size())
button->setCurrentIndex(action_pos[actions_map[i]]);
}
#endif /* USE_JOGSHUTTLE */
}
......@@ -609,8 +609,8 @@ void KdenliveSettingsDialog::updateSettings()
bool updateCapturePath = false;
/*if (m_configShuttle.shuttledevicelist->count() > 0) {
QString device = m_configShuttle.shuttledevicelist->itemData(m_configShuttle.shuttledevicelist->currentIndex()).toString();
if (device != KdenliveSettings::shuttledevice()) KdenliveSettings::setShuttledevice(device);
QString device = m_configShuttle.shuttledevicelist->itemData(m_configShuttle.shuttledevicelist->currentIndex()).toString();
if (device != KdenliveSettings::shuttledevice()) KdenliveSettings::setShuttledevice(device);
}*/
if (m_configEnv.kcfg_capturetoprojectfolder->isChecked() != KdenliveSettings::capturetoprojectfolder()) {
......@@ -651,7 +651,7 @@ void KdenliveSettingsDialog::updateSettings()
KdenliveSettings::setGrab_parameters(data.section(';', 0, 0));
KdenliveSettings::setGrab_extension(data.section(';', 1, 1));
}
// decklink
data = m_configCapture.kcfg_decklink_profile->itemData(m_configCapture.kcfg_decklink_profile->currentIndex()).toString();
if (!data.isEmpty() && (data.section(';', 0, 0) != KdenliveSettings::decklink_parameters() || data.section(';', 1, 1) != KdenliveSettings::decklink_extension())) {
......@@ -729,7 +729,7 @@ void KdenliveSettingsDialog::updateSettings()
QString maps = JogShuttleConfig::actionMap(actions);
//fprintf(stderr, "Shuttle config: %s\n", JogShuttleConfig::actionMap(actions).toAscii().constData());
if (KdenliveSettings::shuttlebuttons() != maps)
KdenliveSettings::setShuttlebuttons(maps);
KdenliveSettings::setShuttlebuttons(maps);
#endif
KConfigDialog::settingsChangedSlot();
......@@ -806,7 +806,7 @@ void KdenliveSettingsDialog::slotAddTranscode()
QString data = m_configTranscode.profile_parameters->toPlainText();
data.append(" %1." + m_configTranscode.profile_extension->text());
data.append(';');
if (!m_configTranscode.profile_description->text().isEmpty())
if (!m_configTranscode.profile_description->text().isEmpty())
data.append(m_configTranscode.profile_description->text());
if (m_configTranscode.profile_audioonly->isChecked()) data.append(";audio");
item->setData(Qt::UserRole, data);
......@@ -1001,7 +1001,7 @@ void KdenliveSettingsDialog::slotManageEncodingProfile()
{
int type = 0;
if (currentPage() == m_page4) {
type = m_configCapture.tabWidget->currentIndex();
type = m_configCapture.tabWidget->currentIndex();
}
QPointer<EncodingProfilesDialog> d = new EncodingProfilesDialog(type);
d->exec();
......@@ -1128,7 +1128,7 @@ void KdenliveSettingsDialog::slotReloadBlackMagic()
Render::getBlackMagicDeviceList(m_configCapture.kcfg_decklink_capturedevice, true);
if (!Render::getBlackMagicOutputDeviceList(m_configSdl.kcfg_blackmagic_output_device), true) {
// No blackmagic card found
m_configSdl.kcfg_external_display->setEnabled(false);
m_configSdl.kcfg_external_display->setEnabled(false);
}
m_configSdl.kcfg_external_display->setEnabled(KdenliveSettings::decklink_device_found());
}
......
......@@ -25,11 +25,11 @@
#include <QHeaderView>
KeyframeEdit::KeyframeEdit(const QDomElement &e, int minFrame, int maxFrame, Timecode tc, int activeKeyframe, QWidget* parent) :
QWidget(parent),
m_min(minFrame),
m_max(maxFrame),
m_timecode(tc)
KeyframeEdit::KeyframeEdit(const QDomElement &e, int minFrame, int maxFrame, const Timecode &tc, int activeKeyframe, QWidget* parent) :
QWidget(parent),
m_min(minFrame),
m_max(maxFrame),
m_timecode(tc)
{
setupUi(this);
if (m_max == -1) {
......@@ -116,8 +116,8 @@ void KeyframeEdit::addParameter(QDomElement e, int activeKeyframe)
keyframe_list->setHorizontalHeaderItem(columnId, new QTableWidgetItem(paramName));
DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, 0,
m_params.at(columnId).attribute("min").toDouble(), m_params.at(columnId).attribute("max").toDouble(),
m_params.at(columnId).attribute("default").toDouble(), comment, columnId, m_params.at(columnId).attribute("suffix"), m_params.at(columnId).attribute("decimals").toInt(), this);
m_params.at(columnId).attribute("min").toDouble(), m_params.at(columnId).attribute("max").toDouble(),
m_params.at(columnId).attribute("default").toDouble(), comment, columnId, m_params.at(columnId).attribute("suffix"), m_params.at(columnId).attribute("decimals").toInt(), this);
connect(doubleparam, SIGNAL(valueChanged(double)), this, SLOT(slotAdjustKeyframeValue(double)));
connect(this, SIGNAL(showComments(bool)), doubleparam, SLOT(slotShowComment(bool)));
connect(doubleparam, SIGNAL(setInTimeline(int)), this, SLOT(slotUpdateVisibleParameter(int)));
......@@ -242,7 +242,7 @@ void KeyframeEdit::slotGenerateParams(int row, int column)
for (int col = 0; col < keyframe_list->horizontalHeader()->count(); col++) {
item = keyframe_list->item(row, col);
if (!item) continue;
if (!item) continue;
int v = item->text().toInt();
if (v >= m_params.at(col).attribute("max").toInt())
item->setText(m_params.at(col).attribute("max"));
......@@ -384,7 +384,7 @@ void KeyframeEdit::slotAdjustKeyframeValue(double value)
int KeyframeEdit::getPos(int row)
{
if (!keyframe_list->verticalHeaderItem(row))
return 0;
return 0;
if (KdenliveSettings::frametimecode())
return keyframe_list->verticalHeaderItem(row)->text().toInt();
else
......@@ -436,7 +436,7 @@ void KeyframeEdit::slotResetKeyframe()
void KeyframeEdit::slotUpdateVisibleParameter(int id, bool update)
{
for (int i = 0; i < m_params.count(); ++i) {
m_params[i].setAttribute("intimeline", (i == id ? "1" : "0"));
m_params[i].setAttribute("intimeline", (i == id ? "1" : "0"));
}
for (int col = 0; col < keyframe_list->columnCount(); col++) {
DoubleParameterWidget *doubleparam = static_cast <DoubleParameterWidget*>(m_slidersLayout->itemAtPosition(col, 0)->widget());
......
......@@ -35,7 +35,8 @@ class KeyItemDelegate: public QItemDelegate
{
Q_OBJECT
public:
KeyItemDelegate(int min, int max, QAbstractItemView* parent = 0): QItemDelegate(parent), m_min(min), m_max(max) {
KeyItemDelegate(int min, int max, QAbstractItemView* parent = 0)
: QItemDelegate(parent), m_min(min), m_max(max) {
}
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const {
......@@ -80,7 +81,7 @@ class KeyframeEdit : public QWidget, public Ui::KeyframeEditor_UI
{
Q_OBJECT
public:
explicit KeyframeEdit(const QDomElement &e, int minFrame, int maxFrame, Timecode tc, int activeKeyframe, QWidget* parent = 0);
explicit KeyframeEdit(const QDomElement &e, int minFrame, int maxFrame, const Timecode &tc, int activeKeyframe, QWidget* parent = 0);
virtual ~KeyframeEdit();
virtual void addParameter(QDomElement e, int activeKeyframe = -1);
const QString getValue(const QString &name);
......
......@@ -36,17 +36,17 @@ const int cursorWidth = 6;
#define SEEK_INACTIVE (-1)
KeyframeHelper::KeyframeHelper(QWidget *parent) :
QWidget(parent)
, frameLength(1)
, m_geom(NULL)
, m_position(0)
, m_scale(0)
, m_movingKeyframe(false)
, m_movingItem()
, m_lineHeight(9)
, m_drag(false)
, m_hoverKeyframe(-1)
, m_seekPosition(SEEK_INACTIVE)
QWidget(parent)
, frameLength(1)
, m_geom(NULL)
, m_position(0)
, m_scale(0)
, m_movingKeyframe(false)
, m_movingItem()
, m_lineHeight(9)
, m_drag(false)
, m_hoverKeyframe(-1)
, m_seekPosition(SEEK_INACTIVE)
{
setFont(KGlobalSettings::toolBarFont());
setMouseTracking(true);
......@@ -62,8 +62,8 @@ void KeyframeHelper::mousePressEvent(QMouseEvent * event)
{
m_hoverKeyframe = -1;
if (event->button() != Qt::LeftButton) {
QWidget::mousePressEvent(event);
return;
QWidget::mousePressEvent(event);
return;
}
int xPos = event->x() - margin;
if (m_geom != NULL && (event->y() < m_lineHeight)) {
......@@ -86,7 +86,7 @@ void KeyframeHelper::mousePressEvent(QMouseEvent * event)
}
for (int i = 0; i < m_extraGeometries.count(); ++i) {
if (m_extraGeometries.at(i)->next_key(item, mousePos) == 0) {
Mlt::GeometryItem *item2 = new Mlt::GeometryItem();
Mlt::GeometryItem *item2 = new Mlt::GeometryItem();
item2->x(item.x());
item2->frame(item.frame());
m_extraMovingItems.append(item2);
......@@ -102,13 +102,13 @@ void KeyframeHelper::mousePressEvent(QMouseEvent * event)
}
}
if (event->y() >= m_lineHeight && event->y() < height()) {
int seekRequest = xPos / m_scale;
m_drag = true;
if (seekRequest != m_position) {
m_seekPosition = seekRequest;
emit requestSeek(m_seekPosition);
update();
}
int seekRequest = xPos / m_scale;
m_drag = true;
if (seekRequest != m_position) {
m_seekPosition = seekRequest;
emit requestSeek(m_seekPosition);
update();
}
}
}
......@@ -156,7 +156,7 @@ void KeyframeHelper::mouseMoveEvent(QMouseEvent * event)
update();
}
event->accept();
return;
return;
}
if (m_movingKeyframe) {
if (!m_dragStart.isNull()) {
......@@ -298,7 +298,7 @@ void KeyframeHelper::paintEvent(QPaintEvent *e)
// draw pointer
if (m_seekPosition != SEEK_INACTIVE) {
p.fillRect(margin + m_seekPosition * m_scale - 1, 0, 3, height(), palette().dark());
p.fillRect(margin + m_seekPosition * m_scale - 1, 0, 3, height(), palette().dark());
}
QPolygon pa(3);
const int cursor = margin + m_position * m_scale;
......@@ -319,7 +319,7 @@ void KeyframeHelper::setValue(const int pos)
{
if (pos == m_position || m_geom == NULL) return;
if (pos == m_seekPosition) {
m_seekPosition = SEEK_INACTIVE;
m_seekPosition = SEEK_INACTIVE;
}
m_position = pos;
update();
......
......@@ -106,7 +106,7 @@ QPixmap KThumb::getImage(const KUrl& url, int width, int height)
return getImage(url, 0, width, height);
}
void KThumb::extractImage(QList <int>frames)
void KThumb::extractImage(const QList<int> &frames)
{
if (!KdenliveSettings::videothumbnails() || m_producer == NULL) return;
m_clipManager->slotRequestThumbs(m_id, frames);
......@@ -196,7 +196,7 @@ QImage KThumb::getFrame(Mlt::Producer *producer, int framepos, int frameWidth, i
frame->set("rescale.interp", "nearest");
frame->set("deinterlace_method", "onefield");
frame->set("top_field_first", -1 );
QImage p = getFrame(frame, frameWidth, displayWidth, height);
const QImage p = getFrame(frame, frameWidth, displayWidth, height);
delete frame;
return p;
}
......@@ -246,7 +246,7 @@ QImage KThumb::getFrame(Mlt::Frame *frame, int frameWidth, int displayWidth, int
}
//static
uint KThumb::imageVariance(QImage image )
uint KThumb::imageVariance(const QImage &image )
{
uint delta = 0;
uint avg = 0;
......@@ -359,7 +359,7 @@ void KThumb::slotCreateAudioThumbs()
}
#if KDE_IS_VERSION(4,5,0)
void KThumb::queryIntraThumbs(QList <int> missingFrames)
void KThumb::queryIntraThumbs(const QList <int> &missingFrames)
{
foreach (int i, missingFrames) {
if (!m_intraFramesQueue.contains(i)) m_intraFramesQueue.append(i);
......
......@@ -59,11 +59,11 @@ public:
bool hasProducer() const;
void clearProducer();
void updateThumbUrl(const QString &hash);
void extractImage(QList <int> frames);
void extractImage(const QList<int> &frames);
QImage extractImage(int frame, int width, int height);
#if KDE_IS_VERSION(4,5,0)
/** @brief Request thumbnails for the frame range. */
void queryIntraThumbs(QList <int> missingFrames);
void queryIntraThumbs(const QList <int> &missingFrames);
/** @brief Query cached thumbnail. */
QImage findCachedThumb(const QString &path);
#endif
......@@ -85,7 +85,7 @@ public:
/** @brief Calculates image variance, useful to know if a thumbnail is interesting.
* @return an integer between 0 and 100. 0 means no variance, eg. black image while bigger values mean contrasted image
* */
static uint imageVariance(QImage image);
static uint imageVariance(const QImage &image);
private slots:
#if KDE_IS_VERSION(4,5,0)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment