Commit 28e953cb authored by Albert Astals Cid's avatar Albert Astals Cid

Minor clazy Qt fixes in tests and demo

parent 74ad4e35
......@@ -21,7 +21,7 @@
AbstractInfoDock::AbstractInfoDock(QWidget *parent)
: QDockWidget(parent), m_filled(false)
{
connect(this, SIGNAL(visibilityChanged(bool)), SLOT(slotVisibilityChanged(bool)));
connect(this, &AbstractInfoDock::visibilityChanged, this, &AbstractInfoDock::slotVisibilityChanged);
}
AbstractInfoDock::~AbstractInfoDock()
......
......@@ -59,7 +59,7 @@ void EmbeddedFilesDock::fillInfo()
m_table->setItem(i, 3, new QTableWidgetItem(file->createDate().toString(Qt::SystemLocaleDate)));
m_table->setItem(i, 4, new QTableWidgetItem(file->modDate().toString(Qt::SystemLocaleDate)));
const QByteArray checksum = file->checksum();
const QString checksumString = !checksum.isEmpty() ? QString::fromLatin1(checksum.toHex()) : QString::fromLatin1("n/a");
const QString checksumString = !checksum.isEmpty() ? QString::fromLatin1(checksum.toHex()) : QStringLiteral("n/a");
m_table->setItem(i, 5, new QTableWidgetItem(checksumString));
++i;
}
......
......@@ -24,7 +24,7 @@
static QString yesNoStatement(bool value)
{
return value ? QString::fromLatin1("yes") : QString::fromLatin1("no");
return value ? QStringLiteral("yes") : QStringLiteral("no");
}
FontsDock::FontsDock(QWidget *parent)
......@@ -50,7 +50,7 @@ void FontsDock::fillInfo()
int i = 0;
Q_FOREACH(const Poppler::FontInfo &font, fonts) {
if (font.name().isNull()) {
m_table->setItem(i, 0, new QTableWidgetItem(QString::fromLatin1("[none]")));
m_table->setItem(i, 0, new QTableWidgetItem(QStringLiteral("[none]")));
} else {
m_table->setItem(i, 0, new QTableWidgetItem(font.name()));
}
......
......@@ -43,8 +43,8 @@ void InfoDock::fillInfo()
m_table->setHorizontalHeaderLabels(QStringList() << tr("Key") << tr("Value"));
m_table->setRowCount(keys.count());
QStringList dateKeys;
dateKeys << QString::fromLatin1("CreationDate");
dateKeys << QString::fromLatin1("ModDate");
dateKeys << QStringLiteral("CreationDate");
dateKeys << QStringLiteral("ModDate");
int i = 0;
Q_FOREACH(const QString &date, dateKeys) {
const int id = keys.indexOf(date);
......
......@@ -30,7 +30,8 @@ NavigationToolBar::NavigationToolBar(QWidget *parent)
m_firstAct = addAction(tr("First"), this, SLOT(slotGoFirst()));
m_prevAct = addAction(tr("Previous"), this, SLOT(slotGoPrev()));
m_pageCombo = new QComboBox(this);
connect(m_pageCombo, SIGNAL(activated(int)), this, SLOT(slotComboActivated(int)));
// TODO replace with qOverload once we start requiring Qt 5.7
connect(m_pageCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, &NavigationToolBar::slotComboActivated);
addWidget(m_pageCombo);
m_nextAct = addAction(tr("Next"), this, SLOT(slotGoNext()));
m_lastAct = addAction(tr("Last"), this, SLOT(slotGoLast()));
......@@ -52,7 +53,8 @@ NavigationToolBar::NavigationToolBar(QWidget *parent)
m_zoomCombo->addItem(tr("300%"));
m_zoomCombo->addItem(tr("400%"));
m_zoomCombo->setCurrentIndex(6); // "100%"
connect(m_zoomCombo, SIGNAL(currentIndexChanged(QString)), this, SLOT(slotZoomComboChanged(QString)));
// TODO replace with qOverload once we start requiring Qt 5.7
connect(m_zoomCombo, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged), this, &NavigationToolBar::slotZoomComboChanged);
addWidget(m_zoomCombo);
m_rotationCombo = new QComboBox(this);
......@@ -61,7 +63,8 @@ NavigationToolBar::NavigationToolBar(QWidget *parent)
m_rotationCombo->addItem(trUtf8("90\302\260"));
m_rotationCombo->addItem(trUtf8("180\302\260"));
m_rotationCombo->addItem(trUtf8("270\302\260"));
connect(m_rotationCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(slotRotationComboChanged(int)));
// TODO replace with qOverload once we start requiring Qt 5.7
connect(m_rotationCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &NavigationToolBar::slotRotationComboChanged);
addWidget(m_rotationCombo);
documentClosed();
......
......@@ -51,7 +51,7 @@ void OptContentDock::fillInfo()
}
m_view->setModel(document()->optionalContentModel());
connect(m_view->model(), SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(reloadImage()));
connect(m_view->model(), &QAbstractItemModel::dataChanged, this, &OptContentDock::reloadImage);
m_view->expandToDepth(1);
}
......
......@@ -38,7 +38,7 @@ public:
void documentClosed() override;
void pageChanged(int page) override;
private Q_SLOTS:
public Q_SLOTS:
void slotZoomChanged(qreal value);
void slotRotationChanged(int value);
......
......@@ -41,7 +41,7 @@ void PermissionsDock::fillInfo()
do { \
QListWidgetItem *item = new QListWidgetItem(); \
item->setFlags(item->flags() & ~Qt::ItemIsEnabled); \
item->setText(title); \
item->setText(QStringLiteral(title)); \
item->setCheckState(document()->function() ? Qt::Checked : Qt::Unchecked); \
m_table->addItem(item); \
} while (0)
......
......@@ -34,8 +34,8 @@ ThumbnailsDock::ThumbnailsDock(QWidget *parent)
m_list->setViewMode(QListView::ListMode);
m_list->setMovement(QListView::Static);
m_list->setVerticalScrollMode(QListView::ScrollPerPixel);
connect(m_list, SIGNAL(itemActivated(QListWidgetItem*)),
this, SLOT(slotItemActivated(QListWidgetItem*)));
connect(m_list, &QListWidget::itemActivated,
this, &ThumbnailsDock::slotItemActivated);
}
ThumbnailsDock::~ThumbnailsDock()
......
......@@ -37,8 +37,8 @@ static void fillToc(const QDomNode &parent, QTreeWidget *tree, QTreeWidgetItem *
newitem->setText(0, e.tagName());
bool isOpen = false;
if (e.hasAttribute(QString::fromLatin1("Open"))) {
isOpen = QVariant(e.attribute(QString::fromLatin1("Open"))).toBool();
if (e.hasAttribute(QStringLiteral("Open"))) {
isOpen = QVariant(e.attribute(QStringLiteral("Open"))).toBool();
}
if (isOpen) {
tree->expandItem(newitem);
......
......@@ -43,21 +43,24 @@
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QMessageBox>
PdfViewer::PdfViewer()
: QMainWindow(), m_currentPage(0), m_doc(nullptr)
PdfViewer::PdfViewer(QWidget *parent)
: QMainWindow(parent), m_currentPage(0), m_doc(nullptr)
{
setWindowTitle(tr("Poppler-Qt5 Demo"));
// setup the menus
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
m_fileOpenAct = fileMenu->addAction(tr("&Open"), this, SLOT(slotOpenFile()));
// TODO Use modern syntax when depending on Qt 5.6
m_fileOpenAct = fileMenu->addAction(tr("&Open"), this, SLOT(slotOpenFile())); // clazy:exclude=old-style-connect
m_fileOpenAct->setShortcut(Qt::CTRL + Qt::Key_O);
fileMenu->addSeparator();
m_fileSaveCopyAct = fileMenu->addAction(tr("&Save a Copy..."), this, SLOT(slotSaveCopy()));
// TODO Use modern syntax when depending on Qt 5.6
m_fileSaveCopyAct = fileMenu->addAction(tr("&Save a Copy..."), this, SLOT(slotSaveCopy())); // clazy:exclude=old-style-connect
m_fileSaveCopyAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_S);
m_fileSaveCopyAct->setEnabled(false);
fileMenu->addSeparator();
QAction *act = fileMenu->addAction(tr("&Quit"), qApp, SLOT(closeAllWindows()));
// TODO Use modern syntax when depending on Qt 5.6
QAction *act = fileMenu->addAction(tr("&Quit"), qApp, SLOT(closeAllWindows())); // clazy:exclude=old-style-connect
act->setShortcut(Qt::CTRL + Qt::Key_Q);
QMenu *viewMenu = menuBar()->addMenu(tr("&View"));
......@@ -65,10 +68,10 @@ PdfViewer::PdfViewer()
QMenu *settingsMenu = menuBar()->addMenu(tr("&Settings"));
m_settingsTextAAAct = settingsMenu->addAction(tr("Text Antialias"));
m_settingsTextAAAct->setCheckable(true);
connect(m_settingsTextAAAct, SIGNAL(toggled(bool)), this, SLOT(slotToggleTextAA(bool)));
connect(m_settingsTextAAAct, &QAction::toggled, this, &PdfViewer::slotToggleTextAA);
m_settingsGfxAAAct = settingsMenu->addAction(tr("Graphics Antialias"));
m_settingsGfxAAAct->setCheckable(true);
connect(m_settingsGfxAAAct, SIGNAL(toggled(bool)), this, SLOT(slotToggleGfxAA(bool)));
connect(m_settingsGfxAAAct, &QAction::toggled, this, &PdfViewer::slotToggleGfxAA);
QMenu *settingsRenderMenu = settingsMenu->addMenu(tr("Render Backend"));
m_settingsRenderBackendGrp = new QActionGroup(settingsRenderMenu);
m_settingsRenderBackendGrp->setExclusive(true);
......@@ -81,12 +84,14 @@ PdfViewer::PdfViewer()
act->setCheckable(true);
act->setData(qVariantFromValue(1));
m_settingsRenderBackendGrp->addAction(act);
connect(m_settingsRenderBackendGrp, SIGNAL(triggered(QAction*)),
this, SLOT(slotRenderBackend(QAction*)));
connect(m_settingsRenderBackendGrp, &QActionGroup::triggered,
this, &PdfViewer::slotRenderBackend);
QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
act = helpMenu->addAction(tr("&About"), this, SLOT(slotAbout()));
act = helpMenu->addAction(tr("About &Qt"), this, SLOT(slotAboutQt()));
// TODO Use modern syntax when depending on Qt 5.6
act = helpMenu->addAction(tr("&About"), this, SLOT(slotAbout())); // clazy:exclude=old-style-connect
// TODO Use modern syntax when depending on Qt 5.6
act = helpMenu->addAction(tr("About &Qt"), this, SLOT(slotAboutQt())); // clazy:exclude=old-style-connect
NavigationToolBar *navbar = new NavigationToolBar(this);
addToolBar(navbar);
......@@ -148,8 +153,8 @@ PdfViewer::PdfViewer()
obs->m_viewer = this;
}
connect(navbar, SIGNAL(zoomChanged(qreal)), view, SLOT(slotZoomChanged(qreal)));
connect(navbar, SIGNAL(rotationChanged(int)), view, SLOT(slotRotationChanged(int)));
connect(navbar, &NavigationToolBar::zoomChanged, view, &PageView::slotZoomChanged);
connect(navbar, &NavigationToolBar::rotationChanged, view, &PageView::slotRotationChanged);
// activate AA by default
m_settingsTextAAAct->setChecked(true);
......@@ -254,8 +259,7 @@ void PdfViewer::slotSaveCopy()
void PdfViewer::slotAbout()
{
const QString text("This is a demo of the Poppler-Qt5 library.");
QMessageBox::about(this, QString::fromLatin1("About Poppler-Qt5 Demo"), text);
QMessageBox::about(this, tr("About Poppler-Qt5 Demo"), tr("This is a demo of the Poppler-Qt5 library."));
}
void PdfViewer::slotAboutQt()
......
......@@ -36,7 +36,7 @@ class PdfViewer : public QMainWindow
friend class DocumentObserver;
public:
PdfViewer();
PdfViewer(QWidget *parent = nullptr);
~PdfViewer();
QSize sizeHint() const override;
......
......@@ -7,6 +7,8 @@
class TestActualText: public QObject
{
Q_OBJECT
public:
TestActualText(QObject *parent = nullptr) : QObject(parent) { }
private slots:
void checkActualText1();
};
......@@ -20,7 +22,7 @@ void TestActualText::checkActualText1()
Poppler::Page *page = doc->page(0);
QVERIFY( page );
QCOMPARE( page->text(QRectF()), QString("The slow brown fox jumps over the black dog.") );
QCOMPARE( page->text(QRectF()), QLatin1String("The slow brown fox jumps over the black dog.") );
delete page;
......
......@@ -13,6 +13,8 @@
class TestAnnotations : public QObject
{
Q_OBJECT
public:
TestAnnotations(QObject *parent = nullptr) : QObject(parent) { }
private slots:
void checkQColorPrecision();
void checkFontSizeAndColor();
......@@ -38,10 +40,10 @@ void TestAnnotations::checkQColorPrecision() {
void TestAnnotations::checkFontSizeAndColor()
{
const QString contents{"foobar"};
const QString contents = QStringLiteral("foobar");
const std::vector<QColor> testColors{QColor::fromRgb(0xAB, 0xCD, 0xEF),
QColor::fromCmyk(0xAB, 0xBC, 0xCD, 0xDE)};
const QFont testFont("Helvetica", 20);
const QFont testFont(QStringLiteral("Helvetica"), 20);
QTemporaryFile tempFile;
QVERIFY(tempFile.open());
......
......@@ -7,6 +7,8 @@
class TestAttachments: public QObject
{
Q_OBJECT
public:
TestAttachments(QObject *parent = nullptr) : QObject(parent) { }
private slots:
void checkNoAttachments();
void checkAttach1();
......@@ -39,7 +41,7 @@ void TestAttachments::checkAttach1()
QCOMPARE( fileList.size(), 2 );
Poppler::EmbeddedFile *embfile = fileList.at(0);
QCOMPARE( embfile->name(), QString( "kroller.png" ) );
QCOMPARE( embfile->name(), QLatin1String( "kroller.png" ) );
QCOMPARE( embfile->description(), QString() );
QCOMPARE( embfile->createDate(), QDateTime( QDate(), QTime() ) );
QCOMPARE( embfile->modDate(), QDateTime( QDate(), QTime() ) );
......@@ -53,7 +55,7 @@ void TestAttachments::checkAttach1()
Poppler::EmbeddedFile *embfile2 = fileList.at(1);
QCOMPARE( embfile2->name(), QString("gnome-64.gif") );
QCOMPARE( embfile2->name(), QLatin1String("gnome-64.gif") );
QCOMPARE( embfile2->description(), QString() );
QCOMPARE( embfile2->modDate(), QDateTime( QDate(), QTime() ) );
QCOMPARE( embfile2->createDate(), QDateTime( QDate(), QTime() ) );
......@@ -83,21 +85,21 @@ void TestAttachments::checkAttach2()
QCOMPARE( fileList.size(), 3 );
Poppler::EmbeddedFile *embfile1 = fileList.at(0);
QCOMPARE( embfile1->name(), QString("Acro7 thoughts") );
QCOMPARE( embfile1->name(), QLatin1String("Acro7 thoughts") );
QCOMPARE( embfile1->description(), QString() );
QCOMPARE( embfile1->createDate(), QDateTime( QDate( 2003, 8, 4 ), QTime( 13, 54, 54), Qt::UTC ) );
QCOMPARE( embfile1->modDate(), QDateTime( QDate( 2003, 8, 4 ), QTime( 14, 15, 27), Qt::UTC ) );
QCOMPARE( embfile1->mimeType(), QString("text/xml") );
QCOMPARE( embfile1->mimeType(), QLatin1String("text/xml") );
Poppler::EmbeddedFile *embfile2 = fileList.at(1);
QCOMPARE( embfile2->name(), QString("acro transitions 1.xls") );
QCOMPARE( embfile2->name(), QLatin1String("acro transitions 1.xls") );
QCOMPARE( embfile2->description(), QString() );
QCOMPARE( embfile2->createDate(), QDateTime( QDate( 2003, 7, 18 ), QTime( 21, 7, 16), Qt::UTC ) );
QCOMPARE( embfile2->modDate(), QDateTime( QDate( 2003, 7, 22 ), QTime( 13, 4, 40), Qt::UTC ) );
QCOMPARE( embfile2->mimeType(), QString("application/excel") );
QCOMPARE( embfile2->mimeType(), QLatin1String("application/excel") );
Poppler::EmbeddedFile *embfile3 = fileList.at(2);
QCOMPARE( embfile3->name(), QString("apago_pdfe_wide.gif") );
QCOMPARE( embfile3->name(), QLatin1String("apago_pdfe_wide.gif") );
QCOMPARE( embfile3->description(), QString() );
QCOMPARE( embfile3->createDate(), QDateTime( QDate( 2003, 1, 31 ), QTime( 15, 54, 29), Qt::UTC ) );
QCOMPARE( embfile3->modDate(), QDateTime( QDate( 2003, 1, 31 ), QTime( 15, 52, 58), Qt::UTC ) );
......@@ -120,7 +122,7 @@ void TestAttachments::checkAttach3()
QCOMPARE( fileList.size(), 1 );
Poppler::EmbeddedFile *embfile = fileList.at(0);
QCOMPARE( embfile->name(), QString( "ADEX1.xpdf.pgp" ) );
QCOMPARE( embfile->name(), QLatin1String( "ADEX1.xpdf.pgp" ) );
QCOMPARE( embfile->description(), QString() );
QCOMPARE( embfile->createDate(), QDateTime( QDate( 2004, 3, 29 ), QTime( 19, 37, 16), Qt::UTC ) );
QCOMPARE( embfile->modDate(), QDateTime( QDate( 2004, 3, 29 ), QTime( 19, 37, 16), Qt::UTC ) );
......@@ -143,11 +145,11 @@ void TestAttachments::checkAttach4()
QCOMPARE( fileList.size(), 1 );
Poppler::EmbeddedFile *embfile = fileList.at(0);
QCOMPARE( embfile->name(), QString( "export-altona.csv" ) );
QCOMPARE( embfile->description(), QString("Altona Export") );
QCOMPARE( embfile->name(), QLatin1String( "export-altona.csv" ) );
QCOMPARE( embfile->description(), QLatin1String("Altona Export") );
QCOMPARE( embfile->createDate(), QDateTime( QDate( 2005, 8, 30 ), QTime( 20, 49, 35), Qt::UTC ) );
QCOMPARE( embfile->modDate(), QDateTime( QDate( 2005, 8, 30 ), QTime( 20, 49, 52), Qt::UTC ) );
QCOMPARE( embfile->mimeType(), QString("application/vnd.ms-excel") );
QCOMPARE( embfile->mimeType(), QLatin1String("application/vnd.ms-excel") );
delete doc;
}
......
......@@ -8,6 +8,9 @@ Q_DECLARE_METATYPE(QTime)
class TestDateConv: public QObject
{
Q_OBJECT
public:
TestDateConv(QObject *parent = nullptr) : QObject(parent) {}
private slots:
void initTestCase();
void checkDates_data();
......
......@@ -7,6 +7,8 @@
class TestFontsData: public QObject
{
Q_OBJECT
public:
TestFontsData(QObject *parent = nullptr) : QObject(parent) { }
private slots:
void checkNoFonts();
void checkType1();
......@@ -72,9 +74,9 @@ void TestFontsData::checkType1()
QList<Poppler::FontInfo> listOfFonts = doc->fonts();
QCOMPARE( listOfFonts.size(), 1 );
QCOMPARE( listOfFonts.at(0).name(), QString("Helvetica") );
QCOMPARE( listOfFonts.at(0).name(), QLatin1String("Helvetica") );
QCOMPARE( listOfFonts.at(0).type(), Poppler::FontInfo::Type1 );
QCOMPARE( listOfFonts.at(0).typeName(), QString("Type 1") );
QCOMPARE( listOfFonts.at(0).typeName(), QLatin1String("Type 1") );
QCOMPARE( listOfFonts.at(0).isEmbedded(), false );
QCOMPARE( listOfFonts.at(0).isSubset(), false );
......@@ -90,16 +92,16 @@ void TestFontsData::checkType3()
QList<Poppler::FontInfo> listOfFonts = doc->fonts();
QCOMPARE( listOfFonts.size(), 2 );
QCOMPARE( listOfFonts.at(0).name(), QString("Helvetica") );
QCOMPARE( listOfFonts.at(0).name(), QLatin1String("Helvetica") );
QCOMPARE( listOfFonts.at(0).type(), Poppler::FontInfo::Type1 );
QCOMPARE( listOfFonts.at(0).typeName(), QString("Type 1") );
QCOMPARE( listOfFonts.at(0).typeName(), QLatin1String("Type 1") );
QCOMPARE( listOfFonts.at(0).isEmbedded(), false );
QCOMPARE( listOfFonts.at(0).isSubset(), false );
QCOMPARE( listOfFonts.at(1).name(), QString("") );
QCOMPARE( listOfFonts.at(1).name(), QString() );
QCOMPARE( listOfFonts.at(1).type(), Poppler::FontInfo::Type3 );
QCOMPARE( listOfFonts.at(1).typeName(), QString("Type 3") );
QCOMPARE( listOfFonts.at(1).typeName(), QLatin1String("Type 3") );
QCOMPARE( listOfFonts.at(1).isEmbedded(), true );
QCOMPARE( listOfFonts.at(1).isSubset(), false );
......@@ -115,16 +117,16 @@ void TestFontsData::checkTrueType()
QList<Poppler::FontInfo> listOfFonts = doc->fonts();
QCOMPARE( listOfFonts.size(), 2 );
QCOMPARE( listOfFonts.at(0).name(), QString("Arial-BoldMT") );
QCOMPARE( listOfFonts.at(0).name(), QLatin1String("Arial-BoldMT") );
QCOMPARE( listOfFonts.at(0).type(), Poppler::FontInfo::TrueType );
QCOMPARE( listOfFonts.at(0).typeName(), QString("TrueType") );
QCOMPARE( listOfFonts.at(0).typeName(), QLatin1String("TrueType") );
QCOMPARE( listOfFonts.at(0).isEmbedded(), false );
QCOMPARE( listOfFonts.at(0).isSubset(), false );
QCOMPARE( listOfFonts.at(1).name(), QString("ArialMT") );
QCOMPARE( listOfFonts.at(1).name(), QLatin1String("ArialMT") );
QCOMPARE( listOfFonts.at(1).type(), Poppler::FontInfo::TrueType );
QCOMPARE( listOfFonts.at(1).typeName(), QString("TrueType") );
QCOMPARE( listOfFonts.at(1).typeName(), QLatin1String("TrueType") );
QCOMPARE( listOfFonts.at(1).isEmbedded(), false );
QCOMPARE( listOfFonts.at(1).isSubset(), false );
......
......@@ -7,6 +7,8 @@
class TestForms: public QObject
{
Q_OBJECT
public:
TestForms(QObject *parent = nullptr) : QObject(parent) { }
private slots:
void testCheckbox();// Test for issue #655
};
......
......@@ -6,6 +6,8 @@
class TestGooString : public QObject
{
Q_OBJECT
public:
TestGooString(QObject *parent = nullptr) : QObject(parent) { }
private slots:
void testInsertData_data();
void testInsertData();
......@@ -83,19 +85,19 @@ void TestGooString::testFormat()
{
const QScopedPointer<GooString> goo(GooString::format("{0:ud} {1:d} {2:d}",
UINT_MAX, INT_MAX, INT_MIN));
const QByteArray expected = QString("%1 %2 %3").arg(UINT_MAX).arg(INT_MAX).arg(INT_MIN).toLatin1();
const QByteArray expected = QStringLiteral("%1 %2 %3").arg(UINT_MAX).arg(INT_MAX).arg(INT_MIN).toLatin1();
QCOMPARE(goo->getCString(), expected.constData());
}
{
const QScopedPointer<GooString> goo(GooString::format("{0:uld} {1:ld} {2:ld}",
ULONG_MAX, LONG_MAX, LONG_MIN));
const QByteArray expected = QString("%1 %2 %3").arg(ULONG_MAX).arg(LONG_MAX).arg(LONG_MIN).toLatin1();
const QByteArray expected = QStringLiteral("%1 %2 %3").arg(ULONG_MAX).arg(LONG_MAX).arg(LONG_MIN).toLatin1();
QCOMPARE(goo->getCString(), expected.constData());
}
{
const QScopedPointer<GooString> goo(GooString::format("{0:ulld} {1:lld} {2:lld}",
ULLONG_MAX, LLONG_MAX, LLONG_MIN));
const QByteArray expected = QString("%1 %2 %3").arg(ULLONG_MAX).arg(LLONG_MAX).arg(LLONG_MIN).toLatin1();
const QByteArray expected = QStringLiteral("%1 %2 %3").arg(ULLONG_MAX).arg(LLONG_MAX).arg(LLONG_MIN).toLatin1();
QCOMPARE(goo->getCString(), expected.constData());
}
{
......
......@@ -6,6 +6,8 @@
class TestLexer : public QObject
{
Q_OBJECT
public:
TestLexer(QObject *parent = nullptr) : QObject(parent) { }
private slots:
void testNumbers();
};
......
......@@ -7,6 +7,8 @@
class TestLinks : public QObject
{
Q_OBJECT
public:
TestLinks(QObject *parent = nullptr) : QObject(parent) { }
private slots:
void checkDocumentWithNoDests();
void checkDests_xr01();
......@@ -31,7 +33,7 @@ void TestLinks::checkDocumentWithNoDests()
QVERIFY( doc );
std::unique_ptr< Poppler::LinkDestination > dest;
dest.reset( doc->linkDestination("no.dests.in.this.document") );
dest.reset( doc->linkDestination(QStringLiteral("no.dests.in.this.document")) );
QVERIFY( !isDestinationValid_pageNumber( dest.get(), doc ) );
QVERIFY( isDestinationValid_name( dest.get() ) );
......@@ -56,7 +58,7 @@ void TestLinks::checkDests_xr01()
const Poppler::LinkDestination dest = link->destination();
QVERIFY( !isDestinationValid_pageNumber( &dest, doc ) );
QVERIFY( isDestinationValid_name( &dest ) );
QCOMPARE( dest.destinationName(), QString::fromLatin1("section.1") );
QCOMPARE( dest.destinationName(), QLatin1String("section.1") );
}
{
......@@ -65,7 +67,7 @@ void TestLinks::checkDests_xr01()
const Poppler::LinkDestination dest = link->destination();
QVERIFY( !isDestinationValid_pageNumber( &dest, doc ) );
QVERIFY( isDestinationValid_name( &dest ) );
QCOMPARE( dest.destinationName(), QString::fromLatin1("section.2") );
QCOMPARE( dest.destinationName(), QLatin1String("section.2") );
}
qDeleteAll(links);
......@@ -80,13 +82,13 @@ void TestLinks::checkDests_xr02()
QVERIFY( doc );
std::unique_ptr< Poppler::LinkDestination > dest;
dest.reset( doc->linkDestination("section.1") );
dest.reset( doc->linkDestination(QStringLiteral("section.1")) );
QVERIFY( isDestinationValid_pageNumber( dest.get(), doc ) );
QVERIFY( !isDestinationValid_name( dest.get() ) );
dest.reset( doc->linkDestination("section.2") );
dest.reset( doc->linkDestination(QStringLiteral("section.2")) );
QVERIFY( isDestinationValid_pageNumber( dest.get(), doc ) );
QVERIFY( !isDestinationValid_name( dest.get() ) );
dest.reset( doc->linkDestination("section.3") );
dest.reset( doc->linkDestination(QStringLiteral("section.3")) );
QVERIFY( !isDestinationValid_pageNumber( dest.get(), doc ) );
QVERIFY( isDestinationValid_name( dest.get() ) );
......
......@@ -5,6 +5,8 @@
class TestMetaData: public QObject
{
Q_OBJECT
public:
TestMetaData(QObject *parent = nullptr) : QObject(parent) { }
private slots:
void checkStrings_data();
void checkStrings();
......@@ -85,8 +87,8 @@ void TestMetaData::checkStringKeys()
QVERIFY( doc );
QStringList keyList;
keyList << "Title" << "Author" << "Creator" << "Keywords" << "CreationDate";
keyList << "Producer" << "ModDate" << "Custom1" << "Custom2";
keyList << QStringLiteral("Title") << QStringLiteral("Author") << QStringLiteral("Creator") << QStringLiteral("Keywords") << QStringLiteral("CreationDate");
keyList << QStringLiteral("Producer") << QStringLiteral("ModDate") << QStringLiteral("Custom1") << QStringLiteral("Custom2");
keyList.sort();
QStringList keysInDoc = doc->infoKeys();
keysInDoc.sort();
......@@ -147,8 +149,8 @@ void TestMetaData::checkDate()
doc = Poppler::Document::load(TESTDATADIR "/unittestcases/truetype.pdf");
QVERIFY( doc );
QCOMPARE( doc->date("ModDate"), QDateTime(QDate(2005, 12, 5), QTime(9,44,46), Qt::UTC ) );
QCOMPARE( doc->date("CreationDate"), QDateTime(QDate(2005, 8, 13), QTime(1,12,11), Qt::UTC ) );
QCOMPARE( doc->date(QStringLiteral("ModDate")), QDateTime(QDate(2005, 12, 5), QTime(9,44,46), Qt::UTC ) );
QCOMPARE( doc->date(QStringLiteral("CreationDate")), QDateTime(QDate(2005, 8, 13), QTime(1,12,11), Qt::UTC ) );
delete doc;
}
......
......@@ -6,6 +6,8 @@
class TestObject : public QObject
{
Q_OBJECT
public:
TestObject(QObject *parent = nullptr) : QObject(parent) { }
private slots:
void benchDefaultConstructor();
void benchMoveConstructor();
......
......@@ -8,6 +8,8 @@
class TestOptionalContent: public QObject
{
Q_OBJECT
public:
TestOptionalContent(QObject *parent = nullptr) : QObject(parent) { }
private slots:
void checkVisPolicy();
void checkNestedLayers();
......@@ -28,10 +30,10 @@ void TestOptionalContent::checkVisPolicy()
Poppler::OptContentModel *optContent = doc->optionalContentModel();
QModelIndex index;
index = optContent->index( 0, 0, QModelIndex() );
QCOMPARE( optContent->data( index, Qt::DisplayRole ).toString(), QString( "A" ) );
QCOMPARE( optContent->data( index, Qt::DisplayRole ).toString(), QLatin1String( "A" ) );
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" ) );
QCOMPARE( optContent->data( index, Qt::DisplayRole ).toString(), QLatin1String( "B" ) );
QCOMPARE( static_cast<Qt::CheckState>( optContent->data( index, Qt::CheckStateRole ).toInt() ), Qt::Checked );
delete doc;
......@@ -49,24 +51,24 @@ void TestOptionalContent::checkNestedLayers()
QModelIndex index;
index = optContent->index( 0, 0, QModelIndex() );
QCOMPARE( optContent->data( index, Qt::DisplayRole ).toString(), QString( "Black Text and Green Snow" ) );
QCOMPARE( optContent->data( index, Qt::DisplayRole ).toString(), QLatin1String( "Black Text and Green Snow" ) );
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" ) );
QCOMPARE( optContent->data( index, Qt::DisplayRole ).toString(), QLatin1String( "Mountains and Image" ) );
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" ) );
QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QLatin1String( "Image" ) );
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" ) );
QCOMPARE( optContent->data( index, Qt::DisplayRole ).toString(), QLatin1String( "Starburst" ) );
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" ) );
QCOMPARE( optContent->data( index, Qt::DisplayRole ).toString(), QLatin1String( "Watermark" ) );
QCOMPARE( static_cast<Qt::CheckState>( optContent->data( index, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
delete doc;
......@@ -375,50 +377,50 @@ void TestOptionalContent::checkRadioButtons()
QModelIndex index;
index = optContent->index( 0, 0, QModelIndex() );
QCOMPARE( optContent->data( index, Qt::DisplayRole ).toString(), QString( "Languages" ) );
QCOMPARE( optContent->data( index, Qt::DisplayRole ).toString(), QLatin1String( "Languages" ) );
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" ) );
QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QLatin1String( "English" ) );
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" ) );
QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QLatin1String( "French" ) );
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" ) );
QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QLatin1String( "Japanese" ) );
QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
// RBGroup of languages, so turning on Japanese should turn off English
QVERIFY( optContent->setData( subindex, QVariant( true ), Qt::CheckStateRole ) );
subindex = optContent->index( 0, 0, index );
QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QString( "English" ) );
QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QLatin1String( "English" ) );
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" ) );
QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QLatin1String( "Japanese" ) );
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" ) );
QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QLatin1String( "French" ) );
QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
// and turning on French should turn off Japanese
QVERIFY( optContent->setData( subindex, QVariant( true ), Qt::CheckStateRole ) );
subindex = optContent->index( 0, 0, index );
QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QString( "English" ) );
QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QLatin1String( "English" ) );
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" ) );
QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QLatin1String( "Japanese" ) );
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" ) );
QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QLatin1String( "French" ) );
QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Checked );