Пример #1
0
/**
 * Creates a dataset for an investigation (based on ID) named 'mantid' if it
 * does not already exist.
 * @param investigationID :: The investigation to create a dataset for.
 * @return The ID of the mantid dataset.
 */
int64_t ICat4Catalog::createMantidDataset(const std::string &investigationID) {
  ICATPortBindingProxy icat;
  setICATProxySettings(icat);

  // We need to obtain an already existing datasetType as it's not recommended
  // to create a new one.
  auto datasetTypeSearch = performSearch(icat, "DatasetType[name ='analyzed']");
  auto datasetType = dynamic_cast<ns1__datasetType *>(datasetTypeSearch.at(0));

  auto investigationSearch =
      performSearch(icat, "Investigation[name = '" + investigationID + "']");
  auto investigation =
      dynamic_cast<ns1__investigation *>(investigationSearch.at(0));

  ns1__dataset dataset;
  std::string datasetName = "mantidTempNotDuplicate";

  dataset.name = &datasetName;
  dataset.complete = false;
  dataset.type = datasetType;
  dataset.investigation = investigation;

  int64_t datasetID = -1;

  if (isAccessAllowed(ns1__accessType__CREATE, dataset)) {
    ns1__create createRequest;
    ns1__createResponse createResponse;

    // We have to re-set the dataset name as when performing isAccessAllowed
    // an error will be thrown if the dataset already exists.
    std::string mantidName = "mantid";
    dataset.name = &mantidName;

    std::string sessionID = m_session->getSessionId();
    createRequest.sessionId = &sessionID;
    createRequest.bean = &dataset;

    if (icat.create(&createRequest, &createResponse) == SOAP_OK) {
      g_log.debug() << "Creating a new dataset named: " << *(dataset.name)
                    << " with investigationID " << investigationID << "\n";
      datasetID = createResponse.return_;
    }
    // Do not throw error from ICAT as we want to continue on GUI. Instead,
    // return -1 below.
  }

  g_log.debug()
      << "The dataset ID returned from ICat4Catalog::createMantidDataset was: "
      << datasetID << "\n";
  return datasetID; // Since we did not have access or could not create the file
                    // the default value (-1).
}
Пример #2
0
static void executeWgrep( void )
{
    DIR                 *dirh;
    struct dirent       *dp;
    unsigned            i;
    char                exp[_MAX_EXT];
    char                ext[_MAX_EXT];

    extendPath( PathBuff, CurrPattern );

    _splitpath( PathBuff, NULL, NULL, NULL, exp );

    if( strcmp( CurrPattern, "@@" ) == 0 ) {
        performSearch( CurrPattern );
    } else {
        dirh = opendir( PathBuff );
        if( dirh != NULL ) {
            for( ;; ) {
                if( DoneFlag ) return;
                dp = readdir( dirh );
                if( dp == NULL ) break;
#if defined( __WATCOMC__ ) && !defined( __UNIX__ )
                if( dp->d_attr & _A_SUBDIR ) continue;
#else
                {
                    struct stat sblk;
                    char tmp_path[_MAX_PATH+1];
                    strcpy( tmp_path, PathBuff );
                    extendPath( tmp_path, dp->d_name );
                    if( stat( tmp_path, &sblk ) == 0 && S_ISDIR( sblk.st_mode ) ) {
                        continue;
                    }
                }
#endif

                if( IgnoreListCnt > 0 ) {
                    _splitpath( dp->d_name, NULL, NULL, NULL, ext );
                    if( stricmp( ext, exp ) != 0 ) {
                        for( i=0; i < IgnoreListCnt; i++ ) {
                            if( stricmp( ext, IgnoreList[i] ) == 0 ) break;
                        }
                        if( i < IgnoreListCnt ) continue;
                    }
                }
                extendPath( PathBuff, dp->d_name );
                performSearch( PathBuff );
            }
            closedir( dirh );
        }
    }
}
Пример #3
0
void InspectorNodeFinder::searchUsingDOMTreeTraversal(Node* parentNode)
{
    // Manual plain text search.
    for (auto node = parentNode; node; node = NodeTraversal::next(node, parentNode)) {
        switch (node->nodeType()) {
        case Node::TEXT_NODE:
        case Node::COMMENT_NODE:
        case Node::CDATA_SECTION_NODE: {
            if (node->nodeValue().findIgnoringCase(m_whitespaceTrimmedQuery) != notFound)
                m_results.add(node);
            break;
        }
        case Node::ELEMENT_NODE: {
            if (matchesElement(*toElement(node)))
                m_results.add(node);

            // Search inside frame elements.
            if (node->isFrameOwnerElement()) {
                HTMLFrameOwnerElement* frameOwner = toHTMLFrameOwnerElement(node);
                if (Document* document = frameOwner->contentDocument())
                    performSearch(document);
            }

            break;
        }
        default:
            break;
        }
    }
}
Пример #4
0
void MainWindow::connectSignals()
{
    connect(guiUpdater_, SIGNAL(timeout()),
            this, SLOT(updateGui()) );

    connect(spotWorker, SIGNAL(loggedOut(sp_session*)),
            this, SLOT(loginFailed()) );
    connect(spotWorker, SIGNAL(loggedIn(sp_session*, sp_error*)),
            this, SLOT(loggedIn()) );

    connect(spotWorker, SIGNAL(metadataUpdated(sp_session*)),
            this, SLOT(updateViews()) );

    connect(spotWorker, SIGNAL(playlistAdded(sp_playlistcontainer*)),
            listListModel_, SLOT(setPlayLists(sp_playlistcontainer*)) );

    connect(searchBox, SIGNAL(currentIndexChanged(QString)),
            spotWorker, SLOT(performSearch(QString)));

    //connect(seekSlider, SIGNAL(sliderMoved(int)),
    //        spotWorker, SLOT(seekPlayer(int)));
    connect(netButton, SIGNAL(clicked()), spotWorker, SLOT(startServer()));

    connect(listListView, SIGNAL(clicked(const QModelIndex)),
            this, SLOT(listListClicked(const QModelIndex)) );

    connect(spotWorker, SIGNAL(searchComplete(sp_search*)),
            trackListModel_, SLOT(setSearch(sp_search*)));

    connect(trackList, SIGNAL(doubleClicked(const QModelIndex)),
            this, SLOT(songDoubleClicked(const QModelIndex)) );
}
Пример #5
0
void SearchEngine::onSearchParamsChanged(const Juff::SearchParams& params) {
//	LOGGER;
	clearSelection();
	curDoc_->clearHighlighting();
	
	if ( params.findWhat.isEmpty() ) {
		searchPopup_->setSearchStatus(-1, 0);
		searchPopup_->setFocusOnFind();
		return;
	}
	
	Juff::SearchResults* results = performSearch(params);
	curDoc_->setSearchResults(results);
	
	if ( results == NULL ) {
		qDebug("Error: SearchResults can't be NULL, probably it's an error in getSearchResults() method");
		return;
	}
	
	if ( results->count() > 0 ) {
		selectNextOccurence();
		if ( searchPopup_->isVisible() ) {
			curDoc_->highlightSearchResults();
		}
	}
	else {
		searchPopup_->setSearchStatus(-1, 0);
	}
	
	searchPopup_->setFocusOnFind();
}
Пример #6
0
void QgsLocatorWidget::search( const QString &string )
{
  mLineEdit->setText( string );
  window()->activateWindow(); // window must also be active - otherwise floating docks can steal keystrokes
  mLineEdit->setFocus();
  performSearch();
}
Пример #7
0
void QgsLocatorWidget::triggerSearchAndShowList()
{
  if ( mProxyModel->rowCount() == 0 )
    performSearch();
  else
    showList();
}
Пример #8
0
Relation Database::performRename(Predicate query, Relation r){
	vector<int> indexes = performSearch(query, r);
	for(int i = 0; i < (int)indexes.size(); i++)
		r = r.rename(i, query.getParameters()[indexes[i]].getValue());

	return r;
}
Пример #9
0
/**
 * Returns the datafiles associated to the given investigation id.
 * @param investigationId  :: unique identifier of the investigation
 * @param outputws         :: shared pointer to datasets
 */
