Ejemplo n.º 1
0
 def SendSearchBack(self, raw):
     self.owner().loadingForm.close()
     try:
         self.bookList.UpdateState()
         data = json.loads(raw)
         if data.get("code") == 200:
             info = data.get("data").get("comics")
             page = int(info.get("page"))
             pages = int(info.get("pages"))
             self.bookList.UpdatePage(page, pages)
             self.jumpLine.setValidator(QtIntLimit(1, pages, self))
             pageText = "页:" + str(self.bookList.page) + "/" + str(self.bookList.pages)
             self.label.setText(pageText)
             for v in info.get("docs", []):
                 title = v.get("title", "")
                 _id = v.get("_id")
                 url = v.get("thumb", {}).get("fileServer")
                 path = v.get("thumb", {}).get("path")
                 originalName = v.get("thumb", {}).get("originalName")
                 info2 = "完本," if v.get("finished") else ""
                 info2 += "{}E/{}P".format(str(v.get("epsCount")), str(v.get("pagesCount")))
                 param = ",".join(v.get("categories"))
                 self.bookList.AddBookItem(_id, title, info2, url, path, param)
             self.CheckCategoryShowItem()
         else:
             # QtWidgets.QMessageBox.information(self, '未搜索到结果', "未搜索到结果", QtWidgets.QMessageBox.Yes)
             self.owner().msgForm.ShowError("未搜索到结果")
     except Exception as es:
         Log.Error(es)
     pass
Ejemplo n.º 2
0
    def SendCommentChildrenBack(self, msg, index):
        try:
            item = self.listWidget.item(index)
            if not item:
                self.loadingForm.close()
                return
            widget = self.listWidget.itemWidget(item)
            if not widget:
                self.loadingForm.close()
                return

            data = json.loads(msg)
            if data.get("code") == 200:
                QtTask().AddHttpTask(lambda x: Server().Send(
                    req.GetCommentsChildrenReq(widget.id), bakParam=x),
                                     self.LoadCommentInfoBack,
                                     backParam=index,
                                     cleanFlag=self.closeFlag)
            else:
                self.loadingForm.close()
                QtBubbleLabel.ShowErrorEx(self, data.get("message", "错误"))
            self.commentLine.setText("")
        except Exception as es:
            self.loadingForm.close()
            Log.Error(es)
Ejemplo n.º 3
0
    def GetCommnetBack(self, data):
        try:
            self.loadingForm.close()
            self.listWidget.UpdateState()
            msg = json.loads(data)
            if msg.get("code") == 200:
                comments = msg.get("data", {}).get("comments", {})
                topComments = msg.get("data", {}).get("topComments", [])
                page = int(comments.get("page", 1))
                pages = int(comments.get("pages", 1))
                limit = int(comments.get("limit", 1))
                self.listWidget.UpdatePage(page, pages)
                self.nums.setText("分页:{}/{}".format(str(page), str(pages)))
                total = comments.get("total", 0)
                # self.tabWidget.setTabText(1, "评论({})".format(str(total)))
                if page == 1:
                    for index, info in enumerate(topComments):
                        floor = "置顶"
                        content = info.get("content")
                        name = info.get("_user", {}).get("name")
                        avatar = info.get("_user", {}).get("avatar", {})
                        title = info.get("_user", {}).get("title", {})
                        level = info.get("_user", {}).get("level", 1)
                        createdTime = info.get("created_at")
                        commentsCount = info.get("commentsCount")
                        commnetId = info.get('_id')
                        likesCount = info.get("likesCount")
                        self.listWidget.AddUserItem(commnetId, commentsCount,
                                                    likesCount, content, name,
                                                    createdTime, floor,
                                                    avatar.get("fileServer"),
                                                    avatar.get("path"),
                                                    avatar.get("originalName"),
                                                    title, level)

                for index, info in enumerate(comments.get("docs")):
                    floor = total - ((page - 1) * limit + index)
                    content = info.get("content")
                    name = info.get("_user", {}).get("name")
                    avatar = info.get("_user", {}).get("avatar", {})
                    createdTime = info.get("created_at")
                    commentsCount = info.get("commentsCount")
                    commnetId = info.get('_id')
                    likesCount = info.get("likesCount")
                    title = info.get("_user", {}).get("title", "")
                    level = info.get("_user", {}).get("level", 1)
                    self.listWidget.AddUserItem(commnetId, commentsCount,
                                                likesCount, content, name,
                                                createdTime, floor,
                                                avatar.get("fileServer"),
                                                avatar.get("path"),
                                                avatar.get("originalName"),
                                                title, level)
            return
        except Exception as es:
            Log.Error(es)
