r21642 by craig - #14430: Hide disabled fonts via model in Font Preview

scribus-commit scribus-commit at lists.scribus.net
Sun Dec 11 20:49:19 UTC 2016


Author: craig
Date: Sun Dec 11 20:49:19 2016
New Revision: 21642

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21642
Log:
#14430: Hide disabled fonts via model in Font Preview

Modified:
    trunk/Scribus/scribus/fontlistmodel.cpp
    trunk/Scribus/scribus/fontlistmodel.h
    trunk/Scribus/scribus/plugins/fontpreview/fontpreview.cpp
    trunk/Scribus/scribus/ui/prefs_fonts.cpp

Modified: trunk/Scribus/scribus/fontlistmodel.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21642&path=/trunk/Scribus/scribus/fontlistmodel.cpp
==============================================================================
--- trunk/Scribus/scribus/fontlistmodel.cpp	(original)
+++ trunk/Scribus/scribus/fontlistmodel.cpp	Sun Dec 11 20:49:19 2016
@@ -13,41 +13,40 @@
 #include "prefsmanager.h"
 #include "scribusdoc.h"
 
-FontListModel::FontListModel(QObject * parent, ScribusDoc * doc)
+FontListModel::FontListModel(QObject * parent, ScribusDoc * doc, bool includeDisabled)
 	: QAbstractTableModel(parent),
 	m_doc(doc),
-	m_fonts(PrefsManager::instance()->appPrefs.fontPrefs.AvailFonts)
+	m_fonts(PrefsManager::instance()->appPrefs.fontPrefs.AvailFonts),
+	m_includeDisabled(includeDisabled)
 {
 	ttfFont = IconManager::instance()->loadPixmap("font_truetype16.png");
 	otfFont = IconManager::instance()->loadPixmap("font_otf16.png");
 	psFont = IconManager::instance()->loadPixmap("font_type1_16.png");
 	substFont = IconManager::instance()->loadPixmap("font_subst16.png");
 
-	m_font_values = m_fonts.values();
-	m_font_names = m_fonts.keys();
-	for (int i = 0; i < m_font_names.length(); ++i)
-	{
-		ScFace font = m_fonts[m_font_names[i]];
-		m_enabledFonts.append(font.usable());
-	}
+	setFonts(m_fonts.keys());
 }
 
 void FontListModel::setFonts(QList<QString> f)
 {
 	beginResetModel();
-	m_font_names = f;
+	m_font_names.clear();
 	m_font_values.clear();
 	m_enabledFonts.clear();
 	m_embedFlags.clear();
-	for (int i = 0; i < m_font_names.length(); ++i)
-	{
-		ScFace font = m_fonts[m_font_names[i]];
-		m_font_values.append(font);
-		m_enabledFonts.append(font.usable());
-		int embedFlags = 0;
-		embedFlags |= font.embedPs() ? EmbedPS : 0;
-		embedFlags |= font.subset()  ? SubsetPDF : 0;
-		m_embedFlags.append(embedFlags);
+	for (int i = 0; i < f.length(); ++i)
+	{
+		ScFace &font = m_fonts[f[i]];
+		if (font.usable() || m_includeDisabled)
+		{
+			m_font_names.append(f[i]);
+			m_font_values.append(font);
+			m_enabledFonts.append(font.usable());
+			int embedFlags = 0;
+			embedFlags |= font.embedPs() ? EmbedPS : 0;
+			embedFlags |= font.subset()  ? SubsetPDF : 0;
+			m_embedFlags.append(embedFlags);
+		}
 	}
 	endResetModel();
 }

Modified: trunk/Scribus/scribus/fontlistmodel.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21642&path=/trunk/Scribus/scribus/fontlistmodel.h
==============================================================================
--- trunk/Scribus/scribus/fontlistmodel.h	(original)
+++ trunk/Scribus/scribus/fontlistmodel.h	Sun Dec 11 20:49:19 2016
@@ -32,7 +32,7 @@
 	Q_OBJECT
 
 	public:
-		FontListModel(QObject * parent = 0, ScribusDoc * doc = 0);
+		FontListModel(QObject * parent = 0, ScribusDoc * doc = 0, bool includeDisabled = false);
 
 		enum ColumnTypes {
             FontUsable = 0,
@@ -57,7 +57,7 @@
 		int columnCount(const QModelIndex&) const;
 		/*! Required inherited method. See Qt4 docs.
 		It handles displaying for user itself.
-		\Note the Qt::CheckStateRole stuff is handling
+		\note the Qt::CheckStateRole stuff is handling
 		user input. And should not be removed. */
 		QVariant data(const QModelIndex & index,
 					  int role = Qt::DisplayRole) const;
@@ -70,7 +70,7 @@
 		Qt::ItemFlags flags(const QModelIndex &index) const;
 
 		//! Returns the font list
-		QList<QString> fonts() { return m_font_names; };
+		QList<QString> fonts() { return m_font_names; }
 		//! Sets font list and refresh the model. This will detach the model from the main Scribus font list!
 		void setFonts(QList<QString> f);
 
@@ -112,6 +112,8 @@
 		QVariant headerData(int section,
 							Qt::Orientation orientation,
 							int role = Qt::DisplayRole) const;
+
+		bool m_includeDisabled;
 };
 
 #endif

Modified: trunk/Scribus/scribus/plugins/fontpreview/fontpreview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21642&path=/trunk/Scribus/scribus/plugins/fontpreview/fontpreview.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fontpreview/fontpreview.cpp	(original)
+++ trunk/Scribus/scribus/plugins/fontpreview/fontpreview.cpp	Sun Dec 11 20:49:19 2016
@@ -30,7 +30,7 @@
 
 	languageChange();
 
-	fontModel = new FontListModel(this, m_Doc);
+	fontModel = new FontListModel(this, m_Doc, false);
 
 	proxyModel = new QSortFilterProxyModel();
 	proxyModel->setDynamicSortFilter(true);

Modified: trunk/Scribus/scribus/ui/prefs_fonts.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21642&path=/trunk/Scribus/scribus/ui/prefs_fonts.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/prefs_fonts.cpp	(original)
+++ trunk/Scribus/scribus/ui/prefs_fonts.cpp	Sun Dec 11 20:49:19 2016
@@ -49,7 +49,7 @@
 
 	setMinimumSize(fontMetrics().width( tr( "Available Fonts" )+ tr( "Font Substitutions" )+ tr( "Additional Paths" ))+180, 200);
 
-	fontListTableView->setModel(new FontListModel(fontListTableView, m_doc));
+	fontListTableView->setModel(new FontListModel(fontListTableView, m_doc, true));
 
 	fontSubstitutionsTableWidget->setRowCount(RList.count());
 	fontSubstitutionsTableWidget->setColumnCount(2);




More information about the scribus-commit mailing list