r21855 by jghali - #14479: Copy and Paste very slow on Windows

scribus-commit scribus-commit at lists.scribus.net
Wed Mar 29 19:02:37 UTC 2017


Author: jghali
Date: Wed Mar 29 19:02:37 2017
New Revision: 21855

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21855
Log:
#14479: Copy and Paste very slow on Windows

Added:
    trunk/Scribus/scribus/ui/colorlistmodel.cpp
    trunk/Scribus/scribus/ui/colorlistmodel.h
Modified:
    trunk/Scribus/Scribus.pro
    trunk/Scribus/scribus/CMakeLists.txt
    trunk/Scribus/scribus/plugins/colorwheel/cwdialog.cpp
    trunk/Scribus/scribus/plugins/colorwheel/cwdialog.h
    trunk/Scribus/scribus/plugins/tools/pathfinder/pathfinderdialog.cpp
    trunk/Scribus/scribus/ui/annot.cpp
    trunk/Scribus/scribus/ui/cmykfw.cpp
    trunk/Scribus/scribus/ui/cmykfw.h
    trunk/Scribus/scribus/ui/cmykfwbase.ui
    trunk/Scribus/scribus/ui/colorcombo.cpp
    trunk/Scribus/scribus/ui/colorcombo.h
    trunk/Scribus/scribus/ui/colorlistbox.cpp
    trunk/Scribus/scribus/ui/colorlistbox.h
    trunk/Scribus/scribus/ui/colorpalette.ui
    trunk/Scribus/scribus/ui/cpalette.cpp
    trunk/Scribus/scribus/ui/cpalette.h
    trunk/Scribus/scribus/ui/dcolor.cpp
    trunk/Scribus/scribus/ui/effectsdialog.cpp
    trunk/Scribus/scribus/ui/gradienteditor.cpp
    trunk/Scribus/scribus/ui/propertiespalette_table.cpp
    trunk/Scribus/scribus/ui/propertywidget_textcolor.cpp
    trunk/Scribus/scribus/ui/proptree.cpp
    trunk/Scribus/scribus/ui/replaceonecolor.cpp
    trunk/Scribus/scribus/ui/search.cpp
    trunk/Scribus/scribus/ui/selectobjects.cpp
    trunk/Scribus/scribus/ui/smcellstylewidget.cpp
    trunk/Scribus/scribus/ui/smcstylewidget.cpp
    trunk/Scribus/scribus/ui/smlinestylewidget.cpp
    trunk/Scribus/scribus/ui/smpstylewidget.cpp
    trunk/Scribus/scribus/ui/smtablestylewidget.cpp
    trunk/Scribus/scribus/ui/storyeditor.cpp
    trunk/Scribus/win32/vc11/scribus-main/Scribus.vcxproj
    trunk/Scribus/win32/vc11/scribus-main/Scribus.vcxproj.filters

Modified: trunk/Scribus/Scribus.pro
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/Scribus.pro
==============================================================================
--- trunk/Scribus/Scribus.pro	(original)
+++ trunk/Scribus/Scribus.pro	Wed Mar 29 19:02:37 2017
@@ -385,6 +385,7 @@
            scribus/ui/colorchart.h \
            scribus/ui/colorcombo.h \
            scribus/ui/colorlistbox.h \
+		   scribus/ui/colorlistmodel.h \
            scribus/ui/contextmenu.h \
            scribus/ui/copypagetomasterpagedialog.h \
            scribus/ui/cpalette.h \
@@ -1459,6 +1460,7 @@
            scribus/ui/colorchart.cpp \
            scribus/ui/colorcombo.cpp \
            scribus/ui/colorlistbox.cpp \
+           scribus/ui/colorlistmodel.cpp \
            scribus/ui/contextmenu.cpp \
            scribus/ui/copypagetomasterpagedialog.cpp \
            scribus/ui/cpalette.cpp \

Modified: trunk/Scribus/scribus/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/CMakeLists.txt
==============================================================================
--- trunk/Scribus/scribus/CMakeLists.txt	(original)
+++ trunk/Scribus/scribus/CMakeLists.txt	Wed Mar 29 19:02:37 2017
@@ -334,6 +334,7 @@
 	ui/colorchart.h
 	ui/colorcombo.h
 	ui/colorlistbox.h
+	ui/colorlistmodel.h
 	ui/contextmenu.h
 	ui/cpalette.h
 	ui/cupsoptions.h
@@ -804,6 +805,7 @@
 	ui/colorchart.cpp
 	ui/colorcombo.cpp
 	ui/colorlistbox.cpp
+	ui/colorlistmodel.cpp
 	ui/contextmenu.cpp
 	ui/cpalette.cpp
 	ui/cupsoptions.cpp

Modified: trunk/Scribus/scribus/plugins/colorwheel/cwdialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/plugins/colorwheel/cwdialog.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/colorwheel/cwdialog.cpp	(original)
+++ trunk/Scribus/scribus/plugins/colorwheel/cwdialog.cpp	Wed Mar 29 19:02:37 2017
@@ -50,7 +50,7 @@
 	defectCombo->addItem(CommonStrings::trVisionFullColorBlind);
 	// document colors
 	documentColorList->setPixmapType(ColorListBox::fancyPixmap);
-	documentColorList->updateBox(m_Doc->PageColors);
+	documentColorList->setColors(m_Doc->PageColors, false);
 	// preferences
 	prefs = PrefsManager::instance()->prefsFile->getPluginContext("colorwheel");
 	typeCombo->setCurrentIndex(prefs->getInt("cw_type", 0));
@@ -83,9 +83,9 @@
 	else if (colorspaceTab->currentWidget() == tabDocument)
 	{
 		colorWheel->actualColor = color;
-		QList<QListWidgetItem*> results = documentColorList->findItems(colorName, Qt::MatchFixedString|Qt::MatchCaseSensitive);
+		QStringList results = documentColorList->findColors(colorName, Qt::MatchFixedString|Qt::MatchCaseSensitive);
 		if (results.count() > 0)
-			documentColorList->setCurrentItem(results[0]);
+			documentColorList->setCurrentColor(results[0]);
 	}
 	else
 		colorWheel->actualColor = color;
@@ -100,10 +100,10 @@
 	// signals and slots that cannot be in ui file
 	connect(colorWheel, SIGNAL(clicked(int, const QPoint&)),
 			this, SLOT(colorWheel_clicked(int, const QPoint&)));
-	connect(documentColorList, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
-			this, SLOT(documentColorList_currentChanged(QListWidgetItem *)));
-	connect(colorList, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
-			this, SLOT(colorList_currentChanged(QListWidgetItem *)));
+	connect(documentColorList, SIGNAL(currentTextChanged(const QString &)),
+			this, SLOT(documentColorList_currentChanged(const QString &)));
+	connect(colorList, SIGNAL(currentTextChanged(const QString &)),
+			this, SLOT(colorList_currentChanged(const QString &)));
 	connect(angleSpin, SIGNAL(valueChanged(int)),
 			this, SLOT(angleSpin_valueChanged(int)));
 	connect(colorspaceTab, SIGNAL(currentChanged(int)),
@@ -164,9 +164,9 @@
 	}
 }
 
-void CWDialog::documentColorList_currentChanged(QListWidgetItem *item)
-{
-	if (!item)
+void CWDialog::documentColorList_currentChanged(const QString& itemText)
+{
+	if (itemText.isEmpty())
 		return;
 	ScColor c(m_Doc->PageColors[documentColorList->currentColor()]);
 	colorWheel->currentColorSpace = c.getColorModel();
@@ -182,12 +182,9 @@
 		colorWheel->currentColorSpace = colorModelRGB;
 	if (tab == tabDocument)
 	{
-		if (!documentColorList->currentItem())
-		{
-			documentColorList->setCurrentItem(documentColorList->item(0));
-			documentColorList->item(0)->setSelected(true);
-		}
-		documentColorList_currentChanged(documentColorList->currentItem());
+		if (!documentColorList->hasSelection())
+			documentColorList->setCurrentRow(0);
+		documentColorList_currentChanged(documentColorList->currentColor());
 	}
 	processColors(typeCombo->currentIndex(), true);
 }
@@ -235,7 +232,7 @@
 		setupHSVComponent(colorWheel->actualColor);
 	}
 	updateNamedLabels();
-	QList<QListWidgetItem*> results = colorList->findItems(colorWheel->trBaseColor, Qt::MatchFixedString|Qt::MatchCaseSensitive);
+	QStringList results = colorList->findColors(colorWheel->trBaseColor, Qt::MatchFixedString|Qt::MatchCaseSensitive);
 	if (results.count() > 0)
 		colorList_currentChanged(results[0]);
 	colorWheel->update(); // force paint event
@@ -301,15 +298,16 @@
 {
 	int ix = colorList->currentRow();
 	colorList->updateBox(colorWheel->colorList);
-	QList<QListWidgetItem*> results = colorList->findItems(colorWheel->trBaseColor, Qt::MatchFixedString|Qt::MatchCaseSensitive);
+	QStringList results = colorList->findColors(colorWheel->trBaseColor, Qt::MatchFixedString|Qt::MatchCaseSensitive);
 	if (results.count() > 0)
 	{
-		QListWidgetItem *item = results[0];
-		int row = colorList->row(item);
+		QString itemColor = results[0];
+		int row = colorList->row(itemColor);
 		if (row > 0)
 		{
-			colorList->takeItem(row);
-			colorList->insertItem(0, item);
+			ScColor color = colorWheel->colorList.value(itemColor);
+			colorList->removeItem(row);
+			colorList->insertItem(0, color, itemColor);
 		}
 	}
 	colorList->setCurrentRow(ix > colorList->count() ? 0 : ix);
@@ -508,13 +506,13 @@
 	hsvLabel2->setText(getHexHsv(colorWheel->actualColor));
 }
 
