void CFavoriteSyncHandler::UpdateToServerL()
{
   RArray<TWFFavSyncListIndex>& indexList = iSyncManager->GetUpdateList();
   for (TInt i = 0; i < indexList.Count(); ++i) {
      TWFFavSyncListIndex listEntry = indexList[i];
      if (listEntry.type == EWFServerList) {
         Favorite* fav = iFavoriteList->at(listEntry.index);
         fav->setSynced(EFalse);
         class isab::ChangeFavoriteMess cfm(fav);
         // Send a message with this as receiver to end up in 
         // GuiProtReceiveMessage function below. Also add the message id 
         // to our array to make sure that we can control that all messages 
         // have returned to us.
         iServerMessageQueue.InsertInOrder(iSender.SendMessage(cfm, this));
      }
   }
   iState |= EWFUpdateToServerDone;
   iState |= EWFWaitingForServerFavReplies;
   if ((iState & EWFAddToServerDone) && (iState & EWFDeleteFromServerDone) && 
       (iState & EWFUpdateToServerDone) && (iServerMessageQueue.Count() == 0)) {
      iState &= ~EWFWaitingForServerFavReplies;
      iState |= EWFServerQueueDone;
   }
   ProcessNextState(); 
}
Пример #2
0
void FavoriteTest::testFromString()
{
	QString from = "fate/stay_night|50|2016-07-02T16:35:12";

	QDateTime date = QDateTime::fromString("2016-07-02 16:35:12", "yyyy-MM-dd HH:mm:ss");
	Favorite expected("fate/stay_night", 50, date);
	Favorite actual = Favorite::fromString("", from);

	QCOMPARE(actual.getName(), expected.getName());
	QCOMPARE(actual.getNote(), expected.getNote());
	QCOMPARE(actual.getLastViewed(), expected.getLastViewed());
}
Пример #3
0
void favoritesTab::loadFavorite(QString name)
{
	int index = name.isEmpty() ? m_currentFav : m_favorites.indexOf(name);
	if (index < 0)
		return;

	Favorite fav = m_favorites[index];
	m_currentTags = fav.getName();
	m_loadFavorite = fav.getLastViewed();

	ui->widgetResults->show();
	load();
}
Пример #4
0
void Favorites::load()
{
    qDebug("Favorites::load");

    QRegExp m3u_id("^#EXTM3U|^#M3U");
    QRegExp info("^#EXTINF:(.*),(.*),(.*)");

    QFile f( _filename );
    if ( f.open( QIODevice::ReadOnly ) )
    {

        f_list.clear();

        Favorite fav;

        QTextStream stream( &f );
        stream.setCodec("UTF-8");

        QString line;
        while ( !stream.atEnd() )
        {
            line = stream.readLine(); // line of text excluding '\n'
            //qDebug( " * line: '%s'", line.toUtf8().data() );
            if (m3u_id.indexIn(line)!=-1)
            {
                //#EXTM3U
                // Ignore line
            }
            else if (info.indexIn(line) != -1)
            {
                fav.setName( info.cap(2) );
                fav.setIcon( info.cap(3) );
            }
            else if (line.startsWith("#"))
            {
                // Comment
                // Ignore
            }
            else
            {
                fav.setFile( line );
                if (fav.name().isEmpty()) fav.setName(line);
                //qDebug("Favorites::load: adding '%s' '%s'", fav.name().toUtf8().constData(), fav.file().toUtf8().constData());
                f_list.append(fav);

                // Clear data
                fav.setName("");
                fav.setFile("");
                fav.setIcon("");
            }
        }
        f.close();
    }
}
void CFavoriteSyncHandler::AddToLmsL()
{
   RArray<TWFFavSyncListIndex>& indexList = iSyncManager->GetAddList();
   for (TInt i = 0; i < indexList.Count(); ++i) {
      TWFFavSyncListIndex listEntry = indexList[i];
      if (listEntry.type == EWFLmsList) {
         Favorite* fav = iFavoriteList->at(listEntry.index);
         fav->setLmID(iLMSManager->AddLandmarkL(*fav), iImeiCrcHex);
         char* lmsId = WFTextUtil::newTDesDupL(*iLmsId);
         fav->setLmsID(lmsId);
         delete[] lmsId;
      }
   }
   iState |= EWFAddToLmsDone;
   ProcessNextState();
}
Пример #6
0
/**
 * Update the local favorites file and add thumb if necessary.
 */
