-rw-r--r-- | kaddressbook/kaddressbookview.cpp | 4 | ||||
-rw-r--r-- | kaddressbook/kaddressbookview.h | 6 | ||||
-rw-r--r-- | kaddressbook/views/cardview.cpp | 31 | ||||
-rw-r--r-- | kaddressbook/views/cardview.h | 7 | ||||
-rw-r--r-- | kaddressbook/views/contactlistview.cpp | 29 | ||||
-rw-r--r-- | kaddressbook/views/contactlistview.h | 4 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.cpp | 4 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 4 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 19 | ||||
-rw-r--r-- | korganizer/komonthview.h | 3 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 26 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 1 |
12 files changed, 129 insertions, 9 deletions
diff --git a/kaddressbook/kaddressbookview.cpp b/kaddressbook/kaddressbookview.cpp index 09859c2..86898e2 100644 --- a/kaddressbook/kaddressbookview.cpp +++ b/kaddressbook/kaddressbookview.cpp @@ -14,65 +14,65 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #ifndef KAB_EMBEDDED #include <qapplication.h> #include <kabc/distributionlistdialog.h> #include <kconfig.h> #include <klocale.h> #include "viewmanager.h" #endif //KAB_EMBEDDED #include <qlayout.h> #include <kabc/distributionlistdialog.h> #include <kabc/addressbook.h> #include <kdebug.h> #include "kaddressbookview.h" KAddressBookView::KAddressBookView( KABC::AddressBook *ab, QWidget *parent, const char *name ) : QWidget( parent, name ), mAddressBook( ab ), mFieldList() { - + initGUI(); } KAddressBookView::~KAddressBookView() { } QRegExp KAddressBookView::getRegExp( const QString s ) { QRegExp re; if ( s.length() == 3 && s.mid(1,1) == "-" ) { QString pattern = "^[" + s.lower() +"]"; re.setCaseSensitive(false); re.setPattern( pattern ); } else { QString pattern = s.lower()+"*"; re.setWildcard(true); // most people understand these better. re.setCaseSensitive(false); re.setPattern( pattern ); } return re; } void KAddressBookView::readConfig( KConfig *config ) { mFieldList = KABC::Field::restoreFields( config, "KABCFields" ); if ( mFieldList.isEmpty() ) mFieldList = KABC::Field::defaultFields(); @@ -152,35 +152,37 @@ KABC::Field::List KAddressBookView::allFields() const void KAddressBookView::setFilter( const Filter &filter ) { mFilter = filter; } KAddressBookView::DefaultFilterType KAddressBookView::defaultFilterType() const { return mDefaultFilterType; } const QString &KAddressBookView::defaultFilterName() const { return mDefaultFilterName; } KABC::AddressBook *KAddressBookView::addressBook() const { return mAddressBook; } QWidget *KAddressBookView::viewWidget() { return mViewWidget; } ViewConfigureWidget *ViewFactory::configureWidget( KABC::AddressBook *ab, QWidget *parent, const char *name ) { return new ViewConfigureWidget( ab, parent, name ); } + + #ifndef KAB_EMBEDDED #include "kaddressbookview.moc" #endif //KAB_EMBEDDED diff --git a/kaddressbook/kaddressbookview.h b/kaddressbook/kaddressbookview.h index 6bbb9c2..3a3f71a 100644 --- a/kaddressbook/kaddressbookview.h +++ b/kaddressbook/kaddressbookview.h @@ -201,65 +201,66 @@ class KAddressBookView : public QWidget @param uid The uid of the selected addressee. @see KListView */ void selected( const QString &uid ); void deleteRequest(); /** This signal should be emitted by a subclass whenever an addressee is executed. This is defined by the KDE system wide config, but it either means single or doubleclicked. @param ui The uid of the selected addressee @see KListView */ void executed( const QString &uid ); /** This signal is emitted whenever a user attempts to start a drag in the view. The slot connected to this signal would usually want to create a QDragObject. */ void startDrag(); /** This signal is emitted whenever the user drops something on the view. The individual view should handle checking if the item is droppable (ie: if it is a vcard). */ void dropped( QDropEvent* ); - protected: + protected: + /** Returns a list of the addressees that should be displayed. This method should always be used by the subclass to get a list of addressees. This method internally takes many factors into account, including the current filter. */ KABC::Addressee::List addressees(); /** This method returns the widget that should be used as the parent for all view components. By using this widget as the parent and not 'this', the view subclass has the option of placing other widgets around the view (ie: search fields, etc). Do not delete this widget! */ QWidget *viewWidget(); QRegExp getRegExp( const QString ); private: void initGUI(); DefaultFilterType mDefaultFilterType; Filter mFilter; QString mDefaultFilterName; KABC::AddressBook *mAddressBook; KABC::Field::List mFieldList; QWidget *mViewWidget; }; #ifndef KAB_EMBEDDED //MOC_SKIP_BEGIN class ViewFactory : public KLibFactory @@ -275,38 +276,39 @@ class ViewFactory /** @return The type of the view. This is normally a small one word string (ie: Table, Icon, Tree, etc). */ virtual QString type() const = 0; /** @return The description of the view. This should be a 3 to 4 line string (don't actually use return characters in the string) describing the features offered by the view. */ virtual QString description() const = 0; /** Creates a config dialog for the view type. The default implementation will return a ViewConfigDialog. This default dialog will allow the user to set the visible fields only. If you need more config options (as most views will), this method can be overloaded to return your sublcass of ViewConfigDialog. If this method is over loaded the base classes method should <B>not</B> be called. */ virtual ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent, const char *name = 0 ); protected: virtual QObject* createObject( QObject*, const char*, const char*, const QStringList & ) { return 0; - } + } + }; #endif diff --git a/kaddressbook/views/cardview.cpp b/kaddressbook/views/cardview.cpp index 03df444..84d3116 100644 --- a/kaddressbook/views/cardview.cpp +++ b/kaddressbook/views/cardview.cpp @@ -4,64 +4,65 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ //BEGIN Includes #include "cardview.h" #include <limits.h> #include <qpainter.h> #include <qtimer.h> #include <qdatetime.h> #include <qlabel.h> #include <qstyle.h> #include <qcursor.h> #include <qtooltip.h> +#include <qapplication.h> #include "kabprefs.h" #include <kdebug.h> #include <kglobalsettings.h> //END includes #define MIN_ITEM_WIDTH 80 //BEGIN Helpers ////////////////////////////////////// // CardViewTip class CardViewTip : public QLabel { public: CardViewTip(QWidget *parent=0, const char *name=0) : QLabel( parent, name ) { setPalette( QToolTip::palette() ); setFrameStyle( Panel|Plain ); setMidLineWidth(0); setIndent(1); } ~CardViewTip() {}; protected: void leaveEvent( QEvent * ) { hide(); } }; ////////////////////////////////////// // CardViewItemList @@ -610,64 +611,66 @@ void CardViewItem::showFullString( const QPoint &itempos, CardViewTip *tip ) } } CardViewItem::Field *CardViewItem::fieldAt( const QPoint & itempos ) const { int ypos = mView->d->mBFm->height() + 7 + mView->d->mItemMargin; int iy = itempos.y(); // skip below caption if ( iy <= ypos ) return 0; // try find a field bool showEmpty = mView->showEmptyFields(); int fh = mView->d->mFm->height(); int maxLines = mView->maxFieldLines(); Field *f; for ( f = d->mFieldList.first(); f; f = d->mFieldList.next() ) { if ( showEmpty || !f->second.isEmpty() ) ypos += ( QMIN( f->second.contains('\n')+1, maxLines ) *fh)+2; if ( iy <= ypos ) break; } return f ? f : 0; } //END CardViewItem //BEGIN CardView CardView::CardView(QWidget *parent, const char *name) : QScrollView(parent, name), d(new CardViewPrivate()) { + mFlagKeyPressed = false; + mFlagBlockKeyPressed = false; d->mItemList.setAutoDelete(true); d->mSeparatorList.setAutoDelete(true); QFont f = font(); d->mFm = new QFontMetrics(f); f.setBold(true); d->mHeaderFont = f; d->mBFm = new QFontMetrics(f); d->mTip = ( new CardViewTip( viewport() ) ), d->mTip->hide(); d->mTimer = ( new QTimer(this, "mouseTimer") ), viewport()->setMouseTracking( true ); viewport()->setFocusProxy(this); viewport()->setFocusPolicy(WheelFocus); viewport()->setBackgroundMode(PaletteBase); connect( d->mTimer, SIGNAL(timeout()), this, SLOT(tryShowFullText()) ); //US setBackgroundMode(PaletteBackground, PaletteBase); setBackgroundMode(PaletteBackground); // no reason for a vertical scrollbar setVScrollBarMode(AlwaysOff); } CardView::~CardView() { delete d->mFm; delete d->mBFm; delete d; d = 0; @@ -1322,65 +1325,73 @@ void CardView::leaveEvent( QEvent * ) if (d->mOnSeparator) { d->mOnSeparator = false; setCursor( ArrowCursor ); } } void CardView::focusInEvent( QFocusEvent * ) { if (!d->mCurrentItem && d->mItemList.count() ) { setCurrentItem( d->mItemList.first() ); } else if ( d->mCurrentItem ) { d->mCurrentItem->repaintCard(); } } void CardView::focusOutEvent( QFocusEvent * ) { if (d->mCurrentItem) d->mCurrentItem->repaintCard(); } void CardView::keyPressEvent( QKeyEvent *e ) { if ( ! ( childCount() && d->mCurrentItem ) ) { e->ignore(); return; } - + if ( mFlagBlockKeyPressed ) + return; + qApp->processEvents(); + if ( e->isAutoRepeat() && !mFlagKeyPressed ) { + e->accept(); + return; + } + if (! e->isAutoRepeat() ) + mFlagKeyPressed = true; uint pos = d->mItemList.findRef( d->mCurrentItem ); CardViewItem *aItem = 0L; // item that gets the focus CardViewItem *old = d->mCurrentItem; switch ( e->key() ) { case Key_Up: if ( pos > 0 ) { aItem = d->mItemList.at( pos - 1 ); setCurrentItem( aItem ); } break; case Key_Down: if ( pos < d->mItemList.count() - 1 ) { aItem = d->mItemList.at( pos + 1 ); setCurrentItem( aItem ); } break; case Key_Left: { // look for an item in the previous/next column, starting from // the vertical middle of the current item. // FIXME use nice calculatd measures!!! QPoint aPoint( d->mCurrentItem->d->x, d->mCurrentItem->d->y ); aPoint -= QPoint( 30,-(d->mCurrentItem->height()/2) ); aItem = itemAt( aPoint ); // maybe we hit some space below an item while ( !aItem && aPoint.y() > 27 ) { aPoint -= QPoint( 0, 16 ); @@ -1686,37 +1697,55 @@ QFont CardView::headerFont() const { return d->mHeaderFont; } void CardView::setFont( const QFont &fnt ) { QScrollView::setFont( fnt ); delete d->mFm; d->mFm = new QFontMetrics( fnt ); } int CardView::separatorWidth() { return d->mSepWidth; } void CardView::setSeparatorWidth( int width ) { d->mSepWidth = width; setLayoutDirty( true ); // hmm, actually I could just adjust the x'es... } int CardView::maxFieldLines() const { return d->mMaxFieldLines; } void CardView::setMaxFieldLines( int howmany ) { d->mMaxFieldLines = howmany ? howmany : INT_MAX; // FIXME update, forcing the items to recalc height!! } + +void CardView::keyReleaseEvent ( QKeyEvent * e ) +{ + if ( mFlagBlockKeyPressed ) + return; + if ( !e->isAutoRepeat() ) { + mFlagBlockKeyPressed = true; + qApp->processEvents(); + mFlagBlockKeyPressed = false; + mFlagKeyPressed = false; + } + QScrollView::keyReleaseEvent ( e ); +} + + + + + //END Cardview #ifndef KAB_EMBEDDED #include "cardview.moc" #endif //KAB_EMBEDDED diff --git a/kaddressbook/views/cardview.h b/kaddressbook/views/cardview.h index 37dddb6..2ea3771 100644 --- a/kaddressbook/views/cardview.h +++ b/kaddressbook/views/cardview.h @@ -376,98 +376,101 @@ class CardView : public QScrollView * a new item or unhighlighted a currently selected item. */ void selectionChanged(); /** Same as above method, only it carries the item that was selected. This * method will only be emitted in single select mode, since it defineds * which item was selected. */ void selectionChanged(CardViewItem *); /** This method is emitted whenever an item is clicked. */ void clicked(CardViewItem *); /** Emitted whenever the user 'executes' an item. This is dependant on * the KDE global config. This could be a single click or a doubleclick. * Also emitted when the return key is pressed on an item. */ void executed(CardViewItem *); /** Emitted whenever the user double clicks on an item. */ void doubleClicked(CardViewItem *); /** Emitted when the current item changes */ void currentChanged( CardViewItem * ); /** Emitted when the return key is pressed in an item. */ void returnPressed( CardViewItem * ); - protected: + protected: + bool mFlagKeyPressed; + bool mFlagBlockKeyPressed; + virtual void keyPressEvent ( QKeyEvent * ); + virtual void keyReleaseEvent ( QKeyEvent * ); /** Determines which cards intersect that region and tells them to paint * themselves. */ void drawContents(QPainter *p, int clipx, int clipy, int clipw, int cliph); /** Sets the layout to dirty and repaints. */ void resizeEvent(QResizeEvent *e); /** Changes the direction the canvas scolls. */ void contentsWheelEvent(QWheelEvent *e); /** Sets the layout to dirty and calls for a repaint. */ void setLayoutDirty(bool dirty); /** Does the math based on the bounding rect of the cards to properly * lay the cards out on the screen. This is only done if the layout is * marked as dirty. */ void calcLayout(); // virtual void mousePressEvent(QMouseEvent *e); // virtual void mouseReleaseEvent(QMouseEvent *e); // virtual void mouseMoveEvent(QMouseEvent *e); virtual void contentsMousePressEvent(QMouseEvent *e); virtual void contentsMouseMoveEvent(QMouseEvent *e); virtual void contentsMouseReleaseEvent(QMouseEvent *e); virtual void contentsMouseDoubleClickEvent(QMouseEvent *e); virtual void enterEvent( QEvent * ); virtual void leaveEvent( QEvent * ); virtual void focusInEvent( QFocusEvent * ); virtual void focusOutEvent( QFocusEvent * ); - virtual void keyPressEvent( QKeyEvent * ); /** Overload this method to be told when a drag should be started. * In most cases you will want to start a drag event with the currently * selected item. */ virtual void startDrag(); private slots: /** Called by a timer to display a label with truncated text. * Pop up a label, if there is a field with obscured text or * label at the cursor position. */ void tryShowFullText(); private: /** draws and erases the rubber bands while columns are resized. * @p pos is the horizontal position inside the viewport to use as * the anchor. * If pos is 0, only erase is done. */ void drawRubberBands( int pos ); CardViewPrivate *d; }; #endif diff --git a/kaddressbook/views/contactlistview.cpp b/kaddressbook/views/contactlistview.cpp index e75810e..09d9c03 100644 --- a/kaddressbook/views/contactlistview.cpp +++ b/kaddressbook/views/contactlistview.cpp @@ -1,63 +1,64 @@ /* This file is part of KAddressBook. Copyright (c) 2002 Mike Pilone <mpilone@slac.com> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include <qheader.h> #include <qiconset.h> #include <qimage.h> #include <qdragobject.h> #include <qcombobox.h> #include <qpainter.h> #include <qbrush.h> #include <qevent.h> +#include <qapplication.h> #include <klocale.h> #include <kglobalsettings.h> #include <kiconloader.h> #include <kdebug.h> #include <kconfig.h> #include <kapplication.h> #include <kurl.h> #include "kaddressbooktableview.h" #include "contactlistview.h" ///////////////////////////////// // DynamicTip Methods DynamicTip::DynamicTip( ContactListView *parent) : QToolTip( parent ) { } void DynamicTip::maybeTip( const QPoint &pos ) { static bool ishidden = true; if (!parentWidget()->inherits( "ContactListView" )) return; ContactListView *plv = (ContactListView*)parentWidget(); if (!plv->tooltips()) return; QPoint posVp = plv->viewport()->pos(); @@ -219,64 +220,66 @@ void ContactListViewItem::paintCell(QPainter * p, ContactListView *ContactListViewItem::parent() { return parentListView; } void ContactListViewItem::refresh() { // Update our addressee, since it may have changed else were mAddressee = mDocument->findByUid(mAddressee.uid()); if (mAddressee.isEmpty()) return; int i = 0; KABC::Field::List::ConstIterator it; for( it = mFields.begin(); it != mFields.end(); ++it ) { setText( i++, (*it)->value( mAddressee ) ); } } /////////////////////////////// // ContactListView ContactListView::ContactListView(KAddressBookTableView *view, KABC::AddressBook* /* doc */, QWidget *parent, const char *name ) : KListView( parent, name ), pabWidget( view ), oldColumn( 0 ) { + mFlagBlockKeyPressed = false; + mFlagKeyPressed = false; mABackground = true; mSingleLine = false; mToolTips = true; #ifndef KAB_EMBEDDED mAlternateColor = KGlobalSettings::alternateBackgroundColor(); #else //KAB_EMBEDDED mAlternateColor = QColor(240, 240, 240); #endif //KAB_EMBEDDED setAlternateBackgroundEnabled(mABackground); setAcceptDrops( true ); viewport()->setAcceptDrops( true ); setAllColumnsShowFocus( true ); setShowSortIndicator(true); setSelectionModeExt( KListView::Extended ); setDropVisualizer(false); // setFrameStyle(QFrame::NoFrame); //setLineWidth ( 0 ); //setMidLineWidth ( 0 ); //setMargin ( 0 ); #ifndef KAB_EMBEDDED connect(this, SIGNAL(dropped(QDropEvent*)), this, SLOT(itemDropped(QDropEvent*))); #endif //KAB_EMBEDDED new DynamicTip( this ); } void ContactListView::printMe() { #ifdef DESKTOP_VERSION @@ -366,35 +369,61 @@ void ContactListView::contentsDropEvent( QDropEvent *e ) { emit addresseeDropped(e); } void ContactListView::setAlternateBackgroundEnabled(bool enabled) { mABackground = enabled; if (mABackground) { setAlternateBackground(mAlternateColor); } else { setAlternateBackground(QColor()); } } void ContactListView::setBackgroundPixmap(const QString &filename) { if (filename.isEmpty()) { unsetPalette(); } else { qDebug("ContactListView::setBackgroundPixmap has to be verified"); //US setPaletteBackgroundPixmap(QPixmap(filename)); KListView::setBackgroundPixmap((const QPixmap&)QPixmap(filename)); } } + +void ContactListView::keyPressEvent ( QKeyEvent * e ) +{ + if ( mFlagBlockKeyPressed ) + return; + qApp->processEvents(); + if ( e->isAutoRepeat() && !mFlagKeyPressed ) { + e->accept(); + return; + } + if (! e->isAutoRepeat() ) + mFlagKeyPressed = true; + KListView::keyPressEvent ( e ); +} +void ContactListView::keyReleaseEvent ( QKeyEvent * e ) +{ + if ( mFlagBlockKeyPressed ) + return; + if ( !e->isAutoRepeat() ) { + mFlagBlockKeyPressed = true; + qApp->processEvents(); + mFlagBlockKeyPressed = false; + mFlagKeyPressed = false; + } + KListView::keyReleaseEvent ( e ); +} #ifndef KAB_EMBEDDED #include "contactlistview.moc" #endif //KAB_EMBEDDED diff --git a/kaddressbook/views/contactlistview.h b/kaddressbook/views/contactlistview.h index 9d1a672..46477e1 100644 --- a/kaddressbook/views/contactlistview.h +++ b/kaddressbook/views/contactlistview.h @@ -63,64 +63,68 @@ class ContactListView : public KListView { Q_OBJECT public: ContactListView(KAddressBookTableView *view, KABC::AddressBook *doc, QWidget *parent, const char *name = 0L ); virtual ~ContactListView() {} //void resort(); /** Returns true if tooltips should be displayed, false otherwise */ bool tooltips() const { return mToolTips; } void setToolTipsEnabled(bool enabled) { mToolTips = enabled; } bool alternateBackground() const { return mABackground; } void setAlternateBackgroundEnabled(bool enabled); bool singleLine() const { return mSingleLine; } void setSingleLineEnabled(bool enabled) { mSingleLine = enabled; } const QColor &alternateColor() const { return mAlternateColor; } void setAlternateColor(const QColor &mAlternateColor); /** Sets the background pixmap to <i>filename</i>. If the * QString is empty (QString::isEmpty()), then the background * pixmap will be disabled. */ void setBackgroundPixmap(const QString &filename); protected: + bool mFlagKeyPressed; + bool mFlagBlockKeyPressed; + virtual void keyPressEvent ( QKeyEvent * ); + virtual void keyReleaseEvent ( QKeyEvent * ); /** Paints the background pixmap in the empty area. This method is needed * since Qt::FixedPixmap will not scroll with the list view. */ virtual void paintEmptyArea( QPainter * p, const QRect & rect ); virtual void contentsMousePressEvent(QMouseEvent*); void contentsMouseMoveEvent( QMouseEvent *e ); void contentsDropEvent( QDropEvent *e ); virtual bool acceptDrag(QDropEvent *e) const; protected slots: void itemDropped(QDropEvent *e); public slots: void printMe(); signals: void startAddresseeDrag(); void addresseeDropped(QDropEvent *); private: KAddressBookTableView *pabWidget; int oldColumn; int column; bool ascending; bool mABackground; bool mSingleLine; bool mToolTips; QColor mAlternateColor; QPoint presspos; diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp index cce68b9..9c35fd6 100644 --- a/kaddressbook/views/kaddressbookcardview.cpp +++ b/kaddressbook/views/kaddressbookcardview.cpp @@ -179,70 +179,74 @@ KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, 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 ); + ev = new QKeyEvent ( QEvent::KeyRelease, 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 ); + ev = new QKeyEvent ( QEvent::KeyRelease, 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 ) ) diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index f4b008c..e322473 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp @@ -32,69 +32,73 @@ #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 ); + ev = new QKeyEvent ( QEvent::KeyRelease, 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 ); + ev = new QKeyEvent ( QEvent::KeyRelease, 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; diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index ca35a86..b9ce4f4 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -971,64 +971,65 @@ void MonthViewCell::cellClicked( QListBoxItem *item ) mMonthView->setSelectedCell( this ); if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); select(); } void MonthViewCell::contextMenu( QListBoxItem *item ) { if ( !item ) return; MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); Incidence *incidence = eventItem->incidence(); if ( incidence ) mMonthView->showContextMenu( incidence ); } void MonthViewCell::selection( QListBoxItem *item ) { if ( !item ) return; mMonthView->setSelectedCell( this ); } // ******************************************************************************* // ******************************************************************************* // ******************************************************************************* KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) : KOEventView( calendar, parent, name ), mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) { + mFlagKeyPressed = false; mShortDayLabelsM = false; mShortDayLabelsW = false; skipResize = false; clPending = true; mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); mWidStack = new QWidgetStack( this ); QVBoxLayout* hb = new QVBoxLayout( this ); mMonthView = new QWidget( mWidStack ); mWeekView = new QWidget( mWidStack ); #if QT_VERSION >= 0x030000 mWidStack->addWidget(mMonthView ); mWidStack->addWidget(mWeekView ); #else mWidStack->addWidget( mMonthView, 1 ); mWidStack->addWidget( mWeekView , 1 ); #endif hb->addWidget( mNavigatorBar ); hb->addWidget( mWidStack ); mShowWeekView = KOPrefs::instance()->mMonthViewWeek; updatePossible = false; //updatePossible = true; mCells.setAutoDelete( true ); mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; mDayLabels.resize( mDaysPerWeek ); mDayLabelsW.resize( mDaysPerWeek ); QFont bfont = font(); if ( QApplication::desktop()->width() < 650 ) { bfont.setPointSize( bfont.pointSize() - 2 ); } bfont.setBold( true ); int i; @@ -1808,67 +1809,83 @@ void KOMonthView::setSelectedCell( MonthViewCell *cell ) if ( mSelectedCell && mSelectedCell != cell ) { MonthViewCell * mvc = mSelectedCell; mSelectedCell = cell; mvc->deselect(); } else mSelectedCell = cell; // if ( mSelectedCell ) // mSelectedCell->select(); if ( !mSelectedCell ) emit incidenceSelected( 0 ); else emit incidenceSelected( mSelectedCell->selectedIncidence() ); } void KOMonthView::processSelectionChange() { QPtrList<Incidence> incidences = selectedIncidences(); if (incidences.count() > 0) { emit incidenceSelected( incidences.first() ); } else { emit incidenceSelected( 0 ); clearSelection(); } } void KOMonthView::clearSelection() { if ( mSelectedCell ) { mSelectedCell->deselect(); mSelectedCell = 0; } } + +void KOMonthView::keyReleaseEvent ( QKeyEvent * e) +{ + if ( !e->isAutoRepeat() ) { + mFlagKeyPressed = false; + } +} + void KOMonthView::keyPressEvent ( QKeyEvent * e ) { - //qDebug("KOMonthView::keyPressEvent "); + + qApp->processEvents(); + if ( e->isAutoRepeat() && !mFlagKeyPressed ) { + //e->ignore(); + e->accept(); + return; + } + if (! e->isAutoRepeat() ) + mFlagKeyPressed = true; switch(e->key()) { case Key_Up: { if ( mShowWeekView ) { emit selectWeekNum ( currentWeek() - 1 ); } else { emit prevMonth(); } } e->accept(); break; case Key_Down: { if ( mShowWeekView ) { emit selectWeekNum ( currentWeek() +1); } else { emit nextMonth(); } } e->accept(); break; case Key_Return: case Key_Enter: { selectInternalWeekNum ( currentWeek() ); } e->accept(); break; case Key_D: diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index c1ca3d4..88050fe 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h @@ -282,39 +282,40 @@ class KOMonthView: public KOEventView private: QTimer* mComputeLayoutTimer; NavigatorBar* mNavigatorBar; int currentWeek(); bool clPending; QWidgetStack * mWidStack; QWidget* mMonthView; QWidget* mWeekView; bool mShowWeekView; bool updatePossible; int mDaysPerWeek; int mNumWeeks; int mNumCells; //bool mWeekStartsMonday; bool mShowSatSunComp; void computeLayout(); void computeLayoutWeek(); QPtrVector<MonthViewCell> mCells; QPtrVector<QLabel> mDayLabels; QPtrVector<KOWeekButton> mWeekLabels; QPtrVector<MonthViewCell> mCellsW; QPtrVector<QLabel> mDayLabelsW; QPtrVector<KOWeekButton> mWeekLabelsW; bool mShortDayLabelsM; bool mShortDayLabelsW; int mWidthLongDayLabel; QDate mStartDate; MonthViewCell *mSelectedCell; - + bool mFlagKeyPressed; KOEventPopupMenu *mContextMenu; void keyPressEvent ( QKeyEvent * ) ; + void keyReleaseEvent ( QKeyEvent * ) ; }; #endif diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index ae03a09..09a0880 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -137,100 +137,111 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : mClosed = false; //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; QString confFile = locateLocal("config","korganizerrc"); QFileInfo finf ( confFile ); bool showWarning = !finf.exists(); setIcon(SmallIcon( "ko24" ) ); mBlockAtStartup = true; mFlagKeyPressed = false; setCaption("KO/Pi"); KOPrefs *p = KOPrefs::instance(); KPimGlobalPrefs::instance()->setGlobalConfig(); if ( p->mHourSize > 22 ) p->mHourSize = 22; QMainWindow::ToolBarDock tbd; if ( p->mToolBarHor ) { if ( p->mToolBarUp ) tbd = Bottom; else tbd = Top; } else { if ( p->mToolBarUp ) tbd = Right; else tbd = Left; } if ( KOPrefs::instance()->mUseAppColors ) QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); globalFlagBlockStartup = 1; iconToolBar = new QPEToolBar( this ); addToolBar (iconToolBar , tbd ); - if ( KOPrefs::instance()->mShowIconFilter ) { +#ifdef DESKTOP_VERSION + if ( KOPrefs::instance()->mShowIconFilter ) +#else + if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar ) +#endif + +{ if ( p->mToolBarHorF ) { if ( p->mToolBarUpF ) tbd = Bottom; else tbd = Top; } else { if ( p->mToolBarUpF ) tbd = Right; else tbd = Left; } filterToolBar = new QPEToolBar ( this ); filterMenubar = new QPEMenuBar( filterToolBar ); QFontMetrics fm ( filterMenubar->font() ); filterPopupMenu = new QPopupMenu( this ); filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); QString addTest = "Ax"; #ifdef DESKTOP_VERSION addTest = "AAAx"; #endif filterMenubar->setFixedWidth( fm.width( i18n("No Filter")+addTest ) ); addToolBar (filterToolBar , tbd ); connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); + if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) + filterToolBar->hide(); } else { filterToolBar = 0; filterMenubar = 0; filterPopupMenu = 0; } if ( p->mShowIconOnetoolbar ) { viewToolBar = iconToolBar ; navigatorToolBar = iconToolBar ; } else { +#ifndef DESKTOP_VERSION + setToolBarsMovable( false ); +#endif if ( p->mToolBarHorV ) { if ( p->mToolBarUpV ) tbd = Bottom; else tbd = Top; } else { if ( p->mToolBarUpV ) tbd = Right; else tbd = Left; } viewToolBar = new QPEToolBar( this ); addToolBar (viewToolBar , tbd ); if ( p->mToolBarHorN ) { if ( p->mToolBarUpN ) tbd = Bottom; else tbd = Top; } else { if ( p->mToolBarUpN ) tbd = Right; else tbd = Left; } navigatorToolBar = new QPEToolBar( this ); addToolBar (navigatorToolBar , tbd ); } @@ -2381,32 +2392,45 @@ void MainWindow::weekAction() } } else { if ( iconToolBar->x() > width()/2 ) { // right side x=0; dX= picker->sizeHint().width()+8; y = 0; } else { x= iconToolBar->width(); y = 0; } } //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) { month = picker->getResult(); emit selectWeek ( month ); //qDebug("weekSelected %d ", month); } delete popup; } void MainWindow::hideEvent ( QHideEvent * ) { QString message; QDateTime nextA = mCalendar->nextAlarmEventDateTime(); if ( nextA.isValid() ) { QString sum = mCalendar->nextSummary(); message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false)); setCaption( message ); } } + +void MainWindow::resizeEvent( QResizeEvent* e) +{ +#ifndef DESKTOP_VERSION + if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar ) { + if (QApplication::desktop()->width() > QApplication::desktop()->height() ) + filterToolBar->hide(); + else + filterToolBar->show(); + } +#endif + QMainWindow::resizeEvent( e); +} diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 7c16aeb..4d1753f 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h @@ -104,64 +104,65 @@ class MainWindow : public QMainWindow signals: void selectWeek ( int ); private slots: void showConfigureAgenda(); void getFile( bool ); void syncFileRequest(); protected: void hideEvent ( QHideEvent * ); QString sentSyncFile(); void displayText( QString, QString); void enableIncidenceActions( bool ); private: bool mBRdisabled; #ifndef DESKTOP_VERSION QCopChannel* infrared; #endif QAction* brAction; KSyncManager* mSyncManager; bool mClosed; void saveOnClose(); bool mFlagKeyPressed; bool mBlockAtStartup; QPEToolBar *iconToolBar; QPEToolBar *viewToolBar; QPEToolBar *navigatorToolBar; QPEToolBar *filterToolBar; QPEMenuBar *filterMenubar; QPopupMenu * filterPopupMenu; void initActions(); void setDefaultPreferences(); + void resizeEvent( QResizeEvent* e); void keyPressEvent ( QKeyEvent * ) ; void keyReleaseEvent ( QKeyEvent * ) ; QPopupMenu *configureToolBarMenu; QPopupMenu *selectFilterMenu; QPopupMenu *selectFilterMenuTB; QPopupMenu *configureAgendaMenu, *syncMenu; CalendarLocal *mCalendar; CalendarView *mView; QAction *mNewSubTodoAction; QAction *mWeekAction; QFont mWeekFont; QPixmap mWeekPixmap; QColor mWeekBgColor; QAction *mShowAction; QAction *mEditAction; QAction *mDeleteAction; QAction *mCloneAction; QAction *mMoveAction; QAction *mBeamAction; QAction *mCancelAction; QAction *mToggleNav; QAction *mToggleFilter; QAction *mToggleAllday; QAction *actionFilterMenuTB; void closeEvent( QCloseEvent* ce ); SimpleAlarmClient mAlarmClient; QTimer mSaveTimer; //bool mBlockSaveFlag; bool mCalendarModifiedFlag; |