You are not logged in.

Dear visitor, welcome to KDE-Forum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Krasu

Beginner

  • "Krasu" started this thread

Posts: 30

Location: Republic of Belarus

  • Send private message

1

Friday, May 27th 2005, 5:17pm

KDirOperator and its history

Who can tell me at once one reason why KDirOperator::backStack and forwardStack are private ?( I can't access diroperator's url history 8o

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

2

Monday, May 30th 2005, 1:45pm

Can't you just access the history through the completion objects?

Cheers,
_
Qt/KDE Developer
Debian User

Krasu

Beginner

  • "Krasu" started this thread

Posts: 30

Location: Republic of Belarus

  • Send private message

3

Monday, May 30th 2005, 8:48pm

I have 4 diroperators in QWidgetStack. I need to synchronize their history. For example, user visits about 100 urls in first diroperator, and then goes to the second one. Now the second diroperator should obtain all visited urls from the first one. If KDirOperator::backStack had been protected, I would have only copy history from one dirop to another, using helper functions

Source code

1
2
3
4
5
6
7
8
9
QPtrStack<KURL>* MyDirOperator::backURLs() const
{
       return backStack;
}

QPtrStack<KURL>* MyDirOperator::forwardURLs() const
{
       return forwardStack;
}


How can copy history from one dirop to another ? History stacks are private 8o

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

4

Tuesday, May 31st 2005, 8:51am

What about syncronizing their completion objects?

Cheers,
_
Qt/KDE Developer
Debian User

Krasu

Beginner

  • "Krasu" started this thread

Posts: 30

Location: Republic of Belarus

  • Send private message

5

Tuesday, May 31st 2005, 1:52pm

You still don't understand me. When user goes to the second KDirOperator in widget stack, he suddenly presses "back" button. But this diroperator doesn't have history, because it has been accessed for the first time, so this action won't take effect.

As you can see in sources, backStack must not be empty, when the user presses "back" button. But I can't fill backStack with correct urls just after the second diroperator has been activated, because backStack is private.

Source code

1
2
3
4
5
6
7
8
9
10
11
12
void KDirOperator::back()
{
    if ( backStack.isEmpty() )
        return;

    forwardStack.push( new KURL(currUrl) );

    KURL *s = backStack.pop();

    setURL(*s, false);
    delete s;
}

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

6

Wednesday, June 1st 2005, 1:53pm

Hmm, if you can get the URL of the current active operator you could use setURL.

I think with clearforward = true it puts its current URL onto its back stack

Cheers,
_
Qt/KDE Developer
Debian User

Krasu

Beginner

  • "Krasu" started this thread

Posts: 30

Location: Republic of Belarus

  • Send private message

7

Thursday, June 2nd 2005, 12:24am

Quoted

Originally posted by anda_skoa
Hmm, if you can get the URL of the current active operator you could use setURL.


Of course I can, but I needn't do this. I need transfer all history entries from first MyDirOperator::backStack to second MyDirOperator::backStack. But I can't do it, because backStack and forwardStack are private. In other words, I can't manipulate diroperator's history directly X(

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

8

Friday, June 3rd 2005, 11:57am

So keeping the stacks synchronized does not do the same?

Cheers,
_
Qt/KDE Developer
Debian User

Krasu

Beginner

  • "Krasu" started this thread

Posts: 30

Location: Republic of Belarus

  • Send private message

9

Friday, June 3rd 2005, 12:43pm

I can't keep them synchronized, because they are private. I can't access them at all.

I wrote simple test app (attach). Compile it and run, visit about 10-15 urls and then go to the second page. Push "back" button. You won't jump to the last url you visited, because backStack of this diroperator contains only one entry (your home dir path).

Now try to synchronize history of both diroperators :)

This post has been edited 3 times, last edit by "Krasu" (Jun 3rd 2005, 1:40pm)


anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

10

Thursday, June 9th 2005, 9:23pm

Sorry that it took so long.
I had a lot to do and then forgot you posted some code :(

My suggestion works as far as I can see.
Can be optimized of course :)

Cheers,
_
Qt/KDE Developer
Debian User

Krasu

Beginner

  • "Krasu" started this thread

Posts: 30

Location: Republic of Belarus

  • Send private message

11

Friday, June 10th 2005, 1:46am

Right. You synchronized history with some hacks. This code is not looking good

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
void KDirOp::slotFinishedLoading()
{
    const QObject* dirop = QObject::sender();

    if (dirop == dirop1)
    {
        dirop2->setURL(dirop1->url(), true);
    }
    else if (dirop == dirop2)
    {
        dirop1->setURL(dirop2->url(), true);
    }
}


Imagine, that I've gone to directory that contains ~5000 files, and all my diroperators start to load it ... 8o Thats why in my app only one diroperator loads an url, and all other go to this url only on demand (through raiseWidget()).

So, it seemed that there is no pretty way to synchronize history. As I already said, history stacks must be protected! :)

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

12

Friday, June 10th 2005, 2:31pm

Quoted

Originally posted by Krasu
Right. You synchronized history with some hacks. This code is not looking good

Agreed, but having more than one KDirOperator showing exaclty the same information sounds like bad design anyway.

Quoted


Imagine, that I've gone to directory that contains ~5000 files, and all my diroperators start to load it ...


You could subclass KDirOperator and create more than one view or set the same KDirLister object on your instances.

Quoted

As I already said, history stacks must be protected! :)


Very bad idea. The two stacks have to keep syncronized, invariants are better kept private.

Cheers,
_
Qt/KDE Developer
Debian User

Krasu

Beginner

  • "Krasu" started this thread

Posts: 30

Location: Republic of Belarus

  • Send private message

13

Friday, June 10th 2005, 6:04pm

Quoted

Originally posted by anda_skoa
You could subclass KDirOperator and create more than one view or set the same KDirLister object on your instances.


Good idea. I'll try this to speed up directory loading :)