Several fixes of warnings/clang tidy
This commit is contained in:
parent
2f527a8380
commit
880903db5f
15 changed files with 58 additions and 67 deletions
|
|
@ -269,7 +269,8 @@ bool SqlLexer::parseDollarQuote(int startpos, int &length, BasicTokenType &token
|
|||
out = sr.toString();
|
||||
return true;
|
||||
}
|
||||
else if (c.isLetter()) {
|
||||
|
||||
if (c.isLetter()) {
|
||||
// is this a dollar quote?
|
||||
while (true) {
|
||||
c = nextChar();
|
||||
|
|
@ -281,7 +282,8 @@ bool SqlLexer::parseDollarQuote(int startpos, int &length, BasicTokenType &token
|
|||
out = sr.toString();
|
||||
return true;
|
||||
}
|
||||
else if (!c.isLetter()) {
|
||||
|
||||
if (!c.isLetter()) {
|
||||
// ERROR, unallowed character
|
||||
tokentype = BasicTokenType::None;
|
||||
length = m_pos - startpos;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
using namespace SqlAst;
|
||||
|
||||
Keyword isKeyword(QString symbol)
|
||||
Keyword isKeyword(const QString &symbol)
|
||||
{
|
||||
static std::unordered_map<std::string, Keyword> lookup_map = {
|
||||
{ "as", Keyword::As },
|
||||
|
|
@ -22,8 +22,8 @@ Keyword isKeyword(QString symbol)
|
|||
auto res = lookup_map.find(symbol.toLower().toUtf8().data());
|
||||
if (res != lookup_map.end())
|
||||
return res->second;
|
||||
else
|
||||
return Keyword::NotAKeyword;
|
||||
|
||||
return Keyword::NotAKeyword;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ void SqlParser::parse()
|
|||
// IF NOT try_reduce(token)
|
||||
// THEN SHIFT
|
||||
// END LOOP
|
||||
while (1) {
|
||||
while (true) {
|
||||
SqlToken token = lexer.nextBasicToken();
|
||||
if (token.ok) {
|
||||
if (token.tokenType == BasicTokenType::Symbol) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "WorkManager.h"
|
||||
|
||||
#include <QRunnable.h>
|
||||
#include <QThreadPool.h>
|
||||
#include <QRunnable>
|
||||
#include <QThreadPool>
|
||||
#include <deque>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
|
|
@ -9,8 +9,8 @@
|
|||
|
||||
class WorkManagerImpl: public WorkManager {
|
||||
public:
|
||||
virtual void addRunnable(QRunnable *runnable) override;
|
||||
virtual void addWork(Work work) override;
|
||||
void addRunnable(QRunnable *runnable) override;
|
||||
void addWork(Work work) override;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ public:
|
|||
: work(std::move(w))
|
||||
{}
|
||||
protected:
|
||||
void run()
|
||||
void run() final
|
||||
{
|
||||
work();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ public:
|
|||
static std::shared_ptr<WorkManager> getWorkManager();
|
||||
|
||||
using Work = std::function<void()>;
|
||||
|
||||
virtual ~WorkManager() = default;
|
||||
virtual void addRunnable(QRunnable *runnable) = 0;
|
||||
virtual void addWork(Work work) = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ ASyncWindow::ASyncWindow(QWidget *parent)
|
|||
|
||||
void ASyncWindow::QueueTask(TSQueue::t_Callable c)
|
||||
{
|
||||
m_taskQueue.add(c);
|
||||
m_taskQueue.add(std::move(c));
|
||||
// Theoretically this needs to be only called if the queue was empty because otherwise it already would
|
||||
// be busy emptying the queue. For now however I think it is safer to call it just to make sure.
|
||||
QMetaObject::invokeMethod(this, "processCallableQueue", Qt::QueuedConnection); // queues on main thread
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ void CodeEditor::updateExtraSelections()
|
|||
{
|
||||
QList<QTextEdit::ExtraSelection> extraSelections;
|
||||
extraSelections.append(currentLine);
|
||||
for (auto e : errorMarkers)
|
||||
for (auto&& e : errorMarkers)
|
||||
extraSelections.append(e);
|
||||
|
||||
setExtraSelections(extraSelections);
|
||||
|
|
|
|||
|
|
@ -82,9 +82,7 @@ QString ConnectionList::iniFileName()
|
|||
}
|
||||
|
||||
|
||||
ConnectionList::ConnectionList()
|
||||
{
|
||||
}
|
||||
ConnectionList::ConnectionList() = default;
|
||||
|
||||
size_t ConnectionList::createNew()
|
||||
{
|
||||
|
|
@ -104,7 +102,7 @@ void ConnectionList::remove(size_t idx, size_t count)
|
|||
// remove from password save
|
||||
}
|
||||
|
||||
void ConnectionList::deleteFromIni(t_Connections::iterator begin, t_Connections::iterator end)
|
||||
void ConnectionList::deleteFromIni(const t_Connections::iterator &begin, const t_Connections::iterator &end)
|
||||
{
|
||||
QString file_name = iniFileName();
|
||||
QSettings settings(file_name, QSettings::IniFormat);
|
||||
|
|
@ -118,7 +116,7 @@ void ConnectionList::load()
|
|||
QString file_name = iniFileName();
|
||||
QSettings settings(file_name, QSettings::IniFormat);
|
||||
auto groups = settings.childGroups();
|
||||
for (auto grp : groups) {
|
||||
for (auto&& grp : groups) {
|
||||
if (grp == "c_IniGroupSecurity") {
|
||||
// Read security settings
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ private:
|
|||
using t_Connections = std::vector<ConnectionConfig>;
|
||||
t_Connections m_connections;
|
||||
|
||||
void deleteFromIni(t_Connections::iterator begin, t_Connections::iterator end);
|
||||
void deleteFromIni(const t_Connections::iterator &begin, const t_Connections::iterator &end);
|
||||
|
||||
static QString iniFileName();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,9 +12,7 @@ ConnectionListModel::ConnectionListModel(ConnectionList *conns, QObject *parent)
|
|||
{
|
||||
}
|
||||
|
||||
ConnectionListModel::~ConnectionListModel()
|
||||
{
|
||||
}
|
||||
ConnectionListModel::~ConnectionListModel() = default;
|
||||
|
||||
int ConnectionListModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
|
|
@ -145,9 +143,7 @@ Expected<ConnectionConfig> ConnectionListModel::get(size_t row)
|
|||
if (row < m_connections->size()) {
|
||||
return m_connections->getConfigByIdx(row);
|
||||
}
|
||||
else {
|
||||
return Expected<ConnectionConfig>::fromException(std::out_of_range("Invalid row"));
|
||||
}
|
||||
return Expected<ConnectionConfig>::fromException(std::out_of_range("Invalid row"));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ int EditColumnTableModel::columnCount(const QModelIndex &) const
|
|||
|
||||
QVariant EditColumnTableModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
size_t rij = static_cast<size_t>(index.row());
|
||||
auto rij = static_cast<size_t>(index.row());
|
||||
auto && d = m_data.at(rij);
|
||||
if (role == Qt::EditRole || role == Qt::DisplayRole) {
|
||||
switch (index.column()) {
|
||||
|
|
@ -90,7 +90,7 @@ Qt::ItemFlags EditColumnTableModel::flags(const QModelIndex &) const
|
|||
|
||||
bool EditColumnTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
size_t rij = static_cast<size_t>(index.row());
|
||||
auto rij = static_cast<size_t>(index.row());
|
||||
auto && d = m_data.at(rij);
|
||||
if (role == Qt::EditRole) {
|
||||
const int col = index.column();
|
||||
|
|
@ -98,39 +98,39 @@ bool EditColumnTableModel::setData(const QModelIndex &index, const QVariant &val
|
|||
d.name = value.toString();
|
||||
return true;
|
||||
}
|
||||
else if (col == TypeCol) {
|
||||
if (col == TypeCol) {
|
||||
d.type = value.toUInt();
|
||||
return true;
|
||||
}
|
||||
else if (col == LengthCol) {
|
||||
if (col == LengthCol) {
|
||||
d.length = value.toInt();
|
||||
return true;
|
||||
}
|
||||
else if (col == ScaleCol) {
|
||||
if (col == ScaleCol) {
|
||||
d.scale = value.toInt();
|
||||
return true;
|
||||
}
|
||||
else if (col == CollateCol) {
|
||||
if (col == CollateCol) {
|
||||
d.collate = value.toUInt();
|
||||
return true;
|
||||
}
|
||||
else if (col == NotNullCol) {
|
||||
if (col == NotNullCol) {
|
||||
d.notNull = value.toBool();
|
||||
return true;
|
||||
}
|
||||
else if (col == DefaultCol) {
|
||||
if (col == DefaultCol) {
|
||||
d.def = value.toString();
|
||||
return true;
|
||||
}
|
||||
else if (col == PrimaryKeyCol) {
|
||||
if (col == PrimaryKeyCol) {
|
||||
d.primaryKey = value.toInt();
|
||||
return true;
|
||||
}
|
||||
else if (col == UniqueCol) {
|
||||
if (col == UniqueCol) {
|
||||
d.notNull = value.toBool();
|
||||
return true;
|
||||
}
|
||||
else if (col == CommentCol) {
|
||||
if (col == CommentCol) {
|
||||
d.comment = value.toString();
|
||||
return true;
|
||||
}
|
||||
|
|
@ -138,7 +138,7 @@ bool EditColumnTableModel::setData(const QModelIndex &index, const QVariant &val
|
|||
return false;
|
||||
}
|
||||
|
||||
bool EditColumnTableModel::removeRows(int row, int count, const QModelIndex &parent)
|
||||
bool EditColumnTableModel::removeRows(int , int , const QModelIndex &)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ void IconColumnDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
|||
const QModelIndex &index) const
|
||||
{
|
||||
if (index.data().canConvert<QString>()) {
|
||||
QString icon_name = qvariant_cast<QString>(index.data());
|
||||
auto icon_name = qvariant_cast<QString>(index.data());
|
||||
|
||||
|
||||
QIcon* icon = IconColumnDelegate::getIcon(icon_name);
|
||||
|
|
@ -51,7 +51,7 @@ QIcon* IconColumnDelegate::getIcon(const QString &name) const
|
|||
auto fr = m_Icons.find(name);
|
||||
if (fr == m_Icons.end()) {
|
||||
// load and insert icon
|
||||
QIcon *icon = new QIcon(name);
|
||||
auto icon = new QIcon(name);
|
||||
fr = m_Icons.emplace(name, icon).first;
|
||||
}
|
||||
return fr->second;
|
||||
|
|
|
|||
|
|
@ -17,10 +17,7 @@ ModuleRegistry& Leon::GetModuleRegistry()
|
|||
return registry;
|
||||
}
|
||||
|
||||
Module::Module()
|
||||
{
|
||||
|
||||
}
|
||||
Module::Module() = default;
|
||||
|
||||
ModuleInstance::ModuleInstance()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ namespace NamespaceItemModel_impl {
|
|||
class Node {
|
||||
public:
|
||||
|
||||
virtual ~Node() {}
|
||||
virtual ~Node() = default;
|
||||
virtual int getRowCount() const = 0;
|
||||
virtual Qt::CheckState getCheckState() const = 0;
|
||||
virtual void setChecked(NamespaceItemModel *model, const QModelIndex &index, bool checked) = 0;
|
||||
|
|
@ -28,24 +28,24 @@ namespace NamespaceItemModel_impl {
|
|||
, ns(nspace)
|
||||
{}
|
||||
|
||||
virtual int getRowCount() const override
|
||||
int getRowCount() const override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual Qt::CheckState getCheckState() const override
|
||||
Qt::CheckState getCheckState() const override
|
||||
{
|
||||
return checked ? Qt::Checked : Qt::Unchecked;
|
||||
}
|
||||
|
||||
virtual void setChecked(NamespaceItemModel *model, const QModelIndex &index, bool chk) override
|
||||
void setChecked(NamespaceItemModel *model, const QModelIndex &index, bool chk) override
|
||||
{
|
||||
checked = chk;
|
||||
emit model->dataChanged(index, index);
|
||||
emit model->dataChanged(index.parent(), index.parent());
|
||||
}
|
||||
|
||||
virtual QVariant data(const QModelIndex &/*index*/, int role) const override
|
||||
QVariant data(const QModelIndex &/*index*/, int role) const override
|
||||
{
|
||||
QVariant v;
|
||||
if (role == Qt::DisplayRole) {
|
||||
|
|
@ -76,7 +76,7 @@ namespace NamespaceItemModel_impl {
|
|||
: name(n)
|
||||
{}
|
||||
|
||||
virtual int getRowCount() const override
|
||||
int getRowCount() const override
|
||||
{
|
||||
return leaves.size();
|
||||
}
|
||||
|
|
@ -87,11 +87,11 @@ namespace NamespaceItemModel_impl {
|
|||
[] (auto l, auto r) -> bool { return *l < *r; });
|
||||
}
|
||||
|
||||
virtual Qt::CheckState getCheckState() const override
|
||||
Qt::CheckState getCheckState() const override
|
||||
{
|
||||
bool some_checked = false;
|
||||
bool some_unchecked = false;
|
||||
for (auto l : leaves) {
|
||||
for (auto&& l : leaves) {
|
||||
if (l->checked)
|
||||
some_checked = true;
|
||||
else
|
||||
|
|
@ -108,19 +108,19 @@ namespace NamespaceItemModel_impl {
|
|||
return result;
|
||||
}
|
||||
|
||||
virtual void setChecked(NamespaceItemModel *model, const QModelIndex &index, bool chk) override
|
||||
void setChecked(NamespaceItemModel *model, const QModelIndex &index, bool chk) override
|
||||
{
|
||||
if (chk)
|
||||
for (auto l : leaves)
|
||||
for (auto&& l : leaves)
|
||||
l->checked = true;
|
||||
if (!chk)
|
||||
for (auto l : leaves)
|
||||
for (auto&& l : leaves)
|
||||
l->checked = false;
|
||||
emit model->dataChanged(index, index);
|
||||
emit model->dataChanged(model->index(0, 0, index), model->index(leaves.size(), 0, index));
|
||||
}
|
||||
|
||||
virtual QVariant data(const QModelIndex &/*index*/, int role) const override
|
||||
QVariant data(const QModelIndex &/*index*/, int role) const override
|
||||
{
|
||||
QVariant v;
|
||||
if (role == Qt::DisplayRole) {
|
||||
|
|
@ -152,7 +152,7 @@ void NamespaceItemModel::init(std::shared_ptr<const PgNamespaceContainer> ns)
|
|||
auto user = std::make_shared<GroupNode>("User");
|
||||
groups = { system, user };
|
||||
|
||||
for (const auto e : *ns)
|
||||
for (auto&& e : *ns)
|
||||
if (e.isSystemCatalog())
|
||||
system->leaves.push_back(std::make_shared<LeafNode>(system, e));
|
||||
else
|
||||
|
|
@ -160,7 +160,7 @@ void NamespaceItemModel::init(std::shared_ptr<const PgNamespaceContainer> ns)
|
|||
|
||||
system->sortLeaves();
|
||||
user->sortLeaves();
|
||||
for (auto e : user->leaves)
|
||||
for (auto&& e : user->leaves)
|
||||
e->checked = true;
|
||||
}
|
||||
|
||||
|
|
@ -188,8 +188,8 @@ QModelIndex NamespaceItemModel::parent(const QModelIndex &index) const
|
|||
{
|
||||
QModelIndex result;
|
||||
if (index.isValid()) {
|
||||
auto *n = static_cast<Node*>(index.internalPointer());
|
||||
LeafNode *ln = dynamic_cast<LeafNode*>(n);
|
||||
auto n = static_cast<Node*>(index.internalPointer());
|
||||
auto ln = dynamic_cast<LeafNode*>(n);
|
||||
if (ln) { // leafnode
|
||||
auto grp = ln->parent.lock(); // Get the parent group
|
||||
auto fr = std::find(groups.begin(), groups.end(), grp); // find it in the list
|
||||
|
|
|
|||
|
|
@ -22,9 +22,7 @@ OpenDatabase::OpenDatabase(const ConnectionConfig& cfg)
|
|||
{
|
||||
}
|
||||
|
||||
OpenDatabase::~OpenDatabase()
|
||||
{
|
||||
}
|
||||
OpenDatabase::~OpenDatabase() = default;
|
||||
|
||||
bool OpenDatabase::Init()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,11 +3,9 @@
|
|||
#include <QComboBox>
|
||||
#include "model/TypeSelectionItemModel.h"
|
||||
|
||||
ParamTypeDelegate::ParamTypeDelegate()
|
||||
{}
|
||||
ParamTypeDelegate::ParamTypeDelegate() = default;
|
||||
|
||||
ParamTypeDelegate::~ParamTypeDelegate()
|
||||
{}
|
||||
ParamTypeDelegate::~ParamTypeDelegate() = default;
|
||||
|
||||
void ParamTypeDelegate::setTypeSelectionModel(TypeSelectionItemModel* model)
|
||||
{
|
||||
|
|
@ -21,7 +19,7 @@ QWidget *ParamTypeDelegate::createEditor(QWidget *parent,
|
|||
{
|
||||
QWidget *w = nullptr;
|
||||
|
||||
QComboBox *cmbbx = new QComboBox(parent);
|
||||
auto cmbbx = new QComboBox(parent);
|
||||
cmbbx->setMaxVisibleItems(32);
|
||||
cmbbx->setModel(m_typeSelectionModel);
|
||||
w = cmbbx;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue