1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
/* This file is part of the KDE libraries
Copyright (C) 2005 Reinhold Kainhofer <[email protected]>
Taken in large parts from the kate highlighting list view kateschema.h:
Copyright (C) 2001-2003 Christoph Cullmann <[email protected]>
Copyright (C) 2002, 2003 Anders Lund <[email protected]>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library 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 Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef FOLDERLISTVIEW_H
#define FOLDERLISTVIEW_H
#include <tdelistview.h>
#include "folderlister.h"
class FolderListItem;
class FolderListCaption;
/*
TQListView that automatically adds columns for FolderListItems for selecting
the default destination and a slot to edit the destinations using the keyboard.
*/
class FolderListView : public TDEListView
{
Q_OBJECT
friend class FolderListItem;
public:
/* mainly for readability */
enum Property { FolderName, Event, Todo, Journal, Contact, All, Unknown, PROP_MAX };
FolderListView( TQWidget *parent, const TQValueList<Property> &types = TQValueList<Property>() );
~FolderListView() {};
/* Display a popupmenu for item i at the specified global position, eventually with a title,
promoting the context name of that item */
void showPopupMenu( FolderListItem *i, const TQPoint &globalPos );
void emitChanged() { emit changed(); };
void setEnabledTypes( const TQValueList<Property> &types );
int columnForType( Property prop ) const { if ( mColumnMap.contains(prop) ) return mColumnMap[prop]; else return -1;}
Property typeForColumn( int col ) const { if ( mTypeMap.contains( col ) ) return mTypeMap[col]; else return Unknown; }
private slots:
/* Display a popupmenu for item i at item position */
void showPopupMenu( TQListViewItem *i );
/* call item to change a property, or display a menu */
void slotMousePressed( int, TQListViewItem*, const TQPoint&, int );
/* asks item to change the property in q */
void slotPopupHandler( int z );
signals:
void changed();
private:
TQValueList<Property> mTypes;
TQMap<Property,int> mColumnMap;
TQMap<int,Property> mTypeMap;
};
/*
TQListViewItem subclass to display/edit a folder on a groupware server.
Selection of default destinations will be done via radio items.
*/
class FolderListItem : public TQCheckListItem
{
typedef TQCheckListItem super;
public:
FolderListItem( FolderListItem *parent, const KPIM::FolderLister::Entry &folder )
: TQCheckListItem( parent, folder.name, TQCheckListItem::CheckBoxController ),
mFolder( folder ), mFolderListView( parent?(parent->folderListView()):0 )
{
setOn( mFolder.active );
}
FolderListItem( FolderListView *listView, const KPIM::FolderLister::Entry &folder )
: TQCheckListItem( listView, folder.name,
TQCheckListItem::CheckBoxController ), mFolder( folder ), mFolderListView( listView )
{
setOn( mFolder.active );
}
KPIM::FolderLister::Entry folder() const
{
return mFolder;
}
/* reimp */
// int width ( const TQFontMetrics & fm, const TQListView * lv, int c ) const;
bool typeSupported( FolderListView::Property prop );
bool isDefault( FolderListView::Property prop );
void setDefault( FolderListView::Property prop, bool def = true );
/* calls changeProperty() if it makes sense considering pos. */
void activate( int column, const TQPoint &localPos );
/* Sets this item as default for property p a */
void changeProperty( FolderListView::Property p );
FolderListView *folderListView() const { return mFolderListView; }
protected:
/* reimp */
void paintCell(TQPainter *p, const TQColorGroup& cg, int col, int width, int align);
private:
KPIM::FolderLister::Entry mFolder;
bool mIsDefault[FolderListView::PROP_MAX];
FolderListView *mFolderListView;
};
#endif
|