forked from blue/squawk
fix some bugs about disabled menus
This commit is contained in:
parent
645b92ba51
commit
7192286aeb
9 changed files with 56 additions and 24 deletions
|
@ -69,6 +69,23 @@ int Models::Accounts::rowCount ( const QModelIndex& parent ) const
|
|||
return accs.size();
|
||||
}
|
||||
|
||||
unsigned int Models::Accounts::size() const
|
||||
{
|
||||
return rowCount(QModelIndex());
|
||||
}
|
||||
|
||||
unsigned int Models::Accounts::activeSize() const
|
||||
{
|
||||
unsigned int size = 0;
|
||||
for (const Models::Account* acc : accs) {
|
||||
if (acc->getActive()) {
|
||||
++size;
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
QVariant Models::Accounts::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
|
||||
|
@ -97,6 +114,7 @@ void Models::Accounts::addAccount(Account* account)
|
|||
endInsertRows();
|
||||
|
||||
emit sizeChanged(accs.size());
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void Models::Accounts::onAccountChanged(Item* item, int row, int col)
|
||||
|
@ -157,12 +175,14 @@ void Models::Accounts::removeAccount(int index)
|
|||
emit sizeChanged(accs.size());
|
||||
}
|
||||
|
||||
std::deque<QString> Models::Accounts::getNames() const
|
||||
std::deque<QString> Models::Accounts::getActiveNames() const
|
||||
{
|
||||
std::deque<QString> res;
|
||||
|
||||
for (std::deque<Models::Account*>::const_iterator i = accs.begin(), end = accs.end(); i != end; ++i) {
|
||||
res.push_back((*i)->getName());
|
||||
for (const Models::Account* acc : accs) {
|
||||
if (acc->getActive()) {
|
||||
res.push_back(acc->getName());
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
|
|
|
@ -39,11 +39,13 @@ public:
|
|||
QVariant data ( const QModelIndex& index, int role ) const override;
|
||||
int columnCount ( const QModelIndex& parent ) const override;
|
||||
int rowCount ( const QModelIndex& parent ) const override;
|
||||
unsigned int size () const;
|
||||
unsigned int activeSize () const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||
|
||||
Account* getAccount(int index);
|
||||
|
||||
std::deque<QString> getNames() const;
|
||||
std::deque<QString> getActiveNames() const;
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue