Skip to content

Commit

Permalink
Add TopMessageListModel component to show top unreaded messages
Browse files Browse the repository at this point in the history
Update Status component to provide typing status
Update NotificationHandler component to show unreadCount
Many bugfixes
  • Loading branch information
Bardia Daneshvar committed May 21, 2016
1 parent 93c9ac0 commit 83e5d35
Show file tree
Hide file tree
Showing 24 changed files with 761 additions and 29 deletions.
3 changes: 3 additions & 0 deletions documents/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Here are all components of the TelegramQml:
* [DialogListModel](dialoglistmodel.md)
* [MessageListModel](messagelistmodel.md)
* [MessageSearchModel](messagesearchmodel.md)
* [TopMessagesModel](topmessagesmodel.md)
* [StickersCategoriesModel](stickerscategoriesmodel.md)
* [StickersModel](stickersmodel.md)
* [ProfileManagerModel](profilemanagermodel.md)
Expand All @@ -48,7 +49,9 @@ Here are all components of the TelegramQml:
* [PeerDetails](peerdetails.md)
* [NotificationHandler](notificationhandler.md)
* [Status](status.md)
* [StatusTyping](statustyping.md)
* [MessagesFilter](messagesfilter.md)
* [SendMessageAction](sendmessageaction.md)

##### Base

