[mythtv] [PATCH] Updated System Status
Kevin Kuphal
kuphal at dls.net
Fri Jul 23 09:08:31 EDT 2004
Kevin Kuphal wrote:
> This patch contains my initial revision of an updated system status
> screen. It currently reports the mythfilldatabase status from the
> original screen as well as a basic tuner status list indicating the
> state of each tuner (watching tv, recording) and if recording, what it
> is currently recording.
>
> I plan to update this again in the near future with more detail and
> more items but wanted to get this to the list for comments/suggestions
> and any fixes for problems I might have made.
>
> Includes one diff against CVS and the two new files for mythfrontend
I'm attaching new copies of this. It was late last night and I realized
this morning I had an error in the mythfrontend.pro as well as wasn't
being very efficient about enumerating the tuners. This should be better
Kevin
-------------- next part --------------
#ifndef STATUSBOX_H_
#define STATUSBOX_H_
#include "mythwidgets.h"
#include "mythdialogs.h"
class QIconView;
class QIconViewItem;
class QWidgetStack;
//class QListViewItem;
//class QLabel;
//class QProgressBar;
//class NuppelVideoPlayer;
//class RingBuffer;
//class QTimer;
//class ProgramInfo;
class StatusBox : public MythDialog
{
Q_OBJECT
public:
StatusBox(MythMainWindow *parent, const char *name = 0);
~StatusBox(void);
protected slots:
void selectionChanged(QIconViewItem *);
void clicked(QIconViewItem *);
void returnPressed(QIconViewItem *);
protected:
void doListingsStatus();
void doTunerStatus();
private:
QIconView *status_list;
QListView *tuner_list;
QIconViewItem *listing_item;
QLabel *heading, *status_label, *helptext, *listing_label;
QGridLayout *grid;
QWidgetStack *content_stack;
// Add a QIconViewItem here for each category
QIconViewItem *listings_item, *tuner_item;
};
#endif
-------------- next part --------------
Index: mythtv/programs/mythfrontend/main.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/main.cpp,v
retrieving revision 1.148
diff -n -u -r1.148 main.cpp
--- mythtv/programs/mythfrontend/main.cpp 29 Jun 2004 17:00:11 -0000 1.148
+++ mythtv/programs/mythfrontend/main.cpp 23 Jul 2004 06:53:32 -0000
@@ -34,6 +34,7 @@
#include "xbox.h"
#include "dbcheck.h"
#include "mythmediamonitor.h"
+#include "statusbox.h"
#define QUIT 1
#define HALT 2
@@ -293,6 +294,7 @@
void showStatus(void)
{
+/*
QString mfdLastRunStart, mfdLastRunEnd, mfdLastRunStatus, Status;
QString querytext, DataDirectMessage;
int DaysOfData;
@@ -378,6 +380,11 @@
status_dialog->exec();
delete status_dialog;
+*/
+ StatusBox statusbox(gContext->GetMainWindow(), "status box");
+ qApp->unlock();
+ statusbox.exec();
+ qApp->lock();
}
void TVMenuCallback(void *data, QString &selection)
Index: mythtv/programs/mythfrontend/mythfrontend.pro
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/mythfrontend.pro,v
retrieving revision 1.47
diff -n -u -r1.47 mythfrontend.pro
--- mythtv/programs/mythfrontend/mythfrontend.pro 21 Jan 2004 03:28:50 -0000 1.47
+++ mythtv/programs/mythfrontend/mythfrontend.pro 23 Jul 2004 06:53:32 -0000
@@ -27,7 +27,8 @@
# Input
HEADERS += manualbox.h playbackbox.h viewscheduled.h globalsettings.h
HEADERS += manualschedule.h programrecpriority.h channelrecpriority.h
+HEADERS += statusbox.h
SOURCES += main.cpp manualbox.cpp playbackbox.cpp viewscheduled.cpp
SOURCES += globalsettings.cpp manualschedule.cpp programrecpriority.cpp
-SOURCES += channelrecpriority.cpp
+SOURCES += channelrecpriority.cpp statusbox.cpp
-------------- next part --------------
#include <qlayout.h>
#include <qiconview.h>
#include <qsqldatabase.h>
#include <qwidgetstack.h>
#include <unistd.h>
#include <iostream>
using namespace std;
#include "statusbox.h"
#include "mythcontext.h"
#include "remoteutil.h"
#include "programinfo.h"
#include "tv.h"
StatusBox::StatusBox(MythMainWindow *parent, const char *name)
: MythDialog(parent, name)
{
// It would be nice if some nice person with graphics skills
// could make some nice icons here
const QPixmap icon;
grid = new QGridLayout(this, 3, 2, 10, 10);
grid->setRowStretch(1,1);
grid->setResizeMode(QLayout::FreeResize);
heading = new QLabel(QString("System Status"), this);
heading->setBackgroundOrigin(QWidget::AncestorOrigin);
grid->addMultiCellWidget(heading, 0, 0, 0, 1, Qt::AlignLeft|Qt::AlignTop);
helptext = new QLabel(QString("%1 %2").arg(screenwidth).arg(screenheight), this);
helptext->setBackgroundOrigin(QWidget::AncestorOrigin);
grid->addMultiCellWidget(helptext, 1, 1, 0, 1, Qt::AlignLeft|Qt::AlignTop);
status_list = new QIconView(this, "status list");
connect(status_list, SIGNAL(selectionChanged(QIconViewItem *)), this, SLOT(selectionChanged(QIconViewItem *)));
connect(status_list, SIGNAL(clicked(QIconViewItem *)), this, SLOT(clicked(QIconViewItem *)));
connect(status_list, SIGNAL(returnPressed(QIconViewItem *)), this, SLOT(returnPressed(QIconViewItem *)));
status_list->setFixedHeight((screenheight/3)*2);
status_list->setWordWrapIconText(false);
status_list->setArrangement(QIconView::TopToBottom);
status_list->setItemTextPos(QIconView::Right);
status_list->setResizeMode(QIconView::Adjust);
status_list->setSpacing(20);
status_list->setMinimumWidth((int)((screenwidth-20)/4));
status_list->setMaxItemWidth(status_list->minimumWidth());
listings_item = new QIconViewItem(status_list, "Listings Status");
listings_item->setPixmap(icon);
status_list->setSelected(listings_item, true);
status_list->setFocus();
tuner_item = new QIconViewItem(status_list, "Tuner Status");
tuner_item->setPixmap(icon);
grid->addWidget(status_list, 2, 0, Qt::AlignLeft|Qt::AlignBottom);
// Create the stack for the content pane
// If you are adding new content, make sure you define your widget globally
// and add it to the content_stack. Then modify the clicked function
// to raise your widget as needed
content_stack = new QWidgetStack(this, "content_stack");
content_stack->setFixedHeight((screenheight/3)*2);
content_stack->setFrameShape(status_list->frameShape());
content_stack->setFrameShadow(status_list->frameShadow());
content_stack->setLineWidth(status_list->lineWidth());
content_stack->setPaletteBackgroundColor(status_list->paletteBackgroundColor());
content_stack->setPaletteForegroundColor(status_list->paletteForegroundColor());
content_stack->setMinimumWidth((int)(((screenwidth-20)/4)*3)-20);
content_stack->setMargin(10);
// Display object for Listing Status
listing_label = new QLabel(this, "listing_label");
listing_label->setAlignment(Qt::AlignTop|Qt::WordBreak);
content_stack->addWidget(listing_label);
// Display object for Tuner Status
tuner_list = new QListView(this, "tuner list");
tuner_list->addColumn("Tuner");
tuner_list->addColumn("Status");
tuner_list->setAllColumnsShowFocus(true);
tuner_list->setColumnAlignment(0, Qt::AlignTop|Qt::AlignCenter);
tuner_list->setColumnAlignment(1, Qt::AlignTop|Qt::AlignLeft);
content_stack->addWidget(tuner_list);
grid->addWidget(content_stack, 2, 1, Qt::AlignTop|Qt::AlignLeft);
}
void StatusBox::selectionChanged(QIconViewItem *item)
{
if (item == listings_item)
helptext->setText(QString("Show the status of mythfilldatabase"));
if (item == tuner_item)
helptext->setText(QString("Show the status of tuner cards"));
}
void StatusBox::clicked(QIconViewItem *item)
{
if (item == listings_item)
{
content_stack->raiseWidget(listing_label);
doListingsStatus();
}
if (item == tuner_item)
{
content_stack->raiseWidget(tuner_list);
doTunerStatus();
}
status_list->setFocus();
}
void StatusBox::returnPressed(QIconViewItem *item)
{
clicked(item);
}
void StatusBox::doListingsStatus()
{
QString mfdLastRunStart, mfdLastRunEnd, mfdLastRunStatus, Status;
QString querytext, DataDirectMessage;
int DaysOfData;
QDateTime qdtNow, GuideDataThrough;
QSqlDatabase *db = QSqlDatabase::database();
qdtNow = QDateTime::currentDateTime();
querytext = QString("SELECT max(endtime) FROM program;");
QSqlQuery query = db->exec(querytext);
if (query.isActive() && query.numRowsAffected())
{
query.next();
GuideDataThrough = QDateTime::fromString(query.value(0).toString(),
Qt::ISODate);
}
mfdLastRunStart = gContext->GetSetting("mythfilldatabaseLastRunStart");
mfdLastRunEnd = gContext->GetSetting("mythfilldatabaseLastRunEnd");
mfdLastRunStatus = gContext->GetSetting("mythfilldatabaseLastRunStatus");
DataDirectMessage = gContext->GetSetting("DataDirectMessage");
Status = QObject::tr("Myth version:") + " " + MYTH_BINARY_VERSION + "\n";
Status += QObject::tr("Last mythfilldatabase guide update:");
Status += "\n ";
Status += QObject::tr("Started: ");
Status += mfdLastRunStart;
if (mfdLastRunEnd > mfdLastRunStart) //if end < start, it's still running.
{
Status += "\n ";
Status += QObject::tr("Finished: ");
Status += mfdLastRunEnd;
}
Status += "\n ";
Status += QObject::tr("Result: ");
Status += mfdLastRunStatus;
DaysOfData = qdtNow.daysTo(GuideDataThrough);
if (GuideDataThrough.isNull())
{
Status += "\n\n";
Status += QObject::tr("There's no guide data available! ");
Status += QObject::tr("Have you run mythfilldatabase?");
Status += "\n";
}
else
{
Status += "\n\n";
Status += QObject::tr("There is guide data until ");
Status += QDateTime(GuideDataThrough).toString("yyyy-MM-dd hh:mm");
if (DaysOfData > 0)
{
Status += QString("\n(%1 ").arg(DaysOfData);
if (DaysOfData >1)
Status += QObject::tr("days");
else
Status += QObject::tr("day");
Status += ").";
}
else
Status += ".";
}
if (DaysOfData <= 3)
{
Status += "\n";
Status += QObject::tr("WARNING: is mythfilldatabase running?");
}
if (!DataDirectMessage.isNull())
{
Status += "\n";
Status += QObject::tr("DataDirect Status: \n");
Status += DataDirectMessage;
}
listing_label->setText(Status);
}
void StatusBox::doTunerStatus()
{
QString querytext = QString("SELECT cardid FROM capturecard;");
QSqlDatabase *db = QSqlDatabase::database();
QSqlQuery query = db->exec(querytext);
if (query.isActive() && query.numRowsAffected())
{
tuner_list->clear();
while(query.next())
{
int cardid = query.value(0).toInt();
cerr << cardid << endl;
QString cmd = QString("QUERY_REMOTEENCODER %1").arg(cardid);
QStringList strlist = cmd;
strlist << "GET_STATE";
gContext->SendReceiveStringList(strlist);
QString Status = QString("Tuner ");
if (strlist[0].toInt()==kState_WatchingLiveTV)
Status += "is watching live TV";
else if (strlist[0].toInt()==kState_RecordingOnly ||
strlist[0].toInt()==kState_WatchingRecording)
Status += "is recording";
else
Status += "is not recording";
if (strlist[0].toInt()==kState_RecordingOnly)
{
strlist = QString("QUERY_RECORDER %1").arg(cardid);
strlist << "GET_RECORDING";
gContext->SendReceiveStringList(strlist);
ProgramInfo *proginfo = new ProgramInfo;
proginfo->FromStringList(strlist, 0);
Status += "\n";
Status += proginfo->title;
Status += " - ";
Status += proginfo->subtitle;
}
QListViewItem *tuner_item = new QListViewItem(tuner_list, QString::number(cardid), Status);
tuner_item->setMultiLinesEnabled(true);
}
}
}
StatusBox::~StatusBox(void)
{
}
More information about the mythtv-dev
mailing list