Ejemplo n.º 1
0
bool UserProfile::reload()
{
    QDomDocument domDoc;
    QDomElement rootElement = findElement(this, source(), parentElement(), domDoc);
    if (!rootElement.isNull()) {
        QDomElement idElement = rootElement.firstChildElement("id");
        if (!idElement.isNull()) {
            setId(idElement.text().toInt());
        } else {
            setId(-1);
        }

        QDomElement nameElement = rootElement.firstChildElement("name");
        if (!nameElement.isNull()) {
            setName(nameElement.text());
        } else {
            setName("");
        }

        QImage nullImage;
        QDomElement photoElement = rootElement.firstChildElement("photo");
        if (!photoElement.isNull()) {
            QByteArray photoData = QByteArray::fromBase64(photoElement.text().toLocal8Bit());
            if (!photoData.isEmpty()) {
                QImage photo;
                if(photo.loadFromData(photoData)) {
                    setPhoto(photo);
                } else {
                    setPhoto(nullImage);
                }
            } else {
                setPhoto(nullImage);
            }
        } else {
            setPhoto(nullImage);
        }

        QDomElement statusesElement = rootElement.firstChildElement("statuses");
        if (!statusesElement.isNull()) {
            m_stateModel->loadFromDomElement(statusesElement);
        } else {
            m_stateModel->removeRows(0, m_stateModel->rowCount());
        }
        return true;
    }
    setName("");
    QImage nullImage (QSize(1,1), QImage::Format_ARGB32);
    setPhoto(nullImage);
    m_stateModel->removeRows(0, m_stateModel->rowCount());

    return false;
}
Ejemplo n.º 2
0
   bool metacall(Person* c, const QByteArray& key, const QByteArray& value) {
      const QStringList settings = QString(key).split(';');
      if (settings.length() < 1)
         return false;

      if (!m_hHash[settings[0].toLatin1()]) {
         if(key.contains(VCardUtils::Property::PHOTO)) {
            //key must contain additional attributes, we don't need them right now (ENCODING, TYPE...)
            setPhoto(c, key, value);
            return true;
         }

         if(key.contains(VCardUtils::Property::ADDRESS)) {
            addAddress(c, key, value);
            return true;
         }

         if(key.contains(VCardUtils::Property::TELEPHONE)) {
            addContactMethod(c, key, value);
            return true;
         }

         return false;
      }
      (this->*(m_hHash[settings[0].toLatin1()]))(c,key,value);
      return true;
   }
