Пример #1
0
 def feedUpdate(self, feedurl=None):
     db = ReaderDb()
     control = db.execute(
         "select feed_url from folders where type='feed' and feed_url=?",
         (feedurl, ))
     feed = control.fetchone()
     thread = FeedSync(self)
     thread.feedAdd(feed)
     thread.finished.connect(self.syncSignal)
     thread.start()
Пример #2
0
 def unreadFolderInit(self):
     db = ReaderDb()
     data = db.execute("select * from store where iscache=1")
     feedList = data.fetchall()
     db.close()
     self.unreadFolder.setForeground(0,QBrush(QColor(0,0,0,255)))
     if len(feedList) > 0:
         self.unreadFolder.setText(0, self.tr("({}) Unread").format(len(feedList)))
         self.unreadFolder.setForeground(0,QBrush(QColor(0,0,255)))
     return feedList
Пример #3
0
 def deletedFolderInit(self):
     db = ReaderDb()
     data = db.execute("select * from store where istrash=1")
     feedList = data.fetchall()
     db.close()
     self.deletedFolder.setForeground(0,QBrush(QColor(0,0,0,255)))
     if len(feedList) > 0:
         self.deletedFolder.setText(0, self.tr("({}) Deleted").format(len(feedList)))
         self.deletedFolder.setForeground(0,QBrush(QColor(0,0,255)))
         self.deletedFolder.setIcon(0, QIcon(":/images/icons/trash_full.png"))
     return feedList
Пример #4
0
 def storeFolderInit(self):
     db = ReaderDb()
     data = db.execute("select * from store where isstore=1")
     feedList = data.fetchall()
     db.close()
     self.storeFolder.setForeground(0,QBrush(QColor(0,0,0,255)))
     if len(feedList) > 0:
         self.storeFolder.setText(0, self.tr("({}) Stored").format(len(feedList)))
         self.storeFolder.setForeground(0,QBrush(QColor(0,0,255)))
     self.treeWidgetTitleSignal.emit(self.storeFolder.text(0))
     return feedList
Пример #5
0
 def feedInit(self):
     db = ReaderDb()
     data = db.execute("select * from store where iscache=1 and feed_url=?",
                       (self.feed_url, ))
     feedList = data.fetchall()
     db.close()
     self.setForeground(0, QBrush(QColor(0, 0, 0, 255)))
     if len(feedList) > 0:
         self.setText(0, "({}) {}".format(len(feedList), self.title))
         self.setForeground(0, QBrush(QColor(0, 0, 255)))
     return feedList
Пример #6
0
 def folderInit(self):
     db = ReaderDb()
     self.categorySorting(self.id)
     for feed in self.feedList:
         db.execute("select * from store where iscache=1 and feed_url=?",
                    feed)
         for entry in db.cursor.fetchall():
             self.entryList.append(entry)
     self.setForeground(0, QBrush(QColor(0, 0, 0, 255)))
     if self.newsCount > 0:
         self.setText(0, "({}) {}".format(self.newsCount, self.title))
         self.setForeground(0, QBrush(QColor(0, 0, 255)))
     return self.entryList
Пример #7
0
 def addItem(self, item):
     self.item = item
     self.setWindowTitle(self.tr("{} - Info").format(self.item.title))
     self.lineEditFeed.setText(self.item.feed_url)
     self.lineEditTitle.setText(self.item.title)
     self.labelMainURL.setText("<a href='{0}'>{0}</a>".format(
         self.item.site_url))
     db = ReaderDb()
     db.execute("select * from folders where type='folder'")
     categories = db.cursor.fetchall()
     for category in categories:
         self.comboBox.addItem(category["title"])
         if item.parent == category["id"]:
             self.comboBox.setCurrentText(category["title"])
Пример #8
0
 def allUpdate(self):
     QApplication.setOverrideCursor(Qt.BusyCursor)
     db = ReaderDb()
     control = db.execute("select feed_url from folders where type='feed'")
     feedList = control.fetchall()
     self.lenFeeds = len(feedList)
     self.statusbar.progress.setMaximum(len(feedList))
     for feedurl in feedList:
         thread = FeedSync(self)
         thread.feedAdd(feedurl)
         thread.isData.connect(self.statusbar.setProgress)
         thread.lenSignal.connect(self.lenNews)
         thread.isData.connect(self.threadProgress)
         thread.start()
Пример #9
0
 def saveInfo(self):
     db = ReaderDb()
     db.execute("select * from folders where type='folder' and title=?",
                (self.comboBox.currentText(), ))
     data = db.cursor.fetchone()
     if data:
         category = data["id"]
     else:
         category = 0
     db.execute("update folders set parent=? where id=?",
                (category, self.item.id))
     db.commit()
     db.close()
     self.parent.syncSignal.emit()
     self.parent.categorySync()
     self.accept()
