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, content 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::OnManualSubmit);
  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("Content");
  59. break;
  60. case 6:
  61. return tr("Time");
  62. break;
  63. case 7:
  64. return tr("Read");
  65. }
  66. }
  67. }
  68.  
  69. return QVariant (QVariant::Invalid);
  70. }
  71.  
  72. Larss::RssParser::~RssParser()
  73. {
  74. }
  75.  
  76. QVariant
  77. Larss::RssParser::data(const QModelIndex &idx, int role) const
  78. {
  79. if (role == Qt::FontRole)
  80. {
  81. // Get default font
  82. QFont default_font = QSqlTableModel::data(idx, role).toString();
  83.  
  84. // Check if this news is read or not
  85. QSqlRecord record = this->record(idx.row());
  86. if (record.value("read") == 0)
  87. default_font.setBold(true);
  88. return default_font;
  89. }
  90. // Call the default implementaton in almost every case
  91. return QSqlTableModel::data(idx, role);
  92. }
  93.  
  94. QString
  95. Larss::RssParser::getLink(const QModelIndex &index)
  96. {
  97. QSqlRecord record = this->record(index.row());
  98. return record.value("link").toString();
  99. }
  100.  
  101. void
  102. Larss::RssParser::setReadStatus(const QModelIndex& index, bool read)
  103. {
  104. QModelIndex read_index = createIndex(index.row(), 7, index.internalPointer());
  105. setData(read_index, read ? 1 : 0);
  106. if (!submitAll())
  107. qDebug() << "Error while setting the read flag";
  108. }
  109.  
  110. quint64
  111. Larss::RssParser::getFeed(const QModelIndex &index)
  112. {
  113. quint64 id = index.internalId();
  114. if (id < FEEDMODEL_MAX_CATEGORIES)
  115. return 0;
  116. else
  117. return (id - FEEDMODEL_MAX_CATEGORIES);
  118. }
  119.  
  120. QString
  121. Larss::RssParser::getContent(const QModelIndex &index)
  122. {
  123. QModelIndex description_index = createIndex(index.row(), 5, index.internalPointer());
  124. return data(description_index, Qt::DisplayRole).toString();
  125. }
  126.  
  127. QString
  128. Larss::RssParser::getTitle(const QModelIndex &index)
  129. {
  130. QModelIndex title_index = createIndex(index.row(), 2, index.internalPointer());
  131. return data(title_index, Qt::DisplayRole).toString();
  132. }
  133.  
  134. void
  135. Larss::RssParser::selectActiveFeed(quint64 feed_id)
  136. {
  137. // Show only the news from the given feed
  138. setFilter(QString("feed='%1'").arg(feed_id));
  139. }