Ejemplo n.º 3
0
ProfileWindow::ProfileWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::ProfileWindow)
{
    ui->setupUi(this);
    ui->textEdit->setMainWindow(this);

    ui->centralwidget->installEventFilter(this);

    connect(ui->selectPictureButton,SIGNAL(clicked()),this,SLOT(selectPicture()));
    connect(ui->saveButton,SIGNAL(clicked()),this,SLOT(verifyUserName()));
    connect(ui->textEdit,SIGNAL(returnPressed()),this,SLOT(verifyUserName()));
    connect(ui->selectEmojiButton,SIGNAL(clicked()),
            ui->textEdit,SLOT(selectEmojiButtonClicked()));

    connect(ui->actionRemovePhoto,SIGNAL(triggered()),
            this,SLOT(removePhoto()));

    ui->nLabel->setText("Select your new name:");
    ui->textEdit->setText(Utilities::WATextToHtml(Client::userName, 32));
    ui->textEdit->moveCursor(QTextCursor::End);
    ui->textEdit->setFocus();

    QDir home = QDir::home();
    QString fileName = home.path() + CACHE_DIR"/profilephoto.png";

    if (home.exists(fileName))
    {
        QImage image(fileName);
        setPhoto(image);
    }
}
Ejemplo n.º 4
0
void IdentityDialog::slotSelectPhoto()
{
	bool ok;
	QString photo = Kopete::UI::AvatarDialog::getAvatar(this, d->photoPath, &ok);
	if ( ok )
		setPhoto( photo );
}
Ejemplo n.º 5
0
void ClientEditor::changePhoto()
{
  QString fname = KFileDialog::getOpenFileName();
  if (!fname.isEmpty()) {
    QPixmap p = QPixmap(fname);
    setPhoto(p);
  }
}
Ejemplo n.º 6
0
void BE::Contacts::setContact(const QModelIndex &index)
{
    QModelIndex translated = index;
    if (index.model() == m_sortFilterProxy)
        translated = m_sortFilterProxy->mapToSource(index);

    if (m_currentContact) {
        if (m_abook->model()->itemFromIndex(translated) == m_currentContact)
            return; // same one
        for (QList<Field>::const_iterator   it = fields.constBegin(),
                                            end = fields.constEnd(); it != end; ++it) {
            if (it->type != Gui::AbookAddressbook::Photo) {
                QString s = lifeText(it->label);
                if (s.startsWith("["))
                    s.clear();
                if (m_currentContact->data(it->type).toString() != s) {
                    m_currentContact->setData( true, Gui::AbookAddressbook::Dirty );
                    if (s.isEmpty())
                        m_currentContact->setData( QVariant(), it->type ); // invalidate
                    else
                        m_currentContact->setData( s, it->type );
                    m_dirty = true;
                }
            }
        }
    }

    m_currentContact = m_abook->model()->itemFromIndex(translated);
    if (!m_currentContact)
        return;

    for (QList<Field>::const_iterator   it = fields.constBegin(),
        end = fields.constEnd(); it != end; ++it) {
        if (it->type != Gui::AbookAddressbook::Photo) {
            QString s;
            QVariant v = m_currentContact->data(it->type);
            if (v.isValid())
                s = v.toString();
            else
                s = "[" + it->key + "]";
            setText(it->label, s);
        }
    }
    QPixmap userPic = m_incognitoPic;
    QString photo = m_currentContact->data(Gui::AbookAddressbook::Photo).toString();
    if (!photo.isEmpty()) {
        if (QDir::isRelativePath(photo))
            photo = QDir::homePath() + "/.abook/" + photo;
        if (QFile::exists(photo) && setPhoto(photo))
            return;
    }
    m_ui2->photo->setPixmap(userPic);

    m_ui->contacts->setCurrentIndex(m_sortFilterProxy->mapFromSource(translated));
}
Ejemplo n.º 7
0
/* Reads user's selected wheels mod. Send info to Make class, which will search for the wheel selection from the file
 * and set appropriate price. Projects then calls setPhoto.*/
void Projects::on_wheelSelection_activated(const QString &arg1)
{
    carChosen.addWheel(arg1); //sends wheel option to make to change object to appropriate object
    calculator->updateTotal(carChosen);
    if(includeTax == true) //Will display total with taxes only if option is selected
    {
        calculator->updateTaxTotal();
        calculator->calculateGrandTotal();
        ui->calcDisplay->setNum(calculator->getGrandTotal());
    }
    else
        ui->calcDisplay->setNum(calculator->getTotal());
    setPhoto(300 + ui->wheelSelection->currentIndex());
}
Ejemplo n.º 8
0
/* Reads user's selected lights mod. Send info to Make class, which will search for the light selection from the file
 * and set appropriate price. Projects then calls setPhoto.*/
