Commit 11bc34aa authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

const'ify + use Q_REQUIRED_RESULT

parent 3e5b0cbc
Pipeline #148083 passed with stage
in 2 minutes and 1 second
......@@ -58,7 +58,7 @@ public:
Term(const Term &lhs, Operation op, const Term &rhs);
~Term();
bool isValid() const;
Q_REQUIRED_RESULT bool isValid() const;
/**
* Negate this term. Negation only applies for Equal or Contains
......@@ -66,8 +66,8 @@ public:
*/
void setNegation(bool isNegated);
bool negated() const;
bool isNegated() const;
Q_REQUIRED_RESULT bool negated() const;
Q_REQUIRED_RESULT bool isNegated() const;
void addSubTerm(const Term &term);
void setSubTerms(const QList<Term> &terms);
......@@ -75,31 +75,31 @@ public:
/**
* Returns the first subTerm in the list of subTerms
*/
Term subTerm() const;
QList<Term> subTerms() const;
Q_REQUIRED_RESULT Term subTerm() const;
Q_REQUIRED_RESULT QList<Term> subTerms() const;
void setOperation(Operation op);
Operation operation() const;
Q_REQUIRED_RESULT Operation operation() const;
bool isEmpty() const;
bool empty() const;
Q_REQUIRED_RESULT bool isEmpty() const;
Q_REQUIRED_RESULT bool empty() const;
/**
* Return the property this term is targeting
*/
QString property() const;
Q_REQUIRED_RESULT QString property() const;
void setProperty(const QString &property);
QVariant value() const;
Q_REQUIRED_RESULT QVariant value() const;
void setValue(const QVariant &value);
Comparator comparator() const;
Q_REQUIRED_RESULT Comparator comparator() const;
void setComparator(Comparator c);
void setUserData(const QString &name, const QVariant &value);
QVariant userData(const QString &name) const;
Q_REQUIRED_RESULT QVariant userData(const QString &name) const;
QVariantMap toVariantMap() const;
Q_REQUIRED_RESULT QVariantMap toVariantMap() const;
static Term fromVariantMap(const QVariantMap &map);
bool operator==(const Term &rhs) const;
......
......@@ -18,7 +18,7 @@ AkonadiSearchDebugSearchPathComboBox::AkonadiSearchDebugSearchPathComboBox(QWidg
AkonadiSearchDebugSearchPathComboBox::~AkonadiSearchDebugSearchPathComboBox() = default;
QString AkonadiSearchDebugSearchPathComboBox::searchPath()
QString AkonadiSearchDebugSearchPathComboBox::searchPath() const
{
const int currentPathIndex = currentIndex();
if (currentPathIndex > -1) {
......@@ -38,7 +38,7 @@ void AkonadiSearchDebugSearchPathComboBox::initialize()
addItem(QStringLiteral("Calendars"), Calendars);
}
QString AkonadiSearchDebugSearchPathComboBox::pathFromEnum(SearchType type)
QString AkonadiSearchDebugSearchPathComboBox::pathFromEnum(SearchType type) const
{
switch (type) {
case Contacts:
......@@ -63,7 +63,7 @@ void AkonadiSearchDebugSearchPathComboBox::setSearchType(AkonadiSearchDebugSearc
}
}
QString AkonadiSearchDebugSearchPathComboBox::defaultLocations(const QString &dbName)
const QString AkonadiSearchDebugSearchPathComboBox::defaultLocations(const QString &dbName) const
{
// First look into the old location from Baloo times in ~/.local/share/baloo,
// because we don't migrate the database files automatically.
......
......@@ -24,13 +24,13 @@ public:
enum SearchType { Contacts = 0, ContactCompleter, Emails, Notes, Calendars };
~AkonadiSearchDebugSearchPathComboBox() override;
QString searchPath();
Q_REQUIRED_RESULT QString searchPath() const;
QString pathFromEnum(SearchType type);
Q_REQUIRED_RESULT QString pathFromEnum(SearchType type) const;
void setSearchType(SearchType type);
private:
QString defaultLocations(const QString &dbname);
const QString defaultLocations(const QString &dbname) const;
void initialize();
};
}
......
......@@ -19,6 +19,10 @@ using namespace Akonadi::Search;
AkonadiSearchDebugWidget::AkonadiSearchDebugWidget(QWidget *parent)
: QWidget(parent)
, mPlainTextEditor(new QPlainTextEdit(this))
, mSearchPathComboBox(new Akonadi::Search::AkonadiSearchDebugSearchPathComboBox(this))
, mLineEdit(new KLineEdit(this))
, mSearchButton(new QPushButton(QStringLiteral("Search"), this))
{
auto mainLayout = new QVBoxLayout(this);
......@@ -26,24 +30,20 @@ AkonadiSearchDebugWidget::AkonadiSearchDebugWidget(QWidget *parent)
mainLayout->addLayout(hbox);
auto lab = new QLabel(QStringLiteral("Item identifier:"), this);
hbox->addWidget(lab);
mLineEdit = new KLineEdit(this);
mLineEdit->setTrapReturnKey(true);
mLineEdit->setClearButtonEnabled(true);
mLineEdit->setObjectName(QStringLiteral("lineedit"));
connect(mLineEdit, &KLineEdit::textChanged, this, &AkonadiSearchDebugWidget::slotSearchLineTextChanged);
hbox->addWidget(mLineEdit);
mSearchPathComboBox = new Akonadi::Search::AkonadiSearchDebugSearchPathComboBox(this);
hbox->addWidget(mSearchPathComboBox);
mSearchPathComboBox->setObjectName(QStringLiteral("searchpathcombo"));
mSearchButton = new QPushButton(QStringLiteral("Search"), this);
mSearchButton->setObjectName(QStringLiteral("searchbutton"));
connect(mSearchButton, &QPushButton::clicked, this, &AkonadiSearchDebugWidget::slotSearch);
hbox->addWidget(mSearchButton);
mSearchButton->setEnabled(false);
mPlainTextEditor = new QPlainTextEdit(this);
new AkonadiSearchSyntaxHighlighter(mPlainTextEditor->document());
mPlainTextEditor->setReadOnly(true);
mainLayout->addWidget(mPlainTextEditor);
......
......@@ -31,7 +31,7 @@ public:
void setSearchType(AkonadiSearchDebugSearchPathComboBox::SearchType type);
void doSearch();
QString plainText() const;
Q_REQUIRED_RESULT QString plainText() const;
private Q_SLOTS:
void slotSearchLineTextChanged(const QString &text);
......@@ -41,9 +41,9 @@ private Q_SLOTS:
private:
QPlainTextEdit *mPlainTextEditor = nullptr;
AkonadiSearchDebugSearchPathComboBox *mSearchPathComboBox = nullptr;
KLineEdit *mLineEdit = nullptr;
QPushButton *mSearchButton = nullptr;
AkonadiSearchDebugSearchPathComboBox *const mSearchPathComboBox;
KLineEdit *const mLineEdit;
QPushButton *const mSearchButton;
};
}
}
......@@ -44,7 +44,7 @@ public:
void pathMatches(const QString &match);
void setLimit(int limit);
int limit() const;
Q_REQUIRED_RESULT int limit() const;
/**
* Execute the query and return an iterator to fetch
......
......@@ -45,7 +45,7 @@ public:
ResultIterator exec() override;
int limit() const;
Q_REQUIRED_RESULT int limit() const;
void setLimit(int limit);
private:
......
......@@ -88,7 +88,7 @@ public:
void bodyMatches(const QString &bodyMatch);
void setLimit(int limit);
int limit() const;
Q_REQUIRED_RESULT int limit() const;
/**
* Execute the query and return an iterator to fetch
......
......@@ -36,12 +36,12 @@ public:
void findIndexedInDatabase(QSet<Akonadi::Item::Id> &indexed, Akonadi::Collection::Id collectionId, const QString &dbPath);
void findIndexed(QSet<Akonadi::Item::Id> &indexed, Akonadi::Collection::Id collectionId);
QString emailIndexingPath() const;
QString collectionIndexingPath() const;
QString calendarIndexingPath() const;
QString akonotesIndexingPath() const;
QString emailContactsIndexingPath() const;
QString contactIndexingPath() const;
Q_REQUIRED_RESULT QString emailIndexingPath() const;
Q_REQUIRED_RESULT QString collectionIndexingPath() const;
Q_REQUIRED_RESULT QString calendarIndexingPath() const;
Q_REQUIRED_RESULT QString akonotesIndexingPath() const;
Q_REQUIRED_RESULT QString emailContactsIndexingPath() const;
Q_REQUIRED_RESULT QString contactIndexingPath() const;
private:
std::unique_ptr<IndexedItemsPrivate> const d;
......
......@@ -35,7 +35,7 @@ public:
void matchNote(const QString &note);
void setLimit(int limit);
int limit() const;
Q_REQUIRED_RESULT int limit() const;
ResultIterator exec() override;
......
......@@ -17,10 +17,10 @@ K_PLUGIN_FACTORY(PIMContactsRunnerConfigFactory, registerPlugin<PIMContactsRunne
PIMContactsRunnerConfig::PIMContactsRunnerConfig(QWidget *parent, const QVariantList &args)
: KCModule(parent, args)
, mQueryCompletionCheckBox(new QCheckBox(i18n("Search in contacts indexed from sent and received emails too"), this))
{
auto vbox = new QVBoxLayout(this);
mQueryCompletionCheckBox = new QCheckBox(i18n("Search in contacts indexed from sent and received emails too"), this);
connect(mQueryCompletionCheckBox, &QCheckBox::stateChanged, this, &PIMContactsRunnerConfig::configChanged);
vbox->addWidget(mQueryCompletionCheckBox);
......
......@@ -24,6 +24,6 @@ public Q_SLOTS:
private:
void configChanged();
QCheckBox *mQueryCompletionCheckBox = nullptr;
QCheckBox *const mQueryCompletionCheckBox;
};
......@@ -24,7 +24,7 @@ class CalendarSearchStore : public PIMSearchStore
public:
explicit CalendarSearchStore(QObject *parent = nullptr);
QStringList types() override;
Q_REQUIRED_RESULT QStringList types() override;
};
}
}
......@@ -24,7 +24,7 @@ class ContactSearchStore : public PIMSearchStore
public:
explicit ContactSearchStore(QObject *parent = nullptr);
QStringList types() override;
Q_REQUIRED_RESULT QStringList types() override;
};
}
}
......@@ -24,9 +24,9 @@ class EmailSearchStore : public PIMSearchStore
public:
explicit EmailSearchStore(QObject *parent = nullptr);
QStringList types() override;
Q_REQUIRED_RESULT QStringList types() override;
QString text(int queryId) override;
QString icon(int) override
Q_REQUIRED_RESULT QString icon(int) override
{
return QStringLiteral("internet-mail");
}
......
......@@ -24,7 +24,7 @@ class NoteSearchStore : public PIMSearchStore
public:
explicit NoteSearchStore(QObject *parent = nullptr);
QStringList types() override;
Q_REQUIRED_RESULT QStringList types() override;
};
}
}
......@@ -61,7 +61,7 @@ public:
* Returns true if the XapianDatabase has changes which need to
* be committed
*/
bool haveChanges() const;
Q_REQUIRED_RESULT bool haveChanges() const;
private:
Xapian::Database *m_db = nullptr;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment