summaryrefslogtreecommitdiffabout
path: root/korganizer/kolocationbox.cpp
authorzautrix <zautrix>2004-06-26 19:01:18 (UTC)
committer zautrix <zautrix>2004-06-26 19:01:18 (UTC)
commitb9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff)
tree2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /korganizer/kolocationbox.cpp
downloadkdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip
kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz
kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2
Initial revision
Diffstat (limited to 'korganizer/kolocationbox.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kolocationbox.cpp96
1 files changed, 96 insertions, 0 deletions
diff --git a/korganizer/kolocationbox.cpp b/korganizer/kolocationbox.cpp
new file mode 100644
index 0000000..f8fee2e
--- a/dev/null
+++ b/korganizer/kolocationbox.cpp
@@ -0,0 +1,96 @@
1/*
2 Copyright (c) 2004 Dirk Loesche <dirk.loesche@bigfoot.de>
3
4 This file is part of KOrganizer/PI
5 KOrganizer Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
6 KOrganizer/PI Copyright (c) 2004 Lutz Rogowski <lutz@pi-sync.net>
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
22 As a special exception, permission is given to link this program
23 with any edition of Qt, and distribute the resulting executable,
24 without including the source code for Qt in the source distribution.
25*/
26
27#include "kolocationbox.h"
28#include <qstring.h>
29#include <qlineedit.h>
30#include <qapplication.h>
31
32
33KOLocationBox::KOLocationBox( bool rw , QWidget *parent , int _maxItems) :
34 QComboBox( rw , parent )
35{
36 maxItems = _maxItems;
37 maxItems = 50; // sorry - hack from me to set maxitems globally to 30
38 setInsertionPolicy(AtTop);
39 setDuplicatesEnabled( FALSE );
40 setMaxCount( maxItems );
41 setAutoCompletion( TRUE );
42
43}
44
45KOLocationBox::~KOLocationBox()
46{
47}
48
49void KOLocationBox::load(int what)
50{
51 clear();
52 // qDebug("load %d ",what );
53 switch(what) {
54 case LOCATION:
55 insertStringList( KOPrefs::instance()->mLocationDefaults, 0 );
56// insertStringList( KOPrefs::instance()->mLocationUserDefaults, 0 );
57 break; // don't disable
58 case SUMMARYEVENT:
59 insertStringList( KOPrefs::instance()->mEventSummaryUser, 0 );
60 break; // don't disable
61 case SUMMARYTODO:
62 insertStringList( KOPrefs::instance()->mTodoSummaryUser, 0 );
63 break; // don't disable
64 }
65}
66
67void KOLocationBox::save(int what)
68{
69 strlist.clear();
70 for( int l = 0; l < count() ; l++ ) {
71 strlist << text( l );
72 }
73 // strlist.sort();
74 QString currentLine = lineEdit()->text();
75 if ( !strlist.contains( currentLine ) )
76 strlist.prepend( currentLine );
77 // qDebug("save %d ", what);
78 switch(what) {
79 case LOCATION:
80 KOPrefs::instance()->mLocationDefaults = strlist;
81// KOPrefs::instance()->mLocationUserDefaults = strlist;
82 break; // don't disable
83 case SUMMARYEVENT:
84 KOPrefs::instance()->mEventSummaryUser = strlist;
85 break; // don't disable
86 case SUMMARYTODO:
87 KOPrefs::instance()->mTodoSummaryUser = strlist;
88 break; // don't disable
89 }
90}
91
92void KOLocationBox::clearItems(int what)
93{
94 clear();
95 save(what);
96}