author | zautrix <zautrix> | 2004-12-05 11:14:32 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-12-05 11:14:32 (UTC) |
commit | 196365e533c6fd1a8f47aa9579763ef5afcebcda (patch) (side-by-side diff) | |
tree | 3784f0be50b790d9386db1e4ebd29d44317db026 /kaddressbook | |
parent | e4e75984b6cb581d87d436cb6c5140eb57dbdc51 (diff) | |
download | kdepimpi-196365e533c6fd1a8f47aa9579763ef5afcebcda.zip kdepimpi-196365e533c6fd1a8f47aa9579763ef5afcebcda.tar.gz kdepimpi-196365e533c6fd1a8f47aa9579763ef5afcebcda.tar.bz2 |
layout bugfixes
-rw-r--r-- | kaddressbook/views/contactlistview.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/xxportselectdialog.cpp | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/kaddressbook/views/contactlistview.cpp b/kaddressbook/views/contactlistview.cpp index ad43970..23b091c 100644 --- a/kaddressbook/views/contactlistview.cpp +++ b/kaddressbook/views/contactlistview.cpp @@ -96,193 +96,193 @@ void DynamicTip::maybeTip( const QPoint &pos ) QString notes = a.note().stripWhiteSpace(); if ( !notes.isEmpty() ) { notes += '\n'; s += '\n' + i18n("label: value", "%1: \n").arg(a.noteLabel()); QFontMetrics fm( font() ); // Begin word wrap code based on QMultiLineEdit code int i = 0; bool doBreak = false; int linew = 0; int lastSpace = -1; int a = 0; int lastw = 0; while ( i < int(notes.length()) ) { doBreak = FALSE; if ( notes[i] != '\n' ) linew += fm.width( notes[i] ); if ( lastSpace >= a && notes[i] != '\n' ) if (linew >= parentWidget()->width()) { doBreak = TRUE; if ( lastSpace > a ) { i = lastSpace; linew = lastw; } else i = QMAX( a, i-1 ); } if ( notes[i] == '\n' || doBreak ) { s += notes.mid( a, i - a + (doBreak?1:0) ) +"\n"; a = i + 1; lastSpace = a; linew = 0; } if ( notes[i].isSpace() ) { lastSpace = i; lastw = linew; } if ( lastSpace <= a ) { lastw = linew; } ++i; } } tip( r, s ); } else hide(); ishidden = !ishidden; } /////////////////////////// // ContactListViewItem Methods ContactListViewItem::ContactListViewItem(const KABC::Addressee &a, ContactListView *parent, KABC::AddressBook *doc, const KABC::Field::List &fields ) : KListViewItem(parent), mAddressee(a), mFields( fields ), parentListView( parent ), mDocument(doc) { refresh(); } QString ContactListViewItem::key(int column, bool ascending) const { #ifndef DESKTOP_VERSION int lan = KGlobal::locale()->language(); //qDebug("language %d ", lan); if ( lan == 1 ) { //GERMAN QString ret = QListViewItem::key(column, ascending).lower().utf8(); int start = -1; while ( (start = ret.find( 'ä', start+1)) > 0 ) { ret.at(start-1) = 'a'; } start = -1; while ( (start = ret.find( 'ö', start+1)) > 0 ) { ret.at(start-1) = 'o'; } start = -1; while ( (start = ret.find( 'ü', start+1)) > 0 ) { ret.at(start-1) = 'o'; } start = -1; while ( (start = ret.find( 'ß', start+1)) > 0 ) { ret.at(start-1) = 's'; } - qDebug("conv string %s ", ret.latin1()); + //qDebug("conv string %s ", ret.latin1()); return ret; } else #endif return QListViewItem::key(column, ascending).lower(); } void ContactListViewItem::paintCell(QPainter * p, const QColorGroup & cg, int column, int width, int align) { KListViewItem::paintCell(p, cg, column, width, align); if ( !p ) return; if (parentListView->singleLine()) { p->setPen( parentListView->alternateColor() ); p->drawLine( 0, height() - 1, width, height() - 1 ); } } ContactListView *ContactListViewItem::parent() { return parentListView; } void ContactListViewItem::refresh() { // Update our addressee, since it may have changed else were mAddressee = mDocument->findByUid(mAddressee.uid()); if (mAddressee.isEmpty()) return; int i = 0; KABC::Field::List::ConstIterator it; for( it = mFields.begin(); it != mFields.end(); ++it ) { setText( i++, (*it)->value( mAddressee ) ); } } /////////////////////////////// // ContactListView ContactListView::ContactListView(KAddressBookTableView *view, KABC::AddressBook* /* doc */, QWidget *parent, const char *name ) : KListView( parent, name ), pabWidget( view ), oldColumn( 0 ) { mABackground = true; mSingleLine = false; mToolTips = true; #ifndef KAB_EMBEDDED mAlternateColor = KGlobalSettings::alternateBackgroundColor(); #else //KAB_EMBEDDED mAlternateColor = QColor(240, 240, 240); #endif //KAB_EMBEDDED setAlternateBackgroundEnabled(mABackground); setAcceptDrops( true ); viewport()->setAcceptDrops( true ); setAllColumnsShowFocus( true ); setShowSortIndicator(true); setSelectionModeExt( KListView::Extended ); setDropVisualizer(false); // setFrameStyle(QFrame::NoFrame); //setLineWidth ( 0 ); //setMidLineWidth ( 0 ); //setMargin ( 0 ); #ifndef KAB_EMBEDDED connect(this, SIGNAL(dropped(QDropEvent*)), this, SLOT(itemDropped(QDropEvent*))); #endif //KAB_EMBEDDED new DynamicTip( this ); } void ContactListView::setAlternateColor(const QColor &m_AlternateColor) { mAlternateColor = m_AlternateColor; } void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect ) { QBrush b = palette().brush(QPalette::Active, QColorGroup::Base); diff --git a/kaddressbook/xxportselectdialog.cpp b/kaddressbook/xxportselectdialog.cpp index ab95d5f..6282453 100644 --- a/kaddressbook/xxportselectdialog.cpp +++ b/kaddressbook/xxportselectdialog.cpp @@ -1,133 +1,134 @@ /* This file is part of KAddressBook. Copyright (c) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk> Tobias Koenig <tokoe@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ /* Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ #include <kabc/addressbook.h> #include <kapplication.h> #include <kcombobox.h> #include <klocale.h> #include <kglobal.h> +#include <qapplication.h> #include <qbuttongroup.h> #include <qcombobox.h> #include <qheader.h> #include <qlabel.h> #include <qlayout.h> #include <qlistview.h> #include <qpushbutton.h> #include <qradiobutton.h> #include <qstringlist.h> #include <qwhatsthis.h> #include "kabcore.h" #include "kabprefs.h" #include "xxportselectdialog.h" XXPortSelectDialog::XXPortSelectDialog( KABCore *core, bool sort, QWidget* parent, const char* name ) : KDialogBase( Plain, i18n( "Choose which contacts to select" ), Help | Ok | Cancel, Ok, parent, name, true, true ), mCore( core ), mUseSorting( sort ) { initGUI(); connect( mFiltersCombo, SIGNAL( activated( int ) ), SLOT( filterChanged( int ) ) ); connect( mCategoriesView, SIGNAL( clicked( QListViewItem* ) ), SLOT( categoryClicked( QListViewItem* ) ) ); // setup filters #ifndef KAB_EMBEDDED mFilters = Filter::restore( kapp->config(), "Filter" ); Filter::List::iterator filterIt; #else //KAB_EMBEDDED mFilters = Filter::restore( KGlobal::config(), "Filter" ); Filter::List::Iterator filterIt; #endif //KAB_EMBEDDED QStringList filters; for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt ) filters.append( (*filterIt).name() ); mFiltersCombo->insertStringList( filters ); mUseFilters->setEnabled( filters.count() > 0 ); // setup categories QStringList categories = KABPrefs::instance()->mCustomCategories; QStringList::Iterator it; for ( it = categories.begin(); it != categories.end(); ++it ) new QCheckListItem( mCategoriesView, *it, QCheckListItem::CheckBox ); mUseCategories->setEnabled( categories.count() > 0 ); int count = mCore->selectedUIDs().count(); mUseSelection->setEnabled( count != 0 ); mUseSelection->setChecked( count > 1 ); mSortTypeCombo->insertItem( i18n( "Ascending" ) ); mSortTypeCombo->insertItem( i18n( "Descending" ) ); mFields = mCore->addressBook()->fields( KABC::Field::All ); KABC::Field::List::Iterator fieldIt; for ( fieldIt = mFields.begin(); fieldIt != mFields.end(); ++fieldIt ) mFieldCombo->insertItem( (*fieldIt)->label() ); } QStringList XXPortSelectDialog::uids() { QStringList uidlist; KABC::AddresseeList list = contacts(); KABC::Addressee::List::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) uidlist.append((*it).uid()); return uidlist; } KABC::AddresseeList XXPortSelectDialog::contacts() { QStringList selection = mCore->selectedUIDs(); KABC::AddresseeList list; if ( mUseSelection->isChecked() ) { QStringList::Iterator it; for ( it = selection.begin(); it != selection.end(); ++it ) { KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); if ( !addr.isEmpty() ) list.append( addr ); } } else if ( mUseFilters->isChecked() ) { // find contacts that can pass selected filter Filter::List::Iterator filterIt; for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt ) if ( (*filterIt).name() == mFiltersCombo->currentText() ) break; KABC::AddressBook::Iterator it; for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) { if ( (*filterIt).filterAddressee( *it ) ) list.append( *it ); @@ -152,137 +153,142 @@ KABC::AddresseeList XXPortSelectDialog::contacts() } if ( mUseSorting ) { list.setReverseSorting( mSortTypeCombo->currentItem() == 1 ); uint pos = mFieldCombo->currentItem(); if ( pos < mFields.count() ) list.sortByField( mFields[ pos ] ); } return list; } QStringList XXPortSelectDialog::categories() const { QStringList list; QListViewItemIterator it( mCategoriesView ); for ( ; it.current(); ++it ) { QCheckListItem* qcli = static_cast<QCheckListItem*>(it.current()); if ( qcli->isOn() ) list.append( it.current()->text( 0 ) ); } return list; } void XXPortSelectDialog::filterChanged( int ) { mUseFilters->setChecked( true ); } void XXPortSelectDialog::categoryClicked( QListViewItem *i ) { QCheckListItem *qcli = static_cast<QCheckListItem*>( i ); if ( qcli->isOn() ) mUseCategories->setChecked( true ); } void XXPortSelectDialog::slotHelp() { #ifndef KAB_EMBEDDED kapp->invokeHelp( "import-and-export" ); #else //KAB_EMBEDDED qDebug("XXPortSelectDialog::slotHelp is not implemented yet"); #endif //KAB_EMBEDDED } void XXPortSelectDialog::initGUI() { QFrame *page = plainPage(); QVBoxLayout *topLayout = new QVBoxLayout( page, KDialog::marginHint(), KDialog::spacingHint() ); QLabel *label = new QLabel( i18n( "Which contacts do you want to select?" ), page ); topLayout->addWidget( label ); mButtonGroup = new QButtonGroup( i18n( "Contact Selection" ), page ); mButtonGroup->setColumnLayout( 0, Qt::Vertical ); mButtonGroup->layout()->setSpacing( KDialog::spacingHint() ); mButtonGroup->layout()->setMargin( KDialog::marginHint() ); QGridLayout *groupLayout = new QGridLayout( mButtonGroup->layout() ); groupLayout->setAlignment( Qt::AlignTop ); mUseWholeBook = new QRadioButton( i18n( "&All" ), mButtonGroup ); mUseWholeBook->setChecked( true ); QWhatsThis::add( mUseWholeBook, i18n( "Select the entire address book" ) ); groupLayout->addWidget( mUseWholeBook, 0, 0 ); mUseSelection = new QRadioButton( i18n( "&Selected" ), mButtonGroup ); QWhatsThis::add( mUseSelection, i18n( "Only contacts selected in KAddressBook.\n" "This option is disabled if no contacts are selected." ) ); groupLayout->addWidget( mUseSelection, 1, 0 ); mUseFilters = new QRadioButton( i18n( "By matching &filter" ), mButtonGroup ); QWhatsThis::add( mUseFilters, i18n( "Only contacts matching the selected filter.\n" "This option is disabled if you haven't defined any filters" ) ); groupLayout->addWidget( mUseFilters, 2, 0 ); mUseCategories = new QRadioButton( i18n( "By Cate&gories" ), mButtonGroup ); QWhatsThis::add( mUseCategories, i18n( "Only contacts who are members of a category that is checked on the list to the left.\n" "This option is disabled if you have no categories." ) ); groupLayout->addWidget( mUseCategories, 3, 0 ); mFiltersCombo = new QComboBox( false, mButtonGroup ); QWhatsThis::add( mFiltersCombo, i18n( "Select a filter to decide which contacts to select." ) ); groupLayout->addWidget( mFiltersCombo, 2, 1 ); mCategoriesView = new QListView( mButtonGroup ); mCategoriesView->addColumn( "" ); mCategoriesView->header()->hide(); QWhatsThis::add( mCategoriesView, i18n( "Check the categories whose members you want to select." ) ); groupLayout->addWidget( mCategoriesView, 3, 1 ); + // if (QApplication::desktop()->height() == 480 ) + // mCategoriesView->setMaximumHeight( 240 ); topLayout->addWidget( mButtonGroup ); QButtonGroup *sortingGroup = new QButtonGroup( i18n( "Sorting" ), page ); sortingGroup->setColumnLayout( 0, Qt::Vertical ); QGridLayout *sortLayout = new QGridLayout( sortingGroup->layout(), 2, 2, KDialog::spacingHint() ); sortLayout->setAlignment( Qt::AlignTop ); label = new QLabel( i18n( "Criterion:" ), sortingGroup ); sortLayout->addWidget( label, 0, 0 ); #ifndef KAB_EMBEDDED mFieldCombo = new KComboBox( false, sortingGroup ); #else //KAB_EMBEDDED //US Combobox is not editable anyway mFieldCombo = new KComboBox( sortingGroup ); #endif //KAB_EMBEDDED sortLayout->addWidget( mFieldCombo, 0, 1 ); label = new QLabel( i18n( "Order:" ), sortingGroup ); sortLayout->addWidget( label, 1, 0 ); #ifndef KAB_EMBEDDED mSortTypeCombo = new KComboBox( false, sortingGroup ); #else //KAB_EMBEDDED //US Combobox is not editable anyway mSortTypeCombo = new KComboBox( sortingGroup ); #endif //KAB_EMBEDDED sortLayout->addWidget( mSortTypeCombo, 1, 1 ); topLayout->addWidget( sortingGroup ); if ( !mUseSorting ) - sortingGroup->hide(); + sortingGroup->hide(); +#ifndef DESKTOP_VERSION + hideButtons(); +#endif } #ifndef KAB_EMBEDDED #include "xxportselectdialog.moc" #endif //KAB_EMBEDDED |