void ICat4Catalog::getDataFiles(const std::string &investigationId,
                                Mantid::API::ITableWorkspace_sptr &outputws) {
  ICATPortBindingProxy icat;
  setICATProxySettings(icat);

  auto searchResults =
      performSearch(icat, "Datafile <-> Dataset <-> Investigation[name = '" +
                              investigationId + "']");
  saveDataFiles(searchResults, outputws);
}
QVector<OsmAnd::AddressesByNameSearch::ResultEntry> OsmAnd::AddressesByNameSearch::performSearch(
        const OsmAnd::AddressesByNameSearch::Criteria& criteria) const
{
    QVector<ResultEntry> result{};
    performSearch(
                criteria,
                [&result](const OsmAnd::ISearch::Criteria& criteria, const OsmAnd::BaseSearch::IResultEntry& resultEntry) {
        result.append(static_cast<const ResultEntry&>(resultEntry));
    });
    return result;

}
Пример #11
0
/**
 * Gets the file location string from the archives.
 * @param fileID :: The id of the file to search for.
 * @return The location of the datafile stored on the archives.
 */
const std::string ICat4Catalog::getFileLocation(const long long &fileID) {
  ICATPortBindingProxy icat;
  setICATProxySettings(icat);

  auto searchResults =
      performSearch(icat, "Datafile[id = '" + std::to_string(fileID) + "']");
  auto datafile = dynamic_cast<ns1__datafile *>(searchResults.at(0));

  if (datafile && datafile->location)
    return *(datafile->location);
  else
    return "";
}
Пример #12
0
/**
 * Returns the list of instruments.
 * @param instruments :: instruments list
 */
