Qt wiki will be updated on October 12th 2023 starting at 11:30 AM (EEST) and the maintenance will last around 2-3 hours. During the maintenance the site will be unavailable.
Model View Tutorial Part1 CdRack/de
This article may require cleanup to meet the Qt Wiki's quality standards. Reason: Auto-imported from ExpressionEngine. Please improve this article if you can. Remove the {{cleanup}} tag and add this page to Updated pages list after it's clean. |
Table of Content
←Allgemeines: Klasse VirtualCdRack
↑Übersicht Model/View Tutorial:CD Verwaltung↑
Teil 1: Read Only Modell→
Die Klasse CdRack
Die Klasse CdRack stellt den Datenlayer der Applikation dar. Sie speichert die einzelnen CDs in einer Liste und auch die Genres. Mittels der üblichen File-Menüs können die Daten in einer XML-Datei gespeichert bzw. aus einer XML-Datei geladen werden.
Die Methode clear() löscht den gesamten Inhalt und löst das Signal reset aus.
Mittels addCD(…) können CDs hinzugefügt werden. Es wird das Signal inserted(int) ausgelöst.
Mittels changeDisk(int, const CdDisk&) können die Daten einer CD geändert werden.
- {
- Q_OBJECT
- public:
- // ----- construction --------------------------------------------------------------------------
- CdRack();
- // ----- methods -------------------------------------------------------------------------------
- void changeDisk(int nIndex, const CdDisk& newData);
- void addCD(const CdDisk& newData);
- void clear(void);
- // ----- accessors -----------------------------------------------------------------------------
- int size();
- const CdDisk& at(int i) const;
- bool isModified() const;
- void setModified(bool bModified);
- signals:
- void reset();
- void contentsChanged();
- void inserted(int nPosition);
- void inserted(int nFirst, int nLast);
- private:
- // ----- privat helpers ------------------------------------------------------------------------
- // ----- members -------------------------------------------------------------------------------
- bool m_bModified;
- QString m_errorString;
- QStringList m_genres;
- };
Die Klasse CdDisk
Die Klasse CdDisk beinhaltet die Daten einer CD.