libtdepim

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 TQt library by Trolltech AS, Norway (or with modified versions
00022  *  of TQt that use the same license as TQt), 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  *  TQt.  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 <tdeconfig.h>
00036 
00037 class KPushButton;
00038 class TDEListView;
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 TQString 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 TQPtrList much, but it has compareItems, which TQValueList doesn't
00057 class CompletionItemList : public TQPtrList<CompletionItem>
00058 {
00059 public:
00060   CompletionItemList() {}
00061   virtual int compareItems( TQPtrCollection::Item s1, TQPtrCollection::Item s2 );
00062 };
00063 
00064 class CompletionOrderEditor : public KDialogBase {
00065   Q_OBJECT
00066   
00067 
00068 public:
00069   CompletionOrderEditor( KPIM::LdapSearch* ldapSearch, TQWidget* parent, const char* name = 0 );
00070   ~CompletionOrderEditor();
00071 
00072   TDEConfig* configFile() { return &mConfig; }
00073 
00074 private slots:
00075   void slotSelectionChanged( TQListViewItem* );
00076   void slotMoveUp();
00077   void slotMoveDown();
00078   virtual void slotOk();
00079 
00080 private:
00081   TDEConfig mConfig;
00082   CompletionItemList mItems;
00083   TDEListView* mListView;
00084   KPushButton* mUpButton;
00085   KPushButton* mDownButton;
00086 
00087   bool mDirty;
00088 };
00089 
00090 } // namespace
00091 
00092 #endif /* COMPLETIONORDEREDITOR_H */
00093