Replacing page number with other counter in listoftodos

I'm using the todonotes package to add notes in my documents. The \listoftodos command adds a ToC for todos.

Instead of the page numbers in this ToC, I would like to display another value, for example \thesection. The todonotes package manipulates a ToC named .tdo, so I'm guessing I can do that with tocloft but so far I've failed to achieve it.

Here is a MWE:

\documentclass{scrbook}

\usepackage{todonotes}
\usepackage{tocloft}
\usepackage{lipsum}

\begin{document}

\chapter{My first chapter}

\section{A first section}

\lipsum

\todo{This is a note}

\section{Another section}

\lipsum

\todo{This is another note}

\listoftodos

\end{document}


The two notes have page numbers 2 and 3 respectively. I would like them to show 1.1 and 1.2 (section numbers) instead. How can I do that?

-
please provide a MWE. – Marco Daniel May 23 '11 at 7:03
OK, added a MWE. – ℝaphink May 23 '11 at 7:12

Update!!!

The following solution sets the correct width of \@pnumwidth

\documentclass{scrbook}

\usepackage{todonotes}
\usepackage{tocloft}
\usepackage{lipsum}
\usepackage{showframe}
\makeatletter
\addtocontents{#1}{\protect\contentsline{#2}{#3}{see \thesection\ at p. \thepage}}}
\if@todonotes@colorinlistoftodos%
\colorbox{\@todonotes@currentbackgroundcolor}%
{\textcolor{\@todonotes@currentbackgroundcolor}{o}}%
\ \@todonotes@caption}}%
\else%
\fi}%
\newcommand*\mylistoftodos{%
\begingroup
\setbox\@tempboxa\hbox{see 9.9 at p. 99}%
\renewcommand*\@tocrmarg{\the\wd\@tempboxa}%
\renewcommand*\@pnumwidth{\the\wd\@tempboxa}%
\listoftodos%
\endgroup
}
\makeatother

\begin{document}
\chapter{My first chapter}
\section{A first section}
\lipsum
\todo{This is a note}
\section{Another section}
\lipsum
\todo{This is another note}

\mylistoftodos
\end{document}


The result is:

-
@Marco: the \protect in lines 6 and 11 do nothing, since they only protect an open brace. I think that a bug report should be filed to the package's author. – egreg May 23 '11 at 7:55
@Egreg: You are right. I only copied the peace of code :-) . Do you send the bug greport. – Marco Daniel May 23 '11 at 8:20
It doesn't work for me : ! LaTeX Error: \@todonotes@addElementToListOfTodos undefined. – ℝaphink May 24 '11 at 6:31
Which version of TL do you have? Maybe you only need an update. – Marco Daniel May 24 '11 at 7:32
To make it compatible with hyperref it should be \addtocontents{#1}{\protect\contentsline{#2}{#3}{see \thesection\ at p. \thepage}{}}} (extra pair of curly braces at the end), @midtiby: you may want to update the example in the todonotes manual. – Jörg Jun 22 '12 at 10:54

Since it is the only ToC in my document, I have found that redifining \addcontentsline works fine and is quite straightforward:

 \renewcommand{\addcontentsline}[3]{%
}


The only side effect I've seen is that it ruins the bookmarks in the PDF. That is OK for my draft (which is why I use todonotes), but not for my final document, so my solution so far is to make a package that wraps up todonotes and passes it the disable option:

\ProvidesPackage{review}
\let\review@disable\@empty
\let\review@dateinlist\@empty
\DeclareOption{disable}{\def\review@disable{true}}
\DeclareOption{dateinlist}{\def\review@dateinlist{true}}
\ProcessOptions

% Put dates instead of page numbers in listoftodos
\newcommand{\tododate}{%
}

\ifx\review@disable \@empty
\usepackage[french,colorinlistoftodos,textsize=small]{todonotes}
\ifx\review@dateinlist \@empty
\else
}
\fi
\else
\usepackage[french,colorinlistoftodos,textsize=small,disable]{todonotes}
\fi


This way, I can call my package in different ways:

\usepackage{review} % normal style
\usepackage[dateinlist}{review} % date instead of page numbers
\usepackage[disable]{review} % disable todonotes and do not mess up bookmarks

-