Esempio n. 1
0
ServerItem *ServerView::getParent(const QString &continentcode, const QString &countrycode, const QString &countryname, const QString &usercontinent, const QString &usercountry) {
	ServerItem *continent = qmContinent.value(continentcode);
	if (! continent) {
		QString name = qmContinentNames.value(continentcode);
		if (name.isEmpty())
			name = continentcode;
		continent = new ServerItem(name, ServerItem::PublicType, continentcode);
		qmContinent.insert(continentcode, continent);
		siPublic->addServerItem(continent);

		if (continentcode == usercontinent) {
			continent->setExpanded(true);
			scrollToItem(continent, QAbstractItemView::PositionAtTop);
		} else {
			continent->setExpanded(false);
		}
	}
	ServerItem *country = qmCountry.value(countrycode);
	if (! country) {
		country = new ServerItem(countryname, ServerItem::PublicType, continentcode, countrycode);
		qmCountry.insert(countrycode, country);
		country->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator);

		continent->addServerItem(country);

		if (countrycode == usercountry) {
			country->setExpanded(true);
			scrollToItem(country, QAbstractItemView::PositionAtTop);
		} else {
			country->setExpanded(false);
		}
	}
	return country;
}
void qm_plistview::keyPressEvent(QKeyEvent *event)
{
    switch (event->key())
    {
        case Qt::Key_Return:
        {
            on_item_dclicked(currentItem());
            break;
        }

        case Qt::Key_Delete:
        {
            delete_it();
            break;
        }

        case Qt::Key_Space:
        {
            if (current_songPos != -1 && current_songPos < topLevelItemCount() )
                scrollToItem(topLevelItem(current_songPos));
            break;
        }

        case Qt::Key_Home:
        {
            if (topLevelItemCount() > 0)
                scrollToItem(topLevelItem(0));
            break;
        }

        case Qt::Key_End:
        {
            if (topLevelItemCount() > 0)
                scrollToItem(topLevelItem(topLevelItemCount() - 1));
            break;
        }

        case Qt::Key_Down:
        {
            if (currentItem()->get_pos < topLevelItemCount())
                setCurrentItem(itemBelow ( currentItem() ));
            break;
        }

        case Qt::Key_Up:
        {
            if (currentItem()->get_pos > 1)
                setCurrentItem(itemAbove ( currentItem() ));
            break;
        }

        default:
            QTreeWidget::keyPressEvent(event);
    }
}
Esempio n. 3
0
  /**
   * The project's undo stack has changed. Display the changed states appropriately.
   */
  void HistoryTreeWidget::handleUndoIndexChanged(int newIndex) {
    QTreeWidgetItem *prevItem = undoCommandToTreeItem(
        m_project->undoStack()->command(newIndex - 1));
    markNotUndone(prevItem);

    QTreeWidgetItem *curItem = undoCommandToTreeItem(m_project->undoStack()->command(newIndex));
    markUndone(curItem);

    markUndone(undoCommandToTreeItem(m_project->undoStack()->command(newIndex + 1)));

    scrollToItem(prevItem);
    scrollToItem(curItem);
  }
