[Kstars-devel] KDE/kdeedu/kstars/kstars

Jason Harris kstars at 30doradus.org
Wed Jul 26 07:07:45 CEST 2006


SVN commit 566433 by harris:

The "DST Rule" label now looks like an HTML link (the text is blue and 
underlined), and clicking on it will open the window explaining the 
available DST rules.

This window was a KMessageBox::informationList(), but I'm now creating 
my own KDialog, because I wanted to be able to increase the width of the 
window so there's no need for a horizontal scrollbar.  Apparently 
the KMessageBox can't resize itself to fit the contents.

CCMAIL: kstars-devel at kde.org



 M  +23 -6     locationdialog.cpp  


--- trunk/KDE/kdeedu/kstars/kstars/locationdialog.cpp #566432:566433
@@ -38,8 +38,8 @@
 {
 	ui = new LocationDialogUI( this );
 	setMainWidget( ui );
-        setCaption( i18n( "Set Geographic Location" ) );
-        setButtons( KDialog::Ok|KDialog::Cancel );
+	setCaption( i18n( "Set Geographic Location" ) );
+	setButtons( KDialog::Ok|KDialog::Cancel );
 
 	for ( int i=0; i<25; ++i )
 		ui->TZBox->addItem( KGlobal::locale()->formatNumber( (double)(i-12) ) );
@@ -66,8 +66,9 @@
 	connect( ui->AddCityButton, SIGNAL( clicked() ), this, SLOT( addCity() ) );
 	connect( ui->ClearFieldsButton, SIGNAL( clicked() ), this, SLOT( clearFields() ) );
 
-	disconnect( ui->DSTLabel, SIGNAL( linkClicked(const QString &) ), ui->DSTLabel, SLOT(openLink(const QString &) ) );
-	connect( ui->DSTLabel, SIGNAL( linkClicked(const QString &) ), this, SLOT( showTZRules() ) );
+	ui->DSTLabel->setNotifyClick( true );
+	ui->DSTLabel->setHtml( "<a href=\"showrules\">" + i18n("DST Rule:") + "</a>" );
+	connect( ui->DSTLabel, SIGNAL( urlClick(const QString &) ), this, SLOT( showTZRules() ) );
 
 	dataModified = false;
 	nameModified = false;
@@ -174,7 +175,6 @@
 
 	//Fill the fields at the bottom of the window with the selected city's data.
 	if ( SelectedCity ) {
-		KStars *p = (KStars *)parent();
 		ui->NewCityName->setText( SelectedCity->translatedName() );
 		if ( SelectedCity->province().isEmpty() )
 			ui->NewProvinceName->setText( QString() );
@@ -378,7 +378,24 @@
 	lines.append( i18n( "ZN: Apr. 1 (01:00) / Oct. 1 (00:00)" ) );
 
 	QString message = i18n( "Daylight Saving Time Rules" );
-	KMessageBox::informationList( 0, message, lines, message );
+//	KMessageBox::informationList( 0, message, lines, message );
+
+	KDialog *tzd = new KDialog( this );
+	tzd->setCaption( message );
+	tzd->setButtons( KDialog::Close );
+	QListWidget *lw = new QListWidget( tzd );
+	lw->addItems( lines );
+	//This is pretty lame...I have to measure the width of the first item in the 
+	//list widget, in order to set its width properly.  Why doesn't it just resize 
+	//the widget to fit the contents automatically?  I tried setting the sizePolicy, 
+	//no joy...
+	int w = 1.1*lw->visualItemRect( lw->item(0) ).width();
+	lw->setMinimumWidth( w );
+	tzd->setMainWidget( lw );
+	tzd->exec();
+
+	delete lw;
+	delete tzd;
 }
 
 void LocationDialog::nameChanged( void ) {


More information about the Kstars-devel mailing list