summaryrefslogtreecommitdiff
path: root/core/pim/todo/todotable.cpp
Side-by-side diff
Diffstat (limited to 'core/pim/todo/todotable.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/pim/todo/todotable.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/core/pim/todo/todotable.cpp b/core/pim/todo/todotable.cpp
index 779b28c..15f733b 100644
--- a/core/pim/todo/todotable.cpp
+++ b/core/pim/todo/todotable.cpp
@@ -186,96 +186,97 @@ QString DueTextItem::key() const
key.append("d");
}
return key;
}
void DueTextItem::setToDoEvent( const ToDoEvent *ev )
{
m_hasDate = ev->hasDate();
m_completed = ev->isCompleted();
if( ev->hasDate() ){
QDate today = QDate::currentDate();
m_off = today.daysTo(ev->date() );
//qWarning("DueText m_off=%d", m_off );
setText( QString::number(m_off) + " day(s) " );
}else{
setText("n.d." );
m_off = 0;
}
//qWarning("m_off=%d", m_off );
}
void DueTextItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected )
{
//qWarning ("paint m_off=%d", m_off );
QColorGroup cg2(cg);
QColor text = cg.text();
if( m_hasDate && !m_completed ){
if( m_off < 0 ){
cg2.setColor(QColorGroup::Text, QColor(red ) );
}else if( m_off == 0 ){
cg2.setColor(QColorGroup::Text, QColor(yellow) ); // orange isn't predefined
}else if( m_off > 0){
cg2.setColor(QColorGroup::Text, QColor(green ) );
}
}
QTableItem::paint(p, cg2, cr, selected );
cg2.setColor(QColorGroup::Text, text );
}
TodoTable::TodoTable( QWidget *parent, const char *name )
// #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR
// : QTable( 0, 3, parent, name, TRUE ),
// #else
: QTable( 0, 4, parent, name ),
// #endif
showComp( true ),
enablePainting( true ),
mCat( 0 ),
currFindRow( -2 ),
showDeadl( true)
{
+ setNumRows(0);
mCat.load( categoryFileName() );
setSorting( TRUE );
setSelectionMode( NoSelection );
setColumnStretchable( 2, TRUE );
setColumnWidth( 0, 20 );
setColumnWidth( 1, 35 );
setLeftMargin( 0 );
verticalHeader()->hide();
horizontalHeader()->setLabel( 0, tr( "C." ) );
horizontalHeader()->setLabel( 1, tr( "Prior." ) );
horizontalHeader()->setLabel( 2, tr( "Description" ) );
setColumnStretchable( 3, FALSE );
setColumnWidth( 3, 20 );
horizontalHeader()->setLabel( 3, tr( "Deadline" ) );
if (showDeadl){
showColumn (3);
}else{
hideColumn (3);
}
connect( this, SIGNAL( clicked( int, int, int, const QPoint & ) ),
this, SLOT( slotClicked( int, int, int, const QPoint & ) ) );
connect( this, SIGNAL( pressed( int, int, int, const QPoint & ) ),
this, SLOT( slotPressed( int, int, int, const QPoint & ) ) );
connect( this, SIGNAL( valueChanged( int, int ) ),
this, SLOT( slotCheckPriority( int, int ) ) );
connect( this, SIGNAL( currentChanged( int, int ) ),
this, SLOT( slotCurrentChanged( int, int ) ) );
menuTimer = new QTimer( this );
connect( menuTimer, SIGNAL(timeout()), this, SLOT(slotShowMenu()) );
mDayTimer = new QTimer( this );
connect( mDayTimer, SIGNAL(timeout()), this, SLOT(slotCheckDay() ) );
mDay = QDate::currentDate();
}
void TodoTable::addEntry( const ToDoEvent &todo )
{
int row = numRows();
setNumRows( row + 1 );
updateJournal( todo, ACTION_ADD );
insertIntoTable( new ToDoEvent(todo), row );
setCurrentCell(row, currentColumn());
updateVisible();
@@ -407,96 +408,99 @@ bool TodoTable::save( const QString &fn )
todoDB.addEvent( *todo );
}
if(!todoDB.save() ){
QFile::remove( strNewFile );
return false;
};
// now do the rename
if ( ::rename( strNewFile, fn ) < 0 )
qWarning( "problem renaming file %s to %s errno %d",
strNewFile.latin1(), fn.latin1(), errno );
// remove the journal
QFile::remove( journalFileName() );
return true;
}
void TodoTable::load( const QString &fn )
{
if ( QFile::exists(journalFileName()) ) {
applyJournal();
QFile::remove(journalFileName() );
}
loadFile( fn );
// QTable::sortColumn(2,TRUE,TRUE);
// QTable::sortColumn(1,TRUE,TRUE);
QTable::sortColumn(0,TRUE,TRUE);
setCurrentCell( 0, 2 );
setSorting(true );
mDayTimer->start( 60 * 1000 ); // gone in 60 seconds?
}
void TodoTable::updateVisible()
{
if ( !isUpdatesEnabled() )
return;
if (showDeadl){
showColumn (3);
adjustColumn(3);
}else{
hideColumn (3);
adjustColumn(2);
}
int visible = 0;
int id = mCat.id( "Todo List", showCat );
for ( int row = 0; row < numRows(); row++ ) {
CheckItem *ci = (CheckItem *)item( row, 0 );
ToDoEvent *t = todoList[ci];
+ if (!t)
+ continue;
+
QArray<int> vlCats = t->categories();
bool hide = false;
if ( !showComp && ci->isChecked() )
hide = true;
if ( !showCat.isEmpty() ) {
if ( showCat == tr( "Unfiled" ) ) {
if ( vlCats.count() > 0 )
hide = true;
} else {
// do some comparing, we have to reverse our idea here... which idea? - zecke
if ( !hide ) {
hide = true;
for ( uint it = 0; it < vlCats.count(); ++it ) {
if ( vlCats[it] == id ) {
hide = false;
break;
}
}
}
}
}
if ( hide ) {
if ( currentRow() == row )
setCurrentCell( -1, 0 );
if ( rowHeight( row ) > 0 )
hideRow( row );
} else {
if ( rowHeight( row ) == 0 ) {
showRow( row );
adjustRow( row );
}
visible++;
}
}
if ( !visible )
setCurrentCell( -1, 0 );
}
void TodoTable::viewportPaintEvent( QPaintEvent *pe )
{
if ( enablePainting )
QTable::viewportPaintEvent( pe );
}
void TodoTable::setPaintingEnabled( bool e )
{
if ( e != enablePainting ) {
if ( !enablePainting ) {