void ICat4Catalog::listInstruments(std::vector<std::string> &instruments) {
  ICATPortBindingProxy icat;
  setICATProxySettings(icat);

  auto searchResults =
      performSearch(icat, "Instrument.fullName ORDER BY fullName");

  for (auto &searchResult : searchResults) {
    auto instrument = dynamic_cast<xsd__string *>(searchResult);
    if (instrument)
      instruments.push_back(instrument->__item);
  }
}
Пример #13
0
/**
 * Returns the list of investigation types.
 * @param invstTypes :: investigation types list
 */
void ICat4Catalog::listInvestigationTypes(
    std::vector<std::string> &invstTypes) {
  ICATPortBindingProxy icat;
  setICATProxySettings(icat);

  auto searchResults =
      performSearch(icat, "InvestigationType.name ORDER BY name");

  for (auto &searchResult : searchResults) {
    auto investigationType = dynamic_cast<xsd__string *>(searchResult);
    if (investigationType)
      invstTypes.push_back(investigationType->__item);
  }
}
Пример #14
0
void SearchEngine::onDocTextChanged() {
	clearSelection();
	curDoc_->clearHighlighting();
	
	Juff::SearchParams params = searchPopup_->searchParams();
	params.backwards = false;
	Juff::SearchResults* results = performSearch(params);
	curDoc_->setSearchResults(results);
	if ( searchPopup_->isVisible() ) {
		curDoc_->highlightSearchResults();
		if ( results != NULL ) {
			searchPopup_->setSearchStatus(-1, results->count());
		}
	}
}
TEST_F(TestApplication, can_perform_search_of_one_unexisting_key) {
    // Arrange
    constexpr char query[] = "UnexistingKey";
    const std::vector<Table::iterator> expected = {
        table_.end()
    };

    // Act
    const auto results = (performSearch(query));

    // Assert
    for (size_t i = 0; i < expected.size(); ++i) {
        EXPECT_TRUE(expected[i] == results[i]);
    }
}
TEST_F(TestApplication, can_perform_search_of_multiple_existing_keys) {
    // Arrange
    constexpr char query[] = "Name2,Name4";
    const std::vector<Table::iterator> expected = {
        table_.begin() + 1,
        table_.begin() + 3
    };

    // Act
    const auto results = (performSearch(query));

    // Assert
    for (size_t i = 0; i < expected.size(); ++i) {
        EXPECT_TRUE(expected[i] == results[i]);
    }
}
Пример #17
0
/**
 * Returns the logged in user's investigations data.
 * @param outputws :: Pointer to table workspace that stores the data.
 */
