[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    =?utf-8?q?=5Bcalligra/libs-kofind=5Frefactor-ahiemstra=5D_words/?=
From:       Arjen Hiemstra <ahiemstra () heimr ! nl>
Date:       2011-03-17 17:52:08
Message-ID: 20110317175208.1D0B7A60B4 () git ! kde ! org
[Download RAW message or body]

Git commit 6840fe817eddb8a80854ae4c3ff4a103626aeb4c by Arjen Hiemstra.
Committed on 15/03/2011 at 12:38.
Pushed by ahiemstra into branch 'libs-kofind_refactor-ahiemstra'.

Add initial support for a search bar and the new searching code to Words.

M  +31   -2    words/part/KWView.cpp     
M  +5    -0    words/part/KWView.h     

http://commits.kde.org/calligra/6840fe817eddb8a80854ae4c3ff4a103626aeb4c

diff --git a/words/part/KWView.cpp b/words/part/KWView.cpp
index 539e6b1..6547d60 100644
--- a/words/part/KWView.cpp
+++ b/words/part/KWView.cpp
@@ -98,6 +98,9 @@
 #include <kstatusbar.h>
 #include <kfiledialog.h>
 #include <kmessagebox.h>
+#include <KoFindText.h>
+#include <KoFindDialog.h>
+#include <KoFindToolbar.h>
 
 static KWFrame *frameForShape(KoShape *shape)
 {
@@ -130,7 +133,7 @@ KWView::KWView(const QString &viewMode, KWDocument *document, \
QWidget *parent)  m_canvas = m_gui->canvas();
     setFocusProxy(m_canvas);
 
-    QHBoxLayout *layout = new QHBoxLayout(this);
+    QVBoxLayout *layout = new QVBoxLayout(this);
     layout->setMargin(0);
     layout->addWidget(m_gui);
 
@@ -143,7 +146,17 @@ KWView::KWView(const QString &viewMode, KWDocument *document, \
QWidget *parent)  
     connect(m_canvas->shapeManager()->selection(), SIGNAL(selectionChanged()), this, \
SLOT(selectionChanged()));  
-    new KoFind(this, m_canvas->resourceManager(), actionCollection());
+    //new KoFind(this, m_canvas->resourceManager(), actionCollection());
+
+    m_find = new KoFindText(m_canvas->resourceManager(), this);
+    //KoFindDialog *dialog = new KoFindDialog(m_find, actionCollection(), this);
+    KoFindToolbar *toolbar = new KoFindToolbar(m_find, actionCollection(), this);
+    toolbar->setVisible(false);
+    connect(m_find, SIGNAL(matchFound(KoFindMatch)), this, \
SLOT(findMatchFound(KoFindMatch))); +    //connect(m_find, SIGNAL(noMatchFound()), \
this, SLOT(findNoMatchFound())); +    //connect(m_find, SIGNAL(highlight()), this, \
SLOT(findHighlight())); +
+    layout->addWidget(toolbar);
 
     m_zoomController = new KoZoomController(m_gui->canvasController(), \
&m_zoomHandler, actionCollection(), 0, this);  
@@ -1529,3 +1542,19 @@ void KWView::bringToFront() {
 void KWView::sendToBack() {
     adjustZOrderOfSelectedFrames(canvasBase(), m_document, \
KoShapeReorderCommand::SendToBack);  }
+
+void KWView::findMatchFound(KoFindMatch match)
+{
+    if(!match.isValid() || !match.location().canConvert<QTextCursor>() || \
!match.container().canConvert<QTextDocument*>()) { +        return;
+    }
+
+    QTextCursor cursor = match.location().value<QTextCursor>();
+
+    m_canvas->resourceManager()->setResource(KoText::CurrentTextAnchor, \
cursor.anchor()); +    \
m_canvas->resourceManager()->setResource(KoText::CurrentTextPosition, \
cursor.position()); +
+    m_find->highlightMatch(match);
+
+    m_canvas->updateCanvas(QRectF(QPoint(0,0), m_canvas->size()));
+}
diff --git a/words/part/KWView.h b/words/part/KWView.h
index a8eec16..476a159 100644
--- a/words/part/KWView.h
+++ b/words/part/KWView.h
@@ -27,6 +27,7 @@
 #include <KoView.h>
 #include <KoViewConverter.h>
 #include <KoZoomHandler.h>
+#include <KoFindMatch.h>
 
 #include <QWidget>
 
@@ -37,6 +38,7 @@ class KWGui;
 
 class KoCanvasBase;
 class KoZoomController;
+class KoFindText;
 class KoRdfSemanticItem;
 class KActionMenu;
 
@@ -192,6 +194,8 @@ private slots:
     void goToNextPage();
     /// A semantic item was updated and should have it's text refreshed.
     void semanticObjectViewSiteUpdated(KoRdfSemanticItem *item, const QString \
&xmlid); +    /// A match was found when searching.
+    void findMatchFound(KoFindMatch match);
 
 private:
 
@@ -205,6 +209,7 @@ private:
     KoZoomHandler m_zoomHandler;
     KoZoomController *m_zoomController;
     KWPage m_currentPage;
+    KoFindText *m_find;
 
     KAction *m_actionFormatFrameSet;
     KAction *m_actionInsertFrameBreak;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic