[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kate
From: Sebastian Pipping <webmaster () hartwork ! org>
Date: 2007-08-31 21:19:54
Message-ID: 1188595194.868740.31358.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 707050 by sping:
Search config is now copied to global config as proposed on the mailing list
CCMAIL: kwrite-devel@kde.org
M +126 -31 utils/katesearchbar.cpp
M +10 -2 utils/katesearchbar.h
M +12 -10 view/kateview.cpp
M +1 -1 view/kateview.h
--- trunk/KDE/kdelibs/kate/utils/katesearchbar.cpp #707049:707050
@@ -2,9 +2,7 @@
##
## TODO:
## * Fix regex search in KateDocument?
-## (Skips when backwords, ".*" endless loop!?)
-## * Fix highlighting of matches/replacements?
-## (Zero width smart range)
+## (Fix case with pattern "\n+")
## * Proper loading/saving of search settings
## * Highlight all (with background thread?)
##
@@ -32,8 +30,11 @@
#include "katesearchbar.h"
#include "kateview.h"
#include "katedocument.h"
+#include "kateglobal.h"
+
#include "ui_searchbarincremental.h"
#include "ui_searchbarpower.h"
+
#include <QtGui/QVBoxLayout>
#include <QtGui/QComboBox>
#include <QtGui/QCheckBox>
@@ -45,7 +46,7 @@
-KateSearchBar::KateSearchBar(KateViewBar * viewBar)
+KateSearchBar::KateSearchBar(KateViewBar * viewBar, bool initAsPower)
: KateViewBarWidget(viewBar),
m_view(viewBar->view()),
m_topRange(NULL),
@@ -67,13 +68,9 @@
m_powerSelectionOnly(false),
m_powerUsePlaceholders(false),
m_powerMode(0) {
+ // Modify parent
QWidget * const widget = centralWidget();
widget->setLayout(m_layout);
-
- // Start in incremental mode
- onMutateIncremental();
- // onMutatePower();
-
m_layout->setMargin(2);
// Init highlight
@@ -81,8 +78,10 @@
m_topRange->setInsertBehavior(SmartRange::ExpandRight);
enableHighlights(true);
- // Read settings
- const long searchFlags = m_view->config()->searchFlags();
+
+ // Copy global to local config backup
+ KateViewConfig * const globalConfig = KateGlobal::self()->viewConfig();
+ const long searchFlags = globalConfig->searchFlags();
m_incHighlightAll = (searchFlags & KateViewConfig::IncHighlightAll) != 0;
m_incFromCursor = (searchFlags & KateViewConfig::IncFromCursor) != 0;
m_incMatchCase = (searchFlags & KateViewConfig::IncMatchCase) != 0;
@@ -98,6 +97,15 @@
: (((searchFlags & KateViewConfig::PowerModeWholeWords) != 0)
? 1
: 0)); // Plain text
+ kDebug() << "GLOBAL SEARCH CONFIG COPIED TO LOCAL" << "past" << searchFlags;
+
+
+ // Load one of either dialogs
+ if (initAsPower) {
+ onMutatePower();
+ } else {
+ onMutateIncremental();
+ }
}
@@ -359,6 +367,30 @@
+void KateSearchBar::onIncMatchCaseToggle(bool invokedByUserAction) {
+ if (invokedByUserAction) {
+ sendConfig();
+ }
+}
+
+
+
+void KateSearchBar::onIncHighlightAllToggle(bool invokedByUserAction) {
+ if (invokedByUserAction) {
+ sendConfig();
+ }
+}
+
+
+
+void KateSearchBar::onIncFromCursorToggle(bool invokedByUserAction) {
+ if (invokedByUserAction) {
+ sendConfig();
+ }
+}
+
+
+
void KateSearchBar::fixForSingleLine(Range & range, bool forwards) {
kDebug() << "Single-line workaround checking" << range;
if (forwards) {
@@ -607,18 +639,21 @@
void KateSearchBar::sendConfig() {
+ KateViewConfig * const globalConfig = KateGlobal::self()->viewConfig();
+ const long pastFlags = globalConfig->searchFlags();
+ long futureFlags = pastFlags;
+
if (m_powerUi != NULL) {
const bool OF_POWER = true;
backupConfig(OF_POWER);
- } else if (m_incUi != NULL) {
- const bool OF_INCREMENTAL = false;
- backupConfig(OF_INCREMENTAL);
- }
- const long searchFlags = 0
- | (m_incHighlightAll ? KateViewConfig::IncHighlightAll : 0)
- | (m_incFromCursor ? KateViewConfig::IncFromCursor : 0)
- | (m_incMatchCase ? KateViewConfig::IncMatchCase : 0)
+ // Update power search flags only
+ const long incFlagsOnly = pastFlags
+ & (KateViewConfig::IncHighlightAll
+ | KateViewConfig::IncFromCursor
+ | KateViewConfig::IncMatchCase);
+
+ futureFlags = incFlagsOnly
| (m_powerMatchCase ? KateViewConfig::PowerMatchCase : 0)
| (m_powerFromCursor ? KateViewConfig::PowerFromCursor : 0)
| (m_powerHighlightAll ? KateViewConfig::PowerHighlightAll : 0)
@@ -632,8 +667,31 @@
? KateViewConfig::PowerModeWholeWords
: KateViewConfig::PowerModePlainText)));
- KateViewConfig * const viewConfig = m_view->config();
- viewConfig->setSearchFlags(searchFlags);
+ } else if (m_incUi != NULL) {
+ const bool OF_INCREMENTAL = false;
+ backupConfig(OF_INCREMENTAL);
+
+ // Update incremental search flags only
+ const long powerFlagsOnly = pastFlags
+ & (KateViewConfig::PowerMatchCase
+ | KateViewConfig::PowerFromCursor
+ | KateViewConfig::PowerHighlightAll
+ | KateViewConfig::PowerSelectionOnly
+ | KateViewConfig::PowerUsePlaceholders
+ | KateViewConfig::PowerModeRegularExpression
+ | KateViewConfig::PowerModeEscapeSequences
+ | KateViewConfig::PowerModeWholeWords
+ | KateViewConfig::PowerModePlainText);
+
+ futureFlags = powerFlagsOnly
+ | (m_incHighlightAll ? KateViewConfig::IncHighlightAll : 0)
+ | (m_incFromCursor ? KateViewConfig::IncFromCursor : 0)
+ | (m_incMatchCase ? KateViewConfig::IncMatchCase : 0);
+ }
+
+ // Adjust global config
+ globalConfig->setSearchFlags(futureFlags);
+ kDebug() << "LOCAL SEARCH CONFIG COPIED TO GLOBAL" << "past" << pastFlags << \
"future" << futureFlags; }
@@ -918,13 +976,49 @@
-void KateSearchBar::onPowerUsePlaceholdersToggle(int state) {
+void KateSearchBar::onPowerUsePlaceholdersToggle(int state, bool \
invokedByUserAction) { const bool disabled = (state != Qt::Checked);
m_powerUi->replacementAdd->setDisabled(disabled);
+
+ if (invokedByUserAction) {
+ sendConfig();
+ }
}
+void KateSearchBar::onPowerMatchCaseToggle(bool invokedByUserAction) {
+ if (invokedByUserAction) {
+ sendConfig();
+ }
+}
+
+
+
+void KateSearchBar::onPowerHighlightAllToggle(bool invokedByUserAction) {
+ if (invokedByUserAction) {
+ sendConfig();
+ }
+}
+
+
+
+void KateSearchBar::onPowerFromCursorToggle(bool invokedByUserAction) {
+ if (invokedByUserAction) {
+ sendConfig();
+ }
+}
+
+
+
+void KateSearchBar::onPowerSelectionOnlyToggle(bool invokedByUserAction) {
+ if (invokedByUserAction) {
+ sendConfig();
+ }
+}
+
+
+
void KateSearchBar::onPowerModeChanged(int index, bool invokedByUserAction) {
const bool disabled = (index < 2); // TODO
m_powerUi->patternAdd->setDisabled(disabled);
@@ -942,6 +1036,8 @@
default:
; // NOOP
}
+
+ sendConfig();
}
}
@@ -1057,8 +1153,8 @@
// Propagate settings (slots are still inactive on purpose)
onPowerPatternChanged(initialPattern);
- onPowerUsePlaceholdersToggle(m_powerUi->usePlaceholders->checkState());
const bool NOT_INVOKED_BY_USER_ACTION = false;
+ onPowerUsePlaceholdersToggle(m_powerUi->usePlaceholders->checkState(), \
NOT_INVOKED_BY_USER_ACTION);
onPowerModeChanged(m_powerUi->searchMode->currentIndex(), \
NOT_INVOKED_BY_USER_ACTION);
if (create) {
@@ -1072,14 +1168,15 @@
connect(m_powerUi->searchMode, SIGNAL(currentIndexChanged(int)), this, \
SLOT(onPowerModeChanged(int)));
connect(m_powerUi->patternAdd, SIGNAL(clicked()), this, \
SLOT(onPowerAddToPatternClicked()));
connect(m_powerUi->usePlaceholders, SIGNAL(stateChanged(int)), this, \
SLOT(onPowerUsePlaceholdersToggle(int))); + connect(m_powerUi->matchCase, \
SIGNAL(stateChanged(int)), this, SLOT(onPowerMatchCaseToggle())); + \
connect(m_powerUi->highlightAll, SIGNAL(stateChanged(int)), this, \
SLOT(onPowerHighlightAllToggle())); + connect(m_powerUi->fromCursor, \
SIGNAL(stateChanged(int)), this, SLOT(onPowerFromCursorToggle())); + \
connect(m_powerUi->selectionOnly, SIGNAL(stateChanged(int)), this, \
SLOT(onPowerSelectionOnlyToggle()));
connect(m_powerUi->replacementAdd, SIGNAL(clicked()), this, \
SLOT(onPowerAddToReplacementClicked())); }
// Focus
m_powerUi->pattern->setFocus(Qt::MouseFocusReason);
-
- // Send config
- // sendConfig();
}
@@ -1164,6 +1261,9 @@
connect(m_incUi->pattern, SIGNAL(textChanged(const QString &)), this, \
SLOT(onIncPatternChanged(const QString &)));
connect(m_incUi->next, SIGNAL(clicked()), this, SLOT(onIncNext()));
connect(m_incUi->prev, SIGNAL(clicked()), this, SLOT(onIncPrev()));
+ connect(m_incMenuMatchCase, SIGNAL(changed()), this, \
SLOT(onIncMatchCaseToggle())); + connect(m_incMenuFromCursor, \
SIGNAL(changed()), this, SLOT(onIncFromCursorToggle())); + \
connect(m_incMenuHighlightAll, SIGNAL(changed()), this, \
SLOT(onIncHighlightAllToggle()));
// Make button click open the menu as well. IMHO with the dropdown arrow \
present the button // better shows his nature than in instant popup mode.
@@ -1172,9 +1272,6 @@
// Focus
m_incUi->pattern->setFocus(Qt::MouseFocusReason);
-
- // Send config
- // sendConfig();
}
@@ -1240,8 +1337,6 @@
void KateSearchBar::hideEvent(QHideEvent * event) {
enableHighlights(false);
KateViewBarWidget::hideEvent(event);
-
- // sendConfig();
}
--- trunk/KDE/kdelibs/kate/utils/katesearchbar.h #707049:707050
@@ -55,7 +55,7 @@
Q_OBJECT
public:
- explicit KateSearchBar(KateViewBar * viewBar);
+ explicit KateSearchBar(KateViewBar * viewBar, bool initAsPower);
~KateSearchBar();
public Q_SLOTS:
@@ -66,6 +66,10 @@
void onIncPatternChanged(const QString & pattern);
void onIncNext();
void onIncPrev();
+ void onIncMatchCaseToggle(bool invokedByUserAction = true);
+ void onIncHighlightAllToggle(bool invokedByUserAction = true);
+ void onIncFromCursorToggle(bool invokedByUserAction = true);
+
void onStep(bool replace, bool forwards = true);
void onPowerPatternChanged(const QString & pattern);
void onPowerFindNext();
@@ -74,7 +78,11 @@
void onPowerReplaceAll();
void onPowerAddToPatternClicked();
void onPowerAddToReplacementClicked();
- void onPowerUsePlaceholdersToggle(int state);
+ void onPowerUsePlaceholdersToggle(int state, bool invokedByUserAction = true);
+ void onPowerMatchCaseToggle(bool invokedByUserAction = true);
+ void onPowerHighlightAllToggle(bool invokedByUserAction = true);
+ void onPowerFromCursorToggle(bool invokedByUserAction = true);
+ void onPowerSelectionOnlyToggle(bool invokedByUserAction = true);
void onPowerModeChanged(int index, bool invokedByUserAction = true);
public Q_SLOTS:
--- trunk/KDE/kdelibs/kate/view/kateview.cpp #707049:707050
@@ -1104,18 +1104,20 @@
void KateView::find()
{
- searchBar()->onMutateIncremental();
-
- searchBar()->showBar();
- searchBar()->setFocus();
+ const bool INIT_HINT_AS_POWER = true;
+ KateSearchBar * const bar = searchBar(INIT_HINT_AS_POWER);
+ bar->onMutateIncremental();
+ bar->showBar();
+ bar->setFocus();
}
void KateView::replace()
{
- searchBar()->onMutatePower();
-
- searchBar()->showBar();
- searchBar()->setFocus();
+ const bool INIT_HINT_AS_INCREMENTAL = false;
+ KateSearchBar * const bar = searchBar(INIT_HINT_AS_INCREMENTAL);
+ bar->onMutatePower();
+ bar->showBar();
+ bar->setFocus();
}
void KateView::findNext()
@@ -2450,12 +2452,12 @@
return m_cmdLine = new KateCmdLine (this, m_viewBar);
}
-KateSearchBar *KateView::searchBar ()
+KateSearchBar *KateView::searchBar (bool initHintAsPower)
{
if (m_searchBar)
return m_searchBar;
- return m_searchBar = new KateSearchBar(m_viewBar);
+ return m_searchBar = new KateSearchBar(m_viewBar, initHintAsPower);
}
KateGotoBar *KateView::gotoBar ()
--- trunk/KDE/kdelibs/kate/view/kateview.h #707049:707050
@@ -607,7 +607,7 @@
*/
public:
KateCmdLine *cmdLine ();
- KateSearchBar *searchBar ();
+ KateSearchBar *searchBar (bool initHintAsPower = false);
KateGotoBar *gotoBar ();
/**
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic