/** * Ensures the current page is a query page that is ready to accept new * queries. * The function first checks the current page. If it is an unlocked query * page, then nothing needs to be done. Otherwise, it checks for the first * unlocked query page by iterating over all pages in the tab widget. If this * fails as well, a new query page is created. */ void QueryWidget::findQueryPage() { QueryPage* pPage; int nPages, i; // First check if the current page is an unlocked query page pPage = dynamic_cast<QueryPage*>(currentPage()); if (pPage != NULL) { if (!pPage->isLocked() && !pPage->isRunning()) return; } // Look for the first unlocked query page nPages = m_pQueryTabs->count(); for (i = 0; i < nPages; i++) { pPage = dynamic_cast<QueryPage*>(m_pQueryTabs->widget(i)); if (pPage != NULL) { if (!pPage->isLocked() && !pPage->isRunning()) { setCurrentPage(pPage); return; } } } // Couldn't find an unlocked query page, create a new one addQueryPage(); }
/** * Update the lock button when the current query page changes. * @param pWidget The new current page */ void QueryWidget::slotCurrentChanged(QWidget* pWidget) { QueryPage* pPage; pPage = (QueryPage*)pWidget; m_pLockAction->setChecked(pPage->isLocked()); }
/** * Update the lock button when the current query page changes. * @param pWidget The new current page */ void QueryWidget::slotCurrentChanged(QWidget* pWidget) { QueryPage* pPage; // Return immediatly if last tab was removed if (!pWidget) return; pPage = (QueryPage*)pWidget; m_pLockAction->setChecked(pPage->isLocked()); }
/** * Runs a query in a query page. * A query page is first selected, with a new one created if required. The * method then creates a Cscope process and runs the query. * @param nType The query's numeric type code * @param sText The query's text, as entered by the user */ void QueryWidget::initQuery(uint nType, const QString& sText) { QueryPage* pPage; // Make sure we have a query page findQueryPage(); pPage = (QueryPage*)currentPage(); // Use the current page, or a new page if the current one is locked if (pPage->isLocked()) { addQueryPage(); pPage = (QueryPage*)currentPage(); } // Reset the page's results list pPage->clear(); pPage->query(nType, sText); // Set the page's tab text according to the new query setPageCaption(pPage); }