-void CWDialog::colorList_currentChanged(QListWidgetItem * item)
-{
-	if (!item)
+void CWDialog::colorList_currentChanged(const QString& itemText)
+{
+	if (itemText.isEmpty())
 		return;
 
 	// if it's base color we do not need to recompute it again
-	if (item->text() == colorWheel->trBaseColor)
+	if (itemText == colorWheel->trBaseColor)
 	{
 		currentColorTable->setItem(0, 4, new QTableWidgetItem(cmykLabel->text()));
 		currentColorTable->setItem(1, 4, new QTableWidgetItem(rgbLabel->text()));
@@ -532,7 +530,7 @@
 	}
 	else
 	{
-		ScColor col(colorWheel->colorList[item->text()]);
+		ScColor col(colorWheel->colorList[itemText]);
 		currentColorTable->setItem(0, 4, new QTableWidgetItem(col.nameCMYK(m_Doc)));
 		currentColorTable->setItem(1, 4, new QTableWidgetItem(col.nameRGB(m_Doc)));
 		currentColorTable->setItem(2, 4, new QTableWidgetItem(getHexHsv(col)));

Modified: trunk/Scribus/scribus/plugins/colorwheel/cwdialog.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/plugins/colorwheel/cwdialog.h
==============================================================================
--- trunk/Scribus/scribus/plugins/colorwheel/cwdialog.h	(original)
+++ trunk/Scribus/scribus/plugins/colorwheel/cwdialog.h	Wed Mar 29 19:02:37 2017
@@ -101,12 +101,12 @@
 		void angleSpin_valueChanged(int);
 		void colorWheel_clicked(int, const QPoint &);
 		void typeCombo_activated(int);
-		void documentColorList_currentChanged(QListWidgetItem *);
+		void documentColorList_currentChanged(const QString& itemText);
 		void defectCombo_activated(int);
 		void addButton_clicked();
 		void replaceButton_clicked();
 		void cancelButton_clicked();
-		void colorList_currentChanged(QListWidgetItem *);
+		void colorList_currentChanged(const QString& text);
 
 		void cSpin_valueChanged( int );
 		void mSpin_valueChanged( int );

Modified: trunk/Scribus/scribus/plugins/tools/pathfinder/pathfinderdialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/plugins/tools/pathfinder/pathfinderdialog.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/tools/pathfinder/pathfinderdialog.cpp	(original)
+++ trunk/Scribus/scribus/plugins/tools/pathfinder/pathfinderdialog.cpp	Wed Mar 29 19:02:37 2017
@@ -50,11 +50,9 @@
 	opSubtraction->setIcon(QIcon(IconManager::instance()->loadIcon("pathsubtraction.png")));
 	opCombine->setIcon(QIcon(IconManager::instance()->loadIcon("pathunite.png")));
 	otherColorComboLine->setPixmapType(ColorCombo::fancyPixmaps);
-	otherColorComboLine->addItem(CommonStrings::tr_NoneColor);
-	otherColorComboLine->insertItems(m_doc->PageColors);
+	otherColorComboLine->setColors(m_doc->PageColors, true);
 	otherColorComboFill->setPixmapType(ColorCombo::fancyPixmaps);
-	otherColorComboFill->addItem(CommonStrings::tr_NoneColor);
-	otherColorComboFill->insertItems(m_doc->PageColors);
+	otherColorComboFill->setColors(m_doc->PageColors, true);
 	setCurrentComboItem(otherColorComboLine, shape1->lineColor());
 	setCurrentComboItem(otherColorComboFill, shape1->fillColor());
 	opMode = 0;

Modified: trunk/Scribus/scribus/ui/annot.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/ui/annot.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/annot.cpp	(original)
+++ trunk/Scribus/scribus/ui/annot.cpp	Wed Mar 29 19:02:37 2017
@@ -103,15 +103,11 @@
 
 	ColorList::Iterator cit;
 	BorderC->setPixmapType(ColorCombo::fancyPixmaps);
-	BorderC->addItem(CommonStrings::tr_NoneColor);
+	BorderC->setColors(Farben, true);
 	if (annotation.borderColor() == CommonStrings::None)
-		BorderC->setCurrentIndex(BorderC->count()-1);
-	for (cit = Farben.begin(); cit != Farben.end(); ++cit)
-	{
-		BorderC->insertItem(cit.value(), doc, cit.key());
-		if (cit.key() == annotation.borderColor())
-			BorderC->setCurrentIndex(BorderC->count()-1);
-	}
+		BorderC->setCurrentIndex(0);
+	else
+		BorderC->setCurrentText(annotation.borderColor());
 
 	// PFJ - 28/02/04 - Altered to the QString/size_t/for style
 	QString borders[] = {CommonStrings::tr_NoneColor, tr("Thin"), tr("Normal"), tr("Wide")};

Modified: trunk/Scribus/scribus/ui/cmykfw.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/ui/cmykfw.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/cmykfw.cpp	(original)
+++ trunk/Scribus/scribus/ui/cmykfw.cpp	Wed Mar 29 19:02:37 2017
@@ -233,7 +233,7 @@
 	connect( ComboBox1, SIGNAL(activated(const QString&)), this, SLOT(selModel(const QString&)));
 //	connect( Swatches, SIGNAL(activated(int)), this, SLOT(selSwatch(int)));
 	connect(Swatches, SIGNAL(activated(const QString &)), this, SLOT(selSwatch()));
-	connect(ColorSwatch, SIGNAL( itemClicked(QListWidgetItem*) ), this, SLOT( selFromSwatch(QListWidgetItem*) ) );
+	connect(ColorSwatch, SIGNAL(itemClicked(int) ), this, SLOT( selFromSwatch(int) ) );
 	connect(Separations, SIGNAL(clicked()), this, SLOT(setSpot()));
 //	connect(Regist, SIGNAL(clicked()), this, SLOT(setRegist()));
 	connect(this, SIGNAL(customContextMenuRequested (const QPoint &)), this, SLOT(slotRightClick()));
@@ -553,9 +553,8 @@
 			CurrSwatch.insert("Yellow", ScColor(0, 0, 255, 0));
 			CurrSwatch.insert("Magenta", ScColor(0, 255, 0, 0));
 		}
-		ColorSwatch->clear();
-		ColorSwatch->insertItems(CurrSwatch);
-		ColorSwatch->setCurrentRow( 0 );
+		ColorSwatch->setColors(CurrSwatch, false);
+		ColorSwatch->setCurrentRow(0);
 		TabStack->setCurrentIndex(1);
 	}
 }
@@ -973,10 +972,11 @@
 		setValues();
 }
 
