summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/main.cpp2
-rw-r--r--core/pim/todo/mainwindow.cpp7
-rw-r--r--core/pim/todo/tableview.cpp97
-rw-r--r--core/pim/todo/tableview.h7
-rw-r--r--core/pim/todo/todomanager.cpp2
-rw-r--r--core/pim/todo/todoview.cpp3
-rw-r--r--core/pim/todo/todoview.h2
7 files changed, 86 insertions, 34 deletions
diff --git a/core/pim/todo/main.cpp b/core/pim/todo/main.cpp
index 58ed45c..aeae794 100644
--- a/core/pim/todo/main.cpp
+++ b/core/pim/todo/main.cpp
@@ -30,9 +30,9 @@ void myMessages( QtMsgType, const char* ) {
}
int main( int argc, char **argv )
{
- qInstallMsgHandler( myMessages );
+// qInstallMsgHandler( myMessages );
QPEApplication a( argc, argv );
QTime time;
time.start();
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index 48954ce..c9c43d4 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -419,9 +419,8 @@ void MainWindow::slotNew() {
// spend expensive time comparing all these strings...
// but only call if we changed something -zecke
populateCategories();
}
-
raiseCurrentView( );
}
void MainWindow::slotDuplicate() {
if(m_syncing) {
@@ -496,8 +495,9 @@ void MainWindow::slotEdit() {
*/
void MainWindow::setCategory( int c) {
if ( c <= 0 ) return;
+
qWarning("Iterating over cats %d", c );
for ( unsigned int i = 1; i < m_catMenu->count(); i++ )
m_catMenu->setItemChecked(i, c == (int)i );
@@ -512,8 +512,9 @@ void MainWindow::setCategory( int c) {
m_curCat = m_todoMgr.categories()[c-2];
setCaption( tr("Todo") + " - " + m_curCat );
}
m_catMenu->setItemChecked( c, true );
+
currentView()->setShowCategory( m_curCat );
raiseCurrentView();
}
void MainWindow::slotShowDeadLine( bool dead) {
@@ -548,10 +549,9 @@ void MainWindow::slotShowDetails() {
* populate the Categories
* Menu
*/
void MainWindow::populateCategories() {
- if (m_todoMgr.isLoaded() )
- m_todoMgr.load();
+ m_todoMgr.load();
m_catMenu->clear();
int id, rememberId;
id = 1;
@@ -613,8 +613,9 @@ void MainWindow::slotEdit( int uid ) {
if ( currentEditor()->accepted() ) {
qWarning("Replacing now" );
m_todoMgr.update( todo.uid(), todo );
currentView()->replaceEvent( todo );
+ /* a Category might have changed */
populateCategories();
}
raiseCurrentView();
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp
index 5594b13..5d82eb2 100644
--- a/core/pim/todo/tableview.cpp
+++ b/core/pim/todo/tableview.cpp
@@ -88,8 +88,11 @@ TableView::TableView( MainWindow* window, QWidget* wid )
m_enablePaint = true;
setUpdatesEnabled( true );
viewport()->setUpdatesEnabled( true );
viewport()->update();
+ setSortOrder( 0 );
+ setAscending( TRUE );
+ m_first = true;
}
/* a new day has started
* update the day
*/
@@ -108,11 +111,11 @@ void TableView::slotShowMenu() {
QString TableView::type() const {
return QString::fromLatin1( tr("Table View") );
}
int TableView::current() {
- int cur = 0;
- // FIXME
- return cur;
+ int uid = sorted().uidAt(currentRow() );
+ qWarning("uid %d", uid );
+ return uid;
}
QString TableView::currentRepresentation() {
return text( currentRow(), 2);
}
@@ -122,10 +125,8 @@ void TableView::showOverDue( bool ) {
updateView();
}
void TableView::updateView( ) {
- setSortOrder( 0 );
- setAscending( true );
sort();
OTodoAccess::List::Iterator it, end;
it = sorted().begin();
end = sorted().end();
@@ -186,40 +187,43 @@ void TableView::setShowDeadline( bool b) {
showColumn(3 );
else
hideColumn(3 );
}
-void TableView::setShowCategory( const QString& ) {
+void TableView::setShowCategory( const QString& str) {
qWarning("setShowCategory");
- updateView();
+ if ( str != m_oleCat || m_first )
+ updateView();
+
+ m_oleCat = str;
+ m_first = false;
+
}
void TableView::clear() {
setNumRows(0);
}
void TableView::slotClicked(int row, int col, int,
const QPoint& point) {
if ( !cellGeometry(row, col ).contains(point ) )
return;
- int ui=0; // FIXME = uid(row);
+
+ int ui= sorted().uidAt( row );
switch( col ) {
- case 0: {
- // FIXME
- CheckItem* item = 0l;
- /*
- * let's see if we centered clicked
- */
- if ( item ) {
- int x = point.x() -columnPos( col );
- int y = point.y() -rowPos( row );
- int w = columnWidth( col );
- int h = rowHeight( row );
- if ( x >= ( w - OCheckItem::BoxSize ) / 2 &&
- x <= ( w - OCheckItem::BoxSize ) / 2 + OCheckItem::BoxSize &&
- y >= ( h - OCheckItem::BoxSize ) / 2 &&
- y <= ( h - OCheckItem::BoxSize ) / 2 + OCheckItem::BoxSize )
- item->toggle();
- }
+ case 0:{
+ int x = point.x() -columnPos( col );
+ int y = point.y() -rowPos( row );
+ int w = columnWidth( col );
+ int h = rowHeight( row );
+ if ( x >= ( w - BoxSize ) / 2 &&
+ x <= ( w - BoxSize ) / 2 + BoxSize &&
+ y >= ( h - BoxSize ) / 2 &&
+ y <= ( h - BoxSize ) / 2 + BoxSize ) {
+ OTodo todo = sorted()[row];
+ todo.setCompleted( !todo.isCompleted() );
+ TodoView::update( todo.uid(), todo );
+ updateView();
+ }
}
break;
case 1:
@@ -261,11 +265,13 @@ QWidget* TableView::widget() {
* based
* We event want to set the setOrder
* to a sort() and update()
*/
-void TableView::sortColumn( int row, bool asc, bool ) {
- QTable::sortColumn( row, asc, TRUE );
-
+void TableView::sortColumn( int col, bool asc, bool ) {
+ qWarning("bool %d", asc );
+ setSortOrder( col );
+ setAscending( asc );
+ updateView();
}
void TableView::viewportPaintEvent( QPaintEvent* e) {
qWarning("Paint event" );
if (m_enablePaint )
@@ -356,4 +362,39 @@ void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool
break;
}
p->restore();
}
+QWidget* TableView::createEditor(int row, int col, bool )const {
+ switch( col ) {
+ case 1: {
+ /* the priority stuff */
+ QComboBox* combo = new QComboBox( viewport() );
+ combo->insertItem( "1" );
+ combo->insertItem( "2" );
+ combo->insertItem( "3" );
+ combo->insertItem( "4" );
+ combo->insertItem( "5" );
+ combo->setCurrentItem( sorted()[row].priority()-1 );
+ return combo;
+ }
+ case 0:
+ default:
+ return 0l;
+ }
+}
+void TableView::setCellContentFromEditor(int row, int col ) {
+ if ( col == 1 ) {
+ QWidget* wid = cellWidget(row, 1 );
+ if ( wid->inherits("QComboBox") ) {
+ int pri = ((QComboBox*)wid)->currentItem() + 1;
+ OTodo todo = sorted()[row];
+ if ( todo.priority() != pri ) {
+ todo.setPriority( pri );
+ TodoView::update( todo.uid(), todo );
+ updateView();
+ }
+ }
+ }
+}
+void TableView::slotPriority() {
+ setCellContentFromEditor( currentRow(), currentColumn() );
+}
diff --git a/core/pim/todo/tableview.h b/core/pim/todo/tableview.h
index b608204..bf41aea 100644
--- a/core/pim/todo/tableview.h
+++ b/core/pim/todo/tableview.h
@@ -77,8 +77,14 @@ namespace Todo {
/* reimplented for internal reasons */
void viewportPaintEvent( QPaintEvent* );
QTimer *m_menuTimer;
bool m_enablePaint:1;
+ QString m_oleCat;
+ bool m_first : 1;
+
+ protected:
+ QWidget* createEditor(int row, int col, bool initFromCell )const;
+ void setCellContentFromEditor( int row, int col );
private slots:
void slotShowMenu();
void slotClicked(int, int, int,
@@ -86,8 +92,9 @@ private slots:
void slotPressed(int, int, int,
const QPoint& );
void slotValueChanged(int, int);
void slotCurrentChanged(int, int );
+ void slotPriority();
};
};
#endif
diff --git a/core/pim/todo/todomanager.cpp b/core/pim/todo/todomanager.cpp
index ebf9e8a..1f81539 100644
--- a/core/pim/todo/todomanager.cpp
+++ b/core/pim/todo/todomanager.cpp
@@ -46,8 +46,9 @@ TodoManager::~TodoManager() {
OTodo TodoManager::event(int uid ) {
return m_db->find( uid );
}
void TodoManager::updateList() {
+ qWarning("update list");
m_list = m_db->allRecords();
}
OTodoAccess::List TodoManager::list() const{
return m_list;
@@ -117,8 +118,9 @@ bool TodoManager::isLoaded()const {
return (m_db == 0 );
}
void TodoManager::load() {
if (!m_db) {
+ qWarning("loading!");
m_db = new OTodoAccess();
m_db->load();
}
}
diff --git a/core/pim/todo/todoview.cpp b/core/pim/todo/todoview.cpp
index 06eaaa9..639fa66 100644
--- a/core/pim/todo/todoview.cpp
+++ b/core/pim/todo/todoview.cpp
@@ -53,9 +53,9 @@ OTodo TodoView::event(int uid ) { return m_main->event( uid ); }
OTodoAccess::List TodoView::list(){
todoWindow()->updateList();
return todoWindow()->list();
}
-OTodoAccess::List TodoView::sorted(){
+OTodoAccess::List TodoView::sorted()const{
return m_sort;
}
void TodoView::sort() {
m_sort = todoWindow()->sorted(m_asc,m_sortOrder );
@@ -67,8 +67,9 @@ void TodoView::sort(int sort) {
void TodoView::setSortOrder( int order ) {
m_sortOrder = order;
}
void TodoView::setAscending( bool b ) {
+ qWarning("setAscending %d", b );
m_asc = b;
}
void TodoView::update(int uid, const SmallTodo& to ) {
//m_main->slotUpate1( uid, to );
diff --git a/core/pim/todo/todoview.h b/core/pim/todo/todoview.h
index 9408ef1..e5c77f9 100644
--- a/core/pim/todo/todoview.h
+++ b/core/pim/todo/todoview.h
@@ -156,9 +156,9 @@ namespace Todo {
protected:
MainWindow* todoWindow();
OTodo event(int uid );
OTodoAccess::List list();
- OTodoAccess::List sorted();
+ OTodoAccess::List sorted()const;
void sort();
void sort(int sort );
void setSortOrder( int order );
void setAscending( bool );