Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Q
qtquickcontrols-nemo
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
NemoMobile
qtquickcontrols-nemo
Commits
847eb1fb
Commit
847eb1fb
authored
Oct 19, 2017
by
Chupligin Sergey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DatePicker] add datelistmodel proto
parent
4df4d8f1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
236 additions
and
2 deletions
+236
-2
controls.pro
src/controls/controls.pro
+4
-2
datelistmodel.cpp
src/controls/datelistmodel.cpp
+140
-0
datelistmodel.h
src/controls/datelistmodel.h
+90
-0
qquicknemocontrolsextensionplugin.cpp
src/controls/qquicknemocontrolsextensionplugin.cpp
+2
-0
No files found.
src/controls/controls.pro
View file @
847eb1fb
...
...
@@ -39,7 +39,8 @@ HEADERS += \
themedaemon
/
mlocalthemedaemonclient
.
h
\
themedaemon
/
mabstractthemedaemonclient
.
h
\
sizing
.
h
\
theme
.
h
theme
.
h
\
datelistmodel
.
h
SOURCES
+=
\
qquicknemocontrolsextensionplugin
.
cpp
\
...
...
@@ -51,7 +52,8 @@ SOURCES += \
themedaemon
/
mlocalthemedaemonclient
.
cpp
\
themedaemon
/
mabstractthemedaemonclient
.
cpp
\
sizing
.
cpp
\
theme
.
cpp
theme
.
cpp
\
datelistmodel
.
cpp
target
.
path
=
$$
[
QT_INSTALL_QML
]
/
$$
PLUGIN_IMPORT_PATH
...
...
src/controls/datelistmodel.cpp
0 → 100644
View file @
847eb1fb
/****************************************************************************************
**
** Copyright (C) 2017 Chupligin Sergey <neochapay@gmail.com>
** All rights reserved.
**
** You may use this file under the terms of BSD license as follows:
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** * Neither the name of the author nor the
** names of its contributors may be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR
** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
****************************************************************************************/
#include "datelistmodel.h"
DateListModel
::
DateListModel
(
QObject
*
parent
)
:
QAbstractListModel
(
parent
)
{
m_hash
.
insert
(
Qt
::
UserRole
,
QByteArray
(
"isOtherMonthDay"
));
m_hash
.
insert
(
Qt
::
UserRole
+
1
,
QByteArray
(
"isCurrentDay"
));
m_hash
.
insert
(
Qt
::
UserRole
+
2
,
QByteArray
(
"isSelectedDay"
));
m_hash
.
insert
(
Qt
::
UserRole
+
3
,
QByteArray
(
"hasEventDay"
));
m_hash
.
insert
(
Qt
::
UserRole
+
4
,
QByteArray
(
"dateOfDay"
));
m_currentDate
=
QDate
::
currentDate
();
m_year
=
m_currentDate
.
year
();
m_month
=
m_currentDate
.
month
();
fill
();
}
int
DateListModel
::
rowCount
(
const
QModelIndex
&
parent
)
const
{
Q_UNUSED
(
parent
);
return
m_dateList
.
count
();
}
QVariant
DateListModel
::
data
(
const
QModelIndex
&
index
,
int
role
)
const
{
Q_UNUSED
(
role
);
if
(
!
index
.
isValid
())
{
return
QVariant
();
}
if
(
index
.
row
()
>=
m_dateList
.
size
())
{
return
QVariant
();
}
dateItem
item
=
m_dateList
.
at
(
index
.
row
());
switch
(
role
)
{
case
Qt
:
:
UserRole
:
return
item
.
isOtherMonthDay
;
case
Qt
:
:
UserRole
+
1
:
return
item
.
isCurrentDay
;
case
Qt
:
:
UserRole
+
2
:
return
item
.
isSelectedDay
;
case
Qt
:
:
UserRole
+
3
:
return
item
.
hasEventDay
;
case
Qt
:
:
UserRole
+
4
:
return
item
.
dateOfDay
;
default:
return
QVariant
();
}
}
QVariant
DateListModel
::
get
(
const
int
idx
)
{
if
(
idx
>=
m_dateList
.
size
())
{
return
QVariant
();
}
QMap
<
QString
,
QVariant
>
itemData
;
dateItem
item
=
m_dateList
.
at
(
idx
);
itemData
.
insert
(
"isOtherMonthDay"
,
item
.
isOtherMonthDay
);
itemData
.
insert
(
"isCurrentDay"
,
item
.
isCurrentDay
);
itemData
.
insert
(
"isSelectedDay"
,
item
.
isSelectedDay
);
itemData
.
insert
(
"hasEventDay"
,
item
.
hasEventDay
);
itemData
.
insert
(
"dateOfDay"
,
item
.
dateOfDay
);
return
QVariant
(
itemData
);
}
void
DateListModel
::
setSelectedDate
(
QDate
date
)
{
if
(
m_selectedDate
!=
date
)
{
m_selectedDate
=
date
;
emit
selectedDateChanged
();
}
}
void
DateListModel
::
setMonth
(
int
month
)
{
if
(
m_month
!=
month
&&
month
>
0
&&
month
<
13
)
{
m_month
=
month
;
fill
();
emit
monthChanged
();
}
}
void
DateListModel
::
setYear
(
int
year
)
{
if
(
m_year
!=
year
)
{
m_year
=
year
;
fill
();
emit
yearChanged
();
}
}
void
DateListModel
::
fill
()
{
}
src/controls/datelistmodel.h
0 → 100644
View file @
847eb1fb
/****************************************************************************************
**
** Copyright (C) 2017 Chupligin Sergey <neochapay@gmail.com>
** All rights reserved.
**
** You may use this file under the terms of BSD license as follows:
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** * Neither the name of the author nor the
** names of its contributors may be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR
** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
****************************************************************************************/
#ifndef DATELISTMODEL_H
#define DATELISTMODEL_H
#include <QAbstractListModel>
#include <QDate>
class
DateListModel
:
public
QAbstractListModel
{
Q_OBJECT
struct
dateItem
{
bool
isOtherMonthDay
;
bool
isCurrentDay
;
bool
isSelectedDay
;
bool
hasEventDay
;
QDate
dateOfDay
;
};
Q_PROPERTY
(
QDate
currentDate
READ
currentDate
)
Q_PROPERTY
(
int
month
READ
month
WRITE
setMonth
NOTIFY
monthChanged
)
Q_PROPERTY
(
int
year
READ
year
WRITE
setYear
NOTIFY
yearChanged
)
Q_PROPERTY
(
QDate
selectedDate
READ
selectedDate
WRITE
setSelectedDate
NOTIFY
selectedDateChanged
)
public:
explicit
DateListModel
(
QObject
*
parent
=
0
);
int
rowCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
;
QVariant
data
(
const
QModelIndex
&
index
,
int
role
)
const
;
QHash
<
int
,
QByteArray
>
roleNames
()
const
{
return
m_hash
;}
void
setSelectedDate
(
QDate
date
);
void
setMonth
(
int
month
);
void
setYear
(
int
year
);
QDate
currentDate
(){
return
m_currentDate
;}
QDate
selectedDate
(){
return
m_selectedDate
;}
int
month
(){
return
m_month
;}
int
year
(){
return
m_year
;}
public
slots
:
QVariant
get
(
const
int
idx
);
signals:
void
selectedDateChanged
();
void
monthChanged
();
void
yearChanged
();
private:
QHash
<
int
,
QByteArray
>
m_hash
;
QList
<
dateItem
>
m_dateList
;
void
fill
();
QDate
m_currentDate
;
QDate
m_selectedDate
;
int
m_month
;
int
m_year
;
};
#endif // DATELISTMODEL_H
src/controls/qquicknemocontrolsextensionplugin.cpp
View file @
847eb1fb
...
...
@@ -27,6 +27,7 @@
#include "nemoimageprovider.h"
#include "sizing.h"
#include "theme.h"
#include "datelistmodel.h"
QQuickNemoControlsExtensionPlugin
::
QQuickNemoControlsExtensionPlugin
(
QObject
*
parent
)
:
QQmlExtensionPlugin
(
parent
)
...
...
@@ -46,6 +47,7 @@ void QQuickNemoControlsExtensionPlugin::registerTypes(const char *uri)
qmlRegisterType
<
NemoWindow
>
(
uri
,
1
,
0
,
"NemoWindow"
);
qmlRegisterType
<
NemoPage
>
(
uri
,
1
,
0
,
"NemoPage"
);
qmlRegisterType
<
QQuickFilteringMouseArea
>
(
uri
,
1
,
0
,
"FilteringMouseArea"
);
qmlRegisterType
<
DateListModel
>
(
uri
,
1
,
0
,
"NemoDateListModel"
);
}
void
QQuickNemoControlsExtensionPlugin
::
initializeEngine
(
QQmlEngine
*
engine
,
const
char
*
uri
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment