From 5990bf5ea2a8bd54c9c346de6209034fdded175f Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Sun, 6 Jul 2008 22:35:23 +0000 Subject: [PATCH] Added "find next" feature svn path=/branches/KDE4/; revision=2292 --- src/customtrackview.cpp | 28 +++++++++++++++++++++++----- src/customtrackview.h | 2 ++ src/kdenliveui.rc | 3 ++- src/mainwindow.cpp | 27 +++++++++++++++++++++++++-- src/mainwindow.h | 2 ++ 5 files changed, 54 insertions(+), 8 deletions(-) diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index b42089cb..04eaba36 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -69,7 +69,7 @@ // const int duration = animate ? 1500 : 1; CustomTrackView::CustomTrackView(KdenliveDoc *doc, QGraphicsScene * projectscene, QWidget *parent) - : QGraphicsView(projectscene, parent), m_cursorPos(0), m_dropItem(NULL), m_cursorLine(NULL), m_operationMode(NONE), m_dragItem(NULL), m_visualTip(NULL), m_moveOpMode(NONE), m_animation(NULL), m_projectDuration(0), m_scale(1.0), m_clickPoint(QPoint()), m_document(doc), m_autoScroll(KdenliveSettings::autoscroll()), m_tracksHeight(KdenliveSettings::trackheight()), m_tool(SELECTTOOL), m_dragGuide(NULL) { + : QGraphicsView(projectscene, parent), m_cursorPos(0), m_dropItem(NULL), m_cursorLine(NULL), m_operationMode(NONE), m_dragItem(NULL), m_visualTip(NULL), m_moveOpMode(NONE), m_animation(NULL), m_projectDuration(0), m_scale(1.0), m_clickPoint(QPoint()), m_document(doc), m_autoScroll(KdenliveSettings::autoscroll()), m_tracksHeight(KdenliveSettings::trackheight()), m_tool(SELECTTOOL), m_dragGuide(NULL), m_findIndex(0) { if (doc) m_commandStack = doc->commandStack(); else m_commandStack == NULL; setMouseTracking(true); @@ -1711,15 +1711,33 @@ bool CustomTrackView::findString(const QString &text) { marker = m_searchPoints.at(i).comment(); if (marker.contains(text, Qt::CaseInsensitive)) { setCursorPos(m_searchPoints.at(i).time().frames(m_document->fps()), true); - int vert = verticalScrollBar()->value(); - int hor = cursorPos(); - ensureVisible(hor, vert + 10, 2, 2, 50, 0); + int vert = verticalScrollBar()->value(); + int hor = cursorPos(); + ensureVisible(hor, vert + 10, 2, 2, 50, 0); + m_findIndex = i; return true; } } return false; } +bool CustomTrackView::findNextString(const QString &text) { + QString marker; + for (int i = m_findIndex + 1; i < m_searchPoints.size(); ++i) { + marker = m_searchPoints.at(i).comment(); + if (marker.contains(text, Qt::CaseInsensitive)) { + setCursorPos(m_searchPoints.at(i).time().frames(m_document->fps()), true); + int vert = verticalScrollBar()->value(); + int hor = cursorPos(); + ensureVisible(hor, vert + 10, 2, 2, 50, 0); + m_findIndex = i; + return true; + } + } + m_findIndex = -1; + return false; +} + void CustomTrackView::initSearchStrings() { m_searchPoints.clear(); @@ -1739,7 +1757,7 @@ void CustomTrackView::initSearchStrings() { void CustomTrackView::clearSearchStrings() { m_searchPoints.clear(); - + m_findIndex = 0; } /* diff --git a/src/customtrackview.h b/src/customtrackview.h index df2f07d0..2b85e14c 100644 --- a/src/customtrackview.h +++ b/src/customtrackview.h @@ -86,6 +86,7 @@ public: QDomElement xmlInfo(); void editKeyFrame(const GenTime pos, const int track, const int index, const QString keyframes); bool findString(const QString &text); + bool findNextString(const QString &text); void initSearchStrings(); void clearSearchStrings(); @@ -162,6 +163,7 @@ private: QMenu *m_timelineContextTransitionMenu; QList m_tracksList; QList m_searchStrings; + int m_findIndex; PROJECTTOOL m_tool; QCursor m_razorCursor; /** Get the index of the video track that is just below current track */ diff --git a/src/kdenliveui.rc b/src/kdenliveui.rc index b2d06771..0aecf894 100644 --- a/src/kdenliveui.rc +++ b/src/kdenliveui.rc @@ -1,6 +1,6 @@ - + Extra Toolbar @@ -9,6 +9,7 @@ + Project diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index c9fde233..91e8b1f4 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -505,6 +505,12 @@ void MainWindow::setupActions() { connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind())); m_projectSearch->setShortcut(Qt::Key_Slash); + m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this); + actionCollection()->addAction("project_find_next", m_projectSearchNext); + connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext())); + m_projectSearchNext->setShortcut(Qt::Key_F3); + m_projectSearchNext->setEnabled(false); + KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Profiles"), this); actionCollection()->addAction("manage_profiles", profilesAction); connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles())); @@ -1192,13 +1198,29 @@ void MainWindow::slotFind() { qApp->installEventFilter(this); } +void MainWindow::slotFindNext() { + TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget(); + if (currentTab->projectView()->findNextString(m_findString)) { + statusBar()->showMessage(i18n("Found : %1", m_findString)); + } else { + statusBar()->showMessage(i18n("Reached end of project")); + } + m_findTimer.start(4000); +} + void MainWindow::findAhead() { TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget(); - if (currentTab->projectView()->findString(m_findString)) statusBar()->showMessage(i18n("Found : %1", m_findString)); - else statusBar()->showMessage(i18n("Not found : %1", m_findString)); + if (currentTab->projectView()->findString(m_findString)) { + m_projectSearchNext->setEnabled(true); + statusBar()->showMessage(i18n("Found : %1", m_findString)); + } else { + m_projectSearchNext->setEnabled(false); + statusBar()->showMessage(i18n("Not found : %1", m_findString)); + } } void MainWindow::findTimeout() { + m_projectSearchNext->setEnabled(false); m_findActivated = false; m_findString = QString(); statusBar()->showMessage(i18n("Find stopped"), 3000); @@ -1242,6 +1264,7 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event) { if (m_findActivated) { if (event->type() == QEvent::ShortcutOverride) { QKeyEvent* ke = (QKeyEvent*) event; + if (ke->text().trimmed().isEmpty()) return false; ke->accept(); return true; } else return false; diff --git a/src/mainwindow.h b/src/mainwindow.h index 2ec2e641..7ef6bca9 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -121,6 +121,7 @@ private: KRecentFilesAction *m_fileOpenRecent; KAction *m_projectSearch; + KAction *m_projectSearchNext; QAction *m_buttonAudioThumbs; QAction *m_buttonVideoThumbs; @@ -201,6 +202,7 @@ private slots: void slotSnapRewind(); void slotFind(); void findTimeout(); + void slotFindNext(); }; #endif -- 2.39.2