Пример #1
0
void VDirectoryTree::updateItemDirectChildren(QTreeWidgetItem *p_item)
{
    QPointer<VDirectory> parentDir;
    if (p_item) {
        parentDir = getVDirectory(p_item);
    } else {
        parentDir = m_notebook->getRootDir();
    }

    const QVector<VDirectory *> &dirs = parentDir->getSubDirs();

    QHash<VDirectory *, QTreeWidgetItem *> itemDirMap;
    int nrChild = p_item ? p_item->childCount() : topLevelItemCount();
    for (int i = 0; i < nrChild; ++i) {
        QTreeWidgetItem *item = p_item ? p_item->child(i) : topLevelItem(i);
        itemDirMap.insert(getVDirectory(item), item);
    }

    for (int i = 0; i < dirs.size(); ++i) {
        VDirectory *dir = dirs[i];
        QTreeWidgetItem *item = itemDirMap.value(dir, NULL);
        if (item) {
            if (p_item) {
                p_item->removeChild(item);
                p_item->insertChild(i, item);
            } else {
                int topIdx = indexOfTopLevelItem(item);
                takeTopLevelItem(topIdx);
                insertTopLevelItem(i, item);
            }

            itemDirMap.remove(dir);
        } else {
            // Insert a new item
            if (p_item) {
                item = new QTreeWidgetItem(p_item);
            } else {
                item = new QTreeWidgetItem(this);
            }

            fillTreeItem(item, dir);
            buildSubTree(item, 1);
        }

        expandSubTree(item);
    }

    // Delete items without corresponding VDirectory
    for (auto iter = itemDirMap.begin(); iter != itemDirMap.end(); ++iter) {
        QTreeWidgetItem *item = iter.value();
        if (p_item) {
            p_item->removeChild(item);
        } else {
            int topIdx = indexOfTopLevelItem(item);
            takeTopLevelItem(topIdx);
        }

        delete item;
    }
}
Пример #2
0
void ItemBoxTreeWidget::removeCategory(int cat_idx)
{
    if (cat_idx >= topLevelItemCount()) {
        return;
    }
    delete takeTopLevelItem(cat_idx);
}
Пример #3
0
void DGameTree::RebuildTree()
{
	GameFile* currentGame = SelectedGame();

	int count = topLevelItemCount();
	for (int a = 0; a < count; a++)
		takeTopLevelItem(0);

	for (QTreeWidgetItem* i : m_path_nodes.values())
	{
		count = i->childCount();
		for (int a = 0; a < count; a++)
			i->takeChild(0);
	}

	if (m_current_style == STYLE_TREE)
	{
		for (QTreeWidgetItem* i : m_path_nodes.values())
			addTopLevelItem(i);
		for (QTreeWidgetItem* i : m_items.keys())
			m_path_nodes.value(m_items.value(i)->GetFolderName())->addChild(i);
	}
	else
	{
		for (QTreeWidgetItem* i : m_items.keys())
			addTopLevelItem(i);
	}

	expandAll();
	ResizeAllCols();
	SelectGame(currentGame);
}
Пример #4
0
void PlayerListWidget::removePlayer(int playerId)
{
	QTreeWidgetItem *player = players.value(playerId, 0);
	if (!player)
		return;
	players.remove(playerId);
	delete takeTopLevelItem(indexOfTopLevelItem(player));
}
Пример #5
0
void ItemBoxTreeWidget::deleteScratchpad()
{
    const int idx = indexOfScratchpad();
    if (idx == -1) {
        return;
    }
    delete takeTopLevelItem(idx);
    //save();
}
Пример #6
0
void ProgressTree2::removeJob(Job *job)
{
    if (!job->parentJob) {
        QTreeWidgetItem* item = findItem(job);
        if (item) {
            takeTopLevelItem(this->indexOfTopLevelItem(item));
            delete item;
        }
    }
}
Пример #7
0
void MenuBarTree::removeItem()
{
	QTreeWidgetItem* item = currentItem();
	if (!item) return;

	if (indexOfTopLevelItem(item) >= 0)
		takeTopLevelItem(indexOfTopLevelItem(item));
	else
		item->parent()->removeChild(item);

	delete item;
}
void KGraphEditorElementTreeWidget::slotRemoveAttribute()
{
  kDebug() << "Remove Attribute";
  if (m_item == 0) // should not happen
  {
    kError() << "null item ; should not happen" << endl;
    return;
  }
  emit removeAttribute(m_item->text(0));
  delete takeTopLevelItem (indexOfTopLevelItem(m_item));
  m_item = 0;
}
Пример #9
0
void  widgets::erase_record_from_the_tree(
        async::key_type const&  key,
        async::cached_resource_info const&  info
        )
{
    TMPROF_BLOCK();

    QTreeWidgetItem*  data_type_node = nullptr;
    {
        auto const  items = findItems(QString(key.get_data_type_name().c_str()), Qt::MatchFlag::MatchExactly, 0);
        if (items.empty())
            return;
        INVARIANT(items.size() == 1);
        data_type_node = items.front();
    }
    QTreeWidgetItem*  uid_node = nullptr;
    {
        std::string const  uid = get_tree_resource_uid(key);
        for (int i = 0, n = data_type_node->childCount(); i != n; ++i)
        {
            auto const  item = data_type_node->child(i);
            std::string const  item_name = qtgl::to_string(item->text(0));
            if (item_name == uid)
            {
                uid_node = item;
                break;
            }
        }
    }
    if (uid_node != nullptr)
    {
        if (qtgl::to_string(uid_node->text(0)) != key.get_unique_id())
        {
            std::string const  item_refs_name = qtgl::to_string(uid_node->text(1));
            int const  old_num_refs = std::atoi(item_refs_name.c_str());
            if (old_num_refs - info.get_ref_count() > 0)
                uid_node->setText(1, QString(std::to_string(old_num_refs - info.get_ref_count()).c_str()));
            else
                delete data_type_node->takeChild(data_type_node->indexOfChild(uid_node));
        }
        else
            delete data_type_node->takeChild(data_type_node->indexOfChild(uid_node));
    }
    if (data_type_node->childCount() == 0)
        delete takeTopLevelItem(indexOfTopLevelItem(data_type_node));
    else
    {
        std::string const  item_refs_name = qtgl::to_string(data_type_node->text(1));
        int const  old_num_refs = std::atoi(item_refs_name.c_str());
        data_type_node->setText(1, QString(std::to_string(old_num_refs - info.get_ref_count()).c_str()));
    }
}
Пример #10
0
void
pcl::modeler::SceneTree::dropEvent(QDropEvent * event)
{
  QList<CloudMeshItem*> selected_cloud_meshes = selectedTypeItems<CloudMeshItem>();

  std::set<RenderWindowItem*> previous_parents;
  for (QList<CloudMeshItem*>::iterator selected_cloud_meshes_it = selected_cloud_meshes.begin();
    selected_cloud_meshes_it != selected_cloud_meshes.end();
    ++ selected_cloud_meshes_it)
  {
    CloudMeshItem* cloud_mesh_item = *selected_cloud_meshes_it;
    RenderWindowItem* render_window_item = dynamic_cast<RenderWindowItem*>(cloud_mesh_item->parent());
    if (render_window_item != NULL)
      previous_parents.insert(render_window_item);
  }

  QTreeWidget::dropEvent(event);

  std::vector<CloudMeshItem*> cloud_mesh_items;
  for (QList<CloudMeshItem*>::iterator selected_cloud_meshes_it = selected_cloud_meshes.begin();
    selected_cloud_meshes_it != selected_cloud_meshes.end();
    ++ selected_cloud_meshes_it)
  {
    CloudMeshItem* cloud_mesh_item = *selected_cloud_meshes_it;
    if (dynamic_cast<RenderWindowItem*>(cloud_mesh_item->parent()) == NULL)
      cloud_mesh_items.push_back(cloud_mesh_item);
    else
      cloud_mesh_item->updateRenderWindow();
  }

  // put the cloud mesh items in a new render window
  if (!cloud_mesh_items.empty())
  {
    for (size_t i = 0, i_end = cloud_mesh_items.size(); i < i_end; ++ i)
      takeTopLevelItem(indexFromItem(cloud_mesh_items[i]).row());
    RenderWindowItem* render_window_item = MainWindow::getInstance().createRenderWindow();
    for (size_t i = 0, i_end = cloud_mesh_items.size(); i < i_end; ++ i)
      render_window_item->addChild(cloud_mesh_items[i]);
    render_window_item->setExpanded(true);
  }

  for (std::set<RenderWindowItem*>::iterator previous_parents_it = previous_parents.begin();
    previous_parents_it != previous_parents.end();
    ++ previous_parents_it)
  {
    (*previous_parents_it)->getRenderWindow()->updateAxes();
    (*previous_parents_it)->getRenderWindow()->render();
  }

  return;
}
Пример #11
0
/**
 * removes and deletes an item from MTreeWidget
 * shouldn't be used on its own, only called from destroy() by a core object
 * \param item from a list which we want to remove
 * \return object linked to an item being removed
 */
