changes to support i8n in the gui (chat and messages)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@318 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2008-01-26 13:08:28 +00:00
parent bfb0b2be2b
commit f9d6f1c418
9 changed files with 734 additions and 397 deletions

View File

@ -89,6 +89,7 @@ void ChatDialog::msgSendListCostumPopupMenu( QPoint point )
contextMnu.addAction( privchatAct); contextMnu.addAction( privchatAct);
contextMnu.exec( mevent->globalPos() ); contextMnu.exec( mevent->globalPos() );
} }
int ChatDialog::loadInitMsg() int ChatDialog::loadInitMsg()
{ {
std::ostringstream out; std::ostringstream out;
@ -145,11 +146,6 @@ void ChatDialog::insertChat()
} }
n = 1 + n / 2; /* shrink it! */ n = 1 + n / 2; /* shrink it! */
//std::cerr << "Space count : " << n << std::endl;
std::string spaces(" ");
/* add in lines at the bottom */ /* add in lines at the bottom */
int ts = time(NULL); int ts = time(NULL);
for(it = newchat.begin(); it != newchat.end(); it++) for(it = newchat.begin(); it != newchat.end(); it++)
@ -164,6 +160,7 @@ void ChatDialog::insertChat()
std::ostringstream out; std::ostringstream out;
QString currenttxt = msgWidget->toHtml(); QString currenttxt = msgWidget->toHtml();
QString extraTxt;
if ((it->name == lastChatName) && (ts - lastChatTime < 60)) if ((it->name == lastChatName) && (ts - lastChatTime < 60))
{ {
@ -173,48 +170,39 @@ void ChatDialog::insertChat()
{ {
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
/* nothing */ /* nothing */
//out << "<br>" << std::endl;
#else #else
out << "<br>" << std::endl; extraTxt += "<br>\n";
#endif #endif
for(int i = 0; i < n; i++) for(int i = 0; i < n; i++)
{ {
out << spaces; extraTxt += " ";
} }
QString timestamp = "[" + QDateTime::currentDateTime().toString("hh:mm:ss") + "]"; QString timestamp = "[" + QDateTime::currentDateTime().toString("hh:mm:ss") + "]";
QString name = QString::fromStdString(it->name); QString name = QString::fromStdString(it->name);
//QString line = "<span style=\"color:#1D84C9\">" + timestamp +
// " " + name + "</span> \n<br>";
QString line = "<span style=\"color:#1D84C9\"><strong>" + timestamp + QString line = "<span style=\"color:#1D84C9\"><strong>" + timestamp +
" " + name + "</strong></span> \n<br>"; " " + name + "</strong></span> \n<br>";
out << line.toStdString(); extraTxt += line;
} }
out << it -> msg; extraTxt += QString::fromStdWString(it->msg);
/* This might be WIN32 only - or maybe Qt4.2.2 only - but need it for windows at the mom */ /* This might be WIN32 only - or maybe Qt4.2.2 only - but need it for windows at the mom */
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
//out << "<br>"; extraTxt += "\n";
//out << "<br>" << std::endl;
out << std::endl;
#else #else
out << std::endl; extraTxt += "\n";
#endif #endif
lastChatName = it -> name; lastChatName = it -> name;
lastChatTime = ts; lastChatTime = ts;
/* add it everytime */ /* add it everytime */
QString extra = QString::fromStdString(out.str()); currenttxt += extraTxt;
currenttxt += extra;
msgWidget->setHtml(currenttxt); msgWidget->setHtml(currenttxt);
//std::cerr << " Added Text: " << std::endl;
//std::cerr << out.str() << std::endl;
QScrollBar *qsb = msgWidget->verticalScrollBar(); QScrollBar *qsb = msgWidget->verticalScrollBar();
qsb -> setValue(qsb->maximum()); qsb -> setValue(qsb->maximum());
} }
@ -233,7 +221,7 @@ void ChatDialog::sendMsg()
//font.setItalic(ui.textitalicChatButton->isChecked()); //font.setItalic(ui.textitalicChatButton->isChecked());
ChatInfo ci; ChatInfo ci;
ci.msg = lineWidget->text().toStdString(); ci.msg = lineWidget->text().toStdWString();
ci.chatflags = RS_CHAT_PUBLIC; ci.chatflags = RS_CHAT_PUBLIC;
//ci.messageFont = font; //ci.messageFont = font;
//ci.messageColor = textColor; //ci.messageColor = textColor;
@ -280,8 +268,8 @@ void ChatDialog::insertSendList()
/* (0) Person */ /* (0) Person */
item -> setText(0, QString::fromStdString(details.name)); item -> setText(0, QString::fromStdString(details.name));
//item -> setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); item -> setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
item -> setFlags(Qt::ItemIsUserCheckable); //item -> setFlags(Qt::ItemIsUserCheckable);
item -> setCheckState(0, Qt::Checked); item -> setCheckState(0, Qt::Checked);
/**** NOT SELECTABLE AT THE MOMENT /**** NOT SELECTABLE AT THE MOMENT

View File

@ -59,10 +59,12 @@ MessagesDialog::MessagesDialog(QWidget *parent)
connect( ui.msgWidget, SIGNAL( itemClicked ( QTreeWidgetItem *, int) ), this, SLOT( updateMessages ( QTreeWidgetItem *, int) ) ); connect( ui.msgWidget, SIGNAL( itemClicked ( QTreeWidgetItem *, int) ), this, SLOT( updateMessages ( QTreeWidgetItem *, int) ) );
connect( ui.listWidget, SIGNAL( currentRowChanged ( int) ), this, SLOT( changeBox ( int) ) ); connect( ui.listWidget, SIGNAL( currentRowChanged ( int) ), this, SLOT( changeBox ( int) ) );
connect(ui.newmessageButton, SIGNAL(clicked()), this, SLOT(newmessage())); connect(ui.newmessageButton, SIGNAL(clicked()), this, SLOT(newmessage()));
connect(ui.removemessageButton, SIGNAL(clicked()), this, SLOT(removemessage())); connect(ui.removemessageButton, SIGNAL(clicked()), this, SLOT(removemessage()));
connect(ui.expandFilesButton, SIGNAL(clicked()), this, SLOT(togglefileview()));
connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(getallrecommended()));
mCurrCertId = ""; mCurrCertId = "";
mCurrMsgId = ""; mCurrMsgId = "";
@ -86,8 +88,8 @@ MessagesDialog::MessagesDialog(QWidget *parent)
msglheader->resizeSection ( 0, 125 ); msglheader->resizeSection ( 0, 125 );
msglheader->resizeSection ( 1, 100 ); msglheader->resizeSection ( 1, 100 );
msglheader->resizeSection ( 2, 100 ); msglheader->resizeSection ( 2, 250 );
msglheader->resizeSection ( 3, 200 ); msglheader->resizeSection ( 3, 50 );
/* Hide platform specific features */ /* Hide platform specific features */
@ -161,6 +163,64 @@ void MessagesDialog::replytomessage()
} }
void MessagesDialog::togglefileview()
{
/* if msg header visible -> hide by changing splitter
* three widgets...
*/
QList<int> sizeList = ui.msgSplitter->sizes();
QList<int>::iterator it;
int listSize = 0;
int msgSize = 0;
int recommendSize = 0;
int i = 0;
for(it = sizeList.begin(); it != sizeList.end(); it++, i++)
{
if (i == 0)
{
listSize = (*it);
}
else if (i == 1)
{
msgSize = (*it);
}
else if (i == 2)
{
recommendSize = (*it);
}
}
int totalSize = listSize + msgSize + recommendSize;
bool toShrink = true;
if (recommendSize < (int) totalSize / 10)
{
toShrink = false;
}
QList<int> newSizeList;
if (toShrink)
{
newSizeList.push_back(listSize + recommendSize / 3);
newSizeList.push_back(msgSize + recommendSize * 2 / 3);
newSizeList.push_back(0);
}
else
{
/* no change */
int nlistSize = (totalSize * 2 / 3) * listSize / (listSize + msgSize);
int nMsgSize = (totalSize * 2 / 3) - listSize;
newSizeList.push_back(nlistSize);
newSizeList.push_back(nMsgSize);
newSizeList.push_back(totalSize * 1 / 3);
}
ui.msgSplitter->setSizes(newSizeList);
}
/* download the recommendations... */ /* download the recommendations... */
void MessagesDialog::getcurrentrecommended() void MessagesDialog::getcurrentrecommended()
@ -318,7 +378,8 @@ void MessagesDialog::insertMessages()
item -> setText(1, QString::fromStdString(out.str())); item -> setText(1, QString::fromStdString(out.str()));
} }
item -> setText(2, QString::fromStdString(it->title)); // Subject
item -> setText(2, QString::fromStdWString(it->title));
// No of Files. // No of Files.
{ {
@ -327,47 +388,11 @@ void MessagesDialog::insertMessages()
item -> setText(3, QString::fromStdString(out.str())); item -> setText(3, QString::fromStdString(out.str()));
} }
// Size. item -> setText(4, QString::fromStdString(it->id));
// Msg. item -> setText(5, QString::fromStdString(it->msgId));
// Rank if ((oldSelected) && (mid == it->msgId))
{ {
std::ostringstream out; newSelected = item;
out << it -> size;
item -> setText(4, QString::fromStdString(out.str()));
}
/* strip out the \n and \r symbols */
std::string tmsg = it -> msg;
for(int i = 0; i < tmsg.length(); i++)
{
if ((tmsg[i] == '\n') ||
(tmsg[i] == '\r'))
{
tmsg[i] = ' ';
}
}
item -> setText(5, QString::fromStdString(tmsg));
{
std::ostringstream out;
out << "5"; // RANK
item -> setText(6, QString::fromStdString(out.str()));
}
{
std::ostringstream out;
out << it -> id;
item -> setText(7, QString::fromStdString(out.str()));
}
{
std::ostringstream out;
out << it -> msgId;
item -> setText(8, QString::fromStdString(out.str()));
if ((oldSelected) && (mid == out.str()))
{
newSelected = item;
}
} }
if (it -> msgflags & RS_MSG_NEW) if (it -> msgflags & RS_MSG_NEW)
@ -421,14 +446,21 @@ void MessagesDialog::insertMsgTxtAndFiles()
if (!qtwi) if (!qtwi)
{ {
/* blank it */ /* blank it */
ui.dateText-> setText("");
ui.toText->setText("");
ui.fromText->setText("");
ui.filesText->setText("");
ui.subjectText->setText("");
ui.msgText->setText(""); ui.msgText->setText("");
ui.msgList->clear(); ui.msgList->clear();
return; return;
} }
else else
{ {
cid = qtwi -> text(7).toStdString(); cid = qtwi -> text(4).toStdString();
mid = qtwi -> text(8).toStdString(); mid = qtwi -> text(5).toStdString();
} }
/* Save the Data.... for later */ /* Save the Data.... for later */
@ -489,43 +521,55 @@ void MessagesDialog::insertMsgTxtAndFiles()
/* add the items in! */ /* add the items in! */
tree->insertTopLevelItems(0, items); tree->insertTopLevelItems(0, items);
/* add the Msg */ /* add the Msg */
std::ostringstream msgout;
std::list<PersonInfo>::const_iterator pit; std::list<PersonInfo>::const_iterator pit;
msgout << "Msg Header ----------------- TS: " << mi->ts;
if (mi->msgto.size() > 0) QString msgTxt;
msgout << std::endl << "To: ";
for(pit = mi->msgto.begin(); pit != mi->msgto.end(); pit++) for(pit = mi->msgto.begin(); pit != mi->msgto.end(); pit++)
{ {
msgout << pit->name << " (" << pit->id << "), "; msgTxt += QString::fromStdString(pit->name);
msgTxt += " <";
msgTxt += QString::fromStdString(pit->id);
msgTxt += ">, ";
} }
if (mi->msgcc.size() > 0) if (mi->msgcc.size() > 0)
msgout << std::endl << "Cc: "; msgTxt += "\nCc: ";
for(pit = mi->msgcc.begin(); pit != mi->msgcc.end(); pit++) for(pit = mi->msgcc.begin(); pit != mi->msgcc.end(); pit++)
{ {
msgout << pit->name << " (" << pit->id << "), "; msgTxt += QString::fromStdString(pit->name);
msgTxt += " <";
msgTxt += QString::fromStdString(pit->id);
msgTxt += ">, ";
} }
if (mi->msgbcc.size() > 0) if (mi->msgbcc.size() > 0)
msgout << std::endl << "Bcc: "; msgTxt += "\nBcc: ";
for(pit = mi->msgbcc.begin(); pit != mi->msgbcc.end(); pit++) for(pit = mi->msgbcc.begin(); pit != mi->msgbcc.end(); pit++)
{ {
msgout << pit->name << " (" << pit->id << "), "; msgTxt += QString::fromStdString(pit->name);
msgTxt += " <";
msgTxt += QString::fromStdString(pit->id);
msgTxt += ">, ";
} }
msgout << std::endl; {
msgout << "----------------------------"; QDateTime qtime;
msgout << std::endl; qtime.setTime_t(mi->ts);
QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss");
ui.dateText-> setText(timestamp);
}
ui.toText->setText(msgTxt);
ui.fromText->setText(QString::fromStdString(mi->srcname));
msgout << "Subject: " << mi -> title << std::endl; ui.subjectText->setText(QString::fromStdWString(mi -> title));
msgout << "Message: " << std::endl; ui.msgText->setText(QString::fromStdWString(mi->msg));
msgout << mi->msg << std::endl;
ui.msgText->setText(QString::fromStdString(msgout.str()));
{
std::ostringstream out;
out << "(" << mi->count << " Files)";
ui.filesText->setText(QString::fromStdString(out.str()));
}
rsiface->unlockData(); /* Unlock Interface */ rsiface->unlockData(); /* Unlock Interface */
@ -545,8 +589,8 @@ bool MessagesDialog::getCurrentMsg(std::string &cid, std::string &mid)
QTreeWidgetItem *qtwi = msglist -> currentItem(); QTreeWidgetItem *qtwi = msglist -> currentItem();
if (qtwi) if (qtwi)
{ {
cid = qtwi -> text(7).toStdString(); cid = qtwi -> text(4).toStdString();
mid = qtwi -> text(8).toStdString(); mid = qtwi -> text(5).toStdString();
return true; return true;
} }
return false; return false;

