[PATCH] Todo: don't prompt for template if no templates defined

Paul Eggleton <[email protected]>
Newsgroups gmane.comp.handhelds.opie.devel
Message-ID <[email protected]>
Hi all,

Attached patch fixes bug #1547 (http://opie-bugs.oszine.de/view.php?id=1547).

Cheers,
Paul

_______________________________________________

http://opie.handhelds.org/cgi-bin/moin.cgi/DeveloperWikiIndex

Opie-devel mailing list
[email protected]
https://handhelds.org/mailman/listinfo/opie-devel
todo_empty_templates.patch (text/x-diff, 2.1 KB)
Index: mainwindow.cpp
===================================================================
RCS file: /cvs/opie/core/pim/todo/mainwindow.cpp,v
retrieving revision 1.60
diff -U3 -r1.60 mainwindow.cpp
--- mainwindow.cpp	6 Apr 2005 21:39:47 -0000	1.60
+++ mainwindow.cpp	28 Dec 2006 01:53:27 -0000
@@ -285,27 +285,35 @@
     }
 }
 void MainWindow::slotItemNew() {
-    NewTaskDlg dlg( templateManager()->templates(), this );
-    if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) {
-        QString tempName = dlg.tempSelected();
-        if ( tempName.isNull() )
-            // Create new, blank task
-            create();
-        else {
-            // Create new task from the template selected
-            OPimTodo event = templateManager()->templateEvent( tempName );
-            event = currentEditor()->edit( this, event );
-            if ( currentEditor()->accepted() ) {
-                event.setUid( 1 );
-                handleAlarms( OPimTodo(), event );
-                m_todoMgr.add( event );
-                currentView()->addEvent( event );
-
-                reloadCategories();
-            }
-            raiseCurrentView();
-        }
-    }
+	QStringList templateList = templateManager()->templates();
+	if(templateList.isEmpty()) {
+		// No templates, just create a blank task
+		create();
+	}
+	else {
+		// There are templates, so allow the user to select one
+		NewTaskDlg dlg( templateList, this );
+		if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) {
+			QString tempName = dlg.tempSelected();
+			if ( tempName.isNull() )
+				// Create new, blank task
+				create();
+			else {
+				// Create new task from the template selected
+				OPimTodo event = templateManager()->templateEvent( tempName );
+				event = currentEditor()->edit( this, event );
+				if ( currentEditor()->accepted() ) {
+					event.setUid( 1 );
+					handleAlarms( OPimTodo(), event );
+					m_todoMgr.add( event );
+					currentView()->addEvent( event );
+
+					reloadCategories();
+				}
+				raiseCurrentView();
+			}
+		}
+	}
 }
 void MainWindow::slotItemEdit() {
     slotEdit( currentView()->current() );
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.