GUI interface still not quite working. Two issues:
* PyQt4.QtSql's SQLite interface doesn't appear to return the same results as the SQLite browser. This is probably me depending on a bad data ordering assumption. * QSqlQueryModel isn't set up to have the db change from underneath it, AFAIK -- have to add the ability to notify it there's new data.
This commit is contained in:
parent
dd3e1fe629
commit
33349efd7f
@ -115,7 +115,8 @@ class mainwindow(QtGui.QMainWindow):
|
||||
self.ui.compass_heading.setNeedle(Qwt.QwtDialSimpleNeedle(Qwt.QwtDialSimpleNeedle.Ray, False, QtCore.Qt.black))
|
||||
self.ui.compass_bearing.setNeedle(Qwt.QwtDialSimpleNeedle(Qwt.QwtDialSimpleNeedle.Ray, False, QtCore.Qt.black))
|
||||
|
||||
#hook up the update signal
|
||||
#hook up the update signals which are explicitly necessary
|
||||
#most of the dashboard_mapper and list_aircraft stuff is implicitly done already
|
||||
self.ui.list_aircraft.selectionModel().currentRowChanged.connect(self.dashboard_mapper.setCurrentModelIndex)
|
||||
self.ui.list_aircraft.selectionModel().currentRowChanged.connect(self.update_heading_widget)
|
||||
self.ui.list_aircraft.selectionModel().currentRowChanged.connect(self.update_bearing_widget)
|
||||
@ -140,11 +141,11 @@ class mainwindow(QtGui.QMainWindow):
|
||||
def unmapped_widgets_dataChanged(self, startIndex, endIndex):
|
||||
index = self.ui.list_aircraft.selectionModel().currentIndex()
|
||||
if index.row() in range(startIndex.row(), endIndex.row()+1): #the current aircraft was affected
|
||||
if self.datamodel._colnames.index("heading") in range(startIndex.column(), endIndex.column()+1):
|
||||
if 6 in range(startIndex.column(), endIndex.column()+1):
|
||||
self.update_heading_widget(index)
|
||||
if self.datamodel._colnames.index("bearing") in range(startIndex.column(), endIndex.column()+1):
|
||||
if 12 in range(startIndex.column(), endIndex.column()+1):
|
||||
self.update_bearing_widget(index)
|
||||
if self.datamodel._colnames.index("rssi") in range(startIndex.column(), endIndex.column()+1):
|
||||
if 2 in range(startIndex.column(), endIndex.column()+1):
|
||||
self.update_rssi_widget(index)
|
||||
|
||||
def update_rssi_widget(self, index):
|
||||
|
@ -42,8 +42,12 @@ class ICAOViewDelegate(QtGui.QStyledItemDelegate):
|
||||
paintstr = index.model().data(index.model().index(index.row(), 8)).toString()
|
||||
else:
|
||||
paintstr = index.model().data(index.model().index(index.row(), 0)).toString()
|
||||
last_report = index.model().data(index.model().index(index.row(), 1)).toDouble()[0]
|
||||
age = (time.time() - last_report)
|
||||
|
||||
#FIXME this is kind of heinous, find out how you got int data out of it last time
|
||||
last_report = time.strptime(str(index.model().data(index.model().index(index.row(), 1)).toString()), "%Y-%m-%d %H:%M:%S")
|
||||
age = (time.mktime(time.gmtime()) - time.mktime(last_report)) - 3600.*time.daylight
|
||||
print age
|
||||
|
||||
max_age = 60. #age at which it grays out
|
||||
#minimum alpha is 0x40 (oldest), max is 0xFF (newest)
|
||||
age = min(age, max_age)
|
||||
@ -52,6 +56,9 @@ class ICAOViewDelegate(QtGui.QStyledItemDelegate):
|
||||
painter.drawText(option.rect.left()+3, option.rect.top(), option.rect.width(), option.rect.height(), option.displayAlignment, paintstr)
|
||||
|
||||
#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
|
||||
#worst case is you make your own damn SQL query model based on abstracttablemodel.
|
||||
class dashboard_sql_model(QtSql.QSqlQueryModel):
|
||||
def __init__(self, parent):
|
||||
QtSql.QSqlQueryModel.__init__(self, parent)
|
||||
@ -61,14 +68,17 @@ class dashboard_sql_model(QtSql.QSqlQueryModel):
|
||||
self._db.open()
|
||||
#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 minute')""", self._db)
|
||||
where tab1.seen > datetime('now', '-1 hour')""", 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()
|
||||
|
@ -38,7 +38,7 @@ class output_sql:
|
||||
c = self._db.cursor()
|
||||
query = """CREATE TABLE IF NOT EXISTS "positions" (
|
||||
"icao" INTEGER KEY NOT NULL,
|
||||
"seen" TEXT NOT NULL,
|
||||
"seen" DATETIME NOT NULL,
|
||||
"alt" INTEGER,
|
||||
"lat" REAL,
|
||||
"lon" REAL
|
||||
@ -46,7 +46,7 @@ class output_sql:
|
||||
c.execute(query)
|
||||
query = """CREATE TABLE IF NOT EXISTS "vectors" (
|
||||
"icao" INTEGER KEY NOT NULL,
|
||||
"seen" TEXT NOT NULL,
|
||||
"seen" DATETIME NOT NULL,
|
||||
"speed" REAL,
|
||||
"heading" REAL,
|
||||
"vertical" REAL
|
||||
|
Loading…
Reference in New Issue
Block a user