Exemplo n.º 1
0
void TreeViewItem::restoreOpennessState (const XmlElement& e) throw()
{
    if (e.hasTagName ("CLOSED"))
    {
        setOpen (false);
    }
    else if (e.hasTagName ("OPEN"))
    {
        setOpen (true);

        forEachXmlChildElement (e, n)
        {
            const String id (n->getStringAttribute ("id"));

            for (int i = 0; i < subItems.size(); ++i)
            {
                TreeViewItem* const ti = subItems.getUnchecked(i);

                if (ti->getUniqueName() == id)
                {
                    ti->restoreOpennessState (*n);
                    break;
                }
            }
        }
    }
Exemplo n.º 2
0
TreeViewItem* TreeViewItem::findItemFromIdentifierString (const String& identifierString)
{
    const String thisId (getUniqueName());

    if (thisId == identifierString)
        return this;

    if (identifierString.startsWith (thisId + "/"))
    {
        const String remainingPath (identifierString.substring (thisId.length() + 1));

        bool wasOpen = isOpen();
        setOpen (true);

        for (int i = subItems.size(); --i >= 0;)
        {
            TreeViewItem* item = subItems.getUnchecked(i)->findItemFromIdentifierString (remainingPath);

            if (item != 0)
                return item;
        }

        setOpen (wasOpen);
    }

    return 0;
}
Exemplo n.º 3
0
bool TutFile::open(const QByteArray &data)
{
	QList<quint32> positions;
	quint32 dataSize = data.size();

	positions = openPositions(data);
	if(positions.isEmpty()) {
		return false;
	}

	tutos.clear();
	for(int i=0 ; i<positions.size()-1 ; ++i) {
		if(positions.at(i) < dataSize && positions.at(i) < positions.at(i+1)) {
			QByteArray t = data.mid(positions.at(i), positions.at(i+1)-positions.at(i));
//			if(t.startsWith("KAO")) {
//				t.prepend('A'); // PC bug
//			}
//			qDebug() << i << t.left(16).toHex();
			tutos.append(t);
		}
	}

	setOpen(true);

	return true;
}
Exemplo n.º 4
0
void TreeItem::insertNode(GNode * node)
{
    nodeObj_ = node;
    node->setGuiPtr(this);
//      return;
    QListIterator < GNode > it = QListIterator < GNode > (node->children());
    while (it.current()) {
        GNode *n = it.current();
#ifdef DEBUGMSG
        qDebug("TreeItem: add %s\n", (const char *) n->name());
#endif
        TreeItem *item = new TreeItem(this, n->name());
        ASSERT(item!=0);
        if (n->isA("SNode")) {
            pixmap_.resize(20, 10);
            pixmap_.fill(((SNode *) n)->color());
            item->setPixmap(0, pixmap_);
        }
#if 0
        if (nodeObj_->isCompound())
            item->setPixmap(0, *pixmap_compound);
        else
            item->setPixmap(0, *pixmap_generalize);
#endif
#ifdef DEBUGMSG
        qDebug("TreeItem: done %s\n", (const char *) n->name());
#endif
        item->insertNode(n);
        ++it;
    }
    setOpen(TRUE);
}
Exemplo n.º 5
0
/*
void ModuleTreeView::expandItem(QListViewItem *item, QPtrList<QListViewItem> *parentList)
{
  while (item)
    {
      setOpen(item, parentList->contains(item));

          if (item->childCount() != 0)
                expandItem(item->firstChild(), parentList);
      item = item->nextSibling();
    }
}
*/
void ModuleTreeView::makeVisible(ConfigModule *module)
{
  QString path = _modules->findModule(module);
  if (path.startsWith(KCGlobal::baseGroup()))
     path = path.mid(KCGlobal::baseGroup().length());

  QStringList groups = QStringList::split('/', path);

  ModuleTreeItem *item = 0;
  QStringList::ConstIterator it;
  for (it=groups.begin(); it != groups.end(); ++it)
  {
     if (item)
        item = static_cast<ModuleTreeItem*>(item->firstChild());
     else
        item = static_cast<ModuleTreeItem*>(firstChild());

     while (item)
     {
        if (item->tag() == *it)
        {
           setOpen(item, true);
           break;
        }
        item = static_cast<ModuleTreeItem*>(item->nextSibling());
     }
     if (!item)
        break; // Not found (?)
  }

  // make the item visible
  if (item)
    ensureItemVisible(item);
}
Exemplo n.º 6
0
void CDatabaseItem::setConnected(bool isconnected)
{
#ifdef DEBUG
  qDebug("CDatabaseItem::setConnected(%s)", debug_string(booltostr(isconnected)));
#endif

  if (isBlocked())
    return;

  setBlocked(true);  

  if (isconnected)
    is_connected = isconnected && mysql()->mysql()->mysqlSelectDb(text(0));
  else
    is_connected = false;

  setPixmap(0, is_connected ? databaseConnectedIcon : databaseDisconnectedIcon);
  if (is_connected)
  {
    new CTableGroupItem(this, text(0), mysql());
    setOpen(true);
  }
  else
    deleteChilds();

  createWindowMenu(consoleWindow()->itemToolBar());
  setBlocked(false);
}
Exemplo n.º 7
0
/**
 * Override
 * Open a connection to the database.
 * @param db            The name of the database which is to open.
 * @param user          A username of a database role.
 * @param password      The password to the username.
 * @param host          The host name or address where the database is home.
 * @param port          The port number to the database.
 * @param connOpts      Additional and optional options.
 * @return              True if database is open. Otherwise returns false.
 */
bool KQPostgreSqlDriver::open(const QString &db, const QString &user, const QString &password, const QString &host, int port, const QString &connOpts)
{
    if (isOpen()) {
        close();
    }
    QByteArray connectionInfo;
    connectionInfo.append("host=").append(host).append(' ');
    connectionInfo.append("port=").append(QString::number(port)).append(' ');
    connectionInfo.append("dbname=").append(db).append(' ');
    connectionInfo.append("user="******"password="******"Could not open database !"), QString(PQerrorMessage(m_connection)), QSqlError::ConnectionError);
        setLastError(error);
        setOpenError(true);
        PQfinish(m_connection);
        m_connection = NULL;

        return false;
    }
    setOpen(true);
    setOpenError(false);

    return true;
}
Exemplo n.º 8
0
WatchRoot::WatchRoot(VariableTree *parent)
    : LazyFetchItem(parent)
{
    setText(VAR_NAME_COLUMN, i18n("Watch"));
    setOpen(true);
	setSelectable(false);
}
Exemplo n.º 9
0
    void mouseDoubleClick (const MouseEvent& e) override
    {
        if (e.y < titleHeight) {
            setOpen (! isOpen);
        }

    }
