summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-02-07 06:10:09 (UTC)
committer zautrix <zautrix>2005-02-07 06:10:09 (UTC)
commit301a4a207171549bd87815705d8dcf32ad15559d (patch) (unidiff)
tree715fde2cd0af0c057f767c25d8e67298425b2c82
parent961fc44f4092c1f981eb3be4284715e6829f885c (diff)
downloadkdepimpi-301a4a207171549bd87815705d8dcf32ad15559d.zip
kdepimpi-301a4a207171549bd87815705d8dcf32ad15559d.tar.gz
kdepimpi-301a4a207171549bd87815705d8dcf32ad15559d.tar.bz2
new cool feature
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp110
-rw-r--r--korganizer/mainwindow.h15
-rw-r--r--microkde/kdatetbl.cpp165
-rw-r--r--microkde/kdatetbl.h63
4 files changed, 314 insertions, 39 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 348dd5e..119e28a 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -72,6 +72,7 @@ using namespace KCal;
72#endif 72#endif
73#include "mainwindow.h" 73#include "mainwindow.h"
74 74
75
75class KOex2phonePrefs : public QDialog 76class KOex2phonePrefs : public QDialog
76{ 77{
77 public: 78 public:
@@ -144,10 +145,11 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
144 setIcon(SmallIcon( "ko24" ) ); 145 setIcon(SmallIcon( "ko24" ) );
145 mBlockAtStartup = true; 146 mBlockAtStartup = true;
146 mFlagKeyPressed = false; 147 mFlagKeyPressed = false;
148 setCaption("KOrganizer/Pi");
147 KOPrefs *p = KOPrefs::instance(); 149 KOPrefs *p = KOPrefs::instance();
148 KPimGlobalPrefs::instance()->setGlobalConfig(); 150 KPimGlobalPrefs::instance()->setGlobalConfig();
149 if ( p->mHourSize > 18 ) 151 if ( p->mHourSize > 22 )
150 p->mHourSize = 18; 152 p->mHourSize = 22;
151 QMainWindow::ToolBarDock tbd; 153 QMainWindow::ToolBarDock tbd;
152 if ( p->mToolBarHor ) { 154 if ( p->mToolBarHor ) {
153 if ( p->mToolBarUp ) 155 if ( p->mToolBarUp )
@@ -167,8 +169,6 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
167 iconToolBar = new QPEToolBar( this ); 169 iconToolBar = new QPEToolBar( this );
168 addToolBar (iconToolBar , tbd ); 170 addToolBar (iconToolBar , tbd );
169 mCalendarModifiedFlag = false; 171 mCalendarModifiedFlag = false;
170
171 setCaption("KOrganizer/Pi");
172 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 172 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
173 splash->setAlignment ( AlignCenter ); 173 splash->setAlignment ( AlignCenter );
174 setCentralWidget( splash ); 174 setCentralWidget( splash );
@@ -557,43 +557,49 @@ void MainWindow::initActions()
557 } 557 }
558 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 558 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
559 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); 559 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) );
560 560 QIconSet icon;
561 menuBarWeek = new QPEMenuBar( iconToolBar ); 561 int pixWid = 22, pixHei = 22;
562 QPopupMenu * wpo = new QPopupMenu (this); 562 QString pathString = "";
563 QPopupMenu * all = new QPopupMenu (this); 563 if ( !p->mToolBarMiniIcons ) {
564 //wpo->insertItem( i18n("W#"), 0 ); 564 if ( QApplication::desktop()->width() < 480 ) {
565 int first = 1; 565 pathString += "icons16/";
566 int i; 566 pixWid = 18; pixHei = 16;
567 for ( i = 1; i < 50; ++i ) { 567 }
568 if ( !(i%10) ) { 568 } else {
569 all->insertItem( i18n("Select week %1-%2" ).arg(first).arg( i-1) ,wpo ); 569 pathString += "iconsmini/";
570 connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeek ( int ) ) ); 570 pixWid = 18; pixHei = 16;
571 first = i; 571 }
572 wpo = new QPopupMenu (this); 572 mWeekBgColor = iconToolBar->backgroundColor();
573 } 573 mWeekPixmap.resize( pixWid , pixHei );
574 wpo->insertItem( QString::number(i), i ); 574 mWeekPixmap.fill( mWeekBgColor );
575 } 575 icon = mWeekPixmap;
576 for ( i = 50; i < 53; ++i ) { 576 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this );
577 wpo->insertItem( QString::number(i), i); 577 mWeekAction->addTo( iconToolBar );
578 } 578 mWeekFont = font();
579 all->insertItem( i18n("Select week %1-%2" ).arg(first).arg( i-1) ,wpo ); 579
580 connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeek ( int ) ) ); 580 int fontPoint = mWeekFont.pointSize();
581 menuBarWeek->insertItem( "00",all,1); 581 QFontMetrics f( mWeekFont );
582 menuBarWeek->setMaximumSize( menuBarWeek->sizeHint( )); 582 int fontWid = f.width( "30" );
583 while ( fontWid > pixWid ) {
584 --fontPoint;
585 mWeekFont.setPointSize( fontPoint );
586 QFontMetrics f( mWeekFont );
587 fontWid = f.width( "30" );
588 qDebug("dec-- ");
589 }
590
591 connect( mWeekAction, SIGNAL( activated() ),
592 this, SLOT( weekAction() ) );
583 593
584 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); 594 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) );
595
596 //#endif
585 // ****************** 597 // ******************
586 QAction *action; 598 QAction *action;
587 QIconSet icon;
588 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 599 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
589 configureToolBarMenu->setCheckable( true ); 600 configureToolBarMenu->setCheckable( true );
590 601
591 QString pathString = ""; 602
592 if ( !p->mToolBarMiniIcons ) {
593 if ( QApplication::desktop()->width() < 480 )
594 pathString += "icons16/";
595 } else
596 pathString += "iconsmini/";
597 configureAgendaMenu->setCheckable( true ); 603 configureAgendaMenu->setCheckable( true );
598 int iii ; 604 int iii ;
599 for ( iii = 1;iii<= 10 ;++iii ){ 605 for ( iii = 1;iii<= 10 ;++iii ){
@@ -1370,8 +1376,14 @@ void MainWindow::updateWeek(QDate seda)
1370 // we have the first week of the year.we are on monday 1376 // we have the first week of the year.we are on monday
1371 weekNum = d.daysTo( seda ) / 7 +1; 1377 weekNum = d.daysTo( seda ) / 7 +1;
1372 } 1378 }
1373 //qDebug("weeknum %s ", QString::number( weekNum).latin1()); 1379
1374 menuBarWeek-> changeItem(1, QString::number( weekNum) ); 1380 mWeekPixmap.fill( mWeekBgColor );
1381 QPainter p ( &mWeekPixmap );
1382 p.setFont( mWeekFont );
1383 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) );
1384 p.end();
1385 QIconSet icon3 ( mWeekPixmap );
1386 mWeekAction->setIconSet ( icon3 );
1375 1387
1376} 1388}
1377void MainWindow::updateWeekNum(const DateList &selectedDates) 1389void MainWindow::updateWeekNum(const DateList &selectedDates)
@@ -1719,7 +1731,7 @@ void MainWindow::keyPressEvent ( QKeyEvent * e )
1719 break; 1731 break;
1720 case Qt::Key_Plus: 1732 case Qt::Key_Plus:
1721 size = p->mHourSize +2; 1733 size = p->mHourSize +2;
1722 if ( size <= 18 ) 1734 if ( size <= 22 )
1723 configureAgenda( size ); 1735 configureAgenda( size );
1724 break; 1736 break;
1725 case Qt::Key_Minus: 1737 case Qt::Key_Minus:
@@ -2011,3 +2023,27 @@ void MainWindow::printCal()
2011 mView->print();//mCp->showDialog(); 2023 mView->print();//mCp->showDialog();
2012} 2024}
2013 2025
2026
2027#include "libkdepim/kdatepicker.h"
2028#include <kdatetbl.h>
2029void MainWindow::weekAction()
2030{
2031 int month;
2032 KPopupFrame* popup = new KPopupFrame(this);
2033 int size = 12;
2034 if ( QApplication::desktop()->width() >= 480 )
2035 size = 18;
2036 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(size, popup);
2037 // -----
2038 picker->resize(picker->sizeHint());
2039 popup->setMainWidget(picker);
2040 picker->setFocus();
2041 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
2042 if(popup->exec(iconToolBar->mapToGlobal(QPoint(0, iconToolBar->height()))))
2043 {
2044 month = picker->getResult();
2045 emit selectWeek ( month );
2046 //qDebug("weekSelected %d ", month);
2047 }
2048 delete popup;
2049}
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 076ab94..5b9f903 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -5,6 +5,7 @@
5#include <qtimer.h> 5#include <qtimer.h>
6#include <qdict.h> 6#include <qdict.h>
7#include <qfile.h> 7#include <qfile.h>
8#include <qmenubar.h>
8#include <qtextstream.h> 9#include <qtextstream.h>
9#include <qregexp.h> 10#include <qregexp.h>
10 11
@@ -23,13 +24,19 @@ class KSyncProfile;
23#define QPEMenuBar QMenuBar 24#define QPEMenuBar QMenuBar
24#endif 25#endif
25class QPEToolBar; 26class QPEToolBar;
26class QPEMenuBar;
27 27
28 28
29namespace KCal { 29namespace KCal {
30class CalendarLocal; 30class CalendarLocal;
31} 31}
32 32
33class KOMenuBar : public QMenuBar
34{
35 public:
36 KOMenuBar( QWidget *parent=0 ): QMenuBar (parent ) {;}
37 QSize sizeHint () const{ qDebug("sizejint ");return QSize ( 40,25 );}
38};
39
33using namespace KCal; 40using namespace KCal;
34 41
35class MainWindow : public QMainWindow 42class MainWindow : public QMainWindow
@@ -50,6 +57,7 @@ class MainWindow : public QMainWindow
50 void recieve( const QCString& msg, const QByteArray& data ); 57 void recieve( const QCString& msg, const QByteArray& data );
51 protected slots: 58 protected slots:
52 void setCaptionToDates(); 59 void setCaptionToDates();
60 void weekAction();
53 void about(); 61 void about();
54 void licence(); 62 void licence();
55 void faq(); 63 void faq();
@@ -120,7 +128,10 @@ class MainWindow : public QMainWindow
120 CalendarLocal *mCalendar; 128 CalendarLocal *mCalendar;
121 CalendarView *mView; 129 CalendarView *mView;
122 QAction *mNewSubTodoAction; 130 QAction *mNewSubTodoAction;
123 QPEMenuBar *menuBarWeek; 131 QAction *mWeekAction;
132 QFont mWeekFont;
133 QPixmap mWeekPixmap;
134 QColor mWeekBgColor;
124 135
125 QAction *mShowAction; 136 QAction *mShowAction;
126 QAction *mEditAction; 137 QAction *mEditAction;
diff --git a/microkde/kdatetbl.cpp b/microkde/kdatetbl.cpp
index 508ce31..fce0e5a 100644
--- a/microkde/kdatetbl.cpp
+++ b/microkde/kdatetbl.cpp
@@ -748,3 +748,168 @@ void KDateTable::virtual_hook( int, void* )
748{ /*BASE::virtual_hook( id, data );*/ } 748{ /*BASE::virtual_hook( id, data );*/ }
749 749
750//#include "kdatetbl.moc" 750//#include "kdatetbl.moc"
751
752
753KDateInternalWeekPicker::KDateInternalWeekPicker
754(int fontsize, QWidget* parent, const char* name)
755 : QGridView(parent, name),
756 result(0) // invalid
757{
758 QRect rect;
759 QFont font;
760 // -----
761 activeCol = -1;
762 activeRow = -1;
763 font=KGlobalSettings::generalFont();
764 font.setPointSize(fontsize);
765 setFont(font);
766 setHScrollBarMode(AlwaysOff);
767 setVScrollBarMode(AlwaysOff);
768 setFrameStyle(QFrame::NoFrame);
769 setNumRows(13);
770 setNumCols(4);
771 // enable to find drawing failures:
772 // setTableFlags(Tbl_clipCellPainting);
773#if 0
774 viewport()->setEraseColor(lightGray); // for consistency with the datepicker
775#endif
776 // ----- find the preferred size
777 // (this is slow, possibly, but unfortunatly it is needed here):
778 QFontMetrics metrics(font);
779 for(int i=1; i <= 52; ++i)
780 {
781 rect=metrics.boundingRect(QString::number( i ));
782 if(max.width()<rect.width()) max.setWidth(rect.width());
783 if(max.height()<rect.height()) max.setHeight(rect.height());
784 }
785
786}
787
788QSize
789KDateInternalWeekPicker::sizeHint() const
790{
791 return QSize((max.width()+6)*numCols()+2*frameWidth(),
792 (max.height()+6)*numRows()+2*frameWidth());
793}
794
795int
796KDateInternalWeekPicker::getResult() const
797{
798 return result;
799}
800
801void
802KDateInternalWeekPicker::setupPainter(QPainter *p)
803{
804 p->setPen(black);
805}
806
807void
808KDateInternalWeekPicker::viewportResizeEvent(QResizeEvent*)
809{
810 setCellWidth(width()/4);
811 setCellHeight(height()/13);
812}
813
814void
815KDateInternalWeekPicker::paintCell(QPainter* painter, int row, int col)
816{
817 int index;
818 QString text;
819 // ----- find the number of the cell:
820 index=4*row+col+1;
821 text=QString::number( index );
822 painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text);
823 if ( activeCol == col && activeRow == row )
824 painter->drawRect( 0, 0, cellWidth(), cellHeight() );
825}
826
827void
828KDateInternalWeekPicker::contentsMousePressEvent(QMouseEvent *e)
829{
830 if(!isEnabled() || e->button() != LeftButton)
831 {
832 KNotifyClient::beep();
833 return;
834 }
835 // -----
836 int row, col;
837 QPoint mouseCoord;
838 // -----
839 mouseCoord = e->pos();
840 row=rowAt(mouseCoord.y());
841 col=columnAt(mouseCoord.x());
842
843 if(row<0 || col<0)
844 { // the user clicked on the frame of the table
845 activeCol = -1;
846 activeRow = -1;
847 } else {
848 activeCol = col;
849 activeRow = row;
850 updateCell( row, col /*, false */ );
851 }
852}
853
854void
855KDateInternalWeekPicker::contentsMouseMoveEvent(QMouseEvent *e)
856{
857 if (e->state() & LeftButton)
858 {
859 int row, col;
860 QPoint mouseCoord;
861 // -----
862 mouseCoord = e->pos();
863 row=rowAt(mouseCoord.y());
864 col=columnAt(mouseCoord.x());
865 int tmpRow = -1, tmpCol = -1;
866 if(row<0 || col<0)
867 { // the user clicked on the frame of the table
868 if ( activeCol > -1 )
869 {
870 tmpRow = activeRow;
871 tmpCol = activeCol;
872 }
873 activeCol = -1;
874 activeRow = -1;
875 } else {
876 bool differentCell = (activeRow != row || activeCol != col);
877 if ( activeCol > -1 && differentCell)
878 {
879 tmpRow = activeRow;
880 tmpCol = activeCol;
881 }
882 if ( differentCell)
883 {
884 activeRow = row;
885 activeCol = col;
886 updateCell( row, col /*, false */ ); // mark the new active cell
887 }
888 }
889 if ( tmpRow > -1 ) // repaint the former active cell
890 updateCell( tmpRow, tmpCol /*, true */ );
891 }
892}
893
894void
895KDateInternalWeekPicker::contentsMouseReleaseEvent(QMouseEvent *e)
896{
897 if(!isEnabled())
898 {
899 return;
900 }
901 // -----
902 int row, col, pos;
903 QPoint mouseCoord;
904 // -----
905 mouseCoord = e->pos();
906 row=rowAt(mouseCoord.y());
907 col=columnAt(mouseCoord.x());
908 if(row<0 || col<0)
909 { // the user clicked on the frame of the table
910 emit(closeMe(0));
911 }
912 pos=4*row+col+1;
913 result=pos;
914 emit(closeMe(1));
915}
diff --git a/microkde/kdatetbl.h b/microkde/kdatetbl.h
index b4d3e16..2efa532 100644
--- a/microkde/kdatetbl.h
+++ b/microkde/kdatetbl.h
@@ -307,3 +307,66 @@ private:
307}; 307};
308 308
309#endif // KDATETBL_H 309#endif // KDATETBL_H
310class KDateInternalWeekPicker : public QGridView
311{
312 Q_OBJECT
313protected:
314 /**
315 * Store the month that has been clicked [1..12].
316 */
317 int result;
318 /**
319 * the cell under mouse cursor when LBM is pressed
320 */
321 short int activeCol;
322 short int activeRow;
323 /**
324 * Contains the largest rectangle needed by the month names.
325 */
326 QRect max;
327signals:
328 /**
329 * This is send from the mouse click event handler.
330 */
331 void closeMe(int);
332public:
333 /**
334 * The constructor.
335 */
336 KDateInternalWeekPicker(int fontsize, QWidget* parent, const char* name=0);
337 /**
338 * The size hint.
339 */
340 QSize sizeHint() const;
341 /**
342 * Return the result. 0 means no selection (reject()), 1..12 are the
343 * months.
344 */
345 int getResult() const;
346protected:
347 /**
348 * Set up the painter.
349 */
350 void setupPainter(QPainter *p);
351 /**
352 * The resize event.
353 */
354 void viewportResizeEvent(QResizeEvent*);
355 /**
356 * Paint a cell. This simply draws the month names in it.
357 */
358 virtual void paintCell(QPainter* painter, int row, int col);
359 /**
360 * Catch mouse click and move events to paint a rectangle around the item.
361 */
362 void contentsMousePressEvent(QMouseEvent *e);
363 void contentsMouseMoveEvent(QMouseEvent *e);
364 /**
365 * Emit monthSelected(int) when a cell has been released.
366 */
367 void contentsMouseReleaseEvent(QMouseEvent *e);
368
369private:
370 class KDateInternalMonthPrivate;
371 KDateInternalMonthPrivate *d;
372};