MsgFile::MsgFile(MsgEdit *parent, Message *msg) : QObject(parent) { m_client = msg->client(); m_edit = parent; m_bCanSend = false; if (m_edit->m_edit->isReadOnly()){ m_edit->m_edit->setText(""); m_edit->m_edit->setReadOnly(false); } m_edit->m_edit->setTextFormat(Qt::PlainText); QString t = msg->getPlainText(); if (!t.isEmpty()) m_edit->m_edit->setText(t); Command cmd; cmd->id = CmdFileName; cmd->param = parent; Event eWidget(EventCommandWidget, cmd); CToolEdit *edtName = (CToolEdit*)(eWidget.process()); if (edtName){ connect(edtName, SIGNAL(textChanged(const QString&)), this, SLOT(changed(const QString&))); edtName->setText(static_cast<FileMessage*>(msg)->getFile()); } changed(static_cast<FileMessage*>(msg)->getFile()); }
void MsgFile::selectFile() { Command cmd; cmd->id = CmdFileName; cmd->param = m_edit; Event eWidget(EventCommandWidget, cmd); CToolEdit *edtName = (CToolEdit*)(eWidget.process()); if (edtName == NULL) return; QString s = edtName->text(); #ifdef WIN32 s.replace(QRegExp("\\\\"), "/"); #endif QStringList lst = Q3FileDialog::getOpenFileNames(QString::null, QString::null, m_edit->topLevelWidget()); if ((lst.count() > 1) || ((lst.count() > 0) && (lst[0].find(' ') >= 0))){ for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it){ #ifdef WIN32 (*it).replace(QRegExp("/"), "\\"); #endif *it = QString("\"") + *it + QString("\""); } #ifdef WIN32 }else{ for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it){ QString &s = *it; s.replace(QRegExp("/"), "\\"); } #endif } edtName->setText(lst.join(" ")); }
MsgUrl::MsgUrl(MsgEdit *parent, Message *msg) : QObject(parent) { m_client = msg->client(); m_edit = parent; if (m_edit->m_edit->isReadOnly()){ m_edit->m_edit->setText(QString::null); m_edit->m_edit->setReadOnly(false); } QString t = msg->getPlainText(); if (!t.isEmpty()) m_edit->m_edit->setText(t); Command cmd; cmd->id = CmdUrlInput; cmd->param = m_edit; EventCommandWidget eWidget(cmd); eWidget.process(); CToolEdit *edtUrl = qobject_cast<CToolEdit*>(eWidget.widget()); if (edtUrl){ connect(edtUrl, SIGNAL(textChanged(const QString&)), this, SLOT(urlChanged(const QString&))); edtUrl->setText(static_cast<UrlMessage*>(msg)->getUrl()); if (edtUrl->text().isEmpty()){ QString url; EventGetURL e; e.process(); url = e.url(); if (!url.isEmpty()){ url = url.mid(1); int n = url.indexOf('\"'); if (n > 0){ QString u = url.left(n); edtUrl->setText(u); url = url.mid(n + 1); n = url.indexOf('\"'); if (n > 0) url = url.mid(n + 1); } n = url.indexOf('\"'); if (n > 0){ url = url.left(n); m_edit->m_edit->setText(url); } } } urlChanged(edtUrl->text()); } }
void MsgFile::selectFile() { Command cmd; cmd->id = CmdFileName; cmd->param = m_edit; EventCommandWidget eWidget(cmd); eWidget.process(); CToolEdit *edtName = qobject_cast<CToolEdit*>(eWidget.widget()); if (edtName == NULL) return; QString s = edtName->text(); QStringList lst = QFileDialog::getOpenFileNames(m_edit->topLevelWidget()); if ((lst.count() > 1) || ((lst.count() > 0) && (lst[0].indexOf(' ') >= 0))){ for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it){ *it = '\"' + QDir::convertSeparators(*it) + '\"'; } }else{ for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it){ *it = QDir::convertSeparators(*it); } } edtName->setText(lst.join(" ")); }