diff options
author | Kandrashin Denis <mail@lintest.ru> | 2012-04-02 21:33:04 +0400 |
---|---|---|
committer | Kandrashin Denis <mail@lintest.ru> | 2012-04-02 21:33:04 +0400 |
commit | a9ba04211f7b58fd52982c31e639e98ba38e4b5d (patch) | |
tree | 64873557d45c93f63cbd2ca590079437205519d6 | |
parent | e4cfac1c4c4ee2edcdfe68e5546aa9c7e4a01e93 (diff) |
Small optimization FbTreeModelQTextEdit
-rw-r--r-- | source/fb2edit.pro | 4 | ||||
-rw-r--r-- | source/fb2main.cpp | 2 | ||||
-rw-r--r-- | source/fb2text.h (renamed from source/fb2edit.h) | 6 | ||||
-rw-r--r-- | source/fb2tree.cpp | 9 | ||||
-rw-r--r-- | source/fb2tree.h | 2 |
5 files changed, 12 insertions, 11 deletions
diff --git a/source/fb2edit.pro b/source/fb2edit.pro index 778c5e9..5076fd7 100644 --- a/source/fb2edit.pro +++ b/source/fb2edit.pro @@ -3,8 +3,8 @@ HEADERS = \ fb2doc.h \ fb2main.h \ fb2read.h \ - fb2tree.h \ - fb2edit.h + fb2text.h \ + fb2tree.h SOURCES = \ fb2app.cpp \ diff --git a/source/fb2main.cpp b/source/fb2main.cpp index 365963c..a0b4b11 100644 --- a/source/fb2main.cpp +++ b/source/fb2main.cpp @@ -4,8 +4,8 @@ #include "fb2main.h" #include "fb2doc.h" -#include "fb2edit.h" #include "fb2read.h" +#include "fb2text.h" #include "fb2tree.h" #include <Qsci/qsciscintilla.h> diff --git a/source/fb2edit.h b/source/fb2text.h index 2bb80e4..2cbabad 100644 --- a/source/fb2edit.h +++ b/source/fb2text.h @@ -1,5 +1,5 @@ -#ifndef FB2EDIT_H -#define FB2EDIT_H +#ifndef FB2TEXT_H +#define FB2TEXT_H #include <QResizeEvent> #include <QTextEdit> @@ -35,4 +35,4 @@ private: QSize m_size; }; -#endif // FB2EDIT_H +#endif // FB2TEXT_H diff --git a/source/fb2tree.cpp b/source/fb2tree.cpp index 6214c37..2d12e0c 100644 --- a/source/fb2tree.cpp +++ b/source/fb2tree.cpp @@ -27,10 +27,11 @@ Fb2TreeItem::~Fb2TreeItem() } } -Fb2TreeItem * Fb2TreeItem::item(int index) const +Fb2TreeItem * Fb2TreeItem::item(const QModelIndex &index) const { - if (index < 0 || index >= m_list.size()) return NULL; - return m_list[index]; + int row = index.row(); + if (row < 0 || row >= m_list.size()) return NULL; + return m_list[row]; } QString Fb2TreeItem::text() const @@ -62,7 +63,7 @@ Fb2TreeItem * Fb2TreeModel::item(const QModelIndex &index) const if (!m_root) return NULL; if (!index.isValid()) return m_root; Fb2TreeItem * parent = item(index.parent()); - return parent ? parent->item(index.row()) : NULL; + return parent ? parent->item(index) : NULL; } int Fb2TreeModel::columnCount(const QModelIndex &parent) const diff --git a/source/fb2tree.h b/source/fb2tree.h index 920d618..88bf8f3 100644 --- a/source/fb2tree.h +++ b/source/fb2tree.h @@ -13,7 +13,7 @@ public: virtual ~Fb2TreeItem(); - Fb2TreeItem * item(int index) const; + Fb2TreeItem * item(const QModelIndex &index) const; int index(Fb2TreeItem * child) const { return m_list.indexOf(child); |