Version 0.002 with working Permissions
This commit is contained in:
parent
571c9046d0
commit
15e2e8f60a
62 changed files with 924 additions and 1277 deletions
|
@ -79,5 +79,7 @@ ToDo
|
|||
|
||||
|
||||
## License ##
|
||||
v0.001 for Friendica < 3.5
|
||||
v0.002 for Friendica >= 3.5
|
||||
Pubished under the [GPL v3](http://gplv3.fsf.org).
|
||||
|
||||
|
|
Binary file not shown.
|
@ -1,6 +1,6 @@
|
|||
<?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">
|
||||
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="Friendiqa" android:icon="@drawable/icon">
|
||||
<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">
|
||||
<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>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
|
@ -42,7 +42,7 @@
|
|||
<!-- Background running -->
|
||||
</activity>
|
||||
</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"/>
|
||||
|
||||
<!-- 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>
|
||||
<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/photoworker.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/newsworker.js</file>
|
||||
<file>js/helper.js</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>
|
||||
</RCC>
|
||||
|
|
|
@ -14,7 +14,7 @@ XHR *XHR::instance()
|
|||
|
||||
XHR::XHR(QObject *parent) : QObject(parent)
|
||||
{
|
||||
// request.setSslConfiguration(QSslConfiguration::defaultConfiguration());
|
||||
request.setSslConfiguration(QSslConfiguration::defaultConfiguration());
|
||||
}
|
||||
|
||||
void XHR::setUrl(QString url)
|
||||
|
@ -79,10 +79,11 @@ void XHR::download()
|
|||
request.setUrl(requrl);
|
||||
reply = manager.get(request);
|
||||
// qDebug() << "reply " << reply->header(QNetworkRequest::LocationHeader)<<reply->header(QNetworkRequest::LastModifiedHeader);
|
||||
// qDebug() << "request " << request.url();
|
||||
// qDebug() << "error " << reply->error();
|
||||
// qDebug() << "request " << request.url();
|
||||
// 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, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onReplyError(QNetworkReply::NetworkError)));
|
||||
}
|
||||
|
@ -177,17 +178,19 @@ void XHR::onReplySuccess()
|
|||
void XHR::onRequestFinished()
|
||||
{
|
||||
// Save the file here
|
||||
QByteArray b = reply->readAll();
|
||||
QImage image = QImage::fromData(b);
|
||||
if (image.isNull()){qDebug() << "Image empty"<<m_url;}
|
||||
QFile file(m_filename);
|
||||
//qDebug() << "buffer downloaded "<<buffer;
|
||||
//QImage image = QImage::fromData(buffer);
|
||||
if (buffer.isNull()){qDebug() << "Image empty"<<m_url; buffer.clear(); emit this->error("image empty",1); reply->deleteLater();}
|
||||
else {QFile file(m_filename);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
image.save(&file, "JPG");
|
||||
b.clear();
|
||||
//image.save(&file, "JPG");
|
||||
file.write(buffer);
|
||||
buffer.clear();
|
||||
file.close();
|
||||
// qDebug() << m_url << "File downloaded "<<file.fileName();
|
||||
//qDebug() << m_url << "File downloaded "<<file.fileName();
|
||||
emit this->downloaded();
|
||||
reply->deleteLater();
|
||||
//reply->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
void XHR::onReadyRead()
|
||||
|
@ -196,6 +199,12 @@ void XHR::onReadyRead()
|
|||
buffer += reply->readAll();
|
||||
}
|
||||
|
||||
void XHR::updateDownloadProgress(qint64 bytesRead, qint64 totalBytes)
|
||||
{
|
||||
qDebug() << "Bytes: " << bytesRead<<" / "<<totalBytes;
|
||||
|
||||
}
|
||||
|
||||
void XHR::onSSLError(const QList<QSslError> &errors)
|
||||
{
|
||||
qDebug() << "XHR::onSSLError :" ;
|
||||
|
|
|
@ -16,10 +16,7 @@ public:
|
|||
static XHR *instance();
|
||||
|
||||
explicit XHR(QObject *parent = 0);
|
||||
|
||||
|
||||
// void setLogin(QString login);
|
||||
|
||||
|
||||
QString url() const;
|
||||
QString login() const;
|
||||
QString filename() const;
|
||||
|
@ -47,9 +44,9 @@ private slots:
|
|||
void onReplyError(QNetworkReply::NetworkError code);
|
||||
void onReplySuccess();
|
||||
void onRequestFinished();
|
||||
//void onFileWritten();
|
||||
void onReadyRead();
|
||||
void onSSLError(const QList<QSslError> &errors);
|
||||
void updateDownloadProgress(qint64 bytesRead, qint64 totalBytes);
|
||||
|
||||
private:
|
||||
QByteArray buffer;
|
||||
|
|
|
@ -24,7 +24,12 @@ RESOURCES = application.qrc
|
|||
OTHER_FILES += qml/friendiqa.qml \
|
||||
translations/*.ts \
|
||||
qml/*.qml
|
||||
qml/newsqml/*.qml
|
||||
qml/contactqml/*.qml
|
||||
qml/photoqml/*.qml
|
||||
qml/configqml/*.qml
|
||||
js/*.js
|
||||
images/*.*
|
||||
|
||||
# German translation is enabled as an example. If you aren't
|
||||
# planning to localize your app, remember to comment out the
|
||||
|
@ -37,4 +42,15 @@ HEADERS += \
|
|||
common/xhr.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;
|
||||
}
|
||||
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)
|
||||
print("Error loading component:"+component.errorString());
|
||||
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){
|
||||
var news=JSON.parse(obj);
|
||||
var newContacts=findNewContacts(news,contacts);
|
||||
// for (var i=0;i<news.length;i++){
|
||||
// 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)
|
||||
callback(news,newContacts)
|
||||
})}
|
||||
|
||||
function findNewContacts(news,contacts){
|
||||
|
@ -104,7 +80,7 @@ function storeNews(login,database,news,rootwindow,callback){
|
|||
// save news after contacts download, call next function
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
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 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)}
|
||||
|
@ -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 friendica_activities=[likearray,dislikearray,attendyesarray,attendnoarray,attendmaybearray]
|
||||
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
|
||||
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
|
||||
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){
|
||||
var messages=JSON.parse(obj);
|
||||
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) {
|
||||
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
|
||||
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
|
||||
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]);
|
||||
//print('store message data for '+JSON.stringify(messages[i]));
|
||||
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
|
||||
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
|
||||
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
|
||||
}
|
||||
|
||||
function deleteNews(login,database,newsid,rootwindow,callback){
|
||||
Helperjs.friendicaPostRequest(login,"/api/statuses/destroy?id="+newsid, rootwindow,function (obj){
|
||||
function deleteNews(login,database,newsid,messagetype,rootwindow,callback){
|
||||
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);
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
print('delete news data for ' + newsid);
|
||||
db.transaction( function(tx) {var result = tx.executeSql('DELETE from news where status_id ='+newsid); // delete news id
|
||||
Helperjs.showMessage("Delete",result,rootwindow)});
|
||||
})}
|
||||
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",obj,rootwindow);
|
||||
callback(obj)
|
||||
});
|
||||
})}
|
||||
|
||||
function retweetNews(login,database,newsid,rootwindow,callback){
|
||||
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]);
|
||||
db.transaction( function(tx) {
|
||||
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=[];
|
||||
for(var i = 0; i < newsrs.rows.length; i++) {
|
||||
newsArray.push(newsrs.rows.item(i));
|
||||
|
|
|
@ -33,7 +33,7 @@ function dataRequest(login,photoID,database,rootwindow) {
|
|||
// print("Source"+source);
|
||||
obj["source"]=source;
|
||||
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"}
|
||||
else if (obj.type=="image/png") {obj["filename"]=obj["id"]+".png"}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ function saveImage(obj,storagedirectory,callback) {
|
|||
} else { //portrait
|
||||
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"});
|
||||
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/layout.js" as Layoutjs
|
||||
import "qrc:/js/helper.js" as Helperjs
|
||||
import "qrc:/qml"
|
||||
import "qrc:/qml/configqml"
|
||||
|
||||
StackView{
|
||||
id: configStack
|
||||
|
@ -192,7 +192,9 @@ onCurrentIndexChanged:{
|
|||
Service.readConfig(db,function(userconfig){Service.getServerConfig(userconfig,configBackground, function(obj){
|
||||
var serverString=obj;
|
||||
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
|
||||
root.login=userconfig;
|
||||
root.contactlist=[];
|
||||
|
@ -232,7 +234,7 @@ onCurrentIndexChanged:{
|
|||
x: root.width/2+14*mm; y: mm; width: 5*mm; height: 5*mm;
|
||||
text: "?"
|
||||
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/helper.js" as Helperjs
|
||||
import "qrc:/js/news.js" as Newsjs
|
||||
import "qrc:/qml"
|
||||
import "qrc:/qml/contactqml"
|
||||
|
||||
Rectangle {
|
||||
y:1
|
|
@ -17,9 +17,9 @@ TabView{
|
|||
id:root
|
||||
tabPosition: Qt.BottomEdge
|
||||
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 contactlist: []
|
||||
property real mm: Screen.pixelDensity
|
||||
|
@ -44,7 +44,7 @@ TabView{
|
|||
updateContactInDB(login,db,newContacts[currentContact].isFriend,newContacts[currentContact])}
|
||||
}
|
||||
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){
|
||||
updateContactInDB(login,db,newContacts[currentContact].isFriend,newContacts[currentContact])}
|
||||
else if(currentContact==newContacts.length){//newImagesProgress.visible=false;
|
||||
|
@ -67,22 +67,23 @@ TabView{
|
|||
}
|
||||
|
||||
function updateContactInDB(login,database,isFriend,contact){// for newstab and friendstab
|
||||
var imagename=login.imagestore+"contacts/"+contact.screen_name.trim()+".jpg";
|
||||
if (isFriend==1){
|
||||
var suffix=contact.profile_image_url.substring(contact.profile_image_url.lastIndexOf("."), contact.profile_image_url.length);
|
||||
var imagename=login.imagestore+"contacts/"+contact.screen_name.trim()+suffix;
|
||||
// if (isFriend==1){
|
||||
xhr.setUrl(Qt.resolvedUrl(contact.profile_image_url));
|
||||
xhr.setFilename(imagename);
|
||||
xhr.download();
|
||||
}
|
||||
//}
|
||||
var db=LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
var result;
|
||||
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
|
||||
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
|
||||
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{
|
||||
|
@ -91,7 +92,14 @@ TabView{
|
|||
}
|
||||
Connections{
|
||||
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: {
|
||||
if (login==""){Service.initDatabase(db)}
|
||||
|
@ -121,24 +129,24 @@ style: TabViewStyle {
|
|||
title: qsTr("News")
|
||||
id: newstab
|
||||
property string newstabStatus:"news"
|
||||
source: "qrc:/qml/NewsTab.qml"
|
||||
source: "qrc:/qml/newsqml/NewsTab.qml"
|
||||
}
|
||||
|
||||
Tab{
|
||||
title: qsTr("Contacts")
|
||||
id: friendstab
|
||||
source: "qrc:/qml/FriendsTab.qml"
|
||||
source: "qrc:/qml/contactqml/FriendsTab.qml"
|
||||
}
|
||||
Tab{
|
||||
title: qsTr("Photos")
|
||||
id: fotostab
|
||||
source: "qrc:/qml/PhotoTab.qml"
|
||||
source: "qrc:/qml/photoqml/PhotoTab.qml"
|
||||
}
|
||||
|
||||
|
||||
Tab{
|
||||
title: qsTr("Config")
|
||||
source: "qrc:/qml/ConfigTab.qml"
|
||||
source: "qrc:/qml/configqml/ConfigTab.qml"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,20 +17,23 @@ Item{
|
|||
property int directmessage: 0;
|
||||
property var contacts: []
|
||||
property var groups: []
|
||||
property string contact_allow:""
|
||||
property string contact_deny:""
|
||||
property string group_allow:""
|
||||
property string group_deny:""
|
||||
property var contact_allow:[]
|
||||
property var contact_deny:[]
|
||||
property var group_allow:[]
|
||||
property var group_deny:[]
|
||||
|
||||
function statusUpdate(title,status,in_reply_to_status_id,attachImageURL) {
|
||||
xhr.url= login.server + "/api/statuses/update.xml";
|
||||
xhr.setLogin(login.username+":"+Qt.atob(login.password));
|
||||
print("login: "+login.username+":"+Qt.atob(login.password));
|
||||
xhr.clearParams();
|
||||
xhr.setParam("source", "Friendiqa");
|
||||
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 (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 )};
|
||||
xhr.post();
|
||||
}
|
||||
|
@ -63,7 +66,7 @@ Item{
|
|||
width: parent.width
|
||||
height: 30*mm
|
||||
wrapMode: TextEdit.Wrap
|
||||
textFormat: TextEdit.RichText
|
||||
textFormat: TextEdit.PlainText
|
||||
}
|
||||
|
||||
Row{
|
||||
|
@ -118,12 +121,11 @@ Item{
|
|||
Row{
|
||||
spacing:2
|
||||
Button{
|
||||
visible: (directmessage==1)?false:true
|
||||
text:qsTr("Permissions")
|
||||
onClicked: {
|
||||
var component = Qt.createComponent("qrc:/qml/PermissionDialog.qml");
|
||||
var sprite = component.createObject(messageColumn);
|
||||
if (sprite == null) { // Error Handling
|
||||
console.log("Error creating object"); }
|
||||
var component = Qt.createComponent("qrc:/qml/newsqml/PermissionDialog.qml");
|
||||
var permissions = component.createObject(messageColumn);
|
||||
}}
|
||||
Button {
|
||||
id: attachButton
|
||||
|
@ -169,7 +171,9 @@ Item{
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onReleased: {if (event.key === Qt.Key_Back && stackView.depth > 1) {
|
||||
stackView.pop(); event.accepted = true;
|
||||
}}
|
||||
FileDialog {
|
||||
id: imageAttachmentDialog
|
||||
title: "Please choose a picture"
|
|
@ -22,7 +22,7 @@ Item {
|
|||
|
||||
function onDirectMessage(friend){
|
||||
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){
|
||||
|
@ -43,9 +43,16 @@ Item {
|
|||
id: newsStack
|
||||
anchors.fill:parent
|
||||
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;
|
||||
}
|
||||
}
|
||||
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 {
|
||||
y:1
|
||||
color: "white"
|
||||
|
@ -68,10 +75,9 @@ Item {
|
|||
else if (currentIndex==1){
|
||||
newsBusy.running=true;
|
||||
Newsjs.requestFavorites(root.login,db,root,function(news){
|
||||
JSON.stringify("Favorites: "+news);
|
||||
Newsjs.storeNews(root.login,root.db,news,root,function(){
|
||||
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){
|
||||
groups=groupobject});
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -166,9 +172,9 @@ Item {
|
|||
}
|
||||
BusyIndicator{
|
||||
id: newsBusy
|
||||
anchors.centerIn:update
|
||||
//anchors.right: update.left
|
||||
//anchors.top:parent.top
|
||||
anchors.horizontalCenter: newsView.horizontalCenter
|
||||
anchors.top:parent.top
|
||||
anchors.topMargin: 2*mm
|
||||
width:7*mm
|
||||
height: 7*mm
|
||||
}
|
|
@ -29,7 +29,7 @@ Item {
|
|||
|
||||
Image {
|
||||
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
|
||||
width: 7*mm
|
||||
height: 7*mm
|
||||
|
@ -91,12 +91,6 @@ Item {
|
|||
}}
|
||||
}
|
||||
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:{
|
||||
if(favoritedCheckbox.checkedState==Qt.Checked)
|
||||
{Newsjs.favorite(login,true,newsitemobject.status_id,root)}
|
||||
|
@ -125,6 +119,7 @@ Item {
|
|||
Rectangle{
|
||||
width: 4*mm
|
||||
height: 3*mm
|
||||
visible:(newsitemobject.in_reply_to_status_id!="")?true:false
|
||||
Text{
|
||||
id:conversationsymbol
|
||||
color: "grey"
|
||||
|
@ -138,17 +133,18 @@ Item {
|
|||
newsBusy.running=true;
|
||||
Newsjs.requestConversation(root.login,db,newsitemobject.status_id,root.contactlist,root,function(news,newContacts){
|
||||
for (var i=0;i<newContacts.length;i++){
|
||||
root.updateContactInDB(root.login,root.db,0,newContacts[i])
|
||||
}
|
||||
Newsjs.storeNews(root.login,root.db,news,root,function(){
|
||||
var currentTime= new Date();
|
||||
Newsjs.conversationfromdb(db,root.login.username,newsitemobject.statusnet_conversation_id, function(newsarray){
|
||||
newsModel.clear();
|
||||
var msg = {'currentTime': currentTime, 'model': newsModel,'news':newsarray,'latestmessage':0};
|
||||
newsWorker.sendMessage(msg);
|
||||
newsBusy.running=false
|
||||
});
|
||||
}
|
||||
root.updateContactInDB(root.login,root.db,0,newContacts[i])
|
||||
}
|
||||
Newsjs.storeNews(root.login,root.db,news,root,function(){
|
||||
var currentTime= new Date();
|
||||
Newsjs.conversationfromdb(db,root.login.username,newsitemobject.statusnet_conversation_id, function(newsarray){
|
||||
newsModel.clear();
|
||||
newstab.newstabStatus="conversation";
|
||||
var msg = {'currentTime': currentTime, 'model': newsModel,'news':newsarray,'latestmessage':0};
|
||||
newsWorker.sendMessage(msg);
|
||||
newsBusy.running=false
|
||||
})
|
||||
}
|
||||
)})
|
||||
}}
|
||||
}}
|
||||
|
@ -192,6 +188,7 @@ Item {
|
|||
CheckBox{id:likeCheckbox
|
||||
height:3*mm
|
||||
width:8*mm
|
||||
visible: (newsitemobject.messagetype==0)? true:false
|
||||
checked:(friendica_activities.self.liked)?true:false
|
||||
style: CheckBoxStyle {
|
||||
background: Rectangle {
|
||||
|
@ -218,6 +215,7 @@ Item {
|
|||
CheckBox{id: dislikeCheckbox
|
||||
height:3*mm
|
||||
width:8*mm
|
||||
visible: (newsitemobject.messagetype==0)? true:false
|
||||
checked: (friendica_activities.self.disliked)?true:false
|
||||
style: CheckBoxStyle {
|
||||
background: Rectangle {
|
||||
|
@ -267,7 +265,9 @@ Item {
|
|||
MenuItem {
|
||||
text: qsTr("Reply")
|
||||
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 {
|
||||
|
@ -325,7 +325,7 @@ Menu{
|
|||
MenuItem {
|
||||
text: qsTr("Delete")
|
||||
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);
|
||||
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 "qrc:/js/service.js" as Service
|
||||
import "qrc:/js/helper.js" as Helperjs
|
||||
import "qrc:/qml"
|
||||
import "qrc:/qml/photoqml"
|
||||
|
||||
Rectangle {
|
||||
id:fotorectangle
|
|
@ -1,25 +1,28 @@
|
|||
<RCC>
|
||||
<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/photoworker.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/newsworker.js</file>
|
||||
<file>js/helper.js</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>
|
||||
</RCC>
|
||||
|
|
|
@ -14,7 +14,7 @@ XHR *XHR::instance()
|
|||
|
||||
XHR::XHR(QObject *parent) : QObject(parent)
|
||||
{
|
||||
// request.setSslConfiguration(QSslConfiguration::defaultConfiguration());
|
||||
request.setSslConfiguration(QSslConfiguration::defaultConfiguration());
|
||||
}
|
||||
|
||||
void XHR::setUrl(QString url)
|
||||
|
@ -79,10 +79,11 @@ void XHR::download()
|
|||
request.setUrl(requrl);
|
||||
reply = manager.get(request);
|
||||
// qDebug() << "reply " << reply->header(QNetworkRequest::LocationHeader)<<reply->header(QNetworkRequest::LastModifiedHeader);
|
||||
// qDebug() << "request " << request.url();
|
||||
// qDebug() << "error " << reply->error();
|
||||
// qDebug() << "request " << request.url();
|
||||
// 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, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onReplyError(QNetworkReply::NetworkError)));
|
||||
}
|
||||
|
@ -177,17 +178,19 @@ void XHR::onReplySuccess()
|
|||
void XHR::onRequestFinished()
|
||||
{
|
||||
// Save the file here
|
||||
QByteArray b = reply->readAll();
|
||||
QImage image = QImage::fromData(b);
|
||||
if (image.isNull()){qDebug() << "Image empty"<<m_url;}
|
||||
QFile file(m_filename);
|
||||
//qDebug() << "buffer downloaded "<<buffer;
|
||||
//QImage image = QImage::fromData(buffer);
|
||||
if (buffer.isNull()){qDebug() << "Image empty"<<m_url; buffer.clear(); emit this->error("image empty",1); reply->deleteLater();}
|
||||
else {QFile file(m_filename);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
image.save(&file, "JPG");
|
||||
b.clear();
|
||||
//image.save(&file, "JPG");
|
||||
file.write(buffer);
|
||||
buffer.clear();
|
||||
file.close();
|
||||
// qDebug() << m_url << "File downloaded "<<file.fileName();
|
||||
//qDebug() << m_url << "File downloaded "<<file.fileName();
|
||||
emit this->downloaded();
|
||||
reply->deleteLater();
|
||||
//reply->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
void XHR::onReadyRead()
|
||||
|
@ -196,6 +199,12 @@ void XHR::onReadyRead()
|
|||
buffer += reply->readAll();
|
||||
}
|
||||
|
||||
void XHR::updateDownloadProgress(qint64 bytesRead, qint64 totalBytes)
|
||||
{
|
||||
qDebug() << "Bytes: " << bytesRead<<" / "<<totalBytes;
|
||||
|
||||
}
|
||||
|
||||
void XHR::onSSLError(const QList<QSslError> &errors)
|
||||
{
|
||||
qDebug() << "XHR::onSSLError :" ;
|
||||
|
|
|
@ -16,10 +16,7 @@ public:
|
|||
static XHR *instance();
|
||||
|
||||
explicit XHR(QObject *parent = 0);
|
||||
|
||||
|
||||
// void setLogin(QString login);
|
||||
|
||||
|
||||
QString url() const;
|
||||
QString login() const;
|
||||
QString filename() const;
|
||||
|
@ -47,9 +44,9 @@ private slots:
|
|||
void onReplyError(QNetworkReply::NetworkError code);
|
||||
void onReplySuccess();
|
||||
void onRequestFinished();
|
||||
//void onFileWritten();
|
||||
void onReadyRead();
|
||||
void onSSLError(const QList<QSslError> &errors);
|
||||
void updateDownloadProgress(qint64 bytesRead, qint64 totalBytes);
|
||||
|
||||
private:
|
||||
QByteArray buffer;
|
||||
|
|
|
@ -24,6 +24,10 @@ RESOURCES = application.qrc
|
|||
OTHER_FILES += qml/friendiqa.qml \
|
||||
translations/*.ts \
|
||||
qml/*.qml
|
||||
qml/newsqml/*.qml
|
||||
qml/contactqml/*.qml
|
||||
qml/photoqml/*.qml
|
||||
qml/configqml/*.qml
|
||||
js/*.js
|
||||
|
||||
# German translation is enabled as an example. If you aren't
|
||||
|
|
|
@ -114,3 +114,8 @@ function inArray(list, prop, val) {
|
|||
}
|
||||
} 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)
|
||||
print("Error loading component:"+component.errorString());
|
||||
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){
|
||||
var news=JSON.parse(obj);
|
||||
var newContacts=findNewContacts(news,contacts);
|
||||
// for (var i=0;i<news.length;i++){
|
||||
// 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)
|
||||
callback(news,newContacts)
|
||||
})}
|
||||
|
||||
function findNewContacts(news,contacts){
|
||||
|
@ -104,7 +80,7 @@ function storeNews(login,database,news,rootwindow,callback){
|
|||
// save news after contacts download, call next function
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
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 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)}
|
||||
|
@ -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 friendica_activities=[likearray,dislikearray,attendyesarray,attendnoarray,attendmaybearray]
|
||||
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
|
||||
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
|
||||
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){
|
||||
var messages=JSON.parse(obj);
|
||||
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) {
|
||||
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
|
||||
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
|
||||
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]);
|
||||
//print('store message data for '+JSON.stringify(messages[i]));
|
||||
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
|
||||
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
|
||||
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
|
||||
}
|
||||
|
||||
function deleteNews(login,database,newsid,rootwindow,callback){
|
||||
Helperjs.friendicaPostRequest(login,"/api/statuses/destroy?id="+newsid, rootwindow,function (obj){
|
||||
function deleteNews(login,database,newsid,messagetype,rootwindow,callback){
|
||||
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);
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
print('delete news data for ' + newsid);
|
||||
db.transaction( function(tx) {var result = tx.executeSql('DELETE from news where status_id ='+newsid); // delete news id
|
||||
Helperjs.showMessage("Delete",result,rootwindow)});
|
||||
})}
|
||||
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",obj,rootwindow);
|
||||
callback(obj)
|
||||
});
|
||||
})}
|
||||
|
||||
function retweetNews(login,database,newsid,rootwindow,callback){
|
||||
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]);
|
||||
db.transaction( function(tx) {
|
||||
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=[];
|
||||
for(var i = 0; i < newsrs.rows.length; i++) {
|
||||
newsArray.push(newsrs.rows.item(i));
|
||||
|
|
|
@ -33,7 +33,7 @@ function dataRequest(login,photoID,database,rootwindow) {
|
|||
// print("Source"+source);
|
||||
obj["source"]=source;
|
||||
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"}
|
||||
else if (obj.type=="image/png") {obj["filename"]=obj["id"]+".png"}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ function saveImage(obj,storagedirectory,callback) {
|
|||
} else { //portrait
|
||||
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"});
|
||||
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/layout.js" as Layoutjs
|
||||
import "qrc:/js/helper.js" as Helperjs
|
||||
import "qrc:/qml"
|
||||
import "qrc:/qml/configqml"
|
||||
|
||||
StackView{
|
||||
id: configStack
|
||||
|
@ -192,7 +192,9 @@ onCurrentIndexChanged:{
|
|||
Service.readConfig(db,function(userconfig){Service.getServerConfig(userconfig,configBackground, function(obj){
|
||||
var serverString=obj;
|
||||
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
|
||||
root.login=userconfig;
|
||||
root.contactlist=[];
|
||||
|
@ -232,7 +234,7 @@ onCurrentIndexChanged:{
|
|||
x: root.width/2+14*mm; y: mm; width: 5*mm; height: 5*mm;
|
||||
text: "?"
|
||||
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/helper.js" as Helperjs
|
||||
import "qrc:/js/news.js" as Newsjs
|
||||
import "qrc:/qml"
|
||||
import "qrc:/qml/contactqml"
|
||||
|
||||
Rectangle {
|
||||
y:1
|
|
@ -16,10 +16,10 @@ import "qrc:/qml"
|
|||
TabView{
|
||||
id:root
|
||||
tabPosition: Qt.BottomEdge
|
||||
width: 400//Screen.desktopAvailableWidth
|
||||
height: 400// Screen.desktopAvailableHeight
|
||||
width: 500//Screen.desktopAvailableWidth
|
||||
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 contactlist: []
|
||||
property real mm: Screen.pixelDensity
|
||||
|
@ -44,7 +44,7 @@ TabView{
|
|||
updateContactInDB(login,db,newContacts[currentContact].isFriend,newContacts[currentContact])}
|
||||
}
|
||||
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){
|
||||
updateContactInDB(login,db,newContacts[currentContact].isFriend,newContacts[currentContact])}
|
||||
else if(currentContact==newContacts.length){//newImagesProgress.visible=false;
|
||||
|
@ -67,22 +67,23 @@ TabView{
|
|||
}
|
||||
|
||||
function updateContactInDB(login,database,isFriend,contact){// for newstab and friendstab
|
||||
var imagename=login.imagestore+"contacts/"+contact.screen_name.trim()+".jpg";
|
||||
if (isFriend==1){
|
||||
var suffix=contact.profile_image_url.substring(contact.profile_image_url.lastIndexOf("."), contact.profile_image_url.length);
|
||||
var imagename=login.imagestore+"contacts/"+contact.screen_name.trim()+suffix;
|
||||
// if (isFriend==1){
|
||||
xhr.setUrl(Qt.resolvedUrl(contact.profile_image_url));
|
||||
xhr.setFilename(imagename);
|
||||
xhr.download();
|
||||
}
|
||||
//}
|
||||
var db=LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
var result;
|
||||
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
|
||||
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
|
||||
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{
|
||||
|
@ -91,7 +92,14 @@ TabView{
|
|||
}
|
||||
Connections{
|
||||
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: {
|
||||
if (login==""){Service.initDatabase(db)}
|
||||
|
@ -121,24 +129,24 @@ style: TabViewStyle {
|
|||
title: qsTr("News")
|
||||
id: newstab
|
||||
property string newstabStatus:"news"
|
||||
source: "qrc:/qml/NewsTab.qml"
|
||||
source: "qrc:/qml/newsqml/NewsTab.qml"
|
||||
}
|
||||
|
||||
Tab{
|
||||
title: qsTr("Contacts")
|
||||
id: friendstab
|
||||
source: "qrc:/qml/FriendsTab.qml"
|
||||
source: "qrc:/qml/contactqml/FriendsTab.qml"
|
||||
}
|
||||
Tab{
|
||||
title: qsTr("Photos")
|
||||
id: fotostab
|
||||
source: "qrc:/qml/PhotoTab.qml"
|
||||
source: "qrc:/qml/photoqml/PhotoTab.qml"
|
||||
}
|
||||
|
||||
|
||||
Tab{
|
||||
title: qsTr("Config")
|
||||
source: "qrc:/qml/ConfigTab.qml"
|
||||
source: "qrc:/qml/configqml/ConfigTab.qml"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,20 +17,23 @@ Item{
|
|||
property int directmessage: 0;
|
||||
property var contacts: []
|
||||
property var groups: []
|
||||
property string contact_allow:""
|
||||
property string contact_deny:""
|
||||
property string group_allow:""
|
||||
property string group_deny:""
|
||||
property var contact_allow:[]
|
||||
property var contact_deny:[]
|
||||
property var group_allow:[]
|
||||
property var group_deny:[]
|
||||
|
||||
function statusUpdate(title,status,in_reply_to_status_id,attachImageURL) {
|
||||
xhr.url= login.server + "/api/statuses/update.xml";
|
||||
xhr.setLogin(login.username+":"+Qt.atob(login.password));
|
||||
print("login: "+login.username+":"+Qt.atob(login.password));
|
||||
xhr.clearParams();
|
||||
xhr.setParam("source", "Friendiqa");
|
||||
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 (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 )};
|
||||
xhr.post();
|
||||
}
|
||||
|
@ -63,7 +66,7 @@ Item{
|
|||
width: parent.width
|
||||
height: 30*mm
|
||||
wrapMode: TextEdit.Wrap
|
||||
textFormat: TextEdit.RichText
|
||||
textFormat: TextEdit.PlainText
|
||||
}
|
||||
|
||||
Row{
|
||||
|
@ -118,12 +121,11 @@ Item{
|
|||
Row{
|
||||
spacing:2
|
||||
Button{
|
||||
visible: (directmessage==1)?false:true
|
||||
text:qsTr("Permissions")
|
||||
onClicked: {
|
||||
var component = Qt.createComponent("qrc:/qml/PermissionDialog.qml");
|
||||
var sprite = component.createObject(messageColumn);
|
||||
if (sprite == null) { // Error Handling
|
||||
console.log("Error creating object"); }
|
||||
var component = Qt.createComponent("qrc:/qml/newsqml/PermissionDialog.qml");
|
||||
var permissions = component.createObject(messageColumn);
|
||||
}}
|
||||
Button {
|
||||
id: attachButton
|
||||
|
@ -169,7 +171,9 @@ Item{
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onReleased: {if (event.key === Qt.Key_Back && stackView.depth > 1) {
|
||||
stackView.pop(); event.accepted = true;
|
||||
}}
|
||||
FileDialog {
|
||||
id: imageAttachmentDialog
|
||||
title: "Please choose a picture"
|
|
@ -22,7 +22,7 @@ Item {
|
|||
|
||||
function onDirectMessage(friend){
|
||||
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){
|
||||
|
@ -43,9 +43,16 @@ Item {
|
|||
id: newsStack
|
||||
anchors.fill:parent
|
||||
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;
|
||||
}
|
||||
}
|
||||
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 {
|
||||
y:1
|
||||
color: "white"
|
||||
|
@ -68,10 +75,9 @@ Item {
|
|||
else if (currentIndex==1){
|
||||
newsBusy.running=true;
|
||||
Newsjs.requestFavorites(root.login,db,root,function(news){
|
||||
JSON.stringify("Favorites: "+news);
|
||||
Newsjs.storeNews(root.login,root.db,news,root,function(){
|
||||
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){
|
||||
groups=groupobject});
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -166,9 +172,9 @@ Item {
|
|||
}
|
||||
BusyIndicator{
|
||||
id: newsBusy
|
||||
anchors.centerIn:update
|
||||
//anchors.right: update.left
|
||||
//anchors.top:parent.top
|
||||
anchors.horizontalCenter: newsView.horizontalCenter
|
||||
anchors.top:parent.top
|
||||
anchors.topMargin: 2*mm
|
||||
width:7*mm
|
||||
height: 7*mm
|
||||
}
|
|
@ -29,7 +29,7 @@ Item {
|
|||
|
||||
Image {
|
||||
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
|
||||
width: 7*mm
|
||||
height: 7*mm
|
||||
|
@ -91,12 +91,6 @@ Item {
|
|||
}}
|
||||
}
|
||||
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:{
|
||||
if(favoritedCheckbox.checkedState==Qt.Checked)
|
||||
{Newsjs.favorite(login,true,newsitemobject.status_id,root)}
|
||||
|
@ -125,6 +119,7 @@ Item {
|
|||
Rectangle{
|
||||
width: 4*mm
|
||||
height: 3*mm
|
||||
visible:(newsitemobject.in_reply_to_status_id!="")?true:false
|
||||
Text{
|
||||
id:conversationsymbol
|
||||
color: "grey"
|
||||
|
@ -138,17 +133,18 @@ Item {
|
|||
newsBusy.running=true;
|
||||
Newsjs.requestConversation(root.login,db,newsitemobject.status_id,root.contactlist,root,function(news,newContacts){
|
||||
for (var i=0;i<newContacts.length;i++){
|
||||
root.updateContactInDB(root.login,root.db,0,newContacts[i])
|
||||
}
|
||||
Newsjs.storeNews(root.login,root.db,news,root,function(){
|
||||
var currentTime= new Date();
|
||||
Newsjs.conversationfromdb(db,root.login.username,newsitemobject.statusnet_conversation_id, function(newsarray){
|
||||
newsModel.clear();
|
||||
var msg = {'currentTime': currentTime, 'model': newsModel,'news':newsarray,'latestmessage':0};
|
||||
newsWorker.sendMessage(msg);
|
||||
newsBusy.running=false
|
||||
});
|
||||
}
|
||||
root.updateContactInDB(root.login,root.db,0,newContacts[i])
|
||||
}
|
||||
Newsjs.storeNews(root.login,root.db,news,root,function(){
|
||||
var currentTime= new Date();
|
||||
Newsjs.conversationfromdb(db,root.login.username,newsitemobject.statusnet_conversation_id, function(newsarray){
|
||||
newsModel.clear();
|
||||
newstab.newstabStatus="conversation";
|
||||
var msg = {'currentTime': currentTime, 'model': newsModel,'news':newsarray,'latestmessage':0};
|
||||
newsWorker.sendMessage(msg);
|
||||
newsBusy.running=false
|
||||
})
|
||||
}
|
||||
)})
|
||||
}}
|
||||
}}
|
||||
|
@ -192,6 +188,7 @@ Item {
|
|||
CheckBox{id:likeCheckbox
|
||||
height:3*mm
|
||||
width:8*mm
|
||||
visible: (newsitemobject.messagetype==0)? true:false
|
||||
checked:(friendica_activities.self.liked)?true:false
|
||||
style: CheckBoxStyle {
|
||||
background: Rectangle {
|
||||
|
@ -218,6 +215,7 @@ Item {
|
|||
CheckBox{id: dislikeCheckbox
|
||||
height:3*mm
|
||||
width:8*mm
|
||||
visible: (newsitemobject.messagetype==0)? true:false
|
||||
checked: (friendica_activities.self.disliked)?true:false
|
||||
style: CheckBoxStyle {
|
||||
background: Rectangle {
|
||||
|
@ -267,7 +265,9 @@ Item {
|
|||
MenuItem {
|
||||
text: qsTr("Reply")
|
||||
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 {
|
||||
|
@ -325,7 +325,7 @@ Menu{
|
|||
MenuItem {
|
||||
text: qsTr("Delete")
|
||||
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);
|
||||
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 "qrc:/js/service.js" as Service
|
||||
import "qrc:/js/helper.js" as Helperjs
|
||||
import "qrc:/qml"
|
||||
import "qrc:/qml/photoqml"
|
||||
|
||||
Rectangle {
|
||||
id:fotorectangle
|
Loading…
Reference in a new issue