added regex highlights

This commit is contained in:
fourtf
2018-05-06 12:52:47 +02:00
parent ba4173822e
commit b95388107f
24 changed files with 388 additions and 139 deletions
+30
View File
@@ -0,0 +1,30 @@
#include "account.hpp"
namespace chatterino {
namespace controllers {
namespace accounts {
Account::Account(const QString &category)
{
}
const QString &Account::getCategory() const
{
return this->category;
}
bool Account::operator<(const Account &other) const
{
if (this->category < other.category) {
return true;
} else if (this->category == other.category) {
if (this->toString() < other.toString()) {
return true;
}
}
return false;
}
} // namespace accounts
} // namespace controllers
} // namespace chatterino
+25
View File
@@ -0,0 +1,25 @@
#pragma once
#include <QString>
namespace chatterino {
namespace controllers {
namespace accounts {
class Account
{
public:
Account(const QString &category);
virtual QString toString() const = 0;
const QString &getCategory() const;
bool operator<(const Account &other) const;
private:
QString category;
};
} // namespace accounts
} // namespace controllers
} // namespace chatterino
@@ -0,0 +1,24 @@
#include "accountcontroller.hpp"
#include "controllers/accounts/accountmodel.hpp"
namespace chatterino {
namespace controllers {
namespace accounts {
AccountController::AccountController()
{
}
AccountModel *AccountController::createModel(QObject *parent)
{
AccountModel *model = new AccountModel(parent);
//(util::BaseSignalVector<stdAccount> *)
model->init(&this->accounts);
return model;
}
} // namespace accounts
} // namespace controllers
} // namespace chatterino
@@ -0,0 +1,29 @@
#pragma once
#include <QObject>
#include "controllers/accounts/account.hpp"
#include "util/sharedptrelementless.hpp"
#include "util/signalvector2.hpp"
namespace chatterino {
namespace controllers {
namespace accounts {
class AccountModel;
class AccountController
{
public:
AccountController();
AccountModel *createModel(QObject *parent);
private:
util::SortedSignalVector<std::shared_ptr<Account>, util::SharedPtrElementLess<Account>>
accounts;
};
} // namespace accounts
} // namespace controllers
} // namespace chatterino
+27
View File
@@ -0,0 +1,27 @@
#include "accountmodel.hpp"
namespace chatterino {
namespace controllers {
namespace accounts {
AccountModel::AccountModel(QObject *parent)
: util::SignalVectorModel<std::shared_ptr<Account>>(1, parent)
{
}
// turn a vector item into a model row
std::shared_ptr<Account> AccountModel::getItemFromRow(std::vector<QStandardItem *> &row)
{
return nullptr;
}
// turns a row in the model into a vector item
void AccountModel::getRowFromItem(const std::shared_ptr<Account> &item,
std::vector<QStandardItem *> &row)
{
row[0]->setData(item->toString(), Qt::DisplayRole);
}
} // namespace accounts
} // namespace controllers
} // namespace chatterino
+30
View File
@@ -0,0 +1,30 @@
#pragma
#include "controllers/accounts/account.hpp"
#include "util/signalvectormodel.hpp"
namespace chatterino {
namespace controllers {
namespace accounts {
class AccountController;
class AccountModel : public util::SignalVectorModel<std::shared_ptr<Account>>
{
public:
AccountModel(QObject *parent);
protected:
// turn a vector item into a model row
virtual std::shared_ptr<Account> getItemFromRow(std::vector<QStandardItem *> &row) override;
// turns a row in the model into a vector item
virtual void getRowFromItem(const std::shared_ptr<Account> &item,
std::vector<QStandardItem *> &row) override;
friend class AccountController;
};
} // namespace accounts
} // namespace controllers
} // namespace chatterino