-void CMYKChoose::selFromSwatch(QListWidgetItem* c)
-{
-	disconnect( ComboBox1, SIGNAL(activated(const QString&)), this, SLOT(selModel(const QString&)));
-	ScColor tmp = CurrSwatch[c->text()];
+void CMYKChoose::selFromSwatch(int itemIndex)
+{
+	QSignalBlocker comboBox1Blocker(ComboBox1);
+	QString colorName = ColorSwatch->text(itemIndex);
+	ScColor tmp = CurrSwatch[colorName];
 	if (isRegistration)
 	{
 		if (tmp.getColorModel() != colorModelCMYK)
@@ -1009,8 +1009,7 @@
 	setValues();
 	Separations->setChecked(tmp.isSpotColor());
 	if ((isNew) && (!ColorName->isModified()))
-		ColorName->setText(c->text());
-	connect( ComboBox1, SIGNAL(activated(const QString&)), this, SLOT(selModel(const QString&)));
+		ColorName->setText(colorName);
 }
 
 void CMYKChoose::setValues()

Modified: trunk/Scribus/scribus/ui/cmykfw.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/ui/cmykfw.h
==============================================================================
--- trunk/Scribus/scribus/ui/cmykfw.h	(original)
+++ trunk/Scribus/scribus/ui/cmykfw.h	Wed Mar 29 19:02:37 2017
@@ -53,7 +53,7 @@
 	void selModel(const QString& mod);
 	void setColor();
 	void setColor2(int h, int s, bool ende);
-	void selFromSwatch(QListWidgetItem* c);
+	void selFromSwatch(int itemIndex);
 	void setValues();
 	void leave();
 

Modified: trunk/Scribus/scribus/ui/cmykfwbase.ui
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/ui/cmykfwbase.ui
==============================================================================
--- trunk/Scribus/scribus/ui/cmykfwbase.ui	(original)
+++ trunk/Scribus/scribus/ui/cmykfwbase.ui	Wed Mar 29 19:02:37 2017
@@ -599,7 +599,7 @@
   </customwidget>
   <customwidget>
    <class>ColorListBox</class>
-   <extends>QListWidget</extends>
+   <extends>QListView</extends>
    <header>ui/colorlistbox.h</header>
   </customwidget>
   <customwidget>

Modified: trunk/Scribus/scribus/ui/colorcombo.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/ui/colorcombo.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/colorcombo.cpp	(original)
+++ trunk/Scribus/scribus/ui/colorcombo.cpp	Wed Mar 29 19:02:37 2017
@@ -14,6 +14,7 @@
  */
 
 #include "colorcombo.h"
+#include "colorlistmodel.h"
 #include "commonstrings.h"
 // #include "qdebug.h"
 
@@ -67,6 +68,19 @@
 	return colorName;
 }
 
+void ColorCombo::setColors(ColorList& list, bool insertNone)
+{
+	ColorListBox* clb = dynamic_cast<ColorListBox*>(view());
+	if (!clb)
+		return;
+
+	ColorListModel* clm = dynamic_cast<ColorListModel*>(clb->model());
+	if (!clm)
+		return;
+
+	clm->setColorList(list, insertNone);
+}
+
 void ColorCombo::setPixmapType(ColorCombo::PixmapType type)
 {
 	ColorListBox* clb = dynamic_cast<ColorListBox*>(view());
@@ -81,49 +95,27 @@
 		clb->setPixmapType(ColorListBox::fancyPixmap);
 }
 
-void ColorCombo::updateBox(ColorList& list, bool insertNone)
-{
-	ColorListBox* clb = dynamic_cast<ColorListBox*>(view());
-	if (!clb)
-		return;
-
-	clb->clear();
-	if (insertNone)
-	{
-		clb->addItem(CommonStrings::tr_NoneColor);
-		clb->item(0)->setData(Qt::UserRole, CommonStrings::None);
-	}
-	clb->insertItems(list);
-}
-
-void ColorCombo::insertItems(ColorList& list)
-{
-	ColorListBox* clb = dynamic_cast<ColorListBox*>(view());
-	if (!clb)
-		return;
-
-	clb->insertItems(list);
-}
-
-void ColorCombo::insertItem(const ScColor& col, ScribusDoc* doc, const QString& colName)
-{
-	ColorListBox* clb = dynamic_cast<ColorListBox*>(view());
-	if (clb)
-		clb->addItem( new ColorPixmapItem(ColorPixmapValue(col, doc, colName)));
-}
-
 void ColorCombo::initColorList(ColorList *colorList, ScribusDoc *doc, QString colorValue)
 {
 	clear();
 	setPixmapType(ColorCombo::fancyPixmaps);
-	addItem(CommonStrings::tr_NoneColor, CommonStrings::None);
+	setColors(*colorList, true);
+
 	if (colorValue == CommonStrings::None)
-		setCurrentIndex(count()-1);
+	{
+		setCurrentIndex(0);
+		return;
+	}
+
+	int index = 0;
 	ColorList::Iterator endOfColorList(colorList->end());
 	for (ColorList::Iterator itc = colorList->begin(); itc != endOfColorList; ++itc)
 	{
-		insertItem( itc.value(), doc, itc.key() );
+		++index;
 		if (itc.key() == colorValue)
-			setCurrentIndex(count()-1);
+		{
+			setCurrentIndex(index);
+			break;
+		}
 	}
 }

Modified: trunk/Scribus/scribus/ui/colorcombo.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/ui/colorcombo.h
==============================================================================
--- trunk/Scribus/scribus/ui/colorcombo.h	(original)
+++ trunk/Scribus/scribus/ui/colorcombo.h	Wed Mar 29 19:02:37 2017
@@ -49,11 +49,9 @@
 
 	QString currentColor() const;
 
+	void setColors(ColorList& list, bool insertNone = true);
 	void setPixmapType(ColorCombo::PixmapType type);
-	void updateBox(ColorList& list, bool insertNone = true);
 
-	void insertItem(const ScColor& col, ScribusDoc* doc, const QString& colName);
-	void insertItems(ColorList& list);
 	void initColorList(ColorList* colorList, ScribusDoc* doc, QString colorValue);
 };
 

Modified: trunk/Scribus/scribus/ui/colorlistbox.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/ui/colorlistbox.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/colorlistbox.cpp	(original)
+++ trunk/Scribus/scribus/ui/colorlistbox.cpp	Wed Mar 29 19:02:37 2017
@@ -13,10 +13,12 @@
 #include <QHelpEvent>
 #include <QMenu>
 #include <QPainter>
+#include <QPersistentModelIndex>
 #include <QPixmap>
 #include <QSignalBlocker>
 #include <QToolTip>
 
+#include "colorlistmodel.h"
 #include "commonstrings.h"
 #include "iconmanager.h"
 #include "sccolorengine.h"
@@ -199,37 +201,62 @@
 int ColorListBox::sortRule;
 
 ColorListBox::ColorListBox(QWidget * parent)
-	: QListWidget(parent)
+	: QListView(parent)
 {
 	cList = NULL;
 	if (initialized != 12345)
 		sortRule = 0;
 	initialized = 12345;
+	QListView::setModel(new ColorListModel(this));
 	setPixmapType(ColorListBox::widePixmap);
+
+	connect(this, SIGNAL(clicked(QModelIndex)),       this, SLOT(emitItemClicked(QModelIndex)));
+	connect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(emitItemDoubleClicked(QModelIndex)));
+	connect(this->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)),
+            this, SLOT(emitCurrentChanged(QModelIndex, QModelIndex)));
+	connect(this->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
+            this, SIGNAL(itemSelectionChanged()));
 	connect(this, SIGNAL(contextMenuRequested()), this, SLOT(slotRightClick()));
 }
 
 ColorListBox::ColorListBox(ColorListBox::PixmapType type, QWidget * parent)
-	: QListWidget(parent)
+	: QListView(parent)
 {
 	cList = NULL;
 	if (initialized != 12345)
 		sortRule = 0;
 	initialized = 12345;
+	QListView::setModel(new ColorListModel(this));
 	setPixmapType(type);
+
+	connect(this, SIGNAL(clicked(QModelIndex)),       this, SLOT(emitItemClicked(QModelIndex)));
+	connect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(emitItemDoubleClicked(QModelIndex)));
+	connect(this->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)),
+            this, SLOT(emitCurrentChanged(QModelIndex, QModelIndex)));
+	connect(this->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
+            this, SIGNAL(itemSelectionChanged()));
 	connect(this, SIGNAL(contextMenuRequested()), this, SLOT(slotRightClick()));
 }
 
 ColorListBox::~ColorListBox()
 {
 	int count = this->count();
-	for(int index = 0; index < count; index++)
-		delete this->item(index);
 	if (itemDelegate())
 		delete itemDelegate();
 	clear();
 }
 
+void ColorListBox::clear()
+{
+	QAbstractItemModel* itemModel = model();
+	itemModel->removeRows(0, itemModel->rowCount());
+}
+
+int ColorListBox::count() const
+{
+	return this->model()->rowCount();
+}
+
 void ColorListBox::changeEvent(QEvent *e)
 {
 	if (e->type() == QEvent::LanguageChange)
@@ -237,12 +264,35 @@
 		languageChange();
 		return;
 	}
-	QListWidget::changeEvent(e);
+	QListView::changeEvent(e);
+}
+
+void ColorListBox::emitCurrentChanged(const QModelIndex &current, const QModelIndex &previous)
+{
+	QPersistentModelIndex persistentCurrent = current;
+
+	QString text = model()->data(current, Qt::DisplayRole).toString();
+	emit currentTextChanged(text);
+	emit currentRowChanged(persistentCurrent.row());
+}
+
+void ColorListBox::emitItemClicked(const QModelIndex &current)
+{
+	QPersistentModelIndex persistentCurrent = current;
+	emit itemClicked(persistentCurrent.row());
+}
+
+void ColorListBox::emitItemDoubleClicked(const QModelIndex &current)
+{
+	QPersistentModelIndex persistentCurrent = current;
+	emit itemDoubleClicked(persistentCurrent.row());
 }
 
 void ColorListBox::languageChange()
 {
-	if (this->count() > 0)
+	// Not needed anymore normally: on language change a paintEvent is sent to widget
+	// and model will return the new translated string for None color
+	/*if (this->count() > 0)
 	{
 		QModelIndexList result;
 		QModelIndex start = model()->index(0, 0, this->rootIndex());
@@ -252,15 +302,127 @@
 		int index = result.first().row();
 		QListWidgetItem* item = this->item(index);
 		item->setText(CommonStrings::tr_NoneColor);
-	}
+	}*/
 }
 
 QString ColorListBox::currentColor() const
 {
 	if (currentRow() >= 0)
-		return item(currentRow())->data(Qt::DisplayRole).toString();
+	{
+		QAbstractItemModel* itemModel = model();
+		return itemModel->data(currentIndex(), Qt::DisplayRole).toString();
+	}
 	else
 		return CommonStrings::tr_NoneColor;
+}
+
+int ColorListBox::currentRow() const
+{
+	return currentIndex().row();
+}
+
+QVariant ColorListBox::data(int row, int role) const
+{
+	QModelIndex index = model()->index(row, 0);
+	return model()->data(index, role);
+}
+
+QStringList ColorListBox::findColors(const QString &name, Qt::MatchFlags flags) const
+{
+	QStringList foundColors;
+	QAbstractItemModel* currentModel = model();
+
+	QModelIndex firstIndex = currentModel->index(0, 0, QModelIndex());
+	QModelIndexList indexes = currentModel->match(firstIndex, Qt::DisplayRole, name, -1, flags);
+	for (int i = 0; i < indexes.count(); ++i)
+	{
+		QModelIndex modelIndex = indexes.at(i);
+		QVariant modelData = currentModel->data(modelIndex, Qt::DisplayRole);
+		foundColors.append(modelData.toString());
+	}
+
+	return foundColors;
+}
+
+bool ColorListBox::hasSelection() const
+{
+	return this->selectionModel()->hasSelection();
+}
+
+void ColorListBox::insertItem(int row, const ScColor& color, QString colorName)
+{
+	ColorListModel* colorListModel = dynamic_cast<ColorListModel*>(model());
+	if (!colorListModel)
+		return;
+
+	ScribusDoc* doc = 0;
+	if (cList)
+		doc = cList->document();
+
+	ColorPixmapValue value(color, doc, colorName);
+	colorListModel->insert(row, value);
+}
+
+bool ColorListBox::isNoneColorShown() const
+{
+	ColorListModel* colorListModel = dynamic_cast<ColorListModel*>(model());
+	if (colorListModel)
+		return colorListModel->isNoneColorShown();
+	return false;
+}
+
+void ColorListBox::removeItem(int i)
+{
+	// None color item cannot be removed
+	if (isNoneColorShown() && (i == 0))
+		return;
+
+	model()->removeRow(i);
+}
+
+int ColorListBox::row(QString colorName)
+{
+	QAbstractItemModel* currentModel = model();
+
+	QModelIndex firstIndex = currentModel->index(0, 0, QModelIndex());
+	QModelIndexList indexes = currentModel->match(firstIndex, Qt::DisplayRole, colorName, -1, Qt::MatchExactly);
+	if (indexes.count() > 0)
+	{
+		const QModelIndex& first = indexes.at(0);
+		return first.row();
+	}
+	return -1;
+}
+
+void ColorListBox::setCurrentColor(QString colorName)
+{
+	if (colorName == CommonStrings::None)
+		colorName == CommonStrings::tr_NoneColor;
+
+	QModelIndex firstIndex = model()->index(0, 0, QModelIndex());
+	QModelIndexList indexes = this->model()->match(firstIndex, Qt::DisplayRole, colorName, -1, Qt::MatchExactly);
+	if (indexes.count() > 0)
+		this->selectionModel()->setCurrentIndex(indexes[0], QItemSelectionModel::ClearAndSelect);
+}
+
+void ColorListBox::setColors(ColorList& list, bool insertNone)
+{
+	ColorList::Iterator it;
+	ScribusDoc* doc = list.document();
+
+	ColorListModel* colorModel = dynamic_cast<ColorListModel*>(this->model());
+	if (!colorModel)
+		return;
+
+	cList = &list;
+
+	colorModel->setColorList(list, insertNone);
+}
+
+void ColorListBox::setCurrentRow(int row)
+{
+	QModelIndex index = this->model()->index(row, 0);
+	selectionModel()->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect);
 }
 
 void ColorListBox::setPixmapType(ColorListBox::PixmapType type)
@@ -303,15 +465,18 @@
 	}
 }
 
+void ColorListBox::setShowNoneColor(bool showNone)
+{
+	ColorListModel* colorListModel = dynamic_cast<ColorListModel*>(model());
+	if (colorListModel)
+		colorListModel->setShowNoneColor(showNone);
+}
+
 void ColorListBox::slotRightClick()
 {
 	QSignalBlocker sigBlocker(this);
-	QString currentSel;
-	QListWidgetItem* itc = currentItem();
-	if (itc)
-		currentSel = itc->text();
-	QListWidgetItem* it = item(0);
-	if (!it)
+	QString currentSel = currentColor();
+	if (currentSel.isEmpty())
 		return;
 
 	QString first;
@@ -321,92 +486,39 @@
 	pmen->addAction( tr("Sort by Type"));
 	sortRule = pmen->actions().indexOf(pmen->exec(QCursor::pos()));
 	delete pmen;
-	if (it->text() == CommonStrings::None || it->text() == CommonStrings::tr_NoneColor)
-		first = it->text();
+
+	ColorListModel* colorListModel = dynamic_cast<ColorListModel*>(model());
+	if (!colorListModel)
+		return;
+
+	if (sortRule == 0)
+		colorListModel->setSortRule(ColorListModel::SortByName);
+	else if (sortRule == 1)
+		colorListModel->setSortRule(ColorListModel::SortByValues);
+	else if (sortRule == 2)
+		colorListModel->setSortRule(ColorListModel::SortByType);
+
+	if (!currentSel.isEmpty())
+		setCurrentColor(currentSel);
+}
+
+QString ColorListBox::text(int row)
+{
+	QVariant varText = data(row, Qt::DisplayRole);
+	return varText.toString();
+}
+
+void ColorListBox::updateBox(ColorList& list)
+{
+	bool showNoneColor = false;
+
 	clear();
 	reset();
-	if (!first.isEmpty())
-		addItem(first);
-	insertItems( *cList );
-	if (!currentSel.isEmpty())
-	{
-		QList<QListWidgetItem *> items = findItems(currentSel, Qt::MatchExactly);
-		if (items.count() > 0)
-			setCurrentItem(items[0]);
-	}
-}
-
-void ColorListBox::updateBox(ColorList& list)
-{
-	clear();
-	reset();
-	insertItems(list);
-}
-
-void ColorListBox::insertItems(ColorList& list)
-{
-	ColorList::Iterator it;
-	ScribusDoc* doc = list.document();
-
-	cList = &list;
-
-	if (sortRule > 0)
-	{
-		QMap<QString, QString> sortMap;
-		for (it = list.begin(); it != list.end(); ++it)
-		{
-			if (it.key() == CommonStrings::None || it.key() == CommonStrings::tr_NoneColor)
-				continue;
-			if (sortRule == 1)
-			{
-				QColor c = it.value().getRawRGBColor();
-				QString sortString = QString("%1-%2-%3-%4").arg(c.hue(), 3, 10, QChar('0')).arg(c.saturation(), 3, 10, QChar('0')).arg(c.value(), 3, 10, QChar('0')).arg(it.key());
-				sortMap.insert(sortString, it.key());
-			}
-			else if (sortRule == 2)
-			{
-				QString sortString = QString("%1-%2");
-				if (it.value().isRegistrationColor())
-					sortMap.insert(sortString.arg("A").arg(it.key()), it.key());
-				else if (it.value().isSpotColor())
-					sortMap.insert(sortString.arg("B").arg(it.key()), it.key());
-				else if (it.value().getColorModel() == colorModelCMYK)
-					sortMap.insert(sortString.arg("C").arg(it.key()), it.key());
-				else
-					sortMap.insert(sortString.arg("D").arg(it.key()), it.key());
-			}
-		}
-
-		QMap<QString, QString>::Iterator itc;
-		for (itc = sortMap.begin(); itc != sortMap.end(); ++itc)
-		{
-			addItem( new ColorPixmapItem(list[itc.value()], doc, itc.value()) );
-		}
-	}
-	else
-	{
-		for (it = list.begin(); it != list.end(); ++it)
-		{
-			if (it.key() == CommonStrings::None || it.key() == CommonStrings::tr_NoneColor)
-				continue;
-			addItem( new ColorPixmapItem(it.value(), doc, it.key()) );
-		}
-	}
-}
-
-void ColorListBox::addItem(ColorPixmapItem* item)
-{
-	QListWidget::addItem(item);
-}
-
-void ColorListBox::addItem(QString text)
-{
-	QListWidget::addItem(text);
-	if (text == CommonStrings::None || text == CommonStrings::tr_NoneColor)
-	{
-		QListWidgetItem* item = this->item(count() - 1);
-		item->setData(Qt::UserRole, CommonStrings::None);
-	}
+
+	ColorListModel* colorModel = dynamic_cast<ColorListModel*>(this->model());
+	if (colorModel)
+		showNoneColor = colorModel->isNoneColorShown();
+	setColors(list, showNoneColor);
 }
 
 bool ColorListBox::viewportEvent(QEvent *event)
@@ -429,5 +541,5 @@
 			}
 		}
 	}
-	return QListWidget::viewportEvent(event);
-}
+	return QListView::viewportEvent(event);
+}

Modified: trunk/Scribus/scribus/ui/colorlistbox.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/ui/colorlistbox.h
==============================================================================
--- trunk/Scribus/scribus/ui/colorlistbox.h	(original)
+++ trunk/Scribus/scribus/ui/colorlistbox.h	Wed Mar 29 19:02:37 2017
@@ -7,55 +7,20 @@
 #ifndef COLORLISTBOX_H
 #define COLORLISTBOX_H
 
+#include <QListView>
 #include <QListWidget>
 #include <QColor>
 #include <QPointer>
+#include <QString>
+#include <QStringList>
 
+#include "colorlistmodel.h"
 #include "colorsetmanager.h"
 #include "commonstrings.h"
+#include "sccolor.h"
+#include "scguardedptr.h"
+#include "sclistboxpixmap.h"
 #include "scribusapi.h"
