-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 @@ -125,383 +125,383 @@ void AddresseeCardView::printMe() return; QPainter p; p.begin ( &printer ); QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); float dx, dy; int wid = (m.width() * 9)/10; dx = (float) wid/(float)contentsWidth (); dy = (float)(m.height()) / (float)contentsHeight (); float scale; // scale to fit the width or height of the paper if ( dx < dy ) scale = dx; else scale = dy; p.translate( m.width()/10,0 ); p.scale( scale, scale ); drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); p.end(); repaint(); #endif } void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) { #ifndef KAB_EMBEDDED if (QTextDrag::canDecode(e)) e->accept(); #else //KAB_EMBEDDED qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); #endif //KAB_EMBEDDED } void AddresseeCardView::dropEvent(QDropEvent *e) { emit addresseeDropped(e); } void AddresseeCardView::startDrag() { emit startAddresseeDrag(); } /////////////////////////////// // KAddressBookCardView KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, QWidget *parent, const char *name ) : KAddressBookView( ab, parent, name ) { mShowEmptyFields = false; // Init the GUI QVBoxLayout *layout = new QVBoxLayout(viewWidget()); mCardView = new AddresseeCardView(viewWidget(), "mCardView"); mCardView->setSelectionMode(CardView::Extended); layout->addWidget(mCardView); // Connect up the signals connect(mCardView, SIGNAL(executed(CardViewItem *)), this, SLOT(addresseeExecuted(CardViewItem *))); connect(mCardView, SIGNAL(selectionChanged()), this, SLOT(addresseeSelected())); connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)), this, SIGNAL(dropped(QDropEvent*))); connect(mCardView, SIGNAL(startAddresseeDrag()), this, SIGNAL(startDrag())); connect(this, SIGNAL(printView()), mCardView , SLOT(printMe())); } KAddressBookCardView::~KAddressBookCardView() { } void KAddressBookCardView::setFocusAV() { if ( mCardView ) mCardView->setFocus(); } void KAddressBookCardView::scrollUP() { QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); QApplication::postEvent( mCardView, ev ); } void KAddressBookCardView::scrollDOWN() { QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); QApplication::postEvent( mCardView, ev ); } void KAddressBookCardView::readConfig(KConfig *config) { KAddressBookView::readConfig(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; if (uid.isNull()) { mCardView->selectAll(selected); } else { 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)) { mCardView->setSelected(aItem, selected); mCardView->ensureItemVisible(item); found = true; } } } } //US added an additional method without parameter void KAddressBookCardView::setSelected() { setSelected(QString::null, true); } void KAddressBookCardView::addresseeExecuted(CardViewItem *item) { #ifndef KAB_EMBEDDED AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item); #else //KAB_EMBEDDED AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item); #endif //KAB_EMBEDDED if (aItem) { //kdDebug()<<"... even has a valid item:)"<<endl; emit executed(aItem->addressee().uid()); } } void KAddressBookCardView::addresseeSelected() { CardViewItem *item; AddresseeCardViewItem *aItem; bool found = false; for (item = mCardView->firstItem(); item && !found; 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 ) { emit selected(aItem->addressee().uid()); found = true; } } } if (!found) emit selected(QString::null); } #ifndef KAB_EMBEDDED #include "kaddressbookcardview.moc" #endif //KAB_EMBEDDED 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 @@ -83,374 +83,374 @@ AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) setGridX( 100 ); setItemsMovable(false); setSorting(true, true); //US ??? setMode( KIconView::Select ); #ifndef KAB_EMBEDDED connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)), this, SLOT(itemDropped(QDropEvent*, const QValueList<QIconDragItem>&))); #endif //KAB_EMBEDDED } AddresseeIconView::~AddresseeIconView() { } void AddresseeIconView::itemDropped(QDropEvent *e, const QValueList<QIconDragItem> &) { emit addresseeDropped(e); } QDragObject *AddresseeIconView::dragObject() { emit startAddresseeDrag(); // We never want IconView to start the drag return 0; } //////////////////////////////// // AddresseeIconViewItem (internal class) #ifndef KAB_EMBEDDED class AddresseeIconViewItem : public KIconViewItem #else //KAB_EMBEDDED class AddresseeIconViewItem : public QIconViewItem #endif //KAB_EMBEDDED { public: #ifndef KAB_EMBEDDED AddresseeIconViewItem(const KABC::Field::List &fields, KABC::AddressBook *doc, const KABC::Addressee &a, QIconView *parent) : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) #else //KAB_EMBEDDED AddresseeIconViewItem(const KABC::Field::List &fields, KABC::AddressBook *doc, const KABC::Addressee &a, QIconView *parent) : QIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) #endif //KAB_EMBEDDED { if ( mFields.isEmpty() ) { mFields = KABC::Field::defaultFields(); } refresh(); } const KABC::Addressee &addressee() const { return mAddressee; } void refresh() { // Update our addressee, since it may have changed elsewhere mAddressee = mDocument->findByUid(mAddressee.uid()); if (!mAddressee.isEmpty()) setText( mAddressee.givenName() + " " + mAddressee.familyName() ); QPixmap icon; QPixmap defaultIcon( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 ) ); KABC::Picture pic = mAddressee.photo(); if ( pic.data().isNull() ) pic = mAddressee.logo(); if ( pic.isIntern() && !pic.data().isNull() ) { QImage img = pic.data(); #ifndef KAB_EMBEDDED if ( img.width() > img.height() ) icon = img.scaleWidth( 32 ); else icon = img.scaleHeight( 32 ); #else //KAB_EMBEDDED qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor"); icon.convertFromImage(img.smoothScale(32, 32)); #endif //KAB_EMBEDDED } else icon = defaultIcon; setPixmap( icon ); } private: KABC::Field::List mFields; KABC::AddressBook *mDocument; 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()) { mIconView->selectAll(selected); } else { bool found = false; for (item = mIconView->firstItem(); item && !found; 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)) { mIconView->setSelected(aItem, selected); mIconView->ensureItemVisible( aItem ); found = true; } } } } void KAddressBookIconView::addresseeExecuted(QIconViewItem *item) { #ifndef KAB_EMBEDDED AddresseeIconViewItem *aItem = dynamic_cast<AddresseeIconViewItem*>(item); #else //KAB_EMBEDDED AddresseeIconViewItem *aItem = (AddresseeIconViewItem*)(item); #endif //KAB_EMBEDDED if (aItem) { emit executed(aItem->addressee().uid()); } } void KAddressBookIconView::addresseeSelected() { QIconViewItem *item; AddresseeIconViewItem *aItem; bool found = false; for (item = mIconView->firstItem(); item && !found; 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) { emit selected(aItem->addressee().uid()); found = true; } } } if (!found) emit selected(QString::null); } #ifndef KAB_EMBEDDED #include "kaddressbookiconview.moc" #endif //KAB_EMBEDDED 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 @@ -1,366 +1,366 @@ // $Id$ #include <qvbox.h> #include <qlistbox.h> #include <qwidget.h> #include <qfile.h> #include <qimage.h> #include <qcombobox.h> #include <qapplication.h> #include <qdragobject.h> #include <qevent.h> #include <qurl.h> #include <qpixmap.h> #include <kabc/addressbook.h> #include <kapplication.h> #include <kconfig.h> #include <kcolorbutton.h> #include <kdebug.h> #include <kglobal.h> #include <kiconloader.h> #include <klineedit.h> #include <klocale.h> #include <kmessagebox.h> #include <kurl.h> #include <kurlrequester.h> //US#include "configuretableviewdialog.h" #include "contactlistview.h" #include "kabprefs.h" #include "undocmds.h" #include "viewmanager.h" #include <qlayout.h> #include <qheader.h> #include <qregexp.h> #include "kaddressbooktableview.h" KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, QWidget *parent, const char *name ) : KAddressBookView( ab, parent, name ) { mainLayout = new QVBoxLayout( viewWidget(), 2 ); // The list view will be created when the config is read. mListView = 0; } KAddressBookTableView::~KAddressBookTableView() { } void KAddressBookTableView::setFocusAV() { if ( mListView ) mListView->setFocus(); } void KAddressBookTableView::scrollUP() { QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); 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")); // Restore the layout of the listview mListView->restoreLayout(config, config->group()); } void KAddressBookTableView::refresh(QString uid) { // For now just repopulate. In reality this method should // check the value of uid, and if valid iterate through // the listview to find the entry, then tell it to refresh. if (uid.isNull()) { // Clear the list view QString currentUID, nextUID; #ifndef KAB_EMBEDDED ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); #else //KAB_EMBEDDED ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); #endif //KAB_EMBEDDED if ( currentItem ) { #ifndef KAB_EMBEDDED ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); #else //KAB_EMBEDDED ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); #endif //KAB_EMBEDDED if ( nextItem ) nextUID = nextItem->addressee().uid(); currentUID = currentItem->addressee().uid(); } mListView->clear(); currentItem = 0; KABC::Addressee::List addresseeList = addressees(); KABC::Addressee::List::Iterator it; for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) continue; ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); if ( (*it).uid() == currentUID ) currentItem = item; else if ( (*it).uid() == nextUID && !currentItem ) currentItem = item; } // Sometimes the background pixmap gets messed up when we add lots // of items. mListView->repaint(); if ( currentItem ) { mListView->setCurrentItem( currentItem ); mListView->ensureItemVisible( currentItem ); } } else { // Only need to update on entry. Iterate through and try to find it ContactListViewItem *ceItem; QListViewItemIterator it( mListView ); while ( it.current() ) { #ifndef KAB_EMBEDDED ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); #else //KAB_EMBEDDED ceItem = (ContactListViewItem*)( it.current() ); #endif //KAB_EMBEDDED if ( ceItem && ceItem->addressee().uid() == uid ) { ceItem->refresh(); return; } ++it; } refresh( QString::null ); } } QStringList KAddressBookTableView::selectedUids() { QStringList uidList; QListViewItem *item; ContactListViewItem *ceItem; for(item = mListView->firstChild(); item; item = item->itemBelow()) { if (mListView->isSelected( item )) { #ifndef KAB_EMBEDDED ceItem = dynamic_cast<ContactListViewItem*>(item); #else //KAB_EMBEDDED ceItem = (ContactListViewItem*)(item); #endif //KAB_EMBEDDED if (ceItem != 0L) uidList << ceItem->addressee().uid(); } } diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp index ead8628..21ecb73 100644 --- a/korganizer/kotodoviewitem.cpp +++ b/korganizer/kotodoviewitem.cpp @@ -1,259 +1,259 @@ /* 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; setMyPixmap(); } void KOTodoViewItem::setMyPixmap() { int size = 5; QPixmap pixi = QPixmap( 1, 1 ); // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { // pixi = SmallIcon("redcross16"); // } else { QPainter p; int pixSize = 0; QPixmap pPix = QPixmap( size, size ); if ( mTodo->description().length() > 0 ) { pixi.resize(size, pixSize+size); pPix.fill( Qt::darkGreen ); p.begin( &pixi ); p. drawPixmap ( 0, pixSize, pPix); p.end(); pixSize += size; } if ( mTodo->isAlarmEnabled() ) { pixi.resize(size, pixSize+size); pPix.fill( Qt::red ); p.begin( &pixi ); p. drawPixmap ( 0, pixSize, pPix); p.end(); pixSize += size; } // } if ( pixi.width() > 1 ) { setPixmap ( 0,pixi ) ; } else { setPixmap ( 0,QPixmap() ) ; } } void KOTodoViewItem::stateChange(bool state) { // qDebug("KOTodoViewItem::stateChange "); // do not change setting on startup if ( m_init ) return; kdDebug() << "State changed, modified " << state << endl; QString keyd = "=="; QString keyt = "=="; if (state) mTodo->setCompleted(state); else mTodo->setPercentComplete(0); if (isOn()!=state) { setOn(state); } 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); } } if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); 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)); } QListViewItem * myChild = firstChild(); KOTodoViewItem *item; while( myChild ) { item = static_cast<KOTodoViewItem*>(myChild); item->stateChange(state); myChild = myChild->nextSibling(); } mTodoView->modified(true); setMyPixmap(); mTodoView->setTodoModified( mTodo ); } bool KOTodoViewItem::isAlternate() { #ifndef KORG_NOLVALTERNATION KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); 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 @@ -386,203 +386,203 @@ void KOViewManager::showWeekView() globalFlagBlockAgenda = 2; qDebug("4globalFlagBlockAgenda = 2; "); //globalFlagBlockPainting = true; mMainView->dateNavigator()->selectWeek(); showAgendaView(); */ mFlagShowNextxDays = false; globalFlagBlockAgenda = 1; globalFlagBlockLabel = 1; if ( mCurrentAgendaView != 7 ) mCurrentAgendaView = -1; showAgendaView(); qApp->processEvents(); globalFlagBlockAgenda = 2; globalFlagBlockLabel = 0; mMainView->dateNavigator()->selectWeek(); mCurrentAgendaView = 7 ; } void KOViewManager::showNextXView() { globalFlagBlockAgenda = 1; if ( mCurrentAgendaView != 3 ) mCurrentAgendaView = -1; showAgendaView(KOPrefs::instance()->mFullViewMonth); globalFlagBlockAgenda = 2; mMainView->dateNavigator()->selectDates( QDate::currentDate(), KOPrefs::instance()->mNextXDays ); mFlagShowNextxDays = true; mCurrentAgendaView = 3 ; } bool KOViewManager::showsNextDays() { return mFlagShowNextxDays; } void KOViewManager::showMonthView() { if (!mMonthView) { mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); addView(mMonthView); // mMonthView->show(); // SIGNALS/SLOTS FOR MONTH VIEW connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), mMainView, SLOT(newEvent(QDateTime))); connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), mMainView, SLOT(showIncidence(Incidence *))); connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), mMainView, SLOT(editIncidence(Incidence *))); connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), mMainView, SLOT(deleteIncidence(Incidence *))); connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), mMainView, SLOT ( moveIncidence( Incidence * ) ) ); connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), mMainView, SLOT ( beamIncidence( Incidence * ) ) ); connect( mMonthView, SIGNAL( selectWeekNum( int ) ), mMainView, SLOT ( selectWeekNum( int ) ) ); connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), mMainView, SLOT ( showDay( QDate ) ) ); connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); mMonthView->updateConfig(); } globalFlagBlockAgenda = 1; //mFlagShowNextxDays = false; // if(mMonthView == mCurrentView) return; mMainView->dateNavigator()->selectMonth(); // DateList tmpList = mMainView->dateNavigator()->selectedDates( ); //mMonthView->showDates(tmpList.first(), tmpList.last()); showView(mMonthView, true ); } void KOViewManager::showTodoView() { //mFlagShowNextxDays = false; if ( !mTodoView ) { mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), "KOViewManager::TodoView" ); addView( mTodoView ); // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); // 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 @@ -45,353 +45,353 @@ SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) : KDialogBase(Plain,i18n("KO/Pi Find "),User1|Close,User1,parent,0,false,false, i18n("&Find")) { mCalendar = calendar; QFrame *topFrame = plainPage(); QVBoxLayout *layout = new QVBoxLayout(topFrame,0,spacingHint()); // Search expression QHBoxLayout *subLayout = new QHBoxLayout(); layout->addLayout(subLayout); searchLabel = new QLabel(topFrame); searchLabel->setText(i18n("Search for:")); subLayout->addWidget(searchLabel); searchEdit = new QLineEdit(topFrame); subLayout->addWidget(searchEdit); searchEdit->setText("*"); // Find all events by default searchEdit->setFocus(); connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); // Subjects to search // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), // topFrame); QHBox *incidenceGroup = new QHBox( topFrame ); layout->addWidget(incidenceGroup); mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); mSearchEvent->setChecked(true); mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); QHBox *subjectGroup = new QHBox( topFrame ); layout->addWidget(subjectGroup); mSummaryCheck = new QCheckBox(i18n("Summaries"),subjectGroup); mSummaryCheck->setChecked(true); mDescriptionCheck = new QCheckBox(i18n("Descriptions"),subjectGroup); mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup); QHBox *attendeeGroup = new QHBox( topFrame ); layout->addWidget(attendeeGroup ); new QLabel( i18n("Attendee:"),attendeeGroup ); mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup ); mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup ); // Date range // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"), // topFrame); // layout->addWidget(rangeGroup); QWidget *rangeWidget = new QWidget(topFrame); QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,spacingHint()); rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget)); mStartDate = new KDateEdit(rangeWidget); rangeLayout->addWidget(mStartDate); rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget)); mEndDate = new KDateEdit(rangeWidget); mEndDate->setDate(QDate::currentDate().addDays(365)); rangeLayout->addWidget(mEndDate); // mInclusiveCheck = new QCheckBox(i18n("Events have to be completely included"), topFrame); //mInclusiveCheck->setChecked(false); layout->addWidget(rangeWidget); //layout->addWidget(mInclusiveCheck); // Subjects to search // Results list view listView = new KOListView(mCalendar,topFrame); //listView->showDates(); layout->addWidget(listView); // if ( KOPrefs::instance()->mCompactDialogs ) { // KOGlobals::fitDialogToScreen( this, true ); // } listView->readSettings(KOGlobals::config(),"SearchListView Layout"); connect(this,SIGNAL(user1Clicked()),SLOT(doSearch())); QPushButton *CloseButton = findButton( Close ); //connect(CloseButton,SIGNAL(clicked()),listView, SLOT(clear())); #ifndef DESKTOP_VERSION setCaption(i18n("Click OK to search ->")); hideButtons(); #endif } 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 @@ -1,157 +1,157 @@ #ifndef DESKTOP_VERSION #include <qksplitter.h> #else #include <qsplitter.h> #endif #include <qlistview.h> #include <qlayout.h> #include <qheader.h> #include <qpushbutton.h> #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 @@ -14,389 +14,385 @@ 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. */ #include <qdatetime.h> #include <qstring.h> #include <qptrlist.h> #include <qfile.h> #include <kdebug.h> #include <klocale.h> #include <kglobal.h> extern "C" { #include <ical.h> #include <icalss.h> #include <icalparser.h> #include <icalrestriction.h> } #include "calendar.h" #include "journal.h" #include "icalformat.h" #include "icalformatimpl.h" #include "compat.h" #define _ICAL_VERSION "2.0" using namespace KCal; const int gSecondsPerMinute = 60; const int gSecondsPerHour = gSecondsPerMinute * 60; const int gSecondsPerDay = gSecondsPerHour * 24; const int gSecondsPerWeek = gSecondsPerDay * 7; ICalFormatImpl::ICalFormatImpl( ICalFormat *parent ) : mParent( parent ), mCalendarVersion( 0 ) { mCompat = new Compat; } ICalFormatImpl::~ICalFormatImpl() { delete mCompat; } class ToStringVisitor : public Incidence::Visitor { public: ToStringVisitor( ICalFormatImpl *impl ) : mImpl( impl ), mComponent( 0 ) {} bool visit( Event *e ) { mComponent = mImpl->writeEvent( e ); return true; } bool visit( Todo *e ) { mComponent = mImpl->writeTodo( e ); return true; } bool visit( Journal *e ) { mComponent = mImpl->writeJournal( e ); return true; } icalcomponent *component() { return mComponent; } private: ICalFormatImpl *mImpl; icalcomponent *mComponent; }; icalcomponent *ICalFormatImpl::writeIncidence(Incidence *incidence) { ToStringVisitor v( this ); incidence->accept(v); return v.component(); } icalcomponent *ICalFormatImpl::writeTodo(Todo *todo) { QString tmpStr; QStringList tmpStrList; icalcomponent *vtodo = icalcomponent_new(ICAL_VTODO_COMPONENT); writeIncidence(vtodo,todo); // due date if (todo->hasDueDate()) { icaltimetype due; if (todo->doesFloat()) { due = writeICalDate(todo->dtDue().date()); } else { due = writeICalDateTime(todo->dtDue()); } icalcomponent_add_property(vtodo,icalproperty_new_due(due)); } // start time if (todo->hasStartDate()) { icaltimetype start; if (todo->doesFloat()) { // 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())); } // location if (!incidence->location().isEmpty()) { icalcomponent_add_property(parent,icalproperty_new_location( incidence->location().utf8())); } // TODO: // status // addPropValue(parent, VCStatusProp, incidence->getStatusStr().utf8()); // secrecy enum icalproperty_class classInt; switch (incidence->secrecy()) { case Incidence::SecrecyPublic: classInt = ICAL_CLASS_PUBLIC; break; case Incidence::SecrecyConfidential: classInt = ICAL_CLASS_CONFIDENTIAL; break; case Incidence::SecrecyPrivate: classInt =ICAL_CLASS_PRIVATE ; default: classInt =ICAL_CLASS_PRIVATE ; break; } icalcomponent_add_property(parent,icalproperty_new_class(classInt)); // priority icalcomponent_add_property(parent,icalproperty_new_priority( incidence->priority())); // categories QStringList categories = incidence->categories(); QStringList::Iterator it; for(it = categories.begin(); it != categories.end(); ++it ) { icalcomponent_add_property(parent,icalproperty_new_categories((*it).utf8())); } // TODO: Ensure correct concatenation of categories properties. /* // categories tmpStrList = incidence->getCategories(); tmpStr = ""; QString catStr; for ( QStringList::Iterator it = tmpStrList.begin(); it != tmpStrList.end(); ++it ) { catStr = *it; if (catStr[0] == ' ') tmpStr += catStr.mid(1); else tmpStr += catStr; // this must be a ';' character as the vCalendar specification requires! // vcc.y has been hacked to translate the ';' to a ',' when the vcal is // read in. tmpStr += ";"; } if (!tmpStr.isEmpty()) { tmpStr.truncate(tmpStr.length()-1); icalcomponent_add_property(parent,icalproperty_new_categories( writeText(incidence->getCategories().join(";")))); } */ // related event if (incidence->relatedTo()) { icalcomponent_add_property(parent,icalproperty_new_relatedto( incidence->relatedTo()->uid().utf8())); } // recurrence rule stuff Recurrence *recur = incidence->recurrence(); if (recur->doesRecur()) { icalcomponent_add_property(parent,writeRecurrenceRule(recur)); } // recurrence excpetion dates DateList dateList = incidence->exDates(); DateList::ConstIterator exIt; for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) { icalcomponent_add_property(parent,icalproperty_new_exdate( writeICalDate(*exIt))); } // attachments QPtrList<Attachment> attachments = incidence->attachments(); for (Attachment *at = attachments.first(); at; at = attachments.next()) icalcomponent_add_property(parent,writeAttachment(at)); // alarms QPtrList<Alarm> alarms = incidence->alarms(); Alarm* alarm; for (alarm = alarms.first(); alarm; alarm = alarms.next()) { if (alarm->enabled()) { diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp index 60b8bc7..567ae54 100644 --- a/microkde/KDGanttMinimizeSplitter.cpp +++ b/microkde/KDGanttMinimizeSplitter.cpp @@ -1,232 +1,232 @@ /* -*- 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) { if ( onButton( p ) != 0 ) { setCursor( arrowCursor ); } else { if ( orient == KDGanttMinimizeSplitter::Horizontal ) setCursor( splitHCursor ); else setCursor( splitVCursor ); } } void KDGanttSplitterHandle::toggle() { int pos; int min, max; if ( !_collapsed ) { s->expandPos( id(), &min, &max ); if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { pos = min; } else { pos = max; } _origPos = s->pick(mapToParent( QPoint( 0,0 ) )); s->moveSplitter( pos, id() ); _collapsed = true; } else { s->moveSplitter( _origPos, id() ); _collapsed = false; } } void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) { if ( _activeButton != 0 ) { if ( onButton( e->pos() ) == _activeButton ) { toggle(); } _activeButton = 0; updateCursor( e->pos() ); } else { if ( !opaque() && e->button() == LeftButton ) { QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) - mouseOffset; s->setRubberband( -1 ); s->moveSplitter( pos, id() ); } } repaint(); } int KDGanttSplitterHandle::onButton( const QPoint& p ) { QValueList<QPointArray> list = buttonRegions(); int index = 1; int add = 12; for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { QRect rect = (*it).boundingRect(); rect.setLeft( rect.left()- add ); rect.setRight( rect.right() + add); rect.setTop( rect.top()- add ); rect.setBottom( rect.bottom() + add); if ( rect.contains( p ) ) { return index; } index++; } return 0; } QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions() { QValueList<QPointArray> list; int sw = 8; int yyy = 1; int xxx = 1; int voffset[] = { (int) -sw*3, (int) sw*3 }; for ( int i = 0; i < 2; i++ ) { QPointArray arr; if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right || _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) { int mid = height()/2 + voffset[i]; arr.setPoints( 3, 1-xxx, mid - sw + 4, sw-3-xxx, mid, 1-xxx, mid + sw -4); } else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left || _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { int mid = height()/2 + voffset[i]; @@ -438,667 +438,667 @@ KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *n mFirstHandle = 0; #if QT_VERSION >= 232 orient = Horizontal; init(); #endif } /*! Constructs a splitter with orientation \a o with the \a parent and \a name arguments being passed on to the QFrame constructor. */ KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name ) :QFrame(parent,name,WPaintUnclipped) { mFirstHandle = 0; #if QT_VERSION >= 232 orient = o; init(); #endif } /*! Destroys the splitter and any children. */ KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter() { #if QT_VERSION >= 232 data->list.setAutoDelete( TRUE ); delete data; #endif } #if QT_VERSION >= 232 void KDGanttMinimizeSplitter::init() { data = new QSplitterData; if ( orient == Horizontal ) setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) ); else setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) ); } #endif /*! \brief the orientation of the splitter By default the orientation is horizontal (the widgets are side by side). The possible orientations are Qt:Vertical and Qt::Horizontal (the default). */ void KDGanttMinimizeSplitter::setOrientation( Orientation o ) { #if QT_VERSION >= 232 if ( orient == o ) return; orient = o; if ( orient == Horizontal ) setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); else setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); QSplitterLayoutStruct *s = data->list.first(); while ( s ) { if ( s->isSplitter ) ((KDGanttSplitterHandle*)s->wid)->setOrientation( o ); s = data->list.next(); // ### next at end of loop, no iterator } recalc( isVisible() ); #endif } #if QT_VERSION >= 232 /*! \reimp */ void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * ) { doResize(); } /* Inserts the widget \a w at the end (or at the beginning if \a first is TRUE) of the splitter's list of widgets. It is the responsibility of the caller of this function to make sure that \a w is not already in the splitter and to call recalcId if needed. (If \a first is TRUE, then recalcId is very probably needed.) */ QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first ) { 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; moveAfter( p, id, upLeft ); moveBefore( p-1, id-1, upLeft ); storeSizes(); } void KDGanttMinimizeSplitter::setG( QWidget *w, int p, int s, bool isSplitter ) { if ( orient == Horizontal ) { if ( false && orient == Horizontal && !isSplitter ) p = contentsRect().width() - p - s; w->setGeometry( p, contentsRect().y(), s, contentsRect().height() ); } else w->setGeometry( contentsRect().x(), p, contentsRect().width(), s ); } /* Places the right/bottom edge of the widget at \a id at position \a pos. \sa idAfter() */ void KDGanttMinimizeSplitter::moveBefore( int pos, int id, bool upLeft ) { if( id < 0 ) return; QSplitterLayoutStruct *s = data->list.at(id); if ( !s ) return; QWidget *w = s->wid; if ( w->isHidden() ) { moveBefore( pos, id-1, upLeft ); } else if ( s->isSplitter ) { int pos1, pos2; int dd = s->sizer; if( false && orient == Horizontal ) { pos1 = pos; pos2 = pos + dd; } else { pos2 = pos - dd; pos1 = pos2 + 1; } if ( upLeft ) { setG( w, pos1, dd, TRUE ); moveBefore( pos2, id-1, upLeft ); } else { moveBefore( pos2, id-1, upLeft ); setG( w, pos1, dd, TRUE ); } } else { int dd, newLeft, nextPos; if( false && orient == Horizontal ) { dd = w->geometry().right() - pos; dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); newLeft = pos+1; nextPos = newLeft + dd; } else { dd = pos - pick( w->pos() ) + 1; dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); newLeft = pos-dd+1; nextPos = newLeft - 1; } setG( w, newLeft, dd, TRUE ); moveBefore( nextPos, id-1, upLeft ); } } /* Places the left/top edge of the widget at \a id at position \a pos. \sa idAfter() */ void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft ) { QSplitterLayoutStruct *s = id < int(data->list.count()) ? data->list.at(id) : 0; if ( !s ) return; QWidget *w = s->wid; if ( w->isHidden() ) { moveAfter( pos, id+1, upLeft ); } else if ( pick( w->pos() ) == pos ) { //No need to do anything if it's already there. return; } else if ( s->isSplitter ) { int dd = s->sizer; int pos1, pos2; 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++ ) { QSplitterLayoutStruct *s = data->list.at(i); if ( !s->isSplitter ) { QSplitterLayoutStruct *p = (i > 0) ? p = data->list.at( i-1 ) : 0; if ( p && p->isSplitter ) if ( first || s->wid->isHidden() ) p->wid->hide(); //may trigger new recalc else p->wid->show(); //may trigger new recalc if ( !s->wid->isHidden() ) first = FALSE; } } bool empty=TRUE; for ( int j = 0; j< n; j++ ) { QSplitterLayoutStruct *s = data->list.at(j); if ( !s->wid->isHidden() ) { empty = FALSE; if ( s->isSplitter ) { minl += s->sizer; maxl += s->sizer; } else { QSize minS = minSize(s->wid); minl += pick( minS ); maxl += pick( s->wid->maximumSize() ); mint = QMAX( mint, trans( minS )); int tm = trans( s->wid->maximumSize() ); if ( tm > 0 ) maxt = QMIN( maxt, tm ); } } } if ( empty ) { if ( parentWidget() != 0 && parentWidget()->inherits("KDGanttMinimizeSplitter") ) { // nested splitters; be nice maxl = maxt = 0; } else { // KDGanttMinimizeSplitter with no children yet maxl = QWIDGETSIZE_MAX; } } else { maxl = QMIN( maxl, QWIDGETSIZE_MAX ); } if ( maxt < mint ) maxt = mint; if ( orient == Horizontal ) { setMaximumSize( maxl, maxt ); setMinimumSize( minl, mint ); } else { setMaximumSize( maxt, maxl ); setMinimumSize( mint, minl ); } if ( update ) doResize(); } /*! Sets resize mode of \a w to \a mode. \sa ResizeMode */ void KDGanttMinimizeSplitter::setResizeMode( QWidget *w, ResizeMode mode ) { processChildEvents(); QSplitterLayoutStruct *s = data->list.first(); while ( s ) { if ( s->wid == w ) { s->mode = mode; return; } s = data->list.next(); } s = addWidget( w, TRUE ); s->mode = mode; } /*! Returns TRUE if opaque resize is on; otherwise returns FALSE. \sa setOpaqueResize() */ bool KDGanttMinimizeSplitter::opaqueResize() const { return data->opaque; } /*! If \a on is TRUE then opaque resizing is turned on; otherwise opaque resizing is turned off. Opaque resizing is initially turned off. @@ -1198,385 +1198,385 @@ QSize KDGanttMinimizeSplitter::sizeHint() const !((QWidget*)o)->isHidden() ) { QSize s = ((QWidget*)o)->sizeHint(); if ( s.isValid() ) { l += pick( s ); t = QMAX( t, trans( s ) ); } } } } return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); } /*! \reimp */ QSize KDGanttMinimizeSplitter::minimumSizeHint() const { constPolish(); int l = 0; int t = 0; if ( children() ) { const QObjectList * c = children(); QObjectListIt it( *c ); QObject * o; while( (o=it.current()) != 0 ) { ++it; if ( o->isWidgetType() && !((QWidget*)o)->isHidden() ) { QSize s = minSizeHint((QWidget*)o); if ( s.isValid() ) { l += pick( s ); t = QMAX( t, trans( s ) ); } } } } return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); } /* Calculates stretch parameters from current sizes */ void KDGanttMinimizeSplitter::storeSizes() { QSplitterLayoutStruct *s = data->list.first(); while ( s ) { if ( !s->isSplitter ) s->sizer = pick( s->wid->size() ); s = data->list.next(); } } #if 0 // ### remove this code ASAP /*! Hides \a w if \a hide is TRUE and updates the splitter. \warning Due to a limitation in the current implementation, calling QWidget::hide() will not work. */ void KDGanttMinimizeSplitter::setHidden( QWidget *w, bool hide ) { if ( w == w1 ) { w1show = !hide; } else if ( w == w2 ) { w2show = !hide; } else { #ifdef QT_CHECK_RANGE qWarning( "KDGanttMinimizeSplitter::setHidden(), unknown widget" ); #endif return; } if ( hide ) w->hide(); else w->show(); recalc( TRUE ); } /*! Returns the hidden status of \a w */ bool KDGanttMinimizeSplitter::isHidden( QWidget *w ) const { if ( w == w1 ) return !w1show; else if ( w == w2 ) 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; while ( !finished ) { finished = TRUE; fixed fp_over = toFixed( overdraft ); fixed fp_w = 0; for ( i = start; i < start+count; i++ ) { if ( chain[i].done ) continue; // if ( sumStretch <= 0 ) fp_w += fp_over / n; // else // fp_w += (fp_over * chain[i].stretch) / sumStretch; int w = fRound( fp_w ); chain[i].size = chain[i].sizeHint - w; fp_w -= toFixed( w ); //give the difference to the next if ( chain[i].size < chain[i].minimumSize ) { chain[i].done = TRUE; chain[i].size = chain[i].minimumSize; finished = FALSE; overdraft -= chain[i].sizeHint - chain[i].minimumSize; // sumStretch -= chain[i].stretch; n--; break; } } } } else { //extra space int n = count; int space_left = space - spacerCount*spacer; // first give to the fixed ones, and handle non-expansiveness for ( i = start; i < start + count; i++ ) { if ( !chain[i].done && (chain[i].maximumSize <= chain[i].sizeHint || wannaGrow && !chain[i].expansive) ) { chain[i].size = chain[i].sizeHint; chain[i].done = TRUE; space_left -= chain[i].sizeHint; sumStretch -= chain[i].stretch; n--; } } extraspace = space_left; /* Do a trial distribution and calculate how much it is off. If there are more deficit pixels than surplus pixels, give the minimum size items what they need, and repeat. Otherwise give to the maximum size items, and repeat. I have a wonderful mathematical proof for the correctness of this principle, but unfortunately this comment is too small to contain it. */ int surplus, deficit; do { surplus = deficit = 0; fixed fp_space = toFixed( space_left ); fixed fp_w = 0; for ( i = start; i < start+count; i++ ) { if ( chain[i].done ) continue; extraspace = 0; if ( sumStretch <= 0 ) fp_w += fp_space / n; else fp_w += (fp_space * chain[i].stretch) / sumStretch; int w = fRound( fp_w ); chain[i].size = w; fp_w -= toFixed( w ); // give the difference to the next if ( w < chain[i].sizeHint ) { deficit += chain[i].sizeHint - w; } else if ( w > chain[i].maximumSize ) { surplus += w - chain[i].maximumSize; } } if ( deficit > 0 && surplus <= deficit ) { // give to the ones that have too little for ( i = start; i < start+count; i++ ) { if ( !chain[i].done && chain[i].size < chain[i].sizeHint ) { chain[i].size = chain[i].sizeHint; chain[i].done = TRUE; space_left -= chain[i].sizeHint; sumStretch -= chain[i].stretch; n--; } } } if ( surplus > 0 && surplus >= deficit ) { // take from the ones that have too much for ( i = start; i < start+count; i++ ) { if ( !chain[i].done && chain[i].size > chain[i].maximumSize ) { chain[i].size = chain[i].maximumSize; chain[i].done = TRUE; space_left -= chain[i].maximumSize; sumStretch -= chain[i].stretch; n--; diff --git a/microkde/kcalendarsystemgregorian.cpp b/microkde/kcalendarsystemgregorian.cpp index 7c5b62a..cc12b9f 100644 --- a/microkde/kcalendarsystemgregorian.cpp +++ b/microkde/kcalendarsystemgregorian.cpp @@ -1,359 +1,359 @@ /* 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"); } bool KCalendarSystemGregorian::isLunar() const { return false; } bool KCalendarSystemGregorian::isLunisolar() const { return false; } bool KCalendarSystemGregorian::isSolar() const { return true; } |