[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-bugs-dist
Subject:    [Bug 82019] Sort the article list with newest articles on top
From:       Sashmit Bhaduri <smt () vfemail ! net>
Date:       2004-06-02 23:46:26
Message-ID: 20040602234626.15720.qmail () ktown ! kde ! org
[Download RAW message or body]

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
      
http://bugs.kde.org/show_bug.cgi?id=82019      
smt vfemail net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From smt vfemail net  2004-06-03 01:46 -------
CVS commit by sashmit: 

- enable and complete the sorting code
- make decending sorting by date default for now (new articles at top)

  M +13 -8     feed.cpp   1.35
  M +4 -4      feed.h   1.22
  M +15 -0     myarticle.cpp   1.13
  M +3 -0      myarticle.h   1.7


--- kdenonbeta/akregator/src/feed.cpp  #1.34:1.35
 @ -112,4 +112,5  @ void Feed::appendArticles(const Document
     //kdDebug() << "appendArticles findDups=="<<findDups<< " isMerged=="<< \
m_merged<<endl;  findDups=true;
+    articles.enableSorting(false);
     Article::List::ConstIterator it;
     Article::List::ConstIterator en = d.articles().end();
 @ -147,4 +148,6  @ void Feed::appendArticles(const Document
         }
     }
+    articles.enableSorting(true);
+    articles.sort();
     //kdDebug() << "m_unread after appending articles=="<<m_unread<<endl;
 }
 @ -313,5 +316,5  @ struct ArticleSequence::Private
 {
    int dummy;
-//   bool doSort :1;
+   bool doSort :1;
 };
 
 @ -360,16 +363,18  @ ArticleSequence::iterator ArticleSequenc
 }
 
-/*
-void ArticleSequence::doNotSort()
+
+void ArticleSequence::enableSorting(bool b)
 {
-    d->doSort = false;
+    d->doSort = b;
 }
 
 void ArticleSequence::sort()
 {
-    d->doSort = true;
-//    qHeapSort( *this );
+    if (d->doSort)
+    {
+        qHeapSort( *this );
+    }
 }
-*/
+
 
 #include "feed.moc"

--- kdenonbeta/akregator/src/feed.h  #1.21:1.22
 @ -36,8 +36,8  @ namespace Akregator
             iterator append( const MyArticle &x );
             iterator prepend( const MyArticle &x );
-/*
-            void doNotSort(); ///< Disables internal item sorting (useful for \
massive insert operations). -            void sort();      ///< Enables internal \
sorting and sorts items. -*/
+
+            void enableSorting(bool b);
+            void sort();
+        
         private:
             struct Private;

--- kdenonbeta/akregator/src/myarticle.cpp  #1.12:1.13
 @ -33,6 +33,11  @ MyArticle::MyArticle() : d(new Private)
 MyArticle::MyArticle(Article article) : d(new Private)
 {
+    static int padding=60;
+    padding--;
+    if (padding==1)
+        padding=60;
     d->article = article;
     d->fetchDate = QDateTime::currentDateTime();
+    d->fetchDate=d->fetchDate.addSecs(padding); // temp HACK..
     if (article.title().isEmpty())
         d->title=buildTitle();
 @ -64,4 +69,14  @ MyArticle &MyArticle::operator=(const My
 }
 
+bool MyArticle::operator<(const MyArticle &other) const
+{
+    return pubDate() > other.pubDate();
+}
+
+bool MyArticle::operator>(const MyArticle &other) const
+{
+    return pubDate() < other.pubDate();
+}
+
 bool MyArticle::operator==(const MyArticle &other) const
 {

--- kdenonbeta/akregator/src/myarticle.h  #1.6:1.7
 @ -53,4 +53,7  @ namespace Akregator
             void dumpXmlData( QDomElement parent, QDomDocument doc ) const;
             
+            bool operator<(const MyArticle &other) const;
+            bool operator>(const MyArticle &other) const;
+
         private:
             struct Private;
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic