Commit e6dc4cb3 authored by Laurent Montel's avatar Laurent Montel

use constFirst

parent 7f56a6f0
......@@ -176,7 +176,7 @@ bool MyTreeView::performDrag()
}
QDrag *drag = new QDrag(this);
drag->setMimeData(model()->mimeData(indexes));
QModelIndex ix = indexes.first();
QModelIndex ix = indexes.constFirst();
if (ix.isValid()) {
QIcon icon = ix.data(AbstractProjectItem::DataThumbnail).value<QIcon>();
QPixmap pix = icon.pixmap(iconSize());
......@@ -936,7 +936,7 @@ const QStringList Bin::getFolderInfo(const QModelIndex &selectedIx)
folderInfo << QString();
return folderInfo;
}
QModelIndex ix = indexes.first();
QModelIndex ix = indexes.constFirst();
if (ix.isValid() && (m_proxyModel->selectionModel()->isSelected(ix) || selectedIx.isValid())) {
AbstractProjectItem *currentItem = static_cast<AbstractProjectItem *>(m_proxyModel->mapToSource(ix).internalPointer());
while (currentItem->itemType() != AbstractProjectItem::FolderItem) {
......@@ -2808,7 +2808,7 @@ void Bin::droppedUrls(const QList<QUrl> &urls, const QStringList &folderInfo)
current = m_proxyModel->mapToSource(m_proxyModel->selectionModel()->currentIndex());
} else {
// get index for folder
current = getIndexForId(folderInfo.first(), true);
current = getIndexForId(folderInfo.constFirst(), true);
}
slotItemDropped(urls, current);
}
......@@ -3409,7 +3409,7 @@ void Bin::slotLoadClipMarkers(const QString &id)
QStringList selection = fd->selectedFiles();
QString url;
if (!selection.isEmpty()) {
url = selection.first();
url = selection.constFirst();
}
//QUrl url = KFileDialog::getOpenUrl(QUrl("kfiledialog:///projectfolder"), "text/plain", this, i18n("Load marker file"));
......@@ -3502,7 +3502,7 @@ void Bin::slotSaveClipMarkers(const QString &id)
QStringList selection = fd->selectedFiles();
QString url;
if (!selection.isEmpty()) {
url = selection.first();
url = selection.constFirst();
}
//QString url = KFileDialog::getSaveFileName(QUrl("kfiledialog:///projectfolder"), "text/plain", this, i18n("Save markers"));
if (url.isEmpty()) {
......@@ -4009,7 +4009,7 @@ void Bin::saveZone(const QStringList &info, const QDir &dir)
if (info.size() != 3) {
return;
}
ProjectClip *clip = getBinClip(info.first());
ProjectClip *clip = getBinClip(info.constFirst());
if (clip && clip->controller()) {
QPoint zone(info.at(1).toInt(), info.at(2).toInt());
clip->controller()->saveZone(zone, dir);
......
......@@ -170,7 +170,7 @@ QUrl Generators::getSavedClip(QString clipFolder)
if (fd.exec() != QDialog::Accepted || fd.selectedUrls().isEmpty()) {
return QUrl();
}
QUrl url = fd.selectedUrls().first();
QUrl url = fd.selectedUrls().constFirst();
if (url.isValid()) {
#if KXMLGUI_VERSION_MINOR < 23 && KXMLGUI_VERSION_MAJOR == 5
......
......@@ -550,7 +550,7 @@ void ClipCreationDialog::createClipsCommand(KdenliveDoc *doc, const QStringList
KdenliveSettings::setAutoimagetransparency(c->isChecked());
list = fileWidget->selectedUrls();
if (!list.isEmpty()) {
KRecentDirs::add(QStringLiteral(":KdenliveClipFolder"), list.first().adjusted(QUrl::RemoveFilename).toLocalFile());
KRecentDirs::add(QStringLiteral(":KdenliveClipFolder"), list.constFirst().adjusted(QUrl::RemoveFilename).toLocalFile());
}
if (b->isChecked() && list.count() == 1) {
// Check for image sequence
......
......@@ -961,7 +961,7 @@ void RenderWidget::focusFirstVisibleItem(const QString &profile)
if (!profile.isEmpty()) {
QList<QTreeWidgetItem *> items = m_view.formats->findItems(profile, Qt::MatchExactly | Qt::MatchRecursive);
if (!items.isEmpty()) {
item = items.first();
item = items.constFirst();
}
}
if (!item) {
......@@ -1723,7 +1723,7 @@ void RenderWidget::refreshParams()
QStringList qs = item->data(0, BitratesRole).toStringList();
if (qs.count() > 1) {
quality = true;
int qmax = qs.first().toInt();
int qmax = qs.constFirst().toInt();
int qmin = qs.last().toInt();
if (qmax < qmin) {
// always show best quality on right
......@@ -1749,7 +1749,7 @@ void RenderWidget::refreshParams()
QStringList qs = item->data(0, AudioBitratesRole).toStringList();
if (qs.count() > 1) {
quality = true;
int qmax = qs.first().toInt();
int qmax = qs.constFirst().toInt();
int qmin = qs.last().toInt();
if (qmax < qmin) {
m_view.audio->setRange(qmax, qmin);
......
......@@ -221,8 +221,8 @@ void CollapsibleEffect::slotCreateRegion()
QPointer<QFileDialog> d = new QFileDialog(QApplication::activeWindow(), QString(), clipFolder, dialogFilter);
d->setFileMode(QFileDialog::ExistingFile);
if (d->exec() == QDialog::Accepted && !d->selectedUrls().isEmpty()) {
KRecentDirs::add(QStringLiteral(":KdenliveClipFolder"), d->selectedUrls().first().adjusted(QUrl::RemoveFilename).toLocalFile());
emit createRegion(effectIndex(), d->selectedUrls().first());
KRecentDirs::add(QStringLiteral(":KdenliveClipFolder"), d->selectedUrls().constFirst().adjusted(QUrl::RemoveFilename).toLocalFile());
emit createRegion(effectIndex(), d->selectedUrls().constFirst());
}
delete d;
}
......
......@@ -375,7 +375,7 @@ void CollapsibleGroup::dropEvent(QDropEvent *event)
emit moveEffect(pastedEffectIndexes, currentEffectIndexes.last(), pasteInfo.groupIndex, pasteInfo.groupName);
} else {
// Group moved before current one
emit moveEffect(pastedEffectIndexes, currentEffectIndexes.first(), pasteInfo.groupIndex, pasteInfo.groupName);
emit moveEffect(pastedEffectIndexes, currentEffectIndexes.constFirst(), pasteInfo.groupIndex, pasteInfo.groupName);
}
event->setDropAction(Qt::MoveAction);
event->accept();
......
......@@ -864,7 +864,7 @@ void EffectStackView2::slotAddEffect(const QDomElement &effect)
void EffectStackView2::slotMoveEffectUp(const QList<int> &indexes, bool up)
{
if (up && indexes.first() <= 1) {
if (up && indexes.constFirst() <= 1) {
return;
}
if (!up && indexes.last() >= m_currentEffectList.count()) {
......@@ -872,7 +872,7 @@ void EffectStackView2::slotMoveEffectUp(const QList<int> &indexes, bool up)
}
int endPos;
if (up) {
endPos = getPreviousIndex(indexes.first());
endPos = getPreviousIndex(indexes.constFirst());
} else {
endPos = getNextIndex(indexes.last());
}
......
......@@ -606,7 +606,7 @@ void GraphicsSceneRectMove::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *e)
}
int ix = 1;
QGraphicsItem *g = i.first();
QGraphicsItem *g = i.constFirst();
while (!(g->flags() & QGraphicsItem::ItemIsSelectable) && ix < i.count()) {
g = i.at(ix);
ix++;
......@@ -640,7 +640,7 @@ void GraphicsSceneRectMove::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
}
QList<QGraphicsView*> viewlist = views();
if (!viewlist.isEmpty()) {
viewlist.first()->setDragMode(QGraphicsView::RubberBandDrag);
viewlist.constFirst()->setDragMode(QGraphicsView::RubberBandDrag);
}
emit actionFinished();
}
......@@ -651,7 +651,7 @@ void GraphicsSceneRectMove::mousePressEvent(QGraphicsSceneMouseEvent *e)
clearTextSelection();
QList<QGraphicsView*> viewlist = views();
if (!viewlist.isEmpty()) {
viewlist.first()->setDragMode(QGraphicsView::ScrollHandDrag);
viewlist.constFirst()->setDragMode(QGraphicsView::ScrollHandDrag);
m_pan = true;
e->accept();
QGraphicsScene::mousePressEvent(e);
......@@ -670,14 +670,14 @@ void GraphicsSceneRectMove::mousePressEvent(QGraphicsSceneMouseEvent *e)
if (e->modifiers() & Qt::ControlModifier) {
clearTextSelection();
if (!viewlist.isEmpty()) {
viewlist.first()->setDragMode(QGraphicsView::ScrollHandDrag);
viewlist.constFirst()->setDragMode(QGraphicsView::ScrollHandDrag);
e->ignore();
//QGraphicsScene::mousePressEvent(e);
return;
}
} else {
if (!viewlist.isEmpty()) {
viewlist.first()->setRubberBandSelectionMode(Qt::IntersectsItemShape);
viewlist.constFirst()->setRubberBandSelectionMode(Qt::IntersectsItemShape);
}
}
bool alreadySelected = false;
......@@ -795,7 +795,7 @@ void GraphicsSceneRectMove::mouseMoveEvent(QGraphicsSceneMouseEvent *e)
e->ignore();
return;
}
QGraphicsView *view = viewlist.first();
QGraphicsView *view = viewlist.constFirst();
if (m_pan) {
QPoint diff = e->lastScreenPos() - e->screenPos();
view->horizontalScrollBar()->setValue(view->horizontalScrollBar()->value() + diff.x());
......
......@@ -144,7 +144,7 @@ public:
{
int intervals = m_intervals = a.size() - 1;
int i;
m_begin = a.first().x();
m_begin = a.constFirst().x();
m_end = a.last().x();
m_a.clear();
......
......@@ -1865,7 +1865,7 @@ void MainWindow::addTimelineClip(const QString &url)
if (pCore->projectManager()->current()) {
QStringList ids = pCore->binController()->getBinIdsByResource(QFileInfo(url));
if (!ids.isEmpty()) {
pCore->bin()->selectClipById(ids.first());
pCore->bin()->selectClipById(ids.constFirst());
slotInsertClipInsert();
}
}
......
......@@ -1036,7 +1036,7 @@ void Monitor::slotExtractCurrentFrame(QString frameName, bool addToProject)
fs->selectFile(frameName);
if (fs->exec()) {
if (!fs->selectedFiles().isEmpty()) {
QUrl savePath = fs->selectedUrls().first();
QUrl savePath = fs->selectedUrls().constFirst();
if (QFile::exists(savePath.toLocalFile()) && KMessageBox::warningYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", savePath.toLocalFile())) == KMessageBox::No) {
delete fs;
slotExtractCurrentFrame(savePath.fileName(), addToProject);
......
......@@ -270,7 +270,7 @@ bool OnMonitorCornersItem::getView()
}
if (scene() && !scene()->views().isEmpty()) {
m_view = scene()->views().first();
m_view = scene()->views().constFirst();
return true;
} else {
return false;
......
......@@ -199,7 +199,7 @@ bool OnMonitorPathItem::getView()
}
if (scene() && !scene()->views().isEmpty()) {
m_view = scene()->views().first();
m_view = scene()->views().constFirst();
return true;
} else {
return false;
......
......@@ -290,7 +290,7 @@ bool OnMonitorRectItem::getView()
}
if (scene() && !scene()->views().isEmpty()) {
m_view = scene()->views().first();
m_view = scene()->views().constFirst();
return true;
} else {
return false;
......
......@@ -39,7 +39,7 @@ BPointItem::BPointItem(const BPoint &point, QGraphicsItem *parent) :
m_point.h2 = mapFromScene(point.h2);
m_point.handlesLinked = false;
m_view = scene()->views().first();
m_view = scene()->views().constFirst();
}
BPoint BPointItem::getPoint() const
......
......@@ -186,7 +186,7 @@ void SplineItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
if (close || event->button() == Qt::RightButton) {
if (items.count() > 1) {
// close the spline
BPointItem *i1 = qgraphicsitem_cast<BPointItem *>(items.first());
BPointItem *i1 = qgraphicsitem_cast<BPointItem *>(items.constFirst());
BPointItem *i2 = qgraphicsitem_cast<BPointItem *>(items.last());
BPoint p1 = i1->getPoint();
BPoint p2 = i2->getPoint();
......
......@@ -45,14 +45,14 @@ ClipStabilize::ClipStabilize(const QStringList &urls, const QString &filterName,
setStyleSheet(stylesheet);
if (m_urls.count() == 1) {
QString newFile = m_urls.first();
QString newFile = m_urls.constFirst();
newFile.append(QStringLiteral(".mlt"));
dest_url->setMode(KFile::File);
dest_url->setUrl(QUrl(newFile));
} else {
label_dest->setText(i18n("Destination folder"));
dest_url->setMode(KFile::Directory | KFile::ExistingOnly);
dest_url->setUrl(QUrl(m_urls.first()).adjusted(QUrl::RemoveFilename));
dest_url->setUrl(QUrl(m_urls.constFirst()).adjusted(QUrl::RemoveFilename));
}
if (m_filtername == QLatin1String("vidstab") || m_filtername == QLatin1String("videostab2")) {
......
......@@ -46,7 +46,7 @@ ClipTranscode::ClipTranscode(const QStringList &urls, const QString &params, con
auto_add->setChecked(KdenliveSettings::add_new_clip());
if (m_urls.count() == 1) {
QString fileName = m_urls.first();
QString fileName = m_urls.constFirst();
source_url->setUrl(QUrl::fromLocalFile(fileName));
dest_url->setMode(KFile::File);
#if KXMLGUI_VERSION_MINOR > 32 || KXMLGUI_VERSION_MAJOR > 5
......@@ -64,7 +64,7 @@ ClipTranscode::ClipTranscode(const QStringList &urls, const QString &params, con
source_url->setHidden(true);
label_dest->setText(i18n("Destination folder"));
dest_url->setMode(KFile::Directory);
dest_url->setUrl(QUrl::fromLocalFile(m_urls.first()).adjusted(QUrl::RemoveFilename));
dest_url->setUrl(QUrl::fromLocalFile(m_urls.constFirst()).adjusted(QUrl::RemoveFilename));
dest_url->setMode(KFile::Directory | KFile::ExistingOnly);
for (int i = 0; i < m_urls.count(); ++i) {
urls_list->addItem(m_urls.at(i));
......
......@@ -395,7 +395,7 @@ QHash<ProjectClip *, AbstractClipJob *> CutClipJob::prepareTranscodeJob(double f
d->setWindowTitle(i18n("Transcoding"));
ui.extra_params->setMaximumHeight(QFontMetrics(qApp->font()).lineSpacing() * 5);
if (clips.count() == 1) {
ui.file_url->setUrl(QUrl(destinations.first()));
ui.file_url->setUrl(QUrl(destinations.constFirst()));
} else {
ui.destination_label->setVisible(false);
ui.file_url->setVisible(false);
......
......@@ -65,7 +65,7 @@ QHash<ProjectClip *, AbstractClipJob *> FilterJob::prepareJob(const QList<Projec
for (int i = 0; i < clips.count(); i++) {
sources << clips.at(i)->url();
}
QString filterName = parameters.first();
QString filterName = parameters.constFirst();
if (filterName == QLatin1String("timewarp")) {
QMap<QString, QString> producerParams = QMap<QString, QString> ();
QMap<QString, QString> filterParams = QMap<QString, QString> ();
......@@ -77,7 +77,7 @@ QHash<ProjectClip *, AbstractClipJob *> FilterJob::prepareJob(const QList<Projec
// Reverse clip using project profile since playlists can only be included with same fps
// extraParams.insert(QStringLiteral("producer_profile"), QStringLiteral("1"));
bool multipleSelection = clips.count() > 1;
QPointer<ClipSpeed> d = new ClipSpeed(clips.count() == 1 ? QUrl::fromLocalFile(sources.first() + QStringLiteral(".mlt")) : QUrl::fromLocalFile(sources.first()).adjusted(QUrl::RemoveFilename), multipleSelection, QApplication::activeWindow());
QPointer<ClipSpeed> d = new ClipSpeed(clips.count() == 1 ? QUrl::fromLocalFile(sources.constFirst() + QStringLiteral(".mlt")) : QUrl::fromLocalFile(sources.constFirst()).adjusted(QUrl::RemoveFilename), multipleSelection, QApplication::activeWindow());
if (d->exec() == QDialog::Accepted) {
QLocale locale;
QString speedString = QStringLiteral("timewarp:%1:").arg(locale.toString(d->speed() / 100));
......@@ -202,7 +202,7 @@ QHash<ProjectClip *, AbstractClipJob *> FilterJob::prepareJob(const QList<Projec
// vidstab
int out = 100000;
if (clips.count() == 1) {
out = clips.first()->duration().frames(KdenliveSettings::project_fps());
out = clips.constFirst()->duration().frames(KdenliveSettings::project_fps());
}
QPointer<ClipStabilize> d = new ClipStabilize(sources, filterName, out);
if (d->exec() == QDialog::Accepted) {
......
......@@ -264,7 +264,7 @@ void JobManager::prepareJobs(const QList<ProjectClip *> &clips, double fps, Abst
if (jobType == AbstractClipJob::TRANSCODEJOB) {
jobs = CutClipJob::prepareTranscodeJob(fps, matching, params);
} else if (jobType == AbstractClipJob::CUTJOB) {
ProjectClip *clip = matching.first();
ProjectClip *clip = matching.constFirst();
double originalFps = clip->getOriginalFps();
jobs = CutClipJob::prepareCutClipJob(fps, originalFps, clip);
} else if (jobType == AbstractClipJob::ANALYSECLIPJOB) {
......
......@@ -160,9 +160,9 @@ AddMarkerCommand::AddMarkerCommand(ProjectClip *clip, QList<CommentedTime> &oldM
if (m_newMarkers.isEmpty()) {
return;
}
if (m_newMarkers.first().markerType() < 0) {
if (m_newMarkers.constFirst().markerType() < 0) {
setText(i18n("Delete marker"));
} else if (m_oldMarkers.first().comment().isEmpty()) {
} else if (m_oldMarkers.constFirst().comment().isEmpty()) {
setText(i18n("Add marker"));
} else {
setText(i18n("Edit marker"));
......
......@@ -347,7 +347,7 @@ bool ProjectManager::saveFileAs()
if (fd.exec() != QDialog::Accepted || fd.selectedFiles().isEmpty()) {
return false;
}
QString outputFile = fd.selectedFiles().first();
QString outputFile = fd.selectedFiles().constFirst();
#if KXMLGUI_VERSION_MINOR < 23 && KXMLGUI_VERSION_MAJOR == 5
// Since Plasma 5.7 (release at same time as KF 5.23,
......
......@@ -1732,7 +1732,7 @@ void ClipItem::dropEvent(QGraphicsSceneDragDropEvent *event)
m_selectionTimer.stop();
}
event->acceptProposedAction();
CustomTrackView *view = static_cast<CustomTrackView *>(scene()->views().first());
CustomTrackView *view = static_cast<CustomTrackView *>(scene()->views().constFirst());
if (view) {
QString geometry = QString::fromUtf8(event->mimeData()->data(QStringLiteral("kdenlive/geometry")));
view->dropClipGeometry(this, geometry);
......@@ -1759,7 +1759,7 @@ void ClipItem::dropEvent(QGraphicsSceneDragDropEvent *event)
// single effect dropped
e.removeAttribute(QStringLiteral("kdenlive_ix"));
}
CustomTrackView *view = static_cast<CustomTrackView *>(scene()->views().first());
CustomTrackView *view = static_cast<CustomTrackView *>(scene()->views().constFirst());
if (view) {
if (transitionDrop) {
view->slotDropTransition(this, e, event->scenePos());
......
......@@ -682,7 +682,7 @@ QList<int> CustomRuler::addChunks(QList<int> chunks, bool add)
std::sort(m_renderingPreviews.begin(), m_renderingPreviews.end());
std::sort(m_dirtyRenderingPreviews.begin(), m_dirtyRenderingPreviews.end());
if (!m_hidePreview) {
update(chunks.first() * m_factor - offset(), MAX_HEIGHT, (chunks.last() - chunks.first()) * KdenliveSettings::timelinechunks() * m_factor + 1, PREVIEW_SIZE);
update(chunks.constFirst() * m_factor - offset(), MAX_HEIGHT, (chunks.last() - chunks.constFirst()) * KdenliveSettings::timelinechunks() * m_factor + 1, PREVIEW_SIZE);
}
return toProcess;
}
......
......@@ -471,7 +471,7 @@ void PreviewManager::slotProcessDirtyChunks()
return;
}
invalidatePreviews(chunks);
m_ruler->updatePreviewDisplay(chunks.first(), chunks.last());
m_ruler->updatePreviewDisplay(chunks.constFirst(), chunks.last());
if (KdenliveSettings::autopreview()) {
m_previewTimer.start();
}
......@@ -544,7 +544,7 @@ void PreviewManager::reloadChunks(const QList<int> &chunks)
}
}
}
m_ruler->updatePreviewDisplay(chunks.first(), chunks.last());
m_ruler->updatePreviewDisplay(chunks.constFirst(), chunks.last());
m_previewTrack->consolidate_blanks();
m_tractor->unlock();
}
......
......@@ -550,7 +550,7 @@ void Transition::dropEvent(QGraphicsSceneDragDropEvent *event)
}
QString geometry = QString::fromUtf8(event->mimeData()->data(QStringLiteral("kdenlive/geometry")));
event->acceptProposedAction();
CustomTrackView *view = static_cast<CustomTrackView *>(scene()->views().first());
CustomTrackView *view = static_cast<CustomTrackView *>(scene()->views().constFirst());
if (view) {
view->dropTransitionGeometry(this, geometry);
}
......
......@@ -116,7 +116,7 @@ QMap<QString, QString> TransitionHandler::getTransitionParamsFromXml(const QDomE
// Something is wrong
map[name] = QString();
} else {
map[name] = lumas.first();
map[name] = lumas.constFirst();
}
}
} else {
......
......@@ -1928,7 +1928,7 @@ void TitleWidget::saveTitle(QUrl url)
//fs->setConfirmOverwrite(true);
//fs->setKeepLocation(true);
if (fs->exec() && !fs->selectedUrls().isEmpty()) {
url = fs->selectedUrls().first();
url = fs->selectedUrls().constFirst();
}
delete fs;
}
......
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