author | zautrix <zautrix> | 2005-01-24 09:57:42 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-24 09:57:42 (UTC) |
commit | 485a6b28e3be6437742852970fdd122ba071b726 (patch) (side-by-side diff) | |
tree | 2ff605dbd72c91fa5d693056cf7dd0c746c0e2e3 | |
parent | ec69f34e62250f95a1f8757c5d58da0bf330678a (diff) | |
download | kdepimpi-485a6b28e3be6437742852970fdd122ba071b726.zip kdepimpi-485a6b28e3be6437742852970fdd122ba071b726.tar.gz kdepimpi-485a6b28e3be6437742852970fdd122ba071b726.tar.bz2 |
chaned qt version comparison
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.cpp | 4 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookiconview.cpp | 4 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 4 | ||||
-rw-r--r-- | korganizer/kotodoviewitem.cpp | 2 | ||||
-rw-r--r-- | korganizer/kotodoviewitem.h | 2 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 2 | ||||
-rw-r--r-- | korganizer/searchdialog.cpp | 22 | ||||
-rw-r--r-- | korganizer/timespanview.cpp | 2 | ||||
-rw-r--r-- | libkcal/icalformatimpl.cpp | 6 | ||||
-rw-r--r-- | microkde/KDGanttMinimizeSplitter.cpp | 10 | ||||
-rw-r--r-- | microkde/kcalendarsystemgregorian.cpp | 8 |
11 files changed, 31 insertions, 35 deletions
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp index 6fcd73f..9d8c5ce 100644 --- a/kaddressbook/views/kaddressbookcardview.cpp +++ b/kaddressbook/views/kaddressbookcardview.cpp @@ -221,209 +221,209 @@ void KAddressBookCardView::readConfig(KConfig *config) // costum colors? if ( config->readBoolEntry( "EnableCustomColors", false ) ) { QPalette p( mCardView->palette() ); QColor c = p.color(QPalette::Normal, QColorGroup::Base ); p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); c = p.color(QPalette::Normal, QColorGroup::Text ); p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); c = p.color(QPalette::Normal, QColorGroup::Button ); p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); c = p.color(QPalette::Normal, QColorGroup::ButtonText ); p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); c = p.color(QPalette::Normal, QColorGroup::Highlight ); p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); mCardView->viewport()->setPalette( p ); } else { // needed if turned off during a session. mCardView->viewport()->setPalette( mCardView->palette() ); } //custom fonts? QFont f( font() ); if ( config->readBoolEntry( "EnableCustomFonts", false ) ) { mCardView->setFont( config->readFontEntry( "TextFont", &f) ); f.setBold( true ); mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); } else { mCardView->setFont( f ); f.setBold( true ); mCardView->setHeaderFont( f ); } mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", true)); mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); mCardView->setShowEmptyFields( mShowEmptyFields ); mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); #if 0 // LR KABPrefs::instance()->mHonorSingleClick is handled and fixed in cardviews contentsMouseDoubleClickEven disconnect(mCardView, SIGNAL(executed(CardViewItem *)), this, SLOT(addresseeExecuted(CardViewItem *))); if (KABPrefs::instance()->mHonorSingleClick) connect(mCardView, SIGNAL(executed(CardViewItem *)), this, SLOT(addresseeExecuted(CardViewItem *))); else connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), this, SLOT(addresseeExecuted(CardViewItem *))); #endif connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), this, SLOT(addresseeExecuted(CardViewItem *))); } void KAddressBookCardView::writeConfig( KConfig *config ) { config->writeEntry( "ItemWidth", mCardView->itemWidth() ); KAddressBookView::writeConfig( config ); } void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) { mCardView->clear(); if ( s.isEmpty() || s == "*" ) { refresh(); return; } QString pattern = s.lower()+"*"; QRegExp re; re.setWildcard(true); // most people understand these better. re.setCaseSensitive(false); re.setPattern( pattern ); if (!re.isValid()) return; mCardView->viewport()->setUpdatesEnabled( false ); KABC::Addressee::List addresseeList = addressees(); KABC::Addressee::List::Iterator it; if ( field ) { for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) continue; -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (re.search(field->value( *it ).lower()) != -1) #else if (re.match(field->value( *it ).lower()) != -1) #endif new AddresseeCardViewItem(fields(), mShowEmptyFields, addressBook(), *it, mCardView); } } else { KABC::Field::List fieldList = allFields(); KABC::Field::List::ConstIterator fieldIt; for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) continue; for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (re.search((*fieldIt)->value( *it ).lower()) != -1) #else if (re.match((*fieldIt)->value( *it ).lower()) != -1) #endif { new AddresseeCardViewItem(fields(), mShowEmptyFields, addressBook(), *it, mCardView); break; } } } } mCardView->viewport()->setUpdatesEnabled( true ); mCardView->viewport()->update(); if ( mCardView->firstItem() ) { mCardView->setCurrentItem ( mCardView->firstItem() ); mCardView->setSelected ( mCardView->firstItem() , true ); } else emit selected(QString::null); } QStringList KAddressBookCardView::selectedUids() { QStringList uidList; CardViewItem *item; AddresseeCardViewItem *aItem; for (item = mCardView->firstItem(); item; item = item->nextItem()) { if (item->isSelected()) { #ifndef KAB_EMBEDDED aItem = dynamic_cast<AddresseeCardViewItem*>(item); #else //KAB_EMBEDDED aItem = (AddresseeCardViewItem*)(item); #endif //KAB_EMBEDDED if (aItem) uidList << aItem->addressee().uid(); } } return uidList; } void KAddressBookCardView::refresh(QString uid) { CardViewItem *item; AddresseeCardViewItem *aItem; if (uid.isNull()) { // Rebuild the view mCardView->viewport()->setUpdatesEnabled( false ); mCardView->clear(); KABC::Addressee::List addresseeList = addressees(); KABC::Addressee::List::Iterator iter; for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) { if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) continue; aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields, addressBook(), *iter, mCardView); } mCardView->viewport()->setUpdatesEnabled( true ); mCardView->viewport()->update(); // by default nothing is selected emit selected(QString::null); } else { // Try to find the one to refresh bool found = false; for (item = mCardView->firstItem(); item && !found; item = item->nextItem()) { #ifndef KAB_EMBEDDED aItem = dynamic_cast<AddresseeCardViewItem*>(item); #else //KAB_EMBEDDED aItem = (AddresseeCardViewItem*)(item); #endif //KAB_EMBEDDED if ((aItem) && (aItem->addressee().uid() == uid)) { aItem->refresh(); found = true; } } } } void KAddressBookCardView::setSelected(QString uid, bool selected) { CardViewItem *item; AddresseeCardViewItem *aItem; diff --git a/kaddressbook/views/kaddressbookiconview.cpp b/kaddressbook/views/kaddressbookiconview.cpp index ef0a23a..fb53215 100644 --- a/kaddressbook/views/kaddressbookiconview.cpp +++ b/kaddressbook/views/kaddressbookiconview.cpp @@ -179,209 +179,209 @@ class AddresseeIconViewItem : public QIconViewItem KABC::Addressee mAddressee; }; /////////////////////////////// // KAddressBookView KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, QWidget *parent, const char *name) : KAddressBookView( ab, parent, name ) { // Init the GUI QVBoxLayout *layout = new QVBoxLayout(viewWidget()); mIconView = new AddresseeIconView(viewWidget(), "mIconView"); layout->addWidget(mIconView); // Connect up the signals //US method executed is part of KIconView //US connect(mIconView, SIGNAL(executed(QIconViewItem *)), //US this, SLOT(addresseeExecuted(QIconViewItem *))); connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), this, SLOT(addresseeExecuted(QIconViewItem *))); connect(mIconView, SIGNAL(selectionChanged()), this, SLOT(addresseeSelected())); connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)), this, SIGNAL(dropped(QDropEvent*))); connect(mIconView, SIGNAL(startAddresseeDrag()), this, SIGNAL(startDrag())); } KAddressBookIconView::~KAddressBookIconView() { } void KAddressBookIconView::setFocusAV() { if ( mIconView ) mIconView->setFocus(); } void KAddressBookIconView::scrollUP() { QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); QApplication::postEvent( mIconView, ev ); } void KAddressBookIconView::scrollDOWN() { QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); QApplication::postEvent( mIconView, ev ); } void KAddressBookIconView::readConfig(KConfig *config) { KAddressBookView::readConfig(config); //US method executed is part of KIconView //US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)), //US this, SLOT(addresseeExecuted(QIconViewItem *))); disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), this, SLOT(addresseeExecuted(QIconViewItem *))); //US method executed is part of KIconView. Use selectionChanged instead /*US if (KABPrefs::instance()->mHonorSingleClick) connect(mIconView, SIGNAL(executed(QIconViewItem *)), this, SLOT(addresseeExecuted(QIconViewItem *))); else connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), this, SLOT(addresseeExecuted(QIconViewItem *))); */ connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), this, SLOT(addresseeExecuted(QIconViewItem *))); } void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) { mIconView->clear(); mIconList.clear(); if ( s.isEmpty() || s == "*" ) { refresh(); return; } QString pattern = s.lower()+"*"; QRegExp re; re.setWildcard(true); // most people understand these better. re.setCaseSensitive(false); re.setPattern( pattern ); if (!re.isValid()) return; KABC::Addressee::List addresseeList = addressees(); KABC::Addressee::List::Iterator it; if ( field ) { for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) continue; -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (re.search(field->value( *it ).lower()) != -1) #else if (re.match(field->value( *it ).lower()) != -1) #endif mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); } } else { KABC::Field::List fieldList = allFields(); KABC::Field::List::ConstIterator fieldIt; for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) continue; for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (re.search((*fieldIt)->value( *it ).lower()) != -1) #else if (re.match((*fieldIt)->value( *it ).lower()) != -1) #endif { mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); break; } } } } mIconView->arrangeItemsInGrid( true ); if ( mIconView->firstItem() ) { mIconView->setCurrentItem ( mIconView->firstItem() ); mIconView->setSelected ( mIconView->firstItem() , true ); } else emit selected(QString::null); } QStringList KAddressBookIconView::selectedUids() { QStringList uidList; QIconViewItem *item; AddresseeIconViewItem *aItem; for (item = mIconView->firstItem(); item; item = item->nextItem()) { if (item->isSelected()) { #ifndef KAB_EMBEDDED aItem = dynamic_cast<AddresseeIconViewItem*>(item); #else //KAB_EMBEDDED aItem = (AddresseeIconViewItem*)(item); #endif //KAB_EMBEDDED if (aItem) uidList << aItem->addressee().uid(); } } return uidList; } void KAddressBookIconView::refresh(QString uid) { QIconViewItem *item; AddresseeIconViewItem *aItem; if ( uid.isNull() ) { // Rebuild the view mIconView->clear(); mIconList.clear(); KABC::Addressee::List addresseeList = addressees(); KABC::Addressee::List::Iterator iter; for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) { if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) continue; aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView ); } mIconView->arrangeItemsInGrid( true ); for ( item = mIconView->firstItem(); item; item = item->nextItem() ) { #ifndef KAB_EMBEDDED AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item ); #else //KAB_EMBEDDED AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item ); #endif //KAB_EMBEDDED mIconList.append( aivi ); } } else { // Try to find the one to refresh for ( item = mIconView->firstItem(); item; item = item->nextItem() ) { #ifndef KAB_EMBEDDED aItem = dynamic_cast<AddresseeIconViewItem*>(item); #else //KAB_EMBEDDED aItem = (AddresseeIconViewItem*)(item); #endif //KAB_EMBEDDED if ((aItem) && (aItem->addressee().uid() == uid)) { aItem->refresh(); mIconView->arrangeItemsInGrid( true ); return; } } refresh( QString::null ); } } void KAddressBookIconView::setSelected(QString uid, bool selected) { QIconViewItem *item; AddresseeIconViewItem *aItem; if (uid.isNull()) diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index 7022dcb..69802a4 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp @@ -63,208 +63,208 @@ void KAddressBookTableView::scrollUP() QApplication::postEvent( mListView, ev ); } void KAddressBookTableView::scrollDOWN() { QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); QApplication::postEvent( mListView, ev ); } void KAddressBookTableView::reconstructListView() { if (mListView) { disconnect(mListView, SIGNAL(selectionChanged()), this, SLOT(addresseeSelected())); disconnect(mListView, SIGNAL(executed(QListViewItem*)), this, SLOT(addresseeExecuted(QListViewItem*))); disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), this, SLOT(addresseeExecuted(QListViewItem*))); disconnect(mListView, SIGNAL(startAddresseeDrag()), this, SIGNAL(startDrag())); disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), this, SLOT(addresseeExecuted(QListViewItem*))); disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, SIGNAL(dropped(QDropEvent*))); delete mListView; } mListView = new ContactListView( this, addressBook(), viewWidget() ); connect(this, SIGNAL(printView()), mListView , SLOT(printMe())); //US set singleClick manually, because it is no global configparameter in embedded space mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick); // Add the columns KABC::Field::List fieldList = fields(); KABC::Field::List::ConstIterator it; int c = 0; for( it = fieldList.begin(); it != fieldList.end(); ++it ) { mListView->addColumn( (*it)->label() ); mListView->setColumnWidthMode(c++, QListView::Manual); //US // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); } connect(mListView, SIGNAL(selectionChanged()), this, SLOT(addresseeSelected())); connect(mListView, SIGNAL(startAddresseeDrag()), this, SIGNAL(startDrag())); connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, SIGNAL(dropped(QDropEvent*))); if (KABPrefs::instance()->mHonorSingleClick) { // qDebug("KAddressBookTableView::reconstructListView single"); connect(mListView, SIGNAL(executed(QListViewItem*)), this, SLOT(addresseeExecuted(QListViewItem*))); } else { // qDebug("KAddressBookTableView::reconstructListView double"); connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), this, SLOT(addresseeExecuted(QListViewItem*))); } connect(mListView, SIGNAL(returnPressed(QListViewItem*)), this, SLOT(addresseeExecuted(QListViewItem*))); connect(mListView, SIGNAL(signalDelete()), this, SLOT(addresseeDeleted())); //US performceimprovement. Refresh is done from the outside //US refresh(); mListView->setSorting( 0, true ); mainLayout->addWidget( mListView ); mainLayout->activate(); mListView->show(); } void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) { mListView->clear(); if ( s.isEmpty() || s == "*" ) { refresh(); return; } QString pattern = s.lower()+"*"; QRegExp re; re.setWildcard(true); // most people understand these better. re.setCaseSensitive(false); re.setPattern( pattern ); if (!re.isValid()) return; KABC::Addressee::List addresseeList = addressees(); KABC::Addressee::List::Iterator it; if ( field ) { for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) continue; -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (re.search(field->value( *it ).lower()) == 0) #else if (re.match(field->value( *it ).lower()) != -1) #endif ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); } } else { KABC::Field::List fieldList = allFields(); KABC::Field::List::ConstIterator fieldIt; for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) continue; for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (re.search((*fieldIt)->value( *it ).lower()) != -1) #else if (re.match((*fieldIt)->value( *it ).lower()) != -1) #endif { ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); break; } } } } // Sometimes the background pixmap gets messed up when we add lots // of items. mListView->repaint(); if ( mListView->firstChild() ) { mListView->setCurrentItem ( mListView->firstChild() ); mListView->setSelected ( mListView->firstChild(), true ); } else emit selected(QString::null); } void KAddressBookTableView::writeConfig(KConfig *config) { KAddressBookView::writeConfig(config); mListView->saveLayout(config, config->group()); } void KAddressBookTableView::readConfig(KConfig *config) { KAddressBookView::readConfig( config ); // The config could have changed the fields, so we need to reconstruct // the listview. reconstructListView(); // costum colors? if ( config->readBoolEntry( "EnableCustomColors", false ) ) { QPalette p( mListView->palette() ); QColor c = p.color(QPalette::Normal, QColorGroup::Base ); p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); c = p.color(QPalette::Normal, QColorGroup::Text ); p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); c = p.color(QPalette::Normal, QColorGroup::Button ); p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); c = p.color(QPalette::Normal, QColorGroup::ButtonText ); p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); c = p.color(QPalette::Normal, QColorGroup::Highlight ); p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); #ifndef KAB_EMBEDDED c = KGlobalSettings::alternateBackgroundColor(); #else //KAB_EMBEDDED c = QColor(240, 240, 240); #endif //KAB_EMBEDDED c = config->readColorEntry ("AlternatingBackgroundColor", &c); mListView->setAlternateColor(c); //US mListView->viewport()->setPalette( p ); mListView->setPalette( p ); } else { // needed if turned off during a session. //US mListView->viewport()->setPalette( mListView->palette() ); mListView->setPalette( mListView->palette() ); } //custom fonts? QFont f( font() ); if ( config->readBoolEntry( "EnableCustomFonts", false ) ) { mListView->setFont( config->readFontEntry( "TextFont", &f) ); f.setBold( true ); //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); } else { mListView->setFont( f ); f.setBold( true ); //US mListView->setHeaderFont( f ); mListView->header()->setFont( f ); } // Set the list view options mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", true)); mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); if (config->readBoolEntry("Background", false)) mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp index ead8628..21ecb73 100644 --- a/korganizer/kotodoviewitem.cpp +++ b/korganizer/kotodoviewitem.cpp @@ -1,163 +1,163 @@ /* This file is part of KOrganizer. Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@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. */ #include <klocale.h> #include <kdebug.h> #include <qapp.h> #include <kiconloader.h> #include "kotodoviewitem.h" #include "kotodoview.h" #include "koprefs.h" KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo) : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) { construct(); } KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo ) : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) { construct(); } QString KOTodoViewItem::key(int column,bool) const { QMap<int,QString>::ConstIterator it = mKeyMap.find(column); if (it == mKeyMap.end()) { return text(column).lower(); } else { return *it; } } void KOTodoViewItem:: setup() { int h = 20; if ( listView () ) { QFontMetrics fm ( listView ()->font () ); h = fm.height(); } setHeight( h ); } void KOTodoViewItem::setSortKey(int column,const QString &key) { mKeyMap.insert(column,key); } -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w, int y,int h) { QListViewItem::paintBranches(p,cg,w,y,h); } #else #endif void KOTodoViewItem::construct() { // qDebug("KOTodoViewItem::construct() "); m_init = true; QString keyd = "=="; QString keyt = "=="; QString skeyd = "=="; QString skeyt = "=="; setOn(mTodo->isCompleted()); setText(0,mTodo->summary()); setText(1,QString::number(mTodo->priority())); setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); if (mTodo->percentComplete()<100) { if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); else setSortKey(2,QString::number(mTodo->percentComplete())); } else { if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); else setSortKey(2,QString::number(99)); } if (mTodo->hasDueDate()) { setText(3, mTodo->dtDueDateStr()); QDate d = mTodo->dtDue().date(); keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); // setSortKey(3,keyd); if (mTodo->doesFloat()) { setText(4,""); } else { setText(4,mTodo->dtDueTimeStr()); QTime t = mTodo->dtDue().time(); keyt.sprintf("%02d%02d",t.hour(),t.minute()); //setSortKey(4,keyt); } } else { setText(3,""); setText(4,""); } setSortKey(3,keyd); setSortKey(4,keyt); if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); if (mTodo->hasStartDate()) { setText(5, mTodo->dtStartDateStr()); QDate d = mTodo->dtStart().date(); skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); if (mTodo->doesFloat()) { setText(6,""); } else { setText(6,mTodo->dtStartTimeStr()); QTime t = mTodo->dtStart().time(); skeyt.sprintf("%02d%02d",t.hour(),t.minute()); } } else { setText(5,""); setText(6,""); } setSortKey(5,skeyd); setSortKey(6,skeyt); setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); setText(8,mTodo->categoriesStr()); #if 0 // Find sort id in description. It's the text behind the last '#' character // found in the description. White spaces are removed from beginning and end // of sort id. int pos = mTodo->description().findRev('#'); if (pos < 0) { setText(6,""); } else { QString str = mTodo->description().mid(pos+1); str.stripWhiteSpace(); setText(6,str); } #endif m_known = false; m_init = false; diff --git a/korganizer/kotodoviewitem.h b/korganizer/kotodoviewitem.h index 74dbe98..bd024c8 100644 --- a/korganizer/kotodoviewitem.h +++ b/korganizer/kotodoviewitem.h @@ -1,93 +1,93 @@ /* This file is part of KOrganizer. Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@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. */ #ifndef KOTODOVIEWITEM_H #define KOTODOVIEWITEM_H #include <qfont.h> #include <qfontmetrics.h> #include <qlineedit.h> #include <qptrlist.h> #include <qstrlist.h> #include <qlistbox.h> #include <qpopupmenu.h> #include <qlabel.h> #include <qmap.h> #include <qlistview.h> #include <qpainter.h> #include <libkcal/calendar.h> #include <libkcal/todo.h> using namespace KCal; class KOTodoView; /** This class provides a way of displaying a single Event of Todo-Type in a KTodoView. @author Cornelius Schumacher <schumacher@kde.org> @see KOTodoView */ class KOTodoViewItem : public QCheckListItem { public: /** Constructor. @param parent is the list view to which this item belongs. @param ev is the event to have the item display information for. */ KOTodoViewItem(QListView *parent, Todo *todo, KOTodoView *kotodo); KOTodoViewItem(KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo); //~KOTodoViewItem() { qDebug("~KOTodoViewItem() %s ", text(0).latin1() );} void construct(); Todo *todo() { return mTodo; } QString key(int, bool) const; void setSortKey(int column,const QString &key); bool isAlternate(); virtual void paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment); virtual void setup(); protected: -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 void paintBranches(QPainter *p,const QColorGroup & cg,int w,int y,int h); #else #endif virtual void stateChange(bool); void setMyPixmap(); private: Todo *mTodo; KOTodoView *mTodoView; QMap<int,QString> mKeyMap; uint m_odd : 1; uint m_known : 1; uint m_unused : 30; bool m_init; }; #endif diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index f6b7718..e255b83 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp @@ -482,107 +482,107 @@ void KOViewManager::showTodoView() // SIGNALS/SLOTS FOR TODO VIEW connect( mTodoView, SIGNAL( newTodoSignal() ), mMainView, SLOT( newTodo() ) ); connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), mMainView, SLOT( newSubTodo( Todo *) ) ); connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), mMainView, SLOT( showTodo( Todo * ) ) ); connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), mMainView, SLOT( editTodo( Todo * ) ) ); connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), mMainView, SLOT( deleteTodo( Todo * ) ) ); connect( mTodoView, SIGNAL( purgeCompletedSignal() ), mMainView, SLOT( purgeCompleted() ) ); connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); connect( mMainView, SIGNAL( configChanged() ), mTodoView, SLOT( updateConfig() ) ); connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, SLOT( updateTodo( Todo *, int ) ) ); connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), mMainView, SLOT ( todo_unsub( Todo * ) ) ); connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), mMainView, SLOT ( moveIncidence( Incidence * ) ) ); connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), mMainView, SLOT ( beamIncidence( Incidence * ) ) ); KConfig *config = KOGlobals::config(); mTodoView->restoreLayout(config,"Todo View"); mTodoView->setNavigator( mMainView->dateNavigator() ); } globalFlagBlockAgenda = 1; showView( mTodoView, true ); } void KOViewManager::showJournalView() { //mFlagShowNextxDays = false; if (!mJournalView) { mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), "KOViewManager::JournalView"); connect( mMainView, SIGNAL( configChanged() ), mJournalView, SLOT( updateConfig() ) ); connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); addView(mJournalView); } showView(mJournalView); } void KOViewManager::showTimeSpanView() { //mFlagShowNextxDays = false; if (!mTimeSpanView) { mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), "KOViewManager::TimeSpanView"); addView(mTimeSpanView); mTimeSpanView->readSettings(); } showView(mTimeSpanView); } Incidence *KOViewManager::currentSelection() { if (!mCurrentView) return 0; if ( mCurrentView == mListView ) { if ( mListView->currentItem() ) return mListView->currentItem(); } return mCurrentView->selectedIncidences().first(); } QDate KOViewManager::currentSelectionDate() { QDate qd; if (mCurrentView) { DateList qvl = mCurrentView->selectedDates(); if (!qvl.isEmpty()) qd = qvl.first(); } return qd; } void KOViewManager::addView(KOrg::BaseView *view) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 mMainView->viewStack()->addWidget( view ); #else mMainView->viewStack()->addWidget( view, 1 ); #endif } void KOViewManager::setDocumentId( const QString &id ) { if (mTodoView) mTodoView->setDocumentId( id ); } diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp index 72ee1d2..39966b5 100644 --- a/korganizer/searchdialog.cpp +++ b/korganizer/searchdialog.cpp @@ -141,257 +141,257 @@ SearchDialog::~SearchDialog() } void SearchDialog::accept() { doSearch(); } void SearchDialog::updateList() { //listView->updateList(); if ( isVisible() ) { updateView(); //qDebug("SearchDialog::updated "); } else { listView->clear(); //qDebug("SearchDialog::cleared "); } } void SearchDialog::searchTextChanged( const QString &_text ) { enableButton( KDialogBase::User1, !_text.isEmpty() ); } void SearchDialog::doSearch() { QRegExp re; re.setWildcard(true); // most people understand these better. re.setCaseSensitive(false); re.setPattern(searchEdit->text()); if (!re.isValid() ) { KMessageBox::sorry(this, i18n("Invalid search expression,\ncannot perform " "the search.\nPlease enter a search expression\n" "using the wildcard characters\n '*' and '?'" "where needed.")); return; } search(re); listView->setStartDate( mStartDate->date() ); listView->showEvents(mMatchedEvents); listView->addTodos(mMatchedTodos); listView->addJournals(mMatchedJournals); if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) { KMessageBox::information(this, i18n("No event/todo were found matching\nyour search expression.\nUse the wildcard characters\n ' * ' and ' ? ' where needed.")); #ifndef DESKTOP_VERSION setCaption(i18n("Click OK to search ->")); #else setCaption(i18n("KO/Pi Find ")); #endif } else { QString mess; mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() ); setCaption( i18n("KO/Pi Find: ") + mess); } } void SearchDialog::updateConfig() { listView->updateConfig(); } void SearchDialog::updateView() { QRegExp re; re.setWildcard(true); // most people understand these better. re.setCaseSensitive(false); re.setPattern(searchEdit->text()); if (re.isValid()) { search(re); } else { mMatchedEvents.clear(); mMatchedTodos.clear(); mMatchedJournals.clear(); } listView->setStartDate( mStartDate->date() ); listView->showEvents(mMatchedEvents); listView->addTodos(mMatchedTodos); listView->addJournals(mMatchedJournals); } void SearchDialog::search(const QRegExp &re) { QPtrList<Event> events = mCalendar->events( mStartDate->date(), mEndDate->date(), false /*mInclusiveCheck->isChecked()*/ ); mMatchedEvents.clear(); if ( mSearchEvent->isChecked() ) { Event *ev; for(ev=events.first();ev;ev=events.next()) { if (mSummaryCheck->isChecked()) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (re.search(ev->summary()) != -1) #else if (re.match(ev->summary()) != -1) #endif { mMatchedEvents.append(ev); continue; } } if (mDescriptionCheck->isChecked()) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (re.search(ev->description()) != -1) #else if (re.match(ev->description()) != -1) #endif { mMatchedEvents.append(ev); continue; } } if (mCategoryCheck->isChecked()) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (re.search(ev->categoriesStr()) != -1) #else if (re.match(ev->categoriesStr()) != -1) #endif { mMatchedEvents.append(ev); continue; } } if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { QPtrList<Attendee> tmpAList = ev->attendees(); Attendee *a; for (a = tmpAList.first(); a; a = tmpAList.next()) { if (mSearchAName->isChecked()) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (re.search(a->name()) != -1) #else if (re.match(a->name()) != -1) #endif { mMatchedEvents.append(ev); break; } } if (mSearchAEmail->isChecked()) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (re.search(a->email()) != -1) #else if (re.match(a->email()) != -1) #endif { mMatchedEvents.append(ev); break; } } } } } } QPtrList<Todo> todos = mCalendar->todos( ); mMatchedTodos.clear(); if ( mSearchTodo->isChecked() ) { Todo *tod; for(tod=todos.first();tod;tod=todos.next()) { if (mSummaryCheck->isChecked()) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (re.search(tod->summary()) != -1) #else if (re.match(tod->summary()) != -1) #endif { mMatchedTodos.append(tod); continue; } } if (mDescriptionCheck->isChecked()) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (re.search(tod->description()) != -1) #else if (re.match(tod->description()) != -1) #endif { mMatchedTodos.append(tod); continue; } } if (mCategoryCheck->isChecked()) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (re.search(tod->categoriesStr()) != -1) #else if (re.match(tod->categoriesStr()) != -1) #endif { mMatchedTodos.append(tod); continue; } } if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { QPtrList<Attendee> tmpAList = tod->attendees(); Attendee *a; for (a = tmpAList.first(); a; a = tmpAList.next()) { if (mSearchAName->isChecked()) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (re.search(a->name()) != -1) #else if (re.match(a->name()) != -1) #endif { mMatchedTodos.append(tod); break; } } if (mSearchAEmail->isChecked()) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (re.search(a->email()) != -1) #else if (re.match(a->email()) != -1) #endif { mMatchedTodos.append(tod); break; } } } } } } mMatchedJournals.clear(); if (mSearchJournal->isChecked() ) { QPtrList<Journal> journals = mCalendar->journals( ); Journal* journ; for(journ=journals.first();journ;journ=journals.next()) { if ( journ->dtStart().date() <= mEndDate->date() &&journ->dtStart().date() >= mStartDate->date()) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (re.search(journ->description()) != -1) #else if (re.match(journ->description()) != -1) #endif { mMatchedJournals.append(journ); continue; } } } } } /* void SearchDialog::keyPressEvent ( QKeyEvent *e) { e->ignore(); } */ //mMatchedJournals; diff --git a/korganizer/timespanview.cpp b/korganizer/timespanview.cpp index 67a3811..df8ff88 100644 --- a/korganizer/timespanview.cpp +++ b/korganizer/timespanview.cpp @@ -12,146 +12,146 @@ #include <klocale.h> #include <kdebug.h> #include "lineview.h" #include "timeline.h" #include "timespanview.h" TimeSpanView::TimeSpanView( QWidget *parent, const char *name ) : QWidget( parent, name ) { QBoxLayout *topLayout = new QVBoxLayout( this ); #ifndef DESKTOP_VERSION mSplitter = new QKSplitter( this ); #else mSplitter = new QSplitter( this ); #endif topLayout->addWidget( mSplitter ); mList = new QListView( mSplitter ); mList->addColumn( i18n("Summary") ); QWidget *rightPane = new QWidget( mSplitter ); QBoxLayout *rightPaneLayout = new QVBoxLayout( rightPane ); mTimeLine = new TimeLine( rightPane ); mTimeLine->setFixedHeight( mList->header()->height() ); rightPaneLayout->addWidget( mTimeLine ); mLineView = new LineView( rightPane ); rightPaneLayout->addWidget( mLineView ); QBoxLayout *buttonLayout = new QHBoxLayout( rightPaneLayout ); QPushButton *zoomInButton = new QPushButton( i18n("Zoom In"), rightPane ); connect( zoomInButton, SIGNAL( clicked() ), SLOT( zoomIn() ) ); buttonLayout->addWidget( zoomInButton ); QPushButton *zoomOutButton = new QPushButton( i18n("Zoom Out"), rightPane ); connect( zoomOutButton, SIGNAL( clicked() ), SLOT( zoomOut() ) ); buttonLayout->addWidget( zoomOutButton ); QPushButton *centerButton = new QPushButton( i18n("Center View"), rightPane ); connect( centerButton, SIGNAL( clicked() ), SLOT( centerView() ) ); buttonLayout->addWidget( centerButton ); connect(mLineView->horizontalScrollBar(),SIGNAL(valueChanged(int)), mTimeLine,SLOT(setContentsPos(int))); } TimeSpanView::~TimeSpanView() { } QValueList<int> TimeSpanView::splitterSizes() { return mSplitter->sizes(); } void TimeSpanView::setSplitterSizes( QValueList<int> sizes ) { mSplitter->setSizes( sizes ); } void TimeSpanView::addItem( KCal::Event *event ) { new QListViewItem( mList, event->summary() ); QDateTime startDt = event->dtStart(); QDateTime endDt = event->dtEnd(); // kdDebug() << "TimeSpanView::addItem(): start: " << startDt.toString() // << " end: " << endDt.toString() << endl; int startSecs = mStartDate.secsTo( startDt ); int durationSecs = startDt.secsTo( endDt ); // kdDebug() << "--- startSecs: " << startSecs << " dur: " << durationSecs << endl; int startX = mStartDate.secsTo( startDt ) / mSecsPerPixel; int endX = startX + startDt.secsTo( endDt ) / mSecsPerPixel; // kdDebug() << "TimeSpanView::addItem(): s: " << startX << " e: " << endX << endl; mLineView->addLine( startX, endX ); } void TimeSpanView::clear() { mList->clear(); mLineView->clear(); } void TimeSpanView::updateView() { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 mLineView->updateContents(); mTimeLine->updateContents(); #else #endif } void TimeSpanView::setDateRange( const QDateTime &start, const QDateTime &end ) { mStartDate = start; mEndDate = end; mTimeLine->setDateRange( start, end ); mSecsPerPixel = mStartDate.secsTo( mEndDate ) / mLineView->pixelWidth(); } QDateTime TimeSpanView::startDateTime() { return mStartDate; } QDateTime TimeSpanView::endDateTime() { return mEndDate; } void TimeSpanView::zoomIn() { int span = mStartDate.daysTo( mEndDate ); setDateRange( mStartDate.addDays( span / 4 ), mEndDate.addDays( span / -4 ) ); emit dateRangeChanged(); } void TimeSpanView::zoomOut() { int span = mStartDate.daysTo( mEndDate ); setDateRange( mStartDate.addDays( span / -4 ), mEndDate.addDays( span / 4 ) ); emit dateRangeChanged(); } void TimeSpanView::centerView() { QScrollBar *scrollBar = mLineView->horizontalScrollBar(); int min = scrollBar->minValue(); int max = scrollBar->maxValue(); scrollBar->setValue( min + (max-min) / 2 ); } diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp index c23978d..bd13132 100644 --- a/libkcal/icalformatimpl.cpp +++ b/libkcal/icalformatimpl.cpp @@ -110,197 +110,193 @@ icalcomponent *ICalFormatImpl::writeTodo(Todo *todo) // kdDebug(5800) << "§§ Incidence " << todo->summary() << " floats." << endl; start = writeICalDate(todo->dtStart().date()); } else { // kdDebug(5800) << "§§ incidence " << todo->summary() << " has time." << endl; start = writeICalDateTime(todo->dtStart()); } icalcomponent_add_property(vtodo,icalproperty_new_dtstart(start)); } // completion date if (todo->isCompleted()) { if (!todo->hasCompletedDate()) { // If todo was created by KOrganizer <2.2 it has no correct completion // date. Set it to now. todo->setCompleted(QDateTime::currentDateTime()); } icaltimetype completed = writeICalDateTime(todo->completed()); icalcomponent_add_property(vtodo,icalproperty_new_completed(completed)); } icalcomponent_add_property(vtodo, icalproperty_new_percentcomplete(todo->percentComplete())); return vtodo; } icalcomponent *ICalFormatImpl::writeEvent(Event *event) { kdDebug(5800) << "Write Event '" << event->summary() << "' (" << event->uid() << ")" << endl; QString tmpStr; QStringList tmpStrList; icalcomponent *vevent = icalcomponent_new(ICAL_VEVENT_COMPONENT); writeIncidence(vevent,event); // start time icaltimetype start; if (event->doesFloat()) { // kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; start = writeICalDate(event->dtStart().date()); } else { // kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; start = writeICalDateTime(event->dtStart()); } icalcomponent_add_property(vevent,icalproperty_new_dtstart(start)); if (event->hasEndDate()) { // end time icaltimetype end; if (event->doesFloat()) { // kdDebug(5800) << "§§ Event " << event->summary() << " floats." << endl; // +1 day because end date is non-inclusive. end = writeICalDate( event->dtEnd().date().addDays( 1 ) ); } else { // kdDebug(5800) << "§§ Event " << event->summary() << " has time." << endl; end = writeICalDateTime(event->dtEnd()); } icalcomponent_add_property(vevent,icalproperty_new_dtend(end)); } // TODO: attachments, resources #if 0 // attachments tmpStrList = anEvent->attachments(); for ( QStringList::Iterator it = tmpStrList.begin(); it != tmpStrList.end(); ++it ) addPropValue(vevent, VCAttachProp, (*it).utf8()); // resources tmpStrList = anEvent->resources(); tmpStr = tmpStrList.join(";"); if (!tmpStr.isEmpty()) addPropValue(vevent, VCResourcesProp, tmpStr.utf8()); #endif // Transparency switch( event->transparency() ) { case Event::Transparent: icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_TRANSPARENT)); break; case Event::Opaque: icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_OPAQUE)); break; } return vevent; } icalcomponent *ICalFormatImpl::writeFreeBusy(FreeBusy *freebusy, Scheduler::Method method) { -#if QT_VERSION >= 300 - kdDebug(5800) << "icalformatimpl: writeFreeBusy: startDate: " - << freebusy->dtStart().toString("ddd MMMM d yyyy: h:m:s ap") << " End Date: " - << freebusy->dtEnd().toString("ddd MMMM d yyyy: h:m:s ap") << endl; -#endif + icalcomponent *vfreebusy = icalcomponent_new(ICAL_VFREEBUSY_COMPONENT); writeIncidenceBase(vfreebusy,freebusy); icalcomponent_add_property(vfreebusy, icalproperty_new_dtstart( writeICalDateTime(freebusy->dtStart()))); icalcomponent_add_property(vfreebusy, icalproperty_new_dtend( writeICalDateTime(freebusy->dtEnd()))); if (method == Scheduler::Request) { icalcomponent_add_property(vfreebusy,icalproperty_new_uid( freebusy->uid().utf8())); } //Loops through all the periods in the freebusy object QValueList<Period> list = freebusy->busyPeriods(); QValueList<Period>::Iterator it; icalperiodtype period; for (it = list.begin(); it!= list.end(); ++it) { period.start = writeICalDateTime((*it).start()); period.end = writeICalDateTime((*it).end()); icalcomponent_add_property(vfreebusy, icalproperty_new_freebusy(period) ); } return vfreebusy; } icalcomponent *ICalFormatImpl::writeJournal(Journal *journal) { icalcomponent *vjournal = icalcomponent_new(ICAL_VJOURNAL_COMPONENT); writeIncidence(vjournal,journal); // start time if (journal->dtStart().isValid()) { icaltimetype start; if (journal->doesFloat()) { // kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; start = writeICalDate(journal->dtStart().date()); } else { // kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; start = writeICalDateTime(journal->dtStart()); } icalcomponent_add_property(vjournal,icalproperty_new_dtstart(start)); } return vjournal; } void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) { // pilot sync stuff // TODO: move this application-specific code to kpilot if (incidence->pilotId()) { incidence->setNonKDECustomProperty("X-PILOTID", QString::number(incidence->pilotId())); incidence->setNonKDECustomProperty("X-PILOTSTAT", QString::number(incidence->syncStatus())); } if ( !incidence->IDStr().isEmpty()) { incidence->setNonKDECustomProperty("X-KOPIEXTID",incidence->IDStr() ); } writeIncidenceBase(parent,incidence); if (incidence->cancelled()) { icalcomponent_add_property(parent,icalproperty_new_status(ICAL_STATUS_CANCELLED)); } // creation date icalcomponent_add_property(parent,icalproperty_new_created( writeICalDateTime(incidence->created()))); // unique id icalcomponent_add_property(parent,icalproperty_new_uid( incidence->uid().utf8())); // revision icalcomponent_add_property(parent,icalproperty_new_sequence( incidence->revision())); // last modification date icalcomponent_add_property(parent,icalproperty_new_lastmodified( writeICalDateTime(incidence->lastModified()))); // description if (!incidence->description().isEmpty()) { icalcomponent_add_property(parent,icalproperty_new_description( incidence->description().utf8())); } // summary if (!incidence->summary().isEmpty()) { icalcomponent_add_property(parent,icalproperty_new_summary( incidence->summary().utf8())); } diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp index 60b8bc7..567ae54 100644 --- a/microkde/KDGanttMinimizeSplitter.cpp +++ b/microkde/KDGanttMinimizeSplitter.cpp @@ -1,136 +1,136 @@ /* -*- Mode: C++ -*- $Id$ */ /**************************************************************************** ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved. ** ** This file is part of the KDGantt library. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** Licensees holding valid commercial KDGantt licenses may use this file in ** accordance with the KDGantt Commercial License Agreement provided with ** the Software. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for ** information about KDGantt Commercial License Agreements. ** ** Contact info@klaralvdalens-datakonsult.se if any conditions of this ** licensing are not clear to you. ** ** 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. ** **********************************************************************/ #include "KDGanttMinimizeSplitter.h" #ifndef QT_NO_SPLITTER___ #include "qpainter.h" #include "qdrawutil.h" -#include "qbitmap.h" -#if QT_VERSION >= 300 +#include "qbitmap.h" +#if QT_VERSION >= 0x030000 #include "qptrlist.h" #include "qmemarray.h" #else #include <qlist.h> #include <qarray.h> #define QPtrList QList #define QMemArray QArray #endif #include "qlayoutengine_p.h" #include "qobjectlist.h" #include "qstyle.h" #include "qapplication.h" //sendPostedEvents #include <qvaluelist.h> #include <qcursor.h> #ifndef KDGANTT_MASTER_CVS //#include "KDGanttMinimizeSplitter.moc" #endif #ifndef DOXYGEN_SKIP_INTERNAL #if QT_VERSION >= 232 static int mouseOffset; static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o, KDGanttMinimizeSplitter *parent, const char * name ) : QWidget( parent, name ), _activeButton( 0 ), _collapsed( false ) { if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) { mSizeHint = QSize(7,7); mUseOffset = true; } else { mSizeHint = QSize(6,6); mUseOffset = false; } s = parent; setOrientation(o); setMouseTracking( true ); //setMaximumHeight( 5 ); // test only } QSize KDGanttSplitterHandle::sizeHint() const { return mSizeHint; } void KDGanttSplitterHandle::setOrientation( Qt::Orientation o ) { orient = o; #ifndef QT_NO_CURSOR if ( o == KDGanttMinimizeSplitter::Horizontal ) setCursor( splitHCursor ); else setCursor( splitVCursor ); #endif } void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) { updateCursor( e->pos() ); if ( !(e->state()&LeftButton) ) return; if ( _activeButton != 0) return; QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) - mouseOffset; if ( true /*opaque()*/ ) { s->moveSplitter( pos, id() ); } else { int min = pos; int max = pos; s->getRange( id(), &min, &max ); s->setRubberband( QMAX( min, QMIN(max, pos ))); } _collapsed = false; } void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e ) { if ( e->button() == LeftButton ) { _activeButton = onButton( e->pos() ); mouseOffset = s->pick(e->pos()); if ( _activeButton != 0) repaint(); updateCursor( e->pos() ); } } void KDGanttSplitterHandle::updateCursor( const QPoint& p) { @@ -534,193 +534,193 @@ QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool firs QSplitterLayoutStruct *s; KDGanttSplitterHandle *newHandle = 0; if ( data->list.count() > 0 ) { s = new QSplitterLayoutStruct; s->mode = KeepSize; QString tmp = "qt_splithandle_"; tmp += w->name(); newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() ); if ( ! mFirstHandle ) mFirstHandle = newHandle; s->wid = newHandle; newHandle->setId(data->list.count()); s->isSplitter = TRUE; s->sizer = pick( newHandle->sizeHint() ); if ( first ) data->list.insert( 0, s ); else data->list.append( s ); } s = new QSplitterLayoutStruct; s->mode = Stretch; s->wid = w; if ( !testWState( WState_Resized ) && w->sizeHint().isValid() ) s->sizer = pick( w->sizeHint() ); else s->sizer = pick( w->size() ); s->isSplitter = FALSE; if ( first ) data->list.insert( 0, s ); else data->list.append( s ); if ( newHandle && isVisible() ) newHandle->show(); //will trigger sending of post events return s; } /*! Tells the splitter that a child widget has been inserted or removed. The event is passed in \a c. */ void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) { if ( c->type() == QEvent::ChildInserted ) { if ( !c->child()->isWidgetType() ) return; if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) ) return; QSplitterLayoutStruct *s = data->list.first(); while ( s ) { if ( s->wid == c->child() ) return; s = data->list.next(); } addWidget( (QWidget*)c->child() ); recalc( isVisible() ); } else if ( c->type() == QEvent::ChildRemoved ) { QSplitterLayoutStruct *p = 0; if ( data->list.count() > 1 ) p = data->list.at(1); //remove handle _after_ first widget. QSplitterLayoutStruct *s = data->list.first(); while ( s ) { if ( s->wid == c->child() ) { data->list.removeRef( s ); delete s; if ( p && p->isSplitter ) { data->list.removeRef( p ); delete p->wid; //will call childEvent delete p; } recalcId(); doResize(); return; } p = s; s = data->list.next(); } } } /*! Shows a rubber band at position \a p. If \a p is negative, the rubber band is removed. */ void KDGanttMinimizeSplitter::setRubberband( int p ) { QPainter paint( this ); paint.setPen( gray ); paint.setBrush( gray ); paint.setRasterOp( XorROP ); QRect r = contentsRect(); const int rBord = 3; //Themable???? -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); #else int sw = style().splitterWidth(); #endif if ( orient == Horizontal ) { if ( opaqueOldPos >= 0 ) paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), 2*rBord, r.height() ); if ( p >= 0 ) paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); } else { if ( opaqueOldPos >= 0 ) paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, r.width(), 2*rBord ); if ( p >= 0 ) paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); } opaqueOldPos = p; } /*! \reimp */ bool KDGanttMinimizeSplitter::event( QEvent *e ) { if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { recalc( isVisible() ); if ( e->type() == QEvent::Show ) data->firstShow = FALSE; } return QWidget::event( e ); } /*! \obsolete Draws the splitter handle in the rectangle described by \a x, \a y, \a w, \a h using painter \a p. \sa QStyle::drawPrimitive() */ void KDGanttMinimizeSplitter::drawSplitter( QPainter *p, QCOORD x, QCOORD y, QCOORD w, QCOORD h ) { #if 0 // LR style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(), (orientation() == Qt::Horizontal ? QStyle::Style_Horizontal : 0)); #endif } /*! Returns the id of the splitter to the right of or below the widget \a w, or 0 if there is no such splitter (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end). */ int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const { QSplitterLayoutStruct *s = data->list.first(); bool seen_w = FALSE; while ( s ) { if ( s->isSplitter && seen_w ) return data->list.at(); if ( !s->isSplitter && s->wid == w ) seen_w = TRUE; s = data->list.next(); } return 0; } /*! Moves the left/top edge of the splitter handle with id \a id as close as possible to position \a p, which is the distance from the left (or top) edge of the widget. For Arabic and Hebrew the layout is reversed, and using this function to set the position of the splitter might lead to unexpected results, since in Arabic and Hebrew the position of splitter one is to the left of the position of splitter zero. \sa idAfter() */ void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id ) { p = adjustPos( p, id ); QSplitterLayoutStruct *s = data->list.at(id); int oldP = orient == Horizontal ? s->wid->x() : s->wid->y(); bool upLeft; if ( false && orient == Horizontal ) { p += s->wid->width(); upLeft = p > oldP; } else upLeft = p < oldP; @@ -816,193 +816,193 @@ void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft ) if( false && orient == Horizontal ) { pos2 = pos - dd; pos1 = pos2 + 1; } else { pos1 = pos; pos2 = pos + dd; } if ( upLeft ) { setG( w, pos1, dd, TRUE ); moveAfter( pos2, id+1, upLeft ); } else { moveAfter( pos2, id+1, upLeft ); setG( w, pos1, dd, TRUE ); } } else { int left = pick( w->pos() ); int right, dd,/* newRight,*/ newLeft, nextPos; if ( false && orient == Horizontal ) { dd = pos - left + 1; dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); newLeft = pos-dd+1; nextPos = newLeft - 1; } else { right = pick( w->geometry().bottomRight() ); dd = right - pos + 1; dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); /*newRight = pos+dd-1;*/ newLeft = pos; nextPos = newLeft + dd; } setG( w, newLeft, dd, TRUE ); /*if( right != newRight )*/ moveAfter( nextPos, id+1, upLeft ); } } void KDGanttMinimizeSplitter::expandPos( int id, int* min, int* max ) { QSplitterLayoutStruct *s = data->list.at(id-1); QWidget* w = s->wid; *min = pick( w->mapToParent( QPoint(0,0) ) ); if ( (uint) id == data->list.count() ) { pick( size() ); } else { QSplitterLayoutStruct *s = data->list.at(id+1); QWidget* w = s->wid; *max = pick( w->mapToParent( QPoint( w->width(), w->height() ) ) ) -8; } } /*! Returns the valid range of the splitter with id \a id in \a *min and \a *max. \sa idAfter() */ void KDGanttMinimizeSplitter::getRange( int id, int *min, int *max ) { int minB = 0; //before int maxB = 0; int minA = 0; int maxA = 0; //after int n = data->list.count(); if ( id < 0 || id >= n ) return; int i; for ( i = 0; i < id; i++ ) { QSplitterLayoutStruct *s = data->list.at(i); if ( s->wid->isHidden() ) { //ignore } else if ( s->isSplitter ) { minB += s->sizer; maxB += s->sizer; } else { minB += pick( minSize(s->wid) ); maxB += pick( s->wid->maximumSize() ); } } for ( i = id; i < n; i++ ) { QSplitterLayoutStruct *s = data->list.at(i); if ( s->wid->isHidden() ) { //ignore } else if ( s->isSplitter ) { minA += s->sizer; maxA += s->sizer; } else { minA += pick( minSize(s->wid) ); maxA += pick( s->wid->maximumSize() ); } } QRect r = contentsRect(); if ( orient == Horizontal && false ) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 int splitterWidth = style().pixelMetric(QStyle::PM_SplitterWidth, this); #else int splitterWidth = style().splitterWidth(); #endif if ( min ) *min = pick(r.topRight()) - QMIN( maxB, pick(r.size())-minA ) - splitterWidth; if ( max ) *max = pick(r.topRight()) - QMAX( minB, pick(r.size())-maxA ) - splitterWidth; } else { if ( min ) *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA ); if ( max ) *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA ); } } /*! Returns the closest legal position to \a p of the splitter with id \a id. \sa idAfter() */ int KDGanttMinimizeSplitter::adjustPos( int p, int id ) { int min = 0; int max = 0; getRange( id, &min, &max ); p = QMAX( min, QMIN( p, max ) ); return p; } void KDGanttMinimizeSplitter::doResize() { QRect r = contentsRect(); int i; int n = data->list.count(); QMemArray<QLayoutStruct> a( n ); for ( i = 0; i< n; i++ ) { a[i].init(); QSplitterLayoutStruct *s = data->list.at(i); if ( s->wid->isHidden() ) { a[i].stretch = 0; a[i].sizeHint = a[i].minimumSize = 0; a[i].maximumSize = 0; } else if ( s->isSplitter ) { a[i].stretch = 0; a[i].sizeHint = a[i].minimumSize = a[i].maximumSize = s->sizer; a[i].empty = FALSE; } else if ( s->mode == KeepSize ) { a[i].stretch = 0; a[i].minimumSize = pick( minSize(s->wid) ); a[i].sizeHint = s->sizer; a[i].maximumSize = pick( s->wid->maximumSize() ); a[i].empty = FALSE; } else if ( s->mode == FollowSizeHint ) { a[i].stretch = 0; a[i].minimumSize = a[i].sizeHint = pick( s->wid->sizeHint() ); a[i].maximumSize = pick( s->wid->maximumSize() ); a[i].empty = FALSE; } else { //proportional a[i].stretch = s->sizer; a[i].maximumSize = pick( s->wid->maximumSize() ); a[i].sizeHint = a[i].minimumSize = pick( minSize(s->wid) ); a[i].empty = FALSE; } } kdganttGeomCalc( a, 0, n, pick( r.topLeft() ), pick( r.size() ), 0 ); for ( i = 0; i< n; i++ ) { QSplitterLayoutStruct *s = data->list.at(i); setG( s->wid, a[i].pos, a[i].size ); } } void KDGanttMinimizeSplitter::recalc( bool update ) { int fi = 2*frameWidth(); int maxl = fi; int minl = fi; int maxt = QWIDGETSIZE_MAX; int mint = fi; int n = data->list.count(); bool first = TRUE; /* The splitter before a hidden widget is always hidden. The splitter before the first visible widget is hidden. The splitter before any other visible widget is visible. */ for ( int i = 0; i< n; i++ ) { @@ -1294,193 +1294,193 @@ bool KDGanttMinimizeSplitter::isHidden( QWidget *w ) const return !w2show; #ifdef QT_CHECK_RANGE else qWarning( "KDGanttMinimizeSplitter::isHidden(), unknown widget" ); #endif return FALSE; } #endif /*! Returns a list of the size parameters of all the widgets in this splitter. Giving the values to another splitter's setSizes() function will produce a splitter with the same layout as this one. Note that if you want to iterate over the list, you should iterate over a copy, e.g. \code QValueList<int> list = mySplitter.sizes(); QValueList<int>::Iterator it = list.begin(); while( it != list.end() ) { myProcessing( *it ); ++it; } \endcode \sa setSizes() */ QValueList<int> KDGanttMinimizeSplitter::sizes() const { if ( !testWState(WState_Polished) ) { QWidget* that = (QWidget*) this; that->polish(); } QValueList<int> list; QSplitterLayoutStruct *s = data->list.first(); while ( s ) { if ( !s->isSplitter ) list.append( s->sizer ); s = data->list.next(); } return list; } /*! Sets the size parameters to the values given in \a list. If the splitter is horizontal, the values set the sizes from left to right. If it is vertical, the sizes are applied from top to bottom. Extra values in \a list are ignored. If \a list contains too few values, the result is undefined but the program will still be well-behaved. \sa sizes() */ void KDGanttMinimizeSplitter::setSizes( QValueList<int> list ) { processChildEvents(); QValueList<int>::Iterator it = list.begin(); QSplitterLayoutStruct *s = data->list.first(); while ( s && it != list.end() ) { if ( !s->isSplitter ) { s->sizer = *it; ++it; } s = data->list.next(); } doResize(); } /*! Gets all posted child events, ensuring that the internal state of the splitter is consistent. */ void KDGanttMinimizeSplitter::processChildEvents() { QApplication::sendPostedEvents( this, QEvent::ChildInserted ); } /*! \reimp */ void KDGanttMinimizeSplitter::styleChange( QStyle& old ) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); #else int sw = style().splitterWidth(); #endif QSplitterLayoutStruct *s = data->list.first(); while ( s ) { if ( s->isSplitter ) s->sizer = sw; s = data->list.next(); } doResize(); QFrame::styleChange( old ); } #endif /*! Specifies the direction of the minimize buttons. If the orientation of the splitter is horizontal then with KDGanttMinimizeSplitter::Left or KDGanttMinimizeSplitter::Right should be used, otherwise either KDGanttMinimizeSplitter::Up or KDGanttMinimizeSplitter::Down should be used. */ void KDGanttMinimizeSplitter::setMinimizeDirection( Direction direction ) { _direction = direction; } /*! Returns the direction of the minimize buttons. */ KDGanttMinimizeSplitter::Direction KDGanttMinimizeSplitter::minimizeDirection() const { return _direction; } /* This is a copy of qGeomCalc() in qlayoutengine.cpp which unfortunately isn't exported. */ static inline int toFixed( int i ) { return i * 256; } static inline int fRound( int i ) { return ( i % 256 < 128 ) ? i / 256 : 1 + i / 256; } void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, int space, int spacer ) { typedef int fixed; int cHint = 0; int cMin = 0; int cMax = 0; int sumStretch = 0; int spacerCount = 0; bool wannaGrow = FALSE; // anyone who really wants to grow? // bool canShrink = FALSE; // anyone who could be persuaded to shrink? int i; for ( i = start; i < start + count; i++ ) { chain[i].done = FALSE; cHint += chain[i].sizeHint; cMin += chain[i].minimumSize; cMax += chain[i].maximumSize; sumStretch += chain[i].stretch; if ( !chain[i].empty ) spacerCount++; wannaGrow = wannaGrow || chain[i].expansive; } int extraspace = 0; if ( spacerCount ) spacerCount--; // only spacers between things if ( space < cMin + spacerCount * spacer ) { // qDebug("not enough space"); for ( i = start; i < start+count; i++ ) { chain[i].size = chain[i].minimumSize; chain[i].done = TRUE; } } else if ( space < cHint + spacerCount*spacer ) { // Less space than sizeHint, but more than minimum. // Currently take space equally from each, like in Qt 2.x. // Commented-out lines will give more space to stretchier items. int n = count; int space_left = space - spacerCount*spacer; int overdraft = cHint - space_left; //first give to the fixed ones: for ( i = start; i < start+count; i++ ) { if ( !chain[i].done && chain[i].minimumSize >= chain[i].sizeHint) { chain[i].size = chain[i].sizeHint; chain[i].done = TRUE; space_left -= chain[i].sizeHint; // sumStretch -= chain[i].stretch; n--; } } bool finished = n == 0; diff --git a/microkde/kcalendarsystemgregorian.cpp b/microkde/kcalendarsystemgregorian.cpp index 7c5b62a..cc12b9f 100644 --- a/microkde/kcalendarsystemgregorian.cpp +++ b/microkde/kcalendarsystemgregorian.cpp @@ -1,344 +1,344 @@ /* Copyright (c) 2002 Carlos Moro <cfmoro@correo.uniovi.es> Copyright (c) 2002 Hans Petter Bieker <bieker@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Derived gregorian kde calendar class // Just a schema. #include <qdatetime.h> #include <qstring.h> #include <klocale.h> #include <kdebug.h> #include "kcalendarsystemgregorian.h" KCalendarSystemGregorian::KCalendarSystemGregorian(const KLocale * locale) : KCalendarSystem(locale) { kdDebug(5400) << "Created gregorian calendar" << endl; } KCalendarSystemGregorian::~KCalendarSystemGregorian() { } int KCalendarSystemGregorian::year(const QDate& date) const { // kdDebug(5400) << "Gregorian year..." << endl; return date.year(); } int KCalendarSystemGregorian::monthsInYear( const QDate & ) const { // kdDebug(5400) << "Gregorian monthsInYear" << endl; return 12; } int KCalendarSystemGregorian::weeksInYear(int year) const { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 QDate temp; temp.setYMD(year, 12, 31); // If the last day of the year is in the first week, we have to check the // week before if ( temp.weekNumber() == 1 ) temp.addDays(-7); return temp.weekNumber(); #else return 52; #endif } int KCalendarSystemGregorian::weekNumber(const QDate& date, int * yearNum) const { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 return date.weekNumber(yearNum); #else return 1; #endif } QString KCalendarSystemGregorian::monthName(const QDate& date, bool shortName) const { return monthName(month(date), shortName); } QString KCalendarSystemGregorian::monthNamePossessive(const QDate& date, bool shortName) const { return monthNamePossessive(month(date), shortName); } QString KCalendarSystemGregorian::monthName(int month, bool shortName) const { // kdDebug(5400) << "Gregorian getMonthName" << endl; if ( shortName ) switch ( month ) { case 1: return locale()->translate("January", "Jan"); case 2: return locale()->translate("February", "Feb"); case 3: return locale()->translate("March", "Mar"); case 4: return locale()->translate("April", "Apr"); case 5: return locale()->translate("May short", "May"); case 6: return locale()->translate("June", "Jun"); case 7: return locale()->translate("July", "Jul"); case 8: return locale()->translate("August", "Aug"); case 9: return locale()->translate("September", "Sep"); case 10: return locale()->translate("October", "Oct"); case 11: return locale()->translate("November", "Nov"); case 12: return locale()->translate("December", "Dec"); } else switch ( month ) { case 1: return locale()->translate("January"); case 2: return locale()->translate("February"); case 3: return locale()->translate("March"); case 4: return locale()->translate("April"); case 5: return locale()->translate("May long", "May"); case 6: return locale()->translate("June"); case 7: return locale()->translate("July"); case 8: return locale()->translate("August"); case 9: return locale()->translate("September"); case 10: return locale()->translate("October"); case 11: return locale()->translate("November"); case 12: return locale()->translate("December"); } return QString::null; } QString KCalendarSystemGregorian::monthNamePossessive(int month, bool shortName) const { // kdDebug(5400) << "Gregorian getMonthName" << endl; if ( shortName ) switch ( month ) { case 1: return locale()->translate("of January", "of Jan"); case 2: return locale()->translate("of February", "of Feb"); case 3: return locale()->translate("of March", "of Mar"); case 4: return locale()->translate("of April", "of Apr"); case 5: return locale()->translate("of May short", "of May"); case 6: return locale()->translate("of June", "of Jun"); case 7: return locale()->translate("of July", "of Jul"); case 8: return locale()->translate("of August", "of Aug"); case 9: return locale()->translate("of September", "of Sep"); case 10: return locale()->translate("of October", "of Oct"); case 11: return locale()->translate("of November", "of Nov"); case 12: return locale()->translate("of December", "of Dec"); } else switch ( month ) { case 1: return locale()->translate("of January"); case 2: return locale()->translate("of February"); case 3: return locale()->translate("of March"); case 4: return locale()->translate("of April"); case 5: return locale()->translate("of May long", "of May"); case 6: return locale()->translate("of June"); case 7: return locale()->translate("of July"); case 8: return locale()->translate("of August"); case 9: return locale()->translate("of September"); case 10: return locale()->translate("of October"); case 11: return locale()->translate("of November"); case 12: return locale()->translate("of December"); } return QString::null; } bool KCalendarSystemGregorian::setYMD(QDate & date, int y, int m, int d) const { // We don't want Qt to add 1900 to them if ( y >= 0 && y <= 99 ) return false; // QDate supports gregorian internally return date.setYMD(y, m, d); } QDate KCalendarSystemGregorian::addYears(const QDate & date, int nyears) const { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 return date.addYears(nyears); #else int year = date.year() + nyears; int month = date.month(); int day = date.day(); QDate newDate( year, month, 1 ); if ( day > newDate.daysInMonth() ) day = newDate.daysInMonth(); return QDate( year, month, day ); #endif } QDate KCalendarSystemGregorian::addMonths(const QDate & date, int nmonths) const { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 return date.addMonths(nmonths); #else int month = date.month(); int nyears; if ( nmonths >= 0 ) { month += nmonths; nyears = ( month - 1 ) / 12; month = ( ( month - 1 ) % 12 ) + 1; } else { nyears = nmonths / 12; // nmonths += nyears * 12; nmonths = nmonths % 12; month += nmonths; if ( month <= 0 ) { month += 12; --nyears; } } int year = date.year() + nyears; int day = date.day(); QDate newDate( year, month, 1 ); if ( day > newDate.daysInMonth() ) day = newDate.daysInMonth(); return QDate( year, month, day ); #endif } QDate KCalendarSystemGregorian::addDays(const QDate & date, int ndays) const { return date.addDays(ndays); } QString KCalendarSystemGregorian::weekDayName(int col, bool shortName) const { // ### Should this really be different to each calendar system? Or are we // only going to support weeks with 7 days? //kdDebug(5400) << "Gregorian wDayName" << endl; return locale()->weekDayName(col, shortName); } QString KCalendarSystemGregorian::weekDayName(const QDate& date, bool shortName) const { return weekDayName(dayOfWeek(date), shortName); } int KCalendarSystemGregorian::dayOfWeek(const QDate& date) const { return date.dayOfWeek(); } int KCalendarSystemGregorian::dayOfYear(const QDate & date) const { return date.dayOfYear(); } int KCalendarSystemGregorian::daysInMonth(const QDate& date) const { // kdDebug(5400) << "Gregorian daysInMonth" << endl; return date.daysInMonth(); } int KCalendarSystemGregorian::minValidYear() const { return 1753; // QDate limit } int KCalendarSystemGregorian::maxValidYear() const { return 8000; // QDate limit } int KCalendarSystemGregorian::day(const QDate& date) const { return date.day(); } int KCalendarSystemGregorian::month(const QDate& date) const { return date.month(); } int KCalendarSystemGregorian::daysInYear(const QDate& date) const { return date.daysInYear(); } int KCalendarSystemGregorian::weekDayOfPray() const { return 7; // sunday } QString KCalendarSystemGregorian::calendarName() const { return QString::fromLatin1("gregorian"); } |