]> git.lyx.org Git - features.git/commitdiff
More accurate toc navigation (LFUN_PARAGRAPH_GOTO).
authorAbdelrazak Younes <younes@lyx.org>
Fri, 16 May 2008 12:48:13 +0000 (12:48 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Fri, 16 May 2008 12:48:13 +0000 (12:48 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24798 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.cpp
src/TocBackend.cpp
src/frontends/qt4/TocModel.cpp

index 4ce8ddb0a2f8e5cff581e2d28807e4ed868aec71..85ac21a8e34dc280191ebd2e1d8190c0f1c905a6 100644 (file)
@@ -1055,7 +1055,8 @@ bool BufferView::dispatch(FuncRequest const & cmd)
        }
 
        case LFUN_PARAGRAPH_GOTO: {
-               int const id = convert<int>(to_utf8(cmd.argument()));
+               int const id = convert<int>(cmd.getArg(0));
+               int const pos = convert<int>(cmd.getArg(1));
                int i = 0;
                for (Buffer * b = &buffer_; i == 0 || b != &buffer_;
                        b = theBufferList().next(b)) {
@@ -1072,6 +1073,7 @@ bool BufferView::dispatch(FuncRequest const & cmd)
 
                        if (b == &buffer_) {
                                // Set the cursor
+                               dit.pos() = pos;
                                setCursor(dit);
                                processUpdateFlags(Update::Force | Update::FitCursor);
                        } else {
index 984eb1ab65863b3f273e7c25ccdf4c60e46f2c8f..f2fabd9bdca4fe06767653a15ca5ed3288215d73 100644 (file)
@@ -76,7 +76,9 @@ docstring const TocItem::asString() const
 
 FuncRequest TocItem::action() const
 {
-       return FuncRequest(LFUN_PARAGRAPH_GOTO, convert<string>(id()));
+       string const arg = convert<string>(dit_.paragraph().id())
+               + ' ' + convert<string>(dit_.pos());
+       return FuncRequest(LFUN_PARAGRAPH_GOTO, arg);
 }
 
 
index 670cb5541dab474d4f626077631397a506db1e10..5acee8fd8315db8247ef796698b8a11477780a77 100644 (file)
@@ -219,13 +219,9 @@ void TocModels::goTo(int type, QModelIndex const & index) const
        }
 
        LASSERT(type >= 0 && type < int(models_.size()), /**/);
-
        TocIterator const it = models_[type]->tocIterator(index);
-
        LYXERR(Debug::GUI, "TocModels::goTo " << it->str());
-
-       string const tmp = convert<string>(it->id());
-       dispatch(FuncRequest(LFUN_PARAGRAPH_GOTO, tmp));
+       dispatch(it->action());
 }