summaryrefslogtreecommitdiff
path: root/core/pim/datebook/datebook.cpp
authorumopapisdn <umopapisdn>2003-05-05 21:44:39 (UTC)
committer umopapisdn <umopapisdn>2003-05-05 21:44:39 (UTC)
commit3b193b852133a82b5c1708b68a7e460c63629768 (patch) (unidiff)
tree8cd0ff3adc14f0b937d24ab99fca327fb3f16875 /core/pim/datebook/datebook.cpp
parent12a700f8903eedeba03d3aba7990b9d660410045 (diff)
downloadopie-3b193b852133a82b5c1708b68a7e460c63629768.zip
opie-3b193b852133a82b5c1708b68a7e460c63629768.tar.gz
opie-3b193b852133a82b5c1708b68a7e460c63629768.tar.bz2
UI and code cleanup. Both UI and code is now more consistent. Also removed menus in favor of toolbuttons. (why were they even available as menus in the first place?)
Diffstat (limited to 'core/pim/datebook/datebook.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp106
1 files changed, 41 insertions, 65 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index cf1eeca..b7e89b0 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -100,37 +100,38 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
100 weekLstView = 0; 100 weekLstView = 0;
101 monthView = 0; 101 monthView = 0;
102 102
103 QPEToolBar *bar = new QPEToolBar( this ); 103// QPEToolBar *bar = new QPEToolBar( this );
104 bar->setHorizontalStretchable( TRUE ); 104// bar->setHorizontalStretchable( TRUE );
105 105
106 QPEMenuBar *mb = new QPEMenuBar( bar ); 106// QPEMenuBar *mb = new QPEMenuBar( bar );
107 mb->setMargin( 0 ); 107// mb->setMargin( 0 );
108 108
109 QPEToolBar *sub_bar = new QPEToolBar(this); 109// QPopupMenu *view = new QPopupMenu( this );
110 110// mb->insertItem( tr( "View" ), view );
111 QPopupMenu *view = new QPopupMenu( this );
112 QPopupMenu *settings = new QPopupMenu( this );
113 111
114 mb->insertItem( tr( "View" ), view ); 112 QPEToolBar *sub_bar = new QPEToolBar(this);
115 mb->insertItem( tr( "Settings" ), settings ); 113 sub_bar->setHorizontalStretchable(TRUE);
116 114
117 QActionGroup *g = new QActionGroup( this ); 115 QActionGroup *g = new QActionGroup( this );
118 g->setExclusive( TRUE ); 116 g->setExclusive( TRUE );
119 117
120 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), 118 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
121 QString::null, 0, this, 0 );
122 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 119 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
123 a->addTo( sub_bar ); 120 a->addTo( sub_bar );
124 121
122 sub_bar->addSeparator();
123
125 a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); 124 a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 );
126 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); 125 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) );
127 a->addTo( sub_bar ); 126 a->addTo( sub_bar );
128 a->addTo( view ); 127 //a->addTo( view );
128
129 sub_bar->addSeparator();
129 130
130 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); 131 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 );
131 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); 132 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) );
132 a->addTo( sub_bar ); 133 a->addTo( sub_bar );
133 a->addTo( view ); 134// a->addTo( view );
134 a->setToggleAction( TRUE ); 135 a->setToggleAction( TRUE );
135 a->setOn( TRUE ); 136 a->setOn( TRUE );
136 dayAction = a; 137 dayAction = a;
@@ -138,31 +139,33 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
138 a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); 139 a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 );
139 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); 140 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) );
140 a->addTo( sub_bar ); 141 a->addTo( sub_bar );
141 a->addTo( view ); 142// a->addTo( view );
142 a->setToggleAction( TRUE ); 143 a->setToggleAction( TRUE );
143 weekAction = a; 144 weekAction = a;
144 145
145 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); 146 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 );
146 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); 147 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) );
147 a->addTo( sub_bar ); 148 a->addTo( sub_bar );
148 a->addTo( view ); 149// a->addTo( view );
149 a->setToggleAction( TRUE ); 150 a->setToggleAction( TRUE );
150 weekLstAction = a; 151 weekLstAction = a;
151 152
152 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); 153 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 );
153 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); 154 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) );
154 a->addTo( sub_bar ); 155 a->addTo( sub_bar );
155 a->addTo( view ); 156// a->addTo( view );
156 a->setToggleAction( TRUE ); 157 a->setToggleAction( TRUE );
157 monthAction = a; 158 monthAction = a;
158 159
159 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 ); 160 sub_bar->addSeparator();
161
162 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 );
160 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); 163 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
161 a->addTo( sub_bar ); 164 a->addTo( sub_bar );
162 165
163 a = new QAction( tr( "Edit..." ), QString::null, 0, 0 ); 166 a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 );
164 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 167 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
165 a->addTo( settings ); 168 a->addTo( sub_bar );
166 169
167 if(defaultView==DAY) viewDay(); 170 if(defaultView==DAY) viewDay();
168 if(defaultView==WEEK) needEvilHack=true;// viewWeek(); 171 if(defaultView==WEEK) needEvilHack=true;// viewWeek();
@@ -373,13 +376,6 @@ void DateBook::view(int v, const QDate &d) {
373} 376}
374 377
375void DateBook::viewDefault(const QDate &d) { 378void DateBook::viewDefault(const QDate &d) {
376/*
377 Config config("DateBook");
378 config.setGroup("Main");
379 int current=config.readNumEntry("defaultview", DAY);
380
381 view(current,d);
382*/
383 view(defaultView,d); 379 view(defaultView,d);
384} 380}
385 381
@@ -526,20 +522,13 @@ void DateBook::initDay()
526 dayView->setStartViewTime( startTime ); 522 dayView->setStartViewTime( startTime );
527 dayView->setJumpToCurTime( bJumpToCurTime ); 523 dayView->setJumpToCurTime( bJumpToCurTime );
528 dayView->setRowStyle( rowStyle ); 524 dayView->setRowStyle( rowStyle );
529 connect( this, SIGNAL( newEvent() ), 525 connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) );
530 dayView, SLOT( redraw() ) ); 526 connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) );
531 connect( dayView, SIGNAL( newEvent() ), 527 connect( dayView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) );
532 this, SLOT( fileNew() ) ); 528 connect( dayView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) );
533 connect( dayView, SIGNAL( removeEvent( const Event & ) ), 529 connect( dayView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) );
534 this, SLOT( removeEvent( const Event & ) ) ); 530 connect( dayView, SIGNAL( beamEvent( const Event & ) ), this, SLOT( beamEvent( const Event & ) ) );
535 connect( dayView, SIGNAL( editEvent( const Event & ) ), 531 connect( dayView, SIGNAL(sigNewEvent(const QString &)), this, SLOT(slotNewEventFromKey(const QString &)) );
536 this, SLOT( editEvent( const Event & ) ) );
537 connect( dayView, SIGNAL( duplicateEvent( const Event & ) ),
538 this, SLOT( duplicateEvent( const Event & ) ) );
539 connect( dayView, SIGNAL( beamEvent( const Event & ) ),
540 this, SLOT( beamEvent( const Event & ) ) );
541 connect( dayView, SIGNAL(sigNewEvent(const QString &)),
542 this, SLOT(slotNewEventFromKey(const QString &)) );
543 } 532 }
544} 533}
545 534
@@ -549,10 +538,8 @@ void DateBook::initWeek()
549 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); 538 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" );
550 weekView->setStartViewTime( startTime ); 539 weekView->setStartViewTime( startTime );
551 views->addWidget( weekView, WEEK ); 540 views->addWidget( weekView, WEEK );
552 connect( weekView, SIGNAL( showDate( int, int, int ) ), 541 connect( weekView, SIGNAL( showDate( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) );
553 this, SLOT( showDay( int, int, int ) ) ); 542 connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) );
554 connect( this, SIGNAL( newEvent() ),
555 weekView, SLOT( redraw() ) );
556 } 543 }
557 544
558 //But also get it right: the year that we display can be different 545 //But also get it right: the year that we display can be different
@@ -568,29 +555,19 @@ void DateBook::initWeek()
568 d = d.addDays( -1 ); 555 d = d.addDays( -1 );
569 calcWeek( d, totWeeks, yearNumber, onMonday ); 556 calcWeek( d, totWeeks, yearNumber, onMonday );
570 } 557 }
571 if ( totWeeks != weekView->totalWeeks() )
572 weekView->setTotalWeeks( totWeeks );
573} 558}
574 559
575void DateBook::initWeekLst() { 560void DateBook::initWeekLst() {
576 if ( !weekLstView ) { 561 if ( !weekLstView ) {
577 weekLstView = new DateBookWeekLst( ampm, onMonday, db, 562 weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" );
578 views, "weeklst view" );
579 views->addWidget( weekLstView, WEEKLST ); 563 views->addWidget( weekLstView, WEEKLST );
580 564
581 //weekLstView->setStartViewTime( startTime ); 565 //weekLstView->setStartViewTime( startTime );
582 connect( weekLstView, SIGNAL( showDate( int, int, int ) ), 566 connect( weekLstView, SIGNAL( showDate( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) );
583 this, SLOT( showDay( int, int, int ) ) ); 567 connect( weekLstView, SIGNAL( addEvent( const QDateTime &, const QDateTime &, const QString & , const QString &) ),
584 connect( weekLstView, SIGNAL( addEvent( const QDateTime &, 568 this, SLOT( slotNewEntry( const QDateTime &, const QDateTime &, const QString & , const QString &) ) );
585 const QDateTime &, 569 connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) );
586 const QString & , const QString &) ), 570 connect( weekLstView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) );
587 this, SLOT( slotNewEntry( const QDateTime &,
588 const QDateTime &,
589 const QString & , const QString &) ) );
590 connect( this, SIGNAL( newEvent() ),
591 weekLstView, SLOT( redraw() ) );
592 connect( weekLstView, SIGNAL( editEvent( const Event & ) ),
593 this, SLOT( editEvent( const Event & ) ) );
594 } 571 }
595} 572}
596 573
@@ -600,10 +577,8 @@ void DateBook::initMonth()
600 if ( !monthView ) { 577 if ( !monthView ) {
601 monthView = new DateBookMonth( views, "month view", FALSE, db ); 578 monthView = new DateBookMonth( views, "month view", FALSE, db );
602 views->addWidget( monthView, MONTH ); 579 views->addWidget( monthView, MONTH );
603 connect( monthView, SIGNAL( dateClicked( int, int, int ) ), 580 connect( monthView, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) );
604 this, SLOT( showDay( int, int, int ) ) ); 581 connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) );
605 connect( this, SIGNAL( newEvent() ),
606 monthView, SLOT( redraw() ) );
607 qApp->processEvents(); 582 qApp->processEvents();
608 } 583 }
609} 584}
@@ -629,6 +604,7 @@ void DateBook::loadSettings()
629 QString tmpString=config.readEntry("defaultCategories"); 604 QString tmpString=config.readEntry("defaultCategories");
630 QStringList tmpStringList=QStringList::split(",",tmpString); 605 QStringList tmpStringList=QStringList::split(",",tmpString);
631 defaultCategories.truncate(0); 606 defaultCategories.truncate(0);
607
632 for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) { 608 for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) {
633 defaultCategories.resize(defaultCategories.count()+1); 609 defaultCategories.resize(defaultCategories.count()+1);
634 defaultCategories[defaultCategories.count()-1]=(*i).toInt(); 610 defaultCategories[defaultCategories.count()-1]=(*i).toInt();