summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp30
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
@@ -107,63 +107,75 @@ void TimeLabels::setCellHeight(int height)
107*/ 107*/
108void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 108void 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 );
@@ -868,48 +880,54 @@ DateList KOAgendaView::selectedDates()
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
874void KOAgendaView::updateView() 886void 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*/
888void KOAgendaView::updateConfig() 900void 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();