performance fix/cleanup.

* LyXKeySym.h: replace global operator==() with pure virtual method.

* QLyXKeySym: new operator==() method.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16598 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-01-08 11:01:26 +00:00
parent cf30cf83c6
commit f18e41b734
3 changed files with 12 additions and 11 deletions

View File

@ -35,6 +35,9 @@ public:
virtual ~LyXKeySym() {}
///
virtual bool operator==(LyXKeySym const& ks) const = 0;
/// Initialize with the name of a key. F. ex. "space" or "a"
virtual void init(std::string const & symbolname) = 0;
@ -64,12 +67,6 @@ public:
};
/**
* We need to be able to equality compare these for the
* sake of the keymap business.
*/
bool operator==(LyXKeySym const & k1, LyXKeySym const & k2);
typedef boost::shared_ptr<LyXKeySym> LyXKeySymPtr;

View File

@ -241,18 +241,17 @@ bool QLyXKeySym::isText() const
}
bool operator==(LyXKeySym const & k1, LyXKeySym const & k2)
bool QLyXKeySym::operator==(LyXKeySym const & ks) const
{
QLyXKeySym const & q1(static_cast<QLyXKeySym const &>(k1));
QLyXKeySym const & q2(static_cast<QLyXKeySym const &>(k2));
QLyXKeySym const & qks = static_cast<QLyXKeySym const &>(ks);
// we do not have enough info for a fair comparison, so return
// false. This works out OK because unknown text from Qt will
// get inserted anyway after the isText() check
if (q1.key() == Qt::Key_unknown || q2.key() == Qt::Key_unknown)
if (key_ == Qt::Key_unknown || qks.key_ == Qt::Key_unknown)
return false;
return q1.key() == q2.key();
return key_ == qks.key_;
}

View File

@ -34,6 +34,11 @@ public:
virtual ~QLyXKeySym() {}
/// .
/// inlined out because of profiling results under linux when
/// opening a document.
inline bool operator==(LyXKeySym const& ks) const;
/// delayed constructor
void set(QKeyEvent * ev);