Ejemplo n.º 1
0
RssFeed::RssFeed(RssManager* manager, RssFolder* parent, const QString& url):
  m_manager(manager),
  m_parent(parent),
  m_url (QUrl::fromEncoded(url.toUtf8()).toString()),
  m_icon(":/Icons/oxygen/application-rss+xml.png"),
  m_unreadCount(0),
  m_dirty(false),
  m_inErrorState(false),
  m_loading(false)
{
  qDebug() << Q_FUNC_INFO << m_url;
  // Listen for new RSS downloads
  connect(manager->rssDownloader(), SIGNAL(downloadFinished(QString,QString)), SLOT(handleFinishedDownload(QString,QString)));
  connect(manager->rssDownloader(), SIGNAL(downloadFailure(QString,QString)), SLOT(handleDownloadFailure(QString,QString)));
  connect(manager->rssParser(), SIGNAL(feedTitle(QString,QString)), SLOT(handleFeedTitle(QString,QString)));
  connect(manager->rssParser(), SIGNAL(newArticle(QString,QVariantHash)), SLOT(handleNewArticle(QString,QVariantHash)));
  connect(manager->rssParser(), SIGNAL(feedParsingFinished(QString,QString)), SLOT(handleFeedParsingFinished(QString,QString)));

  // Download the RSS Feed icon
  m_iconUrl = iconUrl();
  manager->rssDownloader()->downloadUrl(m_iconUrl);

  // Load old RSS articles
  loadItemsFromDisk();
}
Ejemplo n.º 2
0
/**
 * \fn MainWindow::MainWindow(QWidget *parent)
 * \brief Construction de la MainWindow
 * \param Widget parent de MainWindow. 'NULL' par defaut.
 */
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    id = 0;

    NoteManager::getInstance();

    //Configuration

    QWidget* spacer= new QWidget();
    spacer->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);


    //Action
    ui->actionArticle->setIcon(QIcon("/Users/Antoine/Documents/ProjetInfo/Github/Notify_Github/Icons/articleIcon48.png"));
    ui->actionDocument->setIcon(QIcon("/Users/Antoine/Documents/ProjetInfo/Github/Notify_Github/Icons/document1Icon48.png"));
    ui->actionImage_2->setIcon(QIcon("/Users/Antoine/Documents/ProjetInfo/Github/Notify_Github/Icons/imageIcon48.png"));
    ui->actionAudio->setIcon(QIcon("/Users/Antoine/Documents/ProjetInfo/Github/Notify_Github/Icons/audioIcon48.png"));
    ui->actionVideo->setIcon(QIcon("/Users/Antoine/Documents/ProjetInfo/Github/Notify_Github/Icons/videoIcon48.png"));
    ui->actionQuit->setIcon(QIcon("/Users/Antoine/Documents/ProjetInfo/Github/Notify_Github/Icons/stop_2_48.png"));

    //Toolbar
    ui->toolBar->addAction(ui->actionArticle);
    ui->toolBar->addAction(ui->actionDocument);
    ui->toolBar->addAction(ui->actionImage_2);
    ui->toolBar->addAction(ui->actionAudio);
    ui->toolBar->addAction(ui->actionVideo);
    ui->toolBar->addWidget(spacer);
    ui->toolBar->addAction(ui->actionQuit);

    //Connection
    QObject::connect(ui->actionQuit,SIGNAL(triggered()),qApp,SLOT(quit()));
    QObject::connect(ui->actionWorkspace,SIGNAL(triggered()),this,SLOT(newWorkspace()));
    QObject::connect(ui->actionArticle,SIGNAL(triggered()),this,SLOT(newArticle()));
    QObject::connect(ui->actionDocument,SIGNAL(triggered()),this,SLOT(newDocument()));
    QObject::connect(ui->actionVideo,SIGNAL(triggered()),this,SLOT(newVideo()));
    QObject::connect(ui->actionImage_2,SIGNAL(triggered()),this,SLOT(newImage()));
    QObject::connect(ui->actionAudio,SIGNAL(triggered()),this,SLOT(newAudio()));
    QObject::connect(ui->actionSave,SIGNAL(triggered()),this,SLOT(saveWorkspace()));
    QObject::connect(ui->actionSave_As,SIGNAL(triggered()),this,SLOT(saveWorkspaceAs()));

    QObject::connect(this,SIGNAL(clear()),&Workspace::getInstance(),SLOT(clear()));

    //Zone de travail

    gridLayout = new QGridLayout(ui->centralwidget);
    ui->centralwidget->setLayout(gridLayout);

    work = &Workspace::getInstance(ui->centralwidget);
    editor = &Editorspace::getInstance(ui->centralwidget);

    gridLayout->addWidget(work,0,0,1,1);
    gridLayout->addWidget(editor,0,1,2,1);
    gridLayout->addWidget(&Tags::TagManagerWidget::getInstance(ui->centralwidget),1,0,1,1);
}
Ejemplo n.º 3
0
void RssParser::parseRssArticle(QXmlStreamReader& xml, const QString& feedUrl)
{
  QVariantHash article;

  while(!xml.atEnd()) {
    xml.readNext();

    if(xml.isEndElement() && xml.name() == "item")
      break;

    if (xml.isStartElement()) {
      if (xml.name() == "title")
        article["title"] = xml.readElementText();
      else if (xml.name() == "enclosure") {
        if (xml.attributes().value("type") == "application/x-bittorrent")
          article["torrent_url"] = xml.attributes().value("url").toString();
      }
      else if (xml.name() == "link")
        article["news_link"] = xml.readElementText();
      else if (xml.name() == "description")
        article["description"] = xml.readElementText();
      else if (xml.name() == "pubDate")
        article["date"] = parseDate(xml.readElementText());
      else if (xml.name() == "author")
        article["author"] = xml.readElementText();
      else if (xml.name() == "guid")
        article["id"] = xml.readElementText();
    }
  }

  if (!article.contains("id")) {
    // Item does not have a guid, fall back to some other identifier
    const QString link = article.value("news_link").toString();
    if (!link.isEmpty())
      article["id"] = link;
    else {
      const QString title = article.value("title").toString();
      if (!title.isEmpty())
        article["id"] = title;
      else {
        qWarning() << "Item has no guid, link or title, ignoring it...";
        return;
      }
    }
  }

  emit newArticle(feedUrl, article);
}
Ejemplo n.º 4
0
Fenetre::Fenetre(QWidget *parent) : courant(0), QMainWindow(parent)
{
    //*************************
    courant = NULL;
    folder = NULL;
    resize(1200, 512);
    //*************************** Menu ***************************
    QMenu* mFile = menuBar()->addMenu("&File");
    QMenu* mEdit = menuBar()->addMenu("&Edit");
    QMenu* mView = menuBar()->addMenu("&View");


    QMenu* mNouveau = mFile->addMenu("New");
    QAction* mactionAnnuler = mEdit->addAction("Annuler");
    QAction* mactionRefaire = mEdit->addAction("Refaire");
    QAction* mactionSupprimer = mEdit->addAction("Supprimer");
    QMenu* mTag = mEdit->addMenu("Tags");
    QAction* mactionSupprimerTag = mTag->addAction("Supprimer");
    QMenu* mDocument = mEdit->addMenu("Documents");
    QAction* mactionUp = mDocument->addAction("Monter");
    QAction* mactionDown = mDocument->addAction("Descendre");
    QMenu* mExport = mEdit->addMenu("Exporter");
    QAction* mactionOuvrir = mFile->addAction("Ouvrir un espace de travail");
    QAction* mactionNew = mFile->addAction("Nouvel espace de travail");
    QAction* mactionSaveAs = mFile->addAction("Enregistrer sous...");
    QAction* mactionNewArticle = mNouveau->addAction("Article");
    QAction* mactionNewImage = mNouveau->addAction("Image");
    QAction* mactionNewAudio = mNouveau->addAction("Audio");
    QAction* mactionNewVideo = mNouveau->addAction("Video");
    QAction* mactionNewDocument = mNouveau->addAction("Document");

    QAction* mactionExportHTML = mExport->addAction("Html");
    QAction* mactionExportTex = mExport->addAction("Tex");
    QAction* mactionExportTexte = mExport->addAction("Texte");
    QAction* mactionOption=mEdit->addAction("Setting");

    QAction* mactionAddTag = mNouveau->addAction("Tag");

    QAction* mactionSave = mFile->addAction("Sauvegarder");
    mFile->addSeparator();
    QMenu* ouvrirCorbeille = mFile->addMenu("Corbeille");
    QAction* mactionRestaurer = ouvrirCorbeille->addAction("Restaurer");
    QAction* mactionVider = ouvrirCorbeille->addAction("Vider la Corbeille");

    mactionViewEdit = mView->addAction("Onglet Editeur");
    mactionViewHTML = mView->addAction("Onglet Html");
    mactionViewTex = mView->addAction("Onglet Tex");
    mactionViewTexte = mView->addAction("Onglet Texte");

    mFile->addSeparator();
    QAction* actionQuitter = mFile->addAction("&Quitter");
    actionQuitter->setIcon(QIcon("icon/quitter.png"));
    mactionNewArticle->setIcon(QIcon("icon/article.png"));
    mactionNewImage->setIcon(QIcon("icon/image.png"));
    mactionNewAudio->setIcon(QIcon("icon/audio.png"));
    mactionNewVideo->setIcon(QIcon("icon/video.png"));
    mNouveau->setIcon(QIcon("icon/plus.png"));
    mactionDown->setIcon(QIcon("icon/down.png"));
    mactionUp->setIcon(QIcon("icon/up.png"));
    mactionAddTag->setIcon(QIcon("icon/tag.png"));
    mactionSave->setIcon(QIcon("icon/save.png"));

    mactionExportHTML->setIcon(QIcon("icon/html.png"));
    mactionExportTex->setIcon(QIcon("icon/tex.png"));
    mactionExportTexte->setIcon(QIcon("icon/texte.png"));

    mactionAnnuler->setIcon(QIcon("icon/undo.png"));
    mactionRefaire->setIcon(QIcon("icon/redo.png"));
    mactionSupprimer->setIcon(QIcon("icon/cross.png"));
    mactionRestaurer->setIcon(QIcon("icon/corbeille.png"));
    mactionNewDocument->setIcon(QIcon("icon/document.png"));
    mactionOption->setIcon(QIcon("icon/setting.png"));


    mactionOuvrir->setShortcut(QKeySequence("Ctrl+O"));
    actionQuitter->setShortcut(QKeySequence("Ctrl+Q"));
    mactionSave->setShortcut(QKeySequence("Ctrl+S"));

    mactionAnnuler->setShortcut(QKeySequence("Ctrl+Z"));
    mactionRefaire->setShortcut(QKeySequence("Ctrl+Y"));
    mactionSupprimer->setShortcut(tr("Delete"));

    //** VIEW **//
    mactionViewEdit->setCheckable(true);
    mactionViewEdit->setChecked(true);
    mactionViewHTML->setCheckable(true);
    mactionViewTex->setCheckable(true);
    mactionViewTexte->setCheckable(true);


    //Bar de statue
    QStatusBar* statusBar = new QStatusBar;
    statusBar->addWidget(new QLabel("Projet Lo21 - Pauline Crouillère / Emilien Notarianni"));
    this->setStatusBar(statusBar);
    // Création de la barre d'outils
    QToolBar *toolBarFichier = addToolBar("Fichier");

    toolBarFichier->addAction(mactionNewArticle);
    toolBarFichier->addAction(mactionNewImage);
    toolBarFichier->addAction(mactionNewAudio);
    toolBarFichier->addAction(mactionNewVideo);
    toolBarFichier->addAction(mactionNewDocument);
    toolBarFichier->addSeparator();
    toolBarFichier->addAction(mactionAddTag);
    toolBarFichier->addSeparator();
    toolBarFichier->addAction(mactionUp);
    toolBarFichier->addAction(mactionDown);
    toolBarFichier->addSeparator();

    toolBarFichier->addAction(mactionExportHTML);
    toolBarFichier->addAction(mactionExportTex);
    toolBarFichier->addAction(mactionExportTexte);
    toolBarFichier->addSeparator();
    toolBarFichier->addAction(mactionRestaurer);
    toolBarFichier->addSeparator();
    toolBarFichier->addAction(mactionSupprimer);
    toolBarFichier->addSeparator();
    toolBarFichier->addAction(actionQuitter);

    /*************************************************************/
    couche = new QHBoxLayout();
    lw = new LeftWindows();
    ow = new OngletWindows();
    couche->addWidget(lw);
    couche->addWidget(ow);
    couche->setMargin(0);
    couche->setAlignment(Qt::AlignTop);
    centerWindows = new QWidget();
    centerWindows->setLayout(couche);
    setCentralWidget(centerWindows);

    //************************** CONNECT **************************/
    QObject::connect(mactionNewArticle, SIGNAL(triggered()), this, SLOT(newArticle()));
    QObject::connect(mactionNewDocument, SIGNAL(triggered()), this, SLOT(newDocument()));
    QObject::connect(mactionNewImage, SIGNAL(triggered()), this, SLOT(newImage()));
    QObject::connect(mactionNewAudio, SIGNAL(triggered()), this, SLOT(newAudio()));
    QObject::connect(mactionNewVideo, SIGNAL(triggered()), this, SLOT(newVideo()));
    QObject::connect(mactionAddTag, SIGNAL(triggered()), this, SLOT(newTag()));
    QObject::connect(mactionOuvrir,SIGNAL(triggered()),this, SLOT(ouvrirDialogue()));
    QObject::connect(actionQuitter,SIGNAL(triggered()),qApp, SLOT(quit()));

    QObject::connect(mactionUp,SIGNAL(triggered()),this, SLOT(docUp()));
    QObject::connect(mactionDown,SIGNAL(triggered()),this, SLOT(docDown()));

    QObject::connect(mactionRestaurer, SIGNAL(triggered()), this, SLOT(ouvrirCorbeille()));

    QObject::connect(mactionSave, SIGNAL(triggered()), this, SLOT(asave()));

    QObject::connect(mactionExportHTML, SIGNAL(triggered()), this, SLOT(exportHTML()));
    QObject::connect(mactionExportTex, SIGNAL(triggered()), this, SLOT(exportTex()));
    QObject::connect(mactionExportTexte, SIGNAL(triggered()), this, SLOT(exportTexte()));

    QObject::connect(mactionSupprimer, SIGNAL(triggered()), this, SLOT(deleteInCorbeille()));
    QObject::connect(mactionVider, SIGNAL(triggered()), this, SLOT(viderLaCorbeille()));
    //TODO
    QObject::connect(mactionAnnuler, SIGNAL(triggered()), qApp, SLOT(undo()));
    QObject::connect(mactionRefaire, SIGNAL(triggered()), qApp, SLOT(redo()));
    //
    QObject::connect(mactionSaveAs, SIGNAL(triggered()), this, SLOT(copieWorkSpace()));
    QObject::connect(mactionNew, SIGNAL(triggered()), this, SLOT(newWorkSpace()));
    QObject::connect(mactionOption, SIGNAL(triggered()), this, SLOT(setting()));



    QObject::connect(mactionViewEdit, SIGNAL(triggered()), this, SLOT(changeEdit()));
    QObject::connect(mactionViewHTML, SIGNAL(triggered()), this, SLOT(changeHtml()));
    QObject::connect(mactionViewTex,SIGNAL(triggered()),this, SLOT(changeTex()));
    QObject::connect(mactionViewTexte,SIGNAL(triggered()),this, SLOT(changeTexte()));
    QObject::connect(ow, SIGNAL(currentChanged(int)), this, SLOT(changeOnglet(int)));
    QObject::connect(mactionSupprimerTag, SIGNAL(triggered()), this, SLOT(supprimeTag()));

}
Ejemplo n.º 5
0
void RssParser::parseAtomArticle(QXmlStreamReader& xml, const QString& feedUrl, const QString& baseUrl)
{
  QVariantHash article;
  bool double_content = false;

  while(!xml.atEnd()) {
    xml.readNext();

    if(xml.isEndElement() && xml.name() == "entry")
      break;

    if (xml.isStartElement()) {
      if (xml.name() == "title") {
        // Workaround for CDATA (QString cannot parse html escapes on it's own)
        QTextDocument doc;
        doc.setHtml(xml.readElementText());
        article["title"] = doc.toPlainText();
      }
      else if (xml.name() == "link") {
        QString theLink = ( xml.attributes().isEmpty() ?
                              xml.readElementText() :
                              xml.attributes().value("href").toString() );

        // Atom feeds can have relative links, work around this and
        // take the stress of figuring article full URI from UI

        // Assemble full URI
        article["news_link"] = ( baseUrl.isEmpty() ?
                                   theLink :
                                   baseUrl + theLink );
      }
      else if (xml.name() == "summary" || xml.name() == "content"){
        if(double_content) { // Duplicate content -> ignore
          xml.readNext();

          while(xml.name() != "summary" && xml.name() != "content")
            xml.readNext();

          continue;
        }

        // Try to also parse broken articles, which don't use html '&' escapes
        // Actually works great for non-broken content too
        QString feedText = xml.readElementText(QXmlStreamReader::IncludeChildElements);
        if (!feedText.isEmpty())
          article["description"] = feedText;

        double_content = true;
      }
      else if (xml.name() == "updated"){
        // ATOM uses standard compliant date, don't do fancy stuff
        QDateTime articleDate = QDateTime::fromString(xml.readElementText(), Qt::ISODate);
        article["date"] = ( articleDate.isValid() ?
                              articleDate :
                              QDateTime::currentDateTime() );
      }
      else if (xml.name() == "author") {
        xml.readNext();
        while(xml.name() != "author") {
          if(xml.name() == "name")
            article["author"] = xml.readElementText();
          xml.readNext();
        }
      }
      else if (xml.name() == "id")
        article["id"] = xml.readElementText();
    }
  }

  if (!article.contains("id")) {
    // Item does not have a guid, fall back to some other identifier
    const QString link = article.value("news_link").toString();
    if (!link.isEmpty())
      article["id"] = link;
    else {
      const QString title = article.value("title").toString();
      if (!title.isEmpty())
        article["id"] = title;
      else {
        qWarning() << "Item has no guid, link or title, ignoring it...";
        return;
      }
    }
  }

  emit newArticle(feedUrl, article);
}