forked from lubuwest/Friendiqa
Version 0.002 with working Permissions
This commit is contained in:
parent
571c9046d0
commit
15e2e8f60a
|
@ -79,5 +79,7 @@ ToDo
|
||||||
|
|
||||||
|
|
||||||
## License ##
|
## License ##
|
||||||
|
v0.001 for Friendica < 3.5
|
||||||
|
v0.002 for Friendica >= 3.5
|
||||||
Pubished under the [GPL v3](http://gplv3.fsf.org).
|
Pubished under the [GPL v3](http://gplv3.fsf.org).
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<manifest package="org.qtproject.friendiqa" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.002" android:versionCode="2" android:installLocation="auto">
|
<manifest package="org.qtproject.friendiqa" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.2" android:versionCode="2" android:installLocation="auto">
|
||||||
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="Friendiqa" android:icon="@drawable/icon">
|
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="Friendiqa">
|
||||||
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="Friendiqa" android:screenOrientation="unspecified" android:launchMode="singleTop">
|
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="Friendiqa" android:screenOrientation="unspecified" android:launchMode="singleTop">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
<!-- Background running -->
|
<!-- Background running -->
|
||||||
</activity>
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
<uses-sdk android:minSdkVersion="18" android:targetSdkVersion="22"/>
|
<uses-sdk android:minSdkVersion="18" android:targetSdkVersion="21"/>
|
||||||
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
|
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
|
||||||
|
|
||||||
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
|
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.5 KiB |
|
@ -1,25 +1,28 @@
|
||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/">
|
<qresource prefix="/">
|
||||||
|
<file>qml/friendiqa.qml</file>
|
||||||
|
<file>qml/newsqml/NewsTab.qml</file>
|
||||||
|
<file>qml/newsqml/Newsitem.qml</file>
|
||||||
|
<file>qml/newsqml/MessageSend.qml</file>
|
||||||
|
<file>qml/newsqml/PermissionDialog.qml</file>
|
||||||
|
<file>qml/contactqml/FriendsTab.qml</file>
|
||||||
|
<file>qml/contactqml/GroupComponent.qml</file>
|
||||||
|
<file>qml/contactqml/ContactComponent.qml</file>
|
||||||
|
<file>qml/contactqml/ContactDetailsComponent.qml</file>
|
||||||
|
<file>qml/photoqml/PhotoComponent.qml</file>
|
||||||
|
<file>qml/photoqml/PhotogroupComponent.qml</file>
|
||||||
|
<file>qml/photoqml/PhotoPlaceholder.qml</file>
|
||||||
|
<file>qml/photoqml/PhotoTab.qml</file>
|
||||||
|
<file>qml/configqml/InfoBox.qml</file>
|
||||||
|
<file>qml/configqml/ConfigTab.qml</file>
|
||||||
<file>js/layout.js</file>
|
<file>js/layout.js</file>
|
||||||
<file>js/photoworker.js</file>
|
<file>js/photoworker.js</file>
|
||||||
<file>js/service.js</file>
|
<file>js/service.js</file>
|
||||||
<file>qml/MessageSend.qml</file>
|
|
||||||
<file>qml/Newsitem.qml</file>
|
|
||||||
<file>qml/PhotoComponent.qml</file>
|
|
||||||
<file>qml/PhotogroupComponent.qml</file>
|
|
||||||
<file>qml/PhotoPlaceholder.qml</file>
|
|
||||||
<file>qml/friendiqa.qml</file>
|
|
||||||
<file>qml/PhotoTab.qml</file>
|
|
||||||
<file>qml/ConfigTab.qml</file>
|
|
||||||
<file>qml/FriendsTab.qml</file>
|
|
||||||
<file>qml/NewsTab.qml</file>
|
|
||||||
<file>js/news.js</file>
|
<file>js/news.js</file>
|
||||||
<file>js/newsworker.js</file>
|
<file>js/newsworker.js</file>
|
||||||
<file>js/helper.js</file>
|
<file>js/helper.js</file>
|
||||||
<file>images/defaultcontact.jpg</file>
|
<file>images/defaultcontact.jpg</file>
|
||||||
<file>qml/InfoBox.qml</file>
|
|
||||||
<file>qml/GroupComponent.qml</file>
|
|
||||||
<file>qml/ContactComponent.qml</file>
|
|
||||||
<file>qml/PermissionDialog.qml</file>
|
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
@ -14,7 +14,7 @@ XHR *XHR::instance()
|
||||||
|
|
||||||
XHR::XHR(QObject *parent) : QObject(parent)
|
XHR::XHR(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
// request.setSslConfiguration(QSslConfiguration::defaultConfiguration());
|
request.setSslConfiguration(QSslConfiguration::defaultConfiguration());
|
||||||
}
|
}
|
||||||
|
|
||||||
void XHR::setUrl(QString url)
|
void XHR::setUrl(QString url)
|
||||||
|
@ -79,10 +79,11 @@ void XHR::download()
|
||||||
request.setUrl(requrl);
|
request.setUrl(requrl);
|
||||||
reply = manager.get(request);
|
reply = manager.get(request);
|
||||||
// qDebug() << "reply " << reply->header(QNetworkRequest::LocationHeader)<<reply->header(QNetworkRequest::LastModifiedHeader);
|
// qDebug() << "reply " << reply->header(QNetworkRequest::LocationHeader)<<reply->header(QNetworkRequest::LastModifiedHeader);
|
||||||
// qDebug() << "request " << request.url();
|
// qDebug() << "request " << request.url();
|
||||||
// qDebug() << "error " << reply->error();
|
|
||||||
// reply->ignoreSslErrors();
|
// reply->ignoreSslErrors();
|
||||||
connect(reply, &QNetworkReply::readyRead,this, &XHR::onRequestFinished);
|
connect(reply, &QNetworkReply::readyRead,this, &XHR::onReadyRead);
|
||||||
|
connect(reply,SIGNAL(downloadProgress(qint64,qint64)), this,SLOT(updateDownloadProgress(qint64,qint64)));
|
||||||
|
connect(reply, &QNetworkReply::finished,this, &XHR::onRequestFinished);
|
||||||
connect(reply, &QNetworkReply::sslErrors, this, &XHR::onSSLError);
|
connect(reply, &QNetworkReply::sslErrors, this, &XHR::onSSLError);
|
||||||
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onReplyError(QNetworkReply::NetworkError)));
|
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onReplyError(QNetworkReply::NetworkError)));
|
||||||
}
|
}
|
||||||
|
@ -177,17 +178,19 @@ void XHR::onReplySuccess()
|
||||||
void XHR::onRequestFinished()
|
void XHR::onRequestFinished()
|
||||||
{
|
{
|
||||||
// Save the file here
|
// Save the file here
|
||||||
QByteArray b = reply->readAll();
|
//qDebug() << "buffer downloaded "<<buffer;
|
||||||
QImage image = QImage::fromData(b);
|
//QImage image = QImage::fromData(buffer);
|
||||||
if (image.isNull()){qDebug() << "Image empty"<<m_url;}
|
if (buffer.isNull()){qDebug() << "Image empty"<<m_url; buffer.clear(); emit this->error("image empty",1); reply->deleteLater();}
|
||||||
QFile file(m_filename);
|
else {QFile file(m_filename);
|
||||||
file.open(QIODevice::WriteOnly);
|
file.open(QIODevice::WriteOnly);
|
||||||
image.save(&file, "JPG");
|
//image.save(&file, "JPG");
|
||||||
b.clear();
|
file.write(buffer);
|
||||||
|
buffer.clear();
|
||||||
file.close();
|
file.close();
|
||||||
// qDebug() << m_url << "File downloaded "<<file.fileName();
|
//qDebug() << m_url << "File downloaded "<<file.fileName();
|
||||||
emit this->downloaded();
|
emit this->downloaded();
|
||||||
reply->deleteLater();
|
//reply->deleteLater();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XHR::onReadyRead()
|
void XHR::onReadyRead()
|
||||||
|
@ -196,6 +199,12 @@ void XHR::onReadyRead()
|
||||||
buffer += reply->readAll();
|
buffer += reply->readAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void XHR::updateDownloadProgress(qint64 bytesRead, qint64 totalBytes)
|
||||||
|
{
|
||||||
|
qDebug() << "Bytes: " << bytesRead<<" / "<<totalBytes;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void XHR::onSSLError(const QList<QSslError> &errors)
|
void XHR::onSSLError(const QList<QSslError> &errors)
|
||||||
{
|
{
|
||||||
qDebug() << "XHR::onSSLError :" ;
|
qDebug() << "XHR::onSSLError :" ;
|
||||||
|
|
|
@ -17,9 +17,6 @@ public:
|
||||||
|
|
||||||
explicit XHR(QObject *parent = 0);
|
explicit XHR(QObject *parent = 0);
|
||||||
|
|
||||||
|
|
||||||
// void setLogin(QString login);
|
|
||||||
|
|
||||||
QString url() const;
|
QString url() const;
|
||||||
QString login() const;
|
QString login() const;
|
||||||
QString filename() const;
|
QString filename() const;
|
||||||
|
@ -47,9 +44,9 @@ private slots:
|
||||||
void onReplyError(QNetworkReply::NetworkError code);
|
void onReplyError(QNetworkReply::NetworkError code);
|
||||||
void onReplySuccess();
|
void onReplySuccess();
|
||||||
void onRequestFinished();
|
void onRequestFinished();
|
||||||
//void onFileWritten();
|
|
||||||
void onReadyRead();
|
void onReadyRead();
|
||||||
void onSSLError(const QList<QSslError> &errors);
|
void onSSLError(const QList<QSslError> &errors);
|
||||||
|
void updateDownloadProgress(qint64 bytesRead, qint64 totalBytes);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QByteArray buffer;
|
QByteArray buffer;
|
||||||
|
|
|
@ -24,7 +24,12 @@ RESOURCES = application.qrc
|
||||||
OTHER_FILES += qml/friendiqa.qml \
|
OTHER_FILES += qml/friendiqa.qml \
|
||||||
translations/*.ts \
|
translations/*.ts \
|
||||||
qml/*.qml
|
qml/*.qml
|
||||||
|
qml/newsqml/*.qml
|
||||||
|
qml/contactqml/*.qml
|
||||||
|
qml/photoqml/*.qml
|
||||||
|
qml/configqml/*.qml
|
||||||
js/*.js
|
js/*.js
|
||||||
|
images/*.*
|
||||||
|
|
||||||
# German translation is enabled as an example. If you aren't
|
# German translation is enabled as an example. If you aren't
|
||||||
# planning to localize your app, remember to comment out the
|
# planning to localize your app, remember to comment out the
|
||||||
|
@ -37,4 +42,15 @@ HEADERS += \
|
||||||
common/xhr.h \
|
common/xhr.h \
|
||||||
common/filesystem.h
|
common/filesystem.h
|
||||||
|
|
||||||
|
DISTFILES += \
|
||||||
|
android/AndroidManifest.xml \
|
||||||
|
android/gradle/wrapper/gradle-wrapper.jar \
|
||||||
|
android/gradlew \
|
||||||
|
android/res/values/libs.xml \
|
||||||
|
android/build.gradle \
|
||||||
|
android/gradle/wrapper/gradle-wrapper.properties \
|
||||||
|
android/gradlew.bat
|
||||||
|
|
||||||
|
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -114,3 +114,8 @@ function inArray(list, prop, val) {
|
||||||
}
|
}
|
||||||
} return -1;
|
} return -1;
|
||||||
}
|
}
|
||||||
|
function cleanArray(array) {
|
||||||
|
var arraystring=JSON.stringify(array);
|
||||||
|
arraystring=arraystring.replace(/[\[\]]/g , '');
|
||||||
|
return arraystring;
|
||||||
|
}
|
||||||
|
|
|
@ -39,6 +39,6 @@ function finishCreation(component,qmlParameters,parentitem,callback) {
|
||||||
else if (component.status === Component.Error)
|
else if (component.status === Component.Error)
|
||||||
print("Error loading component:"+component.errorString());
|
print("Error loading component:"+component.errorString());
|
||||||
else {print("created")}
|
else {print("created")}
|
||||||
callback(createdObject);
|
//callback(createdObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,31 +44,7 @@ function getFriendsTimeline(login,database,contacts,rootwindow,callback){// retr
|
||||||
Helperjs.friendicaRequest(login,"/api/statuses/friends_timeline"+parameter, rootwindow,function (obj){
|
Helperjs.friendicaRequest(login,"/api/statuses/friends_timeline"+parameter, rootwindow,function (obj){
|
||||||
var news=JSON.parse(obj);
|
var news=JSON.parse(obj);
|
||||||
var newContacts=findNewContacts(news,contacts);
|
var newContacts=findNewContacts(news,contacts);
|
||||||
// for (var i=0;i<news.length;i++){
|
callback(news,newContacts)
|
||||||
// if(contacts.indexOf(news[i].user.id)==-1 && !(inArray(newContacts,"id",news[i].user.id))){
|
|
||||||
// news[i].user.isFriend=0;
|
|
||||||
// newContacts.push(news[i].user);
|
|
||||||
// }
|
|
||||||
// if (news[i].friendica_activities.like.length>0){
|
|
||||||
// // print("Like Contact"+JSON.stringify(news[i].friendica_activities.like));
|
|
||||||
// for (var j=0;j<news[i].friendica_activities.like.length;j++){
|
|
||||||
// if(contacts.indexOf(news[i].friendica_activities.like[j].id)==-1 && !(inArray(newContacts,"id",news[i].friendica_activities.like[j].id))){
|
|
||||||
// news[i].friendica_activities.like[j].isFriend=0;
|
|
||||||
// newContacts.push(news[i].friendica_activities.like[j]);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (news[i].friendica_activities.dislike.length>0){
|
|
||||||
// //print("DisLike Contact"+JSON.stringify(news[i].friendica_activities.dislike));
|
|
||||||
// for (var k=0;j<news[k].friendica_activities.dislike.length;k++){
|
|
||||||
// if(contacts.indexOf(news[i].friendica_activities.dislike[k].id)==-1 && !(inArray(newContacts,"id",news[i].friendica_activties.dislike[k].id))){
|
|
||||||
// news[i].friendica_activities.dislike[k].isFriend=0;
|
|
||||||
// newContacts.push(news[i].friendica_activities.dislike[k]);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
callback(news,newContacts)
|
|
||||||
})}
|
})}
|
||||||
|
|
||||||
function findNewContacts(news,contacts){
|
function findNewContacts(news,contacts){
|
||||||
|
@ -104,7 +80,7 @@ function storeNews(login,database,news,rootwindow,callback){
|
||||||
// save news after contacts download, call next function
|
// save news after contacts download, call next function
|
||||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||||
for (var i=0;i<news.length;i++){
|
for (var i=0;i<news.length;i++){
|
||||||
print('store news data for ' + news[i].id+JSON.stringify(news[i].friendica_activities));
|
//print('store news data for ' + news[i].id+JSON.stringify(news[i].friendica_activities));
|
||||||
var ausdruck=news[i];
|
var ausdruck=news[i];
|
||||||
var likearray=[]; for (var user in news[i].friendica_activities.like){likearray.push(parseInt(news[i].friendica_activities.like[user].id))}
|
var likearray=[]; for (var user in news[i].friendica_activities.like){likearray.push(parseInt(news[i].friendica_activities.like[user].id))}
|
||||||
var dislikearray=[]; for (var user in news[i].friendica_activities.dislike){parseInt(news[i].friendica_activities.dislike[user].id)}
|
var dislikearray=[]; for (var user in news[i].friendica_activities.dislike){parseInt(news[i].friendica_activities.dislike[user].id)}
|
||||||
|
@ -113,10 +89,10 @@ function storeNews(login,database,news,rootwindow,callback){
|
||||||
var attendmaybearray=[]; for (var user in news[i].friendica_activities.attendmaybe){attendmaybearray.push(parseInt(news[i].friendica_activities.attendmaybe[user].id))}
|
var attendmaybearray=[]; for (var user in news[i].friendica_activities.attendmaybe){attendmaybearray.push(parseInt(news[i].friendica_activities.attendmaybe[user].id))}
|
||||||
var friendica_activities=[likearray,dislikearray,attendyesarray,attendnoarray,attendmaybearray]
|
var friendica_activities=[likearray,dislikearray,attendyesarray,attendnoarray,attendmaybearray]
|
||||||
db.transaction( function(tx) {
|
db.transaction( function(tx) {
|
||||||
var result = tx.executeSql('SELECT * from news where status_id = "'+news[i].id+'"'); // check for news id
|
var result = tx.executeSql('SELECT * from news where username="'+login.username+'" AND status_id = "'+news[i].id+'" AND messagetype=0'); // check for news id
|
||||||
if(result.rows.length === 1) {// use update
|
if(result.rows.length === 1) {// use update
|
||||||
print(news[i].id +' exists, update it')
|
print(news[i].id +' exists, update it')
|
||||||
result = tx.executeSql('UPDATE news SET username="'+login.username+'", messagetype=0, text="'+Qt.btoa(news[i].text)+'", created_at="'+Date.parse(cleanDate(news[i].created_at))+'", in_reply_to_status_id="'+news[i].in_reply_to_status_id+'", source="'+news[i].source+'", status_id="'+news[i].id+'", in_reply_to_user_id="'+news[i].in_reply_to_user_id+'", geo="'+news[i].geo+'", favorited="'+news[i].favorited+'", uid="'+news[i].user.id+'", statusnet_html="'+Qt.btoa(news[i].status_html)+'", statusnet_conversation_id="'+news[i].statusnet_conversation_id+'",friendica_activities="'+JSON.stringify(friendica_activities)+'" where status_id="'+news[i].status_id+'"');
|
result = tx.executeSql('UPDATE news SET username="'+login.username+'", messagetype=0, text="'+Qt.btoa(news[i].text)+'", created_at="'+Date.parse(cleanDate(news[i].created_at))+'", in_reply_to_status_id="'+news[i].in_reply_to_status_id+'", source="'+news[i].source+'", status_id="'+news[i].id+'", in_reply_to_user_id="'+news[i].in_reply_to_user_id+'", geo="'+news[i].geo+'", favorited="'+news[i].favorited+'", uid="'+news[i].user.id+'", statusnet_html="'+Qt.btoa(news[i].status_html)+'", statusnet_conversation_id="'+news[i].statusnet_conversation_id+'",friendica_activities="'+JSON.stringify(friendica_activities)+'" where username="'+login.username+'" AND status_id="'+news[i].status_id+'" AND messagetype=0');
|
||||||
} else {// use insert
|
} else {// use insert
|
||||||
result = tx.executeSql('INSERT INTO news (username,messagetype,text,created_at,in_reply_to_status_id,source,status_id,in_reply_to_user_id,geo,favorited,uid,statusnet_html,statusnet_conversation_id,friendica_activities,friendica_activities_self) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,0,Qt.btoa(news[i].text),Date.parse(cleanDate(news[i].created_at)), news[i].in_reply_to_status_id, news[i].source, news[i].id,news[i].in_reply_to_user_id,news[i].geo,news[i].favorited, news[i].user.id,Qt.btoa(news[i].statusnet_html),news[i].statusnet_conversation_id, JSON.stringify(friendica_activities),"[]"])}})
|
result = tx.executeSql('INSERT INTO news (username,messagetype,text,created_at,in_reply_to_status_id,source,status_id,in_reply_to_user_id,geo,favorited,uid,statusnet_html,statusnet_conversation_id,friendica_activities,friendica_activities_self) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,0,Qt.btoa(news[i].text),Date.parse(cleanDate(news[i].created_at)), news[i].in_reply_to_status_id, news[i].source, news[i].id,news[i].in_reply_to_user_id,news[i].geo,news[i].favorited, news[i].user.id,Qt.btoa(news[i].statusnet_html),news[i].statusnet_conversation_id, JSON.stringify(friendica_activities),"[]"])}})
|
||||||
}
|
}
|
||||||
|
@ -128,14 +104,14 @@ function getDirectMessage(login,database,rootwindow,callback){
|
||||||
Helperjs.friendicaRequest(login,"/api/direct_messages/all",rootwindow, function (obj){
|
Helperjs.friendicaRequest(login,"/api/direct_messages/all",rootwindow, function (obj){
|
||||||
var messages=JSON.parse(obj);
|
var messages=JSON.parse(obj);
|
||||||
for (var i=0;i<messages.length;i++){
|
for (var i=0;i<messages.length;i++){
|
||||||
// print('store message data for '+JSON.stringify(messages[i]));
|
//print('store message data for '+JSON.stringify(messages[i]));
|
||||||
db.transaction( function(tx) {
|
db.transaction( function(tx) {
|
||||||
var result = tx.executeSql('SELECT * from news where status_id = "'+messages[i].id+'"'); // check for news id
|
var result = tx.executeSql('SELECT * from news where username= "'+login.username+'" AND status_id = "'+messages[i].id+'" AND messagetype=1'); // check for news id
|
||||||
if(result.rows.length === 1) {// use update
|
if(result.rows.length === 1) {// use update
|
||||||
print(messages[i].id +' exists, update it')
|
print(messages[i].id +' exists, update it')
|
||||||
result = tx.executeSql('UPDATE news SET username="'+login.username+'", messagetype=1, text="'+Qt.btoa(messages[i].text)+'", created_at="'+Date.parse(messages[i].created_at)+'", source="Friendica", status_id="'+messages[i].id+'", uid="'+messages[i].sender.id+'", statusnet_html="'+Qt.btoa(messages[i].text)+'" where status_id="'+messages[i].status_id+'"');
|
result = tx.executeSql('UPDATE news SET username="'+login.username+'", messagetype=1, text="'+Qt.btoa(messages[i].text)+'", created_at="'+Date.parse(cleanDate(messages[i].created_at))+'", source="Friendica", status_id="'+messages[i].id+'", uid="'+messages[i].sender.id+'", statusnet_html="'+Qt.btoa(messages[i].text)+'" where username="'+login.username+'" AND status_id="'+messages[i].status_id+'" AND messagetype=1');
|
||||||
} else {// use insert
|
} else {// use insert
|
||||||
result = tx.executeSql('INSERT INTO news (username,messagetype,text,created_at,source,status_id,uid,statusnet_html) VALUES (?,?,?,?,?,?,?,?)', [login.username,1,Qt.btoa(messages[i].text),Date.parse(messages[i].created_at), "Friendica", messages[i].id, messages[i].sender.id,Qt.btoa(messages[i].text)])}
|
result = tx.executeSql('INSERT INTO news (username,messagetype,text,created_at,source,status_id,uid,statusnet_html) VALUES (?,?,?,?,?,?,?,?)', [login.username,1,Qt.btoa(messages[i].text),Date.parse(cleanDate(messages[i].created_at)), "Friendica", messages[i].id, messages[i].sender.id,Qt.btoa(messages[i].text)])}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -149,10 +125,10 @@ function getNotifications(login,database,rootwindow,callback){
|
||||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||||
//print('store message data for '+JSON.stringify(messages[i]));
|
//print('store message data for '+JSON.stringify(messages[i]));
|
||||||
db.transaction( function(tx) {
|
db.transaction( function(tx) {
|
||||||
var result = tx.executeSql('SELECT * from news where status_id = "'+messages[i].id+'"'); // check for news id
|
var result = tx.executeSql('SELECT * from news where username="'+login.username+'" AND status_id = "'+messages[i].id+'" AND messagetype=2'); // check for news id
|
||||||
if(result.rows.length === 1) {// use update
|
if(result.rows.length === 1) {// use update
|
||||||
print(messages[i].id +' exists, update it')
|
print(messages[i].id +' exists, update it')
|
||||||
result = tx.executeSql('UPDATE news SET username="'+login.username+'", messagetype=2, text="'+Qt.btoa(messages[i].msg_html)+'", created_at="'+Date.parse(messages[i].date)+'", source="Friendica", status_id="'+messages[i].id+'", uid="'+messages[i].uid+'", statusnet_html="'+Qt.btoa(messages[i].msg_html)+'", statusnet_conversation_id="'+messages[i].parent+'" where status_id="'+messages[i].id+'"');
|
result = tx.executeSql('UPDATE news SET username="'+login.username+'", messagetype=2, text="'+Qt.btoa(messages[i].msg_html)+'", created_at="'+Date.parse(messages[i].date)+'", source="Friendica", status_id="'+messages[i].id+'", uid="'+messages[i].uid+'", statusnet_html="'+Qt.btoa(messages[i].msg_html)+'", statusnet_conversation_id="'+messages[i].parent+'" where username="'+login.username+'" AND status_id="'+messages[i].id+'" AND messagetype=2');
|
||||||
} else {// use insert
|
} else {// use insert
|
||||||
result = tx.executeSql('INSERT INTO news (username,messagetype,text,created_at,source,status_id, uid,statusnet_html,statusnet_conversation_id) VALUES (?,?,?,?,?,?,?,?,?)', [login.username,2,Qt.btoa(messages[i].msg_html),Date.parse(messages[i].date),"Friendica", messages[i].id, messages[i].uid,Qt.btoa(messages[i].msg_html),messages[i].parent])}
|
result = tx.executeSql('INSERT INTO news (username,messagetype,text,created_at,source,status_id, uid,statusnet_html,statusnet_conversation_id) VALUES (?,?,?,?,?,?,?,?,?)', [login.username,2,Qt.btoa(messages[i].msg_html),Date.parse(messages[i].date),"Friendica", messages[i].id, messages[i].uid,Qt.btoa(messages[i].msg_html),messages[i].parent])}
|
||||||
});
|
});
|
||||||
|
@ -233,14 +209,21 @@ function fetchUsersForNews(database,username,news){
|
||||||
return news
|
return news
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteNews(login,database,newsid,rootwindow,callback){
|
function deleteNews(login,database,newsid,messagetype,rootwindow,callback){
|
||||||
Helperjs.friendicaPostRequest(login,"/api/statuses/destroy?id="+newsid, rootwindow,function (obj){
|
var api="" ;
|
||||||
|
if (messagetype==0){ api="/api/statuses/destroy?id="}
|
||||||
|
else if (messagetype==1){ api="/api/direct_messages/destroy?id="}
|
||||||
|
else if (messagetype==2){ api="/api/friendica/notifications/seen?id="}
|
||||||
|
|
||||||
|
Helperjs.friendicaPostRequest(login,api+newsid, rootwindow,function (obj){
|
||||||
print("Delete "+obj);
|
print("Delete "+obj);
|
||||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||||
print('delete news data for ' + newsid);
|
print('delete news data for ' + newsid);
|
||||||
db.transaction( function(tx) {var result = tx.executeSql('DELETE from news where status_id ='+newsid); // delete news id
|
db.transaction( function(tx) {var result = tx.executeSql('DELETE from news where username="'+login.username+'" AND messagetype='+messagetype+' AND status_id ='+newsid); // delete news id
|
||||||
Helperjs.showMessage("Delete",result,rootwindow)});
|
Helperjs.showMessage("Delete",obj,rootwindow);
|
||||||
})}
|
callback(obj)
|
||||||
|
});
|
||||||
|
})}
|
||||||
|
|
||||||
function retweetNews(login,database,newsid,rootwindow,callback){
|
function retweetNews(login,database,newsid,rootwindow,callback){
|
||||||
Helperjs.friendicaRequest(login,"/api/statuses/retweet?id="+newsid, rootwindow,function (obj){
|
Helperjs.friendicaRequest(login,"/api/statuses/retweet?id="+newsid, rootwindow,function (obj){
|
||||||
|
@ -329,7 +312,7 @@ function conversationfromdb(database,user,conversationId,callback){
|
||||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||||
db.transaction( function(tx) {
|
db.transaction( function(tx) {
|
||||||
print('select * from news WHERE statusnet_conversation_id='+conversationId+' ORDER BY status_id DESC');
|
print('select * from news WHERE statusnet_conversation_id='+conversationId+' ORDER BY status_id DESC');
|
||||||
var newsrs=tx.executeSql('select * from news WHERE statusnet_conversation_id='+conversationId+' ORDER BY status_id DESC');
|
var newsrs=tx.executeSql('select * from news WHERE username="'+user+'" AND statusnet_conversation_id='+conversationId+' ORDER BY status_id DESC');
|
||||||
var newsArray=[];
|
var newsArray=[];
|
||||||
for(var i = 0; i < newsrs.rows.length; i++) {
|
for(var i = 0; i < newsrs.rows.length; i++) {
|
||||||
newsArray.push(newsrs.rows.item(i));
|
newsArray.push(newsrs.rows.item(i));
|
||||||
|
|
|
@ -33,7 +33,7 @@ function dataRequest(login,photoID,database,rootwindow) {
|
||||||
// print("Source"+source);
|
// print("Source"+source);
|
||||||
obj["source"]=source;
|
obj["source"]=source;
|
||||||
var filename=obj.filename;
|
var filename=obj.filename;
|
||||||
if (filename==""){// check if file as any filename
|
if (filename==""){// check if file has any filename
|
||||||
if (obj.type=="image/jpeg") {obj["filename"]=obj["id"]+".jpg"}
|
if (obj.type=="image/jpeg") {obj["filename"]=obj["id"]+".jpg"}
|
||||||
else if (obj.type=="image/png") {obj["filename"]=obj["id"]+".png"}
|
else if (obj.type=="image/png") {obj["filename"]=obj["id"]+".png"}
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ function saveImage(obj,storagedirectory,callback) {
|
||||||
} else { //portrait
|
} else { //portrait
|
||||||
helpwidth=helpheight*obj.width/obj.height
|
helpwidth=helpheight*obj.width/obj.height
|
||||||
}
|
}
|
||||||
var component=Qt.createComponent("qrc:/qml/PhotoPlaceholder.qml");
|
var component=Qt.createComponent("qrc:/qml/photoqml/PhotoPlaceholder.qml");
|
||||||
var sprite = component.createObject(fotostab, {"x":0,"y":0,"imageName":storagedirectory+"/"+obj.filename ,"width":helpwidth,"height":helpheight,"source": obj["link"]["4"],"downloadtype":"picture"});
|
var sprite = component.createObject(fotostab, {"x":0,"y":0,"imageName":storagedirectory+"/"+obj.filename ,"width":helpwidth,"height":helpheight,"source": obj["link"]["4"],"downloadtype":"picture"});
|
||||||
callback(obj,sprite)
|
callback(obj,sprite)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick.Controls 1.2
|
|
||||||
|
|
||||||
Item {
|
|
||||||
ComboBox{
|
|
||||||
id: selectionTypeCombo
|
|
||||||
width: 150
|
|
||||||
model: ["album", "type","filename"]
|
|
||||||
onCurrentIndexChanged:{
|
|
||||||
var login=Service.readActiveConfig(db);
|
|
||||||
if (currentText!==""){
|
|
||||||
photogroupModel.clear();
|
|
||||||
Service.readData(db, "imageData",function(filter){
|
|
||||||
for (var j=0;j<filter.length;j++){
|
|
||||||
Service.readField("data",db,"imageData",function(obj){
|
|
||||||
// obj.sort(function(obj1,obj2){return obj1.data-obj2.data});
|
|
||||||
if (obj) {
|
|
||||||
for (var k=0;k<obj.length;k++){
|
|
||||||
print("Photomodel:"+obj[k].location+obj[k].filename);
|
|
||||||
photoModel.append({imageString: obj[k].location+obj[k].filename,photoDescription:obj[k].filename})
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (obj[0]) {photogroupModel.append({photoDescription: filter[j]})};
|
|
||||||
},currentText,filter[j]);
|
|
||||||
}},"username",login.username)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
import QtQuick 2.0
|
|
||||||
import QtMultimedia 5.0
|
|
||||||
import QtQuick.Controls 1.2
|
|
||||||
|
|
||||||
Item {
|
|
||||||
Rectangle {
|
|
||||||
VideoOutput {
|
|
||||||
anchors.fill: parent
|
|
||||||
source: localCamera
|
|
||||||
}
|
|
||||||
Camera {
|
|
||||||
id: localCamera
|
|
||||||
}
|
|
||||||
Button {
|
|
||||||
id: shotButton
|
|
||||||
width: 200; height: 75
|
|
||||||
text: "Take Photo"
|
|
||||||
onClicked: {
|
|
||||||
localCamera.imageCapture.capture();
|
|
||||||
} }
|
|
||||||
Connections {
|
|
||||||
target: localCamera.imageCapture
|
|
||||||
onImageSaved: {
|
|
||||||
photofile= imagePaths.append({"path": path})
|
|
||||||
listView.positionViewAtEnd(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
Image {
|
|
||||||
id: photoFromCamera
|
|
||||||
anchors.fill: parent
|
|
||||||
fillMode: Image.PreserveAspectFit
|
|
||||||
source: photo
|
|
||||||
}
|
|
||||||
|
|
||||||
Button {
|
|
||||||
text: "Upload"
|
|
||||||
onClicked:{
|
|
||||||
var login=Service.readActiveConfig(db);
|
|
||||||
img.src=file;
|
|
||||||
Service.Upload(login,file)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,137 +0,0 @@
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick.Controls 1.3
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: contactComponent
|
|
||||||
property var createdAtDate: new Date(contact.created_at)
|
|
||||||
property var linkUrl: contact.network!=="dfrn"?contact.url:contact.url.replace("profile","dfrn_request")
|
|
||||||
Rectangle {
|
|
||||||
id: wrapper
|
|
||||||
width: 16*mm
|
|
||||||
height: 15*mm
|
|
||||||
border.color: "grey"
|
|
||||||
color:"white"
|
|
||||||
Image {
|
|
||||||
id: photoImage
|
|
||||||
x:1
|
|
||||||
y:1
|
|
||||||
width: 10*mm
|
|
||||||
height:10*mm
|
|
||||||
source:(contact.isFriend==1)? "file://"+contact.profile_image :contact.profile_image_url
|
|
||||||
onStatusChanged: if (photoImage.status == Image.Error) {source="qrc:/images/defaultcontact.jpg"}
|
|
||||||
}
|
|
||||||
|
|
||||||
Label {
|
|
||||||
id: namelabel
|
|
||||||
x: 1
|
|
||||||
width: wrapper.width-4
|
|
||||||
height: 3*mm
|
|
||||||
text: contact.screen_name
|
|
||||||
elide:Text.ElideRight
|
|
||||||
anchors.topMargin: 0
|
|
||||||
anchors.left: photoImage.left
|
|
||||||
color: "#303030"
|
|
||||||
font.pixelSize: 3*mm
|
|
||||||
anchors.top: photoImage.bottom
|
|
||||||
}
|
|
||||||
Button{
|
|
||||||
id:infobutton
|
|
||||||
width: 5*mm
|
|
||||||
height: 5*mm
|
|
||||||
text:"?"
|
|
||||||
anchors.left: photoImage.right
|
|
||||||
anchors.leftMargin: 3
|
|
||||||
anchors.topMargin: 3
|
|
||||||
anchors.top: parent.top
|
|
||||||
onClicked:{
|
|
||||||
//print("State: "+ friendComponent.state);
|
|
||||||
contactComponent.state="large"}
|
|
||||||
}
|
|
||||||
Rectangle{
|
|
||||||
id: detailsrectangle
|
|
||||||
anchors.top: namelabel.bottom
|
|
||||||
anchors.topMargin: 2*mm
|
|
||||||
opacity: 0
|
|
||||||
|
|
||||||
Flickable{
|
|
||||||
id:namelabelflickable
|
|
||||||
width: root.width-10*mm
|
|
||||||
height:friendsTabView.height-55*mm
|
|
||||||
boundsBehavior:Flickable.StopAtBounds
|
|
||||||
flickableDirection:Flickable.VerticalFlick
|
|
||||||
contentWidth:width
|
|
||||||
contentHeight: namelabeltext.height
|
|
||||||
clip:true
|
|
||||||
Text{
|
|
||||||
id:namelabeltext
|
|
||||||
//anchors.top: parent.top
|
|
||||||
width: namelabelflickable.width
|
|
||||||
height: implicitHeight
|
|
||||||
font.pixelSize: 3*mm
|
|
||||||
textFormat:Text.RichText
|
|
||||||
wrapMode: Text.Wrap
|
|
||||||
text:"<b>"+qsTr("Description")+": </b> "+Qt.atob(contact.description)+"<br> <b>"+qsTr("Server Type")+":</b> "+contact.location+"<br> <b>"+qsTr("Posts")+":</b> "+contact.statuses_count+
|
|
||||||
"<br> <b>"+qsTr("URL")+":</b> <a href='"+ linkUrl+"'>"+linkUrl+"</a><br> <b>"+
|
|
||||||
qsTr("Created at")+":</b> "+createdAtDate.toLocaleString(Qt.locale())
|
|
||||||
onLinkActivated: {
|
|
||||||
Qt.openUrlExternally(link)}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Row{
|
|
||||||
anchors.top: namelabelflickable.bottom
|
|
||||||
anchors.topMargin: 2*mm
|
|
||||||
spacing:4
|
|
||||||
|
|
||||||
Button{
|
|
||||||
id:photobutton
|
|
||||||
text:"Photos"
|
|
||||||
visible:contact.location=="Friendica"? 1:0
|
|
||||||
onClicked:{contactComponent.state="";
|
|
||||||
root.currentIndex=2;
|
|
||||||
fotostab.active=true;
|
|
||||||
root.fotoSignal(contact) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Button{
|
|
||||||
id:messagebutton
|
|
||||||
text:"Messages"
|
|
||||||
onClicked:{contactComponent.state="";
|
|
||||||
root.currentIndex=0;
|
|
||||||
newstab.active=true;
|
|
||||||
root.messageSignal(contact.id) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Button{
|
|
||||||
id:dmbutton
|
|
||||||
visible: contact.following=="true"?true:false
|
|
||||||
text: "DM"
|
|
||||||
onClicked:{contactComponent.state="";
|
|
||||||
root.currentIndex=0;
|
|
||||||
newstab.active=true;
|
|
||||||
root.directmessageSignal(contact.screen_name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Button{
|
|
||||||
id: closeButton
|
|
||||||
text: "close"
|
|
||||||
onClicked:{contactComponent.state=""}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
states: [
|
|
||||||
State {
|
|
||||||
name: "large"
|
|
||||||
PropertyChanges { target: namelabel; font.pixelSize: 4*mm; width:friendsTabView.width-4*mm; text:Qt.atob(contact.name)+" (@"+contact.screen_name+")"}
|
|
||||||
PropertyChanges { target: contactComponent; z: 2 }
|
|
||||||
PropertyChanges { target: wrapper; width:friendsTabView.width-3*mm;height:friendsTabView.height-20*mm}
|
|
||||||
PropertyChanges { target: photoImage; width:15*mm;height:15*mm }
|
|
||||||
PropertyChanges { target:contactComponent.GridView.view;contentY:contactComponent.y;contentX:contactComponent.x;interactive:false}
|
|
||||||
PropertyChanges { target: detailsrectangle; opacity:1 }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,133 +0,0 @@
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick.Controls 1.3
|
|
||||||
import "qrc:/js/service.js" as Service
|
|
||||||
import "qrc:/js/layout.js" as Layoutjs
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: friendComponent
|
|
||||||
property date createdAtDate: new Date(friend.created_at)
|
|
||||||
Rectangle {
|
|
||||||
id: wrapper
|
|
||||||
width: 16*mm
|
|
||||||
height: 15*mm
|
|
||||||
border.color: "grey"
|
|
||||||
color:"white"
|
|
||||||
Image {
|
|
||||||
id: photoImage
|
|
||||||
x:1
|
|
||||||
y:1
|
|
||||||
width: 10*mm
|
|
||||||
height:10*mm
|
|
||||||
source:"file://"+ friend.profile_image
|
|
||||||
}
|
|
||||||
|
|
||||||
Label {
|
|
||||||
id: namelabel
|
|
||||||
x: 1
|
|
||||||
width: wrapper.width-4
|
|
||||||
height: 3*mm
|
|
||||||
text: friend.screen_name
|
|
||||||
anchors.topMargin: 0
|
|
||||||
anchors.left: photoImage.left
|
|
||||||
color: "#303030"
|
|
||||||
font.pixelSize: 3*mm
|
|
||||||
anchors.top: photoImage.bottom
|
|
||||||
}
|
|
||||||
Button{
|
|
||||||
id:infobutton
|
|
||||||
width: 5*mm
|
|
||||||
height: 5*mm
|
|
||||||
text:"?"
|
|
||||||
anchors.left: photoImage.right
|
|
||||||
anchors.leftMargin: 3
|
|
||||||
anchors.topMargin: 3
|
|
||||||
anchors.top: parent.top
|
|
||||||
onClicked:{
|
|
||||||
//print("State: "+ friendComponent.state);
|
|
||||||
friendComponent.state="large"}
|
|
||||||
}
|
|
||||||
Rectangle{
|
|
||||||
id: detailsrectangle
|
|
||||||
anchors.top: namelabel.bottom
|
|
||||||
anchors.topMargin: 2*mm
|
|
||||||
opacity: 0
|
|
||||||
|
|
||||||
Flickable{
|
|
||||||
id:namelabelflickable
|
|
||||||
width: root.width-10*mm
|
|
||||||
height:wrapper.height-27*mm-3
|
|
||||||
boundsBehavior:Flickable.StopAtBounds
|
|
||||||
flickableDirection:Flickable.VerticalFlick
|
|
||||||
contentWidth:width
|
|
||||||
contentHeight: namelabeltext.height
|
|
||||||
clip:true
|
|
||||||
Text{
|
|
||||||
id:namelabeltext
|
|
||||||
//anchors.top: parent.top
|
|
||||||
width: namelabelflickable.width
|
|
||||||
height: implicitHeight
|
|
||||||
font.pixelSize: 3*mm
|
|
||||||
textFormat:Text.RichText
|
|
||||||
wrapMode: Text.Wrap
|
|
||||||
text:"<b>"+qsTr("Description")+": </b> "+Qt.atob(friend.description)+"<br> <b>"+qsTr("Server Type")+":</b> "+friend.location+"<br> <b>"+qsTr("Posts")+":</b> "+friend.statuses_count+
|
|
||||||
"<br> <b>"+qsTr("URL")+":</b> <a href='"+ friend.url+"'>"+friend.url+"</a><br> <b>"+
|
|
||||||
qsTr("Created at")+":</b> "+createdAtDate.toLocaleString(Qt.locale())
|
|
||||||
onLinkActivated: {
|
|
||||||
Qt.openUrlExternally(link)}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Row{
|
|
||||||
anchors.top: namelabelflickable.bottom
|
|
||||||
anchors.topMargin: 2*mm
|
|
||||||
spacing:4
|
|
||||||
|
|
||||||
Button{
|
|
||||||
id:photobutton
|
|
||||||
text:"Photos"
|
|
||||||
visible:friend.location=="Friendica"? 1:0
|
|
||||||
onClicked:{root.currentIndex=2;
|
|
||||||
fotostab.active=true;
|
|
||||||
root.fotoSignal(friend) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Button{
|
|
||||||
id:messagebutton
|
|
||||||
text:"Messages"
|
|
||||||
onClicked:{root.currentIndex=0;
|
|
||||||
newstab.active=true;
|
|
||||||
root.messageSignal(friend.id) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Button{
|
|
||||||
id:dmbutton
|
|
||||||
visible: friend.following=="true"?true:false
|
|
||||||
text: "DM"
|
|
||||||
onClicked:{root.currentIndex=0;
|
|
||||||
newstab.active=true;
|
|
||||||
root.directmessageSignal(friend.screen_name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Button{
|
|
||||||
id: closeButton
|
|
||||||
text: "close"
|
|
||||||
onClicked:{friendComponent.state=""}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
states: [
|
|
||||||
State {
|
|
||||||
name: "large"
|
|
||||||
PropertyChanges { target: namelabel; font.pixelSize: 4*mm; width:friendsTabView.width-4*mm; text:Qt.atob(friend.name)+" (@"+friend.screen_name+")"}
|
|
||||||
PropertyChanges { target: friendComponent; z: 2 }
|
|
||||||
PropertyChanges { target: wrapper; width:friendsTabView.width-3*mm;height:friendsTabView.height-14*mm}
|
|
||||||
PropertyChanges { target: photoImage; width:15*mm;height:15*mm }
|
|
||||||
PropertyChanges { target:friendComponent.GridView.view;contentY:friendComponent.y;contentX:friendComponent.x;interactive:false}
|
|
||||||
PropertyChanges { target: detailsrectangle; opacity:1 }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,126 +0,0 @@
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick.Dialogs 1.2
|
|
||||||
import QtQuick.Controls 1.4
|
|
||||||
import QtQml.Models 2.1
|
|
||||||
import "qrc:/js/service.js" as Service
|
|
||||||
import "qrc:/js/helper.js" as Helperjs
|
|
||||||
|
|
||||||
Rectangle{
|
|
||||||
id:permissionDialog
|
|
||||||
width: 80*mm
|
|
||||||
height:root.height/3
|
|
||||||
|
|
||||||
Text{
|
|
||||||
x:0.5*mm
|
|
||||||
y:0.5*mm
|
|
||||||
text: "Contacts"
|
|
||||||
}
|
|
||||||
ListView {
|
|
||||||
id: contactView
|
|
||||||
x:0.5*mm
|
|
||||||
y:5.5*mm
|
|
||||||
width: 39*mm
|
|
||||||
height:permissionDialog.height-14*mm
|
|
||||||
clip: true
|
|
||||||
spacing: 0
|
|
||||||
model: contactModel
|
|
||||||
delegate: contactItem
|
|
||||||
}
|
|
||||||
|
|
||||||
ListModel{id: contactModel}
|
|
||||||
Component{
|
|
||||||
id:contactItem
|
|
||||||
|
|
||||||
Rectangle{
|
|
||||||
id:contactitemRect
|
|
||||||
width:contactView.width
|
|
||||||
height: 5*mm
|
|
||||||
property string contactstatus:""
|
|
||||||
color: "light blue"
|
|
||||||
border.color:"grey"
|
|
||||||
Text{
|
|
||||||
color:"grey"
|
|
||||||
text:contact.screen_name
|
|
||||||
}
|
|
||||||
onContactstatusChanged:
|
|
||||||
{ if(contactstatus=="positive"){contactsitemRect.color="green"} else if (contactstatus=="negative"){contactsitemRect.color= "red"} else{contactsitemRect.color= "white"}}
|
|
||||||
MouseArea{
|
|
||||||
anchors.fill: parent}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Text{
|
|
||||||
x:20*mm
|
|
||||||
y:0.5*mm
|
|
||||||
text: "Groups"
|
|
||||||
}
|
|
||||||
ListView {
|
|
||||||
id: groupView
|
|
||||||
x:20*mm
|
|
||||||
y:5.5*mm
|
|
||||||
width: 19*mm
|
|
||||||
height:permissionDialog-8*mm
|
|
||||||
clip: true
|
|
||||||
spacing: 0
|
|
||||||
model: groupModel
|
|
||||||
delegate: groupItem
|
|
||||||
}
|
|
||||||
|
|
||||||
ListModel{id: groupModel}
|
|
||||||
Component{
|
|
||||||
id:groupItem
|
|
||||||
|
|
||||||
Rectangle{
|
|
||||||
id:groupitemRect
|
|
||||||
width:groupView.width
|
|
||||||
height: 5*mm
|
|
||||||
property string groupstatus:""
|
|
||||||
color: "white"
|
|
||||||
border.color:"grey"
|
|
||||||
Text{
|
|
||||||
color:"grey"
|
|
||||||
text:group.groupname
|
|
||||||
}
|
|
||||||
onGroupstatusChanged:
|
|
||||||
{ if(groupstatus=="positive"){groupitemRect.color="green"} else if (groupstatus=="negative"){groupitemRect.color= "red"} else{groupitemRect.color= "white"}}
|
|
||||||
MouseArea{
|
|
||||||
anchors.fill: parent
|
|
||||||
onClicked:{
|
|
||||||
if(groupModel.get(index).groupstatus=="neutral"){
|
|
||||||
groupModel.setProperty(index,"groupstatus","positive")}
|
|
||||||
else if (groupModel.get(index).groupstatus=="positive"){
|
|
||||||
groupModel.setProperty(index,"groupstatus","negative")}
|
|
||||||
else{groupModel.setProperty(index,"groupstatus","neutral")}
|
|
||||||
}}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Button{
|
|
||||||
anchors.horizontalCenter: parent.hoizontalCenter
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
anchors.bottomMargin:1
|
|
||||||
text:qsTr("Done")
|
|
||||||
onClicked:{var group_allow=[];
|
|
||||||
for (var i=0;i<groupModel.count;i++)
|
|
||||||
{if (groupModel.get(i).groupstatus=="positive"){
|
|
||||||
group_allow.append(groupModel.get(i).groupname)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print("groups"+JSON.stringify(group_allow))
|
|
||||||
permissionDialog.destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Component.onCompleted:{
|
|
||||||
print("permissiondialog completed");
|
|
||||||
Helperjs.readData(db,"contacts",login.username,function(contacts){
|
|
||||||
for (var name in contacts){
|
|
||||||
print("contact: "+JSON.stringify(contacts[name]));
|
|
||||||
contactModel.append({"contact":contacts[name]})
|
|
||||||
}},"isFriend",1);
|
|
||||||
|
|
||||||
Helperjs.readData(db,"groups",login.username,function(owngroups){
|
|
||||||
for (var number in owngroups){
|
|
||||||
groupModel.append({"group":owngroup[number]})
|
|
||||||
}});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick.Dialogs 1.2
|
|
||||||
import QtQuick.Controls 1.2
|
|
||||||
|
|
||||||
Item {
|
|
||||||
Rectangle{
|
|
||||||
property string photofile:"../images/Update.png"
|
|
||||||
color: "grey"
|
|
||||||
|
|
||||||
FileDialog {
|
|
||||||
id: fileDialog
|
|
||||||
title: "Please choose a file"
|
|
||||||
folder: shortcuts.pictures
|
|
||||||
selectMultiple: true
|
|
||||||
onAccepted: {
|
|
||||||
photofile=fileDialog.fileUrls[0];
|
|
||||||
console.log("You chose: " + fileDialog.fileUrls)
|
|
||||||
// img.src=file;
|
|
||||||
}
|
|
||||||
onRejected: {
|
|
||||||
console.log("Canceled")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Component.onCompleted: {fileDialog.open()}
|
|
||||||
|
|
||||||
Image {
|
|
||||||
id: photoFromFilesystem
|
|
||||||
x: 20;y:50
|
|
||||||
height: 200
|
|
||||||
fillMode: Image.PreserveAspectFit
|
|
||||||
source: photofile
|
|
||||||
|
|
||||||
onStatusChanged:{
|
|
||||||
if (photoFromFilesystem.status == Image.Ready) {
|
|
||||||
Layoutjs.showFriends(db)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Button {
|
|
||||||
text: "Upload"
|
|
||||||
onClicked:{
|
|
||||||
var login=Service.readActiveConfig(db);
|
|
||||||
Service.uploadMedia(login,photofile, function(returnvalue){print("Upload return"+returnvalue)})
|
|
||||||
}}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,7 +4,7 @@ import QtQuick.Controls 1.2
|
||||||
import "qrc:/js/service.js" as Service
|
import "qrc:/js/service.js" as Service
|
||||||
import "qrc:/js/layout.js" as Layoutjs
|
import "qrc:/js/layout.js" as Layoutjs
|
||||||
import "qrc:/js/helper.js" as Helperjs
|
import "qrc:/js/helper.js" as Helperjs
|
||||||
import "qrc:/qml"
|
import "qrc:/qml/configqml"
|
||||||
|
|
||||||
StackView{
|
StackView{
|
||||||
id: configStack
|
id: configStack
|
||||||
|
@ -192,7 +192,9 @@ onCurrentIndexChanged:{
|
||||||
Service.readConfig(db,function(userconfig){Service.getServerConfig(userconfig,configBackground, function(obj){
|
Service.readConfig(db,function(userconfig){Service.getServerConfig(userconfig,configBackground, function(obj){
|
||||||
var serverString=obj;
|
var serverString=obj;
|
||||||
var serverconfigObject=Qt.createQmlObject(serverString,configBackground,"serverconfigOutput");
|
var serverconfigObject=Qt.createQmlObject(serverString,configBackground,"serverconfigOutput");
|
||||||
usermodel.append({text:username.text});
|
Helperjs.readField("username",root.db,"config","",function(users){
|
||||||
|
if(users.indexOf(username.text)==-1){usermodel.append({text:username.text})}});
|
||||||
|
isActiveField.text="yes"
|
||||||
//reset values
|
//reset values
|
||||||
root.login=userconfig;
|
root.login=userconfig;
|
||||||
root.contactlist=[];
|
root.contactlist=[];
|
||||||
|
@ -232,7 +234,7 @@ onCurrentIndexChanged:{
|
||||||
x: root.width/2+14*mm; y: mm; width: 5*mm; height: 5*mm;
|
x: root.width/2+14*mm; y: mm; width: 5*mm; height: 5*mm;
|
||||||
text: "?"
|
text: "?"
|
||||||
onClicked:{
|
onClicked:{
|
||||||
configStack.push({item:"qrc:/qml/InfoBox.qml"});
|
configStack.push({item:"qrc:/qml/configqml/InfoBox.qml"});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
import QtQuick 2.0
|
||||||
|
import QtQuick.Controls 1.3
|
||||||
|
import "qrc:/js/layout.js" as Layoutjs
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: contactComponent
|
||||||
|
property var createdAtDate: new Date(contact.created_at)
|
||||||
|
property var linkUrl: contact.network!=="dfrn"?contact.url:contact.url.replace("profile","dfrn_request")
|
||||||
|
Rectangle {
|
||||||
|
id: wrapper
|
||||||
|
width: 16*mm
|
||||||
|
height: 15*mm
|
||||||
|
border.color: "grey"
|
||||||
|
color:"white"
|
||||||
|
Image {
|
||||||
|
id: photoImage
|
||||||
|
x:1
|
||||||
|
y:1
|
||||||
|
width: 10*mm
|
||||||
|
height:10*mm
|
||||||
|
source:(contact.profile_image!="")? "file://"+contact.profile_image : contact.profile_image_url
|
||||||
|
onStatusChanged: if (photoImage.status == Image.Error) {source="qrc:/images/defaultcontact.jpg"}
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
id: namelabel
|
||||||
|
x: 1
|
||||||
|
width: wrapper.width-4
|
||||||
|
height: 3*mm
|
||||||
|
text: contact.screen_name
|
||||||
|
elide:Text.ElideRight
|
||||||
|
anchors.topMargin: 0
|
||||||
|
anchors.left: photoImage.left
|
||||||
|
color: "#303030"
|
||||||
|
font.pixelSize: 3*mm
|
||||||
|
anchors.top: photoImage.bottom
|
||||||
|
}
|
||||||
|
Button{
|
||||||
|
id:infobutton
|
||||||
|
width: 5*mm
|
||||||
|
height: 5*mm
|
||||||
|
text:"?"
|
||||||
|
anchors.left: photoImage.right
|
||||||
|
anchors.leftMargin: 3
|
||||||
|
anchors.topMargin: 3
|
||||||
|
anchors.top: parent.top
|
||||||
|
onClicked:{
|
||||||
|
contactComponent.state="large";
|
||||||
|
var component = Qt.createComponent("qrc:/qml/contactqml/ContactDetailsComponent.qml");
|
||||||
|
if (component.status== Component.Ready){
|
||||||
|
var contactDetails = component.createObject(wrapper,{"contact": contact})}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
states: [
|
||||||
|
State {
|
||||||
|
name: "large"
|
||||||
|
PropertyChanges { target: namelabel; font.pixelSize: 4*mm; width:friendsTabView.width-4*mm; text:Qt.atob(contact.name)+" (@"+contact.screen_name+")"}
|
||||||
|
PropertyChanges { target: contactComponent; z: 2 }
|
||||||
|
PropertyChanges { target: wrapper; width:friendsTabView.width-3*mm;height:friendsTabView.height-20*mm}
|
||||||
|
PropertyChanges { target: photoImage; width:15*mm;height:15*mm }
|
||||||
|
PropertyChanges { target:contactComponent.GridView.view;contentY:contactComponent.y;contentX:contactComponent.x;interactive:false}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
import QtQuick 2.0
|
||||||
|
import QtQuick.Controls 1.3
|
||||||
|
|
||||||
|
Rectangle{
|
||||||
|
id: detailsrectangle
|
||||||
|
anchors.top: namelabel.bottom
|
||||||
|
anchors.topMargin: 2*mm
|
||||||
|
//opacity: 0
|
||||||
|
|
||||||
|
Flickable{
|
||||||
|
id:namelabelflickable
|
||||||
|
width: root.width-10*mm
|
||||||
|
height:friendsTabView.height-55*mm
|
||||||
|
boundsBehavior:Flickable.StopAtBounds
|
||||||
|
flickableDirection:Flickable.VerticalFlick
|
||||||
|
contentWidth:width
|
||||||
|
contentHeight: namelabeltext.height
|
||||||
|
clip:true
|
||||||
|
Text{
|
||||||
|
id:namelabeltext
|
||||||
|
width: namelabelflickable.width
|
||||||
|
height: implicitHeight
|
||||||
|
font.pixelSize: 3*mm
|
||||||
|
textFormat:Text.RichText
|
||||||
|
wrapMode: Text.Wrap
|
||||||
|
text:"<b>"+qsTr("Description")+": </b> "+Qt.atob(contact.description)+"<br> <b>"+qsTr("Server Type")+":</b> "+contact.location+"<br> <b>"+qsTr("Posts")+":</b> "+contact.statuses_count+
|
||||||
|
"<br> <b>"+qsTr("URL")+":</b> <a href='"+ linkUrl+"'>"+linkUrl+"</a><br> <b>"+
|
||||||
|
qsTr("Created at")+":</b> "+createdAtDate.toLocaleString(Qt.locale())
|
||||||
|
onLinkActivated: {
|
||||||
|
Qt.openUrlExternally(link)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Row{
|
||||||
|
anchors.top: namelabelflickable.bottom
|
||||||
|
anchors.topMargin: 2*mm
|
||||||
|
spacing:4
|
||||||
|
|
||||||
|
Button{
|
||||||
|
id:photobutton
|
||||||
|
text:"Photos"
|
||||||
|
visible:contact.location=="Friendica"? 1:0
|
||||||
|
onClicked:{contactComponent.state="";detailsrectangle.destroy();
|
||||||
|
root.currentIndex=2;
|
||||||
|
fotostab.active=true;
|
||||||
|
root.fotoSignal(contact) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Button{
|
||||||
|
id:messagebutton
|
||||||
|
text:"Messages"
|
||||||
|
onClicked:{contactComponent.state="";detailsrectangle.destroy();
|
||||||
|
root.currentIndex=0;
|
||||||
|
newstab.active=true;
|
||||||
|
root.messageSignal(contact.id) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Button{
|
||||||
|
id:dmbutton
|
||||||
|
visible: contact.following=="true"?true:false
|
||||||
|
text: "DM"
|
||||||
|
onClicked:{contactComponent.state="";detailsrectangle.destroy();
|
||||||
|
root.currentIndex=0;
|
||||||
|
newstab.active=true;
|
||||||
|
root.directmessageSignal(contact.screen_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Button{
|
||||||
|
id: closeButton
|
||||||
|
text: "close"
|
||||||
|
onClicked:{contactComponent.state="";detailsrectangle.destroy()}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,7 +5,7 @@ import QtQuick.Controls.Styles 1.4
|
||||||
import "qrc:/js/service.js" as Service
|
import "qrc:/js/service.js" as Service
|
||||||
import "qrc:/js/helper.js" as Helperjs
|
import "qrc:/js/helper.js" as Helperjs
|
||||||
import "qrc:/js/news.js" as Newsjs
|
import "qrc:/js/news.js" as Newsjs
|
||||||
import "qrc:/qml"
|
import "qrc:/qml/contactqml"
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
y:1
|
y:1
|
|
@ -17,9 +17,9 @@ TabView{
|
||||||
id:root
|
id:root
|
||||||
tabPosition: Qt.BottomEdge
|
tabPosition: Qt.BottomEdge
|
||||||
width: Screen.desktopAvailableWidth
|
width: Screen.desktopAvailableWidth
|
||||||
height: Screen.desktopAvailableHeight
|
height: Screen.desktopAvailableHeight
|
||||||
|
|
||||||
property var db: ["Photos", "1.0", "Stores Friendica data", 100000000]
|
property var db: ["Friendiqa", "1.0", "Stores Friendica data", 100000000]
|
||||||
property var login: Service.readActiveConfig(db)
|
property var login: Service.readActiveConfig(db)
|
||||||
property var contactlist: []
|
property var contactlist: []
|
||||||
property real mm: Screen.pixelDensity
|
property real mm: Screen.pixelDensity
|
||||||
|
@ -44,7 +44,7 @@ TabView{
|
||||||
updateContactInDB(login,db,newContacts[currentContact].isFriend,newContacts[currentContact])}
|
updateContactInDB(login,db,newContacts[currentContact].isFriend,newContacts[currentContact])}
|
||||||
}
|
}
|
||||||
onCurrentContactChanged:{// download next contact image after photoplaceholder is finished saving and update db
|
onCurrentContactChanged:{// download next contact image after photoplaceholder is finished saving and update db
|
||||||
//print("Current contact"+JSON.stringify(newContacts[currentContact]));
|
//print("Current contact"+JSON.stringify(newContacts[currentContact])+newContacts.length);
|
||||||
if(currentContact<newContacts.length){
|
if(currentContact<newContacts.length){
|
||||||
updateContactInDB(login,db,newContacts[currentContact].isFriend,newContacts[currentContact])}
|
updateContactInDB(login,db,newContacts[currentContact].isFriend,newContacts[currentContact])}
|
||||||
else if(currentContact==newContacts.length){//newImagesProgress.visible=false;
|
else if(currentContact==newContacts.length){//newImagesProgress.visible=false;
|
||||||
|
@ -67,22 +67,23 @@ TabView{
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateContactInDB(login,database,isFriend,contact){// for newstab and friendstab
|
function updateContactInDB(login,database,isFriend,contact){// for newstab and friendstab
|
||||||
var imagename=login.imagestore+"contacts/"+contact.screen_name.trim()+".jpg";
|
var suffix=contact.profile_image_url.substring(contact.profile_image_url.lastIndexOf("."), contact.profile_image_url.length);
|
||||||
if (isFriend==1){
|
var imagename=login.imagestore+"contacts/"+contact.screen_name.trim()+suffix;
|
||||||
|
// if (isFriend==1){
|
||||||
xhr.setUrl(Qt.resolvedUrl(contact.profile_image_url));
|
xhr.setUrl(Qt.resolvedUrl(contact.profile_image_url));
|
||||||
xhr.setFilename(imagename);
|
xhr.setFilename(imagename);
|
||||||
xhr.download();
|
xhr.download();
|
||||||
}
|
//}
|
||||||
var db=LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
var db=LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||||
var result;
|
var result;
|
||||||
db.transaction( function(tx) {
|
db.transaction( function(tx) {
|
||||||
result = tx.executeSql('SELECT * from contacts where id = '+contact.id); // check for news id
|
result = tx.executeSql('SELECT * from contacts where username="'+root.login.username+'" AND id = '+contact.id); // check for news id
|
||||||
if(result.rows.length === 1) {// use update
|
if(result.rows.length === 1) {// use update
|
||||||
result = tx.executeSql('UPDATE contacts SET username="'+login.username+'", id='+contact.id+', name="'+Qt.btoa(contact.name)+'", screen_name="'+contact.screen_name+'", location="'+contact.location+'", profile_image_url="'+contact.profile_image_url+'", description="'+Qt.btoa(contact.description)+'", profile_image="'+imagename+'", url="'+contact.url+'" , protected="'+contact.protected+'", followers_count='+contact.followers_count+', friends_count='+contact.friends_count+', created_at="'+ Date.parse(Newsjs.cleanDate(contact.created_at))+'", favourites_count="'+contact.favorites_count+'", utc_offset="'+contact.utc_offset+'", time_zone="'+contact.time_zone+'", statuses_count='+contact.statuses_count+', following="'+contact.following+'", verified ="'+contact.verified+'", statusnet_blocking="'+contact.statusnet_blocking+'", notifications="'+contact.notifictions+'", statusnet_profile_url="'+contact.statusnet_profile_url+'", cid='+contact.cid+', network="'+contact.network+'", isFriend='+isFriend+' where id='+contact.id);
|
result = tx.executeSql('UPDATE contacts SET username="'+login.username+'", id='+contact.id+', name="'+Qt.btoa(contact.name)+'", screen_name="'+contact.screen_name+'", location="'+contact.location+'", profile_image_url="'+contact.profile_image_url+'", description="'+Qt.btoa(contact.description)+'", profile_image="'+imagename+'", url="'+contact.url+'" , protected="'+contact.protected+'", followers_count='+contact.followers_count+', friends_count='+contact.friends_count+', created_at="'+ Date.parse(Newsjs.cleanDate(contact.created_at))+'", favourites_count="'+contact.favorites_count+'", utc_offset="'+contact.utc_offset+'", time_zone="'+contact.time_zone+'", statuses_count='+contact.statuses_count+', following="'+contact.following+'", verified ="'+contact.verified+'", statusnet_blocking="'+contact.statusnet_blocking+'", notifications="'+contact.notifictions+'", statusnet_profile_url="'+contact.statusnet_profile_url+'", cid='+contact.cid+', network="'+contact.network+'", isFriend='+isFriend+' where username="'+root.login.username+'" AND id='+contact.id);
|
||||||
} else {// use insert
|
} else {// use insert
|
||||||
result = tx.executeSql('INSERT INTO contacts VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,contact.id,Qt.btoa(contact.name),contact.screen_name,contact.location,contact.profile_image_url, Qt.btoa(contact.description),imagename,contact.url,contact.protected,contact.followers_count, contact.friends_count,Date.parse(Newsjs.cleanDate(contact.created_at)),contact.favorites_count,contact.utc_offset,contact.time_zone,contact.statuses_count,contact.following,contact.verfied,contact.statusnet_blocking,contact.notifications,contact.statusnet_profile_url,contact.cid,contact.network,isFriend]);}
|
result = tx.executeSql('INSERT INTO contacts VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,contact.id,Qt.btoa(contact.name),contact.screen_name,contact.location,contact.profile_image_url, Qt.btoa(contact.description),imagename,contact.url,contact.protected,contact.followers_count, contact.friends_count,Date.parse(Newsjs.cleanDate(contact.created_at)),contact.favorites_count,contact.utc_offset,contact.time_zone,contact.statuses_count,contact.following,contact.verfied,contact.statusnet_blocking,contact.notifications,contact.statusnet_profile_url,contact.cid,contact.network,isFriend]);}
|
||||||
});
|
});
|
||||||
if (isFriend!=1){root.currentContact=root.currentContact+1}
|
//if (isFriend!=1){root.currentContact=root.currentContact+1}
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections{
|
Connections{
|
||||||
|
@ -91,7 +92,14 @@ TabView{
|
||||||
}
|
}
|
||||||
Connections{
|
Connections{
|
||||||
target:xhr
|
target:xhr
|
||||||
onError:{print("Error"+data)}
|
onError:{print("Error"+data);
|
||||||
|
var database=LocalStorage.openDatabaseSync(root.db[0],root.db[1],root.db[2],root.db[3]);
|
||||||
|
var result;
|
||||||
|
database.transaction( function(tx) {
|
||||||
|
print("Error for "+JSON.stringify(newContacts[currentContact]));
|
||||||
|
//print('UPDATE contacts SET profile_image="" where username="'+root.login.username+'" AND id = '+newContacts[currentContact].id);
|
||||||
|
result = tx.executeSql('UPDATE contacts SET profile_image="" where username="'+root.login.username+'" AND id = '+newContacts[currentContact].id);
|
||||||
|
root.currentContact=root.currentContact+1})}
|
||||||
}
|
}
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (login==""){Service.initDatabase(db)}
|
if (login==""){Service.initDatabase(db)}
|
||||||
|
@ -121,24 +129,24 @@ style: TabViewStyle {
|
||||||
title: qsTr("News")
|
title: qsTr("News")
|
||||||
id: newstab
|
id: newstab
|
||||||
property string newstabStatus:"news"
|
property string newstabStatus:"news"
|
||||||
source: "qrc:/qml/NewsTab.qml"
|
source: "qrc:/qml/newsqml/NewsTab.qml"
|
||||||
}
|
}
|
||||||
|
|
||||||
Tab{
|
Tab{
|
||||||
title: qsTr("Contacts")
|
title: qsTr("Contacts")
|
||||||
id: friendstab
|
id: friendstab
|
||||||
source: "qrc:/qml/FriendsTab.qml"
|
source: "qrc:/qml/contactqml/FriendsTab.qml"
|
||||||
}
|
}
|
||||||
Tab{
|
Tab{
|
||||||
title: qsTr("Photos")
|
title: qsTr("Photos")
|
||||||
id: fotostab
|
id: fotostab
|
||||||
source: "qrc:/qml/PhotoTab.qml"
|
source: "qrc:/qml/photoqml/PhotoTab.qml"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Tab{
|
Tab{
|
||||||
title: qsTr("Config")
|
title: qsTr("Config")
|
||||||
source: "qrc:/qml/ConfigTab.qml"
|
source: "qrc:/qml/configqml/ConfigTab.qml"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,20 +17,23 @@ Item{
|
||||||
property int directmessage: 0;
|
property int directmessage: 0;
|
||||||
property var contacts: []
|
property var contacts: []
|
||||||
property var groups: []
|
property var groups: []
|
||||||
property string contact_allow:""
|
property var contact_allow:[]
|
||||||
property string contact_deny:""
|
property var contact_deny:[]
|
||||||
property string group_allow:""
|
property var group_allow:[]
|
||||||
property string group_deny:""
|
property var group_deny:[]
|
||||||
|
|
||||||
function statusUpdate(title,status,in_reply_to_status_id,attachImageURL) {
|
function statusUpdate(title,status,in_reply_to_status_id,attachImageURL) {
|
||||||
xhr.url= login.server + "/api/statuses/update.xml";
|
xhr.url= login.server + "/api/statuses/update.xml";
|
||||||
xhr.setLogin(login.username+":"+Qt.atob(login.password));
|
xhr.setLogin(login.username+":"+Qt.atob(login.password));
|
||||||
print("login: "+login.username+":"+Qt.atob(login.password));
|
|
||||||
xhr.clearParams();
|
xhr.clearParams();
|
||||||
xhr.setParam("source", "Friendiqa");
|
xhr.setParam("source", "Friendiqa");
|
||||||
xhr.setParam("status", status);
|
xhr.setParam("status", status);
|
||||||
if (parentId!="") {xhr.setParam("in_reply_to_status_id", parentid)};
|
if (parentId!="") {xhr.setParam("in_reply_to_status_id", parentId)};
|
||||||
if (title!=="") {xhr.setParam("title", title)};
|
if (title!=="") {xhr.setParam("title", title)};
|
||||||
|
if (group_allow.length>0) {xhr.setParam("group_allow", Helperjs.cleanArray(group_allow))};
|
||||||
|
if (group_deny.length>0) {xhr.setParam("group_deny", Helperjs.cleanArray(group_deny))};
|
||||||
|
if (contact_allow.length>0) {xhr.setParam("contact_allow", Helperjs.cleanArray(contact_allow))};
|
||||||
|
if (contact_deny.length>0) {xhr.setParam("contact_deny", Helperjs.cleanArray(contact_deny))};
|
||||||
if (attachImageURL!=="") {xhr.setImageFileParam("media", attachImageURL )};
|
if (attachImageURL!=="") {xhr.setImageFileParam("media", attachImageURL )};
|
||||||
xhr.post();
|
xhr.post();
|
||||||
}
|
}
|
||||||
|
@ -63,7 +66,7 @@ Item{
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: 30*mm
|
height: 30*mm
|
||||||
wrapMode: TextEdit.Wrap
|
wrapMode: TextEdit.Wrap
|
||||||
textFormat: TextEdit.RichText
|
textFormat: TextEdit.PlainText
|
||||||
}
|
}
|
||||||
|
|
||||||
Row{
|
Row{
|
||||||
|
@ -118,12 +121,11 @@ Item{
|
||||||
Row{
|
Row{
|
||||||
spacing:2
|
spacing:2
|
||||||
Button{
|
Button{
|
||||||
|
visible: (directmessage==1)?false:true
|
||||||
text:qsTr("Permissions")
|
text:qsTr("Permissions")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
var component = Qt.createComponent("qrc:/qml/PermissionDialog.qml");
|
var component = Qt.createComponent("qrc:/qml/newsqml/PermissionDialog.qml");
|
||||||
var sprite = component.createObject(messageColumn);
|
var permissions = component.createObject(messageColumn);
|
||||||
if (sprite == null) { // Error Handling
|
|
||||||
console.log("Error creating object"); }
|
|
||||||
}}
|
}}
|
||||||
Button {
|
Button {
|
||||||
id: attachButton
|
id: attachButton
|
||||||
|
@ -169,7 +171,9 @@ Item{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Keys.onReleased: {if (event.key === Qt.Key_Back && stackView.depth > 1) {
|
||||||
|
stackView.pop(); event.accepted = true;
|
||||||
|
}}
|
||||||
FileDialog {
|
FileDialog {
|
||||||
id: imageAttachmentDialog
|
id: imageAttachmentDialog
|
||||||
title: "Please choose a picture"
|
title: "Please choose a picture"
|
|
@ -22,7 +22,7 @@ Item {
|
||||||
|
|
||||||
function onDirectMessage(friend){
|
function onDirectMessage(friend){
|
||||||
print(root.login.server);
|
print(root.login.server);
|
||||||
newsStack.push({item:"qrc:/qml/MessageSend.qml",properties:{"reply_to_user": friend,"directmessage":1,"login":root.login}});
|
newsStack.push({item:"qrc:/qml/newsqml/MessageSend.qml",properties:{"reply_to_user": friend,"directmessage":1,"login":root.login}});
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanNews(database){
|
function cleanNews(database){
|
||||||
|
@ -43,9 +43,16 @@ Item {
|
||||||
id: newsStack
|
id: newsStack
|
||||||
anchors.fill:parent
|
anchors.fill:parent
|
||||||
focus: true
|
focus: true
|
||||||
Keys.onReleased: if (event.key === Qt.Key_Back && stackView.depth > 1) {
|
Keys.onReleased: {if (event.key === Qt.Key_Back && stackView.depth > 1) {
|
||||||
stackView.pop(); event.accepted = true;
|
stackView.pop(); event.accepted = true;
|
||||||
}
|
}
|
||||||
|
else if(event.key === Qt.Key_Back &&newstabStatus=="conversation"){
|
||||||
|
newstabStatus="news"
|
||||||
|
newsModel.clear();
|
||||||
|
Newsjs.newsfromdb(root.db,root.login.username, function(dbnews){
|
||||||
|
showNews(dbnews)
|
||||||
|
})}
|
||||||
|
}
|
||||||
initialItem:Rectangle {
|
initialItem:Rectangle {
|
||||||
y:1
|
y:1
|
||||||
color: "white"
|
color: "white"
|
||||||
|
@ -68,10 +75,9 @@ Item {
|
||||||
else if (currentIndex==1){
|
else if (currentIndex==1){
|
||||||
newsBusy.running=true;
|
newsBusy.running=true;
|
||||||
Newsjs.requestFavorites(root.login,db,root,function(news){
|
Newsjs.requestFavorites(root.login,db,root,function(news){
|
||||||
JSON.stringify("Favorites: "+news);
|
|
||||||
Newsjs.storeNews(root.login,root.db,news,root,function(){
|
Newsjs.storeNews(root.login,root.db,news,root,function(){
|
||||||
Newsjs.favoritesfromdb(db,root.login.username,function(newsarray){
|
Newsjs.favoritesfromdb(db,root.login.username,function(newsarray){
|
||||||
JSON.stringify("FavoritesArray: "+newsarray);showNews(newsarray)
|
showNews(newsarray)
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -89,7 +95,7 @@ Item {
|
||||||
Helperjs.readData(root.db,"groups",root.login.username,function(groupobject){
|
Helperjs.readData(root.db,"groups",root.login.username,function(groupobject){
|
||||||
groups=groupobject});
|
groups=groupobject});
|
||||||
Helperjs.readData(root.db,"contacts",root.login.username,function(friends){
|
Helperjs.readData(root.db,"contacts",root.login.username,function(friends){
|
||||||
newsStack.push({item:"qrc:/qml/MessageSend.qml",properties:{"contacts": friends,"login":root.login}})
|
newsStack.push({item:"qrc:/qml/newsqml/MessageSend.qml",properties:{"contacts": friends,"login":root.login}})
|
||||||
},"isFriend",1);
|
},"isFriend",1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,9 +172,9 @@ Item {
|
||||||
}
|
}
|
||||||
BusyIndicator{
|
BusyIndicator{
|
||||||
id: newsBusy
|
id: newsBusy
|
||||||
anchors.centerIn:update
|
anchors.horizontalCenter: newsView.horizontalCenter
|
||||||
//anchors.right: update.left
|
anchors.top:parent.top
|
||||||
//anchors.top:parent.top
|
anchors.topMargin: 2*mm
|
||||||
width:7*mm
|
width:7*mm
|
||||||
height: 7*mm
|
height: 7*mm
|
||||||
}
|
}
|
|
@ -29,7 +29,7 @@ Item {
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
id:profileImage
|
id:profileImage
|
||||||
source:(newsitemobject.user.isFriend==1)? "file://"+newsitemobject.user.profile_image : newsitemobject.user.profile_image_url
|
source: (newsitemobject.user.profile_image!="")? "file://"+newsitemobject.user.profile_image : newsitemobject.user.profile_image_url
|
||||||
x:1
|
x:1
|
||||||
width: 7*mm
|
width: 7*mm
|
||||||
height: 7*mm
|
height: 7*mm
|
||||||
|
@ -91,12 +91,6 @@ Item {
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
checked:(newsitemobject.favorited>0)
|
checked:(newsitemobject.favorited>0)
|
||||||
Text{
|
|
||||||
anchors.left: parent.right
|
|
||||||
color: "grey"
|
|
||||||
font.pixelSize: 1.5*mm
|
|
||||||
text: (newsitemobject.favorited>0)? newsitemobject.favorited+qsTr(" Favorites"):""
|
|
||||||
}
|
|
||||||
onClicked:{
|
onClicked:{
|
||||||
if(favoritedCheckbox.checkedState==Qt.Checked)
|
if(favoritedCheckbox.checkedState==Qt.Checked)
|
||||||
{Newsjs.favorite(login,true,newsitemobject.status_id,root)}
|
{Newsjs.favorite(login,true,newsitemobject.status_id,root)}
|
||||||
|
@ -125,6 +119,7 @@ Item {
|
||||||
Rectangle{
|
Rectangle{
|
||||||
width: 4*mm
|
width: 4*mm
|
||||||
height: 3*mm
|
height: 3*mm
|
||||||
|
visible:(newsitemobject.in_reply_to_status_id!="")?true:false
|
||||||
Text{
|
Text{
|
||||||
id:conversationsymbol
|
id:conversationsymbol
|
||||||
color: "grey"
|
color: "grey"
|
||||||
|
@ -138,17 +133,18 @@ Item {
|
||||||
newsBusy.running=true;
|
newsBusy.running=true;
|
||||||
Newsjs.requestConversation(root.login,db,newsitemobject.status_id,root.contactlist,root,function(news,newContacts){
|
Newsjs.requestConversation(root.login,db,newsitemobject.status_id,root.contactlist,root,function(news,newContacts){
|
||||||
for (var i=0;i<newContacts.length;i++){
|
for (var i=0;i<newContacts.length;i++){
|
||||||
root.updateContactInDB(root.login,root.db,0,newContacts[i])
|
root.updateContactInDB(root.login,root.db,0,newContacts[i])
|
||||||
}
|
}
|
||||||
Newsjs.storeNews(root.login,root.db,news,root,function(){
|
Newsjs.storeNews(root.login,root.db,news,root,function(){
|
||||||
var currentTime= new Date();
|
var currentTime= new Date();
|
||||||
Newsjs.conversationfromdb(db,root.login.username,newsitemobject.statusnet_conversation_id, function(newsarray){
|
Newsjs.conversationfromdb(db,root.login.username,newsitemobject.statusnet_conversation_id, function(newsarray){
|
||||||
newsModel.clear();
|
newsModel.clear();
|
||||||
var msg = {'currentTime': currentTime, 'model': newsModel,'news':newsarray,'latestmessage':0};
|
newstab.newstabStatus="conversation";
|
||||||
newsWorker.sendMessage(msg);
|
var msg = {'currentTime': currentTime, 'model': newsModel,'news':newsarray,'latestmessage':0};
|
||||||
newsBusy.running=false
|
newsWorker.sendMessage(msg);
|
||||||
});
|
newsBusy.running=false
|
||||||
}
|
})
|
||||||
|
}
|
||||||
)})
|
)})
|
||||||
}}
|
}}
|
||||||
}}
|
}}
|
||||||
|
@ -192,6 +188,7 @@ Item {
|
||||||
CheckBox{id:likeCheckbox
|
CheckBox{id:likeCheckbox
|
||||||
height:3*mm
|
height:3*mm
|
||||||
width:8*mm
|
width:8*mm
|
||||||
|
visible: (newsitemobject.messagetype==0)? true:false
|
||||||
checked:(friendica_activities.self.liked)?true:false
|
checked:(friendica_activities.self.liked)?true:false
|
||||||
style: CheckBoxStyle {
|
style: CheckBoxStyle {
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
|
@ -218,6 +215,7 @@ Item {
|
||||||
CheckBox{id: dislikeCheckbox
|
CheckBox{id: dislikeCheckbox
|
||||||
height:3*mm
|
height:3*mm
|
||||||
width:8*mm
|
width:8*mm
|
||||||
|
visible: (newsitemobject.messagetype==0)? true:false
|
||||||
checked: (friendica_activities.self.disliked)?true:false
|
checked: (friendica_activities.self.disliked)?true:false
|
||||||
style: CheckBoxStyle {
|
style: CheckBoxStyle {
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
|
@ -267,7 +265,9 @@ Item {
|
||||||
MenuItem {
|
MenuItem {
|
||||||
text: qsTr("Reply")
|
text: qsTr("Reply")
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
newsStack.push({item:"qrc:/qml/MessageSend.qml",properties:{"reply_to_user": newsitemobject.user.screen_name,"parentId":newsitemobject.status_id,"login":root.login}});
|
var directmessage=0;
|
||||||
|
if (newsitemobject.messagetype==1){ directmessage=1}
|
||||||
|
newsStack.push({item:"qrc:/qml/newsqml/MessageSend.qml",properties:{"reply_to_user": newsitemobject.user.screen_name,"parentId":newsitemobject.status_id,"login":root.login,"directmessage":directmessage}});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MenuItem {
|
MenuItem {
|
||||||
|
@ -325,7 +325,7 @@ Menu{
|
||||||
MenuItem {
|
MenuItem {
|
||||||
text: qsTr("Delete")
|
text: qsTr("Delete")
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
Newsjs.deleteNews(root.login,root.db,newsitemobject.status_id,root,function(reply){
|
Newsjs.deleteNews(root.login,root.db,newsitemobject.status_id,newsitemobject.messagetype,root,function(reply){
|
||||||
print("Deleted "+reply);
|
print("Deleted "+reply);
|
||||||
newsModel.remove(index);
|
newsModel.remove(index);
|
||||||
})
|
})
|
156
v0.002/Develop/source-android/qml/newsqml/PermissionDialog.qml
Normal file
156
v0.002/Develop/source-android/qml/newsqml/PermissionDialog.qml
Normal file
|
@ -0,0 +1,156 @@
|
||||||
|
import QtQuick 2.0
|
||||||
|
import QtQuick.Dialogs 1.2
|
||||||
|
import QtQuick.Controls 1.4
|
||||||
|
import QtQml.Models 2.1
|
||||||
|
import "qrc:/js/service.js" as Service
|
||||||
|
import "qrc:/js/helper.js" as Helperjs
|
||||||
|
|
||||||
|
Rectangle{
|
||||||
|
id:permissionDialog
|
||||||
|
x: mm
|
||||||
|
width: messageColumn.width-5*mm
|
||||||
|
height:root.height/3
|
||||||
|
|
||||||
|
Text{
|
||||||
|
x:0.5*mm
|
||||||
|
y:0.5*mm
|
||||||
|
text: "Contacts"
|
||||||
|
}
|
||||||
|
ListView {
|
||||||
|
id: contactView
|
||||||
|
x:0.5*mm
|
||||||
|
y:5.5*mm
|
||||||
|
width: permissionDialog.width/2-2*mm
|
||||||
|
height: permissionDialog.height-14*mm
|
||||||
|
clip: true
|
||||||
|
spacing: 1
|
||||||
|
model: contactModel
|
||||||
|
delegate: contactItem
|
||||||
|
}
|
||||||
|
|
||||||
|
ListModel{id: contactModel}
|
||||||
|
Component{
|
||||||
|
id:contactItem
|
||||||
|
Rectangle{
|
||||||
|
id:contactitemRect
|
||||||
|
width:contactView.width
|
||||||
|
height: 5*mm
|
||||||
|
property string contactstatus:"neutral"
|
||||||
|
onContactstatusChanged:
|
||||||
|
{if(contactstatus=="positive"){contactitemRect.color="light green"}
|
||||||
|
else if (contactstatus=="negative"){contactitemRect.color= "light red"}
|
||||||
|
else{contactitemRect.color= "white"}}
|
||||||
|
color: "white"
|
||||||
|
border.color:"grey"
|
||||||
|
Text{
|
||||||
|
color:"grey"
|
||||||
|
text:contact.screen_name
|
||||||
|
}
|
||||||
|
MouseArea{
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked:{
|
||||||
|
if(contactModel.get(index).contactstatus=="neutral"){
|
||||||
|
contactModel.set(index,{"contactstatus":"positive"});
|
||||||
|
contactstatus="positive"
|
||||||
|
}
|
||||||
|
else if (contactModel.get(index).contactstatus=="positive"){
|
||||||
|
contactModel.set(index,{"contactstatus":"negative"})
|
||||||
|
contactstatus="negative"
|
||||||
|
}
|
||||||
|
else{contactModel.set(index,{"contactstatus":"neutral"});
|
||||||
|
contactstatus="neutral";
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Text{
|
||||||
|
x:contactView.width+2*mm
|
||||||
|
y:0.5*mm
|
||||||
|
text: "Groups"
|
||||||
|
}
|
||||||
|
ListView {
|
||||||
|
id: groupView
|
||||||
|
x:contactView.width+2*mm
|
||||||
|
y:5.5*mm
|
||||||
|
width: permissionDialog.width/2-2*mm
|
||||||
|
height: permissionDialog.height-14*mm
|
||||||
|
clip: true
|
||||||
|
spacing: 1
|
||||||
|
model: groupModel
|
||||||
|
delegate: groupItem
|
||||||
|
}
|
||||||
|
|
||||||
|
ListModel{id: groupModel}
|
||||||
|
Component{
|
||||||
|
id:groupItem
|
||||||
|
Rectangle{
|
||||||
|
id:groupitemRect
|
||||||
|
width:groupView.width
|
||||||
|
height: 5*mm
|
||||||
|
property string groupstatus:"neutral"
|
||||||
|
onGroupstatusChanged:
|
||||||
|
{if(groupstatus=="positive"){groupitemRect.color="light green"}
|
||||||
|
else if (groupstatus=="negative"){groupitemRect.color= "light red"}
|
||||||
|
else{groupitemRect.color= "white"}}
|
||||||
|
color: "white"
|
||||||
|
border.color:"grey"
|
||||||
|
Text{
|
||||||
|
color:"grey"
|
||||||
|
text:group.groupname
|
||||||
|
}
|
||||||
|
MouseArea{
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked:{
|
||||||
|
if(groupModel.get(index).groupstatus=="neutral"){
|
||||||
|
groupModel.set(index,{"groupstatus":"positive"});
|
||||||
|
groupstatus="positive"}
|
||||||
|
else if (groupModel.get(index).groupstatus=="positive"){
|
||||||
|
groupModel.set(index,{"groupstatus":"negative"});
|
||||||
|
groupstatus="negative"}
|
||||||
|
else{groupModel.set(index,{"groupstatus":"neutral"})
|
||||||
|
groupstatus="neutral"}
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Button{
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.bottomMargin:1
|
||||||
|
text:qsTr("Done")
|
||||||
|
onClicked:{//var group_allow=[];var group_deny=[];
|
||||||
|
for (var i=0;i<groupModel.count;i++)
|
||||||
|
{if (groupModel.get(i).groupstatus=="positive"){
|
||||||
|
group_allow.push(groupModel.get(i).group.gid)
|
||||||
|
}
|
||||||
|
if (groupModel.get(i).groupstatus=="negative"){
|
||||||
|
group_deny.push(groupModel.get(i).group.gid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (var j=0;j<contactModel.count;j++)
|
||||||
|
{//print("contact: "+JSON.stringify(contactModel.get(j).contact));
|
||||||
|
if (contactModel.get(j).contactstatus=="positive"){
|
||||||
|
print(JSON.stringify(contact_allow));
|
||||||
|
contact_allow.push(contactModel.get(j).contact.cid)
|
||||||
|
}
|
||||||
|
if (contactModel.get(j).contactstatus=="negative"){
|
||||||
|
contact_deny.push(contactModel.get(j).contact.cid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//print("contacts: "+Helperjs.cleanArray(contact_allow))
|
||||||
|
permissionDialog.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted:{
|
||||||
|
Helperjs.readData(db,"contacts",login.username,function(contacts){
|
||||||
|
for (var name in contacts){
|
||||||
|
contactModel.append({"contact":contacts[name],"contactstatus":"neutral"})
|
||||||
|
}},"isFriend",1);
|
||||||
|
|
||||||
|
Helperjs.readData(db,"groups",login.username,function(owngroups){
|
||||||
|
for (var number in owngroups){
|
||||||
|
groupModel.append({"group":owngroups[number],"groupstatus":"neutral"})
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,7 +4,7 @@ import QtQuick.Controls 1.4
|
||||||
import QtQml.Models 2.1
|
import QtQml.Models 2.1
|
||||||
import "qrc:/js/service.js" as Service
|
import "qrc:/js/service.js" as Service
|
||||||
import "qrc:/js/helper.js" as Helperjs
|
import "qrc:/js/helper.js" as Helperjs
|
||||||
import "qrc:/qml"
|
import "qrc:/qml/photoqml"
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id:fotorectangle
|
id:fotorectangle
|
|
@ -1,25 +1,28 @@
|
||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/">
|
<qresource prefix="/">
|
||||||
|
<file>qml/friendiqa.qml</file>
|
||||||
|
<file>qml/newsqml/NewsTab.qml</file>
|
||||||
|
<file>qml/newsqml/Newsitem.qml</file>
|
||||||
|
<file>qml/newsqml/MessageSend.qml</file>
|
||||||
|
<file>qml/newsqml/PermissionDialog.qml</file>
|
||||||
|
<file>qml/contactqml/FriendsTab.qml</file>
|
||||||
|
<file>qml/contactqml/GroupComponent.qml</file>
|
||||||
|
<file>qml/contactqml/ContactComponent.qml</file>
|
||||||
|
<file>qml/contactqml/ContactDetailsComponent.qml</file>
|
||||||
|
<file>qml/photoqml/PhotoComponent.qml</file>
|
||||||
|
<file>qml/photoqml/PhotogroupComponent.qml</file>
|
||||||
|
<file>qml/photoqml/PhotoPlaceholder.qml</file>
|
||||||
|
<file>qml/photoqml/PhotoTab.qml</file>
|
||||||
|
<file>qml/configqml/InfoBox.qml</file>
|
||||||
|
<file>qml/configqml/ConfigTab.qml</file>
|
||||||
<file>js/layout.js</file>
|
<file>js/layout.js</file>
|
||||||
<file>js/photoworker.js</file>
|
<file>js/photoworker.js</file>
|
||||||
<file>js/service.js</file>
|
<file>js/service.js</file>
|
||||||
<file>qml/MessageSend.qml</file>
|
|
||||||
<file>qml/Newsitem.qml</file>
|
|
||||||
<file>qml/PhotoComponent.qml</file>
|
|
||||||
<file>qml/PhotogroupComponent.qml</file>
|
|
||||||
<file>qml/PhotoPlaceholder.qml</file>
|
|
||||||
<file>qml/friendiqa.qml</file>
|
|
||||||
<file>qml/PhotoTab.qml</file>
|
|
||||||
<file>qml/ConfigTab.qml</file>
|
|
||||||
<file>qml/FriendsTab.qml</file>
|
|
||||||
<file>qml/NewsTab.qml</file>
|
|
||||||
<file>js/news.js</file>
|
<file>js/news.js</file>
|
||||||
<file>js/newsworker.js</file>
|
<file>js/newsworker.js</file>
|
||||||
<file>js/helper.js</file>
|
<file>js/helper.js</file>
|
||||||
<file>images/defaultcontact.jpg</file>
|
<file>images/defaultcontact.jpg</file>
|
||||||
<file>qml/InfoBox.qml</file>
|
|
||||||
<file>qml/GroupComponent.qml</file>
|
|
||||||
<file>qml/ContactComponent.qml</file>
|
|
||||||
<file>qml/PermissionDialog.qml</file>
|
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
@ -14,7 +14,7 @@ XHR *XHR::instance()
|
||||||
|
|
||||||
XHR::XHR(QObject *parent) : QObject(parent)
|
XHR::XHR(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
// request.setSslConfiguration(QSslConfiguration::defaultConfiguration());
|
request.setSslConfiguration(QSslConfiguration::defaultConfiguration());
|
||||||
}
|
}
|
||||||
|
|
||||||
void XHR::setUrl(QString url)
|
void XHR::setUrl(QString url)
|
||||||
|
@ -79,10 +79,11 @@ void XHR::download()
|
||||||
request.setUrl(requrl);
|
request.setUrl(requrl);
|
||||||
reply = manager.get(request);
|
reply = manager.get(request);
|
||||||
// qDebug() << "reply " << reply->header(QNetworkRequest::LocationHeader)<<reply->header(QNetworkRequest::LastModifiedHeader);
|
// qDebug() << "reply " << reply->header(QNetworkRequest::LocationHeader)<<reply->header(QNetworkRequest::LastModifiedHeader);
|
||||||
// qDebug() << "request " << request.url();
|
// qDebug() << "request " << request.url();
|
||||||
// qDebug() << "error " << reply->error();
|
|
||||||
// reply->ignoreSslErrors();
|
// reply->ignoreSslErrors();
|
||||||
connect(reply, &QNetworkReply::readyRead,this, &XHR::onRequestFinished);
|
connect(reply, &QNetworkReply::readyRead,this, &XHR::onReadyRead);
|
||||||
|
connect(reply,SIGNAL(downloadProgress(qint64,qint64)), this,SLOT(updateDownloadProgress(qint64,qint64)));
|
||||||
|
connect(reply, &QNetworkReply::finished,this, &XHR::onRequestFinished);
|
||||||
connect(reply, &QNetworkReply::sslErrors, this, &XHR::onSSLError);
|
connect(reply, &QNetworkReply::sslErrors, this, &XHR::onSSLError);
|
||||||
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onReplyError(QNetworkReply::NetworkError)));
|
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onReplyError(QNetworkReply::NetworkError)));
|
||||||
}
|
}
|
||||||
|
@ -177,17 +178,19 @@ void XHR::onReplySuccess()
|
||||||
void XHR::onRequestFinished()
|
void XHR::onRequestFinished()
|
||||||
{
|
{
|
||||||
// Save the file here
|
// Save the file here
|
||||||
QByteArray b = reply->readAll();
|
//qDebug() << "buffer downloaded "<<buffer;
|
||||||
QImage image = QImage::fromData(b);
|
//QImage image = QImage::fromData(buffer);
|
||||||
if (image.isNull()){qDebug() << "Image empty"<<m_url;}
|
if (buffer.isNull()){qDebug() << "Image empty"<<m_url; buffer.clear(); emit this->error("image empty",1); reply->deleteLater();}
|
||||||
QFile file(m_filename);
|
else {QFile file(m_filename);
|
||||||
file.open(QIODevice::WriteOnly);
|
file.open(QIODevice::WriteOnly);
|
||||||
image.save(&file, "JPG");
|
//image.save(&file, "JPG");
|
||||||
b.clear();
|
file.write(buffer);
|
||||||
|
buffer.clear();
|
||||||
file.close();
|
file.close();
|
||||||
// qDebug() << m_url << "File downloaded "<<file.fileName();
|
//qDebug() << m_url << "File downloaded "<<file.fileName();
|
||||||
emit this->downloaded();
|
emit this->downloaded();
|
||||||
reply->deleteLater();
|
//reply->deleteLater();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XHR::onReadyRead()
|
void XHR::onReadyRead()
|
||||||
|
@ -196,6 +199,12 @@ void XHR::onReadyRead()
|
||||||
buffer += reply->readAll();
|
buffer += reply->readAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void XHR::updateDownloadProgress(qint64 bytesRead, qint64 totalBytes)
|
||||||
|
{
|
||||||
|
qDebug() << "Bytes: " << bytesRead<<" / "<<totalBytes;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void XHR::onSSLError(const QList<QSslError> &errors)
|
void XHR::onSSLError(const QList<QSslError> &errors)
|
||||||
{
|
{
|
||||||
qDebug() << "XHR::onSSLError :" ;
|
qDebug() << "XHR::onSSLError :" ;
|
||||||
|
|
|
@ -17,9 +17,6 @@ public:
|
||||||
|
|
||||||
explicit XHR(QObject *parent = 0);
|
explicit XHR(QObject *parent = 0);
|
||||||
|
|
||||||
|
|
||||||
// void setLogin(QString login);
|
|
||||||
|
|
||||||
QString url() const;
|
QString url() const;
|
||||||
QString login() const;
|
QString login() const;
|
||||||
QString filename() const;
|
QString filename() const;
|
||||||
|
@ -47,9 +44,9 @@ private slots:
|
||||||
void onReplyError(QNetworkReply::NetworkError code);
|
void onReplyError(QNetworkReply::NetworkError code);
|
||||||
void onReplySuccess();
|
void onReplySuccess();
|
||||||
void onRequestFinished();
|
void onRequestFinished();
|
||||||
//void onFileWritten();
|
|
||||||
void onReadyRead();
|
void onReadyRead();
|
||||||
void onSSLError(const QList<QSslError> &errors);
|
void onSSLError(const QList<QSslError> &errors);
|
||||||
|
void updateDownloadProgress(qint64 bytesRead, qint64 totalBytes);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QByteArray buffer;
|
QByteArray buffer;
|
||||||
|
|
|
@ -24,6 +24,10 @@ RESOURCES = application.qrc
|
||||||
OTHER_FILES += qml/friendiqa.qml \
|
OTHER_FILES += qml/friendiqa.qml \
|
||||||
translations/*.ts \
|
translations/*.ts \
|
||||||
qml/*.qml
|
qml/*.qml
|
||||||
|
qml/newsqml/*.qml
|
||||||
|
qml/contactqml/*.qml
|
||||||
|
qml/photoqml/*.qml
|
||||||
|
qml/configqml/*.qml
|
||||||
js/*.js
|
js/*.js
|
||||||
|
|
||||||
# German translation is enabled as an example. If you aren't
|
# German translation is enabled as an example. If you aren't
|
||||||
|
|
|
@ -114,3 +114,8 @@ function inArray(list, prop, val) {
|
||||||
}
|
}
|
||||||
} return -1;
|
} return -1;
|
||||||
}
|
}
|
||||||
|
function cleanArray(array) {
|
||||||
|
var arraystring=JSON.stringify(array);
|
||||||
|
arraystring=arraystring.replace(/[\[\]]/g , '');
|
||||||
|
return arraystring;
|
||||||
|
}
|
||||||
|
|
|
@ -39,6 +39,6 @@ function finishCreation(component,qmlParameters,parentitem,callback) {
|
||||||
else if (component.status === Component.Error)
|
else if (component.status === Component.Error)
|
||||||
print("Error loading component:"+component.errorString());
|
print("Error loading component:"+component.errorString());
|
||||||
else {print("created")}
|
else {print("created")}
|
||||||
callback(createdObject);
|
//callback(createdObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,31 +44,7 @@ function getFriendsTimeline(login,database,contacts,rootwindow,callback){// retr
|
||||||
Helperjs.friendicaRequest(login,"/api/statuses/friends_timeline"+parameter, rootwindow,function (obj){
|
Helperjs.friendicaRequest(login,"/api/statuses/friends_timeline"+parameter, rootwindow,function (obj){
|
||||||
var news=JSON.parse(obj);
|
var news=JSON.parse(obj);
|
||||||
var newContacts=findNewContacts(news,contacts);
|
var newContacts=findNewContacts(news,contacts);
|
||||||
// for (var i=0;i<news.length;i++){
|
callback(news,newContacts)
|
||||||
// if(contacts.indexOf(news[i].user.id)==-1 && !(inArray(newContacts,"id",news[i].user.id))){
|
|
||||||
// news[i].user.isFriend=0;
|
|
||||||
// newContacts.push(news[i].user);
|
|
||||||
// }
|
|
||||||
// if (news[i].friendica_activities.like.length>0){
|
|
||||||
// // print("Like Contact"+JSON.stringify(news[i].friendica_activities.like));
|
|
||||||
// for (var j=0;j<news[i].friendica_activities.like.length;j++){
|
|
||||||
// if(contacts.indexOf(news[i].friendica_activities.like[j].id)==-1 && !(inArray(newContacts,"id",news[i].friendica_activities.like[j].id))){
|
|
||||||
// news[i].friendica_activities.like[j].isFriend=0;
|
|
||||||
// newContacts.push(news[i].friendica_activities.like[j]);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (news[i].friendica_activities.dislike.length>0){
|
|
||||||
// //print("DisLike Contact"+JSON.stringify(news[i].friendica_activities.dislike));
|
|
||||||
// for (var k=0;j<news[k].friendica_activities.dislike.length;k++){
|
|
||||||
// if(contacts.indexOf(news[i].friendica_activities.dislike[k].id)==-1 && !(inArray(newContacts,"id",news[i].friendica_activties.dislike[k].id))){
|
|
||||||
// news[i].friendica_activities.dislike[k].isFriend=0;
|
|
||||||
// newContacts.push(news[i].friendica_activities.dislike[k]);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
callback(news,newContacts)
|
|
||||||
})}
|
})}
|
||||||
|
|
||||||
function findNewContacts(news,contacts){
|
function findNewContacts(news,contacts){
|
||||||
|
@ -104,7 +80,7 @@ function storeNews(login,database,news,rootwindow,callback){
|
||||||
// save news after contacts download, call next function
|
// save news after contacts download, call next function
|
||||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||||
for (var i=0;i<news.length;i++){
|
for (var i=0;i<news.length;i++){
|
||||||
print('store news data for ' + news[i].id+JSON.stringify(news[i].friendica_activities));
|
//print('store news data for ' + news[i].id+JSON.stringify(news[i].friendica_activities));
|
||||||
var ausdruck=news[i];
|
var ausdruck=news[i];
|
||||||
var likearray=[]; for (var user in news[i].friendica_activities.like){likearray.push(parseInt(news[i].friendica_activities.like[user].id))}
|
var likearray=[]; for (var user in news[i].friendica_activities.like){likearray.push(parseInt(news[i].friendica_activities.like[user].id))}
|
||||||
var dislikearray=[]; for (var user in news[i].friendica_activities.dislike){parseInt(news[i].friendica_activities.dislike[user].id)}
|
var dislikearray=[]; for (var user in news[i].friendica_activities.dislike){parseInt(news[i].friendica_activities.dislike[user].id)}
|
||||||
|
@ -113,10 +89,10 @@ function storeNews(login,database,news,rootwindow,callback){
|
||||||
var attendmaybearray=[]; for (var user in news[i].friendica_activities.attendmaybe){attendmaybearray.push(parseInt(news[i].friendica_activities.attendmaybe[user].id))}
|
var attendmaybearray=[]; for (var user in news[i].friendica_activities.attendmaybe){attendmaybearray.push(parseInt(news[i].friendica_activities.attendmaybe[user].id))}
|
||||||
var friendica_activities=[likearray,dislikearray,attendyesarray,attendnoarray,attendmaybearray]
|
var friendica_activities=[likearray,dislikearray,attendyesarray,attendnoarray,attendmaybearray]
|
||||||
db.transaction( function(tx) {
|
db.transaction( function(tx) {
|
||||||
var result = tx.executeSql('SELECT * from news where status_id = "'+news[i].id+'"'); // check for news id
|
var result = tx.executeSql('SELECT * from news where username="'+login.username+'" AND status_id = "'+news[i].id+'" AND messagetype=0'); // check for news id
|
||||||
if(result.rows.length === 1) {// use update
|
if(result.rows.length === 1) {// use update
|
||||||
print(news[i].id +' exists, update it')
|
print(news[i].id +' exists, update it')
|
||||||
result = tx.executeSql('UPDATE news SET username="'+login.username+'", messagetype=0, text="'+Qt.btoa(news[i].text)+'", created_at="'+Date.parse(cleanDate(news[i].created_at))+'", in_reply_to_status_id="'+news[i].in_reply_to_status_id+'", source="'+news[i].source+'", status_id="'+news[i].id+'", in_reply_to_user_id="'+news[i].in_reply_to_user_id+'", geo="'+news[i].geo+'", favorited="'+news[i].favorited+'", uid="'+news[i].user.id+'", statusnet_html="'+Qt.btoa(news[i].status_html)+'", statusnet_conversation_id="'+news[i].statusnet_conversation_id+'",friendica_activities="'+JSON.stringify(friendica_activities)+'" where status_id="'+news[i].status_id+'"');
|
result = tx.executeSql('UPDATE news SET username="'+login.username+'", messagetype=0, text="'+Qt.btoa(news[i].text)+'", created_at="'+Date.parse(cleanDate(news[i].created_at))+'", in_reply_to_status_id="'+news[i].in_reply_to_status_id+'", source="'+news[i].source+'", status_id="'+news[i].id+'", in_reply_to_user_id="'+news[i].in_reply_to_user_id+'", geo="'+news[i].geo+'", favorited="'+news[i].favorited+'", uid="'+news[i].user.id+'", statusnet_html="'+Qt.btoa(news[i].status_html)+'", statusnet_conversation_id="'+news[i].statusnet_conversation_id+'",friendica_activities="'+JSON.stringify(friendica_activities)+'" where username="'+login.username+'" AND status_id="'+news[i].status_id+'" AND messagetype=0');
|
||||||
} else {// use insert
|
} else {// use insert
|
||||||
result = tx.executeSql('INSERT INTO news (username,messagetype,text,created_at,in_reply_to_status_id,source,status_id,in_reply_to_user_id,geo,favorited,uid,statusnet_html,statusnet_conversation_id,friendica_activities,friendica_activities_self) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,0,Qt.btoa(news[i].text),Date.parse(cleanDate(news[i].created_at)), news[i].in_reply_to_status_id, news[i].source, news[i].id,news[i].in_reply_to_user_id,news[i].geo,news[i].favorited, news[i].user.id,Qt.btoa(news[i].statusnet_html),news[i].statusnet_conversation_id, JSON.stringify(friendica_activities),"[]"])}})
|
result = tx.executeSql('INSERT INTO news (username,messagetype,text,created_at,in_reply_to_status_id,source,status_id,in_reply_to_user_id,geo,favorited,uid,statusnet_html,statusnet_conversation_id,friendica_activities,friendica_activities_self) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,0,Qt.btoa(news[i].text),Date.parse(cleanDate(news[i].created_at)), news[i].in_reply_to_status_id, news[i].source, news[i].id,news[i].in_reply_to_user_id,news[i].geo,news[i].favorited, news[i].user.id,Qt.btoa(news[i].statusnet_html),news[i].statusnet_conversation_id, JSON.stringify(friendica_activities),"[]"])}})
|
||||||
}
|
}
|
||||||
|
@ -128,14 +104,14 @@ function getDirectMessage(login,database,rootwindow,callback){
|
||||||
Helperjs.friendicaRequest(login,"/api/direct_messages/all",rootwindow, function (obj){
|
Helperjs.friendicaRequest(login,"/api/direct_messages/all",rootwindow, function (obj){
|
||||||
var messages=JSON.parse(obj);
|
var messages=JSON.parse(obj);
|
||||||
for (var i=0;i<messages.length;i++){
|
for (var i=0;i<messages.length;i++){
|
||||||
// print('store message data for '+JSON.stringify(messages[i]));
|
//print('store message data for '+JSON.stringify(messages[i]));
|
||||||
db.transaction( function(tx) {
|
db.transaction( function(tx) {
|
||||||
var result = tx.executeSql('SELECT * from news where status_id = "'+messages[i].id+'"'); // check for news id
|
var result = tx.executeSql('SELECT * from news where username= "'+login.username+'" AND status_id = "'+messages[i].id+'" AND messagetype=1'); // check for news id
|
||||||
if(result.rows.length === 1) {// use update
|
if(result.rows.length === 1) {// use update
|
||||||
print(messages[i].id +' exists, update it')
|
print(messages[i].id +' exists, update it')
|
||||||
result = tx.executeSql('UPDATE news SET username="'+login.username+'", messagetype=1, text="'+Qt.btoa(messages[i].text)+'", created_at="'+Date.parse(messages[i].created_at)+'", source="Friendica", status_id="'+messages[i].id+'", uid="'+messages[i].sender.id+'", statusnet_html="'+Qt.btoa(messages[i].text)+'" where status_id="'+messages[i].status_id+'"');
|
result = tx.executeSql('UPDATE news SET username="'+login.username+'", messagetype=1, text="'+Qt.btoa(messages[i].text)+'", created_at="'+Date.parse(cleanDate(messages[i].created_at))+'", source="Friendica", status_id="'+messages[i].id+'", uid="'+messages[i].sender.id+'", statusnet_html="'+Qt.btoa(messages[i].text)+'" where username="'+login.username+'" AND status_id="'+messages[i].status_id+'" AND messagetype=1');
|
||||||
} else {// use insert
|
} else {// use insert
|
||||||
result = tx.executeSql('INSERT INTO news (username,messagetype,text,created_at,source,status_id,uid,statusnet_html) VALUES (?,?,?,?,?,?,?,?)', [login.username,1,Qt.btoa(messages[i].text),Date.parse(messages[i].created_at), "Friendica", messages[i].id, messages[i].sender.id,Qt.btoa(messages[i].text)])}
|
result = tx.executeSql('INSERT INTO news (username,messagetype,text,created_at,source,status_id,uid,statusnet_html) VALUES (?,?,?,?,?,?,?,?)', [login.username,1,Qt.btoa(messages[i].text),Date.parse(cleanDate(messages[i].created_at)), "Friendica", messages[i].id, messages[i].sender.id,Qt.btoa(messages[i].text)])}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -149,10 +125,10 @@ function getNotifications(login,database,rootwindow,callback){
|
||||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||||
//print('store message data for '+JSON.stringify(messages[i]));
|
//print('store message data for '+JSON.stringify(messages[i]));
|
||||||
db.transaction( function(tx) {
|
db.transaction( function(tx) {
|
||||||
var result = tx.executeSql('SELECT * from news where status_id = "'+messages[i].id+'"'); // check for news id
|
var result = tx.executeSql('SELECT * from news where username="'+login.username+'" AND status_id = "'+messages[i].id+'" AND messagetype=2'); // check for news id
|
||||||
if(result.rows.length === 1) {// use update
|
if(result.rows.length === 1) {// use update
|
||||||
print(messages[i].id +' exists, update it')
|
print(messages[i].id +' exists, update it')
|
||||||
result = tx.executeSql('UPDATE news SET username="'+login.username+'", messagetype=2, text="'+Qt.btoa(messages[i].msg_html)+'", created_at="'+Date.parse(messages[i].date)+'", source="Friendica", status_id="'+messages[i].id+'", uid="'+messages[i].uid+'", statusnet_html="'+Qt.btoa(messages[i].msg_html)+'", statusnet_conversation_id="'+messages[i].parent+'" where status_id="'+messages[i].id+'"');
|
result = tx.executeSql('UPDATE news SET username="'+login.username+'", messagetype=2, text="'+Qt.btoa(messages[i].msg_html)+'", created_at="'+Date.parse(messages[i].date)+'", source="Friendica", status_id="'+messages[i].id+'", uid="'+messages[i].uid+'", statusnet_html="'+Qt.btoa(messages[i].msg_html)+'", statusnet_conversation_id="'+messages[i].parent+'" where username="'+login.username+'" AND status_id="'+messages[i].id+'" AND messagetype=2');
|
||||||
} else {// use insert
|
} else {// use insert
|
||||||
result = tx.executeSql('INSERT INTO news (username,messagetype,text,created_at,source,status_id, uid,statusnet_html,statusnet_conversation_id) VALUES (?,?,?,?,?,?,?,?,?)', [login.username,2,Qt.btoa(messages[i].msg_html),Date.parse(messages[i].date),"Friendica", messages[i].id, messages[i].uid,Qt.btoa(messages[i].msg_html),messages[i].parent])}
|
result = tx.executeSql('INSERT INTO news (username,messagetype,text,created_at,source,status_id, uid,statusnet_html,statusnet_conversation_id) VALUES (?,?,?,?,?,?,?,?,?)', [login.username,2,Qt.btoa(messages[i].msg_html),Date.parse(messages[i].date),"Friendica", messages[i].id, messages[i].uid,Qt.btoa(messages[i].msg_html),messages[i].parent])}
|
||||||
});
|
});
|
||||||
|
@ -233,14 +209,21 @@ function fetchUsersForNews(database,username,news){
|
||||||
return news
|
return news
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteNews(login,database,newsid,rootwindow,callback){
|
function deleteNews(login,database,newsid,messagetype,rootwindow,callback){
|
||||||
Helperjs.friendicaPostRequest(login,"/api/statuses/destroy?id="+newsid, rootwindow,function (obj){
|
var api="" ;
|
||||||
|
if (messagetype==0){ api="/api/statuses/destroy?id="}
|
||||||
|
else if (messagetype==1){ api="/api/direct_messages/destroy?id="}
|
||||||
|
else if (messagetype==2){ api="/api/friendica/notifications/seen?id="}
|
||||||
|
|
||||||
|
Helperjs.friendicaPostRequest(login,api+newsid, rootwindow,function (obj){
|
||||||
print("Delete "+obj);
|
print("Delete "+obj);
|
||||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||||
print('delete news data for ' + newsid);
|
print('delete news data for ' + newsid);
|
||||||
db.transaction( function(tx) {var result = tx.executeSql('DELETE from news where status_id ='+newsid); // delete news id
|
db.transaction( function(tx) {var result = tx.executeSql('DELETE from news where username="'+login.username+'" AND messagetype='+messagetype+' AND status_id ='+newsid); // delete news id
|
||||||
Helperjs.showMessage("Delete",result,rootwindow)});
|
Helperjs.showMessage("Delete",obj,rootwindow);
|
||||||
})}
|
callback(obj)
|
||||||
|
});
|
||||||
|
})}
|
||||||
|
|
||||||
function retweetNews(login,database,newsid,rootwindow,callback){
|
function retweetNews(login,database,newsid,rootwindow,callback){
|
||||||
Helperjs.friendicaRequest(login,"/api/statuses/retweet?id="+newsid, rootwindow,function (obj){
|
Helperjs.friendicaRequest(login,"/api/statuses/retweet?id="+newsid, rootwindow,function (obj){
|
||||||
|
@ -329,7 +312,7 @@ function conversationfromdb(database,user,conversationId,callback){
|
||||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||||
db.transaction( function(tx) {
|
db.transaction( function(tx) {
|
||||||
print('select * from news WHERE statusnet_conversation_id='+conversationId+' ORDER BY status_id DESC');
|
print('select * from news WHERE statusnet_conversation_id='+conversationId+' ORDER BY status_id DESC');
|
||||||
var newsrs=tx.executeSql('select * from news WHERE statusnet_conversation_id='+conversationId+' ORDER BY status_id DESC');
|
var newsrs=tx.executeSql('select * from news WHERE username="'+user+'" AND statusnet_conversation_id='+conversationId+' ORDER BY status_id DESC');
|
||||||
var newsArray=[];
|
var newsArray=[];
|
||||||
for(var i = 0; i < newsrs.rows.length; i++) {
|
for(var i = 0; i < newsrs.rows.length; i++) {
|
||||||
newsArray.push(newsrs.rows.item(i));
|
newsArray.push(newsrs.rows.item(i));
|
||||||
|
|
|
@ -33,7 +33,7 @@ function dataRequest(login,photoID,database,rootwindow) {
|
||||||
// print("Source"+source);
|
// print("Source"+source);
|
||||||
obj["source"]=source;
|
obj["source"]=source;
|
||||||
var filename=obj.filename;
|
var filename=obj.filename;
|
||||||
if (filename==""){// check if file as any filename
|
if (filename==""){// check if file has any filename
|
||||||
if (obj.type=="image/jpeg") {obj["filename"]=obj["id"]+".jpg"}
|
if (obj.type=="image/jpeg") {obj["filename"]=obj["id"]+".jpg"}
|
||||||
else if (obj.type=="image/png") {obj["filename"]=obj["id"]+".png"}
|
else if (obj.type=="image/png") {obj["filename"]=obj["id"]+".png"}
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ function saveImage(obj,storagedirectory,callback) {
|
||||||
} else { //portrait
|
} else { //portrait
|
||||||
helpwidth=helpheight*obj.width/obj.height
|
helpwidth=helpheight*obj.width/obj.height
|
||||||
}
|
}
|
||||||
var component=Qt.createComponent("qrc:/qml/PhotoPlaceholder.qml");
|
var component=Qt.createComponent("qrc:/qml/photoqml/PhotoPlaceholder.qml");
|
||||||
var sprite = component.createObject(fotostab, {"x":0,"y":0,"imageName":storagedirectory+"/"+obj.filename ,"width":helpwidth,"height":helpheight,"source": obj["link"]["4"],"downloadtype":"picture"});
|
var sprite = component.createObject(fotostab, {"x":0,"y":0,"imageName":storagedirectory+"/"+obj.filename ,"width":helpwidth,"height":helpheight,"source": obj["link"]["4"],"downloadtype":"picture"});
|
||||||
callback(obj,sprite)
|
callback(obj,sprite)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
import QtQuick 2.0
|
|
||||||
import QtMultimedia 5.0
|
|
||||||
import QtQuick.Controls 1.2
|
|
||||||
|
|
||||||
Item {
|
|
||||||
Rectangle {
|
|
||||||
VideoOutput {
|
|
||||||
anchors.fill: parent
|
|
||||||
source: localCamera
|
|
||||||
}
|
|
||||||
Camera {
|
|
||||||
id: localCamera
|
|
||||||
}
|
|
||||||
Button {
|
|
||||||
id: shotButton
|
|
||||||
width: 200; height: 75
|
|
||||||
text: "Take Photo"
|
|
||||||
onClicked: {
|
|
||||||
localCamera.imageCapture.capture();
|
|
||||||
} }
|
|
||||||
Connections {
|
|
||||||
target: localCamera.imageCapture
|
|
||||||
onImageSaved: {
|
|
||||||
photofile= imagePaths.append({"path": path})
|
|
||||||
listView.positionViewAtEnd(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
Image {
|
|
||||||
id: photoFromCamera
|
|
||||||
anchors.fill: parent
|
|
||||||
fillMode: Image.PreserveAspectFit
|
|
||||||
source: photo
|
|
||||||
}
|
|
||||||
|
|
||||||
Button {
|
|
||||||
text: "Upload"
|
|
||||||
onClicked:{
|
|
||||||
var login=Service.readActiveConfig(db);
|
|
||||||
img.src=file;
|
|
||||||
Service.Upload(login,file)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,137 +0,0 @@
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick.Controls 1.3
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: contactComponent
|
|
||||||
property var createdAtDate: new Date(contact.created_at)
|
|
||||||
property var linkUrl: contact.network!=="dfrn"?contact.url:contact.url.replace("profile","dfrn_request")
|
|
||||||
Rectangle {
|
|
||||||
id: wrapper
|
|
||||||
width: 16*mm
|
|
||||||
height: 15*mm
|
|
||||||
border.color: "grey"
|
|
||||||
color:"white"
|
|
||||||
Image {
|
|
||||||
id: photoImage
|
|
||||||
x:1
|
|
||||||
y:1
|
|
||||||
width: 10*mm
|
|
||||||
height:10*mm
|
|
||||||
source:(contact.isFriend==1)? "file://"+contact.profile_image :contact.profile_image_url
|
|
||||||
onStatusChanged: if (photoImage.status == Image.Error) {source="qrc:/images/defaultcontact.jpg"}
|
|
||||||
}
|
|
||||||
|
|
||||||
Label {
|
|
||||||
id: namelabel
|
|
||||||
x: 1
|
|
||||||
width: wrapper.width-4
|
|
||||||
height: 3*mm
|
|
||||||
text: contact.screen_name
|
|
||||||
elide:Text.ElideRight
|
|
||||||
anchors.topMargin: 0
|
|
||||||
anchors.left: photoImage.left
|
|
||||||
color: "#303030"
|
|
||||||
font.pixelSize: 3*mm
|
|
||||||
anchors.top: photoImage.bottom
|
|
||||||
}
|
|
||||||
Button{
|
|
||||||
id:infobutton
|
|
||||||
width: 5*mm
|
|
||||||
height: 5*mm
|
|
||||||
text:"?"
|
|
||||||
anchors.left: photoImage.right
|
|
||||||
anchors.leftMargin: 3
|
|
||||||
anchors.topMargin: 3
|
|
||||||
anchors.top: parent.top
|
|
||||||
onClicked:{
|
|
||||||
//print("State: "+ friendComponent.state);
|
|
||||||
contactComponent.state="large"}
|
|
||||||
}
|
|
||||||
Rectangle{
|
|
||||||
id: detailsrectangle
|
|
||||||
anchors.top: namelabel.bottom
|
|
||||||
anchors.topMargin: 2*mm
|
|
||||||
opacity: 0
|
|
||||||
|
|
||||||
Flickable{
|
|
||||||
id:namelabelflickable
|
|
||||||
width: root.width-10*mm
|
|
||||||
height:friendsTabView.height-55*mm
|
|
||||||
boundsBehavior:Flickable.StopAtBounds
|
|
||||||
flickableDirection:Flickable.VerticalFlick
|
|
||||||
contentWidth:width
|
|
||||||
contentHeight: namelabeltext.height
|
|
||||||
clip:true
|
|
||||||
Text{
|
|
||||||
id:namelabeltext
|
|
||||||
//anchors.top: parent.top
|
|
||||||
width: namelabelflickable.width
|
|
||||||
height: implicitHeight
|
|
||||||
font.pixelSize: 3*mm
|
|
||||||
textFormat:Text.RichText
|
|
||||||
wrapMode: Text.Wrap
|
|
||||||
text:"<b>"+qsTr("Description")+": </b> "+Qt.atob(contact.description)+"<br> <b>"+qsTr("Server Type")+":</b> "+contact.location+"<br> <b>"+qsTr("Posts")+":</b> "+contact.statuses_count+
|
|
||||||
"<br> <b>"+qsTr("URL")+":</b> <a href='"+ linkUrl+"'>"+linkUrl+"</a><br> <b>"+
|
|
||||||
qsTr("Created at")+":</b> "+createdAtDate.toLocaleString(Qt.locale())
|
|
||||||
onLinkActivated: {
|
|
||||||
Qt.openUrlExternally(link)}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Row{
|
|
||||||
anchors.top: namelabelflickable.bottom
|
|
||||||
anchors.topMargin: 2*mm
|
|
||||||
spacing:4
|
|
||||||
|
|
||||||
Button{
|
|
||||||
id:photobutton
|
|
||||||
text:"Photos"
|
|
||||||
visible:contact.location=="Friendica"? 1:0
|
|
||||||
onClicked:{contactComponent.state="";
|
|
||||||
root.currentIndex=2;
|
|
||||||
fotostab.active=true;
|
|
||||||
root.fotoSignal(contact) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Button{
|
|
||||||
id:messagebutton
|
|
||||||
text:"Messages"
|
|
||||||
onClicked:{contactComponent.state="";
|
|
||||||
root.currentIndex=0;
|
|
||||||
newstab.active=true;
|
|
||||||
root.messageSignal(contact.id) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Button{
|
|
||||||
id:dmbutton
|
|
||||||
visible: contact.following=="true"?true:false
|
|
||||||
text: "DM"
|
|
||||||
onClicked:{contactComponent.state="";
|
|
||||||
root.currentIndex=0;
|
|
||||||
newstab.active=true;
|
|
||||||
root.directmessageSignal(contact.screen_name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Button{
|
|
||||||
id: closeButton
|
|
||||||
text: "close"
|
|
||||||
onClicked:{contactComponent.state=""}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
states: [
|
|
||||||
State {
|
|
||||||
name: "large"
|
|
||||||
PropertyChanges { target: namelabel; font.pixelSize: 4*mm; width:friendsTabView.width-4*mm; text:Qt.atob(contact.name)+" (@"+contact.screen_name+")"}
|
|
||||||
PropertyChanges { target: contactComponent; z: 2 }
|
|
||||||
PropertyChanges { target: wrapper; width:friendsTabView.width-3*mm;height:friendsTabView.height-20*mm}
|
|
||||||
PropertyChanges { target: photoImage; width:15*mm;height:15*mm }
|
|
||||||
PropertyChanges { target:contactComponent.GridView.view;contentY:contactComponent.y;contentX:contactComponent.x;interactive:false}
|
|
||||||
PropertyChanges { target: detailsrectangle; opacity:1 }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,133 +0,0 @@
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick.Controls 1.3
|
|
||||||
import "qrc:/js/service.js" as Service
|
|
||||||
import "qrc:/js/layout.js" as Layoutjs
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: friendComponent
|
|
||||||
property date createdAtDate: new Date(friend.created_at)
|
|
||||||
Rectangle {
|
|
||||||
id: wrapper
|
|
||||||
width: 16*mm
|
|
||||||
height: 15*mm
|
|
||||||
border.color: "grey"
|
|
||||||
color:"white"
|
|
||||||
Image {
|
|
||||||
id: photoImage
|
|
||||||
x:1
|
|
||||||
y:1
|
|
||||||
width: 10*mm
|
|
||||||
height:10*mm
|
|
||||||
source:"file://"+ friend.profile_image
|
|
||||||
}
|
|
||||||
|
|
||||||
Label {
|
|
||||||
id: namelabel
|
|
||||||
x: 1
|
|
||||||
width: wrapper.width-4
|
|
||||||
height: 3*mm
|
|
||||||
text: friend.screen_name
|
|
||||||
anchors.topMargin: 0
|
|
||||||
anchors.left: photoImage.left
|
|
||||||
color: "#303030"
|
|
||||||
font.pixelSize: 3*mm
|
|
||||||
anchors.top: photoImage.bottom
|
|
||||||
}
|
|
||||||
Button{
|
|
||||||
id:infobutton
|
|
||||||
width: 5*mm
|
|
||||||
height: 5*mm
|
|
||||||
text:"?"
|
|
||||||
anchors.left: photoImage.right
|
|
||||||
anchors.leftMargin: 3
|
|
||||||
anchors.topMargin: 3
|
|
||||||
anchors.top: parent.top
|
|
||||||
onClicked:{
|
|
||||||
//print("State: "+ friendComponent.state);
|
|
||||||
friendComponent.state="large"}
|
|
||||||
}
|
|
||||||
Rectangle{
|
|
||||||
id: detailsrectangle
|
|
||||||
anchors.top: namelabel.bottom
|
|
||||||
anchors.topMargin: 2*mm
|
|
||||||
opacity: 0
|
|
||||||
|
|
||||||
Flickable{
|
|
||||||
id:namelabelflickable
|
|
||||||
width: root.width-10*mm
|
|
||||||
height:wrapper.height-27*mm-3
|
|
||||||
boundsBehavior:Flickable.StopAtBounds
|
|
||||||
flickableDirection:Flickable.VerticalFlick
|
|
||||||
contentWidth:width
|
|
||||||
contentHeight: namelabeltext.height
|
|
||||||
clip:true
|
|
||||||
Text{
|
|
||||||
id:namelabeltext
|
|
||||||
//anchors.top: parent.top
|
|
||||||
width: namelabelflickable.width
|
|
||||||
height: implicitHeight
|
|
||||||
font.pixelSize: 3*mm
|
|
||||||
textFormat:Text.RichText
|
|
||||||
wrapMode: Text.Wrap
|
|
||||||
text:"<b>"+qsTr("Description")+": </b> "+Qt.atob(friend.description)+"<br> <b>"+qsTr("Server Type")+":</b> "+friend.location+"<br> <b>"+qsTr("Posts")+":</b> "+friend.statuses_count+
|
|
||||||
"<br> <b>"+qsTr("URL")+":</b> <a href='"+ friend.url+"'>"+friend.url+"</a><br> <b>"+
|
|
||||||
qsTr("Created at")+":</b> "+createdAtDate.toLocaleString(Qt.locale())
|
|
||||||
onLinkActivated: {
|
|
||||||
Qt.openUrlExternally(link)}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Row{
|
|
||||||
anchors.top: namelabelflickable.bottom
|
|
||||||
anchors.topMargin: 2*mm
|
|
||||||
spacing:4
|
|
||||||
|
|
||||||
Button{
|
|
||||||
id:photobutton
|
|
||||||
text:"Photos"
|
|
||||||
visible:friend.location=="Friendica"? 1:0
|
|
||||||
onClicked:{root.currentIndex=2;
|
|
||||||
fotostab.active=true;
|
|
||||||
root.fotoSignal(friend) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Button{
|
|
||||||
id:messagebutton
|
|
||||||
text:"Messages"
|
|
||||||
onClicked:{root.currentIndex=0;
|
|
||||||
newstab.active=true;
|
|
||||||
root.messageSignal(friend.id) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Button{
|
|
||||||
id:dmbutton
|
|
||||||
visible: friend.following=="true"?true:false
|
|
||||||
text: "DM"
|
|
||||||
onClicked:{root.currentIndex=0;
|
|
||||||
newstab.active=true;
|
|
||||||
root.directmessageSignal(friend.screen_name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Button{
|
|
||||||
id: closeButton
|
|
||||||
text: "close"
|
|
||||||
onClicked:{friendComponent.state=""}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
states: [
|
|
||||||
State {
|
|
||||||
name: "large"
|
|
||||||
PropertyChanges { target: namelabel; font.pixelSize: 4*mm; width:friendsTabView.width-4*mm; text:Qt.atob(friend.name)+" (@"+friend.screen_name+")"}
|
|
||||||
PropertyChanges { target: friendComponent; z: 2 }
|
|
||||||
PropertyChanges { target: wrapper; width:friendsTabView.width-3*mm;height:friendsTabView.height-14*mm}
|
|
||||||
PropertyChanges { target: photoImage; width:15*mm;height:15*mm }
|
|
||||||
PropertyChanges { target:friendComponent.GridView.view;contentY:friendComponent.y;contentX:friendComponent.x;interactive:false}
|
|
||||||
PropertyChanges { target: detailsrectangle; opacity:1 }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,126 +0,0 @@
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick.Dialogs 1.2
|
|
||||||
import QtQuick.Controls 1.4
|
|
||||||
import QtQml.Models 2.1
|
|
||||||
import "qrc:/js/service.js" as Service
|
|
||||||
import "qrc:/js/helper.js" as Helperjs
|
|
||||||
|
|
||||||
Rectangle{
|
|
||||||
id:permissionDialog
|
|
||||||
width: 80*mm
|
|
||||||
height:root.height/3
|
|
||||||
|
|
||||||
Text{
|
|
||||||
x:0.5*mm
|
|
||||||
y:0.5*mm
|
|
||||||
text: "Contacts"
|
|
||||||
}
|
|
||||||
ListView {
|
|
||||||
id: contactView
|
|
||||||
x:0.5*mm
|
|
||||||
y:5.5*mm
|
|
||||||
width: 39*mm
|
|
||||||
height:permissionDialog.height-14*mm
|
|
||||||
clip: true
|
|
||||||
spacing: 0
|
|
||||||
model: contactModel
|
|
||||||
delegate: contactItem
|
|
||||||
}
|
|
||||||
|
|
||||||
ListModel{id: contactModel}
|
|
||||||
Component{
|
|
||||||
id:contactItem
|
|
||||||
|
|
||||||
Rectangle{
|
|
||||||
id:contactitemRect
|
|
||||||
width:contactView.width
|
|
||||||
height: 5*mm
|
|
||||||
property string contactstatus:""
|
|
||||||
color: "light blue"
|
|
||||||
border.color:"grey"
|
|
||||||
Text{
|
|
||||||
color:"grey"
|
|
||||||
text:contact.screen_name
|
|
||||||
}
|
|
||||||
onContactstatusChanged:
|
|
||||||
{ if(contactstatus=="positive"){contactsitemRect.color="green"} else if (contactstatus=="negative"){contactsitemRect.color= "red"} else{contactsitemRect.color= "white"}}
|
|
||||||
MouseArea{
|
|
||||||
anchors.fill: parent}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Text{
|
|
||||||
x:20*mm
|
|
||||||
y:0.5*mm
|
|
||||||
text: "Groups"
|
|
||||||
}
|
|
||||||
ListView {
|
|
||||||
id: groupView
|
|
||||||
x:20*mm
|
|
||||||
y:5.5*mm
|
|
||||||
width: 19*mm
|
|
||||||
height:permissionDialog-8*mm
|
|
||||||
clip: true
|
|
||||||
spacing: 0
|
|
||||||
model: groupModel
|
|
||||||
delegate: groupItem
|
|
||||||
}
|
|
||||||
|
|
||||||
ListModel{id: groupModel}
|
|
||||||
Component{
|
|
||||||
id:groupItem
|
|
||||||
|
|
||||||
Rectangle{
|
|
||||||
id:groupitemRect
|
|
||||||
width:groupView.width
|
|
||||||
height: 5*mm
|
|
||||||
property string groupstatus:""
|
|
||||||
color: "white"
|
|
||||||
border.color:"grey"
|
|
||||||
Text{
|
|
||||||
color:"grey"
|
|
||||||
text:group.groupname
|
|
||||||
}
|
|
||||||
onGroupstatusChanged:
|
|
||||||
{ if(groupstatus=="positive"){groupitemRect.color="green"} else if (groupstatus=="negative"){groupitemRect.color= "red"} else{groupitemRect.color= "white"}}
|
|
||||||
MouseArea{
|
|
||||||
anchors.fill: parent
|
|
||||||
onClicked:{
|
|
||||||
if(groupModel.get(index).groupstatus=="neutral"){
|
|
||||||
groupModel.setProperty(index,"groupstatus","positive")}
|
|
||||||
else if (groupModel.get(index).groupstatus=="positive"){
|
|
||||||
groupModel.setProperty(index,"groupstatus","negative")}
|
|
||||||
else{groupModel.setProperty(index,"groupstatus","neutral")}
|
|
||||||
}}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Button{
|
|
||||||
anchors.horizontalCenter: parent.hoizontalCenter
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
anchors.bottomMargin:1
|
|
||||||
text:qsTr("Done")
|
|
||||||
onClicked:{var group_allow=[];
|
|
||||||
for (var i=0;i<groupModel.count;i++)
|
|
||||||
{if (groupModel.get(i).groupstatus=="positive"){
|
|
||||||
group_allow.append(groupModel.get(i).groupname)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print("groups"+JSON.stringify(group_allow))
|
|
||||||
permissionDialog.destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Component.onCompleted:{
|
|
||||||
print("permissiondialog completed");
|
|
||||||
Helperjs.readData(db,"contacts",login.username,function(contacts){
|
|
||||||
for (var name in contacts){
|
|
||||||
print("contact: "+JSON.stringify(contacts[name]));
|
|
||||||
contactModel.append({"contact":contacts[name]})
|
|
||||||
}},"isFriend",1);
|
|
||||||
|
|
||||||
Helperjs.readData(db,"groups",login.username,function(owngroups){
|
|
||||||
for (var number in owngroups){
|
|
||||||
groupModel.append({"group":owngroup[number]})
|
|
||||||
}});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick.Dialogs 1.2
|
|
||||||
import QtQuick.Controls 1.2
|
|
||||||
|
|
||||||
Item {
|
|
||||||
Rectangle{
|
|
||||||
property string photofile:"../images/Update.png"
|
|
||||||
color: "grey"
|
|
||||||
|
|
||||||
FileDialog {
|
|
||||||
id: fileDialog
|
|
||||||
title: "Please choose a file"
|
|
||||||
folder: shortcuts.pictures
|
|
||||||
selectMultiple: true
|
|
||||||
onAccepted: {
|
|
||||||
photofile=fileDialog.fileUrls[0];
|
|
||||||
console.log("You chose: " + fileDialog.fileUrls)
|
|
||||||
// img.src=file;
|
|
||||||
}
|
|
||||||
onRejected: {
|
|
||||||
console.log("Canceled")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Component.onCompleted: {fileDialog.open()}
|
|
||||||
|
|
||||||
Image {
|
|
||||||
id: photoFromFilesystem
|
|
||||||
x: 20;y:50
|
|
||||||
height: 200
|
|
||||||
fillMode: Image.PreserveAspectFit
|
|
||||||
source: photofile
|
|
||||||
|
|
||||||
onStatusChanged:{
|
|
||||||
if (photoFromFilesystem.status == Image.Ready) {
|
|
||||||
Layoutjs.showFriends(db)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Button {
|
|
||||||
text: "Upload"
|
|
||||||
onClicked:{
|
|
||||||
var login=Service.readActiveConfig(db);
|
|
||||||
Service.uploadMedia(login,photofile, function(returnvalue){print("Upload return"+returnvalue)})
|
|
||||||
}}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,7 +4,7 @@ import QtQuick.Controls 1.2
|
||||||
import "qrc:/js/service.js" as Service
|
import "qrc:/js/service.js" as Service
|
||||||
import "qrc:/js/layout.js" as Layoutjs
|
import "qrc:/js/layout.js" as Layoutjs
|
||||||
import "qrc:/js/helper.js" as Helperjs
|
import "qrc:/js/helper.js" as Helperjs
|
||||||
import "qrc:/qml"
|
import "qrc:/qml/configqml"
|
||||||
|
|
||||||
StackView{
|
StackView{
|
||||||
id: configStack
|
id: configStack
|
||||||
|
@ -192,7 +192,9 @@ onCurrentIndexChanged:{
|
||||||
Service.readConfig(db,function(userconfig){Service.getServerConfig(userconfig,configBackground, function(obj){
|
Service.readConfig(db,function(userconfig){Service.getServerConfig(userconfig,configBackground, function(obj){
|
||||||
var serverString=obj;
|
var serverString=obj;
|
||||||
var serverconfigObject=Qt.createQmlObject(serverString,configBackground,"serverconfigOutput");
|
var serverconfigObject=Qt.createQmlObject(serverString,configBackground,"serverconfigOutput");
|
||||||
usermodel.append({text:username.text});
|
Helperjs.readField("username",root.db,"config","",function(users){
|
||||||
|
if(users.indexOf(username.text)==-1){usermodel.append({text:username.text})}});
|
||||||
|
isActiveField.text="yes"
|
||||||
//reset values
|
//reset values
|
||||||
root.login=userconfig;
|
root.login=userconfig;
|
||||||
root.contactlist=[];
|
root.contactlist=[];
|
||||||
|
@ -232,7 +234,7 @@ onCurrentIndexChanged:{
|
||||||
x: root.width/2+14*mm; y: mm; width: 5*mm; height: 5*mm;
|
x: root.width/2+14*mm; y: mm; width: 5*mm; height: 5*mm;
|
||||||
text: "?"
|
text: "?"
|
||||||
onClicked:{
|
onClicked:{
|
||||||
configStack.push({item:"qrc:/qml/InfoBox.qml"});
|
configStack.push({item:"qrc:/qml/configqml/InfoBox.qml"});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
import QtQuick 2.0
|
||||||
|
import QtQuick.Controls 1.3
|
||||||
|
import "qrc:/js/layout.js" as Layoutjs
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: contactComponent
|
||||||
|
property var createdAtDate: new Date(contact.created_at)
|
||||||
|
property var linkUrl: contact.network!=="dfrn"?contact.url:contact.url.replace("profile","dfrn_request")
|
||||||
|
Rectangle {
|
||||||
|
id: wrapper
|
||||||
|
width: 16*mm
|
||||||
|
height: 15*mm
|
||||||
|
border.color: "grey"
|
||||||
|
color:"white"
|
||||||
|
Image {
|
||||||
|
id: photoImage
|
||||||
|
x:1
|
||||||
|
y:1
|
||||||
|
width: 10*mm
|
||||||
|
height:10*mm
|
||||||
|
source:(contact.profile_image!="")? "file://"+contact.profile_image : contact.profile_image_url
|
||||||
|
onStatusChanged: if (photoImage.status == Image.Error) {source="qrc:/images/defaultcontact.jpg"}
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
id: namelabel
|
||||||
|
x: 1
|
||||||
|
width: wrapper.width-4
|
||||||
|
height: 3*mm
|
||||||
|
text: contact.screen_name
|
||||||
|
elide:Text.ElideRight
|
||||||
|
anchors.topMargin: 0
|
||||||
|
anchors.left: photoImage.left
|
||||||
|
color: "#303030"
|
||||||
|
font.pixelSize: 3*mm
|
||||||
|
anchors.top: photoImage.bottom
|
||||||
|
}
|
||||||
|
Button{
|
||||||
|
id:infobutton
|
||||||
|
width: 5*mm
|
||||||
|
height: 5*mm
|
||||||
|
text:"?"
|
||||||
|
anchors.left: photoImage.right
|
||||||
|
anchors.leftMargin: 3
|
||||||
|
anchors.topMargin: 3
|
||||||
|
anchors.top: parent.top
|
||||||
|
onClicked:{
|
||||||
|
contactComponent.state="large";
|
||||||
|
var component = Qt.createComponent("qrc:/qml/contactqml/ContactDetailsComponent.qml");
|
||||||
|
if (component.status== Component.Ready){
|
||||||
|
var contactDetails = component.createObject(wrapper,{"contact": contact})}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
states: [
|
||||||
|
State {
|
||||||
|
name: "large"
|
||||||
|
PropertyChanges { target: namelabel; font.pixelSize: 4*mm; width:friendsTabView.width-4*mm; text:Qt.atob(contact.name)+" (@"+contact.screen_name+")"}
|
||||||
|
PropertyChanges { target: contactComponent; z: 2 }
|
||||||
|
PropertyChanges { target: wrapper; width:friendsTabView.width-3*mm;height:friendsTabView.height-20*mm}
|
||||||
|
PropertyChanges { target: photoImage; width:15*mm;height:15*mm }
|
||||||
|
PropertyChanges { target:contactComponent.GridView.view;contentY:contactComponent.y;contentX:contactComponent.x;interactive:false}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
import QtQuick 2.0
|
||||||
|
import QtQuick.Controls 1.3
|
||||||
|
|
||||||
|
Rectangle{
|
||||||
|
id: detailsrectangle
|
||||||
|
anchors.top: namelabel.bottom
|
||||||
|
anchors.topMargin: 2*mm
|
||||||
|
//opacity: 0
|
||||||
|
|
||||||
|
Flickable{
|
||||||
|
id:namelabelflickable
|
||||||
|
width: root.width-10*mm
|
||||||
|
height:friendsTabView.height-55*mm
|
||||||
|
boundsBehavior:Flickable.StopAtBounds
|
||||||
|
flickableDirection:Flickable.VerticalFlick
|
||||||
|
contentWidth:width
|
||||||
|
contentHeight: namelabeltext.height
|
||||||
|
clip:true
|
||||||
|
Text{
|
||||||
|
id:namelabeltext
|
||||||
|
width: namelabelflickable.width
|
||||||
|
height: implicitHeight
|
||||||
|
font.pixelSize: 3*mm
|
||||||
|
textFormat:Text.RichText
|
||||||
|
wrapMode: Text.Wrap
|
||||||
|
text:"<b>"+qsTr("Description")+": </b> "+Qt.atob(contact.description)+"<br> <b>"+qsTr("Server Type")+":</b> "+contact.location+"<br> <b>"+qsTr("Posts")+":</b> "+contact.statuses_count+
|
||||||
|
"<br> <b>"+qsTr("URL")+":</b> <a href='"+ linkUrl+"'>"+linkUrl+"</a><br> <b>"+
|
||||||
|
qsTr("Created at")+":</b> "+createdAtDate.toLocaleString(Qt.locale())
|
||||||
|
onLinkActivated: {
|
||||||
|
Qt.openUrlExternally(link)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Row{
|
||||||
|
anchors.top: namelabelflickable.bottom
|
||||||
|
anchors.topMargin: 2*mm
|
||||||
|
spacing:4
|
||||||
|
|
||||||
|
Button{
|
||||||
|
id:photobutton
|
||||||
|
text:"Photos"
|
||||||
|
visible:contact.location=="Friendica"? 1:0
|
||||||
|
onClicked:{contactComponent.state="";detailsrectangle.destroy();
|
||||||
|
root.currentIndex=2;
|
||||||
|
fotostab.active=true;
|
||||||
|
root.fotoSignal(contact) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Button{
|
||||||
|
id:messagebutton
|
||||||
|
text:"Messages"
|
||||||
|
onClicked:{contactComponent.state="";detailsrectangle.destroy();
|
||||||
|
root.currentIndex=0;
|
||||||
|
newstab.active=true;
|
||||||
|
root.messageSignal(contact.id) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Button{
|
||||||
|
id:dmbutton
|
||||||
|
visible: contact.following=="true"?true:false
|
||||||
|
text: "DM"
|
||||||
|
onClicked:{contactComponent.state="";detailsrectangle.destroy();
|
||||||
|
root.currentIndex=0;
|
||||||
|
newstab.active=true;
|
||||||
|
root.directmessageSignal(contact.screen_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Button{
|
||||||
|
id: closeButton
|
||||||
|
text: "close"
|
||||||
|
onClicked:{contactComponent.state="";detailsrectangle.destroy()}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,7 +5,7 @@ import QtQuick.Controls.Styles 1.4
|
||||||
import "qrc:/js/service.js" as Service
|
import "qrc:/js/service.js" as Service
|
||||||
import "qrc:/js/helper.js" as Helperjs
|
import "qrc:/js/helper.js" as Helperjs
|
||||||
import "qrc:/js/news.js" as Newsjs
|
import "qrc:/js/news.js" as Newsjs
|
||||||
import "qrc:/qml"
|
import "qrc:/qml/contactqml"
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
y:1
|
y:1
|
|
@ -16,10 +16,10 @@ import "qrc:/qml"
|
||||||
TabView{
|
TabView{
|
||||||
id:root
|
id:root
|
||||||
tabPosition: Qt.BottomEdge
|
tabPosition: Qt.BottomEdge
|
||||||
width: 400//Screen.desktopAvailableWidth
|
width: 500//Screen.desktopAvailableWidth
|
||||||
height: 400// Screen.desktopAvailableHeight
|
height: 500// Screen.desktopAvailableHeight
|
||||||
|
|
||||||
property var db: ["Photos", "1.0", "Stores Friendica data", 100000000]
|
property var db: ["Friendiqa", "1.0", "Stores Friendica data", 100000000]
|
||||||
property var login: Service.readActiveConfig(db)
|
property var login: Service.readActiveConfig(db)
|
||||||
property var contactlist: []
|
property var contactlist: []
|
||||||
property real mm: Screen.pixelDensity
|
property real mm: Screen.pixelDensity
|
||||||
|
@ -44,7 +44,7 @@ TabView{
|
||||||
updateContactInDB(login,db,newContacts[currentContact].isFriend,newContacts[currentContact])}
|
updateContactInDB(login,db,newContacts[currentContact].isFriend,newContacts[currentContact])}
|
||||||
}
|
}
|
||||||
onCurrentContactChanged:{// download next contact image after photoplaceholder is finished saving and update db
|
onCurrentContactChanged:{// download next contact image after photoplaceholder is finished saving and update db
|
||||||
//print("Current contact"+JSON.stringify(newContacts[currentContact]));
|
//print("Current contact"+JSON.stringify(newContacts[currentContact])+newContacts.length);
|
||||||
if(currentContact<newContacts.length){
|
if(currentContact<newContacts.length){
|
||||||
updateContactInDB(login,db,newContacts[currentContact].isFriend,newContacts[currentContact])}
|
updateContactInDB(login,db,newContacts[currentContact].isFriend,newContacts[currentContact])}
|
||||||
else if(currentContact==newContacts.length){//newImagesProgress.visible=false;
|
else if(currentContact==newContacts.length){//newImagesProgress.visible=false;
|
||||||
|
@ -67,22 +67,23 @@ TabView{
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateContactInDB(login,database,isFriend,contact){// for newstab and friendstab
|
function updateContactInDB(login,database,isFriend,contact){// for newstab and friendstab
|
||||||
var imagename=login.imagestore+"contacts/"+contact.screen_name.trim()+".jpg";
|
var suffix=contact.profile_image_url.substring(contact.profile_image_url.lastIndexOf("."), contact.profile_image_url.length);
|
||||||
if (isFriend==1){
|
var imagename=login.imagestore+"contacts/"+contact.screen_name.trim()+suffix;
|
||||||
|
// if (isFriend==1){
|
||||||
xhr.setUrl(Qt.resolvedUrl(contact.profile_image_url));
|
xhr.setUrl(Qt.resolvedUrl(contact.profile_image_url));
|
||||||
xhr.setFilename(imagename);
|
xhr.setFilename(imagename);
|
||||||
xhr.download();
|
xhr.download();
|
||||||
}
|
//}
|
||||||
var db=LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
var db=LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||||
var result;
|
var result;
|
||||||
db.transaction( function(tx) {
|
db.transaction( function(tx) {
|
||||||
result = tx.executeSql('SELECT * from contacts where id = '+contact.id); // check for news id
|
result = tx.executeSql('SELECT * from contacts where username="'+root.login.username+'" AND id = '+contact.id); // check for news id
|
||||||
if(result.rows.length === 1) {// use update
|
if(result.rows.length === 1) {// use update
|
||||||
result = tx.executeSql('UPDATE contacts SET username="'+login.username+'", id='+contact.id+', name="'+Qt.btoa(contact.name)+'", screen_name="'+contact.screen_name+'", location="'+contact.location+'", profile_image_url="'+contact.profile_image_url+'", description="'+Qt.btoa(contact.description)+'", profile_image="'+imagename+'", url="'+contact.url+'" , protected="'+contact.protected+'", followers_count='+contact.followers_count+', friends_count='+contact.friends_count+', created_at="'+ Date.parse(Newsjs.cleanDate(contact.created_at))+'", favourites_count="'+contact.favorites_count+'", utc_offset="'+contact.utc_offset+'", time_zone="'+contact.time_zone+'", statuses_count='+contact.statuses_count+', following="'+contact.following+'", verified ="'+contact.verified+'", statusnet_blocking="'+contact.statusnet_blocking+'", notifications="'+contact.notifictions+'", statusnet_profile_url="'+contact.statusnet_profile_url+'", cid='+contact.cid+', network="'+contact.network+'", isFriend='+isFriend+' where id='+contact.id);
|
result = tx.executeSql('UPDATE contacts SET username="'+login.username+'", id='+contact.id+', name="'+Qt.btoa(contact.name)+'", screen_name="'+contact.screen_name+'", location="'+contact.location+'", profile_image_url="'+contact.profile_image_url+'", description="'+Qt.btoa(contact.description)+'", profile_image="'+imagename+'", url="'+contact.url+'" , protected="'+contact.protected+'", followers_count='+contact.followers_count+', friends_count='+contact.friends_count+', created_at="'+ Date.parse(Newsjs.cleanDate(contact.created_at))+'", favourites_count="'+contact.favorites_count+'", utc_offset="'+contact.utc_offset+'", time_zone="'+contact.time_zone+'", statuses_count='+contact.statuses_count+', following="'+contact.following+'", verified ="'+contact.verified+'", statusnet_blocking="'+contact.statusnet_blocking+'", notifications="'+contact.notifictions+'", statusnet_profile_url="'+contact.statusnet_profile_url+'", cid='+contact.cid+', network="'+contact.network+'", isFriend='+isFriend+' where username="'+root.login.username+'" AND id='+contact.id);
|
||||||
} else {// use insert
|
} else {// use insert
|
||||||
result = tx.executeSql('INSERT INTO contacts VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,contact.id,Qt.btoa(contact.name),contact.screen_name,contact.location,contact.profile_image_url, Qt.btoa(contact.description),imagename,contact.url,contact.protected,contact.followers_count, contact.friends_count,Date.parse(Newsjs.cleanDate(contact.created_at)),contact.favorites_count,contact.utc_offset,contact.time_zone,contact.statuses_count,contact.following,contact.verfied,contact.statusnet_blocking,contact.notifications,contact.statusnet_profile_url,contact.cid,contact.network,isFriend]);}
|
result = tx.executeSql('INSERT INTO contacts VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,contact.id,Qt.btoa(contact.name),contact.screen_name,contact.location,contact.profile_image_url, Qt.btoa(contact.description),imagename,contact.url,contact.protected,contact.followers_count, contact.friends_count,Date.parse(Newsjs.cleanDate(contact.created_at)),contact.favorites_count,contact.utc_offset,contact.time_zone,contact.statuses_count,contact.following,contact.verfied,contact.statusnet_blocking,contact.notifications,contact.statusnet_profile_url,contact.cid,contact.network,isFriend]);}
|
||||||
});
|
});
|
||||||
if (isFriend!=1){root.currentContact=root.currentContact+1}
|
//if (isFriend!=1){root.currentContact=root.currentContact+1}
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections{
|
Connections{
|
||||||
|
@ -91,7 +92,14 @@ TabView{
|
||||||
}
|
}
|
||||||
Connections{
|
Connections{
|
||||||
target:xhr
|
target:xhr
|
||||||
onError:{print("Error"+data)}
|
onError:{print("Error"+data);
|
||||||
|
var database=LocalStorage.openDatabaseSync(root.db[0],root.db[1],root.db[2],root.db[3]);
|
||||||
|
var result;
|
||||||
|
database.transaction( function(tx) {
|
||||||
|
print("Error for "+JSON.stringify(newContacts[currentContact]));
|
||||||
|
//print('UPDATE contacts SET profile_image="" where username="'+root.login.username+'" AND id = '+newContacts[currentContact].id);
|
||||||
|
result = tx.executeSql('UPDATE contacts SET profile_image="" where username="'+root.login.username+'" AND id = '+newContacts[currentContact].id);
|
||||||
|
root.currentContact=root.currentContact+1})}
|
||||||
}
|
}
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (login==""){Service.initDatabase(db)}
|
if (login==""){Service.initDatabase(db)}
|
||||||
|
@ -121,24 +129,24 @@ style: TabViewStyle {
|
||||||
title: qsTr("News")
|
title: qsTr("News")
|
||||||
id: newstab
|
id: newstab
|
||||||
property string newstabStatus:"news"
|
property string newstabStatus:"news"
|
||||||
source: "qrc:/qml/NewsTab.qml"
|
source: "qrc:/qml/newsqml/NewsTab.qml"
|
||||||
}
|
}
|
||||||
|
|
||||||
Tab{
|
Tab{
|
||||||
title: qsTr("Contacts")
|
title: qsTr("Contacts")
|
||||||
id: friendstab
|
id: friendstab
|
||||||
source: "qrc:/qml/FriendsTab.qml"
|
source: "qrc:/qml/contactqml/FriendsTab.qml"
|
||||||
}
|
}
|
||||||
Tab{
|
Tab{
|
||||||
title: qsTr("Photos")
|
title: qsTr("Photos")
|
||||||
id: fotostab
|
id: fotostab
|
||||||
source: "qrc:/qml/PhotoTab.qml"
|
source: "qrc:/qml/photoqml/PhotoTab.qml"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Tab{
|
Tab{
|
||||||
title: qsTr("Config")
|
title: qsTr("Config")
|
||||||
source: "qrc:/qml/ConfigTab.qml"
|
source: "qrc:/qml/configqml/ConfigTab.qml"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,20 +17,23 @@ Item{
|
||||||
property int directmessage: 0;
|
property int directmessage: 0;
|
||||||
property var contacts: []
|
property var contacts: []
|
||||||
property var groups: []
|
property var groups: []
|
||||||
property string contact_allow:""
|
property var contact_allow:[]
|
||||||
property string contact_deny:""
|
property var contact_deny:[]
|
||||||
property string group_allow:""
|
property var group_allow:[]
|
||||||
property string group_deny:""
|
property var group_deny:[]
|
||||||
|
|
||||||
function statusUpdate(title,status,in_reply_to_status_id,attachImageURL) {
|
function statusUpdate(title,status,in_reply_to_status_id,attachImageURL) {
|
||||||
xhr.url= login.server + "/api/statuses/update.xml";
|
xhr.url= login.server + "/api/statuses/update.xml";
|
||||||
xhr.setLogin(login.username+":"+Qt.atob(login.password));
|
xhr.setLogin(login.username+":"+Qt.atob(login.password));
|
||||||
print("login: "+login.username+":"+Qt.atob(login.password));
|
|
||||||
xhr.clearParams();
|
xhr.clearParams();
|
||||||
xhr.setParam("source", "Friendiqa");
|
xhr.setParam("source", "Friendiqa");
|
||||||
xhr.setParam("status", status);
|
xhr.setParam("status", status);
|
||||||
if (parentId!="") {xhr.setParam("in_reply_to_status_id", parentid)};
|
if (parentId!="") {xhr.setParam("in_reply_to_status_id", parentId)};
|
||||||
if (title!=="") {xhr.setParam("title", title)};
|
if (title!=="") {xhr.setParam("title", title)};
|
||||||
|
if (group_allow.length>0) {xhr.setParam("group_allow", Helperjs.cleanArray(group_allow))};
|
||||||
|
if (group_deny.length>0) {xhr.setParam("group_deny", Helperjs.cleanArray(group_deny))};
|
||||||
|
if (contact_allow.length>0) {xhr.setParam("contact_allow", Helperjs.cleanArray(contact_allow))};
|
||||||
|
if (contact_deny.length>0) {xhr.setParam("contact_deny", Helperjs.cleanArray(contact_deny))};
|
||||||
if (attachImageURL!=="") {xhr.setImageFileParam("media", attachImageURL )};
|
if (attachImageURL!=="") {xhr.setImageFileParam("media", attachImageURL )};
|
||||||
xhr.post();
|
xhr.post();
|
||||||
}
|
}
|
||||||
|
@ -63,7 +66,7 @@ Item{
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: 30*mm
|
height: 30*mm
|
||||||
wrapMode: TextEdit.Wrap
|
wrapMode: TextEdit.Wrap
|
||||||
textFormat: TextEdit.RichText
|
textFormat: TextEdit.PlainText
|
||||||
}
|
}
|
||||||
|
|
||||||
Row{
|
Row{
|
||||||
|
@ -118,12 +121,11 @@ Item{
|
||||||
Row{
|
Row{
|
||||||
spacing:2
|
spacing:2
|
||||||
Button{
|
Button{
|
||||||
|
visible: (directmessage==1)?false:true
|
||||||
text:qsTr("Permissions")
|
text:qsTr("Permissions")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
var component = Qt.createComponent("qrc:/qml/PermissionDialog.qml");
|
var component = Qt.createComponent("qrc:/qml/newsqml/PermissionDialog.qml");
|
||||||
var sprite = component.createObject(messageColumn);
|
var permissions = component.createObject(messageColumn);
|
||||||
if (sprite == null) { // Error Handling
|
|
||||||
console.log("Error creating object"); }
|
|
||||||
}}
|
}}
|
||||||
Button {
|
Button {
|
||||||
id: attachButton
|
id: attachButton
|
||||||
|
@ -169,7 +171,9 @@ Item{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Keys.onReleased: {if (event.key === Qt.Key_Back && stackView.depth > 1) {
|
||||||
|
stackView.pop(); event.accepted = true;
|
||||||
|
}}
|
||||||
FileDialog {
|
FileDialog {
|
||||||
id: imageAttachmentDialog
|
id: imageAttachmentDialog
|
||||||
title: "Please choose a picture"
|
title: "Please choose a picture"
|
|
@ -22,7 +22,7 @@ Item {
|
||||||
|
|
||||||
function onDirectMessage(friend){
|
function onDirectMessage(friend){
|
||||||
print(root.login.server);
|
print(root.login.server);
|
||||||
newsStack.push({item:"qrc:/qml/MessageSend.qml",properties:{"reply_to_user": friend,"directmessage":1,"login":root.login}});
|
newsStack.push({item:"qrc:/qml/newsqml/MessageSend.qml",properties:{"reply_to_user": friend,"directmessage":1,"login":root.login}});
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanNews(database){
|
function cleanNews(database){
|
||||||
|
@ -43,9 +43,16 @@ Item {
|
||||||
id: newsStack
|
id: newsStack
|
||||||
anchors.fill:parent
|
anchors.fill:parent
|
||||||
focus: true
|
focus: true
|
||||||
Keys.onReleased: if (event.key === Qt.Key_Back && stackView.depth > 1) {
|
Keys.onReleased: {if (event.key === Qt.Key_Back && stackView.depth > 1) {
|
||||||
stackView.pop(); event.accepted = true;
|
stackView.pop(); event.accepted = true;
|
||||||
}
|
}
|
||||||
|
else if(event.key === Qt.Key_Back &&newstabStatus=="conversation"){
|
||||||
|
newstabStatus="news"
|
||||||
|
newsModel.clear();
|
||||||
|
Newsjs.newsfromdb(root.db,root.login.username, function(dbnews){
|
||||||
|
showNews(dbnews)
|
||||||
|
})}
|
||||||
|
}
|
||||||
initialItem:Rectangle {
|
initialItem:Rectangle {
|
||||||
y:1
|
y:1
|
||||||
color: "white"
|
color: "white"
|
||||||
|
@ -68,10 +75,9 @@ Item {
|
||||||
else if (currentIndex==1){
|
else if (currentIndex==1){
|
||||||
newsBusy.running=true;
|
newsBusy.running=true;
|
||||||
Newsjs.requestFavorites(root.login,db,root,function(news){
|
Newsjs.requestFavorites(root.login,db,root,function(news){
|
||||||
JSON.stringify("Favorites: "+news);
|
|
||||||
Newsjs.storeNews(root.login,root.db,news,root,function(){
|
Newsjs.storeNews(root.login,root.db,news,root,function(){
|
||||||
Newsjs.favoritesfromdb(db,root.login.username,function(newsarray){
|
Newsjs.favoritesfromdb(db,root.login.username,function(newsarray){
|
||||||
JSON.stringify("FavoritesArray: "+newsarray);showNews(newsarray)
|
showNews(newsarray)
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -89,7 +95,7 @@ Item {
|
||||||
Helperjs.readData(root.db,"groups",root.login.username,function(groupobject){
|
Helperjs.readData(root.db,"groups",root.login.username,function(groupobject){
|
||||||
groups=groupobject});
|
groups=groupobject});
|
||||||
Helperjs.readData(root.db,"contacts",root.login.username,function(friends){
|
Helperjs.readData(root.db,"contacts",root.login.username,function(friends){
|
||||||
newsStack.push({item:"qrc:/qml/MessageSend.qml",properties:{"contacts": friends,"login":root.login}})
|
newsStack.push({item:"qrc:/qml/newsqml/MessageSend.qml",properties:{"contacts": friends,"login":root.login}})
|
||||||
},"isFriend",1);
|
},"isFriend",1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,9 +172,9 @@ Item {
|
||||||
}
|
}
|
||||||
BusyIndicator{
|
BusyIndicator{
|
||||||
id: newsBusy
|
id: newsBusy
|
||||||
anchors.centerIn:update
|
anchors.horizontalCenter: newsView.horizontalCenter
|
||||||
//anchors.right: update.left
|
anchors.top:parent.top
|
||||||
//anchors.top:parent.top
|
anchors.topMargin: 2*mm
|
||||||
width:7*mm
|
width:7*mm
|
||||||
height: 7*mm
|
height: 7*mm
|
||||||
}
|
}
|
|
@ -29,7 +29,7 @@ Item {
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
id:profileImage
|
id:profileImage
|
||||||
source:(newsitemobject.user.isFriend==1)? "file://"+newsitemobject.user.profile_image : newsitemobject.user.profile_image_url
|
source: (newsitemobject.user.profile_image!="")? "file://"+newsitemobject.user.profile_image : newsitemobject.user.profile_image_url
|
||||||
x:1
|
x:1
|
||||||
width: 7*mm
|
width: 7*mm
|
||||||
height: 7*mm
|
height: 7*mm
|
||||||
|
@ -91,12 +91,6 @@ Item {
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
checked:(newsitemobject.favorited>0)
|
checked:(newsitemobject.favorited>0)
|
||||||
Text{
|
|
||||||
anchors.left: parent.right
|
|
||||||
color: "grey"
|
|
||||||
font.pixelSize: 1.5*mm
|
|
||||||
text: (newsitemobject.favorited>0)? newsitemobject.favorited+qsTr(" Favorites"):""
|
|
||||||
}
|
|
||||||
onClicked:{
|
onClicked:{
|
||||||
if(favoritedCheckbox.checkedState==Qt.Checked)
|
if(favoritedCheckbox.checkedState==Qt.Checked)
|
||||||
{Newsjs.favorite(login,true,newsitemobject.status_id,root)}
|
{Newsjs.favorite(login,true,newsitemobject.status_id,root)}
|
||||||
|
@ -125,6 +119,7 @@ Item {
|
||||||
Rectangle{
|
Rectangle{
|
||||||
width: 4*mm
|
width: 4*mm
|
||||||
height: 3*mm
|
height: 3*mm
|
||||||
|
visible:(newsitemobject.in_reply_to_status_id!="")?true:false
|
||||||
Text{
|
Text{
|
||||||
id:conversationsymbol
|
id:conversationsymbol
|
||||||
color: "grey"
|
color: "grey"
|
||||||
|
@ -138,17 +133,18 @@ Item {
|
||||||
newsBusy.running=true;
|
newsBusy.running=true;
|
||||||
Newsjs.requestConversation(root.login,db,newsitemobject.status_id,root.contactlist,root,function(news,newContacts){
|
Newsjs.requestConversation(root.login,db,newsitemobject.status_id,root.contactlist,root,function(news,newContacts){
|
||||||
for (var i=0;i<newContacts.length;i++){
|
for (var i=0;i<newContacts.length;i++){
|
||||||
root.updateContactInDB(root.login,root.db,0,newContacts[i])
|
root.updateContactInDB(root.login,root.db,0,newContacts[i])
|
||||||
}
|
}
|
||||||
Newsjs.storeNews(root.login,root.db,news,root,function(){
|
Newsjs.storeNews(root.login,root.db,news,root,function(){
|
||||||
var currentTime= new Date();
|
var currentTime= new Date();
|
||||||
Newsjs.conversationfromdb(db,root.login.username,newsitemobject.statusnet_conversation_id, function(newsarray){
|
Newsjs.conversationfromdb(db,root.login.username,newsitemobject.statusnet_conversation_id, function(newsarray){
|
||||||
newsModel.clear();
|
newsModel.clear();
|
||||||
var msg = {'currentTime': currentTime, 'model': newsModel,'news':newsarray,'latestmessage':0};
|
newstab.newstabStatus="conversation";
|
||||||
newsWorker.sendMessage(msg);
|
var msg = {'currentTime': currentTime, 'model': newsModel,'news':newsarray,'latestmessage':0};
|
||||||
newsBusy.running=false
|
newsWorker.sendMessage(msg);
|
||||||
});
|
newsBusy.running=false
|
||||||
}
|
})
|
||||||
|
}
|
||||||
)})
|
)})
|
||||||
}}
|
}}
|
||||||
}}
|
}}
|
||||||
|
@ -192,6 +188,7 @@ Item {
|
||||||
CheckBox{id:likeCheckbox
|
CheckBox{id:likeCheckbox
|
||||||
height:3*mm
|
height:3*mm
|
||||||
width:8*mm
|
width:8*mm
|
||||||
|
visible: (newsitemobject.messagetype==0)? true:false
|
||||||
checked:(friendica_activities.self.liked)?true:false
|
checked:(friendica_activities.self.liked)?true:false
|
||||||
style: CheckBoxStyle {
|
style: CheckBoxStyle {
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
|
@ -218,6 +215,7 @@ Item {
|
||||||
CheckBox{id: dislikeCheckbox
|
CheckBox{id: dislikeCheckbox
|
||||||
height:3*mm
|
height:3*mm
|
||||||
width:8*mm
|
width:8*mm
|
||||||
|
visible: (newsitemobject.messagetype==0)? true:false
|
||||||
checked: (friendica_activities.self.disliked)?true:false
|
checked: (friendica_activities.self.disliked)?true:false
|
||||||
style: CheckBoxStyle {
|
style: CheckBoxStyle {
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
|
@ -267,7 +265,9 @@ Item {
|
||||||
MenuItem {
|
MenuItem {
|
||||||
text: qsTr("Reply")
|
text: qsTr("Reply")
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
newsStack.push({item:"qrc:/qml/MessageSend.qml",properties:{"reply_to_user": newsitemobject.user.screen_name,"parentId":newsitemobject.status_id,"login":root.login}});
|
var directmessage=0;
|
||||||
|
if (newsitemobject.messagetype==1){ directmessage=1}
|
||||||
|
newsStack.push({item:"qrc:/qml/newsqml/MessageSend.qml",properties:{"reply_to_user": newsitemobject.user.screen_name,"parentId":newsitemobject.status_id,"login":root.login,"directmessage":directmessage}});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MenuItem {
|
MenuItem {
|
||||||
|
@ -325,7 +325,7 @@ Menu{
|
||||||
MenuItem {
|
MenuItem {
|
||||||
text: qsTr("Delete")
|
text: qsTr("Delete")
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
Newsjs.deleteNews(root.login,root.db,newsitemobject.status_id,root,function(reply){
|
Newsjs.deleteNews(root.login,root.db,newsitemobject.status_id,newsitemobject.messagetype,root,function(reply){
|
||||||
print("Deleted "+reply);
|
print("Deleted "+reply);
|
||||||
newsModel.remove(index);
|
newsModel.remove(index);
|
||||||
})
|
})
|
156
v0.002/Develop/source-linux/qml/newsqml/PermissionDialog.qml
Normal file
156
v0.002/Develop/source-linux/qml/newsqml/PermissionDialog.qml
Normal file
|
@ -0,0 +1,156 @@
|
||||||
|
import QtQuick 2.0
|
||||||
|
import QtQuick.Dialogs 1.2
|
||||||
|
import QtQuick.Controls 1.4
|
||||||
|
import QtQml.Models 2.1
|
||||||
|
import "qrc:/js/service.js" as Service
|
||||||
|
import "qrc:/js/helper.js" as Helperjs
|
||||||
|
|
||||||
|
Rectangle{
|
||||||
|
id:permissionDialog
|
||||||
|
x: mm
|
||||||
|
width: messageColumn.width-5*mm
|
||||||
|
height:root.height/3
|
||||||
|
|
||||||
|
Text{
|
||||||
|
x:0.5*mm
|
||||||
|
y:0.5*mm
|
||||||
|
text: "Contacts"
|
||||||
|
}
|
||||||
|
ListView {
|
||||||
|
id: contactView
|
||||||
|
x:0.5*mm
|
||||||
|
y:5.5*mm
|
||||||
|
width: permissionDialog.width/2-2*mm
|
||||||
|
height: permissionDialog.height-14*mm
|
||||||
|
clip: true
|
||||||
|
spacing: 1
|
||||||
|
model: contactModel
|
||||||
|
delegate: contactItem
|
||||||
|
}
|
||||||
|
|
||||||
|
ListModel{id: contactModel}
|
||||||
|
Component{
|
||||||
|
id:contactItem
|
||||||
|
Rectangle{
|
||||||
|
id:contactitemRect
|
||||||
|
width:contactView.width
|
||||||
|
height: 5*mm
|
||||||
|
property string contactstatus:"neutral"
|
||||||
|
onContactstatusChanged:
|
||||||
|
{if(contactstatus=="positive"){contactitemRect.color="light green"}
|
||||||
|
else if (contactstatus=="negative"){contactitemRect.color= "light red"}
|
||||||
|
else{contactitemRect.color= "white"}}
|
||||||
|
color: "white"
|
||||||
|
border.color:"grey"
|
||||||
|
Text{
|
||||||
|
color:"grey"
|
||||||
|
text:contact.screen_name
|
||||||
|
}
|
||||||
|
MouseArea{
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked:{
|
||||||
|
if(contactModel.get(index).contactstatus=="neutral"){
|
||||||
|
contactModel.set(index,{"contactstatus":"positive"});
|
||||||
|
contactstatus="positive"
|
||||||
|
}
|
||||||
|
else if (contactModel.get(index).contactstatus=="positive"){
|
||||||
|
contactModel.set(index,{"contactstatus":"negative"})
|
||||||
|
contactstatus="negative"
|
||||||
|
}
|
||||||
|
else{contactModel.set(index,{"contactstatus":"neutral"});
|
||||||
|
contactstatus="neutral";
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Text{
|
||||||
|
x:contactView.width+2*mm
|
||||||
|
y:0.5*mm
|
||||||
|
text: "Groups"
|
||||||
|
}
|
||||||
|
ListView {
|
||||||
|
id: groupView
|
||||||
|
x:contactView.width+2*mm
|
||||||
|
y:5.5*mm
|
||||||
|
width: permissionDialog.width/2-2*mm
|
||||||
|
height: permissionDialog.height-14*mm
|
||||||
|
clip: true
|
||||||
|
spacing: 1
|
||||||
|
model: groupModel
|
||||||
|
delegate: groupItem
|
||||||
|
}
|
||||||
|
|
||||||
|
ListModel{id: groupModel}
|
||||||
|
Component{
|
||||||
|
id:groupItem
|
||||||
|
Rectangle{
|
||||||
|
id:groupitemRect
|
||||||
|
width:groupView.width
|
||||||
|
height: 5*mm
|
||||||
|
property string groupstatus:"neutral"
|
||||||
|
onGroupstatusChanged:
|
||||||
|
{if(groupstatus=="positive"){groupitemRect.color="light green"}
|
||||||
|
else if (groupstatus=="negative"){groupitemRect.color= "light red"}
|
||||||
|
else{groupitemRect.color= "white"}}
|
||||||
|
color: "white"
|
||||||
|
border.color:"grey"
|
||||||
|
Text{
|
||||||
|
color:"grey"
|
||||||
|
text:group.groupname
|
||||||
|
}
|
||||||
|
MouseArea{
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked:{
|
||||||
|
if(groupModel.get(index).groupstatus=="neutral"){
|
||||||
|
groupModel.set(index,{"groupstatus":"positive"});
|
||||||
|
groupstatus="positive"}
|
||||||
|
else if (groupModel.get(index).groupstatus=="positive"){
|
||||||
|
groupModel.set(index,{"groupstatus":"negative"});
|
||||||
|
groupstatus="negative"}
|
||||||
|
else{groupModel.set(index,{"groupstatus":"neutral"})
|
||||||
|
groupstatus="neutral"}
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Button{
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.bottomMargin:1
|
||||||
|
text:qsTr("Done")
|
||||||
|
onClicked:{//var group_allow=[];var group_deny=[];
|
||||||
|
for (var i=0;i<groupModel.count;i++)
|
||||||
|
{if (groupModel.get(i).groupstatus=="positive"){
|
||||||
|
group_allow.push(groupModel.get(i).group.gid)
|
||||||
|
}
|
||||||
|
if (groupModel.get(i).groupstatus=="negative"){
|
||||||
|
group_deny.push(groupModel.get(i).group.gid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (var j=0;j<contactModel.count;j++)
|
||||||
|
{//print("contact: "+JSON.stringify(contactModel.get(j).contact));
|
||||||
|
if (contactModel.get(j).contactstatus=="positive"){
|
||||||
|
print(JSON.stringify(contact_allow));
|
||||||
|
contact_allow.push(contactModel.get(j).contact.cid)
|
||||||
|
}
|
||||||
|
if (contactModel.get(j).contactstatus=="negative"){
|
||||||
|
contact_deny.push(contactModel.get(j).contact.cid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//print("contacts: "+Helperjs.cleanArray(contact_allow))
|
||||||
|
permissionDialog.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted:{
|
||||||
|
Helperjs.readData(db,"contacts",login.username,function(contacts){
|
||||||
|
for (var name in contacts){
|
||||||
|
contactModel.append({"contact":contacts[name],"contactstatus":"neutral"})
|
||||||
|
}},"isFriend",1);
|
||||||
|
|
||||||
|
Helperjs.readData(db,"groups",login.username,function(owngroups){
|
||||||
|
for (var number in owngroups){
|
||||||
|
groupModel.append({"group":owngroups[number],"groupstatus":"neutral"})
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,7 +4,7 @@ import QtQuick.Controls 1.4
|
||||||
import QtQml.Models 2.1
|
import QtQml.Models 2.1
|
||||||
import "qrc:/js/service.js" as Service
|
import "qrc:/js/service.js" as Service
|
||||||
import "qrc:/js/helper.js" as Helperjs
|
import "qrc:/js/helper.js" as Helperjs
|
||||||
import "qrc:/qml"
|
import "qrc:/qml/photoqml"
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id:fotorectangle
|
id:fotorectangle
|
Loading…
Reference in a new issue