summaryrefslogtreecommitdiff
authorzecke <zecke>2002-04-15 20:55:49 (UTC)
committer zecke <zecke>2002-04-15 20:55:49 (UTC)
commit943f0de13f6b017e67d0289c7273ddbf496a2cff (patch) (side-by-side diff)
treeed28fa2c3632ce672b31edff10ecf08356d35f64
parente010d922ac415558e5efd35e69e39e45908b5501 (diff)
downloadopie-943f0de13f6b017e67d0289c7273ddbf496a2cff.zip
opie-943f0de13f6b017e67d0289c7273ddbf496a2cff.tar.gz
opie-943f0de13f6b017e67d0289c7273ddbf496a2cff.tar.bz2
journal is in place again
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/TODO2
-rw-r--r--core/pim/todo/mainwindow.cpp2
-rw-r--r--core/pim/todo/todoentryimpl.cpp6
-rw-r--r--core/pim/todo/todotable.cpp48
-rw-r--r--core/pim/todo/todotable.h5
5 files changed, 38 insertions, 25 deletions
diff --git a/core/pim/todo/TODO b/core/pim/todo/TODO
index 040f163..7601dd2 100644
--- a/core/pim/todo/TODO
+++ b/core/pim/todo/TODO
@@ -1,4 +1,4 @@
--fix the journal
+-fix the journal (wip )
-fix day wrapping update all DueDateItems
-when checking the C. box update the deadline
-TodoLabel : public TextView
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index 883d78c..fc17c5f 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -269,17 +269,17 @@ void TodoWindow::slotNew()
NewTaskDialog e( id, this, 0, TRUE );
ToDoEvent todo;
#if defined(Q_WS_QWS) || defined(_WS_QWS_)
e.showMaximized();
#endif
int ret = e.exec();
- qWarning("finished" );
+// qWarning("finished" );
if ( ret == QDialog::Accepted ) {
table->setPaintingEnabled( false );
todo = e.todoEntry();
//todo.assignUid();
table->addEntry( todo );
table->setPaintingEnabled( true );
findAction->setEnabled( TRUE );
}
diff --git a/core/pim/todo/todoentryimpl.cpp b/core/pim/todo/todoentryimpl.cpp
index f938d61..26a685c 100644
--- a/core/pim/todo/todoentryimpl.cpp
+++ b/core/pim/todo/todoentryimpl.cpp
@@ -42,17 +42,16 @@
#include <qapplication.h>
NewTaskDialog::NewTaskDialog( const ToDoEvent& task, QWidget *parent,
const char *name, bool modal, WFlags fl )
: NewTaskDialogBase( parent, name, modal, fl ),
todo( task )
{
- qWarning("setting category" );
todo.setCategories( task.allCategories() );
if ( todo.hasDate() )
date = todo.date();
else
date = QDate::currentDate();
init();
comboPriority->setCurrentItem( task.priority() - 1 );
@@ -99,43 +98,39 @@ void NewTaskDialog::init()
picker->setDate( date.year(), date.month(), date.day() );
}
/*
* Destroys the object and frees any allocated resources
*/
NewTaskDialog::~NewTaskDialog()
{
- qWarning("d'tor" );
// no need to delete child widgets, Qt does it all for us
}
void NewTaskDialog::dateChanged( int y, int m, int d )
{
date = QDate( y, m, d );
buttonDate->setText( TimeString::longDateString( date ) );
}
/*!
*/
ToDoEvent NewTaskDialog::todoEntry()
{
- qWarning("todoEntry()" );
if( checkDate->isChecked() ){
todo.setDate( date );
todo.setHasDate( true );
}else{
todo.setHasDate( false );
}
- qWarning("todoEntry::category()" );
if ( comboCategory->currentCategory() != -1 ) {
QArray<int> arr = comboCategory->currentCategories();
QStringList list;
list = QStringList::split(";", Qtopia::Record::idsToString( arr )) ;
- qWarning("saving category");
todo.setCategories( list );
}
todo.setPriority( comboPriority->currentItem() + 1 );
todo.setCompleted( checkCompleted->isChecked() );
todo.setDescription( txtTodo->text() );
return todo;
@@ -143,17 +138,16 @@ ToDoEvent NewTaskDialog::todoEntry()
/*!
*/
void NewTaskDialog::accept()
{
- qWarning("accept" );
QString strText = txtTodo->text();
if ( strText.isEmpty() ) {
// hmm... just decline it then, the user obviously didn't care about it
QDialog::reject();
return;
}
QDialog::accept();
}
diff --git a/core/pim/todo/todotable.cpp b/core/pim/todo/todotable.cpp
index 401d2c8..96cd860 100644
--- a/core/pim/todo/todotable.cpp
+++ b/core/pim/todo/todotable.cpp
@@ -347,17 +347,17 @@ ToDoEvent TodoTable::currentEntry() const
todo->setCompleted( ( (CheckItem*)item( currentRow(), 0 ) )->isChecked() );
todo->setPriority( ( (ComboItem*)item( currentRow(), 1 ) )->text().toInt() );
return *todo;
}
void TodoTable::replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem )
{
int row = currentRow();
- updateJournal( todo, ACTION_REPLACE, row );
+ updateJournal( todo, ACTION_REPLACE);
if ( !fromTableItem ) {
journalFreeReplaceEntry( todo, row );
updateVisible();
}
}
void TodoTable::removeCurrentEntry()
@@ -370,17 +370,17 @@ void TodoTable::removeCurrentEntry()
if ( !chk )
return;
oldTodo = todoList[chk];
todoList.remove( chk );
oldTodo->setCompleted( chk->isChecked() );
oldTodo->setPriority( static_cast<ComboItem*>(item(row, 1))->text().toInt() );
realignTable( row );
updateVisible();
- updateJournal( *oldTodo, ACTION_REMOVE, row );
+ updateJournal( *oldTodo, ACTION_REMOVE);
delete oldTodo;
}
bool TodoTable::save( const QString &fn )
{
QString strNewFile = fn + ".new";
QFile::remove( strNewFile ); // just to be sure
@@ -406,21 +406,21 @@ bool TodoTable::save( const QString &fn )
// remove the journal
QFile::remove( journalFileName() );
return true;
}
void TodoTable::load( const QString &fn )
{
- loadFile( fn, false );
- if ( QFile::exists(journalFileName()) ) {
- applyJournal( );
- save( 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 );
}
void TodoTable::updateVisible()
{
@@ -496,18 +496,18 @@ void TodoTable::setPaintingEnabled( bool e )
}
}
}
void TodoTable::clear()
{
for ( QMap<CheckItem*, ToDoEvent *>::Iterator it = todoList.begin();
it != todoList.end(); ++it ) {
- ToDoEvent *todo = *it;
- updateJournal( todo, ACTION_REMOVE, 0 );
+ ToDoEvent *todo = it.data();
+ updateJournal( *todo, ACTION_REMOVE );
delete todo;
}
todoList.clear();
for ( int r = 0; r < numRows(); ++r ) {
for ( int c = 0; c < numCols(); ++c ) {
if ( cellWidget( r, c ) )
clearCellWidget( r, c );
clearCell( r, c );
@@ -532,17 +532,17 @@ void TodoTable::slotCheckPriority(int row, int col )
if ( col == 1 ) {
// let everyone know!!
ComboItem* i = static_cast<ComboItem*>( item( row, col ) );
emit signalPriorityChanged( i->text().toInt() );
}
}
-void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action, int row )
+void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action )
{
QFile f( journalFileName() );
if ( !f.open(IO_WriteOnly|IO_Append) )
return;
QString buf;
QCString str;
buf = "<Task";
// todo.save( buf );
@@ -572,17 +572,17 @@ void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action, int
}
void TodoTable::rowHeightChanged( int row )
{
if ( enablePainting )
QTable::rowHeightChanged( row );
}
-void TodoTable::loadFile( const QString &strFile, bool fromJournal )
+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 ){
list.append( new ToDoEvent( (*it) ) );
}
@@ -749,25 +749,45 @@ void TodoTable::applyJournal()
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();
el = el->firstChild();
+ ToDoDB tododb; // allready loaded ;)
+ bool ok;
+ int action;
+ QString dummy;
while( el ){
- qWarning("journal: %s %s", el->attribute("Uid" ).latin1(), el->tagName().latin1() );
- doApply( el );
+ dummy = el->attribute("Action" );
+ action = dummy.toInt(&ok );
+ ToDoEvent ev = xmlToEvent( el );
+ if(ok ){
+ switch( action){
+ case ACTION_ADD:
+ tododb.addEvent(ev );
+ break;
+ case ACTION_REMOVE:
+ tododb.removeEvent( ev );
+ break;
+ case ACTION_REPLACE:
+ tododb.replaceEvent( ev );
+ break;
+ }
+ }
el = el->nextChild();
}
QFile::remove(journalFileName()+ "_new" );
+ tododb.save();
}
}
// check Action and decide
+/*
void TodoTable::doApply(XMLElement *el )
{
QString dummy;
bool ok;
int action;
dummy = el->attribute("Action" );
action = dummy.toInt(&ok );
ToDoEvent ev = xmlToEvent( el );
@@ -779,16 +799,17 @@ void TodoTable::doApply(XMLElement *el )
case ACTION_REMOVE:{ // find an entry with the same uid and remove it then
break;
}
case ACTION_REPLACE:
break;
}
}
}
+*/
namespace {
static bool taskCompare( const ToDoEvent &task, const QRegExp &r, int category )
{
bool returnMe;
QArray<int> cats;
cats = task.categories();
returnMe = false;
@@ -858,17 +879,16 @@ static ToDoEvent xmlToEvent( XMLElement *element )
dummy = element->attribute("Categories" );
QStringList ids = QStringList::split(";", dummy );
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;
// }
diff --git a/core/pim/todo/todotable.h b/core/pim/todo/todotable.h
index 6917e04..6e371e8 100644
--- a/core/pim/todo/todotable.h
+++ b/core/pim/todo/todotable.h
@@ -146,23 +146,22 @@ signals:
protected:
void keyPressEvent( QKeyEvent *e );
private:
void updateVisible();
void viewportPaintEvent( QPaintEvent * );
void internalAddEntries( QList<ToDoEvent> &list);
inline void insertIntoTable( ToDoEvent *todo, int row );
- void updateJournal( const ToDoEvent &todo, journal_action action, int row = -1);
+ void updateJournal( const ToDoEvent &todo, journal_action action);
void mergeJournal();
void journalFreeReplaceEntry( const ToDoEvent &todo, int row );
void journalFreeRemoveEntry( int row );
inline void realignTable( int row );
- void loadFile( const QString &strFile, bool fromJournal = false );
- void doApply(XMLElement *el );
+ void loadFile( const QString &strFile);
private slots:
void slotClicked( int row, int col, int button, const QPoint &pos );
void slotPressed( int row, int col, int button, const QPoint &pos );
void slotCheckPriority(int row, int col );
void slotCurrentChanged(int row, int col );
void slotDoFind( const QString &findString, bool caseSensetive,
bool backwards, int category );