summaryrefslogtreecommitdiffabout
path: root/korganizer/mainwindow.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp206
1 files changed, 172 insertions, 34 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index ca0d542..c6ae868 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -59,2 +59,3 @@
#include "kglobal.h"
+#include "ktoolbar.h"
#include "klocale.h"
@@ -166,2 +167,64 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
addToolBar (iconToolBar , tbd );
+
+ if ( KOPrefs::instance()->mShowIconFilter ) {
+ if ( p->mToolBarHorF ) {
+ if ( p->mToolBarUpF )
+ tbd = Bottom;
+ else
+ tbd = Top;
+ }
+ else {
+ if ( p->mToolBarUpF )
+ tbd = Right;
+ else
+ tbd = Left;
+ }
+ filterToolBar = new QPEToolBar ( this );
+ filterMenubar = new QPEMenuBar( filterToolBar );
+ QFontMetrics fm ( filterMenubar->font() );
+
+ filterPopupMenu = new QPopupMenu( this );
+ filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 );
+ filterMenubar->setFixedWidth( fm.width( i18n("No Filter")+"Ax" ) );
+ addToolBar (filterToolBar , tbd );
+ connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) );
+ connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) );
+ } else {
+ filterToolBar = 0;
+ filterMenubar = 0;
+ filterPopupMenu = 0;
+ }
+
+ if ( p->mToolBarHorV ) {
+ if ( p->mToolBarUpV )
+ tbd = Bottom;
+ else
+ tbd = Top;
+ }
+ else {
+ if ( p->mToolBarUpV )
+ tbd = Right;
+ else
+ tbd = Left;
+ }
+ viewToolBar = new QPEToolBar( this );
+ addToolBar (viewToolBar , tbd );
+ if ( p->mToolBarHorN ) {
+ if ( p->mToolBarUpN )
+ tbd = Bottom;
+ else
+ tbd = Top;
+ }
+ else {
+ if ( p->mToolBarUpN )
+ tbd = Right;
+ else
+ tbd = Left;
+ }
+ navigatorToolBar = new QPEToolBar( this );
+ addToolBar (navigatorToolBar , tbd );
+
+
+
+
mCalendarModifiedFlag = false;
@@ -633,2 +696,4 @@ void MainWindow::initActions()
configureToolBarMenu->insertSeparator();
+ configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 );
+ configureToolBarMenu->insertSeparator();
configureToolBarMenu->insertItem(i18n("Week Number"), 400);
@@ -1001,3 +1066,3 @@ void MainWindow::initActions()
- iconToolBar->setHorizontalStretchable (true );
+
//menuBar->insertItem( iconToolBar );
@@ -1013,21 +1078,21 @@ void MainWindow::initActions()
if (p-> mShowIconNext)
- whatsnext_action->addTo( iconToolBar );
+ whatsnext_action->addTo( viewToolBar );
if (p-> mShowIconNextDays)
- xdays_action->addTo( iconToolBar );
+ xdays_action->addTo( viewToolBar );
if (p-> mShowIconJournal)
- viewjournal_action->addTo( iconToolBar );
+ viewjournal_action->addTo( viewToolBar );
if (p-> mShowIconDay1)
- day1_action->addTo( iconToolBar );
+ day1_action->addTo( viewToolBar );
if (p-> mShowIconDay5)
- day5_action->addTo( iconToolBar );
+ day5_action->addTo( viewToolBar );
if (p-> mShowIconDay7)
- day7_action->addTo( iconToolBar );
+ day7_action->addTo( viewToolBar );
if (p-> mShowIconDay6)
- day6_action->addTo( iconToolBar );
+ day6_action->addTo( viewToolBar );
if (p-> mShowIconMonth)
- month_action->addTo( iconToolBar );
+ month_action->addTo( viewToolBar );
if (p-> mShowIconList)
- showlist_action->addTo( iconToolBar );
+ showlist_action->addTo( viewToolBar );
if (p-> mShowIconTodoview)
- todoview_action->addTo( iconToolBar );
+ todoview_action->addTo( viewToolBar );
@@ -1039,3 +1104,3 @@ void MainWindow::initActions()
mView, SLOT( goPreviousMonth() ) );
- action->addTo( iconToolBar );
+ action->addTo( navigatorToolBar );
}
@@ -1047,3 +1112,3 @@ void MainWindow::initActions()
mView, SLOT( goPrevious() ) );
- action->addTo( iconToolBar );
+ action->addTo( navigatorToolBar );
}
@@ -1052,3 +1117,3 @@ void MainWindow::initActions()
if (p-> mShowIconToday)
- today_action->addTo( iconToolBar );
+ today_action->addTo( navigatorToolBar );
icon = loadPixmap( pathString + "1rightarrowB" );
@@ -1059,3 +1124,3 @@ void MainWindow::initActions()
mView, SLOT( goNext() ) );
- action->addTo( iconToolBar );
+ action->addTo( navigatorToolBar );
}
@@ -1067,3 +1132,3 @@ void MainWindow::initActions()
mView, SLOT( goNextMonth() ) );
- action->addTo( iconToolBar );
+ action->addTo( navigatorToolBar );
}
@@ -1113,8 +1178,23 @@ void MainWindow::initActions()
configureToolBarMenu->setItemChecked( 400, true );
- QLabel* dummy = new QLabel( iconToolBar );
- dummy->setBackgroundColor( iconToolBar->backgroundColor() );
- if (!p-> mShowIconStretch)
+ if (!p-> mShowIconStretch) {
+ QLabel* dummy = new QLabel( iconToolBar );
+ dummy->setBackgroundColor( iconToolBar->backgroundColor() );
+ dummy->setMinimumWidth( 0 );
iconToolBar->setStretchableWidget ( dummy ) ;
- else
+ }
+ else {
+ iconToolBar->setHorizontalStretchable (true );
+ viewToolBar->setHorizontalStretchable (true );
+ navigatorToolBar->setHorizontalStretchable (true );
+ iconToolBar->setVerticalStretchable (true );
+ viewToolBar->setVerticalStretchable (true );
+ navigatorToolBar->setVerticalStretchable (true );
configureToolBarMenu->setItemChecked( 5, true );
+ }
+ if (p-> mShowIconFilter)
+ configureToolBarMenu->setItemChecked( 7, true );
+
+
+ if ( filterMenubar )
+ connect( mView->filterView(), SIGNAL( filterChanged() ), SLOT( updateFilterToolbar() ) );
connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
@@ -1563,4 +1643,23 @@ void MainWindow::saveOnClose()
p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
- p->mToolBarUp = iconToolBar->x() > width()/2 ||
- iconToolBar->y() > height()/2;
+ if ( p->mToolBarHor )
+ p->mToolBarUp = iconToolBar->y() > height()/2;
+ else
+ p->mToolBarUp = iconToolBar->x() > width()/2;
+ p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal );
+ if ( p->mToolBarHorV )
+ p->mToolBarUpV = viewToolBar->y() > height()/2;
+ else
+ p->mToolBarUpV = viewToolBar->x() > width()/2 ;
+ p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal );
+ if ( p->mToolBarHorN )
+ p->mToolBarUpN = navigatorToolBar->y() > height()/2;
+ else
+ p->mToolBarUpN = navigatorToolBar->x() > width()/2 ;
+ if ( filterToolBar ) {
+ p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal );
+ if ( p->mToolBarHorF )
+ p->mToolBarUpF = filterToolBar->y() > height()/2;
+ else
+ p->mToolBarUpF = filterToolBar->x() > width()/2 ;
+ }
mView->writeSettings();
@@ -1807,12 +1906,6 @@ void MainWindow::fillFilterMenu()
selectFilterMenu->clear();
- bool disable = false;
selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 );
selectFilterMenu->insertSeparator();
- if ( mView->filterView()->filtersEnabled() ) {
- selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 1 );
- }
- else {
- selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 1 );
- disable = true;
- }
+ selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 );
+
selectFilterMenu->insertSeparator();
@@ -1822,2 +1915,3 @@ void MainWindow::fillFilterMenu()
int iii = 2;
+ bool checkitem = mView->filterView()->filtersEnabled();
while(filter) {
@@ -1825,5 +1919,3 @@ void MainWindow::fillFilterMenu()
if ( filter == curfilter)
- selectFilterMenu->setItemChecked( iii, true );
- if ( disable )
- selectFilterMenu->setItemEnabled( iii, false );
+ selectFilterMenu->setItemChecked( iii, checkitem );
filter = fili.next();
@@ -1831,2 +1923,25 @@ void MainWindow::fillFilterMenu()
}
+ if ( !checkitem )
+ selectFilterMenu->setItemChecked( 1, true );
+}
+void MainWindow::fillFilterMenuPopup()
+{
+ filterPopupMenu->clear();
+ filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 );
+
+ filterPopupMenu->insertSeparator();
+ QPtrList<CalFilter> fili = mView->filters();
+ CalFilter *curfilter = mView->filterView()->selectedFilter();
+ CalFilter *filter = fili.first();
+ int iii = 1;
+ bool checkitem = mView->filterView()->filtersEnabled();
+ while(filter) {
+ filterPopupMenu->insertItem( filter->name(), iii );
+ if ( filter == curfilter)
+ filterPopupMenu->setItemChecked( iii, checkitem );
+ filter = fili.next();
+ ++iii;
+ }
+ if ( !checkitem )
+ filterPopupMenu->setItemChecked( 0, true );
}
@@ -1834,2 +1949,3 @@ void MainWindow::selectFilter( int fil )
{
+
if ( fil == 0 ) {
@@ -1837,7 +1953,28 @@ void MainWindow::selectFilter( int fil )
} else if ( fil == 1 ){
- mView->toggleFilerEnabled( );
+ if ( mView->filterView()->filtersEnabled() )
+ mView->toggleFilerEnabled( );
} else {
+ if ( !mView->filterView()->filtersEnabled() )
+ mView->toggleFilerEnabled( );
mView->selectFilter( fil-2 );
+ }
+}
+void MainWindow::updateFilterToolbar()
+{
+ if ( filterMenubar ) {
+ if ( !mView->filterView()->filtersEnabled() ) {
+ filterMenubar->changeItem( 0, i18n("No Filter") );
+ } else {
+ CalFilter *curfilter = mView->filterView()->selectedFilter();
+ if ( curfilter ) {
+ filterMenubar->changeItem( 0, curfilter->name() );
+ }
+ }
}
}
+void MainWindow::selectFilterPopup( int fil )
+{
+ selectFilter( fil + 1 );
+
+}
void MainWindow::configureToolBar( int item )
@@ -1848,2 +1985,3 @@ void MainWindow::configureToolBar( int item )
p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
+ p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 );
p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );