⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 newsreader.cpp

📁 this program is Newsreader using RSS (XML) base on Qt app
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************** Form implementation generated from reading ui file 'newsreader.ui'**** Created: Fri Dec 5 11:51:06 2008**      by: The User Interface Compiler ($Id: qt/main.cpp   3.3.3   edited Nov 24 2003 $)**** WARNING! All changes made in this file will be lost!****************************************************************************/#include "newsreader.h"#include <qvariant.h>#include <qtextedit.h>#include <qtextbrowser.h> #include <qpushbutton.h>#include <qlayout.h>#include <qtooltip.h>#include <qwhatsthis.h>#include <qapplication.h>#include <qurl.h>#include <qfont.h>#include <qtextcodec.h>#include <qeuckrcodec.h>#include <qcstring.h>#include <qmime.h>#include <qimage.h>#include <qfileinfo.h>#include <qfile.h>#include <qstringlist.h>  #include <qmessagebox.h> #include <qregexp.h> #include <qlabel.h>#include <qlistbox.h>#include <qlistview.h>#include <qnetwork.h>#include <qurloperator.h>#include <qframe.h>#include <qprogressbar.h>#define kor(str)	QString::fromLocal8Bit(str) /* *  Constructs a NewsReader as a child of 'parent', with the *  name 'name' and widget flags set to 'f'. */NewsReader::NewsReader( QWidget* parent, const char* name, WFlags fl )    : QWidget( parent, name, fl ){    if ( !name )	setName( "NewsReader" );    setMinimumSize( QSize( 640, 480 ) );    setMaximumSize( QSize( 640, 480 ) );    setBaseSize( QSize( 640, 480 ) );///////////////////////////////////////////////////////////intro    MainFrame = new QFrame( this, "MainFrame" );    MainFrame->setGeometry( QRect( 0, 0, 640, 470 ) );    MainFrame->setFrameShape( QFrame::StyledPanel );    MainFrame->setFrameShadow( QFrame::Raised );    MainButton = new QPushButton( MainFrame, "MainButton" );    MainButton->setGeometry( QRect( 58, 216, 165, 80 ) );    MainButton->setPaletteForegroundColor( QColor( 0, 0, 0 ) );    MainButton->setPaletteBackgroundColor( QColor( 237, 233, 227 ) );    MainButton->setAcceptDrops( FALSE );    MainButton->setAutoMask( TRUE );    MainButton->setToggleButton( FALSE );    MainButton->setOn( FALSE );    QObject::connect(MainButton, SIGNAL(clicked()), SLOT(UpdateShow()));    MainFrame->setPaletteBackgroundPixmap(QImage("img/IntroMain.jpg"));    MainButton->setPaletteBackgroundPixmap(QImage("img/enter.jpg"));	///////////////////////////////////////////////////////////update    UpdateList = new QFrame( this, "UpdateList" );    UpdateList->setGeometry( QRect( 0, 0, 640, 480 ) );    UpdateList->setPaletteBackgroundColor( QColor( 112, 112, 112 ) );    UpdateList->setFrameShape( QFrame::StyledPanel );    UpdateList->setFrameShadow( QFrame::Raised );    Update_Button1 = new QPushButton( UpdateList, "Update_Button1" );    Update_Button1->setGeometry( QRect( 0, 10, 70, 60 ) );    Update_Button1->setAutoMask( TRUE );    Update_Button1->setPaletteBackgroundPixmap(QImage("img/final_updatelist.jpg"));    QObject::connect(Update_Button1, SIGNAL(clicked()), SLOT(UpdateShow()));    Update_Button2 = new QPushButton( UpdateList, "Update_Button2" );    Update_Button2->setGeometry( QRect( 0, 80, 70, 60 ) );    Update_Button2->setAutoMask( TRUE );    Update_Button2->setPaletteBackgroundPixmap(QImage("img/final_store.jpg"));    QObject::connect(Update_Button2, SIGNAL(clicked()), SLOT(ShowStoreNewsTitle()));    Update_Button3 = new QPushButton( UpdateList, "Update_Button3" );    Update_Button3->setGeometry( QRect( 0, 150, 70, 60 ) );    Update_Button3->setAutoMask( TRUE );    Update_Button3->setPaletteBackgroundPixmap(QImage("img/final_newslist.jpg"));    QObject::connect(Update_Button3, SIGNAL(clicked()), SLOT(NewsShow()));        Update_Button4 = new QPushButton( UpdateList, "Update_Button4" );    Update_Button4->setGeometry( QRect( 0, 220, 70, 60 ) );    Update_Button4->setAutoMask( TRUE );    Update_Button4->setPaletteBackgroundPixmap(QImage("img/final_newsbrowser.jpg"));    QObject::connect(Update_Button4, SIGNAL(clicked()), SLOT(BrowserShow()));    Update_Button5 = new QPushButton( UpdateList, "Update_Button5" );    Update_Button5->setGeometry( QRect( 0, 290, 70, 60 ) );    Update_Button5->setAutoMask( TRUE );    Update_Button5->setPaletteBackgroundPixmap(QImage("img/final_update.jpg"));    Update_textLabel3 = new QLabel( UpdateList, "Update_textLabel3" );    Update_textLabel3->setGeometry( QRect( 70, 8, 561, 30 ) );    Update_listBox2 = new QListBox( UpdateList, "Update_listBox2" );    Update_listBox2->setGeometry( QRect( 70, 40, 560, 390 ) );    Update_listBox2->setPaletteBackgroundColor( QColor( 218, 218, 218 ) );    Update_progressBar2 = new QProgressBar( UpdateList, "Update_progressBar2" );    Update_progressBar2->setGeometry( QRect( 70, 430, 560, 26 ) );///////////////////////////////////////////////////////////news         NewsList = new QFrame( this, "NewsList" );    NewsList->setGeometry( QRect( 0, 0, 640, 480 ) );    NewsList->setPaletteBackgroundColor( QColor( 112, 112, 112 ) );    NewsList->setFrameShape( QFrame::StyledPanel );    NewsList->setFrameShadow( QFrame::Raised );    News_Button1 = new QPushButton( NewsList, "News_Button1" );    News_Button1->setGeometry( QRect( 0, 10, 70, 60 ) );    News_Button1->setAutoMask( TRUE );    News_Button1->setPaletteBackgroundPixmap(QImage("img/final_updatelist.jpg"));    QObject::connect(News_Button1, SIGNAL(clicked()), SLOT(UpdateShow()));    News_Button2 = new QPushButton( NewsList, "News_Button2" );    News_Button2->setGeometry( QRect( 0, 80, 70, 60 ) );    News_Button2->setAutoMask( TRUE );    News_Button2->setPaletteBackgroundPixmap(QImage("img/final_store.jpg"));    QObject::connect(News_Button2, SIGNAL(clicked()), SLOT(ShowStoreNewsTitle()));    News_Button3 = new QPushButton( NewsList, "News_Button3" );    News_Button3->setGeometry( QRect( 0, 150, 70, 60 ) );    News_Button3->setAutoMask( TRUE );    News_Button3->setPaletteBackgroundPixmap(QImage("img/final_newslist.jpg"));    QObject::connect(News_Button3, SIGNAL(clicked()), SLOT(NewsShow()));        News_Button4 = new QPushButton( NewsList, "News_Button4" );    News_Button4->setGeometry( QRect( 0, 220, 70, 60 ) );    News_Button4->setAutoMask( TRUE );    News_Button4->setPaletteBackgroundPixmap(QImage("img/final_newsbrowser.jpg"));    QObject::connect(News_Button4, SIGNAL(clicked()), SLOT(BrowserShow()));    News_Button5 = new QPushButton( NewsList, "News_Button5" );    News_Button5->setGeometry( QRect( 0, 290, 70, 60 ) );    News_Button5->setAutoMask( TRUE );    News_Button5->setPaletteBackgroundPixmap(QImage("img/final_storeadd.jpg"));    QObject::connect(News_Button5, SIGNAL(clicked()), SLOT(StoreSave()));    News_progressBar2 = new QProgressBar( NewsList, "News_progressBar2" );    News_progressBar2->setGeometry( QRect( 70, 430, 560, 26 ) );    News_listView1 = new QListView( NewsList, "News_listView1" );    News_listView1->addColumn("title");    News_listView1->addColumn("link");    News_listView1->addColumn("Date");    News_listView1->setGeometry( QRect( 70, 40, 560, 390 ) );    News_listView1->setPaletteBackgroundColor( QColor( 218, 218, 218 ) );    News_textLabel3 = new QLabel( NewsList, "News_textLabel3" );    News_textLabel3->setGeometry( QRect( 70, 8, 561, 30 ) );///////////////////////////////////////////////////////////store        StoreList = new QFrame( this, "StoreList" );    StoreList->setGeometry( QRect( 0, 0, 640, 480 ) );    StoreList->setPaletteBackgroundColor( QColor( 112, 112, 112 ) );    StoreList->setFrameShape( QFrame::StyledPanel );    StoreList->setFrameShadow( QFrame::Raised );    Store_Button1 = new QPushButton( StoreList, "Store_Button1" );    Store_Button1->setGeometry( QRect( 0, 10, 70, 60 ) );    Store_Button1->setAutoMask( TRUE );    Store_Button1->setPaletteBackgroundPixmap(QImage("img/final_updatelist.jpg"));    QObject::connect(Store_Button1, SIGNAL(clicked()), SLOT(UpdateShow()));    Store_Button2 = new QPushButton( StoreList, "Store_Button2" );    Store_Button2->setGeometry( QRect( 0, 80, 70, 60 ) );    Store_Button2->setAutoMask( TRUE );    Store_Button2->setPaletteBackgroundPixmap(QImage("img/final_store.jpg"));    QObject::connect(Store_Button2, SIGNAL(clicked()), SLOT(ShowStoreNewsTitle()));    Store_Button3 = new QPushButton( StoreList, "Store_Button3" );    Store_Button3->setGeometry( QRect( 0, 150, 70, 60 ) );    Store_Button3->setAutoMask( TRUE );    Store_Button3->setPaletteBackgroundPixmap(QImage("img/final_newslist.jpg"));    QObject::connect(Store_Button3, SIGNAL(clicked()), SLOT(NewsShow()));        Store_Button4 = new QPushButton( StoreList, "Store_Button4" );    Store_Button4->setGeometry( QRect( 0, 220, 70, 60 ) );    Store_Button4->setAutoMask( TRUE );    Store_Button4->setPaletteBackgroundPixmap(QImage("img/final_newsbrowser.jpg"));    QObject::connect(Store_Button4, SIGNAL(clicked()), SLOT(BrowserShow()));    Store_Button5 = new QPushButton( StoreList, "Store_Button5" );    Store_Button5->setGeometry( QRect( 0, 290, 70, 60 ) );    Store_Button5->setAutoMask( TRUE );    Store_Button5->setPaletteBackgroundPixmap(QImage("img/final_storedel.jpg"));    QObject::connect(Store_Button5, SIGNAL(clicked()), SLOT(StoreDel()));    Store_progressBar2 = new QProgressBar( StoreList, "Store_progressBar2" );    Store_progressBar2->setGeometry( QRect( 70, 430, 560, 26 ) );    Store_listView1 = new QListView( StoreList, "Store_listView1" );    Store_listView1->addColumn("title");    Store_listView1->addColumn("link");    Store_listView1->addColumn("Date");    Store_listView1->setGeometry( QRect( 70, 40, 560, 390 ) );    Store_listView1->setPaletteBackgroundColor( QColor( 218, 218, 218 ) );    Store_textLabel3 = new QLabel( StoreList, "Store_textLabel3" );    Store_textLabel3->setGeometry( QRect( 70, 8, 561, 30 ) );///////////////////////////////////////////////////////////Browser       BrowserList = new QFrame( this, "BrowserList" );    BrowserList->setGeometry( QRect( 0, 0, 640, 480 ) );    BrowserList->setPaletteBackgroundColor( QColor( 112, 112, 112 ) );    BrowserList->setFrameShape( QFrame::StyledPanel );    BrowserList->setFrameShadow( QFrame::Raised );    Browser_Button1 = new QPushButton( BrowserList, "Browser_Button1" );    Browser_Button1->setGeometry( QRect( 0, 10, 70, 60 ) );    Browser_Button1->setAutoMask( TRUE );    Browser_Button1->setPaletteBackgroundPixmap(QImage("img/final_updatelist.jpg"));    QObject::connect(Browser_Button1, SIGNAL(clicked()), SLOT(UpdateShow()));    Browser_Button2 = new QPushButton( BrowserList, "Browser_Button2" );    Browser_Button2->setGeometry( QRect( 0, 80, 70, 60 ) );    Browser_Button2->setAutoMask( TRUE );    Browser_Button2->setPaletteBackgroundPixmap(QImage("img/final_store.jpg"));    QObject::connect(Browser_Button2, SIGNAL(clicked()), SLOT(ShowStoreNewsTitle()));    Browser_Button3 = new QPushButton( BrowserList, "Browser_Button3" );    Browser_Button3->setGeometry( QRect( 0, 150, 70, 60 ) );    Browser_Button3->setAutoMask( TRUE );    Browser_Button3->setPaletteBackgroundPixmap(QImage("img/final_newslist.jpg"));    QObject::connect(Browser_Button3, SIGNAL(clicked()), SLOT(NewsShow()));        Browser_Button4 = new QPushButton( BrowserList, "Browser_Button4" );    Browser_Button4->setGeometry( QRect( 0, 220, 70, 60 ) );    Browser_Button4->setAutoMask( TRUE );    Browser_Button4->setPaletteBackgroundPixmap(QImage("img/final_newsbrowser.jpg"));    QObject::connect(Browser_Button4, SIGNAL(clicked()), SLOT(BrowserShow()));    Browser_Button5 = new QPushButton( BrowserList, "Browser_Button5" );    Browser_Button5->setGeometry( QRect( 0, 290, 70, 60 ) );    Browser_Button5->setAutoMask( TRUE );    Browser_Button5->setPaletteBackgroundPixmap(QImage("img/filnal_zoomin.jpg"));    QObject::connect(Browser_Button5, SIGNAL(clicked()), SLOT(BrowserZoomin()));    Browser_Button6 = new QPushButton( BrowserList, "Browser_Button6" );    Browser_Button6->setGeometry( QRect( 0, 360, 70, 60 ) );    Browser_Button6->setAutoMask( TRUE );    Browser_Button6->setPaletteBackgroundPixmap(QImage("img/final_zoomout.jpg"));    QObject::connect(Browser_Button6, SIGNAL(clicked()), SLOT(BrowserZoomout()));    Browser_progressBar2 = new QProgressBar( BrowserList, "Browser_progressBar2" );    Browser_progressBar2->setGeometry( QRect( 70, 430, 560, 26 ) );    Browser_textEdit1 = new QTextEdit( BrowserList, "Browser_textEdit1" );    Browser_textEdit1->setGeometry( QRect( 70, 40, 560, 390 ) );    Browser_textLabel3 = new QLabel( BrowserList, "Browser_textLabel3" );    Browser_textLabel3->setGeometry( QRect( 70, 8, 561, 30 ) );/////////////////////////////////////////gogo	browserint = true;     BrowserList->hide();     NewsList->hide();     UpdateList->hide();     MainFrame->show();     StoreList->hide();    languageChange();    resize( QSize(640, 480).expandedTo(minimumSizeHint()) );    clearWState( WState_Polished );        http = new QHttp;		//QObject::connect(MainButton, SIGNAL(clicked()), SLOT(MainButton_Click()));     //QObject::connect(Update_listBox2, SIGNAL(clicked(QListBoxItem*)), this, SLOT(ShowNewsTitle()));     QObject::connect(Update_listBox2, SIGNAL(returnPressed( QListBoxItem * )), this, SLOT(ShowNewsTitle()));     QObject::connect(Update_listBox2, SIGNAL(doubleClicked( QListBoxItem * )), this, SLOT(ShowNewsTitle()));     QObject::connect(News_listView1, SIGNAL(returnPressed( QListViewItem * )), this, SLOT(ShowNewsContent()));     QObject::connect(News_listView1, SIGNAL(doubleClicked( QListViewItem * )), this, SLOT(ShowNewsContent()));     QObject::connect(Store_listView1, SIGNAL(returnPressed( QListViewItem * )), this, SLOT(ShowNewsContent1()));     QObject::connect(Store_listView1, SIGNAL(doubleClicked( QListViewItem * )), this, SLOT(ShowNewsContent1()));     QObject::connect(Update_Button5, SIGNAL(clicked()),this,SLOT(pressXmlUpdate()));     //QObject::connect(Update_Button2, SIGNAL(clicked()),this,SLOT(ShowStoreNewsTitle()));    // signals and slots connections}/* *  Destroys the object and frees any allocated resources */NewsReader::~NewsReader(){    // no need to delete child widgets, Qt does it all for us}/* *  Sets the strings of the subwidgets using the current *  language. */void NewsReader::languageChange(){    setCaption( tr( "NewsReader" ) );    MainButton->setText( QString::null );    Update_textLabel3->setText(kor("업데이트 목록"));    News_textLabel3->setText(kor("뉴스 목록"));    Store_textLabel3->setText(kor("보관함 목록"));    Browser_textLabel3->setText(kor("뉴스 브라우저 "));}QString NewsReader::toUniString(QString str){    QTextCodec * codec = QTextCodec::codecForName("eucKR");    QString localeStr = codec->toUnicode(str);    return localeStr;}void NewsReader::ShowStoreNewsTitle(){	MainFrame->hide();	BrowserList->hide();      NewsList->hide();      UpdateList->hide();	StoreList->show();    Store_listView1->clear();      QFile f( "Store.txt" );    QString tmp;    QString line;    QListViewItem *thisItem = 0;        if ( f.open(IO_ReadOnly) ) {        QTextStream stream( &f );	 stream.setEncoding(QTextStream::UnicodeUTF8);         while ( !stream.atEnd() ) {              thisItem = new QListViewItem( Store_listView1, thisItem );	              line = stream.readLine(); // line of text excluding '\n'  	   if(line != "")	   {	       QStringList tmpList; 	 	tmpList = tmpList.split("^",line);  	       	       thisItem->setText( 0, tmpList[0]); 	       thisItem->setText( 1, tmpList[1]);	       thisItem->setText( 2, tmpList[2]);		           }         }	f.close();    }  }void NewsReader::StoreDel(){       //////////선택된 아이템의 값을 가져오는 부분//////////      QListViewItemIterator it( Store_listView1 ); 	for(int i = 0 ; i <= 50; i++){Store_progressBar2->setProgress(i);}      while ( it.current() ) {         for ( unsigned int i = 0; i < 3; i++ ){	      if ( it.current()->isSelected() )	       {                Backup[i]=it.current()->text( i );                  }  	  }         ++it;      }       ////////////////////////////////////////////////////////    QFile f( "Store.txt" );    QString tmp;    if ( f.open(IO_ReadOnly) ) {         QTextStream stream( &f ); 	 stream.setEncoding(QTextStream::UnicodeUTF8); 	 tmp = stream.read(); 	 tmp = tmp.remove(Backup[0]+"^"+Backup[1]+"^"+Backup[2]);  //읽어와서 해당부분을 지우고 tmp변수에 저장        tmp = tmp.remove("");	 f.close();     }     f.remove(); //다시 쓰기 위해 파일을 깨끗하게 제거!!    if ( f.open(IO_ReadWrite) ) {        QTextStream stream( &f );	 stream.setEncoding(QTextStream::UnicodeUTF8);	 stream << tmp; //변경된 파일을 씀!	f.close();    }     Store_listView1->clear(); //리플레시~~    ShowStoreNewsTitle();  //리플레시~~	for(int i = 50 ; i <= 100; i++){Store_progressBar2->setProgress(i);} }void NewsReader::StoreSave(){

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -