r14572 by cbradney - New prefs pane for doc item attributes, start on toc prefs pane

scribus-commit scribus-commit at lists.scribus.net
Sun Jan 24 22:45:28 CET 2010


Revision: 14572
Author: cbradney
Date: 2010-01-24T21:44:09.021357Z
Commit message: New prefs pane for doc item attributes, start on toc prefs pane

Changeset: 
M  /trunk/Scribus/scribus/ui/prefs_imagecachebase.ui
M  /trunk/Scribus/scribus/ui/prefs_tableofcontents.h
M  /trunk/Scribus/scribus/ui/preferencesdialog.cpp
M  /trunk/Scribus/scribus/ui/prefs_documentitemattributes.cpp
M  /trunk/Scribus/scribus/ui/prefs_documentitemattributes.h
M  /trunk/Scribus/scribus/ui/prefs_tableofcontents.cpp

Diffs:
Index: scribus/ui/prefs_tableofcontents.h
===================================================================
--- scribus/ui/prefs_tableofcontents.h	(revision 14571)
+++ scribus/ui/prefs_tableofcontents.h	(revision 14572)
@@ -8,16 +8,59 @@
 #ifndef PREFS_TABLEOFCONTENTS_H
 #define PREFS_TABLEOFCONTENTS_H
 
+#include <QStringList>
+
 #include "ui_prefs_tableofcontentsbase.h"
+#include "prefs_pane.h"
 #include "scribusapi.h"
 
-class SCRIBUS_API Prefs_TableOfContents : public QWidget, Ui::Prefs_TableOfContents
+class SCRIBUS_API Prefs_TableOfContents : public Prefs_Pane, Ui::Prefs_TableOfContents
 {
 	Q_OBJECT
 
 	public:
 		Prefs_TableOfContents(QWidget* parent=0);
 		~Prefs_TableOfContents();
+		virtual void restoreDefaults(struct ApplicationPrefs *prefsData);
+		virtual void saveGuiToPrefs(struct ApplicationPrefs *prefsData) const;
+
+	public slots:
+		void languageChange();
+
+//		virtual void setup( ToCSetupVector * tocsetups, ScribusDoc * doc );
+//		virtual void generatePageItemList();
+		void setupItemAttrs( QStringList newNames );
+//		virtual void selectToC( int numberSelected );
+//		virtual void addToC();
+//		virtual void updateToCListBox();
+//		virtual void updateParagraphStyleComboBox();
+//		virtual void deleteToC();
+//		virtual void itemAttributeSelected( const QString & itemAttributeName );
+//		virtual void itemFrameSelected( const QString & frameName );
+//		virtual void itemPageNumberPlacedSelected( const QString & pageLocation );
+//		virtual void itemParagraphStyleSelected( const QString & itemStyle );
+//		virtual void setToCName( const QString & newName );
+//		virtual void nonPrintingFramesSelected( bool showNonPrinting );
+//
+//	protected:
+//		int numSelected;
+//		QString strPNNotShown;
+//		QString strPNEnd;
+//		QString strPNBeginning;
+//		QString trStrPNNotShown;
+//		QString trStrPNEnd;
+//		QString trStrPNBeginning;
+//		ToCSetupVector localToCSetupVector;
+//		QString trStrNone;
+//		ScribusDoc *currDoc;
+//		QString selectedTOCAttrName;
+//		QStringList paragraphStyleList;
+//		QString strNone;
+//
+//	private:
+//		void init();
+//		void destroy();
+
 };
 
 #endif // PREFS_TABLEOFCONTENTS_H
Index: scribus/ui/prefs_documentitemattributes.h
===================================================================
--- scribus/ui/prefs_documentitemattributes.h	(revision 14571)
+++ scribus/ui/prefs_documentitemattributes.h	(revision 14572)
@@ -9,15 +9,40 @@
 #define PREFS_DOCUMENTITEMATTRIBUTES_H
 
 #include "ui_prefs_documentitemattributesbase.h"
+#include "prefs_pane.h"
 #include "scribusapi.h"
+#include "scribusstructs.h"
 
