From 00bb99ac80741fc50ef8a289719373032f2391eb Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeaccessibility@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kmouth/phrasebook/phrasetree.h | 108 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 kmouth/phrasebook/phrasetree.h (limited to 'kmouth/phrasebook/phrasetree.h') diff --git a/kmouth/phrasebook/phrasetree.h b/kmouth/phrasebook/phrasetree.h new file mode 100644 index 0000000..bd0e1f5 --- /dev/null +++ b/kmouth/phrasebook/phrasetree.h @@ -0,0 +1,108 @@ +/*************************************************************************** + phrasetree.h - description + ------------------- + begin : Don Okt 24 2002 + copyright : (C) 2002 by Gunnar Schmi Dt + email : kmouth@schmi-dt.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef PHRASETREE_H +#define PHRASETREE_H + +#include +#include +#include + +class PhraseBook; +class PhraseShortcutRequest; + +/**The class PhraseTreeItem is an ListViewItem for either a phrase or a phrase book. + *@author Gunnar Schmi Dt + */ + +class PhraseTreeItem : public KListViewItem { + friend class PhraseTree; +private: + /** Creates a phrase item within a sub phrase book */ + PhraseTreeItem (QListView *parent, QListViewItem *after, QString phrase, KShortcut shortcut, QPixmap icon); + /** Creates a phrase item at the top level */ + PhraseTreeItem (QListViewItem *parent, QListViewItem *after, QString phrase, KShortcut shortcut, QPixmap icon); + /** Creates a phrase book item within a sub phrase book */ + PhraseTreeItem (QListView *parent, QListViewItem *after, QString name, QPixmap icon); + /** Creates a phrase book item at the top level */ + PhraseTreeItem (QListViewItem *parent, QListViewItem *after, QString name, QPixmap icon); + +public: + bool isPhrase(); + KShortcut cut(); + void setCut(KShortcut cut); + +private: + bool isPhraseValue; + KShortcut cutValue; +}; + +/** + * The class PhraseTree represents the ListView of the phrase book edit + * dialog. It extends KListView for providing better drag-and-drop support. + * @author Gunnar Schmi Dt + */ + +class PhraseTree : public KListView { + friend class PhraseTreeItem; + Q_OBJECT +public: + PhraseTree (QWidget *parent = 0, const char *name = 0); + ~PhraseTree (); + + void keyPressEvent (QKeyEvent *e); + + PhraseTreeItem *insertPhrase (QListViewItem *parent, QListViewItem *after, QString phrase, QString shortcut); + PhraseTreeItem *insertBook (QListViewItem *parent, QListViewItem *after, QString name); + + QListViewItem *addBook (QListViewItem *parent, QListViewItem *after, PhraseBook *book); + void fillBook (PhraseBook *book, bool respectSelection); + + QDragObject *dragObject (); + QDragObject *dragObject (bool isDependent); + + void moveItem (QListViewItem *item, QListViewItem *parent, QListViewItem *above); + + bool hasSelectedItems(); + void deleteSelectedItems(); + +protected: + bool acceptDrag (QDropEvent* event) const; + +private: + void _warning (const KKeySequence& cut, QString sAction, QString sTitle); + bool isStdAccelPresent (const KShortcut& cut, bool warnUser); + bool isGlobalKeyPresent (const KShortcut& cut, bool warnUser); + bool isApplicationKeyPresent (const KShortcut& cut, bool warnUser); + bool isPhraseKeyPresent (const KShortcut& cut, PhraseTreeItem* cutItem, bool warnUser); +public: + bool isKeyPresent (const KShortcut& cut, PhraseTreeItem* cutItem, bool warnUser); + +public slots: + void itemExpanded (QListViewItem *item); + void itemCollapsed (QListViewItem *item); + +signals: + void shortcutRequest (PhraseShortcutRequest *request); + +private: + QPixmap phrasebook_open; + QPixmap phrasebook_closed; + QPixmap phrase; +}; + +#endif -- cgit v1.2.1