void ICat4Catalog::myData(Mantid::API::ITableWorkspace_sptr &outputws) {
  ICATPortBindingProxy icat;
  setICATProxySettings(icat);

  std::string query =
      "SELECT DISTINCT inves "
      "FROM Investigation inves "
      "JOIN inves.investigationUsers users "
      "JOIN users.user user "
      "WHERE user.name = :user "
      "ORDER BY inves.id DESC "
      "INCLUDE inves.facility, inves.investigationInstruments.instrument, "
      "inves.parameters";

  auto searchResults = performSearch(icat, query);
  saveInvestigations(searchResults, outputws);
}
Пример #18
0
/**
 * Searches for the relevant data based on user input.
 * @param inputs   :: reference to a class contains search inputs
 * @param outputws :: shared pointer to search results workspace
 * @param offset   :: skip this many rows and start returning rows from this
 * point.
 * @param limit    :: limit the number of rows returned by the query.
 */
void ICat4Catalog::search(const CatalogSearchParam &inputs,
                          Mantid::API::ITableWorkspace_sptr &outputws,
                          const int &offset, const int &limit) {
  std::string query = buildSearchQuery(inputs);

  // Check if the query built was valid.
  if (query.empty())
    throw std::runtime_error("You have not input any terms to search for.");

  // Modify the query to include correct SELECT and LIMIT clauses.
  query.insert(0, "SELECT DISTINCT inves");
  query.append(" LIMIT " + std::to_string(offset) + "," +
               std::to_string(limit));

  ICATPortBindingProxy icat;
  setICATProxySettings(icat);

  auto searchResults = performSearch(icat, query);
  saveInvestigations(searchResults, outputws);
}
Пример #19
0
/**
 * Obtain the number of investigations to be returned by the catalog.
 * @return The number of investigations returned by the search performed.
 */
int64_t
ICat4Catalog::getNumberOfSearchResults(const CatalogSearchParam &inputs) {
  ICATPortBindingProxy icat;
  setICATProxySettings(icat);

  std::string query = buildSearchQuery(inputs);
  if (query.empty())
    throw std::runtime_error("You have not input any terms to search for.");
  query.insert(0, "SELECT COUNT(DISTINCT inves)");

  auto searchResults = performSearch(icat, query);
  auto numRes = dynamic_cast<xsd__long *>(searchResults.at(0));

  if (numRes) {
    g_log.debug() << "The number of paging results returned in "
                     "ICat4Catalog::getNumberOfSearchResults is: "
                  << numRes->__item << "\n";
    return numRes->__item;
  } else
    return -1;
}
Пример #20
0
/**
 * Search the archive & obtain the "mantid" dataset ID for a specific
 * investigation if it exists.
 * If it does not exist, we will attempt to create it.
 * @param investigationID :: Used to obtain the related dataset ID.
 * @return Dataset ID of the provided investigation.
 */
