Ejemplo n.º 1
0
 QStringList createSuffixesList()
 {
   QStringList list;
   list.append( PartOfSpeechCategories.values( suffix ) );
   list.append( PartOfSpeechCategories.values( nounSuffix ) );
   return list;
 }
Ejemplo n.º 2
0
 QStringList createExpressionsList()
 {
   QStringList list;
   list.append( PartOfSpeechCategories.values( expression ) );
   list.append( PartOfSpeechCategories.values( idiomaticExpression ) );
   return list;
 }
Ejemplo n.º 3
0
int QxtRPCServiceIntrospector::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    // Qt's signal dispatch mechanism invokes qt_metacall for each slot connected to the object.

    // The metacall protocol expects slots to be checked from the bottom up, starting with QObject and proceeding to
    // the more derived classes. qt_metacall returns a negative number to indicate that the request was processed or a
    // positive number to indicate the greatest method ID that was checked. moc-generated qt_metacall implementations
    // subtract the return value from _id so that slots on a given class can be counted starting at 0, allowing the
    // subclasses to add new signals or slots without breaking compatibility. QxtRPCService doesn't need this because
    // it just asks its base class how many methods it has before adding slots.
    if(QObject::qt_metacall(_c, _id, _a) < 0)
        return _id;

    // qt_metacall is also used for other behaviors besides just invoking methods; we don't implement any of these, so
    // we just return here.
    if(_c != QMetaObject::InvokeMetaMethod)
        return _id;

    // Construct an array of QVariants based on the parameters passed through _a.
    QVariant v[8];
    const QList<int>& types = signalParameters.at(idToParams.value(_id));
    int ct = types.count();
    for(int i = 0; i < ct; i++) {
        // The qt_metacall implementation is expected to already know the data types in _a, so that's why we tracked it.
        v[i] = QVariant(types.at(i), _a[i+1]);
    }

    foreach(const QString& rpcName, idToRpc.values(_id)) {
        // Invoke each RPC message connected to the requested dynamic slot ID.
        rpc->call(rpcName, v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]);
    }

    // Inform the calling function that we handled the call.
    return -1;
}
bool ProjectCollection::addProject(const QString& name, const QString& author, const QString& description, const QMultiHash<int, QString> & users)
{
    if (!k->db->exists(name)) {
        if (!k->projects.contains(name)) {
            
            QMultiHash<SProject::UserType, QString> newusers; 
            foreach (int type, users.uniqueKeys()) {
                     foreach (QString login, users.values(type))
                              newusers.insert( SProject::UserType(type), login);
            }

            if (newusers.values(SProject::Owner).empty())
                return false;
            
            SProject *project = new SProject( kAppProp->cacheDir() +"/"+ k->db->nextFileName());
            project->setProjectName(name);
            project->setAuthor(author);
            project->setDescription(description);
            bool okAddProject = false;
            
            project->setUsers(newusers);
            
            bool okSaveProject = project->save();
            if (okSaveProject)
                okAddProject = k->db->addProject(project);

            delete project;

            return okAddProject;
        }
    }
// Return the current class info list.
QList<ClassInfo> qpycore_get_class_info_list()
{
    PyFrameObject *frame = PyEval_GetFrame();
    QList<ClassInfo> class_info_list = class_info_hash.values(frame);

    class_info_hash.remove(frame);

    return class_info_list;
}
Ejemplo n.º 6
0
 QStringList createVerbsList()
 {
   QStringList list;
   list.append( PartOfSpeechCategories.values( verb ) );
   list.append( IchidanVerbs );
   list.append( GodanVerbs );
   list.append( FukisokuVerbs );
   return list;
 }
Ejemplo n.º 7
0
SessionsManagerDialog::SessionsManagerDialog(QWidget *parent) : Dialog(parent),
	m_ui(new Ui::SessionsManagerDialog)
{
	m_ui->setupUi(this);
	m_ui->openInExistingWindowCheckBox->setChecked(SettingsManager::getValue(SettingsManager::Sessions_OpenInExistingWindowOption).toBool());

	const QStringList sessions(SessionsManager::getSessions());
	QMultiHash<QString, SessionInformation> information;

	for (int i = 0; i < sessions.count(); ++i)
	{
		const SessionInformation session(SessionsManager::getSession(sessions.at(i)));

		information.insert((session.title.isEmpty() ? tr("(Untitled)") : session.title), session);
	}

	QStandardItemModel *model(new QStandardItemModel(this));
	model->setHorizontalHeaderLabels(QStringList({tr("Title"), tr("Identifier"), tr("Windows")}));

	const QList<SessionInformation> sorted(information.values());
	const QString currentSession(SessionsManager::getCurrentSession());
	int row(0);

	for (int i = 0; i < sorted.count(); ++i)
	{
		int windows(0);

		for (int j = 0; j < sorted.at(i).windows.count(); ++j)
		{
			windows += sorted.at(i).windows.at(j).windows.count();
		}

		if (sorted.at(i).path == currentSession)
		{
			row = i;
		}

		QList<QStandardItem*> items({new QStandardItem(sorted.at(i).title.isEmpty() ? tr("(Untitled)") : sorted.at(i).title), new QStandardItem(sorted.at(i).path), new QStandardItem(tr("%n window(s) (%1)", "", sorted.at(i).windows.count()).arg(tr("%n tab(s)", "", windows)))});
		items[0]->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
		items[1]->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
		items[2]->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);

		model->appendRow(items);
	}

	m_ui->sessionsViewWidget->setModel(model);

	connect(m_ui->openButton, SIGNAL(clicked()), this, SLOT(openSession()));
	connect(m_ui->deleteButton, SIGNAL(clicked()), this, SLOT(deleteSession()));
	connect(m_ui->sessionsViewWidget, SIGNAL(needsActionsUpdate()), this, SLOT(updateActions()));

	m_ui->sessionsViewWidget->setCurrentIndex(m_ui->sessionsViewWidget->getIndex(row, 0));
}
Ejemplo n.º 8
0
void MainWindow::menuSessionsAboutToShow()
{
	if (m_sessionsGroup)
	{
		m_sessionsGroup->deleteLater();

		QAction *saveSessionAction = m_ui->menuSessions->actions().at(0);
		saveSessionAction->setParent(this);

		QAction *manageSessionsAction = m_ui->menuSessions->actions().at(1);
		manageSessionsAction->setParent(this);

		m_ui->menuSessions->clear();
		m_ui->menuSessions->addAction(saveSessionAction);
		m_ui->menuSessions->addAction(manageSessionsAction);
		m_ui->menuSessions->addSeparator();
	}

	m_sessionsGroup = new QActionGroup(this);
	m_sessionsGroup->setExclusive(true);

	const QStringList sessions = SessionsManager::getSessions();
	QMultiHash<QString, SessionInformation> information;

	for (int i = 0; i < sessions.count(); ++i)
	{
		const SessionInformation session = SessionsManager::getSession(sessions.at(i));

		information.insert((session.title.isEmpty() ? tr("(Untitled)") : session.title), session);
	}

	const QList<SessionInformation> sorted = information.values();
	const QString currentSession = SessionsManager::getCurrentSession();

	for (int i = 0; i < sorted.count(); ++i)
	{
		int windows = 0;

		for (int j = 0; j < sorted.at(i).windows.count(); ++j)
		{
			windows += sorted.at(i).windows.at(j).windows.count();
		}

		QAction *action = m_ui->menuSessions->addAction(tr("%1 (%n tab(s))", "", windows).arg(sorted.at(i).title.isEmpty() ? tr("(Untitled)") : QString(sorted.at(i).title).replace(QLatin1Char('&'), QLatin1String("&&"))));
		action->setData(sorted.at(i).path);
		action->setCheckable(true);
		action->setChecked(sorted.at(i).path == currentSession);

		m_sessionsGroup->addAction(action);
	}
}
SessionsManagerDialog::SessionsManagerDialog(QWidget *parent) : Dialog(parent),
	m_ui(new Ui::SessionsManagerDialog)
{
	m_ui->setupUi(this);
	m_ui->openInExistingWindowCheckBox->setChecked(SettingsManager::getValue(QLatin1String("Sessions/OpenInExistingWindow")).toBool());

	const QStringList sessions = SessionsManager::getSessions();
	QMultiHash<QString, SessionInformation> information;

	for (int i = 0; i < sessions.count(); ++i)
	{
		const SessionInformation session = SessionsManager::getSession(sessions.at(i));

		information.insert((session.title.isEmpty() ? tr("(Untitled)") : session.title), session);
	}

	const QList<SessionInformation> sorted = information.values();
	const QString currentSession = SessionsManager::getCurrentSession();
	int index = 0;

	m_ui->sessionsWidget->setRowCount(sorted.count());

	for (int i = 0; i < sorted.count(); ++i)
	{
		int windows = 0;

		for (int j = 0; j < sorted.at(i).windows.count(); ++j)
		{
			windows += sorted.at(i).windows.at(j).windows.count();
		}

		if (sorted.at(i).path == currentSession)
		{
			index = i;
		}

		m_ui->sessionsWidget->setItem(i, 0, new QTableWidgetItem(sorted.at(i).title.isEmpty() ? tr("(Untitled)") : sorted.at(i).title));
		m_ui->sessionsWidget->setItem(i, 1, new QTableWidgetItem(sorted.at(i).path));
		m_ui->sessionsWidget->setItem(i, 2, new QTableWidgetItem(QStringLiteral("%1 (%2)").arg(sorted.at(i).windows.count()).arg(windows)));
	}

	connect(m_ui->openButton, SIGNAL(clicked()), this, SLOT(openSession()));
	connect(m_ui->deleteButton, SIGNAL(clicked()), this, SLOT(deleteSession()));
	connect(m_ui->sessionsWidget, SIGNAL(currentCellChanged(int,int,int,int)), this, SLOT(currentChanged(int)));

	m_ui->sessionsWidget->setCurrentCell(index, 0);
}
Ejemplo n.º 10
0
QList<Action *> Menu::findActions(const QMultiHash<int, QVariant> AData, bool ASearchInSubMenu /*= false*/) const
{
    QList<Action *> actionList;
    QList<int> keys = AData.keys();
    foreach(Action *action,FActions)
    {
        foreach (int key, keys)
        {
            if (AData.values(key).contains(action->data(key)))
            {
                actionList.append(action);
                break;
            }
        }
        if (ASearchInSubMenu && action->menu())
            actionList += action->menu()->findActions(AData,ASearchInSubMenu);
    }
MergeConfirmationDialog::MergeConfirmationDialog(DatabaseManager* dbm, const QList<long long>& BIDs,
                                                 OutParams* outParams, QWidget* parent) :
    QDialog(parent), ui(new Ui::MergeConfirmationDialog), dbm(dbm),
    canShowTheDialog(false), outParams(outParams)
{
    ui->setupUi(this);

    QStringList bookmarkNames;
    QMultiHash<long long, QString> bookmarkURLs;

    canShowTheDialog = dbm->bms.RetrieveBookmarkNames(BIDs, bookmarkNames);
    if (!canShowTheDialog)
        return;

    canShowTheDialog = dbm->bms.RetrieveBookmarkFullURLs(BIDs, bookmarkURLs);
    if (!canShowTheDialog)
        return;

    radioContext = new RichRadioButtonContext();

    for (int i = 0; i < BIDs.count(); i++)
    {
        long long BID = BIDs[i];

        //Create formatted URLs for display.
        //Reverse the urls to get the original order, as QMultiHash docs say:
        //  "The items that share the same key are available from most recently to least recently inserted."
        QStringList urls = bookmarkURLs.values(BID);
        std::reverse(urls.begin(), urls.end());

        QString urlsSeparated = "";
        const QString sep = "";
        foreach (const QString& url, urls)
            urlsSeparated += "<li style=\"color: blue;\">" + Util::FullyPercentDecodedUrl(url).toHtmlEscaped() + "</li>" + sep;
        urlsSeparated.chop(sep.length());

        QString radioText = QString("<strong>%1</strong>\n<ul>%2</ul>").arg(bookmarkNames[i], urlsSeparated);

        RichRadioButton* bmRadio = new RichRadioButton(radioText, BID, (i == 0), radioContext);
        ui->mainVerticalLayout->insertWidget(ui->mainVerticalLayout->count() -2, bmRadio);
    }
}
Ejemplo n.º 12
0
void PersonsModel::onContactsFetched()
{
    Q_D(PersonsModel);

    KABC::Addressee::Map addresseeMap;

    //fetch all already loaded contacts from plugins
    Q_FOREACH (const AllContactsMonitorPtr &contactWatcher, d->m_sourceMonitors) {
        addresseeMap.unite(contactWatcher->contacts());
    }

    //add metacontacts
    QMultiHash<QString, QString> contactMapping = PersonManager::instance()->allPersons();

    Q_FOREACH (const QString &key, contactMapping.uniqueKeys()) {
        KABC::Addressee::Map contacts;
        Q_FOREACH (const QString &contact, contactMapping.values(key)) {
            d->contactToPersons[contact] = key;
            if (addresseeMap.contains(contact)) {
                contacts[contact] = addresseeMap.take(contact);
            }
        }
        if (!contacts.isEmpty()) {
            addPerson(MetaContact(key, contacts));
        }
    }

    //add remaining contacts
    KABC::Addressee::Map::const_iterator i;
    for (i = addresseeMap.constBegin(); i != addresseeMap.constEnd(); ++i) {
        addPerson(MetaContact(i.key(), i.value()));
    }

    Q_FOREACH(const AllContactsMonitorPtr monitor, d->m_sourceMonitors) {
        connect(monitor.data(), SIGNAL(contactAdded(QString,KABC::Addressee)), SLOT(onContactAdded(QString,KABC::Addressee)));
        connect(monitor.data(), SIGNAL(contactChanged(QString,KABC::Addressee)), SLOT(onContactChanged(QString,KABC::Addressee)));
        connect(monitor.data(), SIGNAL(contactRemoved(QString)), SLOT(onContactRemoved(QString)));
    }
}
Ejemplo n.º 13
0
int main()
{
    QSet<QString *> s;
    qDeleteAll(s);
    qDeleteAll(s.begin(), s.end());
    qDeleteAll(s.values()); // warning

    QHash<int, QString *> h;
    qDeleteAll(h);
    qDeleteAll(h.begin(), h.end());
    qDeleteAll(h.values()); // warning

    QMap<int*, QString *> m;
    qDeleteAll(m);
    qDeleteAll(m.begin(), m.end());
    qDeleteAll(m.values()); // warning

    QMultiHash<int, QString *> mh;
    qDeleteAll(mh);
    qDeleteAll(mh.begin(), mh.end());
    qDeleteAll(mh.values()); // warning

    QMultiMap<int, QString *> mm;
    qDeleteAll(mm);
    qDeleteAll(mm.begin(), mm.end());
    qDeleteAll(mm.values()); // warning

    qDeleteAll(values());  // ok

    Foo foo;
    qDeleteAll(foo.values());  // ok
    qDeleteAll(foo.doSomethingWithValues(h.values()));  // ok

    qDeleteAll(m.keys()); // warning
    qDeleteAll(keys()); // ok

    qDeleteAll(h.values(1)); // warning

}
Ejemplo n.º 14
0
void IcecastService::ParseDirectoryFinished(
    QFuture<IcecastBackend::StationList> future) {
  IcecastBackend::StationList all_stations = future.result();
  sort(all_stations.begin(), all_stations.end(),
       StationSorter<IcecastBackend::Station>());
  // Remove duplicates by name. These tend to be multiple URLs for the same
  // station.
  IcecastBackend::StationList::iterator it =
      unique(all_stations.begin(), all_stations.end(),
             StationEquality<IcecastBackend::Station>());
  all_stations.erase(it, all_stations.end());

  // Cluster stations by genre.
  QMultiHash<QString, IcecastBackend::Station*> genres;

  // Add stations.
  for (int i = 0; i < all_stations.count(); ++i) {
    IcecastBackend::Station& s = all_stations[i];
    genres.insert(s.genre, &s);
  }

  QSet<QString> genre_set = genres.keys().toSet();

  // Merge genres with only 1 or 2 stations into "Other".
  for (const QString& genre : genre_set) {
    if (genres.count(genre) < 3) {
      const QList<IcecastBackend::Station*>& small_genre = genres.values(genre);
      for (IcecastBackend::Station* s : small_genre) {
        s->genre = "Other";
      }
    }
  }

  backend_->ClearAndAddStations(all_stations);

  app_->task_manager()->SetTaskFinished(load_directory_task_id_);
  load_directory_task_id_ = 0;
}
bool QgsGeometryAnalyzer::eventLayer( QgsVectorLayer* lineLayer, QgsVectorLayer* eventLayer, int lineField, int eventField, QgsFeatureIds &unlocatedFeatureIds, const QString& outputLayer,
                                      const QString& outputFormat, int locationField1, int locationField2, int offsetField, double offsetScale,
                                      bool forceSingleGeometry, QgsVectorDataProvider* memoryProvider, QProgressDialog* p )
{
  if ( !lineLayer || !eventLayer || !lineLayer->isValid() || !eventLayer->isValid() )
  {
    return false;
  }

  //create line field / id map for line layer
  QMultiHash< QString, QgsFeature > lineLayerIdMap; //1:n possible (e.g. several linear reference geometries for one feature in the event layer)
  QgsFeatureIterator fit = lineLayer->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList() << lineField ) );
  QgsFeature fet;
  while ( fit.nextFeature( fet ) )
  {
    lineLayerIdMap.insert( fet.attribute( lineField ).toString(), fet );
  }

  //create output datasource or attributes in memory provider
  QgsVectorFileWriter* fileWriter = nullptr;
  QgsFeatureList memoryProviderFeatures;
  if ( !memoryProvider )
  {
    QgsWkbTypes::Type memoryProviderType = QgsWkbTypes::MultiLineString;
    if ( locationField2 == -1 )
    {
      memoryProviderType = forceSingleGeometry ? QgsWkbTypes::Point : QgsWkbTypes::MultiPoint;
    }
    else
    {
      memoryProviderType = forceSingleGeometry ? QgsWkbTypes::LineString : QgsWkbTypes::MultiLineString;
    }
    fileWriter = new QgsVectorFileWriter( outputLayer,
                                          eventLayer->dataProvider()->encoding(),
                                          eventLayer->fields(),
                                          memoryProviderType,
                                          lineLayer->crs(),
                                          outputFormat );
  }
  else
  {
    memoryProvider->addAttributes( eventLayer->fields().toList() );
  }

  //iterate over eventLayer and write new features to output file or layer
  fit = eventLayer->getFeatures( QgsFeatureRequest().setFlags( QgsFeatureRequest::NoGeometry ) );
  QgsGeometry lrsGeom;
  double measure1, measure2 = 0.0;

  int nEventFeatures = eventLayer->featureCount();
  int featureCounter = 0;
  int nOutputFeatures = 0; //number of output features for the current event feature
  if ( p )
  {
    p->setWindowModality( Qt::WindowModal );
    p->setMinimum( 0 );
    p->setMaximum( nEventFeatures );
    p->show();
  }

  while ( fit.nextFeature( fet ) )
  {
    nOutputFeatures = 0;

    //update progress dialog
    if ( p )
    {
      if ( p->wasCanceled() )
      {
        break;
      }
      p->setValue( featureCounter );
      ++featureCounter;
    }

    measure1 = fet.attribute( locationField1 ).toDouble();
    if ( locationField2 != -1 )
    {
      measure2 = fet.attribute( locationField2 ).toDouble();
      if ( qgsDoubleNear(( measure2 - measure1 ), 0.0 ) )
      {
        continue;
      }
    }

    QList<QgsFeature> featureIdList = lineLayerIdMap.values( fet.attribute( eventField ).toString() );
    QList<QgsFeature>::iterator featureIdIt = featureIdList.begin();
    for ( ; featureIdIt != featureIdList.end(); ++featureIdIt )
    {
      if ( locationField2 == -1 )
      {
        lrsGeom = locateAlongMeasure( measure1, featureIdIt->geometry() );
      }
      else
      {
        lrsGeom = locateBetweenMeasures( measure1, measure2, featureIdIt->geometry() );
      }

      if ( !lrsGeom.isEmpty() )
      {
        ++nOutputFeatures;
        addEventLayerFeature( fet, lrsGeom, featureIdIt->geometry(), fileWriter, memoryProviderFeatures, offsetField, offsetScale, forceSingleGeometry );
      }
    }
    if ( nOutputFeatures < 1 )
    {
      unlocatedFeatureIds.insert( fet.id() );
    }
  }

  if ( p )
  {
    p->setValue( nEventFeatures );
  }

  if ( memoryProvider )
  {
    memoryProvider->addFeatures( memoryProviderFeatures );
  }
  delete fileWriter;
  return true;
}
Ejemplo n.º 16
0
bool UnicodeTournamentTrie::Preprocess( IImporter* importer, QString dir )
{
	QString filename = fileInDirectory( dir, "Unicode Tournament Trie" );

	QFile subTrieFile( filename + "_sub" );
	QFile wayFile( filename + "_ways" );

	if ( !openQFile( &subTrieFile, QIODevice::WriteOnly ) )
		return false;
	if ( !openQFile( &wayFile, QIODevice::WriteOnly ) )
		return false;

	std::vector< IImporter::Place > inputPlaces;
	std::vector< IImporter::Address > inputAddress;
	std::vector< UnsignedCoordinate > inputWayBuffer;
	std::vector< QString > inputWayNames;
	if ( !importer->GetAddressData( &inputPlaces, &inputAddress, &inputWayBuffer, &inputWayNames ) )
		return false;

	Timer time;

	std::sort( inputAddress.begin(), inputAddress.end() );
	qDebug() << "Unicode Tournament Trie: sorted addresses by importance:" << time.restart() << "ms";

	std::vector< UnsignedCoordinate > wayBuffer;
	std::vector< utt::Node > trie( 1 );
	unsigned address = 0;

	// build address name index
	QMultiHash< unsigned, unsigned > addressByName;
	for ( ; address < inputAddress.size(); address++ ) {
		addressByName.insert( inputAddress[address].name, address );
	}

	// compute way lengths
	QList< unsigned > uniqueNames = addressByName.uniqueKeys();
	std::vector< std::pair< double, unsigned > > wayLengths;
	for ( unsigned name = 0; name < ( unsigned ) uniqueNames.size(); name++ ) {
		QList< unsigned > segments = addressByName.values( uniqueNames[name] );
		double distance = 0;
		for( unsigned segment = 0; segment < ( unsigned ) segments.size(); segment++ ) {
			const IImporter::Address segmentAddress = inputAddress[segment];
			for ( unsigned coord = 1; coord < segmentAddress.pathLength; ++coord ) {
				GPSCoordinate sourceGPS = inputWayBuffer[segmentAddress.pathID + coord - 1].ToProjectedCoordinate().ToGPSCoordinate();
				GPSCoordinate targetGPS = inputWayBuffer[segmentAddress.pathID + coord].ToProjectedCoordinate().ToGPSCoordinate();
				distance += sourceGPS.ApproximateDistance( targetGPS );
			}
		}
		wayLengths.push_back( std::pair< double, unsigned >( distance, name ) );
	}

	// sort ways by aggregate lengths
	std::sort( wayLengths.begin(), wayLengths.end() );
	std::vector< unsigned > wayImportance( uniqueNames.size() );
	for ( unsigned way = 0; way < wayLengths.size(); way++ )
		wayImportance[wayLengths[way].second] = way;
	wayLengths.clear();

	std::vector< utt::Node > subTrie( 1 );

	for ( unsigned name = 0; name < ( unsigned ) uniqueNames.size(); name++ ) {
		QList< unsigned > segments = addressByName.values( uniqueNames[name] );

		// build edge connector data structures
		std::vector< EdgeConnector< UnsignedCoordinate>::Edge > connectorEdges;
		std::vector< unsigned > resultSegments;
		std::vector< unsigned > resultSegmentDescriptions;
		std::vector< bool > resultReversed;

		for ( unsigned segment = 0; segment < ( unsigned ) segments.size(); segment++ ) {
			const IImporter::Address& segmentAddress = inputAddress[segments[segment]];
			EdgeConnector< UnsignedCoordinate >::Edge newEdge;
			newEdge.source = inputWayBuffer[segmentAddress.pathID];
			newEdge.target = inputWayBuffer[segmentAddress.pathID + segmentAddress.pathLength - 1];
			newEdge.reverseable = true;
			connectorEdges.push_back( newEdge );
		}

		EdgeConnector< UnsignedCoordinate >::run( &resultSegments, &resultSegmentDescriptions, &resultReversed, connectorEdges );

		// string places with the same name together
		unsigned nextID = 0;
		for ( unsigned segment = 0; segment < resultSegments.size(); segment++ ) {
			utt::Data subEntry;
			subEntry.start = wayBuffer.size();

			for ( unsigned description = 0; description < resultSegments[segment]; description++ ) {
				unsigned segmentID = resultSegmentDescriptions[nextID + description];
				const IImporter::Address& segmentAddress = inputAddress[segments[segmentID]];
				std::vector< UnsignedCoordinate > path;
				for ( unsigned pathID = 0; pathID < segmentAddress.pathLength; pathID++ )
					path.push_back( inputWayBuffer[pathID + segmentAddress.pathID]);
				if ( resultReversed[segmentID] )
					std::reverse( path.begin(), path.end() );
				int skipFirst = description == 0 ? 0 : 1;
				assert( skipFirst == 0 || wayBuffer.back() == path.front() );
				wayBuffer.insert( wayBuffer.end(), path.begin() + skipFirst, path.end() );
			}
			
			utt::PlaceData placeData;
			placeData.name = inputPlaces[inputAddress[segments[resultSegmentDescriptions[nextID]]].nearPlace].name;

			subEntry.length = wayBuffer.size() - subEntry.start;
			insert( &subTrie, wayImportance[name], inputWayNames[uniqueNames[name]], subEntry, placeData );

			nextID += resultSegments[segment];
		}
	}

	writeTrie( &subTrie, subTrieFile );

	assert( address == inputAddress.size() );
	qDebug() << "Unicode Tournament Trie: build tries and tournament trees:" << time.restart() << "ms";

	for ( std::vector< UnsignedCoordinate >::const_iterator i = wayBuffer.begin(), e = wayBuffer.end(); i != e; ++i ) {
		wayFile.write( ( char* ) &i->x, sizeof( i->x ) );
		wayFile.write( ( char* ) &i->y, sizeof( i->y ) );
	}
	qDebug() << "Unicode Tournament Trie: wrote ways:" << time.restart() << "ms";

	return true;
}
Ejemplo n.º 17
0
void Albums::dataUpdated( const QString &name, const Plasma::DataEngine::Data &data )
{
    if( name != QLatin1String("albums") )
        return;

    Meta::AlbumList albums = data[ "albums" ].value<Meta::AlbumList>();
    Meta::TrackPtr track = data[ "currentTrack" ].value<Meta::TrackPtr>();
    QString headerText = data[ "headerText" ].toString();
    setHeaderText( headerText.isEmpty() ? i18n("Albums") : headerText );

    //Don't keep showing the albums for the artist of the last track that had album in the collection
    if( (m_currentTrack == track) && (m_albums == albums) )
        return;

    if( albums.isEmpty() )
    {
        debug() << "received albums is empty";
        setCollapseOn();
        m_albums.clear();
        m_albumsView->clear();
        return;
    }

    setCollapseOff();

    m_albums = albums;
    m_currentTrack = track;
    m_albumsView->clear();
    m_albumsView->setMode( track ? AlbumsProxyModel::SortByYear : AlbumsProxyModel::SortByCreateDate );
    QStandardItem *currentItem( 0 );

    foreach( Meta::AlbumPtr albumPtr, albums )
    {
        // do not show all tracks without an album from the collection, this takes ages
        // TODO: show all tracks from this artist that are not part of an album
        if( albumPtr->name().isEmpty() )
            continue;

        Meta::TrackList tracks = albumPtr->tracks();
        if( tracks.isEmpty() )
            continue;

        AlbumItem *albumItem = new AlbumItem();
        albumItem->setIconSize( 50 );
        albumItem->setAlbum( albumPtr );
        albumItem->setShowArtist( !m_currentTrack );

        int numberOfDiscs = 0;
        int childRow = 0;

        qStableSort( tracks.begin(), tracks.end(), Meta::Track::lessThan );

        QMultiHash< int, TrackItem* > trackItems; // hash of tracks items for each disc
        foreach( Meta::TrackPtr trackPtr, tracks )
        {
            if( numberOfDiscs < trackPtr->discNumber() )
                numberOfDiscs = trackPtr->discNumber();

            TrackItem *trackItem = new TrackItem();
            trackItem->setTrack( trackPtr );

            // bold the current track to make it more visible
            if( m_currentTrack && *m_currentTrack == *trackPtr )
            {
                currentItem = trackItem;
                trackItem->bold();
            }

            // If compilation and same artist, then highlight, but only if there's a current track
            if( m_currentTrack
                && m_currentTrack->artist() && trackPtr->artist()
                && (*m_currentTrack->artist() == *trackPtr->artist())
                && albumPtr->isCompilation() )
            {
                trackItem->italicise();
            }
            trackItems.insert( trackPtr->discNumber(), trackItem );
        }

        for( int i = 0; i <= numberOfDiscs; ++i )
        {
            QList<TrackItem*> items = trackItems.values( i );
            if( !items.isEmpty() )
            {
                const TrackItem *item = items.first();
                QStandardItem *discItem( 0 );
                if( numberOfDiscs > 1 )
                {
                    discItem = new QStandardItem( i18n("Disc %1", item->track()->discNumber()) );
                    albumItem->setChild( childRow++, discItem );
                    int discChildRow = 0;
                    foreach( TrackItem *trackItem, items )
                        discItem->setChild( discChildRow++, trackItem );
                }
                else
                {
                    foreach( TrackItem *trackItem, items )
                        albumItem->setChild( childRow++, trackItem );
                }
            }
        }
        m_albumsView->appendAlbum( albumItem );
    }

    m_albumsView->sort();
    if( currentItem )
    {
        m_albumsView->setRecursiveExpanded( currentItem, true );
        m_albumsView->scrollTo( currentItem );
    }

    updateConstraints();
}
Ejemplo n.º 18
0
bool QgsGeometryAnalyzer::eventLayer( QgsVectorLayer* lineLayer, QgsVectorLayer* eventLayer, int lineField, int eventField, QList<int>& unlocatedFeatureIds, const QString& outputLayer,
                                      const QString& outputFormat, int locationField1, int locationField2, int offsetField, double offsetScale,
                                      bool forceSingleGeometry, QgsVectorDataProvider* memoryProvider, QProgressDialog* p )
{
  if ( !lineLayer || !eventLayer || !lineLayer->isValid() || !eventLayer->isValid() )
  {
    return false;
  }

  //create line field / id map for line layer
  QMultiHash< QString, QgsFeatureId > lineLayerIdMap; //1:n possible (e.g. several linear reference geometries for one feature in the event layer)
  lineLayer->select( QgsAttributeList() << lineField,
                     QgsRectangle(), false, false );
  QgsFeature fet;
  while ( lineLayer->nextFeature( fet ) )
  {
    lineLayerIdMap.insert( fet.attributeMap()[lineField].toString(), fet.id() );
  }

  //create output datasource or attributes in memory provider
  QgsVectorFileWriter* fileWriter = 0;
  QgsFeatureList memoryProviderFeatures;
  if ( !memoryProvider )
  {
    QGis::WkbType memoryProviderType = QGis::WKBMultiLineString;
    if ( locationField2 == -1 )
    {
      memoryProviderType = forceSingleGeometry ? QGis::WKBPoint : QGis::WKBMultiPoint;
    }
    else
    {
      memoryProviderType = forceSingleGeometry ? QGis::WKBLineString : QGis::WKBMultiLineString;
    }
    fileWriter = new QgsVectorFileWriter( outputLayer,
                                          eventLayer->dataProvider()->encoding(),
                                          eventLayer->pendingFields(),
                                          memoryProviderType,
                                          &( lineLayer->crs() ),
                                          outputFormat );
  }
  else
  {
    memoryProvider->addAttributes( eventLayer->pendingFields().values() );
  }

  //iterate over eventLayer and write new features to output file or layer
  eventLayer->select( eventLayer->pendingAllAttributesList(), QgsRectangle(), false, false );
  QgsGeometry* lrsGeom = 0;
  QgsFeature lineFeature;
  double measure1, measure2;

  int nEventFeatures = eventLayer->pendingFeatureCount();
  int featureCounter = 0;
  int nOutputFeatures = 0; //number of output features for the current event feature
  if ( p )
  {
    p->setWindowModality( Qt::WindowModal );
    p->setMinimum( 0 );
    p->setMaximum( nEventFeatures );
    p->show();
  }

  while ( eventLayer->nextFeature( fet ) )
  {
    nOutputFeatures = 0;

    //update progress dialog
    if ( p )
    {
      if ( p->wasCanceled() )
      {
        break;
      }
      p->setValue( featureCounter );
      ++featureCounter;
    }

    measure1 = fet.attributeMap()[locationField1].toDouble();
    if ( locationField2 != -1 )
    {
      measure2 = fet.attributeMap()[locationField2].toDouble();
    }

    QList<QgsFeatureId> featureIdList = lineLayerIdMap.values( fet.attributeMap()[eventField].toString() );
    QList<QgsFeatureId>::const_iterator featureIdIt = featureIdList.constBegin();
    for ( ; featureIdIt != featureIdList.constEnd(); ++featureIdIt )
    {
      if ( !lineLayer->featureAtId( *featureIdIt, lineFeature, true, false ) )
      {
        continue;
      }

      if ( locationField2 == -1 )
      {
        lrsGeom = locateAlongMeasure( measure1, lineFeature.geometry() );
      }
      else
      {
        lrsGeom = locateBetweenMeasures( measure1, measure2, lineFeature.geometry() );
      }

      if ( lrsGeom )
      {
        ++nOutputFeatures;
        addEventLayerFeature( fet, lrsGeom, lineFeature.geometry(), fileWriter, memoryProviderFeatures, offsetField, offsetScale, forceSingleGeometry );
      }
    }
    if ( nOutputFeatures < 1 )
    {
      unlocatedFeatureIds.push_back( fet.id() );
    }
  }

  if ( p )
  {
    p->setValue( nEventFeatures );
  }

  if ( memoryProvider )
  {
    memoryProvider->addFeatures( memoryProviderFeatures );
  }
  delete fileWriter;
  return true;
}
Ejemplo n.º 19
0
QString VideoMetaDataUtil::GetArtPath(const QString &pathname,
                                      const QString &type)
{
    QString basename = pathname.section('/', -1);

    if (basename == pathname)
    {
        LOG(VB_GENERAL, LOG_WARNING, LOC +
                "Programmer Error: Cannot determine art path\n\t\t\t"
                "until the ProgramInfo pathname has been fully resolved.");
        return QString();
    }

    art_path_map_lock.lockForRead();
    ArtList ret(art_path_map.values(basename));
    art_path_map_lock.unlock();
    for (ArtList::const_iterator i = ret.begin();
            i != ret.end(); ++i)
    {
        if ((*i).first == type)
            return (*i).second;
    }

    QString fn = basename;
    fn.prepend("%");

    QString dbcolumn;
    if (type == "Coverart")
        dbcolumn = "coverfile";
    else if (type == "Fanart")
        dbcolumn = "fanart";
    else if (type == "Banners")
        dbcolumn = "banner";
    else if (type == "Screenshots")
        dbcolumn = "screenshot";

    QString querystr = QString("SELECT %1 "
        "FROM videometadata WHERE filename "
        "LIKE :FILENAME").arg(dbcolumn);

    MSqlQuery query(MSqlQuery::InitCon());
    query.prepare(querystr);
    query.bindValue(":FILENAME", fn);

    QString artpath;
    if (query.exec() && query.next())
        artpath = query.value(0).toString();

    if (!artpath.startsWith('/') && pathname.startsWith("myth://"))
    {
        QString workURL = pathname;
        QUrl baseURL(workURL);
        baseURL.setUserName(type);
        QString finalURL =
            baseURL.toString(QUrl::RemovePath) + '/' + artpath;
        artpath = finalURL;
    }

    ArtPair ins(type, artpath);
    art_path_map_lock.lockForWrite();
    art_path_map.insert(basename, ins);
    art_path_map_lock.unlock();

    return artpath;
}
Ejemplo n.º 20
0
void SwitchWindow::makeMenu()
{
    m_menu->clear();
    Plasma::DataEngine *tasks = dataEngine("tasks");
    if (!tasks->isValid()) {
        return;
    }

    QMultiHash<int, QAction*> desktops;

    //make all the window actions
    foreach (const QString &source, tasks->sources()) {
        Plasma::DataEngine::Data window = tasks->query(source);
        if (window.value("startup").toBool()) {
            //kDebug() << "skipped fake task" << source;
            continue;
        }
        if (!window.value("onCurrentActivity").toBool()) {
            continue;
        }

        QString name = window.value("visibleNameWithState").toString();
        if (name.isEmpty()) {
            kDebug() << "failed source" << source;
            continue;
        }

        QAction *action = new QAction(name, m_menu);
        action->setIcon(window.value("icon").value<QIcon>());
        action->setData(source);
        desktops.insert(window.value("desktop").toInt(), action);
    }

    //sort into menu
    if (m_mode == CurrentDesktop) {
        int currentDesktop = KWindowSystem::currentDesktop();
        m_menu->addTitle(i18n("Windows"));
        m_menu->addActions(desktops.values(currentDesktop));
        m_menu->addActions(desktops.values(-1));
    } else {
        int numDesktops = KWindowSystem::numberOfDesktops();
        if (m_mode == AllFlat) {
            for (int i = 1; i <= numDesktops; ++i) {
                if (desktops.contains(i)) {
                    QString name = KWindowSystem::desktopName(i);
                    name = QString("%1: %2").arg(i).arg(name);
                    m_menu->addTitle(name);
                    m_menu->addActions(desktops.values(i));
                }
            }
            if (desktops.contains(-1)) {
                m_menu->addTitle(i18n("All Desktops"));
                m_menu->addActions(desktops.values(-1));
            }
        } else { //submenus
            for (int i = 1; i <= numDesktops; ++i) {
                if (desktops.contains(i)) {
                        QString name = KWindowSystem::desktopName(i);
                        name = QString("%1: %2").arg(i).arg(name);
                        KMenu *subMenu = new KMenu(name, m_menu);
                        subMenu->addActions(desktops.values(i));
                        m_menu->addMenu(subMenu);
                }
            }
            if (desktops.contains(-1)) {
                KMenu *subMenu = new KMenu(i18n("All Desktops"), m_menu);
                subMenu->addActions(desktops.values(-1));
                m_menu->addMenu(subMenu);
            }
        }
    }

    m_menu->adjustSize();
}
Ejemplo n.º 21
0
void SwitchWindow::makeMenu()
{
    qDeleteAll(m_actions);
    m_actions.clear();

    if (m_tasksModel->rowCount() == 0) {
        return;
    }

    QMultiHash<int, QAction*> desktops;

    //make all the window actions
    for (int i = 0; i < m_tasksModel->rowCount(); ++i) {
        if (m_tasksModel->data(m_tasksModel->index(i, 0), LegacyTaskManager::TasksModel::IsStartup).toBool()) {
            qDebug() << "skipped fake task";
            continue;
        }

        QString name = m_tasksModel->data(m_tasksModel->index(i, 0), Qt::DisplayRole).toString();

        if (name.isEmpty()) {
            continue;
        }

        QAction *action = new QAction(name, this);
        action->setIcon(m_tasksModel->data(m_tasksModel->index(i, 0), Qt::DecorationRole).value<QIcon>());
        action->setData(m_tasksModel->data(m_tasksModel->index(i, 0), LegacyTaskManager::TasksModel::Id).toString());
        desktops.insert(m_tasksModel->data(m_tasksModel->index(i, 0), LegacyTaskManager::TasksModel::Desktop).toInt(), action);
        connect(action, &QAction::triggered, [=]() {
            switchTo(action);
        });
    }

    //sort into menu
    if (m_mode == CurrentDesktop) {
        int currentDesktop = KWindowSystem::currentDesktop();

        QAction *a = new QAction(i18nc("plasma_containmentactions_switchwindow", "Windows"), this);
        a->setSeparator(true);
        m_actions << a;
        m_actions << desktops.values(currentDesktop);
        m_actions << desktops.values(-1);

    } else {
        int numDesktops = KWindowSystem::numberOfDesktops();
        if (m_mode == AllFlat) {
            for (int i = 1; i <= numDesktops; ++i) {
                if (desktops.contains(i)) {
                    QString name = KWindowSystem::desktopName(i);
                    name = QStringLiteral("%1: %2").arg(i).arg(name);
                    QAction *a = new QAction(name, this);
                    a->setSeparator(true);
                    m_actions << a;
                    m_actions << desktops.values(i);
                }
            }
            if (desktops.contains(-1)) {
                QAction *a = new QAction(i18nc("plasma_containmentactions_switchwindow", "All Desktops"), this);
                a->setSeparator(true);
                m_actions << a;
                m_actions << desktops.values(-1);
            }

        } else { //submenus
            for (int i = 1; i <= numDesktops; ++i) {
                if (desktops.contains(i)) {
                    QString name = KWindowSystem::desktopName(i);
                    name = QStringLiteral("%1: %2").arg(i).arg(name);
                    QMenu *subMenu = new QMenu(name);
                    subMenu->addActions(desktops.values(i));

                    QAction *a = new QAction(name, this);
                    a->setMenu(subMenu);
                    m_actions << a;
                }
            }
            if (desktops.contains(-1)) {
                QMenu *subMenu = new QMenu(i18nc("plasma_containmentactions_switchwindow", "All Desktops"));
                subMenu->addActions(desktops.values(-1));
                QAction *a = new QAction(i18nc("plasma_containmentactions_switchwindow", "All Desktops"), this);
                a->setMenu(subMenu);
                m_actions << a;
            }
        }
    }
}
DrugBaseEssentials::DrugBaseEssentials():
    Utils::Database(),
    m_dbcore_initialized(false),
    m_isDefaultDb(false)
{
    setConnectionName(Constants::DB_DRUGS_NAME);
    using namespace Constants;
    QMultiHash<int, ftype> types;
    int i = Table_MASTER;
    types.insertMulti(i, ftype(MASTER_DID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(MASTER_UID1, FieldIsUUID));
    types.insertMulti(i, ftype(MASTER_UID2, FieldIsUUID));
    types.insertMulti(i, ftype(MASTER_UID3, FieldIsUUID));
    types.insertMulti(i, ftype(MASTER_OLDUID,FieldIsUUID));
    types.insertMulti(i, ftype(MASTER_SID, FieldIsInteger));
    i = Table_SOURCES;
    types.insertMulti(i, ftype(SOURCES_SID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(SOURCES_DBUID, FieldIsUUID));
    types.insertMulti(i, ftype(SOURCES_MASTERLID, FieldIsInteger));
    types.insertMulti(i, ftype(SOURCES_LANG, FieldIsLanguageText));
    types.insertMulti(i, ftype(SOURCES_WEB, FieldIsShortText));
    types.insertMulti(i, ftype(SOURCES_COPYRIGHT, FieldIsShortText));
    types.insertMulti(i, ftype(SOURCES_LICENSE, FieldIsShortText));
    types.insertMulti(i, ftype(SOURCES_DATE, FieldIsDateTime));
    types.insertMulti(i, ftype(SOURCES_DRUGS_VERSION,FieldIsShortText));
    types.insertMulti(i, ftype(SOURCES_AUTHORS, FieldIsShortText));
    types.insertMulti(i, ftype(SOURCES_VERSION, FieldIsShortText));
    types.insertMulti(i, ftype(SOURCES_PROVIDER, FieldIsShortText));
    types.insertMulti(i, ftype(SOURCES_WEBLINK, FieldIsShortText));
    types.insertMulti(i, ftype(SOURCES_DRUGUID_NAME, FieldIsShortText));
    types.insertMulti(i, ftype(SOURCES_ATC, FieldIsBoolean));
    types.insertMulti(i, ftype(SOURCES_INTERACTIONS, FieldIsBoolean));
    types.insertMulti(i, ftype(SOURCES_COMPL_WEBSITE,FieldIsShortText));
    types.insertMulti(i, ftype(SOURCES_PACKUID_NAME,FieldIsShortText));
    types.insertMulti(i, ftype(SOURCES_COMPLETION, FieldIsShortText));
    types.insertMulti(i, ftype(SOURCES_AUTHOR_COMMENTS, FieldIsLongText));
    types.insertMulti(i, ftype(SOURCES_DRUGNAMECONSTRUCTOR, FieldIsShortText));
    types.insertMulti(i, ftype(SOURCES_FMFCOMPAT, FieldIsShortText));
    types.insertMulti(i, ftype(SOURCES_OPENREACT_COMPAT, FieldIsShortText));
    i = Table_LABELS;
    types.insertMulti(i, ftype(LABELS_LID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(LABELS_LANG, FieldIsLanguageText));
    types.insertMulti(i, ftype(LABELS_LABEL, FieldIsShortText));
    i = Table_LABELSLINK;
    types.insertMulti(i, ftype(LABELSLINK_MASTERLID, FieldIsInteger));
    types.insertMulti(i, ftype(LABELSLINK_LID, FieldIsInteger));
    i= Table_BIB;
    types.insertMulti(i, ftype(BIB_BIBID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(BIB_TYPE, FieldIsShortText));
    types.insertMulti(i, ftype(BIB_LINK, FieldIsShortText));
    types.insertMulti(i, ftype(BIB_TEXTREF, FieldIsShortText));
    types.insertMulti(i, ftype(BIB_ABSTRACT, FieldIsLongText));
    types.insertMulti(i, ftype(BIB_EXPLAIN, FieldIsLongText));
    types.insertMulti(i, ftype(BIB_XML, FieldIsBlob));
    i = Table_BIB_LINK;
    types.insertMulti(i, ftype(BIB_LINK_MASTERID, FieldIsInteger));
    types.insertMulti(i, ftype(BIB_LINK_BIBID, FieldIsInteger));
    i = Table_DRUGS;
    types.insertMulti(i, ftype(DRUGS_ID , FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(DRUGS_DID ,FieldIsInteger));
    types.insertMulti(i, ftype(DRUGS_SID,  FieldIsInteger));
    types.insertMulti(i, ftype(DRUGS_NAME, FieldIsShortText));
    types.insertMulti(i, ftype(DRUGS_ATC_ID, FieldIsInteger));
    types.insertMulti(i, ftype(DRUGS_STRENGTH,FieldIsShortText));
    types.insertMulti(i, ftype(DRUGS_VALID, FieldIsBoolean));
    types.insertMulti(i, ftype(DRUGS_MARKET, FieldIsBoolean));
    types.insertMulti(i, ftype(DRUGS_AID_MASTER_LID, FieldIsInteger));
    types.insertMulti(i, ftype(DRUGS_LINK_SPC, FieldIsShortText));
    types.insertMulti(i, ftype(DRUGS_EXTRA_XML,FieldIsLongText));
    i = Table_MOLS;
    types.insertMulti(i, ftype(MOLS_MID,FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(MOLS_SID, FieldIsInteger));
    types.insertMulti(i, ftype(MOLS_NAME,FieldIsShortText));
    types.insertMulti(i, ftype(MOLS_WWW, FieldIsShortText));
    i = Table_COMPO;
    types.insertMulti(i, ftype(COMPO_ID,FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(COMPO_DID,FieldIsInteger));
    types.insertMulti(i, ftype(COMPO_MID,FieldIsInteger));
    types.insertMulti(i, ftype(COMPO_STRENGTH, FieldIsShortText));
    types.insertMulti(i, ftype(COMPO_STRENGTH_NID, FieldIsInteger));
    types.insertMulti(i, ftype(COMPO_DOSE_REF, FieldIsShortText));
    types.insertMulti(i, ftype(COMPO_REF_NID, FieldIsInteger));
    types.insertMulti(i, ftype(COMPO_NATURE, FieldIsInteger));
    types.insertMulti(i, ftype(COMPO_LK_NATURE, FieldIsInteger));
    i = Table_UNITS;
    types.insertMulti(i, ftype(UNITS_NID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(UNITS_VALUE, FieldIsShortText));
    i = Table_LK_MOL_ATC;
    types.insertMulti(i, ftype(LK_MID,FieldIsInteger));
    types.insertMulti(i, ftype(LK_ATC_ID, FieldIsInteger));
    types.insertMulti(i, ftype(LK_ATC_SID,FieldIsInteger));
    i = Table_PACKAGING;
    types.insertMulti(i, ftype(PACK_DID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(PACK_SID,  FieldIsInteger));
    types.insertMulti(i, ftype(PACK_PACK_UID,FieldIsUUID));
    types.insertMulti(i, ftype(PACK_LABEL,  FieldIsShortText));
    types.insertMulti(i, ftype(PACK_STATUS, FieldIsOneChar));
    types.insertMulti(i, ftype(PACK_MARKET, FieldIsInteger));
    types.insertMulti(i, ftype(PACK_DATE,   FieldIsDateTime));
    types.insertMulti(i, ftype(PACK_OPTION_CODE, FieldIsShortText));
    i = Table_DRUG_ROUTES;
    types.insertMulti(i, ftype(DRUG_ROUTES_DID, FieldIsInteger));
    types.insertMulti(i, ftype(DRUG_ROUTES_RID, FieldIsInteger));
    i = Table_DRUG_FORMS;
    types.insertMulti(i, ftype(DRUG_FORMS_DID,FieldIsInteger));
    types.insertMulti(i, ftype(DRUG_FORMS_MASTERLID,FieldIsInteger));
    i = Table_ROUTES;
    types.insertMulti(i, ftype(ROUTES_RID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(ROUTES_MASTERLID, FieldIsInteger));
    types.insertMulti(i, ftype(ROUTES_SYSTEMIC, FieldIsShortText));
    i = Table_SEARCHENGINES;
    types.insertMulti(i, ftype(SEARCHENGINE_ID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(SEARCHENGINE_LABEL, FieldIsShortText));
    types.insertMulti(i, ftype(SEARCHENGINE_URL,FieldIsShortText));
    i = Table_VERSION;
    types.insertMulti(i, ftype(VERSION_ID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(VERSION_VERSION, FieldIsShortText));
    types.insertMulti(i, ftype(VERSION_DATE, FieldIsDate));
    types.insertMulti(i, ftype(VERSION_COMMENT, FieldIsLongText));
    i = Table_ATC;
    types.insertMulti(i, ftype(ATC_ID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(ATC_CODE, FieldIsShortText));
    types.insertMulti(i, ftype(ATC_WARNDUPLICATES, FieldIsBoolean));
    i = Table_INTERACTIONS;
    types.insertMulti(i, ftype(INTERACTIONS_IAID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(INTERACTIONS_ATC_ID1, FieldIsInteger));
    types.insertMulti(i, ftype(INTERACTIONS_ATC_ID2, FieldIsInteger));
    i = Table_IAKNOWLEDGE;
    types.insertMulti(i, ftype(IAKNOWLEDGE_IAKID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(IAKNOWLEDGE_TYPE, FieldIsShortText));
    types.insertMulti(i, ftype(IAKNOWLEDGE_RISK_MASTERLID, FieldIsInteger));
    types.insertMulti(i, ftype(IAKNOWLEDGE_MANAGEMENT_MASTERLID, FieldIsInteger));
    types.insertMulti(i, ftype(IAKNOWLEDGE_BIB_MASTERID, FieldIsInteger));
    types.insertMulti(i, ftype(IAKNOWLEDGE_WWW, FieldIsShortText));
    i = Table_IA_IAK;
    types.insertMulti(i, ftype(IA_IAK_IAID, FieldIsInteger));
    types.insertMulti(i, ftype(IA_IAK_IAKID, FieldIsInteger));
    i = Table_ATC_LABELS;
    types.insertMulti(i, ftype(ATC_LABELS_ATCID, FieldIsInteger));
    types.insertMulti(i, ftype(ATC_LABELS_MASTERLID, FieldIsInteger));
    i = Table_ATC_CLASS_TREE;
    types.insertMulti(i, ftype(ATC_CLASS_TREE_ID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(ATC_CLASS_TREE_ID_CLASS, FieldIsInteger));
    types.insertMulti(i, ftype(ATC_CLASS_TREE_ID_ATC, FieldIsInteger));
    types.insertMulti(i, ftype(ATC_CLASS_TREE_BIBMASTERID,FieldIsInteger));
    i = Table_PIM_SOURCES;
    types.insertMulti(i, ftype(PIM_SOURCES_SID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(PIM_SOURCES_UID, FieldIsUUID));
    types.insertMulti(i, ftype(PIM_SOURCES_NAME, FieldIsShortText));
    types.insertMulti(i, ftype(PIM_SOURCES_PMID, FieldIsShortText));
    types.insertMulti(i, ftype(PIM_SOURCES_COUNTRY,FieldIsShortText));
    types.insertMulti(i, ftype(PIM_SOURCES_WWW, FieldIsShortText));
    i = Table_PIM_TYPES;
    types.insertMulti(i, ftype(PIM_TYPES_TID,FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(PIM_TYPES_UID,FieldIsUUID));
    types.insertMulti(i, ftype(PIM_TYPES_MASTER_LID, FieldIsInteger));
    i = Table_PIMS;
    types.insertMulti(i, ftype(PIMS_ID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(PIMS_SID, FieldIsInteger));
    types.insertMulti(i, ftype(PIMS_TID, FieldIsInteger));
    types.insertMulti(i, ftype(PIMS_LEVEL, FieldIsInteger));
    types.insertMulti(i, ftype(PIMS_RISK_MASTER_LID, FieldIsInteger));
    i = Table_PIMS_RELATED_ATC;
    types.insertMulti(i, ftype(PIMS_RELATC_RMID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(PIMS_RELATC_PIM_ID, FieldIsInteger));
    types.insertMulti(i, ftype(PIMS_RELATC_ATC_ID, FieldIsInteger));
    types.insertMulti(i, ftype(PIMS_RELATC_MAXDAYDOSE, FieldIsReal));
    types.insertMulti(i, ftype(PIMS_RELATC_MAXDAYDOSEUNIT, FieldIsInteger));
    i = Table_PIMS_RELATED_ICD;
    types.insertMulti(i, ftype(PIMS_RELICD_RMID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(PIMS_RELICD_PIM_ID, FieldIsInteger));
    types.insertMulti(i, ftype(PIMS_RELICD_ICD_SID, FieldIsInteger));
    i = Table_CURRENTVERSION;
    types.insertMulti(i, ftype(CURRENTVERSION_ID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(CURRENTVERSION_NUMBER, FieldIsShortText));

#if DRUGS_DATABASE_VERSION >= 0x000804
    i = Table_DRUG_SPC;
    types.insertMulti(i, ftype(DRUG_SPC_DID,FieldIsInteger));
    types.insertMulti(i, ftype(DRUG_SPC_SPCCONTENT_ID,FieldIsInteger));
    i = Table_SPC_CONTENT;
    types.insertMulti(i, ftype(SPCCONTENT_ID,FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(SPCCONTENT_LABEL,FieldIsShortText));
    types.insertMulti(i, ftype(SPCCONTENT_URL_SOURCE,FieldIsShortText));
    types.insertMulti(i, ftype(SPCCONTENT_DATEOFDOWNLOAD,FieldIsDateTime));
    types.insertMulti(i, ftype(SPCCONTENT_HTMLCONTENT,FieldIsBlob));
    types.insertMulti(i, ftype(SPCCONTENT_SPCCONTENT_RESOURCES_LINK_ID,FieldIsInteger));
    i = Table_SPC_CONTENTRESOURCE_LINK;
    types.insertMulti(i, ftype(SPCCONTENT_RESOURCES_LINK_ID,FieldIsInteger));
    types.insertMulti(i, ftype(SPCCONTENT_SPCCONTENTRESOURCES_ID,FieldIsInteger));
    i = Table_SPC_CONTENTRESOURCE;
    types.insertMulti(i, ftype(SPCCONTENTRESOURCES_ID,FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(SPCCONTENTRESOURCES_TYPE,FieldIsShortText));
    types.insertMulti(i, ftype(SPCCONTENTRESOURCES_NAME,FieldIsShortText));
    types.insertMulti(i, ftype(SPCCONTENTRESOURCES_CONTENT,FieldIsBlob));
#endif

    for(int i=0; i < Table_MaxParam; ++i) {
        addTable(i, "t" + QString::number(i));
        const QList<ftype> &tp = types.values(i);
        for(int j=0; j < tp.count(); ++j) {
            addField(i, tp.at(j).f, "f"+QString::number(tp.count()-j), tp.at(j).t);
        }
    }
    addIndex(Table_SOURCES, SOURCES_SID);
    addIndex(Table_MASTER, MASTER_DID);
    addIndex(Table_LABELS, LABELS_LID);
    addIndex(Table_LABELSLINK, LABELSLINK_LID);
    addIndex(Table_LABELSLINK, LABELSLINK_MASTERLID);
    addIndex(Table_BIB, BIB_BIBID);
    addIndex(Table_BIB_LINK, BIB_LINK_BIBID);
    addIndex(Table_BIB_LINK, BIB_LINK_MASTERID);
    addIndex(Table_DRUGS, DRUGS_DID);
    addIndex(Table_MOLS, MOLS_MID);
    addIndex(Table_COMPO, COMPO_DID);
    addIndex(Table_COMPO, COMPO_MID);
    addIndex(Table_UNITS, UNITS_NID);
    addIndex(Table_LK_MOL_ATC, LK_MID);
    addIndex(Table_LK_MOL_ATC, LK_ATC_ID);
    addIndex(Table_LK_MOL_ATC, LK_ATC_SID);
    addIndex(Table_DRUG_ROUTES, DRUG_ROUTES_DID);
    addIndex(Table_DRUG_ROUTES, DRUG_ROUTES_RID);
    addIndex(Table_DRUG_FORMS, DRUG_FORMS_DID);
    addIndex(Table_DRUG_FORMS, DRUG_FORMS_MASTERLID);
    addIndex(Table_ROUTES, ROUTES_RID);
    addIndex(Table_ROUTES, ROUTES_MASTERLID);
    addIndex(Table_ATC, ATC_CODE);
    addIndex(Table_ATC, ATC_ID);
    addIndex(Table_INTERACTIONS, INTERACTIONS_IAID);
    addIndex(Table_INTERACTIONS, INTERACTIONS_ATC_ID1);
    addIndex(Table_INTERACTIONS, INTERACTIONS_ATC_ID2);

    addIndex(Table_IAKNOWLEDGE, IAKNOWLEDGE_IAKID);
    addIndex(Table_IAKNOWLEDGE, IAKNOWLEDGE_RISK_MASTERLID);
    addIndex(Table_IAKNOWLEDGE, IAKNOWLEDGE_MANAGEMENT_MASTERLID);
    addIndex(Table_IAKNOWLEDGE, IAKNOWLEDGE_BIB_MASTERID);
    addIndex(Table_IA_IAK, IA_IAK_IAID);
    addIndex(Table_IA_IAK, IA_IAK_IAKID);
    addIndex(Table_ATC_LABELS, ATC_LABELS_ATCID);
    addIndex(Table_ATC_LABELS, ATC_LABELS_MASTERLID);
    addIndex(Table_ATC_CLASS_TREE, ATC_CLASS_TREE_ID_CLASS);
    addIndex(Table_ATC_CLASS_TREE, ATC_CLASS_TREE_ID_ATC);
    addIndex(Table_ATC_CLASS_TREE, ATC_CLASS_TREE_BIBMASTERID);
    addIndex(Table_PIMS_RELATED_ATC, PIMS_RELATC_RMID);
    addIndex(Table_PIMS_RELATED_ATC, PIMS_RELATC_PIM_ID);
    addIndex(Table_PIMS_RELATED_ATC, PIMS_RELATC_ATC_ID);
    addIndex(Table_PIMS_RELATED_ICD, PIMS_RELICD_RMID);
    addIndex(Table_PIMS_RELATED_ICD, PIMS_RELICD_PIM_ID);
    addIndex(Table_PIMS_RELATED_ICD, PIMS_RELICD_ICD_SID);
    addIndex(Table_PIMS, PIMS_ID);
    addIndex(Table_PIM_TYPES, PIM_TYPES_TID);
    addIndex(Table_PIM_SOURCES, PIM_SOURCES_SID);

#if DRUGS_DATABASE_VERSION >= 0x000804
    addIndex(Table_DRUG_SPC, DRUG_SPC_DID);
    addIndex(Table_DRUG_SPC, DRUG_SPC_SPCCONTENT_ID);
    addIndex(Table_SPC_CONTENT, SPCCONTENT_ID);
#endif
}
Ejemplo n.º 23
0
namespace EdictFormatting
{
  // Forward declarations of our functions to be used.
  QMultiHash<QString, QString> createPartOfSpeechCategories();
  QSet<QString>                createPartsOfSpeech();
  QSet<QString>                createMiscMarkings();
  QSet<QString>                createFieldOfApplication();
  QStringList                  createNounsList();
  QStringList                  createVerbsList();
  QStringList                  createExpressionsList();
  QStringList                  createPrefixesList();
  QStringList                  createSuffixesList();
 
  // Private variables.
  QString noun      = QString( i18nc( "This must be a single word", "Noun" ) );
  QString verb      = QString( i18nc( "This must be a single word", "Verb" ) );
  QString adjective = QString( i18nc( "This must be a single word", "Adjective" ) );
  QString adverb    = QString( i18nc( "This must be a single word", "Adverb" ) );
  QString particle  = QString( i18nc( "This must be a single word", "Particle" ) );
  QString ichidanVerb   = QString( i18nc( "This is a technical japanese linguist's term... and probably should not be translated (except possibly in far-eastern languages), this must be a single word", "Ichidan" ) );
  QString godanVerb     = QString( i18nc( "This is a technical japanese linguist's term... and probably should not be translated, this must be a single word", "Godan" ) );
  QString fukisokuVerb  = QString( i18nc( "This is a technical japanese linguist's term... and probably should not be translated, this must be a single word", "Fukisoku" ) );
  QString expression = QString( i18n( "Expression" ) );
  QString idiomaticExpression = QString( i18n( "Idiomatic expression" ) );
  QString prefix = QString( i18n( "Prefix" ) );
  QString suffix = QString( i18n( "Suffix" ) );
  QString nounPrefix = QString( i18n( "Noun (used as a prefix)" ) );
  QString nounSuffix = QString( i18n( "Noun (used as a suffix)" ) );


  // Define our public variables.
  QMultiHash<QString, QString> PartOfSpeechCategories = createPartOfSpeechCategories();
  QSet<QString> PartsOfSpeech      = createPartsOfSpeech();
  QSet<QString> MiscMarkings       = createMiscMarkings();
  QSet<QString> FieldOfApplication = createFieldOfApplication();

  // PartOfSpeechCategories needs to has some values before this line.
  QStringList Nouns         = createNounsList();
  QStringList Adjectives    = PartOfSpeechCategories.values( adjective );
  QStringList Adverbs       = PartOfSpeechCategories.values( adverb );
  QStringList IchidanVerbs  = PartOfSpeechCategories.values( ichidanVerb );
  QStringList GodanVerbs    = PartOfSpeechCategories.values( godanVerb );
  QStringList FukisokuVerbs = PartOfSpeechCategories.values( fukisokuVerb );
  QStringList Verbs         = createVerbsList();
  QStringList Expressions   = createExpressionsList();
  QStringList Prefix        = createPrefixesList();
  QStringList Suffix        = createSuffixesList();
  QString     Particle      = PartOfSpeechCategories.value( particle );



  QStringList createNounsList()
  {
    QStringList list;
    list.append( PartOfSpeechCategories.values( noun ) );
    list.append( PartOfSpeechCategories.values( nounPrefix ) );
    list.append( PartOfSpeechCategories.values( nounSuffix ) );
    return list;
  }

  QStringList createVerbsList()
  {
    QStringList list;
    list.append( PartOfSpeechCategories.values( verb ) );
    list.append( IchidanVerbs );
    list.append( GodanVerbs );
    list.append( FukisokuVerbs );
    return list;
  }

  QStringList createExpressionsList()
  {
    QStringList list;
    list.append( PartOfSpeechCategories.values( expression ) );
    list.append( PartOfSpeechCategories.values( idiomaticExpression ) );
    return list;
  }

  QStringList createPrefixesList()
  {
    QStringList list;
    list.append( PartOfSpeechCategories.values( prefix ) );
    list.append( PartOfSpeechCategories.values( nounPrefix ) );
    return list;
  }

  QStringList createSuffixesList()
  {
    QStringList list;
    list.append( PartOfSpeechCategories.values( suffix ) );
    list.append( PartOfSpeechCategories.values( nounSuffix ) );
    return list;
  }

  QMultiHash<QString, QString> createPartOfSpeechCategories()
  { 
    QMultiHash<QString, QString> categories;

    // Nouns
    categories.insert( noun, "n" );
    categories.insert( noun, "n-adv" );
    categories.insert( noun, "n-t" );
    categories.insert( noun, "adv-n" );

    // Noun (used as a prefix)
    categories.insert( nounPrefix, "n-pref" );

    // Noun (used as a suffix)
    categories.insert( nounSuffix, "n-suf" );

    // Ichidan Verbs
    categories.insert( ichidanVerb, "v1" );
    categories.insert( ichidanVerb, "vz" );

    // Godan Verbs
    categories.insert( godanVerb, "v5" );
    categories.insert( godanVerb, "v5aru" );
    categories.insert( godanVerb, "v5b" );
    categories.insert( godanVerb, "v5g" );
    categories.insert( godanVerb, "v5k" );
    categories.insert( godanVerb, "v5k-s" );
    categories.insert( godanVerb, "v5m" );
    categories.insert( godanVerb, "v5n" );
    categories.insert( godanVerb, "v5r" );
    categories.insert( godanVerb, "v5r-i" );
    categories.insert( godanVerb, "v5s" );
    categories.insert( godanVerb, "v5t" );
    categories.insert( godanVerb, "v5u" );
    categories.insert( godanVerb, "v5u-s" );
    categories.insert( godanVerb, "v5uru" );
    categories.insert( godanVerb, "v5z" );

    // Fukisoku verbs
    categories.insert( fukisokuVerb, "iv" );
    categories.insert( fukisokuVerb, "vk" );
    categories.insert( fukisokuVerb, "vn" );
    categories.insert( fukisokuVerb, "vs-i" );
    categories.insert( fukisokuVerb, "vs-s" );

    // Other Verbs
    categories.insert( verb, "vi" );
    categories.insert( verb, "vs" );
    categories.insert( verb, "vt" );
    categories.insert( verb, "aux-v" );

    // Adjectives
    categories.insert( adjective, "adj-i" );
    categories.insert( adjective, "adj-na" );
    categories.insert( adjective, "adj-no" );
    categories.insert( adjective, "adj-pn" );
    categories.insert( adjective, "adj-t" );
    categories.insert( adjective, "adj-f" );
    categories.insert( adjective, "adj" );
    categories.insert( adjective, "aux-adj" );

    // Adverbs
    categories.insert( adverb, "adv" );
    categories.insert( adverb, "adv-n" );
    categories.insert( adverb, "adv-to" );

    // Particle
    categories.insert( particle, "prt" );

    // Expression
    categories.insert( expression, "exp" );

    // Idiomatic expression
    categories.insert( idiomaticExpression, "id" );

    // Prefix
    categories.insert( prefix, "pref" );

    // Suffix
    categories.insert( suffix, "suf" );

    return categories;
  }

  QSet<QString> createPartsOfSpeech()
  {
    QSet<QString> category;

    category << "adj-i" << "adj-na" << "adj-no" << "adj-pn" << "adj-t" << "adj-f"
             << "adj" << "adv" << "adv-n" << "adv-to" << "aux" << "aux-v"
             << "aux-adj" << "conj" << "ctr" << "exp" << "id" << "int"
             << "iv" << "n" << "n-adv" << "n-pref" << "n-suf" << "n-t"
             << "num" << "pn" << "pref" << "prt" << "suf" << "v1"
             << "v5" << "v5aru" << "v5b" << "v5g" << "v5k" << "v5k-s"
             << "v5m" << "v5n" << "v5r" << "v5r-i" <<  "v5s" << "v5t"
             << "v5u" << "v5u-s" << "v5uru" << "v5z" << "vz" << "vi"
             << "vk" << "vn" << "vs" << "vs-i" << "vs-s" << "vt";

    return category;
  }

  QSet<QString> createFieldOfApplication()
  {
    QSet<QString> category;

    // Field of Application terms
    category << "Buddh" << "MA"   << "comp" << "food" << "geom"
             << "ling"  << "math" << "mil"  << "physics";

    return category;
  }

  QSet<QString> createMiscMarkings()
  {
    QSet<QString> category;

    // Miscellaneous Markings (in EDICT terms)
    category << "X"    << "abbr" << "arch" << "ateji"   << "chn"   << "col" << "derog"
             << "eK"   << "ek"   << "fam"  << "fem"     << "gikun" << "hon" << "hum" << "iK"   << "id"
             << "io"   << "m-sl" << "male" << "male-sl" << "ng"    << "oK"  << "obs" << "obsc" << "ok"
             << "poet" << "pol"  << "rare" << "sens"    << "sl"    << "uK"  << "uk"  << "vulg";

    return category;
  }
}
Ejemplo n.º 24
0
//------------------------------------------------------------------------------
//	FUNCTION: invalidate [ public ]
//------------------------------------------------------------------------------
void csvFilterProxyModel::invalidate()
{
	m_filterMapping.clear();

	if (!m_filterModel)
		return;

	// Make a hash of all the groups in the filter
	QMultiHash<size_t, int> groups;
	std::set<int> unusedFilterColumns;

	for (int filterCol = 0; filterCol < m_filterModel->columnCount(); ++filterCol)
	{
		unusedFilterColumns.insert(filterCol);

		size_t group = m_filterModel->data(m_filterModel->index(1, filterCol)).toULongLong();
		groups.insert(group, filterCol);
	}

	// filter in column order, but each group aside from 0 should be filtered using logical 'and' with all group members
	for (auto itr = unusedFilterColumns.begin(); itr != unusedFilterColumns.end(); ++itr)
	{
		int							filterCol = *itr;
		QString						columnName = m_filterModel->headerData(filterCol, Qt::Horizontal, Qt::DisplayRole).toString();
		size_t						group = m_filterModel->data(m_filterModel->index(1, filterCol)).toULongLong();
		size_t						numInGroup = (group == 0 ? 1 : groups.count(group));
		QList<QString>				filterColumnNames;

		// make a list of filter values, i.e. all the things in the filter column
		auto filterColumns = groups.values(group);
		qSort(filterColumns);

		if (group != 0)
		{
			// for each filter in the group
			for (auto groupColumnItr = filterColumns.begin(); groupColumnItr != filterColumns.end(); ++groupColumnItr)
			{
				int column = *groupColumnItr;

				filterColumnNames.push_back(m_filterModel->headerData(column, Qt::Horizontal, Qt::DisplayRole).toString());

				// erase other columns that are part of this group so we don't check them twice
				if (groupColumnItr != filterColumns.begin()) 
					unusedFilterColumns.erase(column);				
			}
		}
		else
		{
			filterColumnNames.push_back(columnName);
			filterColumns.clear();
			filterColumns.push_back(filterCol);
		}

		// find the corresponding column in this spreadsheet
		QList<int> masterColumns;
		for (int i = 0; i < filterColumnNames.size(); ++i)
		{
			for (int masterColumn = 0; masterColumn < sourceModel()->columnCount(); masterColumn++)
			{
				QString masterColunName = sourceModel()->headerData(masterColumn, Qt::Horizontal, Qt::DisplayRole).toString();
				if (masterColunName == filterColumnNames.at(i))
				{
					masterColumns.push_back(masterColumn);
					break;
				}
			}
		}

		// add the mappings to the mapping table
		QList<QPair<int, int>> filterMapping;
		for (int i = 0; i < filterColumns.size(); ++i)
		{
			filterMapping.push_back(QPair<int, int>(filterColumns.at(i), masterColumns.at(i)));
		}
		m_filterMapping.push_back(filterMapping);
	}

	QSortFilterProxyModel::invalidate();
}