void MTreeWidget::remove(MTreeWidgetItem* item)
{
    // no item given to remove, we take selected
    // atm this shouldn't happen, because we always call this with a param
    if (!item)
	item = selected();

    // no item selected
    if (!item)
	return;

    // remove from widget
    takeTopLevelItem(indexOfTopLevelItem(item));
}
Пример #12
0
void ExitsTreeWidget::keyPressEvent ( QKeyEvent * event )
{
    if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter)
    {
        closePersistentEditor( currentItem(), 1 );
        closePersistentEditor( currentItem(), 2 );
    }
    if (event->key() == Qt::Key_Delete && hasFocus() )
    {
        QList<QTreeWidgetItem *> selection = selectedItems();
        foreach(QTreeWidgetItem *item, selection)
        {
            takeTopLevelItem(indexOfTopLevelItem(item));
        }
Пример #13
0
void TrackerList::moveSelectionUp() {
  BitTorrent::TorrentHandle *const torrent = properties->getCurrentTorrent();
  if (!torrent) {
    clear();
    return;
  }
  QList<QTreeWidgetItem *> selected_items = getSelectedTrackerItems();
  if (selected_items.isEmpty()) return;
  bool change = false;
  foreach (QTreeWidgetItem *item, selected_items) {
    int index = indexOfTopLevelItem(item);
    if (index > NB_STICKY_ITEM) {
      insertTopLevelItem(index-1, takeTopLevelItem(index));
      change = true;
    }
  }
Пример #14
0
DGameTree::~DGameTree()
{
	int count = topLevelItemCount();
	for (int a = 0; a < count; a++)
		takeTopLevelItem(0);

	for (QTreeWidgetItem* i : m_path_nodes.values())
	{
		count = i->childCount();
		for (int a = 0; a < count; a++)
			i->takeChild(0);
	}

	for (QTreeWidgetItem* i : m_path_nodes.values())
		delete i;
	for (QTreeWidgetItem* i : m_items.keys())
		delete i;
}
Пример #15
0
void
pcl::modeler::SceneTree::dropEvent(QDropEvent * event)
{
  QList<CloudMeshItem*> selected_cloud_meshes = selectedTypeItems<CloudMeshItem>();

  std::set<RenderWindowItem*> previous_parents;
  for (const auto &cloud_mesh_item : selected_cloud_meshes)
  {
    RenderWindowItem* render_window_item = dynamic_cast<RenderWindowItem*>(cloud_mesh_item->parent());
    if (render_window_item != nullptr)
      previous_parents.insert(render_window_item);
  }

  QTreeWidget::dropEvent(event);

  std::vector<CloudMeshItem*> cloud_mesh_items;
  for (const auto &cloud_mesh_item : selected_cloud_meshes)
  {
    if (dynamic_cast<RenderWindowItem*>(cloud_mesh_item->parent()) == nullptr)
      cloud_mesh_items.push_back(cloud_mesh_item);
    else
      cloud_mesh_item->updateRenderWindow();
  }

  // put the cloud mesh items in a new render window
  if (!cloud_mesh_items.empty())
  {
    for (const auto &cloud_mesh_item : cloud_mesh_items)
      takeTopLevelItem(indexFromItem(cloud_mesh_item).row());
    RenderWindowItem* render_window_item = MainWindow::getInstance().createRenderWindow();
    for (const auto &cloud_mesh_item : cloud_mesh_items)
      render_window_item->addChild(cloud_mesh_item);
    render_window_item->setExpanded(true);
  }

  for (const auto &previous_parent : previous_parents)
  {
    previous_parent->getRenderWindow()->updateAxes();
    previous_parent->getRenderWindow()->render();
  }

  return;
}
Пример #16
0
// delete an item
void UserMenuTree::itemDelete(QTreeWidgetItem *current)
{
	int children,index;
	QTreeWidgetItem *item, *selectitem;
	QTreeWidgetItem *parent = current->parent();
	if(!parent) {
		children = topLevelItemCount();
		index = indexOfTopLevelItem(current);
		if ( index < children-1 ) {
			selectitem = topLevelItem(index+1);
		}
		else if ( index > 0  ) {
			selectitem = topLevelItem(index-1);
		}
		else {
			selectitem = NULL;
		}

		item = takeTopLevelItem(index);
	}
	else {
		children = parent->childCount();
		index = parent->indexOfChild(current);
		if ( index < children-1 ) {
			selectitem = parent->child(index+1);
		}
		else if ( index > 0  ) {
			selectitem = parent->child(index-1);
		}
		else
			selectitem = parent; {
		}

		item = parent->takeChild(index);
	}

	delete item;

	if(selectitem) {
		setCurrentItem(selectitem);
	}
}
Пример #17
0
void TabTree::insertTab(const QString &path, int index, bool selected)
{
    QStringList pathComponents = path.split('/');
    QTreeWidgetItem *item = findLastTreeItem(*this, &pathComponents);

    foreach (const QString &text, pathComponents) {
        QTreeWidgetItem *parent = item;

        if (parent != NULL) {
            int to = 0;
            for ( ; to < parent->childCount(); ++to ) {
                 const int index2 = getTabIndex(parent->child(to));
                 if (index2 != -1 && index < index2)
                     break;
            }
            int from = parent->childCount();
            item = new QTreeWidgetItem(parent);
            if (from != to)
                parent->insertChild(to, parent->takeChild(from));
        } else {
            int to = 0;
            for ( ; to < topLevelItemCount(); ++to ) {
                 const int index2 = getTabIndex(topLevelItem(to));
                 if (index2 != -1 && index < index2)
                     break;
            }
            int from = topLevelItemCount();
            item = new QTreeWidgetItem(this);
            if (from != to)
                insertTopLevelItem(to, takeTopLevelItem(from));
        }

        item->setExpanded(true);
        item->setData(0, DataIndex, -1);
        item->setData(0, DataText, text);

        labelItem(item);
    }
Пример #18
0
void lmcUserTreeWidget::dropEvent(QDropEvent* event) {
	QTreeWidget::dropEvent(event);
		
	if(dragUser) {
		if(!dragItem->parent()) {
		//	user item dragged to group level. revert
			for(int index = 0; index < topLevelItemCount(); index++) {
				QTreeWidgetItem* parentItem = topLevelItem(index);
				if(parentItem->data(0, IdRole).toString().compare(parentId) == 0) {
					takeTopLevelItem(indexOfTopLevelItem(dragItem));
					parentItem->addChild(dragItem);
					return;
				}
			}
		}
	}
	else if(dragGroup) {
		dragItem->setExpanded(expanded);
	}

	if(dragItem)
		emit itemDragDropped(dragItem);
}
Пример #19
0
void QKeyList::delItem(int idx)
{
    QTreeWidgetItem* item = takeTopLevelItem(idx);
    delete item;
    fKeys.erase(fKeys.begin() + idx);
}
Пример #20
0
void EffectsListWidget::initList(QMenu *effectsMenu, KActionCategory *effectActions, QString categoryFile, bool transitionMode)
{
    QString current;
    QString currentFolder;
    bool found = false;
    effectsMenu->clear();

    if (currentItem()) {
        current = currentItem()->text(0);
        if (currentItem()->parent())
            currentFolder = currentItem()->parent()->text(0);
        else if (currentItem()->data(0, TypeRole) == EffectsList::EFFECT_FOLDER)
            currentFolder = currentItem()->text(0);
    }

    QTreeWidgetItem *misc = NULL;
    QTreeWidgetItem *audio = NULL;
    QTreeWidgetItem *custom = NULL;
    QList <QTreeWidgetItem *> folders;

    if (!categoryFile.isEmpty()) {
        QDomDocument doc;
        QFile file(categoryFile);
        doc.setContent(&file, false);
        file.close();
        QStringList folderNames;
        QDomNodeList groups = doc.documentElement().elementsByTagName(QStringLiteral("group"));
        for (int i = 0; i < groups.count(); ++i) {
            folderNames << i18n(groups.at(i).firstChild().firstChild().nodeValue().toUtf8().constData());
        }
        for (int i = 0; i < topLevelItemCount(); ++i) {
            topLevelItem(i)->takeChildren();
            QString currentName = topLevelItem(i)->text(0);
            if (currentName != i18n("Misc") && currentName != i18n("Audio") && currentName != i18nc("Folder Name", "Custom") && !folderNames.contains(currentName)) {
                takeTopLevelItem(i);
                --i;
            }
        }

        for (int i = 0; i < groups.count(); ++i) {
            QTreeWidgetItem *item = findFolder(folderNames.at(i));
            if (item) {
                item->setData(0, IdRole, groups.at(i).toElement().attribute(QStringLiteral("list")));
            } else {
                item = new QTreeWidgetItem((QTreeWidget*)0, QStringList(folderNames.at(i)));
                item->setData(0, TypeRole, QString::number((int) EffectsList::EFFECT_FOLDER));
                item->setData(0, IdRole, groups.at(i).toElement().attribute(QStringLiteral("list")));
                item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
                item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
                insertTopLevelItem(0, item);
            }
            folders.append(item);
        }

        misc = findFolder(i18n("Misc"));
        if (misc == NULL) {
            misc = new QTreeWidgetItem((QTreeWidget*)0, QStringList(i18n("Misc")));
            misc->setData(0, TypeRole, QString::number((int) EffectsList::EFFECT_FOLDER));
            misc->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
            insertTopLevelItem(0, misc);
        }

        audio = findFolder(i18n("Audio"));
        if (audio == NULL) {
            audio = new QTreeWidgetItem((QTreeWidget*)0, QStringList(i18n("Audio")));
            audio->setData(0, TypeRole, QString::number((int) EffectsList::EFFECT_FOLDER));
            audio->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
            insertTopLevelItem(0, audio);
        }

        custom = findFolder(i18nc("Folder Name", "Custom"));
        if (custom == NULL) {
            custom = new QTreeWidgetItem((QTreeWidget*)0, QStringList(i18nc("Folder Name", "Custom")));
            custom->setData(0, TypeRole, QString::number((int) EffectsList::EFFECT_FOLDER));
            custom->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
            insertTopLevelItem(0, custom);
        }
    }

    //insertTopLevelItems(0, folders);
    if (transitionMode) {
        loadEffects(&MainWindow::transitions, misc, &folders, EffectsList::TRANSITION_TYPE, current, &found);
    }
    else {
        loadEffects(&MainWindow::videoEffects, misc, &folders, EffectsList::EFFECT_VIDEO, current, &found);
        loadEffects(&MainWindow::audioEffects, audio, &folders, EffectsList::EFFECT_AUDIO, current, &found);
        loadEffects(&MainWindow::customEffects, custom, static_cast<QList<QTreeWidgetItem *> *>(0), EffectsList::EFFECT_CUSTOM, current, &found);
        if (!found && !currentFolder.isEmpty()) {
            // previously selected effect was removed, focus on its parent folder
            for (int i = 0; i < topLevelItemCount(); ++i) {
                if (topLevelItem(i)->text(0) == currentFolder) {
                    setCurrentItem(topLevelItem(i));
                    break;
                }
            }
        }
    }
    setSortingEnabled(true);
    sortByColumn(0, Qt::AscendingOrder);

    // populate effects menu
    QMenu *sub1 = NULL;
    QMenu *sub2 = NULL;
    QMenu *sub3 = NULL;
    QMenu *sub4 = NULL;
    for (int i = 0; i < topLevelItemCount(); ++i) {
        if (topLevelItem(i)->data(0, TypeRole) == EffectsList::TRANSITION_TYPE) {
            QTreeWidgetItem *item = topLevelItem(i);
            QAction *a = new QAction(item->icon(0), item->text(0), effectsMenu);
            QStringList data = item->data(0, IdRole).toStringList();
            QString id = data.at(1);
            if (id.isEmpty()) id = data.at(0);
            a->setData(data);
            a->setIconVisibleInMenu(false);
            effectsMenu->addAction(a);
            effectActions->addAction("transition_" + id, a);
            continue;
        }
        if (!topLevelItem(i)->childCount())
            continue;
        QMenu *sub = new QMenu(topLevelItem(i)->text(0), effectsMenu);
        effectsMenu->addMenu(sub);
        int effectsInCategory = topLevelItem(i)->childCount();
        bool hasSubCategories = false;
        if (effectsInCategory > 60) {
            // create subcategories if there are too many effects
            hasSubCategories = true;
            sub1 = new QMenu(i18nc("menu name for effects names between these 2 letters", "0 - F"), sub);
            sub->addMenu(sub1);
            sub2 = new QMenu(i18nc("menu name for effects names between these 2 letters", "G - L"), sub);
            sub->addMenu(sub2);
            sub3 = new QMenu(i18nc("menu name for effects names between these 2 letters", "M - R"), sub);
            sub->addMenu(sub3);
            sub4 = new QMenu(i18nc("menu name for effects names between these 2 letters", "S - Z"), sub);
            sub->addMenu(sub4);
        }
        for (int j = 0; j < effectsInCategory; ++j) {
            QTreeWidgetItem *item = topLevelItem(i)->child(j);
            QAction *a = new QAction(item->icon(0), item->text(0), sub);
            QStringList data = item->data(0, IdRole).toStringList();
            QString id = data.at(1);
            if (id.isEmpty()) id = data.at(0);
            a->setData(data);
            a->setIconVisibleInMenu(false);
            if (hasSubCategories) {
                // put action in sub category
                QRegExp rx("^[s-z].+");
                if (rx.exactMatch(item->text(0).toLower())) {
                    sub4->addAction(a);
                } else {
                    rx.setPattern(QStringLiteral("^[m-r].+"));
                    if (rx.exactMatch(item->text(0).toLower())) {
                        sub3->addAction(a);
                    }
                    else {
                        rx.setPattern(QStringLiteral("^[g-l].+"));
                        if (rx.exactMatch(item->text(0).toLower())) {
                            sub2->addAction(a);
                        }
                        else sub1->addAction(a);
                    }
                }
            }
            else sub->addAction(a);
            effectActions->addAction("video_effect_" + id, a);
        }
    }
}
void KeepassGroupView::dropEvent( QDropEvent * event ){
	if(LastHoverItem){
		LastHoverItem->setBackgroundColor(0,QApplication::palette().color(QPalette::Base));
		LastHoverItem->setForeground(0,QBrush(QApplication::palette().color(QPalette::Text)));
	}
	
	if(DragType==EntryDrag){
		entryDropEvent(event);
		return;
	}

	if(InsLinePos!=-1){
		int RemoveLine=InsLinePos;
		InsLinePos=-1;
		viewport()->update(QRegion(0,RemoveLine-2,viewport()->width(),4));
	}
	GroupViewItem* Item=(GroupViewItem*)itemAt(event->pos());
	
	if(!Item){
		qDebug("Append at the end");
		db->moveGroup(DragItem->GroupHandle,NULL,-1);
		if(DragItem->parent()){
			DragItem->parent()->takeChild(DragItem->parent()->indexOfChild(DragItem));
		}
		else{
			takeTopLevelItem(indexOfTopLevelItem(DragItem));
		}
		insertTopLevelItem(topLevelItemCount(),DragItem);
		if(topLevelItemCount()>1){
			if(topLevelItem(topLevelItemCount()-2)==SearchResultItem){
				takeTopLevelItem(topLevelItemCount()-2);
				insertTopLevelItem(topLevelItemCount(),SearchResultItem);	
			}			
		}
		emit fileModified();
	}
	else{
		if (DragItem->GroupHandle==Item->GroupHandle)
			return;
		
		QRect ItemRect=visualItemRect(Item);
		if(event->pos().y()>ItemRect.y()+2 && event->pos().y()<ItemRect.y()+ItemRect.height()-2){
			qDebug("Append as child of '%s'",((char*)Item->text(0).toUtf8().data()));
			db->moveGroup(DragItem->GroupHandle,Item->GroupHandle,-1);
			if(DragItem->parent()){
				DragItem->parent()->takeChild(DragItem->parent()->indexOfChild(DragItem));
			}
			else{
				takeTopLevelItem(indexOfTopLevelItem(DragItem));
			}
			Item->insertChild(Item->childCount(),DragItem);
			emit fileModified();
		}
		else{
			if(event->pos().y()>ItemRect.y()+2){
				qDebug("Insert behind sibling '%s'",((char*)Item->text(0).toUtf8().data()));
				if(DragItem->parent()){
					DragItem->parent()->takeChild(DragItem->parent()->indexOfChild(DragItem));
				}
				else{
					takeTopLevelItem(indexOfTopLevelItem(DragItem));
				}				
				if(Item->parent()){
					int index=Item->parent()->indexOfChild(Item)+1;
					db->moveGroup(DragItem->GroupHandle,((GroupViewItem*)Item->parent())->GroupHandle,index);
					Item->parent()->insertChild(index,DragItem);
				}
				else{
					int index=indexOfTopLevelItem(Item)+1;
					db->moveGroup(DragItem->GroupHandle,NULL,index);
					insertTopLevelItem(index,DragItem);	
				}
				emit fileModified();
			}
			else{	
				qDebug("Insert before sibling '%s'",((char*)Item->text(0).toUtf8().data()));
				if(DragItem->parent()){
					DragItem->parent()->takeChild(DragItem->parent()->indexOfChild(DragItem));
				}
				else{
					takeTopLevelItem(indexOfTopLevelItem(DragItem));
				}				
				if(Item->parent()){
					int index=Item->parent()->indexOfChild(Item);
					db->moveGroup(DragItem->GroupHandle,((GroupViewItem*)Item->parent())->GroupHandle,index);
					Item->parent()->insertChild(index,DragItem);
				}
				else{
					int index=indexOfTopLevelItem(Item);
					db->moveGroup(DragItem->GroupHandle,NULL,index);
					insertTopLevelItem(index,DragItem);	
				}
				emit fileModified();	
			}
		}
		
		
	}
	
}
void KeepassGroupView::OnHideSearchResults(){
	takeTopLevelItem(topLevelItemCount()-1);
}
Пример #23
0
void TupItemManager::mousePressEvent(QMouseEvent *event)
{
    parentNode = "";

    QTreeWidgetItem *item = itemAt(event->pos());

    if (item) {
        setCurrentItem(item);
        emit itemSelected(item);

        if (event->buttons() == Qt::RightButton) {
            QMenu *menu = new QMenu(tr("Options"));

            if (isFolder(item)) {
                QAction *rename = new QAction(tr("Rename"), this);
                connect(rename, SIGNAL(triggered()), this, SLOT(renameItem()));

                QAction *remove = new QAction(tr("Delete"), this);
                connect(remove, SIGNAL(triggered()), this, SIGNAL(itemRemoved()));

                menu->addAction(rename);
                menu->addAction(remove);
            } else {
                QString extension = item->text(2);
                bool isSound = false;
                bool isNative = false;

                if ((extension.compare("OGG") == 0) || (extension.compare("MP3") == 0) || (extension.compare("WAV") == 0))
                    isSound = true; 
                if (extension.compare("OBJ") == 0)
                    isNative = true; 

                if (extension.compare("SVG") == 0) {
                    QAction *edit = new QAction(tr("Edit with Inkscape"), this);
                    connect(edit, SIGNAL(triggered()), this, SLOT(callInkscapeToEdit()));
                    #ifdef Q_OS_UNIX
                        if (!QFile::exists("/usr/bin/inkscape"))
                            edit->setDisabled(true);
                    #else
                        edit->setDisabled(true);
                    #endif
                    menu->addAction(edit);
                } else if ((extension.compare("OBJ") != 0) && !isSound) {
                           QAction *gimpEdit = new QAction(tr("Edit with Gimp"), this);
                           connect(gimpEdit, SIGNAL(triggered()), this, SLOT(callGimpToEdit()));
                           #ifdef Q_OS_UNIX
                               if (!QFile::exists("/usr/bin/gimp"))
                                   gimpEdit->setDisabled(true);
                           #else
                               gimpEdit->setDisabled(true);
                           #endif
                           menu->addAction(gimpEdit);

                           QAction *kritaEdit = new QAction(tr("Edit with Krita"), this);
                           connect(kritaEdit, SIGNAL(triggered()), this, SLOT(callKritaToEdit()));
                           #ifdef Q_OS_UNIX
                               if (!QFile::exists("/usr/bin/krita"))
                                   kritaEdit->setDisabled(true);
                           #else
                                   kritaEdit->setDisabled(true);
                           #endif
                           menu->addAction(kritaEdit);

                           QAction *myPaintEdit = new QAction(tr("Edit with MyPaint"), this);
                           connect(myPaintEdit, SIGNAL(triggered()), this, SLOT(callMyPaintToEdit()));
                           #ifdef Q_OS_UNIX
                               if (!QFile::exists("/usr/bin/mypaint"))
                                   myPaintEdit->setDisabled(true);
                           #else
                               myPaintEdit->setDisabled(true);
                           #endif
                           menu->addAction(myPaintEdit);
                }

                if (!isSound && !isNative) {
                    QAction *clone = new QAction(tr("Clone"), this);
                    connect(clone, SIGNAL(triggered()), this, SLOT(cloneItem()));
                    menu->addAction(clone);
                }

                QAction *exportObject = new QAction(tr("Export"), this);
                connect(exportObject, SIGNAL(triggered()), this, SLOT(exportItem()));

                QAction *rename = new QAction(tr("Rename"), this);
                connect(rename, SIGNAL(triggered()), this, SLOT(renameItem()));

                QAction *remove = new QAction(tr("Delete"), this);
                connect(remove, SIGNAL(triggered()), this, SIGNAL(itemRemoved()));

                menu->addAction(exportObject);
                menu->addAction(rename);
                menu->addAction(remove);
                menu->addSeparator();

                #ifdef Q_OS_UNIX
                    if (!isSound) {
                        if (QFile::exists("/usr/bin/gimp") || QFile::exists("/usr/bin/krita") || QFile::exists("/usr/bin/mypaint")) {
                            QAction *raster = new QAction(tr("Create new raster item"), this);
                            connect(raster, SIGNAL(triggered()), this, SLOT(createNewRaster()));
                            menu->addAction(raster);
                        }

                        if (QFile::exists("/usr/bin/inkscape")) {
                            QAction *svg = new QAction(tr("Create new svg item"), this);
                            connect(svg, SIGNAL(triggered()), this, SLOT(createNewSVG()));
                            menu->addAction(svg);
                        }
                    }
                #endif
            }

            menu->exec(event->globalPos());
        } else if (event->buttons() == Qt::LeftButton) {
                   // SQA: This code doesn't work well at all. Reengineering is urgently required right here!
                   // If the node has a parent, get the parent's name
                   QTreeWidgetItem *top = item->parent(); 
                   if (top)
                       parentNode = top->text(1);

                   // For directories, get the children
                   nodeChildren.clear();
                   if (item->text(2).length()==0 && item->childCount() > 0) {
                       for (int i=0;i<item->childCount();i++) {
                            QTreeWidgetItem *node = item->child(i);
                            nodeChildren << node;
                       }
                   } 

                   QPixmap pixmap = item->icon(0).pixmap(15, 15);

                   QByteArray itemData;
                   QDataStream dataStream(&itemData, QIODevice::WriteOnly);
                   dataStream << pixmap << item->text(1) << item->text(2) << item->text(3);

                   QMimeData *mimeData = new QMimeData;
                   mimeData->setData("application/x-dnditemdata", itemData);

                   QDrag *drag = new QDrag(this);
                   drag->setMimeData(mimeData);
                   drag->setPixmap(pixmap);

                   if (drag->start(Qt::MoveAction) == Qt::MoveAction)
                       delete takeTopLevelItem(indexOfTopLevelItem(item));
        }
    } else {
        if (event->buttons() == Qt::RightButton) {
            QMenu *menu = new QMenu(tr("Options"));

            #ifdef Q_OS_UNIX
            if (QFile::exists("/usr/bin/gimp") || QFile::exists("/usr/bin/krita") || QFile::exists("/usr/bin/mypaint")) {
                QAction *raster = new QAction(tr("Create new raster item"), this);
                connect(raster, SIGNAL(triggered()), this, SLOT(createNewRaster()));
                menu->addAction(raster);
            }
            if (QFile::exists("/usr/bin/inkscape")) {
                QAction *svg = new QAction(tr("Create new svg item"), this);
                connect(svg, SIGNAL(triggered()), this, SLOT(createNewSVG()));
                menu->addAction(svg);
            }
            #endif

            menu->exec(event->globalPos());
        }
    }
}
Пример #24
0
void QPythonParamList::delParam(int idx)
{
    QTreeWidgetItem* item = takeTopLevelItem(idx);
    delete item;
    fParams.erase(fParams.begin() + idx);
}