void favoriteWindow::save()
{
	Favorite oldFav = favorite;
	favorite = Favorite(ui->tagLineEdit->text(), ui->noteSpinBox->value(), ui->lastViewedDateTimeEdit->dateTime());

	if (QFile::exists(ui->imageLineEdit->text()))
	{
		QPixmap img(ui->imageLineEdit->text());
		if (!img.isNull())
		{ favorite.setImage(img); }
	}
	else if (oldFav.getName() != ui->tagLineEdit->text() && QFile::exists(savePath("thumbs/" + oldFav.getName(true) + ".png")))
	{ QFile::rename(savePath("thumbs/" + oldFav.getName(true) + ".png"), savePath("thumbs/" + favorite.getName(true) + ".png")); }

	QFile f(savePath("favorites.txt"));
	f.open(QIODevice::ReadOnly);
		QString favorites = f.readAll();
	f.close();

	favorites.replace("\r\n", "\n").replace("\r", "\n").replace("\n", "\r\n");
	favorites.remove(oldFav.getName() + "|" + QString::number(oldFav.getNote()) + "|" + oldFav.getLastViewed().toString(Qt::ISODate) + "\r\n");
	favorites += favorite.getName() + "|" + QString::number(favorite.getNote()) + "|" + favorite.getLastViewed().toString(Qt::ISODate) + "\r\n";

	f.open(QIODevice::WriteOnly);
		f.write(favorites.toUtf8());
	f.close();

	emit favoritesChanged();
}
Пример #7
0
/**
 * Update the local favorites file and add thumb if necessary.
 */
void favoriteWindow::save()
{
	Favorite oldFav = m_favorite;

	// Update monitors
	int interval = ui->spinMonitoringInterval->value() * 60;
	Site *site = m_profile->getSites().value(ui->comboMonitoringSource->currentText());
	QList<Monitor> monitors = oldFav.getMonitors();
	if (interval == 0)
	{ monitors.clear(); }
	else if (monitors.isEmpty())
	{ monitors.append(Monitor(site, interval, QDateTime::currentDateTimeUtc())); }
	else
	{
		Monitor rep(site, interval, monitors[0].lastCheck());
		monitors[0] = rep;
	}

	m_favorite = Favorite(ui->tagLineEdit->text(), ui->noteSpinBox->value(), ui->lastViewedDateTimeEdit->dateTime(), monitors);
	m_favorite.setImagePath(savePath("thumbs/" + m_favorite.getName(true) + ".png"));

	if (oldFav.getName() != m_favorite.getName())
	{
		if (QFile::exists(savePath("thumbs/" + oldFav.getName(true) + ".png")))
		{ QFile::rename(savePath("thumbs/" + oldFav.getName(true) + ".png"), m_favorite.getImagePath()); }
		m_profile->removeFavorite(oldFav);
	}

	if (QFile::exists(ui->imageLineEdit->text()))
	{
		QPixmap img(ui->imageLineEdit->text());
		if (!img.isNull())
		{ m_favorite.setImage(img); }
	}
	m_profile->addFavorite(m_favorite);
}
Пример #8
0
FavoriteList FavoriteEditor::data() {
    FavoriteList list;

    for (int n = 0; n < table->rowCount(); n++) {
        Favorite f;
        f.setName( table->item(n, COL_NAME)->text() );
        f.setIcon( table->item(n, COL_ICON)->data(Qt::UserRole).toString() );
        f.setSubentry( table->item(n, COL_FILE)->data(Qt::UserRole).toBool() );
        if (f.isSubentry()) {
            f.setFile( table->item(n, COL_FILE)->data(Qt::UserRole + 1).toString() );
        } else {
            f.setFile( table->item(n, COL_FILE)->text() );
        }

        list.append(f);
    }

    return list;
}
Пример #9
0
bool operator==(const Favorite& lhs, const Favorite& rhs)
{ return lhs.getName().toLower() == rhs.getName().toLower(); }