branch: Fix bug #2213: GuiChanges? lacks "Previous Change" button.

see r29108, r29109, r29110, r29111, and r29115.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@30597 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2009-07-15 10:08:56 +00:00
parent 9e6e4ebdd5
commit d0d41147a7
11 changed files with 111 additions and 14 deletions

View File

@ -964,6 +964,7 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd)
case LFUN_CHANGES_MERGE:
case LFUN_CHANGE_NEXT:
case LFUN_CHANGE_PREVIOUS:
case LFUN_ALL_CHANGES_ACCEPT:
case LFUN_ALL_CHANGES_REJECT:
// TODO: context-sensitive enabling of LFUNs
@ -1210,9 +1211,15 @@ bool BufferView::dispatch(FuncRequest const & cmd)
// FIXME: Move this LFUN to Buffer so that we don't have to do this:
processUpdateFlags(Update::Force | Update::FitCursor);
break;
case LFUN_CHANGE_PREVIOUS:
findPreviousChange(this);
// FIXME: Move this LFUN to Buffer so that we don't have to do this:
processUpdateFlags(Update::Force | Update::FitCursor);
break;
case LFUN_CHANGES_MERGE:
if (findNextChange(this)) {
if (findNextChange(this) || findPreviousChange(this)) {
processUpdateFlags(Update::Force | Update::FitCursor);
showDialog("changes");
}

View File

@ -446,6 +446,12 @@ void Cursor::resetAnchor()
}
void Cursor::setCursorToAnchor()
{
if (selection())
setCursor(anchor_);
}
bool Cursor::posBackward()
{

View File

@ -63,6 +63,8 @@ public:
void leaveInset(Inset const & inset);
/// sets cursor part
void setCursor(DocIterator const & it);
/// sets the cursor to the anchor
void setCursorToAnchor();
///
void setCurrentFont();

View File

@ -349,10 +349,10 @@ enum FuncCode
LFUN_PARAGRAPH_MOVE_UP,
// 265
LFUN_BUFFER_TOGGLE_COMPRESSION, // bpeng 20060427
LFUN_MATH_BIGDELIM,
LFUN_CLIPBOARD_PASTE,
LFUN_INSET_DISSOLVE, // jspitzm 20060807
LFUN_CHANGE_NEXT,
LFUN_CHANGE_PREVIOUS, // vfr 20090404
// 270
LFUN_WINDOW_NEW, // Abdel 20061021
LFUN_WINDOW_CLOSE, // Abdel 20061023
@ -424,7 +424,7 @@ enum FuncCode
LFUN_INSET_BEGIN_SELECT, // JMarc, 20090316
LFUN_INSET_END_SELECT, // JMarc, 20090316
LFUN_VC_LOCKING_TOGGLE,
LFUN_MATH_BIGDELIM,
LFUN_LASTACTION // end of the table
};

View File

