overviewwidget.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <qdatetime.h>
00024 #include <qsplitter.h>
00025 #include <qtextedit.h>
00026 #include <qvbox.h>
00027
00028 #include <kconfig.h>
00029 #include <kdialog.h>
00030 #include <klocale.h>
00031
00032 #include <actionpart.h>
00033 #include <error.h>
00034 #include <progress.h>
00035
00036 #include "overviewwidget.h"
00037
00038 using namespace KSync;
00039 using namespace KSync::OverView;
00040
00041 Widget::Widget( QWidget* parent, const char* name )
00042 : QWidget( parent, name )
00043 {
00044 QVBoxLayout *layout = new QVBoxLayout( this );
00045 layout->setMargin( KDialog::marginHint() );
00046
00047 QHBox* info = new QHBox( this );
00048 info->setSpacing( 10 );
00049 info->setMargin( 10 );
00050
00051 QVBox *info2 = new QVBox(info);
00052 m_device = new QLabel( info2 );
00053 m_profile= new QLabel( info2 );
00054 info->setStretchFactor( info2, 5 );
00055
00056 m_logo = new QLabel( info );
00057
00058 m_split = new QSplitter( this );
00059 m_edit = new QTextEdit( m_split );
00060 m_edit->setReadOnly( true );
00061 m_edit->setTextFormat( Qt::LogText );
00062 m_ab = new QWidget( m_split );
00063
00064 KConfig config( "kitchensyncrc" );
00065 config.setGroup( "OverviewPart" );
00066
00067 QValueList<int> sizes = config.readIntListEntry( "SplitterSize" );
00068 if ( sizes.isEmpty() ) {
00069 sizes.append( width() / 2 );
00070 sizes.append( width() / 2 );
00071 }
00072
00073 m_split->setSizes( sizes );
00074
00075 m_layout = new QVBoxLayout( m_ab );
00076 m_layout->insertStretch( -1, 5 );
00077 m_layoutFillIndex = 0;
00078
00079 layout->addWidget( info );
00080 layout->addWidget( m_split, 100 );
00081
00082 m_messageList.setAutoDelete( true );
00083 }
00084
00085 Widget::~Widget()
00086 {
00087 KConfig config( "kitchensyncrc" );
00088 config.setGroup( "OverviewPart" );
00089
00090 config.writeEntry( "SplitterSize", m_split->sizes() );
00091 }
00092
00093 void Widget::setProfile( const Profile& prof )
00094 {
00095 m_profile->setText( "<qt><b>" + i18n( " Profile: " ) + "</b>" + prof.name() + "</qt>" );
00096 cleanView();
00097 }
00098
00099 void Widget::setProfile( const QString& name, const QPixmap& pix )
00100 {
00101 m_device->setText( "<qt><b>"+ i18n( " Device: " ) + "</b>" + name + "</qt>" );
00102 m_logo->setPixmap( pix );
00103 cleanView();
00104 }
00105
00106 void Widget::addProgress( Konnector *, const Progress& prog )
00107 {
00108 m_edit->append( "<b>" + QDateTime::currentDateTime().toString() + "</b> " + prog.text() );
00109 }
00110
00111 void Widget::addProgress( ActionPart *, const Progress& prog )
00112 {
00113 m_edit->append( "<b>" + QDateTime::currentDateTime().toString() + "</b> " + prog.text() );
00114 }
00115
00116 void Widget::syncProgress( ActionPart * part, int status, int )
00117 {
00118 OverViewProgressEntry* it;
00119 for ( it = m_messageList.first(); it; it = m_messageList.next() ) {
00120 if ( QString::compare( it->name(), part->name() ) == 0 ) {
00121 it->setProgress( status );
00122 return;
00123 }
00124 }
00125
00126 OverViewProgressEntry* test = new OverViewProgressEntry( m_ab, "test" );
00127 m_messageList.append( test );
00128
00129 if ( !part->title().isEmpty() ) {
00130 test->setText( part->title() );
00131 }
00132
00133 if ( part->pixmap() ) {
00134 test->setPixmap( *(part->pixmap()) );
00135 }
00136
00137 test->setProgress( status );
00138 m_layout->insertWidget( m_layoutFillIndex , test, 0, AlignTop );
00139 m_layoutFillIndex++;
00140 test->show();
00141 }
00142
00143 void Widget::addError( Konnector *, const Error& prog )
00144 {
00145 m_edit->append( "<b>"+ QDateTime::currentDateTime().toString() + "</b> " + prog.text() );
00146 }
00147
00148 void Widget::addError( ActionPart *, const Error& prog )
00149 {
00150 m_edit->append( "<b>"+ QDateTime::currentDateTime().toString() + "</b> " + prog.text() );
00151 }
00152
00153 void Widget::startSync()
00154 {
00155 m_edit->append( "Starting to sync now" );
00156 }
00157
00158 void Widget::cleanView()
00159 {
00160 m_messageList.clear();
00161 }
00162
00163 #include "overviewwidget.moc"
This file is part of the documentation for kitchensync Library Version 3.3.2.