View File

@ -60,6 +60,9 @@ void updateMessages ( QTreeWidgetItem * item, int column );
void getcurrentrecommended(); void getcurrentrecommended();
void getallrecommended(); void getallrecommended();
/* handle splitter */
void togglefileview();
private: private:
bool getCurrentMsg(std::string &cid, std::string &mid); bool getCurrentMsg(std::string &cid, std::string &mid);

View File

@ -5,18 +5,22 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>519</width> <width>747</width>
<height>343</height> <height>492</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy vsizetype="Expanding" hsizetype="Preferred" >
<hsizetype>5</hsizetype>
<vsizetype>7</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize" >
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="palette" > <property name="palette" >
<palette> <palette>
<active> <active>
@ -501,12 +505,105 @@
<enum>Qt::DefaultContextMenu</enum> <enum>Qt::DefaultContextMenu</enum>
</property> </property>
<layout class="QGridLayout" > <layout class="QGridLayout" >
<property name="margin" > <item row="0" column="0" >
<number>4</number> <widget class="QPushButton" name="newmessageButton" >
</property> <property name="minimumSize" >
<property name="spacing" > <size>
<number>1</number> <width>24</width>
</property> <height>24</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip" >
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal; text-decoration:none;">
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">New Message&lt;/p>&lt;/body>&lt;/html></string>
</property>
<property name="styleSheet" >
<string>QPushButton
{
border-image: url(:/images/folder-draft24.png);
}
QPushButton:hover
{
border-image: url(:/images/folder-draft24-hover.png);
}
QPushButton:pressed
{
border-image: url(:/images/folder-draft24-pressed.png);
}
</string>
</property>
<property name="text" >
<string/>
</property>
<property name="iconSize" >
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="default" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QPushButton" name="replymessageButton" >
<property name="minimumSize" >
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip" >
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal; text-decoration:none;">
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">reply to selected message&lt;/p>&lt;/body>&lt;/html></string>
</property>
<property name="styleSheet" >
<string>
QPushButton
{
border-image: url(:/images/replymail24.png);
}
QPushButton:hover
{
border-image: url(:/images/replymail24-hover.png);
}
QPushButton:pressed
{
border-image: url(:/images/replymail-pressed.png);
}
</string>
</property>
<property name="text" >
<string/>
</property>
<property name="iconSize" >
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item row="0" column="2" > <item row="0" column="2" >
<widget class="QPushButton" name="removemessageButton" > <widget class="QPushButton" name="removemessageButton" >
<property name="minimumSize" > <property name="minimumSize" >
@ -554,15 +651,28 @@ border-image: url(:/images/deletemail-pressed.png);
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="3" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="4" > <item row="1" column="0" colspan="4" >
<widget class="QSplitter" name="splitter_3" > <widget class="QSplitter" name="splitter_2" >
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<widget class="QListWidget" name="listWidget" > <widget class="QListWidget" name="listWidget" >
<property name="maximumSize" > <property name="maximumSize" >
<size> <size>
<width>160</width> <width>120</width>
<height>16777215</height> <height>16777215</height>
</size> </size>
</property> </property>
@ -626,258 +736,443 @@ border-image: url(:/images/deletemail-pressed.png);
</property> </property>
</item> </item>
</widget> </widget>
<widget class="QSplitter" name="splitter_2" > <widget class="QSplitter" name="msgSplitter" >
<property name="orientation" > <property name="orientation" >
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<widget class="QSplitter" name="splitter" > <widget class="QTreeWidget" name="msgWidget" >
<property name="orientation" > <property name="sizePolicy" >
<enum>Qt::Vertical</enum> <sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>5</verstretch>
</sizepolicy>
</property> </property>
<widget class="QTreeWidget" name="msgWidget" > <property name="contextMenuPolicy" >
<property name="contextMenuPolicy" > <enum>Qt::CustomContextMenu</enum>
<enum>Qt::CustomContextMenu</enum> </property>
<property name="indentation" >
<number>16</number>
</property>
<property name="sortingEnabled" >
<bool>true</bool>
</property>
<property name="columnCount" >
<number>4</number>
</property>
<column>
<property name="text" >
<string>Date</string>
</property> </property>
<property name="indentation" > </column>
<number>16</number> <column>
<property name="text" >
<string>From</string>
</property> </property>
<property name="sortingEnabled" > </column>
<bool>true</bool> <column>
<property name="text" >
<string>Subject</string>
</property> </property>
<property name="columnCount" > </column>
<number>6</number> <column>
<property name="text" >
<string>#Recommendations</string>
</property> </property>
<column> </column>
<property name="text" >
<string>Date</string>
</property>
</column>
<column>
<property name="text" >
<string>From</string>
</property>
</column>
<column>
<property name="text" >
<string>Title</string>
</property>
</column>
<column>
<property name="text" >
<string>Count</string>
</property>
</column>
<column>
<property name="text" >
<string>Size</string>
</property>
</column>
<column>
<property name="text" >
<string>Msg</string>
</property>
</column>
</widget>
<widget class="QTextBrowser" name="msgText" />
</widget> </widget>
<widget class="QWidget" name="layoutWidget" > <widget class="QWidget" name="" >
<layout class="QGridLayout" > <layout class="QVBoxLayout" >
<property name="margin" > <item>
<number>0</number> <layout class="QHBoxLayout" >
</property> <item>
<property name="spacing" > <layout class="QVBoxLayout" >
<number>0</number> <item>
</property> <spacer>
<item row="1" column="0" colspan="2" > <property name="orientation" >
<widget class="QTreeWidget" name="msgList" > <enum>Qt::Vertical</enum>
<property name="contextMenuPolicy" > </property>
<enum>Qt::CustomContextMenu</enum> <property name="sizeType" >
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="label_16" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>60</width>
<height>10</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>10</height>
</size>
</property>
<property name="font" >
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>Subject:</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLabel" name="subjectText" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>0</width>
<height>10</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>10</height>
</size>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_7" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>60</width>
<height>10</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>10</height>
</size>
</property>
<property name="font" >
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>From:</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLabel" name="fromText" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>0</width>
<height>10</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>10</height>
</size>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_12" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>60</width>
<height>10</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>10</height>
</size>
</property>
<property name="font" >
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>Date:</string>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QLabel" name="dateText" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>0</width>
<height>10</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>10</height>
</size>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="label_14" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>60</width>
<height>10</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>10</height>
</size>
</property>
<property name="font" >
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>To:</string>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QLabel" name="toText" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>0</width>
<height>10</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>10</height>
</size>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QTextBrowser" name="msgText" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>10</verstretch>
</sizepolicy>
</property> </property>
<property name="sortingEnabled" >
<bool>true</bool>
</property>
<column>
<property name="text" >
<string>File Name</string>
</property>
</column>
<column>
<property name="text" >
<string>Size</string>
</property>
</column>
<column>
<property name="text" >
<string>Sources</string>
</property>
</column>
<column>
<property name="text" >
<string>Hash</string>
</property>
</column>
</widget> </widget>
</item> </item>
<item row="0" column="0" > <item>
<layout class="QGridLayout" > <layout class="QHBoxLayout" >
<property name="margin" > <item>
<number>0</number> <layout class="QGridLayout" >
</property> <property name="leftMargin" >
<property name="spacing" > <number>0</number>
<number>6</number>
</property>
<item row="0" column="0" >
<widget class="QLabel" name="label_6" >
<property name="text" >
<string/>
</property> </property>
<property name="pixmap" > <property name="topMargin" >
<pixmap resource="images.qrc" >:/images/attachment.png</pixmap> <number>0</number>
</property> </property>
</widget> <property name="rightMargin" >
</item> <number>0</number>
<item row="0" column="1" > </property>
<widget class="QLabel" name="label_2" > <property name="bottomMargin" >
<property name="text" > <number>0</number>
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css"> </property>
<property name="horizontalSpacing" >
<number>6</number>
</property>
<property name="verticalSpacing" >
<number>6</number>
</property>
<item row="0" column="1" >
<widget class="QLabel" name="label_6" >
<property name="text" >
<string/>
</property>
<property name="pixmap" >
<pixmap resource="images.qrc" >:/images/attachment.png</pixmap>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; } p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal; text-decoration:none;"> &lt;/style>&lt;/head>&lt;body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal; text-decoration:none;">
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-size:10pt; font-weight:600;">Recommended Files&lt;/span>&lt;/p>&lt;/body>&lt;/html></string> &lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-size:10pt; font-weight:600;">Recommended Files&lt;/span>&lt;/p>&lt;/body>&lt;/html></string>
</property>
</widget>
</item>
<item row="0" column="3" >
<widget class="QLabel" name="filesText" >
<property name="font" >
<font>
<pointsize>10</pointsize>
<italic>true</italic>
</font>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QPushButton" name="expandFilesButton" >
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/add_24x24.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>351</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="downloadButton" >
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/down.png</iconset>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item row="0" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QTreeWidget" name="msgList" >
<property name="contextMenuPolicy" >
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="sortingEnabled" >
<bool>true</bool>
</property>
<column>
<property name="text" >
<string>File Name</string>
</property>
</column>
<column>
<property name="text" >
<string>Size</string>
</property>
</column>
<column>
<property name="text" >
<string>Sources</string>
</property>
</column>
<column>
<property name="text" >
<string>Hash</string>
</property>
</column>
</widget>
</widget> </widget>
</widget> </widget>
</item> </item>
<item row="0" column="1" >
<widget class="QPushButton" name="replymessageButton" >
<property name="minimumSize" >
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip" >
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal; text-decoration:none;">
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">reply to selected message&lt;/p>&lt;/body>&lt;/html></string>
</property>
<property name="styleSheet" >
<string>
QPushButton
{
border-image: url(:/images/replymail24.png);
}
QPushButton:hover
{
border-image: url(:/images/replymail24-hover.png);
}
QPushButton:pressed
{
border-image: url(:/images/replymail-pressed.png);
}
</string>
</property>
<property name="text" >
<string/>
</property>
<property name="iconSize" >
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QPushButton" name="newmessageButton" >
<property name="minimumSize" >
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip" >
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal; text-decoration:none;">
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">New Message&lt;/p>&lt;/body>&lt;/html></string>
</property>
<property name="styleSheet" >
<string>QPushButton
{
border-image: url(:/images/folder-draft24.png);
}
QPushButton:hover
{
border-image: url(:/images/folder-draft24-hover.png);
}
QPushButton:pressed
{
border-image: url(:/images/folder-draft24-pressed.png);
}
</string>
</property>
<property name="text" >
<string/>
</property>
<property name="iconSize" >
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="default" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="3" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
<tabstops> <tabstops>

