1 /* 2 * barrier -- mouse and keyboard sharing utility 3 * Copyright (C) 2012-2016 Symless Ltd. 4 * Copyright (C) 2008 Volker Lanz (vl@fidra.de) 5 * 6 * This package is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * found in the file LICENSE that should have accompanied this file. 9 * 10 * This package is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #if !defined(SCREENSETUPMODEL__H) 20 21 #define SCREENSETUPMODEL__H 22 23 #include <QAbstractTableModel> 24 #include <QList> 25 #include <QString> 26 #include <QStringList> 27 28 #include "Screen.h" 29 30 class ScreenSetupView; 31 class ServerConfigDialog; 32 33 class ScreenSetupModel : public QAbstractTableModel 34 { 35 Q_OBJECT 36 37 friend class ScreenSetupView; 38 friend class ServerConfigDialog; 39 40 public: 41 ScreenSetupModel(ScreenList& screens, int numColumns, int numRows); 42 43 public: mimeType()44 static const QString& mimeType() { return m_MimeType; } 45 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; rowCount()46 int rowCount() const { return m_NumRows; } columnCount()47 int columnCount() const { return m_NumColumns; } rowCount(const QModelIndex &)48 int rowCount(const QModelIndex&) const { return rowCount(); } columnCount(const QModelIndex &)49 int columnCount(const QModelIndex&) const { return columnCount(); } 50 Qt::DropActions supportedDropActions() const; 51 Qt::ItemFlags flags(const QModelIndex& index) const; 52 QStringList mimeTypes() const; 53 QMimeData* mimeData(const QModelIndexList& indexes) const; 54 55 protected: 56 bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent); screen(const QModelIndex & index)57 const Screen& screen(const QModelIndex& index) const { return screen(index.column(), index.row()); } screen(const QModelIndex & index)58 Screen& screen(const QModelIndex& index) { return screen(index.column(), index.row()); } screen(int column,int row)59 const Screen& screen(int column, int row) const { return m_Screens[row * m_NumColumns + column]; } screen(int column,int row)60 Screen& screen(int column, int row) { return m_Screens[row * m_NumColumns + column]; } 61 62 private: 63 ScreenList& m_Screens; 64 const int m_NumColumns; 65 const int m_NumRows; 66 67 static const QString m_MimeType; 68 }; 69 70 #endif 71 72