@ -2089,6 +2089,15 @@ void LyXAction::init()
* \endvar
*/
{ LFUN_CHANGE_NEXT, "change-next", ReadOnly, Edit },
/*!
* \var lyx::FuncCode lyx::LFUN_CHANGE_PREVIOUS
* \li Action: Moves the cursor to the position of the previous change
of the change tracking records.
* \li Syntax: change-previous
* \li Origin: vfr, 4 Apr 2009
* \endvar
*/
{ LFUN_CHANGE_PREVIOUS, "change-previous", ReadOnly, Edit },
/*!
* \var lyx::FuncCode lyx::LFUN_CHANGES_MERGE
* \li Action: Open change tracking dialog for merging and moves the cursor

View File

@ -43,6 +43,7 @@ GuiChanges::GuiChanges(GuiView & lv)
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(nextPB, SIGNAL(clicked()), this, SLOT(nextChange()));
connect(previousPB, SIGNAL(clicked()), this, SLOT(previousChange()));
connect(rejectPB, SIGNAL(clicked()), this, SLOT(rejectChange()));
connect(acceptPB, SIGNAL(clicked()), this, SLOT(acceptChange()));
@ -74,6 +75,12 @@ void GuiChanges::nextChange()
}
void GuiChanges::previousChange()
{
dispatch(FuncRequest(LFUN_CHANGE_PREVIOUS));
}
docstring GuiChanges::changeDate() const
{
Change const & c = bufferview()->getCurrentChange();

View File

@ -35,6 +35,8 @@ protected Q_SLOTS:
void rejectChange();
/// find the next change and highlight it
void nextChange();
/// find the previous change and highlight it
void previousChange();
private:
///

View File

@ -43,6 +43,19 @@
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QPushButton" name="previousPB" >
<property name="toolTip" >
<string>Go to previous change</string>
</property>
<property name="text" >
<string>&amp;Previous change</string>
</property>
<property name="default" >
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="nextPB" >
<property name="toolTip" >

View File

@ -100,11 +100,19 @@ bool findBackwards(DocIterator & cur, MatchString const & match,
}
bool findChange(DocIterator & cur)
bool findChange(DocIterator & cur, bool next)
{
for (; cur; cur.forwardPos())
if (cur.inTexted() && !cur.paragraph().isUnchanged(cur.pos()))
if (!next)
cur.backwardPos();
for (; cur; next ? cur.forwardPos() : cur.backwardPos())
if (cur.inTexted() && !cur.paragraph().isUnchanged(cur.pos())) {
if (!next)
// if we search backwards, take a step forward
// to correctly set the anchor
cur.forwardPos();
return true;
}
return false;
}
@ -317,21 +325,54 @@ void replace(BufferView * bv, FuncRequest const & ev, bool has_deleted)
bool findNextChange(BufferView * bv)
{
DocIterator cur = bv->cursor();
return findChange(bv, true);
}
if (!findChange(cur))
bool findPreviousChange(BufferView * bv)
{
return findChange(bv, false);
}
bool findChange(BufferView * bv, bool next)
{
if (bv->cursor().selection()) {
// set the cursor at the beginning or at the end of the selection
// before searching. Otherwise, the current change will be found.
if (next != bv->cursor().top() > bv->cursor().anchor())
bv->cursor().setCursorToAnchor();
}
DocIterator cur = bv->cursor();
if (!findChange(cur, next))
return false;
bv->cursor().setCursor(cur);
bv->cursor().resetAnchor();
if (!next)
// take a step into the change
cur.backwardPos();
Change orig_change = cur.paragraph().lookupChange(cur.pos());
CursorSlice & tip = cur.top();
for (; !tip.at_end(); tip.forwardPos()) {
Change change = tip.paragraph().lookupChange(tip.pos());
if (change != orig_change)
break;
if (next) {
for (; !tip.at_end(); tip.forwardPos()) {
Change change = tip.paragraph().lookupChange(tip.pos());
if (change != orig_change)
break;
}
} else {
for (; !tip.at_begin(); tip.backwardPos()) {
Change change = tip.paragraph().lookupChange(tip.pos());
if (change != orig_change) {
// take a step forward to correctly set the selection
tip.forwardPos();
break;
}
}
}
// Now put cursor to end of selection:

View File

@ -58,6 +58,14 @@ void replace(BufferView * bv, FuncRequest const &, bool has_deleted = false);
/// find the next change in the buffer
bool findNextChange(BufferView * bv);
/// find the previous change in the buffer
bool findPreviousChange(BufferView * bv);
/// find the change in the buffer
/// \param next true to find the next change, otherwise the previous
bool findChange(BufferView * bv, bool next);
} // namespace lyx
#endif // LYXFIND_H

View File

@ -70,6 +70,7 @@ What's new
- Make it possible to copy from a deleted section (bug 5390).
- Reverse searching added to the merge changes dialog (bug 2213).
* DOCUMENTATION AND LOCALIZATION
@ -223,8 +224,9 @@ What's new
- Fix selection of math insets on some archs.
- Fix unitialized variable in Math, Dialog and inset painting code
(bugs 6082, 6081, 6077).
- Fix of painter glitches caused by unitialized variables (bug 6077).
- Fix unitialized variable in Dialog code (bug 6081).
* DOCUMENTATION AND LOCALIZATION