コード例 #1
0
void ConsoleItemModel::appendItem(ConsoleItem *item, int position)
{
    if (position < 0)
        position = rootItem()->childCount() - 1; // append before editable row

    if (position < 0)
        position = 0;

    rootItem()->insertChild(position, item);
}
コード例 #2
0
void QmlConsoleItemModel::shiftEditableRow()
{
    int position = rootItem()->childCount();
    Q_ASSERT(position > 0);

    // Disable editing for old editable row
    rootItem()->lastChild()->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);

    appendItem(new ConsoleItem(ConsoleItem::InputType), position);
    emit selectEditableRow(index(position, 0, QModelIndex()), QItemSelectionModel::ClearAndSelect);
}
コード例 #3
0
void Toolbar::onSysColorChange()
{
	// the following line is used to hack the toolbar background color for tradeshow
	return;
	int iconSize;
	ImageList_GetIconSize( disabledImageList_, &iconSize, &iconSize );
	disabledImageList_ = ImageList_Create( iconSize, iconSize, ILC_COLOR32, 1, 256 );
	hotImageList_ = ImageList_Create( iconSize, iconSize, ILC_COLOR32, 1, 256 );
	normalImageList_ = ImageList_Create( iconSize, iconSize, ILC_COLOR32, 1, 256 );

	// destroy it
	while( sendMessage( TB_BUTTONCOUNT, 0, 0 ) )
		sendMessage( TB_DELETEBUTTON , 0, 0 );

	HIMAGELIST imglist;
	imglist = (HIMAGELIST)sendMessage( TB_SETIMAGELIST, 0, (LPARAM)normalImageList_ );
	if( imglist )
		ImageList_Destroy( imglist );
	imglist = (HIMAGELIST)sendMessage( TB_SETHOTIMAGELIST, 0, (LPARAM)hotImageList_ );
	if( imglist )
		ImageList_Destroy( imglist );
	imglist = (HIMAGELIST)sendMessage( TB_SETDISABLEDIMAGELIST, 0, (LPARAM)disabledImageList_ );
	if( imglist )
		ImageList_Destroy( imglist );

	imageIndices_.clear();
	Manager::instance().bitmaps().clear();

	unsigned int index = 0;
	changed( index, rootItem() );
}
コード例 #4
0
void KonqPopupMenuTest::testViewReadOnlyDirectory()
{
    KFileItem rootItem(QUrl::fromLocalFile(QDir::rootPath()), QStringLiteral("inode/directory"), KFileItem::Unknown);
    KFileItemList itemList;
    itemList << rootItem;
    QUrl viewUrl = rootItem.url();
    const KonqPopupMenu::Flags flags = m_appFlags |
        KonqPopupMenu::ShowCreateDirectory |
        KonqPopupMenu::ShowUrlOperations |
        KonqPopupMenu::ShowProperties;
    // KonqMainWindow says: doTabHandling = !openedForViewURL && ... So we don't add tabhandling here
    KonqPopupMenu::ActionGroupMap actionGroups;
    actionGroups.insert(KonqPopupMenu::PreviewActions, m_previewActions->actions());

    KonqPopupMenu popup(itemList, viewUrl, m_actionCollection, flags);
    popup.setNewFileMenu(m_newMenu);
    popup.setActionGroups(actionGroups);

    QStringList actions = extractActionNames(popup);
    actions.removeAll(QStringLiteral("services_submenu"));
    qDebug() << actions;
    QStringList expectedActions;
    expectedActions // << "paste" // no paste since readonly
                    << QStringLiteral("openwith")
                    << QStringLiteral("preview_submenu");
    expectedActions << QStringLiteral("separator");
    expectedActions << QStringLiteral("copyTo_submenu") << QStringLiteral("separator"); // no moveTo_submenu, since readonly
    expectedActions << QStringLiteral("properties");
    qDebug() << "Expected:" << expectedActions;
    QCOMPARE(actions, expectedActions);
}
コード例 #5
0
void Toolbar::changed( ItemPtr item )
{// normally a toolbar only has several buttons ( less than 30 ), always do a full refresh
	unsigned int index = 0;
	changed( index, rootItem() );
	++index;
	while( index < (unsigned int)sendMessage( TB_BUTTONCOUNT, 0, 0 ) )
	{
		static const unsigned int MAX_MENU_TEXT = 1024;
		char txtBuf[ MAX_MENU_TEXT + 1 ];
		TBBUTTONINFO info;
		memset( &info, 0, sizeof( info ) );
		info.cbSize = sizeof( info );
		info.dwMask = TBIF_BYINDEX | TBIF_COMMAND | TBIF_IMAGE | TBIF_LPARAM
			| TBIF_SIZE | TBIF_STATE | TBIF_STYLE | TBIF_TEXT;
		info.pszText = txtBuf;
		txtBuf[0] = 0;
		info.cchText = MAX_MENU_TEXT;
		sendMessage( TB_GETBUTTONINFO, index, (LPARAM)&info );
		if( ( info.fsStyle & BTNS_SEP ) && info.lParam )
			DestroyWindow( (HWND)info.lParam );
		sendMessage( TB_DELETEBUTTON , index, 0 );
	}
	restoreText();
	UpdateWindow( toolbar_ );
}
コード例 #6
0
QList<TestConfiguration *> TestTreeModel::getSelectedTests() const
{
    QList<TestConfiguration *> result;
    foreach (Utils::TreeItem *frameworkRoot, rootItem()->children())
        result.append(static_cast<TestTreeItem *>(frameworkRoot)->getSelectedTestConfigurations());
    return result;
}
コード例 #7
0
int ConsoleItemModel::sizeOfFile(const QFont &font)
{
    int lastReadOnlyRow = rootItem()->childCount();
    lastReadOnlyRow -= 2; // skip editable row
    if (lastReadOnlyRow < 0)
        return 0;
    QString filename = static_cast<ConsoleItem *>(rootItem()->childAt(lastReadOnlyRow))->file();
    const int pos = filename.lastIndexOf(QLatin1Char('/'));
    if (pos != -1)
        filename = filename.mid(pos + 1);

    QFontMetrics fm(font);
    m_maxSizeOfFileName = qMax(m_maxSizeOfFileName, fm.width(filename));

    return m_maxSizeOfFileName;
}
コード例 #8
0
int TestResultModel::maxWidthOfFileName(const QFont &font)
{
    if (font != m_measurementFont) {
        m_processedIndices.clear();
        m_maxWidthOfFileName = 0;
        m_measurementFont = font;
    }

    const QFontMetrics fm(font);
    const QVector<Utils::TreeItem *> &topLevelItems = rootItem()->children();
    const int count = topLevelItems.size();
    for (int row = 0; row < count; ++row) {
        int processed = row < m_processedIndices.size() ? m_processedIndices.at(row) : 0;
        const QVector<Utils::TreeItem *> &children = topLevelItems.at(row)->children();
        const int itemCount = children.size();
        if (processed < itemCount) {
            for (int childRow = processed; childRow < itemCount; ++childRow) {
                const TestResultItem *item = static_cast<TestResultItem *>(children.at(childRow));
                if (const TestResult *result = item->testResult()) {
                    QString fileName = result->fileName();
                    const int pos = fileName.lastIndexOf(QLatin1Char('/'));
                    if (pos != -1)
                        fileName = fileName.mid(pos + 1);
                    m_maxWidthOfFileName = qMax(m_maxWidthOfFileName, fm.width(fileName));
                }
            }
            if (row < m_processedIndices.size())
                m_processedIndices.replace(row, itemCount);
            else
                m_processedIndices.insert(row, itemCount);
        }
    }
    return m_maxWidthOfFileName;
}
コード例 #9
0
void ConsoleItemModel::shiftEditableRow()
{
    int position = rootItem()->childCount();
    Q_ASSERT(position > 0);

    appendItem(new ConsoleItem(ConsoleItem::InputType), position);
    emit selectEditableRow(index(position, 0, QModelIndex()), QItemSelectionModel::ClearAndSelect);
}
コード例 #10
0
RegisterMap RegisterHandler::registerMap() const
{
    RegisterMap result;
    Utils::TreeItem *root = rootItem();
    for (int i = 0, n = root->rowCount(); i != n; ++i) {
        RegisterItem *reg = static_cast<RegisterItem *>(root->child(i));
        quint64 value = reg->addressValue();
        if (value)
            result.insert(value, reg->m_reg.name);
    }
    return result;
}
コード例 #11
0
ファイル: contactlist.cpp プロジェクト: senu/psi
void ContactList::updateParents()
{
	// Switch invisible groups
	ContactListRootItem* tmpInvisibleGroup = invisibleGroup_;
	invisibleGroup_ = altInvisibleGroup_;
	altInvisibleGroup_ = tmpInvisibleGroup;

	// Move items around
	rootItem()->updateParents();
	altInvisibleGroup_->updateParents();

	emit dataChanged();
}
コード例 #12
0
ファイル: Window.cpp プロジェクト: lemourin/SimpleMOBA
Window::Window(QWindow *parent)
    : SceneGraph::Window(parent),
      m_environment(this),
      m_game(rootItem()) {
  qmlRegisterUncreatableType<Environment>("Environment", 1, 0, "Environment",
                                          "Uncreatable type!");
  rootContext()->setContextProperty("app", &m_environment);
  rootContext()->setContextProperty("world", m_game.view()->world()->object());
  m_game.view()->world()->mainAction()->registerUserInterface(rootContext());

  setSource(QUrl("qrc:/UserInterface/main.qml"));
  setResizeMode(SizeRootObjectToView);

  connect(engine(), &QQmlEngine::quit, this, &QQuickView::close);
}
コード例 #13
0
ファイル: Window.cpp プロジェクト: Hakiko/SimpleMOBA
Window::Window(QWindow *parent)
    : SceneGraph::Window(parent), m_environment(this), m_game(rootItem()) {
  rootContext()->setContextProperty("app", &m_environment);
  rootContext()->setContextProperty("world", m_game.view()->world()->object());
  rootContext()->setContextProperty("player", m_game.view()->world()->player()->object());
  m_game.view()->world()->mainAction()->registerUserInterface(rootContext());

  setSource(QUrl("qrc:/UserInterface/main.qml"));
  setResizeMode(SizeRootObjectToView);

  connect(engine(), &QQmlEngine::quit, this, &QQuickView::close);
  connect(this, &Window::sceneGraphInitialized, this,
          &Window::onSceneGraphInitialized);
  connect(this, &Window::sceneGraphInvalidated, this,
          &Window::onSceneGraphInvalidated);
}
コード例 #14
0
ParserTreeItem::ConstPtr Parser::parse()
{
    QTime time;
    if (debug)
        time.start();

    ParserTreeItem::Ptr rootItem(new ParserTreeItem());

    // check all projects
    QList<ProjectExplorer::Project *> projects = getProjectList();
    foreach (const ProjectExplorer::Project *prj, projects) {
        if (!prj)
            continue;

        ParserTreeItem::Ptr item;
        if (!d->flatMode)
            item = ParserTreeItem::Ptr(new ParserTreeItem());

        QString prjName(prj->displayName());
        QString prjType(prjName);
        if (prj->document())
            prjType = prj->document()->filePath();
        SymbolInformation inf(prjName, prjType);

        QStringList projectList = addProjectNode(item, prj->rootProjectNode());

        if (d->flatMode) {
            // use prj path (prjType) as a project id
//            addProject(item, prj->files(ProjectExplorer::Project::ExcludeGeneratedFiles), prjType);
            //! \todo return back, works too long
            ParserTreeItem::Ptr flatItem = createFlatTree(projectList);
            item.swap(flatItem);
        }
        item->setIcon(prj->rootProjectNode()->icon());
        rootItem->appendChild(item, inf);
    }

    if (debug)
        qDebug() << "Class View:" << QDateTime::currentDateTime().toString()
            << "Parsed in " << time.elapsed() << "msecs.";

    return rootItem;
}
コード例 #15
0
void Menu::changed( ItemPtr item )
{
    std::stack<HMENU> menus;
    menus.push( hmenu_ );
    bool found = false;
    while( !menus.empty() )
    {
        HMENU hmenu = menus.top();
        menus.pop();
        MENUITEMINFO info = { sizeof( info ), MIIM_ID | MIIM_DATA };
        for( int i = 0; i < GetMenuItemCount( hmenu ); ++i )
            if( GetMenuItemInfo( hmenu, i, TRUE, &info ) &&
                    info.wID == item->commandID() &&
                    ( Item* )info.dwItemData == item )
                changed( hmenu, item );
    }
    if( !found )// we'll do a full refresh
        changed( hmenu_, rootItem() );
}
コード例 #16
0
void RegisterHandler::updateRegister(const Register &r)
{
    RegisterItem *reg = m_registerByName.value(r.name, 0);
    if (!reg) {
        reg = new RegisterItem(r);
        m_registerByName[r.name] = reg;
        rootItem()->appendChild(reg);
        return;
    }

    if (r.size > 0)
        reg->m_reg.size = r.size;
    if (!r.description.isEmpty())
        reg->m_reg.description = r.description;
    if (reg->m_reg.value != r.value) {
        // Indicate red if values change, keep changed.
        reg->m_changed = true;
        reg->m_reg.previousValue = reg->m_reg.value;
        reg->m_reg.value = r.value;
        emit registerChanged(reg->m_reg.name, reg->addressValue()); // Notify attached memory views.
    } else {
        reg->m_changed = false;
    }
}
コード例 #17
0
void Toolbar::restoreText()
{
	SetWindowText( toolbar_, rootItem()->displayName().c_str() );
}
コード例 #18
0
void Toolbar::forceChanged()
{
	forceChanged_ = true;
	changed( rootItem() );
	forceChanged_ = false;
}
コード例 #19
0
ファイル: contactlist.cpp プロジェクト: senu/psi
void ContactList::updateVisibleParents()
{
	rootItem()->updateParents();
	emit dataChanged();
}
コード例 #20
0
void AbstractTreeModel::traverse(AbstractTreeModelVisitor * visitor, TreeItem * start)
{
	start = start ? start : rootItem();
	start->acceptVisitor(visitor);
}