Ejemplo n.º 4
0
 def SendKeywordBack(self, raw):
     try:
         data = json.loads(raw)
         if data.get("code") == 200:
             self.keywordList.clear()
             for keyword in data.get('data', {}).get("keywords", []):
                 self.keywordList.AddItem(keyword)
             pass
         else:
             pass
     except Exception as es:
         Log.Error(es)
     pass
Ejemplo n.º 5
0
 def SendCommentBack(self, msg):
     try:
         data = json.loads(msg)
         if data.get("code") == 200:
             self.ClearCommnetList()
             QtTask().AddHttpTask(lambda x: Server().Send(req.GetComments(self.bookId), bakParam=x),
                                             self.GetCommnetBack, cleanFlag=self.closeFlag)
         else:
             self.loadingForm.close()
             QtBubbleLabel.ShowErrorEx(self, data.get("message", "错误"))
         self.commentLine.setText("")
     except Exception as es:
         self.loadingForm.close()
         Log.Error(es)
Ejemplo n.º 6
0
 def GetChatBack(self, data):
     try:
         data = json.loads(data)
         if data.get("code") == 200:
             infos = data.get("data", {}).get("chatList", {})
             for index, info in enumerate(infos):
                 name = info.get("title")
                 content = info.get("description")
                 # avatar = info.get("_user", {}).get("avatar", {})
                 # createdTime = info.get("created_at")
                 self.listWidget.AddUserItem(info.get("url"), "", "", content, name, "", index+1,
                                             info.get("avatar"),
                                             "", "")
     except Exception as es:
         Log.Error(es)
     return
Ejemplo n.º 7
0
 def SendKeywordBack(self, raw):
     try:
         data = json.loads(raw)
         if data.get("code") == 200:
             self.keywordList.clear()
             for keyword in data.get('data', {}).get("keywords", []):
                 self.keywordList.AddItem(keyword)
             pass
         else:
             pass
     except Exception as es:
         import sys
         cur_tb = sys.exc_info()[
             2]  # return (exc_type, exc_value, traceback)
         e = sys.exc_info()[1]
         Log.Error(cur_tb, e)
     pass
Ejemplo n.º 8
0
    def LoadCommentInfoBack(self, msg, index):
        try:
            self.loadingForm.close()
            item = self.listWidget.item(index)
            if not item:
                return
            widget = self.listWidget.itemWidget(item)
            if not widget:
                return
            self.childrenListWidget.UpdateState()
            data = json.loads(msg)
            self.childrenListWidget.parentId = index
            widget.gridLayout.addWidget(self.childrenWidget, 1, 0, 1, 1)
            if data.get("code") == 200:
                comments = data.get("data", {}).get("comments", {})
                page = int(comments.get("page", 1))
                total = int(comments.get("total", 1))
                pages = int(comments.get("pages", 1))
                limit = int(comments.get("limit", 1))
                self.childrenListWidget.UpdatePage(page, pages)
                for index, info in enumerate(comments.get("docs")):
                    floor = total - ((page - 1) * limit + index)
                    content = info.get("content")
                    name = info.get("_user", {}).get("name")
                    level = info.get("_user", {}).get("lv")
                    avatar = info.get("_user", {}).get("avatar", {})
                    createdTime = info.get("created_at")
                    commentsCount = info.get("commentsCount")
                    likesCount = info.get("likesCount")
                    commnetId = info.get('_id')
                    title = info.get("_user", {}).get("title", "")
                    level = info.get("_user", {}).get("level", 1)
                    self.childrenListWidget.AddUserItem(
                        commnetId, commentsCount, likesCount,
                        content, name, createdTime, floor,
                        avatar.get("fileServer"), avatar.get("path"),
                        avatar.get("originalName"), title, level)

                pass
            self.listWidget.scrollToItem(
                item, self.listWidget.ScrollHint.PositionAtTop)
            size = self.listWidget.size()
            item.setSizeHint(size)
        except Exception as es:
            Log.Error(es)