r22202 by jghali -

scribus-commit scribus-commit at lists.scribus.net
Wed Oct 25 17:50:09 UTC 2017


Author: jghali
Date: Wed Oct 25 17:50:09 2017
New Revision: 22202

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22202
Log:
#15023 related: fix incorrect use of mime data types and AccessibleTextRole in CharTableModel

Modified:
    trunk/Scribus/scribus/chartablemodel.cpp
    trunk/Scribus/scribus/chartablemodel.h

Modified: trunk/Scribus/scribus/chartablemodel.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22202&path=/trunk/Scribus/scribus/chartablemodel.cpp
==============================================================================
--- trunk/Scribus/scribus/chartablemodel.cpp	(original)
+++ trunk/Scribus/scribus/chartablemodel.cpp	Wed Oct 25 17:50:09 2017
@@ -51,7 +51,10 @@
 		return QVariant();
 
 	// for mimeData()
-	if (role == Qt::AccessibleTextRole)
+	if (role == CharTableModel::CharTextRole)
+		return QString("%1").arg(QChar(currentChar));
+
+	if (role == CharTableModel::CharTextAndFontRole)
 		return QString("%1#%2").arg(currentChar).arg(currentFont);
 
 	// tooltip
@@ -237,7 +240,13 @@
 QMimeData *CharTableModel::mimeData(const QModelIndexList &indexes) const
 {
 	QMimeData *mimeData = new QMimeData();
-	mimeData->setText(data(indexes.at(0), Qt::AccessibleTextRole).toString());
+
+	QString text = data(indexes.at(0), CharTableModel::CharTextRole).toString();
+	mimeData->setText(text);
+
+	QString textAndFont = data(indexes.at(0), CharTableModel::CharTextAndFontRole).toString();
+	mimeData->setData("application/x-scribus-charpaltext", textAndFont.toUtf8());
+
 	return mimeData;
 }
 
@@ -246,9 +255,19 @@
 	if (action == Qt::IgnoreAction)
 		return true;
 
-	if (!data->hasText())
-		return false;
-
-	appendUnicode(QString(data->text()), 10);
-	return true;
-}
+	bool success = false;
+	if (data->hasFormat("application/x-scribus-charpaltext"))
+	{
+		QByteArray textAndFont = data->data("application/x-scribus-charpaltext");
+		appendUnicode(QString::fromUtf8(textAndFont), 10);
+		success = true;
+	}
+	else if (data->hasText())
+	{
+		QChar textChar = data->text().at(0);
+		appendUnicode(QString("%1").arg(textChar.unicode(), 10));
+		success = true;
+	}
+		
+	return success;
+}

Modified: trunk/Scribus/scribus/chartablemodel.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22202&path=/trunk/Scribus/scribus/chartablemodel.h
==============================================================================
--- trunk/Scribus/scribus/chartablemodel.h	(original)
+++ trunk/Scribus/scribus/chartablemodel.h	Wed Oct 25 17:50:09 2017
@@ -82,6 +82,13 @@
 	void rowAppended();
 
 private:
+
+	enum DataRole
+	{
+		CharTextRole = Qt::UserRole + 1,
+		CharTextAndFontRole = Qt::UserRole + 2
+	};
+
 	ScribusDoc *m_doc;
 	//! \brief Number of the columns for model
 	int m_cols;




More information about the scribus-commit mailing list