-#include "sclistboxpixmap.h"
-#include "scguardedptr.h"
-#include "sccolor.h"
-
-struct SCRIBUS_API ColorPixmapValue
-{
-	ScColor m_color;
-	ScGuardedPtr<ScribusDoc> m_doc;
-	QString m_name;
-
-	ColorPixmapValue();
-	ColorPixmapValue( const ScColor& col, ScribusDoc* doc, const QString colName );
-	ColorPixmapValue(const ColorPixmapValue& other);
-	ColorPixmapValue& operator= (const ColorPixmapValue& other);
-};
-
-
-Q_DECLARE_METATYPE(ColorPixmapValue)
-
-class ColorPixmapItem : public QListWidgetItem
-{
-	enum usrType {
-		ColorPixmapUserType = UserType + 1
-	};
-public:	
-	ColorPixmapItem( const ScColor& col, ScribusDoc* doc, const QString colName) : QListWidgetItem(NULL, ColorPixmapUserType) { 
-		setText(colName);
-		setData(Qt::UserRole, QVariant::fromValue(ColorPixmapValue(col, doc, colName))); 
-	};
-	ColorPixmapItem( const ColorPixmapValue& col) : QListWidgetItem(NULL, ColorPixmapUserType) { 
-		setText(col.m_name);
-		setData(Qt::UserRole, QVariant::fromValue(col));
-	};
-	ColorPixmapItem( ) : QListWidgetItem(NULL, ColorPixmapUserType) { 
-		setText(CommonStrings::tr_NoneColor);
-		setData(Qt::UserRole, QVariant::fromValue(ColorPixmapValue(ScColor(0,0,0,0), NULL, CommonStrings::tr_NoneColor))); 
-	};
-	QListWidgetItem * clone () const { return new ColorPixmapItem(*this); }
-	QString colorName() const { return data(Qt::UserRole).value<ColorPixmapValue>().m_name; }
-};
-
-
 
 /*! \brief Very nice list box with color names and samples.
 It's inherited from QListBox with all its methods and properties.
@@ -64,7 +29,7 @@
 Edit/Colors dialogs in action.
 \author Petr Vanek <petr at yarpen.cz>
 */
-class SCRIBUS_API ColorListBox : public QListWidget
+class SCRIBUS_API ColorListBox : public QListView
 {
 	Q_OBJECT
 
@@ -85,7 +50,32 @@
 
 		virtual void changeEvent(QEvent *e);
 
+		/*! Return the current color name */
 		QString currentColor() const;
+
+		/*! Return the current row */
+		int currentRow() const;
+
+		/*! Return row count */
+		int count() const;
+
+		/*! Return model data for the given row and role */
+		QVariant data(int row, int role) const;
+
+		/*! Finds colors whose name matches the given string name using the given flags. */
+		QStringList findColors(const QString &name, Qt::MatchFlags flags) const;
+
+		/*! Return if a color is currently selected */
+		bool hasSelection() const;
+
+		/*! Insert color at specified position */
+		void insertItem(int row, const ScColor& color, QString colorName);
+
+		/*! Return if none color is shown at beginning oh list */
+		bool isNoneColorShown() const;
+		
+		/*! \brief Retrieve the pixmap type used by this listbox */
+		ColorListBox::PixmapType pixmapType() const { return m_type; }
 
 		/*! \brief Fill the list box with values taken from list.
 		The list is cleared itself. Then is rendered an icon with
@@ -93,28 +83,56 @@
 		\param list a ColorList to present. */
 		void updateBox(ColorList& list);
 
+		/*! Remove list item at specified index */
+		void removeItem(int i);
+
+		/*! Find row index for specified colorname */
+		int row(QString colorName);
+
 		/*! \brief Fill the list box with values taken from list.
-		The list is not cleared before items insertion.
+		The list is cleared itself. Then is rendered an icon with
+		color attributes (RGB/CMYK/Spot etc.).
 		\param list a ColorList to present. */
-		void insertItems(ColorList& list);
+		void setColors(ColorList& list, bool insertNone);
 
-		void addItem(ColorPixmapItem* item);
-		void addItem(QString text);
+		/*! \brief Set the current color */
+		void setCurrentColor(QString colorName);
 
-		/*! \brief Retrieve the pixmap type used by this listbox */
-		ColorListBox::PixmapType pixmapType() const { return m_type; }
+		/*! \brief Set the current row */
+		void setCurrentRow(int row);
 
 		/*! \brief Set the pixmap type used by this listbox */
 		void setPixmapType(ColorListBox::PixmapType type);
+
+		//! Set if None color is shown as first item in the list
+		void setShowNoneColor(bool showNone);
+
+		/*! \brief Return text displayed at specified row */
+		QString text(int row);
 				
 		/*! \brief Pointer to the color list displayed by this box */
 		ColorList *cList;
+
+	public slots:
+		void clear();
+
 	private slots:
 		void slotRightClick();
+
 	protected slots:
+		void emitCurrentChanged(const QModelIndex &current, const QModelIndex &previous);
+		void emitItemClicked(const QModelIndex &current);
+		void emitItemDoubleClicked(const QModelIndex &current);
 		virtual void languageChange();
+
 	signals:
+		void currentRowChanged(int currentRow);
+		void currentTextChanged(const QString &currentText);
 		void contextMenuRequested();
+		void itemClicked(int currentRow);
+		void itemDoubleClicked(int currentRow);
+		void itemSelectionChanged();
+
 	protected:
 		bool viewportEvent(QEvent *event);
 		static int initialized;

Modified: trunk/Scribus/scribus/ui/colorpalette.ui
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/ui/colorpalette.ui
==============================================================================
--- trunk/Scribus/scribus/ui/colorpalette.ui	(original)
+++ trunk/Scribus/scribus/ui/colorpalette.ui	Wed Mar 29 19:02:37 2017
@@ -1074,7 +1074,7 @@
   </customwidget>
   <customwidget>
    <class>ColorListBox</class>
-   <extends>QListWidget</extends>
+   <extends>QListView</extends>
    <header>ui/colorlistbox.h</header>
   </customwidget>
   <customwidget>

Modified: trunk/Scribus/scribus/ui/cpalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/ui/cpalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/cpalette.cpp	(original)
+++ trunk/Scribus/scribus/ui/cpalette.cpp	Wed Mar 29 19:02:37 2017
@@ -152,8 +152,8 @@
 	connect(color2Shade    , SIGNAL(valueChanged(double)), this, SLOT(setGradientColors()));
 	connect(color3Shade    , SIGNAL(valueChanged(double)), this, SLOT(setGradientColors()));
 	connect(color4Shade    , SIGNAL(valueChanged(double)), this, SLOT(setGradientColors()));
-	connect(colorListFill  , SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(selectColorF(QListWidgetItem*)));
-	connect(colorListStroke, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(selectColorS(QListWidgetItem*)));
+	connect(colorListFill  , SIGNAL(currentRowChanged(int)), this, SLOT(selectColorF(int)));
+	connect(colorListStroke, SIGNAL(currentRowChanged(int)), this, SLOT(selectColorS(int)));
 	connect(colorMeshPoint , SIGNAL(activated(int)), this, SLOT(updateMeshPoint()));
 	connect(editMeshColors , SIGNAL(clicked()), this, SLOT(editMeshPointColor()));
 	connect(editPatternProps      , SIGNAL(clicked()) , this, SLOT(changePatternProps()));
@@ -212,8 +212,8 @@
 	disconnect(color2Shade    , SIGNAL(valueChanged(double)), this, SLOT(setGradientColors()));
 	disconnect(color3Shade    , SIGNAL(valueChanged(double)), this, SLOT(setGradientColors()));
 	disconnect(color4Shade    , SIGNAL(valueChanged(double)), this, SLOT(setGradientColors()));
-	disconnect(colorListFill  , SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(selectColorF(QListWidgetItem*)));
-	disconnect(colorListStroke, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(selectColorS(QListWidgetItem*)));
+	disconnect(colorListFill  , SIGNAL(currentRowChanged(int)), this, SLOT(selectColorF(int)));
+	disconnect(colorListStroke, SIGNAL(currentRowChanged(int)), this, SLOT(selectColorS(int)));
 	disconnect(colorMeshPoint , SIGNAL(activated(int)), this, SLOT(updateMeshPoint()));
 	disconnect(editMeshColors , SIGNAL(clicked()), this, SLOT(editMeshPointColor()));
 	disconnect(editPatternProps      , SIGNAL(clicked()) , this, SLOT(changePatternProps()));
@@ -475,30 +475,24 @@
 	bool sigBlocked1 = colorListStroke->blockSignals(true);
 	bool sigBlocked2 = colorListFill->blockSignals(true);
 
-	colorListStroke->clear();
-	colorListStroke->addItem(CommonStrings::tr_NoneColor);
-	colorListFill->clear();
-	colorListFill->addItem(CommonStrings::tr_NoneColor);
 	if (displayAllColors->isChecked())
 	{
 		if (currentDoc != NULL)
 			currentDoc->getUsedColors(colorList);
 	}
+	colorListFill->setColors(colorList, true);
+	colorListStroke->setColors(colorList, true);
 	gradEditStroke->setColors(colorList);
 	gradEdit->setColors(colorList);
-	colorPoint1->updateBox(colorList, true);
-	colorPoint2->updateBox(colorList, true);
-	colorPoint3->updateBox(colorList, true);
-	colorPoint4->updateBox(colorList, true);
-	colorMeshPoint->updateBox(colorList, true);
-	colorListFill->insertItems(colorList);
-	colorListStroke->insertItems(colorList);
-	if (colorListFill->currentItem())
-		colorListFill->currentItem()->setSelected(false);
-	if (colorListStroke->currentItem())
-		colorListStroke->currentItem()->setSelected(false);
-	hatchLineColor->updateBox(colorList, false);
-	hatchBackground->updateBox(colorList, true);
+	colorPoint1->setColors(colorList, true);
+	colorPoint2->setColors(colorList, true);
+	colorPoint3->setColors(colorList, true);
+	colorPoint4->setColors(colorList, true);
+	colorMeshPoint->setColors(colorList, true);
+	colorListFill->clearSelection();
+	colorListStroke->clearSelection();
+	hatchLineColor->setColors(colorList, false);
+	hatchBackground->setColors(colorList, true);
 
 	colorListStroke->blockSignals(sigBlocked1);
 	colorListFill->blockSignals(sigBlocked2);
@@ -615,19 +609,11 @@
 	strokeShade->setValue(sShade);
 	fillShade->setValue(fShade);
 	if ((stroke != CommonStrings::None) && (!stroke.isEmpty()))
-	{
-		QList<QListWidgetItem *> cCol = colorListStroke->findItems(stroke, Qt::MatchExactly);
-		if (cCol.count() != 0)
-			colorListStroke->setCurrentItem(cCol[0]);
-	}
+		colorListStroke->setCurrentColor(stroke);
 	else
 		colorListStroke->setCurrentRow(0);
 	if ((fill != CommonStrings::None) && (!fill.isEmpty()))
-	{
-		QList<QListWidgetItem *> cCol = colorListFill->findItems(fill, Qt::MatchExactly);
-		if (cCol.count() != 0)
-			colorListFill->setCurrentItem(cCol[0]);
-	}
+		colorListFill->setCurrentColor(fill);
 	else
 		colorListFill->setCurrentRow(0);
 
@@ -637,28 +623,38 @@
 	colorListFill->blockSignals(sigBlocked4);
 }
 
