2007-11-14 22:18:48 -05:00
/****************************************************************
* RetroShare is distributed under the following license :
*
2007-11-18 18:35:53 -05:00
* Copyright ( C ) 2006 , 2007 RetroShare Team
2007-11-14 22:18:48 -05:00
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; either version 2
* of the License , or ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 51 Franklin Street , Fifth Floor ,
* Boston , MA 02110 - 1301 , USA .
2008-11-25 20:19:09 -05:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2010-07-23 14:52:58 -04:00
# include <QMessageBox>
# include <QCloseEvent>
# include <QClipboard>
# include <QTextCodec>
# include <QPrintDialog>
# include <QPrinter>
# include <QFileDialog>
# include <QTextList>
# include <QColorDialog>
# include <QTextDocumentFragment>
# include <QTimer>
2008-11-25 20:19:09 -05:00
# include "rshare.h"
2010-05-23 15:13:41 -04:00
# include "MessageComposer.h"
2008-11-25 20:19:09 -05:00
2008-01-25 03:49:40 -05:00
# include "rsiface/rsiface.h"
# include "rsiface/rspeers.h"
2008-02-04 12:55:59 -05:00
# include "rsiface/rsmsgs.h"
2008-01-25 03:49:40 -05:00
2010-06-07 20:42:15 -04:00
# include "gui/RetroShareLink.h"
2009-12-14 12:13:10 -05:00
# include <gui/settings/rsharesettings.h>
2010-01-20 16:39:27 -05:00
# include "gui/feeds/AttachFileItem.h"
2010-01-25 09:03:38 -05:00
# include "textformat.h"
2009-07-10 19:48:20 -04:00
# include "util/misc.h"
2008-03-24 21:41:01 -04:00
2008-11-25 20:19:09 -05:00
/** Constructor */
2010-05-25 05:32:14 -04:00
MessageComposer : : MessageComposer ( QWidget * parent , Qt : : WFlags flags )
: QMainWindow ( parent , flags ) , mCheckAttachment ( true )
2008-11-25 20:19:09 -05:00
{
2010-01-25 09:03:38 -05:00
/* Invoke the Qt Designer generated object setup routine */
ui . setupUi ( this ) ;
2010-06-14 14:16:32 -04:00
m_nBox = - 1 ; // not defined
2010-01-25 09:03:38 -05:00
setupFileActions ( ) ;
setupEditActions ( ) ;
setupViewActions ( ) ;
setupInsertActions ( ) ;
2008-03-24 21:41:01 -04:00
2010-05-20 17:53:27 -04:00
Settings - > loadWidgetInformation ( this ) ;
2010-01-25 09:03:38 -05:00
setAttribute ( Qt : : WA_DeleteOnClose , true ) ;
// connect up the buttons.
connect ( ui . actionSend , SIGNAL ( triggered ( bool ) ) , this , SLOT ( sendMessage ( ) ) ) ;
//connect( ui.actionReply, SIGNAL( triggered (bool)), this, SLOT( replyMessage( ) ) );
connect ( ui . boldbtn , SIGNAL ( clicked ( ) ) , this , SLOT ( textBold ( ) ) ) ;
connect ( ui . underlinebtn , SIGNAL ( clicked ( ) ) , this , SLOT ( textUnderline ( ) ) ) ;
connect ( ui . italicbtn , SIGNAL ( clicked ( ) ) , this , SLOT ( textItalic ( ) ) ) ;
connect ( ui . colorbtn , SIGNAL ( clicked ( ) ) , this , SLOT ( textColor ( ) ) ) ;
connect ( ui . imagebtn , SIGNAL ( clicked ( ) ) , this , SLOT ( addImage ( ) ) ) ;
//connect(ui.linkbtn, SIGNAL(clicked()), this, SLOT(insertLink()));
connect ( ui . actionContactsView , SIGNAL ( triggered ( ) ) , this , SLOT ( toggleContacts ( ) ) ) ;
2010-05-25 09:22:42 -04:00
connect ( ui . actionSaveas , SIGNAL ( triggered ( ) ) , this , SLOT ( saveasDraft ( ) ) ) ;
2010-01-25 09:03:38 -05:00
connect ( ui . actionAttach , SIGNAL ( triggered ( ) ) , this , SLOT ( attachFile ( ) ) ) ;
2010-05-29 15:05:10 -04:00
connect ( ui . filterPatternLineEdit , SIGNAL ( textChanged ( const QString & ) ) , this , SLOT ( filterRegExpChanged ( ) ) ) ;
connect ( ui . clearButton , SIGNAL ( clicked ( ) ) , this , SLOT ( clearFilter ( ) ) ) ;
2010-07-07 19:03:34 -04:00
connect ( ui . titleEdit , SIGNAL ( textChanged ( const QString & ) ) , this , SLOT ( titleChanged ( ) ) ) ;
2010-01-25 09:03:38 -05:00
connect ( ui . sizeincreaseButton , SIGNAL ( clicked ( ) ) , this , SLOT ( fontSizeIncrease ( ) ) ) ;
connect ( ui . sizedecreaseButton , SIGNAL ( clicked ( ) ) , this , SLOT ( fontSizeDecrease ( ) ) ) ;
2010-01-25 15:16:54 -05:00
connect ( ui . actionQuote , SIGNAL ( triggered ( ) ) , this , SLOT ( blockQuote ( ) ) ) ;
2010-01-25 09:03:38 -05:00
connect ( ui . codeButton , SIGNAL ( clicked ( ) ) , this , SLOT ( toggleCode ( ) ) ) ;
2010-01-25 10:36:24 -05:00
2010-01-25 15:16:54 -05:00
connect ( ui . msgText , SIGNAL ( checkSpellingChanged ( bool ) ) , this , SLOT ( spellChecking ( bool ) ) ) ;
2008-03-24 13:36:17 -04:00
2010-01-25 09:03:38 -05:00
connect ( ui . msgText , SIGNAL ( currentCharFormatChanged ( const QTextCharFormat & ) ) ,
2008-11-25 20:19:09 -05:00
this , SLOT ( currentCharFormatChanged ( const QTextCharFormat & ) ) ) ;
2010-01-25 09:03:38 -05:00
connect ( ui . msgText , SIGNAL ( cursorPositionChanged ( ) ) ,
2008-03-24 13:36:17 -04:00
this , SLOT ( cursorPositionChanged ( ) ) ) ;
2008-03-24 21:41:01 -04:00
2008-11-25 20:19:09 -05:00
connect ( ui . msgText - > document ( ) , SIGNAL ( modificationChanged ( bool ) ) ,
actionSave , SLOT ( setEnabled ( bool ) ) ) ;
connect ( ui . msgText - > document ( ) , SIGNAL ( modificationChanged ( bool ) ) ,
this , SLOT ( setWindowModified ( bool ) ) ) ;
connect ( ui . msgText - > document ( ) , SIGNAL ( undoAvailable ( bool ) ) ,
actionUndo , SLOT ( setEnabled ( bool ) ) ) ;
connect ( ui . msgText - > document ( ) , SIGNAL ( redoAvailable ( bool ) ) ,
actionRedo , SLOT ( setEnabled ( bool ) ) ) ;
setWindowModified ( ui . msgText - > document ( ) - > isModified ( ) ) ;
actionSave - > setEnabled ( ui . msgText - > document ( ) - > isModified ( ) ) ;
actionUndo - > setEnabled ( ui . msgText - > document ( ) - > isUndoAvailable ( ) ) ;
actionRedo - > setEnabled ( ui . msgText - > document ( ) - > isRedoAvailable ( ) ) ;
connect ( actionUndo , SIGNAL ( triggered ( ) ) , ui . msgText , SLOT ( undo ( ) ) ) ;
connect ( actionRedo , SIGNAL ( triggered ( ) ) , ui . msgText , SLOT ( redo ( ) ) ) ;
actionCut - > setEnabled ( false ) ;
actionCopy - > setEnabled ( false ) ;
connect ( actionCut , SIGNAL ( triggered ( ) ) , ui . msgText , SLOT ( cut ( ) ) ) ;
connect ( actionCopy , SIGNAL ( triggered ( ) ) , ui . msgText , SLOT ( copy ( ) ) ) ;
connect ( actionPaste , SIGNAL ( triggered ( ) ) , ui . msgText , SLOT ( paste ( ) ) ) ;
connect ( ui . msgText , SIGNAL ( copyAvailable ( bool ) ) , actionCut , SLOT ( setEnabled ( bool ) ) ) ;
connect ( ui . msgText , SIGNAL ( copyAvailable ( bool ) ) , actionCopy , SLOT ( setEnabled ( bool ) ) ) ;
2008-03-24 21:41:01 -04:00
connect ( QApplication : : clipboard ( ) , SIGNAL ( dataChanged ( ) ) , this , SLOT ( clipboardDataChanged ( ) ) ) ;
2007-11-14 22:18:48 -05:00
2010-05-25 05:32:14 -04:00
connect ( ui . msgSendList , SIGNAL ( itemChanged ( QTreeWidgetItem * , int ) ) , this , SLOT ( togglePersonItem ( QTreeWidgetItem * , int ) ) ) ;
2010-01-25 09:03:38 -05:00
connect ( ui . msgFileList , SIGNAL ( itemChanged ( QTreeWidgetItem * , int ) ) ,
this , SLOT ( toggleRecommendItem ( QTreeWidgetItem * , int ) ) ) ;
2007-11-14 22:18:48 -05:00
2010-01-25 09:03:38 -05:00
/* hide the Tree +/- */
ui . msgSendList - > setRootIsDecorated ( false ) ;
ui . msgFileList - > setRootIsDecorated ( false ) ;
2007-11-17 21:24:03 -05:00
2010-01-25 09:03:38 -05:00
/* to hide the header */
//ui.msgSendList->header()->hide();
2010-07-12 10:01:29 -04:00
/* sort send list by name ascending */
ui . msgSendList - > sortItems ( 0 , Qt : : AscendingOrder ) ;
2008-11-25 20:19:09 -05:00
QActionGroup * grp = new QActionGroup ( this ) ;
connect ( grp , SIGNAL ( triggered ( QAction * ) ) , this , SLOT ( textAlign ( QAction * ) ) ) ;
actionAlignLeft = new QAction ( QIcon ( " :/images/textedit/textleft.png " ) , tr ( " &Left " ) , grp ) ;
actionAlignLeft - > setShortcut ( Qt : : CTRL + Qt : : Key_L ) ;
actionAlignLeft - > setCheckable ( true ) ;
actionAlignCenter = new QAction ( QIcon ( " :/images/textedit/textcenter.png " ) , tr ( " C&enter " ) , grp ) ;
actionAlignCenter - > setShortcut ( Qt : : CTRL + Qt : : Key_E ) ;
actionAlignCenter - > setCheckable ( true ) ;
actionAlignRight = new QAction ( QIcon ( " :/images/textedit/textright.png " ) , tr ( " &Right " ) , grp ) ;
actionAlignRight - > setShortcut ( Qt : : CTRL + Qt : : Key_R ) ;
actionAlignRight - > setCheckable ( true ) ;
actionAlignJustify = new QAction ( QIcon ( " :/images/textedit/textjustify.png " ) , tr ( " &Justify " ) , grp ) ;
actionAlignJustify - > setShortcut ( Qt : : CTRL + Qt : : Key_J ) ;
2008-03-24 13:36:17 -04:00
actionAlignJustify - > setCheckable ( true ) ;
2010-05-25 18:30:25 -04:00
setupFormatActions ( ) ;
2010-05-25 13:18:12 -04:00
/*ui.comboStyle->addItem("Standard");
2008-11-25 20:19:09 -05:00
ui . comboStyle - > addItem ( " Bullet List (Disc) " ) ;
ui . comboStyle - > addItem ( " Bullet List (Circle) " ) ;
ui . comboStyle - > addItem ( " Bullet List (Square) " ) ;
ui . comboStyle - > addItem ( " Ordered List (Decimal) " ) ;
ui . comboStyle - > addItem ( " Ordered List (Alpha lower) " ) ;
2010-05-25 13:18:12 -04:00
ui . comboStyle - > addItem ( " Ordered List (Alpha upper) " ) ; */
//connect(ui.comboStyle, SIGNAL(activated(int)),this, SLOT(textStyle(int)));
connect ( ui . comboStyle , SIGNAL ( activated ( int ) ) , this , SLOT ( changeFormatType ( int ) ) ) ;
2008-03-24 13:36:17 -04:00
connect ( ui . comboFont , SIGNAL ( activated ( const QString & ) ) , this , SLOT ( textFamily ( const QString & ) ) ) ;
2008-11-25 20:19:09 -05:00
ui . comboSize - > setEditable ( true ) ;
QFontDatabase db ;
foreach ( int size , db . standardSizes ( ) )
ui . comboSize - > addItem ( QString : : number ( size ) ) ;
connect ( ui . comboSize , SIGNAL ( activated ( const QString & ) ) , this , SLOT ( textSize ( const QString & ) ) ) ;
2008-03-24 13:36:17 -04:00
ui . comboSize - > setCurrentIndex ( ui . comboSize - > findText ( QString : : number ( QApplication : : font ( ) . pointSize ( ) ) ) ) ;
2010-01-25 09:03:38 -05:00
ui . textalignmentbtn - > setIcon ( QIcon ( QString ( " :/images/textedit/textcenter.png " ) ) ) ;
2008-03-24 13:36:17 -04:00
2008-11-25 20:19:09 -05:00
QMenu * alignmentmenu = new QMenu ( ) ;
alignmentmenu - > addAction ( actionAlignLeft ) ;
alignmentmenu - > addAction ( actionAlignCenter ) ;
alignmentmenu - > addAction ( actionAlignRight ) ;
alignmentmenu - > addAction ( actionAlignJustify ) ;
2008-03-24 13:36:17 -04:00
ui . textalignmentbtn - > setMenu ( alignmentmenu ) ;
2009-07-10 19:48:20 -04:00
QPixmap pxm ( 24 , 24 ) ;
pxm . fill ( Qt : : black ) ;
ui . colorbtn - > setIcon ( pxm ) ;
/* Set header resize modes and initial section sizes */
ui . msgFileList - > setColumnCount ( 5 ) ;
2010-07-15 07:25:34 -04:00
ui . msgFileList - > setColumnHidden ( 4 , true ) ;
2009-07-10 19:48:20 -04:00
QHeaderView * _smheader = ui . msgFileList - > header ( ) ;
_smheader - > resizeSection ( 0 , 200 ) ;
_smheader - > resizeSection ( 1 , 60 ) ;
_smheader - > resizeSection ( 2 , 60 ) ;
_smheader - > resizeSection ( 3 , 220 ) ;
_smheader - > resizeSection ( 4 , 10 ) ;
2010-01-25 09:03:38 -05:00
QPalette palette = QApplication : : palette ( ) ;
codeBackground = palette . color ( QPalette : : Active , QPalette : : Midlight ) ;
2010-05-29 15:05:10 -04:00
ui . clearButton - > hide ( ) ;
2010-01-16 13:03:35 -05:00
2010-07-12 10:01:29 -04:00
/* set focus to subject */
ui . titleEdit - > setFocus ( ) ;
2008-11-25 20:19:09 -05:00
/* Hide platform specific features */
# ifdef Q_WS_WIN
# endif
}
2010-06-17 13:39:32 -04:00
/*static*/ void MessageComposer : : msgFriend ( std : : string id )
{
2010-07-15 07:25:34 -04:00
// std::cerr << "MessageComposer::msgfriend()" << std::endl;
2010-06-17 13:39:32 -04:00
rsicontrol - > ClearInMsg ( ) ;
rsicontrol - > SetInMsg ( id , true ) ;
std : : list < std : : string > sslIds ;
rsPeers - > getSSLChildListOfGPGId ( id , sslIds ) ;
for ( std : : list < std : : string > : : iterator it = sslIds . begin ( ) ; it ! = sslIds . end ( ) ; it + + ) {
//put all sslChilds in message list
rsicontrol - > SetInMsg ( * it , true ) ;
}
/* create a message */
MessageComposer * pMsgDialog = new MessageComposer ( ) ;
pMsgDialog - > newMsg ( ) ;
pMsgDialog - > show ( ) ;
/* window will destroy itself! */
}
2010-07-15 07:25:34 -04:00
void MessageComposer : : recommendFriend ( std : : list < std : : string > & peerids )
{
// std::cerr << "MessageComposer::recommendFriend()" << std::endl;
if ( peerids . size ( ) = = 0 ) {
return ;
}
// rsicontrol -> ClearInMsg();
// rsicontrol -> SetInMsg(id, true);
/* create a message */
MessageComposer * pMsgDialog = new MessageComposer ( ) ;
pMsgDialog - > newMsg ( ) ;
pMsgDialog - > setWindowTitle ( tr ( " Compose: " ) + tr ( " Friend Recommendation " ) ) ;
pMsgDialog - > insertTitleText ( tr ( " Friend Recommendation(s) " ) . toStdString ( ) ) ;
2010-07-16 16:20:46 -04:00
std : : string sMsgText = tr ( " I recommend a good friend of me, you can trust him too when you trust me. <br> Copy person link and paste to Friends list " ) . toStdString ( ) ;
2010-07-15 07:25:34 -04:00
sMsgText + = " <br><br> " ;
/* process peer ids */
std : : list < FileInfo > files_info ;
std : : list < std : : string > : : iterator peerid ;
for ( peerid = peerids . begin ( ) ; peerid ! = peerids . end ( ) ; peerid + + ) {
RsPeerDetails detail ;
if ( rsPeers - > getPeerDetails ( * peerid , detail ) = = false ) {
std : : cerr < < " MessageComposer::recommendFriend() Couldn't find peer id " < < * peerid < < std : : endl ;
continue ;
}
RetroShareLink link ( QString : : fromStdString ( detail . name ) , QString : : fromStdString ( detail . id ) ) ;
if ( link . valid ( ) = = false | | link . type ( ) ! = RetroShareLink : : TYPE_PERSON ) {
continue ;
}
sMsgText + = link . toHtmlFull ( ) . toStdString ( ) + " <br> " ;
// FileInfo info;
// info.fname = link.name().toStdString();
// info.hash = link.hash().toStdString();
// info.inRecommend = true;
// files_info.push_back(info);
}
pMsgDialog - > insertMsgText ( sMsgText ) ;
// pMsgDialog->insertFileList(files_info);
pMsgDialog - > show ( ) ;
/* window will destroy itself! */
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : closeEvent ( QCloseEvent * event )
2007-11-18 18:35:53 -05:00
{
2010-05-25 05:32:14 -04:00
bool bClose = true ;
/* Save to Drafts? */
if ( ui . msgText - > document ( ) - > isModified ( ) ) {
QMessageBox : : StandardButton ret ;
ret = QMessageBox : : warning ( this , tr ( " Save Message " ) ,
tr ( " Message has not been Sent. \n "
" Do you want to save message to draft box? " ) ,
QMessageBox : : Yes | QMessageBox : : No | QMessageBox : : Cancel ) ;
switch ( ret ) {
case QMessageBox : : Yes :
sendMessage_internal ( true ) ;
break ;
case QMessageBox : : Cancel :
bClose = false ;
break ;
default :
break ;
}
}
2009-02-11 13:43:37 -05:00
2010-05-25 05:32:14 -04:00
if ( bClose ) {
Settings - > saveWidgetInformation ( this ) ;
2009-02-11 13:43:37 -05:00
2010-05-25 05:32:14 -04:00
//=== uncheck all repecient's boxes =======
QTreeWidget * sendWidget = ui . msgSendList ;
2008-03-31 17:02:12 -04:00
2010-05-25 05:32:14 -04:00
for ( int i = 0 ; i < sendWidget - > topLevelItemCount ( ) ; + + i )
sendWidget - > topLevelItem ( i ) - > setCheckState ( 0 , Qt : : Unchecked ) ;
2008-03-31 17:02:12 -04:00
2010-05-25 05:32:14 -04:00
QMainWindow : : closeEvent ( event ) ;
} else {
event - > ignore ( ) ;
2008-03-31 17:02:12 -04:00
}
2007-11-18 18:35:53 -05:00
}
2007-11-14 22:18:48 -05:00
2010-05-23 15:13:41 -04:00
void MessageComposer : : insertSendList ( )
2007-11-14 22:18:48 -05:00
{
2008-01-25 03:49:40 -05:00
if ( ! rsPeers )
{
/* not ready yet! */
return ;
}
std : : list < std : : string > peers ;
std : : list < std : : string > : : iterator it ;
rsPeers - > getFriendList ( peers ) ;
2007-11-14 22:18:48 -05:00
/* get a link to the table */
QTreeWidget * sendWidget = ui . msgSendList ;
QList < QTreeWidgetItem * > items ;
2008-01-25 03:49:40 -05:00
for ( it = peers . begin ( ) ; it ! = peers . end ( ) ; it + + )
2007-11-14 22:18:48 -05:00
{
2008-01-25 03:49:40 -05:00
RsPeerDetails detail ;
if ( ! rsPeers - > getPeerDetails ( * it , detail ) )
2007-11-14 22:18:48 -05:00
{
2008-01-25 03:49:40 -05:00
continue ; /* BAD */
2007-11-14 22:18:48 -05:00
}
2008-01-25 03:49:40 -05:00
2007-11-14 22:18:48 -05:00
/* make a widget per friend */
QTreeWidgetItem * item = new QTreeWidgetItem ( ( QTreeWidget * ) 0 ) ;
/* add all the labels */
/* (0) Person */
2010-01-18 17:50:14 -05:00
item - > setText ( 0 , QString : : fromStdString ( detail . name ) + " - " + QString : : fromStdString ( detail . location ) ) ;
2010-01-30 17:00:50 -05:00
if ( detail . state & RS_PEER_STATE_CONNECTED ) {
item - > setTextColor ( 0 , ( Qt : : darkBlue ) ) ;
}
2007-11-14 22:18:48 -05:00
/* () Org */
2008-01-26 08:08:28 -05:00
//item -> setText(1, QString::fromStdString(detail.org));
2007-11-14 22:18:48 -05:00
/* () Location */
2008-01-26 08:08:28 -05:00
//item -> setText(2, QString::fromStdString(detail.location));
2007-11-14 22:18:48 -05:00
/* () Country */
2008-01-26 08:08:28 -05:00
//item -> setText(3, QString::fromStdString(detail.email));
2008-01-25 03:49:40 -05:00
/* () Id */
2008-01-26 08:08:28 -05:00
item - > setText ( 1 , QString : : fromStdString ( detail . id ) ) ;
2007-11-14 22:18:48 -05:00
item - > setFlags ( Qt : : ItemIsUserCheckable | Qt : : ItemIsEnabled ) ;
2008-01-25 03:49:40 -05:00
item - > setCheckState ( 0 , Qt : : Unchecked ) ;
2008-02-04 12:55:59 -05:00
if ( rsicontrol - > IsInMsg ( detail . id ) )
2007-11-14 22:18:48 -05:00
{
item - > setCheckState ( 0 , Qt : : Checked ) ;
}
else
{
item - > setCheckState ( 0 , Qt : : Unchecked ) ;
}
/* add to the list */
items . append ( item ) ;
}
2010-05-29 15:05:10 -04:00
if ( ui . filterPatternLineEdit - > text ( ) . isEmpty ( ) = = false ) {
FilterItems ( ) ;
}
2007-11-14 22:18:48 -05:00
2008-01-25 03:49:40 -05:00
/* remove old items ??? */
sendWidget - > clear ( ) ;
2008-01-26 08:08:28 -05:00
sendWidget - > setColumnCount ( 1 ) ;
2008-01-25 03:49:40 -05:00
2007-11-14 22:18:48 -05:00
/* add the items in! */
sendWidget - > insertTopLevelItems ( 0 , items ) ;
sendWidget - > update ( ) ; /* update display */
}
/* Utility Fns */
/***
RsCertId getSenderRsCertId ( QTreeWidgetItem * i )
{
RsCertId id = ( i - > text ( 3 ) ) . toStdString ( ) ;
return id ;
}
* * */
/* get the list of peers from the RsIface. */
2010-05-23 15:13:41 -04:00
void MessageComposer : : insertFileList ( const std : : list < DirDetails > & dir_info )
2010-04-26 17:11:19 -04:00
{
std : : list < FileInfo > files_info ;
std : : list < DirDetails > : : const_iterator it ;
/* convert dir_info to files_info */
for ( it = dir_info . begin ( ) ; it ! = dir_info . end ( ) ; it + + )
{
FileInfo info ;
info . fname = it - > name ;
info . hash = it - > hash ;
info . rank = 0 ; //it->rank ;
info . size = it - > count ;
info . inRecommend = true ;
files_info . push_back ( info ) ;
}
insertFileList ( files_info ) ;
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : insertFileList ( const std : : list < FileInfo > & files_info )
2007-11-14 22:18:48 -05:00
{
2009-05-17 15:38:42 -04:00
// rsiface->lockData(); /* Lock Interface */
2007-11-14 22:18:48 -05:00
2009-05-17 15:38:42 -04:00
_recList . clear ( ) ;
2007-11-14 22:18:48 -05:00
2009-05-17 15:38:42 -04:00
// const std::list<FileInfo> &recList = rsiface->getRecommendList();
2010-04-26 17:11:19 -04:00
std : : list < FileInfo > : : const_iterator it ;
2007-11-14 22:18:48 -05:00
/* get a link to the table */
QTreeWidget * tree = ui . msgFileList ;
2010-04-26 17:11:19 -04:00
tree - > clear ( ) ;
tree - > setColumnCount ( 5 ) ;
2007-11-14 22:18:48 -05:00
2009-05-17 15:38:42 -04:00
QList < QTreeWidgetItem * > items ;
for ( it = files_info . begin ( ) ; it ! = files_info . end ( ) ; it + + )
2007-11-14 22:18:48 -05:00
{
2010-04-26 17:11:19 -04:00
_recList . push_back ( * it ) ;
2009-05-17 15:38:42 -04:00
2007-11-14 22:18:48 -05:00
/* make a widget per person */
2009-05-17 15:38:42 -04:00
QTreeWidgetItem * item = new QTreeWidgetItem ( ( QTreeWidget * ) 0 ) ;
2007-11-14 22:18:48 -05:00
2010-04-26 17:11:19 -04:00
item - > setText ( 0 , QString : : fromStdString ( it - > fname ) ) ; /* (0) Filename */
item - > setText ( 1 , misc : : friendlyUnit ( it - > size ) ) ; /* (1) Size */
2009-08-10 14:55:49 -04:00
item - > setText ( 2 , QString : : number ( 0 ) ) ; //it->rank));
2009-05-17 15:38:42 -04:00
item - > setText ( 3 , QString : : fromStdString ( it - > hash ) ) ;
item - > setFlags ( Qt : : ItemIsUserCheckable | Qt : : ItemIsEnabled ) ;
2010-04-26 17:11:19 -04:00
item - > setCheckState ( 0 , it - > inRecommend ? Qt : : Checked : Qt : : Unchecked ) ;
2007-11-14 22:18:48 -05:00
/* add to the list */
items . append ( item ) ;
}
/* add the items in! */
tree - > insertTopLevelItems ( 0 , items ) ;
2009-05-17 15:38:42 -04:00
// rsiface->unlockData(); /* UnLock Interface */
2007-11-14 22:18:48 -05:00
tree - > update ( ) ; /* update display */
}
2010-07-07 19:03:34 -04:00
/* title changed */
void MessageComposer : : titleChanged ( )
2007-11-14 22:18:48 -05:00
{
2010-07-07 19:03:34 -04:00
calculateTitle ( ) ;
ui . msgText - > document ( ) - > setModified ( true ) ;
}
2010-01-21 11:35:00 -05:00
2010-07-07 19:03:34 -04:00
void MessageComposer : : calculateTitle ( )
{
setWindowTitle ( tr ( " Compose: " ) + ui . titleEdit - > text ( ) ) ;
}
2010-01-21 11:35:00 -05:00
2010-07-07 19:03:34 -04:00
void MessageComposer : : newMsg ( std : : string msgId /*= ""*/ )
{
/* clear all */
2010-05-25 05:32:14 -04:00
ui . msgText - > setText ( " " ) ;
2007-11-14 22:18:48 -05:00
2010-05-25 05:32:14 -04:00
/* worker fns */
insertSendList ( ) ;
m_sMsgId = msgId ;
2010-06-14 14:16:32 -04:00
m_nBox = - 1 ; // not defined
2010-05-25 05:32:14 -04:00
if ( m_sMsgId . empty ( ) = = false ) {
// fill existing message
MessageInfo msgInfo ;
if ( ! rsMsgs - > getMessage ( m_sMsgId , msgInfo ) ) {
std : : cerr < < " MessageComposer::newMsg() Couldn't find Msg " < < std : : endl ;
m_sMsgId . clear ( ) ;
return ;
}
2010-06-14 14:16:32 -04:00
m_nBox = msgInfo . msgflags & RS_MSG_BOXMASK ;
2010-05-25 05:32:14 -04:00
insertTitleText ( QString : : fromStdWString ( msgInfo . title ) . toStdString ( ) ) ;
2007-11-14 22:18:48 -05:00
2010-05-25 05:32:14 -04:00
insertMsgText ( QString : : fromStdWString ( msgInfo . msg ) . toStdString ( ) ) ;
insertFileList ( msgInfo . files ) ;
std : : list < std : : string > : : iterator to ;
for ( to = msgInfo . msgto . begin ( ) ; to ! = msgInfo . msgto . end ( ) ; to + + ) {
addRecipient ( * to ) ;
}
ui . msgText - > document ( ) - > setModified ( false ) ;
2010-07-07 19:03:34 -04:00
} else {
insertTitleText ( tr ( " No Title " ) . toStdString ( ) ) ;
2010-05-25 05:32:14 -04:00
}
2010-07-07 19:03:34 -04:00
calculateTitle ( ) ;
2007-11-14 22:18:48 -05:00
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : insertTitleText ( std : : string title )
2007-11-14 22:18:48 -05:00
{
ui . titleEdit - > setText ( QString : : fromStdString ( title ) ) ;
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : insertPastedText ( std : : string msg )
2008-09-08 08:41:46 -04:00
{
2010-05-25 05:32:14 -04:00
std : : string : : size_type i = 0 ;
while ( ( i = msg . find_first_of ( ' \n ' , i + 1 ) ) < msg . size ( ) )
msg . replace ( i , 1 , std : : string ( " \n <BR/>> " ) ) ;
2008-09-08 08:41:46 -04:00
2010-05-25 05:32:14 -04:00
ui . msgText - > setHtml ( QString ( " <HTML><font color= \" blue \" > " ) + QString : : fromStdString ( std : : string ( " > " ) + msg ) + " </font><br/><br/></HTML> " ) ;
ui . msgText - > setFocus ( Qt : : OtherFocusReason ) ;
QTextCursor c = ui . msgText - > textCursor ( ) ;
c . movePosition ( QTextCursor : : End ) ;
ui . msgText - > setTextCursor ( c ) ;
ui . msgText - > document ( ) - > setModified ( true ) ;
2008-09-08 08:41:46 -04:00
}
2007-11-14 22:18:48 -05:00
2010-05-23 15:13:41 -04:00
void MessageComposer : : insertForwardPastedText ( std : : string msg )
2008-11-25 20:19:09 -05:00
{
2010-05-25 05:32:14 -04:00
std : : string : : size_type i = 0 ;
while ( ( i = msg . find_first_of ( ' \n ' , i + 1 ) ) < msg . size ( ) )
msg . replace ( i , 1 , std : : string ( " \n <BR/>> " ) ) ;
2008-11-25 20:19:09 -05:00
2010-05-25 05:32:14 -04:00
ui . msgText - > setHtml ( QString ( " <HTML><blockquote [type=cite]><font color= \" blue \" > " ) + QString : : fromStdString ( std : : string ( " " ) + msg ) + " </font><br/><br/></blockquote></HTML> " ) ;
ui . msgText - > setFocus ( Qt : : OtherFocusReason ) ;
QTextCursor c = ui . msgText - > textCursor ( ) ;
c . movePosition ( QTextCursor : : End ) ;
ui . msgText - > setTextCursor ( c ) ;
ui . msgText - > document ( ) - > setModified ( true ) ;
2008-11-25 20:19:09 -05:00
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : insertMsgText ( std : : string msg )
2007-11-14 22:18:48 -05:00
{
2010-05-25 05:32:14 -04:00
ui . msgText - > setText ( QString : : fromStdString ( msg ) ) ;
ui . msgText - > setFocus ( Qt : : OtherFocusReason ) ;
QTextCursor c = ui . msgText - > textCursor ( ) ;
c . movePosition ( QTextCursor : : End ) ;
ui . msgText - > setTextCursor ( c ) ;
ui . msgText - > document ( ) - > setModified ( true ) ;
2007-11-14 22:18:48 -05:00
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : insertHtmlText ( std : : string msg )
2010-01-16 13:03:35 -05:00
{
2010-05-25 05:32:14 -04:00
ui . msgText - > setHtml ( QString ( " <a href=' " ) + QString : : fromStdString ( std : : string ( msg + " '> " ) ) + QString : : fromStdString ( std : : string ( msg ) ) + " </a> " ) ;
2010-01-16 13:03:35 -05:00
2010-05-25 05:32:14 -04:00
ui . msgText - > document ( ) - > setModified ( true ) ;
}
2007-11-14 22:18:48 -05:00
2010-05-23 15:13:41 -04:00
void MessageComposer : : sendMessage ( )
2007-11-14 22:18:48 -05:00
{
2010-05-25 05:32:14 -04:00
sendMessage_internal ( false ) ;
close ( ) ;
}
2007-11-14 22:18:48 -05:00
2010-05-25 05:32:14 -04:00
void MessageComposer : : sendMessage_internal ( bool bDraftbox )
{
/* construct a message */
MessageInfo mi ;
2008-02-04 12:55:59 -05:00
2010-05-25 05:32:14 -04:00
mi . title = ui . titleEdit - > text ( ) . toStdWString ( ) ;
mi . msg = ui . msgText - > toHtml ( ) . toStdWString ( ) ;
rsiface - > lockData ( ) ; /* Lock Interface */
2007-11-14 22:18:48 -05:00
2010-05-25 05:32:14 -04:00
for ( std : : list < FileInfo > : : const_iterator it ( _recList . begin ( ) ) ; it ! = _recList . end ( ) ; + + it )
if ( it - > inRecommend )
mi . files . push_back ( * it ) ;
2007-11-14 22:18:48 -05:00
2010-05-25 05:32:14 -04:00
rsiface - > unlockData ( ) ; /* UnLock Interface */
2007-11-14 22:18:48 -05:00
2010-05-25 05:32:14 -04:00
/* get the ids from the send list */
std : : list < std : : string > peers ;
std : : list < std : : string > : : iterator iit ;
2007-11-14 22:18:48 -05:00
2010-05-25 05:32:14 -04:00
rsPeers - > getFriendList ( peers ) ;
2007-11-14 22:18:48 -05:00
2010-05-25 05:32:14 -04:00
for ( iit = peers . begin ( ) ; iit ! = peers . end ( ) ; iit + + ) {
if ( rsicontrol - > IsInMsg ( * iit ) ) {
mi . msgto . push_back ( * iit ) ;
}
}
2007-11-14 22:18:48 -05:00
2010-05-25 05:32:14 -04:00
if ( bDraftbox ) {
2010-06-14 14:16:32 -04:00
if ( m_nBox ! = - 1 & & ( m_nBox & RS_MSG_DRAFTBOX ) = = RS_MSG_DRAFTBOX ) {
// only save draft box to draft box again, for all other message create a new one in draft box
mi . msgId = m_sMsgId ;
}
2010-05-25 05:32:14 -04:00
rsMsgs - > MessageToDraft ( mi ) ;
} else {
rsMsgs - > MessageSend ( mi ) ;
}
2007-11-14 22:18:48 -05:00
2010-05-25 05:32:14 -04:00
ui . msgText - > document ( ) - > setModified ( false ) ;
}
2007-11-14 22:18:48 -05:00
2010-05-23 15:13:41 -04:00
void MessageComposer : : cancelMessage ( )
2007-11-14 22:18:48 -05:00
{
close ( ) ;
return ;
}
/* Toggling .... Check Boxes.....
* This is dependent on whether we are a
*
* Chan or Msg Dialog .
*/
2010-05-23 15:13:41 -04:00
void MessageComposer : : addRecipient ( std : : string id )
2008-09-03 08:56:37 -04:00
{
QTreeWidget * sendWidget = ui . msgSendList ;
for ( int i = 0 ; i < sendWidget - > topLevelItemCount ( ) ; + + i )
if ( sendWidget - > topLevelItem ( i ) - > text ( 1 ) . toStdString ( ) = = id )
sendWidget - > topLevelItem ( i ) - > setCheckState ( 0 , Qt : : Checked ) ;
2009-02-11 13:43:37 -05:00
//else
//sendWidget->topLevelItem(i)->setCheckState(0,Qt::Unchecked) ;
2008-09-03 08:56:37 -04:00
}
2007-11-14 22:18:48 -05:00
/* First the Msg (People) ones */
2010-05-23 15:13:41 -04:00
void MessageComposer : : togglePersonItem ( QTreeWidgetItem * item , int col )
2007-11-14 22:18:48 -05:00
{
2008-07-10 14:52:56 -04:00
//std::cerr << "TogglePersonItem()" << std::endl;
2007-11-14 22:18:48 -05:00
/* extract id */
2008-01-26 08:08:28 -05:00
std : : string id = ( item - > text ( 1 ) ) . toStdString ( ) ;
2007-11-14 22:18:48 -05:00
/* get state */
bool inMsg = ( Qt : : Checked = = item - > checkState ( 0 ) ) ; /* alway column 0 */
/* call control fns */
rsicontrol - > SetInMsg ( id , inMsg ) ;
return ;
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : toggleRecommendItem ( QTreeWidgetItem * item , int col )
2007-11-14 22:18:48 -05:00
{
2008-07-10 14:52:56 -04:00
//std::cerr << "ToggleRecommendItem()" << std::endl;
2007-11-14 22:18:48 -05:00
/* extract name */
std : : string id = ( item - > text ( 0 ) ) . toStdString ( ) ;
/* get state */
bool inRecommend = ( Qt : : Checked = = item - > checkState ( 0 ) ) ; /* alway column 0 */
/* call control fns */
rsicontrol - > SetInRecommend ( id , inRecommend ) ;
return ;
}
2008-11-25 20:19:09 -05:00
2010-05-23 15:13:41 -04:00
void MessageComposer : : setupFileActions ( )
2008-11-25 20:19:09 -05:00
{
QMenu * menu = new QMenu ( tr ( " &File " ) , this ) ;
menuBar ( ) - > addMenu ( menu ) ;
QAction * a ;
a = new QAction ( QIcon ( " :/images/textedit/filenew.png " ) , tr ( " &New " ) , this ) ;
a - > setShortcut ( QKeySequence : : New ) ;
connect ( a , SIGNAL ( triggered ( ) ) , this , SLOT ( fileNew ( ) ) ) ;
menu - > addAction ( a ) ;
a = new QAction ( QIcon ( " :/images/textedit/fileopen.png " ) , tr ( " &Open... " ) , this ) ;
a - > setShortcut ( QKeySequence : : Open ) ;
connect ( a , SIGNAL ( triggered ( ) ) , this , SLOT ( fileOpen ( ) ) ) ;
menu - > addAction ( a ) ;
menu - > addSeparator ( ) ;
actionSave = a = new QAction ( QIcon ( " :/images/textedit/filesave.png " ) , tr ( " &Save " ) , this ) ;
a - > setShortcut ( QKeySequence : : Save ) ;
2010-05-25 09:22:42 -04:00
connect ( a , SIGNAL ( triggered ( ) ) , this , SLOT ( saveasDraft ( ) ) ) ;
2008-11-25 20:19:09 -05:00
a - > setEnabled ( false ) ;
menu - > addAction ( a ) ;
2010-05-25 09:22:42 -04:00
a = new QAction ( tr ( " Save &As File " ) , this ) ;
2008-11-25 20:19:09 -05:00
connect ( a , SIGNAL ( triggered ( ) ) , this , SLOT ( fileSaveAs ( ) ) ) ;
menu - > addAction ( a ) ;
2010-05-25 06:41:26 -04:00
a = new QAction ( tr ( " Save &As Draft " ) , this ) ;
connect ( a , SIGNAL ( triggered ( ) ) , this , SLOT ( saveasDraft ( ) ) ) ;
menu - > addAction ( a ) ;
2008-11-25 20:19:09 -05:00
menu - > addSeparator ( ) ;
a = new QAction ( QIcon ( " :/images/textedit/fileprint.png " ) , tr ( " &Print... " ) , this ) ;
a - > setShortcut ( QKeySequence : : Print ) ;
connect ( a , SIGNAL ( triggered ( ) ) , this , SLOT ( filePrint ( ) ) ) ;
menu - > addAction ( a ) ;
/*a = new QAction(QIcon(":/images/textedit/fileprint.png"), tr("Print Preview..."), this);
connect ( a , SIGNAL ( triggered ( ) ) , this , SLOT ( filePrintPreview ( ) ) ) ;
menu - > addAction ( a ) ; */
a = new QAction ( QIcon ( " :/images/textedit/exportpdf.png " ) , tr ( " &Export PDF... " ) , this ) ;
a - > setShortcut ( Qt : : CTRL + Qt : : Key_D ) ;
connect ( a , SIGNAL ( triggered ( ) ) , this , SLOT ( filePrintPdf ( ) ) ) ;
menu - > addAction ( a ) ;
menu - > addSeparator ( ) ;
a = new QAction ( tr ( " &Quit " ) , this ) ;
a - > setShortcut ( Qt : : CTRL + Qt : : Key_Q ) ;
connect ( a , SIGNAL ( triggered ( ) ) , this , SLOT ( close ( ) ) ) ;
menu - > addAction ( a ) ;
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : setupEditActions ( )
2008-11-25 20:19:09 -05:00
{
QMenu * menu = new QMenu ( tr ( " &Edit " ) , this ) ;
menuBar ( ) - > addMenu ( menu ) ;
QAction * a ;
a = actionUndo = new QAction ( QIcon ( " :/images/textedit/editundo.png " ) , tr ( " &Undo " ) , this ) ;
a - > setShortcut ( QKeySequence : : Undo ) ;
menu - > addAction ( a ) ;
a = actionRedo = new QAction ( QIcon ( " :/images/textedit/editredo.png " ) , tr ( " &Redo " ) , this ) ;
a - > setShortcut ( QKeySequence : : Redo ) ;
menu - > addAction ( a ) ;
menu - > addSeparator ( ) ;
a = actionCut = new QAction ( QIcon ( " :/images/textedit/editcut.png " ) , tr ( " Cu&t " ) , this ) ;
a - > setShortcut ( QKeySequence : : Cut ) ;
menu - > addAction ( a ) ;
a = actionCopy = new QAction ( QIcon ( " :/images/textedit/editcopy.png " ) , tr ( " &Copy " ) , this ) ;
a - > setShortcut ( QKeySequence : : Copy ) ;
menu - > addAction ( a ) ;
a = actionPaste = new QAction ( QIcon ( " :/images/textedit/editpaste.png " ) , tr ( " &Paste " ) , this ) ;
a - > setShortcut ( QKeySequence : : Paste ) ;
menu - > addAction ( a ) ;
actionPaste - > setEnabled ( ! QApplication : : clipboard ( ) - > text ( ) . isEmpty ( ) ) ;
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : setupViewActions ( )
2008-11-25 20:19:09 -05:00
{
QMenu * menu = new QMenu ( tr ( " &View " ) , this ) ;
menuBar ( ) - > addMenu ( menu ) ;
QAction * a ;
a = new QAction ( QIcon ( " " ) , tr ( " &Contacts Sidebar " ) , this ) ;
connect ( a , SIGNAL ( triggered ( ) ) , this , SLOT ( toggleContacts ( ) ) ) ;
menu - > addAction ( a ) ;
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : setupInsertActions ( )
2008-11-25 20:19:09 -05:00
{
QMenu * menu = new QMenu ( tr ( " &Insert " ) , this ) ;
menuBar ( ) - > addMenu ( menu ) ;
QAction * a ;
a = new QAction ( QIcon ( " " ) , tr ( " &Image " ) , this ) ;
connect ( a , SIGNAL ( triggered ( ) ) , this , SLOT ( addImage ( ) ) ) ;
menu - > addAction ( a ) ;
2010-05-25 13:18:12 -04:00
a = new QAction ( QIcon ( " " ) , tr ( " &Horizontal Line " ) , this ) ;
connect ( a , SIGNAL ( triggered ( ) ) , this , SLOT ( addPostSplitter ( ) ) ) ;
menu - > addAction ( a ) ;
2008-11-25 20:19:09 -05:00
}
2010-05-25 18:30:25 -04:00
void MessageComposer : : setupFormatActions ( )
{
QMenu * menu = new QMenu ( tr ( " &Format " ) , this ) ;
menuBar ( ) - > addMenu ( menu ) ;
menu - > addAction ( actionAlignLeft ) ;
menu - > addAction ( actionAlignCenter ) ;
menu - > addAction ( actionAlignRight ) ;
menu - > addAction ( actionAlignJustify ) ;
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : textBold ( )
2008-11-25 20:19:09 -05:00
{
QTextCharFormat fmt ;
fmt . setFontWeight ( ui . boldbtn - > isChecked ( ) ? QFont : : Bold : QFont : : Normal ) ;
mergeFormatOnWordOrSelection ( fmt ) ;
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : textUnderline ( )
2008-11-25 20:19:09 -05:00
{
QTextCharFormat fmt ;
fmt . setFontUnderline ( ui . underlinebtn - > isChecked ( ) ) ;
mergeFormatOnWordOrSelection ( fmt ) ;
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : textItalic ( )
2008-11-25 20:19:09 -05:00
{
QTextCharFormat fmt ;
fmt . setFontItalic ( ui . italicbtn - > isChecked ( ) ) ;
mergeFormatOnWordOrSelection ( fmt ) ;
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : textFamily ( const QString & f )
2008-11-25 20:19:09 -05:00
{
QTextCharFormat fmt ;
fmt . setFontFamily ( f ) ;
mergeFormatOnWordOrSelection ( fmt ) ;
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : textSize ( const QString & p )
2008-11-25 20:19:09 -05:00
{
2010-02-22 09:20:40 -05:00
qreal pointSize = p . toFloat ( ) ;
if ( p . toFloat ( ) > 0 ) {
QTextCharFormat fmt ;
fmt . setFontPointSize ( pointSize ) ;
mergeFormatOnWordOrSelection ( fmt ) ;
}
2008-11-25 20:19:09 -05:00
}
2010-05-25 13:18:12 -04:00
void MessageComposer : : changeFormatType ( int styleIndex )
{
ui . msgText - > setFocus ( Qt : : OtherFocusReason ) ;
QTextCursor cursor = ui . msgText - > textCursor ( ) ;
//QTextBlockFormat bformat = cursor.blockFormat();
QTextBlockFormat bformat ;
QTextCharFormat cformat ;
switch ( styleIndex ) {
default :
case 0 :
bformat . setProperty ( TextFormat : : HtmlHeading , QVariant ( 0 ) ) ;
cformat . setFontWeight ( QFont : : Normal ) ;
cformat . setProperty ( QTextFormat : : FontSizeAdjustment , QVariant ( 0 ) ) ;
break ;
case 1 :
bformat . setProperty ( TextFormat : : HtmlHeading , QVariant ( 1 ) ) ;
cformat . setFontWeight ( QFont : : Bold ) ;
cformat . setProperty ( QTextFormat : : FontSizeAdjustment , QVariant ( 3 ) ) ;
break ;
case 2 :
bformat . setProperty ( TextFormat : : HtmlHeading , QVariant ( 2 ) ) ;
cformat . setFontWeight ( QFont : : Bold ) ;
cformat . setProperty ( QTextFormat : : FontSizeAdjustment , QVariant ( 2 ) ) ;
break ;
case 3 :
bformat . setProperty ( TextFormat : : HtmlHeading , QVariant ( 3 ) ) ;
cformat . setFontWeight ( QFont : : Bold ) ;
cformat . setProperty ( QTextFormat : : FontSizeAdjustment , QVariant ( 1 ) ) ;
break ;
case 4 :
bformat . setProperty ( TextFormat : : HtmlHeading , QVariant ( 4 ) ) ;
cformat . setFontWeight ( QFont : : Bold ) ;
cformat . setProperty ( QTextFormat : : FontSizeAdjustment , QVariant ( 0 ) ) ;
break ;
case 5 :
bformat . setProperty ( TextFormat : : HtmlHeading , QVariant ( 5 ) ) ;
cformat . setFontWeight ( QFont : : Bold ) ;
cformat . setProperty ( QTextFormat : : FontSizeAdjustment , QVariant ( - 1 ) ) ;
break ;
case 6 :
bformat . setProperty ( TextFormat : : HtmlHeading , QVariant ( 6 ) ) ;
cformat . setFontWeight ( QFont : : Bold ) ;
cformat . setProperty ( QTextFormat : : FontSizeAdjustment , QVariant ( - 2 ) ) ;
break ;
}
//cformat.clearProperty( TextFormat::HasCodeStyle );
cursor . beginEditBlock ( ) ;
cursor . mergeBlockFormat ( bformat ) ;
cursor . select ( QTextCursor : : BlockUnderCursor ) ;
cursor . mergeCharFormat ( cformat ) ;
cursor . endEditBlock ( ) ;
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : textStyle ( int styleIndex )
2008-11-25 20:19:09 -05:00
{
QTextCursor cursor = ui . msgText - > textCursor ( ) ;
if ( styleIndex ! = 0 ) {
QTextListFormat : : Style style = QTextListFormat : : ListDisc ;
switch ( styleIndex ) {
default :
case 1 :
style = QTextListFormat : : ListDisc ;
break ;
case 2 :
style = QTextListFormat : : ListCircle ;
break ;
case 3 :
style = QTextListFormat : : ListSquare ;
break ;
case 4 :
style = QTextListFormat : : ListDecimal ;
break ;
case 5 :
style = QTextListFormat : : ListLowerAlpha ;
break ;
case 6 :
style = QTextListFormat : : ListUpperAlpha ;
break ;
}
cursor . beginEditBlock ( ) ;
QTextBlockFormat blockFmt = cursor . blockFormat ( ) ;
QTextListFormat listFmt ;
if ( cursor . currentList ( ) ) {
listFmt = cursor . currentList ( ) - > format ( ) ;
} else {
listFmt . setIndent ( blockFmt . indent ( ) + 1 ) ;
blockFmt . setIndent ( 0 ) ;
cursor . setBlockFormat ( blockFmt ) ;
}
listFmt . setStyle ( style ) ;
cursor . createList ( listFmt ) ;
cursor . endEditBlock ( ) ;
} else {
// ####
QTextBlockFormat bfmt ;
bfmt . setObjectIndex ( - 1 ) ;
cursor . mergeBlockFormat ( bfmt ) ;
}
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : textColor ( )
2008-11-25 20:19:09 -05:00
{
QColor col = QColorDialog : : getColor ( ui . msgText - > textColor ( ) , this ) ;
if ( ! col . isValid ( ) )
return ;
QTextCharFormat fmt ;
fmt . setForeground ( col ) ;
mergeFormatOnWordOrSelection ( fmt ) ;
colorChanged ( col ) ;
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : textAlign ( QAction * a )
2008-11-25 20:19:09 -05:00
{
if ( a = = actionAlignLeft )
ui . msgText - > setAlignment ( Qt : : AlignLeft ) ;
else if ( a = = actionAlignCenter )
ui . msgText - > setAlignment ( Qt : : AlignHCenter ) ;
else if ( a = = actionAlignRight )
ui . msgText - > setAlignment ( Qt : : AlignRight ) ;
else if ( a = = actionAlignJustify )
ui . msgText - > setAlignment ( Qt : : AlignJustify ) ;
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : currentCharFormatChanged ( const QTextCharFormat & format )
2008-11-25 20:19:09 -05:00
{
fontChanged ( format . font ( ) ) ;
colorChanged ( format . foreground ( ) . color ( ) ) ;
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : cursorPositionChanged ( )
2008-11-25 20:19:09 -05:00
{
alignmentChanged ( ui . msgText - > alignment ( ) ) ;
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : mergeFormatOnWordOrSelection ( const QTextCharFormat & format )
2008-11-25 20:19:09 -05:00
{
QTextCursor cursor = ui . msgText - > textCursor ( ) ;
if ( ! cursor . hasSelection ( ) )
cursor . select ( QTextCursor : : WordUnderCursor ) ;
cursor . mergeCharFormat ( format ) ;
ui . msgText - > mergeCurrentCharFormat ( format ) ;
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : fontChanged ( const QFont & f )
2008-11-25 20:19:09 -05:00
{
ui . comboFont - > setCurrentIndex ( ui . comboFont - > findText ( QFontInfo ( f ) . family ( ) ) ) ;
ui . comboSize - > setCurrentIndex ( ui . comboSize - > findText ( QString : : number ( f . pointSize ( ) ) ) ) ;
ui . boldbtn - > setChecked ( f . bold ( ) ) ;
ui . italicbtn - > setChecked ( f . italic ( ) ) ;
ui . underlinebtn - > setChecked ( f . underline ( ) ) ;
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : colorChanged ( const QColor & c )
2008-11-25 20:19:09 -05:00
{
QPixmap pix ( 16 , 16 ) ;
pix . fill ( c ) ;
ui . colorbtn - > setIcon ( pix ) ;
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : alignmentChanged ( Qt : : Alignment a )
2008-11-25 20:19:09 -05:00
{
if ( a & Qt : : AlignLeft ) {
actionAlignLeft - > setChecked ( true ) ;
} else if ( a & Qt : : AlignHCenter ) {
actionAlignCenter - > setChecked ( true ) ;
} else if ( a & Qt : : AlignRight ) {
actionAlignRight - > setChecked ( true ) ;
} else if ( a & Qt : : AlignJustify ) {
actionAlignJustify - > setChecked ( true ) ;
}
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : clipboardDataChanged ( )
2008-11-25 20:19:09 -05:00
{
actionPaste - > setEnabled ( ! QApplication : : clipboard ( ) - > text ( ) . isEmpty ( ) ) ;
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : fileNew ( )
2008-11-25 20:19:09 -05:00
{
if ( maybeSave ( ) ) {
ui . msgText - > clear ( ) ;
//setCurrentFileName(QString());
}
2008-03-24 21:41:01 -04:00
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : fileOpen ( )
2008-11-25 20:19:09 -05:00
{
QString fn = QFileDialog : : getOpenFileName ( this , tr ( " Open File... " ) ,
QString ( ) , tr ( " HTML-Files (*.htm *.html);;All Files (*) " ) ) ;
if ( ! fn . isEmpty ( ) )
load ( fn ) ;
2008-03-24 21:41:01 -04:00
}
2007-11-14 22:18:48 -05:00
2010-05-23 15:13:41 -04:00
bool MessageComposer : : fileSave ( )
2008-11-25 20:19:09 -05:00
{
if ( fileName . isEmpty ( ) )
return fileSaveAs ( ) ;
QFile file ( fileName ) ;
if ( ! file . open ( QFile : : WriteOnly ) )
return false ;
QTextStream ts ( & file ) ;
ts . setCodec ( QTextCodec : : codecForName ( " UTF-8 " ) ) ;
ts < < ui . msgText - > document ( ) - > toHtml ( " UTF-8 " ) ;
ui . msgText - > document ( ) - > setModified ( false ) ;
return true ;
2008-03-26 15:30:34 -04:00
}
2010-05-23 15:13:41 -04:00
bool MessageComposer : : fileSaveAs ( )
2008-11-25 20:19:09 -05:00
{
QString fn = QFileDialog : : getSaveFileName ( this , tr ( " Save as... " ) ,
QString ( ) , tr ( " HTML-Files (*.htm *.html);;All Files (*) " ) ) ;
if ( fn . isEmpty ( ) )
return false ;
setCurrentFileName ( fn ) ;
return fileSave ( ) ;
2008-03-26 15:30:34 -04:00
}
2010-05-25 06:41:26 -04:00
void MessageComposer : : saveasDraft ( )
{
sendMessage_internal ( true ) ;
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : filePrint ( )
2008-11-25 20:19:09 -05:00
{
# ifndef QT_NO_PRINTER
QPrinter printer ( QPrinter : : HighResolution ) ;
printer . setFullPage ( true ) ;
QPrintDialog * dlg = new QPrintDialog ( & printer , this ) ;
if ( ui . msgText - > textCursor ( ) . hasSelection ( ) )
dlg - > addEnabledOption ( QAbstractPrintDialog : : PrintSelection ) ;
dlg - > setWindowTitle ( tr ( " Print Document " ) ) ;
if ( dlg - > exec ( ) = = QDialog : : Accepted ) {
ui . msgText - > print ( & printer ) ;
}
delete dlg ;
# endif
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : filePrintPdf ( )
2008-11-25 20:19:09 -05:00
{
# ifndef QT_NO_PRINTER
QString fileName = QFileDialog : : getSaveFileName ( this , " Export PDF " ,
QString ( ) , " *.pdf " ) ;
if ( ! fileName . isEmpty ( ) ) {
if ( QFileInfo ( fileName ) . suffix ( ) . isEmpty ( ) )
fileName . append ( " .pdf " ) ;
QPrinter printer ( QPrinter : : HighResolution ) ;
printer . setOutputFormat ( QPrinter : : PdfFormat ) ;
printer . setOutputFileName ( fileName ) ;
ui . msgText - > document ( ) - > print ( & printer ) ;
}
# endif
2008-03-24 21:41:01 -04:00
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : setCurrentFileName ( const QString & fileName )
2008-11-25 20:19:09 -05:00
{
this - > fileName = fileName ;
ui . msgText - > document ( ) - > setModified ( false ) ;
setWindowModified ( false ) ;
2008-03-24 21:41:01 -04:00
}
2010-05-23 15:13:41 -04:00
bool MessageComposer : : load ( const QString & f )
2008-11-25 20:19:09 -05:00
{
if ( ! QFile : : exists ( f ) )
return false ;
QFile file ( f ) ;
if ( ! file . open ( QFile : : ReadOnly ) )
return false ;
QByteArray data = file . readAll ( ) ;
QTextCodec * codec = Qt : : codecForHtml ( data ) ;
QString str = codec - > toUnicode ( data ) ;
if ( Qt : : mightBeRichText ( str ) ) {
ui . msgText - > setHtml ( str ) ;
} else {
str = QString : : fromLocal8Bit ( data ) ;
ui . msgText - > setPlainText ( str ) ;
}
setCurrentFileName ( f ) ;
return true ;
2008-03-24 21:41:01 -04:00
}
2008-11-25 20:19:09 -05:00
2010-05-23 15:13:41 -04:00
bool MessageComposer : : maybeSave ( )
2008-11-25 20:19:09 -05:00
{
if ( ! ui . msgText - > document ( ) - > isModified ( ) )
return true ;
if ( fileName . startsWith ( QLatin1String ( " :/ " ) ) )
return true ;
QMessageBox : : StandardButton ret ;
ret = QMessageBox : : warning ( this , tr ( " Save Message " ) ,
tr ( " Message has not been Sent. \n "
" Do you want to save message ? " ) ,
QMessageBox : : Save | QMessageBox : : Discard
| QMessageBox : : Cancel ) ;
if ( ret = = QMessageBox : : Save )
return fileSave ( ) ;
else if ( ret = = QMessageBox : : Cancel )
return false ;
return true ;
2008-03-24 21:41:01 -04:00
}
2008-11-25 20:19:09 -05:00
2010-05-23 15:13:41 -04:00
void MessageComposer : : toggleContacts ( )
2008-11-25 20:19:09 -05:00
{
ui . contactsdockWidget - > setVisible ( ! ui . contactsdockWidget - > isVisible ( ) ) ;
2008-03-24 13:36:17 -04:00
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : addImage ( )
2008-11-25 20:19:09 -05:00
{
2008-03-25 08:28:13 -04:00
QString fileimg = QFileDialog : : getOpenFileName ( this , tr ( " Choose Image " ) ,
QString ( setter . value ( " LastDir " ) . toString ( ) ) , tr ( " Image Files supported (*.png *.jpeg *.jpg *.gif) " ) ) ;
2008-11-25 20:19:09 -05:00
if ( fileimg . isEmpty ( ) ) {
return ;
}
QImage base ( fileimg ) ;
QString pathimage = fileimg . left ( fileimg . lastIndexOf ( " / " ) ) + " / " ;
setter . setValue ( " LastDir " , pathimage ) ;
Create_New_Image_Tag ( fileimg ) ;
2008-03-25 08:28:13 -04:00
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : Create_New_Image_Tag ( const QString urlremoteorlocal )
2008-11-25 20:19:09 -05:00
{
/*if (image_extension(urlremoteorlocal)) {*/
QString subtext = QString ( " <p><img src= \" %1 \" /> " ) . arg ( urlremoteorlocal ) ;
///////////subtext.append("<br/><br/>Description on image.</p>");
QTextDocumentFragment fragment = QTextDocumentFragment : : fromHtml ( subtext ) ;
ui . msgText - > textCursor ( ) . insertFragment ( fragment ) ;
//emit statusMessage(QString("Image new :").arg(urlremoteorlocal));
//}
2008-03-25 08:28:13 -04:00
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : fontSizeIncrease ( )
2010-01-25 09:03:38 -05:00
{
if ( ! ( ui . msgText - > textCursor ( ) . blockFormat ( ) . hasProperty ( TextFormat : : HtmlHeading ) & &
ui . msgText - > textCursor ( ) . blockFormat ( ) . intProperty ( TextFormat : : HtmlHeading ) ) ) {
QTextCharFormat format ;
int idx = ui . msgText - > currentCharFormat ( ) . intProperty ( QTextFormat : : FontSizeAdjustment ) ;
if ( idx < 3 ) {
format . setProperty ( QTextFormat : : FontSizeAdjustment , QVariant ( + + idx ) ) ;
ui . msgText - > textCursor ( ) . mergeCharFormat ( format ) ;
}
}
ui . msgText - > setFocus ( Qt : : OtherFocusReason ) ;
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : fontSizeDecrease ( )
2010-01-25 09:03:38 -05:00
{
if ( ! ( ui . msgText - > textCursor ( ) . blockFormat ( ) . hasProperty ( TextFormat : : HtmlHeading ) & &
ui . msgText - > textCursor ( ) . blockFormat ( ) . intProperty ( TextFormat : : HtmlHeading ) ) ) {
QTextCharFormat format ;
int idx = ui . msgText - > currentCharFormat ( ) . intProperty ( QTextFormat : : FontSizeAdjustment ) ;
if ( idx > - 1 ) {
format . setProperty ( QTextFormat : : FontSizeAdjustment , QVariant ( - - idx ) ) ;
ui . msgText - > textCursor ( ) . mergeCharFormat ( format ) ;
}
}
ui . msgText - > setFocus ( Qt : : OtherFocusReason ) ;
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : blockQuote ( )
2010-01-25 09:03:38 -05:00
{
QTextBlockFormat blockFormat = ui . msgText - > textCursor ( ) . blockFormat ( ) ;
QTextBlockFormat f ;
if ( blockFormat . hasProperty ( TextFormat : : IsBlockQuote ) & &
blockFormat . boolProperty ( TextFormat : : IsBlockQuote ) ) {
f . setProperty ( TextFormat : : IsBlockQuote , QVariant ( false ) ) ;
f . setLeftMargin ( 0 ) ;
f . setRightMargin ( 0 ) ;
} else {
f . setProperty ( TextFormat : : IsBlockQuote , QVariant ( true ) ) ;
f . setLeftMargin ( 40 ) ;
f . setRightMargin ( 40 ) ;
}
ui . msgText - > textCursor ( ) . mergeBlockFormat ( f ) ;
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : toggleCode ( )
2010-01-25 09:03:38 -05:00
{
static QString preFontFamily ;
QTextCharFormat charFormat = ui . msgText - > currentCharFormat ( ) ;
QTextCharFormat f ;
if ( charFormat . hasProperty ( TextFormat : : HasCodeStyle ) & &
charFormat . boolProperty ( TextFormat : : HasCodeStyle ) ) {
f . setProperty ( TextFormat : : HasCodeStyle , QVariant ( false ) ) ;
f . setBackground ( defaultCharFormat . background ( ) ) ;
f . setFontFamily ( preFontFamily ) ;
ui . msgText - > textCursor ( ) . mergeCharFormat ( f ) ;
} else {
preFontFamily = ui . msgText - > fontFamily ( ) ;
f . setProperty ( TextFormat : : HasCodeStyle , QVariant ( true ) ) ;
f . setBackground ( codeBackground ) ;
f . setFontFamily ( " Dejavu Sans Mono " ) ;
ui . msgText - > textCursor ( ) . mergeCharFormat ( f ) ;
}
ui . msgText - > setFocus ( Qt : : OtherFocusReason ) ;
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : addPostSplitter ( )
2010-01-25 10:36:24 -05:00
{
QTextBlockFormat f = ui . msgText - > textCursor ( ) . blockFormat ( ) ;
QTextBlockFormat f1 = f ;
f . setProperty ( TextFormat : : IsHtmlTagSign , true ) ;
f . setProperty ( QTextFormat : : BlockTrailingHorizontalRulerWidth ,
QTextLength ( QTextLength : : PercentageLength , 80 ) ) ;
if ( ui . msgText - > textCursor ( ) . block ( ) . text ( ) . isEmpty ( ) ) {
ui . msgText - > textCursor ( ) . mergeBlockFormat ( f ) ;
} else {
ui . msgText - > textCursor ( ) . insertBlock ( f ) ;
}
ui . msgText - > textCursor ( ) . insertBlock ( f1 ) ;
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : attachFile ( )
2010-01-20 16:39:27 -05:00
{
// select a file
QString qfile = QFileDialog : : getOpenFileName ( this , tr ( " Add Extra File " ) , " " , " " , 0 ,
QFileDialog : : DontResolveSymlinks ) ;
std : : string filePath = qfile . toStdString ( ) ;
if ( filePath ! = " " )
{
2010-05-23 15:13:41 -04:00
MessageComposer : : addAttachment ( filePath ) ;
2010-01-20 16:39:27 -05:00
}
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : addAttachment ( std : : string filePath ) {
2010-01-20 16:39:27 -05:00
/* add a AttachFileItem to the attachment section */
2010-05-23 15:13:41 -04:00
std : : cerr < < " MessageComposer::addFile() hashing file. " ;
2010-01-20 16:39:27 -05:00
std : : cerr < < std : : endl ;
/* add widget in for new destination */
AttachFileItem * file = new AttachFileItem ( filePath ) ;
//file->
ui . verticalLayout - > addWidget ( file , 1 , 0 ) ;
//when the file is local or is finished hashing, call the fileHashingFinished method to send a chat message
if ( file - > getState ( ) = = AFI_STATE_LOCAL ) {
fileHashingFinished ( file ) ;
} else {
QObject : : connect ( file , SIGNAL ( fileFinished ( AttachFileItem * ) ) , this , SLOT ( fileHashingFinished ( AttachFileItem * ) ) ) ;
}
2010-01-21 11:35:00 -05:00
mAttachments . push_back ( file ) ;
if ( mCheckAttachment )
{
checkAttachmentReady ( ) ;
}
2010-01-20 16:39:27 -05:00
}
2010-05-23 15:13:41 -04:00
void MessageComposer : : fileHashingFinished ( AttachFileItem * file ) {
std : : cerr < < " MessageComposer::fileHashingFinished() started. " ;
2010-01-20 16:39:27 -05:00
std : : cerr < < std : : endl ;
//check that the file is ok tos end
if ( file - > getState ( ) = = AFI_STATE_ERROR ) {
# ifdef CHAT_DEBUG
2010-05-23 15:13:41 -04:00
std : : cerr < < " MessageComposer::fileHashingFinished error file is not hashed. " ;
2010-01-20 16:39:27 -05:00
# endif
return ;
}
2010-06-07 20:42:15 -04:00
RetroShareLink message ( QString : : fromStdString ( file - > FileName ( ) ) , file - > FileSize ( ) , QString : : fromStdString ( file - > FileHash ( ) ) ) ;
2010-01-20 16:39:27 -05:00
# ifdef CHAT_DEBUG
2010-06-07 20:42:15 -04:00
std : : cerr < < " MessageComposer::anchorClicked message : " < < message . toHtmlFull ( ) . toStdString ( ) < < std : : endl ;
2010-01-20 16:39:27 -05:00
# endif
2010-06-07 20:42:15 -04:00
ui . msgText - > textCursor ( ) . insertHtml ( message . toHtmlFull ( ) + QString ( " <br> " ) ) ;
ui . msgText - > setFocus ( Qt : : OtherFocusReason ) ;
2010-01-20 16:39:27 -05:00
}
2008-03-26 15:30:34 -04:00
2010-05-23 15:13:41 -04:00
void MessageComposer : : checkAttachmentReady ( )
2010-01-21 11:35:00 -05:00
{
std : : list < AttachFileItem * > : : iterator fit ;
mCheckAttachment = false ;
for ( fit = mAttachments . begin ( ) ; fit ! = mAttachments . end ( ) ; fit + + )
{
if ( ! ( * fit ) - > isHidden ( ) )
{
if ( ! ( * fit ) - > ready ( ) )
{
/*
*/
ui . actionSend - > setEnabled ( false ) ;
break ;
return ;
}
}
}
if ( fit = = mAttachments . end ( ) )
{
ui . actionSend - > setEnabled ( true ) ;
}
/* repeat... */
int msec_rate = 1000 ;
QTimer : : singleShot ( msec_rate , this , SLOT ( checkAttachmentReady ( void ) ) ) ;
}
2010-05-29 15:05:10 -04:00
/* clear Filter */
void MessageComposer : : clearFilter ( )
{
ui . filterPatternLineEdit - > clear ( ) ;
ui . filterPatternLineEdit - > setFocus ( ) ;
}
void MessageComposer : : filterRegExpChanged ( )
{
QString text = ui . filterPatternLineEdit - > text ( ) ;
if ( text . isEmpty ( ) ) {
ui . clearButton - > hide ( ) ;
} else {
ui . clearButton - > show ( ) ;
}
FilterItems ( ) ;
}
void MessageComposer : : FilterItems ( )
{
QString sPattern = ui . filterPatternLineEdit - > text ( ) ;
int nCount = ui . msgSendList - > topLevelItemCount ( ) ;
for ( int nIndex = 0 ; nIndex < nCount ; nIndex + + ) {
FilterItem ( ui . msgSendList - > topLevelItem ( nIndex ) , sPattern ) ;
}
}
bool MessageComposer : : FilterItem ( QTreeWidgetItem * pItem , QString & sPattern )
{
bool bVisible = true ;
if ( sPattern . isEmpty ( ) = = false ) {
if ( pItem - > text ( 0 ) . contains ( sPattern , Qt : : CaseInsensitive ) = = false ) {
bVisible = false ;
}
}
int nVisibleChildCount = 0 ;
int nCount = pItem - > childCount ( ) ;
for ( int nIndex = 0 ; nIndex < nCount ; nIndex + + ) {
if ( FilterItem ( pItem - > child ( nIndex ) , sPattern ) ) {
nVisibleChildCount + + ;
}
}
if ( bVisible | | nVisibleChildCount ) {
pItem - > setHidden ( false ) ;
} else {
pItem - > setHidden ( true ) ;
}
return ( bVisible | | nVisibleChildCount ) ;
2010-07-23 14:52:58 -04:00
}