Temp commit. Not yet working.
This commit is contained in:
@@ -55,6 +55,12 @@ class ICAOViewDelegate(QtGui.QStyledItemDelegate):
|
||||
painter.setPen(QtGui.QColor(0, 0, 0, alpha))
|
||||
painter.drawText(option.rect.left()+3, option.rect.top(), option.rect.width(), option.rect.height(), option.displayAlignment, paintstr)
|
||||
|
||||
#class dashboard_sql_model(QtCore.QAbstractTableModel):
|
||||
# def __init__(self, parent):
|
||||
# QtCore.QAbstractTableModel.__init__(self, parent)
|
||||
|
||||
# def update(self, icao):
|
||||
|
||||
#TODO must add libqt4-sql, libqt4-sql-sqlite, python-qt4-sql to dependencies
|
||||
#TODO looks like you're going to have to either integrate this into sql.py (ugh!) or find a way to keep it in sync
|
||||
#seems like it wants to have control over maintaining data currency
|
||||
@@ -62,6 +68,13 @@ class ICAOViewDelegate(QtGui.QStyledItemDelegate):
|
||||
class dashboard_sql_model(QtSql.QSqlQueryModel):
|
||||
def __init__(self, parent):
|
||||
QtSql.QSqlQueryModel.__init__(self, parent)
|
||||
self._query = """select tab1.icao, tab1.seen, tab1.lat, tab1.lon, tab1.alt, speed, heading, vertical, ident, type
|
||||
from (select * from (select * from positions order by seen desc) group by icao) tab1
|
||||
left join (select * from (select * from vectors order by seen desc) group by icao) tab2
|
||||
on tab1.icao=tab2.icao
|
||||
left join (select * from (select * from ident)) tab3
|
||||
on tab1.icao=tab3.icao
|
||||
where tab1.seen > datetime('now', '-1 minute')"""
|
||||
self._sql = None
|
||||
self._db = QtSql.QSqlDatabase("QSQLITE")
|
||||
self._db.setDatabaseName("adsb.db") #TODO specify this elsewhere
|
||||
@@ -69,16 +82,9 @@ class dashboard_sql_model(QtSql.QSqlQueryModel):
|
||||
#what is this i don't even
|
||||
#fetches the combined data of all three tables for all ICAOs seen in the last minute.
|
||||
#FIXME PyQt's SQLite gives you different results than the SQLite browser
|
||||
self.setQuery("""select tab1.icao, tab1.seen, tab1.lat, tab1.lon, tab1.alt, speed, heading, vertical, ident, type
|
||||
from (select * from (select * from positions order by seen desc) group by icao) tab1
|
||||
left join (select * from (select * from vectors order by seen desc) group by icao) tab2
|
||||
on tab1.icao=tab2.icao
|
||||
left join (select * from (select * from ident)) tab3
|
||||
on tab1.icao=tab3.icao
|
||||
where tab1.seen > datetime('now', '-1 hour')""", self._db)
|
||||
self.setQuery(self._query, self._db)
|
||||
|
||||
#the big club
|
||||
def update_all(self, icao):
|
||||
# self.beginInsertRows(QtCore.QModelIndex(), 1, 1)
|
||||
self.dataChanged.emit(self.createIndex(0, 0), self.createIndex(self.rowCount(), self.columnCount()))
|
||||
# self.endInsertRows()
|
||||
self.setQuery(self._query, self._db)
|
||||
#self.dataChanged.emit(self.createIndex(0, 0), self.createIndex(self.rowCount(), self.columnCount()))
|
||||
|
||||
Reference in New Issue
Block a user