author | zecke <zecke> | 2003-03-14 08:20:59 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-03-14 08:20:59 (UTC) |
commit | 7e04934c4b7b9f8ad0d74d2da1c7c1273d9fe1d4 (patch) (side-by-side diff) | |
tree | 9d8cb73a1b6013ab409b496cf2b99503f239c0c9 | |
parent | 08094624777d78bcd09f6ba6e2157599960ef7f3 (diff) | |
download | opie-7e04934c4b7b9f8ad0d74d2da1c7c1273d9fe1d4.zip opie-7e04934c4b7b9f8ad0d74d2da1c7c1273d9fe1d4.tar.gz opie-7e04934c4b7b9f8ad0d74d2da1c7c1273d9fe1d4.tar.bz2 |
Do not crash when trying to edit and there is no data
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 3 | ||||
-rw-r--r-- | core/pim/todo/tableview.cpp | 1 |
2 files changed, 3 insertions, 1 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index 7810285..58981ca 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp @@ -609,48 +609,49 @@ bool MainWindow::showQuickTask()const { } QString MainWindow::currentCategory()const { return m_curCat; } int MainWindow::currentCatId() { return m_todoMgr.catId( m_curCat ); } ViewBase* MainWindow::currentView() { return m_curView; } void MainWindow::raiseCurrentView() { m_stack->raiseWidget( m_curView->widget() ); } void MainWindow::slotShowDue(bool ov) { m_overdue = ov; currentView()->showOverDue( ov ); raiseCurrentView(); } void MainWindow::slotShow( int uid ) { qWarning("slotShow"); currentShow()->slotShow( event( uid ) ); m_stack->raiseWidget( currentShow()->widget() ); } void MainWindow::slotEdit( int uid ) { + if (uid == 1 ) return; if(m_syncing) { QMessageBox::warning(this, QWidget::tr("Todo"), QWidget::tr("Can not edit data, currently syncing")); return; } OTodo todo = m_todoMgr.event( uid ); todo = currentEditor()->edit(this, todo ); /* if completed */ if ( currentEditor()->accepted() ) { qWarning("Replacing now" ); m_todoMgr.update( todo.uid(), todo ); currentView()->replaceEvent( todo ); /* a Category might have changed */ populateCategories(); } raiseCurrentView(); } /* void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { m_todoMgr.update( uid, ev ); @@ -770,49 +771,49 @@ int MainWindow::create() { // but only call if we changed something -zecke populateCategories(); } raiseCurrentView( ); return uid; } /* delete it silently... */ bool MainWindow::remove( int uid ) { if (m_syncing) return false; return m_todoMgr.remove( uid ); } void MainWindow::beam( int uid) { ::unlink( beamfile ); OTodo todo = event( uid ); OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) ); OTodoAccess acc( cal ); acc.load(); acc.add( todo ); acc.save(); Ir* ir = new Ir(this ); connect(ir, SIGNAL(done(Ir*) ), this, SLOT(beamDone(Ir*) ) ); - ir->send( beamfile, todo.summary(), "text/x-vCalendar" ); + ir->send(beamfile, todo.summary(), "text/x-vCalendar" ); } void MainWindow::show( int uid ) { slotShow( uid ); } void MainWindow::edit( int uid ) { slotEdit( uid ); } void MainWindow::add( const OPimRecord& rec) { if ( rec.rtti() != OTodo::rtti() ) return; const OTodo& todo = static_cast<const OTodo&>(rec); m_todoMgr.add(todo ); currentView()->addEvent( todo ); // I'm afraid we must call this every time now, otherwise // spend expensive time comparing all these strings... // but only call if we changed something -zecke populateCategories(); } void MainWindow::slotReturnFromView() { raiseCurrentView(); } diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp index ae27fab..d9cda09 100644 --- a/core/pim/todo/tableview.cpp +++ b/core/pim/todo/tableview.cpp @@ -122,48 +122,49 @@ TableView::TableView( MainWindow* window, QWidget* wid ) } /* a new day has started * update the day */ void TableView::newDay() { clear(); updateView(); } TableView::~TableView() { Config config( "todo" ); config.setGroup( "Options" ); for (int i = 0; i < numCols(); i++ ) config.writeEntry("Width"+QString::number(i), columnWidth(i) ); } void TableView::slotShowMenu() { QPopupMenu *menu = todoWindow()->contextMenu( current(), sorted()[currentRow()].recurrence().doesRecur() ); menu->exec(QCursor::pos() ); delete menu; } QString TableView::type() const { return QString::fromLatin1( tr("Table View") ); } int TableView::current() { + if (numRows() == 0 ) return 1; int uid = sorted().uidAt(currentRow() ); return uid; } QString TableView::currentRepresentation() { OTodo to = sorted()[currentRow()]; return to.summary().isEmpty() ? to.description().left(20) : to.summary() ; } /* show overdue */ void TableView::showOverDue( bool ) { clear(); updateView(); } void TableView::updateView( ) { qWarning("update view"); m_row = false; static int id; id = startTimer(4000 ); /* FIXME we want one page to be read! * * Calculate that screensize */ todoWindow()->setReadAhead( 4 ); |