summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-04-07 17:53:50 +0300
committerAndrei Karas <akaras@inbox.ru>2012-04-20 12:40:55 +0300
commite5e52b4500fa8e2c7a8357c6f38a8756b996d27c (patch)
tree2561859b3aa698443b49a5c0a3c4ebf5d1ed32ba
parent7f80748fb8a1b02702075c143750701656aa55e4 (diff)
downloadplus-e5e52b4500fa8e2c7a8357c6f38a8756b996d27c.tar.gz
plus-e5e52b4500fa8e2c7a8357c6f38a8756b996d27c.tar.bz2
plus-e5e52b4500fa8e2c7a8357c6f38a8756b996d27c.tar.xz
plus-e5e52b4500fa8e2c7a8357c6f38a8756b996d27c.zip
Change implimentation for removeing old links from browser box class.
-rw-r--r--src/gui/widgets/browserbox.cpp44
-rw-r--r--src/gui/widgets/browserbox.h1
2 files changed, 17 insertions, 28 deletions
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 5ef7adfcd..0fd70c05b 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -107,6 +107,7 @@ void BrowserBox::addRow(const std::string &row, bool atTop)
std::string newRow;
std::string::size_type idx1, idx2, idx3;
gcn::Font *font = getFont();
+ int linksCount = 0;
if (getWidth() < 0)
return;
@@ -143,6 +144,7 @@ void BrowserBox::addRow(const std::string &row, bool atTop)
bLink.x2 = bLink.x1 + font->getWidth(bLink.caption) + 1;
mLinks.push_back(bLink);
+ linksCount ++;
newRow += "##<" + bLink.caption;
@@ -165,45 +167,29 @@ void BrowserBox::addRow(const std::string &row, bool atTop)
newRow = replaceAll(newRow, "%VER%", SMALL_VERSION);
if (atTop)
+ {
mTextRows.push_front(newRow);
+ mTextRowLinksCount.push_front(linksCount);
+ }
else
+ {
mTextRows.push_back(newRow);
+ mTextRowLinksCount.push_back(linksCount);
+ }
//discard older rows when a row limit has been set
- if (mMaxRows > 0)
+ if (mMaxRows > 0 && !mTextRows.empty())
{
while (mTextRows.size() > mMaxRows)
{
mTextRows.pop_front();
+ int cnt = mTextRowLinksCount.front();
+ mTextRowLinksCount.pop_front();
- int yStart = 0;
-
- LinePartIterator i = mLineParts.begin();
- if (i != mLineParts.end())
+ while (cnt && !mLinks.empty())
{
- ++ i;
- for (; i != mLineParts.end(); ++ i)
- {
- const LinePart &part = *i;
- if (!part.mX)
- {
- yStart = part.mY;
- break;
- }
- }
- }
-
- LinkIterator it = mLinks.begin();
- LinkIterator it_end = mLinks.end();
- while (it != it_end)
- {
- (*it).y1 -= yStart;
- (*it).y2 -= yStart;
-
- if ((*it).y1 < 0)
- it = mLinks.erase(it);
- else
- ++ it;
+ mLinks.erase(mLinks.begin());
+ cnt --;
}
}
}
@@ -294,11 +280,13 @@ void BrowserBox::addImage(const std::string &path)
return;
mTextRows.push_back("~~~" + path);
+ mTextRowLinksCount.push_back(0);
}
void BrowserBox::clearRows()
{
mTextRows.clear();
+ mTextRowLinksCount.clear();
mLinks.clear();
setWidth(0);
setHeight(0);
diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h
index b1582e077..55bea8dad 100644
--- a/src/gui/widgets/browserbox.h
+++ b/src/gui/widgets/browserbox.h
@@ -207,6 +207,7 @@ class BrowserBox : public gcn::Widget,
typedef TextRows::iterator TextRowIterator;
TextRows mTextRows;
+ std::list<int> mTextRowLinksCount;
typedef std::vector<LinePart> LinePartList;
typedef LinePartList::iterator LinePartIterator;