-class SCRIBUS_API Prefs_DocumentItemAttributes : public QWidget, Ui::Prefs_DocumentItemAttributes
+class SCRIBUS_API Prefs_DocumentItemAttributes : public Prefs_Pane, Ui::Prefs_DocumentItemAttributes
 {
 	Q_OBJECT
 
 	public:
 		Prefs_DocumentItemAttributes(QWidget* parent=0);
 		~Prefs_DocumentItemAttributes();
+		virtual void restoreDefaults(struct ApplicationPrefs *prefsData);
+		virtual void saveGuiToPrefs(struct ApplicationPrefs *prefsData) const;
+
+	public slots:
+		void languageChange();
+		virtual QStringList getDocAttributesNames();
+
+	protected:
+		virtual void updateTable();
+	protected slots:
+		virtual void tableItemChanged( int row, int col );
+		virtual void addEntry();
+		virtual void deleteEntry();
+		virtual void clearEntries();
+		virtual void copyEntry();
+	private:
+		ObjAttrVector localAttributes;
+		QStringList relationships;
+		QStringList relationshipsData;
+		QStringList autoAddTo;
+		QStringList autoAddToData;
+		QStringList types;
+		QStringList typesData;
 };
 
 #endif // PREFS_DOCUMENTITEMATTRIBUTES_H
Index: scribus/ui/prefs_documentitemattributes.cpp
===================================================================
--- scribus/ui/prefs_documentitemattributes.cpp	(revision 14571)
+++ scribus/ui/prefs_documentitemattributes.cpp	(revision 14572)
@@ -5,16 +5,250 @@
 for which a new license (GPL+exception) is in place.
 */
 
-#include "prefs_documentitemattributes.h"
+#include <QComboBox>
 
+#include "ui/prefs_documentitemattributes.h"
+#include "prefsstructs.h"
+
 Prefs_DocumentItemAttributes::Prefs_DocumentItemAttributes(QWidget* parent)
-	: QWidget(parent)
+	: Prefs_Pane(parent)
 {
 	setupUi(this);
+	languageChange();
 
+	relationships << tr("None", "relationship") << tr("Relates To") << tr("Is Parent Of") << tr("Is Child Of");
+	relationshipsData << "none" << "relation" << "parent" << "child";
+	autoAddTo << tr("None", "auto add") << tr("Text Frames") << tr("Image Frames");
+	autoAddToData << "none" << "textframes" << "imageframes";
+	types << tr("None", "types") << tr("Boolean") << tr("Integer") << tr("Real Number") << tr("String");
+	typesData << "none" << "boolean" << "integer" << "double" << "string";
+
+	connect(attributesTable, SIGNAL(cellChanged(int,int)), this, SLOT(tableItemChanged(int,int)));
+	connect(addButton, SIGNAL(clicked()), this, SLOT(addEntry()));
+	connect(deleteButton, SIGNAL(clicked()), this, SLOT(deleteEntry()));
+	connect(clearButton, SIGNAL(clicked()), this, SLOT(clearEntries()));
+	connect(copyButton, SIGNAL(clicked()), this, SLOT(copyEntry()));
+
 }
 
 Prefs_DocumentItemAttributes::~Prefs_DocumentItemAttributes()
 {
 }
 