Expand Down
5 changes: 5 additions & 0 deletions documents/notificationhandler.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* [Component details](#component-details)
* [Required Properties](#required-properties)
* [Normal Properties](#normal-properties)
* [Signals](#signals)


Expand All @@ -21,6 +22,10 @@
* <font color='#074885'><b>engine</b></font>: [Engine](engine.md)


### Normal Properties

* <font color='#074885'><b>unreadCount</b></font>: int (readOnly)



### Signals
Expand Down
46 changes: 46 additions & 0 deletions documents/sendmessageaction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# SendMessageAction

* [Component details](#component-details)
* [Normal Properties](#normal-properties)
* [Enumerator](#enumerator)


### Component details:

|Detail|Value|
|------|-----|
|Import|TelegramQml 2.0|
|Component|<font color='#074885'>SendMessageAction</font>|
|C++ class|<font color='#074885'>SendMessageActionObject</font>|
|Inherits|<font color='#074885'>[TypeQObject](typeqobject.md)</font>|
|Model|<font color='#074885'>No</font>|



### Normal Properties

* <font color='#074885'><b>progress</b></font>: int
* <font color='#074885'><b>core</b></font>: SendMessageAction
* <font color='#074885'><b>classType</b></font>: uint




### Enumerator


##### SendMessageActionClassType

|Key|Value|
|---|-----|
|TypeSendMessageTypingAction|0|
|TypeSendMessageCancelAction|1|
|TypeSendMessageRecordVideoAction|2|
|TypeSendMessageUploadVideoAction|3|
|TypeSendMessageRecordAudioAction|4|
|TypeSendMessageUploadAudioAction|5|
|TypeSendMessageUploadPhotoAction|6|
|TypeSendMessageUploadDocumentAction|7|
|TypeSendMessageGeoLocationAction|8|
|TypeSendMessageChooseContactAction|9|

3 changes: 2 additions & 1 deletion documents/status.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@
### Normal Properties

* <font color='#074885'><b>online</b></font>: boolean
* <font color='#074885'><b>typing</b></font>: [InputPeer](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/inputpeer.md)
* <font color='#074885'><b>typing</b></font>: [StatusTyping](statustyping.md)


### Methods

* void <font color='#074885'><b>requestStatus</b></font>(boolean online)
* void <font color='#074885'><b>requestTyping</b></font>([InputPeer](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/inputpeer.md) peer, [SendMessageAction](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/sendmessageaction.md) action)



35 changes: 35 additions & 0 deletions documents/statustyping.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# StatusTyping

* [Component details](#component-details)
* [Required Properties](#required-properties)
* [Normal Properties](#normal-properties)
* [Signals](#signals)


### Component details:

|Detail|Value|
|------|-----|
|Import|TelegramQml 2.0|
|Component|<font color='#074885'>StatusTyping</font>|
|C++ class|<font color='#074885'>TelegramStatusTyping</font>|
|Inherits|<font color='#074885'>object</font>|
|Model|<font color='#074885'>No</font>|


### Required Properties

* <font color='#074885'><b>peer</b></font>: [InputPeer](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/inputpeer.md)


### Normal Properties

* <font color='#074885'><b>action</b></font>: [SendMessageAction](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/sendmessageaction.md)



### Signals

* void <font color='#074885'><b>changed</b></font>()


94 changes: 94 additions & 0 deletions documents/topmessagesmodel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# TopMessagesModel

* [Component details](#component-details)
* [Required Properties](#required-properties)
* [Normal Properties](#normal-properties)
* [Enumerator](#enumerator)
* [Methods](#methods)
* [Roles](#roles)


### Component details:

|Detail|Value|
|------|-----|
|Import|TelegramQml 2.0|
|Component|<font color='#074885'>TopMessagesModel</font>|
|C++ class|<font color='#074885'>TelegramTopMessagesModel</font>|
|Inherits|<font color='#074885'>[MessageListModel](messagelistmodel.md)</font>|
|Model|<font color='#074885'>Yes</font>|


### Required Properties

* <font color='#074885'><b>engine</b></font>: [Engine](engine.md)
* <font color='#074885'><b>currentPeer</b></font>: [InputPeer](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/inputpeer.md)


### Normal Properties

* <font color='#074885'><b>dialogsLimit</b></font>: int
* <font color='#074885'><b>visibleType</b></font>: int


### Methods

* void <font color='#074885'><b>recheck</b></font>()



### Enumerator


##### VisibleTypes

|Key|Value|
|---|-----|
|VisibleTypeNone|0|
|VisibleTypeChannel|1|
|VisibleTypeChat|2|
|VisibleTypeUser|4|
|VisibleTypeMegaGroup|8|
|VisibleTypeAll|15|


### Roles

* model.<font color='#074885'>item</font>
* model.<font color='#074885'>mediaItem</font>
* model.<font color='#074885'>serviceItem</font>
* model.<font color='#074885'>markupItem</font>
* model.<font color='#074885'>entityList</font>
* model.<font color='#074885'>fromUserItem</font>
* model.<font color='#074885'>toUserItem</font>
* model.<font color='#074885'>toChatItem</font>
* model.<font color='#074885'>toPeerItem</font>
* model.<font color='#074885'>message</font>
* model.<font color='#074885'>dateTime</font>
* model.<font color='#074885'>date</font>
* model.<font color='#074885'>unread</font>
* model.<font color='#074885'>sent</font>
* model.<font color='#074885'>out</font>
* model.<font color='#074885'>replyMsgId</font>
* model.<font color='#074885'>replyMessage</font>
* model.<font color='#074885'>replyPeer</font>
* model.<font color='#074885'>forwardFromPeer</font>
* model.<font color='#074885'>forwardDate</font>
* model.<font color='#074885'>messageType</font>
* model.<font color='#074885'>replyType</font>
* model.<font color='#074885'>fileName</font>
* model.<font color='#074885'>fileMimeType</font>
* model.<font color='#074885'>fileTitle</font>
* model.<font color='#074885'>filePerformer</font>
* model.<font color='#074885'>fileDuration</font>
* model.<font color='#074885'>fileIsVoice</font>
* model.<font color='#074885'>fileSize</font>
* model.<font color='#074885'>downloadable</font>
* model.<font color='#074885'>uploading</font>
* model.<font color='#074885'>downloading</font>
* model.<font color='#074885'>transfaring</font>
* model.<font color='#074885'>transfared</font>
* model.<font color='#074885'>transfaredSize</font>
* model.<font color='#074885'>totalSize</font>
* model.<font color='#074885'>filePath</font>
* model.<font color='#074885'>thumbPath</font>
55 changes: 46 additions & 9 deletions plugins.qmltypes
Original file line number Diff line number Diff line change
Expand Up @@ -3164,14 +3164,15 @@ Module {
"RoleMessage": 265,
"RoleMessageOut": 266,
"RoleMessageType": 267,
"RoleLastOnline": 268,
"RoleIsOnline": 269,
"RoleStatus": 270,
"RoleStatusText": 271,
"RoleTyping": 272,
"RoleUnreadCount": 273,
"RoleMute": 274,
"RoleCategory": 275
"RoleMessageUser": 268,
"RoleLastOnline": 269,
"RoleIsOnline": 270,
"RoleStatus": 271,
"RoleStatusText": 272,
"RoleTyping": 273,
"RoleUnreadCount": 274,
"RoleMute": 275,
"RoleCategory": 276
}
}
Property { name: "visibility"; type: "int" }
Expand Down Expand Up @@ -3543,6 +3544,7 @@ Module {
exports: ["TelegramQml/NotificationHandler 2.0"]
exportMetaObjectRevisions: [0]
Property { name: "engine"; type: "TelegramEngine"; isPointer: true }
Property { name: "unreadCount"; type: "int"; isReadonly: true }
Signal {
name: "newMessage"
Parameter { name: "title"; type: "string" }
Expand Down Expand Up @@ -3623,11 +3625,25 @@ Module {
exportMetaObjectRevisions: [0]
Property { name: "engine"; type: "TelegramEngine"; isPointer: true }
Property { name: "online"; type: "bool" }
Property { name: "typing"; type: "InputPeerObject"; isPointer: true }
Property { name: "typing"; type: "TelegramStatusTyping"; isPointer: true }
Method {
name: "requestStatus"
Parameter { name: "online"; type: "bool" }
}
Method {
name: "requestTyping"
Parameter { name: "peer"; type: "InputPeerObject"; isPointer: true }
Parameter { name: "action"; type: "SendMessageActionObject"; isPointer: true }
}
}
Component {
name: "TelegramStatusTyping"
prototype: "QObject"
exports: ["TelegramQml/StatusTyping 2.0"]
exportMetaObjectRevisions: [0]
Property { name: "peer"; type: "InputPeerObject"; isPointer: true }
Property { name: "action"; type: "SendMessageActionObject"; isPointer: true }
Signal { name: "changed" }
}
Component {
name: "TelegramStickersCategoriesModel"
Expand Down Expand Up @@ -3667,6 +3683,27 @@ Module {
Parameter { name: "callback"; type: "QJSValue" }
}
}
Component {
name: "TelegramTopMessagesModel"
defaultProperty: "items"
prototype: "TelegramMessageListModel"
exports: ["TelegramQml/TopMessagesModel 2.0"]
exportMetaObjectRevisions: [0]
Enum {
name: "VisibleTypes"
values: {
"VisibleTypeNone": 0,
"VisibleTypeChannel": 1,
"VisibleTypeChat": 2,
"VisibleTypeUser": 4,
"VisibleTypeMegaGroup": 8,
"VisibleTypeAll": 15
}
}
Property { name: "dialogsLimit"; type: "int" }
Property { name: "visibleType"; type: "int" }
Method { name: "recheck" }
}
Component {
name: "TelegramTypeQObject"
prototype: "QObject"
Expand Down
10 changes: 7 additions & 3 deletions telegrammessagelistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ bool TelegramMessageListModel::editable() const
if(!chat || chat->classType() == ChatObject::TypeChat)
return true;

return chat->moderator() || chat->editor() || chat->creator() || chat->democracy();
return chat->moderator() || chat->editor() || chat->creator() || chat->democracy() || chat->megagroup();
}

int TelegramMessageListModel::limit() const
Expand Down Expand Up @@ -538,6 +538,8 @@ bool TelegramMessageListModel::sendMessage(const QString &message, MessageObject
handler->setText(message);
handler->setReplyTo(replyTo);
handler->setReplyMarkup(replyMarkup);
handler->setSupergroup(megagroup());

connect(handler, &TelegramUploadHandler::errorChanged, this, [this, handler]{
setError(handler->errorText(), handler->errorCode());
delete handler;
Expand Down Expand Up @@ -599,6 +601,8 @@ bool TelegramMessageListModel::sendFile(int type, const QString &file, MessageOb
handler->setSendFileType(type);
handler->setReplyTo(replyTo);
handler->setReplyMarkup(replyMarkup);
handler->setSupergroup(megagroup());

connect(handler, &TelegramUploadHandler::errorChanged, this, [this, handler]{
setError(handler->errorText(), handler->errorCode());
delete handler;
Expand Down Expand Up @@ -723,7 +727,7 @@ void TelegramMessageListModel::forwardMessages(InputPeerObject *fromInputPeer, c
for(int i=0; i<msgs.count(); i++)
randomIds << TelegramTools::generateRandomId();

const bool broadcast = (p->currentPeer->classType() == InputPeerObject::TypeInputPeerChannel);
const bool broadcast = (p->currentPeer->classType() == InputPeerObject::TypeInputPeerChannel && !megagroup());

Telegram *tg = mEngine->telegram();
DEFINE_DIS;
Expand Down Expand Up @@ -790,7 +794,7 @@ void TelegramMessageListModel::sendSticker(DocumentObject *doc, MessageObject *r
if(mEngine->state() != TelegramEngine::AuthLoggedIn)
return;

const bool broadcast = (p->currentPeer->classType() == InputPeerObject::TypeInputPeerChannel);
const bool broadcast = (p->currentPeer->classType() == InputPeerObject::TypeInputPeerChannel && !megagroup());

InputDocument document(InputDocument::typeInputDocument);
document.setId(doc->id());
Expand Down
1 change: 0 additions & 1 deletion telegrammessagesearchmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ void TelegramMessageSearchModel::refresh()
p->maxDate.toTime_t(), 0, 0, limit(), callback);
else
p->lastRequest = tg->messagesSearchGlobal(p->keyword, 0, InputPeer::null, 0, limit(), callback);

}

TelegramMessageSearchModel::~TelegramMessageSearchModel()
Expand Down
Loading

0 comments on commit 83e5d35

Please sign in to comment.