Guest User

Untitled

a guest
Aug 6th, 2018
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.98 KB | None | 0 0
  1. diff --git a/kate/app/kateviewmanager.cpp b/kate/app/kateviewmanager.cpp
  2. index 132a8bf..047a2ac 100644
  3. --- a/kate/app/kateviewmanager.cpp
  4. +++ b/kate/app/kateviewmanager.cpp
  5. @@ -288,6 +288,11 @@ bool KateViewManager::createView ( KTextEditor::Document *doc )
  6.  
  7. // create view, registers its XML gui itself
  8. KTextEditor::View *view = (KTextEditor::View *) doc->createView (activeViewSpace()->stack);
  9. +
  10. + KTextEditor::MultipleFileSearchInterface *iface = qobject_cast<KTextEditor::MultipleFileSearchInterface*>( view );
  11. +
  12. + if ( iface )
  13. + iface->allowMultipleFileSearch();
  14.  
  15. m_viewList.append (view);
  16. m_activeStates[view] = false;
  17. @@ -446,8 +451,23 @@ void KateViewManager::activateView ( KTextEditor::View *view )
  18. createView( view->document() );
  19. return;
  20. }
  21. +
  22. + KTextEditor::View *previousView;
  23. + previousView = activeView();
  24. +
  25. + if ( previousView != 0 )
  26. + {
  27. + disconnect(previousView, SIGNAL(searchReachedBottom()), this, SLOT(searchNextDoc()));
  28. + disconnect(previousView, SIGNAL(searchReachedTop()), this, SLOT(searchPrevDoc()));
  29. + }
  30.  
  31. setActiveView (view);
  32. +
  33. + KTextEditor::MultipleFileSearchInterface *iface = qobject_cast<KTextEditor::MultipleFileSearchInterface*>( view );
  34. +
  35. + connect(view, SIGNAL(searchReachedBottom()), this, SLOT(searchNextDoc()), Qt::UniqueConnection);
  36. + connect(view, SIGNAL(searchReachedTop()), this, SLOT(searchPrevDoc()), Qt::UniqueConnection);
  37. + iface->restoreSearchBar();
  38.  
  39. mainWindow()->setUpdatesEnabled( false );
  40. bool toolbarVisible = mainWindow()->toolBar()->isVisible();
  41. @@ -817,5 +837,37 @@ void KateViewManager::restoreSplitter( const KConfigBase* configBase, const QStr
  42. parent->show();
  43. }
  44.  
  45. +void KateViewManager::searchPrevDoc()
  46. +{
  47. + KTextEditor::View *view;
  48. + int docPos;
  49. + docPos = (KateDocManager::self()->documentList().indexOf(activeView()->document()) - 1);
  50. + if ( docPos == -1 )
  51. + {
  52. + docPos = (KateDocManager::self()->documents() - 1);
  53. + }
  54. + view = activateView(KateDocManager::self()->document(docPos));
  55. + // cursor must be at end of document
  56. + KTextEditor::Cursor cursor;
  57. + cursor = KateDocManager::self()->document(docPos)->documentEnd();
  58. + view->setCursorPosition(cursor);
  59. + view->setSelection(KTextEditor::Range(cursor, cursor));
  60. +}
  61. +
  62. +void KateViewManager::searchNextDoc()
  63. +{
  64. + KTextEditor::View *view;
  65. + int docPos;
  66. + docPos = (KateDocManager::self()->documentList().indexOf(activeView()->document()) + 1);
  67. + if ( docPos == KateDocManager::self()->documents() )
  68. + {
  69. + docPos = 0;
  70. + }
  71. + view = activateView(KateDocManager::self()->document(docPos));
  72. + // cursor must be at beginning of document
  73. + KTextEditor::Cursor cursor;
  74. + view->setCursorPosition(cursor);
  75. + view->setSelection(KTextEditor::Range(cursor, cursor));
  76. +}
  77.  
  78. // kate: space-indent on; indent-width 2; replace-tabs on;
  79. diff --git a/kate/app/kateviewmanager.h b/kate/app/kateviewmanager.h
  80. index cc770be..b1a34a3 100644
  81. --- a/kate/app/kateviewmanager.h
  82. +++ b/kate/app/kateviewmanager.h
  83. @@ -25,9 +25,12 @@
  84. #include "katedocmanager.h"
  85.  
  86.  
  87. +#include <KTextEditor/Cursor>
  88. #include <KTextEditor/View>
  89. #include <KTextEditor/Document>
  90.  
  91. +#include <ktexteditor/multiplefilesearchinterface.h>
  92. +
  93. #include <QPointer>
  94. #include <QList>
  95. #include <QModelIndex>
  96. @@ -107,6 +110,9 @@ class KateViewManager : public QSplitter
  97.  
  98. void activateNextView();
  99. void activatePrevView();
  100. +
  101. + void searchNextDoc();
  102. + void searchPrevDoc();
  103.  
  104. protected:
  105. QPointer<KTextEditor::View> guiMergedView;
  106. @@ -115,6 +121,7 @@ class KateViewManager : public QSplitter
  107. void statChanged ();
  108. void viewChanged ();
  109. void viewCreated (KTextEditor::View *);
  110. + void viewEnableMultipleFileSearch (bool enabled);
  111.  
  112. public:
  113. inline QList<KTextEditor::View*> &viewList ()
  114. diff --git a/ktexteditor/ktexteditor.cpp b/ktexteditor/ktexteditor.cpp
  115. index ddb231a..75d4ee5 100644
  116. --- a/ktexteditor/ktexteditor.cpp
  117. +++ b/ktexteditor/ktexteditor.cpp
  118. @@ -18,6 +18,7 @@
  119. */
  120.  
  121. #include <QtDBus/QtDBus>
  122. +#include <Qt/QtCore>
  123.  
  124. #include "cursor.h"
  125.  
  126. @@ -47,6 +48,7 @@
  127. #include "texthintinterface.h"
  128. #include "variableinterface.h"
  129. #include "containerinterface.h"
  130. +#include "multiplefilesearchinterface.h"
  131.  
  132. #include "annotationinterface.h"
  133. #include "annotationinterface.moc"
  134. @@ -210,6 +212,15 @@ MarkInterface::MarkInterface ()
  135. MarkInterface::~MarkInterface ()
  136. {}
  137.  
  138. +MultipleFileSearchInterface::MultipleFileSearchInterface ()
  139. + : d(new MultipleFileSearchInterfacePrivate())
  140. +{}
  141. +
  142. +MultipleFileSearchInterface::~MultipleFileSearchInterface ()
  143. +{
  144. + delete d;
  145. +}
  146. +
  147. ModificationInterface::ModificationInterface ()
  148. : d(0)
  149. {}
  150. diff --git a/ktexteditor/multiplefilesearchinterface.h b/ktexteditor/multiplefilesearchinterface.h
  151. new file mode 100644
  152. index 0000000..03b9e24
  153. --- /dev/null
  154. +++ b/ktexteditor/multiplefilesearchinterface.h
  155. @@ -0,0 +1,136 @@
  156. +/* This file is part of the KDE project
  157. + Copyright (C) 2010 Andrius da Costa Ribas (andriusmao@gmail.com)
  158. +
  159. + This library is free software; you can redistribute it and/or
  160. + modify it under the terms of the GNU Library General Public
  161. + License as published by the Free Software Foundation; either
  162. + version 2 of the License, or (at your option) any later version.
  163. +
  164. + This library is distributed in the hope that it will be useful,
  165. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  166. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  167. + Library General Public License for more details.
  168. +
  169. + You should have received a copy of the GNU Library General Public License
  170. + along with this library; see the file COPYING.LIB. If not, write to
  171. + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  172. + Boston, MA 02110-1301, USA.
  173. +*/
  174. +
  175. +#ifndef KDELIBS_KTEXTEDITOR_MULTIPLEFILESEARCHINTERFACE_H
  176. +#define KDELIBS_KTEXTEDITOR_MULTIPLEFILESEARCHINTERFACE_H
  177. +
  178. +#include <ktexteditor/ktexteditor_export.h>
  179. +#include <ktexteditor/range.h>
  180. +#include <ktexteditor/multiplefilesearchinterface_p.h>
  181. +
  182. +class QString;
  183. +
  184. +namespace KTextEditor
  185. +{
  186. +
  187. +class View;
  188. +class MultipleFileSearchInterfacePrivate;
  189. +
  190. +/**
  191. + * \brief Multiple file search interface extension for the Document.
  192. + *
  193. + * \ingroup kte_group_doc_extensions
  194. + *
  195. + * \section msearchiface_intro Introduction
  196. + *
  197. + * The MultipleSearchInterface is an extension of SearchInterface for multiple documents
  198. + * apps such as kate, allowing the user to search throuch those multiple documents
  199. + *
  200. + * \section msearchiface_access Accessing the SearchInterface
  201. + *
  202. + * The MultipleSearchInterface is supposed to be an extension interface for a
  203. + * View, in a similar way of SearchInterface for a Document,
  204. + * i.e. the View inherits the interface \e provided that the
  205. + * KTextEditor library in use implements the interface. Use qobject_cast to access
  206. + * the interface:
  207. + * \code
  208. + * // view is of type KTextEditor::View*
  209. + * KTextEditor::MultipleFileSearchInterface *iface =
  210. + * qobject_cast<KTextEditor::MultipleFileSearchInterface*>( view );
  211. + *
  212. + * if( iface ) {
  213. + * // the implementation supports the interface
  214. + * // do stuff
  215. + * }
  216. + *
  217. + * \author Andrius Ribas \<andriusmao@gmail.com\>
  218. + */
  219. +class KTEXTEDITOR_EXPORT MultipleFileSearchInterface
  220. +{
  221. + // Multiple file search
  222. + public:
  223. + MultipleFileSearchInterface ();
  224. +
  225. + /**
  226. + * Virtual destructor.
  227. + */
  228. + virtual ~MultipleFileSearchInterface ();
  229. +
  230. + /**
  231. + * Whether multiple file search is set as allowed.
  232. + * \return \e true if multiple file search is allowed, \e false otherwise.
  233. + */
  234. + virtual bool multipleFileSearchAllowed() = 0;
  235. +
  236. + /**
  237. + * Convenience function to emit searchReachedBottom()
  238. + * \see searchReachedBottom()
  239. + */
  240. + virtual void emitSearchReachedBottom() = 0;
  241. +
  242. + /**
  243. + * Convenience function to emit searchReachedTop()
  244. + * \see searchReachedTop()
  245. + */
  246. + virtual void emitSearchReachedTop() = 0;
  247. +
  248. + public Q_SLOTS:
  249. +
  250. + /**
  251. + * This is a slot that tells the view to allow or disallow multiple file search.
  252. + * \param allowed Whether to enable or disable multiple file search feature.
  253. + */
  254. + virtual void allowMultipleFileSearch(bool allowed = true) = 0;
  255. +
  256. + /**
  257. + * This is a slot that tells the view to restore search bar settings for multiple
  258. + * files search, if necessary.
  259. + * \param allowed Whether to enable or disable multiple file search feature.
  260. + */
  261. + virtual void restoreSearchBar() = 0;
  262. +
  263. + Q_SIGNALS:
  264. +
  265. + /**
  266. + * This signal is emitted when multiple files search is enabled and
  267. + * the search reached the end of current view, this allows the app
  268. + * to know when to change the current view.
  269. + * This signal is meant to be propagated from the search bar.
  270. + * \see searchReachedTop()
  271. + */
  272. + void searchReachedBottom();
  273. + /**
  274. + * This signal is emitted when multiple files search is enabled and
  275. + * the backward search reached the beginning of current view, this
  276. + * allows the app to know when change the current view.
  277. + * This signal is meant to be propagated from the search bar.
  278. + * \see searchReachedBottom()
  279. + */
  280. + void searchReachedTop();
  281. +
  282. + public:
  283. + MultipleFileSearchInterfacePrivate *d;
  284. +
  285. +};
  286. +
  287. +}
  288. +
  289. +Q_DECLARE_INTERFACE(KTextEditor::MultipleFileSearchInterface, "org.kde.KTextEditor.MultipleFileSearchInterface")
  290. +
  291. +#endif
  292. diff --git a/ktexteditor/multiplefilesearchinterface_p.h b/ktexteditor/multiplefilesearchinterface_p.h
  293. new file mode 100644
  294. index 0000000..476b746
  295. --- /dev/null
  296. +++ b/ktexteditor/multiplefilesearchinterface_p.h
  297. @@ -0,0 +1,41 @@
  298. +/* This file is part of the KDE libraries
  299. + Copyright (C) 2010 Andrius da Costa Ribas (andriusmao@gmail.com)
  300. +
  301. + This library is free software; you can redistribute it and/or
  302. + modify it under the terms of the GNU Library General Public
  303. + License version 2 as published by the Free Software Foundation.
  304. +
  305. + This library is distributed in the hope that it will be useful,
  306. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  307. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  308. + Library General Public License for more details.
  309. +
  310. + You should have received a copy of the GNU Library General Public License
  311. + along with this library; see the file COPYING.LIB. If not, write to
  312. + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  313. + Boston, MA 02110-1301, USA.
  314. +*/
  315. +
  316. +#ifndef KDELIBS_KTEXTEDITOR_MULTIPLEFILESEARCHINTERFACE_P_H
  317. +#define KDELIBS_KTEXTEDITOR_MULTIPLEFILESEARCHINTERFACE_P_H
  318. +
  319. +namespace KTextEditor
  320. +{
  321. +
  322. +/**
  323. + * \brief Private class for the d-pointer of the MultipleFileSearchInterface.
  324. + *
  325. + * \ingroup kte_group_view_extensions
  326. + *
  327. + * \see KTextEditor::View
  328. + */
  329. +class MultipleFileSearchInterfacePrivate
  330. +{
  331. + public:
  332. + bool m_multipleFileSearch;
  333. + MultipleFileSearchInterfacePrivate() : m_multipleFileSearch(false) {}
  334. +};
  335. +
  336. +}
  337. +
  338. +#endif
  339. diff --git a/part/search/katesearchbar.cpp b/part/search/katesearchbar.cpp
  340. index 5a4adde..5c9306e 100644
  341. --- a/part/search/katesearchbar.cpp
  342. +++ b/part/search/katesearchbar.cpp
  343. @@ -124,8 +124,6 @@ public:
  344.  
  345. } // anon namespace
  346.  
  347. -
  348. -
  349. KateSearchBar::KateSearchBar(bool initAsPower, KateView* view, KateViewConfig *config)
  350. : KateViewBarWidget(true, view),
  351. m_view(view),
  352. @@ -198,6 +196,9 @@ KateSearchBar::KateSearchBar(bool initAsPower, KateView* view, KateViewConfig *c
  353. updateSelectionOnly();
  354. connect(view, SIGNAL(selectionChanged(KTextEditor::View *)),
  355. this, SLOT(updateSelectionOnly()));
  356. +
  357. + setMultipleFilesVisible(view->multipleFileSearchAllowed());
  358. + restoreState();
  359. }
  360.  
  361.  
  362. @@ -281,6 +282,19 @@ void KateSearchBar::indicateMatch(MatchResult matchResult) {
  363. QLineEdit * const lineEdit = isPower() ? m_powerUi->pattern->lineEdit()
  364. : m_incUi->pattern->lineEdit();
  365. QPalette background(lineEdit->palette());
  366. +
  367. + if ( multipleFiles() ) {
  368. + switch (matchResult) {
  369. + case MatchWrappedForward:
  370. + saveState();
  371. + m_view->emitSearchReachedBottom();
  372. + break;
  373. + case MatchWrappedBackward:
  374. + saveState();
  375. + m_view->emitSearchReachedTop();
  376. + break;
  377. + }
  378. + }
  379.  
  380. switch (matchResult) {
  381. case MatchFound: // FALLTHROUGH
  382. @@ -584,10 +598,10 @@ bool KateSearchBar::find(SearchDirection searchDirection, const QString * replac
  383. selectRange2(match.range());
  384. }
  385.  
  386. - const MatchResult matchResult = !match.isValid() ? MatchMismatch :
  387. - !wrap ? MatchFound :
  388. - searchDirection == SearchForward ? MatchWrappedForward :
  389. - MatchWrappedBackward;
  390. + const MatchResult matchResult = !match.isValid() && !multipleFiles() ? MatchMismatch :
  391. + !wrap ? MatchFound :
  392. + searchDirection == SearchForward ? MatchWrappedForward :
  393. + MatchWrappedBackward;
  394. indicateMatch(matchResult);
  395.  
  396. // Reset highlighting for all matches and highlight replacement if there is one
  397. @@ -648,10 +662,12 @@ void KateSearchBar::givePatternFeedback() {
  398. void KateSearchBar::addCurrentTextToHistory(QComboBox * combo) {
  399. const QString text = combo->currentText();
  400. const int index = combo->findText(text);
  401. - if (index != -1) {
  402. - combo->removeItem(index);
  403. + if (index != 0) {
  404. + if (index != -1) {
  405. + combo->removeItem(index);
  406. + }
  407. + combo->insertItem(0, text);
  408. }
  409. - combo->insertItem(0, text);
  410. combo->setCurrentIndex(0);
  411. }
  412.  
  413. @@ -876,6 +892,8 @@ QString KateSearchBar::searchPattern() const {
  414.  
  415. void KateSearchBar::setSelectionOnly(bool selectionOnly)
  416. {
  417. + setMultipleFilesEnabled(!selectionOnly);
  418. +
  419. if (this->selectionOnly() == selectionOnly)
  420. return;
  421.  
  422. @@ -1271,7 +1289,13 @@ void KateSearchBar::enterPowerMode() {
  423. QLineEdit * const replacementLineEdit = m_powerUi->replacement->lineEdit();
  424. Q_ASSERT(replacementLineEdit != NULL);
  425. replacementLineEdit->completer()->setCaseSensitivity(Qt::CaseSensitive);
  426. + // set multiple files search visibility
  427. + m_powerUi->multipleFiles->setVisible(m_multipleFilesVisible);
  428. }
  429. +
  430. + // we either choose selectionOnly or multipleFiles ( or none )
  431. + connect(m_powerUi->selectionOnly, SIGNAL(toggled(bool)), m_powerUi->multipleFiles, SLOT(setDisabled(bool)), Qt::UniqueConnection);
  432. + connect(m_powerUi->multipleFiles, SIGNAL(toggled(bool)), m_powerUi->selectionOnly, SLOT(setDisabled(bool)), Qt::UniqueConnection);
  433.  
  434. m_powerUi->selectionOnly->setChecked(selectionOnly);
  435.  
  436. @@ -1301,7 +1325,19 @@ void KateSearchBar::enterPowerMode() {
  437. givePatternFeedback();
  438.  
  439. if (create) {
  440. - // Slots
  441. + // any find/replace action shall also trigger saveState ( for multiple files search )
  442. + connect(m_powerUi->multipleFiles, SIGNAL(clicked()), this, SLOT(saveState()));
  443. + connect(m_powerUi->findNext, SIGNAL(clicked()), this, SLOT(saveState()));
  444. + connect(m_powerUi->findPrev, SIGNAL(clicked()), this, SLOT(saveState()));
  445. + connect(m_powerUi->replaceNext, SIGNAL(clicked()), this, SLOT(saveState()));
  446. + connect(m_powerUi->replaceAll, SIGNAL(clicked()), this, SLOT(saveState()));
  447. + connect(m_powerUi->searchMode, SIGNAL(activated(int)), this, SLOT(saveState()));
  448. + connect(m_powerUi->matchCase, SIGNAL(clicked()), this, SLOT(saveState()));
  449. + connect(m_powerUi->findAll, SIGNAL(clicked()), this, SLOT(saveState()));
  450. + connect(patternLineEdit, SIGNAL(returnPressed()), this, SLOT(saveState()));
  451. + connect(replacementLineEdit, SIGNAL(returnPressed()), this, SLOT(saveState()));
  452. +
  453. + // Other slots
  454. connect(m_powerUi->mutate, SIGNAL(clicked()), this, SLOT(enterIncrementalMode()));
  455. connect(patternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(onPowerPatternChanged(const QString &)));
  456. connect(m_powerUi->findNext, SIGNAL(clicked()), this, SLOT(findNext()));
  457. @@ -1530,4 +1566,91 @@ bool KateSearchBar::isPower() const {
  458. return m_powerUi != 0;
  459. }
  460.  
  461. +
  462. +void KateSearchBar::setMultipleFiles(bool multipleFiles) {
  463. + m_multipleFilesSave = multipleFiles;
  464. + if (this->multipleFiles() == multipleFiles)
  465. + return;
  466. +
  467. + if (isPower())
  468. + m_powerUi->multipleFiles->setChecked(multipleFiles);
  469. +}
  470. +
  471. +
  472. +void KateSearchBar::setMultipleFilesVisible(bool visible) {
  473. + m_multipleFilesVisible = visible;
  474. + if (isPower())
  475. + m_powerUi->multipleFiles->setVisible(visible);
  476. +}
  477. +
  478. +
  479. +bool KateSearchBar::multipleFiles() const {
  480. + // must be in Power mode, visible, enabled and checked
  481. + return isPower() ? m_powerUi->multipleFiles->isVisible() && m_powerUi->multipleFiles->isEnabled() && m_powerUi->multipleFiles->isChecked()
  482. + : false;
  483. +}
  484. +
  485. +
  486. +void KateSearchBar::setMultipleFilesEnabled(bool multipleFiles) {
  487. + if (isPower())
  488. + m_powerUi->multipleFiles->setEnabled(multipleFiles);
  489. +}
  490. +
  491. +bool KateSearchBar::saveState() {
  492. + if (!(m_powerUi->multipleFiles->isVisible())) {
  493. + // this happens when we've already switched the view
  494. + return false;
  495. + }
  496. + if ( multipleFiles() ) {
  497. + m_multipleFilesSave = true;
  498. + m_saveFindText = m_powerUi->pattern->currentText();
  499. + m_saveReplaceText = m_powerUi->replacement->currentText();
  500. + m_saveSearchMode = m_powerUi->searchMode->currentIndex();
  501. + m_MatchCase = m_powerUi->matchCase->isChecked();
  502. + return true;
  503. + }
  504. + else {
  505. + m_multipleFilesSave = false;
  506. + return false;
  507. + }
  508. +}
  509. +
  510. +bool KateSearchBar::restoreState() {
  511. + if ( m_multipleFilesSave ) {
  512. + enterPowerMode();
  513. +
  514. + m_powerUi->pattern->setEditText(m_saveFindText);
  515. + addCurrentTextToHistory(m_powerUi->pattern);
  516. +
  517. + m_powerUi->replacement->setEditText(m_saveReplaceText);
  518. + addCurrentTextToHistory(m_powerUi->replacement);
  519. +
  520. + m_powerUi->searchMode->setCurrentIndex(m_saveSearchMode);
  521. + m_powerUi->matchCase->setChecked(m_MatchCase);
  522. +
  523. + m_powerUi->multipleFiles->setChecked(true);
  524. +
  525. + // if we are using multiple files then "selectionOnly" doesn't make sense
  526. + m_powerUi->selectionOnly->setEnabled(false);
  527. + return true;
  528. + }
  529. + else {
  530. + // unmark multipleFiles for other views too as if it were a "global" button
  531. + if ( isPower() )
  532. + m_powerUi->multipleFiles->setChecked(false);
  533. + return false;
  534. + }
  535. +}
  536. +
  537. +bool KateSearchBar::multipleFilesSearchSaved() {
  538. + return m_multipleFilesSave;
  539. +}
  540. +
  541. +// static members initialization
  542. +bool KateSearchBar::m_multipleFilesSave = false;
  543. +QString KateSearchBar::m_saveFindText = QString();
  544. +QString KateSearchBar::m_saveReplaceText = QString();
  545. +int KateSearchBar::m_saveSearchMode = KateSearchBar::MODE_PLAIN_TEXT;
  546. +bool KateSearchBar::m_MatchCase = false;
  547. +
  548. // kate: space-indent on; indent-width 4; replace-tabs on;
  549. diff --git a/part/search/katesearchbar.h b/part/search/katesearchbar.h
  550. index 0602259..c49780f 100644
  551. --- a/part/search/katesearchbar.h
  552. +++ b/part/search/katesearchbar.h
  553. @@ -42,6 +42,7 @@ namespace KTextEditor {
  554. class MovingRange;
  555. }
  556.  
  557. +class KateSearchBarPrivate;
  558.  
  559. class KATEPART_TESTS_EXPORT KateSearchBar : public KateViewBarWidget {
  560. Q_OBJECT
  561. @@ -81,6 +82,7 @@ public:
  562.  
  563. bool selectionOnly() const;
  564. bool matchCase() const;
  565. + bool multipleFiles() const;
  566.  
  567. // Only used by KateView
  568. static void nextMatchForSelection(KateView * view, SearchDirection searchDirection);
  569. @@ -92,6 +94,14 @@ public Q_SLOTS:
  570.  
  571. void setSelectionOnly(bool selectionOnly);
  572. void setMatchCase(bool matchCase);
  573. +
  574. + // for multiple file search settings save
  575. + bool saveState();
  576. + bool restoreState();
  577. +
  578. + void setMultipleFilesVisible(bool visible);
  579. + void setMultipleFilesEnabled(bool enabled);
  580. + void setMultipleFiles(bool multipleFiles);
  581.  
  582. // Called for <F3> and <Shift>+<F3>
  583. void findNext();
  584. @@ -181,9 +191,19 @@ private:
  585. bool m_powerFromCursor : 1;
  586. bool m_powerHighlightAll : 1;
  587. unsigned int m_powerMode : 2;
  588. -};
  589. + bool m_multipleFilesVisible : 1;
  590. +
  591. + // static members for multiple files search parameter saving
  592. + static bool m_multipleFilesSave;
  593. + static QString m_saveFindText;
  594. + static QString m_saveReplaceText;
  595. + static int m_saveSearchMode;
  596. + static bool m_MatchCase;
  597.  
  598. +public:
  599. + static bool multipleFilesSearchSaved();
  600.  
  601. +};
  602.  
  603. #endif // KATE_SEARCH_BAR_H
  604.  
  605. diff --git a/part/search/searchbarpower.ui b/part/search/searchbarpower.ui
  606. index 3add1c0..25d4fb8 100644
  607. --- a/part/search/searchbarpower.ui
  608. +++ b/part/search/searchbarpower.ui
  609. @@ -222,6 +222,16 @@
  610. </property>
  611. </widget>
  612. </item>
  613. + <item>
  614. + <widget class="QCheckBox" name="multipleFiles">
  615. + <property name="text">
  616. + <string>Loop thro&ugh opened files</string>
  617. + </property>
  618. + <property name="visible">
  619. + <bool>false</bool>
  620. + </property>
  621. + </widget>
  622. + </item>
  623. </layout>
  624. </item>
  625. <item row="3" column="0">
  626. diff --git a/part/view/kateview.cpp b/part/view/kateview.cpp
  627. index 1571729..d59d5e6 100644
  628. --- a/part/view/kateview.cpp
  629. +++ b/part/view/kateview.cpp
  630. @@ -2858,4 +2858,47 @@ void KateView::updateRangesIn (KTextEditor::Attribute::ActivationType activation
  631. oldSet = newRangesIn;
  632. }
  633.  
  634. +
  635. +
  636. +// Multiple File Search stuff
  637. +void KateView::restoreSearchBar() {
  638. + if (KateSearchBar::multipleFilesSearchSaved()) {
  639. + if (!m_searchBar) {
  640. + m_searchBar = new KateSearchBar(true, this, KateViewConfig::global());
  641. + }
  642. + m_bottomViewBar->addBarWidget(m_searchBar);
  643. + if ( m_searchBar->restoreState() ) {
  644. + m_bottomViewBar->showBarWidget(m_searchBar);
  645. + m_searchBar->setFocus();
  646. + }
  647. + }
  648. + else if (m_searchBar) {
  649. + if (m_searchBar->isPower()) {
  650. + // just to uncheck "multipleFiles" if necessary
  651. + m_searchBar->restoreState();
  652. + m_searchBar->setFocus();
  653. + }
  654. + }
  655. +}
  656. +
  657. +void KateView::allowMultipleFileSearch(bool allowed)
  658. +{
  659. + MultipleFileSearchInterface::d->m_multipleFileSearch = allowed;
  660. +}
  661. +
  662. +bool KateView::multipleFileSearchAllowed()
  663. +{
  664. + return MultipleFileSearchInterface::d->m_multipleFileSearch;
  665. +}
  666. +
  667. +void KateView::emitSearchReachedBottom()
  668. +{
  669. + emit searchReachedBottom();
  670. +}
  671. +
  672. +void KateView::emitSearchReachedTop()
  673. +{
  674. + emit searchReachedTop();
  675. +}
  676. +
  677. // kate: space-indent on; indent-width 2; replace-tabs on;
  678. diff --git a/part/view/kateview.h b/part/view/kateview.h
  679. index eed38ac..e4263dd 100644
  680. --- a/part/view/kateview.h
  681. +++ b/part/view/kateview.h
  682. @@ -32,6 +32,7 @@
  683. #include <ktexteditor/smartrangewatcher.h>
  684. #include <ktexteditor/configinterface.h>
  685. #include <ktexteditor/annotationinterface.h>
  686. +#include <ktexteditor/multiplefilesearchinterface.h>
  687.  
  688. #include <QtCore/QPointer>
  689. #include <QModelIndex>
  690. @@ -83,7 +84,8 @@ class KATEPART_TESTS_EXPORT KateView : public KTextEditor::View,
  691. public KTextEditor::ConfigInterface,
  692. private KTextEditor::SmartRangeWatcher,
  693. public KTextEditor::AnnotationViewInterface,
  694. - public KTextEditor::CoordinatesToCursorInterface
  695. + public KTextEditor::CoordinatesToCursorInterface,
  696. + public KTextEditor::MultipleFileSearchInterface
  697. {
  698. Q_OBJECT
  699. Q_INTERFACES(KTextEditor::TextHintInterface)
  700. @@ -94,6 +96,7 @@ class KATEPART_TESTS_EXPORT KateView : public KTextEditor::View,
  701. Q_INTERFACES(KTextEditor::CodeCompletionInterface)
  702. Q_INTERFACES(KTextEditor::AnnotationViewInterface)
  703. Q_INTERFACES(KTextEditor::CoordinatesToCursorInterface)
  704. + Q_INTERFACES(KTextEditor::MultipleFileSearchInterface)
  705.  
  706. friend class KateViewInternal;
  707. friend class KateIconBorder;
  708. @@ -772,6 +775,24 @@ public:
  709. * set of ranges which had the caret inside last time
  710. */
  711. QSet<Kate::TextRange *> m_rangesCaretIn;
  712. +
  713. + //
  714. + // KTextEditor::MultipleFileSearchInterface stuff
  715. + //
  716. + public:
  717. +
  718. + virtual bool multipleFileSearchAllowed();
  719. + virtual void emitSearchReachedBottom();
  720. + virtual void emitSearchReachedTop();
  721. +
  722. + public Q_SLOTS:
  723. + virtual void allowMultipleFileSearch(bool allowed = true);
  724. + virtual void restoreSearchBar();
  725. +
  726. + Q_SIGNALS:
  727. + void searchReachedBottom();
  728. + void searchReachedTop();
  729. +
  730. };
  731.  
  732. /**
Add Comment
Please, Sign In to add comment