author | zecke <zecke> | 2002-09-12 13:24:35 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-09-12 13:24:35 (UTC) |
commit | ff3af248587695ad5119057edc5e138acf2664e2 (patch) (side-by-side diff) | |
tree | d7b1bee54be6c2e4688458662e1980f820bd396e | |
parent | e2bc13b329b949f8d0f0d9c21903942d3929c4bb (diff) | |
download | opie-ff3af248587695ad5119057edc5e138acf2664e2.zip opie-ff3af248587695ad5119057edc5e138acf2664e2.tar.gz opie-ff3af248587695ad5119057edc5e138acf2664e2.tar.bz2 |
Ok I thought I removed that
ok now finally remove setRow code from todotable.h
This was committed accidently
-rw-r--r-- | core/pim/todo/todotable.cpp | 22 | ||||
-rw-r--r-- | core/pim/todo/todotable.h | 3 |
2 files changed, 13 insertions, 12 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 @@ -218,48 +218,49 @@ void DueTextItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bo } 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" ) ); + 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 ) ) ); @@ -300,33 +301,33 @@ void TodoTable::slotClicked( int row, int col, int, const QPoint &pos ) i->toggle(); } emit signalDoneChanged( i->isChecked() ); } } break; case 1: break; case 2: // Show detailed view of the selected entry { menuTimer->stop(); ToDoEvent *todo = todoList[static_cast<CheckItem*>(item(row, 0))]; emit showDetails( *todo ); } break; - case 3: + case 3: // may as well edit it... menuTimer->stop(); emit signalEdit(); break; } } void TodoTable::slotPressed( int row, int col, int, const QPoint &pos ) { if ( col == 2 && cellGeometry( row, col ).contains(pos) ) menuTimer->start( 750, TRUE ); } void TodoTable::slotShowMenu() { emit signalShowMenu( QCursor::pos() ); @@ -425,46 +426,49 @@ 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; @@ -586,33 +590,33 @@ void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action ) void TodoTable::rowHeightChanged( int row ) { if ( enablePainting ) QTable::rowHeightChanged( row ); } void TodoTable::loadFile( const QString &/*we use the standard*/ ) { QList<ToDoEvent> list; ToDoDB todoDB; QValueList<ToDoEvent> vaList = todoDB.rawToDos(); for(QValueList<ToDoEvent>::ConstIterator it = vaList.begin(); it != vaList.end(); ++it ){ ToDoEvent *event = new ToDoEvent( (*it) ); list.append( event ); - } + } vaList.clear(); // qDebug("parsing done=%d", t.elapsed() ); if ( list.count() > 0 ) { internalAddEntries( list ); list.clear(); } // qDebug("loading done: t=%d", t.elapsed() ); } void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row ) { QString strTodo = todo.summary(); if( strTodo.isEmpty() ){ strTodo = todo.description().left(40).simplifyWhiteSpace(); //todo.setSummary(strTodo ); } @@ -668,33 +672,33 @@ void TodoTable::keyPressEvent( QKeyEvent *e ) if ( i ) i->toggle(); break; } case 1: break; case 2:{ ToDoEvent *todo = todoList[static_cast<CheckItem*>(item(currentRow(), 0))]; emit showDetails(*todo); break; } case 3: // Future: Let us change the dueDate directly... emit signalEdit(); default: break; - } + } } else QTable::keyPressEvent( e ); } QStringList TodoTable::categories() { // This is called seldom, so calling a load in here // should be fine. mCat.load( categoryFileName() ); QStringList categoryList = mCat.labels( "Todo List" ); return categoryList; } void TodoTable::slotDoFind( const QString &findString, bool caseSensitive, bool backwards, int category ) @@ -745,33 +749,33 @@ void TodoTable::slotDoFind( const QString &findString, bool caseSensitive, setCurrentCell( currFindRow, numCols() - 1 ); // we should always be able to wrap around and find this again, // so don't give confusing not found message... wrapAround = true; } } int TodoTable::showCategoryId() const { int id; id = -1; // if allcategories are selected, you get unfiled... if ( showCat != tr( "Unfiled" ) && showCat != tr( "All" ) ) id = mCat.id( "Todo List", showCat ); return id; } -void TodoTable::applyJournal() +void TodoTable::applyJournal() { // we need to hack QFile file( journalFileName() ); if( file.open(IO_ReadOnly ) ) { QByteArray ar = file.readAll(); file.close(); QFile file2( journalFileName() + "_new" ); if( file2.open(IO_WriteOnly ) ){ QTextStream str(&file2 ); str << QString::fromLatin1("<Tasks>") << endl; str << ar.data(); str << QString::fromLatin1("</Tasks>") << endl; file2.close(); } XMLElement *root = XMLElement::load(journalFileName()+ "_new"); XMLElement *el = root->firstChild(); @@ -796,33 +800,33 @@ void TodoTable::applyJournal() tododb.replaceEvent( ev ); break; } } el = el->nextChild(); } QFile::remove(journalFileName()+ "_new" ); tododb.save(); } } void TodoTable::slotCheckDay() { QDate date = QDate::currentDate(); if( mDay.daysTo(date )!= 0 ){ setPaintingEnabled( FALSE ); for(int i=0; i < numRows(); i++ ){ - ToDoEvent *t = todoList[static_cast<CheckItem*>(item(i, 0))]; + ToDoEvent *t = todoList[static_cast<CheckItem*>(item(i, 0))]; static_cast<DueTextItem*>(item(i, 3) )->setToDoEvent( t ); } setPaintingEnabled( TRUE ); mDay = date; } mDayTimer->start( 60 * 1000 ); // 60 seconds } // check Action and decide /* void TodoTable::doApply(XMLElement *el ) { QString dummy; bool ok; int action; dummy = el->attribute("Action" ); @@ -905,34 +909,34 @@ static ToDoEvent xmlToEvent( XMLElement *element ) QDate date( year, month, day ); event.setDate( date); } dummy = element->attribute("Priority" ); dumInt = dummy.toInt(&ok ); if(!ok ) dumInt = ToDoEvent::NORMAL; event.setPriority( dumInt ); //description dummy = element->attribute("Description" ); event.setDescription( dummy ); // summary dummy = element->attribute("Summary" ); event.setSummary( dummy ); // category dummy = element->attribute("Categories" ); QStringList ids = QStringList::split(";", dummy ); - event.setCategories( ids ); - + event.setCategories( ids ); + //uid dummy = element->attribute("Uid" ); dumInt = dummy.toInt(&ok ); if(ok ) event.setUid( dumInt ); return event; } } // int TodoTable::rowHeight( int ) const // { // return 18; // } // int TodoTable::rowPos( int row ) const // { // return 18*row; diff --git a/core/pim/todo/todotable.h b/core/pim/todo/todotable.h index 7539df1..387dddb 100644 --- a/core/pim/todo/todotable.h +++ b/core/pim/todo/todotable.h @@ -179,35 +179,32 @@ private: QMap<CheckItem*, ToDoEvent *> todoList; QStringList categoryList; bool showComp; QString showCat; QTimer *menuTimer; QDate mDay; QTimer *mDayTimer; // see if the day changed bool enablePainting; Categories mCat; int currFindRow; bool showDeadl:1; }; inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row ) { - int rows = numRows(); - ++rows; - setNumRows( rows ); QString sortKey = (char) ((todo->isCompleted() ? 'a' : 'A') + todo->priority() ) + Qtopia::buildSortKey( todo->description() ); CheckItem *chk = new CheckItem( this, sortKey ); chk->setChecked( todo->isCompleted() ); ComboItem *cmb = new ComboItem( this, QTableItem::WhenCurrent ); cmb->setText( QString::number( todo->priority() ) ); QString sum = todo->summary(); QTableItem *ti = new TodoTextItem( this, sum.isEmpty() ? todo->description().left(40).simplifyWhiteSpace() : sum ); ti->setReplaceable( false ); DueTextItem *due = new DueTextItem(this, todo ); setItem( row, 3, due); setItem( row, 0, chk ); setItem( row, 1, cmb ); |