void Projects::on_lightSelection_activated(const QString &arg1)
{
    carChosen.addLights(arg1); //sends light option to Make to change object's information to what it should now be
    calculator->updateTotal(carChosen); //Calculates new total
    if(includeTax == true) //Will calculate and display total with taxes only if option is selected
    {
        calculator->updateTaxTotal();
        calculator->calculateGrandTotal();
        ui->calcDisplay->setNum(calculator->getGrandTotal());;
    }
    else //Otherwise display raw price
        ui->calcDisplay->setNum(calculator->getTotal());
    setPhoto(100 + ui->lightSelection->currentIndex()); //send light selection to user
}
Ejemplo n.º 9
0
bool AddContactDialog::eventFilter(QObject *obj, QEvent *e)
{
    if( e->type() == QEvent::MouseButtonRelease )
    {
        if( obj == ui->lb_photo )
        {
            QString filename = QFileDialog::getOpenFileName(
                                   this,
                                   tr("Open Picture"),
                                   QDir::currentPath(),
                                   tr("pictur files (*.jpg *.png *.bmp);;All files(*.*)") );
            if (!filename.isEmpty())
                setPhoto( filename );
        }
    }
    return QDialog::eventFilter(obj, e);
}
Ejemplo n.º 10
0
void ProfileWindow::finishedPhotoSelection(QImage image)
{
    // Save picture in disk
    QDir home = QDir::home();
    QString fileName = home.path() + CACHE_DIR"/profilephoto.png";

    image.save(fileName);

    // Show picture in window
    setPhoto(image);

    // Save the thumbnail
    // It'll be updated in DB when the change is confirmed from WA Servers
    Contact &c = Client::roster->getContact(Client::myJid);
    c.photo = image.scaled(QSize(64,64), Qt::KeepAspectRatio, Qt::SmoothTransformation);

    emit photoSelected(Client::myJid, image);
}
Ejemplo n.º 11
0
void MainWindow::showDetail(const QModelIndex index)
{
    if( ! index.isValid() )
    {
        return;
    }

    Global::g_editContactDlg->readContactInfo(index);
    Global::g_editContactDlg->setCurrentModelIndex(index);

    QString txt;
    int r = index.row();
    QString group = tr("<b>Group:</b>") + index.model()->index(r, GROUP).data().toString();
    QString lname = tr("<b>Last Name:</b>") + index.model()->index(r, LASTNAME).data().toString();
    QString fname = tr("<b>First Name:</b>") + index.model()->index(r, FirstName).data().toString();
    QString nname = tr("<b>Nick Name:</b>") + index.model()->index(r, NICKNAME).data().toString();
    QString sex = tr("<b>Sex:</b>") + index.model()->index(r, SEX).data().toString();
    QString age = tr("<b>Age:</b>") + index.model()->index(r, AGE).data().toString();
    QString birth = tr("<b>Birth Day:</b>") + index.model()->index(r, BIRTHDAY).data().toString();
    QString mobile = tr("<b>Mobile:</b>") + index.model()->index(r, MOBILE).data().toString();
    QString email = tr("<b>E-mail:</b>") + index.model()->index(r, EMAIL).data().toString();
    QString qq = tr("<b>QQ:</b>") + index.model()->index(r, QQ).data().toString();

    QByteArray photo = index.model()->index(r, PHOTO).data().toByteArray();

    QString office = tr("<b>Office:</b>") + index.model()->index(r, OFFICE).data().toString();
//    QString officeTel = tr("<b>Office Tel:</b>") + index.model()->index(r, OFFICETEL).data().toString();
    QString officeAddr = tr("<b>Office Address:</b>") + index.model()->index(r, OFFICEADDR).data().toString();
//    QString officeCode = tr("<b>Office Code:</b>") + index.model()->index(r, OFFICECODE).data().toString();
//    QString homeTel = tr("<b>Home Tel:</b>") + index.model()->index(r, HOMETEL).data().toString();
    QString homeAddr = tr("<b>Home Address:</b>") + index.model()->index(r, HOMEADDR).data().toString();
//    QString homeCode = tr("<b>Home Code:</b>") + index.model()->index(r, HOMECODE).data().toString();
    QString weibo = tr("<b>Weibo:</b>") + index.model()->index(r, WEIBO).data().toString();
    QString site = tr("<b>WebSite:</b>") + index.model()->index(r, WEBSITE).data().toString();

    txt = /*id + "<br>" +*/ group + "<br>" + lname + "<br>" + fname + "<br>" + nname + "<br>" + sex + "<br>" + age + "<br>" + \
          birth + "<br>" + mobile + "<br>" + email + "<br>" + qq + "<br>" + office + "<br>" + /*officeTel +"\n" +*/ \
          officeAddr + "<br>" /*+ officeCode + "<br>"*/ + /*homeTel + "\n" +*/ homeAddr + "<br>" + /*homeCode + "\n" +*/ \
          weibo + "<br>" + site;
    ui->detailsLabel->setText( txt );
    setPhoto(photo);
}
Ejemplo n.º 12
0
void BE::Contacts::importPhoto(const QString &path)
{
    if (!m_currentContact) {
        qWarning("CANNOT IMPORT PHOTO FOR INVALID CONTACT!");
        return;
    }
    const QString photo = QString::number(
#if QT_VERSION < QT_VERSION_CHECK(4, 7, 0)
                QDateTime(QDate(1970, 1, 1), QTime(0, 0, 0)).secsTo(QDateTime::currentDateTime())
#else
                QDateTime::currentMSecsSinceEpoch()
#endif
                ) + "." + QFileInfo(path).suffix();

    const QString file = QDir::homePath() + "/.abook/" + photo;
    if (QFile::copy(path, file)) {
        m_currentContact->setData(photo, Gui::AbookAddressbook::Photo);
        setPhoto(file);
    }
}
Ejemplo n.º 13
0
void QXmppVCard::parse(const QDomElement& nodeRecv)
{
    QXmppStanza::parse(nodeRecv);

    setTypeFromStr(nodeRecv.attribute("type"));

    // vCard
    QDomElement cardElement = nodeRecv.firstChildElement("vCard");
    m_fullName = cardElement.firstChildElement("FN").text();
    m_nickName = cardElement.firstChildElement("NICKNAME").text();
    QDomElement nameElement = cardElement.firstChildElement("N");
    m_firstName = nameElement.firstChildElement("GIVEN").text();
    m_lastName = nameElement.firstChildElement("FAMILY").text();
    m_middleName = nameElement.firstChildElement("MIDDLE").text();
    m_url = cardElement.firstChildElement("URL").text();
    QByteArray base64data = cardElement.
                            firstChildElement("PHOTO").
                            firstChildElement("BINVAL").text().toAscii();
    setPhoto(QByteArray::fromBase64(base64data));
}
Ejemplo n.º 14
0
void IdentityDialog::load()
{
	//-------------- General Info ---------------------
	// Photo
	if (d->identity->hasProperty( d->props->photo().key() ))
		setPhoto( d->identity->property(d->props->photo()).value().toString() );


	// Label
	d->general.label->setText( d->identity->label() );

	// NickName
	if (d->identity->hasProperty( d->props->nickName().key() ))
		d->general.nickName->setText( d->identity->property(d->props->nickName()).value().toString() );

	// FirstName
	if (d->identity->hasProperty( d->props->firstName().key() ))
		d->general.firstName->setText( d->identity->property(d->props->firstName()).value().toString() );

	// LastName
	if (d->identity->hasProperty( d->props->lastName().key() ))
		d->general.lastName->setText( d->identity->property(d->props->lastName()).value().toString() );
	
	//-------------- Detailed Info --------------------
	// Email
	if (d->identity->hasProperty( d->props->emailAddress().key() ))
		d->detailed.email->setText( d->identity->property(d->props->emailAddress()).value().toString() );

	// PrivatePhone
	if (d->identity->hasProperty( d->props->privatePhone().key() ))
		d->detailed.privatePhone->setText( 
				d->identity->property(d->props->privatePhone()).value().toString() );

	// MobilePhone
	if (d->identity->hasProperty( d->props->privateMobilePhone().key() ))
		d->detailed.mobilePhone->setText( 
				d->identity->property(d->props->privateMobilePhone()).value().toString() );

}
Ejemplo n.º 15
0
void PurchaseEditor::checkIfCodeExists()
{
  Azahar *myDb = new Azahar;
  myDb->setDatabase(db);
  gelem = "";
  QString codeStr = ui->editCode->text();
  if (codeStr.isEmpty()) codeStr = "0";
  ProductInfo pInfo = myDb->getProductInfo(codeStr);
  if (pInfo.code ==0 && pInfo.desc=="Ninguno") productExists = false;
  if (pInfo.code > 0) {
    status = estatusMod;
    productExists = true;
    qtyOnDb  = pInfo.stockqty;
    //Prepopulate dialog...
    ui->editDesc->setText(pInfo.desc);
    setCategory(pInfo.category);
    setMeasure(pInfo.units);
    ui->editCost->setText(QString::number(pInfo.cost));
    ui->editTax->setText(QString::number(pInfo.tax));
    //FIXME: add tax models
    //ui->editExtraTaxes->setText(QString::number(pInfo.extratax));
    ui->editFinalPrice->setText(QString::number(pInfo.price));
    ui->editPoints->setText(QString::number(pInfo.points));
    ui->chIsAGroup->setChecked(pInfo.isAGroup);
    gelem = pInfo.groupElementsStr;
    if (!(pInfo.photo).isEmpty()) {
      QPixmap photo;
      photo.loadFromData(pInfo.photo);
      setPhoto(photo);
    }
  } else {
    qDebug()<< "no product found with code "<<codeStr;
    qulonglong codeSaved = getCode();
    resetEdits();
    setCode(codeSaved);
  }
}
Ejemplo n.º 16
0
void ChannelData::setPhoto(const MTPChatPhoto &photo) {
	setPhoto(userpicPhotoId(), photo);
}
Ejemplo n.º 17
0
void IdentityDialog::slotClearPhoto()
{
	setPhoto( QString() );
}
Ejemplo n.º 18
0
void UserProfile::removePhoto()
{
    QImage nullImage;
    setPhoto(nullImage);
}
Ejemplo n.º 19
0
void Album::parseLastFmInfo(QByteArray bytes) {
    QXmlStreamReader xml(bytes);

    while(!xml.atEnd() && !xml.hasError()) {
        QXmlStreamReader::TokenType token = xml.readNext();
        if(token == QXmlStreamReader::StartElement) {

            if(xml.name() == "image" && xml.attributes().value("size") == "extralarge") {

                // qDebug() << title << " photo:" << imageUrl;

                bool imageAlreadyPresent = false;
                QString imageLocation = QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/albums/" + getHash();
                if (QFile::exists(imageLocation)) {
                    QFileInfo imageFileInfo(imageLocation);
                    const uint imagelastModified = imageFileInfo.lastModified().toTime_t();
                    if (imagelastModified > QDateTime::currentDateTime().toTime_t() - 86400*30) {
                        imageAlreadyPresent = true;
                    }
                }

                if (!imageAlreadyPresent) {
                    QString imageUrl = xml.readElementText();
                    // qDebug() << name << " photo:" << imageUrl;
                    if (!imageUrl.isEmpty()) {
                        QUrl url = QUrl::fromEncoded(imageUrl.toUtf8());
                        QObject *reply = The::http()->get(url);
                        connect(reply, SIGNAL(data(QByteArray)), SLOT(setPhoto(QByteArray)));
                    }
                }

            }

            else if(xml.name() == "releasedate") {
                QString releasedateString = xml.readElementText().simplified();
                if (!releasedateString.isEmpty()) {
                    // Something like "6 Apr 1999, 00:00"
                    QDateTime releaseDate = QDateTime::fromString(releasedateString, "d MMM yyyy, hh:mm");
                    int releaseYear = releaseDate.date().year();
                    if (releaseYear > 0) {
                        year = releaseDate.date().year();
                    }
                    // qDebug() << name << releasedateString << releaseDate.toString();
                }
            }

            // wiki
            // TODO check at least parent element name
            else if(xml.name() == "content") {
                QString bio = xml.readElementText();
                // qDebug() << name << " got wiki";
                if (!bio.isEmpty()) {
                    // store bio
                    const QString storageLocation =
                            QDesktopServices::storageLocation(QDesktopServices::DataLocation)
                            + "/albums/wikis/";
                    QDir dir;
                    dir.mkpath(storageLocation);
                    QFile file(storageLocation + getHash());
                    if (!file.open(QIODevice::WriteOnly)) {
                        qDebug() << "Error opening file for writing" << file.fileName();
                    }
                    QTextStream stream( &file ); // we will serialize the data into the file
                    stream << bio;
                }
            }

        }

    }

    /* Error handling. */
    if(xml.hasError()) {
        qDebug() << xml.errorString();
    }

    emit gotInfo();
}
Ejemplo n.º 20
0
void UserProfile::setPhoto(const QUrl &filePath)
{
    QImage photo (filePath.toLocalFile());
    setPhoto(photo);
}
Ejemplo n.º 21
0
void CreateGroupWindow::finishedPhotoSelection(QImage image)
{
    this->photo = image;

    setPhoto(image);
}