Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

DlgDownloadReviews.cpp

Go to the documentation of this file.
00001 //
00002 // DlgDownloadReviews.cpp
00003 //
00004 // Copyright (c) Shareaza Development Team, 2002-2005.
00005 // This file is part of SHAREAZA (www.shareaza.com)
00006 //
00007 // Shareaza is free software; you can redistribute it
00008 // and/or modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2 of
00010 // the License, or (at your option) any later version.
00011 //
00012 // Shareaza is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with Shareaza; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 //
00021 
00022 #include "StdAfx.h"
00023 #include "Shareaza.h"
00024 #include "LiveList.h"
00025 #include "DlgDownloadReviews.h"
00026 #include "Settings.h"
00027 #include "Download.h"
00028 #include "CoolInterface.h"
00029 #include "Skin.h"
00030 #include "Downloads.h"
00031 #include "Transfers.h"
00032 
00033 
00034 
00035 IMPLEMENT_DYNAMIC(CDownloadReviewDlg, CSkinDialog)
00036 
00037 BEGIN_MESSAGE_MAP(CDownloadReviewDlg, CSkinDialog)
00038 END_MESSAGE_MAP()
00039 
00040 
00042 // CDownloadReviewDlg dialog
00043 
00044 CDownloadReviewDlg::CDownloadReviewDlg(CWnd* pParent, CDownload* pDownload) : CSkinDialog( CDownloadReviewDlg::IDD, pParent )
00045 {
00046         m_pDownload = pDownload;
00047 }
00048 
00049 CDownloadReviewDlg::~CDownloadReviewDlg()
00050 {
00051 
00052 }
00053 
00054 void CDownloadReviewDlg::DoDataExchange(CDataExchange* pDX)
00055 {
00056         CSkinDialog::DoDataExchange(pDX);
00057         DDX_Control(pDX, IDC_REVIEWS, m_wndReviews);
00058         DDX_Text(pDX, IDC_REVIEW_FILENAME, m_sReviewFileName);
00059 
00060 }
00061 
00063 // CDownloadReviewDlg message handlers
00064 
00065 BOOL CDownloadReviewDlg::OnInitDialog() 
00066 {
00067         CSkinDialog::OnInitDialog();
00068 
00069         CRect rcList;
00070         m_wndReviews.GetClientRect( &rcList );
00071         rcList.right -= GetSystemMetrics( SM_CXVSCROLL );
00072         
00073         m_wndReviews.SetImageList( &CoolInterface.m_pImages, LVSIL_SMALL );
00074         
00075         m_wndReviews.InsertColumn( 0, _T("User"), LVCFMT_LEFT, 100, -1 );
00076         m_wndReviews.InsertColumn( 1, _T("Rating"), LVCFMT_CENTER, 90, 0 );
00077         m_wndReviews.InsertColumn( 2, _T("Comments"), LVCFMT_CENTER, rcList.right- 100 - 80, 1 );
00078         m_wndReviews.InsertColumn( 3, _T("Order"), LVCFMT_CENTER, 0, 2 );
00079         Skin.Translate( _T("CReviewList"), m_wndReviews.GetHeaderCtrl() );
00080         
00081         m_wndReviews.SendMessage( LVM_SETEXTENDEDLISTVIEWSTYLE,
00082                 LVS_EX_FULLROWSELECT|LVS_EX_LABELTIP, LVS_EX_FULLROWSELECT|LVS_EX_LABELTIP );
00083         m_wndReviews.EnableToolTips();
00084         
00085         // Sort by order added- first at the top
00086         CLiveList::Sort( &m_wndReviews, 3, FALSE );
00087         CLiveList::Sort( &m_wndReviews, 3, FALSE );
00088 
00089 
00090         CLiveList pReviews( 4 );
00091         int nIndex = 1;
00092         // Lock while we're loading the list. (In case the download is destroyed)
00093         CSingleLock pLock( &Transfers.m_pSection, TRUE );
00094         
00095         if ( ! m_pDownload ) return FALSE;
00096 
00097         m_sReviewFileName = m_pDownload->m_sRemoteName;
00098 
00099         CDownloadReview* pReview = m_pDownload->GetFirstReview();
00100 
00101         while ( pReview )
00102         {
00103                 CLiveItem* pItem = pReviews.Add( pReview );
00104         
00105                 // Client picture
00106                 // Note: We don't have pictures yet. Currently, it uses a star for a G2 
00107                 // review, and a little person for everyone else
00108                 switch ( pReview->m_nUserPicture )
00109                 {
00110                 case 0:
00111                         pItem->m_nImage = CoolInterface.ImageForID( ID_TOOLS_WIZARD );
00112                         break;
00113                 case 1:
00114                         pItem->m_nImage = CoolInterface.ImageForID( ID_TOOLS_PROFILE );
00115                         break;
00116                 case 2:
00117                         pItem->m_nImage = CoolInterface.ImageForID( ID_TOOLS_WIZARD );
00118                         break;
00119                 case 3:
00120                         pItem->m_nImage = CoolInterface.ImageForID( ID_TOOLS_PROFILE );
00121                         break;
00122                 default:
00123                         pItem->m_nImage = CoolInterface.ImageForID( ID_TOOLS_PROFILE );
00124                 }
00125                 
00126                 pItem->Set( 0, pReview->m_sUserName );
00127 
00128                 int nRating = min( pReview->m_nFileRating, 6 );
00129                 nRating = max ( nRating, 0 );
00130                 CString strRating;
00131                 LoadString( strRating, IDS_RATING_NORATING + nRating );
00132                 pItem->Set( 1, strRating );
00133 
00134                 
00135                 pItem->Set( 2, pReview->m_sFileComments );
00136                 pItem->Format( 3, _T("%i"), nIndex );
00137                 
00138 
00139                 nIndex++;
00140                 pReview = pReview->m_pNext;
00141         }
00142 
00143         pLock.Unlock();
00144 
00145         //m_wndReviews.SetFont( &theApp.m_gdiFontBold );
00146 
00147         pReviews.Apply( &m_wndReviews, TRUE );
00148 
00149         // Set window icon
00150         SkinMe( NULL, IDR_MEDIAFRAME );
00151 
00152         UpdateData( FALSE );
00153         
00154         return TRUE;
00155 }
00156 
00157 
00158 
00159 void CDownloadReviewDlg::OnOK() 
00160 {
00161         UpdateData( TRUE );
00162         
00163         CSkinDialog::OnOK();
00164 }
00165 

Generated on Thu Dec 15 10:39:39 2005 for Shareaza 2.2.1.0 by  doxygen 1.4.2