tdebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

konq_combo.h 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* This file is part of the KDE project
  2. Copyright (C) 2001 Carsten Pfeiffer <pfeiffer@kde.org>
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public
  5. License as published by the Free Software Foundation; either
  6. version 2 of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; see the file COPYING. If not, write to
  13. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  14. Boston, MA 02110-1301, USA.
  15. */
  16. #ifndef KONQ_COMBO_H
  17. #define KONQ_COMBO_H
  18. #include <tqevent.h>
  19. #include <kcombobox.h>
  20. #include <konq_historymgr.h>
  21. class TDECompletion;
  22. class TDEConfig;
  23. // we use KHistoryCombo _only_ for the up/down keyboard handling, otherwise
  24. // KComboBox would do fine.
  25. class KonqCombo : public KHistoryCombo
  26. {
  27. Q_OBJECT
  28. public:
  29. KonqCombo( TQWidget *parent, const char *name );
  30. ~KonqCombo();
  31. // initializes with the completion object and calls loadItems()
  32. void init( TDECompletion * );
  33. // determines internally if it's temporary or final
  34. void setURL( const TQString& url );
  35. void setTemporary( const TQString& );
  36. void setTemporary( const TQString&, const TQPixmap& );
  37. void clearTemporary( bool makeCurrent = true );
  38. void removeURL( const TQString& url );
  39. void insertPermanent( const TQString& );
  40. void updatePixmaps();
  41. void loadItems();
  42. void saveItems();
  43. static void setConfig( TDEConfig * );
  44. virtual void popup();
  45. void setPageSecurity( int );
  46. void insertItem( const TQString &text, int index=-1, const TQString& title=TQString::null );
  47. void insertItem( const TQPixmap &pixmap, const TQString &text, int index=-1, const TQString& title=TQString::null );
  48. protected:
  49. virtual void keyPressEvent( TQKeyEvent * );
  50. virtual bool eventFilter( TQObject *, TQEvent * );
  51. virtual void mousePressEvent( TQMouseEvent * );
  52. virtual void mouseMoveEvent( TQMouseEvent * );
  53. void paintEvent( TQPaintEvent * );
  54. void selectWord(TQKeyEvent *e);
  55. signals:
  56. /**
  57. Specialized signal that emits the state of the modifier
  58. keys along with the actual activated text.
  59. */
  60. void activated( const TQString &, int );
  61. /**
  62. User has clicked on the security lock in the combobar
  63. */
  64. void showPageSecurity();
  65. private slots:
  66. void slotCleared();
  67. void slotRemoved( const TQString& item );
  68. void slotSetIcon( int index );
  69. void slotActivated( const TQString& text );
  70. private:
  71. void updateItem( const TQPixmap& pix, const TQString&, int index, const TQString& title );
  72. void saveState();
  73. void restoreState();
  74. void applyPermanent();
  75. TQString temporaryItem() const { return text( temporary ); }
  76. void removeDuplicates( int index );
  77. bool hasSufficientContrast(const TQColor &c1, const TQColor &c2);
  78. bool m_returnPressed;
  79. bool m_permanent;
  80. int m_cursorPos;
  81. int m_currentIndex;
  82. int m_modifier;
  83. TQString m_currentText;
  84. TQPoint m_dragStart;
  85. int m_pageSecurity;
  86. static TDEConfig *s_config;
  87. static const int temporary; // the index of our temporary item
  88. };
  89. #endif // KONQ_COMBO_H