summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/templatedialogimpl.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/core/pim/todo/templatedialogimpl.cpp b/core/pim/todo/templatedialogimpl.cpp
index c2306ac..63d8107 100644
--- a/core/pim/todo/templatedialogimpl.cpp
+++ b/core/pim/todo/templatedialogimpl.cpp
@@ -64,55 +64,64 @@ TemplateDialogImpl::TemplateDialogImpl( MainWindow* win,
64 } 64 }
65 listView()->addColumn( QWidget::tr("Name") ); 65 listView()->addColumn( QWidget::tr("Name") );
66 66
67 connect( listView(), SIGNAL(clicked(QListViewItem*) ), 67 connect( listView(), SIGNAL(clicked(QListViewItem*) ),
68 this, SLOT(slotClicked(QListViewItem*) ) ); 68 this, SLOT(slotClicked(QListViewItem*) ) );
69} 69}
70TemplateDialogImpl::~TemplateDialogImpl() { 70TemplateDialogImpl::~TemplateDialogImpl() {
71 71
72} 72}
73void TemplateDialogImpl::slotAdd() { 73void TemplateDialogImpl::slotAdd() {
74 QString str = QWidget::tr("New Template %1").arg( listView()->childCount() ); 74 QString str = QWidget::tr("New Template %1").arg( listView()->childCount() );
75 OTodo ev; 75 OTodo ev;
76 m_man->addEvent(str, ev); 76 m_man->addEvent(str, ev);
77 new TemplateListItem( listView(), str, ev ); 77 new TemplateListItem( listView(), str, ev );
78} 78}
79void TemplateDialogImpl::slotRemove() { 79void TemplateDialogImpl::slotRemove() {
80 TemplateListItem* item = (TemplateListItem*) listView()->currentItem(); 80 if (!listView()->currentItem() )
81 return;
82
83 TemplateListItem* item = static_cast<TemplateListItem*>( listView()->currentItem() );
81 listView()->takeItem( item ); 84 listView()->takeItem( item );
82 85
83 m_man->removeEvent( item->text() ); 86 m_man->removeEvent( item->text() );
84 87
85 delete item; 88 delete item;
86} 89}
87void TemplateDialogImpl::slotEdit() { 90void TemplateDialogImpl::slotEdit() {
88 TemplateListItem* item = (TemplateListItem*)listView()->currentItem(); 91 if ( !listView()->currentItem() )
92 return;
93
94 TemplateListItem* item = static_cast<TemplateListItem*>( listView()->currentItem() );
89 OTodo ev = m_win->currentEditor()->edit( m_win, item->event() ); 95 OTodo ev = m_win->currentEditor()->edit( m_win, item->event() );
90 if ( m_win->currentEditor()->accepted() ) { 96 if ( m_win->currentEditor()->accepted() ) {
91 item->setEvent( ev ); 97 item->setEvent( ev );
92 m_man->removeEvent( item->text() ); 98 m_man->removeEvent( item->text() );
93 m_man->addEvent( item->text(), ev ); 99 m_man->addEvent( item->text(), ev );
94 } 100 }
95} 101}
96/* 102/*
97 * we need to update 103 * we need to update
98 * the text 104 * the text
99 */ 105 */
100 106
101void TemplateDialogImpl::slotReturn() { 107void TemplateDialogImpl::slotReturn() {
102 TemplateListItem* tbl = (TemplateListItem*)listView()->currentItem(); 108 if ( !listView()->currentItem() )
109 return;
110
111 TemplateListItem* tbl = static_cast<TemplateListItem*>( listView()->currentItem() );
103 112
104 if (tbl->text() != edit()->text() ) { 113 if (tbl->text() != edit()->text() ) {
105 m_man->removeEvent( tbl->text() ); 114 m_man->removeEvent( tbl->text() );
106 tbl->setText( edit()->text() ); 115 tbl->setText( edit()->text() );
107 m_man->addEvent( tbl->text(), tbl->event() ); 116 m_man->addEvent( tbl->text(), tbl->event() );
108 } 117 }
109} 118}
110/* update the lineedit when changing */ 119/* update the lineedit when changing */
111void TemplateDialogImpl::slotClicked( QListViewItem* item) { 120void TemplateDialogImpl::slotClicked( QListViewItem* item) {
112 if (!item) 121 if (!item)
113 return; 122 return;
114 123
115 TemplateListItem* tbl = static_cast<TemplateListItem*>(item); 124 TemplateListItem* tbl = static_cast<TemplateListItem*>(item);
116 edit()->setText( tbl->text() ); 125 edit()->setText( tbl->text() );
117} 126}
118 127