Пример #10
0
 def run(self):
     if not self.file == "":
         fileR = QFile(self.file)
         fileR.open(QIODevice.ReadOnly | QIODevice.Text)
         etree = cElementTree.XML(fileR.readAll())
         feedList = etree.findall("feed")
         self.parent.progressBar.setMaximum(len(feedList))
         db = ReaderDb()
         counter = 0
         for feed in feedList:
             counter += 1
             self.progress.emit(counter)
             db.execute("select * from folders where feed_url=?",
                        (feed.text, ))
             if not db.cursor.fetchone():
                 try:
                     self.parent.labelFeed.setStyleSheet(
                         "color:green; font-weight:bold;")
                     self.parent.labelFeed.setText(
                         self.tr("{} adding...").format(feed.text))
                     fInfo = feedInfo(feed.text)
                     fav = self.faviconUrl(fInfo["sitelink"])
                     db.execute(
                         "insert into folders (title, type, feed_url, site_url, description, favicon) values (?, 'feed', ?, ?, ?, ?)",
                         (fInfo["title"], fInfo["feedlink"],
                          fInfo["sitelink"], fInfo["description"],
                          self.getFavicon(fav)))
                     db.commit()
                     self.msleep(100)
                 except AttributeError:
                     self.parent.labelFeed.setStyleSheet(
                         "color:red; font-weight:bold;")
                     self.parent.labelFeed.setText(
                         self.tr("{} unable to add.").format(feed.text))
                     self.msleep(500)
             else:
                 self.parent.labelFeed.setStyleSheet(
                     "color:blue; font-weight:bold;")
                 self.parent.labelFeed.setText(
                     self.tr("{} added.").format(feed.text))
                 self.msleep(500)
         db.close()
         fileR.close()
Пример #11
0
    def exportFileDialog(self):
        file = QFileDialog.getSaveFileName(
            self, self.tr("Domestic File"),
            Settings.value("FileDialog/path") or "",
            self.tr("Domestic file (*.dfx)"))
        if not file[0] == "":
            db = ReaderDb()
            db.execute("select feed_url from folders where type='feed'")
            allFeed = db.cursor.fetchall()
            root = cElementTree.Element("domestic")
            for feed in allFeed:
                child = cElementTree.SubElement(root, "feed")
                child.text = feed["feed_url"]

            fileW = QFile(file[0])
            fileW.open(QIODevice.WriteOnly | QIODevice.Text)
            fileW.write(cElementTree.tostring(root, "unicode"))
            fileW.close()
            Settings.setValue("FileDialog/path", os.dirname(file[0]))
            Settings.sync()
Пример #12
0
 def feedAdd(self):
     data = feedInfo(self.lineEditURI.text())
     db = ReaderDb()
     fav = self.faviconUrl(data["sitelink"])
     db.execute("select id from folders where type='folder' and title=?",
                (self.comboBox.currentText(), ))
     folder = db.cursor.fetchone()
     if folder:
         category = folder["id"]
     else:
         category = 0
     db.execute(
         "insert into folders (title, parent, type, feed_url, site_url, description, favicon) values (?, ?, 'feed', ?, ?, ?, ?)",
         (data["title"], category, data["feedlink"], data["sitelink"],
          data["description"], self.getFavicon(fav)))
     db.commit()
     db.close()
     self.feedAddFinished.emit(self.lineEditURI.text())
     self.parent.syncSignal.emit()
     self.parent.categorySync()
     self.close()
Пример #13
0
    def categorySorting(self, id=0, treeitem=None):
        db = ReaderDb()
        db.execute("select * from folders where parent=?",(id,))
        folders = db.cursor.fetchall()
        for folder in folders:
            if folder["type"] == "folder":
                item = FolderItem(treeitem)
                item.addOptions(folder)
                self.parent.syncSignal.connect(item.folderClick)
                key = "TreeWidget/{}".format(item.title.replace(" ", "-"))
                if Settings.value(key) != None:
                    item.setExpanded(int(Settings.value(key)))
                self.categoryList.append(item)
                self.categorySorting(folder["id"], item)

            elif folder["type"] == "feed":
                item = FeedItem(treeitem)
                item.addOptions(folder)
                self.parent.syncSignal.connect(item.feedClick)
                self.categoryList.append(item)
                self.categorySorting(folder["id"], item)
Пример #14
0
 def feedControl(self):
     feed = isFeed(self.lineEditURI.text())
     if feed:
         data = feedInfo(self.lineEditURI.text())
         db = ReaderDb()
         db.execute("select * from folders where feed_url=?",
                    (data["feedlink"], ))
         if not db.cursor.fetchone():
             db.execute("select * from folders where type='folder'")
             for category in db.cursor.fetchall():
                 self.comboBox.addItem(category["title"])
             self.labelCategory.show()
             self.comboBox.show()
             self.buttonBox.button(QDialogButtonBox.Save).show()
             self.buttonBox.button(QDialogButtonBox.Ok).hide()
         else:
             self.labelWarning.setText(
                 self.
                 tr("<span style='color:red; font-size:15px; font-weight:bold;'>That feed is already exist!</span>"
                    ))
             self.labelWarning.show()
     else:
         self.labelWarning.setText(
             self.
             tr("<span style='color:red; font-size:15px; font-weight:bold;'>Wrong link name!</span>"
                ))
         self.labelWarning.show()
