summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-02-07 06:10:09 (UTC)
committer zautrix <zautrix>2005-02-07 06:10:09 (UTC)
commit301a4a207171549bd87815705d8dcf32ad15559d (patch) (side-by-side diff)
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
@@ -69,12 +69,13 @@ using namespace KCal;
#ifdef _OL_IMPORT_
#include "koimportoldialog.h"
#endif
#endif
#include "mainwindow.h"
+
class KOex2phonePrefs : public QDialog
{
public:
KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
QDialog( parent, name, true )
{
@@ -141,16 +142,17 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
QString confFile = locateLocal("config","korganizerrc");
QFileInfo finf ( confFile );
bool showWarning = !finf.exists();
setIcon(SmallIcon( "ko24" ) );
mBlockAtStartup = true;
mFlagKeyPressed = false;
+ setCaption("KOrganizer/Pi");
KOPrefs *p = KOPrefs::instance();
KPimGlobalPrefs::instance()->setGlobalConfig();
- if ( p->mHourSize > 18 )
- p->mHourSize = 18;
+ if ( p->mHourSize > 22 )
+ p->mHourSize = 22;
QMainWindow::ToolBarDock tbd;
if ( p->mToolBarHor ) {
if ( p->mToolBarUp )
tbd = Bottom;
else
tbd = Top;
@@ -164,14 +166,12 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
if ( KOPrefs::instance()->mUseAppColors )
QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
globalFlagBlockStartup = 1;
iconToolBar = new QPEToolBar( this );
addToolBar (iconToolBar , tbd );
mCalendarModifiedFlag = false;
-
- setCaption("KOrganizer/Pi");
QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
splash->setAlignment ( AlignCenter );
setCentralWidget( splash );
#ifndef DESKTOP_VERSION
showMaximized();
#endif
@@ -554,49 +554,55 @@ void MainWindow::initActions()
menuBar->insertItem( i18n("Help"), helpMenu );
//menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
menuBar1->setMaximumSize( menuBar1->sizeHint( ));
}
connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) );
-
- menuBarWeek = new QPEMenuBar( iconToolBar );
- QPopupMenu * wpo = new QPopupMenu (this);
- QPopupMenu * all = new QPopupMenu (this);
- //wpo->insertItem( i18n("W#"), 0 );
- int first = 1;
- int i;
- for ( i = 1; i < 50; ++i ) {
- if ( !(i%10) ) {
- all->insertItem( i18n("Select week %1-%2" ).arg(first).arg( i-1) ,wpo );
- connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeek ( int ) ) );
- first = i;
- wpo = new QPopupMenu (this);
- }
- wpo->insertItem( QString::number(i), i );
- }
- for ( i = 50; i < 53; ++i ) {
- wpo->insertItem( QString::number(i), i);
- }
- all->insertItem( i18n("Select week %1-%2" ).arg(first).arg( i-1) ,wpo );
- connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeek ( int ) ) );
- menuBarWeek->insertItem( "00",all,1);
- menuBarWeek->setMaximumSize( menuBarWeek->sizeHint( ));
+ QIconSet icon;
+ int pixWid = 22, pixHei = 22;
+ QString pathString = "";
+ if ( !p->mToolBarMiniIcons ) {
+ if ( QApplication::desktop()->width() < 480 ) {
+ pathString += "icons16/";
+ pixWid = 18; pixHei = 16;
+ }
+ } else {
+ pathString += "iconsmini/";
+ pixWid = 18; pixHei = 16;
+ }
+ mWeekBgColor = iconToolBar->backgroundColor();
+ mWeekPixmap.resize( pixWid , pixHei );
+ mWeekPixmap.fill( mWeekBgColor );
+ icon = mWeekPixmap;
+ mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this );
+ mWeekAction->addTo( iconToolBar );
+ mWeekFont = font();
+
+ int fontPoint = mWeekFont.pointSize();
+ QFontMetrics f( mWeekFont );
+ int fontWid = f.width( "30" );
+ while ( fontWid > pixWid ) {
+ --fontPoint;
+ mWeekFont.setPointSize( fontPoint );
+ QFontMetrics f( mWeekFont );
+ fontWid = f.width( "30" );
+ qDebug("dec-- ");
+ }
+
+ connect( mWeekAction, SIGNAL( activated() ),
+ this, SLOT( weekAction() ) );
connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) );
+
+ //#endif
// ******************
QAction *action;
- QIconSet icon;
// QPopupMenu *configureMenu= new QPopupMenu( menuBar );
configureToolBarMenu->setCheckable( true );
- QString pathString = "";
- if ( !p->mToolBarMiniIcons ) {
- if ( QApplication::desktop()->width() < 480 )
- pathString += "icons16/";
- } else
- pathString += "iconsmini/";
+
configureAgendaMenu->setCheckable( true );
int iii ;
for ( iii = 1;iii<= 10 ;++iii ){
configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 );
}
//configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
@@ -1367,14 +1373,20 @@ void MainWindow::updateWeek(QDate seda)
d = d.addDays( 1-dow );
else // 5,6,7
d = d.addDays( 8-dow );
// we have the first week of the year.we are on monday
weekNum = d.daysTo( seda ) / 7 +1;
}
- //qDebug("weeknum %s ", QString::number( weekNum).latin1());
- menuBarWeek-> changeItem(1, QString::number( weekNum) );
+
+ mWeekPixmap.fill( mWeekBgColor );
+ QPainter p ( &mWeekPixmap );
+ p.setFont( mWeekFont );
+ p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) );
+ p.end();
+ QIconSet icon3 ( mWeekPixmap );
+ mWeekAction->setIconSet ( icon3 );
}
void MainWindow::updateWeekNum(const DateList &selectedDates)
{
updateWeek( selectedDates.first() );
}
@@ -1716,13 +1728,13 @@ void MainWindow::keyPressEvent ( QKeyEvent * e )
mView->newEvent();
else
mView->editIncidence();
break;
case Qt::Key_Plus:
size = p->mHourSize +2;
- if ( size <= 18 )
+ if ( size <= 22 )
configureAgenda( size );
break;
case Qt::Key_Minus:
size = p->mHourSize - 2;
if ( size >= 4 )
configureAgenda( size );
@@ -2008,6 +2020,30 @@ void MainWindow::printSel( )
void MainWindow::printCal()
{
mView->print();//mCp->showDialog();
}
+
+#include "libkdepim/kdatepicker.h"
+#include <kdatetbl.h>
+void MainWindow::weekAction()
+{
+ int month;
+ KPopupFrame* popup = new KPopupFrame(this);
+ int size = 12;
+ if ( QApplication::desktop()->width() >= 480 )
+ size = 18;
+ KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(size, popup);
+ // -----
+ picker->resize(picker->sizeHint());
+ popup->setMainWidget(picker);
+ picker->setFocus();
+ connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
+ if(popup->exec(iconToolBar->mapToGlobal(QPoint(0, iconToolBar->height()))))
+ {
+ month = picker->getResult();
+ emit selectWeek ( month );
+ //qDebug("weekSelected %d ", month);
+ }
+ delete popup;
+}
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 076ab94..5b9f903 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -2,12 +2,13 @@
#define KORGE_MAINWINDOW_H
#include <qmainwindow.h>
#include <qtimer.h>
#include <qdict.h>
#include <qfile.h>
+#include <qmenubar.h>
#include <qtextstream.h>
#include <qregexp.h>
#include <libkcal/incidence.h>
#include "simplealarmclient.h"
#include <ksyncmanager.h>
@@ -20,19 +21,25 @@ class KSyncProfile;
#ifdef DESKTOP_VERSION
#define QPEToolBar QToolBar
#define QPEMenuBar QMenuBar
#endif
class QPEToolBar;
-class QPEMenuBar;
namespace KCal {
class CalendarLocal;
}
+class KOMenuBar : public QMenuBar
+{
+ public:
+ KOMenuBar( QWidget *parent=0 ): QMenuBar (parent ) {;}
+ QSize sizeHint () const{ qDebug("sizejint ");return QSize ( 40,25 );}
+};
+
using namespace KCal;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
@@ -47,12 +54,13 @@ class MainWindow : public QMainWindow
void updateWeek(QDate);
virtual void showMaximized ();
void configureAgenda( int );
void recieve( const QCString& msg, const QByteArray& data );
protected slots:
void setCaptionToDates();
+ void weekAction();
void about();
void licence();
void faq();
void usertrans();
void features();
void synchowto();
@@ -117,13 +125,16 @@ class MainWindow : public QMainWindow
QPopupMenu *configureToolBarMenu;
QPopupMenu *selectFilterMenu;
QPopupMenu *configureAgendaMenu, *syncMenu;
CalendarLocal *mCalendar;
CalendarView *mView;
QAction *mNewSubTodoAction;
- QPEMenuBar *menuBarWeek;
+ QAction *mWeekAction;
+ QFont mWeekFont;
+ QPixmap mWeekPixmap;
+ QColor mWeekBgColor;
QAction *mShowAction;
QAction *mEditAction;
QAction *mDeleteAction;
QAction *mCloneAction;
QAction *mMoveAction;
diff --git a/microkde/kdatetbl.cpp b/microkde/kdatetbl.cpp
index 508ce31..fce0e5a 100644
--- a/microkde/kdatetbl.cpp
+++ b/microkde/kdatetbl.cpp
@@ -745,6 +745,171 @@ void KPopupFrame::virtual_hook( int, void* )
{ /*BASE::virtual_hook( id, data );*/ }
void KDateTable::virtual_hook( int, void* )
{ /*BASE::virtual_hook( id, data );*/ }
//#include "kdatetbl.moc"
+
+
+KDateInternalWeekPicker::KDateInternalWeekPicker
+(int fontsize, QWidget* parent, const char* name)
+ : QGridView(parent, name),
+ result(0) // invalid
+{
+ QRect rect;
+ QFont font;
+ // -----
+ activeCol = -1;
+ activeRow = -1;
+ font=KGlobalSettings::generalFont();
+ font.setPointSize(fontsize);
+ setFont(font);
+ setHScrollBarMode(AlwaysOff);
+ setVScrollBarMode(AlwaysOff);
+ setFrameStyle(QFrame::NoFrame);
+ setNumRows(13);
+ setNumCols(4);
+ // enable to find drawing failures:
+ // setTableFlags(Tbl_clipCellPainting);
+#if 0
+ viewport()->setEraseColor(lightGray); // for consistency with the datepicker
+#endif
+ // ----- find the preferred size
+ // (this is slow, possibly, but unfortunatly it is needed here):
+ QFontMetrics metrics(font);
+ for(int i=1; i <= 52; ++i)
+ {
+ rect=metrics.boundingRect(QString::number( i ));
+ if(max.width()<rect.width()) max.setWidth(rect.width());
+ if(max.height()<rect.height()) max.setHeight(rect.height());
+ }
+
+}
+
+QSize
+KDateInternalWeekPicker::sizeHint() const
+{
+ return QSize((max.width()+6)*numCols()+2*frameWidth(),
+ (max.height()+6)*numRows()+2*frameWidth());
+}
+
+int
+KDateInternalWeekPicker::getResult() const
+{
+ return result;
+}
+
+void
+KDateInternalWeekPicker::setupPainter(QPainter *p)
+{
+ p->setPen(black);
+}
+
+void
+KDateInternalWeekPicker::viewportResizeEvent(QResizeEvent*)
+{
+ setCellWidth(width()/4);
+ setCellHeight(height()/13);
+}
+
+void
+KDateInternalWeekPicker::paintCell(QPainter* painter, int row, int col)
+{
+ int index;
+ QString text;
+ // ----- find the number of the cell:
+ index=4*row+col+1;
+ text=QString::number( index );
+ painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text);
+ if ( activeCol == col && activeRow == row )
+ painter->drawRect( 0, 0, cellWidth(), cellHeight() );
+}
+
+void
+KDateInternalWeekPicker::contentsMousePressEvent(QMouseEvent *e)
+{
+ if(!isEnabled() || e->button() != LeftButton)
+ {
+ KNotifyClient::beep();
+ return;
+ }
+ // -----
+ int row, col;
+ QPoint mouseCoord;
+ // -----
+ mouseCoord = e->pos();
+ row=rowAt(mouseCoord.y());
+ col=columnAt(mouseCoord.x());
+
+ if(row<0 || col<0)
+ { // the user clicked on the frame of the table
+ activeCol = -1;
+ activeRow = -1;
+ } else {
+ activeCol = col;
+ activeRow = row;
+ updateCell( row, col /*, false */ );
+ }
+}
+
+void
+KDateInternalWeekPicker::contentsMouseMoveEvent(QMouseEvent *e)
+{
+ if (e->state() & LeftButton)
+ {
+ int row, col;
+ QPoint mouseCoord;
+ // -----
+ mouseCoord = e->pos();
+ row=rowAt(mouseCoord.y());
+ col=columnAt(mouseCoord.x());
+ int tmpRow = -1, tmpCol = -1;
+ if(row<0 || col<0)
+ { // the user clicked on the frame of the table
+ if ( activeCol > -1 )
+ {
+ tmpRow = activeRow;
+ tmpCol = activeCol;
+ }
+ activeCol = -1;
+ activeRow = -1;
+ } else {
+ bool differentCell = (activeRow != row || activeCol != col);
+ if ( activeCol > -1 && differentCell)
+ {
+ tmpRow = activeRow;
+ tmpCol = activeCol;
+ }
+ if ( differentCell)
+ {
+ activeRow = row;
+ activeCol = col;
+ updateCell( row, col /*, false */ ); // mark the new active cell
+ }
+ }
+ if ( tmpRow > -1 ) // repaint the former active cell
+ updateCell( tmpRow, tmpCol /*, true */ );
+ }
+}
+
+void
+KDateInternalWeekPicker::contentsMouseReleaseEvent(QMouseEvent *e)
+{
+ if(!isEnabled())
+ {
+ return;
+ }
+ // -----
+ int row, col, pos;
+ QPoint mouseCoord;
+ // -----
+ mouseCoord = e->pos();
+ row=rowAt(mouseCoord.y());
+ col=columnAt(mouseCoord.x());
+ if(row<0 || col<0)
+ { // the user clicked on the frame of the table
+ emit(closeMe(0));
+ }
+ pos=4*row+col+1;
+ result=pos;
+ emit(closeMe(1));
+}
diff --git a/microkde/kdatetbl.h b/microkde/kdatetbl.h
index b4d3e16..2efa532 100644
--- a/microkde/kdatetbl.h
+++ b/microkde/kdatetbl.h
@@ -304,6 +304,69 @@ protected:
private:
class KDateTablePrivate;
KDateTablePrivate *d;
};
#endif // KDATETBL_H
+class KDateInternalWeekPicker : public QGridView
+{
+ Q_OBJECT
+protected:
+ /**
+ * Store the month that has been clicked [1..12].
+ */
+ int result;
+ /**
+ * the cell under mouse cursor when LBM is pressed
+ */
+ short int activeCol;
+ short int activeRow;
+ /**
+ * Contains the largest rectangle needed by the month names.
+ */
+ QRect max;
+signals:
+ /**
+ * This is send from the mouse click event handler.
+ */
+ void closeMe(int);
+public:
+ /**
+ * The constructor.
+ */
+ KDateInternalWeekPicker(int fontsize, QWidget* parent, const char* name=0);
+ /**
+ * The size hint.
+ */
+ QSize sizeHint() const;
+ /**
+ * Return the result. 0 means no selection (reject()), 1..12 are the
+ * months.
+ */
+ int getResult() const;
+protected:
+ /**
+ * Set up the painter.
+ */
+ void setupPainter(QPainter *p);
+ /**
+ * The resize event.
+ */
+ void viewportResizeEvent(QResizeEvent*);
+ /**
+ * Paint a cell. This simply draws the month names in it.
+ */
+ virtual void paintCell(QPainter* painter, int row, int col);
+ /**
+ * Catch mouse click and move events to paint a rectangle around the item.
+ */
+ void contentsMousePressEvent(QMouseEvent *e);
+ void contentsMouseMoveEvent(QMouseEvent *e);
+ /**
+ * Emit monthSelected(int) when a cell has been released.
+ */
+ void contentsMouseReleaseEvent(QMouseEvent *e);
+
+private:
+ class KDateInternalMonthPrivate;
+ KDateInternalMonthPrivate *d;
+};