+void Prefs_DocumentItemAttributes::languageChange()
+{
+
+}
+
+void Prefs_DocumentItemAttributes::restoreDefaults(struct ApplicationPrefs *prefsData)
+{
+	localAttributes=prefsData->itemAttrPrefs.defaultItemAttributes;
+	updateTable();
+}
+
+void Prefs_DocumentItemAttributes::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const
+{
+	prefsData->itemAttrPrefs.defaultItemAttributes=localAttributes;
+}
+
+void Prefs_DocumentItemAttributes::tableItemChanged( int row, int col )
+{
+	switch (col)
+	{
+	case 0:
+		localAttributes[row].name=attributesTable->item(row, col)->text();
+		break;
+	case 1:
+		{
+			QComboBox* qcti=dynamic_cast<QComboBox*>(attributesTable->cellWidget(row,col));
+			if (qcti!=NULL)
+			{
+				int index=qcti->currentIndex();
+				if (index<typesData.count())
+					localAttributes[row].type=typesData[index];
+			}
+		}
+		break;
+	case 2:
+		localAttributes[row].value=attributesTable->item(row, col)->text();
+		break;
+	case 3:
+		localAttributes[row].parameter=attributesTable->item(row, col)->text();
+		break;
+	case 4:
+		{
+			QComboBox* qcti=dynamic_cast<QComboBox*>(attributesTable->cellWidget(row,col));
+			if (qcti!=NULL)
+			{
+				int index=qcti->currentIndex();
+				if (index<relationshipsData.count())
+					localAttributes[row].relationship=relationshipsData[index];
+			}
+		}
+		break;
+	case 5:
+		localAttributes[row].relationshipto=attributesTable->item(row, col)->text();
+		break;
+	case 6:
+		{
+			QComboBox* qcti=dynamic_cast<QComboBox*>(attributesTable->cellWidget(row,col));
+			if (qcti!=NULL)
+			{
+				int index=qcti->currentIndex();
+				if (index<autoAddToData.count())
+					localAttributes[row].autoaddto=autoAddToData[index];
+			}
+		}
+		break;
+	default:
+		break;
+	}
+}
+
+
+void Prefs_DocumentItemAttributes::addEntry()
+{
+	ObjectAttribute blank;
+	blank.relationship="none";
+	blank.autoaddto="none";
+	blank.type="none";
+	localAttributes.append(blank);
+	updateTable();
+}
+
+
+void Prefs_DocumentItemAttributes::updateTable()
+{
+	attributesTable->setRowCount(localAttributes.count());
+	int row=0;
+	for(ObjAttrVector::Iterator it = localAttributes.begin(); it!= localAttributes.end(); ++it)
+	{
+		uint i=0;
+		//Name
+		QTableWidgetItem *item1 = new QTableWidgetItem((*it).name);
+		attributesTable->setItem(row, i++, item1);
+		//Type
+		QComboBox *item2 = new QComboBox();
+		item2->addItems(types);
+/* <<7636
+		int listIndex=types.indexOf((*it).type);
+		if (listIndex!=-1)
+			item2->setCurrentIndex(listIndex);
+		else
+		{
+			item2->setCurrentIndex(0);
+			item2->setItemText(0,(*it).type);
+		}
+ >>7636 */
+		int listIndex=typesData.indexOf((*it).type);
+		if (listIndex==-1)
+		{
+			(*it).type="none";
+			listIndex=0;
+		}
+		item2->setCurrentIndex(listIndex);
+
+		item2->setEditable(true);
+		attributesTable->setCellWidget(row, i++, item2);
+		//Default Value
+		QTableWidgetItem *item3 = new QTableWidgetItem((*it).value);
+		attributesTable->setItem(row, i++, item3);
+		//Default Parameter
+		QTableWidgetItem *item4 = new QTableWidgetItem((*it).parameter);
+		attributesTable->setItem(row, i++, item4);
+		//Relationship
+		QComboBox *item5 = new QComboBox();
+		item5->addItems(relationships);
+		attributesTable->setCellWidget(row, i++, item5);
+		int index=relationshipsData.indexOf((*it).relationship);
+		if (index==-1)
+		{
+			(*it).relationship="none";
+			index=0;
+		}
+		item5->setCurrentIndex(index);
+		//Relationship to
+		QTableWidgetItem *item6 = new QTableWidgetItem((*it).relationshipto);
+		attributesTable->setItem(row, i++, item6);
+		//Auto Add to
+		QComboBox *item7 = new QComboBox();
+		item7->addItems(autoAddTo);
+		attributesTable->setCellWidget(row, i++, item7);
+		int index2=autoAddToData.indexOf((*it).autoaddto);
+		if (index2==-1)
+		{
+			(*it).relationship="none";
+			index2=0;
+		}
+		item7->setCurrentIndex(index2);
+
+		QTableWidgetItem *t=attributesTable->verticalHeaderItem(row);
+		if (t!=NULL)
+			t->setText(QString("%1").arg(row));
+		row++;
+	}
+	deleteButton->setEnabled(localAttributes.count()!=0);
+	copyButton->setEnabled(localAttributes.count()!=0);
+	clearButton->setEnabled(localAttributes.count()!=0);
+}
+
+
+void Prefs_DocumentItemAttributes::deleteEntry()
+{
+	int currRow=attributesTable->currentRow();
+	bool found=false;
+	ObjAttrVector::Iterator it;
+	int count=0;
+	for(it = localAttributes.begin(); it!= localAttributes.end(); ++it)
+	{
+		if(count==currRow)
+		{
+			found=true;
+			break;
+		}
+		++count;
+	}
+	if (found)
+	{
+		localAttributes.erase(it);
+		updateTable();
+	}
+}
+
+
+void Prefs_DocumentItemAttributes::clearEntries()
+{
+	localAttributes.clear();
+	updateTable();
+}
+
+
+void Prefs_DocumentItemAttributes::copyEntry()
+{
+	int currRow=attributesTable->currentRow();
+	bool found=false;
+	ObjAttrVector::Iterator it;
+	int count=0;
+	for(it = localAttributes.begin(); it!= localAttributes.end(); ++it)
+	{
+		if(count==currRow)
+		{
+			found=true;
+			break;
+		}
+		++count;
+	}
+	if (found)
+	{
+		localAttributes.append((*it));
+		updateTable();
+	}
+}
+
+QStringList Prefs_DocumentItemAttributes::getDocAttributesNames()
+{
+	QStringList nameList;
+	for(ObjAttrVector::Iterator it = localAttributes.begin(); it!= localAttributes.end(); ++it)
+		nameList.append((*it).name);
+	return nameList;
+}
Index: scribus/ui/prefs_imagecachebase.ui
===================================================================
--- scribus/ui/prefs_imagecachebase.ui	(revision 14571)
+++ scribus/ui/prefs_imagecachebase.ui	(revision 14572)
@@ -96,7 +96,7 @@
             <enum>QAbstractSpinBox::UpDownArrows</enum>
            </property>
            <property name="suffix">
