mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
import: initialize DiveSiteImportModel in constructor
The old code would construct and then initialize the object in a separate function, which added lots of complication. Just initialize the thing in the constructor, store a reference, not a pointer to the table. And do a few other code cleanups. The result is distinctly more pleasing. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
512eada468
commit
858a0aecba
3 changed files with 23 additions and 35 deletions
|
|
@ -11,13 +11,12 @@ class DivesiteImportedModel : public QAbstractTableModel
|
|||
public:
|
||||
enum columnNames { NAME, LOCATION, COUNTRY, NEAREST, DISTANCE, SELECTED };
|
||||
|
||||
DivesiteImportedModel(QObject *parent = 0);
|
||||
int columnCount(const QModelIndex& index = QModelIndex()) const;
|
||||
int rowCount(const QModelIndex& index = QModelIndex()) const;
|
||||
QVariant data(const QModelIndex& index, int role) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
void repopulate(dive_site_table *sites);
|
||||
DivesiteImportedModel(dive_site_table &, QObject *parent = 0);
|
||||
int columnCount(const QModelIndex& index = QModelIndex()) const override;
|
||||
int rowCount(const QModelIndex& index = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex& index, int role) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
public
|
||||
slots:
|
||||
void changeSelected(QModelIndex clickedIndex);
|
||||
|
|
@ -29,7 +28,7 @@ private:
|
|||
int firstIndex;
|
||||
int lastIndex;
|
||||
std::vector<char> checkStates; // char instead of bool to avoid silly pessimization of std::vector.
|
||||
dive_site_table *importedSitesTable;
|
||||
dive_site_table &importedSitesTable;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue