libkdepim

completionordereditor.h

00001 /* -*- c++ -*-
00002  * completionordereditor.h
00003  *
00004  *  Copyright (c) 2004 David Faure <faure@kde.org>
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; version 2 of the License
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018  *
00019  *  In addition, as a special exception, the copyright holders give
00020  *  permission to link the code of this program with any edition of
00021  *  the Qt library by Trolltech AS, Norway (or with modified versions
00022  *  of Qt that use the same license as Qt), and distribute linked
00023  *  combinations including the two.  You must obey the GNU General
00024  *  Public License in all respects for all of the code used other than
00025  *  Qt.  If you modify this file, you may extend this exception to
00026  *  your version of the file, but you are not obligated to do so.  If
00027  *  you do not wish to do so, delete this exception statement from
00028  *  your version.
00029  */
00030 
00031 #ifndef COMPLETIONORDEREDITOR_H
00032 #define COMPLETIONORDEREDITOR_H
00033 
00034 #include <kdialogbase.h>
00035 #include <kconfig.h>
00036 
00037 class KPushButton;
00038 class KListView;
00039 namespace KPIM {
00040 
00041 class LdapSearch;
00042 class CompletionOrderEditor;
00043 
00044 // Base class for items in the list
00045 class CompletionItem
00046 {
00047 public:
00048   virtual ~CompletionItem() {}
00049   virtual QString label() const = 0;
00050   virtual int completionWeight() const = 0;
00051   virtual void setCompletionWeight( int weight ) = 0;
00052   virtual void save( CompletionOrderEditor* ) = 0;
00053 };
00054 
00055 
00056 // I don't like QPtrList much, but it has compareItems, which QValueList doesn't
00057 class CompletionItemList : public QPtrList<CompletionItem>
00058 {
00059 public:
00060   CompletionItemList() {}
00061   virtual int compareItems( QPtrCollection::Item s1, QPtrCollection::Item s2 );
00062 };
00063 
00064 class CompletionOrderEditor : public KDialogBase {
00065   Q_OBJECT
00066 
00067 public:
00068   CompletionOrderEditor( KPIM::LdapSearch* ldapSearch, QWidget* parent, const char* name = 0 );
00069   ~CompletionOrderEditor();
00070 
00071   KConfig* configFile() { return &mConfig; }
00072 
00073 private slots:
00074   void slotSelectionChanged( QListViewItem* );
00075   void slotMoveUp();
00076   void slotMoveDown();
00077   virtual void slotOk();
00078 
00079 private:
00080   KConfig mConfig;
00081   CompletionItemList mItems;
00082   KListView* mListView;
00083   KPushButton* mUpButton;
00084   KPushButton* mDownButton;
00085 
00086   bool mDirty;
00087 };
00088 
00089 } // namespace
00090 
00091 #endif /* COMPLETIONORDEREDITOR_H */
00092 
KDE Home | KDE Accessibility Home | Description of Access Keys