void KNotesSummaryWidget::updateView() { mNotes = mCalendar->journals(); QLabel *label; for ( label = mLabels.first(); label; label = mLabels.next() ) label->deleteLater(); mLabels.clear(); KIconLoader loader( "knotes" ); int counter = 0; QPixmap pm = loader.loadIcon( "knotes", KIcon::Small ); KCal::Journal::List::Iterator it; if ( mNotes.count() ) { for (it = mNotes.begin(); it != mNotes.end(); ++it) { // Fill Note Pixmap Field label = new QLabel( this ); label->setPixmap( pm ); label->setMaximumWidth( label->minimumSizeHint().width() ); label->setAlignment( AlignVCenter ); mLayout->addWidget( label, counter, 0 ); mLabels.append( label ); // File Note Summary Field QString newtext = (*it)->summary(); KURLLabel *urlLabel = new KURLLabel( (*it)->uid(), newtext, this ); urlLabel->installEventFilter( this ); urlLabel->setTextFormat(RichText); urlLabel->setAlignment( urlLabel->alignment() | Qt::WordBreak ); mLayout->addWidget( urlLabel, counter, 1 ); mLabels.append( urlLabel ); if ( !(*it)->description().isEmpty() ) { QToolTip::add( urlLabel, (*it)->description().left( 80 ) ); } connect( urlLabel, SIGNAL( leftClickedURL( const QString& ) ), this, SLOT( urlClicked( const QString& ) ) ); counter++; } } else {
void SummaryWidget::updateView() { mLayouts.setAutoDelete( true ); mLayouts.clear(); mLayouts.setAutoDelete( false ); mLabels.setAutoDelete( true ); mLabels.clear(); mLabels.setAutoDelete( false ); if ( mStations.count() == 0 ) { kdDebug(5602) << "No weather stations defined..." << endl; return; } QValueList<WeatherData> dataList = mWeatherMap.values(); qHeapSort( dataList ); QValueList<WeatherData>::Iterator it; for ( it = dataList.begin(); it != dataList.end(); ++it ) { QString cover; for ( uint i = 0; i < (*it).cover().count(); ++i ) cover += QString( "- %1\n" ).arg( (*it).cover()[ i ] ); QImage img; img = (*it).icon(); QGridLayout *layout = new QGridLayout( mLayout, 3, 3, 3 ); mLayouts.append( layout ); KURLLabel* urlLabel = new KURLLabel( this ); urlLabel->installEventFilter( this ); urlLabel->setURL( (*it).stationID() ); urlLabel->setPixmap( img.smoothScale( 32, 32 ) ); urlLabel->setMaximumSize( urlLabel->sizeHint() ); urlLabel->setAlignment( AlignTop ); layout->addMultiCellWidget( urlLabel, 0, 1, 0, 0 ); mLabels.append( urlLabel ); connect ( urlLabel, SIGNAL( leftClickedURL( const QString& ) ), this, SLOT( showReport( const QString& ) ) ); QLabel* label = new QLabel( this ); label->setText( QString( "%1 (%2)" ).arg( (*it).name() ).arg( (*it).temperature() ) ); QFont font = label->font(); font.setBold( true ); label->setFont( font ); label->setAlignment( AlignLeft ); layout->addMultiCellWidget( label, 0, 0, 1, 2 ); mLabels.append( label ); QString labelText; labelText = QString( "<b>%1:</b> %2<br>" "<b>%3:</b> %4<br>" "<b>%5:</b> %6" ) .arg( i18n( "Last updated on" ) ) .arg( (*it).date() ) .arg( i18n( "Wind Speed" ) ) .arg( (*it).windSpeed() ) .arg( i18n( "Rel. Humidity" ) ) .arg( (*it).relativeHumidity() ); QToolTip::add( label, labelText.replace( " ", " " ) ); label = new QLabel( cover, this ); label->setAlignment( AlignLeft ); layout->addMultiCellWidget( label, 1, 1, 1, 2 ); mLabels.append( label ); } for ( QLabel *label = mLabels.first(); label; label = mLabels.next() ) label->show(); }