Exemplo n.º 10
0
/**
 * @brief Overwritten drop handler
 *
 * @param evt the event
 */
void TreeEntry::dropped(QDropEvent *evt)
{
    if (evt->provides("application/x-qpamat")) {
        evt->accept();
        QString xml = QString::fromUtf8(evt->encodedData("application/x-qpamat"));
        QDomDocument doc;
        doc.setContent(xml);
        QDomElement elem = doc.documentElement();

        Q3ListViewItem* src = reinterpret_cast<TreeEntry*>(elem.attribute("memoryAddress").toLong());

        QpamatWindow *win = Qpamat::instance()->getWindow();
        if (src == this) {
            win->message(tr("Cannot dray to itself."));
            return;
        }

        TreeEntry* item = m_isCategory ? this : dynamic_cast<TreeEntry*>(parent());
        TreeEntry* appended = 0;
        if (item)
            appended = appendFromXML(item, elem);
        else
            appended = appendFromXML(listView(), elem);

        if (!isOpen())
            setOpen(true);

        listView()->setSelected(appended, true);
        dynamic_cast<Tree*>(listView())->updatePasswordStrengthView();
        delete src;
    }
}
Exemplo n.º 11
0
DriverItem::DriverItem(QListViewItem *parent, QListViewItem *after, DrBase *item) : QListViewItem(parent, after), m_item(item), m_conflict(false)
{
    setOpen(depth() < 3);
    if(item)
        setPixmap(0, SmallIcon((item->isOption() ? "document" : "folder")));
    updateText();
}
Exemplo n.º 12
0
int BulkController::close() {
    if (!isOpen()) {
        qDebug() << " device" << getName() << "already closed";
        return -1;
    }

    qDebug() << "Shutting down USB Bulk device" << getName();

    // Stop the reading thread
    if (m_pReader == NULL) {
        qWarning() << "BulkReader not present for" << getName()
                   << "yet the device is open!";
    } else {
        disconnect(m_pReader, SIGNAL(incomingData(QByteArray, mixxx::Duration)),
                   this, SLOT(receive(QByteArray, mixxx::Duration)));
        m_pReader->stop();
        controllerDebug("  Waiting on reader to finish");
        m_pReader->wait();
        delete m_pReader;
        m_pReader = NULL;
    }

    // Stop controller engine here to ensure it's done before the device is
    // closed incase it has any final parting messages
    stopEngine();

    // Close device
    controllerDebug("  Closing device");
    libusb_close(m_phandle);
    m_phandle = NULL;
    setOpen(false);
    return 0;
}
    bool selectFile (const File& target)
    {
        if (file == target)
        {
            setSelected (true, true);
            return true;
        }

        if (target.isAChildOf (file))
        {
            setOpen (true);

            for (int maxRetries = 500; --maxRetries > 0;)
            {
                for (int i = 0; i < getNumSubItems(); ++i)
                    if (FileListTreeItem* f = dynamic_cast <FileListTreeItem*> (getSubItem (i)))
                        if (f->selectFile (target))
                            return true;

                // if we've just opened and the contents are still loading, wait for it..
                if (subContentsList != nullptr && subContentsList->isStillLoading())
                {
                    Thread::sleep (10);
                    rebuildItemsFromContentList();
                }
                else
                {
                    break;
                }
            }
        }

        return false;
    }
