summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatgic78 <matgic78@gmail.com>2010-03-29 19:30:27 +0200
committermatgic78 <matgic78@gmail.com>2010-04-01 19:27:01 +0200
commitdf47feec690a840eb2633672f7ab36d53ab192b3 (patch)
tree557163f97763b55c85fa9f5af2e6c4cecc44e4a6
parentCleaning awesome bar code a bit.. (diff)
downloadrekonq-df47feec690a840eb2633672f7ab36d53ab192b3.tar.xz
Remove limitation to the number of favorites. You are now able to add and remove favorites. Some work needed on the "add favorite" button
-rw-r--r--src/newtabpage.cpp55
1 files changed, 45 insertions, 10 deletions
diff --git a/src/newtabpage.cpp b/src/newtabpage.cpp
index c61eb60d..7d8787d7 100644
--- a/src/newtabpage.cpp
+++ b/src/newtabpage.cpp
@@ -86,6 +86,23 @@ void NewTabPage::generate(const KUrl &url)
{
if(KUrl("about:preview").isParentOf(url))
{
+ if(url.fileName() == QString("add"))
+ {
+ QStringList names = ReKonfig::previewNames();
+ QStringList urls = ReKonfig::previewUrls();
+
+ names.append("");
+ urls.append("");
+
+ ReKonfig::setPreviewNames(names);
+ ReKonfig::setPreviewUrls(urls);
+
+ // Why doesn't it work well ?
+ // m_root.appendInside(emptyPreview(names.length() - 1));
+ // Replacing with this :
+ generate(KUrl("about:favorites"));
+ return;
+ }
if(url.directory() == QString("preview/remove"))
{
removePreview(url.fileName().toInt());
@@ -141,10 +158,13 @@ void NewTabPage::favoritesPage()
{
m_root.addClass("favorites");
+ // TODO : create a nice button to replace this ugly link
+ m_root.document().findFirst("#navigation").appendOutside("<a href=\"about:preview/add\">Add Preview</a>");
+
QStringList names = ReKonfig::previewNames();
QStringList urls = ReKonfig::previewUrls();
- for(int i=0; i<8; ++i)
+ for(int i=0; i < urls.count() ; ++i)
{
KUrl url = urls.at(i);
QWebElement prev;
@@ -173,7 +193,7 @@ QWebElement NewTabPage::emptyPreview(int index)
prev.findFirst("a").setAttribute("href", QString("about:preview/modify/" + QVariant(index).toString()));
setupPreview(prev, index);
- hideControls(prev);
+ //hideControls(prev);
return prev;
}
@@ -276,16 +296,31 @@ void NewTabPage::removePreview(int index)
QStringList names = ReKonfig::previewNames();
QStringList urls = ReKonfig::previewUrls();
- urls.replace(index, QString(""));
- names.replace(index, QString(""));
-
- ReKonfig::setPreviewNames(names);
- ReKonfig::setPreviewUrls(urls);
+ if(urls.at(index) == "")
+ {
+ urls.removeAt(index);
+ names.removeAt(index);
+
+ // modify config before
+ ReKonfig::setPreviewNames(names);
+ ReKonfig::setPreviewUrls(urls);
+
+ // reload to update index
+ generate(KUrl("about:favorites"));
+ }
+ else
+ {
+ urls.replace(index, QString(""));
+ names.replace(index, QString(""));
+
+ QWebElement prev = m_root.findFirst("#preview" + QVariant(index).toString());
+ prev.replace(emptyPreview(index));
+
+ ReKonfig::setPreviewNames(names);
+ ReKonfig::setPreviewUrls(urls);
+ }
ReKonfig::self()->writeConfig();
-
- QWebElement prev = m_root.findFirst("#preview" + QVariant(index).toString());
- prev.replace(emptyPreview(index));
}