Esempio n. 4
0
void GuiSymbols::on_categoryCO_activated(QString const & text)
{
	if (!categoryFilterCB->isChecked())
		updateSymbolList(false);
	else
		scrollToItem(text);
}
Esempio n. 5
0
void QvvTreeWidget::findNext( QString str, int full_match )
{
    QTreeWidgetItem *lwi = currentItem();

    int i;
    int start;

    int x = topLevelItemCount();

    i = indexOfTopLevelItem( lwi );
    start = i;

    if( x <= 1 or i < 0 ) return; // not found or empty list

    while(4)
    {
        i++;
        if( i >= x ) i = 0;
        if( i == start ) break;
        lwi = topLevelItem( i );
        if(   full_match && lwi->text( 1 ).toUpper() == str.toUpper() ) break;
        if( ! full_match && lwi->text( 1 ).toUpper().indexOf( str.toUpper() ) == 0 ) break;
        lwi = NULL;
    }
    if( lwi )
    {
        setCurrentItem( lwi );
        scrollToItem( lwi );
    }
}
		TITANIUM_FUNCTION(ListView, scrollToItem)
		{
			const auto js_context = this_object.get_context();
			if (arguments.size() >= 2) {
				JSObject animation = js_context.CreateObject();

				const auto _0 = arguments.at(0);
				TITANIUM_ASSERT(_0.IsNumber());
				const auto _1 = arguments.at(1);
				TITANIUM_ASSERT(_1.IsNumber());

				const auto sectionIndex = static_cast<uint32_t>(_0);
				const auto itemIndex    = static_cast<uint32_t>(_1);

				if (arguments.size() >= 3) {
					const auto _3 = arguments.at(2);
					if (_3.IsObject()) {
						animation = listviewAnimationProperties_ctor__.CallAsConstructor({_3});
					}
				}

				scrollToItem(sectionIndex, itemIndex, animation.GetPrivate<ListViewAnimationProperties>());
			}

			return this_object.get_context().CreateUndefined();
		}
Esempio n. 7
0
void MetadataListView::setCurrentItemByKey(const QString& itemKey)
{
    if (itemKey.isNull())
    {
        return;
    }

    int i                 = 0;
    QTreeWidgetItem* item = 0;

    do
    {
        item = topLevelItem(i);

        if (item && (item->flags() & Qt::ItemIsSelectable))
        {
            MetadataListViewItem* lvItem = dynamic_cast<MetadataListViewItem*>(item);

            if (lvItem)
            {
                if (lvItem->getKey() == itemKey)
                {
                    setCurrentItem(item);
                    scrollToItem(item);
                    m_selectedItemKey = itemKey;
                    return;
                }
            }
        }

        ++i;
    }
    while (item);
}
Esempio n. 8
0
void ScanGallery::slotSelectImage(const KUrl &url)
{
    FileTreeViewItem *found = findItemByUrl(url);
    if (found==NULL) found = m_defaultBranch->root();

    scrollToItem(found);
    setCurrentItem(found);
    slotItemActivated(found);
}
Esempio n. 9
0
bool PlaylistWindow::activateItem(QUuid playlistUuid, QUuid itemUuid)
{
    if (!widgets.contains(playlistUuid))
        return false;
    auto qdp = widgets[playlistUuid];
    qdp->scrollToItem(itemUuid);
    qdp->setNowPlayingItem(itemUuid);
    return true;
}
Esempio n. 10
0
void MessagesWidget::showItem( QListWidgetItem *item ) {
	addItem( item );
	scrollToItem( item );

	if ( maximumItemCount_.has_value() ) {
		while ( count() > *maximumItemCount_ )
			delete takeItem( 0 );
	}
}
Esempio n. 11
0
//----------------------------------------------------------------------------------------
OfsTreeWidget::OfsTreeWidget(QWidget *parent, unsigned int capabilities, std::string initialSelection) : QTreeWidget(parent), mCapabilities(capabilities) 
{
    mSelected = initialSelection;

    setColumnCount(1);
    setHeaderHidden(true);
    setSelectionMode(QAbstractItemView::SingleSelection);
    setSelectionBehavior(QAbstractItemView::SelectItems);
    setContextMenuPolicy(Qt::CustomContextMenu);
    setDragDropOverwriteMode(false);
    
    if(capabilities & CAP_ALLOW_DROPS)
        setDragDropMode(QAbstractItemView::DropOnly);

    mUnknownFileIcon = mOgitorMainWindow->mIconProvider.icon(QFileIconProvider::File);

    mFile = Ogitors::OgitorsRoot::getSingletonPtr()->GetProjectFile();

    QTreeWidgetItem* item = 0;
    QTreeWidgetItem* pItem = new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("Project")));
    pItem->setIcon(0, mOgitorMainWindow->mIconProvider.icon(QFileIconProvider::Folder));
    pItem->setTextColor(0, Qt::black);
    QFont fnt = pItem->font(0);
    fnt.setBold(true);
    pItem->setFont(0, fnt);
    pItem->setWhatsThis(0, QString("/"));
    
    addTopLevelItem(pItem);

    fillTree(pItem, "/");

    if(capabilities & CAP_SHOW_FILES)
        fillTreeFiles(pItem, "/");

    expandItem(pItem);

    if(mSelected == "/")
        setItemSelected(pItem, true);
    else
    {
        NameTreeWidgetMap::iterator it = mItemMap.find(mSelected);

        if(it != mItemMap.end())
        {
            clearSelection();
            scrollToItem(it->second);
            setItemSelected(it->second, true);
        }
    }

    connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(onSelectionChanged()));

    if(capabilities & CAP_SHOW_FILES)
    {
        connect(this, SIGNAL(itemCollapsed( QTreeWidgetItem * )), this, SLOT(onItemCollapsed( QTreeWidgetItem * )));
        connect(this, SIGNAL(itemExpanded( QTreeWidgetItem * )), this, SLOT(onItemExpanded( QTreeWidgetItem * )));
    }