-void Cpalette::selectColorS(QListWidgetItem *item)
+void Cpalette::selectColorS(int row)
 {
 	QString colorName;
-	ColorPixmapItem* c = dynamic_cast<ColorPixmapItem*>(item);
-	if (c != NULL)	
-		colorName = c->colorName();
-	else if (! item->data(Qt::DisplayRole).toString().isEmpty()) 
-		colorName = item->data(Qt::DisplayRole).toString();
-	else
+	QVariant varValue = colorListStroke->data(row, Qt::UserRole);
+	if (varValue.canConvert<ColorPixmapValue>())
+	{
+		ColorPixmapValue value(varValue.value<ColorPixmapValue>());
+		colorName = value.m_name;
+	}
+	else
+	{
+		colorName = varValue.toString();
+	}
+	if (colorName.isEmpty())
 		return;
 	emit NewPen(colorName);
 }
 
-void Cpalette::selectColorF(QListWidgetItem *item)
+void Cpalette::selectColorF(int row)
 {
 	QString colorName;
-	ColorPixmapItem* c = dynamic_cast<ColorPixmapItem*>(item);
-	if (c != NULL)	
-		colorName = c->colorName();
-	else if (! item->data(Qt::DisplayRole).toString().isEmpty()) 
-		colorName = item->data(Qt::DisplayRole).toString();
-	else
+	QVariant varValue = colorListFill->data(row, Qt::UserRole);
+	if (varValue.canConvert<ColorPixmapValue>())
+	{
+		ColorPixmapValue value(varValue.value<ColorPixmapValue>());
+		colorName = value.m_name;
+	}
+	else
+	{
+		colorName = varValue.toString();
+	}
+	if (colorName.isEmpty())
 		return;
 	emit NewBrush(colorName);
 }

Modified: trunk/Scribus/scribus/ui/cpalette.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/ui/cpalette.h
==============================================================================
--- trunk/Scribus/scribus/ui/cpalette.h	(original)
+++ trunk/Scribus/scribus/ui/cpalette.h	Wed Mar 29 19:02:37 2017
@@ -98,8 +98,8 @@
 	void hideEditedPatterns(QStringList names);
 	void setActPattern(QString pattern, double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY);
 	void setActPatternStroke(QString pattern, double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY, double space, bool pathF);
-	void selectColorS(QListWidgetItem *c);
-	void selectColorF(QListWidgetItem *c);
+	void selectColorS(int row);
+	void selectColorF(int row);
 	void slotGradStroke(int number);
 	void slotGrad(int nr);
 	void slotGradType(int type);

Modified: trunk/Scribus/scribus/ui/dcolor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/ui/dcolor.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/dcolor.cpp	(original)
+++ trunk/Scribus/scribus/ui/dcolor.cpp	Wed Mar 29 19:02:37 2017
@@ -50,8 +50,7 @@
 		cList.remove(colorName);
 		// 10/26/2004 pv - user can replace deleted color with "None"
 		replacementColData->setPixmapType(ColorCombo::fancyPixmaps);
-		replacementColData->addItem(CommonStrings::tr_NoneColor);
-		replacementColData->insertItems(cList);
+		replacementColData->setColors(cList, true);
 		delColorLayout->addWidget( replacementColData, 1, 1 );
 		replacementColor = replacementColData->itemText(0);
 	}

Modified: trunk/Scribus/scribus/ui/effectsdialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/ui/effectsdialog.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/effectsdialog.cpp	(original)
+++ trunk/Scribus/scribus/ui/effectsdialog.cpp	Wed Mar 29 19:02:37 2017
@@ -107,7 +107,7 @@
 
 	colData = new ColorCombo(false, WStackPage_2);
 	colData->setPixmapType(ColorCombo::fancyPixmaps);
-	colData->insertItems(m_doc->PageColors);
+	colData->setColors(m_doc->PageColors, false);
 	layout17->addWidget( colData );
 	WStackPageLayout->addLayout( layout17 );
 
@@ -244,7 +244,7 @@
 	WStackPage8Layout->addWidget( textLabel1d, 0, 0 );
 	colData1 = new ColorCombo(false, WStackPage_8);
 	colData1->setPixmapType(ColorCombo::fancyPixmaps);
-	colData1->insertItems(m_doc->PageColors);
+	colData1->setColors(m_doc->PageColors, false);
 	WStackPage8Layout->addWidget( colData1, 0, 1, 1, 2);
 	shade1 = new ShadeButton(WStackPage_8);
 	shade1->setValue(100);
@@ -266,7 +266,7 @@
 	WStackPage8Layout->addWidget( textLabel2d, 2, 0 );
 	colData2 = new ColorCombo(false, WStackPage_8);
 	colData2->setPixmapType(ColorCombo::fancyPixmaps);
-	colData2->insertItems(m_doc->PageColors);
+	colData2->setColors(m_doc->PageColors, false);
 	WStackPage8Layout->addWidget( colData2, 2, 1, 1, 2);
 	shade2 = new ShadeButton(WStackPage_8);
 	shade2->setValue(100);
@@ -296,7 +296,7 @@
 	WStackPage9Layout->addWidget( textLabel1t, 0, 0 );
 	colDatat1 = new ColorCombo(false, WStackPage_9);
 	colDatat1->setPixmapType(ColorCombo::fancyPixmaps);
-	colDatat1->insertItems(m_doc->PageColors);
+	colDatat1->setColors(m_doc->PageColors, false);
 	WStackPage9Layout->addWidget( colDatat1, 0, 1, 1, 2 );
 	shadet1 = new ShadeButton(WStackPage_9);
 	shadet1->setValue(100);
@@ -317,7 +317,7 @@
 	WStackPage9Layout->addWidget( textLabel2t, 2, 0 );
 	colDatat2 = new ColorCombo(false, WStackPage_9);
 	colDatat2->setPixmapType(ColorCombo::fancyPixmaps);
-	colDatat2->insertItems(m_doc->PageColors);
+	colDatat2->setColors(m_doc->PageColors, false);
 	WStackPage9Layout->addWidget( colDatat2, 2, 1, 1, 2 );
 	shadet2 = new ShadeButton(WStackPage_9);
 	shadet2->setValue(100);
@@ -338,7 +338,7 @@
 	WStackPage9Layout->addWidget( textLabel3t, 4, 0 );
 	colDatat3 = new ColorCombo(false, WStackPage_9);
 	colDatat3->setPixmapType(ColorCombo::fancyPixmaps);
-	colDatat3->insertItems(m_doc->PageColors);
+	colDatat3->setColors(m_doc->PageColors, false);
 	WStackPage9Layout->addWidget( colDatat3, 4, 1, 1, 2 );
 	shadet3 = new ShadeButton(WStackPage_9);
 	shadet3->setValue(100);
@@ -365,7 +365,7 @@
 	WStackPage10Layout->addWidget( textLabel1q, 0, 0 );
 	colDataq1 = new ColorCombo(false, WStackPage_10);
 	colDataq1->setPixmapType(ColorCombo::fancyPixmaps);
