Example #1
0
void tst_Q3ValueList::pushing()
{
    Q3ValueList<int> a;
    a.append( 100 );

    a.push_front( 10 );
    QCOMPARE( a.first(), 10 );
    QCOMPARE( a.last(), 100 );

    a.push_back( 1000 );
    QCOMPARE( a.first(), 10 );
    QCOMPARE( a.last(), 1000 );
}
Example #2
0
void tst_Q3ValueList::firstLast()
{
    Q3ValueList<int> a;
    a.append( 1 );
    a.append( 10 );
    a.append( 100 );
    a.append( 1000 );
    a.append( 10000 );

    QCOMPARE( a.first(), 1 );
    QCOMPARE( a.last(), 10000 );

    a.first() = 2;
    a.last() = 20000;
    QCOMPARE( a.first(), 2 );
    QCOMPARE( a.last(), 20000 );
}
Example #3
0
void tst_Q3ValueList::remove()
{
    {
        Q3ValueList<int> a;
        a.append( 1 );
        a.append( 10 );
        a.append( 100 );
        a.append( 1000 );
        a.append( 1000 );
        a.append( 10000 );

        QCOMPARE( (uint)a.remove(100), (uint)1 );
        QCOMPARE( (uint)a.remove(1000), (uint)2 );
        QCOMPARE( (int)a.first(), 1 );
        QCOMPARE( (int)a.last(), 10000 );

        a.remove( a.at(0) );
        QCOMPARE( (int)a.first(), 10 );
        QCOMPARE( (int)a.last(), 10000 );

        a.remove( a.at(1) );
        QCOMPARE( (int)a.first(), 10 );
        QCOMPARE( (int)a.last(), 10 );
    }
    {
        Q3ValueList<int> a;
        a.append( 1 );
        a.append( 10 );
        a.append( 100 );
        a.append( 1000 );
        a.append( 10000 );

        Q3ValueList<int>::Iterator it = a.begin();
        ++it;
        QVERIFY(*it == 10);
        it = a.remove(it);
        QVERIFY(*it == 100);
        it = a.remove(it);
        QVERIFY(*it == 1000);
        it = a.remove(it);
        QVERIFY(*it == 10000);
        it = a.remove(it);
        QVERIFY(it == a.end());
    }
}
Example #4
0
void tst_Q3ValueList::popping()
{
    Q3ValueList<int> a;
    a.append( 1 );
    a.append( 10 );
    a.append( 100 );
    a.append( 1000 );
    a.append( 10000 );

    a.pop_front();
    QCOMPARE( a.first(), 10 );
    QCOMPARE( a.last(), 10000 );

    a.pop_back();
    QCOMPARE( a.first(), 10 );
    QCOMPARE( a.last(), 1000 );

    QCOMPARE( (int)a.count(), 3 );

    a.pop_back();
    a.pop_back();
    a.pop_back();
    QVERIFY( a.isEmpty() );
}
Example #5
0
void tst_Q3ValueList::erase()
{
    Q3ValueList<int> a;
    a.append( 1 );
    a.append( 5 );
    a.append( 10 );
    a.append( 50 );
    a.append( 100 );
    a.append( 500 );
    a.append( 1000 );
    a.append( 5000 );
    a.append( 10000 );
    a.append( 50000 );

    a.erase( a.at(0), a.at(5) ); // Remove 1 to 100 (inclusive)
    QCOMPARE( (int)a.first(), 500 );
    QCOMPARE( (int)a.last(), 50000 );

    Q3ValueListIterator<int> it = a.erase( a.at(2) ); // remove 5000
    QCOMPARE( *(it), 10000 );

    it = a.erase( a.at(3) ); // remove 50000
    QVERIFY( (it == a.end()) );
}
Example #6
0
JavaCatWindow::JavaCatWindow() : Q3MainWindow(0, "Java Catalog", Qt::WDestructiveClose) {
  the = this;
  setCaption("Java Catalog");
  commented = 0;
  
  Q3PopupMenu * menu;
  QPixmap pixmap;
  
  Q3ToolBar * tools = new Q3ToolBar(this, "operations");
  
  addToolBar(tools, "Operations", Qt::DockTop, TRUE);
  
  menu = new Q3PopupMenu(this);
  menuBar()->insertItem("&File", menu);
  
  pixmap = QPixmap(fileopen);
  Q3WhatsThis::add(new QToolButton(pixmap, "Open", QString::null,
				  this, SLOT(load()), tools, "open"),
		  OpenText);
  menu->setWhatsThis(menu->insertItem(pixmap, "&Open", this,
				      SLOT(load()), Qt::CTRL+Qt::Key_O),
		     OpenText);
  
  pixmap = QPixmap(filesave);
  Q3WhatsThis::add(new QToolButton(pixmap, "Save", QString::null,
				  this, SLOT(save()), tools, "save"),
		  SaveText);
  menu->setWhatsThis(menu->insertItem(pixmap, "&Save", this,
				      SLOT(save()), Qt::CTRL+Qt::Key_S),
		     SaveText);
  
  menu->insertSeparator();
  pixmap = QPixmap(::scan);
  Q3WhatsThis::add(new QToolButton(pixmap, "Scan", QString::null,
				  this, SLOT(scan()), tools, "scan"),
		  ScanText);
  menu->setWhatsThis(menu->insertItem(pixmap, "S&can", this,
				      SLOT(scan()), Qt::CTRL+Qt::Key_C),
		     ScanText);
  
  menu->insertSeparator();
  menu->insertItem("&Quit", this, SLOT(quit()), Qt::CTRL+Qt::Key_Q);
  
  menu = new Q3PopupMenu(this);
  menuBar()->insertItem("&Browse", menu);
  
  pixmap = QPixmap(browsersearch);
  Q3WhatsThis::add(new QToolButton(pixmap, "Search", QString::null,
				  this, SLOT(browser_search()), tools, "search"),
		  SearchText);
  menu->setWhatsThis(menu->insertItem(pixmap, "&Search", this,
				      SLOT(browser_search()), Qt::CTRL+Qt::Key_S),
		     SearchText);
  
  pixmap = QPixmap(left_xpm);
  Q3WhatsThis::add(new QToolButton(pixmap, "Back", QString::null,
				  this, SLOT(historic_back()),
				  tools, "back"),
		  LeftText);
  
  pixmap = QPixmap(right_xpm);
  Q3WhatsThis::add(new QToolButton(pixmap, "Forward", QString::null,
				  this, SLOT(historic_forward()),
				  tools, "forward"),
		  RightText);
  
  (void)Q3WhatsThis::whatsThisButton(tools);

  //
  
  menu = new Q3PopupMenu(this);
  menuBar()->insertItem("&Style", menu);
  
#if !defined(QT_NO_STYLE_MOTIF)
  menu->insertItem("Motif", this, SLOT(motif_style()));
#endif
#if !defined(QT_NO_STYLE_MOTIFPLUS)
  menu->insertItem("MotifPlus", this, SLOT(motifplus_style()));
#endif
  menu->insertItem("Windows", this, SLOT(windows_style()));
  
  //
  
  menuBar()->insertSeparator();
  menu = new Q3PopupMenu(this);
  menuBar()->insertItem("&Help", menu);
  
  menu->insertItem("&About", this, SLOT(about()), Qt::Key_F1);
  menu->insertItem("About&Qt", this, SLOT(aboutQt()));
  menu->insertSeparator();
  menu->insertItem("What's This", this, SLOT(whatsThis()), Qt::SHIFT+Qt::Key_F1);
    
  //
  
  spl = new QSplitter(Qt::Vertical, this, "spl");
  
  browser = new BrowserView(spl);
  comment = new CommentView(spl);
  
  connect(comment, SIGNAL(refer(const QString &)),
	  browser, SLOT(refer(const QString &)));
  
  spl->moveToFirst(browser);

  Q3ValueList<int> lsz = spl->sizes();
  int h = lsz.first() + lsz.last();
  
  lsz.first() = (h*3)/4;
  lsz.last() = h - lsz.first();
  
  spl->setSizes(lsz);
  
  spl->setResizeMode(comment, QSplitter::KeepSize);
  setCentralWidget(spl);
}
Example #7
0
QRect CEdge::drawTree( Q3Canvas* canvas, int left, int depth, StringToString* filter )
{
	int X_PADDING = 10;
	int Y_SPACING = 30;

//	int X_MARGIN = 10; unused variable 'X_Margin'
	int Y_MARGIN = 10;

	//================================================

	Q3CanvasItem* edge = new Q3CanvasText( LHS(), canvas ),
			   * leaf = NULL;
	Q3CanvasLine* line;

	m_CanvasItems.clear();
	m_CanvasItems.append( edge );

	int myLeft = left,
		myTop = ( depth * Y_SPACING ) + Y_MARGIN,
		myCenterX,
		myBottom,
		childCenterX,
		childLeft,
		childTop,
		shiftAmount;

	Q3ValueList<QRect> daughterBoundingRectangles;
	Q3ValueList<QRect>::iterator it;

	QRect myBoundingRect, rectangle;
	myBoundingRect.setTop( myTop );
	myBoundingRect.setLeft( myLeft );
	myBoundingRect.setBottom( myTop + edge->boundingRect().height() - 1 );
	myBoundingRect.setRight( myLeft + edge->boundingRect().width() - 1 );
	
	int count = 0;
//	bool first = TRUE; unused variable 'first'

	CEdge* daughter;
	for( daughter = m_Daughters.first(); daughter; daughter = m_Daughters.next() )
	{
		daughterBoundingRectangles.append( rectangle );

		daughterBoundingRectangles[count] = daughter->drawTree( canvas, left, depth + 1, filter );

		// Adjust left position based on bounding rectangle of last daughter
		left = daughterBoundingRectangles[count].right() + X_PADDING;

		count++;
	}

	if( m_Daughters.isEmpty() )
	{
		// Create leaf node
		childLeft = myLeft;
		childTop = ( ( depth + 1 ) * Y_SPACING ) + Y_MARGIN;

		leaf = new Q3CanvasText( Filter( filter, RHS() ), canvas );
		m_CanvasItems.append( leaf );

		leaf->move( childLeft, childTop );
		leaf->show();

		// Adjust my bounding rect
		if( leaf->boundingRect().right() > myBoundingRect.right() ) myBoundingRect.setRight( leaf->boundingRect().right() );
		myBoundingRect.setBottom( leaf->boundingRect().bottom() );
	}
	else
	{
		for( it = daughterBoundingRectangles.begin(); it != daughterBoundingRectangles.end(); ++it )
		{
			// Adjust my bounding rect
			if( (*it).right() > myBoundingRect.right() ) myBoundingRect.setRight( (*it).right() );
			if( (*it).bottom() > myBoundingRect.bottom() ) myBoundingRect.setBottom( (*it).bottom() );
		}
	}
	
	if( myBoundingRect.width() == edge->boundingRect().width() ) 
	{
		// Shift all children to the right
		if( m_Daughters.isEmpty() )
		{
			shiftAmount = int (( myBoundingRect.width() - leaf->boundingRect().width() ) / 2.0);

			leaf->move( leaf->boundingRect().left() + shiftAmount, leaf->boundingRect().top() );
			leaf->show();
		}
		else
		{
			shiftAmount = int (( myBoundingRect.width() - ( daughterBoundingRectangles.last().right() - daughterBoundingRectangles.first().left() ) ) / 2.0);
			
			for( daughter = m_Daughters.first(); daughter; daughter = m_Daughters.next() )
			{
				daughter->shiftTree( canvas, shiftAmount, 0 );
			}

			for( it = daughterBoundingRectangles.begin(); it != daughterBoundingRectangles.end(); ++it )
			{
				// Adjust the bounding rect position
				(*it).setLeft( (*it).left() + shiftAmount );
				(*it).setRight( (*it).right() + shiftAmount );
			}
		}
	}
	else myLeft = ( myBoundingRect.right() - ( myBoundingRect.width() / 2 ) ) - ( edge->boundingRect().width() / 2 );


	if( myLeft < myBoundingRect.left() ) myLeft = myBoundingRect.left();
	edge->move( myLeft, myTop );

	// Draw lines to daughter nodes
	if( m_Daughters.isEmpty() )
	{
		myCenterX = edge->boundingRect().center().x();
		myBottom = edge->boundingRect().bottom();

		childCenterX = leaf->boundingRect().center().x();
		childTop = leaf->boundingRect().top();

		if( myCenterX - childCenterX == 1 || myCenterX - childCenterX == -1 ) myCenterX = childCenterX;

		line = new Q3CanvasLine( canvas );
		line->setPoints( myCenterX, myBottom, childCenterX, childTop );
		line->show();

		m_CanvasItems.append( line );
	}
	else
	{
		Q3ValueList<QRect>::iterator it;
		for( it = daughterBoundingRectangles.begin(); it != daughterBoundingRectangles.end(); ++it )
		{
			myCenterX = edge->boundingRect().center().x();
			myBottom = edge->boundingRect().bottom();

			childCenterX = (*it).center().x();
			childTop = (*it).top();

			if( myCenterX - childCenterX == 1 || myCenterX - childCenterX == -1 ) myCenterX = childCenterX;

			line = new Q3CanvasLine( canvas );
			line->setPoints( myCenterX, myBottom, childCenterX, childTop );
			line->show();

			m_CanvasItems.append( line );
		}
	}

	edge->show();
	canvas->update();

	return myBoundingRect;
}