clang-tidy: use auto

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2022-04-11 17:06:50 -07:00 committed by Jonathan White
parent f3f1520f81
commit 7e1d980d08
32 changed files with 224 additions and 223 deletions

View File

@ -90,7 +90,7 @@ void ShortcutWidget::keyEvent(QKeyEvent* event)
return;
}
Qt::Key key = static_cast<Qt::Key>(event->key());
auto key = static_cast<Qt::Key>(event->key());
if (key <= 0 || key == Qt::Key_unknown) {
return;

View File

@ -57,7 +57,7 @@ int AddGroup::executeWithDatabase(QSharedPointer<Database> database, QSharedPoin
return EXIT_FAILURE;
}
Group* newGroup = new Group();
auto newGroup = new Group();
newGroup->setUuid(QUuid::createUuid());
newGroup->setName(groupName);
newGroup->setParent(parentGroup);

View File

@ -41,7 +41,7 @@ static void estimate(const char* pwd, bool advanced)
{
auto& out = Utils::STDOUT;
int len = static_cast<int>(strlen(pwd));
auto len = static_cast<int>(strlen(pwd));
if (!advanced) {
const auto e = PasswordHealth(pwd).entropy();
// clang-format off

View File

@ -865,7 +865,7 @@ bool Entry::equals(const Entry* other, CompareItemOptions options) const
Entry* Entry::clone(CloneFlags flags) const
{
Entry* entry = new Entry();
auto entry = new Entry();
entry->setUpdateTimeinfo(false);
if (flags & CloneNewUuid) {
entry->m_uuid = QUuid::createUuid();

View File

@ -890,7 +890,7 @@ Group* Group::findChildByName(const QString& name)
*/
Group* Group::clone(Entry::CloneFlags entryFlags, Group::CloneFlags groupFlags) const
{
Group* clonedGroup = new Group();
auto clonedGroup = new Group();
clonedGroup->setUpdateTimeinfo(false);

View File

@ -432,13 +432,13 @@ Group* KeePass1Reader::readGroup(QIODevice* cipherStream)
bool reachedEnd = false;
do {
quint16 fieldType = Endian::readSizedInt<quint16>(cipherStream, KeePass1::BYTEORDER, &ok);
auto fieldType = Endian::readSizedInt<quint16>(cipherStream, KeePass1::BYTEORDER, &ok);
if (!ok) {
raiseError(tr("Invalid group field type number"));
return nullptr;
}
int fieldSize = static_cast<int>(Endian::readSizedInt<quint32>(cipherStream, KeePass1::BYTEORDER, &ok));
auto fieldSize = static_cast<int>(Endian::readSizedInt<quint32>(cipherStream, KeePass1::BYTEORDER, &ok));
if (!ok) {
raiseError(tr("Invalid group field size"));
return nullptr;
@ -513,7 +513,7 @@ Group* KeePass1Reader::readGroup(QIODevice* cipherStream)
raiseError(tr("Incorrect group icon field size"));
return nullptr;
}
quint32 iconNumber = Endian::bytesToSizedInt<quint32>(fieldData, KeePass1::BYTEORDER);
auto iconNumber = Endian::bytesToSizedInt<quint32>(fieldData, KeePass1::BYTEORDER);
group->setIcon(iconNumber);
break;
}
@ -564,13 +564,13 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
bool reachedEnd = false;
do {
quint16 fieldType = Endian::readSizedInt<quint16>(cipherStream, KeePass1::BYTEORDER, &ok);
auto fieldType = Endian::readSizedInt<quint16>(cipherStream, KeePass1::BYTEORDER, &ok);
if (!ok) {
raiseError(tr("Missing entry field type number"));
return nullptr;
}
int fieldSize = static_cast<int>(Endian::readSizedInt<quint32>(cipherStream, KeePass1::BYTEORDER, &ok));
auto fieldSize = static_cast<int>(Endian::readSizedInt<quint32>(cipherStream, KeePass1::BYTEORDER, &ok));
if (!ok) {
raiseError(tr("Invalid entry field size"));
return nullptr;
@ -598,7 +598,7 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
raiseError(tr("Invalid entry group id field size"));
return nullptr;
}
quint32 groupId = Endian::bytesToSizedInt<quint32>(fieldData, KeePass1::BYTEORDER);
auto groupId = Endian::bytesToSizedInt<quint32>(fieldData, KeePass1::BYTEORDER);
m_entryGroupIds.insert(entry.data(), groupId);
break;
}
@ -607,7 +607,7 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
raiseError(tr("Invalid entry icon field size"));
return nullptr;
}
quint32 iconNumber = Endian::bytesToSizedInt<quint32>(fieldData, KeePass1::BYTEORDER);
auto iconNumber = Endian::bytesToSizedInt<quint32>(fieldData, KeePass1::BYTEORDER);
entry->setIcon(iconNumber);
break;
}
@ -806,7 +806,7 @@ bool KeePass1Reader::parseGroupTreeState(const QByteArray& data)
}
int pos = 0;
quint32 num = Endian::bytesToSizedInt<quint32>(data.mid(pos, 4), KeePass1::BYTEORDER);
auto num = Endian::bytesToSizedInt<quint32>(data.mid(pos, 4), KeePass1::BYTEORDER);
pos += 4;
if (static_cast<quint32>(data.size() - 4) != (num * 5)) {
@ -814,7 +814,7 @@ bool KeePass1Reader::parseGroupTreeState(const QByteArray& data)
}
for (quint32 i = 0; i < num; i++) {
quint32 groupId = Endian::bytesToSizedInt<quint32>(data.mid(pos, 4), KeePass1::BYTEORDER);
auto groupId = Endian::bytesToSizedInt<quint32>(data.mid(pos, 4), KeePass1::BYTEORDER);
pos += 4;
bool expanded = data.at(pos);
@ -836,13 +836,13 @@ bool KeePass1Reader::parseCustomIcons4(const QByteArray& data)
int pos = 0;
quint32 numIcons = Endian::bytesToSizedInt<quint32>(data.mid(pos, 4), KeePass1::BYTEORDER);
auto numIcons = Endian::bytesToSizedInt<quint32>(data.mid(pos, 4), KeePass1::BYTEORDER);
pos += 4;
quint32 numEntries = Endian::bytesToSizedInt<quint32>(data.mid(pos, 4), KeePass1::BYTEORDER);
auto numEntries = Endian::bytesToSizedInt<quint32>(data.mid(pos, 4), KeePass1::BYTEORDER);
pos += 4;
quint32 numGroups = Endian::bytesToSizedInt<quint32>(data.mid(pos, 4), KeePass1::BYTEORDER);
auto numGroups = Endian::bytesToSizedInt<quint32>(data.mid(pos, 4), KeePass1::BYTEORDER);
pos += 4;
QList<QUuid> iconUuids;
@ -851,7 +851,7 @@ bool KeePass1Reader::parseCustomIcons4(const QByteArray& data)
if (data.size() < (pos + 4)) {
return false;
}
quint32 iconSize = Endian::bytesToSizedInt<quint32>(data.mid(pos, 4), KeePass1::BYTEORDER);
auto iconSize = Endian::bytesToSizedInt<quint32>(data.mid(pos, 4), KeePass1::BYTEORDER);
pos += 4;
if (static_cast<quint32>(data.size()) < (pos + iconSize)) {
@ -873,7 +873,7 @@ bool KeePass1Reader::parseCustomIcons4(const QByteArray& data)
QByteArray entryUuid = data.mid(pos, 16);
pos += 16;
quint32 iconId = Endian::bytesToSizedInt<quint32>(data.mid(pos, 4), KeePass1::BYTEORDER);
auto iconId = Endian::bytesToSizedInt<quint32>(data.mid(pos, 4), KeePass1::BYTEORDER);
pos += 4;
if (m_entryUuids.contains(entryUuid) && (iconId < static_cast<quint32>(iconUuids.size()))) {
@ -886,10 +886,10 @@ bool KeePass1Reader::parseCustomIcons4(const QByteArray& data)
}
for (quint32 i = 0; i < numGroups; i++) {
quint32 groupId = Endian::bytesToSizedInt<quint32>(data.mid(pos, 4), KeePass1::BYTEORDER);
auto groupId = Endian::bytesToSizedInt<quint32>(data.mid(pos, 4), KeePass1::BYTEORDER);
pos += 4;
quint32 iconId = Endian::bytesToSizedInt<quint32>(data.mid(pos, 4), KeePass1::BYTEORDER);
auto iconId = Endian::bytesToSizedInt<quint32>(data.mid(pos, 4), KeePass1::BYTEORDER);
pos += 4;
if (m_groupIds.contains(groupId) && (iconId < static_cast<quint32>(iconUuids.size()))) {

View File

@ -281,7 +281,7 @@ void Application::processIncomingConnection()
void Application::socketReadyRead()
{
QLocalSocket* socket = qobject_cast<QLocalSocket*>(sender());
auto socket = qobject_cast<QLocalSocket*>(sender());
if (!socket) {
return;
}

View File

@ -70,7 +70,7 @@ QSize CategoryListWidget::minimumSizeHint() const
int CategoryListWidget::addCategory(const QString& labelText, const QIcon& icon)
{
QListWidgetItem* item = new QListWidgetItem(m_ui->categoryList);
auto item = new QListWidgetItem(m_ui->categoryList);
item->setText(labelText);
item->setIcon(icon);
m_ui->categoryList->addItem(item);

View File

@ -899,7 +899,7 @@ void DatabaseWidget::openUrlForEntry(Entry* entry)
this);
msgbox.setDefaultButton(QMessageBox::No);
QCheckBox* checkbox = new QCheckBox(tr("Remember my choice"), &msgbox);
auto checkbox = new QCheckBox(tr("Remember my choice"), &msgbox);
msgbox.setCheckBox(checkbox);
bool remember = false;
QObject::connect(checkbox, &QCheckBox::stateChanged, [&](int state) {

View File

@ -88,7 +88,7 @@ void KMessageWidgetPrivate::init(KMessageWidget *q_ptr)
QObject::connect(textLabel, SIGNAL(linkActivated(QString)), q, SIGNAL(linkActivated(QString)));
QObject::connect(textLabel, SIGNAL(linkHovered(QString)), q, SIGNAL(linkHovered(QString)));
QAction *closeAction = new QAction(q);
auto closeAction = new QAction(q);
closeAction->setText(KMessageWidget::tr("&Close"));
closeAction->setToolTip(KMessageWidget::tr("Close message"));
closeAction->setIcon(icons()->icon("message-close"));
@ -114,7 +114,7 @@ void KMessageWidgetPrivate::createLayout()
const auto actions = q->actions();
for (QAction *action: actions) {
QToolButton *button = new QToolButton(content);
auto button = new QToolButton(content);
button->setDefaultAction(action);
button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
buttons.append(button);
@ -126,12 +126,12 @@ void KMessageWidgetPrivate::createLayout()
closeButton->setAutoRaise(buttons.isEmpty());
if (wordWrap) {
QGridLayout *layout = new QGridLayout(content);
auto layout = new QGridLayout(content);
// Set alignment to make sure icon does not move down if text wraps
layout->addWidget(iconLabel, 0, 0, 1, 1, Qt::AlignHCenter | Qt::AlignTop);
layout->addWidget(textLabel, 0, 1);
QHBoxLayout *buttonLayout = new QHBoxLayout;
auto buttonLayout = new QHBoxLayout;
buttonLayout->addStretch();
for (QToolButton* button: asConst(buttons)) {
// For some reason, calling show() is necessary if wordwrap is true,
@ -143,7 +143,7 @@ void KMessageWidgetPrivate::createLayout()
buttonLayout->addWidget(closeButton);
layout->addItem(buttonLayout, 1, 0, 1, 2);
} else {
QHBoxLayout *layout = new QHBoxLayout(content);
auto layout = new QHBoxLayout(content);
layout->addWidget(iconLabel);
layout->addWidget(textLabel);

View File

@ -83,7 +83,7 @@ PasswordGeneratorWidget::PasswordGeneratorWidget(QWidget* parent)
// set font size of password quality and entropy labels dynamically to 80% of
// the default font size, but make it no smaller than 8pt
QFont defaultFont;
int smallerSize = static_cast<int>(defaultFont.pointSize() * 0.8f);
auto smallerSize = static_cast<int>(defaultFont.pointSize() * 0.8f);
if (smallerSize >= 8) {
defaultFont.setPointSize(smallerSize);
m_ui->entropyLabel->setFont(defaultFont);

View File

@ -83,7 +83,7 @@ SearchWidget::~SearchWidget()
bool SearchWidget::eventFilter(QObject* obj, QEvent* event)
{
if (event->type() == QEvent::KeyPress) {
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
auto keyEvent = static_cast<QKeyEvent*>(event);
if (keyEvent->key() == Qt::Key_Escape) {
emit escapePressed();
return true;

View File

@ -82,7 +82,7 @@ TotpExportSettingsDialog::TotpExportSettingsDialog(DatabaseWidget* parent, Entry
QBuffer buffer;
qrc.writeSvg(&buffer, logicalDpiX());
m_totpSvgWidget->load(buffer.data());
const int minsize = static_cast<int>(logicalDpiX() * 2.5);
const auto minsize = static_cast<int>(logicalDpiX() * 2.5);
m_totpSvgWidget->setMinimumSize(minsize, minsize);
} else {
auto errorBox = new QMessageBox(parent);

View File

@ -82,7 +82,7 @@ void WelcomeWidget::refreshLastDatabases()
m_ui->recentListWidget->clear();
const QStringList lastDatabases = config()->get(Config::LastDatabases).toStringList();
for (const QString& database : lastDatabases) {
QListWidgetItem* itm = new QListWidgetItem;
auto itm = new QListWidgetItem;
itm->setText(database);
m_ui->recentListWidget->addItem(itm);
}

View File

@ -196,7 +196,7 @@ void CsvImportWidget::writeDatabase()
if (not m_parserModel->data(m_parserModel->index(r, 1)).isValid()) {
continue;
}
Entry* entry = new Entry();
auto entry = new Entry();
entry->setUuid(QUuid::createUuid());
entry->setGroup(splitGroups(m_parserModel->data(m_parserModel->index(r, 0)).toString()));
entry->setTitle(m_parserModel->data(m_parserModel->index(r, 1)).toString());
@ -325,7 +325,7 @@ Group* CsvImportWidget::splitGroups(const QString& label)
for (const QString& groupName : groupList) {
Group* children = hasChildren(current, groupName);
if (children == nullptr) {
Group* brandNew = new Group();
auto brandNew = new Group();
brandNew->setParent(current);
brandNew->setName(groupName);
brandNew->setUuid(QUuid::createUuid());

View File

@ -790,7 +790,7 @@ void EditEntryWidget::copyPublicKey()
void EditEntryWidget::useExpiryPreset(QAction* action)
{
m_mainUi->expireCheck->setChecked(true);
TimeDelta delta = action->data().value<TimeDelta>();
auto delta = action->data().value<TimeDelta>();
QDateTime now = Clock::currentDateTime();
QDateTime expiryDateTime = now + delta;
m_mainUi->expireDatePicker->setDateTime(expiryDateTime);

View File

@ -390,14 +390,14 @@ bool EntryAttachmentsWidget::eventFilter(QObject* watched, QEvent* e)
if (watched == m_ui->attachmentsView->viewport() && !isReadOnly()) {
const QEvent::Type eventType = e->type();
if (eventType == QEvent::DragEnter || eventType == QEvent::DragMove) {
QDropEvent* dropEv = static_cast<QDropEvent*>(e);
auto dropEv = static_cast<QDropEvent*>(e);
const QMimeData* mimeData = dropEv->mimeData();
if (mimeData->hasUrls()) {
dropEv->acceptProposedAction();
return true;
}
} else if (eventType == QEvent::Drop) {
QDropEvent* dropEv = static_cast<QDropEvent*>(e);
auto dropEv = static_cast<QDropEvent*>(e);
const QMimeData* mimeData = dropEv->mimeData();
if (mimeData->hasUrls()) {
dropEv->acceptProposedAction();

View File

@ -462,7 +462,7 @@ QMimeData* EntryModel::mimeData(const QModelIndexList& indexes) const
return nullptr;
}
QMimeData* data = new QMimeData();
auto data = new QMimeData();
QByteArray encoded;
QDataStream stream(&encoded, QIODevice::WriteOnly);

View File

@ -333,7 +333,7 @@ QMimeData* GroupModel::mimeData(const QModelIndexList& indexes) const
return nullptr;
}
QMimeData* data = new QMimeData();
auto data = new QMimeData();
QByteArray encoded;
QDataStream stream(&encoded, QIODevice::WriteOnly);

View File

@ -91,7 +91,7 @@ void ScreenLockListenerDBus::login1SessionObjectReceived(QDBusMessage response)
qDebug() << "org.freedesktop.login1.Manager.GetSession did not return a QDBusObjectPath";
return;
}
QDBusObjectPath path = arg0.value<QDBusObjectPath>();
auto path = arg0.value<QDBusObjectPath>();
QDBusConnection systemBus = QDBusConnection::systemBus();
systemBus.connect("", // service

View File

@ -37,12 +37,12 @@ QWidget* ReportsPageStatistics::createWidget()
void ReportsPageStatistics::loadSettings(QWidget* widget, QSharedPointer<Database> db)
{
ReportsWidgetStatistics* settingsWidget = reinterpret_cast<ReportsWidgetStatistics*>(widget);
auto settingsWidget = reinterpret_cast<ReportsWidgetStatistics*>(widget);
settingsWidget->loadSettings(db);
}
void ReportsPageStatistics::saveSettings(QWidget* widget)
{
ReportsWidgetStatistics* settingsWidget = reinterpret_cast<ReportsWidgetStatistics*>(widget);
auto settingsWidget = reinterpret_cast<ReportsWidgetStatistics*>(widget);
settingsWidget->saveSettings();
}

View File

@ -788,7 +788,7 @@ namespace Phantom
m.rightMarginForArrow = static_cast<int>(fontHeight * MenuItem_RightMarginForArrowFontRatio);
m.topMargin = static_cast<int>(fontHeight * MenuItem_VerticalMarginsFontRatio);
m.bottomMargin = static_cast<int>(fontHeight * MenuItem_VerticalMarginsFontRatio);
int checkVMargin = static_cast<int>(fontHeight * MenuItem_CheckMarkVerticalInsetFontRatio);
auto checkVMargin = static_cast<int>(fontHeight * MenuItem_CheckMarkVerticalInsetFontRatio);
int checkHeight = fontHeight - checkVMargin * 2;
if (checkHeight < 0)
checkHeight = 0;
@ -817,7 +817,7 @@ namespace Phantom
menuItemCheckRect(const MenuItemMetrics& metrics, Qt::LayoutDirection direction, QRect itemRect, bool hasArrow)
{
QRect r = menuItemContentRect(metrics, itemRect, hasArrow);
int checkVMargin = static_cast<int>(metrics.fontHeight * MenuItem_CheckMarkVerticalInsetFontRatio);
auto checkVMargin = static_cast<int>(metrics.fontHeight * MenuItem_CheckMarkVerticalInsetFontRatio);
if (checkVMargin < 0)
checkVMargin = 0;
r.setSize(QSize(metrics.checkWidth, metrics.fontHeight));
@ -1671,7 +1671,7 @@ void BaseStyle::drawPrimitive(PrimitiveElement elem,
if (arrow == Qt::DownArrow && !qstyleoption_cast<const QStyleOptionToolButton*>(option) && widget) {
auto tbutton = qobject_cast<const QToolButton*>(widget);
if (tbutton && tbutton->popupMode() != QToolButton::InstantPopup && tbutton->defaultAction()) {
int dim = static_cast<int>(qMin(rw, rh) * 0.25);
auto dim = static_cast<int>(qMin(rw, rh) * 0.25);
aw -= dim;
ah -= dim;
// We have another hack in PE_IndicatorButtonDropDown where we shift
@ -2472,7 +2472,7 @@ void BaseStyle::drawControl(ControlElement element,
QPixmap pixmap = header->icon.pixmap(window,
QSize(iconExtent, iconExtent),
(header->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled);
int pixw = static_cast<int>(pixmap.width() / pixmap.devicePixelRatio());
auto pixw = static_cast<int>(pixmap.width() / pixmap.devicePixelRatio());
QRect aligned = alignedRect(
header->direction, QFlag(header->iconAlignment), pixmap.size() / pixmap.devicePixelRatio(), rect);
QRect inter = aligned.intersected(rect);
@ -2745,8 +2745,8 @@ void BaseStyle::drawControl(ControlElement element,
}
QWindow* window = widget ? widget->windowHandle() : nullptr;
QPixmap pixmap = menuItem->icon.pixmap(window, iconSize, mode, state);
const int pixw = static_cast<int>(pixmap.width() / pixmap.devicePixelRatio());
const int pixh = static_cast<int>(pixmap.height() / pixmap.devicePixelRatio());
const auto pixw = static_cast<int>(pixmap.width() / pixmap.devicePixelRatio());
const auto pixh = static_cast<int>(pixmap.height() / pixmap.devicePixelRatio());
QRect pixmapRect = QStyle::alignedRect(option->direction, Qt::AlignCenter, QSize(pixw, pixh), iconRect);
painter->drawPixmap(pixmapRect.topLeft(), pixmap);
}
@ -2883,8 +2883,8 @@ void BaseStyle::drawControl(ControlElement element,
QIcon::State state = button->state & State_On ? QIcon::On : QIcon::Off;
auto window = widget ? widget->window()->windowHandle() : nullptr;
QPixmap pixmap = button->icon.pixmap(window, button->iconSize, mode, state);
int pixmapWidth = static_cast<int>(pixmap.width() / pixmap.devicePixelRatio());
int pixmapHeight = static_cast<int>(pixmap.height() / pixmap.devicePixelRatio());
auto pixmapWidth = static_cast<int>(pixmap.width() / pixmap.devicePixelRatio());
auto pixmapHeight = static_cast<int>(pixmap.height() / pixmap.devicePixelRatio());
int labelWidth = pixmapWidth;
int labelHeight = pixmapHeight;
// 4 is hardcoded in QPushButton::sizeHint()
@ -3276,7 +3276,7 @@ void BaseStyle::drawComplexControl(ComplexControl control,
{
// Fill title
QColor titlebarColor = QColor(active ? highlight : palette.background().color());
auto titlebarColor = QColor(active ? highlight : palette.background().color());
painter->fillRect(option->rect.adjusted(1, 1, -1, 0), titlebarColor);
// Frame and rounded corners
painter->setPen(titleBarFrameBorder);
@ -3983,8 +3983,8 @@ QSize BaseStyle::sizeFromContents(ContentsType type,
}
case CT_MenuBarItem: {
int fontHeight = option ? option->fontMetrics.height() : size.height();
int w = static_cast<int>(fontHeight * Ph::MenuBar_HorizontalPaddingFontRatio);
int h = static_cast<int>(fontHeight * Ph::MenuBar_VerticalPaddingFontRatio);
auto w = static_cast<int>(fontHeight * Ph::MenuBar_HorizontalPaddingFontRatio);
auto h = static_cast<int>(fontHeight * Ph::MenuBar_VerticalPaddingFontRatio);
int line = Ph::dpiScaled(1);
return QSize(size.width() + w * 2, size.height() + h * 2 + line);
}
@ -4176,7 +4176,8 @@ QSize BaseStyle::sizeFromContents(ContentsType type,
auto pbopt = qstyleoption_cast<const QStyleOptionButton*>(option);
if (!pbopt || pbopt->text.isEmpty())
break;
int hpad = static_cast<int>(pbopt->fontMetrics.height() * Phantom::PushButton_HorizontalPaddingFontHeightRatio);
auto hpad =
static_cast<int>(pbopt->fontMetrics.height() * Phantom::PushButton_HorizontalPaddingFontHeightRatio);
newSize.rwidth() += hpad * 2;
if (widget && qobject_cast<const QDialogButtonBox*>(widget->parent())) {
int dialogButtonMinWidth = Phantom::dpiScaled(80);

View File

@ -398,9 +398,9 @@ namespace Phantom
QColor qcolor_of_rgb(qreal r, qreal g, qreal b)
{
int r_ = static_cast<int>(std::lround(srgb_of_linear(r) * 255.0));
int g_ = static_cast<int>(std::lround(srgb_of_linear(g) * 255.0));
int b_ = static_cast<int>(std::lround(srgb_of_linear(b) * 255.0));
auto r_ = static_cast<int>(std::lround(srgb_of_linear(r) * 255.0));
auto g_ = static_cast<int>(std::lround(srgb_of_linear(g) * 255.0));
auto b_ = static_cast<int>(std::lround(srgb_of_linear(b) * 255.0));
return {r_, g_, b_};
}

View File

@ -126,7 +126,7 @@ bool HashedBlockStream::readHashedBlock()
{
bool ok;
quint32 index = Endian::readSizedInt<quint32>(m_baseDevice, ByteOrder, &ok);
auto index = Endian::readSizedInt<quint32>(m_baseDevice, ByteOrder, &ok);
if (!ok || index != m_blockIndex) {
m_error = true;
setErrorString("Invalid block index.");

View File

@ -37,7 +37,7 @@ void TestDeletedObjects::createAndDelete(QSharedPointer<Database> db, int delObj
Group* root = db->rootGroup();
int rootChildrenCount = root->children().size();
Group* g = new Group();
auto g = new Group();
g->setParent(root);
QUuid gUuid = QUuid::createUuid();
g->setUuid(gUuid);
@ -46,19 +46,19 @@ void TestDeletedObjects::createAndDelete(QSharedPointer<Database> db, int delObj
QCOMPARE(db->deletedObjects().at(delObjectsSize - 1).uuid, gUuid);
QCOMPARE(rootChildrenCount, root->children().size());
Group* g1 = new Group();
auto g1 = new Group();
g1->setParent(root);
QUuid g1Uuid = QUuid::createUuid();
g1->setUuid(g1Uuid);
Entry* e1 = new Entry();
auto e1 = new Entry();
e1->setGroup(g1);
QUuid e1Uuid = QUuid::createUuid();
e1->setUuid(e1Uuid);
Group* g2 = new Group();
auto g2 = new Group();
g2->setParent(g1);
QUuid g2Uuid = QUuid::createUuid();
g2->setUuid(g2Uuid);
Entry* e2 = new Entry();
auto e2 = new Entry();
e2->setGroup(g2);
QUuid e2Uuid = QUuid::createUuid();
e2->setUuid(e2Uuid);
@ -73,7 +73,7 @@ void TestDeletedObjects::createAndDelete(QSharedPointer<Database> db, int delObj
QCOMPARE(db->deletedObjects().at(delObjectsSize - 1).uuid, g1Uuid);
QCOMPARE(rootChildrenCount, root->children().size());
Entry* e3 = new Entry();
auto e3 = new Entry();
e3->setGroup(root);
QUuid e3Uuid = QUuid::createUuid();
e3->setUuid(e3Uuid);

View File

@ -591,7 +591,7 @@ void TestEntry::testResolveClonedEntry()
void TestEntry::testIsRecycled()
{
Entry* entry = new Entry();
auto entry = new Entry();
QVERIFY(!entry->isRecycled());
Database db;
@ -604,10 +604,10 @@ void TestEntry::testIsRecycled()
db.recycleEntry(entry);
QVERIFY(entry->isRecycled());
Group* group1 = new Group();
auto group1 = new Group();
group1->setParent(root);
Entry* entry1 = new Entry();
auto entry1 = new Entry();
entry1->setGroup(group1);
QVERIFY(!entry1->isRecycled());
db.recycleGroup(group1);
@ -620,16 +620,16 @@ void TestEntry::testMoveUpDown()
Group* root = db.rootGroup();
QVERIFY(root);
Entry* entry0 = new Entry();
auto entry0 = new Entry();
QVERIFY(entry0);
entry0->setGroup(root);
Entry* entry1 = new Entry();
auto entry1 = new Entry();
QVERIFY(entry1);
entry1->setGroup(root);
Entry* entry2 = new Entry();
auto entry2 = new Entry();
QVERIFY(entry2);
entry2->setGroup(root);
Entry* entry3 = new Entry();
auto entry3 = new Entry();
QVERIFY(entry3);
entry3->setGroup(root);
// default order, straight

View File

@ -42,23 +42,23 @@ void TestEntryModel::initTestCase()
void TestEntryModel::test()
{
Group* group1 = new Group();
Group* group2 = new Group();
auto group1 = new Group();
auto group2 = new Group();
Entry* entry1 = new Entry();
auto entry1 = new Entry();
entry1->setGroup(group1);
entry1->setTitle("testTitle1");
Entry* entry2 = new Entry();
auto entry2 = new Entry();
entry2->setGroup(group1);
entry2->setTitle("testTitle2");
EntryModel* model = new EntryModel(this);
auto model = new EntryModel(this);
QSignalSpy spyAboutToBeMoved(model, SIGNAL(rowsAboutToBeMoved(QModelIndex, int, int, QModelIndex, int)));
QSignalSpy spyMoved(model, SIGNAL(rowsMoved(QModelIndex, int, int, QModelIndex, int)));
ModelTest* modelTest = new ModelTest(model, this);
auto modelTest = new ModelTest(model, this);
model->setGroup(group1);
@ -79,7 +79,7 @@ void TestEntryModel::test()
QSignalSpy spyAboutToRemove(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)));
QSignalSpy spyRemoved(model, SIGNAL(rowsRemoved(QModelIndex, int, int)));
Entry* entry3 = new Entry();
auto entry3 = new Entry();
entry3->setGroup(group1);
QCOMPARE(spyAboutToBeMoved.count(), 0);
@ -130,10 +130,10 @@ void TestEntryModel::test()
void TestEntryModel::testAttachmentsModel()
{
EntryAttachments* entryAttachments = new EntryAttachments(this);
auto entryAttachments = new EntryAttachments(this);
EntryAttachmentsModel* model = new EntryAttachmentsModel(this);
ModelTest* modelTest = new ModelTest(model, this);
auto model = new EntryAttachmentsModel(this);
auto modelTest = new ModelTest(model, this);
QCOMPARE(model->rowCount(), 0);
model->setEntryAttachments(entryAttachments);
@ -175,10 +175,10 @@ void TestEntryModel::testAttachmentsModel()
void TestEntryModel::testAttributesModel()
{
EntryAttributes* entryAttributes = new EntryAttributes(this);
auto entryAttributes = new EntryAttributes(this);
EntryAttributesModel* model = new EntryAttributesModel(this);
ModelTest* modelTest = new ModelTest(model, this);
auto model = new EntryAttributesModel(this);
auto modelTest = new ModelTest(model, this);
QCOMPARE(model->rowCount(), 0);
model->setEntryAttributes(entryAttributes);
@ -227,8 +227,8 @@ void TestEntryModel::testAttributesModel()
void TestEntryModel::testDefaultIconModel()
{
DefaultIconModel* model = new DefaultIconModel(this);
ModelTest* modelTest = new ModelTest(model, this);
auto model = new DefaultIconModel(this);
auto modelTest = new ModelTest(model, this);
QCOMPARE(model->rowCount(), databaseIcons()->count());
@ -238,8 +238,8 @@ void TestEntryModel::testDefaultIconModel()
void TestEntryModel::testCustomIconModel()
{
CustomIconModel* model = new CustomIconModel(this);
ModelTest* modelTest = new ModelTest(model, this);
auto model = new CustomIconModel(this);
auto modelTest = new ModelTest(model, this);
QCOMPARE(model->rowCount(), 0);
@ -264,12 +264,12 @@ void TestEntryModel::testCustomIconModel()
void TestEntryModel::testAutoTypeAssociationsModel()
{
AutoTypeAssociationsModel* model = new AutoTypeAssociationsModel(this);
ModelTest* modelTest = new ModelTest(model, this);
auto model = new AutoTypeAssociationsModel(this);
auto modelTest = new ModelTest(model, this);
QCOMPARE(model->rowCount(), 0);
AutoTypeAssociations* associations = new AutoTypeAssociations(this);
auto associations = new AutoTypeAssociations(this);
model->setAutoTypeAssociations(associations);
QCOMPARE(model->rowCount(), 0);
@ -300,14 +300,14 @@ void TestEntryModel::testAutoTypeAssociationsModel()
void TestEntryModel::testProxyModel()
{
EntryModel* modelSource = new EntryModel(this);
SortFilterHideProxyModel* modelProxy = new SortFilterHideProxyModel(this);
auto modelSource = new EntryModel(this);
auto modelProxy = new SortFilterHideProxyModel(this);
modelProxy->setSourceModel(modelSource);
ModelTest* modelTest = new ModelTest(modelProxy, this);
auto modelTest = new ModelTest(modelProxy, this);
Database* db = new Database();
Entry* entry = new Entry();
auto db = new Database();
auto entry = new Entry();
entry->setTitle("Test Title");
entry->setGroup(db->rootGroup());
@ -358,18 +358,18 @@ void TestEntryModel::testProxyModel()
void TestEntryModel::testDatabaseDelete()
{
EntryModel* model = new EntryModel(this);
ModelTest* modelTest = new ModelTest(model, this);
auto model = new EntryModel(this);
auto modelTest = new ModelTest(model, this);
Database* db1 = new Database();
Group* group1 = new Group();
auto db1 = new Database();
auto group1 = new Group();
group1->setParent(db1->rootGroup());
Entry* entry1 = new Entry();
auto entry1 = new Entry();
entry1->setGroup(group1);
Database* db2 = new Database();
Entry* entry2 = new Entry();
auto db2 = new Database();
auto entry2 = new Entry();
entry2->setGroup(db2->rootGroup());
model->setEntries(QList<Entry*>() << entry1 << entry2);

View File

@ -44,21 +44,21 @@ void TestEntrySearcher::testSearch()
* - group211
* - group2111
*/
Group* group1 = new Group();
Group* group2 = new Group();
Group* group3 = new Group();
auto group1 = new Group();
auto group2 = new Group();
auto group3 = new Group();
group1->setParent(m_rootGroup);
group2->setParent(m_rootGroup);
group3->setParent(m_rootGroup);
Group* group11 = new Group();
auto group11 = new Group();
group11->setParent(group1);
Group* group21 = new Group();
Group* group211 = new Group();
Group* group2111 = new Group();
auto group21 = new Group();
auto group211 = new Group();
auto group2111 = new Group();
group21->setParent(group2);
group211->setParent(group21);
@ -66,39 +66,39 @@ void TestEntrySearcher::testSearch()
group1->setSearchingEnabled(Group::Disable);
Entry* eRoot = new Entry();
auto eRoot = new Entry();
eRoot->setTitle("test search term test");
eRoot->setGroup(m_rootGroup);
Entry* eRoot2 = new Entry();
auto eRoot2 = new Entry();
eRoot2->setNotes("test term test");
eRoot2->setGroup(m_rootGroup);
// Searching is disabled for these
Entry* e1 = new Entry();
auto e1 = new Entry();
e1->setUsername("test search term test");
e1->setGroup(group1);
Entry* e11 = new Entry();
auto e11 = new Entry();
e11->setNotes("test search term test");
e11->setGroup(group11);
// End searching disabled
Entry* e2111 = new Entry();
auto e2111 = new Entry();
e2111->setTitle("test search term test");
e2111->setGroup(group2111);
Entry* e2111b = new Entry();
auto e2111b = new Entry();
e2111b->setNotes("test search test");
e2111b->setUsername("user123");
e2111b->setPassword("testpass");
e2111b->setGroup(group2111);
Entry* e3 = new Entry();
auto e3 = new Entry();
e3->setUrl("test search term test");
e3->setGroup(group3);
Entry* e3b = new Entry();
auto e3b = new Entry();
e3b->setTitle("test search test 123");
e3b->setUsername("test@email.com");
e3b->setPassword("realpass");
@ -153,7 +153,7 @@ void TestEntrySearcher::testSearch()
void TestEntrySearcher::testAndConcatenationInSearch()
{
Entry* entry = new Entry();
auto entry = new Entry();
entry->setNotes("abc def ghi");
entry->setTitle("jkl");
entry->setGroup(m_rootGroup);
@ -179,7 +179,7 @@ void TestEntrySearcher::testAndConcatenationInSearch()
void TestEntrySearcher::testAllAttributesAreSearched()
{
Entry* entry = new Entry();
auto entry = new Entry();
entry->setGroup(m_rootGroup);
entry->setTitle("testTitle");
@ -276,35 +276,35 @@ void TestEntrySearcher::testGroup()
* - group2
* - subgroup2 (1 entry)
*/
Group* group1 = new Group();
Group* group2 = new Group();
auto group1 = new Group();
auto group2 = new Group();
group1->setParent(m_rootGroup);
group1->setName("group1");
group2->setParent(m_rootGroup);
group2->setName("group2");
Group* subgroup1 = new Group();
auto subgroup1 = new Group();
subgroup1->setName("subgroup1");
subgroup1->setParent(group1);
Group* subgroup2 = new Group();
auto subgroup2 = new Group();
subgroup2->setName("subgroup2");
subgroup2->setParent(group2);
Entry* eGroup1 = new Entry();
auto eGroup1 = new Entry();
eGroup1->setTitle("Entry Group 1");
eGroup1->setGroup(group1);
Entry* eSub1 = new Entry();
auto eSub1 = new Entry();
eSub1->setTitle("test search term test");
eSub1->setGroup(subgroup1);
Entry* eSub2 = new Entry();
auto eSub2 = new Entry();
eSub2->setNotes("test test");
eSub2->setGroup(subgroup1);
Entry* eSub3 = new Entry();
auto eSub3 = new Entry();
eSub3->setNotes("test term test");
eSub3->setGroup(subgroup2);

View File

@ -56,9 +56,9 @@ void TestGroup::cleanup()
void TestGroup::testParenting()
{
Database* db = new Database();
auto db = new Database();
QPointer<Group> rootGroup = db->rootGroup();
Group* tmpRoot = new Group();
auto tmpRoot = new Group();
QPointer<Group> g1 = new Group();
QPointer<Group> g2 = new Group();
@ -98,8 +98,8 @@ void TestGroup::testParenting()
QVERIFY(g1->children().at(1) == g3);
QVERIFY(g3->children().contains(g4));
Group* g5 = new Group();
Group* g6 = new Group();
auto g5 = new Group();
auto g6 = new Group();
g5->setParent(db->rootGroup());
g6->setParent(db->rootGroup());
QVERIFY(db->rootGroup()->children().at(1) == g5);
@ -129,8 +129,8 @@ void TestGroup::testParenting()
void TestGroup::testSignals()
{
Database* db = new Database();
Database* db2 = new Database();
auto db = new Database();
auto db2 = new Database();
QPointer<Group> root = db->rootGroup();
QSignalSpy spyAboutToAdd(db, SIGNAL(groupAboutToAdd(Group*, int)));
@ -147,8 +147,8 @@ void TestGroup::testSignals()
QSignalSpy spyAboutToMove2(db2, SIGNAL(groupAboutToMove(Group*, Group*, int)));
QSignalSpy spyMoved2(db2, SIGNAL(groupMoved()));
Group* g1 = new Group();
Group* g2 = new Group();
auto g1 = new Group();
auto g2 = new Group();
g1->setParent(root);
QCOMPARE(spyAboutToAdd.count(), 1);
@ -212,8 +212,8 @@ void TestGroup::testSignals()
QCOMPARE(spyAboutToMove2.count(), 0);
QCOMPARE(spyMoved2.count(), 0);
Group* g3 = new Group();
Group* g4 = new Group();
auto g3 = new Group();
auto g4 = new Group();
g3->setParent(root);
QCOMPARE(spyAboutToAdd.count(), 3);
@ -247,7 +247,7 @@ void TestGroup::testSignals()
void TestGroup::testEntries()
{
Group* group = new Group();
auto group = new Group();
QPointer<Entry> entry1 = new Entry();
entry1->setGroup(group);
@ -269,8 +269,8 @@ void TestGroup::testDeleteSignals()
{
QScopedPointer<Database> db(new Database());
Group* groupRoot = db->rootGroup();
Group* groupChild = new Group();
Group* groupChildChild = new Group();
auto groupChild = new Group();
auto groupChildChild = new Group();
groupRoot->setObjectName("groupRoot");
groupChild->setObjectName("groupChild");
groupChildChild->setObjectName("groupChildChild");
@ -284,8 +284,8 @@ void TestGroup::testDeleteSignals()
QCOMPARE(spyAboutToRemove.count(), 2);
QCOMPARE(spyRemoved.count(), 2);
Group* group = new Group();
Entry* entry = new Entry();
auto group = new Group();
auto entry = new Entry();
entry->setGroup(group);
QSignalSpy spyEntryAboutToRemove(group, SIGNAL(entryAboutToRemove(Entry*)));
QSignalSpy spyEntryRemoved(group, SIGNAL(entryRemoved(Entry*)));
@ -298,9 +298,9 @@ void TestGroup::testDeleteSignals()
QScopedPointer<Database> db2(new Database());
Group* groupRoot2 = db2->rootGroup();
Group* group2 = new Group();
auto group2 = new Group();
group2->setParent(groupRoot2);
Entry* entry2 = new Entry();
auto entry2 = new Entry();
entry2->setGroup(group2);
QSignalSpy spyEntryAboutToRemove2(group2, SIGNAL(entryAboutToRemove(Entry*)));
QSignalSpy spyEntryRemoved2(group2, SIGNAL(entryRemoved(Entry*)));
@ -476,15 +476,15 @@ void TestGroup::testFindEntry()
{
QScopedPointer<Database> db(new Database());
Entry* entry1 = new Entry();
auto entry1 = new Entry();
entry1->setTitle(QString("entry1"));
entry1->setGroup(db->rootGroup());
entry1->setUuid(QUuid::createUuid());
Group* group1 = new Group();
auto group1 = new Group();
group1->setName("group1");
Entry* entry2 = new Entry();
auto entry2 = new Entry();
entry2->setTitle(QString("entry2"));
entry2->setGroup(group1);
@ -558,11 +558,11 @@ void TestGroup::testFindGroupByPath()
{
QScopedPointer<Database> db(new Database());
Group* group1 = new Group();
auto group1 = new Group();
group1->setName("group1");
group1->setParent(db->rootGroup());
Group* group2 = new Group();
auto group2 = new Group();
group2->setName("group2");
group2->setParent(group1);
@ -626,7 +626,7 @@ void TestGroup::testPrint()
output = db->rootGroup()->print(true);
QCOMPARE(output, QString("[empty]\n"));
Entry* entry1 = new Entry();
auto entry1 = new Entry();
entry1->setTitle(QString("entry1"));
entry1->setGroup(db->rootGroup());
entry1->setUuid(QUuid::createUuid());
@ -634,24 +634,24 @@ void TestGroup::testPrint()
output = db->rootGroup()->print();
QCOMPARE(output, QString("entry1\n"));
Group* group1 = new Group();
auto group1 = new Group();
group1->setName("group1");
group1->setParent(db->rootGroup());
Entry* entry2 = new Entry();
auto entry2 = new Entry();
entry2->setTitle(QString("entry2"));
entry2->setGroup(group1);
entry2->setUuid(QUuid::createUuid());
Group* group2 = new Group();
auto group2 = new Group();
group2->setName("group2");
group2->setParent(db->rootGroup());
Group* subGroup = new Group();
auto subGroup = new Group();
subGroup->setName("subgroup");
subGroup->setParent(group2);
Entry* entry3 = new Entry();
auto entry3 = new Entry();
entry3->setTitle(QString("entry3"));
entry3->setGroup(subGroup);
entry3->setUuid(QUuid::createUuid());
@ -691,13 +691,13 @@ void TestGroup::testPrint()
void TestGroup::testAddEntryWithPath()
{
Database* db = new Database();
auto db = new Database();
Group* group1 = new Group();
auto group1 = new Group();
group1->setName("group1");
group1->setParent(db->rootGroup());
Group* group2 = new Group();
auto group2 = new Group();
group2->setName("group2");
group2->setParent(group1);
@ -742,19 +742,19 @@ void TestGroup::testIsRecycled()
Database db;
db.metadata()->setRecycleBinEnabled(true);
Group* group1 = new Group();
auto group1 = new Group();
group1->setName("group1");
group1->setParent(db.rootGroup());
Group* group2 = new Group();
auto group2 = new Group();
group2->setName("group2");
group2->setParent(db.rootGroup());
Group* group3 = new Group();
auto group3 = new Group();
group3->setName("group3");
group3->setParent(group2);
Group* group4 = new Group();
auto group4 = new Group();
group4->setName("group4");
group4->setParent(db.rootGroup());
@ -814,64 +814,64 @@ void TestGroup::testEquals()
void TestGroup::testChildrenSort()
{
auto createTestGroupWithUnorderedChildren = []() -> Group* {
Group* parent = new Group();
auto parent = new Group();
Group* group1 = new Group();
auto group1 = new Group();
group1->setName("B");
group1->setParent(parent);
Group* group2 = new Group();
auto group2 = new Group();
group2->setName("e");
group2->setParent(parent);
Group* group3 = new Group();
auto group3 = new Group();
group3->setName("Test999");
group3->setParent(parent);
Group* group4 = new Group();
auto group4 = new Group();
group4->setName("A");
group4->setParent(parent);
Group* group5 = new Group();
auto group5 = new Group();
group5->setName("z");
group5->setParent(parent);
Group* group6 = new Group();
auto group6 = new Group();
group6->setName("045");
group6->setParent(parent);
Group* group7 = new Group();
auto group7 = new Group();
group7->setName("60");
group7->setParent(parent);
Group* group8 = new Group();
auto group8 = new Group();
group8->setName("04test");
group8->setParent(parent);
Group* group9 = new Group();
auto group9 = new Group();
group9->setName("Test12");
group9->setParent(parent);
Group* group10 = new Group();
auto group10 = new Group();
group10->setName("i");
group10->setParent(parent);
Group* subGroup1 = new Group();
auto subGroup1 = new Group();
subGroup1->setName("sub_xte");
subGroup1->setParent(group10);
Group* subGroup2 = new Group();
auto subGroup2 = new Group();
subGroup2->setName("sub_010");
subGroup2->setParent(group10);
Group* subGroup3 = new Group();
auto subGroup3 = new Group();
subGroup3->setName("sub_000");
subGroup3->setParent(group10);
Group* subGroup4 = new Group();
auto subGroup4 = new Group();
subGroup4->setName("sub_M");
subGroup4->setParent(group10);
Group* subGroup5 = new Group();
auto subGroup5 = new Group();
subGroup5->setName("sub_p");
subGroup5->setParent(group10);
Group* subGroup6 = new Group();
auto subGroup6 = new Group();
subGroup6->setName("sub_45p");
subGroup6->setParent(group10);
Group* subGroup7 = new Group();
auto subGroup7 = new Group();
subGroup7->setName("sub_6p");
subGroup7->setParent(group10);
Group* subGroup8 = new Group();
auto subGroup8 = new Group();
subGroup8->setName("sub_tt");
subGroup8->setParent(group10);
Group* subGroup9 = new Group();
auto subGroup9 = new Group();
subGroup9->setName("sub_t0");
subGroup9->setParent(group10);
@ -996,11 +996,11 @@ void TestGroup::testHierarchy()
Group group1;
group1.setName("group1");
Group* group2 = new Group();
auto group2 = new Group();
group2->setName("group2");
group2->setParent(&group1);
Group* group3 = new Group();
auto group3 = new Group();
group3->setName("group3");
group3->setParent(group2);
@ -1028,12 +1028,12 @@ void TestGroup::testApplyGroupIconRecursively()
// Create a database with two nested groups with one entry each
Database database;
Group* subgroup = new Group();
auto subgroup = new Group();
subgroup->setName("Subgroup");
subgroup->setParent(database.rootGroup());
QVERIFY(subgroup);
Group* subsubgroup = new Group();
auto subsubgroup = new Group();
subsubgroup->setName("Subsubgroup");
subsubgroup->setParent(subgroup);
QVERIFY(subsubgroup);
@ -1125,7 +1125,7 @@ void TestGroup::testUsernamesRecursive()
Database database;
// Create a subgroup
Group* subgroup = new Group();
auto subgroup = new Group();
subgroup->setName("Subgroup");
subgroup->setParent(database.rootGroup());
@ -1152,16 +1152,16 @@ void TestGroup::testMoveUpDown()
Group* root = database.rootGroup();
QVERIFY(root);
Entry* entry0 = new Entry();
auto entry0 = new Entry();
QVERIFY(entry0);
entry0->setGroup(root);
Entry* entry1 = new Entry();
auto entry1 = new Entry();
QVERIFY(entry1);
entry1->setGroup(root);
Entry* entry2 = new Entry();
auto entry2 = new Entry();
QVERIFY(entry2);
entry2->setGroup(root);
Entry* entry3 = new Entry();
auto entry3 = new Entry();
QVERIFY(entry3);
entry3->setGroup(root);
// default order, straight

View File

@ -35,35 +35,35 @@ void TestGroupModel::initTestCase()
void TestGroupModel::test()
{
Database* db = new Database();
auto db = new Database();
Group* groupRoot = db->rootGroup();
groupRoot->setObjectName("groupRoot");
groupRoot->setName("groupRoot");
Group* group1 = new Group();
auto group1 = new Group();
group1->setObjectName("group1");
group1->setName("group1");
group1->setParent(groupRoot);
Group* group11 = new Group();
auto group11 = new Group();
group1->setObjectName("group11");
group11->setName("group11");
group11->setParent(group1);
Group* group12 = new Group();
auto group12 = new Group();
group1->setObjectName("group12");
group12->setName("group12");
group12->setParent(group1);
Group* group121 = new Group();
auto group121 = new Group();
group1->setObjectName("group121");
group121->setName("group121");
group121->setParent(group12);
GroupModel* model = new GroupModel(db, this);
auto model = new GroupModel(db, this);
ModelTest* modelTest = new ModelTest(model, this);
auto modelTest = new ModelTest(model, this);
QModelIndex indexRoot = model->index(0, 0);
QModelIndex index1 = model->index(0, 0, indexRoot);
@ -90,7 +90,7 @@ void TestGroupModel::test()
QSignalSpy spyAboutToMove(model, SIGNAL(rowsAboutToBeMoved(QModelIndex, int, int, QModelIndex, int)));
QSignalSpy spyMoved(model, SIGNAL(rowsMoved(QModelIndex, int, int, QModelIndex, int)));
Group* group2 = new Group();
auto group2 = new Group();
group2->setObjectName("group2");
group2->setName("group2");
group2->setParent(groupRoot);

View File

@ -89,22 +89,22 @@ void TestHibp::testPwned()
Group* root = m_db->rootGroup();
Entry* entry1 = new Entry();
auto entry1 = new Entry();
entry1->setPassword("foo");
entry1->setGroup(root);
Entry* entry2 = new Entry();
auto entry2 = new Entry();
entry2->setPassword("xyz");
entry2->setGroup(root);
Entry* entry3 = new Entry();
auto entry3 = new Entry();
entry3->setPassword("foo");
m_db->recycleEntry(entry3);
Group* group1 = new Group();
auto group1 = new Group();
group1->setParent(root);
Entry* entry4 = new Entry();
auto entry4 = new Entry();
entry4->setPassword("bar");
entry4->setGroup(group1);

View File

@ -310,7 +310,7 @@ void TestMerge::testResolveConflictTemplate(
timestamps["initialTime"] = m_clock->currentDateTimeUtc();
QScopedPointer<Database> dbDestination(createTestDatabase());
Entry* deletedEntry1 = new Entry();
auto deletedEntry1 = new Entry();
deletedEntry1->setUuid(QUuid::createUuid());
deletedEntry1->beginUpdate();
@ -318,7 +318,7 @@ void TestMerge::testResolveConflictTemplate(
deletedEntry1->setTitle("deletedDestination");
deletedEntry1->endUpdate();
Entry* deletedEntry2 = new Entry();
auto deletedEntry2 = new Entry();
deletedEntry2->setUuid(QUuid::createUuid());
deletedEntry2->beginUpdate();
@ -393,7 +393,7 @@ void TestMerge::testResolveConflictTemplate(
m_clock->advanceMinute(1);
Entry* destinationEntrySingle = new Entry();
auto destinationEntrySingle = new Entry();
destinationEntrySingle->setUuid(QUuid::createUuid());
destinationEntrySingle->beginUpdate();
@ -401,7 +401,7 @@ void TestMerge::testResolveConflictTemplate(
destinationEntrySingle->setTitle("entryDestination");
destinationEntrySingle->endUpdate();
Entry* sourceEntrySingle = new Entry();
auto sourceEntrySingle = new Entry();
sourceEntrySingle->setUuid(QUuid::createUuid());
sourceEntrySingle->beginUpdate();
@ -455,7 +455,7 @@ void TestMerge::testDeletionConflictTemplate(int mergeMode,
// entry indirectly deleted in target after updated in source
auto createGroup = [&](const char* name, Group* parent) {
Group* group = new Group();
auto group = new Group();
group->setUuid(QUuid::createUuid());
group->setName(name);
group->setParent(parent, 0);
@ -463,7 +463,7 @@ void TestMerge::testDeletionConflictTemplate(int mergeMode,
return group;
};
auto createEntry = [&](const char* title, Group* parent) {
Entry* entry = new Entry();
auto entry = new Entry();
entry->setUuid(QUuid::createUuid());
entry->setTitle(title);
entry->setGroup(parent);
@ -883,7 +883,7 @@ void TestMerge::testCreateNewGroups()
m_clock->advanceSecond(1);
Group* groupSourceCreated = new Group();
auto groupSourceCreated = new Group();
groupSourceCreated->setName("group3");
groupSourceCreated->setUuid(QUuid::createUuid());
groupSourceCreated->setParent(dbSource->rootGroup());
@ -906,7 +906,7 @@ void TestMerge::testMoveEntryIntoNewGroup()
m_clock->advanceSecond(1);
Group* groupSourceCreated = new Group();
auto groupSourceCreated = new Group();
groupSourceCreated->setName("group3");
groupSourceCreated->setUuid(QUuid::createUuid());
groupSourceCreated->setParent(dbSource->rootGroup());
@ -941,7 +941,7 @@ void TestMerge::testUpdateEntryDifferentLocation()
QScopedPointer<Database> dbSource(
createTestDatabaseStructureClone(dbDestination.data(), Entry::CloneNoFlags, Group::CloneIncludeEntries));
Group* groupDestinationCreated = new Group();
auto groupDestinationCreated = new Group();
groupDestinationCreated->setName("group3");
groupDestinationCreated->setUuid(QUuid::createUuid());
groupDestinationCreated->setParent(dbDestination->rootGroup());
@ -1028,7 +1028,7 @@ void TestMerge::testUpdateGroup()
void TestMerge::testUpdateGroupLocation()
{
QScopedPointer<Database> dbDestination(createTestDatabase());
Group* group3DestinationCreated = new Group();
auto group3DestinationCreated = new Group();
QUuid group3Uuid = QUuid::createUuid();
group3DestinationCreated->setUuid(group3Uuid);
group3DestinationCreated->setName("group3");
@ -1284,7 +1284,7 @@ void TestMerge::testDeletedGroup()
QPointer<Group> group2DestinationInitial = dbDestination->rootGroup()->findChildByName("group2");
QVERIFY(group2DestinationInitial != nullptr);
Entry* entry3DestinationCreated = new Entry();
auto entry3DestinationCreated = new Entry();
entry3DestinationCreated->beginUpdate();
entry3DestinationCreated->setUuid(QUuid::createUuid());
entry3DestinationCreated->setGroup(group2DestinationInitial);
@ -1507,19 +1507,19 @@ void TestMerge::testMergeModified()
Database* TestMerge::createTestDatabase()
{
Database* db = new Database();
auto db = new Database();
Group* group1 = new Group();
auto group1 = new Group();
group1->setName("group1");
group1->setUuid(QUuid::createUuid());
Group* group2 = new Group();
auto group2 = new Group();
group2->setName("group2");
group2->setUuid(QUuid::createUuid());
Entry* entry1 = new Entry();
auto entry1 = new Entry();
entry1->setUuid(QUuid::createUuid());
Entry* entry2 = new Entry();
auto entry2 = new Entry();
entry2->setUuid(QUuid::createUuid());
m_clock->advanceYear(1);
@ -1544,7 +1544,7 @@ Database* TestMerge::createTestDatabase()
Database* TestMerge::createTestDatabaseStructureClone(Database* source, int entryFlags, int groupFlags)
{
Database* db = new Database();
auto db = new Database();
// the old root group is deleted by QObject::parent relationship
db->setRootGroup(source->rootGroup()->clone(static_cast<Entry::CloneFlag>(entryFlags),
static_cast<Group::CloneFlag>(groupFlags)));