update in server info page - Had a bug report that seems to imply a hang in KSystemTimeZones::local() (gdb) bt full #0 0x00007ffff0d7c183 in poll () from /lib/libc.so.6 No symbol table info available. #1 0x00007fffeaafbed0 in socket_do_iteration () from /usr/lib/libdbus-1.so.3 No symbol table info available. #2 0x00007fffeaafadbd in _dbus_transport_do_iteration () from /usr/lib/libdbus-1.so.3 No symbol table info available. #3 0x00007fffeaae5e85 in _dbus_connection_do_iteration_unlocked () from /usr/lib/libdbus-1.so.3 No symbol table info available. #4 0x00007fffeaae71af in _dbus_connection_block_pending_call () from /usr/lib/libdbus-1.so.3 No symbol table info available. #5 0x00007fffeaae67a4 in dbus_connection_send_with_reply_and_block () from /usr/lib/libdbus-1.so.3 No symbol table info available. #6 0x00007ffff33252a5 in ?? () from /usr/lib/libQtDBus.so.4 No symbol table info available. #7 0x00007ffff3325bb9 in ?? () from /usr/lib/libQtDBus.so.4 No symbol table info available. #8 0x00007ffff333481b in ?? () from /usr/lib/libQtDBus.so.4 No symbol table info available. #9 0x00007ffff3334959 in QDBusInterface::QDBusInterface(QString const&, QString const&, QString const&, QDBusConnection const&, QObject*) () from /usr/lib/libQtDBus.so.4 No symbol table info available. #10 0x00007ffff77dd44b in ?? () from /usr/lib/libkdecore.so.5 No symbol table info available. #11 0x00007ffff77ddb49 in KSystemTimeZones::local() () from /usr/lib/libkdecore.so.5 No symbol table info available. #12 0x00007ffff77c0918 in KDateTime::Spec::setType(KDateTime::SpecType, int) () from /usr/lib/libkdecore.so.5 No symbol table info available. #13 0x00007ffff77ce14c in ?? () from /usr/lib/libkdecore.so.5 No symbol table info available. #14 0x00007ffff77a6651 in KCalendarSystem::formatDate(QDate const&, QString const&, KLocale::DigitSet, KLocale::DateTimeFormatStandard) const () from /usr/lib/libkdecore.so.5 No symbol table info available. #15 0x00007ffff77a66b3 in KCalendarSystem::formatDate(QDate const&, QString const&, KLocale::DateTimeFormatStandard) const () from /usr/lib/libkdecore.so.5 No symbol table info available. #16 0x00007ffff77a74b1 in KCalendarSystem::formatDate(QDate const&, KLocale::DateFormat) const () from /usr/lib/libkdecore.so.5 No symbol table info available. #17 0x00007ffff78b08ee in ?? () from /usr/lib/libkdecore.so.5 ---Type <return> to continue, or q <return> to quit--- No symbol table info available. #18 0x00007ffff78afe71 in KLocale::formatDate(QDate const&, KLocale::DateFormat) const () from /usr/lib/libkdecore.so.5 No symbol table info available. #19 0x00007ffff78b552d in ?? () from /usr/lib/libkdecore.so.5 No symbol table info available. #20 0x00007ffff78b5881 in ?? () from /usr/lib/libkdecore.so.5 No symbol table info available. #21 0x00007ffff78b0085 in KLocale::formatDateTime(QDateTime const&, KLocale::DateFormat, bool) const () from /usr/lib/libkdecore.so.5 No symbol table info available. #22 0x0000000000480ca0 in ServerInfoPage::statsUpdated (this=0xa36b20, stats=...) at /home/devel/cantata/src/cantata-0.5.0/gui/serverinfopage.cpp:129
104 lines
3.5 KiB
C++
104 lines
3.5 KiB
C++
/*
|
|
* Cantata
|
|
*
|
|
* Copyright (c) 2011-2012 Craig Drummond <craig.p.drummond@gmail.com>
|
|
*
|
|
* ----
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; see the file COPYING. If not, write to
|
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
* Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#include "serverinfopage.h"
|
|
#include "mpdconnection.h"
|
|
#include "mpdstats.h"
|
|
#include "mainwindow.h"
|
|
#include "mpdparseutils.h"
|
|
#ifdef ENABLE_KDE_SUPPORT
|
|
#include <KDE/KAction>
|
|
#include <KDE/KLocale>
|
|
#include <KDE/KGlobal>
|
|
#include <KDE/KActionCollection>
|
|
#else
|
|
#include <QtGui/QAction>
|
|
#endif
|
|
|
|
|
|
ServerInfoPage::ServerInfoPage(MainWindow *p)
|
|
: QWidget(p)
|
|
{
|
|
setupUi(this);
|
|
#ifdef ENABLE_KDE_SUPPORT
|
|
updateAction = p->actionCollection()->addAction("updatempdinfo");
|
|
updateAction->setText(i18n("Update MPD Information"));
|
|
#else
|
|
updateAction = new QAction(tr("Update MPD Information"), this);
|
|
#endif
|
|
updateAction->setIcon(QIcon::fromTheme("view-refresh"));
|
|
updateInfo->setDefaultAction(updateAction);
|
|
connect(updateAction, SIGNAL(triggered(bool)), MPDConnection::self(), SLOT(getStats()));
|
|
connect(MPDConnection::self(), SIGNAL(statsUpdated(const MPDStats &)), SLOT(statsUpdated(const MPDStats &)));
|
|
connect(MPDConnection::self(), SIGNAL(version(long)), SLOT(mpdVersion(long)));
|
|
connect(MPDConnection::self(), SIGNAL(version(long)), SIGNAL(getUrlHandlers()));
|
|
connect(MPDConnection::self(), SIGNAL(urlHandlers(const QStringList &)), SLOT(urlHandlers(const QStringList &)));
|
|
connect(this, SIGNAL(getUrlHandlers()), MPDConnection::self(), SLOT(getUrlHandlers()));
|
|
|
|
MainWindow::initButton(updateInfo);
|
|
clear();
|
|
}
|
|
|
|
ServerInfoPage::~ServerInfoPage()
|
|
{
|
|
}
|
|
|
|
void ServerInfoPage::clear()
|
|
{
|
|
version->setText(QString());
|
|
uptime->setText(QString());
|
|
timePlaying->setText(QString());
|
|
totalDuration->setText(QString());
|
|
artists->setText(QString());
|
|
album->setText(QString());
|
|
songs->setText(QString());
|
|
lastUpdate->setText(QString());
|
|
urlhandlers->setText(QString());
|
|
}
|
|
|
|
void ServerInfoPage::statsUpdated(const MPDStats &stats)
|
|
{
|
|
dbUpdate=stats.dbUpdate;
|
|
uptime->setText(MPDParseUtils::formatDuration(stats.uptime));
|
|
timePlaying->setText(MPDParseUtils::formatDuration(stats.playtime));
|
|
totalDuration->setText(MPDParseUtils::formatDuration(stats.dbPlaytime));
|
|
artists->setText(QString::number(stats.artists));
|
|
album->setText(QString::number(stats.albums));
|
|
songs->setText(QString::number(stats.songs));
|
|
// #ifdef ENABLE_KDE_SUPPORT
|
|
// lastUpdate->setText(KGlobal::locale()->formatDateTime(stats.dbUpdate));
|
|
// #else
|
|
lastUpdate->setText(stats.dbUpdate.toString(Qt::SystemLocaleShortDate));
|
|
// #endif
|
|
}
|
|
|
|
void ServerInfoPage::mpdVersion(long v)
|
|
{
|
|
version->setText(QString("%1.%2.%3").arg((v>>16)&0xFF).arg((v>>8)&0xFF).arg(v&0xFF));
|
|
}
|
|
|
|
void ServerInfoPage::urlHandlers(const QStringList &handlers)
|
|
{
|
|
urlhandlers->setText(handlers.join(", "));
|
|
}
|