From 00adb66cf0f41466a0b0f4719bb406a62eb304a7 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Sun, 11 Dec 2011 22:57:14 -0500 Subject: [PATCH] ready for settings dialog work --- src/diagnosticsdialog.cpp | 148 ++++++++++++++++----------------- src/resolverconfigdelegate.cpp | 6 +- src/resolverconfigdelegate.h | 4 +- src/settingsdialog.cpp | 15 ++-- src/settingsdialog.h | 16 +++- 5 files changed, 101 insertions(+), 88 deletions(-) diff --git a/src/diagnosticsdialog.cpp b/src/diagnosticsdialog.cpp index f4d4473e9..cc77abab5 100644 --- a/src/diagnosticsdialog.cpp +++ b/src/diagnosticsdialog.cpp @@ -90,81 +90,81 @@ void DiagnosticsDialog::updateLogView() log.append("\n\n"); - // Peers - log.append("SIP PLUGINS:\n"); - QList< Tomahawk::source_ptr > sources = SourceList::instance()->sources( true ); - Q_FOREACH(SipPlugin *sip, SipHandler::instance()->allPlugins()) - { - Q_ASSERT(sip); - QString stateString; - switch( sip->connectionState() ) - { - case SipPlugin::Connecting: - stateString = "Connecting"; - break; + // Peers / Accounts, TODO + log.append("ACCOUNTS:\n"); +// QList< Tomahawk::source_ptr > sources = SourceList::instance()->sources( true ); +// Q_FOREACH(SipPlugin *sip, SipHandler::instance()->allPlugins()) +// { +// Q_ASSERT(sip); +// QString stateString; +// switch( sip->connectionState() ) +// { +// case SipPlugin::Connecting: +// stateString = "Connecting"; +// break; +// +// case SipPlugin::Connected: +// stateString = "Connected"; +// break; +// +// case SipPlugin::Disconnected: +// stateString = "Disconnected"; +// break; +// case SipPlugin::Disconnecting: +// stateString = "Disconnecting"; +// } +// log.append( +// QString(" %2 (%1): %3 (%4)\n") +// .arg(sip->account()->accountServiceName()) +// .arg(sip->friendlyName()) +// .arg(sip->account()->accountFriendlyName()) +// .arg(stateString) +// ); - case SipPlugin::Connected: - stateString = "Connected"; - break; - - case SipPlugin::Disconnected: - stateString = "Disconnected"; - break; - case SipPlugin::Disconnecting: - stateString = "Disconnecting"; - } - log.append( - QString(" %2 (%1): %3 (%4)\n") - .arg(sip->account()->accountServiceName()) - .arg(sip->friendlyName()) - .arg(sip->account()->accountFriendlyName()) - .arg(stateString) - ); - - Q_FOREACH( const QString &peerId, sip->peersOnline() ) - { - /* enable this again, when we check the source has this peerId - bool connected = false; - Q_FOREACH( const Tomahawk::source_ptr &source, sources ) - { - if( source->controlConnection() ) - { - connected = true; - break; - } - }*/ - - QString versionString = SipHandler::instance()->versionString( peerId ); - SipInfo sipInfo = SipHandler::instance()->sipInfo( peerId ); - if( !sipInfo.isValid() ) - log.append( - QString(" %1: %2 %3" /*"(%4)"*/ "\n") - .arg( peerId ) - .arg( "sipinfo invalid" ) - .arg( versionString ) - // .arg( connected ? "connected" : "not connected") - ); - else if( sipInfo.isVisible() ) - log.append( - QString(" %1: %2:%3 %4" /*" (%5)"*/ "\n") - .arg( peerId ) - .arg( sipInfo.host().hostName() ) - .arg( sipInfo.port() ) - .arg( versionString ) - // .arg( connected ? "connected" : "not connected") - - ); - else - log.append( - QString(" %1: visible: false %2" /*" (%3)"*/ "\n") - .arg( peerId ) - .arg( versionString ) - // .arg( connected ? "connected" : "not connected") - - ); - } - log.append("\n"); - } +// Q_FOREACH( const QString &peerId, sip->peersOnline() ) +// { +// /* enable this again, when we check the source has this peerId +// bool connected = false; +// Q_FOREACH( const Tomahawk::source_ptr &source, sources ) +// { +// if( source->controlConnection() ) +// { +// connected = true; +// break; +// } +// }*/ +// +// QString versionString = SipHandler::instance()->versionString( peerId ); +// SipInfo sipInfo = SipHandler::instance()->sipInfo( peerId ); +// if( !sipInfo.isValid() ) +// log.append( +// QString(" %1: %2 %3" /*"(%4)"*/ "\n") +// .arg( peerId ) +// .arg( "sipinfo invalid" ) +// .arg( versionString ) +// // .arg( connected ? "connected" : "not connected") +// ); +// else if( sipInfo.isVisible() ) +// log.append( +// QString(" %1: %2:%3 %4" /*" (%5)"*/ "\n") +// .arg( peerId ) +// .arg( sipInfo.host().hostName() ) +// .arg( sipInfo.port() ) +// .arg( versionString ) +// // .arg( connected ? "connected" : "not connected") +// +// ); +// else +// log.append( +// QString(" %1: visible: false %2" /*" (%3)"*/ "\n") +// .arg( peerId ) +// .arg( versionString ) +// // .arg( connected ? "connected" : "not connected") +// +// ); +// } +// log.append("\n"); +// } ui->logView->setPlainText(log); } diff --git a/src/resolverconfigdelegate.cpp b/src/resolverconfigdelegate.cpp index 9ff6c8f1a..1473a6a52 100644 --- a/src/resolverconfigdelegate.cpp +++ b/src/resolverconfigdelegate.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2011, Christian Muehlhaeuser + * Copyright 2010-2011, Leo Franchi * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -133,8 +133,10 @@ ResolverConfigDelegate::configRectForIndex( const QStyleOptionViewItem& option, } QRect -ResolverConfigDelegate::checkRectForIndex( const QStyleOptionViewItem &option, const QModelIndex &idx ) const +ResolverConfigDelegate::checkRectForIndex( const QStyleOptionViewItem &option, const QModelIndex &idx, int role ) const { + Q_UNUSED( role ); + QStyleOptionViewItemV4 opt = option; initStyleOption( &opt, idx ); QRect itemRect = opt.rect; diff --git a/src/resolverconfigdelegate.h b/src/resolverconfigdelegate.h index 62e3fe9ee..a6c8f32d8 100644 --- a/src/resolverconfigdelegate.h +++ b/src/resolverconfigdelegate.h @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2011, Christian Muehlhaeuser + * Copyright 2010-2011, Leo Franchi * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,7 +29,7 @@ public: explicit ResolverConfigDelegate( QObject* parent = 0 ); virtual void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const; - virtual QRect checkRectForIndex( const QStyleOptionViewItem &option, const QModelIndex &idx ) const; + virtual QRect checkRectForIndex( const QStyleOptionViewItem &option, const QModelIndex &idx, int role ) const; virtual QRect configRectForIndex( const QStyleOptionViewItem& option, const QModelIndex& idx ) const; private slots: diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index 34cd01b1b..e4654ac29 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -46,17 +46,20 @@ #include "resolversmodel.h" #include "scanmanager.h" #include "settingslistdelegate.h" -#include "sipconfigdelegate.h" +#include "AccountDelegate.h" #include "database/database.h" #include "network/servent.h" #include "playlist/dynamic/widgets/LoadingSpinner.h" #include "sip/SipHandler.h" -#include "sip/AccountModel.h" +#include "accounts/AccountModel.h" #include "utils/logger.h" #include "ui_proxydialog.h" #include "ui_stackedsettingsdialog.h" +using namespace Tomahawk; +using namespace Accounts; + static QString md5( const QByteArray& src ) { @@ -69,7 +72,7 @@ SettingsDialog::SettingsDialog( QWidget *parent ) , ui( new Ui_StackedSettingsDialog ) , m_proxySettings( this ) , m_rejected( false ) - , m_sipModel( 0 ) + , m_accountModel( 0 ) , m_resolversModel( 0 ) , m_sipSpinner( 0 ) { @@ -107,7 +110,7 @@ SettingsDialog::SettingsDialog( QWidget *parent ) #endif // SIP PLUGINS - SipConfigDelegate* sipdel = new SipConfigDelegate( this ); + AccountDelegate* sipdel = new AccountDelegate( this ); ui->accountsView->setItemDelegate( sipdel ); ui->accountsView->setContextMenuPolicy( Qt::CustomContextMenu ); ui->accountsView->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel ); @@ -115,8 +118,8 @@ SettingsDialog::SettingsDialog( QWidget *parent ) connect( ui->accountsView, SIGNAL( clicked( QModelIndex ) ), this, SLOT( sipItemClicked( QModelIndex ) ) ); connect( sipdel, SIGNAL( openConfig( SipPlugin* ) ), this, SLOT( openSipConfig( SipPlugin* ) ) ); connect( ui->accountsView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( sipContextMenuRequest( QPoint ) ) ); - m_sipModel = new SipModel( this ); - ui->accountsView->setModel( m_sipModel ); + m_accountModel = new AccountModel( this ); + ui->accountsView->setModel( m_accountModel ); if ( !Servent::instance()->isReady() ) { diff --git a/src/settingsdialog.h b/src/settingsdialog.h index ef2d53eee..a2fa1de90 100644 --- a/src/settingsdialog.h +++ b/src/settingsdialog.h @@ -27,9 +27,7 @@ class LoadingSpinner; class QListWidgetItem; class Ui_StackedSettingsDialog; -class SipPluginFactory; class SipPlugin; -class SipModel; class ResolversModel; class QNetworkReply; @@ -39,6 +37,14 @@ namespace Ui class ProxyDialog; } +namespace Tomahawk +{ + namespace Accounts + { + class AccountModel; + } +} + class ProxyDialog : public QDialog { Q_OBJECT @@ -105,7 +111,7 @@ private slots: void sipCreateConfigClosed( int value ); */ void updateScanOptionsView(); - + void changePage( QListWidgetItem*, QListWidgetItem* ); void serventReady(); @@ -118,9 +124,11 @@ private: ProxyDialog m_proxySettings; bool m_rejected; - SipModel* m_sipModel; + Tomahawk::Accounts::AccountModel* m_accountModel; ResolversModel* m_resolversModel; LoadingSpinner* m_sipSpinner; }; #endif // SETTINGSDIALOG_H + +struct A;