-	colDataq1->insertItems(m_doc->PageColors);
+	colDataq1->setColors(m_doc->PageColors, false);
 	WStackPage10Layout->addWidget( colDataq1, 0, 1, 1, 2 );
 	shadeq1 = new ShadeButton(WStackPage_10);
 	shadeq1->setValue(100);
@@ -386,7 +386,7 @@
 	WStackPage10Layout->addWidget( textLabel2q, 2, 0 );
 	colDataq2 = new ColorCombo(false, WStackPage_10);
 	colDataq2->setPixmapType(ColorCombo::fancyPixmaps);
-	colDataq2->insertItems(m_doc->PageColors);
+	colDataq2->setColors(m_doc->PageColors, false);
 	WStackPage10Layout->addWidget( colDataq2, 2, 1, 1, 2 );
 	shadeq2 = new ShadeButton(WStackPage_10);
 	shadeq2->setValue(100);
@@ -407,7 +407,7 @@
 	WStackPage10Layout->addWidget( textLabel3q, 4, 0 );
 	colDataqc3 = new ColorCombo(false, WStackPage_10);
 	colDataqc3->setPixmapType(ColorCombo::fancyPixmaps);
-	colDataqc3->insertItems(m_doc->PageColors);
+	colDataqc3->setColors(m_doc->PageColors, false);
 	WStackPage10Layout->addWidget( colDataqc3, 4, 1, 1, 2 );
 	shadeqc3 = new ShadeButton(WStackPage_10);
 	shadeqc3->setValue(100);
@@ -428,7 +428,7 @@
 	WStackPage10Layout->addWidget( textLabel4q, 6, 0 );
 	colDataq4 = new ColorCombo(false, WStackPage_10);
 	colDataq4->setPixmapType(ColorCombo::fancyPixmaps);
-	colDataq4->insertItems(m_doc->PageColors);
+	colDataq4->setColors(m_doc->PageColors, false);
 	WStackPage10Layout->addWidget( colDataq4, 6, 1, 1, 2 );
 	shadeq4 = new ShadeButton(WStackPage_10);
 	shadeq4->setValue(100);

Modified: trunk/Scribus/scribus/ui/gradienteditor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/ui/gradienteditor.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/gradienteditor.cpp	(original)
+++ trunk/Scribus/scribus/ui/gradienteditor.cpp	Wed Mar 29 19:02:37 2017
@@ -62,7 +62,7 @@
 void GradientEditor::setColors(ColorList &colorList)
 {
 	m_colorList = colorList;
-	stopColor->updateBox(colorList, true);
+	stopColor->setColors(colorList, true);
 }
 
 void GradientEditor::setPos(double p)

Modified: trunk/Scribus/scribus/ui/propertiespalette_table.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/ui/propertiespalette_table.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette_table.cpp	(original)
+++ trunk/Scribus/scribus/ui/propertiespalette_table.cpp	Wed Mar 29 19:02:37 2017
@@ -57,8 +57,8 @@
 	if (!m_doc)
 		return;
 
-	borderLineColor->updateBox(m_doc->PageColors, ColorCombo::smallPixmaps);
-	fillColor->updateBox(m_doc->PageColors, ColorCombo::smallPixmaps);
+	borderLineColor->setColors(m_doc->PageColors, true);
+	fillColor->setColors(m_doc->PageColors, true);
 }
 
 void PropertiesPalette_Table::setMainWindow(ScribusMainWindow* mainWindow)

Modified: trunk/Scribus/scribus/ui/propertywidget_textcolor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/ui/propertywidget_textcolor.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertywidget_textcolor.cpp	(original)
+++ trunk/Scribus/scribus/ui/propertywidget_textcolor.cpp	Wed Mar 29 19:02:37 2017
@@ -198,9 +198,9 @@
 	if (m_item)
 		disconnectSignals();
 
-	fillColor->updateBox(m_doc->PageColors, true);
-	strokeColor->updateBox(m_doc->PageColors, false);
-	backColor->updateBox(m_doc->PageColors, true);
+	fillColor->setColors(m_doc->PageColors, true);
+	strokeColor->setColors(m_doc->PageColors, false);
+	backColor->setColors(m_doc->PageColors, true);
 	fillColor->view()->setMinimumWidth(fillColor->view()->maximumViewportSize().width() + 24);
 	strokeColor->view()->setMinimumWidth(strokeColor->view()->maximumViewportSize().width() + 24);
 	backColor->view()->setMinimumWidth(backColor->view()->maximumViewportSize().width() + 24);

Modified: trunk/Scribus/scribus/ui/proptree.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/ui/proptree.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/proptree.cpp	(original)
+++ trunk/Scribus/scribus/ui/proptree.cpp	Wed Mar 29 19:02:37 2017
@@ -160,7 +160,7 @@
 	else if (item->m_type == PropTreeItem::ColorComboBox)
 	{
 		ColorCombo *editor = new ColorCombo(ColorCombo::fancyPixmaps, parent);
-		editor->updateBox(item->m_colors, false);
+		editor->setColors(item->m_colors, false);
 		edito = editor;
 		edito->setAutoFillBackground(true);
 		connect(editor, SIGNAL(activated(int)), this, SLOT(valueHasChanged()));

Modified: trunk/Scribus/scribus/ui/replaceonecolor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/ui/replaceonecolor.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/replaceonecolor.cpp	(original)
+++ trunk/Scribus/scribus/ui/replaceonecolor.cpp	Wed Mar 29 19:02:37 2017
@@ -34,11 +34,9 @@
 	setModal(true);
 	setWindowIcon(IconManager::instance()->loadIcon("AppIcon.png" ));
 	originalColor->setPixmapType(ColorCombo::fancyPixmaps);
-	originalColor->addItem(CommonStrings::tr_NoneColor);
-	originalColor->insertItems(usedColors);
+	originalColor->setColors(usedColors, true);
 	replacementColor->setPixmapType(ColorCombo::fancyPixmaps);
-	replacementColor->addItem(CommonStrings::tr_NoneColor);
-	replacementColor->insertItems(availableColors);
+	replacementColor->setColors(availableColors, true);
 }
 
 const QString replaceColorDialog::getOriginalColor()

Modified: trunk/Scribus/scribus/ui/search.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/ui/search.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/search.cpp	(original)
+++ trunk/Scribus/scribus/ui/search.cpp	Wed Mar 29 19:02:37 2017
@@ -135,7 +135,7 @@
 	SFillVal = new ColorCombo( Search );
 	SFillVal->setEditable(false);
 	SFillVal->setPixmapType(ColorCombo::fancyPixmaps);
-	SFillVal->updateBox(doc->PageColors, true);
+	SFillVal->setColors(doc->PageColors, true);
 	SFillVal->setMinimumWidth(SFillVal->view()->maximumViewportSize().width() + 24);
 	setCurrentComboItem(SFillVal, doc->currentStyle.charStyle().fillColor());
 	SFillVal->setEnabled(false);
@@ -146,7 +146,7 @@
 	SStrokeVal = new ColorCombo( Search );
 	SStrokeVal->setEditable(false);
 	SStrokeVal->setPixmapType(ColorCombo::fancyPixmaps);
-	SStrokeVal->updateBox(doc->PageColors, true);
+	SStrokeVal->setColors(doc->PageColors, true);
 	SStrokeVal->view()->setMinimumWidth(SStrokeVal->view()->maximumViewportSize().width() + 24);
 	setCurrentComboItem(SStrokeVal, doc->currentStyle.charStyle().strokeColor());
 	SStrokeVal->setEnabled(false);
@@ -232,7 +232,7 @@
 	RFillVal = new ColorCombo( true, Replace );
 	RFillVal->setEditable(false);
 	RFillVal->setPixmapType(ColorCombo::fancyPixmaps);
-	RFillVal->updateBox(doc->PageColors, true);
+	RFillVal->setColors(doc->PageColors, true);
 	RFillVal->view()->setMinimumWidth(RFillVal->view()->maximumViewportSize().width() + 24);
 	setCurrentComboItem(RFillVal, doc->currentStyle.charStyle().fillColor());
 	RFillVal->setEnabled(false);
@@ -243,7 +243,7 @@
 	RStrokeVal = new ColorCombo( true, Replace );
 	RStrokeVal->setEditable(false);
 	RStrokeVal->setPixmapType(ColorCombo::fancyPixmaps);
-	RStrokeVal->updateBox(doc->PageColors, true);
+	RStrokeVal->setColors(doc->PageColors, true);
 	RStrokeVal->view()->setMinimumWidth(RStrokeVal->view()->maximumViewportSize().width() + 24);
 	setCurrentComboItem(RStrokeVal, doc->currentStyle.charStyle().strokeColor());
 	RStrokeVal->setEnabled(false);

Modified: trunk/Scribus/scribus/ui/selectobjects.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/ui/selectobjects.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/selectobjects.cpp	(original)
+++ trunk/Scribus/scribus/ui/selectobjects.cpp	Wed Mar 29 19:02:37 2017
@@ -34,11 +34,9 @@
 	setModal(true);
 	setWindowIcon(IconManager::instance()->loadIcon("AppIcon.png"));
 	backgroundCombo->setPixmapType(ColorCombo::fancyPixmaps);
