FindAndReplace: more simplification and correct focus handling.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27668 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2008-11-22 17:35:17 +00:00
parent 227dd33f2f
commit b718b83074
4 changed files with 21 additions and 63 deletions

View File

@ -50,6 +50,7 @@ FindAndReplace::FindAndReplace(GuiView & parent)
setupUi(this);
find_work_area_->setGuiView(parent_view_);
find_work_area_->init();
setFocusProxy(find_work_area_);
}
@ -133,20 +134,11 @@ void FindAndReplace::findAdv(bool casesensitive,
// searchString, len, casesensitive, matchword, ! backwards, expandmacros);
}
void FindAndReplace::showEvent(QShowEvent *ev)
bool FindAndReplace::initialiseParams(std::string const &)
{
find_work_area_->setFocus();
selectAll();
QWidget::showEvent(ev);
}
void FindAndReplace::hideEvent(QHideEvent *ev)
{
LYXERR(Debug::DEBUG, "FindAndReplace::hideEvent");
find_work_area_->removeEventFilter(this);
find_work_area_->disable();
this->QWidget::hideEvent(ev);
return true;
}
@ -159,7 +151,6 @@ void FindAndReplace::find(bool backwards)
expandMacrosCB->isChecked(),
ignoreFormatCB->isChecked());
parent_view_.currentMainWorkArea()->redraw();
parent_view_.setCurrentWorkArea(find_work_area_);
find_work_area_->setFocus();
}

View File

@ -36,15 +36,12 @@ class FindAndReplace : public DockView, public Ui::FindAndReplaceUi
public:
FindAndReplace(GuiView & parent);
bool initialiseParams(std::string const &) { return true; }
bool initialiseParams(std::string const &);
void clearParams() {}
void dispatchParams() {}
bool isBufferDependent() const { return true; }
void selectAll();
void showEvent(QShowEvent * ev);
void hideEvent(QHideEvent * ev);
/// update
void updateView() {}
//virtual void update_contents() {}

View File

@ -1223,13 +1223,10 @@ bool GuiWorkArea::isFullScreen()
////////////////////////////////////////////////////////////////////
EmbeddedWorkArea::EmbeddedWorkArea(QWidget * w): GuiWorkArea(w),
delayed_focus_timer_(this)
EmbeddedWorkArea::EmbeddedWorkArea(QWidget * w): GuiWorkArea(w)
{
buffer_ = theBufferList().newBuffer(
support::FileName::tempName().absFilename() + "_embedded.internal");
LASSERT(buffer_ != 0, /* */);
buffer_->setUnnamed(true);
buffer_->setFullyLoaded(true);
setBuffer(*buffer_);
@ -1245,48 +1242,27 @@ EmbeddedWorkArea::~EmbeddedWorkArea()
}
void EmbeddedWorkArea::onDelayedFocus()
void EmbeddedWorkArea::closeEvent(QCloseEvent * ev)
{
LYXERR(Debug::DEBUG, "Delayed Focus");
view().setCurrentWorkArea(this);
setFocus();
}
void EmbeddedWorkArea::showEvent(QShowEvent *ev)
{
view().setCurrentWorkArea(this);
redraw();
setFocus();
installEventFilter(this);
connect(&delayed_focus_timer_, SIGNAL(timeout()), this,
SLOT(onDelayedFocus()));
delayed_focus_timer_.setSingleShot(true);
delayed_focus_timer_.start(100);
GuiWorkArea::showEvent(ev);
}
void EmbeddedWorkArea::closeEvent(QCloseEvent * close_event)
{
LYXERR(Debug::DEBUG, "FindAndReplace::closeEvent()");
removeEventFilter(this);
disable();
GuiWorkArea::closeEvent(ev);
}
GuiWorkArea::closeEvent(close_event);
void EmbeddedWorkArea::hideEvent(QHideEvent * ev)
{
disable();
GuiWorkArea::hideEvent(ev);
}
void EmbeddedWorkArea::disable()
{
// Ok, closing the window before 100ms may be impossible, however...
delayed_focus_timer_.stop();
if (view().currentWorkArea() == this) {
LASSERT(view().currentMainWorkArea(), /* */);
view().setCurrentWorkArea(view().currentMainWorkArea());
}
stopBlinkingCursor();
if (view().currentWorkArea() != this)
return;
LASSERT(view().currentMainWorkArea(), /* */);
view().setCurrentWorkArea(view().currentMainWorkArea());
}
////////////////////////////////////////////////////////////////////

View File

@ -278,17 +278,11 @@ public:
protected:
///
void showEvent(QShowEvent * ev);
/// this happens when the dialog is simply closed/hidden
void closeEvent(QCloseEvent * e);
private Q_SLOTS:
/// this happens 100ms after dialog showEvent()
void onDelayedFocus();
void closeEvent(QCloseEvent * ev);
///
void hideEvent(QHideEvent *ev);
private:
/// @TODO: Investigate on focus issue and remove this ugly hack, please !
QTimer delayed_focus_timer_;
/// Embedded Buffer.
Buffer * buffer_;
}; // EmbeddedWorkArea