[Kstars-devel] KDE/kdeedu/kstars/kstars/tools
Jason Harris
kstars at 30doradus.org
Sat Feb 17 06:05:32 CET 2007
SVN commit 634387 by harris:
AstroCalc fixes. The navigationPanel widget was too narrow to
display its contents. I tried various ways to determine the
correct width in AstroCalc::AstroCalc(), but it seems that the
QTreeWidgetItems don't yet have their correct geometry in the ctor.
Any ideas where this code can be placed to make it work correctly?
I suppose I can make a slot and connect it to a single-shot timer
in the ctor, but is there a less kludgy way?
I left my last attempt in as commented code, but for now I am
just hardcoding a minimum width of 200 pixels.
CCMAIL: kstars-devel at kde.org
M +27 -2 astrocalc.cpp
--- trunk/KDE/kdeedu/kstars/kstars/tools/astrocalc.cpp #634386:634387
@@ -50,7 +50,7 @@
navigationPanel = new QTreeWidget(split);
navigationPanel->setColumnCount(1);
- navigationPanel->setHeaderLabels( QStringList(i18n("Section")) );
+ navigationPanel->setHeaderLabels( QStringList(i18n("Calculator modules")) );
navigationPanel->setSortingEnabled( false );
QIcon jdIcon = QIcon ("jd.png");
@@ -88,6 +88,32 @@
solarItem->setIcon(0,solarIcon);
new QTreeWidgetItem(solarItem,QStringList(i18n("Planets Coordinates")) );
+ //Try to set the minimum width based on the width of the QTreeWidgetItems
+ //FIXME: This isn't working; apparently the widget items don't have geometry yet...
+ /*
+ //Set minimum width of Nav panel to the widest contained item
+ int maxWidth = 0;
+ for ( int iTop = 0; iTop < navigationPanel->topLevelItemCount(); iTop++ ) {
+ QTreeWidgetItem *topItem = navigationPanel->topLevelItem( iTop );
+ //DEBUG
+ kDebug() << "top: " << iTop << endl;
+ for ( int iChild = 0; iChild < topItem->childCount(); iChild++ ) {
+ QTreeWidgetItem *childItem = topItem->child( iChild );
+ //DEBUG
+ kDebug() << "child: " << iChild << endl;
+ int w = navigationPanel->visualItemRect( childItem ).width();
+ //DEBUG
+ kDebug() << "Width: " << w << endl;
+ if ( w > maxWidth ) maxWidth = w;
+ }
+ }
+ navigationPanel->setMinimumWidth( maxWidth );
+ navigationPanel->adjustSize();
+ */
+
+ //FIXME: remove these two lines when the above code is made to work
+ navigationPanel->setMinimumWidth( 200 );
+
//Populate widget stack
acStack = new QStackedWidget( split );
@@ -127,7 +153,6 @@
connect(navigationPanel, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this,
SLOT(slotItemSelection(QTreeWidgetItem *)));
-
}
AstroCalc::~AstroCalc()
More information about the Kstars-devel
mailing list