Esempio n. 12
0
int XFE_ComposeAttachPanel::dropAttachments(const char **item,int numItems)
{
    int dropStatus=_attachFolder->addAttachments(item,numItems);

    // ensure last-added item is visible
    if (dropStatus)
        scrollToItem(_numItems-1);
    
    return dropStatus;
}
Esempio n. 13
0
void MailListView::setSelectedItem(QTableWidgetItem* item)
{
    // Replace any existing selection with this item
    clearSelection();
    item->setSelected(true);

    // Make this item the current item, also
    setCurrentItem(item);
    scrollToItem(item);
}
Esempio n. 14
0
void LibraryTreeWidget::dragLeaveEvent(QDragLeaveEvent *)
{
    m_openBranchTimer->stop();

    if (m_currentItem) {
        setCurrentItem(m_currentItem);
        scrollToItem(m_currentItem);
    }

    m_currentItem = nullptr;
    m_dropItem = nullptr;
}
Esempio n. 15
0
  void TableView::goToFile(const QString& filename)
  {
    for (int i=0;i<rowCount();i++)
    {

      if ( (!isRowHidden(i)) && (item(i,m_slHeaders.indexOf("File"))->text().toUpper() == filename.toUpper()) )
      {
        scrollToItem(item(i,0), QAbstractItemView::PositionAtTop);
        break;
      }
    }
  }