int64_t ICat4Catalog::getMantidDatasetId(const std::string &investigationID) {
  ICATPortBindingProxy icat;
  setICATProxySettings(icat);

  auto searchResults = performSearch(
      icat, "Dataset <-> Investigation[name = '" + investigationID + "']");

  int64_t datasetID = -1;
  for (auto &searchResult : searchResults) {
    auto dataset = dynamic_cast<ns1__dataset *>(searchResult);
    if (dataset && *(dataset->name) == "mantid")
      datasetID = *(dataset->id);
  }

  if (datasetID == -1)
    datasetID = createMantidDataset(investigationID);
  g_log.debug() << "The dataset ID of the mantid dataset was: " << datasetID
                << "\n";

  return datasetID;
}
Пример #21
0
void OsmAnd::BaseSearch::startSearch(
    const Criteria& criteria,
    const NewResultEntryCallback newResultEntryCallback,
    const SearchCompletedCallback searchCompletedCallback,
    QThreadPool* const threadPool,
    const std::shared_ptr<const IQueryController>& queryController /*= nullptr*/) const
{
    const auto runnable = new QRunnableFunctor(
        [this, criteria, newResultEntryCallback, searchCompletedCallback, queryController]
        (const QRunnableFunctor* const runnable)
        {
            QList<IResultEntry> results;
            const NewResultEntryCallback newResultEntryCallbackWrapper =
                [newResultEntryCallback, &results]
                (const Criteria& criteria, const IResultEntry& resultEntry)
                {
                    results.push_back(resultEntry);
                    newResultEntryCallback(criteria, resultEntry);
                };
            performSearch(criteria, newResultEntryCallbackWrapper, queryController);
            searchCompletedCallback(criteria, results);
        });
    threadPool->start(runnable);
}
Пример #22
0
void SearchTab::createGui()
{
	QVBoxLayout *layout = new QVBoxLayout(this);
	layout->setMargin(2);
	layout->setSpacing(0);

	Splitter = new QSplitter(Qt::Horizontal, this);
	layout->addWidget(Splitter);

	QWidget *queryWidget = new QWidget(Splitter);
	QVBoxLayout *queryLayout = new QVBoxLayout(queryWidget);
	queryLayout->setMargin(3);

	QWidget *queryFormWidget = new QWidget(queryWidget);
	queryLayout->addWidget(queryFormWidget);

	QFormLayout *queryFormLayout = new QFormLayout(queryFormWidget);
	queryFormLayout->setLabelAlignment(Qt::AlignLeft | Qt::AlignHCenter);
	queryFormLayout->setRowWrapPolicy(QFormLayout::WrapAllRows);
	queryFormLayout->setMargin(0);

	Query = new QLineEdit(queryFormWidget);
	Query->setMinimumWidth(200);
	queryFormLayout->addRow(tr("Search for:"), Query);

	connect(Query, SIGNAL(returnPressed()), this, SLOT(performSearch()));

	SearchInChats = new QRadioButton(tr("Chats"), queryFormWidget);
	SearchInChats->setChecked(true);
	SelectChat = m_pluginInjectedFactory->makeInjected<HistoryTalkableComboBox>(queryFormWidget);
	SelectChat->setAllLabel(tr(" - All chats - "));
	SelectChat->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
	queryFormLayout->addRow(SearchInChats, SelectChat);

	SearchInStatuses = new QRadioButton(tr("Statuses"), queryFormWidget);
	SelectStatusBuddy = m_pluginInjectedFactory->makeInjected<HistoryTalkableComboBox>(queryFormWidget);
	SelectStatusBuddy->setAllLabel(tr(" - All buddies - "));
	SelectStatusBuddy->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
	SelectStatusBuddy->setEnabled(false);
	queryFormLayout->addRow(SearchInStatuses, SelectStatusBuddy);

	SearchInSmses = new QRadioButton(tr("Smses"), queryFormWidget);
	SelectSmsRecipient = m_pluginInjectedFactory->makeInjected<HistoryTalkableComboBox>(queryFormWidget);
	SelectSmsRecipient->setAllLabel(tr(" - All recipients - "));
	SelectSmsRecipient->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
	SelectSmsRecipient->setEnabled(false);
	queryFormLayout->addRow(SearchInSmses, SelectSmsRecipient);

	QButtonGroup *kindRadioGroup = new QButtonGroup(queryFormWidget);
	kindRadioGroup->addButton(SearchInChats);
	kindRadioGroup->addButton(SearchInStatuses);
	kindRadioGroup->addButton(SearchInSmses);
	connect(kindRadioGroup, SIGNAL(buttonReleased(QAbstractButton*)),
	        this, SLOT(kindChanged(QAbstractButton*)));

	SearchByDate = new QCheckBox(tr("By date"), queryFormWidget);
	SearchByDate->setCheckState(Qt::Unchecked);

	QWidget *dateWidget = new QWidget(queryFormWidget);

	QHBoxLayout *dateLayout = new QHBoxLayout(dateWidget);

	FromDate = new QDateEdit(dateWidget);
	FromDate->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
	FromDate->setCalendarPopup(true);
	FromDate->setDate(QDate::currentDate().addDays(-7));
	dateLayout->addWidget(FromDate);

	dateLayout->addWidget(new QLabel(tr("to"), dateWidget));

	ToDate = new QDateEdit(dateWidget);
	ToDate->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
	ToDate->setCalendarPopup(true);
	ToDate->setDate(QDate::currentDate());
	dateLayout->addWidget(ToDate);

	connect(FromDate, SIGNAL(dateChanged(QDate)), this, SLOT(fromDateChanged(QDate)));
	connect(ToDate, SIGNAL(dateChanged(QDate)), this, SLOT(toDateChanged(QDate)));
	connect(SearchByDate, SIGNAL(toggled(bool)), dateWidget, SLOT(setEnabled(bool)));

	dateWidget->setEnabled(false);
	queryFormLayout->addRow(SearchByDate, dateWidget);

	QPushButton *searchButton = new QPushButton(tr("Search"), queryFormWidget);
	searchButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
	queryFormLayout->addRow(0, searchButton);

	connect(searchButton, SIGNAL(clicked()), this, SLOT(performSearch()));

	TimelineView = m_pluginInjectedFactory->makeInjected<TimelineChatMessagesView>(Splitter);
	TimelineView->setTalkableVisible(true);
	TimelineView->setTitleVisible(true);
	TimelineView->setLengthHeader(tr("Found"));
	connect(TimelineView, SIGNAL(currentDateChanged()), this, SLOT(currentDateChanged()));
	connect(TimelineView, SIGNAL(messagesDisplayed()), this, SLOT(messagesDisplayed()));

	TimelineView->searchBar()->setAutoVisibility(false);
	TimelineView->searchBar()->setSearchWidget(this);
	connect(TimelineView->searchBar(), SIGNAL(clearSearch()), this, SLOT(clearSelect()));

	setFocusProxy(Query);
}
Пример #23
0
		SEM::Var* ConvertVar(Context& context, const Debug::VarInfo::Kind varKind, const AST::Node<AST::TypeVar>& astTypeVarNode) {
			const auto& location = astTypeVarNode.location();
			
			switch (astTypeVarNode->kind()) {
				case AST::TypeVar::ANYVAR: {
					throw ErrorException("'Any' vars not yet implemented for uninitialised variables.");
				}
				
				case AST::TypeVar::NAMEDVAR: {
					const auto& varName = astTypeVarNode->name();
					
					// Search all scopes outside of the current scope.
					const auto searchStartPosition = 1;
					if (varKind != Debug::VarInfo::VAR_MEMBER && !performSearch(context, Name::Relative() + varName, searchStartPosition).isNone()) {
						throw ErrorException(makeString("Variable '%s' shadows existing object at position %s.",
							varName.c_str(), location.toString().c_str()));
					}
					
					const auto varType = ConvertType(context, astTypeVarNode->namedType());
					
					// 'final' keyword uses a different lval type (which doesn't support
					// moving or re-assignment).
					const bool isFinalLval = astTypeVarNode->isFinal();
					
					const auto lvalType = makeLvalType(context, isFinalLval, varType);
					
					const auto var = SEM::Var::Basic(varType, lvalType);
					var->setMarkedUnused(astTypeVarNode->isUnused());
					var->setOverrideConst(astTypeVarNode->isOverrideConst());
					attachVar(context, varName, astTypeVarNode, var, varKind);
					return var;
				}
				
				case AST::TypeVar::PATTERNVAR: {
					const auto varType = ConvertType(context, astTypeVarNode->patternType())->resolveAliases();
					
					if (!varType->isDatatype()) {
						throw ErrorException(makeString("Can't pattern match for non-datatype '%s' at position %s.",
							varType->toString().c_str(), location.toString().c_str()));
					}
					
					const auto& astChildTypeVars = astTypeVarNode->typeVarList();
					const auto& typeChildVars = varType->getObjectType()->variables();
					
					if (astChildTypeVars->size() != typeChildVars.size()) {
						throw ErrorException(makeString("%llu pattern match children specified; %llu expected (for type '%s') at position %s.",
								(unsigned long long) astChildTypeVars->size(),
								(unsigned long long) typeChildVars.size(),
								varType->toString().c_str(),
								location.toString().c_str()));
					}
					
					const auto templateVarMap = varType->generateTemplateVarMap();
					
					std::vector<SEM::Var*> children;
					
					for (size_t i = 0; i < typeChildVars.size(); i++) {
						const auto& astVar = astChildTypeVars->at(i);
						children.push_back(ConvertVar(context, varKind, astVar));
					}
					
					return SEM::Var::Composite(varType, children);
				}
			}
			
			std::terminate();
		}
