summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-04-01 22:32:18 (UTC)
committer zautrix <zautrix>2005-04-01 22:32:18 (UTC)
commit02bdd5a73feb7bd2431c5492c7bbf663f28efbd8 (patch) (unidiff)
treec87553742dfa351f4d4ae2308d68dd87cc400304 /korganizer
parentefb66afca923f23a94b19da1fa12555956e70844 (diff)
downloadkdepimpi-02bdd5a73feb7bd2431c5492c7bbf663f28efbd8.zip
kdepimpi-02bdd5a73feb7bd2431c5492c7bbf663f28efbd8.tar.gz
kdepimpi-02bdd5a73feb7bd2431c5492c7bbf663f28efbd8.tar.bz2
nf
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp24
-rw-r--r--korganizer/kodaymatrix.cpp6
2 files changed, 22 insertions, 8 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 1627dba..2b05d37 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -111,76 +111,79 @@ void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
111{ 111{
112 112
113 // if ( globalFlagBlockAgenda ) 113 // if ( globalFlagBlockAgenda )
114 // return; 114 // return;
115 // bug: the parameters cx, cy, cw, ch are the areas that need to be 115 // bug: the parameters cx, cy, cw, ch are the areas that need to be
116 // redrawn, not the area of the widget. unfortunately, this 116 // redrawn, not the area of the widget. unfortunately, this
117 // code assumes the latter... 117 // code assumes the latter...
118 118
119 // now, for a workaround... 119 // now, for a workaround...
120 // these two assignments fix the weird redraw bug 120 // these two assignments fix the weird redraw bug
121 mRedrawNeeded = true; 121 mRedrawNeeded = true;
122 if ( mRedrawNeeded ) { 122 if ( mRedrawNeeded ) {
123 cx = contentsX() + frameWidth()*2; 123 cx = contentsX() + frameWidth()*2;
124 cw = contentsWidth() ; 124 cw = contentsWidth() ;
125 // end of workaround 125 // end of workaround
126 126
127 int cell = ((int)(cy/mCellHeight)); 127 int cell = ((int)(cy/mCellHeight));
128 int y = cell * mCellHeight; 128 int y = cell * mCellHeight;
129 QFontMetrics fm = fontMetrics(); 129 QFontMetrics fm = fontMetrics();
130 QString hour; 130 QString hour;
131 QString suffix; 131 QString suffix;
132 int timeHeight = fm.ascent(); 132 int timeHeight = fm.ascent();
133 QFont nFont = p->font(); 133 QFont nFont = p->font();
134 134
135 if (!KGlobal::locale()->use12Clock()) 135 if (!KGlobal::locale()->use12Clock()) {
136 suffix = "00"; 136 if ( QApplication::desktop()->width() <= 320 )
137 suffix = "";
138 else
139 suffix = "00";
140 }
137 141
138 if ( timeHeight > mCellHeight ) { 142 if ( timeHeight > mCellHeight ) {
139 timeHeight = mCellHeight-1; 143 timeHeight = mCellHeight-1;
140 int pointS = nFont.pointSize(); 144 int pointS = nFont.pointSize();
141 while ( pointS > 4 ) { 145 while ( pointS > 4 ) {
142 nFont.setPointSize( pointS ); 146 nFont.setPointSize( pointS );
143 fm = QFontMetrics( nFont ); 147 fm = QFontMetrics( nFont );
144 if ( fm.ascent() < mCellHeight ) 148 if ( fm.ascent() < mCellHeight )
145 break; 149 break;
146 -- pointS; 150 -- pointS;
147 } 151 }
148 fm = QFontMetrics( nFont ); 152 fm = QFontMetrics( nFont );
149 timeHeight = fm.ascent(); 153 timeHeight = fm.ascent();
150 } 154 }
151 //timeHeight -= (timeHeight/4-2); 155 //timeHeight -= (timeHeight/4-2);
152 QFont sFont = nFont; 156 QFont sFont = nFont;
153 sFont.setPointSize( sFont.pointSize()/2 ); 157 sFont.setPointSize( sFont.pointSize()/2 );
154 QFontMetrics fmS( sFont ); 158 QFontMetrics fmS( sFont );
155 int sHei = fmS.ascent() ; 159 int sHei = fmS.ascent() ;
156 //sHei -= (sHei/4-2); 160 //sHei -= (sHei/4-2);
157 int startW = this->width() - frameWidth()-2; 161 int startW = this->width() - frameWidth()-2;
158 int tw2 = fmS.width(suffix); 162 int tw2 = fmS.width(suffix);
159 while (y < cy + ch) { 163 while (y < cy + ch) {
160 p->drawLine(cx,y,cw,y); 164 p->drawLine(cx,y,cw,y);
161 hour.setNum(cell); 165 hour.setNum(cell);
162
163 // handle 24h and am/pm time formats 166 // handle 24h and am/pm time formats
164 if (KGlobal::locale()->use12Clock()) { 167 if (KGlobal::locale()->use12Clock()) {
165 if (cell > 11) suffix = "pm"; 168 if (cell > 11) suffix = "pm";
166 else 169 else
167 suffix = "am"; 170 suffix = "am";
168 if (cell == 0) hour.setNum(12); 171 if (cell == 0) hour.setNum(12);
169 if (cell > 12) hour.setNum(cell - 12); 172 if (cell > 12) hour.setNum(cell - 12);
170 tw2 = fmS.width(suffix); 173 tw2 = fmS.width(suffix);
171 } 174 }
172 175
173 // center and draw the time label 176 // center and draw the time label
174 int timeWidth = fm.width(hour); 177 int timeWidth = fm.width(hour);
175 int offset = startW - timeWidth - tw2 ; 178 int offset = startW - timeWidth - tw2 ;
176 p->setFont( nFont ); 179 p->setFont( nFont );
177 p->drawText( offset, y+ timeHeight, hour); 180 p->drawText( offset, y+ timeHeight, hour);
178 p->setFont( sFont ); 181 p->setFont( sFont );
179 offset = startW - tw2+1; 182 offset = startW - tw2+1;
180 p->drawText( offset, y+ sHei, suffix); 183 p->drawText( offset, y+ sHei, suffix);
181 184
182 // increment indices 185 // increment indices
183 y += mCellHeight; 186 y += mCellHeight;
184 cell++; 187 cell++;
185 } 188 }
186 } else { 189 } else {
@@ -192,50 +195,54 @@ void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
192} 195}
193 196
194/** 197/**
195 Calculates the minimum width. 198 Calculates the minimum width.
196*/ 199*/
197int TimeLabels::minimumWidth() const 200int TimeLabels::minimumWidth() const
198{ 201{
199 return mMiniWidth; 202 return mMiniWidth;
200} 203}
201 204
202/** updates widget's internal state */ 205/** updates widget's internal state */
203void TimeLabels::updateConfig() 206void TimeLabels::updateConfig()
204{ 207{
205 mRedrawNeeded = true; 208 mRedrawNeeded = true;
206 // set the font 209 // set the font
207 // config->setGroup("Fonts"); 210 // config->setGroup("Fonts");
208 // QFont font = config->readFontEntry("TimeBar Font"); 211 // QFont font = config->readFontEntry("TimeBar Font");
209 setFont(KOPrefs::instance()->mTimeBarFont); 212 setFont(KOPrefs::instance()->mTimeBarFont);
210 QString test = "20"; 213 QString test = "20";
211 if (KGlobal::locale()->use12Clock()) 214 if (KGlobal::locale()->use12Clock())
212 test = "12"; 215 test = "12";
213 mMiniWidth = fontMetrics().width(test); 216 mMiniWidth = fontMetrics().width(test);
214 if (KGlobal::locale()->use12Clock()) 217 if (KGlobal::locale()->use12Clock())
215 test = "pm"; 218 test = "pm";
216 else 219 else {
217 test = "00"; 220 if ( QApplication::desktop()->width() <= 320 )
221 test = "";
222 else
223 test = "00";
224 }
218 QFont sFont = font(); 225 QFont sFont = font();
219 sFont.setPointSize( sFont.pointSize()/2 ); 226 sFont.setPointSize( sFont.pointSize()/2 );
220 QFontMetrics fmS( sFont ); 227 QFontMetrics fmS( sFont );
221 mMiniWidth += fmS.width( test ) + frameWidth()*2 +4 ; 228 mMiniWidth += fmS.width( test ) + frameWidth()*2 +4 ;
222 // update geometry restrictions based on new settings 229 // update geometry restrictions based on new settings
223 setFixedWidth( mMiniWidth ); 230 setFixedWidth( mMiniWidth );
224 231
225 // update HourSize 232 // update HourSize
226 mCellHeight = KOPrefs::instance()->mHourSize*4; 233 mCellHeight = KOPrefs::instance()->mHourSize*4;
227 resizeContents(50,mRows * mCellHeight); 234 resizeContents(50,mRows * mCellHeight);
228} 235}
229 236
230/** update time label positions */ 237/** update time label positions */
231void TimeLabels::positionChanged() 238void TimeLabels::positionChanged()
232{ 239{
233 int adjustment = mAgenda->contentsY(); 240 int adjustment = mAgenda->contentsY();
234 setContentsPos(0, adjustment); 241 setContentsPos(0, adjustment);
235} 242}
236 243
237/** */ 244/** */
238void TimeLabels::setAgenda(KOAgenda* agenda) 245void TimeLabels::setAgenda(KOAgenda* agenda)
239{ 246{
240 mAgenda = agenda; 247 mAgenda = agenda;
241} 248}
@@ -704,49 +711,52 @@ void KOAgendaView::createDayLabels()
704 break; 711 break;
705 } 712 }
706 maxLen = 2; 713 maxLen = 2;
707 } 714 }
708 //qDebug("Max len %d ", dayTest.length() ); 715 //qDebug("Max len %d ", dayTest.length() );
709 716
710 QFontMetrics tempF( dlf ); 717 QFontMetrics tempF( dlf );
711 newHight = tempF.height(); 718 newHight = tempF.height();
712 mDayLabels->setFont( dlf ); 719 mDayLabels->setFont( dlf );
713 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 720 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
714 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 721 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
715 //mLayoutDayLabels->addSpacing( 2 ); 722 //mLayoutDayLabels->addSpacing( 2 );
716 // QFont lFont = dlf; 723 // QFont lFont = dlf;
717 bool appendLabels = false; 724 bool appendLabels = false;
718 KOAgendaButton *dayLabel; 725 KOAgendaButton *dayLabel;
719 dayLabel = mDayLabelsList.first(); 726 dayLabel = mDayLabelsList.first();
720 if ( !dayLabel ) { 727 if ( !dayLabel ) {
721 appendLabels = true; 728 appendLabels = true;
722 dayLabel = getNewDaylabel(); 729 dayLabel = getNewDaylabel();
723 } 730 }
724 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); 731 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() );
725 dayLabel->setFont( dlf ); 732 dayLabel->setFont( dlf );
726 dayLabel->setNum( -1 ); 733 dayLabel->setNum( -1 );
727 //dayLabel->setAlignment(QLabel::AlignHCenter); 734 //dayLabel->setAlignment(QLabel::AlignHCenter);
728 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 735 if ( QApplication::desktop()->width() <= 320 )
736 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) );
737 else
738 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
729 dayLabel->show(); 739 dayLabel->show();
730 DateList::ConstIterator dit; 740 DateList::ConstIterator dit;
731 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 741 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
732 int counter = -1; 742 int counter = -1;
733 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 743 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
734 ++counter; 744 ++counter;
735 QDate date = *dit; 745 QDate date = *dit;
736 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 746 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
737 if ( ! appendLabels ) { 747 if ( ! appendLabels ) {
738 dayLabel = mDayLabelsList.next(); 748 dayLabel = mDayLabelsList.next();
739 if ( !dayLabel ) 749 if ( !dayLabel )
740 appendLabels = true; 750 appendLabels = true;
741 } 751 }
742 if ( appendLabels ) { 752 if ( appendLabels ) {
743 dayLabel = getNewDaylabel(); 753 dayLabel = getNewDaylabel();
744 } 754 }
745 dayLabel->setMinimumWidth( 1 ); 755 dayLabel->setMinimumWidth( 1 );
746 dayLabel->setMaximumWidth( 10240 ); 756 dayLabel->setMaximumWidth( 10240 );
747 dayLabel->setFont( dlf ); 757 dayLabel->setFont( dlf );
748 dayLabel->show(); 758 dayLabel->show();
749 dayLabel->setAutoRepeat( false ); 759 dayLabel->setAutoRepeat( false );
750 dayLabel->setNum( counter ); 760 dayLabel->setNum( counter );
751 QString str; 761 QString str;
752 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 762 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
@@ -811,58 +821,58 @@ void KOAgendaView::createDayLabels()
811 QLabel *label = new QLabel(text,mDayLabels); 821 QLabel *label = new QLabel(text,mDayLabels);
812 label->setAlignment(AlignCenter); 822 label->setAlignment(AlignCenter);
813 dayLayout->addWidget(label); 823 dayLayout->addWidget(label);
814 } 824 }
815 } 825 }
816 826
817 for(it = cds.first(); it; it = cds.next()) { 827 for(it = cds.first(); it; it = cds.next()) {
818 QWidget *wid = it->smallWidget(mDayLabels,date); 828 QWidget *wid = it->smallWidget(mDayLabels,date);
819 if ( wid ) { 829 if ( wid ) {
820 // wid->setHeight(20); 830 // wid->setHeight(20);
821 dayLayout->addWidget(wid); 831 dayLayout->addWidget(wid);
822 } 832 }
823 } 833 }
824#endif 834#endif
825 } 835 }
826 if ( ! appendLabels ) { 836 if ( ! appendLabels ) {
827 dayLabel = mDayLabelsList.next(); 837 dayLabel = mDayLabelsList.next();
828 if ( !dayLabel ) 838 if ( !dayLabel )
829 appendLabels = true; 839 appendLabels = true;
830 } 840 }
831 if ( appendLabels ) { 841 if ( appendLabels ) {
832 dayLabel = getNewDaylabel(); 842 dayLabel = getNewDaylabel();
833 } 843 }
834 //dayLabel->hide();//test only 844 //dayLabel->hide();//test only
835 qDebug("fremwidd %d ", mAgenda->frameWidth());
836 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()- (mAgenda->frameWidth()*2) ) % mSelectedDates.count() ; 845 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()- (mAgenda->frameWidth()*2) ) % mSelectedDates.count() ;
837 if ( offset < 0 ) offset = 0; 846 if ( offset < 0 ) offset = 0;
838 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); 847 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 );
839 dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); 848 dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) );
840 dayLabel->setFont( dlf ); 849 dayLabel->setFont( dlf );
841 dayLabel->setAutoRepeat( true ); 850 dayLabel->setAutoRepeat( true );
842 dayLabel->show(); 851 dayLabel->show();
843 dayLabel->setNum( -2 ); 852 dayLabel->setNum( -2 );
844 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); 853 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset );
854
845 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); 855 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2);
846 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 856 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
847 if ( !appendLabels ) { 857 if ( !appendLabels ) {
848 dayLabel = mDayLabelsList.next(); 858 dayLabel = mDayLabelsList.next();
849 while ( dayLabel ) { 859 while ( dayLabel ) {
850 //qDebug("!dayLabel %d",dayLabel ); 860 //qDebug("!dayLabel %d",dayLabel );
851 dayLabel->hide(); 861 dayLabel->hide();
852 dayLabel = mDayLabelsList.next(); 862 dayLabel = mDayLabelsList.next();
853 } 863 }
854 } 864 }
855 865
856 mDayLabelsFrame->setFixedHeight( newHight + 4 ); 866 mDayLabelsFrame->setFixedHeight( newHight + 4 );
857} 867}
858 868
859int KOAgendaView::maxDatesHint() 869int KOAgendaView::maxDatesHint()
860{ 870{
861 // Not sure about the max number of events, so return 0 for now. 871 // Not sure about the max number of events, so return 0 for now.
862 return 0; 872 return 0;
863} 873}
864 874
865int KOAgendaView::currentDateCount() 875int KOAgendaView::currentDateCount()
866{ 876{
867 return mSelectedDates.count(); 877 return mSelectedDates.count();
868} 878}
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index 5b5703f..b8a0f09 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -772,50 +772,54 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
772 p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, 772 p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2,
773 row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); 773 row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol);
774 } else { 774 } else {
775 // draw first row to the right 775 // draw first row to the right
776 if ( colModulo ) { 776 if ( colModulo ) {
777 if ( col >= 7 - colModulo ) 777 if ( col >= 7 - colModulo )
778 addCol2 = col - 7 + colModulo; 778 addCol2 = col - 7 + colModulo;
779 } 779 }
780 if ( rowModulo ) { 780 if ( rowModulo ) {
781 if ( row >= 6 - rowModulo ) 781 if ( row >= 6 - rowModulo )
782 addRow = row - 5 + rowModulo; 782 addRow = row - 5 + rowModulo;
783 } 783 }
784 if ( row == 0) 784 if ( row == 0)
785 addRow = 1; 785 addRow = 1;
786 int drawWid = width()-(col*dwidth+1+addCol2)-1; 786 int drawWid = width()-(col*dwidth+1+addCol2)-1;
787 p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid, 787 p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid,
788 dheight+1, selcol); 788 dheight+1, selcol);
789 // draw full block till last line 789 // draw full block till last line
790 selh = mSelEndT/7-row; 790 selh = mSelEndT/7-row;
791 addRow = 0; 791 addRow = 0;
792 if ( rowModulo ) { 792 if ( rowModulo ) {
793 if ( mSelEndT/7 >= 6 - rowModulo ) 793 if ( mSelEndT/7 >= 6 - rowModulo )
794 addRow = mSelEndT/7 - 5 + rowModulo; 794 addRow = mSelEndT/7 - 5 + rowModulo;
795 } 795 }
796 //qDebug("%d %d %d ",selh, row, addRow );
797 int addrow2 = addRow-selh+1;
798 if ( addrow2 < 0 )
799 addrow2 = 0;
796 if (selh > 1) { 800 if (selh > 1) {
797 p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); 801 p.fillRect(1, (row+1)*dheight+addrow2, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol);
798 } 802 }
799 // draw last block from left to mSelEndT 803 // draw last block from left to mSelEndT
800 selw = mSelEndT-7*(mSelEndT/7)+1; 804 selw = mSelEndT-7*(mSelEndT/7)+1;
801 //qDebug("esl %d ",selw ); 805 //qDebug("esl %d ",selw );
802 int add = 0; 806 int add = 0;
803 if ( colModulo ) { 807 if ( colModulo ) {
804 add = 7 - colModulo; 808 add = 7 - colModulo;
805 if ( selw > add ) 809 if ( selw > add )
806 add = selw - add; 810 add = selw - add;
807 else 811 else
808 add = 0; 812 add = 0;
809 } 813 }
810 //qDebug("add %d ", add); 814 //qDebug("add %d ", add);
811 p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, 815 p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow,
812 selw*dwidth+add, dheight+1, selcol); 816 selw*dwidth+add, dheight+1, selcol);
813 } 817 }
814 } 818 }
815 } 819 }
816 820
817 // iterate over all days in the matrix and draw the day label in appropriate colors 821 // iterate over all days in the matrix and draw the day label in appropriate colors
818 QColor actcol = mDefaultTextColorShaded; 822 QColor actcol = mDefaultTextColorShaded;
819 p.setPen(actcol); 823 p.setPen(actcol);
820 QPen tmppen; 824 QPen tmppen;
821 for(int i = 0; i < NUMDAYS; i++) { 825 for(int i = 0; i < NUMDAYS; i++) {