void GCF::Components::ScriptableObjectExplorer::highlightScriptableObject(QObject* object)
{
    if(d->objectItemMap.contains(object))
    {
        QTreeWidgetItem* item = d->objectItemMap[object];
        scrollToItem(item);
        clearSelection();
        item->setSelected(true);
        return;
    }

    for(int i=0; i<d->objectItems.count(); i++)
    {
        QTreeWidgetItem* item = d->objectItems[i];
        if(item->data(0, Qt::UserRole).value<QObject*>() == object)
        {
            scrollToItem(item);
            clearSelection();
            item->setSelected(true);
            return;
        }
    }
}
Esempio n. 17
0
void ScanGallery::slotSelectDirectory(const QString &branchName, const QString &relPath)
{
    kDebug() << "branch" << branchName << "path" << relPath;

    FileTreeViewItem *item;
    if (!branchName.isEmpty()) item = findItemInBranch(branchName, relPath);
    else item = findItemInBranch(branches().at(0), relPath);
							// assume the 1st/only branch
    if (item==NULL) return;

    scrollToItem(item);
    setCurrentItem(item);
    slotItemActivated(item);				// load thumbnails, etc.
}
Esempio n. 18
0
void BGMultiWallpaperList::ensureSelectionVisible()
{
    // KDE 4 - I believe the three lines below are redundant
    //
    //for ( int i = topItem(); i < topItem() + numItemsVisible() - 1; i++)
    //    if ( item( i ) && item( i )->isSelected() )
    //        return;

    for ( int i = 0; i < count(); i++)
        if ( item( i ) && item( i )->isSelected() )
        {
            scrollToItem( item(i) , QAbstractItemView::PositionAtTop );
            return;
        }
}
Esempio n. 19
0
void CoverageView::doUpdate(int changeType, bool)
{
    // Special case ?
    if (changeType == selectedItemChanged) {

	if (!_selectedItem) {
	    clearSelection();
	    return;
	}

	TraceFunction* f = 0;
        QTreeWidgetItem* i = currentItem();
	if (i) {
	    f = _showCallers ?
		((CallerCoverageItem*)i)->function() :
		((CalleeCoverageItem*)i)->function();
	}
	if (f == _selectedItem) return;

        QTreeWidgetItem *item;
        for (int i=0; i<topLevelItemCount(); i++) {
            item = this->topLevelItem(i);
	    f = _showCallers ?
		((CallerCoverageItem*)item)->function() :
		((CalleeCoverageItem*)item)->function();
	    if (f == _selectedItem) {
                scrollToItem(item);
		setCurrentItem(item);
		break;
	    }
	}
	return;
    }

    if (changeType == groupTypeChanged) {
        QTreeWidgetItem *item;
        for (int i=0; i<topLevelItemCount();i++) {
            item = topLevelItem(i);
	    if (_showCallers)
		((CallerCoverageItem*)item)->setGroupType(_groupType);
	    else
                ((CalleeCoverageItem*)item)->setGroupType(_groupType);
        }
	return;
    }

    refresh();
}
/*! \brief Reload the selected entity node
*/
void EntitiesTreeWidget::onReopen()
{
    QTreeWidgetItem *it = currentItem();
    QTreeWidgetItem *parent = it -> parent();
    int index = it -> parent() -> indexOfChild(it);

    if(!it){
        return;
    }

    if(it->parent() == applicationNode){
        if(it->data(0,Qt::UserRole)  == yarp::manager::APPLICATION){
            yarp::manager::Application *app = (yarp::manager::Application*)it->data(0,Qt::UserRole + 1).toLongLong();
            if(app){
                QString fileName = QString("%1").arg(app->getXmlFile());
                QString appName = it->text(0);

                reopenApplication(appName,fileName);
            }

        }
    }else
    if(it->parent() == resourcesNode){
        if(it->data(0,Qt::UserRole)  == yarp::manager::RESOURCE){
            yarp::manager::Computer *res = (yarp::manager::Computer*)it->data(0,Qt::UserRole + 1).toLongLong();
            if(res){
                QString fileName = QString("%1").arg(res->getXmlFile());
                QString resName = it->text(0);

                reopenResource(resName,fileName);
            }
        }
    }else
    if(it->parent() == modulesNode){
        if(it->data(0,Qt::UserRole)  == yarp::manager::MODULE){
            yarp::manager::Module *mod = (yarp::manager::Module*)it->data(0,Qt::UserRole + 1).toLongLong();
            if(mod){
                QString fileName = QString("%1").arg(mod->getXmlFile());
                QString modName = it->text(0);

                reopenModule(modName,fileName);
            }
        }
    }

    parent -> child(index) -> setSelected(true);
    scrollToItem(parent -> child(index));
}
Esempio n. 21
0
void ListView::startMagneticScroll()
{
    if(_items.empty() || _magneticType == MagneticType::NONE)
    {
        return;
    }
    
    // Find the closest item
    Vec2 magneticAnchorPoint = getAnchorPointByMagneticType(_magneticType);
    Vec2 magneticPosition = -_innerContainer->getPosition();
    magneticPosition.x += getContentSize().width * magneticAnchorPoint.x;
    magneticPosition.y += getContentSize().height * magneticAnchorPoint.y;
    
    Widget* pTargetItem = getClosestItemToPosition(magneticPosition, magneticAnchorPoint);
    scrollToItem(getIndex(pTargetItem), magneticAnchorPoint, magneticAnchorPoint);
}
Esempio n. 22
0
void AdBlockTreeWidget::showRule(const AdBlockRule* rule)
{
    if (!m_topItem && rule) {
        m_ruleToBeSelected = rule->filter();
    }
    else if (!m_ruleToBeSelected.isEmpty()) {
        QList<QTreeWidgetItem*> items = findItems(m_ruleToBeSelected, Qt::MatchRecursive);
        if (!items.isEmpty()) {
            QTreeWidgetItem* item = items.at(0);

            setCurrentItem(item);
            scrollToItem(item, QAbstractItemView::PositionAtCenter);
        }

        m_ruleToBeSelected.clear();
    }
}
Esempio n. 23
0
void ViewTable::returnToCell( bool focus )
{
    if( LastRow < 0 || LastRow >= rowCount() )
        LastRow = 0;
    if( LastColumn < 0 || LastColumn >= columnCount() )
        LastColumn = 0;

    setCurrentCell( LastRow, LastColumn );
    setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );

    QTableWidgetItem *item = this->item( LastRow, LastColumn );
    if( item )
            scrollToItem( item, QAbstractItemView::PositionAtCenter );

    if( focus )
        setFocus();
}
Esempio n. 24
0
void ScanGallery::slotHighlightItem(const KUrl &url)
{
    kDebug() << url;

    FileTreeViewItem *found = findItemByUrl(url);
    if (found==NULL) return;

    bool b = blockSignals(true);
    scrollToItem(found);
    setCurrentItem(found);
    blockSignals(b);

    // Need to do this to update/clear the displayed image.  Causes a signal
    // to be sent back to the thumbnail view, but this is benign and fortunately
    // does not cause not a loop.
    slotItemHighlighted(found);
}
Esempio n. 25
0
void FunctionsTreeWidget::addFolder()
{
    blockSignals(true);
    if (selectedItems().isEmpty())
    {
        blockSignals(false);
        return;
    }

    QTreeWidgetItem *item = selectedItems().first();
    if (item->text(COL_PATH).isEmpty())
        item = item->parent();

    int type = item->data(COL_NAME, Qt::UserRole + 1).toInt();

    QString fullPath = item->text(COL_PATH);
    if (fullPath.endsWith('/') == false)
        fullPath.append("/");

    QString newName = "New folder";

    int folderCount = 1;

    while (m_foldersMap.contains(fullPath + newName))
    {
        newName = "New Folder " + QString::number(folderCount++);
    }

    fullPath += newName;

    QTreeWidgetItem *folder = new QTreeWidgetItem(item);
    folder->setText(COL_NAME, newName);
    folder->setIcon(COL_NAME, QIcon(":/folder.png"));
    folder->setData(COL_NAME, Qt::UserRole, Function::invalidId());
    folder->setData(COL_NAME, Qt::UserRole + 1, type);
    folder->setText(COL_PATH, fullPath);
    folder->setFlags(folder->flags() | Qt::ItemIsDropEnabled | Qt::ItemIsEditable);

    m_foldersMap[fullPath] = folder;
    item->setExpanded(true);

    blockSignals(false);

    scrollToItem(folder, QAbstractItemView::PositionAtCenter);
}
Esempio n. 26
0
void CallView::doUpdate(int changeType, bool)
{
    // Special case ?
    if (changeType == selectedItemChanged) {

	if (!_selectedItem) {
	    clearSelection();
	    return;
	}

        CallItem* ci = (CallItem*) currentItem();
	TraceCall* c;
	CostItem* ti;
	if (ci) {
	    c = ci->call();
	    ti = _showCallers ? c->caller() : c->called();
	    if (ti == _selectedItem) return;
	}

        QTreeWidgetItem *item = 0;
        for (int i=0; i<topLevelItemCount();i++) {
            item = topLevelItem(i);
	    c = ((CallItem*) item)->call();
	    ti = _showCallers ? c->caller() : c->called();
	    if (ti == _selectedItem) {
                scrollToItem(item);
                setCurrentItem(item);
		break;
	    }
	}
        if (!item && ci) clearSelection();
	return;
    }
    
    if (changeType == groupTypeChanged) {
        QTreeWidgetItem *item;
        for (int i=0; i<topLevelItemCount(); i++){
            item = topLevelItem(i);
	    ((CallItem*)item)->updateGroup();
        }
	return;
    }

    refresh();
}
Esempio n. 27
0
  /**
   * Add a single work order to the display. This uses the QUndoCommand text (if it's blank, it uses
   *   the QAction text). If there is no text, this does nothing.
   *
   * @param workOrder The work order to display the history for
   */
  void HistoryTreeWidget::addToHistory(WorkOrder *workOrder) {
    QString data = workOrder->bestText();

    connect(workOrder, SIGNAL(destroyed(QObject *)),
            this, SLOT(removeFromHistory(QObject *)));

    QStringList columnData;
    columnData.append(data);
    columnData.append("");
    columnData.append(workOrder->executionTime().toString());

    QTreeWidgetItem *newItem = new QTreeWidgetItem(columnData);
    newItem->setData(0, Qt::UserRole, qVariantFromValue(workOrder));

    // Do font for save work orders
    if (workOrder->createsCleanState()) {
      QFont saveFont = newItem->font(0);
      saveFont.setBold(true);
      saveFont.setItalic(true);
      newItem->setFont(0, saveFont);
      newItem->setForeground(0, Qt::gray);
    }

    // Do font for progress text
    QFont progressFont = newItem->font(1);
    progressFont.setItalic(true);
    newItem->setFont(1, progressFont);
    newItem->setForeground(1, Qt::gray);

    invisibleRootItem()->addChild(newItem);

    connect(workOrder, SIGNAL(statusChanged(WorkOrder *)),
            this, SLOT(updateStatus(WorkOrder *)));
    connect(workOrder, SIGNAL(creatingProgress(WorkOrder *)),
            this, SLOT(updateProgressWidgets()));
    connect(workOrder, SIGNAL(deletingProgress(WorkOrder *)),
            this, SLOT(updateProgressWidgets()));

    if (workOrder->progressBar()) {
      setItemWidget(newItem, 1, workOrder->progressBar());
    }

    scrollToItem(newItem);
    refit();
  }
