Ejemplo n.º 1
0
// private
void FilesWidget::applyFilter()
{
    QStandardItem *root = m_model.invisibleRootItem();
    int parentRowCount = root->rowCount();

    for (int parentRow = 0; parentRow < parentRowCount; ++parentRow) {
        QStandardItem *parent = root->child(parentRow);
        int childRowCount = parent->rowCount();
        bool hideParent = true;

        for (int childRow = 0; childRow < childRowCount; ++childRow) {
            QStandardItem *child = parent->child(childRow);
            bool hideChild = !filterAcceptsChild(child->index());

            if (!hideChild) {
                hideParent = false;
            }

            m_treeFiles->setRowHidden(childRow, parent->index(), hideChild);
        }

        updateParentItemMarkers(parent);

        m_treeFiles->setRowHidden(parentRow, root->index(), hideParent);
    }
}
Ejemplo n.º 2
0
void
MSCalibrationForm::OnMSReferencesUpdated( const QModelIndex& index )
{
    QStandardItemModel& model = *pModel_;
    QStandardItem * item = model.itemFromIndex( index );
    const adcontrols::MSReferences& refs = pMethod_->references();

    if ( item->rowCount() )
        item->removeRows( 0, item->rowCount() );

    size_t row(0);
    for ( adcontrols::MSReferences::vector_type::const_iterator it = refs.begin(); it != refs.end(); ++it, ++row ) {
        int col = 0;
        std::wstring formula = it->formula();
        if ( ! it->adduct_or_loss().empty() )
            formula += std::wstring( it->polarityPositive() ? L" + " : L" - ") + it->adduct_or_loss();

        StandardItemHelper::appendRow( item, formula, true );
        col++;
        if ( item->columnCount() < col + 1 )
            model.insertColumn( item->columnCount(), item->index() );
        model.setData( model.index( row, col, index ), it->exactMass() );

        col++;
        if ( item->columnCount() < col + 1 )
            model.insertColumn( item->columnCount(), item->index() );
        model.setData( model.index( row, col, index ), it->enable() );
    }
}
Ejemplo n.º 3
0
void EditTOC::MoveDown()
{
    QModelIndex index = CheckSelection(0);
    if (!index.isValid()) {
        return;
    }
    QStandardItem *item = m_TableOfContents->itemFromIndex(index);

    QStandardItem *parent_item = item->parent();
    if (!parent_item) {
        parent_item = m_TableOfContents->invisibleRootItem();
    }

    int item_row = item->row();

    // Can't move down if this row is already the last one of its parent
    if (item_row == parent_item->rowCount() - 1) {
        return;
    }

    QList<QStandardItem *> row_items = parent_item->takeRow(item_row);
    parent_item->insertRow(item_row + 1, row_items);

    // Reselect the item
    ui.TOCTree->selectionModel()->clear();
    ui.TOCTree->setCurrentIndex(item->index());
    ui.TOCTree->selectionModel()->select(item->index(), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
    ExpandChildren(item);
}
Ejemplo n.º 4
0
// private slot
void FilesWidget::setCurrentChild(Document *document)
{
    // Set current child and parent back to normal
    if (m_currentChild != NULL) {
        markItemAsCurrent(m_currentChild, false);

        QStandardItem *parent = m_currentChild->parent();

        m_currentChild = NULL;

        updateParentItemMarkers(parent);
    }

    // Mark new current child as current
    if (document != NULL) {
        QStandardItem *child = m_children.value(document, NULL);

        Q_ASSERT(child != NULL);

        QStandardItem *parent = child->parent();

        Q_ASSERT(parent != NULL);

        m_treeFiles->expand(parent->index());
        m_treeFiles->scrollTo(child->index());
        m_treeFiles->selectionModel()->select(child->index(), QItemSelectionModel::ClearAndSelect);

        m_currentChild = child;

        markItemAsCurrent(m_currentChild, true);
        updateParentItemMarkers(parent);
    }
}
Ejemplo n.º 5
0
void EditTOC::MoveRight()
{
    QModelIndex index = CheckSelection(0);
    if (!index.isValid()) {
        return;
    }

    QStandardItem *item = m_TableOfContents->itemFromIndex(index);
    int item_row = item->row();

    // Can't indent if row above is already parent
    if (item_row == 0) {
        return;
    }

    QStandardItem *parent_item = item->parent();
    if (!parent_item) {
        parent_item = m_TableOfContents->invisibleRootItem();
    }

    // Make the item above the parent of this item
    QList<QStandardItem *> row_items = parent_item->takeRow(item_row);
    QStandardItem *new_parent = parent_item->child(item_row - 1, 0);
    new_parent->insertRow(new_parent->rowCount(), row_items);
    QStandardItem *new_item = new_parent->child(new_parent->rowCount() - 1, 0);

    // Reselect the item
    ui.TOCTree->selectionModel()->clear();
    ui.TOCTree->setCurrentIndex(item->index());
    ui.TOCTree->selectionModel()->select(item->index(), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
    ExpandChildren(new_item);
}
Ejemplo n.º 6
0
	void ItemListWidget::on_addPushButton_clicked()
	{
		QStandardItem *newItem = new QStandardItem();
		mModel->appendRow(newItem);

		ui->itemsListView->edit(newItem->index());
		ui->itemsListView->setCurrentIndex(newItem->index());
	}
Ejemplo n.º 7
0
void SpikeNoteWidget::addSpike() {
  QStandardItem* i = new QStandardItem("Edit Text");
  SpikePtr s(new Spike());
  stm_->appendRow(i, s);
  ui_.spikestreeview->setCurrentIndex(i->index());
  ui_.spikestreeview->edit(i->index());

  selectIndex(i->index());
}
Ejemplo n.º 8
0
// private slot
void FilesWidget::addDocument(Document *document)
{
    Q_ASSERT(document != NULL);
    Q_ASSERT(document != DocumentManager::current());

    const Location &location = document->location();
    const QString &filePath = location.filePath("unnamed");
    const QString &directoryPath = location.directoryPath("unnamed");
    const QString &fileName = location.fileName("unnamed");

    // Find or create parent item
    const QModelIndexList &parents = m_model.match(m_model.index(0, 0, QModelIndex()), DirectoryPathRole,
                                                   directoryPath, 1, Qt::MatchExactly);
    QStandardItem *parent;

    if (parents.isEmpty()) {
        parent = new QStandardItem(QIcon(":/icons/16x16/folder.png"), directoryPath);

        parent->setToolTip(directoryPath);
        parent->setData(directoryPath, DirectoryPathRole);
        parent->setData(location.isEmpty() ? "" : directoryPath.toLower(), LowerCaseNameRole);

        m_model.appendRow(parent);
        m_model.sort(0);
    } else {
        parent = m_model.itemFromIndex(parents.first());
    }

    // Create child item
    QStandardItem *child = new QStandardItem(QIcon(":/icons/16x16/file.png"), fileName);

    child->setToolTip(filePath);
    child->setData(qVariantFromValue((void *)document), DocumentPointerRole);
    child->setData(fileName, FileNameRole);
    child->setData(location.isEmpty() ? "" : fileName.toLower(), LowerCaseNameRole);

    m_children.insert(document, child);

    parent->appendRow(child);
    parent->sortChildren(0);

    connect(document, &Document::locationChanged, this, &FilesWidget::updateLocationOfSender);
    connect(document, &Document::modificationChanged, this, &FilesWidget::updateModificationMarkerOfSender);

    // Apply current filter
    if (!filterAcceptsChild(child->index())) {
        m_treeFiles->setRowHidden(child->row(), parent->index(), true);

        if (parent->rowCount() == 1) {
            m_treeFiles->setRowHidden(parent->row(), m_model.invisibleRootItem()->index(), true);
        }
    }

    // Show modification marker, if necessary
    updateModificationMarker(document);
    updateParentItemMarkers(parent);
}
Ejemplo n.º 9
0
void
mail_listview::select_message(mail_id_t id, bool ensure_visible)
{
  QStandardItem* item = model()->item_from_id(id);
  if (!item)
    return;
  setCurrentIndex(item->index());
  if (ensure_visible)
    scrollTo(item->index());
}
void CookiesContentsWidget::removeCookies()
{
	const QModelIndexList indexes = m_ui->cookiesView->selectionModel()->selectedIndexes();

	if (indexes.isEmpty())
	{
		return;
	}

	QNetworkCookieJar *cookieJar = NetworkManagerFactory::getCookieJar();
	QList<QNetworkCookie> cookies;

	for (int i = 0; i < indexes.count(); ++i)
	{
		if (!indexes.at(i).isValid())
		{
			continue;
		}

		if (indexes.at(i).data(Qt::UserRole).toString().isEmpty())
		{
			QStandardItem *domainItem = m_model->itemFromIndex(indexes.at(i));

			if (!domainItem)
			{
				continue;
			}

			for (int j = 0; j < domainItem->rowCount(); ++j)
			{
				QStandardItem *cookieItem = domainItem->child(j, 0);

				if (cookieItem)
				{
					cookies.append(getCookie((cookieItem->index())));
				}
			}
		}
		else
		{
			QStandardItem *cookieItem = m_model->itemFromIndex(indexes.at(i));

			if (cookieItem)
			{
				cookies.append(getCookie(cookieItem->index()));
			}
		}
	}

	for (int i = 0; i < cookies.count(); ++i)
	{
		cookieJar->deleteCookie(cookies.at(i));
	}
}
Ejemplo n.º 11
0
void CurtainWidget::addWidget(QWidget* widget)
{
    int lastRow = mModel->rowCount()-1;
    if (lastRow < 0)
        return;

    QStandardItem *item = mModel->item(lastRow, 0);
    QStandardItem *child = new QStandardItem;
    item->appendRow(child);
    this->setIndexWidget(child->index(), widget);
    this->expand(child->index().parent());
}
Ejemplo n.º 12
0
/*!
 * \param name Name of network
 * \param server Default server details
 *
 * Adds a network to the model.
 */
void ServerModel::addNetwork(QString name, QString server)
{
    QStandardItem *root = invisibleRootItem();

    QStandardItem *pname = new QStandardItem(QIcon(":/options/gfx/network.png"), name);
    QStandardItem *phost = new QStandardItem(server);
    QList<QStandardItem*> list;
    list << pname << phost;

    root->appendRow(list);
    hostmap.insert(server, pname->index());
    netmap.insert(name, pname->index());
}
Ejemplo n.º 13
0
void
MSPeakSummary::setResult( int row, const std::vector<double>& coeffs, double sd )
{
	QStandardItemModel& model = *model_;
    QStandardItem * parent = model.itemFromIndex( model.index( r_result, 0 ) );

    if ( row >= parent->rowCount() )
        parent->setRowCount( row + 1 );

    model.setData( model.index( row, c_mspeaksummary_mode, parent->index() ), row );
    model.setData( model.index( row, c_mspeaksummary_coeffs + 0, parent->index() ), coeffs[0] );
    model.setData( model.index( row, c_mspeaksummary_coeffs + 1, parent->index() ), coeffs[1] );
    model.setData( model.index( row, c_mspeaksummary_sd, parent->index() ), sd );
    // model.setData( model.index( row, c_mspeaksummary_t0, parent->index() ), t0 );
}
Ejemplo n.º 14
0
bool ProgramsModel::AddGroup(QModelIndex &index, int row)
{
    int groupId = myHost->programsModel->GetNextGroupId();

    QString name("New grp");

    //create the group
    QStandardItem *groupItem = new QStandardItem( name );
    groupItem->setData(GroupNode,NodeType);
    groupItem->setData(groupId,ProgramId);
#ifndef QT_NO_DEBUG
    groupItem->setData(groupId,Qt::ToolTipRole);
#endif
    groupItem->setDragEnabled(true);
    groupItem->setDropEnabled(false);
    groupItem->setEditable(true);

    if(row==-1)
        row=rowCount();
    insertRow( row, groupItem );

    index = groupItem->index();

    return true;
}
Ejemplo n.º 15
0
bool ProgramsModel::AddProgram(int groupNum, QModelIndex &index, int row)
{
    QStandardItem *groupItem = item(groupNum);

    //if the group was disabled re-enable it
    if(groupItem->rowCount()==0) {
        groupItem->setBackground(Qt::transparent);
        groupItem->setToolTip("");
    }

    int progId = myHost->programsModel->GetNextProgId();

    QString name("New prog");

    //create the program item
    QStandardItem *prgItem = new QStandardItem( name );
    prgItem->setData(ProgramNode,NodeType);
    prgItem->setData(progId,ProgramId);
#ifndef QT_NO_DEBUG
    prgItem->setData(progId,Qt::ToolTipRole);
#endif
    prgItem->setDragEnabled(true);
    prgItem->setDropEnabled(false);
    prgItem->setEditable(true);

    if(row==-1)
        row=groupItem->rowCount();
    groupItem->insertRow(row, prgItem);

    index = prgItem->index();

//    ValidateProgChange(index);

    return true;
}
Ejemplo n.º 16
0
void EPropertySheet::addProperty ( const char* categoryName, const char* propName, EPropertyVar* propVar )
{
    QStandardItem* categoryItem = getCategory ( categoryName );
    int curRow = 0;
    if ( !categoryItem )
    {
        curRow = mTreeModel->rowCount();
        mTreeModel->setRowCount ( curRow + 1 );
        categoryItem = new QStandardItem ( categoryName );
        mTreeModel->setItem ( curRow, 0, categoryItem );
        categoryItem->setEditable ( false );
        mTreeView->expand ( categoryItem->index() );
    }

    QList<QStandardItem*> lists;
    EPropertySheetTreeItem* item  = new EPropertySheetTreeItem ( propName );
    item->setBackground ( QBrush ( Qt::lightGray ) );
    item->setEditable ( false );
    lists.push_back ( item );

    item  = new EPropertySheetTreeItem();
    item->SetExtraData ( propVar );
    QVariant var;
    toQVariant ( propVar->mProp, var );
    item->setData ( var, Qt::EditRole );
	//item->setWhatsThis("WhatsThis");
	//item->setStatusTip("StatusTip");
	item->setToolTip("ToolTip");
    //item->setData ( Qt::EditRole ,var);
    lists.push_back ( item );

    categoryItem->appendRow ( lists );
}
Ejemplo n.º 17
0
void MainHost::SetupMainContainer()
{
    ObjectInfo info;
    info.nodeType = NodeType::container;
    info.objType = ObjType::Container;
    info.name = "mainContainer";
    info.forcedObjId = FixedObjId::mainContainer;

    mainContainer = objFactory->NewObject(info).staticCast< Connectables::Container >();
    if(mainContainer.isNull())
        return;

    mainContainer->SetLoadingMode(true);

    mainContainer->LoadProgram(0);
    QStandardItem *item = mainContainer->GetFullItem();
    model->invisibleRootItem()->appendRow(item);
    mainContainer->modelIndex=item->index();
    mainContainer->parked=false;
    mainContainer->listenProgramChanges=false;

    mainContainer->SetLoadingMode(false);
    mainContainer->UpdateModificationTime();
    SetSolverUpdateNeeded();
}
Ejemplo n.º 18
0
/*
  Select all messages from a set of threads (passed as a set of mail.thread_id).
  Return the number of selected messages.
*/
int
mail_listview::select_threads(const QSet<uint>& threads)
{
  if (threads.empty())
    return 0;

  int cnt=0;

  QStandardItem* item = model()->first_top_level_item();
  QItemSelectionModel* sel = this->selectionModel();

  while (item) {
    QVariant v = item->data(mail_item_model::mail_msg_role);
    mail_msg* msg = v.value<mail_msg*>();
    QModelIndex index = item->index();
    if (threads.contains(msg->thread_id())) {
      DBG_PRINTF(4, "selecting index for mail_id=%d", msg->get_id());
      sel->select(index, QItemSelectionModel::Select|QItemSelectionModel::Rows);
      cnt++;
    }
    // next item
    QModelIndex index_below  = indexBelow(index);
    if (index_below.isValid()) {
      item = model()->itemFromIndex(index_below);
    }
    else
      item=NULL;
  }
  return cnt;
}
Ejemplo n.º 19
0
void WizardModel::setWizards( QList<IWizard*> wizards )
{
	clear();
	m_installedTemplateIndex = QModelIndex();
	m_wizards = wizards;
	QStandardItem *parentItem = invisibleRootItem();


	QStandardItem *installedTemplates = new QStandardItem(tr("Installed Templates"));
	installedTemplates->setData(IWizard::FileWizard, Qt::UserRole);

	parentItem->appendRow(installedTemplates);
	m_installedTemplateIndex = installedTemplates->index();
	if (m_dummyIcon.isNull())
		m_dummyIcon = QIcon(QLatin1String(Core::Constants::ICON_NEW_FILE));

	foreach (IWizard *wizard, wizards) 
	{
		QStandardItem *kindItem;
		switch (wizard->kind()) {
		case IWizard::FileWizard:
		default:
			kindItem = installedTemplates;
			break;
		}
		addItem(kindItem, wizard);
	}
Ejemplo n.º 20
0
void BookmarkPropertiesDialog::reloadFolders()
{
	m_model->clear();

	QStandardItem *item = new QStandardItem(Utils::getIcon(QLatin1String("inode-directory")), tr("Bookmarks"));
	item->setData(0, Qt::UserRole);
	item->setToolTip(tr("Bookmarks"));

	m_model->invisibleRootItem()->appendRow(item);

	m_index = item->index();

	populateFolder(BookmarksManager::getFolder(0), item);

	QTreeView *view = qobject_cast<QTreeView*>(m_ui->folderComboBox->view());

	if (view)
	{
		view->setCurrentIndex(m_index);
		view->expandAll();

		m_ui->folderComboBox->setRootModelIndex(m_index.parent());
		m_ui->folderComboBox->setModelColumn(0);
		m_ui->folderComboBox->setCurrentIndex(m_index.row());
		m_ui->folderComboBox->setRootModelIndex(QModelIndex());
	}
}
Ejemplo n.º 21
0
QModelIndex CDialogIrcSettings::addAliasRow( const QString& alias, const QString& command )
{
	QStandardItem* aliasItem = new QStandardItem( alias );
	QStandardItem* commandItem = new QStandardItem( command );
	QStandardItem* closeItem = new QStandardItem( QPixmap( ":/Resource/Generic/Exit.png" ), QString() );
	closeItem->setFlags( closeItem->flags() & ~Qt::ItemIsEditable );
	sourceModel->appendRow( QList<QStandardItem*>() << aliasItem << commandItem << closeItem );
	return proxyModel->mapFromSource( aliasItem->index() );
}
Ejemplo n.º 22
0
void MainDialog::theme_load_all() {
    gchar* name;
    gchar* p;
    GList* it, *next;
    gint i;
    RrFont* active, *inactive, *menu_t, *menu_i, *osd;
    QModelIndex currentItemIndex;

    name = tree_get_string("theme/name", "TheBear");
    if(themes) {
        g_list_foreach(themes, (GFunc)g_free, NULL);
        g_list_free(themes);
        themes = NULL;
    }

    p = g_build_filename(g_get_home_dir(), ".themes", NULL);
    add_theme_dir(p);
    g_free(p);
    {
        GSList* it;
        for(it = obt_paths_data_dirs(paths); it; it = g_slist_next(it)) {
            p = g_build_filename((char*)it->data, "themes", NULL);
            add_theme_dir(p);
            g_free(p);
        }
    }

    add_theme_dir(THEME_DIR);
    themes = g_list_sort(themes, (GCompareFunc) strcasecmp);

    themes_model->clear();

    /* return to regular scheduled programming */
    i = 0;
    for(it = themes; it; it = next) {
        next = g_list_next(it);
        /* remove duplicates */
        if(next && !strcmp((char*)it->data, (char*)next->data)) {
            g_free(it->data);
            themes = g_list_delete_link(themes, it);
            continue;
        }

        QStandardItem* item = new QStandardItem(QString::fromUtf8((char*)it->data));
        themes_model->appendRow(item);
        if(!strcmp(name, (char*)it->data)) {
            currentItemIndex = item->index();
            ui.theme_names->selectionModel()->select(currentItemIndex, QItemSelectionModel::Select);
        }
        ++i;
    }
    // FIXME: preview_update_all();
    g_free(name);
    if(currentItemIndex.isValid())
        ui.theme_names->scrollTo(currentItemIndex, QAbstractItemView::PositionAtCenter);
}
void CookiesContentsWidget::removeDomainCookies()
{
	const QModelIndexList indexes = m_ui->cookiesView->selectionModel()->selectedIndexes();

	if (indexes.isEmpty())
	{
		return;
	}

	QNetworkCookieJar *cookieJar = NetworkManagerFactory::getCookieJar();
	QList<QNetworkCookie> cookies;

	for (int i = 0; i < indexes.count(); ++i)
	{
		QStandardItem *domainItem = ((indexes.at(i).isValid() && indexes.at(i).parent() == m_model->invisibleRootItem()->index()) ? findDomain(indexes.at(i).sibling(indexes.at(i).row(), 0).data(Qt::ToolTipRole).toString()) : m_model->itemFromIndex(indexes.at(i).parent()));

		if (domainItem)
		{
			for (int j = 0; j < domainItem->rowCount(); ++j)
			{
				QStandardItem *cookieItem = domainItem->child(j, 0);

				if (cookieItem)
				{
					const QNetworkCookie cookie = getCookie(cookieItem->index());

					if (!cookies.contains(cookie))
					{
						cookies.append(cookie);
					}
				}
			}
		}
	}

	if (cookies.isEmpty())
	{
		return;
	}

	QMessageBox messageBox;
	messageBox.setWindowTitle(tr("Question"));
	messageBox.setText(tr("You are about to delete %n cookies.", "", cookies.count()));
	messageBox.setInformativeText(tr("Do you want to continue?"));
	messageBox.setIcon(QMessageBox::Question);
	messageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
	messageBox.setDefaultButton(QMessageBox::Yes);

	if (messageBox.exec() == QMessageBox::Yes)
	{
		for (int i = 0; i < cookies.count(); ++i)
		{
			cookieJar->deleteCookie(cookies.at(i));
		}
	}
}
Ejemplo n.º 24
0
void StandardItemModel::updateParentFileSavePathFromIndex(const QModelIndex& index, const NzbFileData& nzbFileData) {

    QStandardItem* parentNzbFileNameItem = this->getNzbItem(index);

    NzbFileData parentNzbFileData = this->getNzbFileDataFromIndex(parentNzbFileNameItem->index());
    parentNzbFileData.updateFileSavePath(nzbFileData);

    this->updateNzbFileDataToItem(parentNzbFileNameItem, parentNzbFileData);

}
void QgsMapLayerStyleManagerWidget::currentStyleChanged( QString name )
{
  QList<QStandardItem*> items = mModel->findItems( name );
  if ( items.isEmpty() )
    return;

  QStandardItem* item = items.at( 0 );

  mStyleList->setCurrentIndex( item->index() );
}
QModelIndex AbstractCameraManager::addGroup() {
    QStandardItem *newGroup = new QStandardItem("new Group");
    newGroup->setCheckable(true);
    newGroup->setIcon(folderIcon);
    qDebug() << "folderIcon" << folderIcon;
    if( selectedItem != NULL && !selectedItem->data(CameraRole).isValid() )
        selectedItem->appendRow(newGroup);
    else
        cameraTree.appendRow(newGroup);
    return newGroup->index();
}
Ejemplo n.º 27
0
// This function returns the item specified by the row and col
// in absolute position. The difference between this function and
// normal QStandardItemModel is that the QStandardItemModel uses
// relative row and col.
QStandardItem * ObxTreeView::item(int row, int col)
{
    QStandardItem * item = all_items_[row];
    if (col == 0)
    {
        return item;
    }

    QStandardItem * parent = item->parent();
    QStandardItem * child = 0;
    if (parent == 0)
    {
        child = model_->invisibleRootItem()->child(item->index().row(), col);
    }
    else
    {
        child = parent->child(item->index().row(), col);
    }
    return child;
}
Ejemplo n.º 28
0
/// data() is re-implemented from QStandardItemModel to return the widget window title and icon for the Qt::DecorationRole and Qt::DisplayRole/Qt::EditRole
QVariant AMWindowPaneModel::data(const QModelIndex &index, int role) const {

	switch(role) {

	case Qt::DisplayRole:
	case Qt::EditRole:
		// alias items can have separate descriptions, but for normal items, the DisplayRole and EditRole should be the window title
		if(!isAlias(index) && internalPane(index))
			return internalPane(index)->windowTitle();
		else
			return AMDragDropItemModel::data(index, role);
		break;


	case Qt::DecorationRole:
		if(!isAlias(index) && internalPane(index))
			return internalPane(index)->windowIcon();
		else
			return AMDragDropItemModel::data(index, role);
		break;

	// read-only property, defined as being (a) NOT an alias, AND (b) having no valid window pane widget set
	case AMWindowPaneModel::IsHeadingRole:
		return (index.isValid() && !isAlias(index) && internalPane(index) == 0);
		break;

		// Dock state: alias items should return the dock state of their target. Other items simply return their dock state, as stored in the AMWindowPaneModel::DockStateRole.
	case AMWindowPaneModel::DockStateRole:
		if(isAlias(index)) {
			QStandardItem* target = aliasTarget(index);
			if(target)
				return data(target->index(), role);
			else
				return true;
		}
		else
			return AMDragDropItemModel::data(index, role);
		break;

	case AMWindowPaneModel::UndockResizeRole:
		return AMDragDropItemModel::data(index, role);
		break;

	case AMWindowPaneModel::IsVisibleRole:
		if (AMDragDropItemModel::data(index, role).isValid())
			return AMDragDropItemModel::data(index, role);
		else
			return true;
	    break;

	default:
		return AMDragDropItemModel::data(index, role);
	}
}
Ejemplo n.º 29
0
void FileOrganiserWidget::newFolder()
{
    if (!canCreateNewFolder())
        // The conditions are not met to create a new folder, so...

        return;

    // Either create a folder item below the current folder item or below the
    // root item, depending on the situation

    QModelIndexList selectedIndexes = selectionModel()->selectedIndexes();
    int selectedIndexesCount = selectedIndexes.count();
    QStandardItem *crtItem = !selectedIndexesCount?
                                mModel->invisibleRootItem():
                                mModel->itemFromIndex(selectedIndexes.first());
    QStandardItem *newFolderItem = new QStandardItem(QIcon(CollapsedFolderIcon),
                                                     newFolderName(crtItem));

    newFolderItem->setData(true, Item::Folder);

    crtItem->appendRow(newFolderItem);

    // Some post-processing, but only if no other item is currently being edited

    if (!isEditing()) {
        // Expand the current index (so that we can see the new folder)
        // Note: this is only relevant in the case of a folder item being
        //       currently selected (i.e. it's not the root folder item)

        if (selectedIndexesCount)
            setExpanded(crtItem->index(), true);

        // Offer the user to edit the newly added folder item

        edit(newFolderItem->index());
    }

    // Resize the widget, just to be on the safe side

    resizeToContents();
}
Ejemplo n.º 30
0
/*
  direction: 1=below only, 2=above only, 3=below then above
*/
QStandardItem*
mail_listview::nearest(const mail_msg* msg, int direction) const
{
  mail_item_model* model = this->model();
  QStandardItem* item = model->item_from_id(msg->get_id());
  if (item!=NULL) {
    if (direction==1 || direction==3) {
      QModelIndex index_below=indexBelow(item->index());
      if (index_below.isValid()) {
	return model->itemFromIndex(index_below);
      }
    }
    if (direction==2 || direction==3) {
      QModelIndex index_above=indexAbove(item->index());
      if (index_above.isValid()) {
	return model->itemFromIndex(index_above);
      }
    }
  }
  return NULL;
}