summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-04-02 08:36:37 (UTC)
committer zautrix <zautrix>2005-04-02 08:36:37 (UTC)
commite7cb4c20af8b07bf923c864026481ce316c40e1d (patch) (side-by-side diff)
treec88b2d0c01ce683e73ea9f4657f4d5c6fbe6f922 /korganizer
parent7aefe488d1fe0c34cf29460f48a9a97d632f615e (diff)
downloadkdepimpi-e7cb4c20af8b07bf923c864026481ce316c40e1d.zip
kdepimpi-e7cb4c20af8b07bf923c864026481ce316c40e1d.tar.gz
kdepimpi-e7cb4c20af8b07bf923c864026481ce316c40e1d.tar.bz2
more fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp86
-rw-r--r--korganizer/kodaymatrix.cpp8
2 files changed, 81 insertions, 13 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 2b05d37..8d32152 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -17,301 +17,365 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#include <qhbox.h>
#include <qvbox.h>
#include <qlabel.h>
#include <qframe.h>
#include <qlayout.h>
#ifndef KORG_NOSPLITTER
#include <qsplitter.h>
#endif
#include <qfont.h>
#include <qfontmetrics.h>
#include <qpopupmenu.h>
#include <qtooltip.h>
#include <qpainter.h>
#include <qpushbutton.h>
#include <qapplication.h>
#include <kapplication.h>
#include <KDGanttMinimizeSplitter.h>
#include <kdebug.h>
#include <kstandarddirs.h>
#include <kiconloader.h>
#include <klocale.h>
#include <kconfig.h>
#include <kglobal.h>
#include "calendarview.h"
#include "koviewmanager.h"
#include <libkcal/calendar.h>
#include <libkcal/icaldrag.h>
#include <libkcal/dndfactory.h>
#include <kcalendarsystem.h>
#include "koglobals.h"
#ifndef KORG_NOPLUGINS
#include "kocore.h"
#endif
#include "koprefs.h"
#include "koagenda.h"
#include "koagendaitem.h"
#ifndef KORG_NOPRINTER
#include "calprinter.h"
#endif
#include "koagendaview.h"
//#include "koagendaview.moc"
//extern bool globalFlagBlockPainting;
extern int globalFlagBlockAgenda;
extern int globalFlagBlockStartup;
extern int globalFlagBlockAgendaItemPaint;
extern int globalFlagBlockAgendaItemUpdate;
extern int globalFlagBlockLabel;
using namespace KOrg;
TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) :
QScrollView(parent,name,f)
{
myPix.resize( 1, 1 );
mRows = rows;
mRedrawNeeded = true;
setMinimumHeight( 20 );
mCellHeight = KOPrefs::instance()->mHourSize*4;
enableClipper(true);
setHScrollBarMode(AlwaysOff);
setVScrollBarMode(AlwaysOff);
resizeContents(50,mRows * mCellHeight);
viewport()->setBackgroundMode( PaletteBackground );
}
void TimeLabels::setCellHeight(int height)
{
mCellHeight = height;
}
/*
Optimization so that only the "dirty" portion of the scroll view
is redrawn. Unfortunately, this is not called by default paintEvent() method.
*/
void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
{
- // if ( globalFlagBlockAgenda )
- // return;
- // bug: the parameters cx, cy, cw, ch are the areas that need to be
- // redrawn, not the area of the widget. unfortunately, this
- // code assumes the latter...
-
- // now, for a workaround...
- // these two assignments fix the weird redraw bug
+ cx = contentsX() + frameWidth()*2;
+ cw = contentsWidth() ;
+ // end of workaround
+
+ int cell = ((int)(cy/mCellHeight));
+ int y = cell * mCellHeight;
+ QFontMetrics fm = fontMetrics();
+ QString hour;
+ QString suffix = "am";
+ int timeHeight = fm.ascent();
+ QFont nFont = p->font();
+
+ if (!KGlobal::locale()->use12Clock()) {
+ if ( QApplication::desktop()->width() <= 320 )
+ suffix = "00";
+ else
+ suffix = "00";
+ }
+
+ if ( timeHeight > mCellHeight ) {
+ timeHeight = mCellHeight-1;
+ int pointS = nFont.pointSize();
+ while ( pointS > 4 ) {
+ nFont.setPointSize( pointS );
+ fm = QFontMetrics( nFont );
+ if ( fm.ascent() < mCellHeight )
+ break;
+ -- pointS;
+ }
+ fm = QFontMetrics( nFont );
+ timeHeight = fm.ascent();
+ }
+ //timeHeight -= (timeHeight/4-2);
+ QFont sFont = nFont;
+ sFont.setPointSize( sFont.pointSize()/2 );
+ QFontMetrics fmS( sFont );
+ int sHei = fmS.ascent() ;
+ //sHei -= (sHei/4-2);
+ int startW = this->width() - frameWidth()-2;
+ int tw2 = fmS.width(suffix);
+ timeHeight = (timeHeight-1) /2 -1;
+ while (y < cy + ch+mCellHeight) {
+ p->drawLine(startW-tw2+1 ,y,cw,y);
+ hour.setNum(cell);
+ // handle 24h and am/pm time formats
+ if (KGlobal::locale()->use12Clock()) {
+ if (cell > 11) suffix = "pm";
+ else
+ suffix = "am";
+ if (cell == 0) hour.setNum(12);
+ if (cell > 12) hour.setNum(cell - 12);
+ }
+
+ // center and draw the time label
+ int timeWidth = fm.width(hour);
+ int offset = startW - timeWidth - tw2 ;
+ p->setFont( nFont );
+ p->drawText( offset, y+ timeHeight, hour);
+ p->setFont( sFont );
+ offset = startW - tw2+1;
+ p->drawText( offset, y -1, suffix);
+
+ // increment indices
+ y += mCellHeight;
+ cell++;
+ }
+
+
+
+
+#if 0
mRedrawNeeded = true;
if ( mRedrawNeeded ) {
cx = contentsX() + frameWidth()*2;
cw = contentsWidth() ;
// end of workaround
int cell = ((int)(cy/mCellHeight));
int y = cell * mCellHeight;
QFontMetrics fm = fontMetrics();
QString hour;
QString suffix;
int timeHeight = fm.ascent();
QFont nFont = p->font();
if (!KGlobal::locale()->use12Clock()) {
if ( QApplication::desktop()->width() <= 320 )
suffix = "";
else
suffix = "00";
}
if ( timeHeight > mCellHeight ) {
timeHeight = mCellHeight-1;
int pointS = nFont.pointSize();
while ( pointS > 4 ) {
nFont.setPointSize( pointS );
fm = QFontMetrics( nFont );
if ( fm.ascent() < mCellHeight )
break;
-- pointS;
}
fm = QFontMetrics( nFont );
timeHeight = fm.ascent();
}
//timeHeight -= (timeHeight/4-2);
QFont sFont = nFont;
sFont.setPointSize( sFont.pointSize()/2 );
QFontMetrics fmS( sFont );
int sHei = fmS.ascent() ;
//sHei -= (sHei/4-2);
int startW = this->width() - frameWidth()-2;
int tw2 = fmS.width(suffix);
while (y < cy + ch) {
p->drawLine(cx,y,cw,y);
hour.setNum(cell);
// handle 24h and am/pm time formats
if (KGlobal::locale()->use12Clock()) {
if (cell > 11) suffix = "pm";
else
suffix = "am";
if (cell == 0) hour.setNum(12);
if (cell > 12) hour.setNum(cell - 12);
tw2 = fmS.width(suffix);
}
// center and draw the time label
int timeWidth = fm.width(hour);
int offset = startW - timeWidth - tw2 ;
p->setFont( nFont );
p->drawText( offset, y+ timeHeight, hour);
p->setFont( sFont );
offset = startW - tw2+1;
p->drawText( offset, y+ sHei, suffix);
// increment indices
y += mCellHeight;
cell++;
}
} else {
//qDebug("NO redraw ");
}
// double buffer not yet implemented
//bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP);
//mRedrawNeeded = false;
+#endif
}
/**
Calculates the minimum width.
*/
int TimeLabels::minimumWidth() const
{
return mMiniWidth;
}
/** updates widget's internal state */
void TimeLabels::updateConfig()
{
mRedrawNeeded = true;
// set the font
// config->setGroup("Fonts");
// QFont font = config->readFontEntry("TimeBar Font");
setFont(KOPrefs::instance()->mTimeBarFont);
QString test = "20";
if (KGlobal::locale()->use12Clock())
test = "12";
mMiniWidth = fontMetrics().width(test);
if (KGlobal::locale()->use12Clock())
test = "pm";
else {
if ( QApplication::desktop()->width() <= 320 )
- test = "";
+ test = "00";
else
test = "00";
}
QFont sFont = font();
sFont.setPointSize( sFont.pointSize()/2 );
QFontMetrics fmS( sFont );
mMiniWidth += fmS.width( test ) + frameWidth()*2 +4 ;
// update geometry restrictions based on new settings
setFixedWidth( mMiniWidth );
// update HourSize
mCellHeight = KOPrefs::instance()->mHourSize*4;
resizeContents(50,mRows * mCellHeight);
}
/** update time label positions */
void TimeLabels::positionChanged()
{
int adjustment = mAgenda->contentsY();
setContentsPos(0, adjustment);
}
/** */
void TimeLabels::setAgenda(KOAgenda* agenda)
{
mAgenda = agenda;
}
void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
{
mMouseDownY = e->pos().y();
mOrgCap = topLevelWidget()->caption();
}
void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
{
int diff = mMouseDownY - e->pos().y();
if ( diff < 10 && diff > -10 )
return;
int tSize = KOPrefs::instance()->mHourSize + (diff/10) ;
if ( tSize < 4 )
tSize = 4;
if ( tSize > 22 )
tSize = 22;
tSize = (tSize-2)/2;
topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
}
void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
{
topLevelWidget()->setCaption( mOrgCap );
int diff = mMouseDownY - e->pos().y();
if ( diff < 10 && diff > -10 )
return;
int tSize = KOPrefs::instance()->mHourSize + (diff/10);
if ( tSize < 4 )
tSize = 4;
if ( tSize > 22 )
tSize = 22;
tSize = (tSize/2)*2;
if ( tSize == KOPrefs::instance()->mHourSize )
return;
KOPrefs::instance()->mHourSize = tSize;
emit scaleChanged();
}
/** This is called in response to repaint() */
void TimeLabels::paintEvent(QPaintEvent*)
{
// kdDebug() << "paintevent..." << endl;
// this is another hack!
// QPainter painter(this);
//QString c
repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
}
////////////////////////////////////////////////////////////////////////////
EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
: QFrame(parent,name)
{
mColumns = 1;
mTopBox = 0;
mLocation = loc;
mTopLayout = 0;
mPaintWidget = 0;
mXOffset = 0;
if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
else mPixmap = SmallIcon("1downarrow");
mEnabled.resize(mColumns);
mEnabled.fill( false );
setMinimumHeight(mPixmap.height());
}
EventIndicator::~EventIndicator()
@@ -581,253 +645,257 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
//connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
}
void KOAgendaView::toggleAllDay()
{
if ( mSplitterAgenda->firstHandle() )
mSplitterAgenda->firstHandle()->toggle();
}
void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
{
calendar()->addIncidence( inc );
if ( incOld ) {
if ( incOld->type() == "Todo" )
emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
else
emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
}
}
KOAgendaView::~KOAgendaView()
{
delete mAgendaPopup;
delete mAllDayAgendaPopup;
delete KOAgendaItem::paintPix();
delete KOAgendaItem::paintPixSel();
}
void KOAgendaView::resizeEvent( QResizeEvent* e )
{
//qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
bool uc = false;
int ow = e->oldSize().width();
int oh = e->oldSize().height();
int w = e->size().width();
int h = e->size().height();
if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
uc = true;
//qDebug("view changed %d %d %d %d ", ow, oh , w , h);
}
mUpcomingWidth = e->size().width() ;
if ( mBlockUpdating || uc ) {
mBlockUpdating = false;
//mAgenda->setMinimumSize(800 , 600 );
//qDebug("mAgenda->resize+++++++++++++++ ");
updateConfig();
//qDebug("KOAgendaView::Updating now possible ");
} else
createDayLabels();
//qDebug("resizeEvent end ");
}
void KOAgendaView::slotDaylabelClicked( int num )
{
QDate firstDate = mSelectedDates.first();
if ( num == -1 )
emit showDateView( 6, firstDate );
else if (num >= 0 ) {
if ( mSelectedDates.count() == 1)
emit showDateView( 9, firstDate.addDays( num ) );
else
emit showDateView( 3, firstDate.addDays( num ) );
}
else
showDateView( 10, firstDate.addDays(1) );
}
KOAgendaButton* KOAgendaView::getNewDaylabel()
{
KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
mDayLabelsList.append( dayLabel );
mLayoutDayLabels->addWidget(dayLabel);
return dayLabel ;
}
void KOAgendaView::createDayLabels()
{
if ( mBlockUpdating || globalFlagBlockLabel == 1) {
// qDebug(" KOAgendaView::createDayLabels() blocked ");
return;
}
int newHight;
// ### Before deleting and recreating we could check if mSelectedDates changed...
// It would remove some flickering and gain speed (since this is called by
// each updateView() call)
int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2;
+ if ( QApplication::desktop()->width() <= 320 )
+ maxWid -= 10;
mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
if ( maxWid < 0 )
maxWid = 20;
QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
QFontMetrics fm ( dlf );
int selCount = mSelectedDates.count();
QString dayTest = "Mon 20";
//QString dayTest = "Mon 20";
int wid = fm.width( dayTest );
//maxWid -= ( selCount * 3 ); //working for QLabels
maxWid -= ( selCount * 3 ); //working for QPushButton
if ( maxWid < 0 )
maxWid = 20;
int needWid = wid * selCount;
//qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
//if ( needWid > maxWid )
// qDebug("DAYLABELS TOOOOOOO BIG ");
while ( needWid > maxWid ) {
dayTest = dayTest.left( dayTest.length() - 1 );
wid = fm.width( dayTest );
needWid = wid * selCount;
}
int maxLen = dayTest.length();
int fontPoint = dlf.pointSize();
if ( maxLen < 2 ) {
int fontPoint = dlf.pointSize();
while ( fontPoint > 4 ) {
--fontPoint;
dlf.setPointSize( fontPoint );
QFontMetrics f( dlf );
wid = f.width( "30" );
needWid = wid * selCount;
if ( needWid < maxWid )
break;
}
maxLen = 2;
}
//qDebug("Max len %d ", dayTest.length() );
QFontMetrics tempF( dlf );
newHight = tempF.height();
mDayLabels->setFont( dlf );
// mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
// mLayoutDayLabels->addSpacing(mTimeLabels->width());
//mLayoutDayLabels->addSpacing( 2 );
// QFont lFont = dlf;
bool appendLabels = false;
KOAgendaButton *dayLabel;
dayLabel = mDayLabelsList.first();
if ( !dayLabel ) {
appendLabels = true;
dayLabel = getNewDaylabel();
}
dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() );
dayLabel->setFont( dlf );
dayLabel->setNum( -1 );
//dayLabel->setAlignment(QLabel::AlignHCenter);
+#if 0
if ( QApplication::desktop()->width() <= 320 )
dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) );
else
+#endif
dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
dayLabel->show();
DateList::ConstIterator dit;
bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
int counter = -1;
for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
++counter;
QDate date = *dit;
// QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
if ( ! appendLabels ) {
dayLabel = mDayLabelsList.next();
if ( !dayLabel )
appendLabels = true;
}
if ( appendLabels ) {
dayLabel = getNewDaylabel();
}
dayLabel->setMinimumWidth( 1 );
dayLabel->setMaximumWidth( 10240 );
dayLabel->setFont( dlf );
dayLabel->show();
dayLabel->setAutoRepeat( false );
dayLabel->setNum( counter );
QString str;
int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
switch ( maxLen ) {
case 2:
str = QString::number( date.day() );
break;
case 3:
str = dayName.left( 1 ) +QString::number( date.day());
break;
case 4:
str = dayName.left( 1 ) + " " +QString::number( date.day());
break;
case 5:
str = dayName.left( 2 ) + " " +QString::number( date.day());
break;
case 6:
str = dayName.left( 3 ) + " " +QString::number( date.day());
break;
default:
break;
}
if ( oneday ) {
QString addString;
if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
addString = i18n("Today");
else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
addString = i18n("Tomorrow");
else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
addString = i18n("Yesterday");
else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
addString = i18n("Day before yesterday");
else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
addString = i18n("Day after tomorrow");
if ( !addString.isEmpty() ) {
str = addString+", " + str;
} else {
str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer);
}
}
dayLabel->setText(str);
//dayLabel->setAlignment(QLabel::AlignHCenter);
if (date == QDate::currentDate()) {
QFont bFont = dlf;
bFont.setBold( true );
dayLabel->setFont(bFont);
}
//dayLayout->addWidget(dayLabel);
#ifndef KORG_NOPLUGINS
CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
CalendarDecoration *it;
for(it = cds.first(); it; it = cds.next()) {
QString text = it->shortText( date );
if ( !text.isEmpty() ) {
QLabel *label = new QLabel(text,mDayLabels);
label->setAlignment(AlignCenter);
dayLayout->addWidget(label);
}
}
for(it = cds.first(); it; it = cds.next()) {
QWidget *wid = it->smallWidget(mDayLabels,date);
if ( wid ) {
// wid->setHeight(20);
dayLayout->addWidget(wid);
}
}
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index b8a0f09..8affe50 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -674,208 +674,208 @@ void KODayMatrix::dropEvent(QDropEvent *e)
// P A I N T E V E N T H A N D L I N G
// ----------------------------------------------------------------------------
void KODayMatrix::paintEvent(QPaintEvent * pevent)
{
if ( width() <= 0 || height() <= 0 )
return;
if ( mPendingUpdateBeforeRepaint ) {
updateViewTimed();
mPendingUpdateBeforeRepaint = false;
}
if ( myPix.width() != width() || myPix.height()!=height() ) {
myPix.resize(size() );
mRedrawNeeded = true;
}
if ( mRedrawNeeded ) {
//qDebug("REDRAW ");
QPainter p(&myPix);
p.setFont(font());
int dheight = daysize.height();
int dwidth = daysize.width();
int row,col;
int selw, selh;
int xyOff = frameWidth();
int colModulo = (width()-2) % 7;
int rowModulo = (height()-2) % 6;
//qDebug("col %d row %d ",colModulo,rowModulo );
bool isRTL = KOGlobals::self()->reverseLayout();
// draw background and topleft frame
p.fillRect(0,0,width(),height(), mDefaultBackColor);
p.setPen(mDefaultTextColor);
p.drawRect(0, 0, width(), height());
int mSelStartT = mSelStart;
int mSelEndT = mSelEnd;
if ( mSelEndT >= NUMDAYS )
mSelEndT = NUMDAYS-1;
// draw selected days with highlighted background color
if (mSelStart != NOSELECTION) {
bool skip = false;
if ( ! mouseDown ) {
int mo = days[20].month();
//qDebug("-- %d %d ", mSelStartT, mSelEndT);
//qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() );
int startMo = days[mSelStartT].month();
int endMo = days[mSelEndT].month();
if ( startMo == 12 && mo == 1 && endMo <= 2 )
startMo = 1;
if ( endMo == 1 && mo == 12 )
endMo = 12;
if ( mo == 12 && startMo == 1 )
startMo = 13;
if ( (startMo > mo || endMo < mo) ) {
skip = true;
} else {
if ( days[mSelStartT].month() != mo ) {
int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day();
mSelStartT += add +1;
}
if ( days[mSelEndT].month() != mo ) {
int sub = days[mSelEndT].day();
mSelEndT -= sub ;
}
}
}
//qDebug("SKIP %d ", skip);
if ( ! skip ) {
row = mSelStartT/7;
col = mSelStartT -row*7;
QColor selcol = KOPrefs::instance()->mHighlightColor;
int addCol = 0;
int addRow = 0;
int addRow2 = 0;
int addCol2 = 0;
if (row == mSelEndT/7) {
if ( rowModulo ) {
if ( row >= 6 - rowModulo )
addRow = row - 5 + rowModulo;
}
if ( colModulo ) {
int colt1 = mSelEndT%7;
//qDebug("colt1 %d ", colt1 );
if ( colt1 >= 7 - colModulo )
addCol = colt1 - 7 + colModulo+1;
int colt = mSelStartT%7;
if ( colt >= 7 - colModulo )
addCol2 = colt - 7 + colModulo;
addCol -= addCol2;
//qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 );
}
// Single row selection
- if ( row == 0)
- addRow = 1;
+ //if ( row == 0)
+ // addRow = 1;
p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2,
row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol);
} else {
// draw first row to the right
if ( colModulo ) {
if ( col >= 7 - colModulo )
addCol2 = col - 7 + colModulo;
}
if ( rowModulo ) {
if ( row >= 6 - rowModulo )
addRow = row - 5 + rowModulo;
}
- if ( row == 0)
- addRow = 1;
+ //if ( row == 0)
+ // addRow = 1;
int drawWid = width()-(col*dwidth+1+addCol2)-1;
p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid,
dheight+1, selcol);
// draw full block till last line
selh = mSelEndT/7-row;
addRow = 0;
if ( rowModulo ) {
if ( mSelEndT/7 >= 6 - rowModulo )
addRow = mSelEndT/7 - 5 + rowModulo;
}
//qDebug("%d %d %d ",selh, row, addRow );
int addrow2 = addRow-selh+1;
if ( addrow2 < 0 )
addrow2 = 0;
if (selh > 1) {
p.fillRect(1, (row+1)*dheight+addrow2, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol);
}
// draw last block from left to mSelEndT
selw = mSelEndT-7*(mSelEndT/7)+1;
//qDebug("esl %d ",selw );
int add = 0;
if ( colModulo ) {
add = 7 - colModulo;
if ( selw > add )
add = selw - add;
else
add = 0;
}
//qDebug("add %d ", add);
p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow,
selw*dwidth+add, dheight+1, selcol);
}
}
}
// iterate over all days in the matrix and draw the day label in appropriate colors
QColor actcol = mDefaultTextColorShaded;
p.setPen(actcol);
QPen tmppen;
for(int i = 0; i < NUMDAYS; i++) {
row = i/7;
col = isRTL ? 6-(i-row*7) : i-row*7;
// if it is the first day of a month switch color from normal to shaded and vice versa
if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) {
if (actcol == mDefaultTextColorShaded) {
actcol = mDefaultTextColor;
} else {
actcol = mDefaultTextColorShaded;
}
p.setPen(actcol);
}
if (actcol == mDefaultTextColorShaded) {
if ( ! mouseDown ) {
continue;
}
}
//Reset pen color after selected days block
if (i == mSelEndT+1) {
p.setPen(actcol);
}
// if today then draw rectangle around day
if (today == i) {
tmppen = p.pen();
QPen mTodayPen(p.pen());
if ( daysize.width() < 20 )
mTodayPen.setWidth(1);
else
mTodayPen.setWidth(mTodayMarginWidth);
//draw red rectangle for holidays
if (!mHolidays[i].isNull()) {
if (actcol == mDefaultTextColor) {
mTodayPen.setColor(KOPrefs::instance()->mHolidayColor);
} else {
mTodayPen.setColor(mHolidayColorShaded);
}
}
//draw gray rectangle for today if in selection
if (i >= mSelStartT && i <= mSelEndT) {
QColor grey("grey");
mTodayPen.setColor(grey);
}
p.setPen(mTodayPen);
int addCol = 0;
int addRow = 0;
if (rowModulo) {
if ( row >= 6 - rowModulo )
addRow = row - 5 + rowModulo;
}
if ( colModulo ) {
if ( col >= 7 - colModulo )
addCol = col - 6 + colModulo-1;
}