Re: [PATCH] KDE FormToc cleanup
On Wed, 13 Sep 2000, Dekel Tsur wrote: > On Wed, Sep 13, 2000 at 11:27:40AM +0200, Juergen Vigna wrote: > > > > On 13-Sep-2000 John Levon wrote: > > > > > > I should get some sleep :/ > > > > I forgot in my former mail: > > > > GOOD WORK!!! > > > > I like the new look of the KDE-TOC-DIALOG!!! > > The Klyx TOC dialog is a little bit nicer (e.g. the ability to select a depth > threshold). > John, why aren't you reusing code from Klyx ? > That's an incredibly good question. I suppose I thought that LyX might have changed too much inbetween, but I suppose a lot of it will still be useful. I have a source tarball at home, I should dig it out ! john -- "He who joyfully marches to music in rank and file has already earned my contempt. He has been given a large brain by mistake, since for him the spinal cord would fully suffice." - Albert Einstein
Re: [PATCH] KDE FormToc cleanup
On Wed, Sep 13, 2000 at 11:27:40AM +0200, Juergen Vigna wrote: > > On 13-Sep-2000 John Levon wrote: > > > > I should get some sleep :/ > > I forgot in my former mail: > > GOOD WORK!!! > > I like the new look of the KDE-TOC-DIALOG!!! The Klyx TOC dialog is a little bit nicer (e.g. the ability to select a depth threshold). John, why aren't you reusing code from Klyx ?
Re: [PATCH] KDE FormToc cleanup
On 13-Sep-2000 Lars Gullik Bjønnes wrote: > > or only kde? I meant frontends/kde :) Jürgen -- -._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._ Dr. Jürgen VignaE-Mail: [EMAIL PROTECTED] Italienallee 13/N Tel/Fax: +39-0471-450260 / +39-0471-450253 I-39100 Bozen Web: http://www.sad.it/~jug -._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._ "The medium is the massage." -- Crazy Nigel
Re: [PATCH] KDE FormToc cleanup
Juergen Vigna <[EMAIL PROTECTED]> writes: | On 13-Sep-2000 John Levon wrote: | > | > But to do that would require me to have *two* source trees, because cvs | > won't know about the new files because I can't do "cvs add". | > | | Well I guess we can add you to the cvs-readonly list AND this means you | CAN do an add ;) yes. | > just another of those annoying CVS limitations (personally I can't wait | > for subversion :) | | Lars what do you say? Could you also give him write access for the kde | frontends? or only kde? Lgb
Re: [PATCH] KDE FormToc cleanup
On 13-Sep-2000 John Levon wrote: > > But to do that would require me to have *two* source trees, because cvs > won't know about the new files because I can't do "cvs add". > Well I guess we can add you to the cvs-readonly list AND this means you CAN do an add ;) > just another of those annoying CVS limitations (personally I can't wait > for subversion :) Lars what do you say? Could you also give him write access for the kde frontends? Jürgen -- -._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._ Dr. Jürgen VignaE-Mail: [EMAIL PROTECTED] Italienallee 13/N Tel/Fax: +39-0471-450260 / +39-0471-450253 I-39100 Bozen Web: http://www.sad.it/~jug -._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._ He hath eaten me out of house and home. -- William Shakespeare, "Henry IV"
Re: [PATCH] KDE FormToc cleanup
On 13-Sep-2000 John Levon wrote: > > I should get some sleep :/ I forgot in my former mail: GOOD WORK!!! I like the new look of the KDE-TOC-DIALOG!!! Jürgen -- -._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._ Dr. Jürgen VignaE-Mail: [EMAIL PROTECTED] Italienallee 13/N Tel/Fax: +39-0471-450260 / +39-0471-450253 I-39100 Bozen Web: http://www.sad.it/~jug -._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._ I have accepted Provolone into my life!
Re: [PATCH] KDE FormToc cleanup
On 13-Sep-2000 John Levon wrote: > > Argh, I accidentally sent an old version which won't compile. > Sorry ! New one attached > No problem I read your mail late enough ;) I'll commit this too! NOW: PLEASE make the next patch with the command: cvs diff -N -u >kdewhatever.patch FROM the source root tree (the directory where the Changelog file is). Do you have problems with this? If yes tell me what and we'll see if we can fix them, if not I'll not accept any other patch in any other format! Jürgen -- -._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._ Dr. Jürgen VignaE-Mail: [EMAIL PROTECTED] Italienallee 13/N Tel/Fax: +39-0471-450260 / +39-0471-450253 I-39100 Bozen Web: http://www.sad.it/~jug -._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._ With/Without - and who'll deny it's what the fighting's all about? -- Pink Floyd
Re: [PATCH] KDE FormToc cleanup
Argh, I accidentally sent an old version which won't compile.
Sorry ! New one attached
I should get some sleep :/
thanks
john
On Wed, 13 Sep 2000, John Levon wrote:
2000-09-13 John Levon <[EMAIL PROTECTED]>
* src/frontends/kde/formtocdialog.C
* src/frontends/kde/formtocdialog.h
* src/frontends/kde/FormToc.C
* src/frontends/kde/FormToc.h: change to
make TOC hierarchical properly
? a
? formtoc.diff
Index: FormToc.C
===
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/kde/FormToc.C,v
retrieving revision 1.1
diff -u -r1.1 FormToc.C
--- FormToc.C 2000/09/12 15:13:18 1.1
+++ FormToc.C 2000/09/13 07:05:21
@@ -15,6 +15,8 @@
#include
+#include
+
#include "formtocdialog.h"
#include "Dialogs.h"
@@ -28,6 +30,7 @@
using std::vector;
using std::pair;
+using std::stack;
FormToc::FormToc(LyXView *v, Dialogs *d)
: dialog_(0), lv_(v), d_(d), inset_(0), h_(0), u_(0), ih_(0),
@@ -92,18 +95,59 @@
toclist = tmp[type];
dialog_->tree->clear();
+
+ dialog_->tree->setUpdatesEnabled(false);
-
- // FIXME: should do hierarchically. at each point we need to know
- // id of item we've just inserted, id of most recent sibling, and
- // id of parent
+ int depth = 0;
+ stack< pair< QListViewItem *, QListViewItem *> > istack;
+ QListViewItem *last = 0;
+ QListViewItem *parent = 0;
+ QListViewItem *item;
+
+ // Yes, it is this ugly. Two reasons - root items must have a QListView
+parent,
+ // rather than QListViewItem; and the TOC can move in and out an arbitrary
+number
+ // of levels
- dialog_->tree->setAutoUpdate(false);
for (vector< Buffer::TocItem >::const_iterator iter = toclist.begin();
iter != toclist.end(); ++iter) {
- dialog_->tree->insertItem((string(4*(*iter).depth,'
')+(*iter).str).c_str(), 0, -1, false);
+ if (iter->depth == depth) {
+ // insert it after the last one we processed
+ if (!parent)
+ item = (last) ? (new
+QListViewItem(dialog_->tree,last)) : (new QListViewItem(dialog_->tree));
+ else
+ item = (last) ? (new QListViewItem(parent,last)) :
+(new QListViewItem(parent));
+ } else if (iter->depth > depth) {
+ int diff = iter->depth - depth;
+ // first save old parent and last
+ while (diff--)
+ istack.push(pair< QListViewItem *, QListViewItem *
+>(parent,last));
+ item = (last) ? (new QListViewItem(last)) : (new
+QListViewItem(dialog_->tree));
+ parent = last;
+ } else {
+ int diff = depth - iter->depth;
+ pair< QListViewItem *, QListViewItem * > top;
+ // restore context
+ while (diff--) {
+ top = istack.top();
+ istack.pop();
+ }
+ parent = top.first;
+ last = top.second;
+ // insert it after the last one we processed
+ if (!parent)
+ item = (last) ? (new
+QListViewItem(dialog_->tree,last)) : (new QListViewItem(dialog_->tree));
+ else
+ item = (last) ? (new QListViewItem(parent,last)) :
+(new QListViewItem(parent));
+ }
+ lyxerr[Debug::GUI] << "Table of contents" << endl << "Added item " <<
+iter->str.c_str()
+ << " at depth " << iter->depth << ", previous sibling \"" <<
+(last ? last->text(0) : "0")
+ << "\", parent \"" << (parent ? parent->text(0) : "0") << "\""
+<< endl;
+ item->setText(0,iter->str.c_str());
+ depth = iter->depth;
+ last = item;
}
- dialog_->tree->setAutoUpdate(true);
+
+ dialog_->tree->setUpdatesEnabled(true);
dialog_->tree->update();
}
@@ -113,15 +157,19 @@
switch (type) {
case Buffer::TOC_TOC:
dialog_->setCaption(_("Table of Contents"));
+ dialog_->tree->setColumnText(0,_("Table of Contents"));
break;
case Buffer::TOC_LOF:
dialog_->setCaption(_("List of Figures"));
+ dialog_->tree->setColumnText(0,_("List of Figures"));
break;
case Buffer::TOC_LOT:
dialog_->setCaption(_("List o
