summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Hards <bradh@kde.org>2008-02-28 06:26:09 +1100
committerBrad Hards <bradh@kde.org>2008-02-28 06:26:09 +1100
commit0569ae76b6af1723b4606af189242a23199f387d (patch)
tree1bb15cbee4880f953acd690b7c4ccbeb4198d293
parentf395531a3e8f71a46b3c942f8f437ade1d9fdb57 (diff)
parentd8eba8c10834116b4f0f295375805172f5216993 (diff)
Merge branch 'master' of ssh://bradh@git.freedesktop.org/git/poppler/poppler
-rw-r--r--poppler/Gfx.cc2
-rw-r--r--poppler/OptionalContent.cc2
-rw-r--r--qt4/src/.gitignore2
-rw-r--r--qt4/src/Makefile.am13
-rw-r--r--qt4/src/poppler-optcontent-private.h9
-rw-r--r--qt4/src/poppler-optcontent.cc155
-rw-r--r--qt4/src/poppler-optcontent.h16
-rw-r--r--qt4/tests/check_optcontent.cpp66
8 files changed, 147 insertions, 118 deletions
diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index e8d0b1cf..0618ab09 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -3460,6 +3460,8 @@ void Gfx::opXObject(Object args[], int numArgs) {
// No OC entry - so we proceed as normal
} else if (obj2.isRef()) {
if ( ! catalog->getOptContentConfig()->optContentIsVisible( &obj2 ) ) {
+ obj2.free();
+ obj1.free();
return;
}
} else {
diff --git a/poppler/OptionalContent.cc b/poppler/OptionalContent.cc
index 600c52b6..b081add3 100644
--- a/poppler/OptionalContent.cc
+++ b/poppler/OptionalContent.cc
@@ -174,6 +174,7 @@ bool OCGs::optContentIsVisible( Object *dictRef )
dictRef->fetch( m_xref, &dictObj );
if ( ! dictObj.isDict() ) {
printf( "Unexpected oc reference target: %i\n", dictObj.getType() );
+ dictObj.free();
return result;
}
dict = dictObj.getDict();
@@ -216,6 +217,7 @@ bool OCGs::optContentIsVisible( Object *dictRef )
}
}
dictType.free();
+ dictObj.free();
// printf("visibility: %s\n", result? "on" : "off");
return result;
}
diff --git a/qt4/src/.gitignore b/qt4/src/.gitignore
index 53c90777..3d124ddd 100644
--- a/qt4/src/.gitignore
+++ b/qt4/src/.gitignore
@@ -6,4 +6,4 @@ Makefile
Makefile.in
APIDOCS-html
APIDOCS-latex
-moc_poppler-optcontent.cpp
+*.moc
diff --git a/qt4/src/Makefile.am b/qt4/src/Makefile.am
index cd9af860..10310a18 100644
--- a/qt4/src/Makefile.am
+++ b/qt4/src/Makefile.am
@@ -5,6 +5,8 @@ INCLUDES = \
$(FONTCONFIG_CFLAGS) \
$(POPPLER_QT4_CFLAGS)
+SUFFIXES: .moc
+
poppler_includedir = $(includedir)/poppler/qt4
poppler_include_HEADERS = \
@@ -28,7 +30,7 @@ libpoppler_qt4_la_SOURCES = \
poppler-annotation.cc \
poppler-link-extractor.cc \
poppler-optcontent.cc \
- moc_poppler-optcontent.cpp \
+ poppler-optcontent.h \
../../qt/poppler-page-transition.cc \
poppler-sound.cc \
poppler-form.cc \
@@ -43,6 +45,7 @@ libpoppler_qt4_la_SOURCES = \
poppler-annotation-private.h \
poppler-converter-private.h \
poppler-qiodeviceoutstream-private.h \
+ poppler-optcontent-private.h \
poppler-export.h \
poppler-private.h
@@ -58,6 +61,8 @@ endif
libpoppler_qt4_la_LDFLAGS = -version-info 2:0:0
-# This rule lets GNU make create any moc_*.cpp from the equivalent *.h
-moc_%.cpp: %.h
- moc $< -o $@
+# This rule lets GNU make create any *.moc from the equivalent *.h
+.h.moc:
+ moc -i $< -o $@
+
+poppler-optcontent.$(OBJEXT): poppler-optcontent.moc
diff --git a/qt4/src/poppler-optcontent-private.h b/qt4/src/poppler-optcontent-private.h
index 2462f2ad..7471a421 100644
--- a/qt4/src/poppler-optcontent-private.h
+++ b/qt4/src/poppler-optcontent-private.h
@@ -29,13 +29,14 @@ class OptionalContentGroup;
namespace Poppler
{
+ class OptContentItem;
class RadioButtonGroup
{
public:
RadioButtonGroup( OptContentModelPrivate *ocModel, Array *rbarray);
~RadioButtonGroup();
- void setItemOn( OptContentItem *itemToSetOn );
+ QSet<OptContentItem *> setItemOn( OptContentItem *itemToSetOn );
private:
QList<OptContentItem*> itemsInGroup;
@@ -53,7 +54,7 @@ namespace Poppler
QString name() const { return m_name; }
ItemState state() const { return m_state; }
- bool setState( ItemState state );
+ bool setState(ItemState state, QSet<OptContentItem *> &changedItems);
QList<OptContentItem*> childList() { return m_children; }
@@ -80,7 +81,8 @@ namespace Poppler
~OptContentModelPrivate();
void parseRBGroupsArray( Array *rBGroupArray );
- OptContentItem *nodeFromIndex( const QModelIndex &index ) const;
+ OptContentItem *nodeFromIndex(const QModelIndex &index, bool canBeNull = false) const;
+ QModelIndex indexFromItem(OptContentItem *node, int column) const;
/**
Get the OptContentItem corresponding to a given reference value.
@@ -90,6 +92,7 @@ namespace Poppler
\return the matching optional content item, or null if the reference wasn't found
*/
OptContentItem *itemFromRef( const QString &ref ) const;
+ void setRootNode(OptContentItem *node);
OptContentModel *q;
diff --git a/qt4/src/poppler-optcontent.cc b/qt4/src/poppler-optcontent.cc
index f6e61c13..3899970b 100644
--- a/qt4/src/poppler-optcontent.cc
+++ b/qt4/src/poppler-optcontent.cc
@@ -25,6 +25,7 @@
#include "poppler-private.h"
#include <QtCore/QDebug>
+#include <QtCore/QtAlgorithms>
namespace Poppler
{
@@ -50,14 +51,18 @@ namespace Poppler
{
}
- void RadioButtonGroup::setItemOn( OptContentItem *itemToSetOn )
+ QSet<OptContentItem *> RadioButtonGroup::setItemOn( OptContentItem *itemToSetOn )
{
+ QSet<OptContentItem *> changedItems;
for (int i = 0; i < itemsInGroup.size(); ++i) {
OptContentItem *thisItem = itemsInGroup.at(i);
if (thisItem != itemToSetOn) {
- thisItem->setState( OptContentItem::Off );
+ QSet<OptContentItem *> newChangedItems;
+ thisItem->setState(OptContentItem::Off, newChangedItems);
+ changedItems += newChangedItems;
}
}
+ return changedItems;
}
@@ -97,9 +102,10 @@ namespace Poppler
}
- bool OptContentItem::setState( ItemState state )
+ bool OptContentItem::setState(ItemState state, QSet<OptContentItem *> &changedItems)
{
m_state = state;
+ changedItems.insert(this);
if (!m_group) {
return false;
}
@@ -107,7 +113,7 @@ namespace Poppler
m_group->setState( OptionalContentGroup::On );
for (int i = 0; i < m_rbGroups.size(); ++i) {
RadioButtonGroup *rbgroup = m_rbGroups.at(i);
- rbgroup->setItemOn( this );
+ changedItems += rbgroup->setItemOn( this );
}
} else if ( state == OptContentItem::Off ) {
m_group->setState( OptionalContentGroup::Off );
@@ -165,7 +171,7 @@ namespace Poppler
Object item;
orderArray->getNF(i, &item);
if (item.isRef() ) {
- OptContentItem *ocItem = m_optContentItems[ QString("%1").arg(item.getRefNum()) ];
+ OptContentItem *ocItem = m_optContentItems.value(QString::number(item.getRefNum()), 0);
if (ocItem) {
addChild( parentNode, ocItem );
lastItem = ocItem;
@@ -220,21 +226,24 @@ namespace Poppler
delete d;
}
- void OptContentModel::setRootNode( OptContentItem *node )
+ void OptContentModelPrivate::setRootNode(OptContentItem *node)
{
- delete d->m_rootNode;
- d->m_rootNode = node;
- reset();
+ delete m_rootNode;
+ m_rootNode = node;
+ q->reset();
}
QModelIndex OptContentModel::index(int row, int column, const QModelIndex &parent) const
{
- if (! d->m_rootNode) {
+ if (row < 0 || column != 0) {
return QModelIndex();
}
OptContentItem *parentNode = d->nodeFromIndex( parent );
- return createIndex( row, column, parentNode->childList()[row] );
+ if (row < parentNode->childList().count()) {
+ return createIndex(row, column, parentNode->childList().at(row));
+ }
+ return QModelIndex();
}
QModelIndex OptContentModel::parent(const QModelIndex &child) const
@@ -243,16 +252,20 @@ namespace Poppler
if (!childNode) {
return QModelIndex();
}
- OptContentItem *parentNode = childNode->parent();
- if (!parentNode) {
+ return d->indexFromItem(childNode->parent(), child.column());
+ }
+
+ QModelIndex OptContentModelPrivate::indexFromItem(OptContentItem *node, int column) const
+ {
+ if (!node) {
return QModelIndex();
}
- OptContentItem *grandparentNode = parentNode->parent();
- if (!grandparentNode) {
+ OptContentItem *parentNode = node->parent();
+ if (!parentNode) {
return QModelIndex();
}
- int row = grandparentNode->childList().indexOf(parentNode);
- return createIndex(row, child.column(), parentNode);
+ const int row = parentNode->childList().indexOf(node);
+ return q->createIndex(row, column, node);
}
int OptContentModel::rowCount(const QModelIndex &parent) const
@@ -267,31 +280,35 @@ namespace Poppler
int OptContentModel::columnCount(const QModelIndex &parent) const
{
- return 2;
+ return 1;
}
QVariant OptContentModel::data(const QModelIndex &index, int role) const
{
- if ( (role != Qt::DisplayRole) && (role != Qt::EditRole) ) {
- return QVariant();
- }
-
- OptContentItem *node = d->nodeFromIndex( index );
+ OptContentItem *node = d->nodeFromIndex(index, true);
if (!node) {
return QVariant();
}
- if (index.column() == 0) {
- return node->name();
- } else if (index.column() == 1) {
- if ( node->state() == OptContentItem::On ) {
- return true;
- } else if ( node->state() == OptContentItem::Off ) {
- return false;
- } else {
- return QVariant();
- }
+ switch (role) {
+ case Qt::DisplayRole:
+ return node->name();
+ break;
+ case Qt::EditRole:
+ if (node->state() == OptContentItem::On) {
+ return true;
+ } else if (node->state() == OptContentItem::Off) {
+ return false;
+ }
+ break;
+ case Qt::CheckStateRole:
+ if (node->state() == OptContentItem::On) {
+ return Qt::Checked;
+ } else if (node->state() == OptContentItem::Off) {
+ return Qt::Unchecked;
+ }
+ break;
}
return QVariant();
@@ -299,29 +316,45 @@ namespace Poppler
bool OptContentModel::setData ( const QModelIndex & index, const QVariant & value, int role )
{
- OptContentItem *node = d->nodeFromIndex( index );
+ OptContentItem *node = d->nodeFromIndex(index, true);
if (!node) {
return false;
}
- if (index.column() == 0) {
- // we don't allow setting of the label
- return false;
- } else if (index.column() == 1) {
- if ( value.toBool() == true ) {
- if ( node->state() != OptContentItem::On ) {
- node->setState( OptContentItem::On );
- emit dataChanged( index, index );
- }
- return true;
- } else if ( value.toBool() == false ) {
- if ( node->state() != OptContentItem::Off ) {
- node->setState( OptContentItem::Off );
- emit dataChanged( index, index );
- }
- return true;
- } else {
- return false;
+ switch (role) {
+ case Qt::CheckStateRole:
+ {
+ const bool newvalue = value.toBool();
+ if (newvalue) {
+ if (node->state() != OptContentItem::On) {
+ QSet<OptContentItem *> changedItems;
+ node->setState(OptContentItem::On, changedItems);
+ QModelIndexList indexes;
+ Q_FOREACH (OptContentItem *item, changedItems) {
+ indexes.append(d->indexFromItem(item, 0));
+ }
+ qStableSort(indexes);
+ Q_FOREACH (const QModelIndex &changedIndex, indexes) {
+ emit dataChanged(changedIndex, changedIndex);
+ }
+ return true;
+ }
+ } else {
+ if (node->state() != OptContentItem::Off) {
+ QSet<OptContentItem *> changedItems;
+ node->setState(OptContentItem::Off, changedItems);
+ QModelIndexList indexes;
+ Q_FOREACH (OptContentItem *item, changedItems) {
+ indexes.append(d->indexFromItem(item, 0));
+ }
+ qStableSort(indexes);
+ Q_FOREACH (const QModelIndex &changedIndex, indexes) {
+ emit dataChanged(changedIndex, changedIndex);
+ }
+ return true;
+ }
+ }
+ break;
}
}
@@ -331,14 +364,17 @@ namespace Poppler
Qt::ItemFlags OptContentModel::flags ( const QModelIndex & index ) const
{
if (index.column() == 0) {
- return QAbstractItemModel::flags(index) | Qt::ItemIsSelectable | Qt::ItemIsEnabled;
- } else if (index.column() == 1) {
- return QAbstractItemModel::flags(index) | Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled;
+ return QAbstractItemModel::flags(index) | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled;
} else {
return QAbstractItemModel::flags(index);
}
}
+ QVariant OptContentModel::headerData( int section, Qt::Orientation orientation, int role ) const
+ {
+ return QAbstractItemModel::headerData( section, orientation, role );
+ }
+
void OptContentModelPrivate::addChild( OptContentItem *parent, OptContentItem *child )
{
parent->addChild( child );
@@ -346,18 +382,15 @@ namespace Poppler
OptContentItem* OptContentModelPrivate::itemFromRef( const QString &ref ) const
{
- if ( !m_optContentItems.contains( ref ) ) {
- return 0;
- }
- return m_optContentItems[ ref ];
+ return m_optContentItems.value(ref, 0);
}
- OptContentItem* OptContentModelPrivate::nodeFromIndex( const QModelIndex &index ) const
+ OptContentItem* OptContentModelPrivate::nodeFromIndex(const QModelIndex &index, bool canBeNull) const
{
if (index.isValid()) {
return static_cast<OptContentItem *>(index.internalPointer());
} else {
- return m_rootNode;
+ return canBeNull ? 0 : m_rootNode;
}
}
}
diff --git a/qt4/src/poppler-optcontent.h b/qt4/src/poppler-optcontent.h
index 81dd4126..2b0c5ec5 100644
--- a/qt4/src/poppler-optcontent.h
+++ b/qt4/src/poppler-optcontent.h
@@ -22,24 +22,24 @@
#include <QtCore/QAbstractListModel>
+#include "poppler-export.h"
+
class OCGs;
namespace Poppler
{
- class OptContentItem;
- class OptContentModel;
+ class Document;
class OptContentModelPrivate;
- class OptContentModel : public QAbstractItemModel
+ class POPPLER_QT4_EXPORT OptContentModel : public QAbstractItemModel
{
+ friend class Document;
+
Q_OBJECT
public:
- OptContentModel( OCGs *optContent, QObject *parent = 0);
virtual ~OptContentModel();
- void setRootNode(OptContentItem *node);
-
QModelIndex index(int row, int column, const QModelIndex &parent) const;
QModelIndex parent(const QModelIndex &child) const;
@@ -51,7 +51,11 @@ namespace Poppler
Qt::ItemFlags flags ( const QModelIndex & index ) const;
+ virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
+
private:
+ OptContentModel( OCGs *optContent, QObject *parent = 0);
+
friend class OptContentModelPrivate;
OptContentModelPrivate *d;
};
diff --git a/qt4/tests/check_optcontent.cpp b/qt4/tests/check_optcontent.cpp
index 045ec185..247c67b8 100644
--- a/qt4/tests/check_optcontent.cpp
+++ b/qt4/tests/check_optcontent.cpp
@@ -28,12 +28,10 @@ void TestOptionalContent::checkVisPolicy()
QModelIndex index;
index = optContent->index( 0, 0, QModelIndex() );
QCOMPARE( optContent->data( index, Qt::DisplayRole ).toString(), QString( "A" ) );
- index = optContent->index( 0, 1, QModelIndex() );
- QCOMPARE( optContent->data( index, Qt::DisplayRole ).toBool(), true );
+ QCOMPARE( static_cast<Qt::CheckState>( optContent->data( index, Qt::CheckStateRole ).toInt() ), Qt::Checked );
index = optContent->index( 1, 0, QModelIndex() );
QCOMPARE( optContent->data( index, Qt::DisplayRole ).toString(), QString( "B" ) );
- index = optContent->index( 1, 1, QModelIndex() );
- QCOMPARE( optContent->data( index, Qt::DisplayRole ).toBool(), true );
+ QCOMPARE( static_cast<Qt::CheckState>( optContent->data( index, Qt::CheckStateRole ).toInt() ), Qt::Checked );
delete doc;
}
@@ -51,29 +49,24 @@ void TestOptionalContent::checkNestedLayers()
index = optContent->index( 0, 0, QModelIndex() );
QCOMPARE( optContent->data( index, Qt::DisplayRole ).toString(), QString( "Black Text and Green Snow" ) );
- index = optContent->index( 0, 1, QModelIndex() );
- QCOMPARE( optContent->data( index, Qt::DisplayRole ).toBool(), false );
+ QCOMPARE( static_cast<Qt::CheckState>( optContent->data( index, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
index = optContent->index( 1, 0, QModelIndex() );
QCOMPARE( optContent->data( index, Qt::DisplayRole ).toString(), QString( "Mountains and Image" ) );
- index = optContent->index( 1, 1, QModelIndex() );
- QCOMPARE( optContent->data( index, Qt::DisplayRole ).toBool(), true );
+ QCOMPARE( static_cast<Qt::CheckState>( optContent->data( index, Qt::CheckStateRole ).toInt() ), Qt::Checked );
// This is a sub-item of "Mountains and Image"
QModelIndex subindex = optContent->index( 0, 0, index );
QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QString( "Image" ) );
- subindex = optContent->index( 0, 1, index );
- QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toBool(), true );
+ QCOMPARE( static_cast<Qt::CheckState>( optContent->data( index, Qt::CheckStateRole ).toInt() ), Qt::Checked );
index = optContent->index( 2, 0, QModelIndex() );
QCOMPARE( optContent->data( index, Qt::DisplayRole ).toString(), QString( "Starburst" ) );
- index = optContent->index( 2, 1, QModelIndex() );
- QCOMPARE( optContent->data( index, Qt::DisplayRole ).toBool(), true );
+ QCOMPARE( static_cast<Qt::CheckState>( optContent->data( index, Qt::CheckStateRole ).toInt() ), Qt::Checked );
index = optContent->index( 3, 0, QModelIndex() );
QCOMPARE( optContent->data( index, Qt::DisplayRole ).toString(), QString( "Watermark" ) );
- index = optContent->index( 3, 1, QModelIndex() );
- QCOMPARE( optContent->data( index, Qt::DisplayRole ).toBool(), false );
+ QCOMPARE( static_cast<Qt::CheckState>( optContent->data( index, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
delete doc;
}
@@ -416,79 +409,66 @@ void TestOptionalContent::checkRadioButtons()
index = optContent->index( 0, 0, QModelIndex() );
QCOMPARE( optContent->data( index, Qt::DisplayRole ).toString(), QString( "Languages" ) );
- index = optContent->index( 0, 1, QModelIndex() );
- QCOMPARE( optContent->data( index, Qt::DisplayRole ), QVariant() );
+ QCOMPARE( static_cast<Qt::CheckState>( optContent->data( index, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
// These are sub-items of the "Languages" label
QModelIndex subindex = optContent->index( 0, 0, index );
QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QString( "English" ) );
- subindex = optContent->index( 0, 1, index );
- QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toBool(), true );
+ QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Checked );
subindex = optContent->index( 1, 0, index );
QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QString( "French" ) );
- subindex = optContent->index( 1, 1, index );
- QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toBool(), false );
+ QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
subindex = optContent->index( 2, 0, index );
QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QString( "Japanese" ) );
- subindex = optContent->index( 2, 1, index );
- QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toBool(), false );
+ QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
// RBGroup of languages, so turning on Japanese should turn off English
- bool result = optContent->setData( subindex, QVariant( true ) );
+ bool result = optContent->setData( subindex, QVariant( true ), Qt::CheckStateRole );
subindex = optContent->index( 0, 0, index );
QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QString( "English" ) );
- subindex = optContent->index( 0, 1, index );
- QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toBool(), false );
+ QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
subindex = optContent->index( 2, 0, index );
QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QString( "Japanese" ) );
- subindex = optContent->index( 2, 1, index );
- QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toBool(), true );
+ QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Checked );
subindex = optContent->index( 1, 0, index );
QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QString( "French" ) );
- subindex = optContent->index( 1, 1, index );
- QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toBool(), false );
+ QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
// and turning on French should turn off Japanese
- result = optContent->setData( subindex, QVariant( true ) );
+ result = optContent->setData( subindex, QVariant( true ), Qt::CheckStateRole );
subindex = optContent->index( 0, 0, index );
QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QString( "English" ) );
- subindex = optContent->index( 0, 1, index );
- QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toBool(), false );
+ QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
subindex = optContent->index( 2, 0, index );
QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QString( "Japanese" ) );
- subindex = optContent->index( 2, 1, index );
- QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toBool(), false );
+ QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
subindex = optContent->index( 1, 0, index );
QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QString( "French" ) );
- subindex = optContent->index( 1, 1, index );
- QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toBool(), true );
+ QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Checked );
// and turning off French should leave them all off
- result = optContent->setData( subindex, QVariant( false ) );
+ result = optContent->setData( subindex, QVariant( false ), Qt::CheckStateRole );
subindex = optContent->index( 0, 0, index );
QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QString( "English" ) );
- subindex = optContent->index( 0, 1, index );
- QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toBool(), false );
+ QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
subindex = optContent->index( 2, 0, index );
QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QString( "Japanese" ) );
- subindex = optContent->index( 2, 1, index );
- QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toBool(), false );
+ QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
subindex = optContent->index( 1, 0, index );
QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QString( "French" ) );
- subindex = optContent->index( 1, 1, index );
- QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toBool(), false );
+ QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
delete doc;
}