View File

@ -336,11 +336,24 @@ void PeersDialog::chatfriend()
if (!i) if (!i)
return; return;
std::string status = (i -> text(1)).toStdString();
std::string name = (i -> text(2)).toStdString(); std::string name = (i -> text(2)).toStdString();
std::string id = (i -> text(10)).toStdString(); std::string id = (i -> text(10)).toStdString();
if (status != "Online") RsPeerDetails detail;
if (!rsPeers->getPeerDetails(id, detail))
{
return;
}
if (detail.state & RS_PEER_STATE_CONNECTED)
{
/* must reference ChatDialog */
if (chatDialog)
{
chatDialog->getPrivateChat(id, name, true);
}
}
else
{ {
/* info dialog */ /* info dialog */
QMessageBox::StandardButton sb = QMessageBox::question ( NULL, QMessageBox::StandardButton sb = QMessageBox::question ( NULL,
@ -351,16 +364,11 @@ void PeersDialog::chatfriend()
{ {
msgfriend(); msgfriend();
} }
return;
}
/* must reference ChatDialog */
if (chatDialog)
{
chatDialog->getPrivateChat(id, name, true);
} }
return;
} }
void PeersDialog::msgfriend() void PeersDialog::msgfriend()
{ {
std::cerr << "SharedFilesDialog::msgfriend()" << std::endl; std::cerr << "SharedFilesDialog::msgfriend()" << std::endl;

View File

@ -200,7 +200,7 @@ void PopupChatDialog::addChatMsg(ChatInfo *ci)
/* add in lines at the bottom */ /* add in lines at the bottom */
std::ostringstream out; QString extraTxt;
int ts = time(NULL); int ts = time(NULL);
@ -222,7 +222,7 @@ void PopupChatDialog::addChatMsg(ChatInfo *ci)
{ {
QString line = "<br>\n<span style=\"color:#1D84C9\"><strong> ----- PEER OFFLINE (Chat will be lost) -----</strong></span> \n<br>"; QString line = "<br>\n<span style=\"color:#1D84C9\"><strong> ----- PEER OFFLINE (Chat will be lost) -----</strong></span> \n<br>";
out << line.toStdString(); extraTxt += line;
} }
@ -236,40 +236,35 @@ void PopupChatDialog::addChatMsg(ChatInfo *ci)
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
// Nothing. // Nothing.
#else #else
out << "<br>" << std::endl; extraTxt += "<br>\n";
#endif #endif
for(int i = 0; i < n; i++) for(int i = 0; i < n; i++)
{ {
out << spaces; extraTxt += " ";
} }
//out << "[ " << ci->name << " +" << ts - lastChatTime << "s ]" << std::endl;
//out << "<br>" << std::endl;
QString timestamp = "(" + QDateTime::currentDateTime().toString("hh:mm:ss") + ") "; QString timestamp = "(" + QDateTime::currentDateTime().toString("hh:mm:ss") + ") ";
//QString pre = tr("Peer:" ); //QString pre = tr("Peer:" );
QString name = QString::fromStdString(ci->name); QString name = QString::fromStdString(ci->name);
QString line = "<span style=\"color:#1D84C9\"><strong>" + timestamp + QString line = "<span style=\"color:#1D84C9\"><strong>" + timestamp +
" " + name + "</strong></span> \n<br>"; " " + name + "</strong></span> \n<br>";
out << line.toStdString(); extraTxt += line;
} }
out << ci -> msg; extraTxt += QString::fromStdWString(ci -> msg);
/* This might be WIN32 only - or maybe Qt4.2.2 only - but need it for windows at the mom */ /* This might be WIN32 only - or maybe Qt4.2.2 only - but need it for windows at the mom */
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
//out << "<br>"; // << std::endl; extraTxt += "\n";
out << std::endl;
#else #else
out << std::endl; extraTxt += "\n";
#endif #endif
lastChatTime = ts; lastChatTime = ts;
lastChatName = ci->name; lastChatName = ci->name;
QString extra = QString::fromStdString(out.str()); currenttxt += extraTxt;
currenttxt += extra;
msgWidget->setHtml(currenttxt); msgWidget->setHtml(currenttxt);
@ -296,7 +291,7 @@ void PopupChatDialog::sendChat()
rsiface->unlockData(); /* Unlock Interface */ rsiface->unlockData(); /* Unlock Interface */
} }
ci.msg = lineWidget->text().toStdString(); ci.msg = lineWidget->text().toStdWString();
ci.chatflags = RS_CHAT_PRIVATE; ci.chatflags = RS_CHAT_PRIVATE;
addChatMsg(&ci); addChatMsg(&ci);

