From kde-commits Sun Jan 02 10:40:31 2011 From: Sergio Martins Date: Sun, 02 Jan 2011 10:40:31 +0000 To: kde-commits Subject: [kdepim] a148b71: In to-do view, set a decent minimum size for the c Message-Id: <20110102104031.1F49BA6090 () git ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=129396486709927 commit a148b7186ee6c84b3397b08652755f4a93b9f8df branch master Author: Sergio Martins Date: Sun Jan 2 07:38:07 2011 +0000 In to-do view, set a decent minimum size for the category combo, so that "Select Categories" fits. diff --git a/korganizer/views/todoview/kotodoviewquicksearch.cpp b/korganizer/views/todoview/kotodoviewquicksearch.cpp index c7a276e..ea52249 100644 --- a/korganizer/views/todoview/kotodoviewquicksearch.cpp +++ b/korganizer/views/todoview/kotodoviewquicksearch.cpp @@ -34,7 +34,7 @@ #include #include -#include +#include #include #include @@ -75,6 +75,19 @@ KOTodoViewQuickSearch::KOTodoViewQuickSearch( CalendarSupport::Calendar *calenda layout->addWidget( mCategoryCombo, 1 ); fillCategories(); + { // Make the combo big enough so that "Select Categories" fits. + QFontMetrics fm = mCategoryCombo->lineEdit()->fontMetrics(); + + // QLineEdit::sizeHint() returns a nice size to fit 17 'x' chars. + const int currentPreferedWidth = mCategoryCombo->lineEdit()->sizeHint().width(); + + // Calculate a nice size for "Select Categories" + const int newPreferedWidth = currentPreferedWidth - fm.width( QLatin1Char('x') )*17 + fm.width( mCategoryCombo->defaultText() ); + + const int pixelsToAdd = newPreferedWidth - mCategoryCombo->lineEdit()->width(); + mCategoryCombo->setMinimumWidth( mCategoryCombo->width() + pixelsToAdd ); + } + setLayout( layout ); } @@ -135,7 +148,6 @@ void KOTodoViewQuickSearch::fillCategories() void KOTodoViewQuickSearch::emitSearchCategoryChanged() { - /* The display role doesn't work because it represents subcategories as " subcategory", and we want * "ParentCollection:subCategory" */ emit searchCategoryChanged( mCategoryCombo->checkedItems( Qt::UserRole ) );