PDA

View Full Version : update()



JeanC
11th February 2008, 13:55
Hello,

I hope I can make this clear. I am making my own calendar / reminder.
I use a QTableView and a QStandardItemModel for this. The table also has a delegate and in the delegate a paint event.

The model is constructed like model = new QStandardItemModel(6, 7, this);
So it has empty items. The display of the days is done in the paint event which gets a QDate for the left upper day and from there on it displays all the numbers in the calendar.

This works well for the first time but when I try to display the next month with update(), nothing happens, the paint event does not get called.

So I do something like:



void nextMonth()
{
calculatenextmonthupperleftday();
update();
}


I think this approach should be possible, how can I generate that paint event anew?

Thanks.

jpn
11th February 2008, 15:33
Umm, how does the model know which month to represent?

JeanC
11th February 2008, 15:58
Hi jpn,

I thought it would be possible that only the paint() in the delegate has to know which month to present / paint.
The parent of the delegate is the main class which holds a QDate to present the current first date for the current month to be displayed in the calendar.

I could populate the model with 6 weeks valid QDates, but why, when all that is needed is to display the numbers and some coloring which has to be done by the delegate anyway.

Something wrong with this logic?


Umm, how does the model know which month to represent?

jpn
11th February 2008, 16:08
And where do you store events once you start scheduling stuff in the calendar? What's the purpose of the model in the calendar of yours?

JeanC
11th February 2008, 16:12
Appointments are stored in textfiles. When you double click a date you get a little editor which stores it's stuff on disk when ready. It only needs to know the date for the filename. I have functions to convert between QDate and QModelIndex.
The paint() checks if a file exists and colors the cell accordingly.

The model's only purpose is to make that tableview work, I don't actualy need the QStandardItems in it. I just need the display and the events like currentchanged() and activated().

Am I that crazy? :)


And where do you store events once you start scheduling stuff in the calendar? What's the purpose of the model in the calendar of yours?