Exemplo n.º 14
0
StreamItem::StreamItem( QListView* parent, const QString& n ):
QListViewItem( parent, n )
{
  name = n;
  stream = 0;
  setOpen( true );
}
Exemplo n.º 15
0
void PMCone::restoreMemento( PMMemento * s )
{
   PMMementoDataIterator it( s );
   PMMementoData* data;

   for( ; it.current( ); ++it )
   {
      data = it.current( );
      if( data->objectType( ) == s_pMetaObject )
      {
         switch( data->valueID( ) )
         {
            case PMEnd1ID:
               setEnd1( data->vectorData( ) );
            break;
            case PMEnd2ID:
               setEnd2( data->vectorData( ) );
            break;
            case PMRadius1ID:
               setRadius1( data->doubleData( ) );
            break;
            case PMRadius2ID:
               setRadius2( data->doubleData( ) );
            break;
            case PMOpenID:
               setOpen( data->boolData( ) );
            break;
            default:
               kdError( PMArea ) << "Wrong ID in PMCone::restoreMemento\n";
            break;
         }
      }
   }
   Base::restoreMemento (s);
}
Exemplo n.º 16
0
/*
   SQLite dbs have no user name, passwords, hosts or ports.
   just file names.
*/
bool QSQLite2Driver::open(const QString & db, const QString &, const QString &, const QString &, int, const QString &)
{
    if (isOpen())
        close();

    if (db.isEmpty())
        return false;

    char* err = 0;
    d->access = sqlite_open(QFile::encodeName(db), 0, &err);
    if (err) {
        setLastError(QSqlError(tr("Error opening database"), QString::fromAscii(err),
                     QSqlError::ConnectionError));
        sqlite_freemem(err);
        err = 0;
    }

    if (d->access) {
        setOpen(true);
        setOpenError(false);
        return true;
    }
    setOpenError(true);
    return false;
}
Exemplo n.º 17
0
void DriverItem::updateText()
{
    if(m_item)
    {
        QString s(m_item->get("text"));
        if(m_item->isOption())
            s.append(QString::fromLatin1(": <%1>").arg(m_item->prettyText()));
        if(m_item->type() == DrBase::List)
        {
            // remove all children: something has changed (otherwise this
            // function would not be called), so it make sense to remove
            // those children in all cases.
            while(firstChild())
                delete firstChild();
            DrBase *ch = static_cast< DrListOption * >(m_item)->currentChoice();
            if(ch && ch->type() == DrBase::ChoiceGroup)
            {
                // add new children
                static_cast< DrChoiceGroup * >(ch)->createItem(this);
                setOpen(true);
            }
        }
        setText(0, s);
    }
    else
        setText(0, "ERROR");
    widthChanged();
}
Exemplo n.º 18
0
int HidController::close() {
    if (!isOpen()) {
        qDebug() << "HID device" << getName() << "already closed";
        return -1;
    }

    qDebug() << "Shutting down HID device" << getName();

    // Stop the reading thread
    if (m_pReader == NULL) {
        qWarning() << "HidReader not present for" << getName()
                   << "yet the device is open!";
    } else {
        disconnect(m_pReader, SIGNAL(incomingData(QByteArray)),
                   this, SLOT(receive(QByteArray)));
        m_pReader->stop();
        hid_set_nonblocking(m_pHidDevice, 1);   // Quit blocking
        if (debugging()) qDebug() << "  Waiting on reader to finish";
        m_pReader->wait();
        delete m_pReader;
        m_pReader = NULL;
    }

    // Stop controller engine here to ensure it's done before the device is closed
    //  incase it has any final parting messages
    stopEngine();

    // Close device
    if (debugging()) {
        qDebug() << "  Closing device";
    }
    hid_close(m_pHidDevice);
    setOpen(false);
    return 0;
}
Exemplo n.º 19
0
QSymSQLDriver::QSymSQLDriver(RSqlDatabase& connection, QObject *parent)
    : QSqlDriver(parent)
{
    d = new QSymSQLDriverPrivate();
    d->access = connection;
    setOpen(true);
    setOpenError(false);
}
Exemplo n.º 20
0
void QMYSQLDriver::close()
{
    if ( isOpen() ) {
	mysql_close( d->mysql );
	setOpen( FALSE );
	setOpenError( FALSE );
    }
}
Exemplo n.º 21
0
void UIPopupBox::toggleOpen()
{
    /* Switch 'opened' state: */
    setOpen(!m_fOpen);

    /* Notify listeners about toggling: */
    emit sigToggled(m_fOpen);
}
Exemplo n.º 22
0
FolderTreeItem::FolderTreeItem( QTreeWidget* parent, Folder* folder, Preferences& prefs, PropertiesPanel* propsPanel )
    : TreeItem( (QTreeWidget*) parent ), folder( folder ), prefs( prefs ), propsPanel( propsPanel ) {
    // It's important to setCheckState() first.  Otherwise, if a change is made too soon, 
    // it may reset the markedForStudy property by an event.
    setCheckState( 0, folder->isMarkedForStudy() ? Qt::Checked : Qt::Unchecked );
    setText( 0, folder->getTitle() );
    setOpen( prefs.isFolderOpen( folder->getId() ) );
}
Exemplo n.º 23
0
QSQLiteDriver::QSQLiteDriver(sqlite *connection, QObject *parent, const char *name)
    : QSqlDriver(parent, name ? name : QSQLITE_DRIVER_NAME)
{
    d = new QSQLiteDriverPrivate();
    d->access = connection;
    setOpen(TRUE);
    setOpenError(FALSE);
}
Exemplo n.º 24
0
GlobalRoot::GlobalRoot(VariableTree *parent)
    : LazyFetchItem(parent)
{
    setText(0, i18n("Global"));
    setExpandable(true);
    setOpen(false);
	setSelectable(false);
}
Exemplo n.º 25
0
void QSymSQLDriver::close()
{
    if (isOpen()) {
        d->access.Close();
        setOpen(false);
        setOpenError(false);
    }
}
Exemplo n.º 26
0
QSQLite2Driver::QSQLite2Driver(sqlite *connection, QObject *parent)
    : QSqlDriver(parent)
{
    d = new QSQLite2DriverPrivate();
    d->access = connection;
    setOpen(true);
    setOpenError(false);
}
Exemplo n.º 27
0
void QSQLite2Driver::close()
{
    if (isOpen()) {
        sqlite_close(d->access);
        d->access = 0;
        setOpen(false);
        setOpenError(false);
    }
}
Exemplo n.º 28
0
//==============================================================================
void ProjectTreeViewBase::treeChildrenChanged (const ValueTree& parentTree)
{
    if (parentTree == item.state)
    {
        refreshSubItems();
        treeHasChanged();
        setOpen (true);
    }
}
Exemplo n.º 29
0
/**
 * Override
 * Close an open database connection.
 */
void KQPostgreSqlDriver::close()
{
    if (m_connection && isOpen()) {
        PQfinish(m_connection);
        m_connection = NULL;
        setOpen(false);
        setOpenError(false);
    }
}
Exemplo n.º 30
0
StreamItem::StreamItem( QListViewItem* parent, const QString& n, POLE::Stream* s ): 
QListViewItem( parent, n )
{
  name = n;
  stream = s;
  if( stream )
    setText( 1, QString::number( stream->size() ) );
  setOpen( true );
}