1
0
forked from blue/squawk
squawk/ui/models/accounts.h

65 lines
1.8 KiB
C
Raw Permalink Normal View History

/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2019-03-30 20:13:13 +00:00
#ifndef MODELS_ACCOUNTS_H
#define MODELS_ACCOUNTS_H
#include <qabstractitemmodel.h>
#include <deque>
2019-04-03 18:15:36 +00:00
#include "account.h"
2019-03-30 20:13:13 +00:00
namespace Models
{
class Accounts : public QAbstractTableModel
{
Q_OBJECT
public:
Accounts(QObject* parent = 0);
~Accounts();
2019-04-03 18:15:36 +00:00
void addAccount(Account* account);
2019-05-29 15:05:54 +00:00
void removeAccount(int index);
2019-03-30 20:13:13 +00:00
QVariant data ( const QModelIndex& index, int role ) const override;
int columnCount ( const QModelIndex& parent ) const override;
int rowCount ( const QModelIndex& parent ) const override;
2022-06-03 06:44:48 +00:00
unsigned int size () const;
unsigned int activeSize () const;
2019-03-30 20:13:13 +00:00
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
2019-04-03 18:15:36 +00:00
Account* getAccount(int index);
2022-06-03 06:44:48 +00:00
std::deque<QString> getActiveNames() const;
2019-05-29 15:05:54 +00:00
signals:
void changed();
void sizeChanged(unsigned int size);
2019-05-29 15:05:54 +00:00
2019-03-30 20:13:13 +00:00
private:
2019-04-03 15:09:29 +00:00
std::deque<Account*> accs;
2019-03-30 20:13:13 +00:00
static std::deque<QString> columns;
2019-04-03 18:15:36 +00:00
private slots:
2019-04-09 15:04:08 +00:00
void onAccountChanged(Models::Item* item, int row, int col);
2019-04-03 18:15:36 +00:00
2019-03-30 20:13:13 +00:00
};
}
#endif // MODELS_ACCOUNT_H