View File

@ -162,13 +162,13 @@ void ChanMsgDialog::insertSendList()
/* (0) Person */ /* (0) Person */
item -> setText(0, QString::fromStdString(detail.name)); item -> setText(0, QString::fromStdString(detail.name));
/* () Org */ /* () Org */
item -> setText(1, QString::fromStdString(detail.org)); //item -> setText(1, QString::fromStdString(detail.org));
/* () Location */ /* () Location */
item -> setText(2, QString::fromStdString(detail.location)); //item -> setText(2, QString::fromStdString(detail.location));
/* () Country */ /* () Country */
item -> setText(3, QString::fromStdString(detail.email)); //item -> setText(3, QString::fromStdString(detail.email));
/* () Id */ /* () Id */
item -> setText(4, QString::fromStdString(detail.id)); item -> setText(1, QString::fromStdString(detail.id));
item -> setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); item -> setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
//item -> setCheckState(0, Qt::Checked); //item -> setCheckState(0, Qt::Checked);
@ -192,7 +192,7 @@ void ChanMsgDialog::insertSendList()
/* remove old items ??? */ /* remove old items ??? */
sendWidget->clear(); sendWidget->clear();
sendWidget->setColumnCount(6); sendWidget->setColumnCount(1);
/* add the items in! */ /* add the items in! */
sendWidget->insertTopLevelItems(0, items); sendWidget->insertTopLevelItems(0, items);
@ -378,8 +378,8 @@ void ChanMsgDialog::sendMessage()
/* construct a message */ /* construct a message */
MessageInfo mi; MessageInfo mi;
mi.title = ui.titleEdit->text().toStdString(); mi.title = ui.titleEdit->text().toStdWString();
mi.msg = ui.msgText->toPlainText().toStdString(); mi.msg = ui.msgText->toPlainText().toStdWString();
/* filled in later */ /* filled in later */
//mi.msgId = rand(); //mi.msgId = rand();
@ -451,7 +451,7 @@ void ChanMsgDialog::togglePersonItem( QTreeWidgetItem *item, int col )
std::cerr << "TogglePersonItem()" << std::endl; std::cerr << "TogglePersonItem()" << std::endl;
/* extract id */ /* extract id */
std::string id = (item -> text(4)).toStdString(); std::string id = (item -> text(1)).toStdString();
/* get state */ /* get state */
bool inMsg = (Qt::Checked == item -> checkState(0)); /* alway column 0 */ bool inMsg = (Qt::Checked == item -> checkState(0)); /* alway column 0 */

