summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/categorymenu.cpp2
-rw-r--r--library/imageedit.cpp2
-rw-r--r--library/menubutton.cpp2
3 files changed, 3 insertions, 3 deletions
diff --git a/library/categorymenu.cpp b/library/categorymenu.cpp
index 52a127c..e733107 100644
--- a/library/categorymenu.cpp
+++ b/library/categorymenu.cpp
@@ -1,110 +1,110 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "categorymenu.h" 21#include "categorymenu.h"
22#include "backend/categories.h" 22#include "backend/categories.h"
23#include "categoryselect.h" 23#include "categoryselect.h"
24#include <qstring.h> 24#include <qstring.h>
25#include <qmap.h> 25#include <qmap.h>
26 26
27CategoryMenu::CategoryMenu( const QString &n, bool ig = TRUE, 27CategoryMenu::CategoryMenu( const QString &n, bool ig = TRUE,
28 QWidget *parent = 0, const char *name = 0 ) : 28 QWidget *parent, const char *name ) :
29 QPopupMenu(parent, name), 29 QPopupMenu(parent, name),
30 appName(n), 30 appName(n),
31 includeGlobal(ig) 31 includeGlobal(ig)
32{ 32{
33 currentMid = 1; 33 currentMid = 1;
34 reload(); 34 reload();
35 connect(this, SIGNAL(activated(int)), this, SLOT(mapMenuId(int))); 35 connect(this, SIGNAL(activated(int)), this, SLOT(mapMenuId(int)));
36} 36}
37 37
38CategoryMenu::~CategoryMenu( ) 38CategoryMenu::~CategoryMenu( )
39{ 39{
40} 40}
41 41
42void CategoryMenu::reload() 42void CategoryMenu::reload()
43{ 43{
44 clear(); 44 clear();
45 Categories c; 45 Categories c;
46 46
47 c.load(categoryFileName()); 47 c.load(categoryFileName());
48 48
49 QStringList sl = c.labels(appName, includeGlobal); 49 QStringList sl = c.labels(appName, includeGlobal);
50 int mid = 1; 50 int mid = 1;
51 51
52 insertItem(tr("All"), mid); 52 insertItem(tr("All"), mid);
53 mid++; 53 mid++;
54 insertItem(tr("Unfiled"), mid); 54 insertItem(tr("Unfiled"), mid);
55 mid++; 55 mid++;
56 56
57 for (QStringList::Iterator it = sl.begin(); 57 for (QStringList::Iterator it = sl.begin();
58 it != sl.end(); ++it ) { 58 it != sl.end(); ++it ) {
59 int cid = c.id(appName, *it); 59 int cid = c.id(appName, *it);
60 insertItem(*it, mid); 60 insertItem(*it, mid);
61 menuToId.insert(mid, cid); 61 menuToId.insert(mid, cid);
62 idToMenu.insert(cid, mid); 62 idToMenu.insert(cid, mid);
63 mid++; 63 mid++;
64 } 64 }
65 65
66 setItemChecked(currentMid, TRUE ); 66 setItemChecked(currentMid, TRUE );
67} 67}
68 68
69void CategoryMenu::mapMenuId(int id) 69void CategoryMenu::mapMenuId(int id)
70{ 70{
71 if (id == currentMid) 71 if (id == currentMid)
72 return; 72 return;
73 setItemChecked( currentMid, FALSE ); 73 setItemChecked( currentMid, FALSE );
74 setItemChecked( id, TRUE ); 74 setItemChecked( id, TRUE );
75 currentMid = id; 75 currentMid = id;
76 76
77 emit categoryChange(); 77 emit categoryChange();
78} 78}
79 79
80bool CategoryMenu::isSelected(const QArray<int> &cUids) const 80bool CategoryMenu::isSelected(const QArray<int> &cUids) const
81{ 81{
82 if (currentMid == 1) 82 if (currentMid == 1)
83 return TRUE; 83 return TRUE;
84 84
85 if (currentMid == 2 && cUids.count() == 0) 85 if (currentMid == 2 && cUids.count() == 0)
86 return TRUE; 86 return TRUE;
87 87
88 if (cUids.contains(menuToId[currentMid])) 88 if (cUids.contains(menuToId[currentMid]))
89 return TRUE; 89 return TRUE;
90 90
91 return FALSE; 91 return FALSE;
92} 92}
93 93
94void CategoryMenu::setCurrentCategory( int newCatUid ) 94void CategoryMenu::setCurrentCategory( int newCatUid )
95{ 95{
96 if (!idToMenu.contains(newCatUid)) 96 if (!idToMenu.contains(newCatUid))
97 return; 97 return;
98 98
99 mapMenuId(idToMenu[newCatUid]); 99 mapMenuId(idToMenu[newCatUid]);
100} 100}
101 101
102void CategoryMenu::setCurrentCategoryAll( ) 102void CategoryMenu::setCurrentCategoryAll( )
103{ 103{
104 mapMenuId(1); 104 mapMenuId(1);
105} 105}
106 106
107void CategoryMenu::setCurrentCategoryUnfiled( ) 107void CategoryMenu::setCurrentCategoryUnfiled( )
108{ 108{
109 mapMenuId(2); 109 mapMenuId(2);
110} 110}
diff --git a/library/imageedit.cpp b/library/imageedit.cpp
index 7f98ebb..0c22448 100644
--- a/library/imageedit.cpp
+++ b/library/imageedit.cpp
@@ -1,97 +1,97 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "imageedit.h" 20#include "imageedit.h"
21#include <qpainter.h> 21#include <qpainter.h>
22 22
23ImageEdit::ImageEdit( QWidget *parent = 0, const char *name = 0 ) 23ImageEdit::ImageEdit( QWidget *parent, const char *name )
24 : QScrollView( parent, name, WNorthWestGravity | WResizeNoErase ), buffer() 24 : QScrollView( parent, name, WNorthWestGravity | WResizeNoErase ), buffer()
25{ 25{
26 buffer.resize( size() ); 26 buffer.resize( size() );
27 buffer.fill( colorGroup().color( QColorGroup::Base ) ); 27 buffer.fill( colorGroup().color( QColorGroup::Base ) );
28} 28}
29 29
30ImageEdit::~ImageEdit() 30ImageEdit::~ImageEdit()
31{ 31{
32 32
33} 33}
34 34
35void ImageEdit::contentsMousePressEvent( QMouseEvent *e ) 35void ImageEdit::contentsMousePressEvent( QMouseEvent *e )
36{ 36{
37 lastPos = e->pos(); 37 lastPos = e->pos();
38} 38}
39 39
40void ImageEdit::contentsMouseMoveEvent( QMouseEvent *e ) 40void ImageEdit::contentsMouseMoveEvent( QMouseEvent *e )
41{ 41{
42 QPainter pw( viewport() ); 42 QPainter pw( viewport() );
43 QPainter pb( &buffer ); 43 QPainter pb( &buffer );
44 pb.drawLine( lastPos, e->pos() ); 44 pb.drawLine( lastPos, e->pos() );
45 pw.drawLine( contentsToViewport( lastPos ), 45 pw.drawLine( contentsToViewport( lastPos ),
46 contentsToViewport( e->pos() ) ); 46 contentsToViewport( e->pos() ) );
47 lastPos = e->pos(); 47 lastPos = e->pos();
48} 48}
49 49
50void ImageEdit::contentsMouseReleaseEvent( QMouseEvent * ) 50void ImageEdit::contentsMouseReleaseEvent( QMouseEvent * )
51{ 51{
52} 52}
53 53
54void ImageEdit::viewportResizeEvent( QResizeEvent *e ) 54void ImageEdit::viewportResizeEvent( QResizeEvent *e )
55{ 55{
56 enlargeBuffer(e->size()); 56 enlargeBuffer(e->size());
57} 57}
58 58
59void ImageEdit::enlargeBuffer( const QSize& sz ) 59void ImageEdit::enlargeBuffer( const QSize& sz )
60{ 60{
61 QSize osz = buffer.size(); 61 QSize osz = buffer.size();
62 QSize nsz( QMAX( osz.width(), sz.width() ), QMAX( osz.height(), sz.height() ) ); 62 QSize nsz( QMAX( osz.width(), sz.width() ), QMAX( osz.height(), sz.height() ) );
63 buffer.resize( nsz.width(), nsz.height() ); 63 buffer.resize( nsz.width(), nsz.height() );
64 // clear new area 64 // clear new area
65 QPainter p( &buffer ); 65 QPainter p( &buffer );
66 if ( sz.width() > osz.width() ) 66 if ( sz.width() > osz.width() )
67 p.fillRect( osz.width(), 0, sz.width() - osz.width(), nsz.height(), colorGroup().color( QColorGroup::Base ) ); 67 p.fillRect( osz.width(), 0, sz.width() - osz.width(), nsz.height(), colorGroup().color( QColorGroup::Base ) );
68 if ( sz.height() > osz.height() ) 68 if ( sz.height() > osz.height() )
69 p.fillRect( 0, osz.height(), nsz.width(), sz.height() - osz.height(), colorGroup().color( QColorGroup::Base ) ); 69 p.fillRect( 0, osz.height(), nsz.width(), sz.height() - osz.height(), colorGroup().color( QColorGroup::Base ) );
70 p.end(); 70 p.end();
71} 71}
72 72
73void ImageEdit::drawContents( QPainter *p, int cx, int cy, int cw, int ch ) 73void ImageEdit::drawContents( QPainter *p, int cx, int cy, int cw, int ch )
74{ 74{
75 p->drawPixmap( cx, cy, buffer, cx, cy, cw, ch ); 75 p->drawPixmap( cx, cy, buffer, cx, cy, cw, ch );
76} 76}
77 77
78void ImageEdit::setPixmap( const QPixmap &pm ) 78void ImageEdit::setPixmap( const QPixmap &pm )
79{ 79{
80 QSize osz = buffer.size(); 80 QSize osz = buffer.size();
81 if ( pm.width() < osz.width() || pm.height() < osz.height() ) { 81 if ( pm.width() < osz.width() || pm.height() < osz.height() ) {
82 buffer.fill(white); 82 buffer.fill(white);
83 enlargeBuffer( pm.size() ); 83 enlargeBuffer( pm.size() );
84 QPainter p(&buffer); 84 QPainter p(&buffer);
85 p.drawPixmap(0,0,pm); 85 p.drawPixmap(0,0,pm);
86 } else { 86 } else {
87 buffer = pm; 87 buffer = pm;
88 } 88 }
89 resizeContents( buffer.width(), buffer.height() ); 89 resizeContents( buffer.width(), buffer.height() );
90 viewport()->repaint( FALSE ); 90 viewport()->repaint( FALSE );
91} 91}
92 92
93QPixmap ImageEdit::pixmap() const 93QPixmap ImageEdit::pixmap() const
94{ 94{
95 return buffer; 95 return buffer;
96} 96}
97 97
diff --git a/library/menubutton.cpp b/library/menubutton.cpp
index c34383a..6b1fa2b 100644
--- a/library/menubutton.cpp
+++ b/library/menubutton.cpp
@@ -8,180 +8,180 @@
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "menubutton.h" 21#include "menubutton.h"
22#include <qpopupmenu.h> 22#include <qpopupmenu.h>
23 23
24/*! 24/*!
25 \class MenuButton menubutton.h 25 \class MenuButton menubutton.h
26 \brief The MenuButton class is a pushbutton with a menu. 26 \brief The MenuButton class is a pushbutton with a menu.
27 27
28 Similar in function to a QComboBox. 28 Similar in function to a QComboBox.
29*/ 29*/
30 30
31/*! 31/*!
32 \fn void MenuButton::selected(int index) 32 \fn void MenuButton::selected(int index)
33 33
34 This signal is emitted when the item at \a index is selected. 34 This signal is emitted when the item at \a index is selected.
35*/ 35*/
36 36
37/*! 37/*!
38 \fn void MenuButton::selected(const QString& text) 38 \fn void MenuButton::selected(const QString& text)
39 39
40 This signal is emitted when the item with the given \a text is selected. 40 This signal is emitted when the item with the given \a text is selected.
41*/ 41*/
42 42
43 43
44/*! 44/*!
45 Constructs a MenuButton with the given \a items added (see insertItems()). 45 Constructs a MenuButton with the given \a items added (see insertItems()).
46 The standard \a parent an \a name arguments are passed to the base class. 46 The standard \a parent an \a name arguments are passed to the base class.
47*/ 47*/
48MenuButton::MenuButton( const QStringList& items, QWidget* parent, const char* name) : 48MenuButton::MenuButton( const QStringList& items, QWidget* parent, const char* name) :
49 QPushButton(parent,name) 49 QPushButton(parent,name)
50{ 50{
51 init(); 51 init();
52 insertItems(items); 52 insertItems(items);
53} 53}
54 54
55/*! 55/*!
56 Constructs an empty MenuButton. 56 Constructs an empty MenuButton.
57 The standard \a parent an \a name arguments are passed to the base class. 57 The standard \a parent an \a name arguments are passed to the base class.
58 58
59 \sa insertItems() 59 \sa insertItems()
60*/ 60*/
61MenuButton::MenuButton( QWidget* parent, const char* name) : 61MenuButton::MenuButton( QWidget* parent, const char* name) :
62 QPushButton(parent,name) 62 QPushButton(parent,name)
63{ 63{
64 init(); 64 init();
65} 65}
66 66
67void MenuButton::init() 67void MenuButton::init()
68{ 68{
69 setAutoDefault(FALSE); 69 setAutoDefault(FALSE);
70 pop = new QPopupMenu(this); 70 pop = new QPopupMenu(this);
71 nitems=0; 71 nitems=0;
72 connect(pop, SIGNAL(activated(int)), this, SLOT(select(int))); 72 connect(pop, SIGNAL(activated(int)), this, SLOT(select(int)));
73 setPopup(pop); 73 setPopup(pop);
74 //setPopupDelay(0); 74 //setPopupDelay(0);
75} 75}
76 76
77/*! 77/*!
78 Removes all items from the button and menu. 78 Removes all items from the button and menu.
79*/ 79*/
80void MenuButton::clear() 80void MenuButton::clear()
81{ 81{
82 delete pop; 82 delete pop;
83 init(); 83 init();
84} 84}
85 85
86/*! 86/*!
87 Inserts string \a items into the menu. The string "--" represents 87 Inserts string \a items into the menu. The string "--" represents
88 a separator. 88 a separator.
89*/ 89*/
90void MenuButton::insertItems( const QStringList& items ) 90void MenuButton::insertItems( const QStringList& items )
91{ 91{
92 QStringList::ConstIterator it=items.begin(); 92 QStringList::ConstIterator it=items.begin();
93 for (; it!=items.end(); ++it) { 93 for (; it!=items.end(); ++it) {
94 if ( (*it) == "--" ) 94 if ( (*it) == "--" )
95 insertSeparator(); 95 insertSeparator();
96 else 96 else
97 insertItem(*it); 97 insertItem(*it);
98 } 98 }
99} 99}
100 100
101/*! 101/*!
102 Inserts an \a icon and \a text into the menu. 102 Inserts an \a icon and \a text into the menu.
103*/ 103*/
104void MenuButton::insertItem( const QIconSet& icon, const QString& text=QString::null ) 104void MenuButton::insertItem( const QIconSet& icon, const QString& text )
105{ 105{
106 pop->insertItem(icon, text, nitems++); 106 pop->insertItem(icon, text, nitems++);
107 if ( nitems==1 ) select(0); 107 if ( nitems==1 ) select(0);
108} 108}
109 109
110/*! 110/*!
111 Inserts \a text into the menu. 111 Inserts \a text into the menu.
112*/ 112*/
113void MenuButton::insertItem( const QString& text ) 113void MenuButton::insertItem( const QString& text )
114{ 114{
115 pop->insertItem(text, nitems++); 115 pop->insertItem(text, nitems++);
116 if ( nitems==1 ) select(0); 116 if ( nitems==1 ) select(0);
117} 117}
118 118
119/*! 119/*!
120 Inserts a visual separator into the menu. 120 Inserts a visual separator into the menu.
121*/ 121*/
122void MenuButton::insertSeparator() 122void MenuButton::insertSeparator()
123{ 123{
124 pop->insertSeparator(); 124 pop->insertSeparator();
125} 125}
126 126
127/*! 127/*!
128 Selects the items with text \a s. 128 Selects the items with text \a s.
129*/ 129*/
130void MenuButton::select(const QString& s) 130void MenuButton::select(const QString& s)
131{ 131{
132 for (int i=0; i<nitems; i++) { 132 for (int i=0; i<nitems; i++) {
133 if ( pop->text(i) == s ) { 133 if ( pop->text(i) == s ) {
134 select(i); 134 select(i);
135 break; 135 break;
136 } 136 }
137 } 137 }
138} 138}
139 139
140/*! 140/*!
141 Selects the item at index \a s. 141 Selects the item at index \a s.
142*/ 142*/
143void MenuButton::select(int s) 143void MenuButton::select(int s)
144{ 144{
145 cur = s; 145 cur = s;
146 updateLabel(); 146 updateLabel();
147 if ( pop->iconSet(cur) ) 147 if ( pop->iconSet(cur) )
148 setIconSet(*pop->iconSet(cur)); 148 setIconSet(*pop->iconSet(cur));
149 emit selected(cur); 149 emit selected(cur);
150 emit selected(currentText()); 150 emit selected(currentText());
151} 151}
152 152
153/*! 153/*!
154 Returns the index of the current item. 154 Returns the index of the current item.
155*/ 155*/
156int MenuButton::currentItem() const 156int MenuButton::currentItem() const
157{ 157{
158 return cur; 158 return cur;
159} 159}
160 160
161/*! 161/*!
162 Returns the text of the current item. 162 Returns the text of the current item.
163*/ 163*/
164QString MenuButton::currentText() const 164QString MenuButton::currentText() const
165{ 165{
166 return pop->text(cur); 166 return pop->text(cur);
167} 167}
168 168
169/*! 169/*!
170 Sets the label. If \a label is empty, the 170 Sets the label. If \a label is empty, the
171 current item text is displayed, otherwise \a label should contain 171 current item text is displayed, otherwise \a label should contain
172 "%1", which will be replaced by the current item text. 172 "%1", which will be replaced by the current item text.
173*/ 173*/
174void MenuButton::setLabel(const QString& label) 174void MenuButton::setLabel(const QString& label)
175{ 175{
176 lab = label; 176 lab = label;
177 updateLabel(); 177 updateLabel();
178} 178}
179 179
180void MenuButton::updateLabel() 180void MenuButton::updateLabel()
181{ 181{
182 QString t = pop->text(cur); 182 QString t = pop->text(cur);
183 if ( !lab.isEmpty() ) 183 if ( !lab.isEmpty() )
184 t = lab.arg(t); 184 t = lab.arg(t);
185 setText(t); 185 setText(t);
186} 186}
187 187