kitchensync Library API Documentation

overviewwidget.cpp

00001 /* 00002 This file is part of KitchenSync. 00003 00004 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 00005     Copyright (c) 2002 Maximilian Reiß <harlekin@handhelds.org> 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Library General Public License for more details. 00016 00017 You should have received a copy of the GNU Library General Public License 00018 along with this library; see the file COPYING.LIB. If not, write to 00019 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00020 Boston, MA 02111-1307, USA. 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"
KDE Logo
This file is part of the documentation for kitchensync Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Oct 1 15:18:59 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003