View File

@ -248,8 +248,12 @@ void NotifyQt::displayMessages()
for(it = msgs.begin(); it != msgs.end(); it++) for(it = msgs.begin(); it != msgs.end(); it++)
{ {
out << "Message: "; out << "Message: ";
out << it->title << std::endl;
out << "\t" << it->msg << std::endl; std::string cnv_title(it->title.begin(), it->title.end());
out << cnv_title << std::endl;
std::string cnv_msg(it->msg.begin(), it->msg.end());
out << "\t" << cnv_msg << std::endl;
const std::list<FileInfo> &files = it -> files; const std::list<FileInfo> &files = it -> files;
for(fit = files.begin(), i = 1; fit != files.end(); fit++, i++) for(fit = files.begin(), i = 1; fit != files.end(); fit++, i++)
{ {

View File

@ -187,11 +187,11 @@ class MessageInfo: public BaseInfo
std::list<PersonInfo> msgcc; std::list<PersonInfo> msgcc;
std::list<PersonInfo> msgbcc; std::list<PersonInfo> msgbcc;
std::string title; std::wstring title;
std::string msg; std::wstring msg;
std::string attach_title; std::wstring attach_title;
std::string attach_comment; std::wstring attach_comment;
std::list<FileInfo> files; std::list<FileInfo> files;
int size; /* total of files */ int size; /* total of files */
int count; /* file count */ int count; /* file count */
@ -228,7 +228,7 @@ class ChatInfo: public BaseInfo
std::string rsid; std::string rsid;
unsigned int chatflags; unsigned int chatflags;
std::string name; std::string name;
std::string msg; std::wstring msg;
}; };
/* matched to the uPnP states */ /* matched to the uPnP states */