Хранилища Subversion qb

Редакция

Содержимое файла | Последнее изменение | Открыть журнал | RSS

Редакция Автор № строки Строка
5 diffor 1
/*
2
 * Demo table model
3
 * Copyright (C) 2004-2008 by Gordos Kund / QnD Co Bt.
4
 *
5
 * This library is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU Lesser General Public
7
 * License as published by the Free Software Foundation; either
8
 * version 2.1 of the License, or (at your option) any later version.
9
 *
10
 * This library 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 GNU
13
 * Lesser General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Lesser General Public
16
 * License along with this library; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
 * Please contact gordos.kund@gmail.com with any questions on this license.
19
 */
20
 
21
#include <QtGui>
22
#include <QtCore/QDate>
23
#include <QtCore/QVariant>
24
#include "custommodel.h"
25
 
26
CustomModel::CustomModel(QObject *parent) : QAbstractTableModel(parent)
27
{
28
}
29
 
30
//======================================================================
31
 
32
QVariant CustomModel::data(const QModelIndex &index, int role) const
33
{
34
        if (role!=Qt::DisplayRole )
35
        {
36
                return QVariant();
37
        }
38
 
39
        QVariant value;
40
        QDate ret = QDate::currentDate();
41
        if (index.column() == 0) {
42
                ret=ret.addDays(index.row());
43
                value= ret.toString();
44
                return value;
45
        }
46
 
47
        if (index.column() == 1) {
48
                ret=ret.addDays(index.row());
49
                value= QDate::longMonthName(ret.month());
50
                return value;
51
        }
52
 
53
        if (index.column() == 2) {
54
                ret=ret.addDays(index.row());
55
                value= QDate::longDayName(ret.dayOfWeek());
56
                return value;
57
        }
58
        return value;
59
}
60
 
61
//======================================================================
62
 
63
int CustomModel::rowCount(const QModelIndex & /*parent*/) const
64
{
65
        return 200;
66
}
67
 
68
//======================================================================
69
 
70
int CustomModel::columnCount(const QModelIndex & /*parent*/) const
71
{
72
        return 3;
73
}