summaryrefslogtreecommitdiff
authorzecke <zecke>2002-10-25 22:12:35 (UTC)
committer zecke <zecke>2002-10-25 22:12:35 (UTC)
commitb682e9d2276c10a5c26773c6797ba1ac176ea4cf (patch) (side-by-side diff)
tree9780ad571f14943e3ad6c3ec34a4e787f8a85217
parent595407074ac5724eb33aeb151ce27e38fbca21d5 (diff)
downloadopie-b682e9d2276c10a5c26773c6797ba1ac176ea4cf.zip
opie-b682e9d2276c10a5c26773c6797ba1ac176ea4cf.tar.gz
opie-b682e9d2276c10a5c26773c6797ba1ac176ea4cf.tar.bz2
MainWindow i18n change 'Show only over due' to avoid misunderstanding
then 'share' and 'preload' the taskeditor on first request it'll be created but on destroyed until Destruction the interface. This will happen when the apps quits. This should speed up editing and entering quite a lot
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp2
-rw-r--r--core/pim/todo/otaskeditor.cpp19
-rw-r--r--core/pim/todo/otaskeditor.h7
-rw-r--r--core/pim/todo/taskeditoroverviewimpl.cpp12
-rw-r--r--core/pim/todo/todoeditor.cpp32
-rw-r--r--core/pim/todo/todoeditor.h4
6 files changed, 59 insertions, 17 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index 71e6750..9b2423b 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -1,434 +1,434 @@
/*
               =. This file is part of the OPIE Project
             .=l. Copyright (c) 2002 <>
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <unistd.h>
#include <qmenubar.h>
#include <qmessagebox.h>
#include <qtoolbar.h>
#include <qpopupmenu.h>
#include <qwidgetstack.h>
#include <qaction.h>
#include <qtimer.h>
#include <qvbox.h>
#include <qlineedit.h>
#include <qpe/applnk.h>
#include <qpe/config.h>
#include <qpe/ir.h>
#include <qpe/resource.h>
#include <qpe/qpemessagebox.h>
#include <opie/otodoaccessvcal.h>
#include "quickeditimpl.h"
#include "todotemplatemanager.h"
#include "templateeditor.h"
#include "tableview.h"
#include "textviewshow.h"
#include "todoeditor.h"
#include "mainwindow.h"
using namespace Todo;
MainWindow::MainWindow( QWidget* parent,
const char* name ) {
m_syncing = false;
m_counter = 0;
m_tempManager = new TemplateManager();
m_tempManager->load();
initUI();
initConfig();
initViews();
initActions();
initEditor();
initShow();
initTemplate();
populateTemplates();
raiseCurrentView();
QTimer::singleShot(0, this, SLOT(populateCategories() ) );
}
void MainWindow::initTemplate() {
m_curTempEd = new TemplateEditor( this, templateManager() );
}
void MainWindow::initActions() {
QAction* a = new QAction( tr("New Task" ), Resource::loadPixmap( "new" ),
QString::null, 0, this, 0 );
connect(a, SIGNAL( activated() ),
this, SLOT( slotNew() ) );
a->addTo(m_tool );
a->addTo(m_edit );
a = new QAction( tr("Edit Task"), Resource::loadIconSet( "edit" ),
QString::null, 0, this, 0 );
connect(a, SIGNAL(activated() ),
this, SLOT( slotEdit() ) );
a->addTo( m_tool );
a->addTo( m_edit );
m_editAction = a;
a = new QAction( QString::null, tr("View Task"), 0, this, 0 );
connect(a, SIGNAL( activated() ),
this, SLOT( slotShowDetails() ) );
a->addTo( m_edit );
m_edit->insertSeparator();
a = new QAction( tr("Delete..."), Resource::loadIconSet( "trash" ),
QString::null, 0, this, 0 );
connect(a, SIGNAL(activated() ),
this, SLOT(slotDelete() ) );
a->addTo( m_tool );
a->addTo( m_edit );
m_deleteAction = a;
a = new QAction( QString::null, tr("Delete all..."), 0, this, 0 );
connect(a, SIGNAL( activated() ),
this, SLOT( slotDeleteAll() ) );
a->addTo(m_edit );
m_deleteAllAction = a;
a = new QAction( QString::null, tr("Delete completed"),
0, this, 0 );
connect(a, SIGNAL( activated() ),
this, SLOT( slotDeleteCompleted() ) );
a->addTo(m_edit );
a->setEnabled( TRUE );
m_deleteCompleteAction = a;
m_edit->insertSeparator();
a = new QAction( QString::null, tr("Duplicate"), 0, this, 0 );
connect(a, SIGNAL( activated() ),
this, SLOT( slotDuplicate() ) );
a->addTo(m_edit );
m_duplicateAction = a;
m_edit->insertSeparator();
if ( Ir::supported() ) {
a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ),
QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ),
this, SLOT( slotBeam() ) );
a->addTo( m_edit );
a->addTo( m_tool );
}
a = new QAction( tr("Find"), Resource::loadIconSet( "mag" ),
QString::null, 0, this, 0 );
connect(a, SIGNAL( activated() ),
this, SLOT( slotFind() ) );
a->addTo( m_options );
m_findAction = a;
m_options->insertSeparator();
m_completedAction = new QAction( QString::null, tr("Completed tasks"),
0, this, 0, TRUE );
m_completedAction->addTo( m_options );
m_completedAction->setOn( showCompleted() );
connect(m_completedAction, SIGNAL( toggled(bool) ),
this, SLOT(slotShowCompleted(bool) ) );
m_showDeadLineAction = new QAction( QString::null, tr("Show Deadline"),
0, this, 0, TRUE );
m_showDeadLineAction->addTo( m_options );
m_showDeadLineAction->setOn( showDeadline() );
connect(m_showDeadLineAction, SIGNAL(toggled(bool) ),
this, SLOT( slotShowDeadLine( bool ) ) );
m_options->insertSeparator();
m_bar->insertItem( tr("Data") ,m_edit );
m_bar->insertItem( tr("Category"), m_catMenu );
m_bar->insertItem( tr("Options"), m_options );
/* initialize the view menu */
- a = new QAction( QString::null, tr("Show over due"),
+ a = new QAction( QString::null, tr("Show only over due"),
0, this, 0, TRUE );
a->addTo( m_view );
a->setOn( showOverDue() );
connect(a, SIGNAL(toggled(bool)),
this, SLOT(slotShowDue(bool) ) );
m_view->insertSeparator();
m_bar->insertItem( tr("View"), m_view );
/* templates */
m_edit->insertItem(tr("New from template"), m_template,
-1, 0 );
}
/* m_curCat from Config */
void MainWindow::initConfig() {
Config config( "todo" );
config.setGroup( "View" );
m_completed = config.readBoolEntry( "ShowComplete", TRUE );
m_curCat = config.readEntry( "Category", QString::null );
m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE);
m_overdue = config.readBoolEntry("ShowOverDue", TRUE );
}
void MainWindow::initUI() {
m_mainBox = new QVBox(this, "main box ");
m_curQuick = new QuickEditImpl(this, m_mainBox );
m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) );
m_quickEdit.append( m_curQuick );
m_stack = new QWidgetStack(m_mainBox, "main stack");
setCentralWidget( m_mainBox );
setToolBarsMovable( FALSE );
m_tool = new QToolBar( this );
m_tool->setHorizontalStretchable( TRUE );
m_bar = new QMenuBar( m_tool );
/** QPopupMenu */
m_edit = new QPopupMenu( this );
m_options = new QPopupMenu( this );
m_view = new QPopupMenu( this );
m_catMenu = new QPopupMenu( this );
m_template = new QPopupMenu( this );
m_catMenu->setCheckable( TRUE );
m_template->setCheckable( TRUE );
connect(m_catMenu, SIGNAL(activated(int) ),
this, SLOT(setCategory(int) ) );
connect(m_template, SIGNAL(activated(int) ),
this, SLOT(slotNewFromTemplate(int) ) );
}
void MainWindow::initViews() {
TableView* tableView = new TableView( this, m_stack );
m_stack->addWidget( tableView, m_counter++ );
m_views.append( tableView );
m_curView = tableView;
connectBase( tableView );
/* add QString type + QString configname to
* the View menu
* and subdirs for multiple views
*/
}
void MainWindow::initEditor() {
m_curEdit = new Editor();
}
void MainWindow::initShow() {
m_curShow = new TextViewShow(this);
m_stack->addWidget( m_curShow->widget() , m_counter++ );
}
MainWindow::~MainWindow() {
delete templateManager();
}
void MainWindow::connectBase( ViewBase* base) {
base->connectShow( this, SLOT(slotShow(int) ) );
base->connectEdit( this, SLOT(slotEdit(int) ) );
base->connectUpdateSmall( this,
SLOT(slotUpate1(int, const Todo::SmallTodo&) ));
base->connectUpdateBig( this,
SLOT(slotUpate2(int, const OTodo& ) ) );
base->connectUpdateView( this, SLOT(slotUpdate3( QWidget* ) ) ) ;
base->connectRemove(&m_todoMgr,
SLOT(remove(int)) );
}
QPopupMenu* MainWindow::contextMenu( int uid ) {
QPopupMenu* menu = new QPopupMenu();
m_editAction->addTo( menu );
m_deleteAction->addTo( menu );
m_duplicateAction->addTo( menu );
menu->insertSeparator();
return menu;
}
QPopupMenu* MainWindow::options() {
qWarning("Options");
return m_options;
}
QPopupMenu* MainWindow::edit() {
return m_edit;
}
QPopupMenu* MainWindow::view() {
return m_view;
}
QToolBar* MainWindow::toolbar() {
return m_tool;
}
OTodoAccess::List MainWindow::list()const {
return m_todoMgr.list();
}
OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) {
int cat = 0;
if ( m_curCat != tr("All Categories") )
cat = currentCatId();
int filter = 1;
if (!m_completed )
filter |= 4;
if (m_overdue)
filter |= 2;
return m_todoMgr.sorted( asc, sortOrder, filter, cat );
}
OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) {
int cat = 0;
if ( m_curCat != tr("All Categories") )
cat = currentCatId();
return m_todoMgr.sorted(asc, sortOrder, addFilter, cat );
}
OTodo MainWindow::event( int uid ) {
return m_todoMgr.event( uid );
}
bool MainWindow::isSyncing()const {
return m_syncing;
}
TemplateManager* MainWindow::templateManager() {
return m_tempManager;
}
Editor* MainWindow::currentEditor() {
return m_curEdit;
}
TodoShow* MainWindow::currentShow() {
return m_curShow;
}
void MainWindow::slotReload() {
m_todoMgr.reload();
currentView()->updateView( );
raiseCurrentView();
}
void MainWindow::closeEvent( QCloseEvent* e ) {
if (m_stack->visibleWidget() == currentShow()->widget() ) {
raiseCurrentView();
e->ignore();
return;
}
/*
* we should have flushed and now we're still saving
* so there is no need to flush
*/
if (m_syncing ) {
e->accept();
return;
}
bool quit = false;
if ( m_todoMgr.saveAll() ){
qWarning("saved");
quit = true;
}else {
if ( QMessageBox::critical( this, tr("Out of space"),
tr("Todo was unable\n"
"to save your changes.\n"
"Free up some space\n"
"and try again.\n"
"\nQuit Anyway?"),
QMessageBox::Yes|QMessageBox::Escape,
QMessageBox::No|QMessageBox::Default)
!= QMessageBox::No ) {
e->accept();
quit = true;
}else
e->ignore();
}
if (quit ) {
Config config( "todo" );
config.setGroup( "View" );
config.writeEntry( "ShowComplete", showCompleted() );
config.writeEntry( "Category", currentCategory() );
config.writeEntry( "ShowDeadLine", showDeadline());
config.writeEntry( "ShowOverDue", showOverDue() );
/* svae templates */
templateManager()->save();
e->accept();
}
}
void MainWindow::populateTemplates() {
m_template->clear();
QStringList list = templateManager()->templates();
QStringList::Iterator it;
for ( it = list.begin(); it != list.end(); ++it ) {
m_template->insertItem( (*it) );
}
}
/*
* slotNewFromTemplate
* We use the edit widget to do
* the config but we setUid(-1)
* to get a new uid
*/
/*
* first we get the name of the template
* then we will use the TemplateManager
*/
void MainWindow::slotNewFromTemplate( int id ) {
QString name = m_template->text( id );
OTodo event = templateManager()->templateEvent( name );
event = currentEditor()->edit(this,
event );
if ( currentEditor()->accepted() ) {
/* assign new todo */
event.setUid( -1 );
currentView()->addEvent( event );
m_todoMgr.add( event );
populateCategories();
}
}
void MainWindow::slotNew() {
if(m_syncing) {
QMessageBox::warning(this, tr("Todo"),
tr("Can not edit data, currently syncing"));
return;
}
OTodo todo = currentEditor()->newTodo( currentCatId(),
this );
if ( currentEditor()->accepted() ) {
//todo.assignUid();
m_todoMgr.add( todo );
currentView()->addEvent( todo );
// I'm afraid we must call this every time now, otherwise
// spend expensive time comparing all these strings...
// but only call if we changed something -zecke
diff --git a/core/pim/todo/otaskeditor.cpp b/core/pim/todo/otaskeditor.cpp
index e8e922f..1a68eb5 100644
--- a/core/pim/todo/otaskeditor.cpp
+++ b/core/pim/todo/otaskeditor.cpp
@@ -1,83 +1,90 @@
#include <qdatetime.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qmultilineedit.h>
#include <opie/orecurrancewidget.h>
#include "taskeditoroverviewimpl.h"
#include "taskeditoradvanced.h"
#include "taskeditoralarms.h"
#include "otaskeditor.h"
OTaskEditor::OTaskEditor(int cur)
: QDialog(0, 0, TRUE ) {
init();
- OTodo to;
- to.setCategories( cur );
- load(to);
- m_uid = 1; // generate a new one
+ init( cur );
}
OTaskEditor::OTaskEditor( const OTodo& to)
: QDialog(0, 0, TRUE ) {
init();
- load( to );
- m_uid = to.uid();
+ init( to );
}
OTaskEditor::~OTaskEditor() {
}
+void OTaskEditor::init( int cur ) {
+ OTodo to;
+ if ( cur != 0 )
+ to.setCategories( cur );
+ load(to);
+ m_uid = 1; // generate a new one
+}
+void OTaskEditor::init( const OTodo& to ) {
+ load( to );
+ m_uid = to.uid();
+}
OTodo OTaskEditor::todo()const{
qWarning("saving!");
OTodo to;
to.setUid(m_uid );
m_overView->save( to );
to.setDescription( m_line->text() );
return to;
}
void OTaskEditor::load(const OTodo& to) {
m_overView->load( to );
m_line->setText( to.description() );
}
void OTaskEditor::init() {
QVBoxLayout* lay = new QVBoxLayout(this);
setCaption("Task Editor");
m_tab = new OTabWidget(this);
/*
* Add the Widgets
*/
m_overView = new TaskEditorOverViewImpl(m_tab );
m_tab->addTab( m_overView, QString::null, tr("Overview") );
m_adv = new TaskEditorAdvanced( m_tab );
m_line = new QMultiLineEdit(m_adv );
QLabel* label = new QLabel(m_adv );
label->setText( tr("Description") );
((QGridLayout*) m_adv->layout() )->addWidget( label,3, 0 );
((QGridLayout*) m_adv->layout())->addWidget( m_line,4,0 );
m_tab->addTab( m_adv, QString::null, tr("Advanced") );
m_alarm = new TaskEditorAlarms( m_tab );
m_tab->addTab( m_alarm, QString::null, tr("Alarms") );
m_remind = new TaskEditorAlarms( m_tab );
m_tab->addTab( m_remind, QString::null, tr("Reminders") );
QLabel* lbl = new QLabel(m_tab );
lbl->setText( tr("X-Ref") );
m_tab->addTab( lbl, QString::null, tr("X-Ref") );
m_rec = new ORecurranceWidget( true, QDate::currentDate(), this );
m_tab->addTab( m_rec, QString::null, tr("Recurrance") );
lay->addWidget(m_tab );
/* signal and slots */
connect(m_overView, SIGNAL(recurranceEnabled(bool) ),
m_rec, SLOT(setEnabled(bool) ) );
m_tab->setCurrentTab( m_overView );
}
diff --git a/core/pim/todo/otaskeditor.h b/core/pim/todo/otaskeditor.h
index 5842fdc..bcbd543 100644
--- a/core/pim/todo/otaskeditor.h
+++ b/core/pim/todo/otaskeditor.h
@@ -1,37 +1,44 @@
#ifndef OPIE_TASK_EDITOR_H
#define OPIE_TASK_EDITOR_H
#include <qdialog.h>
#include <opie/otodo.h>
#include <opie/otabwidget.h>
class TaskEditorOverViewImpl;
class TaskEditorAdvanced;
class TaskEditorAlarms;
class ORecurranceWidget;
class QMultiLineEdit;
class OTaskEditor : public QDialog {
Q_OBJECT
public:
OTaskEditor(int cur);
OTaskEditor( const OTodo& todo );
~OTaskEditor();
+ /*
+ * same as the c'tor but this gives us the
+ * power to 'preload' the dialog
+ */
+ void init( int cur );
+ void init( const OTodo& todo );
+
OTodo todo()const;
private:
void load( const OTodo& );
void init();
OTabWidget *m_tab;
TaskEditorOverViewImpl* m_overView;
TaskEditorAdvanced *m_adv;
TaskEditorAlarms *m_alarm;
TaskEditorAlarms* m_remind;
ORecurranceWidget* m_rec;
QMultiLineEdit* m_line;
int m_uid;
};
#endif
diff --git a/core/pim/todo/taskeditoroverviewimpl.cpp b/core/pim/todo/taskeditoroverviewimpl.cpp
index b9b2ae6..c10ad40 100644
--- a/core/pim/todo/taskeditoroverviewimpl.cpp
+++ b/core/pim/todo/taskeditoroverviewimpl.cpp
@@ -1,169 +1,181 @@
#include <qapplication.h>
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qpopupmenu.h>
#include <qpe/datebookmonth.h>
#include <qpe/categoryselect.h>
#include <qpe/timestring.h>
#include "taskeditoroverviewimpl.h"
/*
* we need to hack
*/
TaskEditorOverViewImpl::TaskEditorOverViewImpl( QWidget* parent, const char* name )
: TaskEditorOverView( parent, name ) {
init();
}
TaskEditorOverViewImpl::~TaskEditorOverViewImpl() {
}
void TaskEditorOverViewImpl::load( const OTodo& todo) {
+ /*
+ * now that we're 'preloaded' we
+ * need to disable the buttons
+ * holding the dat
+ */
+ btnDue-> setEnabled( FALSE );
+ btnComp-> setEnabled( FALSE );
+ btnStart->setEnabled( FALSE );
+
+
QDate date = QDate::currentDate();
QString str = TimeString::longDateString( date );
emit recurranceEnabled( FALSE );
ckbStart->setChecked( FALSE );
btnStart->setText( str );
ckbComp->setChecked( FALSE );
btnComp->setText( str );
cmbProgress->setCurrentItem( todo.progress()/20 );
cmbSum->insertItem( todo.summary(), 0 );
cmbSum->setCurrentItem( 0 );
ckbDue->setChecked( todo.hasDueDate() );
btnDue->setText( TimeString::longDateString( todo.dueDate() ) );
cmbPrio->setCurrentItem( todo.priority() -1 );
ckbCompleted->setChecked( todo.isCompleted() );
comboCategory->setCategories( todo.categories(), "Todo List", tr("Todo List") );
}
void TaskEditorOverViewImpl::save( OTodo& to) {
qWarning("save it now");
if ( ckbDue->isChecked() ) {
to.setDueDate( m_due );
to.setHasDueDate( true );
}else
to.setHasDueDate( false );
if ( comboCategory->currentCategory() != -1 ) {
QArray<int> arr = comboCategory->currentCategories();
to.setCategories( arr );
}
to.setPriority( cmbPrio->currentItem() + 1 );
to.setCompleted( ckbCompleted->isChecked() );
to.setSummary( cmbSum->currentText() );
to.setProgress( cmbProgress->currentItem() * 20 );
}
/*
* here we will init the basic view
* one Popup for each Date Button
* and some other signal and slots connection
*/
void TaskEditorOverViewImpl::init() {
QDate curDate = QDate::currentDate();
m_start = m_comp = m_due = curDate;
QString str = TimeString::longDateString( curDate );
+
+
/* Start Date Picker */
m_startPop = new QPopupMenu(this);
m_startBook = new DateBookMonth(m_startPop, 0, TRUE );
m_startPop->insertItem( m_startBook );
connect( m_startBook, SIGNAL( dateClicked(int, int, int) ),
this, SLOT(slotStartChanged(int, int, int) ) );
/* Due Date Picker */
m_duePop = new QPopupMenu(this);
m_dueBook = new DateBookMonth(m_duePop, 0, TRUE );
m_duePop->insertItem( m_dueBook );
connect( m_dueBook, SIGNAL( dateClicked(int, int, int) ),
this, SLOT(slotDueChanged(int, int, int) ) );
m_compPop = new QPopupMenu(this);
m_compBook = new DateBookMonth(m_compPop, 0, TRUE );
m_compPop->insertItem(m_compBook );
connect( m_compBook, SIGNAL(dateClicked(int, int, int) ),
this, SLOT(slotCompletedChanged(int, int, int) ) );
/*
* another part of the hack
* it's deprecated in Qt2 but
* still available in my qt-copy of Qt3.1beta2
*/
btnDue->setIsMenuButton( TRUE );
btnStart->setIsMenuButton( TRUE );
btnComp->setIsMenuButton( TRUE );
/* now connect the hack */
connect(btnDue, SIGNAL(clicked() ),
this, SLOT(hackySlotHack2() ) );
connect(btnStart, SIGNAL(clicked() ),
this, SLOT(hackySlotHack1() ) );
connect(btnComp, SIGNAL(clicked() ),
this, SLOT(hackySlotHack3() ) );
/* recurrance */
connect(CheckBox7, SIGNAL(clicked() ),
this, SLOT(slotRecClicked() ) );
}
void TaskEditorOverViewImpl::slotStartChecked() {
qWarning("slotStartChecked");
btnStart->setEnabled( ckbStart->isChecked() );
}
void TaskEditorOverViewImpl::slotStartChanged(int y, int m, int d) {
m_start.setYMD( y, m, d );
btnStart->setText( TimeString::longDateString( m_start ) );
}
void TaskEditorOverViewImpl::slotDueChecked() {
btnDue->setEnabled( ckbDue->isChecked() );
qWarning("slotDueChecked");
}
void TaskEditorOverViewImpl::slotDueChanged(int y, int m, int d ) {
m_due.setYMD(y, m, d );
btnDue->setText( TimeString::longDateString( m_due ) );
}
void TaskEditorOverViewImpl::slotCompletedChecked() {
btnComp->setEnabled( ckbComp->isChecked() );
qWarning("slotCompletedChecked");
}
void TaskEditorOverViewImpl::slotCompletedChanged(int y, int m, int d) {
m_comp.setYMD( y, m, d );
btnComp->setText( TimeString::longDateString( m_comp ) );
}
/*
* called by a button pressed event...
* three slots to avoid ugly name() tests
* to sender()
*/
void TaskEditorOverViewImpl::hackySlotHack1() {
btnStart->setDown( FALSE );
popup( btnStart, m_startPop );
}
void TaskEditorOverViewImpl::hackySlotHack2() {
btnDue->setDown( FALSE );
popup( btnDue, m_duePop );
}
void TaskEditorOverViewImpl::hackySlotHack3() {
btnComp->setDown( FALSE );
popup( btnComp, m_compPop );
}
void TaskEditorOverViewImpl::slotRecClicked() {
qWarning("enabled recurrance");
emit recurranceEnabled( CheckBox7->isChecked() );
}
/*
* GPL from TT QPushButton code
*/
void TaskEditorOverViewImpl::popup( QPushButton* pu, QPopupMenu* pop) {
if ( pu->mapToGlobal( QPoint(0, pu->rect().bottom() ) ).y() + pop->sizeHint().height() <= qApp->desktop()->height() )
pop->exec( pu->mapToGlobal( pu->rect().bottomLeft() ) );
else
pop->exec( pu->mapToGlobal( pu->rect().topLeft() - QPoint(0, pu->sizeHint().height() ) ) );
}
diff --git a/core/pim/todo/todoeditor.cpp b/core/pim/todo/todoeditor.cpp
index e19ab8d..9b8c5cb 100644
--- a/core/pim/todo/todoeditor.cpp
+++ b/core/pim/todo/todoeditor.cpp
@@ -1,55 +1,67 @@
#include "otaskeditor.h"
#include "todoeditor.h"
using namespace Todo;
Editor::Editor() {
m_accepted = false;
+ m_self = 0l;
}
Editor::~Editor() {
+ delete m_self;
+ m_self = 0;
}
OTodo Editor::newTodo( int cur,
- QWidget* par) {
+ QWidget*) {
- OTaskEditor e( cur);
+ OTaskEditor *e = self();
+ e->setCaption( QObject::tr("Enter Task") );
+ e->init( cur );
#if defined(Q_WS_QWS) || defined(_WS_QWS_)
- e.showMaximized();
+ e->showMaximized();
#endif
- int ret = e.exec();
+ int ret = e->exec();
if ( QDialog::Accepted == ret ) {
m_accepted = true;
}else
m_accepted = false;
- OTodo ev = e.todo();
+ OTodo ev = e->todo();
qWarning("Todo uid");
qWarning("Todo %s %d %d", ev.summary().latin1(), ev.progress(), ev.isCompleted() );
ev.setUid(1);
return ev;
}
OTodo Editor::edit( QWidget *wid,
const OTodo& todo ) {
- OTaskEditor e( todo );
- e.setCaption( QObject::tr( "Edit Task" ) );
+ OTaskEditor *e = self();
+ e->init( todo );
+ e->setCaption( QObject::tr( "Edit Task" ) );
#if defined(Q_WS_QWS) || defined(_WS_QWS_)
- e.showMaximized();
+ e->showMaximized();
#endif
- int ret = e.exec();
+ int ret = e->exec();
- OTodo ev = e.todo();
+ OTodo ev = e->todo();
if ( ret == QDialog::Accepted )
m_accepted = true;
else
m_accepted = false;
return ev;
}
bool Editor::accepted()const {
return m_accepted;
}
+OTaskEditor* Editor::self() {
+ if (!m_self )
+ m_self = new OTaskEditor(0);
+
+ return m_self;
+}
diff --git a/core/pim/todo/todoeditor.h b/core/pim/todo/todoeditor.h
index bbfdcb5..fe30634 100644
--- a/core/pim/todo/todoeditor.h
+++ b/core/pim/todo/todoeditor.h
@@ -1,25 +1,29 @@
#ifndef OPIE_TODO_EDITOR_H
#define OPIE_TODO_EDITOR_H
#include <opie/otodo.h>
+class OTaskEditor;
namespace Todo {
class Editor {
public:
Editor();
~Editor();
OTodo newTodo( int currentCatId,
QWidget* par );
OTodo edit( QWidget* par,
const OTodo& ev = OTodo() );
bool accepted()const;
+ protected:
+ OTaskEditor* self();
private:
bool m_accepted: 1;
+ OTaskEditor* m_self;
};
};
#endif