-            <string> MiB</string>
+            <string> Mb</string>
            </property>
            <property name="minimum">
             <number>100</number>
Index: scribus/ui/preferencesdialog.cpp
===================================================================
--- scribus/ui/preferencesdialog.cpp	(revision 14571)
+++ scribus/ui/preferencesdialog.cpp	(revision 14572)
@@ -126,6 +126,8 @@
 	prefs_Printer->restoreDefaults(&localPrefs);
 	prefs_PDFExport->restoreDefaults(&localPrefs);
 	prefs_PreflightVerifier->restoreDefaults(&localPrefs);
+	prefs_DocumentItemAttributes->restoreDefaults(&localPrefs);
+	prefs_TableOfContents->restoreDefaults(&localPrefs);
 	prefs_ColorManagement->restoreDefaults(&localPrefs);
 	prefs_ColorManagement->setProfiles(&localPrefs, &ScCore->InputProfiles, &ScCore->InputProfilesCMYK, &ScCore->PrinterProfiles, &ScCore->MonitorProfiles);
 	prefs_Scrapbook->restoreDefaults(&localPrefs);
@@ -148,6 +150,8 @@
 	prefs_Printer->saveGuiToPrefs(&localPrefs);
 	prefs_PDFExport->saveGuiToPrefs(&localPrefs);
 	prefs_PreflightVerifier->saveGuiToPrefs(&localPrefs);
+	prefs_DocumentItemAttributes->saveGuiToPrefs(&localPrefs);
+	prefs_TableOfContents->saveGuiToPrefs(&localPrefs);
 	prefs_ColorManagement->saveGuiToPrefs(&localPrefs);
 	prefs_Scrapbook->saveGuiToPrefs(&localPrefs);
 	prefs_Display->saveGuiToPrefs(&localPrefs);
@@ -214,6 +218,8 @@
 		prefsStackWidget->setCurrentIndex(stackWidgetMap[ic]);
 		if (prefsStackWidget->currentWidget()==dynamic_cast<QWidget*>(prefs_ItemTools))
 			prefs_ItemTools->enableFontPreview(true);
+		if (prefsStackWidget->currentWidget()==dynamic_cast<QWidget*>(prefs_TableOfContents))
+			prefs_TableOfContents->setupItemAttrs( prefs_DocumentItemAttributes->getDocAttributesNames() );;
 	}
 }
 
Index: scribus/ui/prefs_tableofcontents.cpp
===================================================================
--- scribus/ui/prefs_tableofcontents.cpp	(revision 14571)
+++ scribus/ui/prefs_tableofcontents.cpp	(revision 14572)
@@ -5,10 +5,11 @@
 for which a new license (GPL+exception) is in place.
 */
 
-#include "prefs_tableofcontents.h"
+#include "ui/prefs_tableofcontents.h"
+#include "prefsstructs.h"
 
 Prefs_TableOfContents::Prefs_TableOfContents(QWidget* parent)
-	: QWidget(parent)
+	: Prefs_Pane(parent)
 {
 	setupUi(this);
 
@@ -18,3 +19,33 @@
 {
 }
 
+void Prefs_TableOfContents::restoreDefaults(struct ApplicationPrefs *prefsData)
+{
+
+}
+
+void Prefs_TableOfContents::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const
+{
+
+}
+
+void Prefs_TableOfContents::languageChange()
+{
+
+}
+
+void Prefs_TableOfContents::setupItemAttrs( QStringList newNames )
+{
+//	disconnect( itemAttrComboBox, SIGNAL( activated(const QString&) ), this, SLOT( itemAttributeSelected(const QString&) ) );
+//	itemAttrComboBox->clear();
+//	itemAttrComboBox->addItem(trStrNone);
+//	itemAttrComboBox->addItems(newNames);
+//	if (numSelected!=999)
+//	{
+//		if (localToCSetupVector[numSelected].itemAttrName==strNone)
+//			setCurrentComboItem(itemAttrComboBox, trStrNone);
+//		else
+//			setCurrentComboItem(itemAttrComboBox, localToCSetupVector[numSelected].itemAttrName);
+//	}
+//	connect( itemAttrComboBox, SIGNAL( activated(const QString&) ), this, SLOT( itemAttributeSelected(const QString&) ) );
+}




More information about the scribus-commit mailing list