Never mind the below. See the Gmail IMAP Opera Wiki page instead.
The way Gmail's IMAP implementation works and how you do operations on messages is really funky. No email client is perfectly setup to work with Gmail, which definitely makes Gmail IMAP hard to get used to.
However, now that I'm used to it and understand how it works (this is a must-read), things have been going smoothly in Opera.
With that said, here are some tips that you can follow:
Ignore all of Opera's mail access points (and "unread") except for what's under the "Mail for firstname.lastname@example.org". Seriously, just don't pay attention to things that aren't made for Gmail.
Ignore the Trash label IMAP folder. Don't use it. It's just another label folder and really isn't a special trash folder.
Keep the [Gmail] folders list expanded at all times. You'll need it open for dragging messages from other folders to them. (As an alternative to dragging, you can select messages, right-click the selection, cut, change to another folder and then right-click and paste in the message list of another folder. The cut and paste options are available under Edit in Opera's main menu bar also.)
Don't use Opera's Spam icon to mark a message as spam. Gmail handles spam itself.
All the IMAP folders that are not under [Gmail] are labels (even INBOX).
If you want to change the label associated with a message, drag it to another label folder. If the message doesn't have a label and is just in [Gmail]/All Mail, drag it to a label folder (that includes INBOX) to apply a label.
If you want to remove a label from a message, while in the label folder, just mark the message as deleted by hitting del. Then, the message will only show in your archived messages under [Gmail]/All mail.
If you want to move a message to trash (from a label or [Gmail]/All Mail), drag it to [Gmail]/Trash. Then, if you want to totally get rid of the message, while in [Gmail]/Trash, mark the message as deleted by selecting it and pressing del.
If you want to mark a message as spam, drag it to [Gmail]/Spam. If you want to reverse that, drag it somewhere else.
Now, to delete spam, you just mark messages in [Gmail]/Spam as deleted by selecting them and pressing delete. However, before even viewing the Spam folder, you should click the view button on the toolbar for another folder's message list and choose "display" and then "list only". Then, view the spam folder and delete messages etc. When you're done, just go to another folder and change the display back to "List and messages below". That way, you won't view and download bodies of spam messages. However, you don't have to delete spam messages anyway. Gmail will do that automatically after a while.
To actually clear [Gmail]/Trash, you have to select and delete all messages in it. There's no right-click -> empty.
The reason you ignore Opera's Unread view is because unread messages from folders under [Gmail] will show up in there too and make the unread view a mess.
The reason you ignore Opera's Received view is because it will contain your Spam messages. Plus dragging from any of Opera's views to an IMAP folder will copy and paste instead of cut and paste.
Once you expand the "Mail for email@example.com" access point, it's better to avoid clicking on "Mail for firstname.lastname@example.org" as it'll show all mail for your gmail account, which may cause you do download and view message bodies for spam. It's best to stick to viewing only specfic IMAP folders.
If you click on "Mail for email@example.com" and it collapses the whole access point, when you reexpand it, the [Gmail] folder view will be collapsed and you'll have to rexpand it. To avoid this, it's best to never collapse "Mail for firstname.lastname@example.org".
One exception to ignoring Opera's access points is Opera's Drafts view under "All messages". Opera will autosave drafts *locally* there. You can open them up if you need to continue where you left off. Or, if you want to place a copy on the server, drag one (or copy and paste) to the [Gmail]/Drafts folder so that you can use it in the Gmail webmail interface. Also note though that Opera's drafts might pile up after a while. If that happens and you want to get rid of them, just delete them and then empty Opera's trash view.
Now, if you have other IMAP accounts set up in Opera, you'll want to right-click in the mail panel and choose show only "insert imap account" to show only the one IMAP account you want to work with at the moment. If you show all accounts, Opera's Unread view will be littered with unread messages in folders under [Gmail] and you might actually want to use the unread view for regular imap accounts.
Ignore [Gmail]/All Mail until you actually need to go in it. Messages that are shown in label folders are going to be shown in here too and you must resist getting bugged by the duplicate entries.
Ignore duplicate entries that show up in new mail notifications. One is just from an All Mail entry.
Ignore unread counts in folders under [Gmail]. Don't let them distract you.
Ignore the unread count on the mail panel button when you have multiple accounts and you're using "show messages from account". Even if you're not showing the gmail account, unread messages in the gmail account will affect the count on the mail panel button. This doesn't make the count on the button very useful, so just ignore it.
Don't set an IMAP sent folder in Opera's preferences. When you send messages through smtp.1and1.com, they're added to [Gmail]/Sent mail automatically.
Note that when you move a message to the [Gmail]/Trash, [Gmail]/All Mail won't recognize the update until the next sync. If you can't wait, just click the All Mail folder and it will sync.
In short, Gmail is just totally different and when using any client that wasn't made specifically for it, you have to be mindful of the client's traditional IMAP UI operations and work around them. And, most of all, you just have to ignore UI parts that just don't apply to Gmail IMAP.
There is a pretty good solution to this problem.
Unsubscribe from [Gmail] and all the mailboxes in it. Then, in the webmail interface, enable the Gmail labs Advanced IMAP Controls extension under settings -> labs.
Then, under Forwarding and POP/IMAP in the webmail interface:
Do not automatically expunge messages
When a message is expunged from the last visible IMAP folder:
Move the message to the Gmail Trash
Then, Gmail pretty much works like a normal imap client and works really well with Opera
I no longer use the Gmail labs IMAP extension. Found out after all this time of deleting stuff the extension didn't remove the messages correctly and ended up with thousands of old messages. Now I just stick to doing it the hard way.