viewgit/index.php:465 Only variables should be passed by reference [2048]

viewgit/index.php:466 Non-static method GeSHi::get_language_name_from_extension() should not be called statically [2048]

  1. #include "rssparser.h"
  2. #include <QDebug>
  3. #include <QtXml>
  4. #include <QtSql>
  5. #include <QtNetwork>
  6. #include <QtGui>
  7. #include <QtCore>
  8.  
  9. using namespace Larss;
  10.  
  11. Larss::RssParser::RssParser(QSqlDatabase db, FeedModel *model, QObject *parent) :
  12. QSqlTableModel (parent, db)
  13. {
  14. // Create the database if it does not exists.
  15. if (!db.tables().contains ("news"))
  16. {
  17. qDebug () << "Creating table news that is not in database...";
  18. QSqlQuery query(db);
  19. query.prepare("CREATE TABLE news (id INTEGER PRIMARY KEY, feed INTEGER, title TEXT, link TEXT, description TEXT, time INTEGER, read INTEGER);");
  20. if (!query.exec())
  21. qDebug () << "Error occurred while creating the database:" << query.lastError();
  22. }
  23.  
  24. // Set init parameters for the QSqlDataTable
  25. setTable("news");
  26.  
  27. // Select manual submit so user cannot modify content directly
  28. setEditStrategy(QSqlTableModel::OnRowChange);
  29. this->model = model;
  30. select();
  31. }
  32.  
  33. QVariant
  34. Larss::RssParser::headerData(int section, Qt::Orientation orientation, int role) const
  35. {
  36. if (role == Qt::DisplayRole)
  37. {
  38. if (orientation == Qt::Horizontal)
  39. {
  40. switch (section)
  41. {
  42. case 0:
  43. return tr("ID");
  44. break;
  45. case 1:
  46. return tr("Feed");
  47. break;
  48. case 2:
  49. return tr("Title");
  50. break;
  51. case 3:
  52. return tr("Link");
  53. break;
  54. case 4:
  55. return tr("Description");
  56. break;
  57. case 5:
  58. return tr("Time");
  59. break;
  60. case 6:
  61. return tr("Read");
  62. }
  63. }
  64. }
  65.  
  66. return QVariant (QVariant::Invalid);
  67. }
  68.  
  69. Larss::RssParser::~RssParser()
  70. {
  71. }
  72.  
  73. QVariant
  74. Larss::RssParser::data(const QModelIndex &idx, int role) const
  75. {
  76. if (role == Qt::FontRole)
  77. {
  78. // Get default font
  79. QFont default_font = QSqlTableModel::data(idx, role).toString();
  80.  
  81. // Check if this news is read or not
  82. QSqlRecord record = this->record(idx.row());
  83. if (record.value("read") == 0)
  84. default_font.setBold(true);
  85. return default_font;
  86. }
  87. // Call the default implementaton in almost every case
  88. return QSqlTableModel::data(idx, role);
  89. }
  90.  
  91. QString
  92. Larss::RssParser::getLink(const QModelIndex &index)
  93. {
  94. QSqlRecord record = this->record(index.row());
  95. return record.value("link").toString();
  96. }
  97.  
  98. void
  99. Larss::RssParser::setReadStatus(const QModelIndex& index, bool read)
  100. {
  101. QModelIndex read_index = createIndex(index.row(), 6, index.internalPointer());
  102. setData(read_index, read ? 1 : 0);
  103. }
  104.  
  105. quint64
  106. Larss::RssParser::getFeed(const QModelIndex &index)
  107. {
  108. quint64 id = index.internalId();
  109. if (id < FEEDMODEL_MAX_CATEGORIES)
  110. return 0;
  111. else
  112. return (id - FEEDMODEL_MAX_CATEGORIES);
  113. }
  114.  
  115. QString
  116. Larss::RssParser::getDescription(const QModelIndex &index)
  117. {
  118. QModelIndex description_index = createIndex(index.row(), 4, index.internalPointer());
  119. return data(description_index, Qt::DisplayRole).toString();
  120. }
  121.  
  122. void
  123. Larss::RssParser::selectActiveFeed(quint64 feed_id)
  124. {
  125. // Show only the news from the given feed
  126. setFilter(QString("feed='%1'").arg(feed_id));
  127. }