aboutsummaryrefslogtreecommitdiff
path: root/src/RWAHostModel.cpp
blob: 5f62adc28bf5b930a93d19af6427c54c7944e880 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "RWAHostModel.h"

RWAHostModel::RWAHostModel(QObject *parent) {
    Q_UNUSED(parent)
}

int RWAHostModel::rowCount(const QModelIndex& parent) const {
    Q_UNUSED(parent);
    return mDatas.size();
}

int RWAHostModel::columnCount(const QModelIndex& parent) const {
    Q_UNUSED(parent);
    return 1;
}

QVariant RWAHostModel::data(const QModelIndex &index, int role) const
 {
  if (!index.isValid())
      return QVariant();
  if ( role == Qt::DisplayRole) {
          return mDatas[index.row()];
  }
  return QVariant();
}

void RWAHostModel::populate() {
    beginResetModel();
    mDatas.clear();
    RWAHost *host1 = new RWAHost("uuid-1", "Erster Server", "url1");
    RWAHost *host2 = new RWAHost("uuid-2", "Zweiter Server", "url2");
    RWAHost *host3 = new RWAHost("uuid-3", "Dritter Server", "url3");
    mDatas.append(host1->alias());
    mDatas.append(host2->alias());
    mDatas.append(host3->alias());
    endResetModel();
}