NCSAFindBar::NCSAFindBar( Okular::Document * document, QWidget * parent )
  : QWidget( parent )
  , m_active( false )
{
    doc = document;
    if(NULL != doc)
    {
      doc->addObserver(this);
    }
    QVBoxLayout * vlay = new QVBoxLayout( this );
    QHBoxLayout * displayRow = new QHBoxLayout();
    vlay->addLayout( displayRow );
    display = new QLabel("");
    displayRow->addWidget(display);
    displayRow->insertStretch(1);
    resultComboBox = new QComboBox();
    //resultComboBox->addItems(fonts);
    displayRow->addWidget(resultComboBox);

    QHBoxLayout * lay = new QHBoxLayout();
    vlay->setMargin( 2 );
    vlay->addLayout(lay);


    QPushButton * optionsBtn = new QPushButton( this );
    optionsBtn->setText( i18n( "NCSA Options" ) );
    optionsBtn->setToolTip( i18n( "Modify search behavior" ) );
    QMenu * optionsMenu = new QMenu( optionsBtn );
    m_buildFontAct = optionsMenu->addAction( i18n( "Create custom font" ) );
    connect( m_buildFontAct, SIGNAL(triggered(bool)), this, SLOT(buildFontAct(bool)) );

    optionsBtn->setMenu( optionsMenu );
    lay->addWidget( optionsBtn );
    
    QStringList fonts = QFontDatabase().families();
    
    fontComboBox = new QComboBox();
    fontComboBox->addItems(fonts);
    lay->addWidget(fontComboBox);
    connect( fontComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(changeFont(int)) );
    connect( resultComboBox, SIGNAL(highlighted(int)), this, SLOT(resultComboBoxIndexChanged(int)) );

    QPalette p(palette());
    p.setColor(QPalette::Background, Qt::white);
    display->setAutoFillBackground(true);
    display->setPalette(p);
    display->setText("Lalala");
    QFont font;
    font.setPointSize(32);
    font.setBold(true);
    font.setFamily(fonts.at(16));

    display->setFont(font);
    
    searchLine = new QLineEdit();
    lay->addWidget(searchLine);
    
    connect(searchLine,SIGNAL(textChanged(QString)),this,SLOT(searchLineTextChanged(QString)));
    hide();
    
    QPushButton * searchBtn = new QPushButton( KIcon( "Search" ), i18nc( "Search using word spotting technique", "search" ), this );
    searchBtn->setToolTip( i18n( "Search using word spotting technique" ) );
    lay->addWidget( searchBtn );
    connect( searchBtn, SIGNAL(clicked()), this, SLOT(performSearch()) );

    // "activate" it only at th very end
    m_active = true;
    wordSpottingUtil = NULL;
    
}
Пример #25
0
Relation Database::performProject(Predicate query, Relation r){
	r = r.project(performSearch(query, r));
	return r;
}