Esempio n. 28
0
void EnfuseStackList::processingItem(const KUrl& url, bool run)
{
    d->processItem = findItemByUrl(url);
    if (d->processItem)
    {
        if (run)
        {
            setCurrentItem(d->processItem, true);
            scrollToItem(d->processItem);
            d->progressTimer->start(300);
        }
        else
        {
            d->progressTimer->stop();
            d->processItem = 0;
        }
    }
}
Esempio n. 29
0
void ViewTable::returnToId( bool focus )
{
    int row = this->getRowById( LastId );
    if( row < 0 )
    {
        returnToCell( focus );
        return;
    }

    setCurrentCell( row, LastColumn );
    setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );

    QTableWidgetItem *item = this->item( row, LastColumn );
    if( item )
            scrollToItem( item, QAbstractItemView::PositionAtCenter );

    if( focus )
        setFocus();
}
Esempio n. 30
0
void JobListWidget::selectJob(JobPtr job)
{
    if(!job)
    {
        DEBUG << "Null JobPtr passed.";
        return;
    }

    for(int i = 0; i < count(); ++i)
    {
        JobListWidgetItem *jobItem = static_cast<JobListWidgetItem *>(item(i));
        if(jobItem && (jobItem->job()->objectKey() == job->objectKey()))
        {
            clearSelection();
            setCurrentItem(jobItem);
            scrollToItem(currentItem(), QAbstractItemView::EnsureVisible);
            break;
        }
    }
}