summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-03-30 23:17:42 (UTC)
committer zautrix <zautrix>2005-03-30 23:17:42 (UTC)
commit529c0fb8a8bf15e7bd375ddeb355c5802baf4c93 (patch) (unidiff)
tree72ebca6de7e54f2cf89d3d6df61d3b40aa66a444 /korganizer
parent28ac86e2efbc10f210dbd2d5ac0053f4e6198d57 (diff)
downloadkdepimpi-529c0fb8a8bf15e7bd375ddeb355c5802baf4c93.zip
kdepimpi-529c0fb8a8bf15e7bd375ddeb355c5802baf4c93.tar.gz
kdepimpi-529c0fb8a8bf15e7bd375ddeb355c5802baf4c93.tar.bz2
key fix
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp19
-rw-r--r--korganizer/komonthview.h3
-rw-r--r--korganizer/mainwindow.cpp26
-rw-r--r--korganizer/mainwindow.h1
4 files changed, 46 insertions, 3 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index ca35a86..b9ce4f4 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -811,384 +811,385 @@ void MonthViewCell::updateConfig( bool bigFont ) // = false
811 int ps = fo.pointSize() + 2; 811 int ps = fo.pointSize() + 2;
812 if ( ps < 18 ) 812 if ( ps < 18 )
813 ps += 2; 813 ps += 2;
814 fo.setPointSize( ps ); 814 fo.setPointSize( ps );
815 setFont( fo ); 815 setFont( fo );
816 } else 816 } else
817 setFont( KOPrefs::instance()->mMonthViewFont ); 817 setFont( KOPrefs::instance()->mMonthViewFont );
818 818
819 QFontMetrics fm( font() ); 819 QFontMetrics fm( font() );
820 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 820 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
821 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 821 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
822 mHolidayPalette = mStandardPalette; 822 mHolidayPalette = mStandardPalette;
823 mPrimaryPalette = mStandardPalette; 823 mPrimaryPalette = mStandardPalette;
824 mNonPrimaryPalette = mStandardPalette; 824 mNonPrimaryPalette = mStandardPalette;
825 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 825 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
826 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 826 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
827 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 827 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
828 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 828 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
829 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 829 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
830 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 830 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
831 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 831 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
832 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 832 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
833 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 833 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
834 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 834 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
835 } 835 }
836 //updateCell(); 836 //updateCell();
837} 837}
838 838
839void MonthViewCell::enableScrollBars( bool enabled ) 839void MonthViewCell::enableScrollBars( bool enabled )
840{ 840{
841 if ( enabled ) { 841 if ( enabled ) {
842 QListBoxItem *fi = firstItem (); 842 QListBoxItem *fi = firstItem ();
843 if (fi ) { 843 if (fi ) {
844 int ihei = fi->height( this ); 844 int ihei = fi->height( this );
845 int hei = numRows () * ihei; 845 int hei = numRows () * ihei;
846 if ( hei < height() - horizontalScrollBar()->height () ) { 846 if ( hei < height() - horizontalScrollBar()->height () ) {
847 setVScrollBarMode(QScrollView::AlwaysOff); 847 setVScrollBarMode(QScrollView::AlwaysOff);
848 } 848 }
849 else 849 else
850 setVScrollBarMode(QScrollView::Auto); 850 setVScrollBarMode(QScrollView::Auto);
851 if ( ihei *3 > height() ) 851 if ( ihei *3 > height() )
852 setHScrollBarMode(QScrollView::AlwaysOff); 852 setHScrollBarMode(QScrollView::AlwaysOff);
853 else 853 else
854 setHScrollBarMode(QScrollView::Auto); 854 setHScrollBarMode(QScrollView::Auto);
855 } else { 855 } else {
856 setVScrollBarMode(QScrollView::Auto); 856 setVScrollBarMode(QScrollView::Auto);
857 setHScrollBarMode(QScrollView::Auto); 857 setHScrollBarMode(QScrollView::Auto);
858 } 858 }
859 } else { 859 } else {
860 setVScrollBarMode(QScrollView::AlwaysOff); 860 setVScrollBarMode(QScrollView::AlwaysOff);
861 setHScrollBarMode(QScrollView::AlwaysOff); 861 setHScrollBarMode(QScrollView::AlwaysOff);
862 } 862 }
863} 863}
864 864
865Incidence *MonthViewCell::selectedIncidence() 865Incidence *MonthViewCell::selectedIncidence()
866{ 866{
867 int index = currentItem(); 867 int index = currentItem();
868 if ( index < 0 ) return 0; 868 if ( index < 0 ) return 0;
869 869
870 MonthViewItem *mitem = 870 MonthViewItem *mitem =
871 static_cast<MonthViewItem *>( item( index ) ); 871 static_cast<MonthViewItem *>( item( index ) );
872 872
873 if ( !mitem ) return 0; 873 if ( !mitem ) return 0;
874 874
875 return mitem->incidence(); 875 return mitem->incidence();
876} 876}
877 877
878QDate MonthViewCell::selectedIncidenceDate() 878QDate MonthViewCell::selectedIncidenceDate()
879{ 879{
880 QDate qd; 880 QDate qd;
881 int index = currentItem(); 881 int index = currentItem();
882 if ( index < 0 ) return qd; 882 if ( index < 0 ) return qd;
883 883
884 MonthViewItem *mitem = 884 MonthViewItem *mitem =
885 static_cast<MonthViewItem *>( item( index ) ); 885 static_cast<MonthViewItem *>( item( index ) );
886 886
887 if ( !mitem ) return qd; 887 if ( !mitem ) return qd;
888 888
889 return mitem->incidenceDate(); 889 return mitem->incidenceDate();
890} 890}
891 891
892void MonthViewCell::deselect() 892void MonthViewCell::deselect()
893{ 893{
894 clearSelection(); 894 clearSelection();
895 enableScrollBars( false ); 895 enableScrollBars( false );
896 // updateCell(); 896 // updateCell();
897} 897}
898void MonthViewCell::select() 898void MonthViewCell::select()
899{ 899{
900 ;// updateCell(); 900 ;// updateCell();
901} 901}
902 902
903void MonthViewCell::resizeEvent ( QResizeEvent * e ) 903void MonthViewCell::resizeEvent ( QResizeEvent * e )
904{ 904{
905 if ( !mMonthView->isUpdatePossible() ) 905 if ( !mMonthView->isUpdatePossible() )
906 return; 906 return;
907 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); 907 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height());
908 deselect(); 908 deselect();
909 mLabel->setMaximumHeight( height() - lineWidth()*2 ); 909 mLabel->setMaximumHeight( height() - lineWidth()*2 );
910 910
911 QString text; 911 QString text;
912 mLabel->setText( text ); 912 mLabel->setText( text );
913 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 913 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
914 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 914 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
915 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 915 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
916 mLabel->resize( mLabelBigSize ); 916 mLabel->resize( mLabelBigSize );
917 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 917 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
918 } else { 918 } else {
919 mLabel->resize( mLabelSize ); 919 mLabel->resize( mLabelSize );
920 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 920 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
921 } 921 }
922 mLabel->setText( text ); 922 mLabel->setText( text );
923 923
924 int size = height() - mLabel->height() - lineWidth()-1; 924 int size = height() - mLabel->height() - lineWidth()-1;
925 //qDebug("LW %d ", lineWidth()); 925 //qDebug("LW %d ", lineWidth());
926 if ( size > 0 ) 926 if ( size > 0 )
927 verticalScrollBar()->setMaximumHeight( size ); 927 verticalScrollBar()->setMaximumHeight( size );
928 size = width() - mLabel->width() -lineWidth()-1; 928 size = width() - mLabel->width() -lineWidth()-1;
929 if ( size > 0 ) 929 if ( size > 0 )
930 horizontalScrollBar()->setMaximumWidth( size ); 930 horizontalScrollBar()->setMaximumWidth( size );
931 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); 931 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() );
932 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 932 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
933 // mItemList->resize ( width(), height () ); 933 // mItemList->resize ( width(), height () );
934 if ( e ) 934 if ( e )
935 KNoScrollListBox::resizeEvent ( e ); 935 KNoScrollListBox::resizeEvent ( e );
936} 936}
937 937
938void MonthViewCell::defaultAction( QListBoxItem *item ) 938void MonthViewCell::defaultAction( QListBoxItem *item )
939{ 939{
940 if ( !item ) return; 940 if ( !item ) return;
941 941
942 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 942 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
943 Incidence *incidence = eventItem->incidence(); 943 Incidence *incidence = eventItem->incidence();
944 if ( incidence ) mMonthView->defaultAction( incidence ); 944 if ( incidence ) mMonthView->defaultAction( incidence );
945} 945}
946void MonthViewCell::showDay() 946void MonthViewCell::showDay()
947{ 947{
948 emit showDaySignal( date() ); 948 emit showDaySignal( date() );
949} 949}
950void MonthViewCell::newEvent() 950void MonthViewCell::newEvent()
951{ 951{
952 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 952 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
953 emit newEventSignal( dt ); 953 emit newEventSignal( dt );
954} 954}
955void MonthViewCell::cellClicked( QListBoxItem *item ) 955void MonthViewCell::cellClicked( QListBoxItem *item )
956{ 956{
957 static QListBoxItem * lastClicked = 0; 957 static QListBoxItem * lastClicked = 0;
958 if ( item == 0 ) { 958 if ( item == 0 ) {
959 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 959 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
960 emit newEventSignal( dt ); 960 emit newEventSignal( dt );
961 return; 961 return;
962 } 962 }
963 /* 963 /*
964 if ( lastClicked ) 964 if ( lastClicked )
965 if ( ! item ) { 965 if ( ! item ) {
966 if ( lastClicked->listBox() != item->listBox() ) 966 if ( lastClicked->listBox() != item->listBox() )
967 lastClicked->listBox()->clearSelection(); 967 lastClicked->listBox()->clearSelection();
968 } 968 }
969 */ 969 */
970 970
971 mMonthView->setSelectedCell( this ); 971 mMonthView->setSelectedCell( this );
972 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); 972 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true );
973 select(); 973 select();
974} 974}
975 975
976void MonthViewCell::contextMenu( QListBoxItem *item ) 976void MonthViewCell::contextMenu( QListBoxItem *item )
977{ 977{
978 if ( !item ) return; 978 if ( !item ) return;
979 979
980 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 980 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
981 Incidence *incidence = eventItem->incidence(); 981 Incidence *incidence = eventItem->incidence();
982 if ( incidence ) mMonthView->showContextMenu( incidence ); 982 if ( incidence ) mMonthView->showContextMenu( incidence );
983} 983}
984 984
985void MonthViewCell::selection( QListBoxItem *item ) 985void MonthViewCell::selection( QListBoxItem *item )
986{ 986{
987 if ( !item ) return; 987 if ( !item ) return;
988 988
989 mMonthView->setSelectedCell( this ); 989 mMonthView->setSelectedCell( this );
990} 990}
991 991
992 992
993// ******************************************************************************* 993// *******************************************************************************
994// ******************************************************************************* 994// *******************************************************************************
995// ******************************************************************************* 995// *******************************************************************************
996 996
997 997
998KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 998KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
999 : KOEventView( calendar, parent, name ), 999 : KOEventView( calendar, parent, name ),
1000 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 1000 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
1001 mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 1001 mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
1002{ 1002{
1003 mFlagKeyPressed = false;
1003 mShortDayLabelsM = false; 1004 mShortDayLabelsM = false;
1004 mShortDayLabelsW = false; 1005 mShortDayLabelsW = false;
1005 skipResize = false; 1006 skipResize = false;
1006 clPending = true; 1007 clPending = true;
1007 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); 1008 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" );
1008 mWidStack = new QWidgetStack( this ); 1009 mWidStack = new QWidgetStack( this );
1009 QVBoxLayout* hb = new QVBoxLayout( this ); 1010 QVBoxLayout* hb = new QVBoxLayout( this );
1010 mMonthView = new QWidget( mWidStack ); 1011 mMonthView = new QWidget( mWidStack );
1011 mWeekView = new QWidget( mWidStack ); 1012 mWeekView = new QWidget( mWidStack );
1012#if QT_VERSION >= 0x030000 1013#if QT_VERSION >= 0x030000
1013 mWidStack->addWidget(mMonthView ); 1014 mWidStack->addWidget(mMonthView );
1014 mWidStack->addWidget(mWeekView ); 1015 mWidStack->addWidget(mWeekView );
1015#else 1016#else
1016 mWidStack->addWidget( mMonthView, 1 ); 1017 mWidStack->addWidget( mMonthView, 1 );
1017 mWidStack->addWidget( mWeekView , 1 ); 1018 mWidStack->addWidget( mWeekView , 1 );
1018#endif 1019#endif
1019 hb->addWidget( mNavigatorBar ); 1020 hb->addWidget( mNavigatorBar );
1020 hb->addWidget( mWidStack ); 1021 hb->addWidget( mWidStack );
1021 mShowWeekView = KOPrefs::instance()->mMonthViewWeek; 1022 mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
1022 updatePossible = false; 1023 updatePossible = false;
1023 //updatePossible = true; 1024 //updatePossible = true;
1024 mCells.setAutoDelete( true ); 1025 mCells.setAutoDelete( true );
1025 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1026 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1026 mDayLabels.resize( mDaysPerWeek ); 1027 mDayLabels.resize( mDaysPerWeek );
1027 mDayLabelsW.resize( mDaysPerWeek ); 1028 mDayLabelsW.resize( mDaysPerWeek );
1028 QFont bfont = font(); 1029 QFont bfont = font();
1029 if ( QApplication::desktop()->width() < 650 ) { 1030 if ( QApplication::desktop()->width() < 650 ) {
1030 bfont.setPointSize( bfont.pointSize() - 2 ); 1031 bfont.setPointSize( bfont.pointSize() - 2 );
1031 } 1032 }
1032 bfont.setBold( true ); 1033 bfont.setBold( true );
1033 int i; 1034 int i;
1034 1035
1035 for( i = 0; i < mDaysPerWeek; i++ ) { 1036 for( i = 0; i < mDaysPerWeek; i++ ) {
1036 QLabel *label = new QLabel( mMonthView ); 1037 QLabel *label = new QLabel( mMonthView );
1037 label->setFont(bfont); 1038 label->setFont(bfont);
1038 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1039 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1039 label->setLineWidth(1); 1040 label->setLineWidth(1);
1040 label->setAlignment(AlignCenter); 1041 label->setAlignment(AlignCenter);
1041 mDayLabels.insert( i, label ); 1042 mDayLabels.insert( i, label );
1042 label = new QLabel( mWeekView ); 1043 label = new QLabel( mWeekView );
1043 label->setFont(bfont); 1044 label->setFont(bfont);
1044 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1045 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1045 label->setLineWidth(1); 1046 label->setLineWidth(1);
1046 label->setAlignment(AlignCenter); 1047 label->setAlignment(AlignCenter);
1047 mDayLabelsW.insert( i, label ); 1048 mDayLabelsW.insert( i, label );
1048 } 1049 }
1049 1050
1050 bfont.setBold( false ); 1051 bfont.setBold( false );
1051 mWeekLabels.resize( mNumWeeks+1 ); 1052 mWeekLabels.resize( mNumWeeks+1 );
1052 mWeekLabelsW.resize( 2 ); 1053 mWeekLabelsW.resize( 2 );
1053 for( i = 0; i < mNumWeeks+1; i++ ) { 1054 for( i = 0; i < mNumWeeks+1; i++ ) {
1054 KOWeekButton *label = new KOWeekButton( mMonthView ); 1055 KOWeekButton *label = new KOWeekButton( mMonthView );
1055 label->setFocusPolicy(NoFocus); 1056 label->setFocusPolicy(NoFocus);
1056 label->setFont(bfont); 1057 label->setFont(bfont);
1057 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1058 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1058 label->setFlat(true); 1059 label->setFlat(true);
1059 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1060 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1060 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1061 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1061 //label->setLineWidth(1); 1062 //label->setLineWidth(1);
1062 //label->setAlignment(AlignCenter); 1063 //label->setAlignment(AlignCenter);
1063 mWeekLabels.insert( i, label ); 1064 mWeekLabels.insert( i, label );
1064 } 1065 }
1065 mWeekLabels[mNumWeeks]->setText( i18n("W")); 1066 mWeekLabels[mNumWeeks]->setText( i18n("W"));
1066 mWeekLabels[0]->setFocusPolicy(WheelFocus); 1067 mWeekLabels[0]->setFocusPolicy(WheelFocus);
1067 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); 1068 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));
1068 1069
1069 for( i = 0; i < 1+1; i++ ) { 1070 for( i = 0; i < 1+1; i++ ) {
1070 KOWeekButton *label = new KOWeekButton( mWeekView ); 1071 KOWeekButton *label = new KOWeekButton( mWeekView );
1071 label->setFocusPolicy(NoFocus); 1072 label->setFocusPolicy(NoFocus);
1072 label->setFont(bfont); 1073 label->setFont(bfont);
1073 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1074 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1074 label->setFlat(true); 1075 label->setFlat(true);
1075 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1076 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1076 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1077 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1077 //label->setLineWidth(1); 1078 //label->setLineWidth(1);
1078 //label->setAlignment(AlignCenter); 1079 //label->setAlignment(AlignCenter);
1079 mWeekLabelsW.insert( i, label ); 1080 mWeekLabelsW.insert( i, label );
1080 } 1081 }
1081 mWeekLabelsW[1]->setText( i18n("W")); 1082 mWeekLabelsW[1]->setText( i18n("W"));
1082 mWeekLabelsW[0]->setFocusPolicy(WheelFocus); 1083 mWeekLabelsW[0]->setFocusPolicy(WheelFocus);
1083 1084
1084 1085
1085 int row, col; 1086 int row, col;
1086 mCells.resize( mNumCells ); 1087 mCells.resize( mNumCells );
1087 for( row = 0; row < mNumWeeks; ++row ) { 1088 for( row = 0; row < mNumWeeks; ++row ) {
1088 for( col = 0; col < mDaysPerWeek; ++col ) { 1089 for( col = 0; col < mDaysPerWeek; ++col ) {
1089 MonthViewCell *cell = new MonthViewCell( this, mMonthView ); 1090 MonthViewCell *cell = new MonthViewCell( this, mMonthView );
1090 mCells.insert( row * mDaysPerWeek + col, cell ); 1091 mCells.insert( row * mDaysPerWeek + col, cell );
1091 1092
1092 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1093 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1093 SLOT( defaultAction( Incidence * ) ) ); 1094 SLOT( defaultAction( Incidence * ) ) );
1094 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1095 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
1095 SIGNAL( newEventSignal( QDateTime ) ) ); 1096 SIGNAL( newEventSignal( QDateTime ) ) );
1096 connect( cell, SIGNAL( showDaySignal( QDate ) ), 1097 connect( cell, SIGNAL( showDaySignal( QDate ) ),
1097 SIGNAL( showDaySignal( QDate ) ) ); 1098 SIGNAL( showDaySignal( QDate ) ) );
1098 } 1099 }
1099 } 1100 }
1100 mCellsW.resize( mDaysPerWeek ); 1101 mCellsW.resize( mDaysPerWeek );
1101 for( col = 0; col < mDaysPerWeek; ++col ) { 1102 for( col = 0; col < mDaysPerWeek; ++col ) {
1102 MonthViewCell *cell = new MonthViewCell( this, mWeekView ); 1103 MonthViewCell *cell = new MonthViewCell( this, mWeekView );
1103 mCellsW.insert( col, cell ); 1104 mCellsW.insert( col, cell );
1104 1105
1105 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1106 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1106 SLOT( defaultAction( Incidence * ) ) ); 1107 SLOT( defaultAction( Incidence * ) ) );
1107 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1108 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
1108 SIGNAL( newEventSignal( QDateTime ) ) ); 1109 SIGNAL( newEventSignal( QDateTime ) ) );
1109 connect( cell, SIGNAL( showDaySignal( QDate ) ), 1110 connect( cell, SIGNAL( showDaySignal( QDate ) ),
1110 SIGNAL( showDaySignal( QDate ) ) ); 1111 SIGNAL( showDaySignal( QDate ) ) );
1111 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); 1112 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont );
1112 } 1113 }
1113 1114
1114 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); 1115 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
1115 mContextMenu = eventPopup(); 1116 mContextMenu = eventPopup();
1116 // updateConfig(); //useless here... 1117 // updateConfig(); //useless here...
1117 // ... but we need mWidthLongDayLabel computed 1118 // ... but we need mWidthLongDayLabel computed
1118 QFontMetrics fontmetric(mDayLabels[0]->font()); 1119 QFontMetrics fontmetric(mDayLabels[0]->font());
1119 mWidthLongDayLabel = 0; 1120 mWidthLongDayLabel = 0;
1120 for (int i = 0; i < 7; i++) { 1121 for (int i = 0; i < 7; i++) {
1121 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1122 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1122 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1123 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1123 } 1124 }
1124 1125
1125 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1126 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1126 1127
1127#if 0 1128#if 0
1128 if ( mShowWeekView ) 1129 if ( mShowWeekView )
1129 mWidStack->raiseWidget( mWeekView ); 1130 mWidStack->raiseWidget( mWeekView );
1130 else 1131 else
1131 mWidStack->raiseWidget( mMonthView ); 1132 mWidStack->raiseWidget( mMonthView );
1132#endif 1133#endif
1133 1134
1134 emit incidenceSelected( 0 ); 1135 emit incidenceSelected( 0 );
1135 1136
1136 mComputeLayoutTimer = new QTimer( this ); 1137 mComputeLayoutTimer = new QTimer( this );
1137 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); 1138 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout()));
1138 1139
1139 1140
1140#ifndef DESKTOP_VERSION 1141#ifndef DESKTOP_VERSION
1141 resize( QApplication::desktop()->size() ); 1142 resize( QApplication::desktop()->size() );
1142#else 1143#else
1143 resize(640, 480 ); 1144 resize(640, 480 );
1144 updatePossible = true; 1145 updatePossible = true;
1145#endif 1146#endif
1146 computeLayout(); 1147 computeLayout();
1147 1148
1148 if ( mShowWeekView ) 1149 if ( mShowWeekView )
1149 mWidStack->raiseWidget( mWeekView ); 1150 mWidStack->raiseWidget( mWeekView );
1150 else 1151 else
1151 mWidStack->raiseWidget( mMonthView ); 1152 mWidStack->raiseWidget( mMonthView );
1152} 1153}
1153 1154
1154KOMonthView::~KOMonthView() 1155KOMonthView::~KOMonthView()
1155{ 1156{
1156 delete mContextMenu; 1157 delete mContextMenu;
1157} 1158}
1158 1159
1159void KOMonthView::selectInternalWeekNum ( int n ) 1160void KOMonthView::selectInternalWeekNum ( int n )
1160{ 1161{
1161 switchView(); 1162 switchView();
1162 if ( !KOPrefs::instance()->mMonthViewWeek ) 1163 if ( !KOPrefs::instance()->mMonthViewWeek )
1163 emit selectMonth (); 1164 emit selectMonth ();
1164 else 1165 else
1165 emit selectWeekNum ( n ); 1166 emit selectWeekNum ( n );
1166} 1167}
1167 1168
1168int KOMonthView::currentWeek() 1169int KOMonthView::currentWeek()
1169{ 1170{
1170 if ( mShowWeekView ) 1171 if ( mShowWeekView )
1171 return mWeekLabelsW[0]->getWeekNum(); 1172 return mWeekLabelsW[0]->getWeekNum();
1172 return mWeekLabels[0]->getWeekNum(); 1173 return mWeekLabels[0]->getWeekNum();
1173} 1174}
1174void KOMonthView::switchView() 1175void KOMonthView::switchView()
1175{ 1176{
1176 if ( selectedCell( ) ) 1177 if ( selectedCell( ) )
1177 selectedCell()->deselect(); 1178 selectedCell()->deselect();
1178 mShowWeekView = !mShowWeekView; 1179 mShowWeekView = !mShowWeekView;
1179 KOPrefs::instance()->mMonthViewWeek = mShowWeekView; 1180 KOPrefs::instance()->mMonthViewWeek = mShowWeekView;
1180 if ( clPending ) { 1181 if ( clPending ) {
1181 computeLayout(); 1182 computeLayout();
1182 updateConfig(); 1183 updateConfig();
1183 } 1184 }
1184 if ( mShowWeekView ) 1185 if ( mShowWeekView )
1185 mWidStack->raiseWidget( mWeekView ); 1186 mWidStack->raiseWidget( mWeekView );
1186 else 1187 else
1187 mWidStack->raiseWidget( mMonthView ); 1188 mWidStack->raiseWidget( mMonthView );
1188 clPending = false; 1189 clPending = false;
1189} 1190}
1190 1191
1191int KOMonthView::maxDatesHint() 1192int KOMonthView::maxDatesHint()
1192{ 1193{
1193 return mNumCells; 1194 return mNumCells;
1194} 1195}
@@ -1648,239 +1649,255 @@ void KOMonthView::computeLayoutWeek()
1648 } 1649 }
1649 //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); 1650 //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 );
1650 } 1651 }
1651 y= dayLabelHei; 1652 y= dayLabelHei;
1652 h = cellHei ; 1653 h = cellHei ;
1653 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); 1654 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei);
1654 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1655 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1655 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1656 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1656 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1657 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1657 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; 1658 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ;
1658 updateDayLabels(); 1659 updateDayLabels();
1659 //bool forceUpdate = !updatePossible; 1660 //bool forceUpdate = !updatePossible;
1660 updatePossible = true; 1661 updatePossible = true;
1661 //mWeekLabels[mNumWeeks]->setText( i18n("M")); 1662 //mWeekLabels[mNumWeeks]->setText( i18n("M"));
1662 //if ( forceUpdate ) 1663 //if ( forceUpdate )
1663 // updateView(); 1664 // updateView();
1664} 1665}
1665void KOMonthView::computeLayout() 1666void KOMonthView::computeLayout()
1666{ 1667{
1667 1668
1668 1669
1669 static int lastWid = 0; 1670 static int lastWid = 0;
1670 static int lastHei = 0; 1671 static int lastHei = 0;
1671 1672
1672 if ( mShowWeekView ){ 1673 if ( mShowWeekView ){
1673 computeLayoutWeek(); 1674 computeLayoutWeek();
1674 return; 1675 return;
1675 } 1676 }
1676 int daysToShow = 7; 1677 int daysToShow = 7;
1677 bool combinedSatSun = false; 1678 bool combinedSatSun = false;
1678 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1679 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1679 daysToShow = 6; 1680 daysToShow = 6;
1680 combinedSatSun = true; 1681 combinedSatSun = true;
1681 } 1682 }
1682 int tWid = topLevelWidget()->size().width(); 1683 int tWid = topLevelWidget()->size().width();
1683 int tHei = topLevelWidget()->size().height(); 1684 int tHei = topLevelWidget()->size().height();
1684 1685
1685 int wid = width();//e 1686 int wid = width();//e
1686 int hei = height()-1-mNavigatorBar->height(); 1687 int hei = height()-1-mNavigatorBar->height();
1687 1688
1688 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { 1689 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) {
1689 return; 1690 return;
1690 } 1691 }
1691 if ( lastWid == width() && lastHei == height() ){ 1692 if ( lastWid == width() && lastHei == height() ){
1692 //qDebug("KOMonthview::No compute layout needed "); 1693 //qDebug("KOMonthview::No compute layout needed ");
1693 return; 1694 return;
1694 } 1695 }
1695 1696
1696 lastWid = width(); 1697 lastWid = width();
1697 lastHei = height(); 1698 lastHei = height();
1698 //qDebug("KOMonthView::computeLayout() MMM ------------------- "); 1699 //qDebug("KOMonthView::computeLayout() MMM ------------------- ");
1699 QFontMetrics fm ( mWeekLabels[0]->font() ); 1700 QFontMetrics fm ( mWeekLabels[0]->font() );
1700 int weeklabelwid = fm.width( "888" ); 1701 int weeklabelwid = fm.width( "888" );
1701 wid -= weeklabelwid; 1702 wid -= weeklabelwid;
1702 1703
1703 int colWid = wid / daysToShow; 1704 int colWid = wid / daysToShow;
1704 int lastCol = wid - ( colWid*6 ); 1705 int lastCol = wid - ( colWid*6 );
1705 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 1706 int dayLabelHei = mDayLabels[0]->sizeHint().height();
1706 int cellHei = (hei - dayLabelHei) /6; 1707 int cellHei = (hei - dayLabelHei) /6;
1707 int colModulo = wid % daysToShow; 1708 int colModulo = wid % daysToShow;
1708 int rowModulo = (hei- dayLabelHei) % 6; 1709 int rowModulo = (hei- dayLabelHei) % 6;
1709 //qDebug("rowmod %d ", rowModulo); 1710 //qDebug("rowmod %d ", rowModulo);
1710 int i; 1711 int i;
1711 int x,y,w,h; 1712 int x,y,w,h;
1712 x= 0; 1713 x= 0;
1713 y= 0; 1714 y= 0;
1714 w = colWid; 1715 w = colWid;
1715 h = dayLabelHei ; 1716 h = dayLabelHei ;
1716 for ( i = 0; i < 7; i++) { 1717 for ( i = 0; i < 7; i++) {
1717 if ( i == daysToShow-colModulo ) 1718 if ( i == daysToShow-colModulo )
1718 ++w; 1719 ++w;
1719 if ( combinedSatSun ) { 1720 if ( combinedSatSun ) {
1720 if ( i >= daysToShow-1 ) { 1721 if ( i >= daysToShow-1 ) {
1721 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 1722 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
1722 x -= w/2 ; 1723 x -= w/2 ;
1723 } 1724 }
1724 else 1725 else
1725 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1726 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1726 } else 1727 } else
1727 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1728 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1728 x += w; 1729 x += w;
1729 } 1730 }
1730 x= 0; 1731 x= 0;
1731 y= dayLabelHei; 1732 y= dayLabelHei;
1732 w = colWid; 1733 w = colWid;
1733 h = cellHei ; 1734 h = cellHei ;
1734 int max = 0; 1735 int max = 0;
1735 for ( i = 0; i < mCells.count(); ++i) { 1736 for ( i = 0; i < mCells.count(); ++i) {
1736 //qDebug("iii %d ", i); 1737 //qDebug("iii %d ", i);
1737 w = colWid; 1738 w = colWid;
1738 if ( ((i) % 7) >= 7-colModulo ) { 1739 if ( ((i) % 7) >= 7-colModulo ) {
1739 ++w; 1740 ++w;
1740 } 1741 }
1741 if ( i == (6-rowModulo)*7) 1742 if ( i == (6-rowModulo)*7)
1742 ++h; 1743 ++h;
1743 if ( combinedSatSun ) { 1744 if ( combinedSatSun ) {
1744 if ( (i)%7 >= daysToShow-1 ) { 1745 if ( (i)%7 >= daysToShow-1 ) {
1745 if ( (i)%7 == daysToShow-1 ) { 1746 if ( (i)%7 == daysToShow-1 ) {
1746 max = h/2; 1747 max = h/2;
1747 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1748 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max );
1748 x -= w ;y += h/2; 1749 x -= w ;y += h/2;
1749 } else { 1750 } else {
1750 max = h-h/2; 1751 max = h-h/2;
1751 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1752 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max );
1752 y -= h/2; 1753 y -= h/2;
1753 } 1754 }
1754 } else { 1755 } else {
1755 max = h; 1756 max = h;
1756 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1757 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1757 } 1758 }
1758 1759
1759 } 1760 }
1760 else { 1761 else {
1761 max = h; 1762 max = h;
1762 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1763 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1763 } 1764 }
1764 x += w; 1765 x += w;
1765 if ( x + w/2 > wid ) { 1766 if ( x + w/2 > wid ) {
1766 x = 0; 1767 x = 0;
1767 y += h; 1768 y += h;
1768 } 1769 }
1769 //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); 1770 //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 );
1770 } 1771 }
1771 y= dayLabelHei; 1772 y= dayLabelHei;
1772 h = cellHei ; 1773 h = cellHei ;
1773 for ( i = 0; i < 6; i++) { 1774 for ( i = 0; i < 6; i++) {
1774 if ( i == (6-rowModulo)) 1775 if ( i == (6-rowModulo))
1775 ++h; 1776 ++h;
1776 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); 1777 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
1777 y += h; 1778 y += h;
1778 } 1779 }
1779 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1780 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1780 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1781 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1781 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1782 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1782 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; 1783 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ;
1783 updateDayLabels(); 1784 updateDayLabels();
1784 //bool forceUpdate = !updatePossible; 1785 //bool forceUpdate = !updatePossible;
1785 updatePossible = true; 1786 updatePossible = true;
1786 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1787 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1787} 1788}
1788 1789
1789void KOMonthView::showContextMenu( Incidence *incidence ) 1790void KOMonthView::showContextMenu( Incidence *incidence )
1790{ 1791{
1791 mContextMenu->showIncidencePopup(incidence); 1792 mContextMenu->showIncidencePopup(incidence);
1792 /* 1793 /*
1793 if( incidence && incidence->type() == "Event" ) { 1794 if( incidence && incidence->type() == "Event" ) {
1794 Event *event = static_cast<Event *>(incidence); 1795 Event *event = static_cast<Event *>(incidence);
1795 mContextMenu->showEventPopup(event); 1796 mContextMenu->showEventPopup(event);
1796 } else { 1797 } else {
1797 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; 1798 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
1798 } 1799 }
1799 */ 1800 */
1800} 1801}
1801MonthViewCell * KOMonthView::selectedCell( ) 1802MonthViewCell * KOMonthView::selectedCell( )
1802{ 1803{
1803 return mSelectedCell; 1804 return mSelectedCell;
1804} 1805}
1805void KOMonthView::setSelectedCell( MonthViewCell *cell ) 1806void KOMonthView::setSelectedCell( MonthViewCell *cell )
1806{ 1807{
1807 //qDebug("KOMonthView::setSelectedCell "); 1808 //qDebug("KOMonthView::setSelectedCell ");
1808 if ( mSelectedCell && mSelectedCell != cell ) { 1809 if ( mSelectedCell && mSelectedCell != cell ) {
1809 MonthViewCell * mvc = mSelectedCell; 1810 MonthViewCell * mvc = mSelectedCell;
1810 mSelectedCell = cell; 1811 mSelectedCell = cell;
1811 mvc->deselect(); 1812 mvc->deselect();
1812 } else 1813 } else
1813 mSelectedCell = cell; 1814 mSelectedCell = cell;
1814 // if ( mSelectedCell ) 1815 // if ( mSelectedCell )
1815 // mSelectedCell->select(); 1816 // mSelectedCell->select();
1816 if ( !mSelectedCell ) 1817 if ( !mSelectedCell )
1817 emit incidenceSelected( 0 ); 1818 emit incidenceSelected( 0 );
1818 else 1819 else
1819 emit incidenceSelected( mSelectedCell->selectedIncidence() ); 1820 emit incidenceSelected( mSelectedCell->selectedIncidence() );
1820} 1821}
1821 1822
1822void KOMonthView::processSelectionChange() 1823void KOMonthView::processSelectionChange()
1823{ 1824{
1824 QPtrList<Incidence> incidences = selectedIncidences(); 1825 QPtrList<Incidence> incidences = selectedIncidences();
1825 if (incidences.count() > 0) { 1826 if (incidences.count() > 0) {
1826 emit incidenceSelected( incidences.first() ); 1827 emit incidenceSelected( incidences.first() );
1827 } else { 1828 } else {
1828 emit incidenceSelected( 0 ); 1829 emit incidenceSelected( 0 );
1829 clearSelection(); 1830 clearSelection();
1830 } 1831 }
1831} 1832}
1832 1833
1833void KOMonthView::clearSelection() 1834void KOMonthView::clearSelection()
1834{ 1835{
1835 if ( mSelectedCell ) { 1836 if ( mSelectedCell ) {
1836 mSelectedCell->deselect(); 1837 mSelectedCell->deselect();
1837 mSelectedCell = 0; 1838 mSelectedCell = 0;
1838 } 1839 }
1839} 1840}
1841
1842void KOMonthView::keyReleaseEvent ( QKeyEvent * e)
1843{
1844 if ( !e->isAutoRepeat() ) {
1845 mFlagKeyPressed = false;
1846 }
1847}
1848
1840void KOMonthView::keyPressEvent ( QKeyEvent * e ) 1849void KOMonthView::keyPressEvent ( QKeyEvent * e )
1841{ 1850{
1842 //qDebug("KOMonthView::keyPressEvent "); 1851
1852 qApp->processEvents();
1853 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1854 //e->ignore();
1855 e->accept();
1856 return;
1857 }
1858 if (! e->isAutoRepeat() )
1859 mFlagKeyPressed = true;
1843 switch(e->key()) { 1860 switch(e->key()) {
1844 case Key_Up: 1861 case Key_Up:
1845 { 1862 {
1846 if ( mShowWeekView ) { 1863 if ( mShowWeekView ) {
1847 emit selectWeekNum ( currentWeek() - 1 ); 1864 emit selectWeekNum ( currentWeek() - 1 );
1848 } 1865 }
1849 else { 1866 else {
1850 emit prevMonth(); 1867 emit prevMonth();
1851 } 1868 }
1852 } 1869 }
1853 e->accept(); 1870 e->accept();
1854 break; 1871 break;
1855 case Key_Down: 1872 case Key_Down:
1856 { 1873 {
1857 if ( mShowWeekView ) { 1874 if ( mShowWeekView ) {
1858 emit selectWeekNum ( currentWeek() +1); 1875 emit selectWeekNum ( currentWeek() +1);
1859 } 1876 }
1860 else { 1877 else {
1861 emit nextMonth(); 1878 emit nextMonth();
1862 } 1879 }
1863 1880
1864 } 1881 }
1865 e->accept(); 1882 e->accept();
1866 break; 1883 break;
1867 case Key_Return: 1884 case Key_Return:
1868 case Key_Enter: 1885 case Key_Enter:
1869 { 1886 {
1870 selectInternalWeekNum ( currentWeek() ); 1887 selectInternalWeekNum ( currentWeek() );
1871 } 1888 }
1872 e->accept(); 1889 e->accept();
1873 break; 1890 break;
1874 case Key_D: 1891 case Key_D:
1875 if ( mSelectedCell ) { 1892 if ( mSelectedCell ) {
1876 mSelectedCell->showDay(); 1893 mSelectedCell->showDay();
1877 e->accept(); 1894 e->accept();
1878 } else { 1895 } else {
1879 e->ignore(); 1896 e->ignore();
1880 } 1897 }
1881 break; 1898 break;
1882 default: 1899 default:
1883 e->ignore(); 1900 e->ignore();
1884 break; 1901 break;
1885 } 1902 }
1886} 1903}
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index c1ca3d4..88050fe 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -122,199 +122,200 @@ class MonthViewItem: public QListBoxItem
122 bool mblockRepaint; 122 bool mblockRepaint;
123 int mMultiday; 123 int mMultiday;
124 bool mRecur; 124 bool mRecur;
125 bool mAlarm; 125 bool mAlarm;
126 bool mReply; 126 bool mReply;
127 bool mInfo; 127 bool mInfo;
128 128
129 QPalette mPalette; 129 QPalette mPalette;
130 QDate mDate; 130 QDate mDate;
131 131
132 Incidence *mIncidence; 132 Incidence *mIncidence;
133}; 133};
134 134
135 135
136class KOMonthView; 136class KOMonthView;
137 137
138class MonthViewCell : public KNoScrollListBox 138class MonthViewCell : public KNoScrollListBox
139{ 139{
140 Q_OBJECT 140 Q_OBJECT
141 public: 141 public:
142 MonthViewCell(KOMonthView *,QWidget* ); 142 MonthViewCell(KOMonthView *,QWidget* );
143 ~MonthViewCell() {mAvailItemList.setAutoDelete( true );} 143 ~MonthViewCell() {mAvailItemList.setAutoDelete( true );}
144 144
145 void setDate( const QDate & ); 145 void setDate( const QDate & );
146 QDate date() const; 146 QDate date() const;
147 147
148 void setPrimary( bool ); 148 void setPrimary( bool );
149 bool isPrimary() const; 149 bool isPrimary() const;
150 150
151 void setHoliday( bool ); 151 void setHoliday( bool );
152 void setHoliday( const QString & ); 152 void setHoliday( const QString & );
153 153
154 void updateCell(); 154 void updateCell();
155 void startUpdateCell(); 155 void startUpdateCell();
156 void finishUpdateCell(); 156 void finishUpdateCell();
157 void repaintfinishUpdateCell(); 157 void repaintfinishUpdateCell();
158 void insertEvent(Event *); 158 void insertEvent(Event *);
159 void insertTodo(Todo *); 159 void insertTodo(Todo *);
160 160
161 void updateConfig( bool bigFont = false ); 161 void updateConfig( bool bigFont = false );
162 162
163 void enableScrollBars( bool ); 163 void enableScrollBars( bool );
164 164
165 Incidence *selectedIncidence(); 165 Incidence *selectedIncidence();
166 QDate selectedIncidenceDate(); 166 QDate selectedIncidenceDate();
167 QPushButton * dateLabel() { return mLabel; } 167 QPushButton * dateLabel() { return mLabel; }
168 168
169 void deselect(); 169 void deselect();
170 void select(); 170 void select();
171#ifdef DESKTOP_VERSION 171#ifdef DESKTOP_VERSION
172 static QToolTipGroup *toolTipGroup(); 172 static QToolTipGroup *toolTipGroup();
173#endif 173#endif
174 signals: 174 signals:
175 void defaultAction( Incidence * ); 175 void defaultAction( Incidence * );
176 void newEventSignal( QDateTime ); 176 void newEventSignal( QDateTime );
177 void showDaySignal( QDate ); 177 void showDaySignal( QDate );
178 178
179 protected: 179 protected:
180 QStringList mToolTip; 180 QStringList mToolTip;
181 void resizeEvent( QResizeEvent * ); 181 void resizeEvent( QResizeEvent * );
182 182
183 183
184public slots: 184public slots:
185 void showDay(); 185 void showDay();
186 186
187 protected slots: 187 protected slots:
188 void defaultAction( QListBoxItem * ); 188 void defaultAction( QListBoxItem * );
189 void contextMenu( QListBoxItem * ); 189 void contextMenu( QListBoxItem * );
190 void selection( QListBoxItem * ); 190 void selection( QListBoxItem * );
191 void cellClicked( QListBoxItem * ); 191 void cellClicked( QListBoxItem * );
192 void newEvent(); 192 void newEvent();
193 193
194 private: 194 private:
195 MonthViewItem* mCurrentAvailItem; 195 MonthViewItem* mCurrentAvailItem;
196 QPtrList <MonthViewItem> mAvailItemList; 196 QPtrList <MonthViewItem> mAvailItemList;
197 KOMonthView *mMonthView; 197 KOMonthView *mMonthView;
198 int currentPalette; 198 int currentPalette;
199 199
200 QDate mDate; 200 QDate mDate;
201 bool mPrimary; 201 bool mPrimary;
202 bool mHoliday; 202 bool mHoliday;
203 QString mHolidayString; 203 QString mHolidayString;
204 204
205 //QLabel *mLabel; 205 //QLabel *mLabel;
206 QPushButton *mLabel; 206 QPushButton *mLabel;
207 //QListBox *mItemList; 207 //QListBox *mItemList;
208#ifdef DESKTOP_VERSION 208#ifdef DESKTOP_VERSION
209 static QToolTipGroup *mToolTipGroup; 209 static QToolTipGroup *mToolTipGroup;
210#endif 210#endif
211 QSize mLabelSize; 211 QSize mLabelSize;
212 QSize mLabelBigSize; 212 QSize mLabelBigSize;
213 QPalette mHolidayPalette; 213 QPalette mHolidayPalette;
214 QPalette mStandardPalette; 214 QPalette mStandardPalette;
215 QPalette mPrimaryPalette; 215 QPalette mPrimaryPalette;
216 QPalette mNonPrimaryPalette; 216 QPalette mNonPrimaryPalette;
217 void setMyPalette(); 217 void setMyPalette();
218 QPalette getPalette (); 218 QPalette getPalette ();
219 219
220}; 220};
221 221
222 222
223class KOMonthView: public KOEventView 223class KOMonthView: public KOEventView
224{ 224{
225 Q_OBJECT 225 Q_OBJECT
226 public: 226 public:
227 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); 227 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
228 ~KOMonthView(); 228 ~KOMonthView();
229 229
230 /** Returns maximum number of days supported by the komonthview */ 230 /** Returns maximum number of days supported by the komonthview */
231 virtual int maxDatesHint(); 231 virtual int maxDatesHint();
232 232
233 /** Returns number of currently shown dates. */ 233 /** Returns number of currently shown dates. */
234 virtual int currentDateCount(); 234 virtual int currentDateCount();
235 235
236 /** returns the currently selected events */ 236 /** returns the currently selected events */
237 virtual QPtrList<Incidence> selectedIncidences(); 237 virtual QPtrList<Incidence> selectedIncidences();
238 238
239 /** returns dates of the currently selected events */ 239 /** returns dates of the currently selected events */
240 virtual DateList selectedDates(); 240 virtual DateList selectedDates();
241 241
242 virtual void printPreview(CalPrinter *calPrinter, 242 virtual void printPreview(CalPrinter *calPrinter,
243 const QDate &, const QDate &); 243 const QDate &, const QDate &);
244 bool isMonthView() { return !mShowWeekView; } 244 bool isMonthView() { return !mShowWeekView; }
245 bool isUpdatePossible() { return updatePossible; } 245 bool isUpdatePossible() { return updatePossible; }
246 246
247 MonthViewCell * selectedCell(); 247 MonthViewCell * selectedCell();
248 bool skipResize; 248 bool skipResize;
249 NavigatorBar* navigatorBar() { return mNavigatorBar ;} 249 NavigatorBar* navigatorBar() { return mNavigatorBar ;}
250 public slots: 250 public slots:
251 virtual void updateView(); 251 virtual void updateView();
252 virtual void updateConfig(); 252 virtual void updateConfig();
253 virtual void showDates(const QDate &start, const QDate &end); 253 virtual void showDates(const QDate &start, const QDate &end);
254 virtual void showEvents(QPtrList<Event> eventList); 254 virtual void showEvents(QPtrList<Event> eventList);
255 255
256 void changeEventDisplay(Event *, int); 256 void changeEventDisplay(Event *, int);
257 257
258 void clearSelection(); 258 void clearSelection();
259 259
260 void showContextMenu( Incidence * ); 260 void showContextMenu( Incidence * );
261 261
262 void setSelectedCell( MonthViewCell * ); 262 void setSelectedCell( MonthViewCell * );
263 void switchView(); 263 void switchView();
264 void setKeyBoardFocus(); 264 void setKeyBoardFocus();
265 void setKeyBFocus(); 265 void setKeyBFocus();
266 266
267 protected slots: 267 protected slots:
268 void slotComputeLayout(); 268 void slotComputeLayout();
269 void selectInternalWeekNum ( int ); 269 void selectInternalWeekNum ( int );
270 void processSelectionChange(); 270 void processSelectionChange();
271 signals: 271 signals:
272 void nextMonth(); 272 void nextMonth();
273 void prevMonth(); 273 void prevMonth();
274 void selectWeekNum ( int ); 274 void selectWeekNum ( int );
275 void selectMonth (); 275 void selectMonth ();
276 void showDaySignal( QDate ); 276 void showDaySignal( QDate );
277 protected: 277 protected:
278 void resizeEvent(QResizeEvent *); 278 void resizeEvent(QResizeEvent *);
279 void viewChanged(); 279 void viewChanged();
280 void updateDayLabels(); 280 void updateDayLabels();
281 281
282 private: 282 private:
283 QTimer* mComputeLayoutTimer; 283 QTimer* mComputeLayoutTimer;
284 NavigatorBar* mNavigatorBar; 284 NavigatorBar* mNavigatorBar;
285 int currentWeek(); 285 int currentWeek();
286 bool clPending; 286 bool clPending;
287 QWidgetStack * mWidStack; 287 QWidgetStack * mWidStack;
288 QWidget* mMonthView; 288 QWidget* mMonthView;
289 QWidget* mWeekView; 289 QWidget* mWeekView;
290 bool mShowWeekView; 290 bool mShowWeekView;
291 bool updatePossible; 291 bool updatePossible;
292 int mDaysPerWeek; 292 int mDaysPerWeek;
293 int mNumWeeks; 293 int mNumWeeks;
294 int mNumCells; 294 int mNumCells;
295 //bool mWeekStartsMonday; 295 //bool mWeekStartsMonday;
296 bool mShowSatSunComp; 296 bool mShowSatSunComp;
297 void computeLayout(); 297 void computeLayout();
298 void computeLayoutWeek(); 298 void computeLayoutWeek();
299 299
300 QPtrVector<MonthViewCell> mCells; 300 QPtrVector<MonthViewCell> mCells;
301 QPtrVector<QLabel> mDayLabels; 301 QPtrVector<QLabel> mDayLabels;
302 QPtrVector<KOWeekButton> mWeekLabels; 302 QPtrVector<KOWeekButton> mWeekLabels;
303 QPtrVector<MonthViewCell> mCellsW; 303 QPtrVector<MonthViewCell> mCellsW;
304 QPtrVector<QLabel> mDayLabelsW; 304 QPtrVector<QLabel> mDayLabelsW;
305 QPtrVector<KOWeekButton> mWeekLabelsW; 305 QPtrVector<KOWeekButton> mWeekLabelsW;
306 306
307 bool mShortDayLabelsM; 307 bool mShortDayLabelsM;
308 bool mShortDayLabelsW; 308 bool mShortDayLabelsW;
309 int mWidthLongDayLabel; 309 int mWidthLongDayLabel;
310 310
311 QDate mStartDate; 311 QDate mStartDate;
312 312
313 MonthViewCell *mSelectedCell; 313 MonthViewCell *mSelectedCell;
314 314 bool mFlagKeyPressed;
315 KOEventPopupMenu *mContextMenu; 315 KOEventPopupMenu *mContextMenu;
316 void keyPressEvent ( QKeyEvent * ) ; 316 void keyPressEvent ( QKeyEvent * ) ;
317 void keyReleaseEvent ( QKeyEvent * ) ;
317 318
318}; 319};
319 320
320#endif 321#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index ae03a09..09a0880 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,396 +1,407 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qpushbutton.h> 7#include <qpushbutton.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qtextcodec.h> 10#include <qtextcodec.h>
11#include <qfile.h> 11#include <qfile.h>
12#include <qdir.h> 12#include <qdir.h>
13#include <qapp.h> 13#include <qapp.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qspinbox.h> 16#include <qspinbox.h>
17#include <qcheckbox.h> 17#include <qcheckbox.h>
18#include <qmap.h> 18#include <qmap.h>
19#include <qwmatrix.h> 19#include <qwmatrix.h>
20#include <qtextbrowser.h> 20#include <qtextbrowser.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qtopia/alarmserver.h> 28#include <qtopia/alarmserver.h>
29#include <qtopia/qcopenvelope_qws.h> 29#include <qtopia/qcopenvelope_qws.h>
30#include <unistd.h> // for sleep 30#include <unistd.h> // for sleep
31#else 31#else
32#include <qmenubar.h> 32#include <qmenubar.h>
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#include <qapplication.h> 34#include <qapplication.h>
35//#include <resource.h> 35//#include <resource.h>
36 36
37#endif 37#endif
38#include <libkcal/calendarlocal.h> 38#include <libkcal/calendarlocal.h>
39#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40#include <libkcal/phoneformat.h> 40#include <libkcal/phoneformat.h>
41#include <libkdepim/ksyncprofile.h> 41#include <libkdepim/ksyncprofile.h>
42#include <libkdepim/phoneaccess.h> 42#include <libkdepim/phoneaccess.h>
43#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "calendarview.h" 46#include "calendarview.h"
47#include "koviewmanager.h" 47#include "koviewmanager.h"
48#include "datenavigator.h" 48#include "datenavigator.h"
49#include "koagendaview.h" 49#include "koagendaview.h"
50#include "koagenda.h" 50#include "koagenda.h"
51#include "kodialogmanager.h" 51#include "kodialogmanager.h"
52#include "kdialogbase.h" 52#include "kdialogbase.h"
53#include "kapplication.h" 53#include "kapplication.h"
54#include "kofilterview.h" 54#include "kofilterview.h"
55#include "kstandarddirs.h" 55#include "kstandarddirs.h"
56#include "koprefs.h" 56#include "koprefs.h"
57#include "kfiledialog.h" 57#include "kfiledialog.h"
58#include "koglobals.h" 58#include "koglobals.h"
59#include "kglobal.h" 59#include "kglobal.h"
60#include "ktoolbar.h" 60#include "ktoolbar.h"
61#include "klocale.h" 61#include "klocale.h"
62#include "kconfig.h" 62#include "kconfig.h"
63#include "simplealarmclient.h" 63#include "simplealarmclient.h"
64#include "externalapphandler.h" 64#include "externalapphandler.h"
65 65
66using namespace KCal; 66using namespace KCal;
67#ifndef _WIN32_ 67#ifndef _WIN32_
68#include <unistd.h> 68#include <unistd.h>
69#else 69#else
70#ifdef _OL_IMPORT_ 70#ifdef _OL_IMPORT_
71#include "koimportoldialog.h" 71#include "koimportoldialog.h"
72#endif 72#endif
73#endif 73#endif
74#include "mainwindow.h" 74#include "mainwindow.h"
75 75
76 76
77class KOex2phonePrefs : public QDialog 77class KOex2phonePrefs : public QDialog
78{ 78{
79 public: 79 public:
80 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 80 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
81 QDialog( parent, name, true ) 81 QDialog( parent, name, true )
82 { 82 {
83 setCaption( i18n("Export to phone options") ); 83 setCaption( i18n("Export to phone options") );
84 QVBoxLayout* lay = new QVBoxLayout( this ); 84 QVBoxLayout* lay = new QVBoxLayout( this );
85 lay->setSpacing( 3 ); 85 lay->setSpacing( 3 );
86 lay->setMargin( 3 ); 86 lay->setMargin( 3 );
87 QLabel *lab; 87 QLabel *lab;
88 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 88 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
89 lab->setAlignment (AlignHCenter ); 89 lab->setAlignment (AlignHCenter );
90 QHBox* temphb; 90 QHBox* temphb;
91 temphb = new QHBox( this ); 91 temphb = new QHBox( this );
92 new QLabel( i18n("I/O device: "), temphb ); 92 new QLabel( i18n("I/O device: "), temphb );
93 mPhoneDevice = new QLineEdit( temphb); 93 mPhoneDevice = new QLineEdit( temphb);
94 lay->addWidget( temphb ); 94 lay->addWidget( temphb );
95 temphb = new QHBox( this ); 95 temphb = new QHBox( this );
96 new QLabel( i18n("Connection: "), temphb ); 96 new QLabel( i18n("Connection: "), temphb );
97 mPhoneConnection = new QLineEdit( temphb); 97 mPhoneConnection = new QLineEdit( temphb);
98 lay->addWidget( temphb ); 98 lay->addWidget( temphb );
99 temphb = new QHBox( this ); 99 temphb = new QHBox( this );
100 new QLabel( i18n("Model(opt.): "), temphb ); 100 new QLabel( i18n("Model(opt.): "), temphb );
101 mPhoneModel = new QLineEdit( temphb); 101 mPhoneModel = new QLineEdit( temphb);
102 lay->addWidget( temphb ); 102 lay->addWidget( temphb );
103 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 103 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
104 mWriteBackFuture->setChecked( true ); 104 mWriteBackFuture->setChecked( true );
105 lay->addWidget( mWriteBackFuture ); 105 lay->addWidget( mWriteBackFuture );
106 temphb = new QHBox( this ); 106 temphb = new QHBox( this );
107 new QLabel( i18n("Max. weeks in future: ") , temphb ); 107 new QLabel( i18n("Max. weeks in future: ") , temphb );
108 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 108 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
109 mWriteBackFutureWeeks->setValue( 8 ); 109 mWriteBackFutureWeeks->setValue( 8 );
110 lay->addWidget( temphb ); 110 lay->addWidget( temphb );
111 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 111 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
112 lab->setAlignment (AlignHCenter ); 112 lab->setAlignment (AlignHCenter );
113 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 113 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
114 lay->addWidget( ok ); 114 lay->addWidget( ok );
115 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 115 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
116 lay->addWidget( cancel ); 116 lay->addWidget( cancel );
117 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 117 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
118 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 118 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
119 resize( 220, 240 ); 119 resize( 220, 240 );
120 qApp->processEvents(); 120 qApp->processEvents();
121 int dw = QApplication::desktop()->width(); 121 int dw = QApplication::desktop()->width();
122 int dh = QApplication::desktop()->height(); 122 int dh = QApplication::desktop()->height();
123 move( (dw-width())/2, (dh - height() )/2 ); 123 move( (dw-width())/2, (dh - height() )/2 );
124 } 124 }
125 125
126public: 126public:
127 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 127 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
128 QCheckBox* mWriteBackFuture; 128 QCheckBox* mWriteBackFuture;
129 QSpinBox* mWriteBackFutureWeeks; 129 QSpinBox* mWriteBackFutureWeeks;
130}; 130};
131 131
132int globalFlagBlockStartup; 132int globalFlagBlockStartup;
133MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 133MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
134 QMainWindow( parent, name ) 134 QMainWindow( parent, name )
135{ 135{
136 136
137 mClosed = false; 137 mClosed = false;
138 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 138 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
139 QString confFile = locateLocal("config","korganizerrc"); 139 QString confFile = locateLocal("config","korganizerrc");
140 QFileInfo finf ( confFile ); 140 QFileInfo finf ( confFile );
141 bool showWarning = !finf.exists(); 141 bool showWarning = !finf.exists();
142 setIcon(SmallIcon( "ko24" ) ); 142 setIcon(SmallIcon( "ko24" ) );
143 mBlockAtStartup = true; 143 mBlockAtStartup = true;
144 mFlagKeyPressed = false; 144 mFlagKeyPressed = false;
145 setCaption("KO/Pi"); 145 setCaption("KO/Pi");
146 KOPrefs *p = KOPrefs::instance(); 146 KOPrefs *p = KOPrefs::instance();
147 KPimGlobalPrefs::instance()->setGlobalConfig(); 147 KPimGlobalPrefs::instance()->setGlobalConfig();
148 if ( p->mHourSize > 22 ) 148 if ( p->mHourSize > 22 )
149 p->mHourSize = 22; 149 p->mHourSize = 22;
150 QMainWindow::ToolBarDock tbd; 150 QMainWindow::ToolBarDock tbd;
151 if ( p->mToolBarHor ) { 151 if ( p->mToolBarHor ) {
152 if ( p->mToolBarUp ) 152 if ( p->mToolBarUp )
153 tbd = Bottom; 153 tbd = Bottom;
154 else 154 else
155 tbd = Top; 155 tbd = Top;
156 } 156 }
157 else { 157 else {
158 if ( p->mToolBarUp ) 158 if ( p->mToolBarUp )
159 tbd = Right; 159 tbd = Right;
160 else 160 else
161 tbd = Left; 161 tbd = Left;
162 } 162 }
163 if ( KOPrefs::instance()->mUseAppColors ) 163 if ( KOPrefs::instance()->mUseAppColors )
164 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 164 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
165 globalFlagBlockStartup = 1; 165 globalFlagBlockStartup = 1;
166 iconToolBar = new QPEToolBar( this ); 166 iconToolBar = new QPEToolBar( this );
167 addToolBar (iconToolBar , tbd ); 167 addToolBar (iconToolBar , tbd );
168 168
169 if ( KOPrefs::instance()->mShowIconFilter ) { 169#ifdef DESKTOP_VERSION
170 if ( KOPrefs::instance()->mShowIconFilter )
171#else
172 if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar )
173#endif
174
175{
170 if ( p->mToolBarHorF ) { 176 if ( p->mToolBarHorF ) {
171 if ( p->mToolBarUpF ) 177 if ( p->mToolBarUpF )
172 tbd = Bottom; 178 tbd = Bottom;
173 else 179 else
174 tbd = Top; 180 tbd = Top;
175 } 181 }
176 else { 182 else {
177 if ( p->mToolBarUpF ) 183 if ( p->mToolBarUpF )
178 tbd = Right; 184 tbd = Right;
179 else 185 else
180 tbd = Left; 186 tbd = Left;
181 } 187 }
182 filterToolBar = new QPEToolBar ( this ); 188 filterToolBar = new QPEToolBar ( this );
183 filterMenubar = new QPEMenuBar( filterToolBar ); 189 filterMenubar = new QPEMenuBar( filterToolBar );
184 QFontMetrics fm ( filterMenubar->font() ); 190 QFontMetrics fm ( filterMenubar->font() );
185 191
186 filterPopupMenu = new QPopupMenu( this ); 192 filterPopupMenu = new QPopupMenu( this );
187 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); 193 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 );
188 QString addTest = "Ax"; 194 QString addTest = "Ax";
189#ifdef DESKTOP_VERSION 195#ifdef DESKTOP_VERSION
190 addTest = "AAAx"; 196 addTest = "AAAx";
191#endif 197#endif
192 filterMenubar->setFixedWidth( fm.width( i18n("No Filter")+addTest ) ); 198 filterMenubar->setFixedWidth( fm.width( i18n("No Filter")+addTest ) );
193 addToolBar (filterToolBar , tbd ); 199 addToolBar (filterToolBar , tbd );
194 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); 200 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) );
195 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); 201 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) );
202 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar )
203 filterToolBar->hide();
196 } else { 204 } else {
197 filterToolBar = 0; 205 filterToolBar = 0;
198 filterMenubar = 0; 206 filterMenubar = 0;
199 filterPopupMenu = 0; 207 filterPopupMenu = 0;
200 } 208 }
201 if ( p->mShowIconOnetoolbar ) { 209 if ( p->mShowIconOnetoolbar ) {
202 viewToolBar = iconToolBar ; 210 viewToolBar = iconToolBar ;
203 navigatorToolBar = iconToolBar ; 211 navigatorToolBar = iconToolBar ;
204 } else { 212 } else {
213#ifndef DESKTOP_VERSION
214 setToolBarsMovable( false );
215#endif
205 if ( p->mToolBarHorV ) { 216 if ( p->mToolBarHorV ) {
206 if ( p->mToolBarUpV ) 217 if ( p->mToolBarUpV )
207 tbd = Bottom; 218 tbd = Bottom;
208 else 219 else
209 tbd = Top; 220 tbd = Top;
210 } 221 }
211 else { 222 else {
212 if ( p->mToolBarUpV ) 223 if ( p->mToolBarUpV )
213 tbd = Right; 224 tbd = Right;
214 else 225 else
215 tbd = Left; 226 tbd = Left;
216 } 227 }
217 viewToolBar = new QPEToolBar( this ); 228 viewToolBar = new QPEToolBar( this );
218 addToolBar (viewToolBar , tbd ); 229 addToolBar (viewToolBar , tbd );
219 if ( p->mToolBarHorN ) { 230 if ( p->mToolBarHorN ) {
220 if ( p->mToolBarUpN ) 231 if ( p->mToolBarUpN )
221 tbd = Bottom; 232 tbd = Bottom;
222 else 233 else
223 tbd = Top; 234 tbd = Top;
224 } 235 }
225 else { 236 else {
226 if ( p->mToolBarUpN ) 237 if ( p->mToolBarUpN )
227 tbd = Right; 238 tbd = Right;
228 else 239 else
229 tbd = Left; 240 tbd = Left;
230 } 241 }
231 navigatorToolBar = new QPEToolBar( this ); 242 navigatorToolBar = new QPEToolBar( this );
232 addToolBar (navigatorToolBar , tbd ); 243 addToolBar (navigatorToolBar , tbd );
233 } 244 }
234 245
235 246
236 247
237 mCalendarModifiedFlag = false; 248 mCalendarModifiedFlag = false;
238 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 249 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
239 splash->setAlignment ( AlignCenter ); 250 splash->setAlignment ( AlignCenter );
240 setCentralWidget( splash ); 251 setCentralWidget( splash );
241#ifndef DESKTOP_VERSION 252#ifndef DESKTOP_VERSION
242 showMaximized(); 253 showMaximized();
243#endif 254#endif
244 255
245 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 256 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
246 setDefaultPreferences(); 257 setDefaultPreferences();
247 mCalendar = new CalendarLocal(); 258 mCalendar = new CalendarLocal();
248 mView = new CalendarView( mCalendar, this,"mCalendar " ); 259 mView = new CalendarView( mCalendar, this,"mCalendar " );
249 mView->hide(); 260 mView->hide();
250 //mView->resize(splash->size() ); 261 //mView->resize(splash->size() );
251 initActions(); 262 initActions();
252 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 263 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
253 mSyncManager->setBlockSave(false); 264 mSyncManager->setBlockSave(false);
254 mView->setSyncManager(mSyncManager); 265 mView->setSyncManager(mSyncManager);
255#ifndef DESKTOP_VERSION 266#ifndef DESKTOP_VERSION
256 iconToolBar->show(); 267 iconToolBar->show();
257 qApp->processEvents(); 268 qApp->processEvents();
258#endif 269#endif
259 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 270 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
260 int vh = height() ; 271 int vh = height() ;
261 int vw = width(); 272 int vw = width();
262 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 273 //qDebug("Toolbar hei %d ",iconToolBar->height() );
263 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 274 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
264 vh -= iconToolBar->height(); 275 vh -= iconToolBar->height();
265 } else { 276 } else {
266 vw -= iconToolBar->height(); 277 vw -= iconToolBar->height();
267 } 278 }
268 //mView->setMaximumSize( splash->size() ); 279 //mView->setMaximumSize( splash->size() );
269 //mView->resize( splash->size() ); 280 //mView->resize( splash->size() );
270 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 281 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
271 mView->readSettings(); 282 mView->readSettings();
272 bool newFile = false; 283 bool newFile = false;
273 if( !QFile::exists( defaultFileName() ) ) { 284 if( !QFile::exists( defaultFileName() ) ) {
274 QFileInfo finfo ( defaultFileName() ); 285 QFileInfo finfo ( defaultFileName() );
275 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 286 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
276 qDebug("oldfile %s ", oldFile.latin1()); 287 qDebug("oldfile %s ", oldFile.latin1());
277 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 288 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
278 finfo.setFile( oldFile ); 289 finfo.setFile( oldFile );
279 if (finfo.exists() ) { 290 if (finfo.exists() ) {
280 KMessageBox::information( this, message); 291 KMessageBox::information( this, message);
281 mView->openCalendar( oldFile ); 292 mView->openCalendar( oldFile );
282 qApp->processEvents(); 293 qApp->processEvents();
283 } else { 294 } else {
284 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 295 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
285 finfo.setFile( oldFile ); 296 finfo.setFile( oldFile );
286 if (finfo.exists() ) { 297 if (finfo.exists() ) {
287 KMessageBox::information( this, message); 298 KMessageBox::information( this, message);
288 mView->openCalendar( oldFile ); 299 mView->openCalendar( oldFile );
289 qApp->processEvents(); 300 qApp->processEvents();
290 } 301 }
291 } 302 }
292 mView->saveCalendar( defaultFileName() ); 303 mView->saveCalendar( defaultFileName() );
293 newFile = true; 304 newFile = true;
294 } 305 }
295 306
296 QTime neededSaveTime = QDateTime::currentDateTime().time(); 307 QTime neededSaveTime = QDateTime::currentDateTime().time();
297 mView->openCalendar( defaultFileName() ); 308 mView->openCalendar( defaultFileName() );
298 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 309 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
299 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 310 qDebug("KO: Calendar loading time: %d ms",msNeeded );
300 311
301 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 312 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
302 KOPrefs::instance()->setAllDefaults(); 313 KOPrefs::instance()->setAllDefaults();
303 int count = mView->addCategories(); 314 int count = mView->addCategories();
304 } 315 }
305 processIncidenceSelection( 0 ); 316 processIncidenceSelection( 0 );
306 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 317 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
307 SLOT( processIncidenceSelection( Incidence * ) ) ); 318 SLOT( processIncidenceSelection( Incidence * ) ) );
308 connect( mView, SIGNAL( modifiedChanged( bool ) ), 319 connect( mView, SIGNAL( modifiedChanged( bool ) ),
309 SLOT( slotModifiedChanged( bool ) ) ); 320 SLOT( slotModifiedChanged( bool ) ) );
310 321
311 322
312 connect( mView, SIGNAL( tempDisableBR(bool) ), 323 connect( mView, SIGNAL( tempDisableBR(bool) ),
313 SLOT( disableBR(bool) ) ); 324 SLOT( disableBR(bool) ) );
314 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 325 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
315 mView->setModified( false ); 326 mView->setModified( false );
316 mBlockAtStartup = false; 327 mBlockAtStartup = false;
317 mView->setModified( false ); 328 mView->setModified( false );
318 setCentralWidget( mView ); 329 setCentralWidget( mView );
319 globalFlagBlockStartup = 0; 330 globalFlagBlockStartup = 0;
320 mView->show(); 331 mView->show();
321 delete splash; 332 delete splash;
322 if ( newFile ) 333 if ( newFile )
323 mView->updateConfig(); 334 mView->updateConfig();
324 // qApp->processEvents(); 335 // qApp->processEvents();
325 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 336 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
326 //fillSyncMenu(); 337 //fillSyncMenu();
327 338
328 339
329 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 340 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
330 connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); 341 connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
331 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); 342 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
332 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 343 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
333 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 344 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
334 mSyncManager->setDefaultFileName( sentSyncFile()); 345 mSyncManager->setDefaultFileName( sentSyncFile());
335 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 346 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
336 mSyncManager->fillSyncMenu(); 347 mSyncManager->fillSyncMenu();
337 348
338 349
339 350
340 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 351 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
341 if ( showWarning ) { 352 if ( showWarning ) {
342 KMessageBox::information( this, 353 KMessageBox::information( this,
343 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 354 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
344 qApp->processEvents(); 355 qApp->processEvents();
345 mView->dialogManager()->showSyncOptions(); 356 mView->dialogManager()->showSyncOptions();
346 } 357 }
347 358
348 //US listen for result adressed from Ka/Pi 359 //US listen for result adressed from Ka/Pi
349#ifndef DESKTOP_VERSION 360#ifndef DESKTOP_VERSION
350 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 361 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
351#endif 362#endif
352#ifndef DESKTOP_VERSION 363#ifndef DESKTOP_VERSION
353 infrared = 0; 364 infrared = 0;
354#endif 365#endif
355 updateFilterToolbar(); 366 updateFilterToolbar();
356 updateWeek( mView->startDate() ); 367 updateWeek( mView->startDate() );
357 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 368 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
358 SLOT( updateWeekNum( const KCal::DateList & ) ) ); 369 SLOT( updateWeekNum( const KCal::DateList & ) ) );
359 mBRdisabled = false; 370 mBRdisabled = false;
360 //toggleBeamReceive(); 371 //toggleBeamReceive();
361} 372}
362MainWindow::~MainWindow() 373MainWindow::~MainWindow()
363{ 374{
364 //qDebug("MainWindow::~MainWindow() "); 375 //qDebug("MainWindow::~MainWindow() ");
365 //save toolbar location 376 //save toolbar location
366 delete mCalendar; 377 delete mCalendar;
367 delete mSyncManager; 378 delete mSyncManager;
368#ifndef DESKTOP_VERSION 379#ifndef DESKTOP_VERSION
369 if ( infrared ) 380 if ( infrared )
370 delete infrared; 381 delete infrared;
371#endif 382#endif
372 383
373 384
374} 385}
375 386
376void MainWindow::disableBR(bool b) 387void MainWindow::disableBR(bool b)
377{ 388{
378#ifndef DESKTOP_VERSION 389#ifndef DESKTOP_VERSION
379 if ( b ) { 390 if ( b ) {
380 if ( infrared ) { 391 if ( infrared ) {
381 toggleBeamReceive(); 392 toggleBeamReceive();
382 mBRdisabled = true; 393 mBRdisabled = true;
383 } 394 }
384 mBRdisabled = true; 395 mBRdisabled = true;
385 } else { 396 } else {
386 if ( mBRdisabled ) { 397 if ( mBRdisabled ) {
387 mBRdisabled = false; 398 mBRdisabled = false;
388 //makes no sense,because other cal ap is probably running 399 //makes no sense,because other cal ap is probably running
389 // toggleBeamReceive(); 400 // toggleBeamReceive();
390 } 401 }
391 } 402 }
392#endif 403#endif
393 404
394} 405}
395bool MainWindow::beamReceiveEnabled() 406bool MainWindow::beamReceiveEnabled()
396{ 407{
@@ -2221,192 +2232,205 @@ void MainWindow::loadCalendar()
2221 if ( result != 0 ) { 2232 if ( result != 0 ) {
2222 loadbup = false; 2233 loadbup = false;
2223 } 2234 }
2224 } else { 2235 } else {
2225 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2236 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2226 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 2237 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
2227 0, 1 ); 2238 0, 1 );
2228 2239
2229 return; 2240 return;
2230 } 2241 }
2231 if ( loadbup ) { 2242 if ( loadbup ) {
2232 mView->openCalendar( fn ); 2243 mView->openCalendar( fn );
2233 KOPrefs::instance()->mLastLoadFile = fn; 2244 KOPrefs::instance()->mLastLoadFile = fn;
2234 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 2245 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
2235 setCaption(mess); 2246 setCaption(mess);
2236 } 2247 }
2237 2248
2238} 2249}
2239void MainWindow::quickImportIcal() 2250void MainWindow::quickImportIcal()
2240{ 2251{
2241 importFile( KOPrefs::instance()->mLastImportFile, false ); 2252 importFile( KOPrefs::instance()->mLastImportFile, false );
2242} 2253}
2243void MainWindow::importFile( QString fn, bool quick ) 2254void MainWindow::importFile( QString fn, bool quick )
2244{ 2255{
2245 QFileInfo info; 2256 QFileInfo info;
2246 info.setFile( fn ); 2257 info.setFile( fn );
2247 QString mess; 2258 QString mess;
2248 bool loadbup = true; 2259 bool loadbup = true;
2249 if ( !info. exists() ) { 2260 if ( !info. exists() ) {
2250 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 2261 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
2251 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2262 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2252 mess ); 2263 mess );
2253 return; 2264 return;
2254 } 2265 }
2255 int result = 0; 2266 int result = 0;
2256 if ( !quick ) { 2267 if ( !quick ) {
2257 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2268 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2258 result = QMessageBox::warning( this, "KO/Pi: Warning!", 2269 result = QMessageBox::warning( this, "KO/Pi: Warning!",
2259 mess, 2270 mess,
2260 "Import", "Cancel", 0, 2271 "Import", "Cancel", 0,
2261 0, 1 ); 2272 0, 1 );
2262 } 2273 }
2263 if ( result == 0 ) { 2274 if ( result == 0 ) {
2264 if ( mView->openCalendar( fn, true )) { 2275 if ( mView->openCalendar( fn, true )) {
2265 KOPrefs::instance()->mLastImportFile = fn; 2276 KOPrefs::instance()->mLastImportFile = fn;
2266 setCaption(i18n("Imported file successfully")); 2277 setCaption(i18n("Imported file successfully"));
2267 } else { 2278 } else {
2268 setCaption(i18n("Error importing file")); 2279 setCaption(i18n("Error importing file"));
2269 } 2280 }
2270 } 2281 }
2271} 2282}
2272 2283
2273void MainWindow::importIcal() 2284void MainWindow::importIcal()
2274{ 2285{
2275 2286
2276 QString fn =KOPrefs::instance()->mLastImportFile; 2287 QString fn =KOPrefs::instance()->mLastImportFile;
2277 2288
2278 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 2289 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
2279 if ( fn == "" ) 2290 if ( fn == "" )
2280 return; 2291 return;
2281 importFile( fn, true ); 2292 importFile( fn, true );
2282 2293
2283} 2294}
2284 2295
2285void MainWindow::exportVCalendar() 2296void MainWindow::exportVCalendar()
2286{ 2297{
2287 QString fn = KOPrefs::instance()->mLastVcalFile; 2298 QString fn = KOPrefs::instance()->mLastVcalFile;
2288 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 2299 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
2289 if ( fn == "" ) 2300 if ( fn == "" )
2290 return; 2301 return;
2291 QFileInfo info; 2302 QFileInfo info;
2292 info.setFile( fn ); 2303 info.setFile( fn );
2293 QString mes; 2304 QString mes;
2294 bool createbup = true; 2305 bool createbup = true;
2295 if ( info. exists() ) { 2306 if ( info. exists() ) {
2296 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 2307 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
2297 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 2308 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
2298 i18n("Overwrite!"), i18n("Cancel"), 0, 2309 i18n("Overwrite!"), i18n("Cancel"), 0,
2299 0, 1 ); 2310 0, 1 );
2300 if ( result != 0 ) { 2311 if ( result != 0 ) {
2301 createbup = false; 2312 createbup = false;
2302 } 2313 }
2303 } 2314 }
2304 if ( createbup ) { 2315 if ( createbup ) {
2305 if ( mView->exportVCalendar( fn ) ) { 2316 if ( mView->exportVCalendar( fn ) ) {
2306 KOPrefs::instance()->mLastVcalFile = fn; 2317 KOPrefs::instance()->mLastVcalFile = fn;
2307 if ( fn.length() > 20 ) 2318 if ( fn.length() > 20 )
2308 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 2319 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
2309 else 2320 else
2310 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 2321 mes = i18n("KO/Pi:Exported to %1").arg(fn );
2311 setCaption(mes); 2322 setCaption(mes);
2312 } 2323 }
2313 } 2324 }
2314 2325
2315} 2326}
2316QString MainWindow::sentSyncFile() 2327QString MainWindow::sentSyncFile()
2317{ 2328{
2318#ifdef DESKTOP_VERSION 2329#ifdef DESKTOP_VERSION
2319 return locateLocal( "tmp", "copysynccal.ics" ); 2330 return locateLocal( "tmp", "copysynccal.ics" );
2320#else 2331#else
2321 return QString( "/tmp/copysynccal.ics" ); 2332 return QString( "/tmp/copysynccal.ics" );
2322#endif 2333#endif
2323} 2334}
2324 2335
2325void MainWindow::syncFileRequest() 2336void MainWindow::syncFileRequest()
2326{ 2337{
2327 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2338 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2328 mSyncManager->slotSyncMenu( 999 ); 2339 mSyncManager->slotSyncMenu( 999 );
2329 } 2340 }
2330 2341
2331 setCaption(i18n("Saving Data to temp file ..." )); 2342 setCaption(i18n("Saving Data to temp file ..." ));
2332 mView->saveCalendar( sentSyncFile() ); 2343 mView->saveCalendar( sentSyncFile() );
2333 setCaption(i18n("Data saved to temp file!" )); 2344 setCaption(i18n("Data saved to temp file!" ));
2334 2345
2335} 2346}
2336void MainWindow::getFile( bool success ) 2347void MainWindow::getFile( bool success )
2337{ 2348{
2338 if ( ! success ) { 2349 if ( ! success ) {
2339 setCaption( i18n("Error receiving file. Nothing changed!") ); 2350 setCaption( i18n("Error receiving file. Nothing changed!") );
2340 return; 2351 return;
2341 } 2352 }
2342 mView->openCalendar( sentSyncFile() ); 2353 mView->openCalendar( sentSyncFile() );
2343 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2354 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2344 mSyncManager->slotSyncMenu( 999 ); 2355 mSyncManager->slotSyncMenu( 999 );
2345 } 2356 }
2346 setCaption( i18n("Pi-Sync successful!") ); 2357 setCaption( i18n("Pi-Sync successful!") );
2347} 2358}
2348 2359
2349void MainWindow::printSel( ) 2360void MainWindow::printSel( )
2350{ 2361{
2351 mView->viewManager()->agendaView()->agenda()->printSelection(); 2362 mView->viewManager()->agendaView()->agenda()->printSelection();
2352} 2363}
2353 2364
2354void MainWindow::printCal() 2365void MainWindow::printCal()
2355{ 2366{
2356 mView->print();//mCp->showDialog(); 2367 mView->print();//mCp->showDialog();
2357} 2368}
2358 2369
2359 2370
2360#include "libkdepim/kdatepicker.h" 2371#include "libkdepim/kdatepicker.h"
2361#include <kdatetbl.h> 2372#include <kdatetbl.h>
2362 2373
2363void MainWindow::weekAction() 2374void MainWindow::weekAction()
2364{ 2375{
2365 int month; 2376 int month;
2366 KPopupFrame* popup = new KPopupFrame(this); 2377 KPopupFrame* popup = new KPopupFrame(this);
2367 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); 2378 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup);
2368 // ----- 2379 // -----
2369 picker->resize(picker->sizeHint()); 2380 picker->resize(picker->sizeHint());
2370 popup->setMainWidget(picker); 2381 popup->setMainWidget(picker);
2371 picker->setFocus(); 2382 picker->setFocus();
2372 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 2383 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
2373 int x = 0; 2384 int x = 0;
2374 int y = iconToolBar->height(); 2385 int y = iconToolBar->height();
2375 int dX = 0; 2386 int dX = 0;
2376 int dY = 0; 2387 int dY = 0;
2377 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2388 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2378 if ( iconToolBar->y() > height()/2 ) { 2389 if ( iconToolBar->y() > height()/2 ) {
2379 dY = picker->sizeHint().height()+8; 2390 dY = picker->sizeHint().height()+8;
2380 y = 0; 2391 y = 0;
2381 } 2392 }
2382 } else { 2393 } else {
2383 if ( iconToolBar->x() > width()/2 ) { // right side 2394 if ( iconToolBar->x() > width()/2 ) { // right side
2384 x=0; 2395 x=0;
2385 dX= picker->sizeHint().width()+8; 2396 dX= picker->sizeHint().width()+8;
2386 y = 0; 2397 y = 0;
2387 } else { 2398 } else {
2388 x= iconToolBar->width(); 2399 x= iconToolBar->width();
2389 y = 0; 2400 y = 0;
2390 } 2401 }
2391 } 2402 }
2392 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2403 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2393 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) 2404 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))))
2394 { 2405 {
2395 month = picker->getResult(); 2406 month = picker->getResult();
2396 emit selectWeek ( month ); 2407 emit selectWeek ( month );
2397 //qDebug("weekSelected %d ", month); 2408 //qDebug("weekSelected %d ", month);
2398 } 2409 }
2399 delete popup; 2410 delete popup;
2400} 2411}
2401 2412
2402void MainWindow::hideEvent ( QHideEvent * ) 2413void MainWindow::hideEvent ( QHideEvent * )
2403{ 2414{
2404 QString message; 2415 QString message;
2405 QDateTime nextA = mCalendar->nextAlarmEventDateTime(); 2416 QDateTime nextA = mCalendar->nextAlarmEventDateTime();
2406 if ( nextA.isValid() ) { 2417 if ( nextA.isValid() ) {
2407 QString sum = mCalendar->nextSummary(); 2418 QString sum = mCalendar->nextSummary();
2408 2419
2409 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)); 2420 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));
2410 setCaption( message ); 2421 setCaption( message );
2411 } 2422 }
2412} 2423}
2424
2425void MainWindow::resizeEvent( QResizeEvent* e)
2426{
2427#ifndef DESKTOP_VERSION
2428 if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar ) {
2429 if (QApplication::desktop()->width() > QApplication::desktop()->height() )
2430 filterToolBar->hide();
2431 else
2432 filterToolBar->show();
2433 }
2434#endif
2435 QMainWindow::resizeEvent( e);
2436}
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 7c16aeb..4d1753f 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -1,172 +1,173 @@
1#ifndef KORGE_MAINWINDOW_H 1#ifndef KORGE_MAINWINDOW_H
2#define KORGE_MAINWINDOW_H 2#define KORGE_MAINWINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include <qtimer.h> 5#include <qtimer.h>
6#include <qdict.h> 6#include <qdict.h>
7#include <qfile.h> 7#include <qfile.h>
8#include <qmenubar.h> 8#include <qmenubar.h>
9#include <qtextstream.h> 9#include <qtextstream.h>
10#include <qregexp.h> 10#include <qregexp.h>
11 11
12#include <libkcal/incidence.h> 12#include <libkcal/incidence.h>
13#include "simplealarmclient.h" 13#include "simplealarmclient.h"
14#include <ksyncmanager.h> 14#include <ksyncmanager.h>
15#ifndef DESKTOP_VERSION 15#ifndef DESKTOP_VERSION
16#include <qcopchannel_qws.h> 16#include <qcopchannel_qws.h>
17#endif 17#endif
18class QAction; 18class QAction;
19class CalendarView; 19class CalendarView;
20class KSyncProfile; 20class KSyncProfile;
21#ifdef DESKTOP_VERSION 21#ifdef DESKTOP_VERSION
22 22
23#define QPEToolBar QToolBar 23#define QPEToolBar QToolBar
24#define QPEMenuBar QMenuBar 24#define QPEMenuBar QMenuBar
25#endif 25#endif
26class QPEToolBar; 26class QPEToolBar;
27class QPEMenuBar; 27class QPEMenuBar;
28 28
29 29
30namespace KCal { 30namespace KCal {
31class CalendarLocal; 31class CalendarLocal;
32} 32}
33 33
34class KOMenuBar : public QMenuBar 34class KOMenuBar : public QMenuBar
35{ 35{
36 public: 36 public:
37 KOMenuBar( QWidget *parent=0 ): QMenuBar (parent ) {;} 37 KOMenuBar( QWidget *parent=0 ): QMenuBar (parent ) {;}
38 QSize sizeHint () const{ qDebug("sizejint ");return QSize ( 40,25 );} 38 QSize sizeHint () const{ qDebug("sizejint ");return QSize ( 40,25 );}
39}; 39};
40 40
41using namespace KCal; 41using namespace KCal;
42 42
43class MainWindow : public QMainWindow 43class MainWindow : public QMainWindow
44{ 44{
45 Q_OBJECT 45 Q_OBJECT
46 public: 46 public:
47 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); 47 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = "");
48 ~MainWindow(); 48 ~MainWindow();
49 bool beamReceiveEnabled(); 49 bool beamReceiveEnabled();
50 static QString defaultFileName(); 50 static QString defaultFileName();
51 static QString syncFileName(); 51 static QString syncFileName();
52 static QString resourcePath(); 52 static QString resourcePath();
53 public slots: 53 public slots:
54 void setCaption ( const QString & ); 54 void setCaption ( const QString & );
55 void updateWeekNum(const KCal::DateList &); 55 void updateWeekNum(const KCal::DateList &);
56 void updateWeek(QDate); 56 void updateWeek(QDate);
57 void updateFilterToolbar(); 57 void updateFilterToolbar();
58 virtual void showMaximized (); 58 virtual void showMaximized ();
59 void configureAgenda( int ); 59 void configureAgenda( int );
60 void recieve( const QCString& msg, const QByteArray& data ); 60 void recieve( const QCString& msg, const QByteArray& data );
61 protected slots: 61 protected slots:
62 void setCaptionToDates(); 62 void setCaptionToDates();
63 void weekAction(); 63 void weekAction();
64 void about(); 64 void about();
65 void licence(); 65 void licence();
66 void faq(); 66 void faq();
67 void usertrans(); 67 void usertrans();
68 void features(); 68 void features();
69 void synchowto(); 69 void synchowto();
70 void kdesynchowto(); 70 void kdesynchowto();
71 void multisynchowto(); 71 void multisynchowto();
72 void whatsNew(); 72 void whatsNew();
73 void keyBindings(); 73 void keyBindings();
74 void aboutAutoSaving();; 74 void aboutAutoSaving();;
75 void aboutKnownBugs(); 75 void aboutKnownBugs();
76 76
77 void processIncidenceSelection( Incidence * ); 77 void processIncidenceSelection( Incidence * );
78 78
79 void importQtopia(); 79 void importQtopia();
80 void importBday(); 80 void importBday();
81 void importOL(); 81 void importOL();
82 void importIcal(); 82 void importIcal();
83 void importFile( QString, bool ); 83 void importFile( QString, bool );
84 void quickImportIcal(); 84 void quickImportIcal();
85 85
86 void slotModifiedChanged( bool ); 86 void slotModifiedChanged( bool );
87 87
88 void save(); 88 void save();
89 void saveStopTimer(); 89 void saveStopTimer();
90 void configureToolBar( int ); 90 void configureToolBar( int );
91 void printSel(); 91 void printSel();
92 void printCal(); 92 void printCal();
93 void saveCalendar(); 93 void saveCalendar();
94 void loadCalendar(); 94 void loadCalendar();
95 void exportVCalendar(); 95 void exportVCalendar();
96 void fillFilterMenu(); 96 void fillFilterMenu();
97 void fillFilterMenuTB(); 97 void fillFilterMenuTB();
98 void selectFilter( int ); 98 void selectFilter( int );
99 void fillFilterMenuPopup(); 99 void fillFilterMenuPopup();
100 void selectFilterPopup( int ); 100 void selectFilterPopup( int );
101 void exportToPhone( int ); 101 void exportToPhone( int );
102 void toggleBeamReceive(); 102 void toggleBeamReceive();
103 void disableBR(bool); 103 void disableBR(bool);
104 signals: 104 signals:
105 void selectWeek ( int ); 105 void selectWeek ( int );
106 private slots: 106 private slots:
107 void showConfigureAgenda(); 107 void showConfigureAgenda();
108 void getFile( bool ); 108 void getFile( bool );
109 void syncFileRequest(); 109 void syncFileRequest();
110 110
111 protected: 111 protected:
112 void hideEvent ( QHideEvent * ); 112 void hideEvent ( QHideEvent * );
113 QString sentSyncFile(); 113 QString sentSyncFile();
114 void displayText( QString, QString); 114 void displayText( QString, QString);
115 void enableIncidenceActions( bool ); 115 void enableIncidenceActions( bool );
116 116
117 private: 117 private:
118 bool mBRdisabled; 118 bool mBRdisabled;
119#ifndef DESKTOP_VERSION 119#ifndef DESKTOP_VERSION
120 QCopChannel* infrared; 120 QCopChannel* infrared;
121#endif 121#endif
122 QAction* brAction; 122 QAction* brAction;
123 KSyncManager* mSyncManager; 123 KSyncManager* mSyncManager;
124 bool mClosed; 124 bool mClosed;
125 void saveOnClose(); 125 void saveOnClose();
126 bool mFlagKeyPressed; 126 bool mFlagKeyPressed;
127 bool mBlockAtStartup; 127 bool mBlockAtStartup;
128 QPEToolBar *iconToolBar; 128 QPEToolBar *iconToolBar;
129 QPEToolBar *viewToolBar; 129 QPEToolBar *viewToolBar;
130 QPEToolBar *navigatorToolBar; 130 QPEToolBar *navigatorToolBar;
131 QPEToolBar *filterToolBar; 131 QPEToolBar *filterToolBar;
132 QPEMenuBar *filterMenubar; 132 QPEMenuBar *filterMenubar;
133 QPopupMenu * filterPopupMenu; 133 QPopupMenu * filterPopupMenu;
134 void initActions(); 134 void initActions();
135 void setDefaultPreferences(); 135 void setDefaultPreferences();
136 void resizeEvent( QResizeEvent* e);
136 void keyPressEvent ( QKeyEvent * ) ; 137 void keyPressEvent ( QKeyEvent * ) ;
137 void keyReleaseEvent ( QKeyEvent * ) ; 138 void keyReleaseEvent ( QKeyEvent * ) ;
138 QPopupMenu *configureToolBarMenu; 139 QPopupMenu *configureToolBarMenu;
139 QPopupMenu *selectFilterMenu; 140 QPopupMenu *selectFilterMenu;
140 QPopupMenu *selectFilterMenuTB; 141 QPopupMenu *selectFilterMenuTB;
141 QPopupMenu *configureAgendaMenu, *syncMenu; 142 QPopupMenu *configureAgendaMenu, *syncMenu;
142 CalendarLocal *mCalendar; 143 CalendarLocal *mCalendar;
143 CalendarView *mView; 144 CalendarView *mView;
144 QAction *mNewSubTodoAction; 145 QAction *mNewSubTodoAction;
145 QAction *mWeekAction; 146 QAction *mWeekAction;
146 QFont mWeekFont; 147 QFont mWeekFont;
147 QPixmap mWeekPixmap; 148 QPixmap mWeekPixmap;
148 QColor mWeekBgColor; 149 QColor mWeekBgColor;
149 150
150 QAction *mShowAction; 151 QAction *mShowAction;
151 QAction *mEditAction; 152 QAction *mEditAction;
152 QAction *mDeleteAction; 153 QAction *mDeleteAction;
153 QAction *mCloneAction; 154 QAction *mCloneAction;
154 QAction *mMoveAction; 155 QAction *mMoveAction;
155 QAction *mBeamAction; 156 QAction *mBeamAction;
156 QAction *mCancelAction; 157 QAction *mCancelAction;
157 158
158 QAction *mToggleNav; 159 QAction *mToggleNav;
159 QAction *mToggleFilter; 160 QAction *mToggleFilter;
160 QAction *mToggleAllday; 161 QAction *mToggleAllday;
161 QAction *actionFilterMenuTB; 162 QAction *actionFilterMenuTB;
162 163
163 void closeEvent( QCloseEvent* ce ); 164 void closeEvent( QCloseEvent* ce );
164 SimpleAlarmClient mAlarmClient; 165 SimpleAlarmClient mAlarmClient;
165 QTimer mSaveTimer; 166 QTimer mSaveTimer;
166 //bool mBlockSaveFlag; 167 //bool mBlockSaveFlag;
167 bool mCalendarModifiedFlag; 168 bool mCalendarModifiedFlag;
168 QPixmap loadPixmap( QString ); 169 QPixmap loadPixmap( QString );
169}; 170};
170 171
171 172
172#endif 173#endif