summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-09-19 21:01:00 (UTC)
committer harlekin <harlekin>2002-09-19 21:01:00 (UTC)
commitc03cc47ea4ecba39c89283f9bfc3ee55f572793f (patch) (side-by-side diff)
tree7cab842df67039350234bbb6700773928c2b35ab
parent65ba4e3610c94ba1de71a41dd6bf69662555e206 (diff)
downloadopie-c03cc47ea4ecba39c89283f9bfc3ee55f572793f.zip
opie-c03cc47ea4ecba39c89283f9bfc3ee55f572793f.tar.gz
opie-c03cc47ea4ecba39c89283f9bfc3ee55f572793f.tar.bz2
added line clipping to config and code cleanups
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/plugins/todolist/todopluginconfig.cpp35
-rw-r--r--core/pim/today/plugins/todolist/todopluginconfig.h3
-rw-r--r--core/pim/today/plugins/todolist/todopluginwidget.cpp2
3 files changed, 26 insertions, 14 deletions
diff --git a/core/pim/today/plugins/todolist/todopluginconfig.cpp b/core/pim/today/plugins/todolist/todopluginconfig.cpp
index 2d8f1b6..69ad727 100644
--- a/core/pim/today/plugins/todolist/todopluginconfig.cpp
+++ b/core/pim/today/plugins/todolist/todopluginconfig.cpp
@@ -1,70 +1,79 @@
/*
* todopluginconfig.cpp
*
* copyright : (c) 2002 by Maximilian Reiß
* email : harlekin@handhelds.org
*
*/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "todopluginconfig.h"
#include <qpe/config.h>
#include <qlayout.h>
+#include <qhbox.h>
#include <qtoolbutton.h>
#include <qlabel.h>
+
TodolistPluginConfig::TodolistPluginConfig( QWidget *parent, const char* name)
: ConfigWidget(parent, name ) {
QVBoxLayout * layout = new QVBoxLayout( this );
+ layout->setMargin( 20 );
- QFrame* Frame9 = new QFrame( this, "Frame9" );
- Frame9->setGeometry( QRect( -5, 0, 230, 310 ) );
- Frame9->setFrameShape( QFrame::StyledPanel );
- Frame9->setFrameShadow( QFrame::Raised );
+ QHBox *box1 = new QHBox( this );
- QLabel* TextLabel6 = new QLabel( Frame9, "TextLabel6" );
- TextLabel6->setGeometry( QRect( 20, 10, 100, 60 ) );
- TextLabel6->setText( tr( "How many\n"
- "tasks should \n"
+ QLabel* TextLabel6 = new QLabel( box1, "TextLabel6" );
+ TextLabel6->setText( tr( "How many\n tasks should \n"
"be shown?" ) );
- SpinBox2 = new QSpinBox( Frame9, "SpinBox2" );
- SpinBox2->setGeometry( QRect( 115, 20, 58, 25 ) );
- SpinBox2->setMaxValue( 20 );
- SpinBox2->setValue( 5 );
+ SpinBox2 = new QSpinBox( box1, "SpinBox2" );
+ SpinBox2->setMaxValue( 40 );
+
+ QHBox *box2 = new QHBox( this );
+
+ QLabel* clipLabel = new QLabel( box2, "" );
+ clipLabel->setText( tr( "Clip line after\n X chars" ) );
+
+ SpinBoxClip = new QSpinBox( box2, "SpinClip" );
+ SpinBoxClip->setMaxValue( 200 );
- layout->addWidget( Frame9 );
+ layout->addWidget( box1 );
+ layout->addWidget( box2 );
readConfig();
}
void TodolistPluginConfig::readConfig() {
Config cfg( "todaytodoplugin" );
cfg.setGroup( "config" );
m_max_lines_task = cfg.readNumEntry( "maxlinestask", 5 );
SpinBox2->setValue( m_max_lines_task );
+ m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 );
+ SpinBoxClip->setValue( m_maxCharClip );
}
void TodolistPluginConfig::writeConfig() {
Config cfg( "todaytodoplugin" );
cfg.setGroup( "config" );
m_max_lines_task = SpinBox2->value();
cfg.writeEntry( "maxlinestask", m_max_lines_task );
+ m_maxCharClip = SpinBoxClip->value();
+ cfg.writeEntry( "maxcharclip", m_maxCharClip );
cfg.write();
}
TodolistPluginConfig::~TodolistPluginConfig() {
}
diff --git a/core/pim/today/plugins/todolist/todopluginconfig.h b/core/pim/today/plugins/todolist/todopluginconfig.h
index 6be4b1e..934b319 100644
--- a/core/pim/today/plugins/todolist/todopluginconfig.h
+++ b/core/pim/today/plugins/todolist/todopluginconfig.h
@@ -1,54 +1,57 @@
/*
* todopluginconfig.h
*
* copyright : (c) 2002 by Maximilian Reiß
* email : harlekin@handhelds.org
*
*/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef TODOLIST_PLUGIN_CONFIG_H
#define TODOLIST_PLUGIN_CONFIG_H
#include <qwidget.h>
#include <qspinbox.h>
#include "../../configwidget.h"
class TodolistPluginConfig : public ConfigWidget {
public:
TodolistPluginConfig( QWidget *parent, const char *name );
~TodolistPluginConfig();
private:
/**
* if changed then save
*/
bool changed();
void readConfig();
void writeConfig();
QSpinBox* SpinBox2;
+ QSpinBox* SpinBoxClip;
// how many lines should be showed in the todolist section
int m_max_lines_task;
+ // clip the lines after X chars
+ int m_maxCharClip;
};
#endif
diff --git a/core/pim/today/plugins/todolist/todopluginwidget.cpp b/core/pim/today/plugins/todolist/todopluginwidget.cpp
index 4731b43..d793aae 100644
--- a/core/pim/today/plugins/todolist/todopluginwidget.cpp
+++ b/core/pim/today/plugins/todolist/todopluginwidget.cpp
@@ -1,134 +1,134 @@
/*
* todopluginwidget.cpp
*
* copyright : (c) 2002 by Maximilian Reiß
* email : harlekin@handhelds.org
*
*/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "todopluginwidget.h"
#include <qvaluelist.h>
#include <qtl.h>
#include <qstring.h>
#include <qscrollview.h>
#include <qobject.h>
#include <qlayout.h>
#include <qpe/config.h>
#include <qpe/timestring.h>
#include <qpe/qcopenvelope_qws.h>
TodolistPluginWidget::TodolistPluginWidget( QWidget *parent, const char* name )
: QWidget( parent, name ) {
todoLabel= 0l;
todo = 0l;
if ( todo ) {
delete todo;
}
todo = new ToDoDB();
readConfig();
- m_maxCharClip = 36;
getTodo();
}
TodolistPluginWidget::~TodolistPluginWidget() {
delete todo;
}
void TodolistPluginWidget::readConfig() {
Config cfg( "todaytodoplugin" );
cfg.setGroup( "config" );
m_maxLinesTask = cfg.readNumEntry( "maxlinestask", 5 );
+ m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 );
}
/**
* Get the todos
*/
void TodolistPluginWidget::getTodo() {
QVBoxLayout* layoutTodo = new QVBoxLayout( this );
if ( todoLabel ) {
delete todoLabel;
}
todoLabel = new OClickableLabel( this );
todoLabel->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) );
connect( todoLabel, SIGNAL( clicked() ), this, SLOT( startTodolist() ) );
QString output;
QString tmpout;
int count = 0;
int ammount = 0;
// get overdue todos first
QValueList<ToDoEvent> overDueList = todo->overDue();
qBubbleSort( overDueList );
for ( QValueList<ToDoEvent>::Iterator it = overDueList.begin();
it != overDueList.end(); ++it ) {
if (!(*it).isCompleted() && ( ammount < m_maxLinesTask ) ) {
QString desc = (*it).summary();
if( desc.isEmpty() ) {
desc = (*it).description();
}
tmpout += "<font color=#e00000><b>-" + desc.mid( 0, m_maxCharClip ) + "</b></font><br>";
ammount++;
}
}
// get total number of still open todos
QValueList<ToDoEvent> openTodo = todo->rawToDos();
qBubbleSort( openTodo );
for ( QValueList<ToDoEvent>::Iterator it = openTodo.begin();
it != openTodo.end(); ++it ) {
if ( !(*it).isCompleted() ){
count +=1;
// not the overdues, we allready got them, and not if we are
// over the maxlines
if ( !(*it).isOverdue() && ( ammount < m_maxLinesTask ) ) {
QString desc = (*it).summary();
if( desc.isEmpty() ) {
desc = (*it).description();
}
tmpout += "<b>-</b>" + desc.mid( 0, m_maxCharClip ) + "<br>";
ammount++;
}
}
}
if ( count > 0 ) {
if( count == 1 ) {
output += QObject::tr( "There is <b> 1</b> active task: <br>" );
} else {
output += QObject::tr( "There are <b> %1</b> active tasks: <br>" ).arg( count );
}
output += tmpout;
} else {
output = QObject::tr( "No active tasks" );
}
todoLabel->setText( output );
layoutTodo->addWidget( todoLabel );
}
/**
* start the todolist
*/
void TodolistPluginWidget::startTodolist() {
QCopEnvelope e( "QPE/System", "execute(QString)" );
e << QString( "todolist" );
}