View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0008796 | Scribus | Usability | public | 2010-02-10 09:39 | 2024-09-16 20:54 |
Reporter | cezaryece | Assigned To | cbradney | ||
Priority | normal | Severity | feature | Reproducibility | always |
Status | closed | Resolution | duplicate | ||
Fixed in Version | 1.7.0.svn | ||||
Summary | 0008796: [feature request] more usable TOC | ||||
Description | Making TOC is too complicated in my opinion. As I am Ventura user I would like to see more powerful and automatic way of making TOC. In Ventura I simply set which paragraph style should be included in TOC. And simply in TOC text with these paragraph styles are inlcuded, but of course with new customizable style. So, in use it is very simple. I don't have to manually add special metatags to frames with appropriate content. I see also simply way to include this way of making of TOC in Scribus - automatically add to attributes of frame text content using selectable paragraph style as value of TOC attribute... | ||||
Tags | #rottenpatch, patch | ||||
Patch | Yes | ||||
|
This sounds very good to me. Ideally, I'd also like to specify additional information such as author names (for individual chapters) to be included into the TOC via selection of the corresponding paragraph style. |
|
Some more on this: This could be achieved via a configuration option allowing field input such as <Chapter:PageNumber> <Author>: <Chapter> (which then becomes a list like: 5 Bernhard Reiter: Scribus and TOCs 9 John Doe: Whatever etc.) |
|
your description looks to me like a duplicate of the feature request 0005975 which has been already acknowledged by a scribus team member. OT: cezaryece, am I right in the assumption that you and Scribus are involved in the process of making this biweekly http://www.mojemiasto.slupsk.pl/? If yes, it would be much appreciated if you add a few words to our success stories on the scribus wiki http://wiki.scribus.net/index.php/Success_stories -- by a coincidence, Slupsk was my home town too:) |
|
OT @mhanski - I try to write my success story if I get account. BTW nice to find neighbor in Scribus developers. I would like to join developer team as well, but understanding these tons of code is trouble for me. If you find some time for helping me at start contact me at czarek(at)oferuje.pl |
|
OT @cezaryece: I've just sent you your wiki account data and some additional details per private e-mail. Regarding joining the developer team, the best you can do right now is to get in touch with Scribus core team guys on IRC channel #scribus You could also join the Scribus mailing list see http://lists.scribus.info/mailman/listinfo/scribus -- both the mailing list and the guys on the IRC channel are very helpful and friendly to newcomers. |
|
and join the scribus-dev mailing list too! we would love to have more active developers |
|
Another approach which could simplify TOC creation. Add an additional context menu entry "add to first TOC" Clicking on that entry would create a new attribute to the current text frame with the first TOC and with the value of the first line (or paragraph?) of the content of the text frame. If you additionally add a shortcut for that entry, creating a TOC would be really fast. |
|
But this is still manually creation. I would like to see feature to automatically generating of TOC. If I work with magazin with aprox. 120 pages and 80 articles there is easy to forget apply proprietary frame atribute and miss some articles in TOC - it can be hard do recognize this mistake. So, I think there should be a way for automatically done this work. But... both ways together should working - sometimes there may be some frame without priopretary paragraph style, so adding this by hand is usefull too. Note for developers: code this feature (if you start working at it) with wider horizonts and please keep in mind that in near or far future other than text frames may have captions or titles, so TOC engine should be prepared for making Table Of Illustrations, Table Of Tables, Table Of Photos etc... |
|
Both ways should be possible! The automated way is described in issue 0005975 The way I described is more flexible and leaves the complete control to the user. |
|
toc.diff (36,485 bytes)
Index: Scribus/scribus/tocindexprefs.h =================================================================== --- Scribus/scribus/tocindexprefs.h (wersja 15812) +++ Scribus/scribus/tocindexprefs.h (kopia robocza) @@ -56,9 +56,19 @@ virtual void itemFrameSelected( const QString & frameName ); virtual void itemPageNumberPlacedSelected( const QString & pageLocation ); virtual void itemParagraphStyleSelected( const QString & itemStyle ); + + virtual void PScomboBoxSelected1text(const QString&); + virtual void PScomboBoxSelected1toc(const QString&); + virtual void PScomboBoxSelected2text(const QString&); + virtual void PScomboBoxSelected2toc(const QString&); + virtual void PScomboBoxSelected3text(const QString&); + virtual void PScomboBoxSelected3toc(const QString&); + virtual void setToCName( const QString & newName ); virtual void nonPrintingFramesSelected( bool showNonPrinting ); + virtual void usePSsearching( bool searchPS ); + protected: int numSelected; QString strPNNotShown; Index: Scribus/scribus/tocindexprefs.ui =================================================================== --- Scribus/scribus/tocindexprefs.ui (wersja 15812) +++ Scribus/scribus/tocindexprefs.ui (kopia robocza) @@ -1,83 +1,76 @@ -<ui version="4.0" > +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> <class>TOCIndexPrefs</class> - <widget class="QWidget" name="TOCIndexPrefs" > - <property name="geometry" > + <widget class="QWidget" name="TOCIndexPrefs"> + <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>444</width> - <height>234</height> + <width>492</width> + <height>559</height> </rect> </property> - <property name="windowTitle" > + <property name="windowTitle"> <string>Table of Contents and Indexes</string> </property> - <layout class="QVBoxLayout" > - <property name="spacing" > + <layout class="QVBoxLayout"> + <property name="spacing"> <number>6</number> </property> - <property name="margin" > + <property name="margin"> <number>0</number> </property> <item> - <widget class="QTabWidget" name="tabTOCIndexWidget" > - <widget class="QWidget" name="tab" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>436</width> - <height>202</height> - </rect> - </property> - <attribute name="title" > + <widget class="QTabWidget" name="tabTOCIndexWidget"> + <widget class="QWidget" name="tab"> + <attribute name="title"> <string>Table Of Contents</string> </attribute> - <layout class="QHBoxLayout" > - <property name="spacing" > + <layout class="QHBoxLayout"> + <property name="spacing"> <number>6</number> </property> - <property name="margin" > + <property name="margin"> <number>0</number> </property> <item> - <layout class="QVBoxLayout" > - <property name="spacing" > + <layout class="QVBoxLayout"> + <property name="spacing"> <number>6</number> </property> - <property name="margin" > + <property name="margin"> <number>0</number> </property> <item> - <widget class="QListWidget" name="tocListBox" /> + <widget class="QListWidget" name="tocListBox"/> </item> <item> - <widget class="QLineEdit" name="tocNameLineEdit" /> + <widget class="QLineEdit" name="tocNameLineEdit"/> </item> <item> - <layout class="QHBoxLayout" > - <property name="spacing" > + <layout class="QHBoxLayout"> + <property name="spacing"> <number>6</number> </property> - <property name="margin" > + <property name="margin"> <number>0</number> </property> <item> - <widget class="QPushButton" name="tocAddButton" > - <property name="text" > + <widget class="QPushButton" name="tocAddButton"> + <property name="text"> <string>&Add</string> </property> - <property name="shortcut" > + <property name="shortcut"> <string>Alt+A</string> </property> </widget> </item> <item> - <widget class="QPushButton" name="tocDeleteButton" > - <property name="text" > + <widget class="QPushButton" name="tocDeleteButton"> + <property name="text"> <string>&Delete</string> </property> - <property name="shortcut" > + <property name="shortcut"> <string>Alt+D</string> </property> </widget> @@ -87,117 +80,239 @@ </layout> </item> <item> - <layout class="QVBoxLayout" > - <property name="spacing" > + <layout class="QVBoxLayout"> + <property name="spacing"> <number>6</number> </property> - <property name="margin" > + <property name="margin"> <number>0</number> </property> <item> - <layout class="QGridLayout" > - <property name="margin" > + <layout class="QGridLayout"> + <property name="margin"> <number>0</number> </property> - <property name="spacing" > + <property name="spacing"> <number>6</number> </property> - <item row="1" column="1" > - <widget class="QComboBox" name="itemDestFrameComboBox" > - <property name="toolTip" > - <string>The frame the table of contents will be placed into</string> + <item row="0" column="0"> + <widget class="QLabel" name="tocItemAttrLabel"> + <property name="text"> + <string>Item Attribute Name:</string> </property> + <property name="wordWrap"> + <bool>false</bool> + </property> </widget> </item> - <item row="2" column="0" > - <widget class="QLabel" name="tocNumberPlacementLabel" > - <property name="text" > - <string>Page Number Placement:</string> + <item row="0" column="1"> + <widget class="QComboBox" name="itemAttrComboBox"> + <property name="toolTip"> + <string>The Item Attribute that will be set on frames used as a basis for creation of the entries</string> </property> - <property name="wordWrap" > - <bool>false</bool> - </property> </widget> </item> - <item row="0" column="0" > - <widget class="QLabel" name="tocItemAttrLabel" > - <property name="text" > - <string>Item Attribute Name:</string> + <item row="1" column="0"> + <widget class="QLabel" name="tocDestFrameLabel"> + <property name="text"> + <string>Destination Frame:</string> </property> - <property name="wordWrap" > + <property name="wordWrap"> <bool>false</bool> </property> </widget> </item> - <item row="0" column="1" > - <widget class="QComboBox" name="itemAttrComboBox" > - <property name="toolTip" > - <string>The Item Attribute that will be set on frames used as a basis for creation of the entries</string> + <item row="1" column="1"> + <widget class="QComboBox" name="itemDestFrameComboBox"> + <property name="toolTip"> + <string>The frame the table of contents will be placed into</string> </property> </widget> </item> - <item row="2" column="1" > - <widget class="QComboBox" name="itemNumberPlacementComboBox" > - <property name="toolTip" > + <item row="2" column="0"> + <widget class="QLabel" name="tocNumberPlacementLabel"> + <property name="text"> + <string>Page Number Placement:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QComboBox" name="itemNumberPlacementComboBox"> + <property name="toolTip"> <string>Place page numbers of the entries at the beginning or the end of the line, or not at all</string> </property> </widget> </item> - <item row="4" column="0" colspan="2" > - <widget class="QCheckBox" name="itemListNonPrintingCheckBox" > - <property name="toolTip" > - <string>Include frames that are set to not print as well</string> + <item row="3" column="0"> + <widget class="QLabel" name="tocParagraphStyleLabel"> + <property name="text"> + <string>TOC Paragraph Style:</string> </property> - <property name="text" > - <string>List Non-Printing Entries</string> + <property name="wordWrap"> + <bool>false</bool> </property> </widget> </item> - <item row="3" column="1" > - <widget class="QComboBox" name="itemParagraphStyleComboBox" > - <property name="toolTip" > + <item row="3" column="1"> + <widget class="QComboBox" name="itemParagraphStyleComboBox"> + <property name="toolTip"> <string>The paragraph style used for the entry lines</string> </property> </widget> </item> - <item row="3" column="0" > - <widget class="QLabel" name="tocParagraphStyleLabel" > - <property name="text" > - <string>Paragraph Style:</string> + <item row="14" column="0" colspan="2"> + <widget class="QCheckBox" name="itemListNonPrintingCheckBox"> + <property name="toolTip"> + <string>Include frames that are set to not print as well</string> </property> - <property name="wordWrap" > - <bool>false</bool> + <property name="text"> + <string>List Non-Printing Entries</string> </property> </widget> </item> - <item row="1" column="0" > - <widget class="QLabel" name="tocDestFrameLabel" > - <property name="text" > - <string>Destination Frame:</string> + </layout> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>Paragraph Style based TOC</string> </property> - <property name="wordWrap" > - <bool>false</bool> - </property> + <widget class="QWidget" name="gridLayoutWidget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>20</y> + <width>267</width> + <height>239</height> + </rect> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0" colspan="2"> + <widget class="QCheckBox" name="itemParStyleBasedCheckBox"> + <property name="toolTip"> + <string>Turning ON seraching text for selected paragraph styles</string> + </property> + <property name="text"> + <string>Use Paragraph Style based TOC</string> + </property> + </widget> + </item> + <item row="1" column="0" colspan="2"> + <widget class="QLabel" name="PSLabel1toc"> + <property name="text"> + <string>Level1</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="PSlabel1text"> + <property name="text"> + <string>Search Paragraph Style</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QComboBox" name="PScomboBox1text"> + <property name="toolTip"> + <string>The paragraph style name for searching in text</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="PSlabel1toc"> + <property name="text"> + <string>TOC Paragraph Style</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QComboBox" name="PScomboBox1toc"> + <property name="toolTip"> + <string>The paragraph style used for the entry lines</string> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="PSLabel2toc"> + <property name="text"> + <string> Level2</string> + </property> + </widget> + </item> + <item row="5" column="0"> + <widget class="QLabel" name="PSlabel2text"> + <property name="text"> + <string> Search Paragraph Style</string> + </property> + </widget> + </item> + <item row="6" column="0"> + <widget class="QLabel" name="PSlabel2toc"> + <property name="text"> + <string> TOC Paragraph Style</string> + </property> + </widget> + </item> + <item row="7" column="0"> + <widget class="QLabel" name="PSLabelLtoc"> + <property name="text"> + <string> Level3</string> + </property> + </widget> + </item> + <item row="8" column="0"> + <widget class="QLabel" name="PSlabel3text"> + <property name="text"> + <string> Search Paragraph Style</string> + </property> + </widget> + </item> + <item row="9" column="0"> + <widget class="QLabel" name="PSlabel3toc"> + <property name="text"> + <string> TOC Paragraph Style</string> + </property> + </widget> + </item> + <item row="5" column="1"> + <widget class="QComboBox" name="PScomboBox2text"> + <property name="toolTip"> + <string>The paragraph style name for searching in text</string> + </property> + </widget> + </item> + <item row="6" column="1"> + <widget class="QComboBox" name="PScomboBox2toc"> + <property name="toolTip"> + <string>The paragraph style used for the entry lines</string> + </property> + </widget> + </item> + <item row="8" column="1"> + <widget class="QComboBox" name="PScomboBox3text"> + <property name="toolTip"> + <string>The paragraph style name for searching in text</string> + </property> + </widget> + </item> + <item row="9" column="1"> + <widget class="QComboBox" name="PScomboBox3toc"> + <property name="toolTip"> + <string>The paragraph style used for the entry lines</string> + </property> + </widget> + </item> + </layout> + </widget> </widget> </item> </layout> </item> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" stdset="0" > - <size> - <width>16</width> - <height>36</height> - </size> - </property> - </spacer> - </item> </layout> </item> </layout> @@ -206,7 +321,7 @@ </item> </layout> </widget> - <layoutdefault spacing="6" margin="0" /> + <layoutdefault spacing="6" margin="0"/> <tabstops> <tabstop>tabTOCIndexWidget</tabstop> <tabstop>tocListBox</tabstop> Index: Scribus/scribus/text/storytext.cpp =================================================================== --- Scribus/scribus/text/storytext.cpp (wersja 15812) +++ Scribus/scribus/text/storytext.cpp (kopia robocza) @@ -850,13 +850,13 @@ } -int StoryText::nrOfParagraph(uint index) const +uint StoryText::nrOfParagraph(int pos) const { int result = 0; StoryText* that = const_cast<StoryText *>(this); bool lastWasPARSEP = true; - index = qMin(index, (uint) that->length()); - for (uint i=0; i < index; ++i) { + pos = qMin(pos, that->length()); + for (int i=0; i < pos; ++i) { lastWasPARSEP = that->d->at(i)->ch == SpecialChars::PARSEP; if (lastWasPARSEP) ++result; Index: Scribus/scribus/text/storytext.h =================================================================== --- Scribus/scribus/text/storytext.h (wersja 15812) +++ Scribus/scribus/text/storytext.h (kopia robocza) @@ -146,7 +146,7 @@ uint nrOfParagraphs() const; int startOfParagraph(uint index) const; int endOfParagraph(uint index) const; - int nrOfParagraph(uint index) const; + uint nrOfParagraph(int pos) const; uint nrOfRuns() const; int startOfRun(uint index) const; Index: Scribus/scribus/tocindexprefs.cpp =================================================================== --- Scribus/scribus/tocindexprefs.cpp (wersja 15812) +++ Scribus/scribus/tocindexprefs.cpp (kopia robocza) @@ -44,6 +44,10 @@ * \brief Constructs a TOCIndexPrefs as a child of 'parent', with the * name 'name' and widget flags set to 'f'. */ + +#define con_LEVEL_CB_SLOT( post ) connect(PScomboBox##post , SIGNAL( activated(const QString&) ), this, SLOT( PScomboBoxSelected##post(const QString&) ) ) +#define dis_LEVEL_CB_SLOT( post) disconnect(PScomboBox##post , SIGNAL( activated(const QString&) ), this, SLOT( PScomboBoxSelected##post(const QString&) ) ) + TOCIndexPrefs::TOCIndexPrefs( QWidget* parent, const char* name, Qt::WFlags fl ) : QWidget( parent, fl ) { @@ -54,7 +58,13 @@ itemAttrComboBox->setMaximumWidth(fontMetrics().width( "This is a very long Name" )); itemNumberPlacementComboBox->setMaximumWidth(fontMetrics().width( "This is a very long Name" )); itemParagraphStyleComboBox->setMaximumWidth(fontMetrics().width( "This is a very long Name" )); - resize( QSize(444, 234).expandedTo(minimumSizeHint()) ); + PScomboBox1text->setMaximumWidth(fontMetrics().width( "This is a very long Name" )); + PScomboBox1toc->setMaximumWidth(fontMetrics().width( "This is a very long Name" )); + PScomboBox2text->setMaximumWidth(fontMetrics().width( "This is a very long Name" )); + PScomboBox2toc->setMaximumWidth(fontMetrics().width( "This is a very long Name" )); + PScomboBox3text->setMaximumWidth(fontMetrics().width( "This is a very long Name" )); + PScomboBox3toc->setMaximumWidth(fontMetrics().width( "This is a very long Name" )); + resize( QSize(444, 450).expandedTo(minimumSizeHint()) ); // signals and slots connections connect( tocListBox, SIGNAL( currentRowChanged(int) ), this, SLOT( selectToC(int) ) ); @@ -63,9 +73,17 @@ connect( itemAttrComboBox, SIGNAL( activated(const QString&) ), this, SLOT( itemAttributeSelected(const QString&) ) ); connect( itemDestFrameComboBox, SIGNAL( activated(const QString&) ), this, SLOT( itemFrameSelected(const QString&) ) ); connect( itemParagraphStyleComboBox, SIGNAL( activated(const QString&) ), this, SLOT( itemParagraphStyleSelected(const QString&) ) ); + con_LEVEL_CB_SLOT(1text); + con_LEVEL_CB_SLOT(1toc); + con_LEVEL_CB_SLOT(2text); + con_LEVEL_CB_SLOT(2toc); + con_LEVEL_CB_SLOT(3text); + con_LEVEL_CB_SLOT(3toc); + connect( itemNumberPlacementComboBox, SIGNAL( activated(const QString&) ), this, SLOT( itemPageNumberPlacedSelected(const QString&) ) ); connect( tocNameLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( setToCName(const QString&) ) ); connect( itemListNonPrintingCheckBox, SIGNAL( toggled(bool) ), this, SLOT( nonPrintingFramesSelected(bool) ) ); + connect( itemParStyleBasedCheckBox, SIGNAL( toggled(bool) ), this, SLOT( usePSsearching(bool) ) ); init(); } @@ -200,9 +218,19 @@ disconnect( itemAttrComboBox, SIGNAL( activated(const QString&) ), this, SLOT( itemAttributeSelected(const QString&) ) ); disconnect( itemDestFrameComboBox, SIGNAL( activated(const QString&) ), this, SLOT( itemFrameSelected(const QString&) ) ); disconnect( itemParagraphStyleComboBox, SIGNAL( activated(const QString&) ), this, SLOT( itemParagraphStyleSelected(const QString&) ) ); + + dis_LEVEL_CB_SLOT(1text); + dis_LEVEL_CB_SLOT(1toc); + dis_LEVEL_CB_SLOT(2text); + dis_LEVEL_CB_SLOT(2toc); + dis_LEVEL_CB_SLOT(3text); + dis_LEVEL_CB_SLOT(3toc); + disconnect( itemNumberPlacementComboBox, SIGNAL( activated(const QString&) ), this, SLOT( itemPageNumberPlacedSelected(const QString&) ) ); disconnect( tocNameLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( setToCName(const QString&) ) ); disconnect( itemListNonPrintingCheckBox, SIGNAL( toggled(bool) ), this, SLOT( nonPrintingFramesSelected(bool) ) ); + disconnect( itemParStyleBasedCheckBox, SIGNAL( toggled(bool) ), this, SLOT( usePSsearching(bool) ) ); + if (localToCSetupVector[numSelected].itemAttrName==strNone) setCurrentComboItem(itemAttrComboBox, trStrNone); else @@ -230,8 +258,23 @@ else setCurrentComboItem(itemParagraphStyleComboBox, localToCSetupVector[numSelected].textStyle); } + +#define setPScbox( post ) \ + if (!paragraphStyleList.contains(localToCSetupVector[numSelected].SearchStyle##post) || localToCSetupVector[numSelected].SearchStyle##post==strNone) \ + setCurrentComboItem(PScomboBox##post, trStrNone); \ + else \ + setCurrentComboItem(PScomboBox##post, localToCSetupVector[numSelected].textStyle); + + setPScbox(1text) + setPScbox(1toc) + setPScbox(2text) + setPScbox(2toc) + setPScbox(3text) + setPScbox(3toc) + } - + itemParStyleBasedCheckBox->setChecked(localToCSetupVector[numSelected].usePSsearching); + if (tocListBox->currentItem()) tocNameLineEdit->setText(tocListBox->currentItem()->text()); @@ -239,9 +282,18 @@ connect( itemAttrComboBox, SIGNAL( activated(const QString&) ), this, SLOT( itemAttributeSelected(const QString&) ) ); connect( itemDestFrameComboBox, SIGNAL( activated(const QString&) ), this, SLOT( itemFrameSelected(const QString&) ) ); connect( itemParagraphStyleComboBox, SIGNAL( activated(const QString&) ), this, SLOT( itemParagraphStyleSelected(const QString&) ) ); + + con_LEVEL_CB_SLOT(1text); + con_LEVEL_CB_SLOT(1toc); + con_LEVEL_CB_SLOT(2text); + con_LEVEL_CB_SLOT(2toc); + con_LEVEL_CB_SLOT(3text); + con_LEVEL_CB_SLOT(3toc); + connect( itemNumberPlacementComboBox, SIGNAL( activated(const QString&) ), this, SLOT( itemPageNumberPlacedSelected(const QString&) ) ); connect( tocNameLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( setToCName(const QString&) ) ); connect( itemListNonPrintingCheckBox, SIGNAL( toggled(bool) ), this, SLOT( nonPrintingFramesSelected(bool) ) ); + connect( itemParStyleBasedCheckBox, SIGNAL( toggled(bool) ), this, SLOT( usePSsearching(bool) ) ); } @@ -296,6 +348,18 @@ } itemParagraphStyleComboBox->clear(); itemParagraphStyleComboBox->addItems(paragraphStyleList); + PScomboBox1text->clear(); + PScomboBox1text->addItems(paragraphStyleList); + PScomboBox1toc->clear(); + PScomboBox1toc->addItems(paragraphStyleList); + PScomboBox2text->clear(); + PScomboBox2text->addItems(paragraphStyleList); + PScomboBox2toc->clear(); + PScomboBox2toc->addItems(paragraphStyleList); + PScomboBox3text->clear(); + PScomboBox3text->addItems(paragraphStyleList); + PScomboBox3toc->clear(); + PScomboBox3toc->addItems(paragraphStyleList); } @@ -414,6 +478,36 @@ } } +//void TOCIndexPrefs::levelParagraphStyleSelected( const QString& itemStyle, const ushort Level, bool searchPS ) +#define LEVEL_CB_SLOT_DEF( post ) void TOCIndexPrefs::PScomboBoxSelected##post(const QString& itemStyle) \ +{ \ + int numberSelected=tocListBox->currentRow(); \ + if (numberSelected>=0) \ + { \ + int i=0; \ + ToCSetupVector::Iterator it=localToCSetupVector.begin(); \ + while (it!= localToCSetupVector.end() && i<numberSelected) \ + { \ + ++it; ++i; \ + } \ + if (itemStyle==trStrNone) \ + { \ + (*it).SearchStyle##post=strNone; \ + } \ + else \ + { \ + (*it).SearchStyle##post=itemStyle; \ + } \ + } \ +} + +LEVEL_CB_SLOT_DEF(1text) +LEVEL_CB_SLOT_DEF(1toc) +LEVEL_CB_SLOT_DEF(2text) +LEVEL_CB_SLOT_DEF(2toc) +LEVEL_CB_SLOT_DEF(3text) +LEVEL_CB_SLOT_DEF(3toc) + ToCSetupVector* TOCIndexPrefs::getNewToCs() { return &localToCSetupVector; @@ -453,3 +547,20 @@ (*it).listNonPrintingFrames=showNonPrinting; } } + + +void TOCIndexPrefs::usePSsearching( bool searchPS ) +{ + int numberSelected=tocListBox->currentRow(); + if (numberSelected>=0) + { + int i=0; + ToCSetupVector::Iterator it=localToCSetupVector.begin(); + while (it!= localToCSetupVector.end() && i<numberSelected) + { + ++it; + ++i; + } + (*it).usePSsearching=searchPS; + } +} Index: Scribus/scribus/pagestructs.h =================================================================== --- Scribus/scribus/pagestructs.h (wersja 15812) +++ Scribus/scribus/pagestructs.h (kopia robocza) @@ -36,6 +36,13 @@ QString textStyle; //Paragraph style for text //QString leaderParaStyle; //Paragraph style for leaders //QString pageNumberParaStyle; //Paragraph style for page numbers + QString SearchStyle1text;//Paragraph style for searching level1 + QString SearchStyle1toc; //Paragraph style for text level1 + QString SearchStyle2text;//Paragraph style for searching level2 + QString SearchStyle2toc; //Paragraph style for text level2 + QString SearchStyle3text;//Paragraph style for searching level3 + QString SearchStyle3toc; //Paragraph style for text level3 + bool usePSsearching; //Use Paragraph style based TOC }; typedef QList<ToCSetup> ToCSetupVector; Index: Scribus/scribus/tocgenerator.cpp =================================================================== --- Scribus/scribus/tocgenerator.cpp (wersja 15812) +++ Scribus/scribus/tocgenerator.cpp (kopia robocza) @@ -22,15 +22,20 @@ #include <QMap> #include <QString> +#include <QVector> #include "scribusdoc.h" #include "pagestructs.h" #include "pageitem.h" +#include "pageitem_textframe.h" #include "gtparagraphstyle.h" #include "gtframestyle.h" #include "gtwriter.h" #include "page.h" +#include "scmessagebox.h" +#include "scribuscore.h" + TOCGenerator::TOCGenerator(QObject *parent, ScribusDoc *doc) : QObject(parent) { currDoc=doc; @@ -65,6 +70,10 @@ } return targetFrame; } +struct TOCItem { + QString Text; + QString TocPs; +}; void TOCGenerator::generateDefault() { @@ -74,18 +83,44 @@ for(ToCSetupVector::Iterator tocSetupIt = currDoc->docToCSetups.begin() ; tocSetupIt != currDoc->docToCSetups.end(); ++tocSetupIt ) { PageItem* tocFrame=findTargetFrame((*tocSetupIt).frameName); - if (tocFrame!=NULL) + if (tocFrame != NULL) { PageItem *currentDocItem; - QMap<QString, QString> tocMap; + QMap<QString, TOCItem> tocMap; //added TOC pragraph style for current item tocMap.clear(); uint *pageCounter = new uint[currDoc->DocPages.count()]; - if (pageCounter==NULL) + if (pageCounter == NULL) return; uint pageNumberWidth=QString("%1").arg(currDoc->DocPages.count()).length(); for (int i=0;i<currDoc->DocPages.count();++i) - pageCounter[i]=0; - int maxDataWidth=0; + pageCounter[i] = 0; + int maxDataWidth = 0; + + //setup vectors with PS names + QVector<QString> PSnames; //Vector holds PS names for searching + QVector<QString> TOCnames; //Vector holds PS names for TOC + if ((*tocSetupIt).usePSsearching) + { + PSnames.clear(); + TOCnames.clear(); + QString trStrNone=tr("None"); + if (((*tocSetupIt).SearchStyle1text != "") && ((*tocSetupIt).SearchStyle1text != trStrNone)) + { + PSnames.append((*tocSetupIt).SearchStyle1text); + TOCnames.append((*tocSetupIt).SearchStyle1toc); + if (((*tocSetupIt).SearchStyle2text != "") && ((*tocSetupIt).SearchStyle2text != trStrNone)) + { + PSnames.append((*tocSetupIt).SearchStyle2text); + TOCnames.append((*tocSetupIt).SearchStyle2toc); + if (((*tocSetupIt).SearchStyle3text != "") && ((*tocSetupIt).SearchStyle3text != trStrNone)) + { + PSnames.append((*tocSetupIt).SearchStyle3text); + TOCnames.append((*tocSetupIt).SearchStyle3toc); + } + } + } + } + for (int d = 0; d < currDoc->DocItems.count(); ++d) { currentDocItem = currDoc->DocItems.at(d); @@ -98,19 +133,61 @@ if (!(*tocSetupIt).listNonPrintingFrames && !currentDocItem->printEnabled()) continue; ObjectAttribute objattr=currentDocItem->getObjectAttribute((*tocSetupIt).itemAttrName); - if (!objattr.name.isNull()) + + if ((*tocSetupIt).usePSsearching && currentDocItem->isTextFrame() && objattr.name != "noTOC") + //check if text frame is set to omit TOC generation (attribute "noTOC") OR other frame is set to TOC generation { - //The key is generated to produce a sequence of numbers for the page numbers - //First is the page of the item - //Second is an incremented counter for the item so multiple per page works - //Third is the section based page number which is actually used in the TOC. + //for text frames + //find paragraph with style for TOC generation (eg Header style) + PageItem_TextFrame *txtFrame = currentDocItem->asTextFrame(); + StoryText SText = txtFrame->itemText; + + for (int i = txtFrame->firstInFrame(); i < txtFrame->lastInFrame();) + { + QString ParName = SText.paragraphStyle(i).parent(); + int ParIndex = SText.nrOfParagraph(i); + + //if paragraph start at preceding page + if (SText.startOfParagraph(ParIndex) < i) + { + i = SText.startOfParagraph(ParIndex+1); + continue; + } + int PSindex = PSnames.indexOf(ParName); + if ( PSindex != -1) + { + //The key is generated to produce a sequence of numbers for the page numbers + //First is the page of the item + //Second is an incremented counter for the item so multiple per page works + //Third is the section based page number which is actually used in the TOC. + QString key=QString("%1,%2,%3").arg(currentDocItem->OwnPage + currDoc->FirstPnum, pageNumberWidth).arg(pageCounter[currentDocItem->OwnPage]++).arg(currDoc->getSectionPageNumberForPageIndex(currentDocItem->OwnPage)); + + TOCItem toc_item; + toc_item.Text = SText.text(SText.startOfParagraph(ParIndex),SText.endOfParagraph(ParIndex)-SText.startOfParagraph(ParIndex)); + toc_item.TocPs = TOCnames.at(PSindex); + if (!toc_item.Text.isEmpty()) + { + tocMap.insert(key, toc_item); + if (SText.length() > maxDataWidth) + maxDataWidth = SText.length(); + } + } + i = SText.startOfParagraph(ParIndex+1); + } + } + if (!objattr.name.isNull()) //for all frames + { QString key=QString("%1,%2,%3").arg(currentDocItem->OwnPage + currDoc->FirstPnum, pageNumberWidth).arg(pageCounter[currentDocItem->OwnPage]++).arg(currDoc->getSectionPageNumberForPageIndex(currentDocItem->OwnPage)); - tocMap.insert(key, objattr.value); + TOCItem toc_item; + toc_item.Text = objattr.value; + toc_item.TocPs = (*tocSetupIt).textStyle; + tocMap.insert(key, toc_item); if (objattr.value.length()>maxDataWidth) maxDataWidth=objattr.value.length(); } } } + //Set up the gtWriter instance with the selected paragraph style gtWriter* writer = new gtWriter(false, tocFrame); if (writer!=NULL) @@ -119,27 +196,29 @@ writer->setOverridePStyleFont(false); gtFrameStyle* fstyle = writer->getDefaultStyle(); gtParagraphStyle* pstyle = new gtParagraphStyle(*fstyle); - pstyle->setName((*tocSetupIt).textStyle); - writer->setParagraphStyle(pstyle); - + //pstyle->setName((*tocSetupIt).textStyle); + //writer->setParagraphStyle(pstyle); + QString oldTocPage=QString::null; - for (QMap<QString, QString>::Iterator tocIt=tocMap.begin();tocIt!=tocMap.end();++tocIt) + for (QMap<QString, TOCItem>::Iterator tocIt=tocMap.begin();tocIt!=tocMap.end();++tocIt) { QString tocPage(tocIt.key().section( ',', 2, 2 ).trimmed()); QString tocLine; //Start with text or numbers if ((*tocSetupIt).pageLocation==End || (*tocSetupIt).pageLocation==NotShown) - tocLine = tocIt.value(); + tocLine = tocIt.value().Text; if ((*tocSetupIt).pageLocation==Beginning && oldTocPage!=tocPage) tocLine = tocPage; //Add in the tab for the leaders tocLine+="\t"; //End with text or numbers if ((*tocSetupIt).pageLocation==Beginning) - tocLine += tocIt.value(); + tocLine += tocIt.value().Text; if ((*tocSetupIt).pageLocation==End && oldTocPage!=tocPage) tocLine += tocPage; tocLine += "\n"; + pstyle->setName(tocIt.value().TocPs); + writer->setParagraphStyle(pstyle); writer->append(tocLine); } delete writer; |
|
I have done some job on this feature and you can review this in attached toc.diff patch (for 1.3.9svn, sorry, but I need this feature just now even incomplete). How it should work - in document Prefs/TOC dialog you can turn ON Paragraph Style based TOC generating and select which styles are searched in text and which styles use for it in TOC text - 3 Paragraph Styles may be searched and included in TOC with separate styles (eg indentation) - this is some kind of hierarchical TOC, but IMHO more flexible than simply indentation of styles levels - during TOC generation all paragraphs with selected in TOC prefs styles are founded and text from it is used as item in TOC TODO - simultaneous working with old attribute based mechanism need deep testing - in dialog there should be disabling/enabling whole PS settings depend on switching ON/OFF PS based TOC creation - dialog should be fixed for nice looking sizes of controls - translation - MORE URGENT - at this stage settings in TOC prefs are working after setting but are not remembered (or I cant made them restored) after next invoking prefs dialog |
|
i wonder why the old mechanism is in... cezaryece, you should have a chat with MrB, who -- as far i recall it -- has implemented the "old" way of doing... personally, i'm a rather against having both mecanismes in the code and the style based approach seems superior to me... but i have to admit that i don't know why it has done the other way round (maybe styles were not available at that time? who knows...) p.s.: <cezaryece> in old way you can create TOC of graphics frames without text and styles <a_l_e> well, you could always put the text in a non printable field... it still would be simpler to manage |
|
>personally, i'm a rather against having both mecanismes in >the code and the style based approach seems superior to me... I agree. Frame based tocs are require a lot of "manual work" and were the main reason for never fully switching to scribus. The old mechanism could be useful for doing indexes of images and the like though. |
|
with frame style, one could have TOC for graphics too, just say make the list of all image frame of that style. Text to appear in the TOc could be an attribute. |
|
Any news about this patch/feature? Is this aplied already in 1.5? |
|
Any updates here? Similar requests are all around the place. |
|
Nope. Cezary has long ago stopped working on scribus. There is a python script with a base for an index generator : https://bugs.scribus.net/view.php?id=5975#c44678 |
|
cezary's ideas have been reimplemented (in a simpler way) in https://github.com/aoloe/scribus-plugin-tableofcontents with just a little bit of luck, there will be a first usable version of it very soon (it currently does work, but it needs a few improvements before i want to get people to use it...) |
Date Modified | Username | Field | Change |
---|---|---|---|
2010-02-10 09:39 | cezaryece | New Issue | |
2010-02-14 19:10 | Bernhard Reiter | Note Added: 0023272 | |
2010-02-14 19:12 | Bernhard Reiter | Note Edited: 0023272 | |
2010-02-14 19:39 | Bernhard Reiter | Note Added: 0023273 | |
2010-03-16 15:01 | mhanski | Relationship added | duplicate of 0005975 |
2010-03-16 15:29 | mhanski | Note Added: 0023520 | |
2010-03-16 15:37 | mhanski | Note Edited: 0023520 | |
2010-03-17 08:42 | cezaryece | Note Added: 0023528 | |
2010-03-17 12:32 | mhanski | Note Added: 0023533 | |
2010-03-17 12:52 | mhanski | Note Edited: 0023533 | |
2010-03-17 18:49 | cbradney | Note Added: 0023538 | |
2010-04-12 08:31 | aliB | Note Added: 0023666 | |
2010-04-12 08:32 | aliB | Note Edited: 0023666 | |
2010-04-12 13:55 | cezaryece | Note Added: 0023667 | |
2010-04-12 14:09 | aliB | Note Added: 0023668 | |
2010-11-17 21:55 | cezaryece | File Added: toc.diff | |
2010-11-17 22:08 | cezaryece | Note Added: 0024847 | |
2010-11-17 23:38 | ale | Note Added: 0024848 | |
2011-08-03 10:24 | janD | Note Added: 0026676 | |
2011-09-19 08:56 | pygmee | Note Added: 0026888 | |
2012-05-15 18:22 | rdebel | Note Added: 0028007 | |
2012-06-18 19:37 | ale | Assigned To | => cezaryece |
2012-06-18 19:37 | ale | Status | new => assigned |
2014-06-11 08:39 | JLuc | Tag Attached: patch | |
2016-03-10 14:11 | Kunda | Patch | => Yes |
2017-11-29 18:38 | michelv | Note Added: 0044676 | |
2017-11-29 18:55 | JLuc | Tag Attached: #rottenpatch | |
2017-11-29 23:07 | JLuc | Note Added: 0044679 | |
2017-12-02 16:30 | ale | Note Added: 0044700 | |
2024-03-18 20:35 | cbradney | Assigned To | cezaryece => cbradney |
2024-03-18 20:36 | cbradney | Status | assigned => resolved |
2024-03-18 20:36 | cbradney | Resolution | open => duplicate |
2024-03-18 20:37 | cbradney | Fixed in Version | => 1.7.0.svn |
2024-09-16 20:54 | cbradney | Status | resolved => closed |