]> git.sesse.net Git - kdenlive/commitdiff
Added "find next" feature
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 6 Jul 2008 22:35:23 +0000 (22:35 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 6 Jul 2008 22:35:23 +0000 (22:35 +0000)
svn path=/branches/KDE4/; revision=2292

src/customtrackview.cpp
src/customtrackview.h
src/kdenliveui.rc
src/mainwindow.cpp
src/mainwindow.h

index b42089cb6158324e4a77d984ab4526c83f122269..04eaba36cafbe9ce9e1d706b60f7305dfdb2b424 100644 (file)
@@ -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;
 }
 
 /*
index df2f07d0a0ed910aa78089ec4919837d1ad365aa..2b85e14ce708ddfb187301fb573e99fceab23e9d 100644 (file)
@@ -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 <TrackInfo> m_tracksList;
     QList <CommentedTime> m_searchStrings;
+    int m_findIndex;
     PROJECTTOOL m_tool;
     QCursor m_razorCursor;
     /** Get the index of the video track that is just below current track */
index b2d06771aa814888d1668732ef3db9902cff20d1..0aecf89420832dce54016c44a761bfa6ba33fb08 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<gui name="kdenlive" version="19">
+<gui name="kdenlive" version="20">
   <ToolBar name="extraToolBar" >
     <text>Extra Toolbar</text>
        <Action name="project_render" />
@@ -9,6 +9,7 @@
   <MenuBar>
     <Menu name="edit" >
       <Action name="project_find" />
+      <Action name="project_find_next" />
     </Menu>
     
     <Menu name="project" ><text>Project</text>
index c9fde2332d392bbdfb1c090866dc658d98ba89fa..91e8b1f4097718794de527bc34dbeb945c193fab 100644 (file)
@@ -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;
index 2ec2e641117fd138e09f3d155eaadd98745f50ea..7ef6bca9cbf6bd412be82309917dfd38eb1dc782 100644 (file)
@@ -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