You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kpilot/kpilot/todoWidget.h

170 lines
4.4 KiB

/* todoWidget.h KPilot
**
** Copyright (C) 2004 Reinhold Kainhofer <reinhold@kainhofer.com>
**
** This file defines the todo-viewing widget used in KPilot
** to display the Pilot's todo records.
*/
/*
** 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.
**
** 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program in a file called COPYING; if not, write to
** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
** MA 02110-1301, USA.
*/
/*
** Bug reports and questions can be sent to kde-pim@kde.org
*/
#ifndef _KPILOT_TODOWIDGET_H
#define _KPILOT_TODOWIDGET_H
class TQComboBox;
class TQPushButton;
class TQTextView;
#include "pilotComponent.h"
#include "pilotTodoEntry.h"
#include "listItems.h"
class TodoListView : public TDEListView
{
TQ_OBJECT
public:
TodoListView(TQWidget * parent = 0, const char * name = 0 ):TDEListView(parent, name){};
~TodoListView() {};
signals:
void itemChecked(TQCheckListItem*item);
void itemChecked(TQCheckListItem*item, bool on);
//protected:
public:
void itemWasChecked(TQCheckListItem*item, bool on) {
emit itemChecked(item);
emit itemChecked(item, on);
}
};
class TodoCheckListItem : public PilotCheckListItem
{
public:
TodoCheckListItem(TQListView*parent, const TQString&text, recordid_t pilotid, void*r);
~TodoCheckListItem() {};
virtual void stateChange(bool state);
};
class TodoWidget : public PilotComponent
{
TQ_OBJECT
public:
TodoWidget(TQWidget* parent,const TQString& dbpath);
~TodoWidget();
// Pilot Component Methods:
virtual bool preHotSync(TQString &);
virtual void postHotSync();
virtual void showComponent();
virtual void hideComponent();
public slots:
/**
* Called when a particular todo is selected. This slot displays
* it in the viewer widget.
*/
void slotShowTodo(TQListViewItem*);
void slotEditRecord(TQListViewItem*item);
void slotEditRecord();
void slotCreateNewRecord();
void slotDeleteRecord();
void slotEditCancelled();
void slotUpdateButtons(); // Enable/disable buttons
signals:
void recordChanged(PilotTodoEntry *);
protected slots:
/**
* When an edit window is closed, the corresponding record
* is updated and possibly re-displayed.
*/
void slotUpdateRecord(PilotTodoEntry*);
/**
* Pop up an edit window for a new record.
*/
void slotAddRecord(PilotTodoEntry*);
/**
* Change category. This means that the display should be
* cleared and that the list should be repopulated.
*/
void slotSetCategory(int);
void slotItemChecked(TQCheckListItem*item, bool on);
void slotItemRenamed(TQListViewItem*item, const TQString &txt, int nr);
private:
void setupWidget();
void updateWidget(); // Called with the lists have changed..
void writeTodo(PilotTodoEntry* which,PilotDatabase *db=0L);
/**
* getAllTodos reads the database and places all
* the todos from the database in the list
* in memory --- not the list on the screen.
* @see fTodoList
*/
int getAllTodos(PilotDatabase *todoDB);
/**
* Create a sensible "title" for an todo, composed
* of first + last name if possible.
*/
TQString createTitle(PilotTodoEntry *,int displayMode);
/**
* We use a TQComboBox fCatList to hold the user-visible names
* of all the categories. The TQTextView fTodoInfo is for
* displaying the currently selected todo, if any.
* The TQListView fListBox lists all the todoes in the
* currently selected category.
*
* The entire todo database is read into memory in the
* TQPtrList fTodoList. We need the appinfo block from the
* database to determine which categories there are; this
* is held in fTodoAppInfo.
*
* The two buttons should speak for themselves.
*/
TQComboBox *fCatList;
TQTextView *fTodoInfo;
PilotToDoInfo *fTodoAppInfo;
TQPtrList<PilotTodoEntry> fTodoList;
TodoListView *fListBox;
TQPushButton *fEditButton,*fDeleteButton;
PilotDatabase *fTodoDB;
protected:
/**
* Keep track of how many open todo editing windows there
* are. You can't sync when there are open windows.
*/
int fPendingTodos;
};
#endif