-	backgroundCombo->addItem(CommonStrings::tr_NoneColor);
-	backgroundCombo->insertItems(availableColors);
+	backgroundCombo->setColors(availableColors, true);
 	lineCombo->setPixmapType(ColorCombo::fancyPixmaps);
-	lineCombo->addItem(CommonStrings::tr_NoneColor);
-	lineCombo->insertItems(availableColors);
+	lineCombo->setColors(availableColors, true);
 	lineWidthSpin->setNewUnit(unitIndex);
 	lineWidthSpin->setMinimum(0);
 	lineWidthSpin->setMaximum(1000);

Modified: trunk/Scribus/scribus/ui/smcellstylewidget.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/ui/smcellstylewidget.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/smcellstylewidget.cpp	(original)
+++ trunk/Scribus/scribus/ui/smcellstylewidget.cpp	Wed Mar 29 19:02:37 2017
@@ -169,12 +169,6 @@
 {
 	fillColor->clear();
 
-	fillColor->addItem(CommonStrings::tr_NoneColor);
-	ColorList::Iterator itEnd = colors.end();
-	ScribusDoc* doc = colors.document();
-	for (ColorList::Iterator it = colors.begin(); it != itEnd; ++it)
-	{
-		fillColor->insertItem(it.value(), doc, it.key());
-	}
+	fillColor->setColors(colors, true);
 	fillColor->view()->setMinimumWidth(fillColor->view()->maximumViewportSize().width()+24);
 }

Modified: trunk/Scribus/scribus/ui/smcstylewidget.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/ui/smcstylewidget.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/smcstylewidget.cpp	(original)
+++ trunk/Scribus/scribus/ui/smcstylewidget.cpp	Wed Mar 29 19:02:37 2017
@@ -182,17 +182,9 @@
 	strokeColor_->clear();
 	backColor_->clear();
 
-	fillColor_->addItem(CommonStrings::tr_NoneColor);
-	strokeColor_->addItem(CommonStrings::tr_NoneColor);
-	backColor_->addItem(CommonStrings::tr_NoneColor);
-	ColorList::Iterator itend=colors.end();
-	ScribusDoc* doc = colors.document();
-	for (ColorList::Iterator it = colors.begin(); it != itend; ++it)
-	{
-		fillColor_->insertItem(it.value(), doc, it.key());
-		strokeColor_->insertItem(it.value(), doc, it.key());
-		backColor_->insertItem(it.value(), doc, it.key());
-	}
+	fillColor_->setColors(colors, true);
+	strokeColor_->setColors(colors, true);
+	backColor_->setColors(colors, true);
 	fillColor_->view()->setMinimumWidth(fillColor_->view()->maximumViewportSize().width()+24);
 	strokeColor_->view()->setMinimumWidth(strokeColor_->view()->maximumViewportSize().width()+24);
 	backColor_->view()->setMinimumWidth(backColor_->view()->maximumViewportSize().width()+24);

Modified: trunk/Scribus/scribus/ui/smlinestylewidget.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/ui/smlinestylewidget.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/smlinestylewidget.cpp	(original)
+++ trunk/Scribus/scribus/ui/smlinestylewidget.cpp	Wed Mar 29 19:02:37 2017
@@ -103,8 +103,7 @@
 // 	disconnect(lineStyles, SIGNAL(highlighted(int)), this, SLOT(slotEditNewLine(int)));
 	disconnect(lineStyles, SIGNAL(currentRowChanged(int)), this, SLOT(slotEditNewLine(int)));
 	m_currentStyle = lineStyle;
-	colorCombo->clear();
-	colorCombo->updateBox(colorList, false);
+	colorCombo->setColors(colorList, false);
 	m_colors = colorList;
 	updateLineList();
 	slotEditNewLine(subLine);

Modified: trunk/Scribus/scribus/ui/smpstylewidget.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/ui/smpstylewidget.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/smpstylewidget.cpp	(original)
+++ trunk/Scribus/scribus/ui/smpstylewidget.cpp	Wed Mar 29 19:02:37 2017
@@ -174,13 +174,7 @@
 void SMPStyleWidget::fillColorCombo(ColorList &colors)
 {
 	backColor_->clear();
-	backColor_->addItem(CommonStrings::tr_NoneColor);
-	ColorList::Iterator itend=colors.end();
-	ScribusDoc* doc = colors.document();
-	for (ColorList::Iterator it = colors.begin(); it != itend; ++it)
-	{
-		backColor_->insertItem(it.value(), doc, it.key());
-	}
+	backColor_->setColors(colors, true);
 	backColor_->view()->setMinimumWidth(backColor_->view()->maximumViewportSize().width()+24);
 }
 

Modified: trunk/Scribus/scribus/ui/smtablestylewidget.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/ui/smtablestylewidget.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/smtablestylewidget.cpp	(original)
+++ trunk/Scribus/scribus/ui/smtablestylewidget.cpp	Wed Mar 29 19:02:37 2017
@@ -169,13 +169,7 @@
 {
 	fillColor->clear();
 
-	fillColor->addItem(CommonStrings::tr_NoneColor);
-	ColorList::Iterator itEnd = colors.end();
-	ScribusDoc* doc = colors.document();
-	for (ColorList::Iterator it = colors.begin(); it != itEnd; ++it)
-	{
-		fillColor->insertItem(it.value(), doc, it.key());
-	}
+	fillColor->setColors(colors, true);
 	fillColor->view()->setMinimumWidth(fillColor->view()->maximumViewportSize().width()+24);
 }
 

Modified: trunk/Scribus/scribus/ui/storyeditor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/scribus/ui/storyeditor.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/storyeditor.cpp	(original)
+++ trunk/Scribus/scribus/ui/storyeditor.cpp	Wed Mar 29 19:02:37 2017
@@ -1155,15 +1155,8 @@
 
 void SToolBColorF::setCurrentDocument(ScribusDoc *doc)
 {
-	if (doc!=NULL)
-		TxFill->updateBox(doc->PageColors, true);
-	else
-	{
-		TxFill->clear();
-		TxFill->addItem(CommonStrings::tr_NoneColor);
-	}
-//	if (doc!=NULL)
-//		TxFill->insertItems(doc->PageColors, ColorCombo::smallPixmaps);
+	ColorList list = doc ? doc->PageColors : ColorList();
+	TxFill->setColors(list, true);
 	resize(minimumSizeHint());
 }
 
@@ -1227,10 +1220,8 @@
 
 void SToolBColorS::setCurrentDocument(ScribusDoc *doc)
 {
-	TxStroke->clear();
-	TxStroke->addItem(CommonStrings::tr_NoneColor);
-	if (doc!=NULL)
-		TxStroke->insertItems(doc->PageColors);
+	ColorList list = doc ? doc->PageColors : ColorList();
+	TxStroke->setColors(list, true);
 	resize(minimumSizeHint());
 }
 

Modified: trunk/Scribus/win32/vc11/scribus-main/Scribus.vcxproj
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/win32/vc11/scribus-main/Scribus.vcxproj
==============================================================================
--- trunk/Scribus/win32/vc11/scribus-main/Scribus.vcxproj	(original)
+++ trunk/Scribus/win32/vc11/scribus-main/Scribus.vcxproj	Wed Mar 29 19:02:37 2017
@@ -415,6 +415,7 @@
     <ClInclude Include="..\..\..\scribus\text\textshaper.h" />
     <ClInclude Include="..\..\..\scribus\text\textsource.h" />
     <moc Include="..\..\..\scribus\ui\directionselect.h" />
+    <moc Include="..\..\..\scribus\ui\colorlistmodel.h" />
     <ClInclude Include="..\..\..\scribus\ui\helpnavigation.h" />
     <ClInclude Include="..\..\..\scribus\third_party\hyphen\hnjalloc.h" />
     <moc Include="..\..\..\scribus\ui\hruler.h" />
@@ -1026,6 +1027,7 @@
     <ClCompile Include="..\..\..\scribus\ui\colorlistbox.cpp" />
     <ClCompile Include="..\..\..\scribus\colorsetmanager.cpp" />
     <ClCompile Include="..\..\..\scribus\commonstrings.cpp" />
+    <ClCompile Include="..\..\..\scribus\ui\colorlistmodel.cpp" />
     <ClCompile Include="..\..\..\scribus\ui\contextmenu.cpp" />
     <ClCompile Include="..\..\..\scribus\ui\copypagetomasterpagedialog.cpp" />
     <ClCompile Include="..\..\..\scribus\ui\cpalette.cpp" />

Modified: trunk/Scribus/win32/vc11/scribus-main/Scribus.vcxproj.filters
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21855&path=/trunk/Scribus/win32/vc11/scribus-main/Scribus.vcxproj.filters
==============================================================================
--- trunk/Scribus/win32/vc11/scribus-main/Scribus.vcxproj.filters	(original)
+++ trunk/Scribus/win32/vc11/scribus-main/Scribus.vcxproj.filters	Wed Mar 29 19:02:37 2017
@@ -1067,6 +1067,9 @@
     <ClInclude Include="..\..\..\scribus\text\textsource.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\..\scribus\ui\colorlistmodel.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\..\scribus\desaxe\digester.cpp">
@@ -2660,6 +2663,9 @@
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="..\..\..\scribus\ui\textpalette.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\..\scribus\ui\colorlistmodel.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
   </ItemGroup>




More information about the scribus-commit mailing list