Пример #15
0
 def updateToolTip(self):
     db = ReaderDb()
     db.execute("select * from store where iscache=1")
     unread = db.cursor.fetchall()
     db.execute("select * from store where isstore=1")
     store = db.cursor.fetchall()
     db.execute("select * from store where istrash=1")
     trash = db.cursor.fetchall()
     self.setToolTip(
         self.tr('''<span style='font-size:14pt'>{} - {}</span>
     <br><span style='font-size:10pt'>Unread: {}</span>
     <br><span style='font-size:10pt'>Stored: {}</span>
     <br><span style='font-size:10pt'>Deleted: {}</span>''').format(
             QApplication.applicationName(),
             QApplication.applicationVersion(), len(unread), len(store),
             len(trash)))
Пример #16
0
 def categorySorting(self, id=0):
     db = ReaderDb()
     db.execute("select * from folders where parent=?", (id, ))
     folders = db.cursor.fetchall()
     for feed in folders:
         if feed["type"] == "feed":
             db.execute(
                 "select * from store where iscache=1 and feed_url=?",
                 (feed["feed_url"], ))
             data = db.cursor.fetchall()
             self.feedList.append((feed["feed_url"], ))
             self.newsCount += len(data)
         self.categorySorting(feed["id"])
Пример #17
0
 def feedStore(self):
     itemAll = self.page.treeWidget.selectedItems()
     db = ReaderDb()
     if len(itemAll):
         if self.treeWidget.currentItem() != self.treeWidget.storeFolder:
             for item in itemAll:
                 db.execute(
                     "update store set istrash=0, iscache=0, isstore=1 where entry_url=?",
                     (item.getEntryUrl(), ))
                 index = self.page.treeWidget.indexOfTopLevelItem(item)
                 self.page.treeWidget.takeTopLevelItem(index)
                 QApplication.processEvents()
         else:
             QMessageBox.warning(self, self.tr("Warning!"),
                                 self.tr("These are already stored."))
     else:
         QMessageBox.warning(self, self.tr("Warning!"),
                             self.tr("Selection has not done!"))
     db.commit()
     db.close()
     self.syncSignal.emit()
Пример #18
0
 def feedDelete(self):
     db = ReaderDb()
     if self.page.treeWidget.hasFocus():
         itemAll = self.page.treeWidget.selectedItems()
         if len(itemAll):
             for item in itemAll:
                 if self.treeWidget.currentItem(
                 ) == self.treeWidget.deletedFolder:
                     db.execute(
                         "update store set istrash=-1, iscache=0, isstore=0, entry_content='' where entry_url=?",
                         (item.getEntryUrl(), ))
                 else:
                     db.execute(
                         "update store set istrash=1, iscache=0, isstore=0 where entry_url=?",
                         (item.getEntryUrl(), ))
                 index = self.page.treeWidget.indexOfTopLevelItem(item)
                 self.page.treeWidget.takeTopLevelItem(index)
                 QApplication.processEvents()
         else:
             QMessageBox.warning(self, self.tr("Warning!"),
                                 self.tr("Selection has not done!"))
     elif self.treeWidget.hasFocus():
         items = self.treeWidget.selectedItems()
         if len(items):
             if isinstance(items[0], FeedItem):
                 box = QMessageBox.question(
                     self, self.tr("Are you sure?"),
                     self.tr("Do you want to delete the {} feed?").format(
                         items[0].title))
                 if box == 16384:
                     db.execute("delete from folders where feed_url=?",
                                (items[0].feed_url, ))
                     if isinstance(items[0]._parent, FolderItem):
                         parent = items[0]._parent
                         index = parent.indexOfChild(items[0])
                         parent.takeChild(index)
                     else:
                         index = self.treeWidget.indexOfTopLevelItem(
                             items[0])
                         self.treeWidget.takeTopLevelItem(index)
             elif isinstance(items[0], FolderItem):
                 db.execute("select * from folders where parent=?",
                            (items[0].id, ))
                 if db.cursor.fetchone():
                     QMessageBox.warning(
                         self, self.tr("Warning!"),
                         self.tr("Before, you empty for the directory!"))
                 else:
                     db.execute("delete from folders where id=?",
                                (items[0].id, ))
                     index = self.treeWidget.indexOfTopLevelItem(items[0])
                     self.treeWidget.takeTopLevelItem(index)
     else:
         QMessageBox.warning(self, self.tr("Warning!"),
                             self.tr("Selection has not done!"))
     db.commit()
     db.close()
     self.syncSignal.emit()