Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
Buho
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
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
KDE
Buho
Commits
219cf0a6
Commit
219cf0a6
authored
Oct 02, 2018
by
Camilo higuita
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
link and note snow use custom models and can be sorted
parent
0a95bc2a
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
185 additions
and
261 deletions
+185
-261
main.cpp
main.cpp
+5
-0
main.qml
main.qml
+2
-9
src/db/dbactions.cpp
src/db/dbactions.cpp
+0
-78
src/db/dbactions.h
src/db/dbactions.h
+0
-5
src/models/links/links.cpp
src/models/links/links.cpp
+47
-48
src/models/links/links.h
src/models/links/links.h
+6
-9
src/models/links/linksmodel.cpp
src/models/links/linksmodel.cpp
+22
-22
src/models/links/linksmodel.h
src/models/links/linksmodel.h
+4
-9
src/views/links/LinksView.qml
src/views/links/LinksView.qml
+54
-24
src/views/links/Previewer.qml
src/views/links/Previewer.qml
+2
-1
src/views/notes/NotesView.qml
src/views/notes/NotesView.qml
+7
-13
src/widgets/CardDelegate.qml
src/widgets/CardDelegate.qml
+36
-21
src/widgets/CardsView.qml
src/widgets/CardsView.qml
+0
-22
No files found.
main.cpp
View file @
219cf0a6
...
...
@@ -25,6 +25,7 @@
#include "src/linker.h"
#include "models/notes/notesmodel.h"
#include "models/links/linksmodel.h"
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -62,10 +63,14 @@ int main(int argc, char *argv[])
context
->
setContextProperty
(
"linker"
,
&
linker
);
context
->
setContextProperty
(
"tag"
,
tag
);
qmlRegisterType
<
DocumentHandler
>
(
"org.buho.editor"
,
1
,
0
,
"DocumentHandler"
);
qmlRegisterUncreatableMetaObject
(
OWL
::
staticMetaObject
,
"Owl"
,
1
,
0
,
"KEY"
,
"Error"
);
qmlRegisterType
<
NotesModel
>
(
"Notes"
,
1
,
0
,
"NotesModel"
);
qmlRegisterType
<
LinksModel
>
(
"Links"
,
1
,
0
,
"LinksModel"
);
engine
.
load
(
QUrl
(
QStringLiteral
(
"qrc:/main.qml"
)));
if
(
engine
.
rootObjects
().
isEmpty
())
return
-
1
;
...
...
main.qml
View file @
219cf0a6
...
...
@@ -180,13 +180,6 @@ Maui.ApplicationWindow
}
Component.onCompleted
:
{
notesView
.
populate
()
linksView
.
populate
()
}
function
newNote
()
{
currentView
=
views
.
notes
...
...
@@ -209,8 +202,8 @@ Maui.ApplicationWindow
function
previewLink
(
link
)
{
var
tags
=
ow
l
.
getLinkTags
(
link
.
link
)
link
.
tags
=
tags
// var tags = linksView.mode
l.getLinkTags(link.link)
//
link.tags = tags
linksView
.
previewer
.
show
(
link
)
}
...
...
src/db/dbactions.cpp
View file @
219cf0a6
...
...
@@ -67,84 +67,6 @@ QVariantList DBActions::get(const QString &queryTxt)
return
mapList
;
}
bool
DBActions
::
insertLink
(
const
QVariantMap
&
link
)
{
auto
url
=
link
[
OWL
::
KEYMAP
[
OWL
::
KEY
::
LINK
]].
toString
();
auto
color
=
link
[
OWL
::
KEYMAP
[
OWL
::
KEY
::
COLOR
]].
toString
();
auto
pin
=
link
[
OWL
::
KEYMAP
[
OWL
::
KEY
::
PIN
]].
toInt
();
auto
fav
=
link
[
OWL
::
KEYMAP
[
OWL
::
KEY
::
FAV
]].
toInt
();
auto
tags
=
link
[
OWL
::
KEYMAP
[
OWL
::
KEY
::
TAG
]].
toStringList
();
auto
preview
=
link
[
OWL
::
KEYMAP
[
OWL
::
KEY
::
PREVIEW
]].
toString
();
auto
title
=
link
[
OWL
::
KEYMAP
[
OWL
::
KEY
::
TITLE
]].
toString
();
auto
image_path
=
OWL
::
saveImage
(
Linker
::
getUrl
(
preview
),
OWL
::
LinksPath
+
QUuid
::
createUuid
().
toString
());
QVariantMap
link_map
=
{
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
LINK
],
url
},
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
TITLE
],
title
},
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
PIN
],
pin
},
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
FAV
],
fav
},
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
PREVIEW
],
image_path
},
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
COLOR
],
color
},
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
ADD_DATE
],
QDateTime
::
currentDateTime
().
toString
()},
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
UPDATED
],
QDateTime
::
currentDateTime
().
toString
()}
};
if
(
this
->
db
->
insert
(
OWL
::
TABLEMAP
[
OWL
::
TABLE
::
LINKS
],
link_map
))
{
for
(
auto
tg
:
tags
)
this
->
tag
->
tagAbstract
(
tg
,
OWL
::
TABLEMAP
[
OWL
::
TABLE
::
LINKS
],
url
,
color
);
this
->
linkInserted
(
link_map
);
return
true
;
}
return
false
;
}
bool
DBActions
::
updateLink
(
const
QVariantMap
&
link
)
{
auto
url
=
link
[
OWL
::
KEYMAP
[
OWL
::
KEY
::
LINK
]].
toString
();
auto
color
=
link
[
OWL
::
KEYMAP
[
OWL
::
KEY
::
COLOR
]].
toString
();
auto
pin
=
link
[
OWL
::
KEYMAP
[
OWL
::
KEY
::
PIN
]].
toInt
();
auto
fav
=
link
[
OWL
::
KEYMAP
[
OWL
::
KEY
::
FAV
]].
toInt
();
auto
tags
=
link
[
OWL
::
KEYMAP
[
OWL
::
KEY
::
TAG
]].
toStringList
();
auto
updated
=
link
[
OWL
::
KEYMAP
[
OWL
::
KEY
::
UPDATED
]].
toString
();
QVariantMap
link_map
=
{
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
COLOR
],
color
},
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
PIN
],
pin
},
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
FAV
],
fav
},
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
UPDATED
],
updated
},
};
for
(
auto
tg
:
tags
)
this
->
tag
->
tagAbstract
(
tg
,
OWL
::
TABLEMAP
[
OWL
::
TABLE
::
LINKS
],
url
,
color
);
return
this
->
db
->
update
(
OWL
::
TABLEMAP
[
OWL
::
TABLE
::
LINKS
],
link_map
,
{{
OWL
::
KEYMAP
[
OWL
::
KEY
::
LINK
],
url
}}
);
}
bool
DBActions
::
removeLink
(
const
QVariantMap
&
link
)
{
return
this
->
db
->
remove
(
OWL
::
TABLEMAP
[
OWL
::
TABLE
::
LINKS
],
link
);
}
QVariantList
DBActions
::
getLinks
()
{
return
this
->
get
(
"select * from links ORDER BY updated ASC"
);
}
QVariantList
DBActions
::
getLinkTags
(
const
QString
&
link
)
{
return
this
->
tag
->
getAbstractTags
(
OWL
::
TABLEMAP
[
OWL
::
TABLE
::
LINKS
],
link
);
}
bool
DBActions
::
execQuery
(
const
QString
&
queryTxt
)
{
auto
query
=
this
->
db
->
getQuery
(
queryTxt
);
...
...
src/db/dbactions.h
View file @
219cf0a6
...
...
@@ -36,11 +36,6 @@ public:
Q_INVOKABLE
QVariantList
get
(
const
QString
&
queryTxt
);
/*main actions*/
Q_INVOKABLE
bool
insertLink
(
const
QVariantMap
&
link
);
Q_INVOKABLE
bool
updateLink
(
const
QVariantMap
&
link
);
Q_INVOKABLE
bool
removeLink
(
const
QVariantMap
&
link
);
Q_INVOKABLE
QVariantList
getLinks
();
Q_INVOKABLE
QVariantList
getLinkTags
(
const
QString
&
link
);
protected:
OWL
::
DB_LIST
getDBData
(
const
QString
&
queryTxt
);
...
...
src/models/links/links.cpp
View file @
219cf0a6
...
...
@@ -2,6 +2,7 @@
#include <QUuid>
#include "db/db.h"
#include "linker.h"
#ifdef STATIC_MAUIKIT
#include "tagging.h"
...
...
@@ -17,50 +18,50 @@ Links::Links(QObject *parent) : QObject(parent)
void
Links
::
sortBy
(
const
OWL
::
KEY
&
key
,
const
QString
&
order
)
{
this
->
notes
=
this
->
db
->
getDBData
(
QString
(
"select * from note
s ORDER BY %1 %2"
).
arg
(
OWL
::
KEYMAP
[
key
],
order
));
this
->
links
=
this
->
db
->
getDBData
(
QString
(
"select * from link
s ORDER BY %1 %2"
).
arg
(
OWL
::
KEYMAP
[
key
],
order
));
}
OWL
::
DB_LIST
Links
::
items
()
const
{
return
this
->
note
s
;
return
this
->
link
s
;
}
bool
Links
::
insert
Note
(
const
QVariantMap
&
note
)
bool
Links
::
insert
Link
(
const
QVariantMap
&
link
)
{
qDebug
()
<<
"TAGS"
<<
note
[
OWL
::
KEYMAP
[
OWL
::
KEY
::
TAG
]].
toStringList
();
auto
url
=
link
[
OWL
::
KEYMAP
[
OWL
::
KEY
::
LINK
]].
toString
();
auto
color
=
link
[
OWL
::
KEYMAP
[
OWL
::
KEY
::
COLOR
]].
toString
();
auto
pin
=
link
[
OWL
::
KEYMAP
[
OWL
::
KEY
::
PIN
]].
toInt
();
auto
fav
=
link
[
OWL
::
KEYMAP
[
OWL
::
KEY
::
FAV
]].
toInt
();
auto
tags
=
link
[
OWL
::
KEYMAP
[
OWL
::
KEY
::
TAG
]].
toStringList
();
auto
preview
=
link
[
OWL
::
KEYMAP
[
OWL
::
KEY
::
PREVIEW
]].
toString
();
auto
title
=
link
[
OWL
::
KEYMAP
[
OWL
::
KEY
::
TITLE
]].
toString
();
auto
title
=
note
[
OWL
::
KEYMAP
[
OWL
::
KEY
::
TITLE
]].
toString
();
auto
body
=
note
[
OWL
::
KEYMAP
[
OWL
::
KEY
::
BODY
]].
toString
();
auto
color
=
note
[
OWL
::
KEYMAP
[
OWL
::
KEY
::
COLOR
]].
toString
();
auto
pin
=
note
[
OWL
::
KEYMAP
[
OWL
::
KEY
::
PIN
]].
toInt
();
auto
fav
=
note
[
OWL
::
KEYMAP
[
OWL
::
KEY
::
FAV
]].
toInt
();
auto
tags
=
note
[
OWL
::
KEYMAP
[
OWL
::
KEY
::
TAG
]].
toStringList
();
auto
image_path
=
OWL
::
saveImage
(
Linker
::
getUrl
(
preview
),
OWL
::
LinksPath
+
QUuid
::
createUuid
().
toString
());
auto
id
=
QUuid
::
createUuid
().
toString
();
QVariantMap
note_map
=
QVariantMap
link_map
=
{
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
ID
],
id
},
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
LINK
],
url
},
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
TITLE
],
title
},
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
BODY
],
body
},
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
COLOR
],
color
},
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
PIN
],
pin
},
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
FAV
],
fav
},
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
UPDATED
],
QDateTime
::
currentDateTime
().
toString
()},
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
ADD_DATE
],
QDateTime
::
currentDateTime
().
toString
()}
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
PREVIEW
],
image_path
},
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
COLOR
],
color
},
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
ADD_DATE
],
QDateTime
::
currentDateTime
().
toString
()},
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
UPDATED
],
QDateTime
::
currentDateTime
().
toString
()}
};
if
(
this
->
db
->
insert
(
OWL
::
TABLEMAP
[
OWL
::
TABLE
::
NOTES
],
note
_map
))
if
(
this
->
db
->
insert
(
OWL
::
TABLEMAP
[
OWL
::
TABLE
::
LINKS
],
link
_map
))
{
for
(
auto
tg
:
tags
)
this
->
tag
->
tagAbstract
(
tg
,
OWL
::
TABLEMAP
[
OWL
::
TABLE
::
NOTES
],
id
,
color
);
this
->
tag
->
tagAbstract
(
tg
,
OWL
::
TABLEMAP
[
OWL
::
TABLE
::
LINKS
],
url
,
color
);
this
->
note
s
<<
OWL
::
DB
this
->
link
s
<<
OWL
::
DB
({
{
OWL
::
KEY
::
ID
,
id
},
{
OWL
::
KEY
::
LINK
,
url
},
{
OWL
::
KEY
::
TITLE
,
title
},
{
OWL
::
KEY
::
BODY
,
body
},
{
OWL
::
KEY
::
COLOR
,
color
},
{
OWL
::
KEY
::
PREVIEW
,
preview
},
{
OWL
::
KEY
::
PIN
,
QString
::
number
(
pin
)},
{
OWL
::
KEY
::
FAV
,
QString
::
number
(
fav
)},
{
OWL
::
KEY
::
UPDATED
,
QDateTime
::
currentDateTime
().
toString
()},
...
...
@@ -73,39 +74,37 @@ bool Links::insertNote(const QVariantMap ¬e)
return
false
;
}
bool
Links
::
update
Note
(
const
int
&
index
,
const
QVariant
&
value
,
const
int
&
role
)
bool
Links
::
update
Link
(
const
int
&
index
,
const
QVariant
&
value
,
const
int
&
role
)
{
if
(
index
<
0
||
index
>=
note
s
.
size
())
if
(
index
<
0
||
index
>=
link
s
.
size
())
return
false
;
const
auto
oldValue
=
this
->
note
s
[
index
][
static_cast
<
OWL
::
KEY
>
(
role
)];
const
auto
oldValue
=
this
->
link
s
[
index
][
static_cast
<
OWL
::
KEY
>
(
role
)];
if
(
oldValue
==
value
.
toString
())
return
false
;
this
->
notes
[
index
].
insert
(
static_cast
<
OWL
::
KEY
>
(
role
),
value
.
toString
());
qDebug
()
<<
"VALUE TO UPDATE"
<<
OWL
::
KEYMAP
[
static_cast
<
OWL
::
KEY
>
(
role
)]
<<
oldValue
;
this
->
links
[
index
].
insert
(
static_cast
<
OWL
::
KEY
>
(
role
),
value
.
toString
());
this
->
update
Note
(
this
->
note
s
[
index
]);
this
->
update
Link
(
this
->
link
s
[
index
]);
return
true
;
}
bool
Links
::
update
Note
(
const
OWL
::
DB
&
note
)
bool
Links
::
update
Link
(
const
OWL
::
DB
&
link
)
{
auto
id
=
note
[
OWL
::
KEY
::
ID
];
auto
title
=
note
[
OWL
::
KEY
::
TITLE
];
auto
body
=
note
[
OWL
::
KEY
::
BODY
];
auto
color
=
note
[
OWL
::
KEY
::
COLOR
];
auto
pin
=
note
[
OWL
::
KEY
::
PIN
].
toInt
();
auto
fav
=
note
[
OWL
::
KEY
::
FAV
].
toInt
();
auto
tags
=
note
[
OWL
::
KEY
::
TAG
].
split
(
","
,
QString
::
SkipEmptyParts
);
auto
updated
=
note
[
OWL
::
KEY
::
UPDATED
];
QVariantMap
note_map
=
auto
url
=
link
[
OWL
::
KEY
::
LINK
];
auto
color
=
link
[
OWL
::
KEY
::
COLOR
];
auto
pin
=
link
[
OWL
::
KEY
::
PIN
].
toInt
();
auto
fav
=
link
[
OWL
::
KEY
::
FAV
].
toInt
();
auto
tags
=
link
[
OWL
::
KEY
::
TAG
].
split
(
","
,
QString
::
SkipEmptyParts
);
auto
updated
=
link
[
OWL
::
KEY
::
UPDATED
];
QVariantMap
link_map
=
{
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
TITLE
],
title
},
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
BODY
],
body
},
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
COLOR
],
color
},
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
PIN
],
pin
},
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
FAV
],
fav
},
...
...
@@ -113,18 +112,18 @@ bool Links::updateNote(const OWL::DB ¬e)
};
for
(
auto
tg
:
tags
)
this
->
tag
->
tagAbstract
(
tg
,
OWL
::
TABLEMAP
[
OWL
::
TABLE
::
NOTES
],
id
,
color
);
this
->
tag
->
tagAbstract
(
tg
,
OWL
::
TABLEMAP
[
OWL
::
TABLE
::
LINKS
],
url
,
color
);
return
this
->
db
->
update
(
OWL
::
TABLEMAP
[
OWL
::
TABLE
::
NOTES
],
note_map
,
{{
OWL
::
KEYMAP
[
OWL
::
KEY
::
ID
],
id
}}
);
return
this
->
db
->
update
(
OWL
::
TABLEMAP
[
OWL
::
TABLE
::
LINKS
],
link_map
,
{{
OWL
::
KEYMAP
[
OWL
::
KEY
::
LINK
],
url
}}
);
}
bool
Links
::
remove
Note
(
const
QVariantMap
&
note
)
bool
Links
::
remove
Link
(
const
QVariantMap
&
link
)
{
qDebug
()
<<
note
;
return
this
->
db
->
remove
(
OWL
::
TABLEMAP
[
OWL
::
TABLE
::
NOTES
],
note
);
qDebug
()
<<
link
;
return
this
->
db
->
remove
(
OWL
::
TABLEMAP
[
OWL
::
TABLE
::
LINKS
],
link
);
}
QVariantList
Links
::
get
NoteTags
(
const
QString
&
id
)
QVariantList
Links
::
get
LinkTags
(
const
QString
&
link
)
{
return
this
->
tag
->
getAbstractTags
(
OWL
::
TABLEMAP
[
OWL
::
TABLE
::
NOTES
],
id
);
return
this
->
tag
->
getAbstractTags
(
OWL
::
TABLEMAP
[
OWL
::
TABLE
::
LINKS
],
link
);
}
src/models/links/links.h
View file @
219cf0a6
...
...
@@ -18,19 +18,16 @@ public:
void
sortBy
(
const
OWL
::
KEY
&
key
,
const
QString
&
order
=
"DESC"
);
Q_INVOKABLE
bool
insertLink
(
const
QVariantMap
&
link
);
bool
updateLink
(
const
int
&
index
,
const
QVariant
&
value
,
const
int
&
role
);
bool
updateLink
(
const
OWL
::
DB
&
link
);
Q_INVOKABLE
bool
removeLink
(
const
QVariantMap
&
link
);
bool
insertNote
(
const
QVariantMap
&
note
);
bool
updateNote
(
const
int
&
index
,
const
QVariant
&
value
,
const
int
&
role
);
bool
updateNote
(
const
OWL
::
DB
&
note
);
bool
removeNote
(
const
QVariantMap
&
note
);
QVariantList
getNoteTags
(
const
QString
&
id
);
Q_INVOKABLE
QVariantList
getLinkTags
(
const
QString
&
link
);
private:
Tagging
*
tag
;
DB
*
db
;
OWL
::
DB_LIST
note
s
;
OWL
::
DB_LIST
link
s
;
signals:
...
...
src/models/links/linksmodel.cpp
View file @
219cf0a6
...
...
@@ -4,29 +4,29 @@
LinksModel
::
LinksModel
(
QObject
*
parent
)
:
QAbstractListModel
(
parent
)
{
this
->
m
Note
s
=
new
Links
(
this
);
this
->
m
Link
s
=
new
Links
(
this
);
}
int
LinksModel
::
rowCount
(
const
QModelIndex
&
parent
)
const
{
if
(
parent
.
isValid
()
||
!
m
Note
s
)
if
(
parent
.
isValid
()
||
!
m
Link
s
)
return
0
;
return
m
Note
s
->
items
().
size
();
return
m
Link
s
->
items
().
size
();
}
QVariant
LinksModel
::
data
(
const
QModelIndex
&
index
,
int
role
)
const
{
if
(
!
index
.
isValid
()
||
!
m
Note
s
)
if
(
!
index
.
isValid
()
||
!
m
Link
s
)
return
QVariant
();
return
m
Note
s
->
items
().
at
(
index
.
row
())[
static_cast
<
OWL
::
KEY
>
(
role
)];
return
m
Link
s
->
items
().
at
(
index
.
row
())[
static_cast
<
OWL
::
KEY
>
(
role
)];
}
QVariantMap
LinksModel
::
get
(
const
int
&
index
)
{
QVariantMap
res
;
const
auto
note
=
m
Note
s
->
items
().
at
(
index
);
const
auto
note
=
m
Link
s
->
items
().
at
(
index
);
for
(
auto
key
:
note
.
keys
())
res
.
insert
(
OWL
::
KEYMAP
[
key
],
note
[
key
]);
return
res
;
...
...
@@ -35,25 +35,25 @@ QVariantMap LinksModel::get(const int &index)
void
LinksModel
::
sortBy
(
const
int
&
index
,
const
QString
&
order
)
{
beginResetModel
();
m
Note
s
->
sortBy
(
static_cast
<
OWL
::
KEY
>
(
index
),
order
);
m
Link
s
->
sortBy
(
static_cast
<
OWL
::
KEY
>
(
index
),
order
);
endResetModel
();
}
bool
LinksModel
::
insert
(
const
QVariantMap
&
note
)
bool
LinksModel
::
insert
(
const
QVariantMap
&
link
)
{
const
int
index
=
m
Note
s
->
items
().
size
();
const
int
index
=
m
Link
s
->
items
().
size
();
beginInsertRows
(
QModelIndex
(),
index
,
index
);
this
->
m
Notes
->
insertNote
(
note
);
this
->
m
Links
->
insertLink
(
link
);
endInsertRows
();
return
false
;
}
bool
LinksModel
::
setData
(
const
QModelIndex
&
index
,
const
QVariant
&
value
,
int
role
)
{
if
(
!
m
Note
s
)
if
(
!
m
Link
s
)
return
false
;
if
(
m
Notes
->
updateNote
(
index
.
row
(),
value
,
role
))
if
(
m
Links
->
updateLink
(
index
.
row
(),
value
,
role
))
{
emit
dataChanged
(
index
,
index
,
QVector
<
int
>
()
<<
role
);
return
true
;
...
...
@@ -92,36 +92,36 @@ QHash<int, QByteArray> LinksModel::roleNames() const
//Notes *NotesModel::notes() const
//{
// return m
Note
s;
// return m
Link
s;
//}
//void NotesModel::setNotes(Notes *value)
//{
// beginResetModel();
// if(m
Note
s)
// m
Note
s->disconnect(this);
// m
Note
s = value;
// if(m
Link
s)
// m
Link
s->disconnect(this);
// m
Link
s = value;
//// if(m
Note
s)
//// if(m
Link
s)
//// {
//// connect(m
Note
s, &Notes::preItemAppended, this, [=]()
//// connect(m
Link
s, &Notes::preItemAppended, this, [=]()
//// {
//// const int index = m
Note
s->items().size();
//// const int index = m
Link
s->items().size();
//// beginInsertRows(QModelIndex(), index, index);
//// });
//// connect(m
Note
s, &Notes::postItemAppended, this, [=]()
//// connect(m
Link
s, &Notes::postItemAppended, this, [=]()
//// {
//// endInsertRows();
//// });
//// connect(m
Note
s, &Notes::preItemRemoved, this, [=](int index)
//// connect(m
Link
s, &Notes::preItemRemoved, this, [=](int index)
//// {
//// beginInsertRows(QModelIndex(), index, index);
//// });
//// connect(m
Note
s, &Notes::preItemRemoved, this, [=]()
//// connect(m
Link
s, &Notes::preItemRemoved, this, [=]()
//// {
//// endRemoveRows();
//// });
...
...
src/models/links/linksmodel.h
View file @
219cf0a6
#ifndef
NOTE
SMODEL_H
#define
NOTE
SMODEL_H
#ifndef
LINK
SMODEL_H
#define
LINK
SMODEL_H
#include <QAbstractListModel>
#include <QList>
...
...
@@ -24,7 +24,7 @@ public:
Q_INVOKABLE
QVariantMap
get
(
const
int
&
index
);
Q_INVOKABLE
void
sortBy
(
const
int
&
index
,
const
QString
&
order
);
Q_INVOKABLE
bool
insert
(
const
QVariantMap
&
note
);
Q_INVOKABLE
bool
insert
(
const
QVariantMap
&
link
);
// Editable:
bool
setData
(
const
QModelIndex
&
index
,
const
QVariant
&
value
,
...
...
@@ -34,13 +34,8 @@ public:
virtual
QHash
<
int
,
QByteArray
>
roleNames
()
const
override
;
friend
bool
operator
<
(
const
OWL
::
DB
&
m1
,
const
OWL
::
DB
&
m2
)
{
return
m1
[
OWL
::
KEY
::
TITLE
]
<
m2
[
OWL
::
KEY
::
TITLE
];
}
private:
Links
*
m
Note
s
;
Links
*
m
Link
s
;
};
#endif // NOTESMODEL_H
src/views/links/LinksView.qml
View file @
219cf0a6
import
QtQuick
2.9
import
"
../../widgets
"
import
QtQuick
.
Controls
2.4
import
org
.
kde
.
mauikit
1.0
as
Maui
import
"
../../widgets
"
import
"
../../utils/owl.js
"
as
O
import
Links
1.0
import
Owl
1.0
Maui.Page
{
id
:
control
property
alias
cardsView
:
cardsView
property
alias
previewer
:
previewer
property
alias
model
:
linksModel
property
var
currentLink
:
({})
signal
linkClicked
(
var
link
)
headBarVisible
:
!
cardsView
.
holder
.
visible
margins
:
space
.
big
...
...
@@ -20,15 +29,46 @@ Maui.Page
Maui.ToolButton
{
iconName
:
cardsView
.
gridView
?
"
view-list-icons
"
:
"
view-list-details
"
onClicked
:
{
cardsView
.
gridView
=
!
cardsView
.
gridView
cardsView
.
refresh
()
}
onClicked
:
cardsView
.
gridView
=
!
cardsView
.
gridView
},
Maui.ToolButton
{
iconName
:
"
view-sort
"
onClicked
:
sortMenu
.
open
();
Menu
{
id
:
sortMenu
MenuItem
{
text
:
qsTr
(
"
Title
"
)
onTriggered
:
linksModel
.
sortBy
(
KEY
.
TITLE
,
"
ASC
"
)
}
MenuItem
{
text
:
qsTr
(
"
Color
"
)
onTriggered
:
linksModel
.
sortBy
(
KEY
.
COLOR
,
"
ASC
"
)
}
MenuItem
{
text
:
qsTr
(
"
Add date
"
)
onTriggered
:
linksModel
.
sortBy
(
KEY
.
ADD_DATE
,
"
DESC
"
)
}
MenuItem
{
text
:
qsTr
(
"
Updated
"
)
onTriggered
:
linksModel
.
sortBy
(
KEY
.
UPDATED
,
"
DESC
"
)
}
MenuItem
{
text
:
qsTr
(
"
Fav
"
)
onTriggered
:
linksModel
.
sortBy
(
KEY
.
FAV
,
"
DESC
"
)
}
}
}
]
...
...
@@ -56,8 +96,12 @@ Maui.Page
Previewer
{
id
:
previewer
onLinkSaved
:
if
(
owl
.
updateLink
(
link
))
cardsView
.
currentItem
.
update
(
link
)
onLinkSaved
:
cardsView
.
currentItem
.
update
(
link
)
}
LinksModel
{
id
:
linksModel
}
CardsView
...
...
@@ -71,6 +115,8 @@ Maui.Page
holder.body
:
"
Click here to save a new link
"
holder.emojiSize
:
iconSizes
.
huge
itemHeight
:
unit
*
250
model
:
linksModel
Connections
{
target
:
cardsView
.
holder
...
...
@@ -84,20 +130,4 @@ Maui.Page
cardsView
.
model
.
remove
(
cardsView
.
currentIndex
)
}
}
function
populate
()
{
var
data
=
owl
.
getLinks
()
for
(
var
i
in
data
)
{
console
.
log
(
"
PREVIEW
"
,
data
[
i
].
preview
)
append
(
data
[
i
])
}
}
function
append
(
link
)
{
cardsView
.
model
.
append
(
link
)
}
}
src/views/links/Previewer.qml
View file @
219cf0a6
...
...
@@ -21,7 +21,7 @@ Maui.Popup
anchors.fill
:
parent
margins
:
0
padding
:
0
headBarTitle
:
webView
.
title
headBarExit
:
false
headBar.leftContent
:
[
Maui.ToolButton
...
...
@@ -170,6 +170,7 @@ Maui.Popup
function
packLink
()
{
linkSaved
({
title
:
webView
.
title
,
link
:
webView
.
url
,
color
:
colorBar
.
currentColor
,
tag
:
tagBar
.
getTags
(),
...
...
src/views/notes/NotesView.qml
View file @
219cf0a6
...
...
@@ -5,6 +5,7 @@ import "../../widgets"
import
org
.
kde
.
mauikit
1.0
as
Maui
import
org
.
kde
.
kirigami
2.2
as
Kirigami
import
"
../../utils/owl.js
"
as
O
import
Notes
1.0
import
Owl
1.0
...
...
@@ -46,6 +47,12 @@ Maui.Page
onTriggered
:
notesModel
.
sortBy
(
KEY
.
TITLE
,
"
ASC
"
)
}
MenuItem
{
text
:
qsTr
(
"
Color
"
)
onTriggered
:
notesModel
.
sortBy
(
KEY
.
COLOR
,
"
ASC
"
)
}
MenuItem
{
text
:
qsTr
(
"
Add date
"
)
...
...
@@ -148,17 +155,4 @@ Maui.Page
}
}
}
function
populate
()
{
// var data = owl.getNotes()
// for(var i in data)
// append(data[i])
}
function
append
(
note
)
{
cardsView
.
model
.
append
(
note
)
}
}
src/widgets/CardDelegate.qml
View file @
219cf0a6
...
...
@@ -95,7 +95,8 @@ ItemDelegate
Layout.leftMargin
:
space
.
medium
Layout.bottomMargin
:
space
.
medium
Layout.rightMargin
:
space
.
medium
Layout.alignment
:
Qt
.
AlignLeft
Layout.alignment
:
Qt
.
AlignLeft
|
Qt
.
AlignVCenter
Layout.preferredHeight
:
model
.
preview
?
parent
.
height
*
0.4
:
undefined
Layout.fillWidth
:
true
Layout.fillHeight
:
true
...
...
@@ -106,32 +107,22 @@ ItemDelegate
font.weight
:
Font
.
Bold
font.bold
:
true
font.pointSize
:
fontSizes
.
large
clip
:
true
}
TextArea
Loader
{
id
:
body
padding
:
0
visible
:
typeof
model
.
body
!==
'
undefined
'
Layout.leftMargin
:
visible
?
space
.
medium
:
0
Layout.bottomMargin
:
visible
?
space
.
medium
:
0
Layout.rightMargin
:
visible
?
space
.
medium
:
0
id
:
bodyLoader
Layout.leftMargin
:
space
.
medium
Layout.bottomMargin
:
space
.
medium
Layout.rightMargin
:
space
.
medium
Layout.topMargin
:
title
.
visible
?
0
:
space
.
medium
Layout.alignment
:
Qt
.
AlignLeft
Layout.fillHeight
:
visible
Layout.fillWidth
:
visible
enabled
:
false
text
:
model
.
body
?
model
.
body
:
""
color
:
model
.
color
?
Qt
.
darker
(
model
.
color
,
3
)
:
textColor
wrapMode
:
TextEdit
.
WrapAnywhere
textFormat
:
TextEdit
.
RichText
font.pointSize
:
fontSizes
.
big
Layout.fillHeight
:
true
Layout.fillWidth
:
true
background
:
Rectangle
{
color
:
"
transparent
"
}
sourceComponent
:
typeof
model
.
body
!==
'
undefined
'
?
bodyComponent
:
undefined
}
...
...
@@ -148,6 +139,30 @@ ItemDelegate
}
}
Component
{
id
:
bodyComponent