| 17 | const QString ScreenSetupModel::m_MimeType = "application/x-deskflow-screen"; |
| 18 | |
| 19 | ScreenSetupModel::ScreenSetupModel(ScreenList &screens, int numColumns, int numRows) |
| 20 | : QAbstractTableModel(nullptr), |
| 21 | m_Screens(screens), |
| 22 | m_NumColumns(numColumns), |
| 23 | m_NumRows(numRows) |
| 24 | { |
| 25 | |
| 26 | // bound rows and columns to prevent multiply overflow. |
| 27 | // this is unlikely to happen, as the grid size is only 3x9. |
| 28 | if (m_NumColumns > 100 || m_NumRows > 100) { |
| 29 | qFatal("grid size out of bounds: %d columns x %d rows", m_NumColumns, m_NumRows); |
| 30 | return; |
| 31 | } |
| 32 | |
| 33 | const long span = static_cast<long>(m_NumColumns) * m_NumRows; |
| 34 | if (span > screens.size()) { |
| 35 | qFatal("scrren list (%lld) too small for %d columns x %d rows", screens.size(), m_NumColumns, m_NumRows); |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | QVariant ScreenSetupModel::data(const QModelIndex &index, int role) const |
| 40 | { |