author | zautrix <zautrix> | 2005-03-27 10:47:39 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-27 10:47:39 (UTC) |
commit | 1800cf5f3af1f666dddcbfffe3171adcd467ae3d (patch) (unidiff) | |
tree | 64b69e4bfbeacf5a036f027dd099c82c6c77e299 | |
parent | b170a7414ff72016285ea207caa7ccf786530e77 (diff) | |
download | kdepimpi-1800cf5f3af1f666dddcbfffe3171adcd467ae3d.zip kdepimpi-1800cf5f3af1f666dddcbfffe3171adcd467ae3d.tar.gz kdepimpi-1800cf5f3af1f666dddcbfffe3171adcd467ae3d.tar.bz2 |
fixxx
-rw-r--r-- | korganizer/koagendaview.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index fa6b951..18f242c 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -67,143 +67,155 @@ | |||
67 | 67 | ||
68 | #include "koagendaview.h" | 68 | #include "koagendaview.h" |
69 | //#include "koagendaview.moc" | 69 | //#include "koagendaview.moc" |
70 | 70 | ||
71 | //extern bool globalFlagBlockPainting; | 71 | //extern bool globalFlagBlockPainting; |
72 | extern int globalFlagBlockAgenda; | 72 | extern int globalFlagBlockAgenda; |
73 | extern int globalFlagBlockStartup; | 73 | extern int globalFlagBlockStartup; |
74 | extern int globalFlagBlockAgendaItemPaint; | 74 | extern int globalFlagBlockAgendaItemPaint; |
75 | extern int globalFlagBlockAgendaItemUpdate; | 75 | extern int globalFlagBlockAgendaItemUpdate; |
76 | extern int globalFlagBlockLabel; | 76 | extern int globalFlagBlockLabel; |
77 | using namespace KOrg; | 77 | using namespace KOrg; |
78 | 78 | ||
79 | 79 | ||
80 | 80 | ||
81 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : | 81 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : |
82 | QScrollView(parent,name,f) | 82 | QScrollView(parent,name,f) |
83 | { | 83 | { |
84 | mRows = rows; | 84 | mRows = rows; |
85 | 85 | ||
86 | setMinimumHeight( 20 ); | 86 | setMinimumHeight( 20 ); |
87 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 87 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
88 | 88 | ||
89 | enableClipper(true); | 89 | enableClipper(true); |
90 | 90 | ||
91 | setHScrollBarMode(AlwaysOff); | 91 | setHScrollBarMode(AlwaysOff); |
92 | setVScrollBarMode(AlwaysOff); | 92 | setVScrollBarMode(AlwaysOff); |
93 | 93 | ||
94 | resizeContents(50,mRows * mCellHeight); | 94 | resizeContents(50,mRows * mCellHeight); |
95 | 95 | ||
96 | viewport()->setBackgroundMode( PaletteBackground ); | 96 | viewport()->setBackgroundMode( PaletteBackground ); |
97 | } | 97 | } |
98 | 98 | ||
99 | void TimeLabels::setCellHeight(int height) | 99 | void TimeLabels::setCellHeight(int height) |
100 | { | 100 | { |
101 | mCellHeight = height; | 101 | mCellHeight = height; |
102 | } | 102 | } |
103 | 103 | ||
104 | /* | 104 | /* |
105 | Optimization so that only the "dirty" portion of the scroll view | 105 | Optimization so that only the "dirty" portion of the scroll view |
106 | is redrawn. Unfortunately, this is not called by default paintEvent() method. | 106 | is redrawn. Unfortunately, this is not called by default paintEvent() method. |
107 | */ | 107 | */ |
108 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) | 108 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) |
109 | { | 109 | { |
110 | 110 | ||
111 | // if ( globalFlagBlockAgenda ) | 111 | // if ( globalFlagBlockAgenda ) |
112 | // return; | 112 | // return; |
113 | // bug: the parameters cx, cy, cw, ch are the areas that need to be | 113 | // bug: the parameters cx, cy, cw, ch are the areas that need to be |
114 | // redrawn, not the area of the widget. unfortunately, this | 114 | // redrawn, not the area of the widget. unfortunately, this |
115 | // code assumes the latter... | 115 | // code assumes the latter... |
116 | 116 | ||
117 | // now, for a workaround... | 117 | // now, for a workaround... |
118 | // these two assignments fix the weird redraw bug | 118 | // these two assignments fix the weird redraw bug |
119 | cx = contentsX() + 2; | 119 | cx = contentsX() + 2; |
120 | cw = contentsWidth() - 2; | 120 | cw = contentsWidth() - 2; |
121 | // end of workaround | 121 | // end of workaround |
122 | 122 | ||
123 | int cell = ((int)(cy/mCellHeight)); | 123 | int cell = ((int)(cy/mCellHeight)); |
124 | int y = cell * mCellHeight; | 124 | int y = cell * mCellHeight; |
125 | QFontMetrics fm = fontMetrics(); | 125 | QFontMetrics fm = fontMetrics(); |
126 | QString hour; | 126 | QString hour; |
127 | QString suffix; | 127 | QString suffix; |
128 | QString fullTime; | 128 | QString fullTime; |
129 | int tW = fm.width("24:00i"); | 129 | int tW = fm.width("24:00i"); |
130 | int timeHeight = fm.height(); | 130 | int timeHeight = fm.height(); |
131 | timeHeight -= (timeHeight/4-2); | 131 | //timeHeight -= (timeHeight/4-2); |
132 | int borderWidth = 0; | 132 | int borderWidth = 0; |
133 | QFont nFont = p->font(); | 133 | QFont nFont = p->font(); |
134 | QFont sFont = nFont; | 134 | |
135 | sFont.setPointSize( sFont.pointSize()/2+2 ); | ||
136 | if (!KGlobal::locale()->use12Clock()) | 135 | if (!KGlobal::locale()->use12Clock()) |
137 | suffix = "00"; | 136 | suffix = "00"; |
138 | else | 137 | else |
139 | borderWidth = 0; | 138 | borderWidth = 0; |
140 | QFontMetrics fmS( sFont ); | ||
141 | int sHei = fmS.height(); | ||
142 | if ( timeHeight > mCellHeight ) { | 139 | if ( timeHeight > mCellHeight ) { |
143 | timeHeight = mCellHeight-1; | 140 | timeHeight = mCellHeight-1; |
144 | sHei -= 2; | 141 | int pointS = nFont.pointSize(); |
142 | while ( pointS > 4 ) { | ||
143 | nFont.setPointSize( pointS ); | ||
144 | fm = QFontMetrics( nFont ); | ||
145 | if ( fm.height() < mCellHeight ) | ||
146 | break; | ||
147 | -- pointS; | ||
148 | } | ||
149 | fm = QFontMetrics( nFont ); | ||
150 | borderWidth = 4; | ||
151 | timeHeight = fm.height(); | ||
145 | } | 152 | } |
153 | timeHeight -= (timeHeight/4-2); | ||
154 | QFont sFont = nFont; | ||
155 | sFont.setPointSize( sFont.pointSize()/2+2 ); | ||
156 | QFontMetrics fmS( sFont ); | ||
157 | int sHei = fmS.height(); | ||
146 | 158 | ||
147 | while (y < cy + ch) { | 159 | while (y < cy + ch) { |
148 | p->drawLine(cx,y,cx+tW,y); | 160 | p->drawLine(cx,y,cx+tW,y); |
149 | hour.setNum(cell); | 161 | hour.setNum(cell); |
150 | 162 | ||
151 | // handle 24h and am/pm time formats | 163 | // handle 24h and am/pm time formats |
152 | if (KGlobal::locale()->use12Clock()) { | 164 | if (KGlobal::locale()->use12Clock()) { |
153 | if (cell > 11) suffix = "pm"; | 165 | if (cell > 11) suffix = "pm"; |
154 | else | 166 | else |
155 | suffix = "am"; | 167 | suffix = "am"; |
156 | if (cell == 0) hour.setNum(12); | 168 | if (cell == 0) hour.setNum(12); |
157 | if (cell > 12) hour.setNum(cell - 12); | 169 | if (cell > 12) hour.setNum(cell - 12); |
158 | } | 170 | } |
159 | 171 | ||
160 | // create string in format of "XX:XX" or "XXpm/am" | 172 | // create string in format of "XX:XX" or "XXpm/am" |
161 | fullTime = hour;// + suffix; | 173 | fullTime = hour;// + suffix; |
162 | 174 | ||
163 | // center and draw the time label | 175 | // center and draw the time label |
164 | int timeWidth = fm.width(fullTime+"i"); | 176 | int timeWidth = fm.width(fullTime+"i"); |
165 | int tw2 = fm.width(suffix); | 177 | int tw2 = fm.width(suffix); |
166 | int offset = this->width() - timeWidth - tw2; | 178 | int offset = this->width() - timeWidth - tw2; |
167 | p->setFont( nFont ); | 179 | p->setFont( nFont ); |
168 | p->drawText(cx - borderWidth + offset, y+ timeHeight, fullTime); | 180 | p->drawText(cx - borderWidth + offset, y+ timeHeight, fullTime); |
169 | p->setFont( sFont ); | 181 | p->setFont( sFont ); |
170 | offset += timeWidth; | 182 | offset += timeWidth; |
171 | p->drawText(cx - borderWidth + offset, y+ sHei, suffix); | 183 | p->drawText(cx - borderWidth + offset, y+ sHei, suffix); |
172 | 184 | ||
173 | // increment indices | 185 | // increment indices |
174 | y += mCellHeight; | 186 | y += mCellHeight; |
175 | cell++; | 187 | cell++; |
176 | } | 188 | } |
177 | } | 189 | } |
178 | 190 | ||
179 | /** | 191 | /** |
180 | Calculates the minimum width. | 192 | Calculates the minimum width. |
181 | */ | 193 | */ |
182 | int TimeLabels::minimumWidth() const | 194 | int TimeLabels::minimumWidth() const |
183 | { | 195 | { |
184 | return mMiniWidth; | 196 | return mMiniWidth; |
185 | } | 197 | } |
186 | 198 | ||
187 | /** updates widget's internal state */ | 199 | /** updates widget's internal state */ |
188 | void TimeLabels::updateConfig() | 200 | void TimeLabels::updateConfig() |
189 | { | 201 | { |
190 | // set the font | 202 | // set the font |
191 | // config->setGroup("Fonts"); | 203 | // config->setGroup("Fonts"); |
192 | // QFont font = config->readFontEntry("TimeBar Font"); | 204 | // QFont font = config->readFontEntry("TimeBar Font"); |
193 | setFont(KOPrefs::instance()->mTimeBarFont); | 205 | setFont(KOPrefs::instance()->mTimeBarFont); |
194 | mMiniWidth = fontMetrics().width("88:88") + 2 ; | 206 | mMiniWidth = fontMetrics().width("88:88") + 2 ; |
195 | // update geometry restrictions based on new settings | 207 | // update geometry restrictions based on new settings |
196 | setFixedWidth(minimumWidth()); | 208 | setFixedWidth(minimumWidth()); |
197 | 209 | ||
198 | // update HourSize | 210 | // update HourSize |
199 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 211 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
200 | resizeContents(50,mRows * mCellHeight); | 212 | resizeContents(50,mRows * mCellHeight); |
201 | } | 213 | } |
202 | 214 | ||
203 | /** update time label positions */ | 215 | /** update time label positions */ |
204 | void TimeLabels::positionChanged() | 216 | void TimeLabels::positionChanged() |
205 | { | 217 | { |
206 | int adjustment = mAgenda->contentsY(); | 218 | int adjustment = mAgenda->contentsY(); |
207 | setContentsPos(0, adjustment); | 219 | setContentsPos(0, adjustment); |
208 | } | 220 | } |
209 | 221 | ||
@@ -828,128 +840,134 @@ void KOAgendaView::createDayLabels() | |||
828 | //mDayLabels->show(); | 840 | //mDayLabels->show(); |
829 | //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); | 841 | //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); |
830 | //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); | 842 | //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); |
831 | mDayLabelsFrame->setFixedHeight( newHight ); | 843 | mDayLabelsFrame->setFixedHeight( newHight ); |
832 | } | 844 | } |
833 | 845 | ||
834 | int KOAgendaView::maxDatesHint() | 846 | int KOAgendaView::maxDatesHint() |
835 | { | 847 | { |
836 | // Not sure about the max number of events, so return 0 for now. | 848 | // Not sure about the max number of events, so return 0 for now. |
837 | return 0; | 849 | return 0; |
838 | } | 850 | } |
839 | 851 | ||
840 | int KOAgendaView::currentDateCount() | 852 | int KOAgendaView::currentDateCount() |
841 | { | 853 | { |
842 | return mSelectedDates.count(); | 854 | return mSelectedDates.count(); |
843 | } | 855 | } |
844 | 856 | ||
845 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 857 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
846 | { | 858 | { |
847 | QPtrList<Incidence> selected; | 859 | QPtrList<Incidence> selected; |
848 | Incidence *incidence; | 860 | Incidence *incidence; |
849 | 861 | ||
850 | incidence = mAgenda->selectedIncidence(); | 862 | incidence = mAgenda->selectedIncidence(); |
851 | if (incidence) selected.append(incidence); | 863 | if (incidence) selected.append(incidence); |
852 | 864 | ||
853 | incidence = mAllDayAgenda->selectedIncidence(); | 865 | incidence = mAllDayAgenda->selectedIncidence(); |
854 | if (incidence) selected.append(incidence); | 866 | if (incidence) selected.append(incidence); |
855 | 867 | ||
856 | return selected; | 868 | return selected; |
857 | } | 869 | } |
858 | 870 | ||
859 | DateList KOAgendaView::selectedDates() | 871 | DateList KOAgendaView::selectedDates() |
860 | { | 872 | { |
861 | DateList selected; | 873 | DateList selected; |
862 | QDate qd; | 874 | QDate qd; |
863 | 875 | ||
864 | qd = mAgenda->selectedIncidenceDate(); | 876 | qd = mAgenda->selectedIncidenceDate(); |
865 | if (qd.isValid()) selected.append(qd); | 877 | if (qd.isValid()) selected.append(qd); |
866 | 878 | ||
867 | qd = mAllDayAgenda->selectedIncidenceDate(); | 879 | qd = mAllDayAgenda->selectedIncidenceDate(); |
868 | if (qd.isValid()) selected.append(qd); | 880 | if (qd.isValid()) selected.append(qd); |
869 | 881 | ||
870 | return selected; | 882 | return selected; |
871 | } | 883 | } |
872 | 884 | ||
873 | 885 | ||
874 | void KOAgendaView::updateView() | 886 | void KOAgendaView::updateView() |
875 | { | 887 | { |
876 | if ( mBlockUpdating ) | 888 | if ( mBlockUpdating ) |
877 | return; | 889 | return; |
878 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 890 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
879 | fillAgenda(); | 891 | fillAgenda(); |
880 | 892 | ||
881 | } | 893 | } |
882 | 894 | ||
883 | 895 | ||
884 | /* | 896 | /* |
885 | Update configuration settings for the agenda view. This method is not | 897 | Update configuration settings for the agenda view. This method is not |
886 | complete. | 898 | complete. |
887 | */ | 899 | */ |
888 | void KOAgendaView::updateConfig() | 900 | void KOAgendaView::updateConfig() |
889 | { | 901 | { |
890 | if ( mBlockUpdating ) | 902 | if ( mBlockUpdating ) |
891 | return; | 903 | return; |
904 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { | ||
905 | int old = KOPrefs::instance()->mHourSize; | ||
906 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; | ||
907 | qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); | ||
908 | } | ||
909 | |||
892 | 910 | ||
893 | // update config for children | 911 | // update config for children |
894 | mTimeLabels->updateConfig(); | 912 | mTimeLabels->updateConfig(); |
895 | mAgenda->storePosition(); | 913 | mAgenda->storePosition(); |
896 | mAgenda->updateConfig(); | 914 | mAgenda->updateConfig(); |
897 | mAllDayAgenda->updateConfig(); | 915 | mAllDayAgenda->updateConfig(); |
898 | // widget synchronization | 916 | // widget synchronization |
899 | //TODO: find a better way, maybe signal/slot | 917 | //TODO: find a better way, maybe signal/slot |
900 | mTimeLabels->positionChanged(); | 918 | mTimeLabels->positionChanged(); |
901 | 919 | ||
902 | // for some reason, this needs to be called explicitly | 920 | // for some reason, this needs to be called explicitly |
903 | mTimeLabels->repaint(); | 921 | mTimeLabels->repaint(); |
904 | 922 | ||
905 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 923 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
906 | 924 | ||
907 | // ToolTips displaying summary of events | 925 | // ToolTips displaying summary of events |
908 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 926 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
909 | ->mEnableToolTips); | 927 | ->mEnableToolTips); |
910 | 928 | ||
911 | //setHolidayMasks(); | 929 | //setHolidayMasks(); |
912 | 930 | ||
913 | //createDayLabels(); called by via updateView(); | 931 | //createDayLabels(); called by via updateView(); |
914 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 932 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
915 | updateView(); | 933 | updateView(); |
916 | mAgenda->restorePosition(); | 934 | mAgenda->restorePosition(); |
917 | } | 935 | } |
918 | 936 | ||
919 | 937 | ||
920 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 938 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
921 | { | 939 | { |
922 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; | 940 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; |
923 | //qDebug("KOAgendaView::updateEventDates "); | 941 | //qDebug("KOAgendaView::updateEventDates "); |
924 | QDateTime startDt,endDt; | 942 | QDateTime startDt,endDt; |
925 | QDate startDate; | 943 | QDate startDate; |
926 | int lenInSecs; | 944 | int lenInSecs; |
927 | // if ( type == KOAgenda::RESIZETOP ) | 945 | // if ( type == KOAgenda::RESIZETOP ) |
928 | // qDebug("RESIZETOP "); | 946 | // qDebug("RESIZETOP "); |
929 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 947 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
930 | // qDebug("RESIZEBOTTOM "); | 948 | // qDebug("RESIZEBOTTOM "); |
931 | // if ( type == KOAgenda::MOVE ) | 949 | // if ( type == KOAgenda::MOVE ) |
932 | // qDebug("MOVE "); | 950 | // qDebug("MOVE "); |
933 | if ( item->incidence()->type() == "Event" ) { | 951 | if ( item->incidence()->type() == "Event" ) { |
934 | startDt =item->incidence()->dtStart(); | 952 | startDt =item->incidence()->dtStart(); |
935 | endDt = item->incidence()->dtEnd(); | 953 | endDt = item->incidence()->dtEnd(); |
936 | lenInSecs = startDt.secsTo( endDt ); | 954 | lenInSecs = startDt.secsTo( endDt ); |
937 | } | 955 | } |
938 | 956 | ||
939 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 957 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
940 | 958 | ||
941 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { | 959 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { |
942 | startDate = mSelectedDates[item->mLastMoveXPos]; | 960 | startDate = mSelectedDates[item->mLastMoveXPos]; |
943 | } else { | 961 | } else { |
944 | if (item->cellX() < 0) { | 962 | if (item->cellX() < 0) { |
945 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 963 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
946 | } else { | 964 | } else { |
947 | startDate = mSelectedDates[item->cellX()]; | 965 | startDate = mSelectedDates[item->cellX()]; |
948 | } | 966 | } |
949 | } | 967 | } |
950 | startDt.setDate(startDate); | 968 | startDt.setDate(startDate); |
951 | 969 | ||
952 | if (item->incidence()->doesFloat()) { | 970 | if (item->incidence()->doesFloat()) { |
953 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 971 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
954 | } else { | 972 | } else { |
955 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 973 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |