Subversion Repositories OpenInventory

Rev

Rev 38 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

#ifndef TABLEFIELD_H
#define TABLEFIELD_H

#include <QObject>
#include <QtGui>
#include <QMainWindow>
#include <QString>
#include <QtSql>
#include <QSqlTableModel>
#include <QTableView>
#include <QSqlDriverPlugin>
#include <QIcon>
#include <QVariant>
#include <QProcess>
#include <QByteArray>

class TableField : public QObject
{
Q_OBJECT
public:

/***********************************************************************************************
 ** Êîíñòðóêòîð êëàññà TableField èìååò îäèí îáÿçàòåëüíûé ïàðàìåòð - èìÿ ïîëÿ
 ** îñòàëüíûå ïàðàìåòðû èìåþò çíà÷åíèÿ ïî óìîë÷àíèþ:
 ** *parent = 0 (íåò "ðîäèòåëüñêîãî" îáúåêòà)
 ** ftype = CHAR(30) (òèï õðàíèìûõ â ïîëå äàííûõ - ñòðîêà èç 30 ñèìâîëîâ)
 ** fdefaultValue = NULL (äàííûå â ïîëå ìîãóò èìåòü "ïóñòîå" çíà÷åíèå)
 ***********************************************************************************************/



   explicit   TableField(QString fname = "ID", QObject *parent = 0, QString ftype = "CHAR(30)", QString fdefaultValue = "NULL");

signals:

public slots:

private:
    QString fieldName;          // ïåðåìåííàÿ ñîäåðæèò èìÿ ïîëÿ
    QString fieldType;          // ïåðåìåííàÿ óêàçûâàåò íà òèï äàííûõ, õðàíèìûõ â ïîëå
    QString defaultValue;       // çíà÷åíèå ïîëÿ ïî óìîë÷àíèþ
    QString characterSet;       // ïåðåìåííàÿ ñîäåðæèò êîäèðîâêó, â êîòîðîé õðàíÿòüñÿ òåêñòîâûå äàííûå
    bool notNull;               // ôëàã, óêàçûâàþùèé, ÷òî õðàíèìîå â ïîëå çíà÷åíèå íå ìîæåò áûòü ïóñòûì (NULL)
    bool autoIncrement;         // ôëàã, óêàçûâàþùèé, ÷òî ïîëå ÿâëÿåòñÿ àâòîèíêåìåíòíûì
    QString SqlString;          // ñêòîêà Sql-çàïðîñà äëÿ ñîçäàíèÿ ïîëÿ â áàçå äàííûõ
    void createSqlString();     // ôóíêöèÿ ãåíåðèðóåò ñòðîêó Sql-çàïðîñà, êîòîðàÿ ñîçäàåò â áàçå äàííûõ ñîîòâåòñòâóþùåå ïîëå
protected:

public:
    void setName(QString name);
    void setType(QString ftype);
    void setAutoIncrement(bool autoInc); // óñòàíàâëèâàåì ôëàã, óêàçûâàþùèé, ÷òî ïîëå ÿâëÿåòñÿ àâòîèíêåìåíòíûì
    bool isAutoIncrement(); // óñòàíàâëèâàåì ôëàã, óêàçûâàþùèé, ÿâëÿåòñÿ ëè ïîëå àâòîèíêåìåíòíûì

    QString name();
    QString type();
    bool isNotNull();
    void setNotNull(bool fnotNull);
    void setDefaultValue(QString fdefaultValue);

    QString sqlString();        // ôóíêöèÿ âîçâðàùàåò ñòðîêó Sql-çàïðîñà, êîòîðàÿ ñîçäàåò â áàçå äàííûõ ñîîòâåòñòâóþùåå ïîëå
};

#endif // TABLEFIELD_H