Partially replaced queries in bitmessageqt.blacklist
This commit is contained in:
parent
9bca4faf9f
commit
7dd75eec21
|
@ -1,10 +1,11 @@
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
|
import helper_db
|
||||||
import widgets
|
import widgets
|
||||||
from addresses import addBMIfNotPresent
|
from addresses import addBMIfNotPresent
|
||||||
from bmconfigparser import BMConfigParser
|
from bmconfigparser import BMConfigParser
|
||||||
from dialogs import AddAddressDialog
|
from dialogs import AddAddressDialog
|
||||||
from helper_sql import sqlExecute, sqlQuery
|
from helper_sql import sqlExecute
|
||||||
from queues import UISignalQueue
|
from queues import UISignalQueue
|
||||||
from retranslateui import RetranslateMixin
|
from retranslateui import RetranslateMixin
|
||||||
from tr import _translate
|
from tr import _translate
|
||||||
|
@ -61,16 +62,14 @@ class Blacklist(QtGui.QWidget, RetranslateMixin):
|
||||||
_translate("MainWindow", "Address is valid."):
|
_translate("MainWindow", "Address is valid."):
|
||||||
address = addBMIfNotPresent(str(
|
address = addBMIfNotPresent(str(
|
||||||
self.NewBlacklistDialogInstance.lineEditAddress.text()))
|
self.NewBlacklistDialogInstance.lineEditAddress.text()))
|
||||||
# First we must check to see if the address is already in the
|
label = str(self.NewBlacklistDialogInstance.lineEditLabel.text().toUtf8())
|
||||||
# address book. The user cannot add it again or else it will
|
if helper_db.put_addresslist(
|
||||||
# cause problems when updating and deleting the entry.
|
label, address,
|
||||||
t = (address,)
|
group='blacklist'
|
||||||
if BMConfigParser().get('bitmessagesettings', 'blackwhitelist') == 'black':
|
if BMConfigParser().get(
|
||||||
sql = '''select * from blacklist where address=?'''
|
'bitmessagesettings', 'blackwhitelist') == 'black'
|
||||||
else:
|
else 'whitelist'
|
||||||
sql = '''select * from whitelist where address=?'''
|
):
|
||||||
queryreturn = sqlQuery(sql,*t)
|
|
||||||
if queryreturn == []:
|
|
||||||
self.tableWidgetBlacklist.setSortingEnabled(False)
|
self.tableWidgetBlacklist.setSortingEnabled(False)
|
||||||
self.tableWidgetBlacklist.insertRow(0)
|
self.tableWidgetBlacklist.insertRow(0)
|
||||||
newItem = QtGui.QTableWidgetItem(unicode(
|
newItem = QtGui.QTableWidgetItem(unicode(
|
||||||
|
@ -82,12 +81,6 @@ class Blacklist(QtGui.QWidget, RetranslateMixin):
|
||||||
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
|
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
|
||||||
self.tableWidgetBlacklist.setItem(0, 1, newItem)
|
self.tableWidgetBlacklist.setItem(0, 1, newItem)
|
||||||
self.tableWidgetBlacklist.setSortingEnabled(True)
|
self.tableWidgetBlacklist.setSortingEnabled(True)
|
||||||
t = (str(self.NewBlacklistDialogInstance.lineEditLabel.text().toUtf8()), address, True)
|
|
||||||
if BMConfigParser().get('bitmessagesettings', 'blackwhitelist') == 'black':
|
|
||||||
sql = '''INSERT INTO blacklist VALUES (?,?,?)'''
|
|
||||||
else:
|
|
||||||
sql = '''INSERT INTO whitelist VALUES (?,?,?)'''
|
|
||||||
sqlExecute(sql, *t)
|
|
||||||
else:
|
else:
|
||||||
UISignalQueue.put((
|
UISignalQueue.put((
|
||||||
'updateStatusBar',
|
'updateStatusBar',
|
||||||
|
@ -158,19 +151,18 @@ class Blacklist(QtGui.QWidget, RetranslateMixin):
|
||||||
|
|
||||||
def rerenderBlackWhiteList(self):
|
def rerenderBlackWhiteList(self):
|
||||||
tabs = self.parent().parent()
|
tabs = self.parent().parent()
|
||||||
if BMConfigParser().get('bitmessagesettings', 'blackwhitelist') == 'black':
|
list_type = BMConfigParser().get(
|
||||||
tabs.setTabText(tabs.indexOf(self), _translate('blacklist', 'Blacklist'))
|
'bitmessagesettings', 'blackwhitelist')
|
||||||
else:
|
tabs.setTabText(
|
||||||
tabs.setTabText(tabs.indexOf(self), _translate('blacklist', 'Whitelist'))
|
tabs.indexOf(self),
|
||||||
|
_translate('blacklist', 'Blacklist') if list_type == 'black'
|
||||||
|
else _translate('blacklist', 'Whitelist'))
|
||||||
|
|
||||||
self.tableWidgetBlacklist.setRowCount(0)
|
self.tableWidgetBlacklist.setRowCount(0)
|
||||||
listType = BMConfigParser().get('bitmessagesettings', 'blackwhitelist')
|
|
||||||
if listType == 'black':
|
|
||||||
queryreturn = sqlQuery('''SELECT label, address, enabled FROM blacklist''')
|
|
||||||
else:
|
|
||||||
queryreturn = sqlQuery('''SELECT label, address, enabled FROM whitelist''')
|
|
||||||
self.tableWidgetBlacklist.setSortingEnabled(False)
|
self.tableWidgetBlacklist.setSortingEnabled(False)
|
||||||
for row in queryreturn:
|
for label, address, enabled in helper_db.get_addresslist(
|
||||||
label, address, enabled = row
|
group='blacklist' if list_type == 'black' else 'whiteslist'
|
||||||
|
):
|
||||||
self.tableWidgetBlacklist.insertRow(0)
|
self.tableWidgetBlacklist.insertRow(0)
|
||||||
newItem = QtGui.QTableWidgetItem(unicode(label, 'utf-8'))
|
newItem = QtGui.QTableWidgetItem(unicode(label, 'utf-8'))
|
||||||
if not enabled:
|
if not enabled:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user